diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..1027042a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,39 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: bug +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots (OPTIONAL)** +If applicable, add screenshots to help explain your problem. + +**Logs** +- Paste the output of the console window in a text file, and attach the text file. +- If applicable (`logfile` set to 2), attach the `qconsole.log` file. On Windows, it can be found in **%APPDATA%\...\qconsole.log** and on Linux, it can be found on the home directory **~/.openmohaa/.../qconsole.log**. + +**Version information (please complete the following information):** + - OS: [e.g. `Debian`] + - OS Version [e.g `12`] + - OpenMoHAA Version: [e.g `0.70.0-alpha+0.0b1a20dcf win_msvc64-x86_64-debug`, can be found below **Common Initialization** in the console, or by typing `version`] + +**Dump (OPTIONAL)** +You can include a core dump generated by the OS (`.dmp` file). If you compiled OpenMoHAA yourself, also add all output openmohaa binaries (except libopenal and libSDL). + +**Additional context (OPTIONAL)** +Add any other context about the problem here. diff --git a/.github/workflows/branches-build.yml b/.github/workflows/branches-build.yml new file mode 100644 index 00000000..c3fa846a --- /dev/null +++ b/.github/workflows/branches-build.yml @@ -0,0 +1,17 @@ +name: Build branch + +on: + push: + branches: + - '**' + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build-all: + uses: ./.github/workflows/shared-build.yml + with: + environment: "testing" diff --git a/.github/workflows/build-cmake.yml b/.github/workflows/build-cmake.yml deleted file mode 100644 index ef9e80e3..00000000 --- a/.github/workflows/build-cmake.yml +++ /dev/null @@ -1,194 +0,0 @@ -name: Build - -on: - push: - branches: - - '*' - pull_request: - workflow_call: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -env: - # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) - BUILD_TYPE: RelWithDebInfo - -jobs: - build-platform-linux: - strategy: - matrix: - architecture: [ - {name: 'amd64', triple: 'x86_64-linux-gnu'}, - {name: 'i686', triple: 'i686-linux-gnu'}, - {name: 'aarch64', triple: 'aarch64-linux-gnu'}, - {name: 'armhf', triple: 'arm-linux-gnueabihf'} - ] - - name: "Building for platform linux-${{matrix.architecture.name}}" - runs-on: ubuntu-22.04 - - steps: - - name: Settings - working-directory: ${{github.workspace}} - run: | - echo "CMAKE_BUILD_PARALLEL_LEVEL=$(($(nproc) * 16))" >> $GITHUB_ENV -# echo "CMAKE_GENERATOR=Ninja" >> $GITHUB_ENV - - - name: Install required packages - run: | - sudo apt update && sudo apt install -y flex bison - - - name: Install required cross-platform packages (${{ matrix.architecture.triple }}) - if: matrix.architecture.name != 'amd64' - run: sudo apt install -y gcc-12-${{ matrix.architecture.triple }} g++-12-${{ matrix.architecture.triple }} - - # Setup SDL - - name: Set up SDL - id: sdl - uses: libsdl-org/setup-sdl@main - with: - version: sdl2-latest - build-type: Release - cmake-arguments: "-DCMAKE_C_COMPILER=clang - -DCMAKE_CXX_COMPILER=clang++ - -DCMAKE_C_FLAGS=--target=${{ matrix.architecture.triple }} - -DCMAKE_CXX_FLAGS=--target=${{ matrix.architecture.triple }}" - - - uses: actions/checkout@v3 - with: - path: 'source' - - - name: CMake Settings - run: | - echo "CMAKE_PARAM=--log-level=VERBOSE \ - -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ - -DCMAKE_INSTALL_PREFIX='${{github.workspace}}/install' \ - -DCMAKE_C_COMPILER=clang \ - -DCMAKE_CXX_COMPILER=clang++ \ - -DCMAKE_C_FLAGS=--target=${{ matrix.architecture.triple }} \ - -DCMAKE_CXX_FLAGS=--target=${{ matrix.architecture.triple }} \ - -DGIT_REVISION_BUILD_NUMBER=${{ github.run_number }}" >> $GITHUB_ENV - - - name: Configure CMake - working-directory: ${{github.workspace}} - run: | - cmake -B ./build ${{ env.CMAKE_PARAM }} ./source - - - name: Build - working-directory: ${{github.workspace}} - run: | - cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} - - - name: Test - working-directory: ${{github.workspace}} - # Execute tests defined by the CMake configuration. - # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail - run: | - cd "${{github.workspace}}/build" - ctest -C ${{env.BUILD_TYPE}} - - - name: Install - working-directory: ${{github.workspace}} - # Install to the directory defined in CMAKE_INSTALL_PREFIX - run: | - cmake --install ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} - cp '${{steps.sdl.outputs.prefix}}/lib/libSDL2.so' '${{github.workspace}}/install' - - - uses: actions/upload-artifact@v3 - with: - name: out-linux-${{matrix.architecture.name}} - if-no-files-found: error - path: - ${{github.workspace}}/install - - build-platform-windows: - strategy: - matrix: - architecture: [ - {name: 'x64', config: 'x64' }, - {name: 'x86', config: 'Win32' }, - {name: 'arm64', config: 'ARM64' } - ] - - name: "Building for platform windows-${{matrix.architecture.name}}" - runs-on: windows-2022 - - steps: - - name: Settings - working-directory: ${{github.workspace}} - run: | - echo "CMAKE_BUILD_PARALLEL_LEVEL=$((Get-CimInstance Win32_ComputerSystem).NumberOfLogicalProcessors * 16)" >> $GITHUB_ENV - - # Setup SDL - - name: Set up SDL - id: sdl - uses: libsdl-org/setup-sdl@main - with: - version: sdl2-latest - build-type: Release - cmake-arguments: "-A ${{ matrix.architecture.config }}" - - - name: Install Flex/Bison - working-directory: ${{github.workspace}} - run: | - mkdir thirdparties && cd thirdparties - git clone --depth 1 --single-branch --branch v2.5.25 https://github.com/lexxmark/winflexbison.git - cmake -B winflexbison-build -DCMAKE_INSTALL_PREFIX='${{github.workspace}}/thirdparties/winflexbison-install' ./winflexbison - cmake --build winflexbison-build --config Release --parallel - cmake --install winflexbison-build - - - uses: actions/checkout@v3 - with: - path: 'source' - - - name: CMake Settings - run: | - echo "CMAKE_PARAM=-A ${{ matrix.architecture.config }} ` - --log-level=VERBOSE ` - -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ` - -DCMAKE_INSTALL_PREFIX='${{github.workspace}}/install' ` - -DGIT_REVISION_BUILD_NUMBER=${{ github.run_number }} ` - -DBISON_EXECUTABLE='${{github.workspace}}/thirdparties/winflexbison-install/win_bison.exe' ` - -DFLEX_EXECUTABLE='${{github.workspace}}/thirdparties/winflexbison-install/win_flex.exe'".Replace("`r", "").Replace("`n", "") >> $env:GITHUB_ENV - - - name: Configure CMake - working-directory: ${{github.workspace}} - run: | - cmake -B ./build ${{ env.CMAKE_PARAM }} ./source - - - name: Build - working-directory: ${{github.workspace}} - run: | - cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} - - - name: Test - working-directory: ${{github.workspace}} - # Execute tests defined by the CMake configuration. - # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail - run: | - cd "${{github.workspace}}/build" - ctest -C ${{env.BUILD_TYPE}} - - - name: Install - working-directory: ${{github.workspace}} - # Install to the directory defined in CMAKE_INSTALL_PREFIX - run: | - cmake --install ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} - Copy-Item '${{steps.sdl.outputs.prefix}}/bin/*.dll' -Destination '${{github.workspace}}/install' - - - uses: actions/upload-artifact@v3 - with: - name: out-windows-${{matrix.architecture.name}} - if-no-files-found: error - path: | - ${{github.workspace}}/install - !${{github.workspace}}/install/**/*.pdb - - - uses: actions/upload-artifact@v3 - with: - name: out-windows-${{matrix.architecture.name}}-pdb - if-no-files-found: error - path: | - ${{github.workspace}}/install diff --git a/.github/workflows/codeql.yml b/.github/workflows/main-codeql.yml similarity index 85% rename from .github/workflows/codeql.yml rename to .github/workflows/main-codeql.yml index fc4f71a7..5de08e79 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/main-codeql.yml @@ -20,6 +20,10 @@ on: schedule: - cron: '42 8 * * 1' +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: analyze: name: Analyze @@ -41,7 +45,13 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 + + - uses: awalsh128/cache-apt-pkgs-action@latest + name: Install required packages + with: + packages: libopenal-dev libpulse-dev portaudio19-dev libasound2-dev libjack-dev libpipewire-0.3-dev qtbase5-dev libdbus-1-dev + version: "0.1" # Setup SDL - name: Set up SDL @@ -52,7 +62,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -66,7 +76,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@v3 # â„šī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -79,6 +89,6 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 with: category: "/language:${{matrix.language}}" diff --git a/.github/workflows/shared-build-linux.yml b/.github/workflows/shared-build-linux.yml new file mode 100644 index 00000000..9bbf28c3 --- /dev/null +++ b/.github/workflows/shared-build-linux.yml @@ -0,0 +1,246 @@ +########################## +# +# Linux +# Ubuntu 22.04 +# +# Using this version instead of 24.04 to use a lower GLIBC version (2.34). +# ARM is used for more efficiency, and x64 is used for legacy architectures like PowerPC. +########################## +name: Linux build workflow + +on: + workflow_call: + inputs: + environment: + required: true + type: string + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: RelWithDebInfo + RELEASE_STAGE: ${{ vars.RELEASE_STAGE || 'unstable' }} + +jobs: + build: + strategy: + matrix: + architecture: [ + {name: 'amd64', os: "ubuntu-22.04-arm", package: 'x86-64-linux-gnu', triple: 'x86_64-linux-gnu', arch_option: 'linux-x86_64'}, + {name: 'i686', os: "ubuntu-22.04-arm", package: 'i686-linux-gnu', triple: 'i686-linux-gnu', arch_option: 'linux-x86'}, + {name: 'arm64', os: "ubuntu-22.04-arm", package: 'aarch64-linux-gnu', triple: 'aarch64-linux-gnu', arch_option: 'linux-aarch64'}, + {name: 'armhf', os: "ubuntu-22.04-arm", package: 'arm-linux-gnueabihf', triple: 'arm-linux-gnueabihf', arch_option: 'linux-armv4'}, + {name: 'powerpc', os: "ubuntu-22.04", package: 'powerpc-linux-gnu', triple: 'powerpc-linux-gnu', arch_option: 'linux-ppc'}, + {name: 'ppc64', os: "ubuntu-22.04", package: 'powerpc64-linux-gnu', triple: 'powerpc64-linux-gnu', arch_option: 'linux-ppc64'}, + {name: 'ppc64el', os: "ubuntu-22.04-arm", package: 'powerpc64le-linux-gnu', triple: 'powerpc64le-linux-gnu', arch_option: 'linux-ppc64le'} + ] + + name: "Building for platform linux-${{matrix.architecture.name}}" + runs-on: ${{ matrix.architecture.os }} + environment: ${{ inputs.environment }} + env: + wolfssl-version: 'v5.7.6-stable' + curl-version: '8_12_1' + openal-soft-branch: '1.24.3' + + steps: + ### + # Packages + ### + + - uses: awalsh128/cache-apt-pkgs-action@latest + name: Install required packages + with: + packages: flex bison ninja-build cmake clang libpulse-dev portaudio19-dev libasound2-dev libjack-dev libpipewire-0.3-dev qtbase5-dev libdbus-1-dev + version: "${{ runner.os }}-${{ runner.arch }}-v1" + + - name: Settings + working-directory: ${{github.workspace}} + run: | + echo "HOST_TRIPLE=$(gcc -dumpmachine)" >> $GITHUB_ENV + + - uses: awalsh128/cache-apt-pkgs-action@latest + name: Install required cross-platform packages (${{ matrix.architecture.package }}) + if: env.HOST_TRIPLE != matrix.architecture.triple + with: + packages: gcc-12-${{ matrix.architecture.package }} g++-12-${{ matrix.architecture.package }} + version: "${{ runner.os }}-${{ runner.arch }}-v1" + + - name: Settings + working-directory: ${{github.workspace}} + run: | + echo "CMAKE_GENERATOR=Ninja Multi-Config" >> $GITHUB_ENV + echo "CC=clang" >> $GITHUB_ENV + echo "CXX=clang++" >> $GITHUB_ENV + echo "CFLAGS='--target=${{ matrix.architecture.triple }}'" >> $GITHUB_ENV + echo "CXXFLAGS='--target=${{ matrix.architecture.triple }}'" >> $GITHUB_ENV + + ### + # SDL + ### + + # Setup SDL + - name: Set up SDL + id: sdl + uses: libsdl-org/setup-sdl@main + with: + version: 2-latest + build-type: Release + # Workaround for when changing the runner OS version + cmake-arguments: "-DCACHE_OS_VERSION=Ubuntu_22.04" + + ### + # OpenAL + ### + - name: Cache OpenAL + id: cache-openal-soft + uses: actions/cache@v4 + with: + path: 'thirdparties/soft-oal/install' + key: ${{ runner.os }}-${{ matrix.architecture.name }}-openal-soft-${{ env.openal-soft-branch }}-v1 + + # soft-oal setup + - name: Checkout soft-oal + if: steps.cache-openal-soft.outputs.cache-hit != 'true' + uses: actions/checkout@v4 + with: + repository: 'kcat/openal-soft' + path: 'thirdparties/soft-oal' + ref: '${{ env.openal-soft-branch }}' + + - name: Configure and install soft-oal + if: steps.cache-openal-soft.outputs.cache-hit != 'true' + working-directory: ${{github.workspace}}/thirdparties/soft-oal + run: | + cmake -B ./build \ + -DALSOFT_UTILS=OFF \ + -DCMAKE_INSTALL_PREFIX='${{github.workspace}}/thirdparties/soft-oal/install' + cmake --build ./build --config Release --parallel + cmake --install ./build --config Release + + ### + # WolfSSL + ### + - name: Cache WolfSSL + id: cache-wolfssl + uses: actions/cache@v4 + with: + path: 'thirdparties/wolfssl/install' + key: ${{ runner.os }}-${{ matrix.architecture.name }}-wolfssl-${{ env.wolfssl-version }}-v1 + + # WolfSSL setup + - name: Checkout WolfSSL + if: steps.cache-wolfssl.outputs.cache-hit != 'true' + uses: actions/checkout@v4 + with: + repository: 'wolfssl/wolfssl' + path: 'thirdparties/wolfssl' + ref: '${{ env.wolfssl-version }}' + + # WolfSSL build + - name: Configure and install wolfssl + if: steps.cache-wolfssl.outputs.cache-hit != 'true' + working-directory: ${{github.workspace}}/thirdparties/wolfssl + run: | + cmake -B ./build \ + -DCMAKE_INSTALL_PREFIX='${{github.workspace}}/thirdparties/wolfssl/install' \ + -DCMAKE_C_FLAGS="$CFLAGS -fPIC" \ + -DCMAKE_CXX_FLAGS="$CFLAGS -fPIC" \ + -DBUILD_SHARED_LIBS=OFF -DWOLFSSL_OPENSSLEXTRA=ON -DWOLFSSL_ASM=OFF -DWOLFSSL_EXAMPLES=OFF -DWOLFSSL_CURL=ON + cmake --build ./build --config Release --parallel + cmake --install ./build --config Release + + ### + # cURL + ### + - name: Cache cURL + id: cache-curl + uses: actions/cache@v4 + with: + path: 'thirdparties/curl/install' + key: ${{ runner.os }}-${{ matrix.architecture.name }}-curl-${{ env.curl-version }}-v1 + + # cURL setup + - name: Checkout cURL + if: steps.cache-curl.outputs.cache-hit != 'true' + uses: actions/checkout@v4 + with: + repository: 'curl/curl' + path: 'thirdparties/curl' + ref: 'curl-${{ env.curl-version }}' + + # cURL build + - name: Configure and install curl + if: steps.cache-curl.outputs.cache-hit != 'true' + working-directory: ${{github.workspace}}/thirdparties/curl + run: | + cmake -B ./build \ + -DCMAKE_INSTALL_PREFIX='${{github.workspace}}/thirdparties/curl/install' \ + -DCURL_USE_LIBPSL=OFF \ + -DCURL_USE_WOLFSSL=ON \ + -DCURL_ZLIB="" \ + -DCURL_BROTLI="" \ + -DCURL_ZSTD="" \ + -DCMAKE_SHARED_LINKER_FLAGS="-lm" \ + -DWolfSSL_ROOT='${{github.workspace}}/thirdparties/wolfssl/install' + cmake --build ./build --config Release --parallel + cmake --install ./build --config Release + + ### + # Project + ### + + - uses: actions/checkout@v4 + with: + path: 'source' + + - name: CMake Settings + run: | + echo "CMAKE_PARAM=--log-level=VERBOSE \ + -DCMAKE_INSTALL_PREFIX='${{github.workspace}}/install' \ + -DOPENAL_LIBRARY='${{github.workspace}}/thirdparties/soft-oal' \ + -DOPENAL_INCLUDE_DIR='${{github.workspace}}/thirdparties/soft-oal/install/include' \ + -DCURL_ROOT='${{github.workspace}}/thirdparties/curl/install' \ + -DGIT_REVISION_BUILD_NUMBER=${{ github.run_number }} \ + -DPRODUCT_VERSION_STAGE='${{ env.RELEASE_STAGE }}'" >> $GITHUB_ENV + + - name: Configure CMake + working-directory: ${{github.workspace}} + run: | + cmake -B ./build ${{ env.CMAKE_PARAM }} ./source + + - name: Build + working-directory: ${{github.workspace}} + run: | + cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel + + - name: Test + working-directory: ${{github.workspace}} + # Execute tests defined by the CMake configuration. + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail + run: | + cd "${{github.workspace}}/build" + ctest -C ${{env.BUILD_TYPE}} + + - name: Install + working-directory: ${{github.workspace}} + # Install to the directory defined in CMAKE_INSTALL_PREFIX + run: | + cmake --install ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + # Copy libraries + mkdir ${{github.workspace}}/package + cp -l ${{steps.sdl.outputs.prefix}}/lib/libSDL2-2.0.so.0 '${{github.workspace}}/package/' + cp -l ${{github.workspace}}/thirdparties/soft-oal/install/lib/libopenal.so.1 '${{github.workspace}}/package/' + cp -l ${{github.workspace}}/thirdparties/curl/install/lib*/libcurl.so.4 '${{github.workspace}}/package/' + if [ -d ${{github.workspace}}/install/bin ]; then cp -r ${{github.workspace}}/install/bin/openmohaa/. '${{github.workspace}}/package'; fi + if [ -d ${{github.workspace}}/install/lib ]; then cp -r ${{github.workspace}}/install/lib/openmohaa/. '${{github.workspace}}/package'; fi + + ### + # Artifacts + ### + + - uses: actions/upload-artifact@v4 + with: + name: out-linux-${{matrix.architecture.name}} + if-no-files-found: error + path: + ${{github.workspace}}/package \ No newline at end of file diff --git a/.github/workflows/shared-build-macos.yml b/.github/workflows/shared-build-macos.yml new file mode 100644 index 00000000..d4ba04c1 --- /dev/null +++ b/.github/workflows/shared-build-macos.yml @@ -0,0 +1,239 @@ +########################## +# +# Apple macOS +# macOS 15 +# +# This version is used as the OS, as it's faster than other versions. +########################## +name: MacOS build workflow + +on: + workflow_call: + inputs: + environment: + required: true + type: string + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: RelWithDebInfo + RELEASE_STAGE: ${{ vars.RELEASE_STAGE || 'unstable' }} + +jobs: + build: + strategy: + matrix: + architecture: [ + #{name: 'x86_64', triple: 'x86_64-apple-macos10.8'}, + #{name: 'arm64', triple: 'arm64-apple-macos11'} + #{name: 'x86_64', build_name: 'x86_64'}, + #{name: 'arm64', build_name: 'arm64'}, + # Compile into an universal binary + {name: 'multiarch(arm64-x86_64)', build_name: 'arm64;x86_64' } + ] + + name: "Building for platform macos-${{matrix.architecture.name}}" + runs-on: "macos-15" + env: + openal-soft-branch: '1.24.3' + wolfssl-version: 'v5.7.6-stable' + curl-version: '8_12_1' + + steps: + ### + # Packages + ### + + - name: Install required packages + run: | + brew install git flex bison ninja cmake llvm perl + + - name: Settings + working-directory: ${{github.workspace}} + run: | + echo "CMAKE_GENERATOR=Ninja Multi-Config" >> $GITHUB_ENV + echo "CC=clang" >> $GITHUB_ENV + echo "CXX=clang++" >> $GITHUB_ENV + echo "MACOSX_DEPLOYMENT_TARGET=10.15" >> $GITHUB_ENV + + ### + # SDL + ### + + # Setup SDL + - name: Set up SDL + id: sdl + uses: libsdl-org/setup-sdl@main + with: + version: 2-latest + build-type: Release + cmake-arguments: "-DCMAKE_OSX_ARCHITECTURES='${{ matrix.architecture.build_name }}' + -DCMAKE_VERBOSE_MAKEFILE=on" + + ### + # OpenAL + ### + - name: Cache OpenAL + id: cache-openal-soft + uses: actions/cache@v4 + with: + path: 'thirdparties/soft-oal/install' + key: ${{ runner.os }}-${{ matrix.architecture.name }}-openal-soft-${{ env.openal-soft-branch }}-v1 + + # soft-oal setup + # Use GCC instead of Clang because of missing SSE intrinsics + # It also doesn't enable altivec support on PowerPC by default + - name: Checkout soft-oal + if: steps.cache-openal-soft.outputs.cache-hit != 'true' + uses: actions/checkout@v4 + with: + repository: 'kcat/openal-soft' + path: 'thirdparties/soft-oal' + ref: '${{ env.openal-soft-branch }}' + + # soft-oal build + - name: Configure and install soft-oal + if: steps.cache-openal-soft.outputs.cache-hit != 'true' + working-directory: ${{github.workspace}}/thirdparties/soft-oal + run: | + cmake -B ./build \ + -DCMAKE_INSTALL_PREFIX='${{github.workspace}}/thirdparties/soft-oal/install' \ + -DCMAKE_OSX_ARCHITECTURES='${{ matrix.architecture.build_name }}' \ + -DCMAKE_VERBOSE_MAKEFILE=on + cmake --build ./build --config Release --parallel + cmake --install ./build --config Release + + ### + # WolfSSL + ### +# FIXME: Figure out how to compile WolfSSL cross-architecture +# +# - name: Cache WolfSSL +# id: cache-wolfssl +# uses: actions/cache@v4 +# with: +# path: 'thirdparties/wolfssl_install' +# key: ${{ runner.os }}-${{ matrix.architecture.name }}-wolfssl-${{ env.wolfssl-version }}-v1 +# +# # WolfSSL setup +# - name: Checkout WolfSSL +# if: steps.cache-wolfssl.outputs.cache-hit != 'true' +# uses: actions/checkout@v4 +# with: +# repository: 'wolfssl/wolfssl' +# path: 'thirdparties/wolfssl' +# ref: '${{ env.wolfssl-version }}' +# +# # WolfSSL build +# - name: Configure and install wolfssl +# if: steps.cache-wolfssl.outputs.cache-hit != 'true' +# working-directory: ${{github.workspace}}/thirdparties/wolfssl +# run: | +# cmake -B ./build \ +# -DCMAKE_INSTALL_PREFIX='${{github.workspace}}/thirdparties/wolfssl_install' \ +# -DCMAKE_OSX_ARCHITECTURES='${{ matrix.architecture.build_name }}' \ +# -DBUILD_SHARED_LIBS=OFF -DWOLFSSL_OPENSSLEXTRA=ON -DWOLFSSL_ASM=OFF -DWOLFSSL_EXAMPLES=OFF -DWOLFSSL_CURL=ON +# cmake --build ./build --config Release --parallel +# cmake --install ./build --config Release + + ### + # cURL + ### + - name: Cache cURL + id: cache-curl + uses: actions/cache@v4 + with: + path: 'thirdparties/curl/install' + key: ${{ runner.os }}-${{ matrix.architecture.name }}-curl-${{ env.curl-version }}-v1 + + # cURL setup + - name: Checkout cURL + if: steps.cache-curl.outputs.cache-hit != 'true' + uses: actions/checkout@v4 + with: + repository: 'curl/curl' + path: 'thirdparties/curl' + ref: 'curl-${{ env.curl-version }}' + + # cURL build + - name: Configure and install curl + if: steps.cache-curl.outputs.cache-hit != 'true' + working-directory: ${{github.workspace}}/thirdparties/curl + run: | + cmake -B ./build \ + -DCMAKE_INSTALL_PREFIX='${{github.workspace}}/thirdparties/curl/install' \ + -DCMAKE_OSX_ARCHITECTURES='${{ matrix.architecture.build_name }}' \ + -DCURL_USE_LIBPSL=OFF \ + -DCURL_USE_WOLFSSL=OFF \ + -DCURL_USE_LIBSSH2=OFF \ + -DUSE_LIBIDN2=OFF \ + -DUSE_NGHTTP2=OFF \ + -DCURL_ENABLE_SSL=OFF \ + -DCURL_ZLIB="" \ + -DCURL_BROTLI="" \ + -DCURL_ZSTD="" \ + -DWolfSSL_ROOT='${{github.workspace}}/thirdparties/wolfssl_install' + cmake --build ./build --config Release --parallel + cmake --install ./build --config Release + + ### + # Project + ### + + - uses: actions/checkout@v4 + with: + path: 'source' + + - name: CMake Settings + run: | + echo "CMAKE_PARAM=--log-level=VERBOSE \ + -DCMAKE_INSTALL_PREFIX='${{github.workspace}}/install' \ + -DCMAKE_VERBOSE_MAKEFILE=on \ + -DCMAKE_OSX_ARCHITECTURES='${{ matrix.architecture.build_name }}' \ + -DOPENAL_LIBRARY='${{github.workspace}}/thirdparties/soft-oal/install' \ + -DOPENAL_INCLUDE_DIR='${{github.workspace}}/thirdparties/soft-oal/install/include/AL' \ + -DCURL_ROOT='${{github.workspace}}/thirdparties/curl/install' \ + -DGIT_REVISION_BUILD_NUMBER=${{ github.run_number }} \ + -DPRODUCT_VERSION_STAGE='${{ env.RELEASE_STAGE }}'" >> $GITHUB_ENV + + - name: Configure CMake + working-directory: ${{github.workspace}} + run: | + cmake -B ./build ${{ env.CMAKE_PARAM }} ./source + + - name: Build + working-directory: ${{github.workspace}} + run: | + cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel + + - name: Test + working-directory: ${{github.workspace}} + # Execute tests defined by the CMake configuration. + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail + run: | + cd "${{github.workspace}}/build" + ctest -C ${{env.BUILD_TYPE}} + + - name: Install + working-directory: ${{github.workspace}} + # Install to the directory defined in CMAKE_INSTALL_PREFIX + run: | + cmake --install ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + # Create hard-link and copy symbolic links + mkdir ${{github.workspace}}/package + cp -l ${{steps.sdl.outputs.prefix}}/lib/libSDL2-2.0.0.dylib '${{github.workspace}}/package/' + cp -l ${{github.workspace}}/thirdparties/soft-oal/install/lib/libopenal.1.dylib '${{github.workspace}}/package/' + cp -l ${{github.workspace}}/thirdparties/curl/install/lib*/libcurl.4.dylib '${{github.workspace}}/package/' + if [ -d ${{github.workspace}}/install/bin ]; then cp -r ${{github.workspace}}/install/bin/openmohaa/. '${{github.workspace}}/package'; fi + if [ -d ${{github.workspace}}/install/lib ]; then cp -r ${{github.workspace}}/install/lib/openmohaa/. '${{github.workspace}}/package'; fi + + ### + # Artifacts + ### + + - uses: actions/upload-artifact@v4 + with: + name: out-macos-${{matrix.architecture.name}} + if-no-files-found: error + path: + ${{github.workspace}}/package diff --git a/.github/workflows/shared-build-windows.yml b/.github/workflows/shared-build-windows.yml new file mode 100644 index 00000000..6aa11ad6 --- /dev/null +++ b/.github/workflows/shared-build-windows.yml @@ -0,0 +1,259 @@ +########################## +# +# Microsoft Windows +# Windows Server 2025 +# +########################## +name: Windows build workflow + +on: + workflow_call: + inputs: + environment: + required: true + type: string + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: RelWithDebInfo + RELEASE_STAGE: ${{ vars.RELEASE_STAGE || 'unstable' }} + +jobs: + build: + strategy: + matrix: + architecture: [ + {name: 'x64', os: 'windows-2025', config: 'x64', toolset: 'x64', arch_option: 'VC-WIN64A' }, + {name: 'x86', os: 'windows-2025', config: 'Win32', toolset: 'x64_x86', arch_option: 'VC-WIN32' }, + {name: 'arm64', os: 'windows-11-arm', config: 'ARM64', toolset: 'x64_arm64', arch_option: 'VC-WIN64-ARM' } + ] + + name: "Building for platform windows-${{matrix.architecture.name}}" + runs-on: ${{ matrix.architecture.os }} + environment: ${{ inputs.environment }} + env: + flexbison-branch: 'v2.5.25' + wolfssl-version: 'v5.7.6-stable' + curl-version: '8_12_1' + openal-soft-branch: '1.24.3' + + steps: + ### + # Packages + ### + + - name: Cache Flex/Bison + id: cache-flexbison + uses: actions/cache@v4 + with: + path: 'thirdparties/winflexbison-install' + key: ${{ runner.os }}-${{ matrix.architecture.name }}-flexbison-${{ env.flexbison-branch }}-v1 + + - name: Install Flex/Bison + if: steps.cache-flexbison.outputs.cache-hit != 'true' + working-directory: ${{github.workspace}} + run: | + mkdir thirdparties && cd thirdparties + git clone --depth 1 --single-branch --branch ${{ env.flexbison-branch }} https://github.com/lexxmark/winflexbison.git + cmake -B winflexbison-build -DCMAKE_INSTALL_PREFIX='${{github.workspace}}/thirdparties/winflexbison-install' ./winflexbison + cmake --build winflexbison-build --config Release --parallel + cmake --install winflexbison-build --config Release + + - name: Settings + working-directory: ${{github.workspace}} + run: | + echo "CMAKE_GENERATOR=Ninja Multi-Config" >> $env:GITHUB_ENV + echo "CC=cl.exe" >> $env:GITHUB_ENV + echo "CXX=cl.exe" >> $env:GITHUB_ENV + pushd "$($env:PROGRAMFILES)\Microsoft Visual Studio\*\*\VC\Auxiliary\Build" + cmd /c "vcvarsall.bat ${{ matrix.architecture.toolset }} & set" | ForEach-Object { + if ($_ -match "=") { + # Split into key=value + $var = $_.split("=", 2); + echo "$($var[0])=$($var[1])" >> $env:GITHUB_ENV + } + } + popd + + - name: Cache Required Packages + id: cache-required-packages + uses: actions/cache@v4 + with: + path: 'C:\Packages' + key: ${{ runner.os }}-${{ matrix.architecture.name }}-required-packages-v1 + + - name: Install required packages + if: steps.cache-required-packages.outputs.cache-hit != 'true' + run: | + $DownloadPath="$($env:USERPROFILE)\Downloads" + if ("${{ matrix.architecture.config }}" -ieq "ARM64") { + Invoke-WebRequest "https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-winarm64.zip" -OutFile "$DownloadPath\ninja-win.zip" + } else { + Invoke-WebRequest "https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-win.zip" -OutFile "$DownloadPath\ninja-win.zip" + } + Expand-Archive -Path "$DownloadPath\ninja-win.zip" -DestinationPath "C:\Packages\ninja" + Invoke-WebRequest "https://download.qt.io/official_releases/jom/jom.zip" -OutFile "$DownloadPath\jom.zip" + Expand-Archive -Path "$DownloadPath\jom.zip" -DestinationPath "C:\Packages\jom" + + - name: Setup required packages path + run: | + $env:PATH += ";C:\Packages\ninja;C:\Packages\jom;" + echo "PATH=$($env:PATH)" >> $env:GITHUB_ENV + + ### + # SDL + ### + + # Setup SDL + - name: Set up SDL + id: sdl + uses: libsdl-org/setup-sdl@main + with: + version: 2-latest + build-type: Release + cmake-arguments: "" + + ### + # OpenAL + ### + - name: Cache OpenAL + id: cache-openal-soft + uses: actions/cache@v4 + with: + path: 'thirdparties/soft-oal/install' + key: ${{ runner.os }}-${{ matrix.architecture.name }}-openal-soft-${{ env.openal-soft-branch }}-v1 + + # soft-oal setup + - name: Checkout soft-oal + if: steps.cache-openal-soft.outputs.cache-hit != 'true' + uses: actions/checkout@v4 + with: + repository: 'kcat/openal-soft' + path: 'thirdparties/soft-oal' + ref: '${{ env.openal-soft-branch }}' + + # soft-oal build + # Statically link the CRT runtime into OAL as a workaround to prevent crashes + - name: Configure and install soft-oal + if: steps.cache-openal-soft.outputs.cache-hit != 'true' + working-directory: ${{github.workspace}}/thirdparties/soft-oal + run: | + cmake -B ./build ` + -DCMAKE_INSTALL_PREFIX='${{github.workspace}}/thirdparties/soft-oal/install' ` + -DALSOFT_BUILD_ROUTER=OFF ` + -DALSOFT_REQUIRE_WINMM=ON ` + -DALSOFT_REQUIRE_DSOUND=ON ` + -DALSOFT_REQUIRE_WASAPI=ON ` + -DCMAKE_C_FLAGS_RELEASE="/MT /O2 /Ob2 /DNDEBUG" ` + -DCMAKE_CXX_FLAGS_RELEASE="/MT /O2 /Ob2 /DNDEBUG" ` + -DCMAKE_C_FLAGS_MINSIZEREL="/MT /O2 /Ob2 /DNDEBUG" ` + -DCMAKE_CXX_FLAGS_MINSIZEREL="/MT /O1 /Ob1 /DNDEBUG" ` + -DCMAKE_C_FLAGS_RELWITHDEBINFO="/MT /Zi /O2 /Ob1 /DNDEBUG" ` + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="/MT /Zi /O2 /Ob1 /DNDEBUG" + cmake --build ./build --config Release --parallel + cmake --install ./build --config Release + # Unfortunately soft-oal produces a binary called OpenAL32 even in 64-bit + if (("x64", "ARM64") -icontains "${{ matrix.architecture.config }}") { Rename-Item -Path '.\install\bin\OpenAL32.dll' -NewName 'OpenAL64.dll' } + + ### + # cURL + # + # Uses Schannel as SSL backend, native CAs are used + ### + - name: Cache cURL + id: cache-curl + uses: actions/cache@v4 + with: + path: 'thirdparties/curl/install' + key: ${{ runner.os }}-${{ matrix.architecture.name }}-curl-${{ env.curl-version }}-v1 + + # cURL setup + - name: Checkout cURL + if: steps.cache-curl.outputs.cache-hit != 'true' + uses: actions/checkout@v4 + with: + repository: 'curl/curl' + path: 'thirdparties/curl' + ref: 'curl-${{ env.curl-version }}' + + # cURL build + - name: Configure and install curl + if: steps.cache-curl.outputs.cache-hit != 'true' + working-directory: ${{github.workspace}}/thirdparties/curl + run: | + cmake -B ./build ` + -DCMAKE_INSTALL_PREFIX='${{github.workspace}}/thirdparties/curl/install' ` + -DCURL_USE_LIBPSL=OFF ` + -DCURL_USE_SCHANNEL=ON + cmake --build ./build --config Release --parallel + cmake --install ./build --config Release + + ### + # Project + ### + + - uses: actions/checkout@v4 + with: + path: 'source' + + - name: CMake Settings + run: | + echo "CMAKE_PARAM= ` + --log-level=VERBOSE ` + -DCMAKE_INSTALL_PREFIX='${{github.workspace}}/install' ` + -DGIT_REVISION_BUILD_NUMBER=${{ github.run_number }} ` + -DBISON_EXECUTABLE='${{github.workspace}}/thirdparties/winflexbison-install/win_bison.exe' ` + -DOPENAL_LIBRARY='${{github.workspace}}/thirdparties/soft-oal' ` + -DOPENAL_INCLUDE_DIR='${{github.workspace}}/thirdparties/soft-oal/install/include' ` + -DCURL_ROOT='${{github.workspace}}/thirdparties/curl/install' ` + -DFLEX_EXECUTABLE='${{github.workspace}}/thirdparties/winflexbison-install/win_flex.exe' ` + -DPRODUCT_VERSION_STAGE='${{ env.RELEASE_STAGE }}'".Replace("`r", "").Replace("`n", "") >> $env:GITHUB_ENV + + - name: Configure CMake + working-directory: ${{github.workspace}} + run: | + cmake -B ./build ${{ env.CMAKE_PARAM }} ./source + + - name: Build + working-directory: ${{github.workspace}} + run: | + cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel + + - name: Test + working-directory: ${{github.workspace}} + # Execute tests defined by the CMake configuration. + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail + run: | + cd "${{github.workspace}}/build" + ctest -C ${{env.BUILD_TYPE}} + + - name: Install + working-directory: ${{github.workspace}} + # Install to the directory defined in CMAKE_INSTALL_PREFIX + run: | + cmake --install ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + New-Item -ItemType Directory '${{github.workspace}}/package' + Copy-Item '${{steps.sdl.outputs.prefix}}/bin/*.dll' -Destination '${{github.workspace}}/package' + Copy-Item '${{github.workspace}}/thirdparties/soft-oal/install/bin/*.dll' -Destination '${{github.workspace}}/package' + Copy-Item '${{github.workspace}}/thirdparties/curl/install/bin/*.dll' -Destination '${{github.workspace}}/package' + if (Test-Path ${{github.workspace}}/install/bin) { Copy-Item '${{github.workspace}}/install/bin/*' -Include '*.dll','*.exe','*.pdb' -Destination '${{github.workspace}}/package' } + if (Test-Path ${{github.workspace}}/install/lib) { Copy-Item '${{github.workspace}}/install/lib/*' -Include '*.dll','*.exe','*.pdb' -Destination '${{github.workspace}}/package' } + + ### + # Artifact + ### + + - uses: actions/upload-artifact@v4 + with: + name: out-windows-${{matrix.architecture.name}} + if-no-files-found: error + path: | + ${{github.workspace}}/package + !${{github.workspace}}/package/**/*.pdb + + - uses: actions/upload-artifact@v4 + with: + name: out-windows-${{matrix.architecture.name}}-pdb + if-no-files-found: error + path: | + ${{github.workspace}}/package \ No newline at end of file diff --git a/.github/workflows/shared-build.yml b/.github/workflows/shared-build.yml new file mode 100644 index 00000000..3bac5e21 --- /dev/null +++ b/.github/workflows/shared-build.yml @@ -0,0 +1,24 @@ +name: Shared build workflow + +on: + workflow_call: + inputs: + environment: + required: true + type: string + +jobs: + build-platform-linux: + uses: ./.github/workflows/shared-build-linux.yml + with: + environment: ${{inputs.environment}} + + build-platform-windows: + uses: ./.github/workflows/shared-build-windows.yml + with: + environment: ${{inputs.environment}} + + build-platform-macos: + uses: ./.github/workflows/shared-build-macos.yml + with: + environment: ${{inputs.environment}} diff --git a/.github/workflows/publish-release.yml b/.github/workflows/tags-publish-release.yml similarity index 59% rename from .github/workflows/publish-release.yml rename to .github/workflows/tags-publish-release.yml index 1ff4bcd0..a1d44b74 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/tags-publish-release.yml @@ -6,7 +6,7 @@ on: - "v*.*.*" env: - RELEASE_TYPE: ${{ vars.RELEASE_TYPE || 'test' }} + RELEASE_STAGE: ${{ vars.RELEASE_STAGE || 'unstable' }} RELEASE_IS_PRERELEASE: ${{ vars.RELEASE_IS_PRELEASE }} permissions: @@ -14,7 +14,9 @@ permissions: jobs: build-all: - uses: ./.github/workflows/build-cmake.yml + uses: ./.github/workflows/shared-build.yml + with: + environment: "release" deploy_all: strategy: @@ -25,36 +27,42 @@ jobs: target_os: [ 'linux-amd64', 'linux-i686', - 'linux-aarch64', + 'linux-arm64', 'linux-armhf', + 'linux-powerpc', + 'linux-ppc64', + 'linux-ppc64el', 'windows-x64', - 'windows-x86', 'windows-x64-pdb', + 'windows-x86', 'windows-x86-pdb', 'windows-arm64', - 'windows-arm64-pdb' + 'windows-arm64-pdb', + #'macos-x86_64', + #'macos-arm64', + 'macos-multiarch(arm64-x86_64)', ] - runs-on: ubuntu-22.04 - environment: release + runs-on: ubuntu-24.04 + environment: "release" needs: [build-all] env: RELEASE_NAME: ${{ github.event.repository.name }}-${{github.ref_name}}-${{matrix.target_os}} steps: - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: 'out-${{matrix.target_os}}' path: ${{github.workspace}}/${{matrix.target_os}} - name: Zip - working-directory: ${{github.workspace}}/${{matrix.target_os}} - run: zip -r ../${{ env.RELEASE_NAME }}.zip ./ + working-directory: '${{github.workspace}}/${{matrix.target_os}}' + run: zip -r "../${{ env.RELEASE_NAME }}.zip" ./ - name: Release - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: - name: '${{github.ref_name}}-${{env.RELEASE_TYPE}}' + name: '${{github.ref_name}}-${{env.RELEASE_STAGE}}' prerelease: ${{env.RELEASE_IS_PRERELEASE}} files: ${{github.workspace}}/${{ env.RELEASE_NAME }}.zip diff --git a/.gitignore b/.gitignore index f5adba0c..642e22a5 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,8 @@ Makefile.local *.swp *tags *~ +/.vscode/ +/baseq3 # OS X #################### diff --git a/CMakeLists.txt b/CMakeLists.txt index ac6ed6c8..ba983bc9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,36 +1,58 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(openmohaa) -include(TargetArch.cmake) +include(misc/cmake/TargetArch.cmake) target_architecture(TARGET_ARCH) +list(LENGTH TARGET_ARCH TARGET_ARCH_COUNT) +set(USE_INTERNAL_LIBS ON) +if(USE_SYSTEM_LIBS) + set(USE_INTERNAL_LIBS OFF) +endif() + +option(USE_INTERNAL_JPEG "If set, use bundled libjpeg." ${USE_INTERNAL_LIBS}) +option(USE_INTERNAL_MAD "If set, use bundled libmad." ${USE_INTERNAL_LIBS}) +option(USE_INTERNAL_ZLIB "If set, use bundled zlib." ${USE_INTERNAL_LIBS}) +option(USE_RENDERER_DLOPEN "Whether to compile the renderer as separate pluggable modules" OFF) +option(TARGET_LOCAL_SYSTEM "Indicate that the project will be compiled and installed for the local system" OFF) if(TARGET_GAME_TYPE) message(SEND_ERROR "TARGET_GAME_TYPE is now unsupported, it is now done at runtime.") endif() - set(TARGET_BASE_GAME "./") set(CMAKE_DEBUG_POSTFIX "-dbg") +# +# Microsoft compiler specific parameters +# if(MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE) # Treat no return type as error add_compile_options(/we4715) endif() -if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU") +# +# Clang and GCC specific parameters +# +if(CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU") add_compile_options(-Wno-comment) # Treat no return type as error add_compile_options(-Werror=return-type) endif() +# +# Clang specific parameters +# if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") # Ignore warnings for code like 'assert("Assert string")' add_compile_options(-Wno-pointer-bool-conversion) endif() +# +# GCC specific parameters +# if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # Add this option on gcc to prevent functions from having the STB_GNU_UNIQUE binding # Otherwise, it would prevent libraries from being unloaded @@ -42,26 +64,40 @@ if(DEBUG_MEMORY) add_definitions(-D_DEBUG_MEM) endif() -IF("${TARGET_ARCH}" STREQUAL "i386") +if("${TARGET_ARCH}" STREQUAL "i386") set(TARGET_ARCH_SUFFIX "x86") -ELSE() +else() set(TARGET_ARCH_SUFFIX ${TARGET_ARCH}) -ENDIF() +endif() -message(STATUS "Architecture detected: ${TARGET_ARCH}, suffix set to ${TARGET_ARCH_SUFFIX}.") +message(STATUS "Architecture detected: ${TARGET_ARCH}") -IF(WIN32) +if(TARGET_LOCAL_SYSTEM) + add_definitions(-DTARGET_LOCAL_SYSTEM) + # As it targets the local system, no need to know about the architecture used + set(TARGET_BIN_SUFFIX "") + message(STATUS "Binary suffix will not be used as the local system is the target") +elseif(${TARGET_ARCH_COUNT} GREATER 1) + add_definitions(-DTARGET_MULTIPLE_ARCHITECTURES) + set(TARGET_BIN_SUFFIX ".multiarch") + message(STATUS "Multiple architectures were specified, suffix set to 'multiarch'.") +else() + set(TARGET_BIN_SUFFIX ".${TARGET_ARCH}") + message(STATUS "Binary suffix set to '${TARGET_ARCH_SUFFIX}'.") +endif() + +if(WIN32) set(TARGET_PLATFORM_PREFIX "") message(STATUS "Using Win32 naming convention") -ELSEIF(UNIX) +elseif(UNIX) set(TARGET_PLATFORM_PREFIX "") message(STATUS "Using Unix naming convention") -ELSE() +else() set(TARGET_PLATFORM_PREFIX "") -ENDIF() +endif() -IF(CMAKE_BUILD_TYPE MATCHES Debug) - add_definitions(-D_DEBUG) +if(CMAKE_BUILD_TYPE MATCHES Debug) + add_compile_definitions(_DEBUG) # NOTE: The following may mess up function importation #if(UNIX) @@ -69,18 +105,60 @@ IF(CMAKE_BUILD_TYPE MATCHES Debug) # set(CMAKE_ENABLE_EXPORTS ON) # message(STATUS "Enabling exports on Unix for backtrace") #endif() -ENDIF() +else() + # Non-debug builds + add_compile_definitions(NDEBUG) +endif() +if(APPLE) + # macOS doesn't search the executable path by default + # so, locate libraries like SDL in the executable path + set(CMAKE_INSTALL_RPATH "@executable_path") + set(CMAKE_BUILD_WITH_INSTALL_RPATH ON) + + if(CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "GNU") + # Set the visibility to hidden on macOS to prevent shared libraries from + # using functions in the executable + # it's ok to hide them because the backtrace on macOS will still print the name of the functions + add_compile_options(-fvisibility=hidden) + endif() +endif() + +# +# Setup the installation directory +# +if(WIN32) + # By default, both DLLs and EXEs are in the same directory + set(CMAKE_DEFAULT_INSTALL_RUNTIME_DIR bin) + set(BIN_INSTALL_SUBDIR ".") + set(LIB_INSTALL_SUBDIR ".") +else() + # Unix + set(CMAKE_DEFAULT_INSTALL_RUNTIME_DIR lib${CMAKE_LIB_SUFFIX}) + set(BIN_INSTALL_SUBDIR ${CMAKE_PROJECT_NAME}) + set(LIB_INSTALL_SUBDIR ${CMAKE_PROJECT_NAME}) +endif() + +# By default, put both binaries and shared libraries in the same directory +# the game uses internal shared libraries that must be in the same folder as the binaries +set(CMAKE_INSTALL_BINDIR ${CMAKE_DEFAULT_INSTALL_RUNTIME_DIR} CACHE PATH "Binary dir") +set(CMAKE_INSTALL_LIBDIR ${CMAKE_INSTALL_BINDIR} CACHE PATH "Library dir") +include(GNUInstallDirs) + +# # Common stuff - +# add_subdirectory("code/qcommon") add_subdirectory("code/gamespy") +# # Application - +# add_subdirectory("code/sys") +## ## Server app +## add_subdirectory("code/server") add_executable(omohaaded "code/null/null_client.c" "code/null/null_input.c" "code/null/null_snddma.c") @@ -91,48 +169,104 @@ target_link_libraries(omohaaded PRIVATE omohserver) target_link_libraries(omohaaded PRIVATE syslib) target_link_libraries(omohaaded PRIVATE qcommon qcommon_standalone) -# Gamespy dependency +# Add the gamespy dependency target_include_directories(omohaaded PUBLIC "code/qcommon" "code/script" "code/gamespy" "code/server") -set_target_properties(omohaaded PROPERTIES OUTPUT_NAME "omohaaded${TARGET_BASE_SUFFIX}${TARGET_ARCH_SUFFIX}") +set_target_properties(omohaaded PROPERTIES OUTPUT_NAME "omohaaded${TARGET_BIN_SUFFIX}") set_target_properties(omohaaded PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}) +INSTALL(TARGETS omohaaded DESTINATION ${CMAKE_INSTALL_BINDIR}/${BIN_INSTALL_SUBDIR}) + if (MSVC) target_link_options(omohaaded PRIVATE "/MANIFEST:NO") - INSTALL(FILES $ DESTINATION "./" OPTIONAL) + INSTALL(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}/${BIN_INSTALL_SUBDIR} OPTIONAL) endif() -INSTALL(TARGETS omohaaded DESTINATION "./") - if (NOT BUILD_NO_CLIENT) + ## ## Client app + ## + option(NO_MODERN_DMA "Use older sound-system" FALSE) - add_subdirectory("code/renderer") - add_subdirectory("code/sdl") add_subdirectory("code/client") - - #include("code/renderergl2/glsl/shaders.cmake") - #file(GLOB_RECURSE SOURCES_RENDERER "code/sdl/*.c" "code/renderercommon/*.c" "code/renderergl2/*.c" "code/renderergl2/*.cpp") - #list(FILTER SOURCES_RENDERER EXCLUDE REGEX "code/renderergl2/tr_subs.c") - #list(FILTER SOURCES_RENDERER EXCLUDE REGEX "code/renderergl2/tr_model.c") + add_subdirectory("code/renderercommon") + add_subdirectory("code/sdl") add_executable(openmohaa "misc/dummy.c") target_link_libraries(openmohaa PRIVATE syslib) target_link_libraries(openmohaa PRIVATE omohserver) target_link_libraries(openmohaa PRIVATE omohclient) - target_link_libraries(openmohaa PRIVATE omohrenderer omohsdl) + target_link_libraries(openmohaa PRIVATE omohrenderer) target_link_libraries(openmohaa PRIVATE qcommon qcommon_standalone) - ### Gamespy dependency - target_include_directories(openmohaa PUBLIC "code/qcommon" "code/script" "code/gamespy" "code/server" "code/client" "code/uilib" "code/jpeg-8c") - set_target_properties(openmohaa PROPERTIES OUTPUT_NAME "openmohaa${TARGET_BASE_SUFFIX}${TARGET_ARCH_SUFFIX}") + # Add the gamespy dependency + target_include_directories(openmohaa PUBLIC "code/qcommon" "code/script" "code/gamespy" "code/server" "code/client" "code/uilib") + set_target_properties(openmohaa PROPERTIES OUTPUT_NAME "openmohaa${TARGET_BIN_SUFFIX}") set_target_properties(openmohaa PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}) - target_link_libraries(openmohaa PRIVATE jpeg8) + if(USE_INTERNAL_JPEG) + target_include_directories(openmohaa PUBLIC "code/jpeg-8c") + target_link_libraries(openmohaa PRIVATE jpeg8) + else() + find_package(JPEG REQUIRED) + target_include_directories(openmohaa PUBLIC ${JPEG_INCLUDE_DIRS}) + target_link_libraries(openmohaa PRIVATE ${JPEG_LIBRARIES}) + endif() + + INSTALL(TARGETS openmohaa DESTINATION ${CMAKE_INSTALL_BINDIR}/${BIN_INSTALL_SUBDIR}) if (MSVC) target_link_options(openmohaa PRIVATE "/MANIFEST:NO") - INSTALL(FILES $ DESTINATION "./" OPTIONAL) + INSTALL(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}/${BIN_INSTALL_SUBDIR} OPTIONAL) endif() - INSTALL(TARGETS openmohaa DESTINATION "./") + if(UNIX AND NOT APPLE) + # + # Desktop entries installation on Unix + # + set(TARGET_ARCH ${TARGET_BIN_SUFFIX}) + + # Configure the .desktop entries with the arch suffix + configure_file( + misc/linux/org.openmoh.openmohaa.desktop.in + ${CMAKE_BINARY_DIR}/misc/linux/org.openmoh.openmohaa.desktop + @ONLY + ) + configure_file( + misc/linux/org.openmoh.openmohaab.desktop.in + ${CMAKE_BINARY_DIR}/misc/linux/org.openmoh.openmohaab.desktop + @ONLY + ) + configure_file( + misc/linux/org.openmoh.openmohaas.desktop.in + ${CMAKE_BINARY_DIR}/misc/linux/org.openmoh.openmohaas.desktop + @ONLY + ) + + # Install .desktop entries + install(FILES ${CMAKE_BINARY_DIR}/misc/linux/org.openmoh.openmohaa.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications) + install(FILES ${CMAKE_BINARY_DIR}/misc/linux/org.openmoh.openmohaab.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications) + install(FILES ${CMAKE_BINARY_DIR}/misc/linux/org.openmoh.openmohaas.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications) + + install(FILES misc/linux/org.openmoh.openmohaa.metainfo.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/metainfo) + + install(FILES misc/openmohaa.svg DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/symbolic/apps/ RENAME org.openmoh.openmohaa.svg) + endif() +endif() + +# +# Launcher +# +add_subdirectory(code/Launcher) + +# +# uninstall target +# +if(NOT TARGET uninstall) + configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" + IMMEDIATE @ONLY) + + add_custom_target(uninstall + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) endif() diff --git a/README.md b/README.md index 10317740..9d221b94 100644 --- a/README.md +++ b/README.md @@ -1,48 +1,49 @@ # OpenMoHAA -![Build](https://github.com/openmoh/openmohaa/actions/workflows/build-cmake.yml/badge.svg?branch=main) [![Release](https://img.shields.io/github/v/release/openmoh/openmohaa)](https://github.com/openmoh/openmohaa/releases) [![Downloads](https://img.shields.io/github/downloads/openmoh/openmohaa/total)](https://github.com/openmoh/openmohaa/releases) +[![Build](https://github.com/openmoh/openmohaa/actions/workflows/branches-build.yml/badge.svg?branch=main)](https://github.com/openmoh/openmohaa/actions/workflows/branches-build.yml) [![Release](https://img.shields.io/github/v/release/openmoh/openmohaa)](https://github.com/openmoh/openmohaa/releases) [![Downloads](https://img.shields.io/github/downloads/openmoh/openmohaa/total)](https://github.com/openmoh/openmohaa/releases) ![License](https://img.shields.io/github/license/openmoh/openmohaa) ![Commits](https://img.shields.io/github/commit-activity/t/openmoh/openmohaa) ![Discord](https://img.shields.io/discord/596049712579215361?logo=discord&logoColor=white&color=5865F2) - -``` - / _ \ _ __ ___ _ __ | \/ |/ _ \| | | | / \ / \ - | | | | '_ \ / _ \ '_ \| |\/| | | | | |_| | / _ \ / _ \ - | |_| | |_) | __/ | | | | | | |_| | _ |/ ___ \ / ___ \ - \___/| .__/ \___|_| |_|_| |_|\___/|_| |_/_/ \_\/_/ \_\ - |_| -``` +![logo](misc/openmohaa-text-sm.png) ## Intro -The main goal of OpenMoHAA is to ensure the future and continuity of **Medal of Honor: Allied Assault**. It has always been a dream in the community to provide patches and security fixes for the game. Thanks to the ioquake3 project, F.A.K.K SDK and other quality tools, OpenMoHAA has already reached more than half of its goal: to create an open-source version of MoH:AA (based on version 2.40) that is fully compatible with the original game (in terms of protocol, assets, and scripts). +The main goal of OpenMoHAA is to ensure the future and continuity of **Medal of Honor: Allied Assault** (including Spearhead and Breakthrough expansions) on all platforms/architectures by providing new patches/features. Thanks to the ioquake3 project and the F.A.K.K SDK, OpenMoHAA has already reached more than half of its goal: an open-source version of MoH:AA (based on version 2.40) that is fully compatible with both the original game and expansions, in terms of network protocol, assets, and scripts. OpenMoHAA is compatible with both MOH:AA servers and clients (Spearhead and Breakthrough included). ## Getting started -- [Installing OpenMoHAA](docs/getting_started_installation.md) +- [Downloading and installing OpenMoHAA](docs/getting_started_installation.md) - [Running OpenMoHAA and using expansion assets](docs/getting_started_running.md) +- [Game configuration](docs/configuration.md) + +If you encounter any issues, please refer to the [FAQ](docs/faq.md) for possible solutions. ## Current state -### Multiplayer - -The Multiplayer part is almost fully stable. - -Server admins can use OpenMoHAA to [host](docs/getting_started_installation.md#server) a mohaa/mohaas/mohaab server. Bugs must be reported by creating a new [issue](https://github.com/openmoh/openmohaa/issues) on the OpenMoHAA GitHub project. Players can use OpenMoHAA to [play](docs/getting_started_installation.md#client) on a mohaa/mohaas/mohaab server. - -All game modes including `Tug-of-War` from Medal of Honor: Spearhead, and `Liberation` from Medal of Honor: Breakthrough are implemented and are working as intended. Mods like `Freeze-Tag` are working as well. - ### Single-player -The `training` map can be played from start to end. The single-player campaign is not fully functional, but at least AI can breathe, talk, run, and shoot. +The entire single-player campaign should work (Allied Assault, Spearhead and Breakthrough). If you encounter any bug, please create a new [GitHub issue](https://github.com/openmoh/openmohaa/issues) describing them. + +### Multiplayer + +The Multiplayer part is almost fully stable, all game modes including `Tug-of-War` from Medal of Honor: Spearhead, and `Liberation` from Medal of Honor: Breakthrough are implemented and are working as intended. Mods like `Freeze-Tag` are working as well. + +OpenMoHAA can be used to [host](docs/getting_started_installation.md#server) a mohaa/mohaas/mohaab server and players can use OpenMoHAA to [play](docs/getting_started_installation.md#client) on any server. If some bugs/strange behavior occurs, the best way to report them is by [creating a new issue](https://github.com/openmoh/openmohaa/issues) on the [OpenMoHAA GitHub](https://github.com/openmoh/openmohaa) project with the steps to reproduce (with eventually the problematic mods). + +One of the big multiplayer features are bots. They were introduced for testing and for entertainment purposes so players can have fun alone. See [Configuring bots](docs/configuration/server.md#bots) in the dedicated server configuration documentation to set them up. ## Features -- [What's working and what's not](docs/features_implementation.md) -- [New features](docs/features.md) -- [Scripting commands](https://htmlpreview.github.io/?https://github.com/openmoh/openmohaa/blob/main/docs/features_g_allclasses.html) +- [List of new features](docs/features.md) +- [Scripting](docs/scripting.md) + +## Reporting issues + +If you encounter a bug, report it by creating a new [issue](https://github.com/openmoh/openmohaa/issues). Make sure to select the `Bug report` template and fill in the appropriate fields. + +If you need help or have a problem, you can head over to the [discussions](https://github.com/openmoh/openmohaa/discussions) or join the OpenMoHAA Discord server (the link is at the bottom of this README). ## Compiling diff --git a/cmake_uninstall.cmake.in b/cmake_uninstall.cmake.in new file mode 100644 index 00000000..7db7869a --- /dev/null +++ b/cmake_uninstall.cmake.in @@ -0,0 +1,21 @@ +if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") + message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt") +endif() + +file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files) +string(REGEX REPLACE "\n" ";" files "${files}") +foreach(file ${files}) + message(STATUS "Uninstalling $ENV{DESTDIR}${file}") + if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + execute_process( + COMMAND "@CMAKE_COMMAND@" -E remove "$ENV{DESTDIR}${file}" + OUTPUT_VARIABLE rm_out + RESULT_VARIABLE rm_retval + ) + if(NOT "${rm_retval}" STREQUAL 0) + message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") + endif() + else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + message(STATUS "File $ENV{DESTDIR}${file} does not exist.") + endif() +endforeach() diff --git a/code/AL/al.h b/code/AL/al.h index 413b3833..a4e3ad51 100644 --- a/code/AL/al.h +++ b/code/AL/al.h @@ -1,8 +1,40 @@ #ifndef AL_AL_H #define AL_AL_H -#if defined(__cplusplus) +/* NOLINTBEGIN */ +#ifdef __cplusplus extern "C" { + +#ifdef _MSVC_LANG +#define AL_CPLUSPLUS _MSVC_LANG +#else +#define AL_CPLUSPLUS __cplusplus +#endif + +#ifndef AL_DISABLE_NOEXCEPT +#if AL_CPLUSPLUS >= 201103L +#define AL_API_NOEXCEPT noexcept +#else +#define AL_API_NOEXCEPT +#endif +#if AL_CPLUSPLUS >= 201703L +#define AL_API_NOEXCEPT17 noexcept +#else +#define AL_API_NOEXCEPT17 +#endif + +#else /* AL_DISABLE_NOEXCEPT */ + +#define AL_API_NOEXCEPT +#define AL_API_NOEXCEPT17 +#endif + +#undef AL_CPLUSPLUS + +#else /* __cplusplus */ + +#define AL_API_NOEXCEPT +#define AL_API_NOEXCEPT17 #endif #ifndef AL_API @@ -15,14 +47,14 @@ extern "C" { #endif #endif -#if defined(_WIN32) +#ifdef _WIN32 #define AL_APIENTRY __cdecl #else #define AL_APIENTRY #endif -/** Deprecated macro. */ +/* Deprecated macros. */ #define OPENAL #define ALAPI AL_API #define ALAPIENTRY AL_APIENTRY @@ -30,7 +62,7 @@ extern "C" { #define AL_ILLEGAL_ENUM AL_INVALID_ENUM #define AL_ILLEGAL_COMMAND AL_INVALID_OPERATION -/** Supported AL version. */ +/* Supported AL versions. */ #define AL_VERSION_1_0 #define AL_VERSION_1_1 @@ -40,43 +72,43 @@ typedef char ALboolean; /** character */ typedef char ALchar; -/** signed 8-bit 2's complement integer */ +/** signed 8-bit integer */ typedef signed char ALbyte; /** unsigned 8-bit integer */ typedef unsigned char ALubyte; -/** signed 16-bit 2's complement integer */ +/** signed 16-bit integer */ typedef short ALshort; /** unsigned 16-bit integer */ typedef unsigned short ALushort; -/** signed 32-bit 2's complement integer */ +/** signed 32-bit integer */ typedef int ALint; /** unsigned 32-bit integer */ typedef unsigned int ALuint; -/** non-negative 32-bit binary integer size */ +/** non-negative 32-bit integer size */ typedef int ALsizei; -/** enumerated 32-bit value */ +/** 32-bit enumeration value */ typedef int ALenum; -/** 32-bit IEEE754 floating-point */ +/** 32-bit IEEE-754 floating-point */ typedef float ALfloat; -/** 64-bit IEEE754 floating-point */ +/** 64-bit IEEE-754 floating-point */ typedef double ALdouble; -/** void type (for opaque pointers only) */ +/** void type (opaque pointers only) */ typedef void ALvoid; -/* Enumerant values begin at column 50. No tabs. */ +/* Enumeration values begin at column 50. Do not use tabs. */ -/** "no distance model" or "no buffer" */ +/** No distance model or no buffer */ #define AL_NONE 0 /** Boolean False. */ @@ -89,10 +121,10 @@ typedef void ALvoid; /** * Relative source. * Type: ALboolean - * Range: [AL_TRUE, AL_FALSE] + * Range: [AL_FALSE, AL_TRUE] * Default: AL_FALSE * - * Specifies if the Source has relative coordinates. + * Specifies if the source uses relative coordinates. */ #define AL_SOURCE_RELATIVE 0x202 @@ -103,7 +135,8 @@ typedef void ALvoid; * Range: [0 - 360] * Default: 360 * - * The angle covered by the inner cone, where the source will not attenuate. + * The angle covered by the inner cone, the area within which the source will + * not be attenuated by direction. */ #define AL_CONE_INNER_ANGLE 0x1001 @@ -112,8 +145,8 @@ typedef void ALvoid; * Range: [0 - 360] * Default: 360 * - * The angle covered by the outer cone, where the source will be fully - * attenuated. + * The angle covered by the outer cone, the area outside of which the source + * will be fully attenuated by direction. */ #define AL_CONE_OUTER_ANGLE 0x1002 @@ -123,7 +156,7 @@ typedef void ALvoid; * Range: [0.5 - 2.0] * Default: 1.0 * - * A multiplier for the frequency (sample rate) of the source's buffer. + * A multiplier for the sample rate of the source's buffer. */ #define AL_PITCH 0x1003 @@ -134,12 +167,12 @@ typedef void ALvoid; * * The source or listener location in three dimensional space. * - * OpenAL, like OpenGL, uses a right handed coordinate system, where in a - * frontal default view X (thumb) points right, Y points up (index finger), and - * Z points towards the viewer/camera (middle finger). + * OpenAL uses a right handed coordinate system, like OpenGL, where with a + * default view, X points right (thumb), Y points up (index finger), and Z + * points towards the viewer/camera (middle finger). * - * To switch from a left handed coordinate system, flip the sign on the Z - * coordinate. + * To change from or to a left handed coordinate system, negate the Z + * component. */ #define AL_POSITION 0x1004 @@ -148,8 +181,11 @@ typedef void ALvoid; * Type: ALfloat[3], ALint[3] * Default: {0, 0, 0} * - * Specifies the current direction in local space. - * A zero-length vector specifies an omni-directional source (cone is ignored). + * Specifies the current direction in local space. A zero-length vector + * specifies an omni-directional source (cone is ignored). + * + * To change from or to a left handed coordinate system, negate the Z + * component. */ #define AL_DIRECTION 0x1005 @@ -158,26 +194,30 @@ typedef void ALvoid; * Type: ALfloat[3], ALint[3] * Default: {0, 0, 0} * - * Specifies the current velocity in local space. + * Specifies the current velocity, relative to the position. + * + * To change from or to a left handed coordinate system, negate the Z + * component. */ #define AL_VELOCITY 0x1006 /** * Source looping. * Type: ALboolean - * Range: [AL_TRUE, AL_FALSE] + * Range: [AL_FALSE, AL_TRUE] * Default: AL_FALSE * - * Specifies whether source is looping. + * Specifies whether source playback loops. */ #define AL_LOOPING 0x1007 /** * Source buffer. - * Type: ALuint - * Range: any valid Buffer. + * Type: ALuint + * Range: any valid Buffer ID + * Default: AL_NONE * - * Specifies the buffer to provide sound samples. + * Specifies the buffer to provide sound samples for a source. */ #define AL_BUFFER 0x1009 @@ -186,12 +226,12 @@ typedef void ALvoid; * Type: ALfloat * Range: [0.0 - ] * - * A value of 1.0 means unattenuated. Each division by 2 equals an attenuation - * of about -6dB. Each multiplicaton by 2 equals an amplification of about - * +6dB. + * For sources, an initial linear gain value (before attenuation is applied). + * For the listener, an output linear gain adjustment. * - * A value of 0.0 is meaningless with respect to a logarithmic scale; it is - * silent. + * A value of 1.0 means unattenuated. Each division by 2 equals an attenuation + * of about -6dB. Each multiplication by 2 equals an amplification of about + * +6dB. */ #define AL_GAIN 0x100A @@ -200,8 +240,8 @@ typedef void ALvoid; * Type: ALfloat * Range: [0.0 - 1.0] * - * The minimum gain allowed for a source, after distance and cone attenation is - * applied (if applicable). + * The minimum gain allowed for a source, after distance and cone attenuation + * are applied (if applicable). */ #define AL_MIN_GAIN 0x100D @@ -210,31 +250,33 @@ typedef void ALvoid; * Type: ALfloat * Range: [0.0 - 1.0] * - * The maximum gain allowed for a source, after distance and cone attenation is - * applied (if applicable). + * The maximum gain allowed for a source, after distance and cone attenuation + * are applied (if applicable). */ #define AL_MAX_GAIN 0x100E /** * Listener orientation. - * Type: ALfloat[6] + * Type: ALfloat[6] * Default: {0.0, 0.0, -1.0, 0.0, 1.0, 0.0} * * Effectively two three dimensional vectors. The first vector is the front (or - * "at") and the second is the top (or "up"). + * "at") and the second is the top (or "up"). Both vectors are relative to the + * listener position. * - * Both vectors are in local space. + * To change from or to a left handed coordinate system, negate the Z + * component of both vectors. */ #define AL_ORIENTATION 0x100F /** * Source state (query only). - * Type: ALint + * Type: ALenum * Range: [AL_INITIAL, AL_PLAYING, AL_PAUSED, AL_STOPPED] */ #define AL_SOURCE_STATE 0x1010 -/** Source state value. */ +/* Source state values. */ #define AL_INITIAL 0x1011 #define AL_PLAYING 0x1012 #define AL_PAUSED 0x1013 @@ -267,9 +309,9 @@ typedef void ALvoid; * Range: [0.0 - ] * Default: 1.0 * - * The distance in units that no attenuation occurs. + * The distance in units that no distance attenuation occurs. * - * At 0.0, no distance attenuation ever occurs on non-linear attenuation models. + * At 0.0, no distance attenuation occurs with non-linear attenuation models. */ #define AL_REFERENCE_DISTANCE 0x1020 @@ -292,7 +334,7 @@ typedef void ALvoid; * Default: 0.0 * * The gain attenuation applied when the listener is outside of the source's - * outer cone. + * outer cone angle. */ #define AL_CONE_OUTER_GAIN 0x1022 @@ -300,7 +342,7 @@ typedef void ALvoid; * Source maximum distance. * Type: ALfloat * Range: [0.0 - ] - * Default: +inf + * Default: FLT_MAX * * The distance above which the source is not attenuated any further with a * clamped distance model, or where attenuation reaches 0.0 gain for linear @@ -308,16 +350,16 @@ typedef void ALvoid; */ #define AL_MAX_DISTANCE 0x1023 -/** Source buffer position, in seconds */ +/** Source buffer offset, in seconds */ #define AL_SEC_OFFSET 0x1024 -/** Source buffer position, in sample frames */ +/** Source buffer offset, in sample frames */ #define AL_SAMPLE_OFFSET 0x1025 -/** Source buffer position, in bytes */ +/** Source buffer offset, in bytes */ #define AL_BYTE_OFFSET 0x1026 /** * Source type (query only). - * Type: ALint + * Type: ALenum * Range: [AL_STATIC, AL_STREAMING, AL_UNDETERMINED] * * A Source is Static if a Buffer has been attached using AL_BUFFER. @@ -330,31 +372,30 @@ typedef void ALvoid; */ #define AL_SOURCE_TYPE 0x1027 -/** Source type value. */ +/* Source type values. */ #define AL_STATIC 0x1028 #define AL_STREAMING 0x1029 #define AL_UNDETERMINED 0x1030 -/** Buffer format specifier. */ +/** Unsigned 8-bit mono buffer format. */ #define AL_FORMAT_MONO8 0x1100 +/** Signed 16-bit mono buffer format. */ #define AL_FORMAT_MONO16 0x1101 +/** Unsigned 8-bit stereo buffer format. */ #define AL_FORMAT_STEREO8 0x1102 +/** Signed 16-bit stereo buffer format. */ #define AL_FORMAT_STEREO16 0x1103 -/** Buffer frequency (query only). */ +/** Buffer frequency/sample rate (query only). */ #define AL_FREQUENCY 0x2001 /** Buffer bits per sample (query only). */ #define AL_BITS 0x2002 /** Buffer channel count (query only). */ #define AL_CHANNELS 0x2003 -/** Buffer data size (query only). */ +/** Buffer data size in bytes (query only). */ #define AL_SIZE 0x2004 -/** - * Buffer state. - * - * Not for public use. - */ +/* Buffer state. Not for public use. */ #define AL_UNUSED 0x2010 #define AL_PENDING 0x2011 #define AL_PROCESSED 0x2012 @@ -363,32 +404,31 @@ typedef void ALvoid; /** No error. */ #define AL_NO_ERROR 0 -/** Invalid name paramater passed to AL call. */ +/** Invalid name (ID) passed to an AL call. */ #define AL_INVALID_NAME 0xA001 -/** Invalid enum parameter passed to AL call. */ +/** Invalid enumeration passed to AL call. */ #define AL_INVALID_ENUM 0xA002 -/** Invalid value parameter passed to AL call. */ +/** Invalid value passed to AL call. */ #define AL_INVALID_VALUE 0xA003 /** Illegal AL call. */ #define AL_INVALID_OPERATION 0xA004 -/** Not enough memory. */ +/** Not enough memory to execute the AL call. */ #define AL_OUT_OF_MEMORY 0xA005 -/** Context string: Vendor ID. */ +/** Context string: Vendor name. */ #define AL_VENDOR 0xB001 /** Context string: Version. */ #define AL_VERSION 0xB002 -/** Context string: Renderer ID. */ +/** Context string: Renderer name. */ #define AL_RENDERER 0xB003 /** Context string: Space-separated extension list. */ #define AL_EXTENSIONS 0xB004 - /** * Doppler scale. * Type: ALfloat @@ -398,7 +438,6 @@ typedef void ALvoid; * Scale for source and listener velocities. */ #define AL_DOPPLER_FACTOR 0xC000 -AL_API void AL_APIENTRY alDopplerFactor(ALfloat value); /** * Doppler velocity (deprecated). @@ -406,7 +445,6 @@ AL_API void AL_APIENTRY alDopplerFactor(ALfloat value); * A multiplier applied to the Speed of Sound. */ #define AL_DOPPLER_VELOCITY 0xC001 -AL_API void AL_APIENTRY alDopplerVelocity(ALfloat value); /** * Speed of Sound, in units per second. @@ -415,14 +453,13 @@ AL_API void AL_APIENTRY alDopplerVelocity(ALfloat value); * Default: 343.3 * * The speed at which sound waves are assumed to travel, when calculating the - * doppler effect. + * doppler effect from source and listener velocities. */ #define AL_SPEED_OF_SOUND 0xC003 -AL_API void AL_APIENTRY alSpeedOfSound(ALfloat value); /** * Distance attenuation model. - * Type: ALint + * Type: ALenum * Range: [AL_NONE, AL_INVERSE_DISTANCE, AL_INVERSE_DISTANCE_CLAMPED, * AL_LINEAR_DISTANCE, AL_LINEAR_DISTANCE_CLAMPED, * AL_EXPONENT_DISTANCE, AL_EXPONENT_DISTANCE_CLAMPED] @@ -439,9 +476,8 @@ AL_API void AL_APIENTRY alSpeedOfSound(ALfloat value); * distance calculated is clamped between the reference and max distances. */ #define AL_DISTANCE_MODEL 0xD000 -AL_API void AL_APIENTRY alDistanceModel(ALenum distanceModel); -/** Distance model value. */ +/* Distance model values. */ #define AL_INVERSE_DISTANCE 0xD001 #define AL_INVERSE_DISTANCE_CLAMPED 0xD002 #define AL_LINEAR_DISTANCE 0xD003 @@ -449,208 +485,223 @@ AL_API void AL_APIENTRY alDistanceModel(ALenum distanceModel); #define AL_EXPONENT_DISTANCE 0xD005 #define AL_EXPONENT_DISTANCE_CLAMPED 0xD006 -/** Renderer State management. */ -AL_API void AL_APIENTRY alEnable(ALenum capability); -AL_API void AL_APIENTRY alDisable(ALenum capability); -AL_API ALboolean AL_APIENTRY alIsEnabled(ALenum capability); +#ifndef AL_NO_PROTOTYPES +/* Renderer State management. */ +AL_API void AL_APIENTRY alEnable(ALenum capability) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alDisable(ALenum capability) AL_API_NOEXCEPT; +AL_API ALboolean AL_APIENTRY alIsEnabled(ALenum capability) AL_API_NOEXCEPT; -/** State retrieval. */ -AL_API const ALchar* AL_APIENTRY alGetString(ALenum param); -AL_API void AL_APIENTRY alGetBooleanv(ALenum param, ALboolean *values); -AL_API void AL_APIENTRY alGetIntegerv(ALenum param, ALint *values); -AL_API void AL_APIENTRY alGetFloatv(ALenum param, ALfloat *values); -AL_API void AL_APIENTRY alGetDoublev(ALenum param, ALdouble *values); -AL_API ALboolean AL_APIENTRY alGetBoolean(ALenum param); -AL_API ALint AL_APIENTRY alGetInteger(ALenum param); -AL_API ALfloat AL_APIENTRY alGetFloat(ALenum param); -AL_API ALdouble AL_APIENTRY alGetDouble(ALenum param); +/* Context state setting. */ +AL_API void AL_APIENTRY alDopplerFactor(ALfloat value) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alDopplerVelocity(ALfloat value) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alSpeedOfSound(ALfloat value) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alDistanceModel(ALenum distanceModel) AL_API_NOEXCEPT; + +/* Context state retrieval. */ +AL_API const ALchar* AL_APIENTRY alGetString(ALenum param) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetBooleanv(ALenum param, ALboolean *values) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetIntegerv(ALenum param, ALint *values) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetFloatv(ALenum param, ALfloat *values) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetDoublev(ALenum param, ALdouble *values) AL_API_NOEXCEPT; +AL_API ALboolean AL_APIENTRY alGetBoolean(ALenum param) AL_API_NOEXCEPT; +AL_API ALint AL_APIENTRY alGetInteger(ALenum param) AL_API_NOEXCEPT; +AL_API ALfloat AL_APIENTRY alGetFloat(ALenum param) AL_API_NOEXCEPT; +AL_API ALdouble AL_APIENTRY alGetDouble(ALenum param) AL_API_NOEXCEPT; /** - * Error retrieval. - * - * Obtain the first error generated in the AL context since the last check. + * Obtain the first error generated in the AL context since the last call to + * this function. */ -AL_API ALenum AL_APIENTRY alGetError(void); +AL_API ALenum AL_APIENTRY alGetError(void) AL_API_NOEXCEPT; +/** Query for the presence of an extension on the AL context. */ +AL_API ALboolean AL_APIENTRY alIsExtensionPresent(const ALchar *extname) AL_API_NOEXCEPT; /** - * Extension support. - * - * Query for the presence of an extension, and obtain any appropriate function - * pointers and enum values. + * Retrieve the address of a function. The returned function may be context- + * specific. */ -AL_API ALboolean AL_APIENTRY alIsExtensionPresent(const ALchar *extname); -AL_API void* AL_APIENTRY alGetProcAddress(const ALchar *fname); -AL_API ALenum AL_APIENTRY alGetEnumValue(const ALchar *ename); +AL_API void* AL_APIENTRY alGetProcAddress(const ALchar *fname) AL_API_NOEXCEPT; +/** + * Retrieve the value of an enum. The returned value may be context-specific. + */ +AL_API ALenum AL_APIENTRY alGetEnumValue(const ALchar *ename) AL_API_NOEXCEPT; -/** Set Listener parameters */ -AL_API void AL_APIENTRY alListenerf(ALenum param, ALfloat value); -AL_API void AL_APIENTRY alListener3f(ALenum param, ALfloat value1, ALfloat value2, ALfloat value3); -AL_API void AL_APIENTRY alListenerfv(ALenum param, const ALfloat *values); -AL_API void AL_APIENTRY alListeneri(ALenum param, ALint value); -AL_API void AL_APIENTRY alListener3i(ALenum param, ALint value1, ALint value2, ALint value3); -AL_API void AL_APIENTRY alListeneriv(ALenum param, const ALint *values); +/* Set listener parameters. */ +AL_API void AL_APIENTRY alListenerf(ALenum param, ALfloat value) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alListener3f(ALenum param, ALfloat value1, ALfloat value2, ALfloat value3) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alListenerfv(ALenum param, const ALfloat *values) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alListeneri(ALenum param, ALint value) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alListener3i(ALenum param, ALint value1, ALint value2, ALint value3) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alListeneriv(ALenum param, const ALint *values) AL_API_NOEXCEPT; -/** Get Listener parameters */ -AL_API void AL_APIENTRY alGetListenerf(ALenum param, ALfloat *value); -AL_API void AL_APIENTRY alGetListener3f(ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3); -AL_API void AL_APIENTRY alGetListenerfv(ALenum param, ALfloat *values); -AL_API void AL_APIENTRY alGetListeneri(ALenum param, ALint *value); -AL_API void AL_APIENTRY alGetListener3i(ALenum param, ALint *value1, ALint *value2, ALint *value3); -AL_API void AL_APIENTRY alGetListeneriv(ALenum param, ALint *values); +/* Get listener parameters. */ +AL_API void AL_APIENTRY alGetListenerf(ALenum param, ALfloat *value) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetListener3f(ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetListenerfv(ALenum param, ALfloat *values) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetListeneri(ALenum param, ALint *value) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetListener3i(ALenum param, ALint *value1, ALint *value2, ALint *value3) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetListeneriv(ALenum param, ALint *values) AL_API_NOEXCEPT; -/** Create Source objects. */ -AL_API void AL_APIENTRY alGenSources(ALsizei n, ALuint *sources); -/** Delete Source objects. */ -AL_API void AL_APIENTRY alDeleteSources(ALsizei n, const ALuint *sources); -/** Verify a handle is a valid Source. */ -AL_API ALboolean AL_APIENTRY alIsSource(ALuint source); +/** Create source objects. */ +AL_API void AL_APIENTRY alGenSources(ALsizei n, ALuint *sources) AL_API_NOEXCEPT; +/** Delete source objects. */ +AL_API void AL_APIENTRY alDeleteSources(ALsizei n, const ALuint *sources) AL_API_NOEXCEPT; +/** Verify an ID is for a valid source. */ +AL_API ALboolean AL_APIENTRY alIsSource(ALuint source) AL_API_NOEXCEPT; -/** Set Source parameters. */ -AL_API void AL_APIENTRY alSourcef(ALuint source, ALenum param, ALfloat value); -AL_API void AL_APIENTRY alSource3f(ALuint source, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3); -AL_API void AL_APIENTRY alSourcefv(ALuint source, ALenum param, const ALfloat *values); -AL_API void AL_APIENTRY alSourcei(ALuint source, ALenum param, ALint value); -AL_API void AL_APIENTRY alSource3i(ALuint source, ALenum param, ALint value1, ALint value2, ALint value3); -AL_API void AL_APIENTRY alSourceiv(ALuint source, ALenum param, const ALint *values); +/* Set source parameters. */ +AL_API void AL_APIENTRY alSourcef(ALuint source, ALenum param, ALfloat value) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alSource3f(ALuint source, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alSourcefv(ALuint source, ALenum param, const ALfloat *values) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alSourcei(ALuint source, ALenum param, ALint value) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alSource3i(ALuint source, ALenum param, ALint value1, ALint value2, ALint value3) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alSourceiv(ALuint source, ALenum param, const ALint *values) AL_API_NOEXCEPT; -/** Get Source parameters. */ -AL_API void AL_APIENTRY alGetSourcef(ALuint source, ALenum param, ALfloat *value); -AL_API void AL_APIENTRY alGetSource3f(ALuint source, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3); -AL_API void AL_APIENTRY alGetSourcefv(ALuint source, ALenum param, ALfloat *values); -AL_API void AL_APIENTRY alGetSourcei(ALuint source, ALenum param, ALint *value); -AL_API void AL_APIENTRY alGetSource3i(ALuint source, ALenum param, ALint *value1, ALint *value2, ALint *value3); -AL_API void AL_APIENTRY alGetSourceiv(ALuint source, ALenum param, ALint *values); +/* Get source parameters. */ +AL_API void AL_APIENTRY alGetSourcef(ALuint source, ALenum param, ALfloat *value) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetSource3f(ALuint source, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetSourcefv(ALuint source, ALenum param, ALfloat *values) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetSourcei(ALuint source, ALenum param, ALint *value) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetSource3i(ALuint source, ALenum param, ALint *value1, ALint *value2, ALint *value3) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetSourceiv(ALuint source, ALenum param, ALint *values) AL_API_NOEXCEPT; -/** Play, replay, or resume (if paused) a list of Sources */ -AL_API void AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources); -/** Stop a list of Sources */ -AL_API void AL_APIENTRY alSourceStopv(ALsizei n, const ALuint *sources); -/** Rewind a list of Sources */ -AL_API void AL_APIENTRY alSourceRewindv(ALsizei n, const ALuint *sources); -/** Pause a list of Sources */ -AL_API void AL_APIENTRY alSourcePausev(ALsizei n, const ALuint *sources); +/** Play, restart, or resume a source, setting its state to AL_PLAYING. */ +AL_API void AL_APIENTRY alSourcePlay(ALuint source) AL_API_NOEXCEPT; +/** Stop a source, setting its state to AL_STOPPED if playing or paused. */ +AL_API void AL_APIENTRY alSourceStop(ALuint source) AL_API_NOEXCEPT; +/** Rewind a source, setting its state to AL_INITIAL. */ +AL_API void AL_APIENTRY alSourceRewind(ALuint source) AL_API_NOEXCEPT; +/** Pause a source, setting its state to AL_PAUSED if playing. */ +AL_API void AL_APIENTRY alSourcePause(ALuint source) AL_API_NOEXCEPT; -/** Play, replay, or resume a Source */ -AL_API void AL_APIENTRY alSourcePlay(ALuint source); -/** Stop a Source */ -AL_API void AL_APIENTRY alSourceStop(ALuint source); -/** Rewind a Source (set playback postiton to beginning) */ -AL_API void AL_APIENTRY alSourceRewind(ALuint source); -/** Pause a Source */ -AL_API void AL_APIENTRY alSourcePause(ALuint source); +/** Play, restart, or resume a list of sources atomically. */ +AL_API void AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources) AL_API_NOEXCEPT; +/** Stop a list of sources atomically. */ +AL_API void AL_APIENTRY alSourceStopv(ALsizei n, const ALuint *sources) AL_API_NOEXCEPT; +/** Rewind a list of sources atomically. */ +AL_API void AL_APIENTRY alSourceRewindv(ALsizei n, const ALuint *sources) AL_API_NOEXCEPT; +/** Pause a list of sources atomically. */ +AL_API void AL_APIENTRY alSourcePausev(ALsizei n, const ALuint *sources) AL_API_NOEXCEPT; /** Queue buffers onto a source */ -AL_API void AL_APIENTRY alSourceQueueBuffers(ALuint source, ALsizei nb, const ALuint *buffers); +AL_API void AL_APIENTRY alSourceQueueBuffers(ALuint source, ALsizei nb, const ALuint *buffers) AL_API_NOEXCEPT; /** Unqueue processed buffers from a source */ -AL_API void AL_APIENTRY alSourceUnqueueBuffers(ALuint source, ALsizei nb, ALuint *buffers); +AL_API void AL_APIENTRY alSourceUnqueueBuffers(ALuint source, ALsizei nb, ALuint *buffers) AL_API_NOEXCEPT; -/** Create Buffer objects */ -AL_API void AL_APIENTRY alGenBuffers(ALsizei n, ALuint *buffers); -/** Delete Buffer objects */ -AL_API void AL_APIENTRY alDeleteBuffers(ALsizei n, const ALuint *buffers); -/** Verify a handle is a valid Buffer */ -AL_API ALboolean AL_APIENTRY alIsBuffer(ALuint buffer); +/** Create buffer objects */ +AL_API void AL_APIENTRY alGenBuffers(ALsizei n, ALuint *buffers) AL_API_NOEXCEPT; +/** Delete buffer objects */ +AL_API void AL_APIENTRY alDeleteBuffers(ALsizei n, const ALuint *buffers) AL_API_NOEXCEPT; +/** Verify an ID is a valid buffer (including the NULL buffer) */ +AL_API ALboolean AL_APIENTRY alIsBuffer(ALuint buffer) AL_API_NOEXCEPT; -/** Specifies the data to be copied into a buffer */ -AL_API void AL_APIENTRY alBufferData(ALuint buffer, ALenum format, const ALvoid *data, ALsizei size, ALsizei freq); +/** + * Copies data into the buffer, interpreting it using the specified format and + * samplerate. + */ +AL_API void AL_APIENTRY alBufferData(ALuint buffer, ALenum format, const ALvoid *data, ALsizei size, ALsizei samplerate) AL_API_NOEXCEPT; -/** Set Buffer parameters, */ -AL_API void AL_APIENTRY alBufferf(ALuint buffer, ALenum param, ALfloat value); -AL_API void AL_APIENTRY alBuffer3f(ALuint buffer, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3); -AL_API void AL_APIENTRY alBufferfv(ALuint buffer, ALenum param, const ALfloat *values); -AL_API void AL_APIENTRY alBufferi(ALuint buffer, ALenum param, ALint value); -AL_API void AL_APIENTRY alBuffer3i(ALuint buffer, ALenum param, ALint value1, ALint value2, ALint value3); -AL_API void AL_APIENTRY alBufferiv(ALuint buffer, ALenum param, const ALint *values); +/* Set buffer parameters. */ +AL_API void AL_APIENTRY alBufferf(ALuint buffer, ALenum param, ALfloat value) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alBuffer3f(ALuint buffer, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alBufferfv(ALuint buffer, ALenum param, const ALfloat *values) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alBufferi(ALuint buffer, ALenum param, ALint value) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alBuffer3i(ALuint buffer, ALenum param, ALint value1, ALint value2, ALint value3) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alBufferiv(ALuint buffer, ALenum param, const ALint *values) AL_API_NOEXCEPT; -/** Get Buffer parameters. */ -AL_API void AL_APIENTRY alGetBufferf(ALuint buffer, ALenum param, ALfloat *value); -AL_API void AL_APIENTRY alGetBuffer3f(ALuint buffer, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3); -AL_API void AL_APIENTRY alGetBufferfv(ALuint buffer, ALenum param, ALfloat *values); -AL_API void AL_APIENTRY alGetBufferi(ALuint buffer, ALenum param, ALint *value); -AL_API void AL_APIENTRY alGetBuffer3i(ALuint buffer, ALenum param, ALint *value1, ALint *value2, ALint *value3); -AL_API void AL_APIENTRY alGetBufferiv(ALuint buffer, ALenum param, ALint *values); +/* Get buffer parameters. */ +AL_API void AL_APIENTRY alGetBufferf(ALuint buffer, ALenum param, ALfloat *value) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetBuffer3f(ALuint buffer, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetBufferfv(ALuint buffer, ALenum param, ALfloat *values) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetBufferi(ALuint buffer, ALenum param, ALint *value) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetBuffer3i(ALuint buffer, ALenum param, ALint *value1, ALint *value2, ALint *value3) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetBufferiv(ALuint buffer, ALenum param, ALint *values) AL_API_NOEXCEPT; +#endif /* AL_NO_PROTOTYPES */ -/** Pointer-to-function type, useful for dynamically getting AL entry points. */ -typedef void (AL_APIENTRY *LPALENABLE)(ALenum capability); -typedef void (AL_APIENTRY *LPALDISABLE)(ALenum capability); -typedef ALboolean (AL_APIENTRY *LPALISENABLED)(ALenum capability); -typedef const ALchar* (AL_APIENTRY *LPALGETSTRING)(ALenum param); -typedef void (AL_APIENTRY *LPALGETBOOLEANV)(ALenum param, ALboolean *values); -typedef void (AL_APIENTRY *LPALGETINTEGERV)(ALenum param, ALint *values); -typedef void (AL_APIENTRY *LPALGETFLOATV)(ALenum param, ALfloat *values); -typedef void (AL_APIENTRY *LPALGETDOUBLEV)(ALenum param, ALdouble *values); -typedef ALboolean (AL_APIENTRY *LPALGETBOOLEAN)(ALenum param); -typedef ALint (AL_APIENTRY *LPALGETINTEGER)(ALenum param); -typedef ALfloat (AL_APIENTRY *LPALGETFLOAT)(ALenum param); -typedef ALdouble (AL_APIENTRY *LPALGETDOUBLE)(ALenum param); -typedef ALenum (AL_APIENTRY *LPALGETERROR)(void); -typedef ALboolean (AL_APIENTRY *LPALISEXTENSIONPRESENT)(const ALchar *extname); -typedef void* (AL_APIENTRY *LPALGETPROCADDRESS)(const ALchar *fname); -typedef ALenum (AL_APIENTRY *LPALGETENUMVALUE)(const ALchar *ename); -typedef void (AL_APIENTRY *LPALLISTENERF)(ALenum param, ALfloat value); -typedef void (AL_APIENTRY *LPALLISTENER3F)(ALenum param, ALfloat value1, ALfloat value2, ALfloat value3); -typedef void (AL_APIENTRY *LPALLISTENERFV)(ALenum param, const ALfloat *values); -typedef void (AL_APIENTRY *LPALLISTENERI)(ALenum param, ALint value); -typedef void (AL_APIENTRY *LPALLISTENER3I)(ALenum param, ALint value1, ALint value2, ALint value3); -typedef void (AL_APIENTRY *LPALLISTENERIV)(ALenum param, const ALint *values); -typedef void (AL_APIENTRY *LPALGETLISTENERF)(ALenum param, ALfloat *value); -typedef void (AL_APIENTRY *LPALGETLISTENER3F)(ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3); -typedef void (AL_APIENTRY *LPALGETLISTENERFV)(ALenum param, ALfloat *values); -typedef void (AL_APIENTRY *LPALGETLISTENERI)(ALenum param, ALint *value); -typedef void (AL_APIENTRY *LPALGETLISTENER3I)(ALenum param, ALint *value1, ALint *value2, ALint *value3); -typedef void (AL_APIENTRY *LPALGETLISTENERIV)(ALenum param, ALint *values); -typedef void (AL_APIENTRY *LPALGENSOURCES)(ALsizei n, ALuint *sources); -typedef void (AL_APIENTRY *LPALDELETESOURCES)(ALsizei n, const ALuint *sources); -typedef ALboolean (AL_APIENTRY *LPALISSOURCE)(ALuint source); -typedef void (AL_APIENTRY *LPALSOURCEF)(ALuint source, ALenum param, ALfloat value); -typedef void (AL_APIENTRY *LPALSOURCE3F)(ALuint source, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3); -typedef void (AL_APIENTRY *LPALSOURCEFV)(ALuint source, ALenum param, const ALfloat *values); -typedef void (AL_APIENTRY *LPALSOURCEI)(ALuint source, ALenum param, ALint value); -typedef void (AL_APIENTRY *LPALSOURCE3I)(ALuint source, ALenum param, ALint value1, ALint value2, ALint value3); -typedef void (AL_APIENTRY *LPALSOURCEIV)(ALuint source, ALenum param, const ALint *values); -typedef void (AL_APIENTRY *LPALGETSOURCEF)(ALuint source, ALenum param, ALfloat *value); -typedef void (AL_APIENTRY *LPALGETSOURCE3F)(ALuint source, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3); -typedef void (AL_APIENTRY *LPALGETSOURCEFV)(ALuint source, ALenum param, ALfloat *values); -typedef void (AL_APIENTRY *LPALGETSOURCEI)(ALuint source, ALenum param, ALint *value); -typedef void (AL_APIENTRY *LPALGETSOURCE3I)(ALuint source, ALenum param, ALint *value1, ALint *value2, ALint *value3); -typedef void (AL_APIENTRY *LPALGETSOURCEIV)(ALuint source, ALenum param, ALint *values); -typedef void (AL_APIENTRY *LPALSOURCEPLAYV)(ALsizei n, const ALuint *sources); -typedef void (AL_APIENTRY *LPALSOURCESTOPV)(ALsizei n, const ALuint *sources); -typedef void (AL_APIENTRY *LPALSOURCEREWINDV)(ALsizei n, const ALuint *sources); -typedef void (AL_APIENTRY *LPALSOURCEPAUSEV)(ALsizei n, const ALuint *sources); -typedef void (AL_APIENTRY *LPALSOURCEPLAY)(ALuint source); -typedef void (AL_APIENTRY *LPALSOURCESTOP)(ALuint source); -typedef void (AL_APIENTRY *LPALSOURCEREWIND)(ALuint source); -typedef void (AL_APIENTRY *LPALSOURCEPAUSE)(ALuint source); -typedef void (AL_APIENTRY *LPALSOURCEQUEUEBUFFERS)(ALuint source, ALsizei nb, const ALuint *buffers); -typedef void (AL_APIENTRY *LPALSOURCEUNQUEUEBUFFERS)(ALuint source, ALsizei nb, ALuint *buffers); -typedef void (AL_APIENTRY *LPALGENBUFFERS)(ALsizei n, ALuint *buffers); -typedef void (AL_APIENTRY *LPALDELETEBUFFERS)(ALsizei n, const ALuint *buffers); -typedef ALboolean (AL_APIENTRY *LPALISBUFFER)(ALuint buffer); -typedef void (AL_APIENTRY *LPALBUFFERDATA)(ALuint buffer, ALenum format, const ALvoid *data, ALsizei size, ALsizei freq); -typedef void (AL_APIENTRY *LPALBUFFERF)(ALuint buffer, ALenum param, ALfloat value); -typedef void (AL_APIENTRY *LPALBUFFER3F)(ALuint buffer, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3); -typedef void (AL_APIENTRY *LPALBUFFERFV)(ALuint buffer, ALenum param, const ALfloat *values); -typedef void (AL_APIENTRY *LPALBUFFERI)(ALuint buffer, ALenum param, ALint value); -typedef void (AL_APIENTRY *LPALBUFFER3I)(ALuint buffer, ALenum param, ALint value1, ALint value2, ALint value3); -typedef void (AL_APIENTRY *LPALBUFFERIV)(ALuint buffer, ALenum param, const ALint *values); -typedef void (AL_APIENTRY *LPALGETBUFFERF)(ALuint buffer, ALenum param, ALfloat *value); -typedef void (AL_APIENTRY *LPALGETBUFFER3F)(ALuint buffer, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3); -typedef void (AL_APIENTRY *LPALGETBUFFERFV)(ALuint buffer, ALenum param, ALfloat *values); -typedef void (AL_APIENTRY *LPALGETBUFFERI)(ALuint buffer, ALenum param, ALint *value); -typedef void (AL_APIENTRY *LPALGETBUFFER3I)(ALuint buffer, ALenum param, ALint *value1, ALint *value2, ALint *value3); -typedef void (AL_APIENTRY *LPALGETBUFFERIV)(ALuint buffer, ALenum param, ALint *values); -typedef void (AL_APIENTRY *LPALDOPPLERFACTOR)(ALfloat value); -typedef void (AL_APIENTRY *LPALDOPPLERVELOCITY)(ALfloat value); -typedef void (AL_APIENTRY *LPALSPEEDOFSOUND)(ALfloat value); -typedef void (AL_APIENTRY *LPALDISTANCEMODEL)(ALenum distanceModel); +/* Pointer-to-function types, useful for storing dynamically loaded AL entry + * points. + */ +typedef void (AL_APIENTRY *LPALENABLE)(ALenum capability) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALDISABLE)(ALenum capability) AL_API_NOEXCEPT17; +typedef ALboolean (AL_APIENTRY *LPALISENABLED)(ALenum capability) AL_API_NOEXCEPT17; +typedef const ALchar* (AL_APIENTRY *LPALGETSTRING)(ALenum param) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETBOOLEANV)(ALenum param, ALboolean *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETINTEGERV)(ALenum param, ALint *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETFLOATV)(ALenum param, ALfloat *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETDOUBLEV)(ALenum param, ALdouble *values) AL_API_NOEXCEPT17; +typedef ALboolean (AL_APIENTRY *LPALGETBOOLEAN)(ALenum param) AL_API_NOEXCEPT17; +typedef ALint (AL_APIENTRY *LPALGETINTEGER)(ALenum param) AL_API_NOEXCEPT17; +typedef ALfloat (AL_APIENTRY *LPALGETFLOAT)(ALenum param) AL_API_NOEXCEPT17; +typedef ALdouble (AL_APIENTRY *LPALGETDOUBLE)(ALenum param) AL_API_NOEXCEPT17; +typedef ALenum (AL_APIENTRY *LPALGETERROR)(void) AL_API_NOEXCEPT17; +typedef ALboolean (AL_APIENTRY *LPALISEXTENSIONPRESENT)(const ALchar *extname) AL_API_NOEXCEPT17; +typedef void* (AL_APIENTRY *LPALGETPROCADDRESS)(const ALchar *fname) AL_API_NOEXCEPT17; +typedef ALenum (AL_APIENTRY *LPALGETENUMVALUE)(const ALchar *ename) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALLISTENERF)(ALenum param, ALfloat value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALLISTENER3F)(ALenum param, ALfloat value1, ALfloat value2, ALfloat value3) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALLISTENERFV)(ALenum param, const ALfloat *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALLISTENERI)(ALenum param, ALint value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALLISTENER3I)(ALenum param, ALint value1, ALint value2, ALint value3) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALLISTENERIV)(ALenum param, const ALint *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETLISTENERF)(ALenum param, ALfloat *value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETLISTENER3F)(ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETLISTENERFV)(ALenum param, ALfloat *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETLISTENERI)(ALenum param, ALint *value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETLISTENER3I)(ALenum param, ALint *value1, ALint *value2, ALint *value3) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETLISTENERIV)(ALenum param, ALint *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGENSOURCES)(ALsizei n, ALuint *sources) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALDELETESOURCES)(ALsizei n, const ALuint *sources) AL_API_NOEXCEPT17; +typedef ALboolean (AL_APIENTRY *LPALISSOURCE)(ALuint source) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCEF)(ALuint source, ALenum param, ALfloat value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCE3F)(ALuint source, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCEFV)(ALuint source, ALenum param, const ALfloat *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCEI)(ALuint source, ALenum param, ALint value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCE3I)(ALuint source, ALenum param, ALint value1, ALint value2, ALint value3) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCEIV)(ALuint source, ALenum param, const ALint *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETSOURCEF)(ALuint source, ALenum param, ALfloat *value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETSOURCE3F)(ALuint source, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETSOURCEFV)(ALuint source, ALenum param, ALfloat *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETSOURCEI)(ALuint source, ALenum param, ALint *value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETSOURCE3I)(ALuint source, ALenum param, ALint *value1, ALint *value2, ALint *value3) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETSOURCEIV)(ALuint source, ALenum param, ALint *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCEPLAYV)(ALsizei n, const ALuint *sources) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCESTOPV)(ALsizei n, const ALuint *sources) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCEREWINDV)(ALsizei n, const ALuint *sources) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCEPAUSEV)(ALsizei n, const ALuint *sources) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCEPLAY)(ALuint source) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCESTOP)(ALuint source) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCEREWIND)(ALuint source) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCEPAUSE)(ALuint source) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCEQUEUEBUFFERS)(ALuint source, ALsizei nb, const ALuint *buffers) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCEUNQUEUEBUFFERS)(ALuint source, ALsizei nb, ALuint *buffers) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGENBUFFERS)(ALsizei n, ALuint *buffers) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALDELETEBUFFERS)(ALsizei n, const ALuint *buffers) AL_API_NOEXCEPT17; +typedef ALboolean (AL_APIENTRY *LPALISBUFFER)(ALuint buffer) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALBUFFERDATA)(ALuint buffer, ALenum format, const ALvoid *data, ALsizei size, ALsizei samplerate) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALBUFFERF)(ALuint buffer, ALenum param, ALfloat value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALBUFFER3F)(ALuint buffer, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALBUFFERFV)(ALuint buffer, ALenum param, const ALfloat *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALBUFFERI)(ALuint buffer, ALenum param, ALint value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALBUFFER3I)(ALuint buffer, ALenum param, ALint value1, ALint value2, ALint value3) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALBUFFERIV)(ALuint buffer, ALenum param, const ALint *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETBUFFERF)(ALuint buffer, ALenum param, ALfloat *value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETBUFFER3F)(ALuint buffer, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETBUFFERFV)(ALuint buffer, ALenum param, ALfloat *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETBUFFERI)(ALuint buffer, ALenum param, ALint *value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETBUFFER3I)(ALuint buffer, ALenum param, ALint *value1, ALint *value2, ALint *value3) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETBUFFERIV)(ALuint buffer, ALenum param, ALint *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALDOPPLERFACTOR)(ALfloat value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALDOPPLERVELOCITY)(ALfloat value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSPEEDOFSOUND)(ALfloat value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALDISTANCEMODEL)(ALenum distanceModel) AL_API_NOEXCEPT17; -#if defined(__cplusplus) +#ifdef __cplusplus } /* extern "C" */ #endif +/* NOLINTEND */ #endif /* AL_AL_H */ diff --git a/code/AL/alc.h b/code/AL/alc.h index 294e8b33..d048ca04 100644 --- a/code/AL/alc.h +++ b/code/AL/alc.h @@ -1,8 +1,40 @@ #ifndef AL_ALC_H #define AL_ALC_H -#if defined(__cplusplus) +/* NOLINTBEGIN */ +#ifdef __cplusplus extern "C" { + +#ifdef _MSVC_LANG +#define ALC_CPLUSPLUS _MSVC_LANG +#else +#define ALC_CPLUSPLUS __cplusplus +#endif + +#ifndef AL_DISABLE_NOEXCEPT +#if ALC_CPLUSPLUS >= 201103L +#define ALC_API_NOEXCEPT noexcept +#else +#define ALC_API_NOEXCEPT +#endif +#if ALC_CPLUSPLUS >= 201703L +#define ALC_API_NOEXCEPT17 noexcept +#else +#define ALC_API_NOEXCEPT17 +#endif + +#else /* AL_DISABLE_NOEXCEPT */ + +#define ALC_API_NOEXCEPT +#define ALC_API_NOEXCEPT17 +#endif + +#undef ALC_CPLUSPLUS + +#else /* __cplusplus */ + +#define ALC_API_NOEXCEPT +#define ALC_API_NOEXCEPT17 #endif #ifndef ALC_API @@ -15,14 +47,14 @@ extern "C" { #endif #endif -#if defined(_WIN32) +#ifdef _WIN32 #define ALC_APIENTRY __cdecl #else #define ALC_APIENTRY #endif -/** Deprecated macro. */ +/* Deprecated macros. */ #define ALCAPI ALC_API #define ALCAPIENTRY ALC_APIENTRY #define ALC_INVALID 0 @@ -31,9 +63,9 @@ extern "C" { #define ALC_VERSION_0_1 1 /** Opaque device handle */ -typedef struct ALCdevice_struct ALCdevice; +typedef struct ALCdevice ALCdevice; /** Opaque context handle */ -typedef struct ALCcontext_struct ALCcontext; +typedef struct ALCcontext ALCcontext; /** 8-bit boolean */ typedef char ALCboolean; @@ -41,41 +73,41 @@ typedef char ALCboolean; /** character */ typedef char ALCchar; -/** signed 8-bit 2's complement integer */ +/** signed 8-bit integer */ typedef signed char ALCbyte; /** unsigned 8-bit integer */ typedef unsigned char ALCubyte; -/** signed 16-bit 2's complement integer */ +/** signed 16-bit integer */ typedef short ALCshort; /** unsigned 16-bit integer */ typedef unsigned short ALCushort; -/** signed 32-bit 2's complement integer */ +/** signed 32-bit integer */ typedef int ALCint; /** unsigned 32-bit integer */ typedef unsigned int ALCuint; -/** non-negative 32-bit binary integer size */ +/** non-negative 32-bit integer size */ typedef int ALCsizei; -/** enumerated 32-bit value */ +/** 32-bit enumeration value */ typedef int ALCenum; -/** 32-bit IEEE754 floating-point */ +/** 32-bit IEEE-754 floating-point */ typedef float ALCfloat; -/** 64-bit IEEE754 floating-point */ +/** 64-bit IEEE-754 floating-point */ typedef double ALCdouble; /** void type (for opaque pointers only) */ typedef void ALCvoid; -/* Enumerant values begin at column 50. No tabs. */ +/* Enumeration values begin at column 50. Do not use tabs. */ /** Boolean False. */ #define ALC_FALSE 0 @@ -89,7 +121,7 @@ typedef void ALCvoid; /** Context attribute: Hz. */ #define ALC_REFRESH 0x1008 -/** Context attribute: AL_TRUE or AL_FALSE. */ +/** Context attribute: AL_TRUE or AL_FALSE synchronous context? */ #define ALC_SYNC 0x1009 /** Context attribute: requested Mono (3D) Sources. */ @@ -107,30 +139,32 @@ typedef void ALCvoid; /** Invalid context handle. */ #define ALC_INVALID_CONTEXT 0xA002 -/** Invalid enum parameter passed to an ALC call. */ +/** Invalid enumeration passed to an ALC call. */ #define ALC_INVALID_ENUM 0xA003 -/** Invalid value parameter passed to an ALC call. */ +/** Invalid value passed to an ALC call. */ #define ALC_INVALID_VALUE 0xA004 /** Out of memory. */ #define ALC_OUT_OF_MEMORY 0xA005 -/** Runtime ALC version. */ +/** Runtime ALC major version. */ #define ALC_MAJOR_VERSION 0x1000 +/** Runtime ALC minor version. */ #define ALC_MINOR_VERSION 0x1001 -/** Context attribute list properties. */ +/** Context attribute list size. */ #define ALC_ATTRIBUTES_SIZE 0x1002 +/** Context attribute list properties. */ #define ALC_ALL_ATTRIBUTES 0x1003 /** String for the default device specifier. */ #define ALC_DEFAULT_DEVICE_SPECIFIER 0x1004 /** - * String for the given device's specifier. + * Device specifier string. * - * If device handle is NULL, it is instead a null-char separated list of + * If device handle is NULL, it is instead a null-character separated list of * strings of known device specifiers (list ends with an empty string). */ #define ALC_DEVICE_SPECIFIER 0x1005 @@ -141,9 +175,9 @@ typedef void ALCvoid; /** Capture extension */ #define ALC_EXT_CAPTURE 1 /** - * String for the given capture device's specifier. + * Capture device specifier string. * - * If device handle is NULL, it is instead a null-char separated list of + * If device handle is NULL, it is instead a null-character separated list of * strings of known capture device specifiers (list ends with an empty string). */ #define ALC_CAPTURE_DEVICE_SPECIFIER 0x310 @@ -158,80 +192,116 @@ typedef void ALCvoid; /** String for the default extended device specifier. */ #define ALC_DEFAULT_ALL_DEVICES_SPECIFIER 0x1012 /** - * String for the given extended device's specifier. + * Device's extended specifier string. * - * If device handle is NULL, it is instead a null-char separated list of + * If device handle is NULL, it is instead a null-character separated list of * strings of known extended device specifiers (list ends with an empty string). */ #define ALC_ALL_DEVICES_SPECIFIER 0x1013 -/** Context management. */ -ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCint* attrlist); -ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent(ALCcontext *context); -ALC_API void ALC_APIENTRY alcProcessContext(ALCcontext *context); -ALC_API void ALC_APIENTRY alcSuspendContext(ALCcontext *context); -ALC_API void ALC_APIENTRY alcDestroyContext(ALCcontext *context); -ALC_API ALCcontext* ALC_APIENTRY alcGetCurrentContext(void); -ALC_API ALCdevice* ALC_APIENTRY alcGetContextsDevice(ALCcontext *context); +#ifndef ALC_NO_PROTOTYPES +/* Context management. */ -/** Device management. */ -ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *devicename); -ALC_API ALCboolean ALC_APIENTRY alcCloseDevice(ALCdevice *device); +/** Create and attach a context to the given device. */ +ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCint *attrlist) ALC_API_NOEXCEPT; +/** + * Makes the given context the active process-wide context. Passing NULL clears + * the active context. + */ +ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent(ALCcontext *context) ALC_API_NOEXCEPT; +/** Resumes processing updates for the given context. */ +ALC_API void ALC_APIENTRY alcProcessContext(ALCcontext *context) ALC_API_NOEXCEPT; +/** Suspends updates for the given context. */ +ALC_API void ALC_APIENTRY alcSuspendContext(ALCcontext *context) ALC_API_NOEXCEPT; +/** Remove a context from its device and destroys it. */ +ALC_API void ALC_APIENTRY alcDestroyContext(ALCcontext *context) ALC_API_NOEXCEPT; +/** Returns the currently active context. */ +ALC_API ALCcontext* ALC_APIENTRY alcGetCurrentContext(void) ALC_API_NOEXCEPT; +/** Returns the device that a particular context is attached to. */ +ALC_API ALCdevice* ALC_APIENTRY alcGetContextsDevice(ALCcontext *context) ALC_API_NOEXCEPT; +/* Device management. */ + +/** Opens the named playback device. */ +ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *devicename) ALC_API_NOEXCEPT; +/** Closes the given playback device. */ +ALC_API ALCboolean ALC_APIENTRY alcCloseDevice(ALCdevice *device) ALC_API_NOEXCEPT; + +/* Error support. */ + +/** Obtain the most recent Device error. */ +ALC_API ALCenum ALC_APIENTRY alcGetError(ALCdevice *device) ALC_API_NOEXCEPT; + +/* Extension support. */ /** - * Error support. - * - * Obtain the most recent Device error. + * Query for the presence of an extension on the device. Pass a NULL device to + * query a device-inspecific extension. */ -ALC_API ALCenum ALC_APIENTRY alcGetError(ALCdevice *device); +ALC_API ALCboolean ALC_APIENTRY alcIsExtensionPresent(ALCdevice *device, const ALCchar *extname) ALC_API_NOEXCEPT; +/** + * Retrieve the address of a function. Given a non-NULL device, the returned + * function may be device-specific. + */ +ALC_API ALCvoid* ALC_APIENTRY alcGetProcAddress(ALCdevice *device, const ALCchar *funcname) ALC_API_NOEXCEPT; +/** + * Retrieve the value of an enum. Given a non-NULL device, the returned value + * may be device-specific. + */ +ALC_API ALCenum ALC_APIENTRY alcGetEnumValue(ALCdevice *device, const ALCchar *enumname) ALC_API_NOEXCEPT; + +/* Query functions. */ + +/** Returns information about the device, and error strings. */ +ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *device, ALCenum param) ALC_API_NOEXCEPT; +/** Returns information about the device and the version of OpenAL. */ +ALC_API void ALC_APIENTRY alcGetIntegerv(ALCdevice *device, ALCenum param, ALCsizei size, ALCint *values) ALC_API_NOEXCEPT; + +/* Capture functions. */ /** - * Extension support. - * - * Query for the presence of an extension, and obtain any appropriate - * function pointers and enum values. + * Opens the named capture device with the given frequency, format, and buffer + * size. */ -ALC_API ALCboolean ALC_APIENTRY alcIsExtensionPresent(ALCdevice *device, const ALCchar *extname); -ALC_API void* ALC_APIENTRY alcGetProcAddress(ALCdevice *device, const ALCchar *funcname); -ALC_API ALCenum ALC_APIENTRY alcGetEnumValue(ALCdevice *device, const ALCchar *enumname); +ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize) ALC_API_NOEXCEPT; +/** Closes the given capture device. */ +ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice(ALCdevice *device) ALC_API_NOEXCEPT; +/** Starts capturing samples into the device buffer. */ +ALC_API void ALC_APIENTRY alcCaptureStart(ALCdevice *device) ALC_API_NOEXCEPT; +/** Stops capturing samples. Samples in the device buffer remain available. */ +ALC_API void ALC_APIENTRY alcCaptureStop(ALCdevice *device) ALC_API_NOEXCEPT; +/** Reads samples from the device buffer. */ +ALC_API void ALC_APIENTRY alcCaptureSamples(ALCdevice *device, ALCvoid *buffer, ALCsizei samples) ALC_API_NOEXCEPT; +#endif /* ALC_NO_PROTOTYPES */ -/** Query function. */ -ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *device, ALCenum param); -ALC_API void ALC_APIENTRY alcGetIntegerv(ALCdevice *device, ALCenum param, ALCsizei size, ALCint *values); +/* Pointer-to-function types, useful for storing dynamically loaded ALC entry + * points. + */ +typedef ALCcontext* (ALC_APIENTRY *LPALCCREATECONTEXT)(ALCdevice *device, const ALCint *attrlist) ALC_API_NOEXCEPT17; +typedef ALCboolean (ALC_APIENTRY *LPALCMAKECONTEXTCURRENT)(ALCcontext *context) ALC_API_NOEXCEPT17; +typedef void (ALC_APIENTRY *LPALCPROCESSCONTEXT)(ALCcontext *context) ALC_API_NOEXCEPT17; +typedef void (ALC_APIENTRY *LPALCSUSPENDCONTEXT)(ALCcontext *context) ALC_API_NOEXCEPT17; +typedef void (ALC_APIENTRY *LPALCDESTROYCONTEXT)(ALCcontext *context) ALC_API_NOEXCEPT17; +typedef ALCcontext* (ALC_APIENTRY *LPALCGETCURRENTCONTEXT)(void) ALC_API_NOEXCEPT17; +typedef ALCdevice* (ALC_APIENTRY *LPALCGETCONTEXTSDEVICE)(ALCcontext *context) ALC_API_NOEXCEPT17; +typedef ALCdevice* (ALC_APIENTRY *LPALCOPENDEVICE)(const ALCchar *devicename) ALC_API_NOEXCEPT17; +typedef ALCboolean (ALC_APIENTRY *LPALCCLOSEDEVICE)(ALCdevice *device) ALC_API_NOEXCEPT17; +typedef ALCenum (ALC_APIENTRY *LPALCGETERROR)(ALCdevice *device) ALC_API_NOEXCEPT17; +typedef ALCboolean (ALC_APIENTRY *LPALCISEXTENSIONPRESENT)(ALCdevice *device, const ALCchar *extname) ALC_API_NOEXCEPT17; +typedef ALCvoid* (ALC_APIENTRY *LPALCGETPROCADDRESS)(ALCdevice *device, const ALCchar *funcname) ALC_API_NOEXCEPT17; +typedef ALCenum (ALC_APIENTRY *LPALCGETENUMVALUE)(ALCdevice *device, const ALCchar *enumname) ALC_API_NOEXCEPT17; +typedef const ALCchar* (ALC_APIENTRY *LPALCGETSTRING)(ALCdevice *device, ALCenum param) ALC_API_NOEXCEPT17; +typedef void (ALC_APIENTRY *LPALCGETINTEGERV)(ALCdevice *device, ALCenum param, ALCsizei size, ALCint *values) ALC_API_NOEXCEPT17; +typedef ALCdevice* (ALC_APIENTRY *LPALCCAPTUREOPENDEVICE)(const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize) ALC_API_NOEXCEPT17; +typedef ALCboolean (ALC_APIENTRY *LPALCCAPTURECLOSEDEVICE)(ALCdevice *device) ALC_API_NOEXCEPT17; +typedef void (ALC_APIENTRY *LPALCCAPTURESTART)(ALCdevice *device) ALC_API_NOEXCEPT17; +typedef void (ALC_APIENTRY *LPALCCAPTURESTOP)(ALCdevice *device) ALC_API_NOEXCEPT17; +typedef void (ALC_APIENTRY *LPALCCAPTURESAMPLES)(ALCdevice *device, ALCvoid *buffer, ALCsizei samples) ALC_API_NOEXCEPT17; -/** Capture function. */ -ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize); -ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice(ALCdevice *device); -ALC_API void ALC_APIENTRY alcCaptureStart(ALCdevice *device); -ALC_API void ALC_APIENTRY alcCaptureStop(ALCdevice *device); -ALC_API void ALC_APIENTRY alcCaptureSamples(ALCdevice *device, ALCvoid *buffer, ALCsizei samples); - -/** Pointer-to-function type, useful for dynamically getting ALC entry points. */ -typedef ALCcontext* (ALC_APIENTRY *LPALCCREATECONTEXT)(ALCdevice *device, const ALCint *attrlist); -typedef ALCboolean (ALC_APIENTRY *LPALCMAKECONTEXTCURRENT)(ALCcontext *context); -typedef void (ALC_APIENTRY *LPALCPROCESSCONTEXT)(ALCcontext *context); -typedef void (ALC_APIENTRY *LPALCSUSPENDCONTEXT)(ALCcontext *context); -typedef void (ALC_APIENTRY *LPALCDESTROYCONTEXT)(ALCcontext *context); -typedef ALCcontext* (ALC_APIENTRY *LPALCGETCURRENTCONTEXT)(void); -typedef ALCdevice* (ALC_APIENTRY *LPALCGETCONTEXTSDEVICE)(ALCcontext *context); -typedef ALCdevice* (ALC_APIENTRY *LPALCOPENDEVICE)(const ALCchar *devicename); -typedef ALCboolean (ALC_APIENTRY *LPALCCLOSEDEVICE)(ALCdevice *device); -typedef ALCenum (ALC_APIENTRY *LPALCGETERROR)(ALCdevice *device); -typedef ALCboolean (ALC_APIENTRY *LPALCISEXTENSIONPRESENT)(ALCdevice *device, const ALCchar *extname); -typedef void* (ALC_APIENTRY *LPALCGETPROCADDRESS)(ALCdevice *device, const ALCchar *funcname); -typedef ALCenum (ALC_APIENTRY *LPALCGETENUMVALUE)(ALCdevice *device, const ALCchar *enumname); -typedef const ALCchar* (ALC_APIENTRY *LPALCGETSTRING)(ALCdevice *device, ALCenum param); -typedef void (ALC_APIENTRY *LPALCGETINTEGERV)(ALCdevice *device, ALCenum param, ALCsizei size, ALCint *values); -typedef ALCdevice* (ALC_APIENTRY *LPALCCAPTUREOPENDEVICE)(const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize); -typedef ALCboolean (ALC_APIENTRY *LPALCCAPTURECLOSEDEVICE)(ALCdevice *device); -typedef void (ALC_APIENTRY *LPALCCAPTURESTART)(ALCdevice *device); -typedef void (ALC_APIENTRY *LPALCCAPTURESTOP)(ALCdevice *device); -typedef void (ALC_APIENTRY *LPALCCAPTURESAMPLES)(ALCdevice *device, ALCvoid *buffer, ALCsizei samples); - -#if defined(__cplusplus) -} +#ifdef __cplusplus +} /* extern "C" */ #endif +/* NOLINTEND */ #endif /* AL_ALC_H */ diff --git a/code/AL/alext.h b/code/AL/alext.h index 0447f2bb..3908e194 100644 --- a/code/AL/alext.h +++ b/code/AL/alext.h @@ -1,38 +1,22 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 2008 by authors. - * 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 Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - #ifndef AL_ALEXT_H #define AL_ALEXT_H +/* NOLINTBEGIN */ #include -/* Define int64_t and uint64_t types */ -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#include -#elif defined(_WIN32) && defined(__GNUC__) +/* Define int64 and uint64 types */ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ + (defined(__cplusplus) && __cplusplus >= 201103L) #include +typedef int64_t _alsoft_int64_t; +typedef uint64_t _alsoft_uint64_t; #elif defined(_WIN32) -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; +typedef __int64 _alsoft_int64_t; +typedef unsigned __int64 _alsoft_uint64_t; #else /* Fallback if nothing above works */ -#include +#include +typedef int64_t _alsoft_int64_t; +typedef uint64_t _alsoft_uint64_t; #endif #include "alc.h" @@ -42,6 +26,8 @@ typedef unsigned __int64 uint64_t; extern "C" { #endif +struct _GUID; + #ifndef AL_LOKI_IMA_ADPCM_format #define AL_LOKI_IMA_ADPCM_format 1 #define AL_FORMAT_IMA_ADPCM_MONO16_EXT 0x10000 @@ -97,6 +83,31 @@ extern "C" { #ifndef AL_EXT_MCFORMATS #define AL_EXT_MCFORMATS 1 +/* Provides support for surround sound buffer formats with 8, 16, and 32-bit + * samples. + * + * QUAD8: Unsigned 8-bit, Quadraphonic (Front Left, Front Right, Rear Left, + * Rear Right). + * QUAD16: Signed 16-bit, Quadraphonic. + * QUAD32: 32-bit float, Quadraphonic. + * REAR8: Unsigned 8-bit, Rear Stereo (Rear Left, Rear Right). + * REAR16: Signed 16-bit, Rear Stereo. + * REAR32: 32-bit float, Rear Stereo. + * 51CHN8: Unsigned 8-bit, 5.1 Surround (Front Left, Front Right, Front Center, + * LFE, Side Left, Side Right). Note that some audio systems may label + * 5.1's Side channels as Rear or Surround; they are equivalent for the + * purposes of this extension. + * 51CHN16: Signed 16-bit, 5.1 Surround. + * 51CHN32: 32-bit float, 5.1 Surround. + * 61CHN8: Unsigned 8-bit, 6.1 Surround (Front Left, Front Right, Front Center, + * LFE, Rear Center, Side Left, Side Right). + * 61CHN16: Signed 16-bit, 6.1 Surround. + * 61CHN32: 32-bit float, 6.1 Surround. + * 71CHN8: Unsigned 8-bit, 7.1 Surround (Front Left, Front Right, Front Center, + * LFE, Rear Left, Rear Right, Side Left, Side Right). + * 71CHN16: Signed 16-bit, 7.1 Surround. + * 71CHN32: 32-bit float, 7.1 Surround. + */ #define AL_FORMAT_QUAD8 0x1204 #define AL_FORMAT_QUAD16 0x1205 #define AL_FORMAT_QUAD32 0x1206 @@ -133,9 +144,9 @@ extern "C" { #ifndef AL_EXT_STATIC_BUFFER #define AL_EXT_STATIC_BUFFER 1 -typedef ALvoid (AL_APIENTRY*PFNALBUFFERDATASTATICPROC)(const ALint,ALenum,ALvoid*,ALsizei,ALsizei); +typedef void (AL_APIENTRY*PFNALBUFFERDATASTATICPROC)(const ALuint,ALenum,ALvoid*,ALsizei,ALsizei) AL_API_NOEXCEPT17; #ifdef AL_ALEXT_PROTOTYPES -AL_API ALvoid AL_APIENTRY alBufferDataStatic(const ALint buffer, ALenum format, ALvoid *data, ALsizei len, ALsizei freq); +void AL_APIENTRY alBufferDataStatic(const ALuint buffer, ALenum format, ALvoid *data, ALsizei size, ALsizei freq) AL_API_NOEXCEPT; #endif #endif @@ -151,11 +162,11 @@ AL_API ALvoid AL_APIENTRY alBufferDataStatic(const ALint buffer, ALenum format, #ifndef ALC_EXT_thread_local_context #define ALC_EXT_thread_local_context 1 -typedef ALCboolean (ALC_APIENTRY*PFNALCSETTHREADCONTEXTPROC)(ALCcontext *context); -typedef ALCcontext* (ALC_APIENTRY*PFNALCGETTHREADCONTEXTPROC)(void); +typedef ALCboolean (ALC_APIENTRY*PFNALCSETTHREADCONTEXTPROC)(ALCcontext *context) ALC_API_NOEXCEPT17; +typedef ALCcontext* (ALC_APIENTRY*PFNALCGETTHREADCONTEXTPROC)(void) ALC_API_NOEXCEPT17; #ifdef AL_ALEXT_PROTOTYPES -ALC_API ALCboolean ALC_APIENTRY alcSetThreadContext(ALCcontext *context); -ALC_API ALCcontext* ALC_APIENTRY alcGetThreadContext(void); +ALC_API ALCboolean ALC_APIENTRY alcSetThreadContext(ALCcontext *context) ALC_API_NOEXCEPT; +ALC_API ALCcontext* ALC_APIENTRY alcGetThreadContext(void) ALC_API_NOEXCEPT; #endif #endif @@ -168,9 +179,9 @@ ALC_API ALCcontext* ALC_APIENTRY alcGetThreadContext(void); #define AL_SOFT_buffer_sub_data 1 #define AL_BYTE_RW_OFFSETS_SOFT 0x1031 #define AL_SAMPLE_RW_OFFSETS_SOFT 0x1032 -typedef ALvoid (AL_APIENTRY*PFNALBUFFERSUBDATASOFTPROC)(ALuint,ALenum,const ALvoid*,ALsizei,ALsizei); +typedef void (AL_APIENTRY*PFNALBUFFERSUBDATASOFTPROC)(ALuint,ALenum,const ALvoid*,ALsizei,ALsizei) AL_API_NOEXCEPT17; #ifdef AL_ALEXT_PROTOTYPES -AL_API ALvoid AL_APIENTRY alBufferSubDataSOFT(ALuint buffer,ALenum format,const ALvoid *data,ALsizei offset,ALsizei length); +AL_API void AL_APIENTRY alBufferSubDataSOFT(ALuint buffer,ALenum format,const ALvoid *data,ALsizei offset,ALsizei length) AL_API_NOEXCEPT; #endif #endif @@ -187,12 +198,12 @@ AL_API ALvoid AL_APIENTRY alBufferSubDataSOFT(ALuint buffer,ALenum format,const #define AL_FOLDBACK_EVENT_STOP 0x4113 #define AL_FOLDBACK_MODE_MONO 0x4101 #define AL_FOLDBACK_MODE_STEREO 0x4102 -typedef void (AL_APIENTRY*LPALFOLDBACKCALLBACK)(ALenum,ALsizei); -typedef void (AL_APIENTRY*LPALREQUESTFOLDBACKSTART)(ALenum,ALsizei,ALsizei,ALfloat*,LPALFOLDBACKCALLBACK); -typedef void (AL_APIENTRY*LPALREQUESTFOLDBACKSTOP)(void); +typedef void (AL_APIENTRY*LPALFOLDBACKCALLBACK)(ALenum,ALsizei) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALREQUESTFOLDBACKSTART)(ALenum,ALsizei,ALsizei,ALfloat*,LPALFOLDBACKCALLBACK) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALREQUESTFOLDBACKSTOP)(void) AL_API_NOEXCEPT17; #ifdef AL_ALEXT_PROTOTYPES -AL_API void AL_APIENTRY alRequestFoldbackStart(ALenum mode,ALsizei count,ALsizei length,ALfloat *mem,LPALFOLDBACKCALLBACK callback); -AL_API void AL_APIENTRY alRequestFoldbackStop(void); +AL_API void AL_APIENTRY alRequestFoldbackStart(ALenum mode,ALsizei count,ALsizei length,ALfloat *mem,LPALFOLDBACKCALLBACK callback) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alRequestFoldbackStop(void) AL_API_NOEXCEPT; #endif #endif @@ -255,15 +266,15 @@ AL_API void AL_APIENTRY alRequestFoldbackStop(void); #define AL_SAMPLE_LENGTH_SOFT 0x200A #define AL_SEC_LENGTH_SOFT 0x200B -typedef void (AL_APIENTRY*LPALBUFFERSAMPLESSOFT)(ALuint,ALuint,ALenum,ALsizei,ALenum,ALenum,const ALvoid*); -typedef void (AL_APIENTRY*LPALBUFFERSUBSAMPLESSOFT)(ALuint,ALsizei,ALsizei,ALenum,ALenum,const ALvoid*); -typedef void (AL_APIENTRY*LPALGETBUFFERSAMPLESSOFT)(ALuint,ALsizei,ALsizei,ALenum,ALenum,ALvoid*); -typedef ALboolean (AL_APIENTRY*LPALISBUFFERFORMATSUPPORTEDSOFT)(ALenum); +typedef void (AL_APIENTRY*LPALBUFFERSAMPLESSOFT)(ALuint,ALuint,ALenum,ALsizei,ALenum,ALenum,const ALvoid*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALBUFFERSUBSAMPLESSOFT)(ALuint,ALsizei,ALsizei,ALenum,ALenum,const ALvoid*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALGETBUFFERSAMPLESSOFT)(ALuint,ALsizei,ALsizei,ALenum,ALenum,ALvoid*) AL_API_NOEXCEPT17; +typedef ALboolean (AL_APIENTRY*LPALISBUFFERFORMATSUPPORTEDSOFT)(ALenum) AL_API_NOEXCEPT17; #ifdef AL_ALEXT_PROTOTYPES -AL_API void AL_APIENTRY alBufferSamplesSOFT(ALuint buffer, ALuint samplerate, ALenum internalformat, ALsizei samples, ALenum channels, ALenum type, const ALvoid *data); -AL_API void AL_APIENTRY alBufferSubSamplesSOFT(ALuint buffer, ALsizei offset, ALsizei samples, ALenum channels, ALenum type, const ALvoid *data); -AL_API void AL_APIENTRY alGetBufferSamplesSOFT(ALuint buffer, ALsizei offset, ALsizei samples, ALenum channels, ALenum type, ALvoid *data); -AL_API ALboolean AL_APIENTRY alIsBufferFormatSupportedSOFT(ALenum format); +AL_API void AL_APIENTRY alBufferSamplesSOFT(ALuint buffer, ALuint samplerate, ALenum internalformat, ALsizei samples, ALenum channels, ALenum type, const ALvoid *data) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alBufferSubSamplesSOFT(ALuint buffer, ALsizei offset, ALsizei samples, ALenum channels, ALenum type, const ALvoid *data) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetBufferSamplesSOFT(ALuint buffer, ALsizei offset, ALsizei samples, ALenum channels, ALenum type, ALvoid *data) AL_API_NOEXCEPT; +AL_API ALboolean AL_APIENTRY alIsBufferFormatSupportedSOFT(ALenum format) AL_API_NOEXCEPT; #endif #endif @@ -294,13 +305,13 @@ AL_API ALboolean AL_APIENTRY alIsBufferFormatSupportedSOFT(ALenum format); #define ALC_6POINT1_SOFT 0x1505 #define ALC_7POINT1_SOFT 0x1506 -typedef ALCdevice* (ALC_APIENTRY*LPALCLOOPBACKOPENDEVICESOFT)(const ALCchar*); -typedef ALCboolean (ALC_APIENTRY*LPALCISRENDERFORMATSUPPORTEDSOFT)(ALCdevice*,ALCsizei,ALCenum,ALCenum); -typedef void (ALC_APIENTRY*LPALCRENDERSAMPLESSOFT)(ALCdevice*,ALCvoid*,ALCsizei); +typedef ALCdevice* (ALC_APIENTRY*LPALCLOOPBACKOPENDEVICESOFT)(const ALCchar*) ALC_API_NOEXCEPT17; +typedef ALCboolean (ALC_APIENTRY*LPALCISRENDERFORMATSUPPORTEDSOFT)(ALCdevice*,ALCsizei,ALCenum,ALCenum) ALC_API_NOEXCEPT17; +typedef void (ALC_APIENTRY*LPALCRENDERSAMPLESSOFT)(ALCdevice*,ALCvoid*,ALCsizei) ALC_API_NOEXCEPT17; #ifdef AL_ALEXT_PROTOTYPES -ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceName); -ALC_API ALCboolean ALC_APIENTRY alcIsRenderFormatSupportedSOFT(ALCdevice *device, ALCsizei freq, ALCenum channels, ALCenum type); -ALC_API void ALC_APIENTRY alcRenderSamplesSOFT(ALCdevice *device, ALCvoid *buffer, ALCsizei samples); +ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceName) AL_API_NOEXCEPT; +ALC_API ALCboolean ALC_APIENTRY alcIsRenderFormatSupportedSOFT(ALCdevice *device, ALCsizei freq, ALCenum channels, ALCenum type) AL_API_NOEXCEPT; +ALC_API void ALC_APIENTRY alcRenderSamplesSOFT(ALCdevice *device, ALCvoid *buffer, ALCsizei samples) AL_API_NOEXCEPT; #endif #endif @@ -318,38 +329,764 @@ ALC_API void ALC_APIENTRY alcRenderSamplesSOFT(ALCdevice *device, ALCvoid *buffe #define AL_SOFT_source_latency 1 #define AL_SAMPLE_OFFSET_LATENCY_SOFT 0x1200 #define AL_SEC_OFFSET_LATENCY_SOFT 0x1201 -typedef int64_t ALint64SOFT; -typedef uint64_t ALuint64SOFT; -typedef void (AL_APIENTRY*LPALSOURCEDSOFT)(ALuint,ALenum,ALdouble); -typedef void (AL_APIENTRY*LPALSOURCE3DSOFT)(ALuint,ALenum,ALdouble,ALdouble,ALdouble); -typedef void (AL_APIENTRY*LPALSOURCEDVSOFT)(ALuint,ALenum,const ALdouble*); -typedef void (AL_APIENTRY*LPALGETSOURCEDSOFT)(ALuint,ALenum,ALdouble*); -typedef void (AL_APIENTRY*LPALGETSOURCE3DSOFT)(ALuint,ALenum,ALdouble*,ALdouble*,ALdouble*); -typedef void (AL_APIENTRY*LPALGETSOURCEDVSOFT)(ALuint,ALenum,ALdouble*); -typedef void (AL_APIENTRY*LPALSOURCEI64SOFT)(ALuint,ALenum,ALint64SOFT); -typedef void (AL_APIENTRY*LPALSOURCE3I64SOFT)(ALuint,ALenum,ALint64SOFT,ALint64SOFT,ALint64SOFT); -typedef void (AL_APIENTRY*LPALSOURCEI64VSOFT)(ALuint,ALenum,const ALint64SOFT*); -typedef void (AL_APIENTRY*LPALGETSOURCEI64SOFT)(ALuint,ALenum,ALint64SOFT*); -typedef void (AL_APIENTRY*LPALGETSOURCE3I64SOFT)(ALuint,ALenum,ALint64SOFT*,ALint64SOFT*,ALint64SOFT*); -typedef void (AL_APIENTRY*LPALGETSOURCEI64VSOFT)(ALuint,ALenum,ALint64SOFT*); +typedef _alsoft_int64_t ALint64SOFT; +typedef _alsoft_uint64_t ALuint64SOFT; +typedef void (AL_APIENTRY*LPALSOURCEDSOFT)(ALuint,ALenum,ALdouble) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALSOURCE3DSOFT)(ALuint,ALenum,ALdouble,ALdouble,ALdouble) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALSOURCEDVSOFT)(ALuint,ALenum,const ALdouble*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALGETSOURCEDSOFT)(ALuint,ALenum,ALdouble*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALGETSOURCE3DSOFT)(ALuint,ALenum,ALdouble*,ALdouble*,ALdouble*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALGETSOURCEDVSOFT)(ALuint,ALenum,ALdouble*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALSOURCEI64SOFT)(ALuint,ALenum,ALint64SOFT) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALSOURCE3I64SOFT)(ALuint,ALenum,ALint64SOFT,ALint64SOFT,ALint64SOFT) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALSOURCEI64VSOFT)(ALuint,ALenum,const ALint64SOFT*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALGETSOURCEI64SOFT)(ALuint,ALenum,ALint64SOFT*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALGETSOURCE3I64SOFT)(ALuint,ALenum,ALint64SOFT*,ALint64SOFT*,ALint64SOFT*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALGETSOURCEI64VSOFT)(ALuint,ALenum,ALint64SOFT*) AL_API_NOEXCEPT17; #ifdef AL_ALEXT_PROTOTYPES -AL_API void AL_APIENTRY alSourcedSOFT(ALuint source, ALenum param, ALdouble value); -AL_API void AL_APIENTRY alSource3dSOFT(ALuint source, ALenum param, ALdouble value1, ALdouble value2, ALdouble value3); -AL_API void AL_APIENTRY alSourcedvSOFT(ALuint source, ALenum param, const ALdouble *values); -AL_API void AL_APIENTRY alGetSourcedSOFT(ALuint source, ALenum param, ALdouble *value); -AL_API void AL_APIENTRY alGetSource3dSOFT(ALuint source, ALenum param, ALdouble *value1, ALdouble *value2, ALdouble *value3); -AL_API void AL_APIENTRY alGetSourcedvSOFT(ALuint source, ALenum param, ALdouble *values); -AL_API void AL_APIENTRY alSourcei64SOFT(ALuint source, ALenum param, ALint64SOFT value); -AL_API void AL_APIENTRY alSource3i64SOFT(ALuint source, ALenum param, ALint64SOFT value1, ALint64SOFT value2, ALint64SOFT value3); -AL_API void AL_APIENTRY alSourcei64vSOFT(ALuint source, ALenum param, const ALint64SOFT *values); -AL_API void AL_APIENTRY alGetSourcei64SOFT(ALuint source, ALenum param, ALint64SOFT *value); -AL_API void AL_APIENTRY alGetSource3i64SOFT(ALuint source, ALenum param, ALint64SOFT *value1, ALint64SOFT *value2, ALint64SOFT *value3); -AL_API void AL_APIENTRY alGetSourcei64vSOFT(ALuint source, ALenum param, ALint64SOFT *values); +AL_API void AL_APIENTRY alSourcedSOFT(ALuint source, ALenum param, ALdouble value) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alSource3dSOFT(ALuint source, ALenum param, ALdouble value1, ALdouble value2, ALdouble value3) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alSourcedvSOFT(ALuint source, ALenum param, const ALdouble *values) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetSourcedSOFT(ALuint source, ALenum param, ALdouble *value) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetSource3dSOFT(ALuint source, ALenum param, ALdouble *value1, ALdouble *value2, ALdouble *value3) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetSourcedvSOFT(ALuint source, ALenum param, ALdouble *values) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alSourcei64SOFT(ALuint source, ALenum param, ALint64SOFT value) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alSource3i64SOFT(ALuint source, ALenum param, ALint64SOFT value1, ALint64SOFT value2, ALint64SOFT value3) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alSourcei64vSOFT(ALuint source, ALenum param, const ALint64SOFT *values) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetSourcei64SOFT(ALuint source, ALenum param, ALint64SOFT *value) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetSource3i64SOFT(ALuint source, ALenum param, ALint64SOFT *value1, ALint64SOFT *value2, ALint64SOFT *value3) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetSourcei64vSOFT(ALuint source, ALenum param, ALint64SOFT *values) AL_API_NOEXCEPT; #endif #endif +#ifndef ALC_EXT_DEFAULT_FILTER_ORDER +#define ALC_EXT_DEFAULT_FILTER_ORDER 1 +#define ALC_DEFAULT_FILTER_ORDER 0x1100 +#endif + +#ifndef AL_SOFT_deferred_updates +#define AL_SOFT_deferred_updates 1 +#define AL_DEFERRED_UPDATES_SOFT 0xC002 +typedef void (AL_APIENTRY*LPALDEFERUPDATESSOFT)(void) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALPROCESSUPDATESSOFT)(void) AL_API_NOEXCEPT17; +#ifdef AL_ALEXT_PROTOTYPES +AL_API void AL_APIENTRY alDeferUpdatesSOFT(void) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alProcessUpdatesSOFT(void) AL_API_NOEXCEPT; +#endif +#endif + +#ifndef AL_SOFT_block_alignment +#define AL_SOFT_block_alignment 1 +#define AL_UNPACK_BLOCK_ALIGNMENT_SOFT 0x200C +#define AL_PACK_BLOCK_ALIGNMENT_SOFT 0x200D +#endif + +#ifndef AL_SOFT_MSADPCM +#define AL_SOFT_MSADPCM 1 +#define AL_FORMAT_MONO_MSADPCM_SOFT 0x1302 +#define AL_FORMAT_STEREO_MSADPCM_SOFT 0x1303 +#endif + +#ifndef AL_SOFT_source_length +#define AL_SOFT_source_length 1 +/*#define AL_BYTE_LENGTH_SOFT 0x2009*/ +/*#define AL_SAMPLE_LENGTH_SOFT 0x200A*/ +/*#define AL_SEC_LENGTH_SOFT 0x200B*/ +#endif + +#ifndef AL_SOFT_buffer_length_query +#define AL_SOFT_buffer_length_query 1 +/*#define AL_BYTE_LENGTH_SOFT 0x2009*/ +/*#define AL_SAMPLE_LENGTH_SOFT 0x200A*/ +/*#define AL_SEC_LENGTH_SOFT 0x200B*/ +#endif + +#ifndef ALC_SOFT_pause_device +#define ALC_SOFT_pause_device 1 +typedef void (ALC_APIENTRY*LPALCDEVICEPAUSESOFT)(ALCdevice *device) ALC_API_NOEXCEPT17; +typedef void (ALC_APIENTRY*LPALCDEVICERESUMESOFT)(ALCdevice *device) ALC_API_NOEXCEPT17; +#ifdef AL_ALEXT_PROTOTYPES +ALC_API void ALC_APIENTRY alcDevicePauseSOFT(ALCdevice *device) ALC_API_NOEXCEPT; +ALC_API void ALC_APIENTRY alcDeviceResumeSOFT(ALCdevice *device) ALC_API_NOEXCEPT; +#endif +#endif + +#ifndef AL_EXT_BFORMAT +#define AL_EXT_BFORMAT 1 +/* Provides support for B-Format ambisonic buffers (first-order, FuMa scaling + * and layout). + * + * BFORMAT2D_8: Unsigned 8-bit, 3-channel non-periphonic (WXY). + * BFORMAT2D_16: Signed 16-bit, 3-channel non-periphonic (WXY). + * BFORMAT2D_FLOAT32: 32-bit float, 3-channel non-periphonic (WXY). + * BFORMAT3D_8: Unsigned 8-bit, 4-channel periphonic (WXYZ). + * BFORMAT3D_16: Signed 16-bit, 4-channel periphonic (WXYZ). + * BFORMAT3D_FLOAT32: 32-bit float, 4-channel periphonic (WXYZ). + */ +#define AL_FORMAT_BFORMAT2D_8 0x20021 +#define AL_FORMAT_BFORMAT2D_16 0x20022 +#define AL_FORMAT_BFORMAT2D_FLOAT32 0x20023 +#define AL_FORMAT_BFORMAT3D_8 0x20031 +#define AL_FORMAT_BFORMAT3D_16 0x20032 +#define AL_FORMAT_BFORMAT3D_FLOAT32 0x20033 +#endif + +#ifndef AL_EXT_MULAW_BFORMAT +#define AL_EXT_MULAW_BFORMAT 1 +#define AL_FORMAT_BFORMAT2D_MULAW 0x10031 +#define AL_FORMAT_BFORMAT3D_MULAW 0x10032 +#endif + +#ifndef ALC_SOFT_HRTF +#define ALC_SOFT_HRTF 1 +#define ALC_HRTF_SOFT 0x1992 +#define ALC_DONT_CARE_SOFT 0x0002 +#define ALC_HRTF_STATUS_SOFT 0x1993 +#define ALC_HRTF_DISABLED_SOFT 0x0000 +#define ALC_HRTF_ENABLED_SOFT 0x0001 +#define ALC_HRTF_DENIED_SOFT 0x0002 +#define ALC_HRTF_REQUIRED_SOFT 0x0003 +#define ALC_HRTF_HEADPHONES_DETECTED_SOFT 0x0004 +#define ALC_HRTF_UNSUPPORTED_FORMAT_SOFT 0x0005 +#define ALC_NUM_HRTF_SPECIFIERS_SOFT 0x1994 +#define ALC_HRTF_SPECIFIER_SOFT 0x1995 +#define ALC_HRTF_ID_SOFT 0x1996 +typedef const ALCchar* (ALC_APIENTRY*LPALCGETSTRINGISOFT)(ALCdevice *device, ALCenum paramName, ALCsizei index) ALC_API_NOEXCEPT17; +typedef ALCboolean (ALC_APIENTRY*LPALCRESETDEVICESOFT)(ALCdevice *device, const ALCint *attribs) ALC_API_NOEXCEPT17; +#ifdef AL_ALEXT_PROTOTYPES +ALC_API const ALCchar* ALC_APIENTRY alcGetStringiSOFT(ALCdevice *device, ALCenum paramName, ALCsizei index) ALC_API_NOEXCEPT; +ALC_API ALCboolean ALC_APIENTRY alcResetDeviceSOFT(ALCdevice *device, const ALCint *attribs) ALC_API_NOEXCEPT; +#endif +#endif + +#ifndef AL_SOFT_gain_clamp_ex +#define AL_SOFT_gain_clamp_ex 1 +#define AL_GAIN_LIMIT_SOFT 0x200E +#endif + +#ifndef AL_SOFT_source_resampler +#define AL_SOFT_source_resampler +#define AL_NUM_RESAMPLERS_SOFT 0x1210 +#define AL_DEFAULT_RESAMPLER_SOFT 0x1211 +#define AL_SOURCE_RESAMPLER_SOFT 0x1212 +#define AL_RESAMPLER_NAME_SOFT 0x1213 +typedef const ALchar* (AL_APIENTRY*LPALGETSTRINGISOFT)(ALenum pname, ALsizei index) AL_API_NOEXCEPT17; +#ifdef AL_ALEXT_PROTOTYPES +AL_API const ALchar* AL_APIENTRY alGetStringiSOFT(ALenum pname, ALsizei index) AL_API_NOEXCEPT; +#endif +#endif + +#ifndef AL_SOFT_source_spatialize +#define AL_SOFT_source_spatialize +#define AL_SOURCE_SPATIALIZE_SOFT 0x1214 +#define AL_AUTO_SOFT 0x0002 +#endif + +#ifndef ALC_SOFT_output_limiter +#define ALC_SOFT_output_limiter +#define ALC_OUTPUT_LIMITER_SOFT 0x199A +#endif + +#ifndef ALC_SOFT_device_clock +#define ALC_SOFT_device_clock 1 +typedef _alsoft_int64_t ALCint64SOFT; +typedef _alsoft_uint64_t ALCuint64SOFT; +#define ALC_DEVICE_CLOCK_SOFT 0x1600 +#define ALC_DEVICE_LATENCY_SOFT 0x1601 +#define ALC_DEVICE_CLOCK_LATENCY_SOFT 0x1602 +#define AL_SAMPLE_OFFSET_CLOCK_SOFT 0x1202 +#define AL_SEC_OFFSET_CLOCK_SOFT 0x1203 +typedef void (ALC_APIENTRY*LPALCGETINTEGER64VSOFT)(ALCdevice *device, ALCenum pname, ALsizei size, ALCint64SOFT *values) ALC_API_NOEXCEPT17; +#ifdef AL_ALEXT_PROTOTYPES +ALC_API void ALC_APIENTRY alcGetInteger64vSOFT(ALCdevice *device, ALCenum pname, ALsizei size, ALCint64SOFT *values) ALC_API_NOEXCEPT; +#endif +#endif + +#ifndef AL_SOFT_direct_channels_remix +#define AL_SOFT_direct_channels_remix 1 +#define AL_DROP_UNMATCHED_SOFT 0x0001 +#define AL_REMIX_UNMATCHED_SOFT 0x0002 +#endif + +#ifndef AL_SOFT_bformat_ex +#define AL_SOFT_bformat_ex 1 +#define AL_AMBISONIC_LAYOUT_SOFT 0x1997 +#define AL_AMBISONIC_SCALING_SOFT 0x1998 + +/* Ambisonic layouts */ +#define AL_FUMA_SOFT 0x0000 +#define AL_ACN_SOFT 0x0001 + +/* Ambisonic scalings (normalization) */ +/*#define AL_FUMA_SOFT*/ +#define AL_SN3D_SOFT 0x0001 +#define AL_N3D_SOFT 0x0002 +#endif + +#ifndef ALC_SOFT_loopback_bformat +#define ALC_SOFT_loopback_bformat 1 +#define ALC_AMBISONIC_LAYOUT_SOFT 0x1997 +#define ALC_AMBISONIC_SCALING_SOFT 0x1998 +#define ALC_AMBISONIC_ORDER_SOFT 0x1999 +#define ALC_MAX_AMBISONIC_ORDER_SOFT 0x199B + +#define ALC_BFORMAT3D_SOFT 0x1507 + +/* Ambisonic layouts */ +#define ALC_FUMA_SOFT 0x0000 +#define ALC_ACN_SOFT 0x0001 + +/* Ambisonic scalings (normalization) */ +/*#define ALC_FUMA_SOFT*/ +#define ALC_SN3D_SOFT 0x0001 +#define ALC_N3D_SOFT 0x0002 +#endif + +#ifndef AL_SOFT_effect_target +#define AL_SOFT_effect_target +#define AL_EFFECTSLOT_TARGET_SOFT 0x199C +#endif + +#ifndef AL_SOFT_events +#define AL_SOFT_events 1 +#define AL_EVENT_CALLBACK_FUNCTION_SOFT 0x19A2 +#define AL_EVENT_CALLBACK_USER_PARAM_SOFT 0x19A3 +#define AL_EVENT_TYPE_BUFFER_COMPLETED_SOFT 0x19A4 +#define AL_EVENT_TYPE_SOURCE_STATE_CHANGED_SOFT 0x19A5 +#define AL_EVENT_TYPE_DISCONNECTED_SOFT 0x19A6 +typedef void (AL_APIENTRY*ALEVENTPROCSOFT)(ALenum eventType, ALuint object, ALuint param, + ALsizei length, const ALchar *message, void *userParam) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALEVENTCONTROLSOFT)(ALsizei count, const ALenum *types, ALboolean enable) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALEVENTCALLBACKSOFT)(ALEVENTPROCSOFT callback, void *userParam) AL_API_NOEXCEPT17; +typedef void* (AL_APIENTRY*LPALGETPOINTERSOFT)(ALenum pname) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALGETPOINTERVSOFT)(ALenum pname, void **values) AL_API_NOEXCEPT17; +#ifdef AL_ALEXT_PROTOTYPES +AL_API void AL_APIENTRY alEventControlSOFT(ALsizei count, const ALenum *types, ALboolean enable) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alEventCallbackSOFT(ALEVENTPROCSOFT callback, void *userParam) AL_API_NOEXCEPT; +AL_API void* AL_APIENTRY alGetPointerSOFT(ALenum pname) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetPointervSOFT(ALenum pname, void **values) AL_API_NOEXCEPT; +#endif +#endif + +#ifndef ALC_SOFT_reopen_device +#define ALC_SOFT_reopen_device +typedef ALCboolean (ALC_APIENTRY*LPALCREOPENDEVICESOFT)(ALCdevice *device, + const ALCchar *deviceName, const ALCint *attribs) ALC_API_NOEXCEPT17; +#ifdef AL_ALEXT_PROTOTYPES +ALCboolean ALC_APIENTRY alcReopenDeviceSOFT(ALCdevice *device, const ALCchar *deviceName, + const ALCint *attribs) ALC_API_NOEXCEPT; +#endif +#endif + +#ifndef AL_SOFT_callback_buffer +#define AL_SOFT_callback_buffer +#define AL_BUFFER_CALLBACK_FUNCTION_SOFT 0x19A0 +#define AL_BUFFER_CALLBACK_USER_PARAM_SOFT 0x19A1 +typedef ALsizei (AL_APIENTRY*ALBUFFERCALLBACKTYPESOFT)(ALvoid *userptr, ALvoid *sampledata, ALsizei numbytes) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALBUFFERCALLBACKSOFT)(ALuint buffer, ALenum format, ALsizei freq, ALBUFFERCALLBACKTYPESOFT callback, ALvoid *userptr) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALGETBUFFERPTRSOFT)(ALuint buffer, ALenum param, ALvoid **value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALGETBUFFER3PTRSOFT)(ALuint buffer, ALenum param, ALvoid **value1, ALvoid **value2, ALvoid **value3) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALGETBUFFERPTRVSOFT)(ALuint buffer, ALenum param, ALvoid **values) AL_API_NOEXCEPT17; +#ifdef AL_ALEXT_PROTOTYPES +AL_API void AL_APIENTRY alBufferCallbackSOFT(ALuint buffer, ALenum format, ALsizei freq, ALBUFFERCALLBACKTYPESOFT callback, ALvoid *userptr) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetBufferPtrSOFT(ALuint buffer, ALenum param, ALvoid **ptr) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetBuffer3PtrSOFT(ALuint buffer, ALenum param, ALvoid **ptr0, ALvoid **ptr1, ALvoid **ptr2) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetBufferPtrvSOFT(ALuint buffer, ALenum param, ALvoid **ptr) AL_API_NOEXCEPT; +#endif +#endif + +#ifndef AL_SOFT_UHJ +#define AL_SOFT_UHJ +#define AL_FORMAT_UHJ2CHN8_SOFT 0x19A2 +#define AL_FORMAT_UHJ2CHN16_SOFT 0x19A3 +#define AL_FORMAT_UHJ2CHN_FLOAT32_SOFT 0x19A4 +#define AL_FORMAT_UHJ3CHN8_SOFT 0x19A5 +#define AL_FORMAT_UHJ3CHN16_SOFT 0x19A6 +#define AL_FORMAT_UHJ3CHN_FLOAT32_SOFT 0x19A7 +#define AL_FORMAT_UHJ4CHN8_SOFT 0x19A8 +#define AL_FORMAT_UHJ4CHN16_SOFT 0x19A9 +#define AL_FORMAT_UHJ4CHN_FLOAT32_SOFT 0x19AA + +#define AL_STEREO_MODE_SOFT 0x19B0 +#define AL_NORMAL_SOFT 0x0000 +#define AL_SUPER_STEREO_SOFT 0x0001 +#define AL_SUPER_STEREO_WIDTH_SOFT 0x19B1 +#endif + +#ifndef AL_SOFT_UHJ_ex +#define AL_SOFT_UHJ_ex +#define AL_FORMAT_UHJ2CHN_MULAW_SOFT 0x19B3 +#define AL_FORMAT_UHJ2CHN_ALAW_SOFT 0x19B4 +#define AL_FORMAT_UHJ2CHN_IMA4_SOFT 0x19B5 +#define AL_FORMAT_UHJ2CHN_MSADPCM_SOFT 0x19B6 +#define AL_FORMAT_UHJ3CHN_MULAW_SOFT 0x19B7 +#define AL_FORMAT_UHJ3CHN_ALAW_SOFT 0x19B8 +#define AL_FORMAT_UHJ4CHN_MULAW_SOFT 0x19B9 +#define AL_FORMAT_UHJ4CHN_ALAW_SOFT 0x19BA +#endif + +#ifndef ALC_SOFT_output_mode +#define ALC_SOFT_output_mode +#define ALC_OUTPUT_MODE_SOFT 0x19AC +#define ALC_ANY_SOFT 0x19AD +/*#define ALC_MONO_SOFT 0x1500*/ +/*#define ALC_STEREO_SOFT 0x1501*/ +#define ALC_STEREO_BASIC_SOFT 0x19AE +#define ALC_STEREO_UHJ_SOFT 0x19AF +#define ALC_STEREO_HRTF_SOFT 0x19B2 +/*#define ALC_QUAD_SOFT 0x1503*/ +#define ALC_SURROUND_5_1_SOFT 0x1504 +#define ALC_SURROUND_6_1_SOFT 0x1505 +#define ALC_SURROUND_7_1_SOFT 0x1506 +#endif + +#ifndef AL_SOFT_source_start_delay +#define AL_SOFT_source_start_delay +typedef void (AL_APIENTRY*LPALSOURCEPLAYATTIMESOFT)(ALuint source, ALint64SOFT start_time) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALSOURCEPLAYATTIMEVSOFT)(ALsizei n, const ALuint *sources, ALint64SOFT start_time) AL_API_NOEXCEPT17; +#ifdef AL_ALEXT_PROTOTYPES +void AL_APIENTRY alSourcePlayAtTimeSOFT(ALuint source, ALint64SOFT start_time) AL_API_NOEXCEPT; +void AL_APIENTRY alSourcePlayAtTimevSOFT(ALsizei n, const ALuint *sources, ALint64SOFT start_time) AL_API_NOEXCEPT; +#endif +#endif + +#ifndef ALC_EXT_debug +#define ALC_EXT_debug +#define ALC_CONTEXT_FLAGS_EXT 0x19CF +#define ALC_CONTEXT_DEBUG_BIT_EXT 0x0001 +#endif + +#ifndef AL_EXT_debug +#define AL_EXT_debug +#define AL_DONT_CARE_EXT 0x0002 +#define AL_DEBUG_OUTPUT_EXT 0x19B2 +#define AL_DEBUG_CALLBACK_FUNCTION_EXT 0x19B3 +#define AL_DEBUG_CALLBACK_USER_PARAM_EXT 0x19B4 +#define AL_DEBUG_SOURCE_API_EXT 0x19B5 +#define AL_DEBUG_SOURCE_AUDIO_SYSTEM_EXT 0x19B6 +#define AL_DEBUG_SOURCE_THIRD_PARTY_EXT 0x19B7 +#define AL_DEBUG_SOURCE_APPLICATION_EXT 0x19B8 +#define AL_DEBUG_SOURCE_OTHER_EXT 0x19B9 +#define AL_DEBUG_TYPE_ERROR_EXT 0x19BA +#define AL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_EXT 0x19BB +#define AL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_EXT 0x19BC +#define AL_DEBUG_TYPE_PORTABILITY_EXT 0x19BD +#define AL_DEBUG_TYPE_PERFORMANCE_EXT 0x19BE +#define AL_DEBUG_TYPE_MARKER_EXT 0x19BF +#define AL_DEBUG_TYPE_PUSH_GROUP_EXT 0x19C0 +#define AL_DEBUG_TYPE_POP_GROUP_EXT 0x19C1 +#define AL_DEBUG_TYPE_OTHER_EXT 0x19C2 +#define AL_DEBUG_SEVERITY_HIGH_EXT 0x19C3 +#define AL_DEBUG_SEVERITY_MEDIUM_EXT 0x19C4 +#define AL_DEBUG_SEVERITY_LOW_EXT 0x19C5 +#define AL_DEBUG_SEVERITY_NOTIFICATION_EXT 0x19C6 +#define AL_DEBUG_LOGGED_MESSAGES_EXT 0x19C7 +#define AL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_EXT 0x19C8 +#define AL_MAX_DEBUG_MESSAGE_LENGTH_EXT 0x19C9 +#define AL_MAX_DEBUG_LOGGED_MESSAGES_EXT 0x19CA +#define AL_MAX_DEBUG_GROUP_STACK_DEPTH_EXT 0x19CB +#define AL_MAX_LABEL_LENGTH_EXT 0x19CC +#define AL_STACK_OVERFLOW_EXT 0x19CD +#define AL_STACK_UNDERFLOW_EXT 0x19CE +#define AL_CONTEXT_FLAGS_EXT 0x19CF +#define AL_BUFFER_EXT 0x1009 /* Same as AL_BUFFER */ +#define AL_SOURCE_EXT 0x19D0 +#define AL_FILTER_EXT 0x19D1 +#define AL_EFFECT_EXT 0x19D2 +#define AL_AUXILIARY_EFFECT_SLOT_EXT 0x19D3 + +typedef void (AL_APIENTRY*ALDEBUGPROCEXT)(ALenum source, ALenum type, ALuint id, ALenum severity, ALsizei length, const ALchar *message, void *userParam) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALDEBUGMESSAGECALLBACKEXT)(ALDEBUGPROCEXT callback, void *userParam) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALDEBUGMESSAGEINSERTEXT)(ALenum source, ALenum type, ALuint id, ALenum severity, ALsizei length, const ALchar *message) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALDEBUGMESSAGECONTROLEXT)(ALenum source, ALenum type, ALenum severity, ALsizei count, const ALuint *ids, ALboolean enable) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALPUSHDEBUGGROUPEXT)(ALenum source, ALuint id, ALsizei length, const ALchar *message) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALPOPDEBUGGROUPEXT)(void) AL_API_NOEXCEPT17; +typedef ALuint (AL_APIENTRY*LPALGETDEBUGMESSAGELOGEXT)(ALuint count, ALsizei logBufSize, ALenum *sources, ALenum *types, ALuint *ids, ALenum *severities, ALsizei *lengths, ALchar *logBuf) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALOBJECTLABELEXT)(ALenum identifier, ALuint name, ALsizei length, const ALchar *label) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALGETOBJECTLABELEXT)(ALenum identifier, ALuint name, ALsizei bufSize, ALsizei *length, ALchar *label) AL_API_NOEXCEPT17; +typedef void* (AL_APIENTRY*LPALGETPOINTEREXT)(ALenum pname) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALGETPOINTERVEXT)(ALenum pname, void **values) AL_API_NOEXCEPT17; +#ifdef AL_ALEXT_PROTOTYPES +void AL_APIENTRY alDebugMessageCallbackEXT(ALDEBUGPROCEXT callback, void *userParam) AL_API_NOEXCEPT; +void AL_APIENTRY alDebugMessageInsertEXT(ALenum source, ALenum type, ALuint id, ALenum severity, ALsizei length, const ALchar *message) AL_API_NOEXCEPT; +void AL_APIENTRY alDebugMessageControlEXT(ALenum source, ALenum type, ALenum severity, ALsizei count, const ALuint *ids, ALboolean enable) AL_API_NOEXCEPT; +void AL_APIENTRY alPushDebugGroupEXT(ALenum source, ALuint id, ALsizei length, const ALchar *message) AL_API_NOEXCEPT; +void AL_APIENTRY alPopDebugGroupEXT(void) AL_API_NOEXCEPT; +ALuint AL_APIENTRY alGetDebugMessageLogEXT(ALuint count, ALsizei logBufSize, ALenum *sources, ALenum *types, ALuint *ids, ALenum *severities, ALsizei *lengths, ALchar *logBuf) AL_API_NOEXCEPT; +void AL_APIENTRY alObjectLabelEXT(ALenum identifier, ALuint name, ALsizei length, const ALchar *label) AL_API_NOEXCEPT; +void AL_APIENTRY alGetObjectLabelEXT(ALenum identifier, ALuint name, ALsizei bufSize, ALsizei *length, ALchar *label) AL_API_NOEXCEPT; +void* AL_APIENTRY alGetPointerEXT(ALenum pname) AL_API_NOEXCEPT; +void AL_APIENTRY alGetPointervEXT(ALenum pname, void **values) AL_API_NOEXCEPT; +#endif +#endif + +#ifndef ALC_SOFT_system_events +#define ALC_SOFT_system_events +#define ALC_PLAYBACK_DEVICE_SOFT 0x19D4 +#define ALC_CAPTURE_DEVICE_SOFT 0x19D5 +#define ALC_EVENT_TYPE_DEFAULT_DEVICE_CHANGED_SOFT 0x19D6 +#define ALC_EVENT_TYPE_DEVICE_ADDED_SOFT 0x19D7 +#define ALC_EVENT_TYPE_DEVICE_REMOVED_SOFT 0x19D8 +#define ALC_EVENT_SUPPORTED_SOFT 0x19D9 +#define ALC_EVENT_NOT_SUPPORTED_SOFT 0x19DA +typedef void (ALC_APIENTRY*ALCEVENTPROCTYPESOFT)(ALCenum eventType, ALCenum deviceType, + ALCdevice *device, ALCsizei length, const ALCchar *message, void *userParam) ALC_API_NOEXCEPT17; +typedef ALCenum (ALC_APIENTRY*LPALCEVENTISSUPPORTEDSOFT)(ALCenum eventType, ALCenum deviceType) ALC_API_NOEXCEPT17; +typedef ALCboolean (ALC_APIENTRY*LPALCEVENTCONTROLSOFT)(ALCsizei count, const ALCenum *events, ALCboolean enable) ALC_API_NOEXCEPT17; +typedef void (ALC_APIENTRY*LPALCEVENTCALLBACKSOFT)(ALCEVENTPROCTYPESOFT callback, void *userParam) ALC_API_NOEXCEPT17; +#ifdef AL_ALEXT_PROTOTYPES +ALCenum ALC_APIENTRY alcEventIsSupportedSOFT(ALCenum eventType, ALCenum deviceType) ALC_API_NOEXCEPT; +ALCboolean ALC_APIENTRY alcEventControlSOFT(ALCsizei count, const ALCenum *events, ALCboolean enable) ALC_API_NOEXCEPT; +void ALC_APIENTRY alcEventCallbackSOFT(ALCEVENTPROCTYPESOFT callback, void *userParam) ALC_API_NOEXCEPT; +#endif +#endif + +#ifndef AL_EXT_direct_context +#define AL_EXT_direct_context +typedef ALCvoid* (ALC_APIENTRY *LPALCGETPROCADDRESS2)(ALCdevice *device, const ALCchar *funcname) AL_API_NOEXCEPT17; + +typedef void (AL_APIENTRY *LPALENABLEDIRECT)(ALCcontext *context, ALenum capability) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALDISABLEDIRECT)(ALCcontext *context, ALenum capability) AL_API_NOEXCEPT17; +typedef ALboolean (AL_APIENTRY *LPALISENABLEDDIRECT)(ALCcontext *context, ALenum capability) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALDOPPLERFACTORDIRECT)(ALCcontext *context, ALfloat value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSPEEDOFSOUNDDIRECT)(ALCcontext *context, ALfloat value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALDISTANCEMODELDIRECT)(ALCcontext *context, ALenum distanceModel) AL_API_NOEXCEPT17; +typedef const ALchar* (AL_APIENTRY *LPALGETSTRINGDIRECT)(ALCcontext *context, ALenum param) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETBOOLEANVDIRECT)(ALCcontext *context, ALenum param, ALboolean *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETINTEGERVDIRECT)(ALCcontext *context, ALenum param, ALint *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETFLOATVDIRECT)(ALCcontext *context, ALenum param, ALfloat *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETDOUBLEVDIRECT)(ALCcontext *context, ALenum param, ALdouble *values) AL_API_NOEXCEPT17; +typedef ALboolean (AL_APIENTRY *LPALGETBOOLEANDIRECT)(ALCcontext *context, ALenum param) AL_API_NOEXCEPT17; +typedef ALint (AL_APIENTRY *LPALGETINTEGERDIRECT)(ALCcontext *context, ALenum param) AL_API_NOEXCEPT17; +typedef ALfloat (AL_APIENTRY *LPALGETFLOATDIRECT)(ALCcontext *context, ALenum param) AL_API_NOEXCEPT17; +typedef ALdouble (AL_APIENTRY *LPALGETDOUBLEDIRECT)(ALCcontext *context, ALenum param) AL_API_NOEXCEPT17; +typedef ALenum (AL_APIENTRY *LPALGETERRORDIRECT)(ALCcontext *context) AL_API_NOEXCEPT17; +typedef ALboolean (AL_APIENTRY *LPALISEXTENSIONPRESENTDIRECT)(ALCcontext *context, const ALchar *extname) AL_API_NOEXCEPT17; +typedef void* (AL_APIENTRY *LPALGETPROCADDRESSDIRECT)(ALCcontext *context, const ALchar *fname) AL_API_NOEXCEPT17; +typedef ALenum (AL_APIENTRY *LPALGETENUMVALUEDIRECT)(ALCcontext *context, const ALchar *ename) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALLISTENERFDIRECT)(ALCcontext *context, ALenum param, ALfloat value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALLISTENER3FDIRECT)(ALCcontext *context, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALLISTENERFVDIRECT)(ALCcontext *context, ALenum param, const ALfloat *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALLISTENERIDIRECT)(ALCcontext *context, ALenum param, ALint value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALLISTENER3IDIRECT)(ALCcontext *context, ALenum param, ALint value1, ALint value2, ALint value3) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALLISTENERIVDIRECT)(ALCcontext *context, ALenum param, const ALint *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETLISTENERFDIRECT)(ALCcontext *context, ALenum param, ALfloat *value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETLISTENER3FDIRECT)(ALCcontext *context, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETLISTENERFVDIRECT)(ALCcontext *context, ALenum param, ALfloat *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETLISTENERIDIRECT)(ALCcontext *context, ALenum param, ALint *value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETLISTENER3IDIRECT)(ALCcontext *context, ALenum param, ALint *value1, ALint *value2, ALint *value3) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETLISTENERIVDIRECT)(ALCcontext *context, ALenum param, ALint *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGENSOURCESDIRECT)(ALCcontext *context, ALsizei n, ALuint *sources) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALDELETESOURCESDIRECT)(ALCcontext *context, ALsizei n, const ALuint *sources) AL_API_NOEXCEPT17; +typedef ALboolean (AL_APIENTRY *LPALISSOURCEDIRECT)(ALCcontext *context, ALuint source) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCEFDIRECT)(ALCcontext *context, ALuint source, ALenum param, ALfloat value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCE3FDIRECT)(ALCcontext *context, ALuint source, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCEFVDIRECT)(ALCcontext *context, ALuint source, ALenum param, const ALfloat *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCEIDIRECT)(ALCcontext *context, ALuint source, ALenum param, ALint value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCE3IDIRECT)(ALCcontext *context, ALuint source, ALenum param, ALint value1, ALint value2, ALint value3) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCEIVDIRECT)(ALCcontext *context, ALuint source, ALenum param, const ALint *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETSOURCEFDIRECT)(ALCcontext *context, ALuint source, ALenum param, ALfloat *value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETSOURCE3FDIRECT)(ALCcontext *context, ALuint source, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETSOURCEFVDIRECT)(ALCcontext *context, ALuint source, ALenum param, ALfloat *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETSOURCEIDIRECT)(ALCcontext *context, ALuint source, ALenum param, ALint *value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETSOURCE3IDIRECT)(ALCcontext *context, ALuint source, ALenum param, ALint *value1, ALint *value2, ALint *value3) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETSOURCEIVDIRECT)(ALCcontext *context, ALuint source, ALenum param, ALint *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCEPLAYDIRECT)(ALCcontext *context, ALuint source) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCESTOPDIRECT)(ALCcontext *context, ALuint source) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCEREWINDDIRECT)(ALCcontext *context, ALuint source) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCEPAUSEDIRECT)(ALCcontext *context, ALuint source) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCEPLAYVDIRECT)(ALCcontext *context, ALsizei n, const ALuint *sources) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCESTOPVDIRECT)(ALCcontext *context, ALsizei n, const ALuint *sources) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCEREWINDVDIRECT)(ALCcontext *context, ALsizei n, const ALuint *sources) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCEPAUSEVDIRECT)(ALCcontext *context, ALsizei n, const ALuint *sources) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCEQUEUEBUFFERSDIRECT)(ALCcontext *context, ALuint source, ALsizei nb, const ALuint *buffers) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCEUNQUEUEBUFFERSDIRECT)(ALCcontext *context, ALuint source, ALsizei nb, ALuint *buffers) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGENBUFFERSDIRECT)(ALCcontext *context, ALsizei n, ALuint *buffers) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALDELETEBUFFERSDIRECT)(ALCcontext *context, ALsizei n, const ALuint *buffers) AL_API_NOEXCEPT17; +typedef ALboolean (AL_APIENTRY *LPALISBUFFERDIRECT)(ALCcontext *context, ALuint buffer) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALBUFFERDATADIRECT)(ALCcontext *context, ALuint buffer, ALenum format, const ALvoid *data, ALsizei size, ALsizei samplerate) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALBUFFERFDIRECT)(ALCcontext *context, ALuint buffer, ALenum param, ALfloat value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALBUFFER3FDIRECT)(ALCcontext *context, ALuint buffer, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALBUFFERFVDIRECT)(ALCcontext *context, ALuint buffer, ALenum param, const ALfloat *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALBUFFERIDIRECT)(ALCcontext *context, ALuint buffer, ALenum param, ALint value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALBUFFER3IDIRECT)(ALCcontext *context, ALuint buffer, ALenum param, ALint value1, ALint value2, ALint value3) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALBUFFERIVDIRECT)(ALCcontext *context, ALuint buffer, ALenum param, const ALint *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETBUFFERFDIRECT)(ALCcontext *context, ALuint buffer, ALenum param, ALfloat *value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETBUFFER3FDIRECT)(ALCcontext *context, ALuint buffer, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETBUFFERFVDIRECT)(ALCcontext *context, ALuint buffer, ALenum param, ALfloat *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETBUFFERIDIRECT)(ALCcontext *context, ALuint buffer, ALenum param, ALint *value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETBUFFER3IDIRECT)(ALCcontext *context, ALuint buffer, ALenum param, ALint *value1, ALint *value2, ALint *value3) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETBUFFERIVDIRECT)(ALCcontext *context, ALuint buffer, ALenum param, ALint *values) AL_API_NOEXCEPT17; +/* ALC_EXT_EFX */ +typedef void (AL_APIENTRY *LPALGENEFFECTSDIRECT)(ALCcontext *context, ALsizei n, ALuint *effects) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALDELETEEFFECTSDIRECT)(ALCcontext *context, ALsizei n, const ALuint *effects) AL_API_NOEXCEPT17; +typedef ALboolean (AL_APIENTRY *LPALISEFFECTDIRECT)(ALCcontext *context, ALuint effect) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALEFFECTIDIRECT)(ALCcontext *context, ALuint effect, ALenum param, ALint value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALEFFECTIVDIRECT)(ALCcontext *context, ALuint effect, ALenum param, const ALint *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALEFFECTFDIRECT)(ALCcontext *context, ALuint effect, ALenum param, ALfloat value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALEFFECTFVDIRECT)(ALCcontext *context, ALuint effect, ALenum param, const ALfloat *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETEFFECTIDIRECT)(ALCcontext *context, ALuint effect, ALenum param, ALint *value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETEFFECTIVDIRECT)(ALCcontext *context, ALuint effect, ALenum param, ALint *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETEFFECTFDIRECT)(ALCcontext *context, ALuint effect, ALenum param, ALfloat *value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETEFFECTFVDIRECT)(ALCcontext *context, ALuint effect, ALenum param, ALfloat *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGENFILTERSDIRECT)(ALCcontext *context, ALsizei n, ALuint *filters) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALDELETEFILTERSDIRECT)(ALCcontext *context, ALsizei n, const ALuint *filters) AL_API_NOEXCEPT17; +typedef ALboolean (AL_APIENTRY *LPALISFILTERDIRECT)(ALCcontext *context, ALuint filter) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALFILTERIDIRECT)(ALCcontext *context, ALuint filter, ALenum param, ALint value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALFILTERIVDIRECT)(ALCcontext *context, ALuint filter, ALenum param, const ALint *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALFILTERFDIRECT)(ALCcontext *context, ALuint filter, ALenum param, ALfloat value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALFILTERFVDIRECT)(ALCcontext *context, ALuint filter, ALenum param, const ALfloat *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETFILTERIDIRECT)(ALCcontext *context, ALuint filter, ALenum param, ALint *value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETFILTERIVDIRECT)(ALCcontext *context, ALuint filter, ALenum param, ALint *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETFILTERFDIRECT)(ALCcontext *context, ALuint filter, ALenum param, ALfloat *value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETFILTERFVDIRECT)(ALCcontext *context, ALuint filter, ALenum param, ALfloat *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGENAUXILIARYEFFECTSLOTSDIRECT)(ALCcontext *context, ALsizei n, ALuint *effectslots) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALDELETEAUXILIARYEFFECTSLOTSDIRECT)(ALCcontext *context, ALsizei n, const ALuint *effectslots) AL_API_NOEXCEPT17; +typedef ALboolean (AL_APIENTRY *LPALISAUXILIARYEFFECTSLOTDIRECT)(ALCcontext *context, ALuint effectslot) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTIDIRECT)(ALCcontext *context, ALuint effectslot, ALenum param, ALint value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTIVDIRECT)(ALCcontext *context, ALuint effectslot, ALenum param, const ALint *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTFDIRECT)(ALCcontext *context, ALuint effectslot, ALenum param, ALfloat value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTFVDIRECT)(ALCcontext *context, ALuint effectslot, ALenum param, const ALfloat *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTIDIRECT)(ALCcontext *context, ALuint effectslot, ALenum param, ALint *value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTIVDIRECT)(ALCcontext *context, ALuint effectslot, ALenum param, ALint *values) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTFDIRECT)(ALCcontext *context, ALuint effectslot, ALenum param, ALfloat *value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTFVDIRECT)(ALCcontext *context, ALuint effectslot, ALenum param, ALfloat *values) AL_API_NOEXCEPT17; +/* AL_EXT_BUFFER_DATA_STATIC */ +typedef void (AL_APIENTRY *LPALBUFFERDATASTATICDIRECT)(ALCcontext *context, ALuint buffer, ALenum format, ALvoid *data, ALsizei size, ALsizei freq) AL_API_NOEXCEPT17; +/* AL_EXT_debug */ +typedef void (AL_APIENTRY*LPALDEBUGMESSAGECALLBACKDIRECTEXT)(ALCcontext *context, ALDEBUGPROCEXT callback, void *userParam) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALDEBUGMESSAGEINSERTDIRECTEXT)(ALCcontext *context, ALenum source, ALenum type, ALuint id, ALenum severity, ALsizei length, const ALchar *message) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALDEBUGMESSAGECONTROLDIRECTEXT)(ALCcontext *context, ALenum source, ALenum type, ALenum severity, ALsizei count, const ALuint *ids, ALboolean enable) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALPUSHDEBUGGROUPDIRECTEXT)(ALCcontext *context, ALenum source, ALuint id, ALsizei length, const ALchar *message) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALPOPDEBUGGROUPDIRECTEXT)(ALCcontext *context) AL_API_NOEXCEPT17; +typedef ALuint (AL_APIENTRY*LPALGETDEBUGMESSAGELOGDIRECTEXT)(ALCcontext *context, ALuint count, ALsizei logBufSize, ALenum *sources, ALenum *types, ALuint *ids, ALenum *severities, ALsizei *lengths, ALchar *logBuf) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALOBJECTLABELDIRECTEXT)(ALCcontext *context, ALenum identifier, ALuint name, ALsizei length, const ALchar *label) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALGETOBJECTLABELDIRECTEXT)(ALCcontext *context, ALenum identifier, ALuint name, ALsizei bufSize, ALsizei *length, ALchar *label) AL_API_NOEXCEPT17; +typedef void* (AL_APIENTRY*LPALGETPOINTERDIRECTEXT)(ALCcontext *context, ALenum pname) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY*LPALGETPOINTERVDIRECTEXT)(ALCcontext *context, ALenum pname, void **values) AL_API_NOEXCEPT17; +/* AL_EXT_FOLDBACK */ +typedef void (AL_APIENTRY *LPALREQUESTFOLDBACKSTARTDIRECT)(ALCcontext *context, ALenum mode, ALsizei count, ALsizei length, ALfloat *mem, LPALFOLDBACKCALLBACK callback) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALREQUESTFOLDBACKSTOPDIRECT)(ALCcontext *context) AL_API_NOEXCEPT17; +/* AL_SOFT_buffer_sub_data */ +typedef void (AL_APIENTRY *LPALBUFFERSUBDATADIRECTSOFT)(ALCcontext *context, ALuint buffer, ALenum format, const ALvoid *data, ALsizei offset, ALsizei length) AL_API_NOEXCEPT17; +/* AL_SOFT_source_latency */ +typedef void (AL_APIENTRY *LPALSOURCEDDIRECTSOFT)(ALCcontext*,ALuint,ALenum,ALdouble) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCE3DDIRECTSOFT)(ALCcontext*,ALuint,ALenum,ALdouble,ALdouble,ALdouble) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCEDVDIRECTSOFT)(ALCcontext*,ALuint,ALenum,const ALdouble*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETSOURCEDDIRECTSOFT)(ALCcontext*,ALuint,ALenum,ALdouble*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETSOURCE3DDIRECTSOFT)(ALCcontext*,ALuint,ALenum,ALdouble*,ALdouble*,ALdouble*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETSOURCEDVDIRECTSOFT)(ALCcontext*,ALuint,ALenum,ALdouble*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCEI64DIRECTSOFT)(ALCcontext*,ALuint,ALenum,ALint64SOFT) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCE3I64DIRECTSOFT)(ALCcontext*,ALuint,ALenum,ALint64SOFT,ALint64SOFT,ALint64SOFT) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCEI64VDIRECTSOFT)(ALCcontext*,ALuint,ALenum,const ALint64SOFT*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETSOURCEI64DIRECTSOFT)(ALCcontext*,ALuint,ALenum,ALint64SOFT*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETSOURCE3I64DIRECTSOFT)(ALCcontext*,ALuint,ALenum,ALint64SOFT*,ALint64SOFT*,ALint64SOFT*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETSOURCEI64VDIRECTSOFT)(ALCcontext*,ALuint,ALenum,ALint64SOFT*) AL_API_NOEXCEPT17; +/* AL_SOFT_deferred_updates */ +typedef void (AL_APIENTRY *LPALDEFERUPDATESDIRECTSOFT)(ALCcontext *context) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALPROCESSUPDATESDIRECTSOFT)(ALCcontext *context) AL_API_NOEXCEPT17; +/* AL_SOFT_source_resampler */ +typedef const ALchar* (AL_APIENTRY *LPALGETSTRINGIDIRECTSOFT)(ALCcontext *context, ALenum pname, ALsizei index) AL_API_NOEXCEPT17; +/* AL_SOFT_events */ +typedef void (AL_APIENTRY *LPALEVENTCONTROLDIRECTSOFT)(ALCcontext *context, ALsizei count, const ALenum *types, ALboolean enable) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALEVENTCALLBACKDIRECTSOFT)(ALCcontext *context, ALEVENTPROCSOFT callback, void *userParam) AL_API_NOEXCEPT17; +typedef void* (AL_APIENTRY *LPALGETPOINTERDIRECTSOFT)(ALCcontext *context, ALenum pname) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETPOINTERVDIRECTSOFT)(ALCcontext *context, ALenum pname, void **values) AL_API_NOEXCEPT17; +/* AL_SOFT_callback_buffer */ +typedef void (AL_APIENTRY *LPALBUFFERCALLBACKDIRECTSOFT)(ALCcontext *context, ALuint buffer, ALenum format, ALsizei freq, ALBUFFERCALLBACKTYPESOFT callback, ALvoid *userptr) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETBUFFERPTRDIRECTSOFT)(ALCcontext *context, ALuint buffer, ALenum param, ALvoid **value) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETBUFFER3PTRDIRECTSOFT)(ALCcontext *context, ALuint buffer, ALenum param, ALvoid **value1, ALvoid **value2, ALvoid **value3) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETBUFFERPTRVDIRECTSOFT)(ALCcontext *context, ALuint buffer, ALenum param, ALvoid **values) AL_API_NOEXCEPT17; +/* AL_SOFT_source_start_delay */ +typedef void (AL_APIENTRY *LPALSOURCEPLAYATTIMEDIRECTSOFT)(ALCcontext *context, ALuint source, ALint64SOFT start_time) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALSOURCEPLAYATTIMEVDIRECTSOFT)(ALCcontext *context, ALsizei n, const ALuint *sources, ALint64SOFT start_time) AL_API_NOEXCEPT17; +/* EAX */ +typedef ALenum (AL_APIENTRY *LPEAXSETDIRECT)(ALCcontext *context, const struct _GUID *property_set_id, ALuint property_id, ALuint source_id, ALvoid *value, ALuint value_size) AL_API_NOEXCEPT17; +typedef ALenum (AL_APIENTRY *LPEAXGETDIRECT)(ALCcontext *context, const struct _GUID *property_set_id, ALuint property_id, ALuint source_id, ALvoid *value, ALuint value_size) AL_API_NOEXCEPT17; +typedef ALboolean (AL_APIENTRY *LPEAXSETBUFFERMODEDIRECT)(ALCcontext *context, ALsizei n, const ALuint *buffers, ALint value) AL_API_NOEXCEPT17; +typedef ALenum (AL_APIENTRY *LPEAXGETBUFFERMODEDIRECT)(ALCcontext *context, ALuint buffer, ALint *pReserved) AL_API_NOEXCEPT17; +#ifdef AL_ALEXT_PROTOTYPES +ALCvoid* ALC_APIENTRY alcGetProcAddress2(ALCdevice *device, const ALCchar *funcName) AL_API_NOEXCEPT; + +void AL_APIENTRY alEnableDirect(ALCcontext *context, ALenum capability) AL_API_NOEXCEPT; +void AL_APIENTRY alDisableDirect(ALCcontext *context, ALenum capability) AL_API_NOEXCEPT; +ALboolean AL_APIENTRY alIsEnabledDirect(ALCcontext *context, ALenum capability) AL_API_NOEXCEPT; + +void AL_APIENTRY alDopplerFactorDirect(ALCcontext *context, ALfloat value) AL_API_NOEXCEPT; +void AL_APIENTRY alSpeedOfSoundDirect(ALCcontext *context, ALfloat value) AL_API_NOEXCEPT; +void AL_APIENTRY alDistanceModelDirect(ALCcontext *context, ALenum distanceModel) AL_API_NOEXCEPT; + +const ALchar* AL_APIENTRY alGetStringDirect(ALCcontext *context, ALenum param) AL_API_NOEXCEPT; +void AL_APIENTRY alGetBooleanvDirect(ALCcontext *context, ALenum param, ALboolean *values) AL_API_NOEXCEPT; +void AL_APIENTRY alGetIntegervDirect(ALCcontext *context, ALenum param, ALint *values) AL_API_NOEXCEPT; +void AL_APIENTRY alGetFloatvDirect(ALCcontext *context, ALenum param, ALfloat *values) AL_API_NOEXCEPT; +void AL_APIENTRY alGetDoublevDirect(ALCcontext *context, ALenum param, ALdouble *values) AL_API_NOEXCEPT; +ALboolean AL_APIENTRY alGetBooleanDirect(ALCcontext *context, ALenum param) AL_API_NOEXCEPT; +ALint AL_APIENTRY alGetIntegerDirect(ALCcontext *context, ALenum param) AL_API_NOEXCEPT; +ALfloat AL_APIENTRY alGetFloatDirect(ALCcontext *context, ALenum param) AL_API_NOEXCEPT; +ALdouble AL_APIENTRY alGetDoubleDirect(ALCcontext *context, ALenum param) AL_API_NOEXCEPT; + +ALenum AL_APIENTRY alGetErrorDirect(ALCcontext *context) AL_API_NOEXCEPT; +ALboolean AL_APIENTRY alIsExtensionPresentDirect(ALCcontext *context, const ALchar *extname) AL_API_NOEXCEPT; +void* AL_APIENTRY alGetProcAddressDirect(ALCcontext *context, const ALchar *fname) AL_API_NOEXCEPT; +ALenum AL_APIENTRY alGetEnumValueDirect(ALCcontext *context, const ALchar *ename) AL_API_NOEXCEPT; + +void AL_APIENTRY alListenerfDirect(ALCcontext *context, ALenum param, ALfloat value) AL_API_NOEXCEPT; +void AL_APIENTRY alListener3fDirect(ALCcontext *context, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3) AL_API_NOEXCEPT; +void AL_APIENTRY alListenerfvDirect(ALCcontext *context, ALenum param, const ALfloat *values) AL_API_NOEXCEPT; +void AL_APIENTRY alListeneriDirect(ALCcontext *context, ALenum param, ALint value) AL_API_NOEXCEPT; +void AL_APIENTRY alListener3iDirect(ALCcontext *context, ALenum param, ALint value1, ALint value2, ALint value3) AL_API_NOEXCEPT; +void AL_APIENTRY alListenerivDirect(ALCcontext *context, ALenum param, const ALint *values) AL_API_NOEXCEPT; +void AL_APIENTRY alGetListenerfDirect(ALCcontext *context, ALenum param, ALfloat *value) AL_API_NOEXCEPT; +void AL_APIENTRY alGetListener3fDirect(ALCcontext *context, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3) AL_API_NOEXCEPT; +void AL_APIENTRY alGetListenerfvDirect(ALCcontext *context, ALenum param, ALfloat *values) AL_API_NOEXCEPT; +void AL_APIENTRY alGetListeneriDirect(ALCcontext *context, ALenum param, ALint *value) AL_API_NOEXCEPT; +void AL_APIENTRY alGetListener3iDirect(ALCcontext *context, ALenum param, ALint *value1, ALint *value2, ALint *value3) AL_API_NOEXCEPT; +void AL_APIENTRY alGetListenerivDirect(ALCcontext *context, ALenum param, ALint *values) AL_API_NOEXCEPT; + +void AL_APIENTRY alGenSourcesDirect(ALCcontext *context, ALsizei n, ALuint *sources) AL_API_NOEXCEPT; +void AL_APIENTRY alDeleteSourcesDirect(ALCcontext *context, ALsizei n, const ALuint *sources) AL_API_NOEXCEPT; +ALboolean AL_APIENTRY alIsSourceDirect(ALCcontext *context, ALuint source) AL_API_NOEXCEPT; +void AL_APIENTRY alSourcefDirect(ALCcontext *context, ALuint source, ALenum param, ALfloat value) AL_API_NOEXCEPT; +void AL_APIENTRY alSource3fDirect(ALCcontext *context, ALuint source, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3) AL_API_NOEXCEPT; +void AL_APIENTRY alSourcefvDirect(ALCcontext *context, ALuint source, ALenum param, const ALfloat *values) AL_API_NOEXCEPT; +void AL_APIENTRY alSourceiDirect(ALCcontext *context, ALuint source, ALenum param, ALint value) AL_API_NOEXCEPT; +void AL_APIENTRY alSource3iDirect(ALCcontext *context, ALuint source, ALenum param, ALint value1, ALint value2, ALint value3) AL_API_NOEXCEPT; +void AL_APIENTRY alSourceivDirect(ALCcontext *context, ALuint source, ALenum param, const ALint *values) AL_API_NOEXCEPT; +void AL_APIENTRY alGetSourcefDirect(ALCcontext *context, ALuint source, ALenum param, ALfloat *value) AL_API_NOEXCEPT; +void AL_APIENTRY alGetSource3fDirect(ALCcontext *context, ALuint source, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3) AL_API_NOEXCEPT; +void AL_APIENTRY alGetSourcefvDirect(ALCcontext *context, ALuint source, ALenum param, ALfloat *values) AL_API_NOEXCEPT; +void AL_APIENTRY alGetSourceiDirect(ALCcontext *context, ALuint source, ALenum param, ALint *value) AL_API_NOEXCEPT; +void AL_APIENTRY alGetSource3iDirect(ALCcontext *context, ALuint source, ALenum param, ALint *value1, ALint *value2, ALint *value3) AL_API_NOEXCEPT; +void AL_APIENTRY alGetSourceivDirect(ALCcontext *context, ALuint source, ALenum param, ALint *values) AL_API_NOEXCEPT; +void AL_APIENTRY alSourcePlayDirect(ALCcontext *context, ALuint source) AL_API_NOEXCEPT; +void AL_APIENTRY alSourceStopDirect(ALCcontext *context, ALuint source) AL_API_NOEXCEPT; +void AL_APIENTRY alSourceRewindDirect(ALCcontext *context, ALuint source) AL_API_NOEXCEPT; +void AL_APIENTRY alSourcePauseDirect(ALCcontext *context, ALuint source) AL_API_NOEXCEPT; +void AL_APIENTRY alSourcePlayvDirect(ALCcontext *context, ALsizei n, const ALuint *sources) AL_API_NOEXCEPT; +void AL_APIENTRY alSourceStopvDirect(ALCcontext *context, ALsizei n, const ALuint *sources) AL_API_NOEXCEPT; +void AL_APIENTRY alSourceRewindvDirect(ALCcontext *context, ALsizei n, const ALuint *sources) AL_API_NOEXCEPT; +void AL_APIENTRY alSourcePausevDirect(ALCcontext *context, ALsizei n, const ALuint *sources) AL_API_NOEXCEPT; +void AL_APIENTRY alSourceQueueBuffersDirect(ALCcontext *context, ALuint source, ALsizei nb, const ALuint *buffers) AL_API_NOEXCEPT; +void AL_APIENTRY alSourceUnqueueBuffersDirect(ALCcontext *context, ALuint source, ALsizei nb, ALuint *buffers) AL_API_NOEXCEPT; + +void AL_APIENTRY alGenBuffersDirect(ALCcontext *context, ALsizei n, ALuint *buffers) AL_API_NOEXCEPT; +void AL_APIENTRY alDeleteBuffersDirect(ALCcontext *context, ALsizei n, const ALuint *buffers) AL_API_NOEXCEPT; +ALboolean AL_APIENTRY alIsBufferDirect(ALCcontext *context, ALuint buffer) AL_API_NOEXCEPT; +void AL_APIENTRY alBufferDataDirect(ALCcontext *context, ALuint buffer, ALenum format, const ALvoid *data, ALsizei size, ALsizei samplerate) AL_API_NOEXCEPT; +void AL_APIENTRY alBufferfDirect(ALCcontext *context, ALuint buffer, ALenum param, ALfloat value) AL_API_NOEXCEPT; +void AL_APIENTRY alBuffer3fDirect(ALCcontext *context, ALuint buffer, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3) AL_API_NOEXCEPT; +void AL_APIENTRY alBufferfvDirect(ALCcontext *context, ALuint buffer, ALenum param, const ALfloat *values) AL_API_NOEXCEPT; +void AL_APIENTRY alBufferiDirect(ALCcontext *context, ALuint buffer, ALenum param, ALint value) AL_API_NOEXCEPT; +void AL_APIENTRY alBuffer3iDirect(ALCcontext *context, ALuint buffer, ALenum param, ALint value1, ALint value2, ALint value3) AL_API_NOEXCEPT; +void AL_APIENTRY alBufferivDirect(ALCcontext *context, ALuint buffer, ALenum param, const ALint *values) AL_API_NOEXCEPT; +void AL_APIENTRY alGetBufferfDirect(ALCcontext *context, ALuint buffer, ALenum param, ALfloat *value) AL_API_NOEXCEPT; +void AL_APIENTRY alGetBuffer3fDirect(ALCcontext *context, ALuint buffer, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3) AL_API_NOEXCEPT; +void AL_APIENTRY alGetBufferfvDirect(ALCcontext *context, ALuint buffer, ALenum param, ALfloat *values) AL_API_NOEXCEPT; +void AL_APIENTRY alGetBufferiDirect(ALCcontext *context, ALuint buffer, ALenum param, ALint *value) AL_API_NOEXCEPT; +void AL_APIENTRY alGetBuffer3iDirect(ALCcontext *context, ALuint buffer, ALenum param, ALint *value1, ALint *value2, ALint *value3) AL_API_NOEXCEPT; +void AL_APIENTRY alGetBufferivDirect(ALCcontext *context, ALuint buffer, ALenum param, ALint *values) AL_API_NOEXCEPT; + +void AL_APIENTRY alGenEffectsDirect(ALCcontext *context, ALsizei n, ALuint *effects) AL_API_NOEXCEPT; +void AL_APIENTRY alDeleteEffectsDirect(ALCcontext *context, ALsizei n, const ALuint *effects) AL_API_NOEXCEPT; +ALboolean AL_APIENTRY alIsEffectDirect(ALCcontext *context, ALuint effect) AL_API_NOEXCEPT; +void AL_APIENTRY alEffectiDirect(ALCcontext *context, ALuint effect, ALenum param, ALint iValue) AL_API_NOEXCEPT; +void AL_APIENTRY alEffectivDirect(ALCcontext *context, ALuint effect, ALenum param, const ALint *piValues) AL_API_NOEXCEPT; +void AL_APIENTRY alEffectfDirect(ALCcontext *context, ALuint effect, ALenum param, ALfloat flValue) AL_API_NOEXCEPT; +void AL_APIENTRY alEffectfvDirect(ALCcontext *context, ALuint effect, ALenum param, const ALfloat *pflValues) AL_API_NOEXCEPT; +void AL_APIENTRY alGetEffectiDirect(ALCcontext *context, ALuint effect, ALenum param, ALint *piValue) AL_API_NOEXCEPT; +void AL_APIENTRY alGetEffectivDirect(ALCcontext *context, ALuint effect, ALenum param, ALint *piValues) AL_API_NOEXCEPT; +void AL_APIENTRY alGetEffectfDirect(ALCcontext *context, ALuint effect, ALenum param, ALfloat *pflValue) AL_API_NOEXCEPT; +void AL_APIENTRY alGetEffectfvDirect(ALCcontext *context, ALuint effect, ALenum param, ALfloat *pflValues) AL_API_NOEXCEPT; + +void AL_APIENTRY alGenFiltersDirect(ALCcontext *context, ALsizei n, ALuint *filters) AL_API_NOEXCEPT; +void AL_APIENTRY alDeleteFiltersDirect(ALCcontext *context, ALsizei n, const ALuint *filters) AL_API_NOEXCEPT; +ALboolean AL_APIENTRY alIsFilterDirect(ALCcontext *context, ALuint filter) AL_API_NOEXCEPT; +void AL_APIENTRY alFilteriDirect(ALCcontext *context, ALuint filter, ALenum param, ALint iValue) AL_API_NOEXCEPT; +void AL_APIENTRY alFilterivDirect(ALCcontext *context, ALuint filter, ALenum param, const ALint *piValues) AL_API_NOEXCEPT; +void AL_APIENTRY alFilterfDirect(ALCcontext *context, ALuint filter, ALenum param, ALfloat flValue) AL_API_NOEXCEPT; +void AL_APIENTRY alFilterfvDirect(ALCcontext *context, ALuint filter, ALenum param, const ALfloat *pflValues) AL_API_NOEXCEPT; +void AL_APIENTRY alGetFilteriDirect(ALCcontext *context, ALuint filter, ALenum param, ALint *piValue) AL_API_NOEXCEPT; +void AL_APIENTRY alGetFilterivDirect(ALCcontext *context, ALuint filter, ALenum param, ALint *piValues) AL_API_NOEXCEPT; +void AL_APIENTRY alGetFilterfDirect(ALCcontext *context, ALuint filter, ALenum param, ALfloat *pflValue) AL_API_NOEXCEPT; +void AL_APIENTRY alGetFilterfvDirect(ALCcontext *context, ALuint filter, ALenum param, ALfloat *pflValues) AL_API_NOEXCEPT; + +void AL_APIENTRY alGenAuxiliaryEffectSlotsDirect(ALCcontext *context, ALsizei n, ALuint *effectslots) AL_API_NOEXCEPT; +void AL_APIENTRY alDeleteAuxiliaryEffectSlotsDirect(ALCcontext *context, ALsizei n, const ALuint *effectslots) AL_API_NOEXCEPT; +ALboolean AL_APIENTRY alIsAuxiliaryEffectSlotDirect(ALCcontext *context, ALuint effectslot) AL_API_NOEXCEPT; +void AL_APIENTRY alAuxiliaryEffectSlotiDirect(ALCcontext *context, ALuint effectslot, ALenum param, ALint iValue) AL_API_NOEXCEPT; +void AL_APIENTRY alAuxiliaryEffectSlotivDirect(ALCcontext *context, ALuint effectslot, ALenum param, const ALint *piValues) AL_API_NOEXCEPT; +void AL_APIENTRY alAuxiliaryEffectSlotfDirect(ALCcontext *context, ALuint effectslot, ALenum param, ALfloat flValue) AL_API_NOEXCEPT; +void AL_APIENTRY alAuxiliaryEffectSlotfvDirect(ALCcontext *context, ALuint effectslot, ALenum param, const ALfloat *pflValues) AL_API_NOEXCEPT; +void AL_APIENTRY alGetAuxiliaryEffectSlotiDirect(ALCcontext *context, ALuint effectslot, ALenum param, ALint *piValue) AL_API_NOEXCEPT; +void AL_APIENTRY alGetAuxiliaryEffectSlotivDirect(ALCcontext *context, ALuint effectslot, ALenum param, ALint *piValues) AL_API_NOEXCEPT; +void AL_APIENTRY alGetAuxiliaryEffectSlotfDirect(ALCcontext *context, ALuint effectslot, ALenum param, ALfloat *pflValue) AL_API_NOEXCEPT; +void AL_APIENTRY alGetAuxiliaryEffectSlotfvDirect(ALCcontext *context, ALuint effectslot, ALenum param, ALfloat *pflValues) AL_API_NOEXCEPT; + +void AL_APIENTRY alBufferDataStaticDirect(ALCcontext *context, ALuint buffer, ALenum format, ALvoid *data, ALsizei size, ALsizei freq) AL_API_NOEXCEPT; + +void AL_APIENTRY alDebugMessageCallbackDirectEXT(ALCcontext *context, ALDEBUGPROCEXT callback, void *userParam) AL_API_NOEXCEPT; +void AL_APIENTRY alDebugMessageInsertDirectEXT(ALCcontext *context, ALenum source, ALenum type, ALuint id, ALenum severity, ALsizei length, const ALchar *message) AL_API_NOEXCEPT; +void AL_APIENTRY alDebugMessageControlDirectEXT(ALCcontext *context, ALenum source, ALenum type, ALenum severity, ALsizei count, const ALuint *ids, ALboolean enable) AL_API_NOEXCEPT; +void AL_APIENTRY alPushDebugGroupDirectEXT(ALCcontext *context, ALenum source, ALuint id, ALsizei length, const ALchar *message) AL_API_NOEXCEPT; +void AL_APIENTRY alPopDebugGroupDirectEXT(ALCcontext *context) AL_API_NOEXCEPT; +ALuint AL_APIENTRY alGetDebugMessageLogDirectEXT(ALCcontext *context, ALuint count, ALsizei logBufSize, ALenum *sources, ALenum *types, ALuint *ids, ALenum *severities, ALsizei *lengths, ALchar *logBuf) AL_API_NOEXCEPT; +void AL_APIENTRY alObjectLabelDirectEXT(ALCcontext *context, ALenum identifier, ALuint name, ALsizei length, const ALchar *label) AL_API_NOEXCEPT; +void AL_APIENTRY alGetObjectLabelDirectEXT(ALCcontext *context, ALenum identifier, ALuint name, ALsizei bufSize, ALsizei *length, ALchar *label) AL_API_NOEXCEPT; +void* AL_APIENTRY alGetPointerDirectEXT(ALCcontext *context, ALenum pname) AL_API_NOEXCEPT; +void AL_APIENTRY alGetPointervDirectEXT(ALCcontext *context, ALenum pname, void **values) AL_API_NOEXCEPT; + +void AL_APIENTRY alRequestFoldbackStartDirect(ALCcontext *context, ALenum mode, ALsizei count, ALsizei length, ALfloat *mem, LPALFOLDBACKCALLBACK callback) AL_API_NOEXCEPT; +void AL_APIENTRY alRequestFoldbackStopDirect(ALCcontext *context) AL_API_NOEXCEPT; + +void AL_APIENTRY alBufferSubDataDirectSOFT(ALCcontext *context, ALuint buffer, ALenum format, const ALvoid *data, ALsizei offset, ALsizei length) AL_API_NOEXCEPT; + +void AL_APIENTRY alSourcedDirectSOFT(ALCcontext *context, ALuint source, ALenum param, ALdouble value) AL_API_NOEXCEPT; +void AL_APIENTRY alSource3dDirectSOFT(ALCcontext *context, ALuint source, ALenum param, ALdouble value1, ALdouble value2, ALdouble value3) AL_API_NOEXCEPT; +void AL_APIENTRY alSourcedvDirectSOFT(ALCcontext *context, ALuint source, ALenum param, const ALdouble *values) AL_API_NOEXCEPT; +void AL_APIENTRY alGetSourcedDirectSOFT(ALCcontext *context, ALuint source, ALenum param, ALdouble *value) AL_API_NOEXCEPT; +void AL_APIENTRY alGetSource3dDirectSOFT(ALCcontext *context, ALuint source, ALenum param, ALdouble *value1, ALdouble *value2, ALdouble *value3) AL_API_NOEXCEPT; +void AL_APIENTRY alGetSourcedvDirectSOFT(ALCcontext *context, ALuint source, ALenum param, ALdouble *values) AL_API_NOEXCEPT; +void AL_APIENTRY alSourcei64DirectSOFT(ALCcontext *context, ALuint source, ALenum param, ALint64SOFT value) AL_API_NOEXCEPT; +void AL_APIENTRY alSource3i64DirectSOFT(ALCcontext *context, ALuint source, ALenum param, ALint64SOFT value1, ALint64SOFT value2, ALint64SOFT value3) AL_API_NOEXCEPT; +void AL_APIENTRY alSourcei64vDirectSOFT(ALCcontext *context, ALuint source, ALenum param, const ALint64SOFT *values) AL_API_NOEXCEPT; +void AL_APIENTRY alGetSourcei64DirectSOFT(ALCcontext *context, ALuint source, ALenum param, ALint64SOFT *value) AL_API_NOEXCEPT; +void AL_APIENTRY alGetSource3i64DirectSOFT(ALCcontext *context, ALuint source, ALenum param, ALint64SOFT *value1, ALint64SOFT *value2, ALint64SOFT *value3) AL_API_NOEXCEPT; +void AL_APIENTRY alGetSourcei64vDirectSOFT(ALCcontext *context, ALuint source, ALenum param, ALint64SOFT *values) AL_API_NOEXCEPT; + +void AL_APIENTRY alDeferUpdatesDirectSOFT(ALCcontext *context) AL_API_NOEXCEPT; +void AL_APIENTRY alProcessUpdatesDirectSOFT(ALCcontext *context) AL_API_NOEXCEPT; + +const ALchar* AL_APIENTRY alGetStringiDirectSOFT(ALCcontext *context, ALenum pname, ALsizei index) AL_API_NOEXCEPT; + +void AL_APIENTRY alEventControlDirectSOFT(ALCcontext *context, ALsizei count, const ALenum *types, ALboolean enable) AL_API_NOEXCEPT; +void AL_APIENTRY alEventCallbackDirectSOFT(ALCcontext *context, ALEVENTPROCSOFT callback, void *userParam) AL_API_NOEXCEPT; +void* AL_APIENTRY alGetPointerDirectSOFT(ALCcontext *context, ALenum pname) AL_API_NOEXCEPT; +void AL_APIENTRY alGetPointervDirectSOFT(ALCcontext *context, ALenum pname, void **values) AL_API_NOEXCEPT; + +void AL_APIENTRY alBufferCallbackDirectSOFT(ALCcontext *context, ALuint buffer, ALenum format, ALsizei freq, ALBUFFERCALLBACKTYPESOFT callback, ALvoid *userptr) AL_API_NOEXCEPT; +void AL_APIENTRY alGetBufferPtrDirectSOFT(ALCcontext *context, ALuint buffer, ALenum param, ALvoid **ptr) AL_API_NOEXCEPT; +void AL_APIENTRY alGetBuffer3PtrDirectSOFT(ALCcontext *context, ALuint buffer, ALenum param, ALvoid **ptr0, ALvoid **ptr1, ALvoid **ptr2) AL_API_NOEXCEPT; +void AL_APIENTRY alGetBufferPtrvDirectSOFT(ALCcontext *context, ALuint buffer, ALenum param, ALvoid **ptr) AL_API_NOEXCEPT; + +void AL_APIENTRY alSourcePlayAtTimeDirectSOFT(ALCcontext *context, ALuint source, ALint64SOFT start_time) AL_API_NOEXCEPT; +void AL_APIENTRY alSourcePlayAtTimevDirectSOFT(ALCcontext *context, ALsizei n, const ALuint *sources, ALint64SOFT start_time) AL_API_NOEXCEPT; + +ALenum AL_APIENTRY EAXSetDirect(ALCcontext *context, const struct _GUID *property_set_id, ALuint property_id, ALuint source_id, ALvoid *value, ALuint value_size) AL_API_NOEXCEPT; +ALenum AL_APIENTRY EAXGetDirect(ALCcontext *context, const struct _GUID *property_set_id, ALuint property_id, ALuint source_id, ALvoid *value, ALuint value_size) AL_API_NOEXCEPT; +ALboolean AL_APIENTRY EAXSetBufferModeDirect(ALCcontext *context, ALsizei n, const ALuint *buffers, ALint value) AL_API_NOEXCEPT; +ALenum AL_APIENTRY EAXGetBufferModeDirect(ALCcontext *context, ALuint buffer, ALint *pReserved) AL_API_NOEXCEPT; +#endif +#endif + +#ifndef AL_SOFT_bformat_hoa +#define AL_SOFT_bformat_hoa +#define AL_UNPACK_AMBISONIC_ORDER_SOFT 0x199D +#endif + #ifdef __cplusplus } #endif +/* NOLINTEND */ #endif diff --git a/code/AL/efx-presets.h b/code/AL/efx-presets.h index 86dcbda2..acd5bf39 100644 --- a/code/AL/efx-presets.h +++ b/code/AL/efx-presets.h @@ -2,6 +2,7 @@ #ifndef EFX_PRESETS_H #define EFX_PRESETS_H +/* NOLINTBEGIN */ #ifndef EFXEAXREVERBPROPERTIES_DEFINED #define EFXEAXREVERBPROPERTIES_DEFINED @@ -345,7 +346,7 @@ typedef struct { /* Driving Presets */ #define EFX_REVERB_PRESET_DRIVING_COMMENTATOR \ - { 1.0000f, 0.0000f, 3.1623f, 0.5623f, 0.5012f, 2.4200f, 0.8800f, 0.6800f, 0.1995f, 0.0930f, { 0.0000f, 0.0000f, 0.0000f }, 0.2512f, 0.0170f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.2500f, 0.0000f, 0.9886f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } + { 1.0000f, 0.0000f, 0.3162f, 0.5623f, 0.5012f, 2.4200f, 0.8800f, 0.6800f, 0.1995f, 0.0930f, { 0.0000f, 0.0000f, 0.0000f }, 0.2512f, 0.0170f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.2500f, 0.0000f, 0.9886f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } #define EFX_REVERB_PRESET_DRIVING_PITGARAGE \ { 0.4287f, 0.5900f, 0.3162f, 0.7079f, 0.5623f, 1.7200f, 0.9300f, 0.8700f, 0.5623f, 0.0000f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0160f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.1100f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } @@ -399,4 +400,5 @@ typedef struct { #define EFX_REVERB_PRESET_SMALLWATERROOM \ { 1.0000f, 0.7000f, 0.3162f, 0.4477f, 1.0000f, 1.5100f, 1.2500f, 1.1400f, 0.8913f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.1790f, 0.1500f, 0.8950f, 0.1900f, 0.9920f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } +/* NOLINTEND */ #endif /* EFX_PRESETS_H */ diff --git a/code/AL/efx.h b/code/AL/efx.h index 57766983..1e93bf22 100644 --- a/code/AL/efx.h +++ b/code/AL/efx.h @@ -1,6 +1,8 @@ #ifndef AL_EFX_H #define AL_EFX_H +/* NOLINTBEGIN */ +#include #include "alc.h" #include "al.h" @@ -203,80 +205,80 @@ extern "C" { /* Effect object function types. */ -typedef void (AL_APIENTRY *LPALGENEFFECTS)(ALsizei, ALuint*); -typedef void (AL_APIENTRY *LPALDELETEEFFECTS)(ALsizei, const ALuint*); -typedef ALboolean (AL_APIENTRY *LPALISEFFECT)(ALuint); -typedef void (AL_APIENTRY *LPALEFFECTI)(ALuint, ALenum, ALint); -typedef void (AL_APIENTRY *LPALEFFECTIV)(ALuint, ALenum, const ALint*); -typedef void (AL_APIENTRY *LPALEFFECTF)(ALuint, ALenum, ALfloat); -typedef void (AL_APIENTRY *LPALEFFECTFV)(ALuint, ALenum, const ALfloat*); -typedef void (AL_APIENTRY *LPALGETEFFECTI)(ALuint, ALenum, ALint*); -typedef void (AL_APIENTRY *LPALGETEFFECTIV)(ALuint, ALenum, ALint*); -typedef void (AL_APIENTRY *LPALGETEFFECTF)(ALuint, ALenum, ALfloat*); -typedef void (AL_APIENTRY *LPALGETEFFECTFV)(ALuint, ALenum, ALfloat*); +typedef void (AL_APIENTRY *LPALGENEFFECTS)(ALsizei, ALuint*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALDELETEEFFECTS)(ALsizei, const ALuint*) AL_API_NOEXCEPT17; +typedef ALboolean (AL_APIENTRY *LPALISEFFECT)(ALuint) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALEFFECTI)(ALuint, ALenum, ALint) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALEFFECTIV)(ALuint, ALenum, const ALint*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALEFFECTF)(ALuint, ALenum, ALfloat) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALEFFECTFV)(ALuint, ALenum, const ALfloat*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETEFFECTI)(ALuint, ALenum, ALint*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETEFFECTIV)(ALuint, ALenum, ALint*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETEFFECTF)(ALuint, ALenum, ALfloat*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETEFFECTFV)(ALuint, ALenum, ALfloat*) AL_API_NOEXCEPT17; /* Filter object function types. */ -typedef void (AL_APIENTRY *LPALGENFILTERS)(ALsizei, ALuint*); -typedef void (AL_APIENTRY *LPALDELETEFILTERS)(ALsizei, const ALuint*); -typedef ALboolean (AL_APIENTRY *LPALISFILTER)(ALuint); -typedef void (AL_APIENTRY *LPALFILTERI)(ALuint, ALenum, ALint); -typedef void (AL_APIENTRY *LPALFILTERIV)(ALuint, ALenum, const ALint*); -typedef void (AL_APIENTRY *LPALFILTERF)(ALuint, ALenum, ALfloat); -typedef void (AL_APIENTRY *LPALFILTERFV)(ALuint, ALenum, const ALfloat*); -typedef void (AL_APIENTRY *LPALGETFILTERI)(ALuint, ALenum, ALint*); -typedef void (AL_APIENTRY *LPALGETFILTERIV)(ALuint, ALenum, ALint*); -typedef void (AL_APIENTRY *LPALGETFILTERF)(ALuint, ALenum, ALfloat*); -typedef void (AL_APIENTRY *LPALGETFILTERFV)(ALuint, ALenum, ALfloat*); +typedef void (AL_APIENTRY *LPALGENFILTERS)(ALsizei, ALuint*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALDELETEFILTERS)(ALsizei, const ALuint*) AL_API_NOEXCEPT17; +typedef ALboolean (AL_APIENTRY *LPALISFILTER)(ALuint) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALFILTERI)(ALuint, ALenum, ALint) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALFILTERIV)(ALuint, ALenum, const ALint*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALFILTERF)(ALuint, ALenum, ALfloat) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALFILTERFV)(ALuint, ALenum, const ALfloat*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETFILTERI)(ALuint, ALenum, ALint*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETFILTERIV)(ALuint, ALenum, ALint*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETFILTERF)(ALuint, ALenum, ALfloat*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETFILTERFV)(ALuint, ALenum, ALfloat*) AL_API_NOEXCEPT17; /* Auxiliary Effect Slot object function types. */ -typedef void (AL_APIENTRY *LPALGENAUXILIARYEFFECTSLOTS)(ALsizei, ALuint*); -typedef void (AL_APIENTRY *LPALDELETEAUXILIARYEFFECTSLOTS)(ALsizei, const ALuint*); -typedef ALboolean (AL_APIENTRY *LPALISAUXILIARYEFFECTSLOT)(ALuint); -typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTI)(ALuint, ALenum, ALint); -typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTIV)(ALuint, ALenum, const ALint*); -typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTF)(ALuint, ALenum, ALfloat); -typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTFV)(ALuint, ALenum, const ALfloat*); -typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTI)(ALuint, ALenum, ALint*); -typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTIV)(ALuint, ALenum, ALint*); -typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTF)(ALuint, ALenum, ALfloat*); -typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTFV)(ALuint, ALenum, ALfloat*); +typedef void (AL_APIENTRY *LPALGENAUXILIARYEFFECTSLOTS)(ALsizei, ALuint*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALDELETEAUXILIARYEFFECTSLOTS)(ALsizei, const ALuint*) AL_API_NOEXCEPT17; +typedef ALboolean (AL_APIENTRY *LPALISAUXILIARYEFFECTSLOT)(ALuint) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTI)(ALuint, ALenum, ALint) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTIV)(ALuint, ALenum, const ALint*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTF)(ALuint, ALenum, ALfloat) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTFV)(ALuint, ALenum, const ALfloat*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTI)(ALuint, ALenum, ALint*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTIV)(ALuint, ALenum, ALint*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTF)(ALuint, ALenum, ALfloat*) AL_API_NOEXCEPT17; +typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTFV)(ALuint, ALenum, ALfloat*) AL_API_NOEXCEPT17; #ifdef AL_ALEXT_PROTOTYPES -AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects); -AL_API ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, const ALuint *effects); -AL_API ALboolean AL_APIENTRY alIsEffect(ALuint effect); -AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint iValue); -AL_API ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, const ALint *piValues); -AL_API ALvoid AL_APIENTRY alEffectf(ALuint effect, ALenum param, ALfloat flValue); -AL_API ALvoid AL_APIENTRY alEffectfv(ALuint effect, ALenum param, const ALfloat *pflValues); -AL_API ALvoid AL_APIENTRY alGetEffecti(ALuint effect, ALenum param, ALint *piValue); -AL_API ALvoid AL_APIENTRY alGetEffectiv(ALuint effect, ALenum param, ALint *piValues); -AL_API ALvoid AL_APIENTRY alGetEffectf(ALuint effect, ALenum param, ALfloat *pflValue); -AL_API ALvoid AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *pflValues); +AL_API void AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alDeleteEffects(ALsizei n, const ALuint *effects) AL_API_NOEXCEPT; +AL_API ALboolean AL_APIENTRY alIsEffect(ALuint effect) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint iValue) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alEffectiv(ALuint effect, ALenum param, const ALint *piValues) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alEffectf(ALuint effect, ALenum param, ALfloat flValue) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alEffectfv(ALuint effect, ALenum param, const ALfloat *pflValues) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetEffecti(ALuint effect, ALenum param, ALint *piValue) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetEffectiv(ALuint effect, ALenum param, ALint *piValues) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetEffectf(ALuint effect, ALenum param, ALfloat *pflValue) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *pflValues) AL_API_NOEXCEPT; -AL_API ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters); -AL_API ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, const ALuint *filters); -AL_API ALboolean AL_APIENTRY alIsFilter(ALuint filter); -AL_API ALvoid AL_APIENTRY alFilteri(ALuint filter, ALenum param, ALint iValue); -AL_API ALvoid AL_APIENTRY alFilteriv(ALuint filter, ALenum param, const ALint *piValues); -AL_API ALvoid AL_APIENTRY alFilterf(ALuint filter, ALenum param, ALfloat flValue); -AL_API ALvoid AL_APIENTRY alFilterfv(ALuint filter, ALenum param, const ALfloat *pflValues); -AL_API ALvoid AL_APIENTRY alGetFilteri(ALuint filter, ALenum param, ALint *piValue); -AL_API ALvoid AL_APIENTRY alGetFilteriv(ALuint filter, ALenum param, ALint *piValues); -AL_API ALvoid AL_APIENTRY alGetFilterf(ALuint filter, ALenum param, ALfloat *pflValue); -AL_API ALvoid AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *pflValues); +AL_API void AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alDeleteFilters(ALsizei n, const ALuint *filters) AL_API_NOEXCEPT; +AL_API ALboolean AL_APIENTRY alIsFilter(ALuint filter) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alFilteri(ALuint filter, ALenum param, ALint iValue) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alFilteriv(ALuint filter, ALenum param, const ALint *piValues) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alFilterf(ALuint filter, ALenum param, ALfloat flValue) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alFilterfv(ALuint filter, ALenum param, const ALfloat *pflValues) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetFilteri(ALuint filter, ALenum param, ALint *piValue) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetFilteriv(ALuint filter, ALenum param, ALint *piValues) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetFilterf(ALuint filter, ALenum param, ALfloat *pflValue) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *pflValues) AL_API_NOEXCEPT; -AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots); -AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, const ALuint *effectslots); -AL_API ALboolean AL_APIENTRY alIsAuxiliaryEffectSlot(ALuint effectslot); -AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint iValue); -AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, const ALint *piValues); -AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat flValue); -AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, const ALfloat *pflValues); -AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint *piValue); -AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, ALint *piValues); -AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat *pflValue); -AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, ALfloat *pflValues); +AL_API void AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, const ALuint *effectslots) AL_API_NOEXCEPT; +AL_API ALboolean AL_APIENTRY alIsAuxiliaryEffectSlot(ALuint effectslot) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint iValue) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, const ALint *piValues) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat flValue) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, const ALfloat *pflValues) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint *piValue) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, ALint *piValues) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat *pflValue) AL_API_NOEXCEPT; +AL_API void AL_APIENTRY alGetAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, ALfloat *pflValues) AL_API_NOEXCEPT; #endif /* Filter ranges and defaults. */ @@ -757,5 +759,6 @@ AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotfv(ALuint effectslot, ALenum p #ifdef __cplusplus } /* extern "C" */ #endif +/* NOLINTEND */ #endif /* AL_EFX_H */ diff --git a/code/Launcher/CMakeLists.txt b/code/Launcher/CMakeLists.txt new file mode 100644 index 00000000..133435ff --- /dev/null +++ b/code/Launcher/CMakeLists.txt @@ -0,0 +1,38 @@ +cmake_minimum_required(VERSION 3.12) + +project(Launcher) + +set(LAUNCHER_SOURCES "${CMAKE_SOURCE_DIR}/code/Launcher/launch_main.cpp") + +if (WIN32) + set(LAUNCHER_SOURCES ${LAUNCHER_SOURCES} + "${CMAKE_SOURCE_DIR}/code/Launcher/launch_win32.cpp" + "${CMAKE_SOURCE_DIR}/code/sys/win_resource.rc") +else() + set(LAUNCHER_SOURCES ${LAUNCHER_SOURCES} + "${CMAKE_SOURCE_DIR}/code/Launcher/launch_linux.cpp") +endif() + +function (create_launcher name type) + if (NOT BUILD_NO_CLIENT) + add_executable(openmohaa_launcher_${name} ${LAUNCHER_SOURCES}) + target_include_directories(openmohaa_launcher_${name} PUBLIC "../qcommon") + target_compile_definitions(openmohaa_launcher_${name} PRIVATE NO_RC_MANIFEST=1 TARGET_GAME=${type}) + target_compile_features(openmohaa_launcher_${name} PRIVATE cxx_std_17) + set_target_properties(openmohaa_launcher_${name} PROPERTIES OUTPUT_NAME "launch_openmohaa_${name}${TARGET_BIN_SUFFIX}") + + INSTALL(TARGETS openmohaa_launcher_${name} DESTINATION ${CMAKE_INSTALL_BINDIR}/${BIN_INSTALL_SUBDIR}) + endif() + + #add_executable(omohaaded_launcher_${name} ${LAUNCHER_SOURCES}) + #target_include_directories(omohaaded_launcher_${name} PUBLIC "../qcommon") + #target_compile_definitions(omohaaded_launcher_${name} PRIVATE NO_RC_MANIFEST=1 TARGET_GAME=${type} DEDICATED=1) + #target_compile_features(omohaaded_launcher_${name} PRIVATE cxx_std_17) + #set_target_properties(omohaaded_launcher_${name} PROPERTIES OUTPUT_NAME "launch_omohaaded_${name}${TARGET_BIN_SUFFIX}") + # + #INSTALL(TARGETS omohaaded_launcher_${name} DESTINATION ${CMAKE_INSTALL_BINDIR}/${PROJECT_INSTALL_SUBDIR}) +endfunction() + +create_launcher(base 0) +create_launcher(spearhead 1) +create_launcher(breakthrough 2) diff --git a/code/renderer/tr_vis.cpp b/code/Launcher/launch.h similarity index 74% rename from code/renderer/tr_vis.cpp rename to code/Launcher/launch.h index 0236e4e9..3ac1ff8c 100644 --- a/code/renderer/tr_vis.cpp +++ b/code/Launcher/launch.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -20,15 +20,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -// tr_vis.cpp: visibility culling +// launch.h: Base interface for starting programs -#include "tr_local.h" -#include "tr_vis.h" +#include "q_platform.h" -void R_VisDebug() { - // FIXME: unimplemented -} +#include +#include +#include -void R_VisDebugLoad(const char* szBSPName) { - // FIXME: unimplemented -} +std::filesystem::path GetProgramLocation(); +void LaunchProgram(const std::filesystem::path& path, const std::vector& argumentList); diff --git a/code/Launcher/launch_linux.cpp b/code/Launcher/launch_linux.cpp new file mode 100644 index 00000000..ee7e7764 --- /dev/null +++ b/code/Launcher/launch_linux.cpp @@ -0,0 +1,80 @@ +/* +=========================================================================== +Copyright (C) 2024 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA source code 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. + +OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// main.cpp: Windows implementation of the launcher + +#include "launch.h" + +#include +#include +#include +#include + +#include +#include + +extern "C" char** environ; + +std::filesystem::path GetProgramLocation() +{ + char path[FILENAME_MAX]; + ssize_t count = readlink("/proc/self/exe", path, FILENAME_MAX); + + return std::filesystem::path(std::string(path, (count > 0) ? count : 0)).parent_path(); +} + +void LaunchProgram(const std::filesystem::path& path, const std::vector& argumentList) +{ + pid_t pid; + std::string pathString = path.string(); + size_t argCount = argumentList.size(); + char** argv; + int status; + + argv = new char*[argCount + 2]; + argv[0] = (char*)pathString.c_str(); + + for (size_t i = 0; i < argCount; i++) { + argv[i + 1] = (char*)argumentList[i].c_str(); + } + argv[argCount + 1] = NULL; + + //status = posix_spawn(&pid, pathString.c_str(), NULL, NULL, argv, environ); + //delete[] argv; + //if (status != 0) { + // std::cout << "posix_spawn returned error: " << status << std::endl; + // return; + //} + + // + // Using execve rather than posix_spawn + // This replaces the current process that is not needed anyway + // + status = execve(pathString.c_str(), argv, environ); + delete[] argv; + if (status == -1) { + std::cout << "posix_spawn returned error: " << errno << std::endl; + return; + } + + waitpid(pid, NULL, 0); +} diff --git a/code/Launcher/launch_main.cpp b/code/Launcher/launch_main.cpp new file mode 100644 index 00000000..afefd20a --- /dev/null +++ b/code/Launcher/launch_main.cpp @@ -0,0 +1,67 @@ +/* +=========================================================================== +Copyright (C) 2024 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA source code 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. + +OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// main.cpp: The launcher + +#include "launch.h" + +#include +#include +#include + +const char* targetGameList[] = +{ + "Base", + "Spearhead", + "Breakthrough" +}; + +int main(int argc, const char* argv[]) { + std::vector argumentList; +#if !defined(DEDICATED) || !DEDICATED + const char* programName = "openmohaa" ARCH_SUFFIX DLL_SUFFIX EXE_EXT; +#else + const char* programName = "omohaaded" ARCH_SUFFIX DLL_SUFFIX EXE_EXT; +#endif + + argumentList.push_back("+set"); + argumentList.push_back("com_target_game"); + argumentList.push_back(std::to_string(TARGET_GAME)); + + for (size_t i = 1; i < argc; i++) { + argumentList.push_back(argv[i]); + } + + std::cout << "Using the target game: " << targetGameList[TARGET_GAME] << std::endl; + std::cout << std::endl; + std::cout << "Expected program name: " << programName << std::endl; + + const std::filesystem::path programLocation = GetProgramLocation(); + const std::filesystem::path programPath = programLocation / programName; + + std::cout << "Program location: " << programLocation << std::endl; + std::cout << "Expected path: " << programPath << std::endl; + + LaunchProgram(programPath, argumentList); + + return 0; +} diff --git a/code/Launcher/launch_win32.cpp b/code/Launcher/launch_win32.cpp new file mode 100644 index 00000000..ed506df7 --- /dev/null +++ b/code/Launcher/launch_win32.cpp @@ -0,0 +1,87 @@ +/* +=========================================================================== +Copyright (C) 2024 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA source code 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. + +OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// main.cpp: Windows implementation of the launcher + +#include "launch.h" + +#include +#include +#include + +std::filesystem::path GetProgramLocation() +{ + wchar_t path[FILENAME_MAX] = { 0 }; + GetModuleFileNameW(nullptr, path, FILENAME_MAX); + + return std::filesystem::path(path).parent_path(); +} + +void LaunchProgram(const std::filesystem::path& path, const std::vector& argumentList) +{ + PROCESS_INFORMATION processInfo; + STARTUPINFOW startupInfo; + BOOL returnValue; + std::wstring osCommandLine; + std::wstring commandLine; + size_t argCount = argumentList.size(); + + memset(&processInfo, 0, sizeof(processInfo)); + memset(&startupInfo, 0, sizeof(startupInfo)); + startupInfo.cb = sizeof(startupInfo); + + for (size_t i = 0; i < argCount; i++) { + commandLine += L"\""; + commandLine += std::wstring(argumentList[i].begin(), argumentList[i].end()); + commandLine += L"\""; + if (i != argCount - 1) { + commandLine += L" "; + } + } + + osCommandLine = path.wstring(); + osCommandLine += L" "; + osCommandLine += commandLine; + + returnValue = CreateProcessW( + path.wstring().c_str(), + (LPWSTR)osCommandLine.c_str(), + NULL, + NULL, + FALSE, + 0, + NULL, + std::filesystem::current_path().wstring().c_str(), + &startupInfo, + &processInfo + ); + + if (!returnValue) { + std::cout << "Error in CreateProcess: " << GetLastError() << std::endl; + return; + } + + WaitForSingleObject(processInfo.hProcess, INFINITE); + + CloseHandle(processInfo.hProcess); + CloseHandle(processInfo.hThread); +} diff --git a/code/autoupdater/autoupdater.c b/code/autoupdater/autoupdater.c index 4a052027..e013a1f4 100644 --- a/code/autoupdater/autoupdater.c +++ b/code/autoupdater/autoupdater.c @@ -933,10 +933,13 @@ static void waitToApplyUpdates(void) OS forcibly closes the pipe), we will unblock. Then we can loop on kill() until the process is truly gone. */ int x = 0; + struct timespec req; + req.tv_sec = 0; + req.tv_nsec = 100000000; read(3, &x, sizeof (x)); info("Pipe has closed, waiting for process to fully go away now."); while (kill(options.waitforprocess, 0) == 0) { - usleep(100000); + nanosleep(&req, NULL); } #endif } diff --git a/code/cgame/CMakeLists.txt b/code/cgame/CMakeLists.txt index 1ec5a6a2..a0423773 100644 --- a/code/cgame/CMakeLists.txt +++ b/code/cgame/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(cgame) # Shared source files for modules @@ -27,16 +27,11 @@ target_compile_features(cgame PUBLIC cxx_nullptr) target_compile_features(cgame PUBLIC c_variadic_macros) target_link_libraries(cgame PUBLIC qcommon) -set_target_properties(cgame PROPERTIES PREFIX "${TARGET_PLATFORM_PREFIX}") -set_target_properties(cgame PROPERTIES OUTPUT_NAME "cgame${TARGET_ARCH_SUFFIX}") -set_target_properties(cgame PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${TARGET_BASE_GAME}") +set_target_properties(cgame PROPERTIES PREFIX "") +set_target_properties(cgame PROPERTIES OUTPUT_NAME "cgame${TARGET_BIN_SUFFIX}") -INSTALL( - TARGETS cgame - LIBRARY DESTINATION "${TARGET_BASE_GAME}" - RUNTIME DESTINATION "${TARGET_BASE_GAME}" -) +INSTALL(TARGETS cgame DESTINATION ${CMAKE_INSTALL_LIBDIR}/${LIB_INSTALL_SUBDIR}) if(MSVC) - INSTALL(FILES $ DESTINATION "${TARGET_BASE_GAME}" OPTIONAL) + INSTALL(FILES $ DESTINATION ${CMAKE_INSTALL_LIBDIR}/${LIB_INSTALL_SUBDIR} OPTIONAL) endif() \ No newline at end of file diff --git a/code/cgame/cg_archive.cpp b/code/cgame/cg_archive.cpp index 3a1b260e..3d944fb9 100644 --- a/code/cgame/cg_archive.cpp +++ b/code/cgame/cg_archive.cpp @@ -113,7 +113,7 @@ void CG_ArchiveModelHandle(MemArchiver& archiver, qhandle_t* handle) if (tmp.length()) { *handle = cgi.R_RegisterModel(tmp.c_str()); } else { - *handle = NULL; + *handle = (qhandle_t)0; } } else { if (*handle) { @@ -135,7 +135,7 @@ void CG_ArchiveShaderHandle(MemArchiver& archiver, qhandle_t* handle) if (tmp.length()) { *handle = cgi.R_RegisterShader(tmp.c_str()); } else { - *handle = NULL; + *handle = (qhandle_t)0; } } else { if (*handle) { @@ -163,7 +163,7 @@ void CG_ArchiveRefEntity(MemArchiver& archiver, refEntity_t* ref) archiver.ArchiveVec3(ref->axis[2]); archiver.ArchiveBoolean(&ref->nonNormalizedAxes); archiver.ArchiveVec3(ref->origin); - archiver.ArchiveRaw(ref->frameInfo, 192); + archiver.ArchiveRaw(ref->frameInfo, sizeof(ref->frameInfo)); archiver.ArchiveFloat(&ref->actionWeight); archiver.ArchiveShort(&ref->wasframe); archiver.ArchiveFloat(&ref->scale); @@ -171,7 +171,7 @@ void CG_ArchiveRefEntity(MemArchiver& archiver, refEntity_t* ref) archiver.ArchiveInteger(&ref->skinNum); CG_ArchiveShaderHandle(archiver, &ref->customShader); - archiver.ArchiveRaw(ref->shaderRGBA, 4); + archiver.ArchiveRaw(ref->shaderRGBA, sizeof(ref->shaderRGBA)); archiver.ArchiveFloat(ref->shaderTexCoord); archiver.ArchiveFloat(&ref->shaderTexCoord[1]); archiver.ArchiveFloat(&ref->shaderTime); diff --git a/code/cgame/cg_commands.cpp b/code/cgame/cg_commands.cpp index 6103d7a9..0ccee1bc 100644 --- a/code/cgame/cg_commands.cpp +++ b/code/cgame/cg_commands.cpp @@ -196,7 +196,8 @@ Event EV_Client_SetColorVelocity "rVel gVel bVel", "Set the color velocity of the spawned dlight tempmodel" ); -Event EV_Client_SetRandomVelocity( +Event EV_Client_SetRandomVelocity +( "randvel", EV_DEFAULT, "SfFSfFSfF", @@ -210,7 +211,8 @@ Event EV_Client_SetRandomVelocity( "without randomness.\n" "This velocity is applied using the world axis" ); -Event EV_Client_SetRandomVelocityAlongAxis( +Event EV_Client_SetRandomVelocityAlongAxis +( "randvelaxis", EV_DEFAULT, "SfFSfFSfF", @@ -225,6 +227,14 @@ Event EV_Client_SetRandomVelocityAlongAxis( "without randomness.\n" "This velocity is applied using the parent axis" ); +Event EV_Client_NoTagAxis +( + "notagaxis", + EV_DEFAULT, + NULL, + NULL, + "Forces the effect to use the model's orientation for randvelaxis and offsetalongaxis" +); Event EV_Client_SetAccel ( "accel", @@ -554,7 +564,16 @@ Event EV_Client_LoopSound EV_DEFAULT, "sFFf", "soundName volume min_distance pitch", - "Play the specifed sound as a looping sound" + "Play the specified sound as a looping sound" +); +// Added in 2.0 +Event EV_Client_StopLoopSound +( + "stoploopsound", + EV_DEFAULT, + NULL, + NULL, + "Stop the looping sound" ); Event EV_Client_Cache ( @@ -975,7 +994,7 @@ Event EV_Client_BounceDecal( "maxamount temporary", "Put a mark when the tempmodel bounces and hits a surface\n" "maxamount = Max amount of decals to make when bouncing\n" - "temporary = specify 1 for a temporary mark that only appears for a short time, 0 for a decal that stays aroung " + "temporary = specify 1 for a temporary mark that only appears for a short time, 0 for a decal that stays around " "longer (default is 0)\n" ); Event EV_Client_SetDecalRadius @@ -1075,6 +1094,15 @@ Event EV_Client_Print "string", "Prints a string." ); +// Added in 2.0 +Event EV_Client_PrintDeathMsg +( + "printdeathmsg", + EV_DEFAULT, + "sssss", + "msg1, msg2, killer, victim, deathType", + "Prints a death message string. Used to allow death messages to appear in their correct language on client machines.." +); Event EV_Client_SetVolumetric ( "volumetric", @@ -1112,7 +1140,7 @@ Event EV_Client_SetAlignStretch( EV_DEFAULT, "F", "scaleMultiplier", - "Aligns the temp model to the direction of travel, and stretches it betwen the last and current positions.\n" + "Aligns the temp model to the direction of travel, and stretches it between the last and current positions.\n" ); Event EV_Client_SetClampVelocity ( @@ -1185,6 +1213,14 @@ Event EV_Client_SFXStartDelayed "fDelay sCommand arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8", "Used for adding commands to a special effect with a time delay" ); +Event EV_Client_PlayForceFeedback +( + "playforcefeedback", + EV_DEFAULT, + "s", + "effectname", + "Starts a force feedback effect." +); EffectsEventQueueNode EffectsEventQueue; @@ -1221,6 +1257,7 @@ CLASS_DECLARATION(Listener, ClientGameCommandManager, NULL) { {&EV_Client_SetColorVelocity, &ClientGameCommandManager::SetAngularVelocity }, {&EV_Client_SetRandomVelocity, &ClientGameCommandManager::SetRandomVelocity }, {&EV_Client_SetRandomVelocityAlongAxis, &ClientGameCommandManager::SetRandomVelocityAlongAxis}, + {&EV_Client_NoTagAxis, &ClientGameCommandManager::SetNoTagAxis }, {&EV_Client_SetAccel, &ClientGameCommandManager::SetAccel }, {&EV_Client_SetFriction, &ClientGameCommandManager::SetFriction }, {&EV_Client_SetSpin, &ClientGameCommandManager::SetSpin }, @@ -1250,6 +1287,7 @@ CLASS_DECLARATION(Listener, ClientGameCommandManager, NULL) { {&EV_Client_StopSound, &ClientGameCommandManager::StopSound }, {&EV_Client_StopAliasChannel, &ClientGameCommandManager::StopAliasChannel }, {&EV_Client_LoopSound, &ClientGameCommandManager::LoopSound }, + {&EV_Client_StopLoopSound, &ClientGameCommandManager::StopLoopSound }, {&EV_Client_Cache, &ClientGameCommandManager::Cache }, {&EV_Client_CacheImage, &ClientGameCommandManager::CacheImage }, {&EV_Client_CacheFont, &ClientGameCommandManager::CacheFont }, @@ -1312,6 +1350,7 @@ CLASS_DECLARATION(Listener, ClientGameCommandManager, NULL) { {&EV_Client_SetClampVelocity, &ClientGameCommandManager::SetClampVel }, {&EV_Client_SetClampVelocityAxis, &ClientGameCommandManager::SetClampVelAxis }, {&EV_Client_Print, &ClientGameCommandManager::Print }, + {&EV_Client_PrintDeathMsg, &ClientGameCommandManager::PrintDeathMsg }, {&EV_Client_EyeLimits, &ClientGameCommandManager::SetEyeLimits }, {&EV_Client_EyeMovement, &ClientGameCommandManager::SetEyeMovement }, {&EV_Client_SFXStart, &ClientGameCommandManager::StartSFX }, @@ -1383,9 +1422,11 @@ qboolean ClientGameCommandManager::PostEventForEntity(Event *ev, float fWait) EffectsEventQueueNode *node; int inttime; - if (!m_fEventWait || current_entity_number < 0) { - if (!str::icmp(ev->getName(), ")")) { - m_fEventWait = 0.0; + if (m_fEventWait < 0 || current_entity_number < 0) { + if (m_fEventWait != 0.0) { + if (!str::icmp(ev->getName(), ")")) { + m_fEventWait = 0.0; + } } delete ev; @@ -1402,7 +1443,7 @@ qboolean ClientGameCommandManager::PostEventForEntity(Event *ev, float fWait) event = EffectsEventQueue.next; inttime = EVENT_msec + (fWait * 1000.0f + 0.5f); - while (event != &EffectsEventQueue && inttime > event->inttime) { + while (event != &EffectsEventQueue && inttime >= event->inttime) { event = event->next; } @@ -1438,8 +1479,8 @@ void ClientGameCommandManager::SetBaseAndAmplitude(Event *ev, Vector& base, Vect base[j] = ev->GetFloat(i++); amplitude[j] = ev->GetFloat(i++); } else { - base[j] = 0.0; - amplitude[j] = atof(org.c_str()); + base[j] = atof(org.c_str()); + amplitude[j] = 0.0; } } } @@ -1462,6 +1503,13 @@ void ClientGameCommandManager::Print(Event *ev) } } +void ClientGameCommandManager::PrintDeathMsg(Event* ev) +{ + if (current_entity) { + cgi.DPrintf("%d:%s\n", current_entity->entityNumber, ev->GetString(1).c_str()); + } +} + qboolean ClientGameCommandManager::IsBlockCommand(const str& name) { if (!str::icmp(name, "originspawn")) { @@ -1541,7 +1589,6 @@ void ClientGameCommandManager::CommandDelay(Event *ev) ev1->AddValue(ev->GetValue(i)); } - delay = ev->GetFloat(1) * 1000; if (current_entity_number != -1) { PostEventForEntity(ev1, fWait); } else { @@ -1551,6 +1598,16 @@ void ClientGameCommandManager::CommandDelay(Event *ev) current_tiki->name ); } + + if (IsBlockCommand(eventName)) { + m_fEventWait = fWait; + } else { + m_fEventWait = 0; + } + + if (current_entity_number == -1 && m_fEventWait > 0) { + m_fEventWait = -1; + } } void ClientGameCommandManager::StartSFX(Event *ev) @@ -2157,7 +2214,9 @@ void ClientGameCommandManager::SetInwardSphere(Event *ev) } m_spawnthing->cgd.flags |= T_INWARDSPHERE; - m_spawnthing->sphereRadius = ev->GetFloat(1); + if (ev->NumArgs() > 0) { + m_spawnthing->sphereRadius = ev->GetFloat(1); + } } //============= @@ -2586,7 +2645,9 @@ void ClientGameCommandManager::SetColorRange(Event *ev) return; } - // FIXME: unused stub?? + // + // Unused + // } //============= @@ -2666,6 +2727,15 @@ void ClientGameCommandManager::SetRandomVelocityAlongAxis(Event *ev) SetRandomVelocity(ev); } +void ClientGameCommandManager::SetNoTagAxis(Event* ev) +{ + if (!m_spawnthing) { + return; + } + + m_spawnthing->cgd.flags2 |= T2_NOTAGAXIS; +} + void ClientGameCommandManager::SetRadialVelocity(Event *ev) { if (!m_spawnthing) { @@ -2803,7 +2873,9 @@ void ClientGameCommandManager::SetAccel(Event *ev) m_spawnthing->cgd.accel[1] = ev->GetFloat(2); m_spawnthing->cgd.accel[2] = ev->GetFloat(3); - m_spawnthing->cgd.flags2 |= T2_ACCEL; + if (!(m_spawnthing->cgd.flags & T_SWARM)) { + m_spawnthing->cgd.flags2 |= T2_ACCEL; + } } void ClientGameCommandManager::SetFriction(Event *ev) @@ -3032,7 +3104,7 @@ spawnthing_t *ClientGameCommandManager::InitializeSpawnthing(spawnthing_t *sp) sp->cgd.parent = -1; sp->cgd.tiki = nullptr; sp->cgd.lightstyle = -1; - sp->cgd.physicsRate = 10; + sp->cgd.physicsRate = cg_effect_physicsrate->integer; sp->cgd.shadername = "beamshader"; sp->cgd.decal_orientation = 0; sp->cgd.decal_radius = 10; @@ -3794,7 +3866,7 @@ void ClientGameCommandManager::PlaySound( } if (!name || !soundAlias) { - Com_Printf( + cgi.DPrintf( "\nERROR PlaySound: %s needs an alias in ubersound.scr or uberdialog.scr - Please fix.\n", sound_name.c_str() ); @@ -3851,7 +3923,7 @@ void ClientGameCommandManager::PlaySound( } else { if (debugSound->integer) { Com_Printf( - "\nWARNING: OVERRIDE OVERRIDE OVERRIDESound %s had all its parm overriden by code.\n\n", + "\nWARNING: OVERRIDE OVERRIDE OVERRIDESound %s had all its parm overridden by code.\n\n", sound_name.c_str() ); } @@ -3965,6 +4037,9 @@ void ClientGameCommandManager::StopSound(Event *ev) cgi.S_StopSound(current_entity_number, channel); } +//=============== +// StopAliasChannel +//=============== void ClientGameCommandManager::StopAliasChannel(Event *ev) { str sound_name; @@ -3991,7 +4066,7 @@ void ClientGameCommandManager::StopAliasChannel(Event *ev) } if (!name || !soundAlias) { - Com_Printf("\nERROR stopaliaschannel: couldn't find alias %s\n", sound_name.c_str()); + cgi.DPrintf("\nERROR stopaliaschannel: couldn't find alias %s\n", sound_name.c_str()); return; } @@ -4060,6 +4135,54 @@ void ClientGameCommandManager::LoopSound(Event *ev) current_centity->tikiLoopSoundFlags = 0; } +//=============== +// StopLoopSound +//=============== +void ClientGameCommandManager::StopLoopSound(Event* ev) +{ + if (!current_centity) { + cgi.DPrintf("CCM::StopLoopSound : StopLoopSound in %s without current_centity\n", cgi.TIKI_Name(current_tiki)); + return; + } + + cgi.DPrintf("\n\nClientGameCommandManager::StopLoopSound\n\n"); + current_centity->tikiLoopSound = (sfxHandle_t)0; +} + +//=============== +// CacheImageResource +//=============== +void CacheImageResource(const char* stuff) { + str real_stuff; + char filename[1024]; + + if (cgi.fsDebug->integer == 2) { + Com_Printf("client cacheimage: %s\n", stuff); + } + + Q_strncpyz(filename, stuff, sizeof(filename)); + cgi.FS_CanonicalFilename(filename); + + cgi.R_RegisterShaderNoMip(filename); +} + +//=============== +// CacheFontResource +//=============== +void CacheFontResource(const char* stuff) { + str real_stuff; + char filename[1024]; + + if (cgi.fsDebug->integer == 2) { + Com_Printf("client cacheimage: %s\n", stuff); + } + + Q_strncpyz(filename, stuff, sizeof(filename)); + cgi.FS_CanonicalFilename(filename); + + cgi.R_LoadFont(filename); +} + //=============== // CacheResource //=============== @@ -4099,12 +4222,12 @@ void ClientGameCommandManager::Cache(Event *ev) void ClientGameCommandManager::CacheImage(Event *ev) { - // FIXME: stub + CacheImageResource(ev->GetString(1).c_str()); } void ClientGameCommandManager::CacheFont(Event *ev) { - // FIXME: stub + CacheFontResource(ev->GetString(1).c_str()); } //=============== @@ -4112,15 +4235,16 @@ void ClientGameCommandManager::CacheFont(Event *ev) //=============== void AliasResource(dtiki_t *pmdl, const char *alias, const char *realname, const char *parameters) { - if (pmdl) { - if (!pmdl->a->alias_list) { - pmdl->a->alias_list = cgi.AliasList_New(pmdl->a->name); - } - - cgi.Alias_ListAdd((AliasList_t *)pmdl->a->alias_list, alias, realname, parameters); - } else { + if (!pmdl) { cgi.Alias_Add(alias, realname, parameters); + return; } + + if (!pmdl->a->alias_list) { + pmdl->a->alias_list = cgi.AliasList_New(pmdl->a->name); + } + + cgi.Alias_ListAdd((AliasList_t*)pmdl->a->alias_list, alias, realname, parameters); } qboolean bLoadForMap(const char *psMapsBuffer, const char *name) @@ -4141,7 +4265,7 @@ qboolean bLoadForMap(const char *psMapsBuffer, const char *name) } if (!token || !token[0]) { - Com_Printf("ERROR bLoadForMap: %s alias with empty maps specification.\n", name); + cgi.DPrintf("ERROR bLoadForMap: %s alias with empty maps specification.\n", name); return false; } @@ -4181,19 +4305,32 @@ void ClientGameCommandManager::AliasCache(Event *ev) psMapsBuffer = NULL; for (i = 3; i <= ev->NumArgs(); i++) { - if (!strcmp(ev->GetToken(i).c_str(), "maps")) { + str s = ev->GetString(i); + + if (!s.icmp("maps")) { i++; - psMapsBuffer = ev->GetToken(i); - } else if (!strcmp(ev->GetToken(i).c_str(), "always")) { - bAlwaysLoaded = true; - } else { - strcat(parmbuffer, ev->GetToken(i)); - strcat(parmbuffer, " "); + psMapsBuffer = (char *)ev->GetToken(i).c_str(); + continue; } + + if (!s.icmp("always")) { + bAlwaysLoaded = true; + continue; + } + + strcat(parmbuffer, s); + strcat(parmbuffer, " "); } - if (bAlwaysLoaded || bLoadForMap(psMapsBuffer, ev->GetString(1))) { + if (bAlwaysLoaded) { AliasResource(current_tiki, ev->GetString(1), ev->GetString(2), parmbuffer); + } + + if (bLoadForMap(psMapsBuffer, ev->GetString(1))) { + if (!bAlwaysLoaded) { + AliasResource(current_tiki, ev->GetString(1), ev->GetString(2), parmbuffer); + } + CacheResource(ev->GetString(2)); } } @@ -4223,28 +4360,33 @@ void ClientGameCommandManager::Alias(Event *ev) psMapsBuffer = NULL; for (i = 3; i <= ev->NumArgs(); i++) { - if (!strcmp(ev->GetToken(i).c_str(), "maps")) { + str s = ev->GetString(i); + + if (!s.icmp("maps")) { i++; - psMapsBuffer = ev->GetToken(i); - } else if (!strcmp(ev->GetToken(i).c_str(), "always")) { + psMapsBuffer = (char *)ev->GetToken(i).c_str(); + continue; + } + + if (!s.icmp("always")) { bAlwaysLoaded = true; + } else if (subtitle) { + strcat(parmbuffer, "\""); + strcat(parmbuffer, s); + strcat(parmbuffer, "\" "); + + subtitle = 0; } else { + subtitle = s.icmp("subtitle") == 0; + if (!subtitle) { - if (!Q_stricmp(ev->GetToken(i), "subtitle") || !Q_stricmp(ev->GetToken(i), "forcesubtitle")) { - subtitle = qtrue; - strcat(parmbuffer, ev->GetToken(i)); - } else { - strcat(parmbuffer, ev->GetToken(i)); - } - } else { - strcat(parmbuffer, "\""); - strcat(parmbuffer, ev->GetToken(i)); - strcat(parmbuffer, "\""); - subtitle = qfalse; + subtitle = s.icmp("forcesubtitle") == 0; } - strcat(parmbuffer, " "); + strcat(parmbuffer, s); } + + strcat(parmbuffer, " "); } if (bAlwaysLoaded || bLoadForMap(psMapsBuffer, ev->GetString(1))) { @@ -4976,7 +5118,15 @@ bool ClientGameCommandManager::GetTagPositionAndOrientation(str tagname, orienta //=============== void ClientGameCommandManager::RestartAllEmitters(void) { - // FIXME: stub?? + ctempmodel_t *p; + + // + // FIXME: not sure if it's the right thing + // + + for (p = m_active_tempmodels.prev; p != &m_active_tempmodels; p = p->next) { + p->cgd.createTime = cg.time; + } } //=============== @@ -5029,7 +5179,7 @@ void CG_ProcessInitCommands(dtiki_t *tiki, refEntity_t *ent) } if (!commandManager.SelectProcessEvent(ev)) { - Com_Printf( + cgi.DPrintf( "^~^~^ CG_ProcessInitCommands: Bad init client command '%s' in '%s'\n", pcmd->args[0], tiki->name ); } @@ -5075,7 +5225,7 @@ void CG_ProcessCacheInitCommands(dtiki_t *tiki) } if (!commandManager.SelectProcessEvent(ev)) { - Com_Printf( + cgi.DPrintf( "^~^~^ CG_ProcessInitCommands: Bad init client command '%s' in '%s'\n", pcmd->args[0], tiki->name ); } @@ -5148,7 +5298,7 @@ qboolean CG_ProcessEntityCommands(int frame, int anim, int entnum, refEntity_t * current_centity = cent; current_entity_number = entnum; current_tiki = ent->tiki; - CG_AnimationDebugMessage(entnum, "Processing Ent Commands: Entity: %3d Anim:#(%i) Frame:#(%i)\n", anim, frame); + CG_AnimationDebugMessage(entnum, "Processing Ent Commands: Entity: %3d Anim:#(%i) Frame:#(%i)\n", entnum, anim, frame); for (i = 0; i < tikicmds.num_cmds; i++) { Event *ev; @@ -5187,7 +5337,7 @@ void CG_ClientCommandDebugMessage(centity_t *cent, const char *fmt, ...) char msg[1024]; va_start(argptr, fmt); - vsprintf(msg, fmt, argptr); + Q_vsnprintf(msg, sizeof(msg), fmt, argptr); va_end(argptr); if ((!cg_debugAnimWatch->integer) || ((cg_debugAnimWatch->integer - 1) == cent->currentState.number)) { @@ -5342,7 +5492,7 @@ qboolean CG_Command_ProcessFile(const char *filename, qboolean quiet, dtiki_t *c current_tiki = NULL; // Update the loading screen - sprintf(tempName, "m%s", filename); + Com_sprintf(tempName, sizeof(tempName), "m%s", filename); cgi.LoadResource(tempName); bufstart = buffer; @@ -5351,7 +5501,7 @@ qboolean CG_Command_ProcessFile(const char *filename, qboolean quiet, dtiki_t *c Event *ev; // grab each line as we go - strcpy(com_token, COM_ParseExt(&buffer, qtrue)); + Q_strncpyz(com_token, COM_ParseExt(&buffer, qtrue), sizeof(com_token)); if (!com_token[0]) { break; } @@ -5359,7 +5509,7 @@ qboolean CG_Command_ProcessFile(const char *filename, qboolean quiet, dtiki_t *c if (!Q_stricmp(com_token, "end") || !Q_stricmp(com_token, "server")) { // skip the line while (1) { - strcpy(com_token, COM_ParseExt(&buffer, qfalse)); + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); if (!com_token[0]) { break; } @@ -5372,7 +5522,7 @@ qboolean CG_Command_ProcessFile(const char *filename, qboolean quiet, dtiki_t *c // get the rest of the line while (1) { - strcpy(com_token, COM_ParseExt(&buffer, qfalse)); + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); if (!com_token[0]) { break; } @@ -5384,7 +5534,7 @@ qboolean CG_Command_ProcessFile(const char *filename, qboolean quiet, dtiki_t *c cgi.FS_FreeFile((void *)bufstart); // Update the loading screen - sprintf(tempName, "o%s", filename); + Com_sprintf(tempName, sizeof(tempName), "o%s", filename); cgi.LoadResource(tempName); return qtrue; @@ -5690,7 +5840,7 @@ void ClientGameCommandManager::SetCurrentTiki(Event *ev) str tikiName; if (ev->NumArgs() != 1) { - Com_Printf("ERROR: settiki command takes 1 parameter.\n"); + cgi.DPrintf("ERROR: settiki command takes 1 parameter.\n"); return; } diff --git a/code/cgame/cg_commands.h b/code/cgame/cg_commands.h index 7bd22fd2..60e39dec 100644 --- a/code/cgame/cg_commands.h +++ b/code/cgame/cg_commands.h @@ -113,6 +113,7 @@ TIKI file, similar to ScriptMaster in the server game dll. #define T2_VARYCOLOR (1 << 20) #define T2_SPIN (1 << 21) #define T2_RELATIVEANGLES (1 << 22) +#define T2_NOTAGAXIS (1 << 23) class spawnthing_t; class specialeffect_t; @@ -763,6 +764,7 @@ private: void SpawnVSSSource(int count, int timealive); void EventViewKick(Event *ev); void Print(Event *ev); + void PrintDeathMsg(Event *ev); // Added in 2.0 void StartBlock(Event *ev); void EndBlock(Event *ev); void UpdateSpawnThing(spawnthing_t *ep); @@ -788,6 +790,7 @@ private: void SetScaleRate(Event *ev); void SetRandomVelocity(Event *ev); void SetRandomVelocityAlongAxis(Event *ev); + void SetNoTagAxis(Event *ev); // Added in 2.0 void SetAccel(Event *ev); void SetFriction(Event *ev); void SetSpin(Event *ev); @@ -849,6 +852,7 @@ private: void StopSound(Event *ev); void StopAliasChannel(Event *ev); void LoopSound(Event *ev); + void StopLoopSound(Event *ev); // Added in 2.0 void Cache(Event *ev); void CacheImage(Event *ev); void CacheFont(Event *ev); diff --git a/code/cgame/cg_consolecmds.c b/code/cgame/cg_consolecmds.c index ef409d57..9ab3817f 100644 --- a/code/cgame/cg_consolecmds.c +++ b/code/cgame/cg_consolecmds.c @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2008-2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -160,17 +160,157 @@ baseshader_t *CG_GetShaderUnderCrosshair(qboolean bVerbose, trace_t *pRetTrace) static void CG_PrintContentTypes(int iContentFlags) { - // FIXME: unimplemented + if (iContentFlags & CONTENTS_SOLID) { + cgi.Printf(" solid"); + } + if (iContentFlags & CONTENTS_LAVA) { + cgi.Printf(" lava"); + } + if (iContentFlags & CONTENTS_SLIME) { + cgi.Printf(" slime"); + } + if (iContentFlags & CONTENTS_WATER) { + cgi.Printf(" water"); + } + if (iContentFlags & CONTENTS_FOG) { + cgi.Printf(" fog"); + } + if (iContentFlags & CONTENTS_FENCE) { + cgi.Printf(" fence"); + } + if (iContentFlags & CONTENTS_AREAPORTAL) { + cgi.Printf(" areaportal"); + } + if (iContentFlags & CONTENTS_PLAYERCLIP) { + cgi.Printf(" playerclip"); + } + if (iContentFlags & CONTENTS_VEHICLECLIP) { + cgi.Printf(" vehicleclip"); + } + if (iContentFlags & CONTENTS_MONSTERCLIP) { + cgi.Printf(" monsterclip"); + } + if (iContentFlags & CONTENTS_WEAPONCLIP) { + cgi.Printf(" weaponclip"); + } + if (iContentFlags & CONTENTS_SHOOTONLY) { + cgi.Printf(" shootableonly"); + } + if (iContentFlags & CONTENTS_ORIGIN) { + cgi.Printf(" origin"); + } + if (iContentFlags & CONTENTS_TRANSLUCENT) { + cgi.Printf(" trans"); + } } static void CG_PrintSurfaceProperties(int iSurfaceFlags) { - // FIXME: unimplemented + if (iSurfaceFlags & SURF_NODAMAGE) { + cgi.Printf(" nodamage"); + } + if (iSurfaceFlags & SURF_SLICK) { + cgi.Printf(" slick"); + } + if (iSurfaceFlags & SURF_SKY) { + cgi.Printf(" sky"); + } + if (iSurfaceFlags & SURF_LADDER) { + cgi.Printf(" ladder"); + } + if (iSurfaceFlags & SURF_NOIMPACT) { + cgi.Printf(" noimpact"); + } + if (iSurfaceFlags & SURF_NOMARKS) { + cgi.Printf(" nomarks"); + } + if (iSurfaceFlags & SURF_CASTSHADOW) { + cgi.Printf(" castshadow"); + } + if (iSurfaceFlags & SURF_NODRAW) { + cgi.Printf(" nodraw"); + } + if (iSurfaceFlags & SURF_NOLIGHTMAP) { + cgi.Printf(" nolightmap"); + } + if (iSurfaceFlags & SURF_ALPHASHADOW) { + cgi.Printf(" alphashadow"); + } + if (iSurfaceFlags & SURF_NOSTEPS) { + cgi.Printf(" nofootsteps"); + } + if (iSurfaceFlags & SURF_NONSOLID) { + cgi.Printf(" nonsolid"); + } + if (iSurfaceFlags & SURF_OVERBRIGHT) { + cgi.Printf(" overbright"); + } + if (iSurfaceFlags & SURF_BACKSIDE) { + cgi.Printf(" backside"); + } + if (iSurfaceFlags & SURF_NODLIGHT) { + cgi.Printf(" nodlight"); + } + if (iSurfaceFlags & SURF_HINT) { + cgi.Printf(" hint"); + } + if (iSurfaceFlags & SURF_PATCH) { + cgi.Printf(" patch"); + } } static void CG_PrintSurfaceType(int iSurfType) { - // FIXME: unimplemented + switch (iSurfType & MASK_SURF_TYPE) { + case SURF_FOLIAGE: + cgi.Printf("foliage"); + break; + case SURF_SNOW: + cgi.Printf("snow"); + break; + case SURF_CARPET: + cgi.Printf("carpet"); + break; + case SURF_SAND: + cgi.Printf("sand"); + break; + case SURF_PUDDLE: + cgi.Printf("puddle"); + break; + case SURF_GLASS: + cgi.Printf("glass"); + break; + case SURF_GRAVEL: + cgi.Printf("gravel"); + break; + case SURF_MUD: + cgi.Printf("mud"); + break; + case SURF_DIRT: + cgi.Printf("dirt"); + break; + case SURF_GRILL: + cgi.Printf("metal grill"); + break; + case SURF_GRASS: + cgi.Printf("grass"); + break; + case SURF_ROCK: + cgi.Printf("rock"); + break; + case SURF_PAPER: + cgi.Printf("paper"); + break; + case SURF_WOOD: + cgi.Printf("wood"); + break; + case SURF_METAL: + cgi.Printf("metal"); + break; + default: + cgi.Printf("!!*none specified*!!"); + break; + } } void CG_GetCHShader(void) @@ -216,9 +356,9 @@ void CG_EditCHShader(void) pShader = CG_GetShaderUnderCrosshair(qfalse, NULL); if (pShader) { - strcpy(name, "editspecificshader "); - strcat(name, pShader->shader); - strcat(name, "\n"); + Q_strncpyz(name, "editspecificshader ", sizeof(name)); + Q_strcat(name, sizeof(name), pShader->shader); + Q_strcat(name, sizeof(name), "\n"); cgi.AddCommand(name); } else { cgi.Printf("No surface selected\n"); @@ -340,65 +480,65 @@ typedef struct { } consoleCommand_t; static consoleCommand_t commands[] = { - {"useweaponclass", &CG_UseWeaponClass_f }, - {"weapnext", &CG_NextWeapon_f }, - {"weapprev", &CG_PrevWeapon_f }, - {"uselast", &CG_UseLastWeapon_f }, - {"holster", &CG_HolsterWeapon_f }, - {"weapdrop", &CG_DropWeapon_f }, - {"toggleitem", &CG_ToggleItem_f }, - {"+scores", &CG_ScoresDown_f }, - {"-scores", &CG_ScoresUp_f }, - {"viewpos", &CG_Viewpos_f }, - {"sizeup", &CG_SizeUp_f }, - {"sizedown", &CG_SizeDown_f }, - {"cg_eventlist", &CG_EventList_f }, - {"cg_eventhelp", &CG_EventHelp_f }, - {"cg_dumpevents", &CG_DumpEventHelp_f }, - {"cg_pendingevents", &CG_PendingEvents_f }, - {"cg_classlist", &CG_ClassList_f }, - {"cg_classtree", &CG_ClassTree_f }, - {"cg_classevents", &CG_ClassEvents_f }, - {"cg_dumpclassevents", &CG_DumpClassEvents_f }, - {"cg_dumpallclasses", &CG_DumpAllClasses_f }, - {"testemitter", &CG_TestEmitter_f }, - {"triggertestemitter", &CG_TriggerTestEmitter_f }, - {"prevemittercommand", &CG_PrevEmitterCommand_f }, - {"nextemittercommand", &CG_NextEmitterCommand_f }, - {"newemittercommand", &CG_NewEmitterCommand_f }, - {"deleteemittercommand", &CG_DeleteEmitterCommand_f }, - {"dumpemitter", &CG_DumpEmitter_f }, - {"loademitter", &CG_LoadEmitter_f }, - {"resetvss", &CG_ResetVSSSources }, - {"getchshader", &CG_GetCHShader }, - {"editchshader", &CG_EditCHShader }, - {"messagemode", &CG_MessageMode_f }, - {"messagemode_all", &CG_MessageMode_All_f }, - {"messagemode_team", &CG_MessageMode_Team_f }, - {"messagemode_private", &CG_MessageMode_Private_f }, - {"say", &CG_MessageSingleAll_f }, - {"sayteam", &CG_MessageSingleTeam_f }, - {"teamsay", &CG_MessageSingleTeam_f }, - {"sayprivate", &CG_MessageSingleClient_f }, - {"sayone", &CG_MessageSingleClient_f }, - {"wisper", &CG_MessageSingleClient_f }, - {"instamsg_main", &CG_InstaMessageMain_f }, - {"instamsg_group_a", &CG_InstaMessageGroupA_f }, - {"instamsg_group_b", &CG_InstaMessageGroupB_f }, - {"instamsg_group_c", &CG_InstaMessageGroupC_f }, - {"instamsg_group_d", &CG_InstaMessageGroupD_f }, - {"instamsg_group_e", &CG_InstaMessageGroupE_f }, - {"pushmenu_teamselect", &CG_PushMenuTeamSelect_f }, - {"pushmenu_weaponselect", &CG_PushMenuWeaponSelect_f }, + {"useweaponclass", &CG_UseWeaponClass_f }, + {"weapnext", &CG_NextWeapon_f }, + {"weapprev", &CG_PrevWeapon_f }, + {"uselast", &CG_UseLastWeapon_f }, + {"holster", &CG_HolsterWeapon_f }, + {"weapdrop", &CG_DropWeapon_f }, + {"toggleitem", &CG_ToggleItem_f }, + {"+scores", &CG_ScoresDown_f }, + {"-scores", &CG_ScoresUp_f }, + {"viewpos", &CG_Viewpos_f }, + {"sizeup", &CG_SizeUp_f }, + {"sizedown", &CG_SizeDown_f }, + {"cg_eventlist", &CG_EventList_f }, + {"cg_eventhelp", &CG_EventHelp_f }, + {"cg_dumpevents", &CG_DumpEventHelp_f }, + {"cg_pendingevents", &CG_PendingEvents_f }, + {"cg_classlist", &CG_ClassList_f }, + {"cg_classtree", &CG_ClassTree_f }, + {"cg_classevents", &CG_ClassEvents_f }, + {"cg_dumpclassevents", &CG_DumpClassEvents_f }, + {"cg_dumpallclasses", &CG_DumpAllClasses_f }, + {"testemitter", &CG_TestEmitter_f }, + {"triggertestemitter", &CG_TriggerTestEmitter_f }, + {"prevemittercommand", &CG_PrevEmitterCommand_f }, + {"nextemittercommand", &CG_NextEmitterCommand_f }, + {"newemittercommand", &CG_NewEmitterCommand_f }, + {"deleteemittercommand", &CG_DeleteEmitterCommand_f }, + {"dumpemitter", &CG_DumpEmitter_f }, + {"loademitter", &CG_LoadEmitter_f }, + {"resetvss", &CG_ResetVSSSources }, + {"getchshader", &CG_GetCHShader }, + {"editchshader", &CG_EditCHShader }, + {"messagemode", &CG_MessageMode_f }, + {"messagemode_all", &CG_MessageMode_All_f }, + {"messagemode_team", &CG_MessageMode_Team_f }, + {"messagemode_private", &CG_MessageMode_Private_f }, + {"say", &CG_MessageSingleAll_f }, + {"sayteam", &CG_MessageSingleTeam_f }, + {"teamsay", &CG_MessageSingleTeam_f }, + {"sayprivate", &CG_MessageSingleClient_f }, + {"sayone", &CG_MessageSingleClient_f }, + {"wisper", &CG_MessageSingleClient_f }, + {"instamsg_main", &CG_InstaMessageMain_f }, + {"instamsg_group_a", &CG_InstaMessageGroupA_f }, + {"instamsg_group_b", &CG_InstaMessageGroupB_f }, + {"instamsg_group_c", &CG_InstaMessageGroupC_f }, + {"instamsg_group_d", &CG_InstaMessageGroupD_f }, + {"instamsg_group_e", &CG_InstaMessageGroupE_f }, + {"pushmenu_teamselect", &CG_PushMenuTeamSelect_f }, + {"pushmenu_weaponselect", &CG_PushMenuWeaponSelect_f }, // Added in 2.0 - {"pushcallvote", &CG_PushCallVote_f }, - {"pushcallvotesublist", &CG_PushCallVoteSubList_f }, - {"pushcallvotesubtext", &CG_PushCallVoteSubText_f }, - {"pushcallvotesubinteger",&CG_PushCallVoteSubInteger_f }, - {"pushcallvotesubfloat", &CG_PushCallVoteSubFloat_f }, - {"pushcallvotesubclient", &CG_PushCallVoteSubClient_f }, - {"pushvote", &CG_PushVote_f }, - {"callentryvote", &CG_CallEntryVote_f }, + {"pushcallvote", &CG_PushCallVote_f }, + {"pushcallvotesublist", &CG_PushCallVoteSubList_f }, + {"pushcallvotesubtext", &CG_PushCallVoteSubText_f }, + {"pushcallvotesubinteger", &CG_PushCallVoteSubInteger_f}, + {"pushcallvotesubfloat", &CG_PushCallVoteSubFloat_f }, + {"pushcallvotesubclient", &CG_PushCallVoteSubClient_f }, + {"pushvote", &CG_PushVote_f }, + {"callentryvote", &CG_CallEntryVote_f }, }; /* @@ -565,5 +705,5 @@ int CG_WeaponCommandButtonBits(void) cg.iWeaponCommand = 0; } - return iShiftedWeaponCommand & WEAPON_COMMAND_MASK; + return iShiftedWeaponCommand & GetWeaponCommandMask(cg_protocol >= PROTOCOL_MOHTA_MIN ? WEAPON_COMMAND_MAX_VER17 : WEAPON_COMMAND_MAX_VER6); } diff --git a/code/cgame/cg_drawtools.cpp b/code/cgame/cg_drawtools.cpp index da1fb632..043b3882 100644 --- a/code/cgame/cg_drawtools.cpp +++ b/code/cgame/cg_drawtools.cpp @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2025 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -191,8 +191,8 @@ void CG_DrawDisconnect(void) } handle = cgi.R_RegisterShader("gfx/2d/net.tga"); - w = cgi.R_GetShaderWidth(handle); - h = cgi.R_GetShaderHeight(handle); + w = cgi.R_GetShaderWidth(handle) * cgs.uiHiResScale[0]; + h = cgi.R_GetShaderHeight(handle) * cgs.uiHiResScale[1]; x = ((float)cgs.glconfig.vidWidth - w) * 0.5; y = (float)cgs.glconfig.vidHeight - h; @@ -331,7 +331,7 @@ static void CG_DrawPauseIcon() x = (cgs.glconfig.vidWidth - w) / 2.f; cgi.R_SetColor(colorWhite); - cgi.R_DrawStretchPic(x, y, w, h, 0, 0, 1, 1, handle); + cgi.R_DrawStretchPic(x, y, w * cgs.uiHiResScale[0], h * cgs.uiHiResScale[1], 0, 0, 1, 1, handle); } static void CG_DrawServerLag() @@ -362,8 +362,8 @@ static void CG_DrawServerLag() } handle = cgi.R_RegisterShader("gfx/2d/slowserver"); - w = (float)cgi.R_GetShaderWidth(handle) / 4; - h = (float)cgi.R_GetShaderHeight(handle) / 4; + w = (float)cgi.R_GetShaderWidth(handle) * cgs.uiHiResScale[0] / 4; + h = (float)cgi.R_GetShaderHeight(handle) * cgs.uiHiResScale[1] / 4; x = ((float)cgs.glconfig.vidWidth - w) / 2; y = (float)cgs.glconfig.vidHeight - h; cgi.R_DrawStretchPic(x, y, w, h, 0.0, 0.0, 1.0, 1.0, handle); @@ -577,14 +577,18 @@ void CG_RefreshHudDrawElements() void CG_HudDrawElements() { - int i; - float fX, fY; - float fWidth, fHeight; + int i; + float fX, fY; + float fWidth, fHeight; + vec2_t virtualScale; if (!cg_huddraw_force->integer && !cg_hud->integer) { return; } + virtualScale[0] = cgs.glconfig.vidWidth / 640.0; + virtualScale[1] = cgs.glconfig.vidHeight / 480.0; + for (i = 0; i < MAX_HUDDRAW_ELEMENTS; i++) { if ((!cgi.HudDrawElements[i].hShader && !cgi.HudDrawElements[i].string[0]) || !cgi.HudDrawElements[i].vColor[3]) { @@ -597,6 +601,13 @@ void CG_HudDrawElements() fWidth = cgi.HudDrawElements[i].iWidth; fHeight = cgi.HudDrawElements[i].iHeight; + if (!cgi.HudDrawElements[i].bVirtualScreen) { + fWidth *= cgs.uiHiResScale[0]; + fHeight *= cgs.uiHiResScale[1]; + fX *= cgs.uiHiResScale[0]; + fY *= cgs.uiHiResScale[1]; + } + if (cgi.HudDrawElements[i].iHorizontalAlign == HUD_ALIGN_X_CENTER) { if (cgi.HudDrawElements[i].bVirtualScreen) { fX += 320.0 - fWidth * 0.5; @@ -627,23 +638,21 @@ void CG_HudDrawElements() cgi.R_SetColor(cgi.HudDrawElements[i].vColor); if (cgi.HudDrawElements[i].string[0]) { - if (cgi.HudDrawElements[i].pFont) { - cgi.R_DrawString( - cgi.HudDrawElements[i].pFont, - cgi.LV_ConvertString(cgi.HudDrawElements[i].string), - fX, - fY, - -1, - cgi.HudDrawElements[i].bVirtualScreen - ); + fontheader_t *pFont = cgi.HudDrawElements[i].pFont; + if (!pFont) { + pFont = cgs.media.hudDrawFont; + } + + if (cgi.HudDrawElements[i].bVirtualScreen) { + cgi.R_DrawString(pFont, cgi.LV_ConvertString(cgi.HudDrawElements[i].string), fX, fY, -1, virtualScale); } else { cgi.R_DrawString( - cgs.media.hudDrawFont, + pFont, cgi.LV_ConvertString(cgi.HudDrawElements[i].string), - fX, - fY, + fX / cgs.uiHiResScale[0], + fY / cgs.uiHiResScale[1], -1, - cgi.HudDrawElements[i].bVirtualScreen + cgs.uiHiResScale ); } } else { @@ -675,14 +684,17 @@ void CG_DrawObjectives() { float vColor[4]; float fX, fY; + int iNumObjectives; + float fObjectivesTop; static float fWidth; float fHeight; int iNumLines[20]; int iTotalNumLines; int i; - int ii; int iCurrentObjective; float fTimeDelta; + const char *pszLocalizedText; + const char *pszLine; iTotalNumLines = 0; for (i = CS_OBJECTIVES; i < CS_OBJECTIVES + MAX_OBJECTIVES; ++i) { @@ -702,50 +714,78 @@ void CG_DrawObjectives() return; } - for (i = 0; i < MAX_OBJECTIVES; i++) { - if ((cg.Objectives[i].flags & 0xFFFFFFFE)) { - iNumLines[i] = 0; + // Added in 2.0 + // Get the minimum Y value, it should be below the compass + fObjectivesTop = cgi.UI_GetObjectivesTop(); + iNumObjectives = 0; - for (ii = 0; ii < MAX_STRING_CHARS; ii++) { - if (cg.Objectives[i].text[ii] == '\n') { - iTotalNumLines++; - iNumLines[i]++; - } else if (!cg.Objectives[i].text[ii]) { - iTotalNumLines++; - iNumLines[i]++; - break; - } - } + for (i = 0; i < MAX_OBJECTIVES; i++) { + if ((cg.Objectives[i].flags == OBJ_FLAG_NONE) || (cg.Objectives[i].flags & OBJ_FLAG_HIDDEN)) { + continue; } + + iNumObjectives++; + iNumLines[i] = 0; + pszLocalizedText = cgi.LV_ConvertString(cg.Objectives[i].text); + + for (pszLine = strchr(pszLocalizedText, '\n'); pszLine; pszLine = strchr(pszLine + 1, '\n')) { + iNumLines[i]++; + } + + iTotalNumLines += iNumLines[i]; } fX = 25.0; - fY = 125.0; - fWidth = (float)(25 * iTotalNumLines + 155) + 5.0 - 130.0; + fY = fObjectivesTop + 5; + fWidth = (float)(iTotalNumLines * 12 + fObjectivesTop + iNumObjectives * 25 + 32) - fY; vColor[2] = 0.2f; vColor[1] = 0.2f; vColor[0] = 0.2f; vColor[3] = cg.ObjectivesCurrentAlpha * 0.75; cgi.R_SetColor(vColor); - cgi.R_DrawStretchPic(fX, fY, 450.0, fWidth, 0.0, 0.0, 1.0, 1.0, cgs.media.objectivesBackShader); + cgi.R_DrawStretchPic( + fX, + fY, + 450.0 * cgs.uiHiResScale[0], + fWidth * cgs.uiHiResScale[1], + 0.0, + 0.0, + 1.0, + 1.0, + cgs.media.objectivesBackShader + ); fX = 30.0; - fY = 130.0; + fY = fObjectivesTop + 10; vColor[0] = 1.0; vColor[1] = 1.0; vColor[2] = 1.0; vColor[3] = cg.ObjectivesCurrentAlpha; cgi.R_SetColor(vColor); - cgi.R_DrawString(cgs.media.objectiveFont, cgi.LV_ConvertString("Mission Objectives:"), fX, fY, -1, 0); + cgi.R_DrawString( + cgs.media.objectiveFont, + cgi.LV_ConvertString("Mission Objectives:"), + fX, + fY / cgs.uiHiResScale[1], + -1, + cgs.uiHiResScale + ); fY = fY + 5.0; - cgi.R_DrawString(cgs.media.objectiveFont, "_______________________________________________________", fX, fY, -1, 0); - fHeight = 155.0; + cgi.R_DrawString( + cgs.media.objectiveFont, + "_______________________________________________________", + fX, + fY / cgs.uiHiResScale[1], + -1, + cgs.uiHiResScale + ); + fHeight = fObjectivesTop + 35 * cgs.uiHiResScale[1]; for (i = 0; i < MAX_OBJECTIVES; ++i) { qhandle_t hBoxShader; - if ((cg.Objectives[i].flags & OBJ_FLAG_HIDDEN) || !cg.Objectives[i].flags) { + if ((cg.Objectives[i].flags == OBJ_FLAG_NONE) || (cg.Objectives[i].flags & OBJ_FLAG_HIDDEN)) { continue; } @@ -778,7 +818,14 @@ void CG_DrawObjectives() cgi.R_SetColor(vColor); fX = 55.0; fY = fHeight; - cgi.R_DrawString(cgs.media.objectiveFont, cgi.LV_ConvertString(cg.Objectives[i].text), 55.0, fHeight, -1, 0); + cgi.R_DrawString( + cgs.media.objectiveFont, + cgi.LV_ConvertString(cg.Objectives[i].text), + 55.0, + fY / cgs.uiHiResScale[1], + -1, + cgs.uiHiResScale + ); fX = 30.0; fY = fHeight; @@ -787,9 +834,19 @@ void CG_DrawObjectives() vColor[2] = 1.0; vColor[3] = cg.ObjectivesCurrentAlpha; cgi.R_SetColor(vColor); - cgi.R_DrawStretchPic(fX, fY, 16.0, 16.0, 0.0, 0.0, 1.0, 1.0, hBoxShader); + cgi.R_DrawStretchPic( + fX * cgs.uiHiResScale[0], + fY, + 16.0 * cgs.uiHiResScale[0], + 16.0 * cgs.uiHiResScale[1], + 0.0, + 0.0, + 1.0, + 1.0, + hBoxShader + ); - fHeight += 25 * iNumLines[i]; + fHeight += iNumLines[i] * 12 + 25 * cgs.uiHiResScale[1]; } } @@ -813,7 +870,17 @@ void CG_DrawPlayerTeam() if (handle) { cgi.R_SetColor(NULL); - cgi.R_DrawStretchPic(96.0, cgs.glconfig.vidHeight - 46, 24.0, 24.0, 0.0, 0.0, 1.0, 1.0, handle); + cgi.R_DrawStretchPic( + 96.0 * cgs.uiHiResScale[0], + cgs.glconfig.vidHeight - 46 * cgs.uiHiResScale[1], + 24.0 * cgs.uiHiResScale[0], + 24.0 * cgs.uiHiResScale[1], + 0.0, + 0.0, + 1.0, + 1.0, + handle + ); } } @@ -855,13 +922,28 @@ void CG_DrawPlayerEntInfo() if (handle) { cgi.R_SetColor(0); - cgi.R_DrawStretchPic(56.0, fY, 16.0, 16.0, 0.0, 0.0, 1.0, 1.0, handle); - fX = 56.0 + 24.0; + cgi.R_DrawStretchPic( + fX, fY, 16.0 * cgs.uiHiResScale[0], 16.0 * cgs.uiHiResScale[1], 0.0, 0.0, 1.0, 1.0, handle + ); } cgi.R_SetColor(color); - cgi.R_DrawString(cgs.media.hudDrawFont, (char *)pszName, fX, fY, -1, 0); - cgi.R_DrawString(cgs.media.hudDrawFont, va("%i", cg.snap->ps.stats[STAT_INFOCLIENT_HEALTH]), fX, fY + 20.0, -1, 0); + cgi.R_DrawString( + cgs.media.hudDrawFont, + (char *)pszName, + fX / cgs.uiHiResScale[0] + 24.0, + fY / cgs.uiHiResScale[1], + -1, + cgs.uiHiResScale + ); + cgi.R_DrawString( + cgs.media.hudDrawFont, + va("%i", cg.snap->ps.stats[STAT_INFOCLIENT_HEALTH]), + fX / cgs.uiHiResScale[0] + 24.0, + fY / cgs.uiHiResScale[1] + 20.0, + -1, + cgs.uiHiResScale + ); } void CG_UpdateAttackerDisplay() @@ -900,7 +982,17 @@ void CG_UpdateAttackerDisplay() if (handle) { cgi.R_SetColor(0); - cgi.R_DrawStretchPic(56.0, fY, 24.0, 24.0, 0.0, 0.0, 1.0, 1.0, handle); + cgi.R_DrawStretchPic( + 56.0 * cgs.uiHiResScale[0], + fY, + 24.0 * cgs.uiHiResScale[0], + 24.0 * cgs.uiHiResScale[1], + 0.0, + 0.0, + 1.0, + 1.0, + handle + ); } if ((cg.snap->ps.stats[STAT_TEAM] == TEAM_ALLIES || cg.snap->ps.stats[STAT_TEAM] == TEAM_AXIS) @@ -914,7 +1006,7 @@ void CG_UpdateAttackerDisplay() color[2] = 0.5; } - fX = 56.0 + 32.0; + fX = 56.0; } else { color[0] = 1.0; color[1] = 0.5; @@ -922,11 +1014,15 @@ void CG_UpdateAttackerDisplay() } cgi.R_SetColor(color); - cgi.R_DrawString(cgs.media.attackerFont, pszName, fX, fY, -1, 0); + cgi.R_DrawString( + cgs.media.attackerFont, pszName, fX / cgs.uiHiResScale[0] + 32.0, fY / cgs.uiHiResScale[1], -1, cgs.uiHiResScale + ); } void CG_UpdateCountdown() { + const char *message = ""; + if (!cg.snap) { return; } @@ -937,16 +1033,25 @@ void CG_UpdateCountdown() iSecondsLeft = (cgs.matchEndTime - cg.time) / 1000; if (iSecondsLeft >= 0) { iMinutesLeft = iSecondsLeft / 60; - cgi.Cvar_Set( - "ui_timemessage", va("%s %2i:%02i", cgi.LV_ConvertString("Time Left:"), iMinutesLeft, iSecondsLeft % 60) - ); + message = va("%s %2i:%02i", cgi.LV_ConvertString("Time Left:"), iMinutesLeft, iSecondsLeft % 60); } else if (!cgs.matchEndTime) { - cgi.Cvar_Set("ui_timemessage", ""); + message = ""; } } else { // The match has not started yet - cgi.Cvar_Set("ui_timemessage", "Waiting For Players"); + message = "Waiting For Players"; } + + if (strcmp(ui_timemessage->string, message)) { + cgi.Cvar_Set("ui_timemessage", message); + } +} + +static void CG_RemoveStopwatch() +{ + cgi.Cmd_Execute(EXEC_NOW, "ui_removehud hud_stopwatch\n"); + cgi.Cmd_Execute(EXEC_NOW, "ui_removehud hud_fuse\n"); + cgi.Cmd_Execute(EXEC_NOW, "ui_removehud hud_fuse_wet\n"); } void CG_DrawStopwatch() @@ -954,38 +1059,55 @@ void CG_DrawStopwatch() int iFraction; if (!cg_hud->integer) { - cgi.Cmd_Execute(EXEC_NOW, "ui_removehud hud_stopwatch\n"); + CG_RemoveStopwatch(); return; } if (!cgi.stopWatch->iStartTime) { - cgi.Cmd_Execute(EXEC_NOW, "ui_removehud hud_stopwatch\n"); + CG_RemoveStopwatch(); return; } if (cgi.stopWatch->iStartTime >= cgi.stopWatch->iEndTime) { - cgi.Cmd_Execute(EXEC_NOW, "ui_removehud hud_stopwatch\n"); + CG_RemoveStopwatch(); return; } if (cgi.stopWatch->iEndTime <= cg.time) { - cgi.Cmd_Execute(EXEC_NOW, "ui_removehud hud_stopwatch\n"); + CG_RemoveStopwatch(); return; } if (cg.ObjectivesCurrentAlpha >= 0.02) { - cgi.Cmd_Execute(EXEC_NOW, "ui_removehud hud_stopwatch\n"); + CG_RemoveStopwatch(); return; } if (cg.snap && cg.snap->ps.stats[STAT_HEALTH] <= 0) { - cgi.Cmd_Execute(EXEC_NOW, "ui_removehud hud_stopwatch\n"); + CG_RemoveStopwatch(); return; } + if (cgi.stopWatch->eType >= SWT_FUSE_WET) { + iFraction = cgi.stopWatch->iEndTime - cgi.stopWatch->iStartTime; + } else { + iFraction = cgi.stopWatch->iEndTime - cg.time; + } - iFraction = cgi.stopWatch->iEndTime - cg.time; cgi.Cvar_Set("ui_stopwatch", va("%i", iFraction)); - cgi.Cmd_Execute(EXEC_NOW, "ui_addhud hud_stopwatch\n"); + + switch (cgi.stopWatch->eType) { + case SWT_NORMAL: + default: + cgi.Cmd_Execute(EXEC_NOW, "ui_addhud hud_stopwatch\n"); + break; + case SWT_FUSE: + cgi.Cmd_Execute(EXEC_NOW, "ui_addhud hud_fuse\n"); + break; + case SWT_FUSE_WET: + cgi.Cmd_Execute(EXEC_NOW, "ui_removehud hud_fuse\n"); + cgi.Cmd_Execute(EXEC_NOW, "ui_addhud hud_fuse_wet\n"); + break; + } } void CG_DrawInstantMessageMenu() @@ -1009,7 +1131,9 @@ void CG_DrawInstantMessageMenu() x = 8.0; y = ((float)cgs.glconfig.vidHeight - h) * 0.5; cgi.R_SetColor(0); - cgi.R_DrawStretchPic(x, y, w, h, 0.0, 0.0, 1.0, 1.0, handle); + cgi.R_DrawStretchPic( + x * cgs.uiHiResScale[0], y, w * cgs.uiHiResScale[0], h * cgs.uiHiResScale[1], 0.0, 0.0, 1.0, 1.0, handle + ); } void CG_DrawSpectatorView_ver_15() @@ -1032,10 +1156,14 @@ void CG_DrawSpectatorView_ver_15() if (!bOnTeam) { cgi.Key_GetKeysForCommand("+attackprimary", &iKey1, &iKey2); pszString = cgi.LV_ConvertString(va("Press Fire(%s) to join the battle!", cgi.Key_KeynumToBindString(iKey1))); - fX = (float)(cgs.glconfig.vidWidth - cgi.UI_FontStringWidth(cgs.media.attackerFont, pszString, -1)) * 0.5; - fY = cgs.glconfig.vidHeight - 64.0; + fX = (float)(cgs.glconfig.vidWidth + - cgi.UI_FontStringWidth(cgs.media.attackerFont, pszString, -1) * cgs.uiHiResScale[0]) + * 0.5; + fY = cgs.glconfig.vidHeight - 64.0 * cgs.uiHiResScale[1]; cgi.R_SetColor(NULL); - cgi.R_DrawString(cgs.media.attackerFont, pszString, fX, fY, -1, qfalse); + cgi.R_DrawString( + cgs.media.attackerFont, pszString, fX / cgs.uiHiResScale[0], fY / cgs.uiHiResScale[1], -1, cgs.uiHiResScale + ); } if (cg.predicted_player_state.pm_flags & PMF_CAMERA_VIEW) { @@ -1048,10 +1176,14 @@ void CG_DrawSpectatorView_ver_15() cgi.Key_KeynumToBindString(iKey1b)) ); - fX = (float)(cgs.glconfig.vidWidth - cgi.UI_FontStringWidth(cgs.media.attackerFont, pszString, -1)) * 0.5; - fY = (float)cgs.glconfig.vidHeight - 40.0; + fX = (float)(cgs.glconfig.vidWidth + - cgi.UI_FontStringWidth(cgs.media.attackerFont, pszString, -1) * cgs.uiHiResScale[0]) + * 0.5; + fY = (float)cgs.glconfig.vidHeight - 40.0 * cgs.uiHiResScale[1]; cgi.R_SetColor(0); - cgi.R_DrawString(cgs.media.attackerFont, pszString, fX, fY, -1, 0); + cgi.R_DrawString( + cgs.media.attackerFont, pszString, fX / cgs.uiHiResScale[0], fY / cgs.uiHiResScale[1], -1, cgs.uiHiResScale + ); } if (!bOnTeam && (cg.predicted_player_state.pm_flags & PMF_CAMERA_VIEW)) { @@ -1059,10 +1191,14 @@ void CG_DrawSpectatorView_ver_15() pszString = cgi.LV_ConvertString(va("Press Use(%s) to enter free spectate mode.", cgi.Key_KeynumToBindString(iKey1))); - fX = (float)(cgs.glconfig.vidWidth - cgi.UI_FontStringWidth(cgs.media.attackerFont, pszString, -1)) * 0.5; - fY = (float)cgs.glconfig.vidHeight - 24.0; + fX = (float)(cgs.glconfig.vidWidth + - cgi.UI_FontStringWidth(cgs.media.attackerFont, pszString, -1) * cgs.uiHiResScale[0]) + * 0.5; + fY = (float)cgs.glconfig.vidHeight - 24.0 * cgs.uiHiResScale[1]; cgi.R_SetColor(0); - cgi.R_DrawString(cgs.media.attackerFont, pszString, fX, fY, -1, 0); + cgi.R_DrawString( + cgs.media.attackerFont, pszString, fX / cgs.uiHiResScale[0], fY / cgs.uiHiResScale[1], -1, cgs.uiHiResScale + ); } if (!(cg.predicted_player_state.pm_flags & PMF_CAMERA_VIEW)) { @@ -1072,20 +1208,27 @@ void CG_DrawSpectatorView_ver_15() va("Press Use(%s) to enter player following spectate mode.", cgi.Key_KeynumToBindString(iKey1)) ); - fX = (float)(cgs.glconfig.vidWidth - cgi.UI_FontStringWidth(cgs.media.attackerFont, pszString, -1)) * 0.5; - fY = (float)cgs.glconfig.vidHeight - 24.0; + fX = (float)(cgs.glconfig.vidWidth + - cgi.UI_FontStringWidth(cgs.media.attackerFont, pszString, -1) * cgs.uiHiResScale[0]) + * 0.5; + fY = (float)cgs.glconfig.vidHeight - 24.0 * cgs.uiHiResScale[1]; cgi.R_SetColor(0); - cgi.R_DrawString(cgs.media.attackerFont, pszString, fX, fY, -1, 0); + cgi.R_DrawString( + cgs.media.attackerFont, pszString, fX / cgs.uiHiResScale[0], fY / cgs.uiHiResScale[1], -1, cgs.uiHiResScale + ); } - if ((cg.predicted_player_state.pm_flags & 0x80) != 0 && cg.snap && cg.snap->ps.stats[STAT_INFOCLIENT] != -1) { + if ((cg.predicted_player_state.pm_flags & PMF_CAMERA_VIEW) != 0 && cg.snap + && cg.snap->ps.stats[STAT_INFOCLIENT] != -1) { int iClientNum; qhandle_t hShader; vec4_t color; char buf[128]; iClientNum = cg.snap->ps.stats[STAT_INFOCLIENT]; - sprintf(buf, "%s : %i", cg.clientinfo[iClientNum].name, cg.snap->ps.stats[STAT_INFOCLIENT_HEALTH]); + Com_sprintf( + buf, sizeof(buf), "%s : %i", cg.clientinfo[iClientNum].name, cg.snap->ps.stats[STAT_INFOCLIENT_HEALTH] + ); hShader = 0; color[0] = 0.5; @@ -1093,10 +1236,14 @@ void CG_DrawSpectatorView_ver_15() color[2] = 0.5; color[3] = 1.0; - fX = (float)(cgs.glconfig.vidWidth - cgi.UI_FontStringWidth(cgs.media.attackerFont, pszString, -1) - 16) * 0.5; - fY = (float)cgs.glconfig.vidHeight - 80.0; + fX = (float)(cgs.glconfig.vidWidth + - (cgi.UI_FontStringWidth(cgs.media.attackerFont, pszString, -1) - 16) * cgs.uiHiResScale[0]) + * 0.5; + fY = (float)cgs.glconfig.vidHeight - 80.0 * cgs.uiHiResScale[1]; cgi.R_SetColor(color); - cgi.R_DrawString(cgs.media.attackerFont, buf, fX, fY, -1, 0); + cgi.R_DrawString( + cgs.media.attackerFont, buf, fX / cgs.uiHiResScale[0], fY / cgs.uiHiResScale[1], -1, cgs.uiHiResScale + ); if (cg.clientinfo[iClientNum].team == TEAM_ALLIES) { hShader = cgi.R_RegisterShader("textures/hud/allies"); @@ -1105,9 +1252,18 @@ void CG_DrawSpectatorView_ver_15() } if (hShader) { - fX -= 20.0; cgi.R_SetColor(NULL); - cgi.R_DrawStretchPic(fX, fY, 16.0, 16.0, 0.0, 0.0, 1.0, 1.0, hShader); + cgi.R_DrawStretchPic( + fX - 20.0 * cgs.uiHiResScale[0], + fY, + 16.0 * cgs.uiHiResScale[0], + 16.0 * cgs.uiHiResScale[1], + 0.0, + 0.0, + 1.0, + 1.0, + hShader + ); } } } @@ -1139,10 +1295,14 @@ void CG_DrawSpectatorView_ver_6() pszString = cgi.LV_ConvertString(va("Press Use(%s) to follow a player.", cgi.Key_KeynumToBindString(iKey1))); } - fX = (float)(cgs.glconfig.vidWidth - cgi.UI_FontStringWidth(cgs.media.attackerFont, pszString, -1)) * 0.5; - fY = (float)cgs.glconfig.vidHeight - 40.0; + fX = (float)(cgs.glconfig.vidWidth + - cgi.UI_FontStringWidth(cgs.media.attackerFont, pszString, -1) * cgs.uiHiResScale[0]) + * 0.5; + fY = (float)cgs.glconfig.vidHeight - 40.0 * cgs.uiHiResScale[1]; cgi.R_SetColor(0); - cgi.R_DrawString(cgs.media.attackerFont, pszString, fX, fY, -1, 0); + cgi.R_DrawString( + cgs.media.attackerFont, pszString, fX / cgs.uiHiResScale[0], fY / cgs.uiHiResScale[1], -1, cgs.uiHiResScale + ); if (!bOnTeam && (cg.predicted_player_state.pm_flags & PMF_CAMERA_VIEW)) { cgi.Key_GetKeysForCommand("+moveup", &iKey1, &iKey2); @@ -1153,10 +1313,14 @@ void CG_DrawSpectatorView_ver_6() cgi.Key_KeynumToBindString(iKey1b)) ); - fX = (float)(cgs.glconfig.vidWidth - cgi.UI_FontStringWidth(cgs.media.attackerFont, pszString, -1)) * 0.5; - fY = (float)cgs.glconfig.vidHeight - 24.0; + fX = (float)(cgs.glconfig.vidWidth + - cgi.UI_FontStringWidth(cgs.media.attackerFont, pszString, -1) * cgs.uiHiResScale[0]) + * 0.5; + fY = (float)cgs.glconfig.vidHeight - 24.0 * cgs.uiHiResScale[1]; cgi.R_SetColor(0); - cgi.R_DrawString(cgs.media.attackerFont, pszString, fX, fY, -1, 0); + cgi.R_DrawString( + cgs.media.attackerFont, pszString, fX / cgs.uiHiResScale[0], fY / cgs.uiHiResScale[1], -1, cgs.uiHiResScale + ); } } @@ -1180,7 +1344,7 @@ void CG_DrawCrosshair() float x, y; float width, height; - shader = NULL; + shader = (qhandle_t)0; if (!cg_hud->integer || !ui_crosshair->integer) { return; @@ -1190,7 +1354,7 @@ void CG_DrawCrosshair() return; } - if ((cg.snap->ps.pm_flags & PMF_NO_LEAN) || (cg.snap->ps.pm_flags & PMF_INTERMISSION)) { + if ((cg.snap->ps.pm_flags & PMF_NO_HUD) || (cg.snap->ps.pm_flags & PMF_INTERMISSION)) { return; } @@ -1199,6 +1363,9 @@ void CG_DrawCrosshair() return; } + // Fixed in OPM: R_RegisterShaderNoMip + // Use R_RegisterShaderNoMip, as it's UI stuff + if (cgs.gametype != GT_FFA) { AngleVectorsLeft(cg.refdefViewAngles, forward, NULL, NULL); @@ -1226,23 +1393,23 @@ void CG_DrawCrosshair() || ((myFlags & EF_AXIS) && (friendEnt->currentState.eFlags & EF_AXIS))) { // friend if (cg.snap->ps.stats[STAT_CROSSHAIR]) { - shader = cgi.R_RegisterShader(cg_crosshair_friend->string); + shader = cgi.R_RegisterShaderNoMip(cg_crosshair_friend->string); } } else { // enemy if (cg.snap->ps.stats[STAT_CROSSHAIR]) { - shader = cgi.R_RegisterShader(cg_crosshair->string); + shader = cgi.R_RegisterShaderNoMip(cg_crosshair->string); } } } else { if (cg.snap->ps.stats[STAT_CROSSHAIR]) { - shader = cgi.R_RegisterShader(cg_crosshair->string); + shader = cgi.R_RegisterShaderNoMip(cg_crosshair->string); } } } else { // FFA if (cg.snap->ps.stats[STAT_CROSSHAIR]) { - shader = cgi.R_RegisterShader(cg_crosshair->string); + shader = cgi.R_RegisterShaderNoMip(cg_crosshair->string); } } @@ -1253,7 +1420,7 @@ void CG_DrawCrosshair() y = (cgs.glconfig.vidHeight - height) * 0.5f; cgi.R_SetColor(NULL); - cgi.R_DrawStretchPic(x, y, width, height, 0, 0, 1, 1, shader); + cgi.R_DrawStretchPic(x, y, width * cgs.uiHiResScale[0], height * cgs.uiHiResScale[1], 0, 0, 1, 1, shader); } } @@ -1284,15 +1451,17 @@ void CG_DrawVote() percentNo = cgs.numVotesNo * 100 / (cgs.numUndecidedVotes + cgs.numVotesNo + cgs.numVotesYes); percentUndecided = cgs.numUndecidedVotes * 100 / (cgs.numUndecidedVotes + cgs.numVotesNo + cgs.numVotesYes); - x = 8; - y = (cgs.glconfig.vidHeight > 480) ? (cgs.glconfig.vidHeight * 0.725f) : (cgs.glconfig.vidHeight * 0.75f); + x = 8 * cgs.uiHiResScale[0]; + y = ((cgs.glconfig.vidHeight > 480) ? (cgs.glconfig.vidHeight * 0.725f) : (cgs.glconfig.vidHeight * 0.75f)); cgi.R_SetColor(NULL); text = va("%s: %s", cgi.LV_ConvertString("Vote Running"), cgs.voteString); - cgi.R_DrawString(cgs.media.attackerFont, text, x, y, -1, qfalse); + cgi.R_DrawString( + cgs.media.attackerFont, text, x / cgs.uiHiResScale[0], y / cgs.uiHiResScale[1], -1, cgs.uiHiResScale + ); - y += 12; + y += 12 * cgs.uiHiResScale[1]; text = va("%s: %isec %s: %i%% %s: %i%% %s: %i%%", @@ -1304,7 +1473,9 @@ void CG_DrawVote() percentNo, cgi.LV_ConvertString("Undecided"), percentUndecided); - cgi.R_DrawString(cgs.media.attackerFont, text, x, y, -1, qfalse); + cgi.R_DrawString( + cgs.media.attackerFont, text, x / cgs.uiHiResScale[0], y / cgs.uiHiResScale[1], -1, cgs.uiHiResScale + ); if (cg.snap && !cg.snap->ps.voted) { col[0] = 0.5; @@ -1313,15 +1484,19 @@ void CG_DrawVote() col[3] = 1.0; cgi.R_SetColor(col); - y += 12; + y += 12 * cgs.uiHiResScale[1]; text = cgi.LV_ConvertString("Vote now, it's your patriotic duty!"); - cgi.R_DrawString(cgs.media.attackerFont, text, x, y, -1, qfalse); + cgi.R_DrawString( + cgs.media.attackerFont, text, x / cgs.uiHiResScale[0], y / cgs.uiHiResScale[1], -1, cgs.uiHiResScale + ); - y += 12; + y += 12 * cgs.uiHiResScale[1]; text = cgi.LV_ConvertString("To vote Yes, press F1. To vote No, press F2."); - cgi.R_DrawString(cgs.media.attackerFont, text, x, y, -1, qfalse); + cgi.R_DrawString( + cgs.media.attackerFont, text, x / cgs.uiHiResScale[0], y / cgs.uiHiResScale[1], -1, cgs.uiHiResScale + ); cgi.R_SetColor(NULL); } } diff --git a/code/cgame/cg_lightstyles.cpp b/code/cgame/cg_lightstyles.cpp index dfb9e76f..3a280a66 100644 --- a/code/cgame/cg_lightstyles.cpp +++ b/code/cgame/cg_lightstyles.cpp @@ -59,7 +59,7 @@ qboolean CG_LightStyleColor(int style, int realtime, vec4_t color, qboolean clam time = realtime / 50; frac = (realtime - (time * 50.0f)) / 50.0f; - memset(color, 0, sizeof(color)); + VectorClear4(color); if ((style < 0) || (style >= (MAX_LIGHTSTYLES * 2))) { cgi.DPrintf("CG_LightStyleColor: style out of range.\n"); return qtrue; diff --git a/code/cgame/cg_local.h b/code/cgame/cg_local.h index 314bf2b9..86921201 100644 --- a/code/cgame/cg_local.h +++ b/code/cgame/cg_local.h @@ -187,6 +187,7 @@ extern "C" { float min_dist; float width; char shader[MAX_RAIN_SHADERS][MAX_STRING_CHARS]; + char currentShader[MAX_STRING_CHARS]; int numshaders; } crain_t; @@ -269,6 +270,8 @@ extern "C" { qhandle_t hAlliedPlayerModelHandle; dtiki_t *pAxisPlayerModel; qhandle_t hAxisPlayerModelHandle; + qboolean serverAlliedModelValid; + qboolean serverAxisModelValid; // view eyes vec3_t vOffsetViewAngles; @@ -340,6 +343,7 @@ extern "C" { float ObjectivesBaseAlpha; float ObjectivesDesiredAlpha; float ObjectivesCurrentAlpha; + int ObjectivesCurrentIndex; // misc crain_t rain; @@ -378,6 +382,7 @@ extern "C" { float screenXScale; // derived from glconfig float screenYScale; float screenXBias; + vec2_t uiHiResScale; int serverCommandSequence; // reliable command stream counter int processedSnapshotNum; // the number of snapshots cgame has requested @@ -429,6 +434,7 @@ extern "C" { extern cgs_t cgs; extern cg_t cg; extern clientGameImport_t cgi; + extern target_game_e cg_target_game; extern int cg_protocol; extern centity_t cg_entities[MAX_GENTITIES]; extern markPoly_t *cg_markPolys; @@ -500,10 +506,18 @@ extern "C" { extern cvar_t *voiceChat; extern cvar_t *cg_shadowscount; extern cvar_t *cg_shadowdebug; + extern cvar_t *ui_timemessage; + + // + // Added in OPM + // + extern cvar_t *cg_fov; + extern cvar_t *cg_cheats; // // cg_main.c // + qboolean CG_UseLargeLightmaps(const char* mapName); void CG_ProcessConfigString(int num, qboolean modelOnly); const char *CG_ConfigString(int index); void CG_AddToTeamChat(const char *str); @@ -519,6 +533,9 @@ extern "C" { // // cg_modelanim.cpp // + void CG_ProcessPlayerModel(); + void CG_ServerModelLoaded(const char* name, qhandle_t handle); + void CG_ServerModelUnloaded(qhandle_t handle); void CG_ModelAnim(centity_t *cent, qboolean bDoShaderTime); void CG_AttachEntity( refEntity_t *entity, refEntity_t *parent, dtiki_t *tiki, int tagnum, qboolean use_angles, vec3_t attach_offset @@ -726,8 +743,8 @@ extern "C" { void CG_InitTestTreadMark(); void CG_AddTreadMarks(); int CG_PermanentMark( - const vec3_t origin, - const vec3_t dir, + vec3_t origin, + vec3_t dir, float orientation, float fSScale, float fTScale, @@ -920,7 +937,8 @@ qboolean CG_LightStyleColor(int style, int realtime, vec4_t color, qboolean clam void CG_InstaMessageGroupD_f(void); void CG_InstaMessageGroupE_f(void); void CG_HudPrint_f(void); - int CG_CheckCaptureKey(int key, qboolean down, unsigned int time); + + qboolean CG_CheckCaptureKey(int key, qboolean down, unsigned int time); // // cg_vehicle.cpp diff --git a/code/cgame/cg_main.c b/code/cgame/cg_main.c index 70f4346b..71295f3e 100644 --- a/code/cgame/cg_main.c +++ b/code/cgame/cg_main.c @@ -35,12 +35,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA clientGameImport_t cgi; static clientGameExport_t cge; -cvar_t *paused; -cvar_t *developer; -cg_t cg; -cgs_t cgs; -int cg_protocol; -centity_t cg_entities[MAX_GENTITIES]; +cvar_t *paused; +cvar_t *developer; +cg_t cg; +cgs_t cgs; +target_game_e cg_target_game = TG_INVALID; +int cg_protocol; +centity_t cg_entities[MAX_GENTITIES]; cvar_t *cg_animSpeed; cvar_t *cg_debugAnim; @@ -109,6 +110,13 @@ cvar_t *vm_lean_lower; cvar_t *voiceChat; cvar_t *cg_shadowscount; cvar_t *cg_shadowdebug; +cvar_t *ui_timemessage; + +// +// Added in OPM +// +cvar_t *cg_fov; +cvar_t *cg_cheats; /* ================= @@ -154,9 +162,9 @@ void CG_RegisterCvars(void) cg_shadowdebug = cgi.Cvar_Get("cg_shadowdebug", "0", 0); developer = cgi.Cvar_Get("developer", "0", 0); dm_playermodel = cgi.Cvar_Get("dm_playermodel", "american_army", 3); - dm_playergermanmodel = cgi.Cvar_Get("dm_playergermanmodel", "german_wehrmacht_soldier", 3); + dm_playergermanmodel = cgi.Cvar_Get("dm_playergermanmodel", "german_wehrmacht_soldier", CVAR_ARCHIVE | CVAR_USERINFO); cg_forceModel = cgi.Cvar_Get("cg_forceModel", "0", CVAR_ARCHIVE); - cg_animationviewmodel = cgi.Cvar_Get("cg_animationviewmodel", "0", 8); + cg_animationviewmodel = cgi.Cvar_Get("cg_animationviewmodel", "0", CVAR_SYSTEMINFO); cg_hitmessages = cgi.Cvar_Get("cg_hitmessages", "1", CVAR_ARCHIVE); cg_acidtrip = cgi.Cvar_Get("cg_acidtrip", "0", CVAR_CHEAT); cg_hud = cgi.Cvar_Get("cg_hud", "0", 0); @@ -196,53 +204,113 @@ void CG_RegisterCvars(void) vm_lean_lower = cgi.Cvar_Get("vm_lean_lower", "0.1", 0); voiceChat = cgi.Cvar_Get("cg_voicechat", "1", 0); + ui_timemessage = cgi.Cvar_Get("ui_timemessage", "", 0); + // see if we are also running the server on this machine temp = cgi.Cvar_Get("sv_running", "0", 0); cgs.localServer = temp->integer; + + // + // Added in OPM + // + + cg_fov = cgi.Cvar_Get("cg_fov", "80", CVAR_ARCHIVE); + cg_cheats = cgi.Cvar_Get("cheats", "0", CVAR_USERINFO | CVAR_SERVERINFO | CVAR_LATCH); +} +/* +=============== +CG_UseLargeLightmaps + +Added in 2.0 +Returns true if the standard BSP file should be used, false if the smaller lightmap BSP file should be used +=============== +*/ +qboolean CG_UseLargeLightmaps(const char* mapName) { + char buffer[MAX_QPATH]; + + Com_sprintf(buffer, sizeof(buffer), "maps/%s_sml.bsp", mapName); + + if (cgi.FS_ReadFile(buffer, NULL, qtrue) == -1) { + return qtrue; + } + + return cgi.Cvar_Get("r_largemap", "0", 0)->integer; +} + +/* +================ +CG_RegisterSoundsForFile + +Register the specified ubersound source file +================ +*/ +void CG_RegisterSoundsForFile(const char *name) +{ + int startTime; + int endTime; + + Com_Printf("\n\n-----------PARSING '%s'------------\n", name); + Com_Printf( + "Any SetCurrentTiki errors means that tiki wasn't prefetched and tiki-specific sounds for it won't work. To " + "fix prefetch the tiki. Ignore if you don't use that tiki on this level.\n" + ); + + startTime = cgi.Milliseconds(); + CG_Command_ProcessFile(name, qfalse, NULL); + endTime = cgi.Milliseconds(); + + Com_Printf("Parse/Load time: %f seconds.\n", (float)(endTime - startTime) / 1000.0); + Com_Printf("-------------PARSING '%s' DONE---------------\n\n", name); +} + +/* +================= +qsort_compare_strings + +perform case-insensitive sorting +================= +*/ +int qsort_compare_strings(const void *s1, const void *s2) +{ + return Q_stricmp(*(const char **)s1, *(const char **)s2); } /* ================= CG_RegisterSounds -called during a precache command +Called during a precache command ================= */ void CG_RegisterSounds(void) { - int startTime; - int endTime; - char filename[MAX_QPATH]; + char **fileList; + int numFiles; + int i; - Com_Printf("\n\n-----------PARSING UBERSOUND------------\n"); - Com_Printf( - "Any SetCurrentTiki errors means that tiki wasn't prefetched and " - "tiki-specific sounds for it won't work. To fix prefe" - "tch the tiki. Ignore if you don't use that tiki on this level.\n" - ); - Com_sprintf(filename, sizeof(filename), "ubersound/ubersound.scr"); + fileList = cgi.FS_ListFilteredFiles("ubersound/", "scr", "*.scr", qfalse, &numFiles, qtrue); + if (cg_target_game >= TG_MOHTA) { + // Fixed in 2.0 + // The behavior has changed, all aliases get cleared + if (cgs.gametype != GT_SINGLE_PLAYER) { + cgi.Alias_Clear(); + } + } else { + if (!cgs.localServer) { + cgi.Alias_Clear(); + } + } + + qsort(fileList, numFiles, sizeof(char *), &qsort_compare_strings); - startTime = cgi.Milliseconds(); - CG_Command_ProcessFile(filename, 0, 0); - endTime = cgi.Milliseconds(); + for (i = 0; i < numFiles; i++) { + // Added in 2.0 + // Since 2.0, all files in the ubersound folder + // are parsed + CG_RegisterSoundsForFile(va("ubersound/%s", fileList[i])); + } - Com_Printf("Parse/Load time: %f seconds.\n", (endTime - startTime) / 1000.0f); - - Com_Printf("-------------UBERSOUND DONE---------------\n\n"); - Com_Printf("\n\n-----------PARSING UBERDIALOG------------\n"); - Com_Printf( - "Any SetCurrentTiki errors means that tiki wasn't prefetched and " - "tiki-specific sounds for it won't work. To fix prefe" - "tch the tiki. Ignore if you don't use that tiki on this level.\n" - ); - Com_sprintf(filename, sizeof(filename), "ubersound/uberdialog.scr"); - - startTime = cgi.Milliseconds(); - CG_Command_ProcessFile(filename, 0, 0); - endTime = cgi.Milliseconds() - startTime; - - Com_Printf("Parse/Load time: %f seconds.\n", endTime / 1000.0f); - Com_Printf("-------------UBERDIALOG DONE---------------\n\n"); + cgi.FS_FreeFileList(fileList); } /* @@ -252,13 +320,11 @@ CG_IsHandleUnique Check if the model handle is unique ================ */ -static qboolean CG_IsHandleUnique(int num) { - qhandle_t handle; +static qboolean CG_IsHandleUnique(qhandle_t handle) { int i; int numRef; numRef = 0; - handle = cgs.model_draw[num]; for (i = 0; i < MAX_MODELS; i++) { if (cgs.model_draw[i] == handle) { numRef++; @@ -301,6 +367,8 @@ void CG_ProcessConfigString(int num, qboolean modelOnly) if (tiki) { CG_ProcessCacheInitCommands(tiki); } + + CG_ServerModelLoaded(str, hModel); } else { // clear out the model if (hOldModel && CG_IsHandleUnique(hOldModel)) { @@ -308,6 +376,10 @@ void CG_ProcessConfigString(int num, qboolean modelOnly) cgi.R_UnregisterServerModel(hOldModel); } cgs.model_draw[num - CS_MODELS] = 0; + + if (!str || !str[0]) { + CG_ServerModelUnloaded(hOldModel); + } } } @@ -335,28 +407,39 @@ void CG_ProcessConfigString(int num, qboolean modelOnly) cg.rain.width = atof(str); return; case CS_RAIN_SHADER: + Q_strncpyz(cg.rain.currentShader, str, sizeof(cg.rain.currentShader)); if (cg.rain.numshaders) { - for (i = 0; i < cg.rain.numshaders; i++) { - sprintf(cg.rain.shader[i], "%s%i", str, i); + // Fixed in OPM + // not sure why some maps set a digit at the end... + size_t len = strlen(cg.rain.currentShader); + if (isdigit(cg.rain.currentShader[len - 1])) { + cg.rain.currentShader[len - 1] = 0; } - } else { - strcpy(cg.rain.shader[0], str); + } + for (i = 0; i < cg.rain.numshaders; ++i) { + Com_sprintf(cg.rain.shader[i], sizeof(cg.rain.shader[i]), "%s%i", cg.rain.currentShader, i); + } + if (!cg.rain.numshaders) { + Q_strncpyz(cg.rain.shader[0], cg.rain.currentShader, sizeof(cg.rain.shader[0])); } return; case CS_RAIN_NUMSHADERS: cg.rain.numshaders = atoi(str); if (cg.rain.numshaders) { for (i = 0; i < cg.rain.numshaders; i++) { - sprintf(cg.rain.shader[i], "%s%i", str, i); + Com_sprintf(cg.rain.shader[i], sizeof(cg.rain.shader[i]), "%s%i", cg.rain.currentShader, i); } } return; + case CS_CURRENT_OBJECTIVE: + cg.ObjectivesCurrentIndex = atoi(str); + return; } if (num >= CS_OBJECTIVES && num < CS_OBJECTIVES + MAX_OBJECTIVES) { cobjective_t *objective = &cg.Objectives[num - CS_OBJECTIVES]; objective->flags = atoi(Info_ValueForKey(str, "flags")); - strcpy(objective->text, Info_ValueForKey(str, "text")); + Q_strncpyz(objective->text, Info_ValueForKey(str, "text"), sizeof(objective->text)); } switch (num) { @@ -411,7 +494,7 @@ void CG_ProcessConfigString(int num, qboolean modelOnly) if (len) { qboolean streamed; char buf[1024]; - strcpy(buf, str); + Q_strncpyz(buf, str, sizeof(buf)); streamed = buf[len - 1] != '0'; buf[len - 1] = 0; @@ -525,6 +608,7 @@ void CG_GetRendererConfig(void) cgi.GetGlconfig(&cgs.glconfig); cgs.screenXScale = cgs.glconfig.vidWidth / 640.0; cgs.screenYScale = cgs.glconfig.vidHeight / 480.0; + cgi.UI_GetHighResolutionScale(cgs.uiHiResScale); } /* @@ -623,6 +707,8 @@ void CG_Init(clientGameImport_t *imported, int serverMessageNum, int serverComma cgi = *imported; cg_protocol = cgi.Cvar_Get("com_protocol", "", 0)->integer; + cg_target_game = (target_game_e)cgi.Cvar_Get("com_target_game", "0", 0)->integer; + CG_InitCGMessageAPI(&cge); CG_InitScoresAPI(&cge); @@ -811,7 +897,7 @@ void Com_Error(int level, const char *error, ...) char text[1024]; va_start(argptr, error); - vsprintf(text, error, argptr); + Q_vsnprintf(text, sizeof(text), error, argptr); va_end(argptr); cgi.Error(level, "%s", text); @@ -823,7 +909,7 @@ void Com_Printf(const char *msg, ...) char text[1024]; va_start(argptr, msg); - vsprintf(text, msg, argptr); + Q_vsnprintf(text, sizeof(text), msg, argptr); va_end(argptr); cgi.Printf("%s", text); diff --git a/code/cgame/cg_marks.c b/code/cgame/cg_marks.c index 4c413d1a..27e681ac 100644 --- a/code/cgame/cg_marks.c +++ b/code/cgame/cg_marks.c @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -36,93 +36,94 @@ MARK POLYS #define MAX_MARK_FRAGMENTS 128 #define MAX_MARK_POINTS 384 -static vec3_t cg_vEntAngles; -static vec3_t cg_vEntOrigin; -static vec3_t cg_fEntAxis[3]; +static vec3_t cg_vEntAngles; +static vec3_t cg_vEntOrigin; +static vec3_t cg_fEntAxis[3]; static qboolean cg_bEntAnglesSet; -static int cg_iLastEntIndex; -static int cg_iLastEntTime; +static int cg_iLastEntIndex; +static int cg_iLastEntTime; static qboolean cg_bLastEntValid; -markPoly_t* cg_freeMarkPolys; // single linked list -markObj_t cg_activeMarkObjs; -markObj_t* cg_freeMarkObjs; +markPoly_t *cg_freeMarkPolys; // single linked list +markObj_t cg_activeMarkObjs; +markObj_t *cg_freeMarkObjs; treadMark_t cg_treadMarks[MAX_TREAD_MARKS]; -markPoly_t* cg_markPolys; -int cg_iNumMarkPolys; -markObj_t* cg_markObjs; -int cg_iNumFreeMarkObjs; -int cg_iMinFreeMarkObjs; -qboolean cg_bMarksInitialized; -cvar_t* cg_treadmark_test; +markPoly_t *cg_markPolys; +int cg_iNumMarkPolys; +markObj_t *cg_markObjs; +int cg_iNumFreeMarkObjs; +int cg_iMinFreeMarkObjs; +qboolean cg_bMarksInitialized; +cvar_t *cg_treadmark_test; -vec3_t vec_upwards; +vec3_t vec_upwards = {0, 0, 1}; typedef struct cg_impactmarkinfo_s { vec3_t axis[3]; vec3_t origin; - float fSCenter; - float fTCenter; - float texCoordScaleS; - float texCoordScaleT; - byte colors[4]; - int leafnum; + float fSCenter; + float fTCenter; + float texCoordScaleS; + float texCoordScaleT; + byte colors[4]; + int leafnum; } cg_impactmarkinfo_t; typedef struct cg_treadmarkinfo_s { - treadMark_t* pTread; - vec3_t vDirection; - vec3_t vRight; - float fStartDist; - float fStartTex; - float fStartAlpha; - float fLeftStartDist; - float fRightStartDist; - float fRightCenterDist; - float fLeftTexScale; - float fRightTexScale; - float fCenterTexScale; - float fLeftAlphaScale; - float fRightAlphaScale; - float fCenterAlphaScale; - float fOOWidth; - float fOODoubleWidth; - byte colors[4]; - int leafnum; + treadMark_t *pTread; + vec3_t vDirection; + vec3_t vRight; + float fStartDist; + float fStartTex; + float fStartAlpha; + float fLeftStartDist; + float fRightStartDist; + float fRightCenterDist; + float fLeftTexScale; + float fRightTexScale; + float fCenterTexScale; + float fLeftAlphaScale; + float fRightAlphaScale; + float fCenterAlphaScale; + float fOOWidth; + float fOODoubleWidth; + byte colors[4]; + int leafnum; } cg_treadmarkinfo_t; int CG_GetMarkFragments( - int numVerts, - const vec3_t* pVerts, - const vec3_t vProjection, - const vec3_t* pPointBuffer, - markFragment_t* pFragmentBuffer, - float fRadiusSquared -) { - int i, j; - int iNumEnts; - int iCurrPoints, iCurrFragments; - int iCurrMaxPoints, iCurrMaxFragments; - int iNewPoints, iNewFragments; - clipHandle_t cmodel; - vec3_t vProjectionDir; - vec3_t vMins, vMaxs; - vec3_t vTemp; - vec3_t vAngles, vOrigin; - const vec3_t* pCurrPoint; - centity_t* pEntList[64]; - entityState_t* pEnt; - markFragment_t* pCurrFragment; - markFragment_t* pFragment; + int numVerts, + const vec3_t *pVerts, + const vec3_t vProjection, + const vec3_t *pPointBuffer, + markFragment_t *pFragmentBuffer, + float fRadiusSquared +) +{ + int i, j; + int iNumEnts; + int iCurrPoints, iCurrFragments; + int iCurrMaxPoints, iCurrMaxFragments; + int iNewPoints, iNewFragments; + clipHandle_t cmodel; + vec3_t vProjectionDir; + vec3_t vMins, vMaxs; + vec3_t vTemp; + vec3_t vAngles, vOrigin; + const vec3_t *pCurrPoint; + centity_t *pEntList[64]; + entityState_t *pEnt; + markFragment_t *pCurrFragment; + markFragment_t *pFragment; iNewFragments = cgi.R_MarkFragments( numVerts, pVerts, vProjection, MAX_MARK_POINTS, - (float*)pPointBuffer, + (float *)pPointBuffer, MAX_MARK_FRAGMENTS, pFragmentBuffer, fRadiusSquared @@ -141,12 +142,12 @@ int CG_GetMarkFragments( return iNewFragments; } - iCurrPoints = iNewPoints; - iCurrFragments = iNewFragments; - iCurrMaxPoints = MAX_MARK_POINTS - iNewPoints; + iCurrPoints = iNewPoints; + iCurrFragments = iNewFragments; + iCurrMaxPoints = MAX_MARK_POINTS - iNewPoints; iCurrMaxFragments = MAX_MARK_FRAGMENTS - iNewFragments; - pCurrPoint = &pPointBuffer[iNewPoints]; - pCurrFragment = &pFragmentBuffer[iNewFragments]; + pCurrPoint = &pPointBuffer[iNewPoints]; + pCurrFragment = &pFragmentBuffer[iNewFragments]; VectorNormalize2(vProjection, vProjectionDir); ClearBounds(vMins, vMaxs); @@ -170,7 +171,7 @@ int CG_GetMarkFragments( VectorCopy(pEntList[i]->lerpOrigin, vOrigin); cmodel = cgi.CM_InlineModel(pEnt->modelindex); - + iNewFragments = cgi.R_MarkFragmentsForInlineModel( cmodel, vAngles, @@ -179,7 +180,7 @@ int CG_GetMarkFragments( pVerts, vProjection, iCurrMaxPoints, - (float*)pCurrPoint, + (float *)pCurrPoint, iCurrMaxFragments, pCurrFragment, fRadiusSquared @@ -191,7 +192,7 @@ int CG_GetMarkFragments( } iNewPoints = 0; - for (j = 0, pFragment = pCurrFragment; j < iNewPoints; j++, pFragment++) { + for (j = 0, pFragment = pCurrFragment; j < iNewFragments; j++, pFragment++) { pFragment->firstPoint += iCurrPoints; pFragment->iIndex = -pEnt->number; iNewPoints += pFragment->numPoints; @@ -211,18 +212,19 @@ int CG_GetMarkFragments( return iCurrFragments; } -static qboolean CG_GetMarkInlineModelOrientation(int iIndex) { - centity_t* pCEnt; +static qboolean CG_GetMarkInlineModelOrientation(int iIndex) +{ + centity_t *pCEnt; if (iIndex == cg_iLastEntIndex && cg_iLastEntTime == cg.time) { return cg_bLastEntValid; } pCEnt = &cg_entities[-iIndex]; - if (pCEnt->currentValid && pCEnt->currentState.modelindex < cgs.inlineDrawModel[ENTITYNUM_NONE]) - { + if (pCEnt->currentValid && pCEnt->currentState.modelindex < cgs.numInlineModels) { VectorCopy(pCEnt->lerpAngles, cg_vEntAngles); VectorCopy(pCEnt->lerpOrigin, cg_vEntOrigin); + cg_bLastEntValid = qtrue; if (cg_vEntAngles[0] || cg_vEntAngles[1] || cg_vEntAngles[2]) { AngleVectorsLeft(cg_vEntAngles, cg_fEntAxis[0], cg_fEntAxis[1], cg_fEntAxis[2]); @@ -233,7 +235,7 @@ static qboolean CG_GetMarkInlineModelOrientation(int iIndex) { } cg_iLastEntIndex = iIndex; - cg_iLastEntTime = cg.time; + cg_iLastEntTime = cg.time; return cg_bLastEntValid; } @@ -249,25 +251,24 @@ static qboolean CG_GetMarkInlineModelOrientation(int iIndex) { return qfalse; } -static void CG_FragmentPosToWorldPos(const vec3_t vFrom, vec3_t vTo) { - if (cg_bEntAnglesSet) - { +static void CG_FragmentPosToWorldPos(const vec3_t vFrom, vec3_t vTo) +{ + if (cg_bEntAnglesSet) { VectorMA(cg_vEntOrigin, vFrom[0], cg_fEntAxis[0], vTo); VectorMA(vTo, vFrom[1], cg_fEntAxis[1], vTo); VectorMA(vTo, vFrom[2], cg_fEntAxis[2], vTo); - } - else - { + } else { vTo[0] = cg_vEntOrigin[0] + *vFrom; vTo[1] = cg_vEntOrigin[1] + vFrom[1]; vTo[2] = cg_vEntOrigin[2] + vFrom[2]; } } -qboolean CG_UpdateMarkPosition(markObj_t* pMark) { +qboolean CG_UpdateMarkPosition(markObj_t *pMark) +{ vec3_t v; vec3_t pt; - int iIndex; + int iIndex; iIndex = pMark->markPolys->iIndex; if (!CG_GetMarkInlineModelOrientation(iIndex)) { @@ -276,8 +277,7 @@ qboolean CG_UpdateMarkPosition(markObj_t* pMark) { VectorCopy(pMark->markPolys->verts[0].xyz, v); - if (cg_bEntAnglesSet) - { + if (cg_bEntAnglesSet) { VectorScale(cg_fEntAxis[0], v[0], pt); VectorMA(pt, v[1], cg_fEntAxis[1], pt); VectorMA(pt, v[2], cg_fEntAxis[2], pt); @@ -291,12 +291,8 @@ qboolean CG_UpdateMarkPosition(markObj_t* pMark) { return qtrue; } -void CG_AddFragmentToScene( - int iIndex, - qhandle_t hShader, - int iNumVerts, - polyVert_t* pVerts -) { +void CG_AddFragmentToScene(int iIndex, qhandle_t hShader, int iNumVerts, polyVert_t *pVerts) +{ if (!iIndex) { cgi.R_AddPolyToScene(hShader, iNumVerts, pVerts, 0); return; @@ -308,9 +304,9 @@ void CG_AddFragmentToScene( } if (cg_bEntAnglesSet) { - int i; - vec3_t vTmp; - polyVert_t* pCurrVert; + int i; + vec3_t vTmp; + polyVert_t *pCurrVert; for (i = 0; i < iNumVerts; i++) { pCurrVert = &pVerts[i]; @@ -323,8 +319,8 @@ void CG_AddFragmentToScene( VectorAdd(vTmp, cg_vEntOrigin, pCurrVert->xyz); } } else { - int i; - polyVert_t* pCurrVert; + int i; + polyVert_t *pCurrVert; for (i = 0; i < iNumVerts; i++) { pCurrVert = &pVerts[i]; @@ -366,7 +362,7 @@ void CG_InitMarks(void) cgi.Free(cg_markPolys); } - cg_markPolys = (markPoly_t*)cgi.Malloc(sizeof(markPoly_t) * cg_iNumMarkPolys); + cg_markPolys = (markPoly_t *)cgi.Malloc(sizeof(markPoly_t) * cg_iNumMarkPolys); if (!cg_markPolys) { cgi.Error(ERR_DROP, "CG_InitMarks: Could not allocate array for mark polys"); @@ -376,7 +372,7 @@ void CG_InitMarks(void) cgi.Free(cg_markObjs); } - cg_markObjs = (markObj_t*)cgi.Malloc(sizeof(markObj_t) * iMaxMarks); + cg_markObjs = (markObj_t *)cgi.Malloc(sizeof(markObj_t) * iMaxMarks); if (!cg_markObjs) { cgi.Error(ERR_DROP, "CG_InitMarks: Could not allocate array for mark objects"); @@ -400,7 +396,7 @@ void CG_InitMarks(void) } cg_markObjs[i].nextMark = NULL; - cg_iNumFreeMarkObjs = iMaxMarks; + cg_iNumFreeMarkObjs = iMaxMarks; cg_bMarksInitialized = qtrue; } @@ -415,7 +411,7 @@ void CG_FreeMarkPoly(markPoly_t *le) return; } - le->nextPoly = cg_freeMarkPolys; + le->nextPoly = cg_freeMarkPolys; cg_freeMarkPolys = le; } @@ -424,11 +420,13 @@ void CG_FreeMarkPoly(markPoly_t *le) CG_FreeMarkObj ================== */ -void CG_FreeMarkObj(markObj_t* pMark) { - markPoly_t* pPoly; - markPoly_t* pNextPoly; +void CG_FreeMarkObj(markObj_t *pMark) +{ + markPoly_t *pPoly; + markPoly_t *pNextPoly; + + assert(pMark != &cg_activeMarkObjs); - pPoly = pMark->markPolys; for (pPoly = pMark->markPolys; pPoly; pPoly = pNextPoly) { pNextPoly = pPoly->nextPoly; CG_FreeMarkPoly(pPoly); @@ -436,8 +434,8 @@ void CG_FreeMarkObj(markObj_t* pMark) { pMark->prevMark->nextMark = pMark->nextMark; pMark->nextMark->prevMark = pMark->prevMark; - pMark->nextMark = cg_freeMarkObjs; - cg_freeMarkObjs = pMark; + pMark->nextMark = cg_freeMarkObjs; + cg_freeMarkObjs = pMark; cg_iNumFreeMarkObjs++; } @@ -446,13 +444,12 @@ void CG_FreeMarkObj(markObj_t* pMark) { CG_FreeBestMarkObj ================== */ -void CG_FreeBestMarkObj(qboolean bAllowFade) { - markObj_t* pMark; +void CG_FreeBestMarkObj(qboolean bAllowFade) +{ + markObj_t *pMark; - for (pMark = cg_activeMarkObjs.prevMark; pMark != &cg_activeMarkObjs; pMark = pMark->prevMark) - { - if (pMark->lastVisTime < cg.time - 250) - { + for (pMark = cg_activeMarkObjs.prevMark; pMark != &cg_activeMarkObjs; pMark = pMark->prevMark) { + if (pMark->lastVisTime < cg.time - 250) { CG_FreeMarkObj(pMark); return; } @@ -463,13 +460,14 @@ void CG_FreeBestMarkObj(qboolean bAllowFade) { return; } - for (pMark = cg_activeMarkObjs.prevMark; pMark != &cg_activeMarkObjs; pMark = pMark->prevMark) - { + for (pMark = cg_activeMarkObjs.prevMark; pMark != &cg_activeMarkObjs; pMark = pMark->prevMark) { if (!pMark->alphaFade || pMark->time > cg.time - 9000) { - pMark->time = cg.time - 9000; - pMark->alphaFade = 1; + break; } } + + pMark->time = cg.time - 9000; + pMark->alphaFade = qtrue; } /* @@ -479,11 +477,11 @@ CG_AllocMark Will allways succeed, even if it requires freeing an old active mark =================== */ -markObj_t* CG_AllocMark(int iNumPolys) +markObj_t *CG_AllocMark(int iNumPolys) { - int iPolyCount; - markPoly_t* pPoly; - markObj_t* pMark; + int iPolyCount; + markPoly_t *pPoly; + markObj_t *pMark; if (!cg_bMarksInitialized) { return NULL; @@ -493,79 +491,79 @@ markObj_t* CG_AllocMark(int iNumPolys) return NULL; } + if (iNumPolys > cg_iNumMarkPolys) { + // Added in OPM + // Make sure to not over allocate polys + return NULL; + } + if (cg_iNumFreeMarkObjs <= cg_iMinFreeMarkObjs) { CG_FreeBestMarkObj(1); } - pMark = cg_freeMarkObjs; + pMark = cg_freeMarkObjs; cg_freeMarkObjs = cg_freeMarkObjs->nextMark; memset(pMark, 0, sizeof(markObj_t)); pMark->lastVisTime = cg.time; - for (iPolyCount = 0; iPolyCount < iNumPolys; iPolyCount++) - { + for (iPolyCount = 0; iPolyCount < iNumPolys; iPolyCount++) { while (!cg_freeMarkPolys) { CG_FreeBestMarkObj(qfalse); } - pPoly = cg_freeMarkPolys; + pPoly = cg_freeMarkPolys; cg_freeMarkPolys = pPoly->nextPoly; memset(pPoly, 0, sizeof(*pPoly)); - pPoly->nextPoly = pMark->markPolys; + pPoly->nextPoly = pMark->markPolys; pMark->markPolys = pPoly; } - // link into the active list - pMark->nextMark = cg_activeMarkObjs.nextMark; - pMark->prevMark = &cg_activeMarkObjs; + pMark->nextMark = cg_activeMarkObjs.nextMark; + pMark->prevMark = &cg_activeMarkObjs; cg_activeMarkObjs.nextMark->prevMark = pMark; - cg_activeMarkObjs.nextMark = pMark; + cg_activeMarkObjs.nextMark = pMark; + cg_iNumFreeMarkObjs--; + assert(cg_iNumFreeMarkObjs >= 0); + return pMark; } -int CG_ImpactMark_GetLeafCallback(markFragment_t* mf, void* pCustom) { - return ((cg_impactmarkinfo_t*)pCustom)->leafnum; +int CG_ImpactMark_GetLeafCallback(markFragment_t *mf, void *pCustom) +{ + return ((cg_impactmarkinfo_t *)pCustom)->leafnum; } -qboolean CG_ImpactMark_PerPolyCallback( - const vec3_t* markPoints, - markFragment_t* mf, - polyVert_t* verts, - void* pCustom -) { - int j; - polyVert_t* v; - cg_impactmarkinfo_t* pInfo; +qboolean CG_ImpactMark_PerPolyCallback(const vec3_t *markPoints, markFragment_t *mf, polyVert_t *verts, void *pCustom) +{ + int j; + polyVert_t *v; + cg_impactmarkinfo_t *pInfo; - pInfo = (cg_impactmarkinfo_t*)pCustom; + pInfo = (cg_impactmarkinfo_t *)pCustom; - if (mf->iIndex >= 0) - { + if (mf->iIndex >= 0) { for (j = 0; j < mf->numPoints; j++) { vec3_t delta; v = &verts[j]; VectorCopy(markPoints[j + mf->firstPoint], v->xyz); VectorSubtract(v->xyz, pInfo->origin, delta); - v->st[0] = pInfo->fSCenter + DotProduct(delta, pInfo->axis[1]) * pInfo->texCoordScaleS; - v->st[1] = pInfo->fTCenter + DotProduct(delta, pInfo->axis[2]) * pInfo->texCoordScaleT; + v->st[0] = pInfo->fSCenter + DotProduct(delta, pInfo->axis[1]) * pInfo->texCoordScaleS; + v->st[1] = pInfo->fTCenter + DotProduct(delta, pInfo->axis[2]) * pInfo->texCoordScaleT; v->modulate[0] = pInfo->colors[0]; v->modulate[1] = pInfo->colors[1]; v->modulate[2] = pInfo->colors[2]; v->modulate[3] = pInfo->colors[3]; } - } - else - { + } else { if (!CG_GetMarkInlineModelOrientation(mf->iIndex)) { return qfalse; } - for (j = 0; j < mf->numPoints; j++) { vec3_t vWorldPos; vec3_t delta; @@ -575,8 +573,8 @@ qboolean CG_ImpactMark_PerPolyCallback( CG_FragmentPosToWorldPos(v->xyz, vWorldPos); VectorSubtract(vWorldPos, pInfo->origin, delta); - v->st[0] = pInfo->fSCenter + DotProduct(delta, pInfo->axis[1]) * pInfo->texCoordScaleS; - v->st[1] = pInfo->fTCenter + DotProduct(delta, pInfo->axis[2]) * pInfo->texCoordScaleT; + v->st[0] = pInfo->fSCenter + DotProduct(delta, pInfo->axis[1]) * pInfo->texCoordScaleS; + v->st[1] = pInfo->fTCenter + DotProduct(delta, pInfo->axis[2]) * pInfo->texCoordScaleT; v->modulate[0] = pInfo->colors[0]; v->modulate[1] = pInfo->colors[1]; v->modulate[2] = pInfo->colors[2]; @@ -618,24 +616,23 @@ void CG_ImpactMark( float fTCenter ) { - int i; - int numFragments; - float fSScale2, fTScale2; - float fSScale3, fTScale3; - vec3_t originalPoints[4]; - vec3_t markPoints[MAX_MARK_POINTS]; - vec3_t projection; - markFragment_t markFragments[MAX_MARK_FRAGMENTS], *mf; - vec3_t v; - float fRadiusSquared; + int i; + int numFragments; + float fSScale2, fTScale2; + float fSScale3, fTScale3; + vec3_t originalPoints[4]; + vec3_t markPoints[MAX_MARK_POINTS]; + vec3_t projection; + markFragment_t markFragments[MAX_MARK_FRAGMENTS], *mf; + vec3_t v; + float fRadiusSquared; cg_impactmarkinfo_t info; if (!cg_bMarksInitialized) { return; } - if (!cg_addMarks->integer - && markShader != cgs.media.shadowMarkShader + if (!cg_addMarks->integer && markShader != cgs.media.shadowMarkShader && markShader != cgs.media.footShadowMarkShader) { return; } @@ -647,7 +644,7 @@ void CG_ImpactMark( fTScale = 1.0; } - fRadiusSquared = fSScale * fSScale + fTScale * fTScale; + fRadiusSquared = fSScale * fSScale + fTScale * fTScale; info.texCoordScaleS = 0.5 / fSScale; info.texCoordScaleT = 0.5 / fTScale; @@ -693,26 +690,16 @@ void CG_ImpactMark( // get the fragments VectorScale(dir, -32, projection); - numFragments = CG_GetMarkFragments( - 4, - originalPoints, - projection, - markPoints, - markFragments, - fRadiusSquared - ); + numFragments = CG_GetMarkFragments(4, originalPoints, projection, markPoints, markFragments, fRadiusSquared); - if (dolighting) - { + if (dolighting) { vec3_t vLight; cgi.R_GetLightingForDecal(vLight, dir, origin); info.colors[0] = (int)(red * vLight[0]); info.colors[1] = (int)(green * vLight[1]); info.colors[2] = (int)(blue * vLight[2]); - } - else - { + } else { info.colors[0] = (int)(red * 255.0f); info.colors[1] = (int)(green * 255.0f); info.colors[2] = (int)(blue * 255.0f); @@ -730,8 +717,7 @@ void CG_ImpactMark( VectorAdd(origin, dir, v); info.leafnum = cgi.CM_PointLeafnum(v); - if (temporary) - { + if (temporary) { polyVert_t verts[8]; for (i = 0, mf = markFragments; i < numFragments; i++, mf++) { @@ -739,20 +725,18 @@ void CG_ImpactMark( mf->numPoints = 8; } - if (CG_ImpactMark_PerPolyCallback(markPoints, mf, verts, (void*)&info)) { + if (CG_ImpactMark_PerPolyCallback(markPoints, mf, verts, (void *)&info)) { CG_AddFragmentToScene(mf->iIndex, markShader, mf->numPoints, verts); } } - } - else - { + } else { CG_AssembleFinalMarks( markPoints, markFragments, numFragments, &CG_ImpactMark_PerPolyCallback, &CG_ImpactMark_GetLeafCallback, - (void*)&info, + (void *)&info, info.origin, sqrt(fRadiusSquared), markShader, @@ -763,32 +747,31 @@ void CG_ImpactMark( } void CG_AssembleFinalMarks( - vec3_t *markPoints, - markFragment_t *markFragments, - int numFragments, - qboolean (*PerPolyCallback)(const vec3_t* markPoints, markFragment_t* mf, polyVert_t* verts, void* pCustom), - int (*GetLeafCallback)(markFragment_t* mf, void* pCustom), - void *pCustom, - vec3_t pos, - float radius, - qhandle_t markShader, - qboolean fadein, - qboolean alphaFade + vec3_t *markPoints, + markFragment_t *markFragments, + int numFragments, + qboolean (*PerPolyCallback)(const vec3_t *markPoints, markFragment_t *mf, polyVert_t *verts, void *pCustom), + int (*GetLeafCallback)(markFragment_t *mf, void *pCustom), + void *pCustom, + vec3_t pos, + float radius, + qhandle_t markShader, + qboolean fadein, + qboolean alphaFade ) { - markObj_t* pMark; - markPoly_t* pPoly; - int iGroup, iFirstNewGroup; - int numFragsForMark; - int i; - markFragment_t* mf; + markObj_t *pMark; + markPoly_t *pPoly; + int iGroup, iFirstNewGroup; + int numFragsForMark; + int i; + markFragment_t *mf; iFirstNewGroup = 0; - do - { - i = iFirstNewGroup; - mf = &markFragments[iFirstNewGroup]; - iGroup = mf->iIndex; + do { + i = iFirstNewGroup; + mf = &markFragments[iFirstNewGroup]; + iGroup = mf->iIndex; numFragsForMark = 0; for (; i < numFragments; i++, mf++) { @@ -804,19 +787,35 @@ void CG_AssembleFinalMarks( break; } - pMark->time = cg.time; - pMark->alphaFade = alphaFade; + pMark->time = cg.time; + pMark->alphaFade = alphaFade; pMark->markShader = markShader; - pMark->fadein = fadein; + pMark->fadein = fadein; VectorCopy(pos, pMark->pos); pMark->radius = radius; - i = iFirstNewGroup; - mf = &markFragments[iFirstNewGroup]; + i = iFirstNewGroup; + mf = &markFragments[iFirstNewGroup]; iFirstNewGroup = 0; if (mf->iIndex < 0) { - VectorSubtract(pMark->pos, cg_entities[-mf->iIndex].lerpOrigin, pMark->pos); + centity_t *cent; + vec3_t pos; + + cent = &cg_entities[-mf->iIndex]; + + VectorSubtract(pMark->pos, cent->lerpOrigin, pos); + + if (cent->lerpAngles[0] || cent->lerpAngles[1] || cent->lerpAngles[2]) { + vec3_t axis[3]; + + // Fixed in OPM + // Make the position completely local to the entity + AngleVectorsLeft(cent->lerpAngles, axis[0], axis[1], axis[2]); + MatrixTransformVectorRight(axis, pos, pMark->pos); + } else { + VectorCopy(pos, pMark->pos); + } } pPoly = pMark->markPolys; @@ -836,8 +835,8 @@ void CG_AssembleFinalMarks( if (PerPolyCallback(markPoints, mf, pPoly->verts, pCustom)) { pPoly->numVerts = mf->numPoints; - pPoly->iIndex = mf->iIndex; - pPoly = pPoly->nextPoly; + pPoly->iIndex = mf->iIndex; + pPoly = pPoly->nextPoly; } } } @@ -894,15 +893,15 @@ CG_AddMarks void CG_AddMarks(void) { - int j; - int t; - int fade; - markObj_t* pMark; - markObj_t* pNext; - markPoly_t* pPoly; - polyVert_t* pVert; - polyVert_t tmpVerts[8]; - int viewleafnum; + int j; + int t; + int fade; + markObj_t *pMark; + markObj_t *pNext; + markPoly_t *pPoly; + polyVert_t *pVert; + polyVert_t tmpVerts[8]; + int viewleafnum; if (!cg_bMarksInitialized) { return; @@ -919,8 +918,7 @@ void CG_AddMarks(void) pNext = pMark->nextMark; // see if it is time to completely remove it - if (pMark->alphaFade && cg.time > pMark->time + MARK_TOTAL_TIME) - { + if (pMark->alphaFade && cg.time > pMark->time + MARK_TOTAL_TIME) { CG_FreeMarkObj(pMark); continue; } @@ -937,26 +935,25 @@ void CG_AddMarks(void) } if (pMark->markPolys->iIndex < 0) { - if (CG_FrustumCullSphere(pMark->pos, pMark->radius)) { - continue; - } - } else { vec3_t vWorldPos; CG_FragmentPosToWorldPos(pMark->pos, vWorldPos); if (CG_FrustumCullSphere(vWorldPos, pMark->radius)) { continue; } + } else { + if (CG_FrustumCullSphere(pMark->pos, pMark->radius)) { + continue; + } } pMark->lastVisTime = cg.time; if (pMark->fadein) { fade = 255 * (cg.time - pMark->time) / MARK_FADE_TIME; if (fade > 255) { - fade = 255; + fade = 255; pMark->fadein = 0; } - for (pPoly = pMark->markPolys; pPoly; pPoly = pPoly->nextPoly) { for (j = 0; j < pPoly->numVerts; j++) { pPoly->verts[j].modulate[3] = fade; @@ -976,10 +973,8 @@ void CG_AddMarks(void) } } - for (pPoly = pMark->markPolys; pPoly; pPoly = pPoly->nextPoly) - { - if (pPoly->iIndex < 0) - { + for (pPoly = pMark->markPolys; pPoly; pPoly = pPoly->nextPoly) { + if (pPoly->iIndex < 0) { memcpy(tmpVerts, pPoly->verts, 24 * pPoly->numVerts); pVert = tmpVerts; } else { @@ -1007,7 +1002,8 @@ qboolean CG_CheckMakeMarkOnEntity(int iEntIndex) return qfalse; } - if (cg_entities[iEntIndex].currentState.modelindex < 0 || cg_entities[iEntIndex].currentState.modelindex > cgi.CM_NumInlineModels()) { + if (cg_entities[iEntIndex].currentState.modelindex < 0 + || cg_entities[iEntIndex].currentState.modelindex > cgi.CM_NumInlineModels()) { return qfalse; } @@ -1021,9 +1017,9 @@ void CG_InitTestTreadMark() int CG_StartTreadMark(int iReference, qhandle_t treadShader, const vec3_t vStartPos, float fWidth, float fAlpha) { - int i; - int iTreadNum; - treadMark_t* pTread; + int i; + int iTreadNum; + treadMark_t *pTread; if (!cg_bMarksInitialized) { return -1; @@ -1037,7 +1033,7 @@ int CG_StartTreadMark(int iReference, qhandle_t treadShader, const vec3_t vStart for (i = 0; i < MAX_TREAD_MARKS; i++) { if (!cg_treadMarks[i].iState) { iTreadNum = i; - pTread = &cg_treadMarks[i]; + pTread = &cg_treadMarks[i]; break; } } @@ -1047,11 +1043,11 @@ int CG_StartTreadMark(int iReference, qhandle_t treadShader, const vec3_t vStart } memset(pTread, 0, sizeof(*pTread)); - pTread->iState = 1; + pTread->iState = 1; pTread->iReferenceNumber = iReference; - pTread->iLastTime = cg.time; - pTread->hTreadShader = treadShader; - pTread->fWidth = fWidth * 0.5; + pTread->iLastTime = cg.time; + pTread->hTreadShader = treadShader; + pTread->fWidth = fWidth * 0.5; VectorCopy(vStartPos, pTread->vMidPos); VectorCopy(vStartPos, pTread->vEndPos); @@ -1065,33 +1061,390 @@ int CG_StartTreadMark(int iReference, qhandle_t treadShader, const vec3_t vStart return iTreadNum; } -qboolean CG_MakeTreadMarkDecal_PerPolyCallback(const vec3_t *markPoints, markFragment_t *mf, polyVert_t *verts, void *pCustom) +qboolean +CG_MakeTreadMarkDecal_PerPolyCallback(const vec3_t *markPoints, markFragment_t *mf, polyVert_t *verts, void *pCustom) { - // FIXME: unimplemented - return qfalse; + int j; + float fDist; + float fSideDist; + float fSideAlpha; + float fCenterAlpha; + float fFrac; + float fTex, fAlpha; + polyVert_t *v; + cg_treadmarkinfo_t *pInfo; + + pInfo = (cg_treadmarkinfo_t *)pCustom; + + if (mf->iIndex < 0) { + vec3_t vWorldPos; + + if (!CG_GetMarkInlineModelOrientation(mf->iIndex)) { + return qfalse; + } + + for (j = 0; j < mf->numPoints; j++) { + v = &verts[j]; + VectorCopy(markPoints[mf->firstPoint + j], v->xyz); + v->modulate[0] = pInfo->colors[0]; + v->modulate[1] = pInfo->colors[1]; + v->modulate[2] = pInfo->colors[2]; + v->modulate[3] = pInfo->colors[3]; + + CG_FragmentPosToWorldPos(v->xyz, vWorldPos); + fSideDist = DotProduct(pInfo->vRight, vWorldPos) - pInfo->fRightCenterDist; + v->st[0] = (fSideDist + pInfo->pTread->fWidth) * pInfo->fOODoubleWidth; + + fSideAlpha = fSideDist * pInfo->fOOWidth; + fDist = DotProduct(vWorldPos, pInfo->vDirection); + if (fSideAlpha < 0) { + fSideAlpha = -fSideAlpha; + v->st[1] = pInfo->fStartTex + ((fDist - pInfo->fLeftStartDist) * pInfo->fLeftTexScale * fSideAlpha) + + ((fDist - pInfo->fStartDist) * pInfo->fCenterTexScale * (1.0 - fSideAlpha)); + v->modulate[3] = pInfo->fStartAlpha + + (1.0 - fSideAlpha) + * ((fDist - pInfo->fStartDist) * pInfo->fCenterTexScale * pInfo->fCenterAlphaScale) + + (fDist - pInfo->fLeftStartDist) * pInfo->fLeftAlphaScale * fSideAlpha; + } else { + v->st[1] = pInfo->fStartTex + ((fDist - pInfo->fRightStartDist) * pInfo->fRightTexScale * fSideAlpha) + + ((fDist - pInfo->fStartDist) * pInfo->fCenterTexScale * (1.0 - fSideAlpha)); + v->modulate[3] = pInfo->fStartAlpha + + (1.0 - fSideAlpha) + * ((fDist - pInfo->fStartDist) * pInfo->fCenterTexScale * pInfo->fCenterAlphaScale) + + (fDist - pInfo->fRightStartDist) * pInfo->fRightAlphaScale * fSideAlpha; + } + } + } else { + for (j = 0; j < mf->numPoints; j++) { + v = &verts[j]; + VectorCopy(markPoints[mf->firstPoint + j], v->xyz); + v->modulate[0] = pInfo->colors[0]; + v->modulate[1] = pInfo->colors[1]; + v->modulate[2] = pInfo->colors[2]; + v->modulate[3] = pInfo->colors[3]; + + fSideDist = DotProduct(pInfo->vRight, v->xyz) - pInfo->fRightCenterDist; + v->st[0] = (fSideDist + pInfo->pTread->fWidth) * pInfo->fOODoubleWidth; + + fSideAlpha = fSideDist * pInfo->fOOWidth; + fDist = DotProduct(v->xyz, pInfo->vDirection); + if (fSideAlpha < 0) { + fSideAlpha = -fSideAlpha; + fTex = (fDist - pInfo->fLeftStartDist) * pInfo->fLeftTexScale; + fAlpha = (fDist - pInfo->fLeftStartDist) * pInfo->fLeftAlphaScale; + } else { + fTex = (fDist - pInfo->fRightStartDist) * pInfo->fRightTexScale; + fAlpha = (fDist - pInfo->fRightStartDist) * pInfo->fRightAlphaScale; + } + + v->st[1] = pInfo->fStartTex + (fTex * fSideAlpha) + + (fDist - pInfo->fStartDist) * pInfo->fCenterTexScale * (1.0 - fSideAlpha); + v->modulate[3] = pInfo->fStartAlpha + + ((1.0 - fSideAlpha) * ((fDist - pInfo->fStartDist) * pInfo->fCenterAlphaScale)) + + (fAlpha * fSideAlpha); + } + } + + return qtrue; } int CG_MakeTreadMarkDecal_GetLeafCallback(markFragment_t *mf, void *pCustom) { - return ((cg_treadmarkinfo_t*)pCustom)->leafnum; + return ((cg_treadmarkinfo_t *)pCustom)->leafnum; } void CG_MakeTreadMarkDecal(treadMark_t *pTread, qboolean bStartSegment, qboolean bTemporary) { - // FIXME: unimplemented + int i; + int numFragments; + vec3_t originalPoints[4]; + vec3_t markPoints[MAX_MARK_POLYVERTS]; + vec3_t projection; + markFragment_t markFragments[MAX_MARK_FRAGMENTS]; + markFragment_t *mf; + cg_treadmarkinfo_t info; + float fEndAlpha, fEndTex; + float fDist; + vec3_t vStartCenter; + vec3_t vEndCenter; + vec3_t vDelta; + vec3_t origin; + float fRadiusSquared; + + if (bStartSegment) { + VectorCopy(pTread->vStartVerts[1], originalPoints[0]); + VectorCopy(pTread->vStartVerts[0], originalPoints[1]); + VectorCopy(pTread->vMidVerts[0], originalPoints[2]); + VectorCopy(pTread->vMidVerts[1], originalPoints[3]); + + info.fStartAlpha = pTread->fStartAlpha; + fEndAlpha = pTread->fMidAlpha; + info.fStartTex = pTread->fStartTexCoord; + fEndTex = pTread->fMidTexCoord; + + // Calculate the start center + VectorAdd(originalPoints[1], originalPoints[0], vStartCenter); + VectorScale(vStartCenter, 0.5, vStartCenter); + VectorCopy(pTread->vMidPos, vEndCenter); + VectorCopy(pTread->vStartDir, info.vDirection); + } else { + VectorCopy(pTread->vMidVerts[1], originalPoints[0]); + VectorCopy(pTread->vMidVerts[0], originalPoints[1]); + VectorCopy(pTread->vEndVerts[0], originalPoints[2]); + VectorCopy(pTread->vEndVerts[1], originalPoints[3]); + + info.fStartAlpha = pTread->fMidAlpha; + fEndAlpha = pTread->fEndAlpha; + info.fStartTex = pTread->fMidTexCoord; + fEndTex = pTread->fEndTexCoord; + + VectorCopy(pTread->vMidPos, vStartCenter); + VectorCopy(pTread->vEndPos, vEndCenter); + + // Calculate the direction + VectorSubtract(vEndCenter, vStartCenter, info.vDirection); + VectorNormalizeFast(info.vDirection); + } + + CrossProduct(vec_upwards, info.vDirection, info.vRight); + info.fRightCenterDist = DotProduct(vEndCenter, info.vRight); + info.fOODoubleWidth = 0.5 / pTread->fWidth; + info.fOOWidth = info.fOODoubleWidth * 2; + info.fStartDist = DotProduct(info.vDirection, vStartCenter); + info.fRightStartDist = DotProduct(info.vDirection, originalPoints[1]); + info.fLeftStartDist = DotProduct(info.vDirection, originalPoints[0]); + + // + // Center + // + + VectorSubtract(vEndCenter, vStartCenter, vDelta); + fDist = VectorLength(vDelta); + + fRadiusSquared = (Square(fDist) + Square(pTread->fWidth)) * 0.25; + + info.fCenterTexScale = (fEndTex - info.fStartTex) / fDist; + info.fCenterAlphaScale = (fEndAlpha - info.fStartAlpha) / fDist; + + // + // Right + // + + VectorSubtract(originalPoints[2], originalPoints[1], vDelta); + fDist = VectorLength(vDelta); + + info.fRightTexScale = (fEndTex - info.fStartTex) / fDist; + info.fRightAlphaScale = (fEndAlpha - info.fStartAlpha) / fDist; + + // + // Left + // + + VectorSubtract(originalPoints[3], originalPoints[1], vDelta); + fDist = VectorLength(vDelta); + + info.fLeftTexScale = (fEndTex - info.fStartTex) / fDist; + info.fLeftAlphaScale = (fEndAlpha - info.fStartAlpha) / fDist; + + VectorSet(projection, 0, 0, -32); + info.colors[0] = info.colors[1] = info.colors[2] = info.colors[3] = -1; + + numFragments = CG_GetMarkFragments(4, originalPoints, projection, markPoints, markFragments, fRadiusSquared); + VectorAdd(vStartCenter, vEndCenter, origin); + VectorScale(origin, 0.5, origin); + info.leafnum = cgi.CM_PointLeafnum(origin); + info.pTread = pTread; + + if (bTemporary) { + for (i = 0; i < numFragments; i++) { + polyVert_t verts[8]; + + mf = &markFragments[i]; + if (mf->numPoints > 8) { + mf->numPoints = 8; + } + if (CG_MakeTreadMarkDecal_PerPolyCallback(markPoints, mf, verts, &info)) { + CG_AddFragmentToScene(mf->iIndex, pTread->hTreadShader, mf->numPoints, verts); + } + } + } else { + CG_AssembleFinalMarks( + markPoints, + markFragments, + numFragments, + &CG_MakeTreadMarkDecal_PerPolyCallback, + &CG_MakeTreadMarkDecal_GetLeafCallback, + &info, + origin, + sqrt(fRadiusSquared), + pTread->hTreadShader, + qfalse, + qfalse + ); + } } -int CG_UpdateTreadMark(int iReference, vec_t *vNewPos, float fAlpha) +int CG_UpdateTreadMark(int iReference, const vec3_t vNewPos, float fAlpha) { - // FIXME: unimplemented + int i; + int iTreadNum; + float fDist; + float fSplitLength; + float fNewLength; + float fTmp; + qboolean bDoSegmentation; + vec3_t vDelta, vDeltaNorm; + vec3_t vDir, vMidDir; + vec3_t vRight; + treadMark_t *pTread; + + iTreadNum = -1; + + for (i = 0; i < MAX_TREAD_MARKS; i++) { + if (cg_treadMarks[i].iReferenceNumber == iReference) { + iTreadNum = i; + pTread = &cg_treadMarks[i]; + } + } + + if (iTreadNum == -1 || !pTread->iState) { + return -1; + } + + pTread->iLastTime = cg.time; + + if (VectorCompare(pTread->vEndPos, vNewPos)) { + if (fAlpha >= 0) { + pTread->fEndAlpha = fAlpha * 255.0; + } + return 0; + } + + VectorSubtract(vNewPos, pTread->vMidPos, vDelta); + fDist = VectorNormalize2(vDelta, vDeltaNorm); + if (pTread->iState == 1) { + fSplitLength = 0; + bDoSegmentation = qfalse; + } else { + VectorAdd(vDeltaNorm, pTread->vStartDir, vMidDir); + VectorScale(vMidDir, 0.5, vMidDir); + VectorNormalizeFast(vMidDir); + + fTmp = DotProduct(vMidDir, vDeltaNorm); + fSplitLength = pTread->fWidth / fTmp; + + if (fTmp < -0.5) { + fTmp = fTmp + * (fTmp + * (fTmp + * (fTmp * (fTmp * (fTmp * -337.31875783205 + -1237.54375255107) + -1802.11467325687) + + -1303.19904613494) + + -471.347871690988) + + -70.0883838161826); + } else if (fTmp > 0.5) { + fTmp = fTmp + * (fTmp + * (fTmp + * (fTmp * (fTmp * (fTmp * -1507.55394345521 + 6580.58002318442) + -11860.0735285953) + + 11290.7510782536) + + -5986.89654545347) + + 1675.66417006387) + + -192.426950291139; + } else { + fTmp = fTmp * (fTmp * -0.531387674508458 + -2.11e-14) + 1.00086138065435; + } + + fNewLength = fSplitLength * fTmp; + if (fNewLength + 24 > fDist) { + bDoSegmentation = qfalse; + } else if (fSplitLength < -1) { + fSplitLength = -fSplitLength; + bDoSegmentation = qtrue; + } else if (fDist > 256) { + bDoSegmentation = qtrue; + } else { + CrossProduct(vec_upwards, pTread->vStartDir, vRight); + VectorNormalizeFast(vRight); + bDoSegmentation = fabs(DotProduct(vRight, vDelta)) > 16; + } + } + + if (pTread->iState == 2 && bDoSegmentation) { + VectorCopy(pTread->vMidVerts[0], pTread->vStartVerts[0]); + VectorCopy(pTread->vMidVerts[1], pTread->vStartVerts[1]); + pTread->fMidTexCoord = pTread->fEndTexCoord; + pTread->fMidAlpha = pTread->fEndAlpha; + VectorCopy(vNewPos, pTread->vEndPos); + + if (fAlpha >= 0) { + pTread->fEndAlpha = fAlpha * 255.0; + } + + pTread->iState = 3; + } else if (pTread->iState == 0 || pTread->iState == 1) { + VectorCopy(vNewPos, pTread->vEndPos); + + if (fAlpha >= 0) { + pTread->fEndAlpha = fAlpha * 255.0; + } + + CrossProduct(vec_upwards, vDeltaNorm, vDir); + VectorMA(pTread->vMidPos, pTread->fWidth, vDir, pTread->vMidVerts[0]); + VectorMA(pTread->vMidPos, 0.0 - pTread->fWidth, vDir, pTread->vMidVerts[1]); + VectorMA(pTread->vEndPos, pTread->fWidth, vDir, pTread->vEndVerts[0]); + VectorMA(pTread->vEndPos, 0.0 - pTread->fWidth, vDir, pTread->vEndVerts[1]); + + pTread->fEndTexCoord = fDist / 32.0; + + if (pTread->iState == 1 && fDist > 8) { + VectorCopy(vDelta, pTread->vStartDir); + pTread->iState = 2; + } + return 0; + } else { + if (bDoSegmentation) { + CG_MakeTreadMarkDecal(pTread, qtrue, qfalse); + + VectorCopy(pTread->vMidVerts[0], pTread->vStartVerts[0]); + VectorCopy(pTread->vMidVerts[1], pTread->vStartVerts[1]); + VectorSubtract(pTread->vEndPos, pTread->vMidPos, pTread->vStartDir); + VectorNormalizeFast(pTread->vStartDir); + VectorCopy(pTread->vEndPos, pTread->vMidPos); + pTread->fMidTexCoord = pTread->fEndTexCoord; + pTread->fMidAlpha = pTread->fEndAlpha; + + if (pTread->fStartTexCoord >= 1.0) { + pTread->fMidTexCoord -= (int)pTread->fStartTexCoord; + pTread->fStartTexCoord -= (int)pTread->fStartTexCoord; + } + } + + VectorCopy(vNewPos, pTread->vEndPos); + pTread->fEndTexCoord = pTread->fMidTexCoord + fDist / 32.0; + + if (fAlpha >= 0) { + pTread->fEndAlpha = fAlpha * 255.0; + } + } + + CrossProduct(vec_upwards, vMidDir, vRight); + VectorNormalizeFast(vRight); + VectorMA(pTread->vMidPos, fSplitLength, vRight, pTread->vMidVerts[0]); + VectorMA(pTread->vMidPos, 0.0 - fSplitLength, vRight, pTread->vMidVerts[1]); + CrossProduct(vec_upwards, vDeltaNorm, vRight); + VectorNormalizeFast(vRight); + VectorMA(pTread->vEndPos, pTread->fWidth, vRight, pTread->vEndVerts[0]); + VectorMA(pTread->vEndPos, 0.0 - pTread->fWidth, vRight, pTread->vEndVerts[1]); + return 0; } void CG_AddTreadMarks() { - trace_t trace; - vec3_t vPos, vEnd; - int i; + treadMark_t *pTread; + trace_t trace; + vec3_t vPos, vEnd; + int i; if (cg_treadmark_test->integer) { VectorCopy(cg.predicted_player_state.origin, vPos); @@ -1112,39 +1465,38 @@ void CG_AddTreadMarks() "CG_AddTreadMarks test" ); - if (trace.fraction < 1.0 && CG_UpdateTreadMark(1, trace.endpos, 0.f) == -1) { + if (trace.fraction < 1.0 && CG_UpdateTreadMark(1, trace.endpos, 1.0) == -1) { qhandle_t shader = cgi.R_RegisterShader("testtread"); - CG_StartTreadMark(1, shader, trace.endpos, cg_treadmark_test->integer, 1.0f); + CG_StartTreadMark(1, shader, trace.endpos, cg_treadmark_test->integer, 1.0); } } for (i = 0; i < MAX_TREAD_MARKS; i++) { - if (!cg_treadMarks[i].iState) { + pTread = &cg_treadMarks[i]; + + if (!pTread->iState) { continue; } - if (cg.time - cg_treadMarks[i].iLastTime > 500) { - CG_MakeTreadMarkDecal( - &cg_treadMarks[i], - cg_treadMarks[i].iState == 3 ? qtrue : qfalse, - qfalse - ); - cg_treadMarks[i].iState = 0; - } - else { - CG_MakeTreadMarkDecal( - &cg_treadMarks[i], - cg_treadMarks[i].iState == 3 ? qtrue : qfalse, - qtrue - ); + if (cg.time - pTread->iLastTime > 500) { + if (pTread->iState == 3) { + CG_MakeTreadMarkDecal(pTread, qtrue, qfalse); + } + CG_MakeTreadMarkDecal(pTread, qfalse, qfalse); + pTread->iState = 0; + } else { + if (pTread->iState == 3) { + CG_MakeTreadMarkDecal(pTread, qtrue, qtrue); + } + CG_MakeTreadMarkDecal(pTread, qfalse, qtrue); } } } int CG_PermanentMark( - const vec3_t origin, - const vec3_t dir, + vec3_t origin, + vec3_t dir, float orientation, float fSScale, float fTScale, @@ -1159,8 +1511,148 @@ int CG_PermanentMark( void *pVoidPolyVerts ) { - // FIXME: unimplemented - return 0; + byte colors[4]; + int i, j; + int numFragments; + float fSScale2, fTScale2; + float fSScale3, fTScale3; + float texCoordScaleS, texCoordScaleT; + vec3_t originalPoints[4]; + vec3_t markPoints[MAX_MARK_POLYVERTS]; + vec3_t projection; + vec3_t vLight; + vec3_t vTmp; + vec3_t axis[3]; + markFragment_t *mf; + polyVert_t *pPolyVerts; + polyVert_t *v; + clipHandle_t cmodel; + trace_t trace; + float fRadiusSquared; + + pPolyVerts = (polyVert_t *)pVoidPolyVerts; + + VectorMA(origin, -2048, dir, vTmp); + VectorAdd(origin, dir, origin); + CG_Trace( + &trace, origin, vec3_origin, vec3_origin, vTmp, ENTITYNUM_NONE, MASK_MARK, qfalse, qtrue, "CG_PermanentMark" + ); + + if (trace.fraction == 1) { + return 0; + } + + VectorCopy(trace.endpos, origin); + VectorCopy(trace.plane.normal, dir); + + if (!fSScale) { + fSScale = 1.0; + } + if (!fTScale) { + fTScale = 1.0; + } + texCoordScaleT = 0.5 / fTScale; + texCoordScaleS = 0.5 / fSScale; + if (fSCenter < 0.0 || fSCenter > 1.0) { + fSCenter = 0.5; + } + if (fTCenter < 0.0 || fTCenter > 1.0) { + fTCenter = 0.5; + } + fRadiusSquared = fSScale * fSScale; + fRadiusSquared = fTScale * fTScale + fRadiusSquared; + fSScale2 = (fSScale * (1.0 - fSCenter)) * 2; + fTScale2 = (fTScale * (1.0 - fTCenter)) * 2; + fSScale3 = fSCenter * 2 * fSScale; + fTScale3 = fTCenter * 2 * fTScale; + + VectorNormalize2(dir, axis[0]); + PerpendicularVector(axis[1], axis[0]); + RotatePointAroundVector(axis[2], axis[0], axis[1], orientation); + CrossProduct(axis[0], axis[2], axis[1]); + + // create the full polygon + for (i = 0; i < 3; i++) { + originalPoints[0][i] = origin[i] - fSScale3 * axis[1][i] - fTScale3 * axis[2][i]; + originalPoints[1][i] = origin[i] + fSScale2 * axis[1][i] - fTScale3 * axis[2][i]; + originalPoints[2][i] = origin[i] + fSScale2 * axis[1][i] + fTScale2 * axis[2][i]; + originalPoints[3][i] = origin[i] - fSScale3 * axis[1][i] + fTScale2 * axis[2][i]; + } + + VectorScale(dir, -32, projection); + numFragments = CG_GetMarkFragments( + ARRAY_LEN(originalPoints), originalPoints, projection, markPoints, pMarkFragments, fRadiusSquared + ); + + if (!dolighting) { + colors[0] = (int)(red * 255.0f); + colors[1] = (int)(green * 255.0f); + colors[2] = (int)(blue * 255.0f); + } + + colors[3] = (int)(alpha * 255.0f); + + for (i = 0, mf = pMarkFragments; i < numFragments; i++, mf++) { + vec3_t vWorldPos; + vec3_t delta; + + if (mf->numPoints > 8) { + mf->numPoints = 8; + } + + if (mf->iIndex >= 0) { + for (j = 0; j < mf->numPoints; j++) { + v = &pPolyVerts[mf->firstPoint + j]; + VectorCopy(markPoints[mf->firstPoint + j], v->xyz); + + if (dolighting) { + cgi.R_GetLightingForDecal(vLight, dir, v->xyz); + + colors[0] = (int)(red * vLight[0]); + colors[1] = (int)(green * vLight[1]); + colors[2] = (int)(blue * vLight[2]); + } + + v->modulate[0] = colors[0]; + v->modulate[1] = colors[1]; + v->modulate[2] = colors[2]; + v->modulate[3] = colors[3]; + + VectorSubtract(v->xyz, origin, delta); + v->st[0] = fSCenter + DotProduct(delta, axis[1]) * texCoordScaleS; + v->st[1] = fTCenter + DotProduct(delta, axis[2]) * texCoordScaleT; + } + } else if (CG_GetMarkInlineModelOrientation(mf->iIndex)) { + for (j = 0; j < mf->numPoints; j++) { + v = &pPolyVerts[mf->firstPoint + j]; + VectorCopy(markPoints[mf->firstPoint + j], v->xyz); + + if (dolighting) { + CG_FragmentPosToWorldPos(v->xyz, vWorldPos); + cgi.R_GetLightingForDecal(vLight, dir, v->xyz); + + colors[0] = (int)(red * vLight[0]); + colors[1] = (int)(green * vLight[1]); + colors[2] = (int)(blue * vLight[2]); + } + + v->modulate[0] = colors[0]; + v->modulate[1] = colors[1]; + v->modulate[2] = colors[2]; + v->modulate[3] = colors[3]; + + VectorSubtract(v->xyz, origin, delta); + v->st[0] = fSCenter + DotProduct(delta, axis[1]) * texCoordScaleS; + v->st[1] = fTCenter + DotProduct(delta, axis[2]) * texCoordScaleT; + } + + mf->iIndex = -cgi.CM_InlineModel(cg_entities[-mf->iIndex].currentState.modelindex); + } else { + mf->numPoints = 0; + } + } + + return numFragments; } int CG_PermanentTreadMarkDecal( @@ -1171,14 +1663,412 @@ int CG_PermanentTreadMarkDecal( void *pVoidPolyVerts ) { - // FIXME: unimplemented - return 0; + byte colors[4]; + int i, j; + int numFragments; + vec3_t originalPoints[4]; + vec3_t markPoints[MAX_MARK_POLYVERTS]; + vec3_t projection; + vec3_t vLight; + markFragment_t *mf; + polyVert_t *pPolyVerts; + polyVert_t *v; + clipHandle_t cmodel; + float fStartAlpha, fEndAlpha; + float fStartTex, fEndTex; + float fRightCenterDist; + float fOOWidth, fOODoubleWidth; + float fDist, fSideDist; + float fFrac; + float fStartDist, fRightStartDist, fLeftStartDist; + float fCenterTexScale, fRightTexScale, fLeftTexScale; + float fCenterAlphaScale, fRightAlphaScale, fLeftAlphaScale; + float fSideAlpha, fCenterAlpha; + vec3_t vStartCenter, vEndCenter; + vec3_t vDirection; + vec3_t vRight; + vec3_t vDelta; + float fRadiusSquared; + + pPolyVerts = (polyVert_t *)pVoidPolyVerts; + + if (bStartSegment) { + VectorCopy(pTread->vStartVerts[1], originalPoints[0]); + VectorCopy(pTread->vStartVerts[0], originalPoints[1]); + VectorCopy(pTread->vMidVerts[0], originalPoints[2]); + VectorCopy(pTread->vMidVerts[1], originalPoints[3]); + + fStartAlpha = pTread->fStartAlpha; + fEndAlpha = pTread->fMidAlpha; + fStartTex = pTread->fStartTexCoord; + fEndTex = pTread->fMidTexCoord; + + // Calculate the start center + vStartCenter[0] = (originalPoints[1][0] + originalPoints[0][0]) * 0.5; + vStartCenter[1] = (originalPoints[1][1] + originalPoints[0][1]) * 0.5; + vStartCenter[2] = (originalPoints[1][2] + originalPoints[0][2]) * 0.5; + VectorCopy(pTread->vMidPos, vEndCenter); + VectorCopy(pTread->vStartDir, vDirection); + } else { + VectorCopy(pTread->vMidVerts[1], originalPoints[0]); + VectorCopy(pTread->vMidVerts[0], originalPoints[1]); + VectorCopy(pTread->vEndVerts[0], originalPoints[2]); + VectorCopy(pTread->vEndVerts[1], originalPoints[3]); + + fStartAlpha = pTread->fMidAlpha; + fEndAlpha = pTread->fEndAlpha; + fStartTex = pTread->fMidTexCoord; + fEndTex = pTread->fEndTexCoord; + + VectorCopy(pTread->vMidPos, vStartCenter); + VectorCopy(pTread->vEndPos, vEndCenter); + + // Calculate the direction + VectorSubtract(vEndCenter, vStartCenter, vDirection); + VectorNormalizeFast(vDirection); + } + + CrossProduct(vec_upwards, vDirection, vRight); + fRightCenterDist = DotProduct(vEndCenter, vRight); + fOOWidth = 1.0 / pTread->fWidth; + fOODoubleWidth = 1.0 / (pTread->fWidth * 2); + fStartDist = DotProduct(vDirection, vStartCenter); + fRightStartDist = DotProduct(vDirection, originalPoints[1]); + fLeftStartDist = DotProduct(vDirection, originalPoints[1]); + + // + // Calculate center + // + VectorSubtract(vEndCenter, vStartCenter, vDelta); + fDist = VectorLength(vDelta); + fCenterTexScale = (fEndTex - fStartTex) / fDist; + fCenterAlphaScale = (fEndAlpha - fStartAlpha) / fDist; + fSideDist = fDist; + + // + // Calculate right + // + VectorSubtract(originalPoints[2], originalPoints[1], vDelta); + fDist = VectorLength(vDelta); + fRightTexScale = (fEndTex - fStartTex) / fDist; + fRightAlphaScale = (fEndAlpha - fStartAlpha) / fDist; + + // + // Calculate left + // + VectorSubtract(originalPoints[3], originalPoints[0], vDelta); + fDist = VectorLength(vDelta); + fLeftTexScale = (fEndTex - fStartTex) / fDist; + fLeftAlphaScale = (fEndAlpha - fStartAlpha) / fDist; + + VectorSet(projection, 0, 0, -32); + colors[0] = colors[1] = colors[2] = colors[3] = 0xff; + + numFragments = CG_GetMarkFragments( + 4, originalPoints, projection, markPoints, pMarkFragments, (Square(pTread->fWidth) + Square(fSideDist)) * 0.25 + ); + + for (i = 0; i < numFragments; i++) { + vec3_t vWorldPos; + + mf = &pMarkFragments[i]; + + if (mf->numPoints > 8) { + mf->numPoints = 8; + } + + if (mf->iIndex >= 0) { + for (j = 0; j < mf->numPoints; j++) { + v = &pPolyVerts[mf->firstPoint + j]; + VectorCopy(markPoints[mf->firstPoint + j], v->xyz); + + if (dolighting) { + cgi.R_GetLightingForDecal(vLight, projection, v->xyz); + + colors[0] = vLight[0]; + colors[1] = vLight[1]; + colors[2] = vLight[2]; + } + + fSideDist = DotProduct(v->xyz, vRight) - fRightCenterDist; + fSideAlpha = fSideDist * fOOWidth; + v->st[0] = (fSideDist + pTread->fWidth) * fOODoubleWidth; + + if (fSideAlpha < 0) { + fSideAlpha = -fSideAlpha; + v->st[1] = + fStartTex + ((DotProduct(v->xyz, vDirection) - fLeftStartDist) * fLeftTexScale * fSideAlpha); + } else { + v->st[1] = + fStartTex + ((DotProduct(v->xyz, vDirection) - fRightStartDist) * fRightTexScale * fSideAlpha); + } + + v->st[1] += (DotProduct(v->xyz, vDirection) - fStartDist) * fCenterTexScale * (1.0 - fSideAlpha); + } + } else if (CG_GetMarkInlineModelOrientation(mf->iIndex)) { + for (j = 0; j < mf->numPoints; j++) { + v = &pPolyVerts[mf->firstPoint + j]; + VectorCopy(markPoints[mf->firstPoint + j], v->xyz); + + if (dolighting) { + cgi.R_GetLightingForDecal(vLight, projection, v->xyz); + + colors[0] = vLight[0]; + colors[1] = vLight[1]; + colors[2] = vLight[2]; + } + + v->modulate[0] = colors[0]; + v->modulate[1] = colors[1]; + v->modulate[2] = colors[2]; + v->modulate[3] = colors[3]; + + CG_FragmentPosToWorldPos(v->xyz, vWorldPos); + + fSideDist = DotProduct(vWorldPos, vRight) - fRightCenterDist; + fSideAlpha = fSideDist * fOOWidth; + v->st[0] = (fSideDist + pTread->fWidth) * fOODoubleWidth; + + if (fSideAlpha < 0) { + fSideAlpha = -fSideAlpha; + v->st[1] = + fStartTex + ((DotProduct(vWorldPos, vDirection) - fLeftStartDist) * fLeftTexScale * fSideAlpha); + } else { + v->st[1] = fStartTex + + ((DotProduct(vWorldPos, vDirection) - fRightStartDist) * fRightTexScale * fSideAlpha); + } + + v->st[1] += (DotProduct(vWorldPos, vDirection) - fStartDist) * fCenterTexScale * (1.0 - fSideAlpha); + } + + mf->iIndex = -cgi.CM_InlineModel(cg_entities[-mf->iIndex].currentState.modelindex); + } else { + mf->numPoints = 0; + } + } + + return numFragments; } int CG_PermanentUpdateTreadMark( treadMark_t *pTread, float fAlpha, float fMinSegment, float fMaxSegment, float fMaxOffset, float fTexScale ) { - // FIXME: unimplemented + trace_t trace; + float fDist; + float fSplitLength; + float fNewLength; + float fTmp; + qboolean bDoSegmentation; + vec3_t vPos; + vec3_t vEnd; + vec3_t vNewPos; + vec3_t vDelta, vDeltaNorm; + vec3_t vDir, vMidDir; + vec3_t vRight; + + VectorCopy(cg.predicted_player_state.origin, vPos); + VectorCopy(cg.predicted_player_state.origin, vEnd); + + vPos[2] += 32; + vEnd[2] -= 256; + + CG_Trace( + &trace, + vPos, + vec3_origin, + vec3_origin, + vEnd, + cg.snap->ps.clientNum, + MASK_TREADMARK, + qfalse, + qtrue, + "CG_PermanentUpdateTreadMark" + ); + + VectorCopy(trace.endpos, vNewPos); + + if (cg.time - pTread->iLastTime > 500) { + VectorClear(pTread->vStartDir); + VectorClear(pTread->vStartVerts[0]); + VectorClear(pTread->vStartVerts[1]); + pTread->fStartTexCoord = 0; + pTread->fStartAlpha = 0; + + VectorClear(pTread->vMidPos); + VectorClear(pTread->vMidVerts[0]); + VectorClear(pTread->vMidVerts[1]); + pTread->fMidTexCoord = 0; + pTread->fMidAlpha = 0; + + VectorClear(pTread->vEndPos); + VectorClear(pTread->vEndVerts[0]); + VectorClear(pTread->vEndVerts[1]); + pTread->fEndTexCoord = 0; + pTread->fEndAlpha = 0; + + pTread->iState = 1; + pTread->iReferenceNumber = 0; + pTread->iLastTime = cg.time; + VectorCopy(vNewPos, pTread->vMidPos); + VectorCopy(vNewPos, pTread->vEndPos); + + if (fAlpha < 0) { + pTread->fMidAlpha = 255.0; + } else { + pTread->fMidAlpha = fAlpha * 255.0; + } + pTread->fEndAlpha = pTread->fMidAlpha; + + return 0; + } + + if (VectorCompare(pTread->vEndPos, vNewPos)) { + if (fAlpha < 0) { + return -1; + } + + fTmp = pTread->fEndAlpha; + pTread->fEndAlpha = fAlpha * 255; + + //if (fabs(fTmp - pTread->fEndAlpha > 0.05)) { + // Fixed in OPM + // Looks like this was accidental + if (fabs(fTmp - pTread->fEndAlpha) > 0.05) { + return -1; + } + + return 0; + } + + VectorSubtract(vNewPos, pTread->vMidPos, vDelta); + fDist = VectorNormalize2(vDelta, vDeltaNorm); + + if (pTread->iState == 1) { + fSplitLength = 0.0; + bDoSegmentation = qfalse; + } else { + VectorAdd(vDeltaNorm, pTread->vStartDir, vMidDir); + VectorScale(vMidDir, 0.5, vMidDir); + VectorNormalizeFast(vMidDir); + + fTmp = DotProduct(vMidDir, vDeltaNorm); + fSplitLength = pTread->fWidth / fTmp; + + if (fTmp < -0.5) { + fNewLength = + fTmp + * (fTmp + * (fTmp + * (fTmp * (fTmp * (fTmp * -337.31875783205 + -1237.54375255107) + -1802.11467325687) + + -1303.19904613494) + + -471.347871690988) + + -70.0883838161826); + } else if (fTmp > 0.5) { + fNewLength = + fTmp + * (fTmp + * (fTmp + * (fTmp * (fTmp * (fTmp * -1507.55394345521 + 6580.58002318442) + -11860.0735285953) + + 11290.7510782536) + + -5986.89654545347) + + 1675.66417006387) + + -192.426950291139; + } else { + fNewLength = fTmp * (fTmp * -0.531387674508458 + -2.11e-14) + 1.00086138065435; + } + + fNewLength *= fSplitLength; + if (fNewLength + fMinSegment > fDist) { + bDoSegmentation = qfalse; + } else if (fSplitLength < -1) { + fSplitLength = -fSplitLength; + bDoSegmentation = qtrue; + } else if (fDist > fMaxSegment) { + bDoSegmentation = qtrue; + } else { + CrossProduct(vec_upwards, pTread->vStartDir, vRight); + VectorNormalizeFast(vRight); + + if (fabs(DotProduct(vRight, vDelta)) > fMaxOffset) { + bDoSegmentation = qtrue; + } else { + bDoSegmentation = qfalse; + } + } + } + + if (pTread->iState == 2 && bDoSegmentation) { + VectorCopy(pTread->vStartVerts[0], pTread->vMidVerts[0]); + VectorCopy(pTread->vStartVerts[1], pTread->vMidVerts[1]); + pTread->fMidTexCoord = pTread->fEndTexCoord; + pTread->fMidAlpha = pTread->fEndAlpha; + VectorCopy(vNewPos, pTread->vEndPos); + + if (fAlpha >= 0) { + pTread->fEndAlpha = fAlpha * 255.0; + } + + pTread->iState = 3; + + return 0; + } else if (pTread->iState == 1 || pTread->iState == 2) { + VectorCopy(vNewPos, pTread->vEndPos); + + if (fAlpha >= 0.0) { + pTread->fEndAlpha = fAlpha * 255.0; + } + + CrossProduct(vec_upwards, vDeltaNorm, vDir); + VectorMA(pTread->vMidPos, pTread->fWidth, vDir, pTread->vMidVerts[0]); + VectorMA(pTread->vMidPos, -pTread->fWidth, vDir, pTread->vMidVerts[1]); + VectorMA(pTread->vEndPos, pTread->fWidth, vDir, pTread->vEndVerts[0]); + VectorMA(pTread->vEndPos, -pTread->fWidth, vDir, pTread->vEndVerts[1]); + + pTread->fEndTexCoord = fDist * fTexScale; + + if (pTread->iState == 1 && fDist > 8.0) { + VectorCopy(vDelta, pTread->vStartDir); + pTread->iState = 2; + } + + return 0; + } else if (bDoSegmentation) { + if (!pTread->iReferenceNumber) { + pTread->iReferenceNumber = 1; + return 1; + } + + pTread->iReferenceNumber = 0; + VectorCopy(pTread->vStartVerts[0], pTread->vMidVerts[0]); + VectorCopy(pTread->vStartVerts[1], pTread->vMidVerts[1]); + VectorSubtract(pTread->vEndPos, pTread->vMidPos, pTread->vStartDir); + VectorNormalizeFast(pTread->vStartDir); + + VectorCopy(pTread->vEndPos, pTread->vMidPos); + pTread->fMidTexCoord = pTread->fEndTexCoord; + pTread->fMidAlpha = pTread->fEndAlpha; + + if (pTread->fStartTexCoord >= 1.0) { + pTread->fStartTexCoord = pTread->fStartTexCoord - floor(pTread->fStartTexCoord); + pTread->fMidTexCoord = pTread->fMidTexCoord - floor(pTread->fStartTexCoord); + } + + VectorCopy(vNewPos, pTread->vEndPos); + pTread->fEndTexCoord = fDist * fTexScale + pTread->fMidTexCoord; + if (fAlpha >= 0) { + pTread->fEndAlpha = fAlpha * 255.0; + } + } + + CrossProduct(vec_upwards, vMidDir, vRight); + VectorNormalizeFast(vRight); + VectorMA(pTread->vMidPos, fSplitLength, vRight, pTread->vMidVerts[0]); + VectorMA(pTread->vMidPos, -fSplitLength, vRight, pTread->vMidVerts[1]); + CrossProduct(vec_upwards, vDeltaNorm, vRight); + VectorNormalizeFast(vRight); + VectorMA(pTread->vEndPos, pTread->fWidth, vRight, pTread->vEndVerts[0]); + VectorMA(pTread->vEndPos, -pTread->fWidth, vRight, pTread->vEndVerts[1]); + return 0; } diff --git a/code/cgame/cg_modelanim.c b/code/cgame/cg_modelanim.c index 5386db19..d47dc1cc 100644 --- a/code/cgame/cg_modelanim.c +++ b/code/cgame/cg_modelanim.c @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2025 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -26,6 +26,33 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "cg_local.h" #include "tiki.h" +static qboolean cg_forceModelAllowed = qfalse; + +/* +=============== +CG_GetPlayerModelTiki +=============== +*/ +const char *CG_GetPlayerModelTiki(const char *modelName) +{ + return va("models/player/%s.tik", modelName); +} + +/* +=============== +CG_GetPlayerLocalModelTiki +=============== +*/ +const char *CG_GetPlayerLocalModelTiki(const char *modelName) +{ + return va("models/player/%s.tik", modelName); +} + +/* +=============== +CG_PlayerTeamIcon +=============== +*/ void CG_PlayerTeamIcon(refEntity_t *pModel, entityState_t *pPlayerState) { qboolean bInArtillery, bInTeam, bSpecialIcon; @@ -180,6 +207,118 @@ void CG_PlayerTeamIcon(refEntity_t *pModel, entityState_t *pPlayerState) } } +/* +=============== +CG_InterpolateAnimParms + +Interpolate between current and next entity +=============== +*/ +void CG_InterpolateAnimParms(entityState_t *state, entityState_t *sNext, refEntity_t *model) +{ + static cvar_t *vmEntity = NULL; + int i; + float t; + float animLength; + float t1, t2; + + if (!vmEntity) { + vmEntity = cgi.Cvar_Get("viewmodelanim", "1", 0); + } + + if (sNext && sNext->usageIndex == state->usageIndex) { + t1 = cg.time - cg.snap->serverTime; + t2 = cg.nextSnap->serverTime - cg.snap->serverTime; + t = t1 / t2; + + model->actionWeight = (sNext->actionWeight - state->actionWeight) * t + state->actionWeight; + + for (i = 0; i < MAX_FRAMEINFOS; i++) { + if (sNext->frameInfo[i].weight) { + model->frameInfo[i].index = sNext->frameInfo[i].index; + if (sNext->frameInfo[i].index == state->frameInfo[i].index && state->frameInfo[i].weight) { + model->frameInfo[i].weight = + (sNext->frameInfo[i].weight - state->frameInfo[i].weight) * t + state->frameInfo[i].weight; + + if (sNext->frameInfo[i].time >= state->frameInfo[i].time) { + model->frameInfo[i].time = + (sNext->frameInfo[i].time - state->frameInfo[i].time) * t + state->frameInfo[i].time; + } else { + animLength = cgi.Anim_Time(model->tiki, sNext->frameInfo[i].index); + if (!animLength) { + t1 = 0.0; + } else { + t1 = (animLength + sNext->frameInfo[i].time - state->frameInfo[i].time) * t + + state->frameInfo[i].time; + } + + t2 = t1; + while (t2 > animLength) { + t2 -= animLength; + + if (t2 == t1) { + t2 = 1.0; + break; + } + + t1 = t2; + } + + model->frameInfo[i].time = t2; + } + } else { + animLength = cgi.Anim_Time(model->tiki, sNext->frameInfo[i].index); + if (!animLength) { + t1 = 0.0; + } else { + t1 = sNext->frameInfo[i].time - (cg.nextSnap->serverTime - cg.time) / 1000.0; + } + + model->frameInfo[i].time = Q_max(0, t1); + model->frameInfo[i].weight = sNext->frameInfo[i].weight; + } + } else if (sNext->frameInfo[i].index == state->frameInfo[i].index) { + animLength = cgi.Anim_Time(model->tiki, sNext->frameInfo[i].index); + if (!animLength) { + t1 = 0.0; + } else { + t1 = (cg.time - cg.snap->serverTime) / 1000.0 + state->frameInfo[i].time; + } + + model->frameInfo[i].index = Q_clamp_int(state->frameInfo[i].index, 0, model->tiki->a->num_anims - 1); + model->frameInfo[i].time = Q_min(animLength, t1); + model->frameInfo[i].weight = (1.0 - t) * state->frameInfo[i].weight; + } else { + model->frameInfo[i].index = -1; + model->frameInfo[i].weight = 0.0; + } + } + } else { + // no next state, don't blend anims + + model->actionWeight = state->actionWeight; + for (i = 0; i < MAX_FRAMEINFOS; i++) { + if (state->frameInfo[i].weight) { + model->frameInfo[i].index = Q_clamp_int(state->frameInfo[i].index, 0, model->tiki->a->num_anims - 1); + model->frameInfo[i].time = state->frameInfo[i].time; + model->frameInfo[i].weight = state->frameInfo[i].weight; + } else { + model->frameInfo[i].index = -1; + model->frameInfo[i].weight = 0.0; + } + } + } + + if (vmEntity->integer == state->number) { + static cvar_t *curanim; + if (!curanim) { + curanim = cgi.Cvar_Get("viewmodelanimslot", "1", 0); + } + + cgi.Cvar_Set("viewmodelanimclienttime", va("%0.2f", model->frameInfo[curanim->integer].time)); + } +} + /* =============== CG_CastFootShadow @@ -187,20 +326,20 @@ CG_CastFootShadow Cast complex foot shadow using lights =============== */ -void CG_CastFootShadow(const vec_t* vLightPos, vec_t* vLightIntensity, int iTag, refEntity_t* model) +void CG_CastFootShadow(const vec_t *vLightPos, vec_t *vLightIntensity, int iTag, refEntity_t *model) { - int i; - float fAlpha; - float fLength; - float fWidth; - float fAlphaOfs; - float fOfs; - float fPitchCos; - vec3_t vPos; - vec3_t vEnd; - vec3_t vDelta; - vec3_t vLightAngles; - trace_t trace; + int i; + float fAlpha; + float fLength; + float fWidth; + float fAlphaOfs; + float fOfs; + float fPitchCos; + vec3_t vPos; + vec3_t vEnd; + vec3_t vDelta; + vec3_t vLightAngles; + trace_t trace; orientation_t oFoot; VectorCopy(model->origin, vPos); @@ -210,8 +349,7 @@ void CG_CastFootShadow(const vec_t* vLightPos, vec_t* vLightIntensity, int iTag, VectorMA(vPos, vEnd[i], model->axis[i], vPos); } - if (cg_shadowdebug->integer) - { + if (cg_shadowdebug->integer) { vec3_t vDir; // @@ -262,12 +400,11 @@ void CG_CastFootShadow(const vec_t* vLightPos, vec_t* vLightIntensity, int iTag, } fLength = fPitchCos * fPitchCos * 32.0 + fPitchCos * 8.0 + 10.0; - fOfs = 0.5 - (-4.1 / tan(DEG2RAD(vLightAngles[0])) + 4.0 - fLength) / fLength * 0.5; + fOfs = 0.5 - (-4.1 / tan(DEG2RAD(vLightAngles[0])) + 4.0 - fLength) / fLength * 0.5; VectorMA(vPos, -96.0, vDelta, vEnd); CG_Trace(&trace, vPos, vec3_origin, vec3_origin, vEnd, 0, MASK_FOOTSHADOW, qfalse, qtrue, "CG_CastFootShadow"); - - if (cg_shadowdebug->integer) - { + + if (cg_shadowdebug->integer) { cgi.R_DebugLine(vPos, vLightPos, 0.75, 0.75, 0.5, 1.0); cgi.R_DebugLine(vPos, vEnd, 1.0, 1.0, 1.0, 1.0); } @@ -281,7 +418,7 @@ void CG_CastFootShadow(const vec_t* vLightPos, vec_t* vLightIntensity, int iTag, trace.fraction = 0; } - fWidth = 10.f - (1.f - trace.fraction) * 6.f; + fWidth = 10.f - (1.f - trace.fraction) * 6.f; fAlphaOfs = (1.f - trace.fraction) * fAlpha; fAlpha = Q_max(vLightIntensity[0], Q_max(vLightIntensity[1], vLightIntensity[2])); @@ -334,13 +471,21 @@ CG_CastSimpleFeetShadow Cast basic feet shadow =============== */ -void CG_CastSimpleFeetShadow(const trace_t* pTrace, float fWidth, float fAlpha, int iRightTag, int iLeftTag, const dtiki_t* tiki, refEntity_t* model) +void CG_CastSimpleFeetShadow( + const trace_t *pTrace, + float fWidth, + float fAlpha, + int iRightTag, + int iLeftTag, + const dtiki_t *tiki, + refEntity_t *model +) { - int i; - float fShadowYaw; - float fLength; - vec3_t vPos, vRightPos, vLeftPos; - vec3_t vDelta; + int i; + float fShadowYaw; + float fLength; + vec3_t vPos, vRightPos, vLeftPos; + vec3_t vDelta; orientation_t oFoot; // @@ -374,7 +519,7 @@ void CG_CastSimpleFeetShadow(const trace_t* pTrace, float fWidth, float fAlpha, // get the facing yaw fShadowYaw = vectoyaw(vDelta); - fLength = VectorNormalize(vDelta) * 0.5 + 12; + fLength = VectorNormalize(vDelta) * 0.5 + 12; if (fLength < fWidth * 0.7) { fLength = fWidth * 0.7; } @@ -439,15 +584,13 @@ qboolean CG_EntityShadow(centity_t *cent, refEntity_t *model) } if (iTagR != -1) { - int iNumLights, iCurrLight; + int iNumLights, iCurrLight; vec3_t avLightPos[16], avLightIntensity[16]; iNumLights = Q_clamp(cg_shadowscount->integer, 1, 8); iNumLights = cgi.R_GatherLightSources(model->origin, avLightPos, avLightIntensity, iNumLights); - if (iNumLights) - { - for (iCurrLight = 0; iCurrLight < iNumLights; iCurrLight++) - { + if (iNumLights) { + for (iCurrLight = 0; iCurrLight < iNumLights; iCurrLight++) { CG_CastFootShadow(avLightPos[iCurrLight], avLightIntensity[iCurrLight], iTagL, model); CG_CastFootShadow(avLightPos[iCurrLight], avLightIntensity[iCurrLight], iTagR, model); } @@ -550,7 +693,7 @@ void CG_AnimationDebugMessage(int number, const char *fmt, ...) char msg[1024]; va_start(argptr, fmt); - vsprintf(msg, fmt, argptr); + Q_vsnprintf(msg, sizeof(msg), fmt, argptr); va_end(argptr); if ((!cg_debugAnimWatch->integer) || ((cg_debugAnimWatch->integer - 1) == number)) { @@ -614,6 +757,11 @@ void CG_AttachEntity( VectorAdd(entity->origin, vOrigin, entity->lightingOrigin); } +/* +=============== +CG_AttachEyeEntity +=============== +*/ void CG_AttachEyeEntity( refEntity_t *entity, refEntity_t *parent, dtiki_t *tiki, int tagnum, qboolean use_angles, vec_t *attach_offset ) @@ -626,8 +774,7 @@ void CG_AttachEyeEntity( AnglesToAxis(cg.refdefViewAngles, entity->axis); } - if (attach_offset[0] || attach_offset[1] || attach_offset[2]) - { + if (attach_offset[0] || attach_offset[1] || attach_offset[2]) { for (i = 0; i < 3; i++) { VectorMA(entity->origin, attach_offset[i], entity->axis[i], entity->origin); } @@ -639,56 +786,219 @@ void CG_AttachEyeEntity( VectorCopy(parent->lightingOrigin, entity->lightingOrigin); } +/* +=============== +CG_IsValidServerModel +=============== +*/ +qboolean CG_IsValidServerModel(const char *modelpath) +{ + const char *str; + int i; + + for (i = 1; i < MAX_MODELS; i++) { + str = CG_ConfigString(CS_MODELS + i); + if (!Q_stricmp(str, modelpath)) { + return qtrue; + } + } + + return qfalse; +} + +/* +=============== +CG_CheckValidModels + +This verifies the allied player model and the german player model: +- If they don't exist on the client, reset to the default allied player model +- If they don't exist on the server, don't allow forceModel so the client explicitly know the skin isn't supported +=============== +*/ +void CG_CheckValidModels() +{ + const char *modelpath; + qboolean isDirty = qfalse; + + if (dm_playermodel->modified) { + // Check for allied model + modelpath = va("models/player/%s.tik", dm_playermodel->string); + if (!cgi.R_RegisterModel(modelpath)) { + cgi.Printf( + "Allied model '%s' is invalid, resetting to '%s'\n", dm_playermodel->string, dm_playermodel->resetString + ); + + cgi.Cvar_Set("dm_playermodel", dm_playermodel->resetString); + modelpath = va("models/player/%s.tik", dm_playermodel->string); + } + + cg.serverAlliedModelValid = CG_IsValidServerModel(modelpath); + } + + if (dm_playergermanmodel->modified) { + // Check for axis model + modelpath = va("models/player/%s.tik", dm_playergermanmodel->string); + if (!cgi.R_RegisterModel(modelpath)) { + cgi.Printf( + "Allied model '%s' is invalid, resetting to '%s'\n", + dm_playergermanmodel->string, + dm_playergermanmodel->resetString + ); + + cgi.Cvar_Set("dm_playergermanmodel", dm_playergermanmodel->resetString); + modelpath = va("models/player/%s.tik", dm_playergermanmodel->string); + } + + cg.serverAxisModelValid = CG_IsValidServerModel(modelpath); + } + + if (dm_playermodel->modified || dm_playergermanmodel->modified) { + cg_forceModelAllowed = cg.serverAlliedModelValid && cg.serverAxisModelValid; + } +} + +/* +=============== +CG_ServerModelLoaded +=============== +*/ +void CG_ServerModelLoaded(const char *name, qhandle_t handle) +{ + if (!Q_stricmpn(name, "models/player/", 14) && (!cg.serverAlliedModelValid || !cg.serverAxisModelValid)) { + char modelName[MAX_QPATH]; + COM_StripExtension(name + 14, modelName, sizeof(modelName)); + + // + // The player model has been loaded on the server + // so try again parsing + // + if (!Q_stricmp(modelName, dm_playermodel->string)) { + dm_playermodel->modified = qtrue; + } + if (!Q_stricmp(modelName, dm_playergermanmodel->string)) { + dm_playergermanmodel->modified = qtrue; + } + } +} + +/* +=============== +CG_ServerModelUnloaded +=============== +*/ +void CG_ServerModelUnloaded(qhandle_t handle) +{ +#if 0 + if (cg.serverAlliedModelValid && handle == cg.hAlliedPlayerModelHandle) { + dm_playermodel->modified = qtrue; + } + if (cg.serverAxisModelValid && handle == cg.hAxisPlayerModelHandle) { + dm_playergermanmodel->modified = qtrue; + } +#endif +} + +/* +=============== +CG_UpdateForceModels +=============== +*/ void CG_UpdateForceModels() { qhandle_t hModel; - char* pszAlliesPartial; - char* pszAxisPartial; - char szAlliesModel[256]; - char szAxisModel[256]; + char *pszAlliesPartial; + char *pszAxisPartial; + char szAlliesModel[256]; + char szAxisModel[256]; + qboolean isDirty; - if (cg.pAlliedPlayerModel && cg.pAxisPlayerModel && !dm_playermodel->modified && !dm_playergermanmodel->modified) { + isDirty = dm_playermodel->modified || dm_playergermanmodel->modified || cg_forceModel->modified; + + if (!cg_forceModelAllowed) { + if (isDirty) { + cgi.Printf( + "One or more of the selected players model don't exist on the server or are not loaded, using the " + "default skin\n" + ); + } + + return; + } + + if (cg.pAlliedPlayerModel && cg.pAxisPlayerModel && !isDirty) { return; } pszAlliesPartial = dm_playermodel->string; - pszAxisPartial = dm_playergermanmodel->string; + pszAxisPartial = dm_playergermanmodel->string; - sprintf(szAlliesModel, "models/player/%s.tik", pszAlliesPartial); - sprintf(szAxisModel, "models/player/%s.tik", pszAxisPartial); - hModel = cgi.R_RegisterModel(szAlliesModel); - if (!hModel) hModel = cgi.R_RegisterModel("models/player/american_army.tik"); + Com_sprintf(szAlliesModel, sizeof(szAlliesModel), "models/player/%s.tik", pszAlliesPartial); + Com_sprintf(szAxisModel, sizeof(szAxisModel), "models/player/%s.tik", pszAxisPartial); + + hModel = cg.serverAlliedModelValid ? cgi.R_RegisterModel(szAlliesModel) : 0; + if (!hModel) { + Com_sprintf(szAlliesModel, sizeof(szAlliesModel), "models/player/%s.tik", dm_playermodel->resetString); + hModel = cgi.R_RegisterModel(szAlliesModel); + } if (hModel) { cg.hAlliedPlayerModelHandle = hModel; - cg.pAlliedPlayerModel = cgi.R_Model_GetHandle(hModel); + cg.pAlliedPlayerModel = cgi.R_Model_GetHandle(hModel); if (!cg.pAlliedPlayerModel) { cg.hAlliedPlayerModelHandle = 0; } } else { cg.hAlliedPlayerModelHandle = 0; - cg.pAlliedPlayerModel = 0; + cg.pAlliedPlayerModel = NULL; } - hModel = cgi.R_RegisterModel(szAxisModel); - if (!hModel) hModel = cgi.R_RegisterModel("models/player/german_wehrmacht_soldier.tik"); + hModel = cg.serverAxisModelValid ? cgi.R_RegisterModel(szAxisModel) : 0; + if (!hModel) { + Com_sprintf(szAxisModel, sizeof(szAxisModel), "models/player/%s.tik", dm_playergermanmodel->resetString); + hModel = cgi.R_RegisterModel(szAxisModel); + } if (hModel) { cg.hAxisPlayerModelHandle = hModel; - cg.pAxisPlayerModel = cgi.R_Model_GetHandle(hModel); + cg.pAxisPlayerModel = cgi.R_Model_GetHandle(hModel); if (!cg.pAxisPlayerModel) { cg.hAxisPlayerModelHandle = 0; } } else { cg.hAxisPlayerModelHandle = 0; - cg.pAxisPlayerModel = 0; + cg.pAxisPlayerModel = 0; } // Clear modified flag - dm_playermodel->modified = qfalse; - dm_playergermanmodel->modified = qfalse; + //dm_playermodel->modified = qfalse; + //dm_playergermanmodel->modified = qfalse; } +/* +=============== +CG_ProcessPlayerModel + +Checks player models, and update force models +=============== +*/ +void CG_ProcessPlayerModel() +{ + CG_CheckValidModels(); + if (cg_forceModel->integer) { + CG_UpdateForceModels(); + } + + // Clear modified flag + dm_playermodel->modified = qfalse; + dm_playergermanmodel->modified = qfalse; + cg_forceModel->modified = qfalse; +} + +/* +=============== +CG_ModelAnim +=============== +*/ void CG_ModelAnim(centity_t *cent, qboolean bDoShaderTime) { entityState_t *s1; @@ -697,7 +1007,6 @@ void CG_ModelAnim(centity_t *cent, qboolean bDoShaderTime) int i; vec3_t vMins, vMaxs, vTmp; const char *szTagName; - static cvar_t *vmEntity = NULL; int iAnimFlags; s1 = ¢->currentState; @@ -709,10 +1018,6 @@ void CG_ModelAnim(centity_t *cent, qboolean bDoShaderTime) memset(&model, 0, sizeof(model)); - if (!vmEntity) { - vmEntity = cgi.Cvar_Get("viewmodelanim", "1", 0); - } - if (cent->interpolate) { sNext = ¢->nextState; } @@ -834,8 +1139,8 @@ void CG_ModelAnim(centity_t *cent, qboolean bDoShaderTime) model.tiki = cgi.R_Model_GetHandle(cgs.model_draw[s1->modelindex]); if (s1->number != cg.snap->ps.clientNum && (s1->eType == ET_PLAYER || (s1->eFlags & EF_DEAD))) { - if (cg_forceModel->integer) { - CG_UpdateForceModels(); + if (cg_forceModel->integer && cg_forceModelAllowed) { + //CG_UpdateForceModels(); if (s1->eFlags & EF_AXIS) { model.hModel = cg.hAxisPlayerModelHandle; @@ -859,9 +1164,9 @@ void CG_ModelAnim(centity_t *cent, qboolean bDoShaderTime) if (!model.hModel || !model.tiki) { // Use a model in case it still doesn't exist if (s1->eFlags & EF_AXIS) { - model.hModel = cgi.R_RegisterModel("models/player/german_wehrmacht_soldier.tik"); + model.hModel = cgi.R_RegisterModel(CG_GetPlayerModelTiki(dm_playergermanmodel->resetString)); } else { - model.hModel = cgi.R_RegisterModel("models/player/american_army.tik"); + model.hModel = cgi.R_RegisterModel(CG_GetPlayerModelTiki(dm_playermodel->resetString)); } model.tiki = cgi.R_Model_GetHandle(model.hModel); model.hOldModel = cgs.model_draw[s1->modelindex]; @@ -880,103 +1185,7 @@ void CG_ModelAnim(centity_t *cent, qboolean bDoShaderTime) model.renderfx |= s1->renderfx; cgi.TIKI_SetEyeTargetPos(model.tiki, model.entityNumber, s1->eyeVector); - if (sNext && sNext->usageIndex == s1->usageIndex) { - float t; - float animLength; - float t1, t2; - - t1 = cg.time - cg.snap->serverTime; - t2 = cg.nextSnap->serverTime - cg.snap->serverTime; - t = t1 / t2; - model.actionWeight = (sNext->actionWeight - s1->actionWeight) * t + s1->actionWeight; - - for (i = 0; i < MAX_FRAMEINFOS; i++) { - if (sNext->frameInfo[i].weight) { - model.frameInfo[i].index = sNext->frameInfo[i].index; - if (sNext->frameInfo[i].index == s1->frameInfo[i].index && s1->frameInfo[i].weight) { - model.frameInfo[i].weight = - (sNext->frameInfo[i].weight - s1->frameInfo[i].weight) * t + s1->frameInfo[i].weight; - - if (sNext->frameInfo[i].time >= s1->frameInfo[i].time) { - model.frameInfo[i].time = - (sNext->frameInfo[i].time - s1->frameInfo[i].time) * t + s1->frameInfo[i].time; - } else { - animLength = cgi.Anim_Time(model.tiki, sNext->frameInfo[i].index); - if (!animLength) { - t1 = 0.0; - } else { - t1 = (animLength + sNext->frameInfo[i].time - s1->frameInfo[i].time) * t - + s1->frameInfo[i].time; - } - - t2 = t1; - while (t2 > animLength) { - t2 -= animLength; - } - - model.frameInfo[i].time = t2; - } - } else { - animLength = cgi.Anim_Time(model.tiki, sNext->frameInfo[i].index); - if (!animLength) { - t1 = 0.0; - } else { - t1 = sNext->frameInfo[i].time - (cg.nextSnap->serverTime - cg.time) / 1000.0; - } - - t2 = t1; - if (t2 < 0.0) { - t2 = 0.0; - } - - model.frameInfo[i].time = t2; - model.frameInfo[i].weight = sNext->frameInfo[i].weight; - } - } else if (sNext->frameInfo[i].index == s1->frameInfo[i].index) { - animLength = cgi.Anim_Time(model.tiki, sNext->frameInfo[i].index); - if (!animLength) { - t1 = 0.0; - } else { - t1 = (cg.time - cg.snap->serverTime) / 1000.0 + s1->frameInfo[i].time; - } - - t2 = t1; - if (t2 < animLength) { - t2 = animLength; - } - - model.frameInfo[i].index = s1->frameInfo[i].index; - model.frameInfo[i].time = t2; - model.frameInfo[i].weight = (1.0 - t) * s1->frameInfo[i].weight; - } else { - model.frameInfo[i].index = -1; - model.frameInfo[i].weight = 0.0; - } - } - } else { - // no next state, don't blend anims - - model.actionWeight = s1->actionWeight; - for (i = 0; i < MAX_FRAMEINFOS; i++) { - if (s1->frameInfo[i].weight) { - model.frameInfo[i].index = s1->frameInfo[i].index; - model.frameInfo[i].time = s1->frameInfo[i].time; - model.frameInfo[i].weight = s1->frameInfo[i].weight; - } else { - model.frameInfo[i].index = -1; - model.frameInfo[i].weight = 0.0; - } - } - } - - if (vmEntity->integer == s1->number) { - static cvar_t *curanim; - if (!curanim) { - curanim = cgi.Cvar_Get("viewmodelanimslot", "1", 0); - } - - cgi.Cvar_Set("viewmodelanimclienttime", va("%0.2f", model.frameInfo[curanim->integer].time)); - } + CG_InterpolateAnimParms(s1, sNext, &model); if (cent->currentState.parent != ENTITYNUM_NONE) { int iTagNum; @@ -1190,7 +1399,9 @@ void CG_ModelAnim(centity_t *cent, qboolean bDoShaderTime) if (!cg.pLastPlayerWorldModel || cg.pLastPlayerWorldModel != model.tiki) { qhandle_t hModel; char fpsname[128]; + COM_StripExtension(model.tiki->a->name, fpsname, sizeof(fpsname)); + Q_strcat(fpsname, sizeof(fpsname), "_fps.tik"); hModel = cgi.R_RegisterModel(fpsname); if (hModel) { @@ -1201,9 +1412,9 @@ void CG_ModelAnim(centity_t *cent, qboolean bDoShaderTime) } } else { if (cg.snap->ps.stats[STAT_TEAM] == TEAM_AXIS) { - hModel = cgi.R_RegisterModel("models/player/german_wehrmacht_soldier_fps.tik"); + hModel = cgi.R_RegisterModel(CG_GetPlayerLocalModelTiki(dm_playergermanmodel->resetString)); } else { - hModel = cgi.R_RegisterModel("models/player/american_army_fps.tik"); + hModel = cgi.R_RegisterModel(CG_GetPlayerLocalModelTiki(dm_playermodel->resetString)); } if (hModel) { @@ -1227,6 +1438,7 @@ void CG_ModelAnim(centity_t *cent, qboolean bDoShaderTime) memset(model.surfaces, 0, sizeof(model.surfaces)); CG_ViewModelAnimation(&model); + model.renderfx |= RF_FRAMELERP; cgi.ForceUpdatePose(&model); if ((cent->currentState.eFlags & EF_UNARMED) || cg_drawviewmodel->integer <= 1 @@ -1323,7 +1535,12 @@ void CG_ModelAnim(centity_t *cent, qboolean bDoShaderTime) if (model.frameInfo[i].weight) { if (!((cent->animLastWeight >> i) & 1) || model.frameInfo[i].index != cent->animLast[i]) { CG_ProcessEntityCommands(TIKI_FRAME_ENTRY, model.frameInfo[i].index, s1->number, &model, cent); - cent->animLastTimes[i] = 0.0; + if (cent->animLastTimes[i] == -1) { + cent->animLast[i] = model.frameInfo[i].index; + cent->animLastTimes[i] = model.frameInfo[i].time; + } else { + cent->animLastTimes[i] = 0; + } } CG_ClientCommands(&model, cent, i); diff --git a/code/cgame/cg_nature.cpp b/code/cgame/cg_nature.cpp index 304f0906..c7a623c8 100644 --- a/code/cgame/cg_nature.cpp +++ b/code/cgame/cg_nature.cpp @@ -51,16 +51,16 @@ void RainTouch(ctempmodel_t *ct, trace_t *trace) void ClientGameCommandManager::RainTouch(Event *ev) { - // FIXME: unimplemented + // Nothing to do } void ClientGameCommandManager::InitializeRainCvars() { int i; - cg_rain = cgi.Cvar_Get("cg_rain", "0", CVAR_ARCHIVE); + cg_rain = cgi.Cvar_Get("cg_rain", "1", CVAR_ARCHIVE); cg_rain_drawcoverage = - cgi.Cvar_Get("cg_rain_drawcoverage", "0", CVAR_SAVEGAME | CVAR_SERVER_CREATED | CVAR_SYSTEMINFO); + cgi.Cvar_Get("cg_rain_drawcoverage", "0", CVAR_SAVEGAME | CVAR_RESETSTRING | CVAR_SYSTEMINFO); cg.rain.density = 0.0; cg.rain.speed = 2048.0f; diff --git a/code/cgame/cg_parsemsg.cpp b/code/cgame/cg_parsemsg.cpp index 12fc0e4d..fe723d77 100644 --- a/code/cgame/cg_parsemsg.cpp +++ b/code/cgame/cg_parsemsg.cpp @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "cg_local.h" #include "cg_parsemsg.h" #include "cg_specialfx.h" +#include "cg_radar.h" #include "str.h" @@ -84,7 +85,12 @@ void CG_MakeBulletHoleSound(const vec3_t i_vPos, const vec3_t i_vNorm, int iLarg iSurfType = SURF_PUDDLE; } - if (trace.fraction == 1.0f || trace.startsolid || (trace.surfaceFlags & SURF_SKY)) { + if (trace.fraction == 1) { + // no reason to make a sound if it nothing was hit + return; + } + + if ((trace.surfaceFlags & SURF_SKY) || !CG_CheckMakeMarkOnEntity(trace.entityNum)) { return; } @@ -160,49 +166,49 @@ static void CG_MakeBulletHoleType( float fVolume; switch (iEffectNum) { - case 0: + case SFX_BHIT_PAPER_LITE: sBulletHole += "paper"; break; - case 2: + case SFX_BHIT_WOOD_LITE: sBulletHole += "wood"; break; - case 4: + case SFX_BHIT_METAL_LITE: sBulletHole += "metal"; break; - case 6: + case SFX_BHIT_STONE_LITE: sBulletHole += "stone"; break; - case 8: + case SFX_BHIT_DIRT_LITE: sBulletHole += "dirt"; break; - case 10: + case SFX_BHIT_GRILL_LITE: sBulletHole += "grill"; break; - case 12: + case SFX_BHIT_GRASS_LITE: sBulletHole += "grass"; break; - case 14: + case SFX_BHIT_MUD_LITE: sBulletHole += "mud"; break; - case 16: + case SFX_BHIT_PUDDLE_LITE: sBulletHole += "puddle"; break; - case 18: + case SFX_BHIT_GLASS_LITE: sBulletHole += "glass"; break; - case 20: + case SFX_BHIT_GRAVEL_LITE: sBulletHole += "gravel"; break; - case 22: + case SFX_BHIT_SAND_LITE: sBulletHole += "sand"; break; - case 24: + case SFX_BHIT_FOLIAGE_LITE: sBulletHole += "foliage"; break; - case 26: + case SFX_BHIT_SNOW_LITE: sBulletHole += "snow"; break; - case 28: + case SFX_BHIT_CARPET_LITE: sBulletHole += "carpet"; break; default: @@ -252,7 +258,12 @@ CG_MakeBulletHole(const vec3_t i_vPos, const vec3_t i_vNorm, int iLarge, trace_t iSurfType = SURF_PUDDLE; } - if (trace.fraction == 1.0f || trace.startsolid || (trace.surfaceFlags & SURF_SKY)) { + if (trace.fraction == 1.0f || trace.startsolid) { + return; + } + + if (trace.surfaceFlags & SURF_SKY) { + // ignore sky surfaces return; } @@ -267,7 +278,7 @@ CG_MakeBulletHole(const vec3_t i_vPos, const vec3_t i_vNorm, int iLarge, trace_t break; case SURF_SNOW: sBulletHole += "snow"; - iEffect = SFX_BHIT_FOLIAGE_LITE; + iEffect = SFX_BHIT_SNOW_LITE; break; case SURF_CARPET: sBulletHole += "carpet"; @@ -283,7 +294,7 @@ CG_MakeBulletHole(const vec3_t i_vPos, const vec3_t i_vNorm, int iLarge, trace_t break; case SURF_GLASS: sBulletHole += "glass"; - iEffect = SFX_BHIT_GRASS_LITE; + iEffect = SFX_BHIT_GLASS_LITE; break; case SURF_GRAVEL: fRadius = 0.f; @@ -366,7 +377,7 @@ static void CG_MakeBubbleTrail(const vec3_t i_vStart, const vec3_t i_vEnd, int i fDist -= fMove; while (fDist > 0.f) { VectorMA(vPos, fMove, vDir, vPos); - sfxManager.MakeEffect_Angles(32, vPos, vec_zero); + sfxManager.MakeEffect_Angles(SFX_WATER_TRAIL_BUBBLE, vPos, vec_zero); fMove = 16.f + crandom() * 8.f * alpha; fDist -= fMove; @@ -426,7 +437,7 @@ static void CG_BulletTracerEffect(const vec3_t i_vStart, const vec3_t i_vEnd, in 0, 1, 1.0, - 1.0, + scale, BEAM_INVERTED, 1000.0, iLife, @@ -459,35 +470,36 @@ static void CG_MakeBulletTracerInternal( float alpha ) { - vec3_t vPos; - int iBullet; - int iContinueCount; - int iDist; - int iHeadDist; - int iTravelDist; - float fLen, fDist; - trace_t trace; - qboolean bStartInWater, bInWater; - qboolean bBulletDone; - qboolean bMadeTracer; - vec3_t vDir; - vec3_t vTrailStart; - vec3_t vTraceStart; - vec3_t vTraceEnd; - vec3_t vTmp; - int iNumImpacts; - trace_t tImpacts[128]; - float fImpSndDistRA; - static float fImpSndDistLA; - float fImpSndDistRB; - float fImpSndDistLB; - int iImpSndIndexRA; - int iImpSndIndexRB; - int iImpSndIndexLB; - float fVolume; - float fPitch; - float fZingDistA, fZingDistB, fZingDistC; - vec3_t vZingPosA, vZingPosB, vZingPosC; + vec3_t vPos; + int iBullet; + int iContinueCount; + int iDist; + int iHeadDist; + int iTravelDist; + float fLen, fDist; + trace_t trace; + qboolean bStartInWater, bInWater; + qboolean bBulletDone; + qboolean bMadeTracer; + vec3_t vDir; + vec3_t vTrailStart; + vec3_t vTraceStart; + vec3_t vTraceEnd; + vec3_t vTmp; + int iNumImpacts; + trace_t tImpacts[128]; + float fImpSndDistRA; + float fImpSndDistLA; + float fImpSndDistRB; + float fImpSndDistLB; + int iImpSndIndexRA; + int iImpSndIndexLA; + int iImpSndIndexRB; + int iImpSndIndexLB; + float fVolume; + float fPitch; + float fZingDistA, fZingDistB, fZingDistC; + vec3_t vZingPosA, vZingPosB, vZingPosC; fZingDistB = 9999.0; fZingDistA = 9999.0; @@ -535,7 +547,7 @@ static void CG_MakeBulletTracerInternal( while (trace.fraction < 1) { if (bIgnoreEntities) { - cgi.CM_BoxTrace(&trace, vTraceStart, vTraceEnd, vec_zero, vec_zero, 0, MASK_SHOT, qfalse); + cgi.CM_BoxTrace(&trace, vTraceStart, vTraceEnd, vec_zero, vec_zero, 0, MASK_SHOT_FLUID, qfalse); if (trace.fraction == 1.0f) { trace.entityNum = ENTITYNUM_NONE; @@ -554,7 +566,7 @@ static void CG_MakeBulletTracerInternal( vec_zero, vTraceStart, ENTITYNUM_NONE, - MASK_SHOT, + MASK_SHOT_FLUID, qfalse, qfalse, "CG_MakeBulletTracerInternal" @@ -564,11 +576,11 @@ static void CG_MakeBulletTracerInternal( if (trace.contents & CONTENTS_FLUID) { fDist = DotProduct(vDir, trace.plane.normal) * -2.0f; VectorMA(vDir, fDist, trace.plane.normal, vTmp); - VectorAdd(vTmp, vTmp, trace.plane.normal); + VectorMA(trace.plane.normal, 2.0, vTmp, trace.plane.normal); VectorNormalizeFast(trace.plane.normal); } - if (!bInWater && trace.fraction < 1.0f && iNumImpacts <= 127) { + if (!bInWater && trace.fraction < 1.0f && iNumImpacts < ARRAY_LEN(tImpacts)) { memcpy(&tImpacts[iNumImpacts], &trace, sizeof(trace_t)); iNumImpacts++; } @@ -583,7 +595,8 @@ static void CG_MakeBulletTracerInternal( || (trace.contents & CONTENTS_WATER)) && iContinueCount < 5) { if (bInWater) { - VectorSubtract(trace.endpos, vDir, vTmp); + VectorMA(trace.endpos, -1.0, vDir, vTmp); + if (!(trace.contents & CONTENTS_FLUID) && !(trace.surfaceFlags & SURF_PUDDLE) && !(cgi.CM_PointContents(vTmp, 0) & CONTENTS_FLUID)) { CG_MakeBubbleTrail(vTrailStart, trace.endpos, iLarge, alpha); @@ -595,8 +608,7 @@ static void CG_MakeBulletTracerInternal( bInWater = qtrue; } - VectorAdd(vDir, vDir, vTraceStart); - VectorAdd(vTraceStart, vTraceStart, trace.endpos); + VectorMA(trace.endpos, 2.0, vDir, vTraceStart); iContinueCount++; } else { @@ -658,46 +670,46 @@ static void CG_MakeBulletTracerInternal( if (iNumImpacts > 2) { fImpSndDistRA = 9999.0f; fImpSndDistRB = 9999.0f; - iImpSndIndexRA = 0; - iImpSndIndexRB = 0; + fImpSndDistLA = 9999.0f; fImpSndDistLB = 9999.0f; + iImpSndIndexRA = 0; + iImpSndIndexLA = 0; + iImpSndIndexRB = 0; iImpSndIndexLB = 0; for (iBullet = 0; iBullet < iNumImpacts; iBullet++) { CG_MakeBulletHole( - tImpacts[iImpSndIndexLB].endpos, - tImpacts[iImpSndIndexLB].plane.normal, - iLarge, - &tImpacts[iImpSndIndexLB], - qfalse + tImpacts[iBullet].endpos, tImpacts[iBullet].plane.normal, iLarge, &tImpacts[iBullet], qfalse ); - VectorSubtract(tImpacts[iImpSndIndexLB].endpos, cg.SoundOrg, vTmp); + VectorSubtract(tImpacts[iBullet].endpos, cg.SoundOrg, vTmp); iHeadDist = VectorLength(vTmp); if (DotProduct(vTmp, cg.SoundAxis[1]) <= 0.f) { - if (iHeadDist < 9999.0f || iHeadDist < fImpSndDistLB) { - if (iHeadDist < 9999.0f) { - fImpSndDistRA = iHeadDist; - fImpSndDistLB = 9999.0; + if (iHeadDist < fImpSndDistLA || iHeadDist < fImpSndDistLB) { + if (iHeadDist < fImpSndDistLA) { + iImpSndIndexLB = iImpSndIndexLA; + fImpSndDistLB = fImpSndDistLA; iImpSndIndexRA = iBullet; + fImpSndDistRA = iHeadDist; } else if (iHeadDist < fImpSndDistLB) { - fImpSndDistLB = iHeadDist; + iImpSndIndexLB = iBullet; + fImpSndDistLB = iHeadDist; } } } else { if (iHeadDist < fImpSndDistRA || iHeadDist < fImpSndDistRB) { if (iHeadDist < fImpSndDistRA) { iImpSndIndexRB = iImpSndIndexRA; + fImpSndDistRB = fImpSndDistRA; iImpSndIndexRA = iBullet; + fImpSndDistRA = iHeadDist; } else if (iHeadDist < fImpSndDistRB) { - fImpSndDistRB = iHeadDist; iImpSndIndexRB = iBullet; + fImpSndDistRB = iHeadDist; } } } - - iImpSndIndexLB++; } if (fImpSndDistRA < 9999.0f) { @@ -717,6 +729,24 @@ static void CG_MakeBulletTracerInternal( ); } } + + if (fImpSndDistLA < 9999.0f) { + CG_MakeBulletHoleSound( + tImpacts[iImpSndIndexLA].endpos, + tImpacts[iImpSndIndexLA].plane.normal, + iLarge, + &tImpacts[iImpSndIndexLA] + ); + + if (fImpSndDistLB < 9999.0f) { + CG_MakeBulletHoleSound( + tImpacts[iImpSndIndexLB].endpos, + tImpacts[iImpSndIndexLB].plane.normal, + iLarge, + &tImpacts[iImpSndIndexLB] + ); + } + } } else { for (iBullet = 0; iBullet < iNumImpacts; iBullet++) { CG_MakeBulletHole( @@ -735,8 +765,14 @@ static void CG_MakeBulletTracerInternal( } commandManager.PlaySound("snd_b_zing", vZingPosA, -1, fVolume, -1.0f, fPitch, 1); - commandManager.PlaySound("snd_b_zing", vZingPosB, -1, fVolume, -1.0f, fPitch, 1); - commandManager.PlaySound("snd_b_zing", vZingPosC, -1, fVolume, -1.0f, fPitch, 1); + + if (fZingDistB != 9999) { + commandManager.PlaySound("snd_b_zing", vZingPosB, -1, fVolume, -1.0f, fPitch, 1); + + if (fZingDistC != 9999) { + commandManager.PlaySound("snd_b_zing", vZingPosC, -1, fVolume, -1.0f, fPitch, 1); + } + } } } @@ -859,14 +895,15 @@ void CG_AddBulletImpacts() } if (fImpSndDistRA < fImpSndDistLA) { - if (wall_impact_type[iImpSndIndexRA]) { + if (wall_impact_type[iImpSndIndexRA] != SFX_BHIT_PAPER_LITE) { if (wall_impact_large[iImpSndIndexRA]) { fVolume = 1.f; } else { fVolume = 0.75f; } - if (wall_impact_type[iImpSndIndexRA] == 2 || wall_impact_type[iImpSndIndexRA] == 3) { + if (wall_impact_type[iImpSndIndexRA] == SFX_BHIT_WOOD_LITE + || wall_impact_type[iImpSndIndexRA] == SFX_BHIT_WOOD_HARD) { sSoundName = "snd_bh_metal"; } else { sSoundName = "snd_bh_wood"; @@ -897,7 +934,8 @@ void CG_AddBulletImpacts() fVolume = 0.75f; } - if (wall_impact_type[iImpSndIndexRB] == 2 || wall_impact_type[iImpSndIndexRB] == 3) { + if (wall_impact_type[iImpSndIndexRB] == SFX_BHIT_WOOD_LITE + || wall_impact_type[iImpSndIndexRB] == SFX_BHIT_WOOD_HARD) { sSoundName = "snd_bh_metal"; } else { sSoundName = "snd_bh_wood"; @@ -923,14 +961,14 @@ void CG_AddBulletImpacts() } if (fImpSndDistLA > 9999.0f) { - if (wall_impact_type[0]) { + if (wall_impact_type[0] != SFX_BHIT_PAPER_LITE) { if (wall_impact_large[0]) { fVolume = 1.f; } else { fVolume = 0.75f; } - if (wall_impact_type[0] == 2 || wall_impact_type[0] == 3) { + if (wall_impact_type[0] == SFX_BHIT_WOOD_LITE || wall_impact_type[0] == SFX_BHIT_WOOD_HARD) { sSoundName = "snd_bh_metal"; } else { sSoundName = "snd_bh_wood"; @@ -945,14 +983,15 @@ void CG_AddBulletImpacts() } if (fImpSndDistLB < fImpSndDistLA) { - if (wall_impact_type[iImpSndIndexLB]) { + if (wall_impact_type[iImpSndIndexLB] != SFX_BHIT_PAPER_LITE) { if (wall_impact_large[iImpSndIndexLB]) { fVolume = 1.f; } else { fVolume = 0.75f; } - if (wall_impact_type[iImpSndIndexLB] == 2 || wall_impact_type[iImpSndIndexLB] == 3) { + if (wall_impact_type[iImpSndIndexLB] == SFX_BHIT_WOOD_LITE + || wall_impact_type[iImpSndIndexLB] == SFX_BHIT_WOOD_HARD) { sSoundName = "snd_bh_metal"; } else { sSoundName = "snd_bh_wood"; @@ -987,14 +1026,16 @@ void CG_AddBulletImpacts() if (flesh_impact_count) { if (flesh_impact_count > 1) { fImpSndDistRA = 9999.0; + fImpSndDistRB = 9999.0; iImpSndIndexRA = 0; + iImpSndIndexRB = 0; for (i = 0; i < flesh_impact_count; i++) { - VectorSubtract(wall_impact_pos[i], cg.SoundOrg, vTmp); + VectorSubtract(flesh_impact_pos[i], cg.SoundOrg, vTmp); iHeadDist = VectorLength(vTmp); if (DotProduct(vTmp, cg.SoundAxis[1]) > 0.f) { - if (iHeadDist < fImpSndDistRA) { + if (iHeadDist < fImpSndDistRB) { fImpSndDistRA = iHeadDist; iImpSndIndexRA = i; } @@ -1003,6 +1044,30 @@ void CG_AddBulletImpacts() iImpSndIndexRA = i; } } + + if (fImpSndDistRA < 9999) { + sfxManager.MakeEffect_Normal( + flesh_impact_large[iImpSndIndexRA] ? SFX_BHIT_HUMAN_UNIFORM_HARD : SFX_BHIT_HUMAN_UNIFORM_LITE, + flesh_impact_pos[iImpSndIndexRA], + flesh_impact_norm[iImpSndIndexRA] + ); + } + + if (fImpSndDistRB < 9999) { + sfxManager.MakeEffect_Normal( + flesh_impact_large[iImpSndIndexRB] ? SFX_BHIT_HUMAN_UNIFORM_HARD : SFX_BHIT_HUMAN_UNIFORM_LITE, + flesh_impact_pos[iImpSndIndexRB], + flesh_impact_norm[iImpSndIndexRB] + ); + } + } else { + for (i = 0; i < flesh_impact_count; i++) { + sfxManager.MakeEffect_Normal( + flesh_impact_large[i] ? SFX_BHIT_HUMAN_UNIFORM_HARD : SFX_BHIT_HUMAN_UNIFORM_LITE, + flesh_impact_pos[i], + flesh_impact_norm[i] + ); + } } flesh_impact_count = 0; @@ -1031,22 +1096,33 @@ void CG_MakeExplosionEffect(const vec3_t vPos, int iType) return; } - switch (iType) { - case 13: - iBaseEffect = SFX_EXP_GREN_BASE; - break; - case 14: - iBaseEffect = SFX_EXP_BAZOOKA_BASE; - break; - case 15: - iBaseEffect = SFX_EXP_HEAVYSHELL_BASE; - break; - case 16: - iBaseEffect = SFX_EXP_TANK_BASE; - break; - default: - iBaseEffect = SFX_EXP_GREN_BASE; - break; + if (cg_protocol >= protocol_e::PROTOCOL_MOHTA_MIN) { + switch (iType) { + case CGM_EXPLOSION_EFFECT_1: + iBaseEffect = SFX_EXP_GREN_BASE; + break; + case CGM_EXPLOSION_EFFECT_2: + iBaseEffect = SFX_EXP_BAZOOKA_BASE; + break; + case CGM_EXPLOSION_EFFECT_3: + iBaseEffect = SFX_EXP_HEAVYSHELL_BASE; + break; + case CGM_EXPLOSION_EFFECT_4: + iBaseEffect = SFX_EXP_TANK_BASE; + break; + default: + iBaseEffect = SFX_EXP_GREN_BASE; + break; + } + } else { + switch (iType) { + case CGM6_EXPLOSION_EFFECT_2: + iBaseEffect = SFX_EXP_BAZOOKA_BASE; + break; + default: + iBaseEffect = SFX_EXP_GREN_BASE; + break; + } } CG_Trace( @@ -1074,14 +1150,18 @@ void CG_MakeExplosionEffect(const vec3_t vPos, int iType) break; case SFX_EXP_BAZOOKA_BASE: iSurfEffect = SFX_EXP_BAZOOKA_SNOW; - iBaseEffect = -1; + if (cg_protocol >= protocol_e::PROTOCOL_MOHTA_MIN) { + iBaseEffect = -1; + } break; case SFX_EXP_HEAVYSHELL_BASE: iSurfEffect = SFX_EXP_HEAVYSHELL_SNOW; break; default: iSurfEffect = SFX_EXP_GREN_SNOW; - iBaseEffect = -1; + if (cg_protocol >= protocol_e::PROTOCOL_MOHTA_MIN) { + iBaseEffect = -1; + } break; } fRadius = 0; @@ -1115,14 +1195,18 @@ void CG_MakeExplosionEffect(const vec3_t vPos, int iType) break; case SFX_EXP_BAZOOKA_BASE: iSurfEffect = SFX_EXP_BAZOOKA_DIRT; - iBaseEffect = -1; + if (cg_protocol >= protocol_e::PROTOCOL_MOHTA_MIN) { + iBaseEffect = -1; + } break; case SFX_EXP_HEAVYSHELL_BASE: iSurfEffect = SFX_EXP_HEAVYSHELL_DIRT; break; default: iSurfEffect = SFX_EXP_GREN_DIRT; - iBaseEffect = -1; + if (cg_protocol >= protocol_e::PROTOCOL_MOHTA_MIN) { + iBaseEffect = -1; + } break; } fRadius = 0; @@ -1144,7 +1228,9 @@ void CG_MakeExplosionEffect(const vec3_t vPos, int iType) break; default: iSurfEffect = SFX_EXP_GREN_GRASS; - iBaseEffect = -1; + if (cg_protocol >= protocol_e::PROTOCOL_MOHTA_MIN) { + iBaseEffect = -1; + } break; } fRadius = 0; @@ -1156,14 +1242,18 @@ void CG_MakeExplosionEffect(const vec3_t vPos, int iType) break; case SFX_EXP_BAZOOKA_BASE: iSurfEffect = SFX_EXP_BAZOOKA_STONE; - iBaseEffect = -1; + if (cg_protocol >= protocol_e::PROTOCOL_MOHTA_MIN) { + iBaseEffect = -1; + } break; case SFX_EXP_HEAVYSHELL_BASE: iSurfEffect = SFX_EXP_HEAVYSHELL_STONE; break; default: iSurfEffect = SFX_EXP_GREN_STONE; - iBaseEffect = -1; + if (cg_protocol >= protocol_e::PROTOCOL_MOHTA_MIN) { + iBaseEffect = -1; + } break; } break; @@ -1211,7 +1301,9 @@ void CG_MakeExplosionEffect(const vec3_t vPos, int iType) ); } - sfxManager.MakeEffect_Normal(iBaseEffect, vEnd, trace.plane.normal); + if (iBaseEffect != -1) { + sfxManager.MakeEffect_Normal(iBaseEffect, vEnd, trace.plane.normal); + } } void CG_MakeVehicleEffect(vec3_t i_vStart, vec3_t i_vEnd, vec3_t i_vDir) @@ -1247,10 +1339,10 @@ void CG_ParseCGMessage_ver_15() iType = cgi.MSG_ReadBits(6); switch (iType) { - case 1: - case 2: - case 5: - if (iType == 1) { + case CGM_BULLET_1: + case CGM_BULLET_2: + case CGM_BULLET_5: + if (iType == CGM_BULLET_1) { vTmp[0] = cgi.MSG_ReadCoord(); vTmp[1] = cgi.MSG_ReadCoord(); vTmp[2] = cgi.MSG_ReadCoord(); @@ -1259,7 +1351,7 @@ void CG_ParseCGMessage_ver_15() vStart[1] = cgi.MSG_ReadCoord(); vStart[2] = cgi.MSG_ReadCoord(); - if (iType != 1) { + if (iType != CGM_BULLET_1) { vTmp[0] = vStart[0]; vTmp[1] = vStart[1]; vTmp[2] = vStart[2]; @@ -1279,18 +1371,18 @@ void CG_ParseCGMessage_ver_15() alpha = 1.0f; } - if (iType == 1) { - CG_MakeBulletTracer(vTmp, vStart, vEndArray, 1, iLarge, qfalse, qtrue, alpha); - } else if (iType == 2) { + if (iType == CGM_BULLET_1) { + CG_MakeBulletTracer(vTmp, vStart, vEndArray, 1, iLarge, qtrue, qtrue, alpha); + } else if (iType == CGM_BULLET_2) { CG_MakeBulletTracer(vTmp, vStart, vEndArray, 1, iLarge, qfalse, qtrue, alpha); } else { CG_MakeBubbleTrail(vStart, vEndArray[0], iLarge, alpha); } break; - case 3: - case 4: - if (iType == 3) { + case CGM_BULLET_3: + case CGM_BULLET_4: + if (iType == CGM_BULLET_3) { vTmp[0] = cgi.MSG_ReadCoord(); vTmp[1] = cgi.MSG_ReadCoord(); vTmp[2] = cgi.MSG_ReadCoord(); @@ -1324,12 +1416,12 @@ void CG_ParseCGMessage_ver_15() CG_MakeBulletTracer(vTmp, vStart, vEndArray, iCount, iLarge, iInfo, qtrue, alpha); } break; - case 6: - case 7: - case 8: - case 9: - case 10: - case 11: + case CGM_BULLET_6: + case CGM_BULLET_7: + case CGM_BULLET_8: + case CGM_BULLET_9: + case CGM_BULLET_10: + case CGM_BULLET_11: vStart[0] = cgi.MSG_ReadCoord(); vStart[1] = cgi.MSG_ReadCoord(); vStart[2] = cgi.MSG_ReadCoord(); @@ -1337,7 +1429,7 @@ void CG_ParseCGMessage_ver_15() iLarge = cgi.MSG_ReadBits(2); switch (iType) { - case 6: + case CGM_BULLET_6: if (wall_impact_count < MAX_IMPACTS) { VectorCopy(vStart, wall_impact_pos[wall_impact_count]); VectorCopy(vEnd, wall_impact_norm[wall_impact_count]); @@ -1346,16 +1438,16 @@ void CG_ParseCGMessage_ver_15() wall_impact_count++; } break; - case 7: + case CGM_BULLET_7: if (wall_impact_count < MAX_IMPACTS) { VectorCopy(vStart, wall_impact_pos[wall_impact_count]); VectorCopy(vEnd, wall_impact_norm[wall_impact_count]); wall_impact_large[wall_impact_count] = iLarge; - wall_impact_type[wall_impact_count] = 6; + wall_impact_type[wall_impact_count] = SFX_BHIT_STONE_LITE; wall_impact_count++; } break; - case 8: + case CGM_BULLET_8: if (flesh_impact_count < MAX_IMPACTS) { // negative VectorNegate(vEnd, vEnd); @@ -1365,7 +1457,7 @@ void CG_ParseCGMessage_ver_15() flesh_impact_count++; } break; - case 9: + case CGM_BULLET_9: if (flesh_impact_count < MAX_IMPACTS) { // negative VectorNegate(vEnd, vEnd); @@ -1375,21 +1467,21 @@ void CG_ParseCGMessage_ver_15() flesh_impact_count++; } break; - case 10: + case CGM_BULLET_10: if (wall_impact_count < MAX_IMPACTS) { VectorCopy(vStart, wall_impact_pos[wall_impact_count]); VectorCopy(vEnd, wall_impact_norm[wall_impact_count]); wall_impact_large[wall_impact_count] = iLarge; - wall_impact_type[wall_impact_count] = 2; + wall_impact_type[wall_impact_count] = SFX_BHIT_WOOD_LITE; wall_impact_count++; } break; - case 11: + case CGM_BULLET_11: if (wall_impact_count < MAX_IMPACTS) { VectorCopy(vStart, wall_impact_pos[wall_impact_count]); VectorCopy(vEnd, wall_impact_norm[wall_impact_count]); wall_impact_large[wall_impact_count] = iLarge; - wall_impact_type[wall_impact_count] = 4; + wall_impact_type[wall_impact_count] = SFX_BHIT_METAL_LITE; wall_impact_count++; } break; @@ -1398,7 +1490,7 @@ void CG_ParseCGMessage_ver_15() } break; - case 12: + case CGM_MELEE_IMPACT: vStart[0] = cgi.MSG_ReadCoord(); vStart[1] = cgi.MSG_ReadCoord(); vStart[2] = cgi.MSG_ReadCoord(); @@ -1407,33 +1499,33 @@ void CG_ParseCGMessage_ver_15() vEnd[2] = cgi.MSG_ReadCoord(); CG_MeleeImpact(vStart, vEnd); break; - case 13: - case 14: - case 15: - case 16: + case CGM_EXPLOSION_EFFECT_1: + case CGM_EXPLOSION_EFFECT_2: + case CGM_EXPLOSION_EFFECT_3: + case CGM_EXPLOSION_EFFECT_4: vStart[0] = cgi.MSG_ReadCoord(); vStart[1] = cgi.MSG_ReadCoord(); vStart[2] = cgi.MSG_ReadCoord(); CG_MakeExplosionEffect(vStart, iType); break; - case 18: - case 19: - case 20: - case 21: - case 22: - case 23: - case 24: - case 25: + case CGM_MAKE_EFFECT_1: + case CGM_MAKE_EFFECT_2: + case CGM_MAKE_EFFECT_3: + case CGM_MAKE_EFFECT_4: + case CGM_MAKE_EFFECT_5: + case CGM_MAKE_EFFECT_6: + case CGM_MAKE_EFFECT_7: + case CGM_MAKE_EFFECT_8: vStart[0] = cgi.MSG_ReadCoord(); vStart[1] = cgi.MSG_ReadCoord(); vStart[2] = cgi.MSG_ReadCoord(); cgi.MSG_ReadDir(vEnd); - sfxManager.MakeEffect_Normal(iType + SFX_EXP_GREN_PUDDLE, vStart, vEnd); + sfxManager.MakeEffect_Normal((iType - CGM_MAKE_EFFECT_1) + SFX_OIL_LEAK_BIG, vStart, vEnd); break; - case 26: - case 27: + case CGM_MAKE_CRATE_DEBRIS: + case CGM_MAKE_WINDOW_DEBRIS: { str sEffect; char cTmp[8]; @@ -1446,7 +1538,7 @@ void CG_ParseCGMessage_ver_15() // get the integer as string snprintf(cTmp, sizeof(cTmp), "%d", iLarge); - if (iType == 26) { + if (iType == CGM_MAKE_CRATE_DEBRIS) { sEffect = "models/fx/crates/debris_"; } else { sEffect = "models/fx/windows/debris_"; @@ -1463,7 +1555,7 @@ void CG_ParseCGMessage_ver_15() } break; - case 28: + case CGM_BULLET_NO_BARREL_1: vTmp[0] = cgi.MSG_ReadCoord(); vTmp[1] = cgi.MSG_ReadCoord(); vTmp[2] = cgi.MSG_ReadCoord(); @@ -1474,6 +1566,7 @@ void CG_ParseCGMessage_ver_15() vEndArray[0][1] = cgi.MSG_ReadCoord(); vEndArray[0][2] = cgi.MSG_ReadCoord(); iLarge = cgi.MSG_ReadBits(2); + if (cgi.MSG_ReadBits(1)) { int iAlpha = cgi.MSG_ReadBits(10); alpha = (float)iAlpha / 512.0; @@ -1487,7 +1580,7 @@ void CG_ParseCGMessage_ver_15() CG_MakeBulletTracer(vTmp, vStart, vEndArray, 1, iLarge, qtrue, qtrue, alpha); break; - case 29: + case CGM_BULLET_NO_BARREL_2: memset(vTmp, 0, sizeof(vTmp)); vStart[0] = cgi.MSG_ReadCoord(); vStart[1] = cgi.MSG_ReadCoord(); @@ -1496,6 +1589,7 @@ void CG_ParseCGMessage_ver_15() vEndArray[0][1] = cgi.MSG_ReadCoord(); vEndArray[0][2] = cgi.MSG_ReadCoord(); iLarge = cgi.MSG_ReadBits(1); + if (cgi.MSG_ReadBits(1)) { int iAlpha = cgi.MSG_ReadBits(10); alpha = (float)iAlpha / 512.0; @@ -1509,9 +1603,13 @@ void CG_ParseCGMessage_ver_15() CG_MakeBulletTracer(vTmp, vStart, vEndArray, 1, iLarge, qfalse, qtrue, alpha); break; - case 30: + case CGM_HUDDRAW_SHADER: iInfo = cgi.MSG_ReadByte(); - strcpy(cgi.HudDrawElements[iInfo].shaderName, cgi.MSG_ReadString()); + Q_strncpyz( + cgi.HudDrawElements[iInfo].shaderName, + cgi.MSG_ReadString(), + sizeof(cgi.HudDrawElements[iInfo].shaderName) + ); cgi.HudDrawElements[iInfo].string[0] = 0; cgi.HudDrawElements[iInfo].pFont = NULL; cgi.HudDrawElements[iInfo].fontName[0] = 0; @@ -1519,13 +1617,13 @@ void CG_ParseCGMessage_ver_15() CG_HudDrawShader(iInfo); break; - case 31: + case CGM_HUDDRAW_ALIGN: iInfo = cgi.MSG_ReadByte(); cgi.HudDrawElements[iInfo].iHorizontalAlign = cgi.MSG_ReadBits(2); cgi.HudDrawElements[iInfo].iVerticalAlign = cgi.MSG_ReadBits(2); break; - case 32: + case CGM_HUDDRAW_RECT: iInfo = cgi.MSG_ReadByte(); cgi.HudDrawElements[iInfo].iX = cgi.MSG_ReadShort(); cgi.HudDrawElements[iInfo].iY = cgi.MSG_ReadShort(); @@ -1533,46 +1631,52 @@ void CG_ParseCGMessage_ver_15() cgi.HudDrawElements[iInfo].iHeight = cgi.MSG_ReadShort(); break; - case 33: + case CGM_HUDDRAW_VIRTUALSIZE: iInfo = cgi.MSG_ReadByte(); cgi.HudDrawElements[iInfo].bVirtualScreen = cgi.MSG_ReadBits(1); break; - case 34: + case CGM_HUDDRAW_COLOR: iInfo = cgi.MSG_ReadByte(); cgi.HudDrawElements[iInfo].vColor[0] = cgi.MSG_ReadByte() / 255.0; cgi.HudDrawElements[iInfo].vColor[1] = cgi.MSG_ReadByte() / 255.0; cgi.HudDrawElements[iInfo].vColor[2] = cgi.MSG_ReadByte() / 255.0; break; - case 35: + case CGM_HUDDRAW_ALPHA: iInfo = cgi.MSG_ReadByte(); cgi.HudDrawElements[iInfo].vColor[3] = cgi.MSG_ReadByte() / 255.0; break; - case 36: + case CGM_HUDDRAW_STRING: iInfo = cgi.MSG_ReadByte(); cgi.HudDrawElements[iInfo].hShader = 0; - strcpy(cgi.HudDrawElements[iInfo].string, cgi.MSG_ReadString()); + Q_strncpyz( + cgi.HudDrawElements[iInfo].string, cgi.MSG_ReadString(), sizeof(cgi.HudDrawElements[iInfo].string) + ); break; - case 37: + case CGM_HUDDRAW_FONT: iInfo = cgi.MSG_ReadByte(); - strcpy(cgi.HudDrawElements[iInfo].fontName, cgi.MSG_ReadString()); + Q_strncpyz( + cgi.HudDrawElements[iInfo].fontName, cgi.MSG_ReadString(), sizeof(cgi.HudDrawElements[iInfo].fontName) + ); cgi.HudDrawElements[iInfo].hShader = 0; cgi.HudDrawElements[iInfo].shaderName[0] = 0; // load the font CG_HudDrawFont(iInfo); break; - case 38: - case 39: - { - int iOldEnt; + case CGM_NOTIFY_HIT: + case CGM_NOTIFY_KILL: + if (cg.snap) { + const char *soundName; + int iOldEnt; + + iOldEnt = current_entity_number; - iOldEnt = current_entity_number; current_entity_number = cg.snap->ps.clientNum; - if (iType == 36) { + if (iType == CGM_NOTIFY_KILL) { commandManager.PlaySound("dm_kill_notify", NULL, CHAN_LOCAL, 2.0, -1, -1, 1); } else { commandManager.PlaySound("dm_hit_notify", NULL, CHAN_LOCAL, 2.0, -1, -1, 1); @@ -1582,7 +1686,7 @@ void CG_ParseCGMessage_ver_15() } break; - case 40: + case CGM_VOICE_CHAT: { int iOldEnt; @@ -1598,29 +1702,58 @@ void CG_ParseCGMessage_ver_15() if (iLarge) { current_entity_number = iInfo; - commandManager.PlaySound(szTmp, vStart, CHAN_LOCAL, -1, -1, -1, 0); - } else { + commandManager.PlaySound(szTmp, vStart, CHAN_AUTO, -1, -1, -1, 0); + } else if (cg.snap) { current_entity_number = cg.snap->ps.clientNum; - commandManager.PlaySound(szTmp, vStart, CHAN_AUTO, -1, -1, -1, 1); + commandManager.PlaySound(szTmp, vStart, CHAN_LOCAL, -1, -1, -1, 1); } + CG_RadarClientSpeaks(iInfo); current_entity_number = iOldEnt; } break; - case 41: - vStart[0] = cgi.MSG_ReadCoord(); - vStart[1] = cgi.MSG_ReadCoord(); - vStart[2] = cgi.MSG_ReadCoord(); - vEnd[0] = cgi.MSG_ReadCoord(); - vEnd[1] = cgi.MSG_ReadCoord(); - vEnd[2] = cgi.MSG_ReadCoord(); - cgi.MSG_ReadByte(); - cgi.MSG_ReadByte(); - VectorSubtract(vEnd, vStart, vTmp); + case CGM_FENCEPOST: + { + int iHalf; + vec3_t vForward, vRight, vUp; + float fLength; - // FIXME: unimplemented - // ?? can't figure out what is this + vStart[0] = cgi.MSG_ReadCoord(); + vStart[1] = cgi.MSG_ReadCoord(); + vStart[2] = cgi.MSG_ReadCoord(); + vEnd[0] = cgi.MSG_ReadCoord(); + vEnd[1] = cgi.MSG_ReadCoord(); + vEnd[2] = cgi.MSG_ReadCoord(); + iHalf = cgi.MSG_ReadByte(); + cgi.MSG_ReadByte(); + + VectorSubtract(vEnd, vStart, vForward); + fLength = VectorNormalize(vForward); + iCount = fLength / 2.0; + + MakeNormalVectors(vForward, vRight, vUp); + + for (i = 0; i < iCount; i++) { + vec3_t vOrg; + vec3_t vNormal; + + VectorCopy(vStart, vOrg); + + VectorMA(vOrg, random(), vForward, vOrg); + VectorMA(vOrg, crandom() * iHalf, vRight, vOrg); + VectorMA(vOrg, crandom() * iHalf, vUp, vOrg); + + // + // Spawn the fence wood effect + // + + VectorSubtract(vStart, vOrg, vNormal); + VectorNormalize(vNormal); + + sfxManager.MakeEffect_Normal(SFX_FENCE_WOOD, vOrg, vNormal); + } + } break; default: cgi.Error(ERR_DROP, "CG_ParseCGMessage: Unknown CGM message type"); @@ -1647,10 +1780,10 @@ void CG_ParseCGMessage_ver_6() iType = cgi.MSG_ReadBits(6); switch (iType) { - case 1: - case 2: - case 5: - if (iType == 1) { + case CGM6_BULLET_1: + case CGM6_BULLET_2: + case CGM6_BULLET_5: + if (iType == CGM6_BULLET_1) { vTmp[0] = cgi.MSG_ReadCoord(); vTmp[1] = cgi.MSG_ReadCoord(); vTmp[2] = cgi.MSG_ReadCoord(); @@ -1659,7 +1792,7 @@ void CG_ParseCGMessage_ver_6() vStart[1] = cgi.MSG_ReadCoord(); vStart[2] = cgi.MSG_ReadCoord(); - if (iType != 1) { + if (iType != CGM6_BULLET_1) { vTmp[0] = vStart[0]; vTmp[1] = vStart[1]; vTmp[2] = vStart[2]; @@ -1670,18 +1803,18 @@ void CG_ParseCGMessage_ver_6() vEndArray[0][2] = cgi.MSG_ReadCoord(); iLarge = cgi.MSG_ReadBits(1); - if (iType == 1) { - CG_MakeBulletTracer(vTmp, vStart, vEndArray, 1, iLarge, qfalse, qtrue); - } else if (iType == 2) { + if (iType == CGM6_BULLET_1) { + CG_MakeBulletTracer(vTmp, vStart, vEndArray, 1, iLarge, qtrue, qtrue); + } else if (iType == CGM6_BULLET_2) { CG_MakeBulletTracer(vTmp, vStart, vEndArray, 1, iLarge, qfalse, qtrue); } else { CG_MakeBubbleTrail(vStart, vEndArray[0], iLarge); } break; - case 3: - case 4: - if (iType == 3) { + case CGM6_BULLET_3: + case CGM6_BULLET_4: + if (iType == CGM6_BULLET_3) { vTmp[0] = cgi.MSG_ReadCoord(); vTmp[1] = cgi.MSG_ReadCoord(); vTmp[2] = cgi.MSG_ReadCoord(); @@ -1705,11 +1838,11 @@ void CG_ParseCGMessage_ver_6() CG_MakeBulletTracer(vTmp, vStart, vEndArray, iCount, iLarge, iInfo, qtrue); } break; - case 6: - case 7: - case 8: - case 9: - case 10: + case CGM6_BULLET_6: + case CGM6_BULLET_7: + case CGM6_BULLET_8: + case CGM6_BULLET_9: + case CGM6_BULLET_10: vStart[0] = cgi.MSG_ReadCoord(); vStart[1] = cgi.MSG_ReadCoord(); vStart[2] = cgi.MSG_ReadCoord(); @@ -1717,16 +1850,16 @@ void CG_ParseCGMessage_ver_6() iLarge = cgi.MSG_ReadBits(1); switch (iType) { - case 6: + case CGM6_BULLET_6: if (wall_impact_count < MAX_IMPACTS) { VectorCopy(vStart, wall_impact_pos[wall_impact_count]); VectorCopy(vEnd, wall_impact_norm[wall_impact_count]); wall_impact_large[wall_impact_count] = iLarge; - wall_impact_type[wall_impact_count] = 0; + wall_impact_type[wall_impact_count] = SFX_BHIT_PAPER_LITE; wall_impact_count++; } break; - case 7: + case CGM6_BULLET_7: if (flesh_impact_count < MAX_IMPACTS) { // negative VectorNegate(vEnd, vEnd); @@ -1736,7 +1869,7 @@ void CG_ParseCGMessage_ver_6() flesh_impact_count++; } break; - case 8: + case CGM6_BULLET_8: if (flesh_impact_count < MAX_IMPACTS) { // negative VectorNegate(vEnd, vEnd); @@ -1746,21 +1879,21 @@ void CG_ParseCGMessage_ver_6() flesh_impact_count++; } break; - case 9: + case CGM6_BULLET_9: if (wall_impact_count < MAX_IMPACTS) { VectorCopy(vStart, wall_impact_pos[wall_impact_count]); VectorCopy(vEnd, wall_impact_norm[wall_impact_count]); wall_impact_large[wall_impact_count] = iLarge; - wall_impact_type[wall_impact_count] = (iLarge != 0) + 2; + wall_impact_type[wall_impact_count] = iLarge ? SFX_BHIT_WOOD_HARD : SFX_BHIT_WOOD_LITE; wall_impact_count++; } break; - case 10: + case CGM6_BULLET_10: if (wall_impact_count < MAX_IMPACTS) { VectorCopy(vStart, wall_impact_pos[wall_impact_count]); VectorCopy(vEnd, wall_impact_norm[wall_impact_count]); wall_impact_large[wall_impact_count] = iLarge; - wall_impact_type[wall_impact_count] = (iLarge != 0) + 4; + wall_impact_type[wall_impact_count] = iLarge ? SFX_BHIT_METAL_HARD : SFX_BHIT_METAL_LITE; wall_impact_count++; } break; @@ -1769,7 +1902,7 @@ void CG_ParseCGMessage_ver_6() } break; - case 11: + case CGM6_MELEE_IMPACT: vStart[0] = cgi.MSG_ReadCoord(); vStart[1] = cgi.MSG_ReadCoord(); vStart[2] = cgi.MSG_ReadCoord(); @@ -1778,31 +1911,31 @@ void CG_ParseCGMessage_ver_6() vEnd[2] = cgi.MSG_ReadCoord(); CG_MeleeImpact(vStart, vEnd); break; - case 12: - case 13: + case CGM6_EXPLOSION_EFFECT_1: + case CGM6_EXPLOSION_EFFECT_2: vStart[0] = cgi.MSG_ReadCoord(); vStart[1] = cgi.MSG_ReadCoord(); vStart[2] = cgi.MSG_ReadCoord(); CG_MakeExplosionEffect(vStart, iType); break; - case 15: - case 16: - case 17: - case 18: - case 19: - case 20: - case 21: - case 22: + case CGM6_MAKE_EFFECT_1: + case CGM6_MAKE_EFFECT_2: + case CGM6_MAKE_EFFECT_3: + case CGM6_MAKE_EFFECT_4: + case CGM6_MAKE_EFFECT_5: + case CGM6_MAKE_EFFECT_6: + case CGM6_MAKE_EFFECT_7: + case CGM6_MAKE_EFFECT_8: vStart[0] = cgi.MSG_ReadCoord(); vStart[1] = cgi.MSG_ReadCoord(); vStart[2] = cgi.MSG_ReadCoord(); cgi.MSG_ReadDir(vEnd); - sfxManager.MakeEffect_Normal(iType + SFX_EXP_GREN_PUDDLE, vStart, vEnd); + sfxManager.MakeEffect_Normal((iType - CGM6_MAKE_EFFECT_1) + SFX_OIL_LEAK_BIG, vStart, vEnd); break; - case 23: - case 24: + case CGM6_MAKE_CRATE_DEBRIS: + case CGM6_MAKE_WINDOW_DEBRIS: { str sEffect; char cTmp[8]; @@ -1815,7 +1948,7 @@ void CG_ParseCGMessage_ver_6() // get the integer as string snprintf(cTmp, sizeof(cTmp), "%d", iLarge); - if (iType == 23) { + if (iType == CGM6_MAKE_CRATE_DEBRIS) { sEffect = "models/fx/crates/debris_"; } else { sEffect = "models/fx/windows/debris_"; @@ -1832,7 +1965,7 @@ void CG_ParseCGMessage_ver_6() } break; - case 25: + case CGM6_BULLET_NO_BARREL_1: vTmp[0] = cgi.MSG_ReadCoord(); vTmp[1] = cgi.MSG_ReadCoord(); vTmp[2] = cgi.MSG_ReadCoord(); @@ -1847,7 +1980,7 @@ void CG_ParseCGMessage_ver_6() CG_MakeBulletTracer(vTmp, vStart, vEndArray, 1, iLarge, qtrue, qtrue); break; - case 26: + case CGM6_BULLET_NO_BARREL_2: memset(vTmp, 0, sizeof(vTmp)); vStart[0] = cgi.MSG_ReadCoord(); vStart[1] = cgi.MSG_ReadCoord(); @@ -1860,9 +1993,13 @@ void CG_ParseCGMessage_ver_6() CG_MakeBulletTracer(vTmp, vStart, vEndArray, 1, iLarge, qfalse, qtrue); break; - case 27: + case CGM6_HUDDRAW_SHADER: iInfo = cgi.MSG_ReadByte(); - strcpy(cgi.HudDrawElements[iInfo].shaderName, cgi.MSG_ReadString()); + Q_strncpyz( + cgi.HudDrawElements[iInfo].shaderName, + cgi.MSG_ReadString(), + sizeof(cgi.HudDrawElements[iInfo].shaderName) + ); cgi.HudDrawElements[iInfo].string[0] = 0; cgi.HudDrawElements[iInfo].pFont = NULL; cgi.HudDrawElements[iInfo].fontName[0] = 0; @@ -1870,13 +2007,13 @@ void CG_ParseCGMessage_ver_6() CG_HudDrawShader(iInfo); break; - case 28: + case CGM6_HUDDRAW_ALIGN: iInfo = cgi.MSG_ReadByte(); cgi.HudDrawElements[iInfo].iHorizontalAlign = cgi.MSG_ReadBits(2); cgi.HudDrawElements[iInfo].iVerticalAlign = cgi.MSG_ReadBits(2); break; - case 29: + case CGM6_HUDDRAW_RECT: iInfo = cgi.MSG_ReadByte(); cgi.HudDrawElements[iInfo].iX = cgi.MSG_ReadShort(); cgi.HudDrawElements[iInfo].iY = cgi.MSG_ReadShort(); @@ -1884,46 +2021,51 @@ void CG_ParseCGMessage_ver_6() cgi.HudDrawElements[iInfo].iHeight = cgi.MSG_ReadShort(); break; - case 30: + case CGM6_HUDDRAW_VIRTUALSIZE: iInfo = cgi.MSG_ReadByte(); cgi.HudDrawElements[iInfo].bVirtualScreen = cgi.MSG_ReadBits(1); break; - case 31: + case CGM6_HUDDRAW_COLOR: iInfo = cgi.MSG_ReadByte(); cgi.HudDrawElements[iInfo].vColor[0] = cgi.MSG_ReadByte() / 255.0; cgi.HudDrawElements[iInfo].vColor[1] = cgi.MSG_ReadByte() / 255.0; cgi.HudDrawElements[iInfo].vColor[2] = cgi.MSG_ReadByte() / 255.0; break; - case 32: + case CGM6_HUDDRAW_ALPHA: iInfo = cgi.MSG_ReadByte(); cgi.HudDrawElements[iInfo].vColor[3] = cgi.MSG_ReadByte() / 255.0; break; - case 33: + case CGM6_HUDDRAW_STRING: iInfo = cgi.MSG_ReadByte(); cgi.HudDrawElements[iInfo].hShader = 0; - strcpy(cgi.HudDrawElements[iInfo].string, cgi.MSG_ReadString()); + Q_strncpyz( + cgi.HudDrawElements[iInfo].string, cgi.MSG_ReadString(), sizeof(cgi.HudDrawElements[iInfo].string) + ); break; - case 34: + case CGM6_HUDDRAW_FONT: iInfo = cgi.MSG_ReadByte(); - strcpy(cgi.HudDrawElements[iInfo].fontName, cgi.MSG_ReadString()); + Q_strncpyz( + cgi.HudDrawElements[iInfo].fontName, cgi.MSG_ReadString(), sizeof(cgi.HudDrawElements[iInfo].fontName) + ); cgi.HudDrawElements[iInfo].hShader = 0; cgi.HudDrawElements[iInfo].shaderName[0] = 0; // load the font CG_HudDrawFont(iInfo); break; - case 35: - case 36: - { + case CGM6_NOTIFY_HIT: + case CGM6_NOTIFY_KILL: + if (cg.snap) { int iOldEnt; - iOldEnt = current_entity_number; + iOldEnt = current_entity_number; + current_entity_number = cg.snap->ps.clientNum; - if (iType == 36) { + if (iType == CGM6_NOTIFY_KILL) { commandManager.PlaySound("dm_kill_notify", NULL, CHAN_LOCAL, 2.0, -1, -1, 1); } else { commandManager.PlaySound("dm_hit_notify", NULL, CHAN_LOCAL, 2.0, -1, -1, 1); @@ -1933,7 +2075,7 @@ void CG_ParseCGMessage_ver_6() } break; - case 37: + case CGM6_VOICE_CHAT: { int iOldEnt; @@ -1950,10 +2092,10 @@ void CG_ParseCGMessage_ver_6() current_entity_number = iInfo; commandManager.PlaySound(szTmp, vStart, CHAN_LOCAL, -1, -1, -1, 0); - } else { + } else if (cg.snap) { current_entity_number = cg.snap->ps.clientNum; - commandManager.PlaySound(szTmp, vStart, CHAN_AUTO, -1, -1, -1, 1); + commandManager.PlaySound(szTmp, vStart, CHAN_LOCAL, -1, -1, -1, 1); } current_entity_number = iOldEnt; diff --git a/code/cgame/cg_predict.c b/code/cgame/cg_predict.c index 03f9a3e9..4eeb4ac1 100644 --- a/code/cgame/cg_predict.c +++ b/code/cgame/cg_predict.c @@ -190,8 +190,9 @@ void CG_ShowTrace(trace_t *trace, int passent, const char *reason) assert(reason); assert(trace); - sprintf( + Com_sprintf( text, + sizeof(text), "%0.2f : Pass (%d) Frac %f Hit (%d): '%s'\n", (float)cg.time / 1000.0f, passent, @@ -329,8 +330,18 @@ static void CG_InterpolatePlayerStateCamera(void) // VectorCopy(cg.predicted_player_state.camera_angles, cg.camera_angles); VectorCopy(cg.predicted_player_state.camera_origin, cg.camera_origin); - cg.camera_fov = cg.predicted_player_state.fov; + // + // Added in OPM + // Use the specified fov specified by the server + // when zooming + // + if (cg.predicted_player_state.stats[STAT_INZOOM]) { + cg.camera_fov = cg.predicted_player_state.fov; + } else { + cg.camera_fov = cg_fov->value; + } + // if the next frame is a teleport, we can't lerp to it if (cg.nextFrameCameraCut) { return; @@ -342,13 +353,24 @@ static void CG_InterpolatePlayerStateCamera(void) f = (float)(cg.time - prev->serverTime) / (next->serverTime - prev->serverTime); - // interpolate fov - cg.camera_fov = prev->ps.fov + f * (next->ps.fov - prev->ps.fov); + if (cg.predicted_player_state.stats[STAT_INZOOM]) { + // interpolate fov + cg.camera_fov = prev->ps.fov + f * (next->ps.fov - prev->ps.fov); + } else { + cg.camera_fov = cg_fov->value; + } if (!(cg.snap->ps.pm_flags & PMF_CAMERA_VIEW)) { return; } + // Added in 2.0 + if (cg.predicted_player_state.camera_flags & CF_CAMERA_ANGLES_TURRETMODE) { + VectorCopy(cg.nextSnap->ps.camera_origin, cg.camera_origin); + VectorCopy(cg.nextSnap->ps.camera_angles, cg.camera_angles); + return; + } + for (i = 0; i < 3; i++) { cg.camera_origin[i] = prev->ps.camera_origin[i] + f * (next->ps.camera_origin[i] - prev->ps.camera_origin[i]); cg.camera_angles[i] = LerpAngle(prev->ps.camera_angles[i], next->ps.camera_angles[i], f); @@ -493,8 +515,13 @@ void CG_PredictPlayerState(void) cg_pmove.leanSpeed = 2.f; } else { cg_pmove.alwaysAllowLean = qtrue; + if (cgs.gametype != GT_SINGLE_PLAYER) { + cg_pmove.leanMax = 40.f; + } else { + // Don't allow lean in single-player, like in the original game + cg_pmove.leanMax = 0; + } - cg_pmove.leanMax = 40.f; cg_pmove.leanAdd = 10.f; cg_pmove.leanRecoverSpeed = 15.f; cg_pmove.leanSpeed = 4.f; @@ -515,7 +542,11 @@ void CG_PredictPlayerState(void) // the server time is beyond our current cg.time, // because predicted player positions are going to // be ahead of everything else anyway - if (cg.nextSnap && !cg.nextFrameTeleport && !cg.thisFrameTeleport) { + // Added in OPM: prediction check + // Don't use the next snapshot if the prediction is about to be disabled + // this prevent "blinking" issues like when entering a vehicle turret gun + // where arms would be seen shortly + if (cg.nextSnap && !cg.nextFrameTeleport && !cg.thisFrameTeleport && !(cg.nextSnap->ps.pm_flags & PMF_NO_PREDICTION)) { cg.predicted_player_state = cg.nextSnap->ps; cg.physicsTime = cg.nextSnap->serverTime; } else { diff --git a/code/cgame/cg_public.h b/code/cgame/cg_public.h index 1b895795..4e5de840 100644 --- a/code/cgame/cg_public.h +++ b/code/cgame/cg_public.h @@ -120,7 +120,9 @@ functions exported to the main executable // console variable interaction cvar_t *(*Cvar_Get)(const char *var_name, const char *value, int flags); + cvar_t *(*Cvar_Find)(const char *var_name); void (*Cvar_Set)(const char *var_name, const char *value); + void (*Cvar_CheckRange)(cvar_t* var, float min, float max, qboolean integral); // ClientCommand and ConsoleCommand parameter access int (*Argc)(void); @@ -311,12 +313,12 @@ functions exported to the main executable ); // 0 = white fontheader_t *(*R_LoadFont)(const char *name); void (*R_DrawString)( - fontheader_t *font, const char *text, float x, float y, int maxLen, qboolean virtualScreen + fontheader_t *font, const char *text, float x, float y, int maxLen, const float *pvVirtualScreen ); refEntity_t *(*R_GetRenderEntity)(int entityNumber); void (*R_ModelBounds)(clipHandle_t model, vec3_t mins, vec3_t maxs); float (*R_ModelRadius)(clipHandle_t model); - float (*R_Noise)(float x, float y, float z, float t); + float (*R_Noise)(float x, float y, float z, double t); void (*R_DebugLine)(const vec3_t start, const vec3_t end, float r, float g, float b, float alpha); baseshader_t *(*GetShader)(int shaderNum); // =========== Swipes ============= @@ -360,6 +362,9 @@ functions exported to the main executable void (*UI_ShowMenu)(const char *name, qboolean bForce); void (*UI_HideMenu)(const char *name, qboolean bForce); int (*UI_FontStringWidth)(fontheader_t *font, const char *string, int maxLen); + // Added in 2.0 + float (*UI_GetObjectivesTop)(void); + void (*UI_GetHighResolutionScale)(vec2_t scale); int (*Key_StringToKeynum)(const char *str); const char *(*Key_KeynumToBindString)(int keyNum); @@ -430,6 +435,8 @@ functions exported to the main executable void (*CL_RestoreSavedCgameState)(); void (*CL_ClearSavedCgameState)(); + size_t (*getConfigStringIdNormalized)(size_t num); + cvar_t *fsDebug; hdelement_t *HudDrawElements; clientAnim_t *anim; @@ -463,8 +470,8 @@ functions exported to the main executable int (*CG_GetParent)(int entNum); float (*CG_GetObjectiveAlpha)(); int (*CG_PermanentMark)( - const vec3_t origin, - const vec3_t dir, + vec3_t origin, + vec3_t dir, float orientation, float sScale, float tScale, diff --git a/code/cgame/cg_scoreboard.cpp b/code/cgame/cg_scoreboard.cpp index fe3a0846..f6cb81c8 100644 --- a/code/cgame/cg_scoreboard.cpp +++ b/code/cgame/cg_scoreboard.cpp @@ -58,19 +58,19 @@ void CG_PrepScoreBoardInfo() { switch (cgs.gametype) { case GT_TEAM_ROUNDS: - strcpy(cg.scoresMenuName, "DM_Round_Scoreboard"); + Q_strncpyz(cg.scoresMenuName, "DM_Round_Scoreboard", sizeof(cg.scoresMenuName)); break; case GT_OBJECTIVE: - strcpy(cg.scoresMenuName, "Obj_Scoreboard"); + Q_strncpyz(cg.scoresMenuName, "Obj_Scoreboard", sizeof(cg.scoresMenuName)); break; case GT_TOW: - strcpy(cg.scoresMenuName, "Tow_Scoreboard"); + Q_strncpyz(cg.scoresMenuName, "Tow_Scoreboard", sizeof(cg.scoresMenuName)); break; case GT_LIBERATION: - strcpy(cg.scoresMenuName, "Lib_Scoreboard"); + Q_strncpyz(cg.scoresMenuName, "Lib_Scoreboard", sizeof(cg.scoresMenuName)); break; default: - strcpy(cg.scoresMenuName, "DM_Scoreboard"); + Q_strncpyz(cg.scoresMenuName, "DM_Scoreboard", sizeof(cg.scoresMenuName)); break; } } @@ -296,14 +296,15 @@ void CG_ParseScores_ver_15() switch (iClientTeam) { case 1: - strcpy(szString3, cgi.LV_ConvertString("Spectators")); + Q_strncpyz(szString3, cgi.LV_ConvertString("Spectators"), sizeof(szString3)); break; case 2: - strcpy(szString3, cgi.LV_ConvertString("Free-For-Allers")); + Q_strncpyz(szString3, cgi.LV_ConvertString("Free-For-Allers"), sizeof(szString3)); break; case 3: - sprintf( + Com_sprintf( szString3, + sizeof(szString3), "%s - %d %s", cgi.LV_ConvertString("Allies"), atoi(cgi.Argv(2 + iCurrentEntry + iDatumCount * i)), @@ -312,8 +313,9 @@ void CG_ParseScores_ver_15() iCurrentEntry++; break; case 4: - sprintf( + Com_sprintf( szString3, + sizeof(szString3), "%s - %d %s", cgi.LV_ConvertString("Axis"), atoi(cgi.Argv(2 + iCurrentEntry + iDatumCount * i)), @@ -322,7 +324,7 @@ void CG_ParseScores_ver_15() iCurrentEntry++; break; default: - strcpy(szString3, cgi.LV_ConvertString("No Team")); + Q_strncpyz(szString3, cgi.LV_ConvertString("No Team"), sizeof(szString3)); break; } } else if (iClientNum == -2) { @@ -330,14 +332,14 @@ void CG_ParseScores_ver_15() szString2[0] = 0; szString3[0] = 0; } else { - strcpy(szString2, va("%i", iClientNum)); - strcpy(szString3, cg.clientinfo[iClientNum].name); + Q_strncpyz(szString2, va("%i", iClientNum), sizeof(szString2)); + Q_strncpyz(szString3, cg.clientinfo[iClientNum].name, sizeof(szString3)); } - strcpy(szString4, cgi.Argv(2 + iCurrentEntry + iDatumCount * i)); - strcpy(szString5, cgi.Argv(3 + iCurrentEntry + iDatumCount * i)); - strcpy(szString6, cgi.Argv(4 + iCurrentEntry + iDatumCount * i)); - strcpy(szString7, cgi.Argv(5 + iCurrentEntry + iDatumCount * i)); + Q_strncpyz(szString4, cgi.Argv(2 + iCurrentEntry + iDatumCount * i), sizeof(szString4)); + Q_strncpyz(szString5, cgi.Argv(3 + iCurrentEntry + iDatumCount * i), sizeof(szString5)); + Q_strncpyz(szString6, cgi.Argv(4 + iCurrentEntry + iDatumCount * i), sizeof(szString6)); + Q_strncpyz(szString7, cgi.Argv(5 + iCurrentEntry + iDatumCount * i), sizeof(szString7)); if (cgs.gametype >= GT_TEAM_ROUNDS && iClientNum == -1 && (iClientTeam == TEAM_ALLIES || iClientTeam == TEAM_AXIS)) { @@ -370,19 +372,19 @@ void CG_ParseScores_ver_15() } else { iClientNum = atoi(cgi.Argv(iCurrentEntry + iDatumCount * i)); if (iClientNum >= 0) { - strcpy(szString2, va("%i", iClientNum)); - strcpy(szString3, cg.clientinfo[iClientNum].name); - strcpy(szString4, cgi.Argv(1 + iCurrentEntry + iDatumCount * i)); - strcpy(szString5, cgi.Argv(2 + iCurrentEntry + iDatumCount * i)); - strcpy(szString6, cgi.Argv(3 + iCurrentEntry + iDatumCount * i)); - strcpy(szString7, cgi.Argv(4 + iCurrentEntry + iDatumCount * i)); + Q_strncpyz(szString2, va("%i", iClientNum), sizeof(szString2)); + Q_strncpyz(szString3, cg.clientinfo[iClientNum].name, sizeof(szString3)); + Q_strncpyz(szString4, cgi.Argv(1 + iCurrentEntry + iDatumCount * i), sizeof(szString4)); + Q_strncpyz(szString5, cgi.Argv(2 + iCurrentEntry + iDatumCount * i), sizeof(szString5)); + Q_strncpyz(szString6, cgi.Argv(3 + iCurrentEntry + iDatumCount * i), sizeof(szString6)); + Q_strncpyz(szString7, cgi.Argv(4 + iCurrentEntry + iDatumCount * i), sizeof(szString7)); } else { szString2[0] = 0; if (iClientNum == -3) { - strcpy(szString2, cgi.LV_ConvertString("Players")); + Q_strncpyz(szString2, cgi.LV_ConvertString("Players"), sizeof(szString2)); bIsHeader = qtrue; } else if (iClientNum == -2) { - strcpy(szString2, cgi.LV_ConvertString("Spectators")); + Q_strncpyz(szString2, cgi.LV_ConvertString("Spectators"), sizeof(szString2)); bIsHeader = qtrue; } else { // unknown @@ -535,32 +537,32 @@ void CG_ParseScores_ver_6() switch (iClientTeam) { case 1: - strcpy(szString2, cgi.LV_ConvertString("Spectators")); + Q_strncpyz(szString2, cgi.LV_ConvertString("Spectators"), sizeof(szString2)); break; case 2: - strcpy(szString2, cgi.LV_ConvertString("Free-For-Allers")); + Q_strncpyz(szString2, cgi.LV_ConvertString("Free-For-Allers"), sizeof(szString2)); break; case 3: - strcpy(szString2, cgi.LV_ConvertString("Allies")); + Q_strncpyz(szString2, cgi.LV_ConvertString("Allies"), sizeof(szString2)); break; case 4: - strcpy(szString2, cgi.LV_ConvertString("Axis")); + Q_strncpyz(szString2, cgi.LV_ConvertString("Axis"), sizeof(szString2)); break; default: - strcpy(szString2, cgi.LV_ConvertString("No Team")); + Q_strncpyz(szString2, cgi.LV_ConvertString("No Team"), sizeof(szString2)); break; } } else if (iClientNum == -2) { // spectating szString2[0] = 0; } else { - strcpy(szString2, cg.clientinfo[iClientNum].name); + Q_strncpyz(szString2, cg.clientinfo[iClientNum].name, sizeof(szString2)); } - strcpy(szString3, cgi.Argv(2 + iCurrentEntry + iDatumCount * i)); - strcpy(szString4, cgi.Argv(3 + iCurrentEntry + iDatumCount * i)); - strcpy(szString5, cgi.Argv(4 + iCurrentEntry + iDatumCount * i)); - strcpy(szString6, cgi.Argv(5 + iCurrentEntry + iDatumCount * i)); + Q_strncpyz(szString3, cgi.Argv(2 + iCurrentEntry + iDatumCount * i), sizeof(szString3)); + Q_strncpyz(szString4, cgi.Argv(3 + iCurrentEntry + iDatumCount * i), sizeof(szString4)); + Q_strncpyz(szString5, cgi.Argv(4 + iCurrentEntry + iDatumCount * i), sizeof(szString5)); + Q_strncpyz(szString6, cgi.Argv(5 + iCurrentEntry + iDatumCount * i), sizeof(szString6)); if (iClientNum == cg.snap->ps.clientNum) { pItemTextColor = vThisClientTextColor; @@ -587,17 +589,17 @@ void CG_ParseScores_ver_6() } else { iClientNum = atoi(cgi.Argv(iCurrentEntry + iDatumCount * i)); if (iClientNum >= 0) { - strcpy(szString2, cg.clientinfo[iClientNum].name); - strcpy(szString3, cgi.Argv(1 + iCurrentEntry + iDatumCount * i)); - strcpy(szString4, cgi.Argv(2 + iCurrentEntry + iDatumCount * i)); - strcpy(szString5, cgi.Argv(3 + iCurrentEntry + iDatumCount * i)); - strcpy(szString6, cgi.Argv(4 + iCurrentEntry + iDatumCount * i)); + Q_strncpyz(szString2, cg.clientinfo[iClientNum].name, sizeof(szString2)); + Q_strncpyz(szString3, cgi.Argv(1 + iCurrentEntry + iDatumCount * i), sizeof(szString3)); + Q_strncpyz(szString4, cgi.Argv(2 + iCurrentEntry + iDatumCount * i), sizeof(szString4)); + Q_strncpyz(szString5, cgi.Argv(3 + iCurrentEntry + iDatumCount * i), sizeof(szString5)); + Q_strncpyz(szString6, cgi.Argv(4 + iCurrentEntry + iDatumCount * i), sizeof(szString6)); } else { if (iClientNum == -3) { - strcpy(szString2, cgi.LV_ConvertString("Players")); + Q_strncpyz(szString2, cgi.LV_ConvertString("Players"), sizeof(szString2)); bIsHeader = qtrue; } else if (iClientNum == -2) { - strcpy(szString2, cgi.LV_ConvertString("Spectators")); + Q_strncpyz(szString2, cgi.LV_ConvertString("Spectators"), sizeof(szString2)); bIsHeader = qtrue; } else { // unknown diff --git a/code/cgame/cg_servercmds.c b/code/cgame/cg_servercmds.c index 25c0e356..bc9f100a 100644 --- a/code/cgame/cg_servercmds.c +++ b/code/cgame/cg_servercmds.c @@ -1,6 +1,7 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2008-2024 the OpenMoHAA team +Copyright (C) 1999-2005 Id Software, Inc. This file is part of OpenMoHAA source code. @@ -25,12 +26,27 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "cg_local.h" #include "../fgame/bg_voteoptions.h" +#include "cg_servercmds_filter.h" +/* +================ +IsWeaponAllowed + +Returns true if the weapon is allowed +================ +*/ static const char *IsWeaponAllowed(int dmFlags, int flags) { return (dmFlags & flags) ? "0" : "1"; } +/* +================ +QueryLandminesAllowed2 + +Returns true if landmines is allowed by the map or by a dm flag +================ +*/ static qboolean QueryLandminesAllowed2(const char *mapname, int dmflags) { if (dmflags & DF_WEAPON_NO_LANDMINE) { @@ -134,6 +150,7 @@ void CG_ParseServerinfo(void) cgi.Cvar_Set("cg_fraglimit", Info_ValueForKey(info, "fraglimit")); cgi.Cvar_Set("cg_timelimit", Info_ValueForKey(info, "timelimit")); cgi.Cvar_Set("cg_maxclients", Info_ValueForKey(info, "sv_gametype")); + cgi.Cvar_Set("cg_allowvote", Info_ValueForKey(info, "g_allowvote")); cgi.Cvar_Set("cg_obj_alliedtext1", Info_ValueForKey(info, "g_obj_alliedtext1")); cgi.Cvar_Set("cg_obj_alliedtext2", Info_ValueForKey(info, "g_obj_alliedtext2")); cgi.Cvar_Set("cg_obj_alliedtext3", Info_ValueForKey(info, "g_obj_alliedtext3")); @@ -148,10 +165,10 @@ void CG_ParseServerinfo(void) cgi.Cvar_Set("cg_scoreboardpicover", Info_ValueForKey(info, "g_scoreboardpicover")); mapChecksumStr = Info_ValueForKey(info, "sv_mapChecksum"); if (mapChecksumStr && mapChecksumStr[0]) { - cgs.mapChecksum = atoi(mapChecksumStr); + cgs.mapChecksum = atoi(mapChecksumStr); cgs.useMapChecksum = qtrue; } else { - cgs.mapChecksum = 0; + cgs.mapChecksum = 0; cgs.useMapChecksum = qfalse; } @@ -169,11 +186,15 @@ void CG_ParseServerinfo(void) if (spawnpos) { Q_strncpyz(map, mapname, spawnpos - mapname + 1); } else { - strcpy(map, mapname); + Q_strncpyz(map, mapname, sizeof(map)); } - Com_sprintf(cgs.mapname, sizeof(cgs.mapname), "maps/%s.bsp", map); - + if (CG_UseLargeLightmaps(mapname)) { + Com_sprintf(cgs.mapname, sizeof(cgs.mapname), "maps/%s.bsp", map); + } else { + Com_sprintf(cgs.mapname, sizeof(cgs.mapname), "maps/%s_sml.bsp", map); + } + // hide/show huds if (cgs.gametype) { cgi.Cmd_Execute(EXEC_NOW, "ui_addhud hud_timelimit\n"); @@ -296,7 +317,7 @@ static void CG_ServerCommand(qboolean modelOnly) } if (!strcmp(cmd, "cs")) { - CG_ConfigStringModified(atoi(cgi.Argv(1)), modelOnly); + CG_ConfigStringModified(cgi.getConfigStringIdNormalized(atoi(cgi.Argv(1))), modelOnly); return; } @@ -311,12 +332,12 @@ static void CG_ServerCommand(qboolean modelOnly) } return; } else if (!strcmp(cmd, "printdeathmsg")) { - const char *s1, *s2, * attackerName, * victimName, *type; + const char *s1, *s2, *attackerName, *victimName, *type; const char *result1, *result2; int hudColor; - result1 = NULL; - result2 = NULL; + result1 = NULL; + result2 = NULL; s1 = cgi.Argv(1); s2 = cgi.Argv(2); attackerName = cgi.Argv(3); @@ -352,7 +373,14 @@ static void CG_ServerCommand(qboolean modelOnly) } if (!strcmp(cmd, "stufftext")) { - cgi.Cmd_Stuff(cgi.Argv(1)); + char *cmd = cgi.Argv(1); + if (CG_IsStatementFiltered(cmd)) { + // Added in OPM + // Don't execute filtered commands + return; + } + + cgi.Cmd_Stuff(cmd); cgi.Cmd_Stuff("\n"); return; } diff --git a/code/cgame/cg_servercmds_filter.c b/code/cgame/cg_servercmds_filter.c new file mode 100644 index 00000000..9e2170f7 --- /dev/null +++ b/code/cgame/cg_servercmds_filter.c @@ -0,0 +1,292 @@ +/* +=========================================================================== +Copyright (C) 2025 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA source code 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. + +OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// DESCRIPTION: +// cg_servercmds_filter.c -- filtered server commands + +#include "cg_local.h" +#include "cg_servercmds_filter.h" + +// +// List of variables allowed to be changed by the server +// +static const char *whiteListedVariables[] = { + // some mods set this variable to make the sky uniform + "r_fastsky", + + "ui_hud", + "subtitle0", + "subtitle1", + "subtitle2", + "subtitle3", + "name", + + // for 3rd person server + "cg_3rd_person", + "cg_cameraverticaldisplacement" +}; + +// +// List of variables allowed to be changed by the server +// +static const char *whiteListedLocalServerVariables[] = {"ui_hidemouse", "ui_showmouse", "cg_marks_add"}; + +// +// List of commands allowed to be executed by the server +// +static const char *whiteListedCommands[] = { + // + // HUD + //========== + "pushmenu", + "pushmenu_teamselect", + "pushmenu_weaponselect", + "popmenu", + "globalwidgetcommand", // used for mods adding custom HUDs + "ui_addhud", + "ui_removehud", + "echo", // to print stuff client-side + + // + // Sounds + //========== + "tmstart", + "tmstartloop", + "tmstop", + "tmvolume", + "play", + "playmp3", + "stopmp3", + + // + // Misc + //========== + "primarydmweapon", + "wait", + "+moveup", // workaround for mods that want to prevent inactivity when handling the spectate + "-moveup", + "screenshot", + "screenshotJPEG", + "levelshot", + "`stufftext" // Stufftext detection from Reborn, the player gets kicked without it +}; + +// +// List of commands allowed to be executed locally +// (when the client also runs the server) +// +static const char *whiteListedLocalServerCommands[] = { + // Used by briefings + "spmap", + "map", + "disconnect", + + "cinematic", + "showmenu", + "hidemenu" +}; + + +/* +==================== +CG_IsVariableFiltered + +Returns whether or not the variable should be filtered +==================== +*/ +static qboolean CG_IsVariableFiltered(const char *name) +{ + size_t i; + + for (i = 0; i < ARRAY_LEN(whiteListedVariables); i++) { + if (!Q_stricmp(name, whiteListedVariables[i])) { + return qfalse; + } + } + + if (cgs.localServer) { + for (i = 0; i < ARRAY_LEN(whiteListedLocalServerVariables); i++) { + if (!Q_stricmp(name, whiteListedLocalServerVariables[i])) { + return qfalse; + } + } + } + + // Filtered + return qtrue; +} + +/* +==================== +CG_IsSetVariableFiltered + +Returns whether or not the variable should be filtered +==================== +*/ +static qboolean CG_IsSetVariableFiltered(const char *name, char type) +{ + cvar_t *var; + + if (!CG_IsVariableFiltered(name)) { + return qfalse; + } + + if (type != 'u' && type != 's') { + // Don't allow custom info variables to avoid flooding + // the client with many serverinfo and userinfo variables + + var = cgi.Cvar_Find(name); + if (!var) { + // Allow as it doesn't exist + return qfalse; + } + + if (var->flags & CVAR_USER_CREATED) { + // Allow, it's user-created, wouldn't cause issues + return qfalse; + } + } + + // Filtered + return qtrue; +} + +/* +==================== +CG_IsCommandFiltered + +Returns whether or not the variable should be filtered +==================== +*/ +static qboolean CG_IsCommandFiltered(const char *name) +{ + size_t i; + + for (i = 0; i < ARRAY_LEN(whiteListedCommands); i++) { + if (!Q_stricmp(name, whiteListedCommands[i])) { + return qfalse; + } + } + + if (cgs.localServer) { + // Allow more commands when the client is hosting the server + // Mostly used on single-player mode, like when briefings switch to the next map + for (i = 0; i < ARRAY_LEN(whiteListedLocalServerCommands); i++) { + if (!Q_stricmp(name, whiteListedLocalServerCommands[i])) { + return qfalse; + } + } + } + + // + // Test variables + // + return CG_IsVariableFiltered(name); +} + +/* +==================== +RemoveEndToken +==================== +*/ +static qboolean RemoveEndToken(char* com_token) { + char* p; + + for (p = com_token; p[0]; p++) { + if (*p == ';') { + *p = 0; + return qtrue; + } + } + + return qfalse; +} + +/* +==================== +CG_IsStatementFiltered + +Returns whether or not the statement is filtered +==================== +*/ +qboolean CG_IsStatementFiltered(char *cmd) +{ + char* parsed; + char com_token[256]; + qboolean bNextStatement = qfalse; + + parsed = cmd; + + for (Q_strncpyz(com_token, COM_ParseExt(&parsed, qtrue), sizeof(com_token)); com_token[0]; Q_strncpyz(com_token, COM_ParseExt(&parsed, qtrue), sizeof(com_token))) { + bNextStatement = RemoveEndToken(com_token); + + if (com_token[0] == ';') { + continue; + } + + if (!Q_stricmp(com_token, "set") || !Q_stricmp(com_token, "setu") || !Q_stricmp(com_token, "seta") + || !Q_stricmp(com_token, "sets") || !Q_stricmp(com_token, "append")) { + char type; + + if (Q_stricmp(com_token, "append")) { + type = com_token[3]; + } else { + type = 0; + } + + // + // variable + // + Q_strncpyz(com_token, COM_ParseExt(&parsed, qfalse), sizeof(com_token)); + bNextStatement |= RemoveEndToken(com_token); + if (com_token[0] == ';') { + continue; + } + + if (CG_IsSetVariableFiltered(com_token, type)) { + return qtrue; + } + } else { + // + // normal command + // + if (CG_IsCommandFiltered(com_token)) { + return qtrue; + } + } + + if (!bNextStatement) { + // Skip up to the next statement + while (parsed && parsed[0]) { + char c = parsed[0]; + + parsed++; + if (c == '\n' || c == ';') { + break; + } + } + } + } + + return qfalse; +} + diff --git a/code/renderer/tr_ghost.cpp b/code/cgame/cg_servercmds_filter.h similarity index 82% rename from code/renderer/tr_ghost.cpp rename to code/cgame/cg_servercmds_filter.h index 2b619982..f8351028 100644 --- a/code/renderer/tr_ghost.cpp +++ b/code/cgame/cg_servercmds_filter.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2025 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -20,7 +20,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -// tr_ghost.cpp +// DESCRIPTION: +// cg_servercmds_filter.h -- filtered server commands -#include "tr_local.h" -#include "tr_ghost.h" +#pragma once + +#include "cg_local.h" + +qboolean CG_IsStatementFiltered(char *cmd); \ No newline at end of file diff --git a/code/cgame/cg_snapshot.c b/code/cgame/cg_snapshot.c index 051d1fb9..06b6d67d 100644 --- a/code/cgame/cg_snapshot.c +++ b/code/cgame/cg_snapshot.c @@ -73,10 +73,10 @@ static void CG_ResetEntity(centity_t *cent) CG_RemoveClientEntity(cent->currentState.number, tiki, cent); // reset the animation for the entities - if (tiki && tiki->a->bIsCharacter) { + if (tiki) { for (i = 0; i < MAX_FRAMEINFOS; i++) { - cent->animLast[i] = cent->currentState.frameInfo[i].index; - cent->animLastTimes[i] = cent->currentState.frameInfo[i].time; + cent->animLast[i] = -1; + cent->animLastTimes[i] = -1; if (cent->currentState.frameInfo[i].weight) { cent->animLastWeight |= 1 << i; } else { @@ -87,7 +87,8 @@ static void CG_ResetEntity(centity_t *cent) } else { // clear all the last animations for (i = 0; i < MAX_FRAMEINFOS; i++) { - cent->animLast[i] = -1; + cent->animLast[i] = -1; + cent->animLastTimes[i] = 0.0; } cent->animLastWeight = 0; @@ -346,8 +347,10 @@ static snapshot_t *CG_ReadNextSnapshot(void) snapshot_t *dest; if (cg.latestSnapshotNum > cgs.processedSnapshotNum + 1000) { - cgi.Error( - ERR_DROP, "CG_ReadNextSnapshot: way out of range, %i > %i", cg.latestSnapshotNum, cgs.processedSnapshotNum + cgi.Printf( + "WARNING: CG_ReadNextSnapshot: way out of range, %i > %i\n", + cg.latestSnapshotNum, + cgs.processedSnapshotNum ); } diff --git a/code/cgame/cg_specialfx.cpp b/code/cgame/cg_specialfx.cpp index 8f5abb61..48042803 100644 --- a/code/cgame/cg_specialfx.cpp +++ b/code/cgame/cg_specialfx.cpp @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -38,7 +38,8 @@ static vec3_t g_vLadderstepMaxs; ClientSpecialEffectsManager sfxManager; -Event EV_SFX_EffectDelay( +Event EV_SFX_EffectDelay +( "effectdelay", EV_DEFAULT, "iivvvvv", @@ -94,7 +95,7 @@ void ClientSpecialEffectsManager::LoadEffects() cgi.DPrintf("Loading Special Effects...\n"); AxisClear(axis); - for (i = 0; i < MAX_SPECIAL_EFFECTS; i++) { + for (i = 0; i < SFX_COUNT; i++) { switch (i) { case SFX_BHIT_PAPER_LITE: szEffectModel = "models/fx/bh_paper_lite.tik"; @@ -234,9 +235,15 @@ void ClientSpecialEffectsManager::LoadEffects() szEffectModel = "models/fx/bazookaexp_base.tik"; break; case SFX_EXP_HEAVYSHELL_BASE: + if (cg_protocol < protocol_e::PROTOCOL_MOHTA_MIN) { + continue; + } szEffectModel = "models/fx/heavyshellexp_base.tik"; break; case SFX_EXP_TANK_BASE: + if (cg_protocol < protocol_e::PROTOCOL_MOHTA_MIN) { + continue; + } szEffectModel = "models/fx/tankexp_base.tik"; break; case SFX_EXP_GREN_PAPER: @@ -285,30 +292,57 @@ void ClientSpecialEffectsManager::LoadEffects() szEffectModel = "models/fx/grenexp_carpet.tik"; break; case SFX_EXP_HEAVYSHELL_DIRT: + if (cg_protocol < protocol_e::PROTOCOL_MOHTA_MIN) { + continue; + } szEffectModel = "models/fx/heavyshellexp_dirt.tik"; break; case SFX_EXP_HEAVYSHELL_STONE: + if (cg_protocol < protocol_e::PROTOCOL_MOHTA_MIN) { + continue; + } szEffectModel = "models/fx/heavyshellexp_stone.tik"; break; case SFX_EXP_HEAVYSHELL_SNOW: + if (cg_protocol < protocol_e::PROTOCOL_MOHTA_MIN) { + continue; + } szEffectModel = "models/fx/heavyshellexp_snow.tik"; break; case SFX_EXP_TANK_DIRT: + if (cg_protocol < protocol_e::PROTOCOL_MOHTA_MIN) { + continue; + } szEffectModel = "models/fx/tankexp_dirt.tik"; break; case SFX_EXP_TANK_STONE: + if (cg_protocol < protocol_e::PROTOCOL_MOHTA_MIN) { + continue; + } szEffectModel = "models/fx/tankexp_stone.tik"; break; case SFX_EXP_TANK_SNOW: + if (cg_protocol < protocol_e::PROTOCOL_MOHTA_MIN) { + continue; + } szEffectModel = "models/fx/tankexp_snow.tik"; break; case SFX_EXP_BAZOOKA_DIRT: + if (cg_protocol < protocol_e::PROTOCOL_MOHTA_MIN) { + continue; + } szEffectModel = "models/fx/bazookaexp_dirt.tik"; break; case SFX_EXP_BAZOOKA_STONE: + if (cg_protocol < protocol_e::PROTOCOL_MOHTA_MIN) { + continue; + } szEffectModel = "models/fx/bazookaexp_stone.tik"; break; case SFX_EXP_BAZOOKA_SNOW: + if (cg_protocol < protocol_e::PROTOCOL_MOHTA_MIN) { + continue; + } szEffectModel = "models/fx/bazookaexp_snow.tik"; break; case SFX_WATER_RIPPLE_STILL: @@ -478,7 +512,7 @@ void ClientSpecialEffectsManager::ExecuteEffect( current_tiki = NULL; pCommand->emitter->cgd.origin = vPos; - if (pCommand->emitter->cgd.flags & T_ANGLES) { + if (!(pCommand->emitter->cgd.flags & T_ANGLES)) { pCommand->emitter->cgd.angles = vAngles; } @@ -486,7 +520,7 @@ void ClientSpecialEffectsManager::ExecuteEffect( AxisCopy(axis, pCommand->emitter->tag_axis); pCommand->emitter->cgd.createTime = cg.time; commandManager.SetSpawnthing(pCommand->emitter); - + (commandManager.*pCommand->endfcn)(); } } @@ -904,7 +938,144 @@ void CG_LandingSound(centity_t *ent, refEntity_t *pREnt, float volume, int iEqui void CG_BodyFallSound(centity_t *ent, refEntity_t *pREnt, float volume) { - // FIXME: unimplemented + int contents; + int surftype; + int iEffectNum = -1; + vec3_t vStart, vEnd; + vec3_t midlegs; + str sSoundName; + trace_t trace; + + VectorCopy(ent->lerpOrigin, vStart); + vStart[2] += 8; + + VectorCopy(vStart, vEnd); + vEnd[2] -= 64; + + if (ent->currentState.eType == ET_PLAYER) { + CG_Trace( + &trace, + vStart, + g_vFootstepMins, + g_vFootstepMaxs, + vEnd, + ent->currentState.number, + MASK_PLAYERSOLID, + qtrue, + qtrue, + "Player Landing" + ); + } else { + CG_Trace( + &trace, + vStart, + g_vFootstepMins, + g_vFootstepMaxs, + vEnd, + ent->currentState.number, + MASK_MONSTERSOLID, + qfalse, + qfalse, + "Monster Landing" + ); + } + + if (trace.fraction == 1) { + return; + } + + sSoundName = "snd_bodyfall_"; + contents = CG_PointContents(trace.endpos, -1); + if (contents & MASK_WATER) { + // take our ground position and trace upwards + VectorCopy(trace.endpos, midlegs); + midlegs[2] += WATER_NO_SPLASH_HEIGHT; + contents = CG_PointContents(midlegs, -1); + if (contents & MASK_WATER) { + sSoundName += "wade"; + } else { + sSoundName += "puddle"; + iEffectNum = SFX_FOOT_PUDDLE; + } + } else { + surftype = trace.surfaceFlags & MASK_SURF_TYPE; + switch (surftype) { + case SURF_FOLIAGE: + sSoundName += "foliage"; + iEffectNum = SFX_FOOT_GRASS; + break; + case SURF_SNOW: + sSoundName += "snow"; + iEffectNum = SFX_FOOT_SNOW; + break; + case SURF_CARPET: + sSoundName += "carpet"; + iEffectNum = SFX_FOOT_LIGHT_DUST; + break; + case SURF_SAND: + sSoundName += "sand"; + iEffectNum = SFX_FOOT_SAND; + break; + case SURF_PUDDLE: + sSoundName += "puddle"; + iEffectNum = SFX_FOOT_PUDDLE; + break; + case SURF_GLASS: + sSoundName += "glass"; + iEffectNum = SFX_FOOT_LIGHT_DUST; + break; + case SURF_GRAVEL: + sSoundName += "gravel"; + iEffectNum = SFX_FOOT_HEAVY_DUST; + break; + case SURF_MUD: + sSoundName += "mud"; + iEffectNum = SFX_FOOT_MUD; + break; + case SURF_DIRT: + sSoundName += "dirt"; + iEffectNum = SFX_FOOT_DIRT; + break; + case SURF_GRILL: + sSoundName += "grill"; + iEffectNum = SFX_FOOT_LIGHT_DUST; + break; + case SURF_GRASS: + sSoundName += "grass"; + iEffectNum = SFX_FOOT_GRASS; + break; + case SURF_ROCK: + sSoundName += "stone"; + iEffectNum = SFX_FOOT_HEAVY_DUST; + break; + case SURF_PAPER: + sSoundName += "paper"; + iEffectNum = SFX_FOOT_LIGHT_DUST; + break; + case SURF_WOOD: + sSoundName += "wood"; + iEffectNum = SFX_FOOT_LIGHT_DUST; + break; + case SURF_METAL: + sSoundName += "metal"; + iEffectNum = SFX_FOOT_LIGHT_DUST; + break; + default: + sSoundName += "stone"; + iEffectNum = SFX_FOOT_HEAVY_DUST; + break; + } + } + + if (cg_debugFootsteps->integer) { + cgi.DPrintf("BodyFall: %s volume: %.2f effect = %i\n", sSoundName.c_str(), volume, iEffectNum); + } + + commandManager.PlaySound(sSoundName, trace.endpos, -1, volume, -1, -1, 1); + + if (iEffectNum != -1) { + sfxManager.MakeEffect_Angles(iEffectNum, trace.endpos, Vector(270, 0, 0)); + } } /* @@ -1023,5 +1194,5 @@ qboolean ClientSpecialEffectsManager::EffectsPending() specialeffect_t *ClientSpecialEffectsManager::GetTestEffectPointer() { - return &m_effects[SPECIAL_EFFECT_TEST]; + return &m_effects[SFX_TEST_EFFECT]; } diff --git a/code/cgame/cg_specialfx.h b/code/cgame/cg_specialfx.h index 4a84e52c..9df6c06d 100644 --- a/code/cgame/cg_specialfx.h +++ b/code/cgame/cg_specialfx.h @@ -170,12 +170,9 @@ public: specialeffectcommand_t *AddNewCommand(); }; -#define MAX_SPECIAL_EFFECTS 99 -#define SPECIAL_EFFECT_TEST MAX_SPECIAL_EFFECTS - 1 - class ClientSpecialEffectsManager : public Listener { - specialeffect_t m_effects[99]; + specialeffect_t m_effects[SFX_COUNT]; qboolean m_bEffectsLoaded; int m_iNumPendingEvents; diff --git a/code/cgame/cg_tempmodels.cpp b/code/cgame/cg_tempmodels.cpp index fae4fd55..3ce3ab04 100644 --- a/code/cgame/cg_tempmodels.cpp +++ b/code/cgame/cg_tempmodels.cpp @@ -79,6 +79,11 @@ void ClientGameCommandManager::FreeTempModel(ctempmodel_t *p) RemoveClientEntity(p->number, p->cgd.tiki, NULL, p); + if (m_active_tempmodels.next == p) { + // use the next active temp model + m_active_tempmodels.next = p->next; + } + // remove from the doubly linked active list p->prev->next = p->next; p->next->prev = p->prev; @@ -86,6 +91,22 @@ void ClientGameCommandManager::FreeTempModel(ctempmodel_t *p) // the free list is only singly linked p->next = m_free_tempmodels; m_free_tempmodels = p; + + if (p->m_spawnthing) { + p->m_spawnthing->numtempmodels--; + // delete unused spawnthings + if (!p->m_spawnthing->numtempmodels) { + m_emitters.RemoveObject(p->m_spawnthing); + + if (p->m_spawnthing == m_spawnthing) { + m_spawnthing = NULL; + } + + delete p->m_spawnthing; + } + + p->m_spawnthing = NULL; + } } //=============== @@ -110,10 +131,10 @@ void ClientGameCommandManager::FreeAllTempModels(void) //=============== void ClientGameCommandManager::FreeSomeTempModels(void) { - ctempmodel_t* model; - int count = 0; - unsigned int i; - unsigned int numToFree; + ctempmodel_t *model; + int count = 0; + unsigned int i; + unsigned int numToFree; if (!m_free_tempmodels) { return; @@ -138,10 +159,10 @@ void ClientGameCommandManager::FreeSomeTempModels(void) //=============== // FreeSpawnthing //=============== -void ClientGameCommandManager::FreeSpawnthing(spawnthing_t* sp) +void ClientGameCommandManager::FreeSpawnthing(spawnthing_t *sp) { - ctempmodel_t* model; - ctempmodel_t* prev; + ctempmodel_t *model; + ctempmodel_t *prev; if (sp->numtempmodels) { for (model = m_active_tempmodels.prev; model != &m_active_tempmodels; model = prev) { @@ -178,7 +199,7 @@ void ClientGameCommandManager::ResetTempModels(void) } static int lastTempModelFrameTime = 0; -int next_tempmodel_warning = 0; +int next_tempmodel_warning = 0; void CG_ResetTempModels(void) { @@ -207,11 +228,16 @@ void ClientGameCommandManager::InitializeTempModels(void) void ClientGameCommandManager::InitializeTempModelCvars(void) { - cg_showtempmodels = cgi.Cvar_Get("cg_showtempmodels", "0", 0); - cg_detail = cgi.Cvar_Get("detail", "1", CVAR_ARCHIVE); - cg_effectdetail = cgi.Cvar_Get("cg_effectdetail", "0.2", CVAR_ARCHIVE); + cg_showtempmodels = cgi.Cvar_Get("cg_showtempmodels", "0", 0); + cg_detail = cgi.Cvar_Get("detail", "1", CVAR_ARCHIVE); + + cg_effectdetail = cgi.Cvar_Get("cg_effectdetail", "0.2", CVAR_ARCHIVE); + cgi.Cvar_CheckRange(cg_effectdetail, 0.2, 1.0, qfalse); + cg_effect_physicsrate = cgi.Cvar_Get("cg_effect_physicsrate", "10", CVAR_ARCHIVE); cg_max_tempmodels = cgi.Cvar_Get("cg_max_tempmodels", "1100", CVAR_ARCHIVE); + cgi.Cvar_CheckRange(cg_max_tempmodels, 200, MAX_TEMPMODELS, qtrue); + cg_reserve_tempmodels = cgi.Cvar_Get("cg_reserve_tempmodels", "200", CVAR_ARCHIVE); if (cg_max_tempmodels->integer > MAX_TEMPMODELS) { @@ -232,9 +258,9 @@ void ClientGameCommandManager::InitializeTempModelCvars(void) //=============== void ClientGameCommandManager::AnimateTempModel(ctempmodel_t *p, Vector origin, refEntity_t *newEnt) { - int numframes; - int deltatime; - int frametime; + int numframes; + int deltatime; + int frametime; float prev; // This code is for animating tempmodels that are spawned from the client @@ -418,9 +444,11 @@ qboolean ClientGameCommandManager::TempModelRealtimeEffects(ctempmodel_t *p, flo p->ent.shaderRGBA[0] = (int)((float)tempColor[0] * vLighting[0]); p->ent.shaderRGBA[1] = (int)((float)tempColor[1] * vLighting[1]); + p->ent.shaderRGBA[2] = (int)((float)tempColor[2] * vLighting[2]); } else { p->ent.shaderRGBA[0] = tempColor[0]; p->ent.shaderRGBA[1] = tempColor[1]; + p->ent.shaderRGBA[2] = tempColor[2]; } if (p->cgd.flags & T_FADEIN && (fadein < 1)) // Do the fadein effect @@ -468,16 +496,16 @@ void ClientGameCommandManager::OtherTempModelEffects(ctempmodel_t *p, Vector ori if (p->number != -1) { refEntity_t *old_entity; dtiki_t *old_tiki; - int oldnum; - float oldscale; + int oldnum; + float oldscale; // Set the axis AnglesToAxis(p->cgd.angles, axis); old_entity = current_entity; - old_tiki = current_tiki; - oldnum = current_entity_number; - oldscale = current_scale; + old_tiki = current_tiki; + oldnum = current_entity_number; + oldscale = current_scale; current_scale = newEnt->scale; current_entity = newEnt; @@ -502,7 +530,7 @@ void ClientGameCommandManager::OtherTempModelEffects(ctempmodel_t *p, Vector ori if (p->cgd.flags2 & T2_ALIGNSTRETCH) { Vector vDelta; - float fScale; + float fScale; vDelta = p->cgd.origin - p->cgd.oldorigin; fScale = vDelta.length() * p->cgd.scale2; @@ -518,6 +546,7 @@ qboolean ClientGameCommandManager::TempModelPhysics(ctempmodel_t *p, float ftime Vector tempangles; trace_t trace; float dot; + int i; VectorCopy(p->ent.origin, p->lastEnt.origin); AxisCopy(p->ent.axis, p->lastEnt.axis); @@ -538,8 +567,8 @@ qboolean ClientGameCommandManager::TempModelPhysics(ctempmodel_t *p, float ftime // If linked to the parent or hardlinked, get the parent's origin if ((p->cgd.flags & (T_PARENTLINK | T_HARDLINK)) && (p->cgd.parent != ENTITYNUM_NONE)) { - centity_t* pc; - refEntity_t* e; + centity_t *pc; + refEntity_t *e; pc = &cg_entities[p->cgd.parent]; if (!pc->currentValid) { @@ -553,8 +582,7 @@ qboolean ClientGameCommandManager::TempModelPhysics(ctempmodel_t *p, float ftime parentOrigin = e->origin; vectoangles(e->axis[0], parentAngles); - } - else if (p->cgd.flags & T_SWARM) { + } else if (p->cgd.flags & T_SWARM) { p->cgd.parentOrigin = p->cgd.velocity + p->cgd.accel * ftime * scale; } @@ -633,9 +661,7 @@ qboolean ClientGameCommandManager::TempModelPhysics(ctempmodel_t *p, float ftime p->cgd.velocity.x = Q_clamp_float(p->cgd.velocity.x, p->cgd.minVel.x, p->cgd.maxVel.x); p->cgd.velocity.y = Q_clamp_float(p->cgd.velocity.y, p->cgd.minVel.y, p->cgd.maxVel.y); p->cgd.velocity.z = Q_clamp_float(p->cgd.velocity.z, p->cgd.minVel.z, p->cgd.maxVel.z); - } - - if (p->cgd.flags2 & T2_CLAMP_VEL_AXIS) { + } else if (p->cgd.flags2 & T2_CLAMP_VEL_AXIS) { Vector localVelocity; localVelocity.x = DotProduct(p->cgd.velocity, p->ent.axis[0]); localVelocity.y = DotProduct(p->cgd.velocity, p->ent.axis[1]); @@ -650,8 +676,48 @@ qboolean ClientGameCommandManager::TempModelPhysics(ctempmodel_t *p, float ftime p->cgd.velocity.z = DotProduct(localVelocity, p->ent.axis[2]); } - if (p->cgd.flags2 & T_ALIGN) { - // FIXME: vss wind + if (p->cgd.flags2 & T2_WIND_AFFECT) { + for (i = 0; i < 3; i++) { + float fWind; + + switch (i) { + case 0: + fWind = vss_wind_x->value; + break; + case 1: + fWind = vss_wind_y->value; + break; + case 2: + fWind = vss_wind_z->value; + break; + } + + if (fWind < 0) { + if (p->cgd.velocity[i] > fWind) { + p->cgd.velocity[i] -= ftime * vss_wind_strength->value; + if (p->cgd.velocity[i] > fWind) { + p->cgd.velocity[i] = fWind; + } + } else if (p->cgd.velocity[i] < fWind) { + p->cgd.velocity[i] += ftime * vss_movement_dampen->value; + if (p->cgd.velocity[i] < fWind) { + p->cgd.velocity[i] = fWind; + } + } + } else { + if (p->cgd.velocity[i] < fWind) { + p->cgd.velocity[i] += ftime * vss_wind_strength->value; + if (p->cgd.velocity[i] > fWind) { + p->cgd.velocity[i] = fWind; + } + } else if (p->cgd.velocity[i] > fWind) { + p->cgd.velocity[i] -= ftime * vss_wind_strength->value; + if (p->cgd.velocity[i] < fWind) { + p->cgd.velocity[i] = fWind; + } + } + } + } } } else { Vector normal; @@ -829,10 +895,11 @@ void ClientGameCommandManager::AddTempModels(void) refEntity_t *old_ent; // To counteract cg.time going backwards - if (lastTempModelFrameTime && ((cg.time < lastTempModelFrameTime) || (cg.time - lastTempModelFrameTime > TOO_MUCH_TIME_PASSED))) { + if (lastTempModelFrameTime + && ((cg.time < lastTempModelFrameTime) || (cg.time - lastTempModelFrameTime > TOO_MUCH_TIME_PASSED))) { p = m_active_tempmodels.prev; for (; p != &m_active_tempmodels; p = next) { - next = p->prev; + next = p->prev; p->lastPhysicsTime = cg.time; } lastTempModelFrameTime = cg.time; @@ -913,7 +980,12 @@ void ClientGameCommandManager::AddTempModels(void) // time of this tempmodel lerpfrac = (float)(cg.time - p->lastPhysicsTime) / (float)physics_rate; // Clamp - lerpfrac = Q_clamp_float(lerpfrac, 0, 1); + if (lerpfrac > 1 || (p->cgd.flags2 & T2_PHYSICS_EVERYFRAME)) { + lerpfrac = 1; + } + if (lerpfrac < 0) { + lerpfrac = 0; + } // Increment the time this tempmodel has been alive p->aliveTime += frameTime; @@ -927,7 +999,7 @@ void ClientGameCommandManager::AddTempModels(void) // Run physics if the lastEnt is not valid to get a valid lerp if (!p->lastEntValid) { float t; - t = physics_rate / 1000.0f; + t = physics_rate / 1000.0f; ret = TempModelPhysics(p, t, scale); if (!ret) { @@ -1113,7 +1185,7 @@ void ClientGameCommandManager::SpawnTempModel(int mcount) if (m_spawnthing->cgd.flags & T_WAVE) { p->m_spawnthing = m_spawnthing; m_spawnthing->numtempmodels++; - start = Vector(0, 0, 0); + start = Vector(0, 0, 0); } else { p->m_spawnthing = NULL; start = m_spawnthing->cgd.origin; @@ -1137,7 +1209,13 @@ void ClientGameCommandManager::SpawnTempModel(int mcount) { Vector dst; // Create a circular shaped burst around the up vector - float angle = ((float)count / (float)m_spawnthing->count) * 360; // * M_PI * 2; + float angle; + + if (mcount == 1) { + angle = random() * 360; + } else { + angle = ((float)count / (float)m_spawnthing->count) * 360; // * M_PI * 2; + } Vector end = Vector(vLeft) * m_spawnthing->sphereRadius * current_entity_scale; RotatePointAroundVector(dst, Vector(vForward), end, angle); @@ -1146,7 +1224,7 @@ void ClientGameCommandManager::SpawnTempModel(int mcount) newForward = p->cgd.origin - m_spawnthing->cgd.origin; newForward.normalize(); } - } else if (m_spawnthing->cgd.flags & T_SPHERE) { + } else if (m_spawnthing->cgd.flags & T_INWARDSPHERE) { // Project the origin along a random ray, and set the forward // vector pointing back to the origin Vector dir, end; @@ -1390,7 +1468,7 @@ void ClientGameCommandManager::SpawnTempModel(int mcount) p->cgd.avelocity[i] = m_spawnthing->avelocity_amplitude[i] * random() + m_spawnthing->avelocity_base[i]; // Randomize angles or set absolute - p->cgd.angles[i] += random() * m_spawnthing->angles_amplitude[i]; + p->cgd.angles[i] = m_spawnthing->angles_amplitude[i] * random() + m_spawnthing->cgd.angles[i]; } // If forward velocity is set, just use that otherwise use random @@ -1424,18 +1502,15 @@ void ClientGameCommandManager::SpawnTempModel(int mcount) } } - // Calculate one tick of velocity based on time alive ( passed in ) - p->cgd.origin = p->cgd.origin + (p->cgd.velocity * ((float)p->aliveTime / 1000.0f) * current_entity_scale); - - if (p->cgd.flags2 & T2_ACCEL) { + if (m_spawnthing->cgd.flags2 & T2_RADIALVELOCITY) { float fLength; p->cgd.velocity = p->cgd.origin - start; fLength = p->cgd.velocity.length(); if (fLength) { - float fVel = m_spawnthing->cgd.velocity.x - + (m_spawnthing->cgd.velocity.y + m_spawnthing->cgd.velocity.z * crandom()) / fLength; + float fVel = m_spawnthing->cgd.velocity[0] + + (m_spawnthing->cgd.velocity[1] + m_spawnthing->cgd.velocity[2] * random()) / fLength; p->cgd.velocity *= fVel; } @@ -1446,20 +1521,22 @@ void ClientGameCommandManager::SpawnTempModel(int mcount) (m_spawnthing->randvel_base[i] + m_spawnthing->randvel_amplitude[i] * random()) * current_entity_scale; if (m_spawnthing->cgd.flags & T_RANDVELAXIS) { - p->cgd.velocity += fVel * Vector(m_spawnthing->tag_axis[i]); + if (p->cgd.flags2 & T2_NOTAGAXIS) { + p->cgd.velocity += fVel * Vector(m_spawnthing->axis[i]); + } else { + p->cgd.velocity += fVel * Vector(m_spawnthing->tag_axis[i]); + } } else { p->cgd.velocity[i] += fVel; } } if (p->cgd.flags & (T_ALIGN | T_DETAIL)) { - if (p->cgd.velocity.x && p->cgd.velocity.y) { - p->cgd.angles = p->cgd.velocity.toAngles(); - } - - p->cgd.origin += p->cgd.velocity * (p->aliveTime / 1000.0) * current_entity_scale; + p->cgd.angles = p->cgd.velocity.toAngles(); } + p->cgd.origin += p->cgd.velocity * (p->aliveTime / 1000.0) * current_entity_scale; + if (p->cgd.flags & T_AUTOCALCLIFE) { Vector end, delta; float length, speed; diff --git a/code/cgame/cg_testemitter.cpp b/code/cgame/cg_testemitter.cpp index 3fc360fe..760cd55f 100644 --- a/code/cgame/cg_testemitter.cpp +++ b/code/cgame/cg_testemitter.cpp @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2023-2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -26,6 +26,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "cg_commands.h" #include "cg_specialfx.h" +typedef enum te_mode_e { + TE_MODE_EMITTER, + TE_MODE_MODEL_ANIM, + TE_MODE_MODEL_INIT, + TE_MODE_SFX, +} te_mode_t; + cvar_t *cg_te_alpha; cvar_t *cg_te_dietouch; cvar_t *cg_te_bouncefactor; @@ -101,6 +108,7 @@ cvar_t *cg_te_radial_scale; cvar_t *cg_te_radial_min; cvar_t *cg_te_radial_max; cvar_t *cg_te_friction; +cvar_t *cg_te_spin; // Added in 2.0 cvar_t *cg_te_varycolor; cvar_t *cg_te_spritegridlighting; cvar_t *cg_te_cone_height; @@ -113,18 +121,22 @@ cvar_t *cg_te_tag; cvar_t *cg_te_xangles; cvar_t *cg_te_yangles; cvar_t *cg_te_zangles; -class specialeffect_t; -refEntity_t te_refEnt; -cvar_t *cg_te_emittermodel; -cvar_t *cg_te_mode; -cvar_t *cg_te_mode_name; -cvar_t *cg_te_currCommand; -cvar_t *cg_te_numCommands; -float te_vEmitterOrigin[3]; -int te_iNumCommands; -int te_iCurrCommand; +cvar_t *cg_te_emittermodel; +cvar_t *cg_te_mode; +cvar_t *cg_te_mode_name; +cvar_t *cg_te_currCommand; +cvar_t *cg_te_numCommands; + +refEntity_t te_refEnt; +float te_vEmitterOrigin[3]; +int te_iNumCommands; +int te_iCurrCommand; + specialeffect_t *pTesteffect; +specialeffectcommand_t *pCurrCommand; +spawnthing_t *pCurrSpawnthing; + #define MAX_TESTEMITTERS_SAVE 32 str cg_te_alphaG[MAX_TESTEMITTERS_SAVE]; @@ -202,6 +214,7 @@ str cg_te_radial_scaleG[MAX_TESTEMITTERS_SAVE]; str cg_te_radial_minG[MAX_TESTEMITTERS_SAVE]; str cg_te_radial_maxG[MAX_TESTEMITTERS_SAVE]; str cg_te_frictionG[MAX_TESTEMITTERS_SAVE]; +str cg_te_spinG[MAX_TESTEMITTERS_SAVE]; // Added in 2.0 str cg_te_varycolorG[MAX_TESTEMITTERS_SAVE]; str cg_te_spritegridlightingG[MAX_TESTEMITTERS_SAVE]; str cg_te_spawnrange_aG[MAX_TESTEMITTERS_SAVE]; @@ -291,6 +304,7 @@ void CG_SaveEffectCommandCvars(int iCommand) cg_te_radial_minG[iCommand] = cg_te_radial_min->string; cg_te_radial_maxG[iCommand] = cg_te_radial_max->string; cg_te_frictionG[iCommand] = cg_te_friction->string; + cg_te_spinG[iCommand] = cg_te_spin->string; // Added in 2.0 cg_te_varycolorG[iCommand] = cg_te_varycolor->string; cg_te_spritegridlightingG[iCommand] = cg_te_spritegridlighting->string; cg_te_spawnrange_aG[iCommand] = cg_te_spawnrange_a->string; @@ -302,77 +316,1674 @@ void CG_SaveEffectCommandCvars(int iCommand) cg_te_tagG[iCommand] = cg_te_tag->string; } +void CG_GetEffectCommandCvars(int iCommand) +{ + cgi.Cvar_Set("cg_te_alpha", cg_te_alphaG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_dietouch", cg_te_dietouchG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_bouncefactor", cg_te_bouncefactorG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_scale", cg_te_scaleG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_scalemin", cg_te_scaleminG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_scalemax", cg_te_scalemaxG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_model", cg_te_modelG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_life", cg_te_lifeG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_color_r", cg_te_color_rG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_color_g", cg_te_color_gG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_color_b", cg_te_color_bG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_accel_x", cg_te_accel_xG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_accel_y", cg_te_accel_yG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_accel_z", cg_te_accel_zG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_count", cg_te_countG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_fade", cg_te_fadeG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_fadedelay", cg_te_fadedelayG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_fadein", cg_te_fadeinG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_spawnrate", cg_te_spawnrateG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_offsbase_x", cg_te_offsbase_xG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_offsbase_y", cg_te_offsbase_yG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_offsbase_z", cg_te_offsbase_zG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_offsamp_x", cg_te_offsamp_xG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_offsamp_y", cg_te_offsamp_yG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_offsamp_z", cg_te_offsamp_zG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_scalerate", cg_te_scalerateG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_circle", cg_te_circleG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_sphere", cg_te_sphereG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_insphere", cg_te_insphereG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_radius", cg_te_radiusG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_align", cg_te_alignG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_flickeralpha", cg_te_flickeralphaG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_collision", cg_te_collisionG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_randomroll", cg_te_randomrollG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_anglesbase_p", cg_te_anglesbase_pG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_anglesbase_y", cg_te_anglesbase_yG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_anglesbase_r", cg_te_anglesbase_rG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_anglesamp_p", cg_te_anglesamp_pG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_anglesamp_y", cg_te_anglesamp_yG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_anglesamp_r", cg_te_anglesamp_rG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_forwardvel", cg_te_forwardvelG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_randvelbase_x", cg_te_randvelbase_xG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_randvelbase_y", cg_te_randvelbase_yG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_randvelbase_z", cg_te_randvelbase_zG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_randvelamp_x", cg_te_randvelamp_xG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_randvelamp_y", cg_te_randvelamp_yG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_randvelamp_z", cg_te_randvelamp_zG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_clampvelmin_x", cg_te_clampvelmin_xG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_clampvelmax_x", cg_te_clampvelmax_xG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_clampvelmin_y", cg_te_clampvelmin_yG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_clampvelmax_y", cg_te_clampvelmax_yG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_clampvelmin_z", cg_te_clampvelmin_zG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_clampvelmax_z", cg_te_clampvelmax_zG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_clampvelaxis", cg_te_clampvelaxisG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_volumetric", cg_te_volumetricG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_randaxis", cg_te_randaxisG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_axisoffsbase_x", cg_te_axisoffsbase_xG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_axisoffsbase_y", cg_te_axisoffsbase_yG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_axisoffsbase_z", cg_te_axisoffsbase_zG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_axisoffsamp_x", cg_te_axisoffsamp_xG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_axisoffsamp_y", cg_te_axisoffsamp_yG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_axisoffsamp_z", cg_te_axisoffsamp_zG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_swarm_freq", cg_te_swarm_freqG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_swarm_maxspeed", cg_te_swarm_maxspeedG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_swarm_delta", cg_te_swarm_deltaG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_avelbase_p", cg_te_avelbase_pG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_avelbase_y", cg_te_avelbase_yG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_avelbase_r", cg_te_avelbase_rG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_avelamp_p", cg_te_avelamp_pG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_avelamp_y", cg_te_avelamp_yG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_avelamp_r", cg_te_avelamp_rG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_radial_scale", cg_te_radial_scaleG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_radial_min", cg_te_radial_minG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_radial_max", cg_te_radial_maxG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_friction", cg_te_frictionG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_spin", cg_te_spinG[iCommand].c_str()); // Added in 2.0 + cgi.Cvar_Set("cg_te_varycolor", cg_te_varycolorG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_spritegridlighting", cg_te_spritegridlightingG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_spawnrange_a", cg_te_spawnrange_aG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_spawnrnage_b", cg_te_spawnrange_bG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_cone_height", cg_te_cone_heightG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_alignstretch_scale", cg_te_alignstretch_scaleG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_command_time", cg_te_command_timeG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_singlelinecommand", cg_te_singlelinecommandG[iCommand].c_str()); + cgi.Cvar_Set("cg_te_tag", cg_te_tagG[iCommand].c_str()); +} + void CG_ResetEffectCommandCvars() { - // FIXME: unimplemented + cgi.Cvar_Set("cg_te_alpha", "1"); + cgi.Cvar_Set("cg_te_dietouch", "0"); + cgi.Cvar_Set("cg_te_bouncefactor", "0.3"); + cgi.Cvar_Set("cg_te_scale", "1"); + cgi.Cvar_Set("cg_te_scalemin", "0"); + cgi.Cvar_Set("cg_te_scalemax", "0"); + cgi.Cvar_Set("cg_te_model", "none"); + cgi.Cvar_Set("cg_te_life", "1"); + cgi.Cvar_Set("cg_te_color_r", "1"); + cgi.Cvar_Set("cg_te_color_g", "1"); + cgi.Cvar_Set("cg_te_color_b", "1"); + cgi.Cvar_Set("cg_te_accel_x", "0"); + cgi.Cvar_Set("cg_te_accel_y", "0"); + cgi.Cvar_Set("cg_te_accel_z", "0"); + cgi.Cvar_Set("cg_te_count", "1"); + cgi.Cvar_Set("cg_te_fade", "0"); + cgi.Cvar_Set("cg_te_fadedelay", "0"); + cgi.Cvar_Set("cg_te_fadein", "0"); + cgi.Cvar_Set("cg_te_spawnrate", "1"); + cgi.Cvar_Set("cg_te_offsbase_x", "0"); + cgi.Cvar_Set("cg_te_offsbase_y", "0"); + cgi.Cvar_Set("cg_te_offsbase_z", "0"); + cgi.Cvar_Set("cg_te_offsamp_x", "0"); + cgi.Cvar_Set("cg_te_offsamp_y", "0"); + cgi.Cvar_Set("cg_te_offsamp_z", "0"); + cgi.Cvar_Set("cg_te_scalerate", "0"); + cgi.Cvar_Set("cg_te_circle", "0"); + cgi.Cvar_Set("cg_te_sphere", "0"); + cgi.Cvar_Set("cg_te_insphere", "0"); + cgi.Cvar_Set("cg_te_radius", "0"); + cgi.Cvar_Set("cg_te_align", "0"); + cgi.Cvar_Set("cg_te_flickeralpha", "0"); + cgi.Cvar_Set("cg_te_collision", "0"); + cgi.Cvar_Set("cg_te_randomroll", "0"); + cgi.Cvar_Set("cg_te_anglesbase_p", "0"); + cgi.Cvar_Set("cg_te_anglesbase_y", "0"); + cgi.Cvar_Set("cg_te_anglesbase_r", "0"); + cgi.Cvar_Set("cg_te_anglesamp_p", "0"); + cgi.Cvar_Set("cg_te_anglesamp_y", "0"); + cgi.Cvar_Set("cg_te_anglesamp_r", "0"); + cgi.Cvar_Set("cg_te_forwardvel", "0"); + cgi.Cvar_Set("cg_te_randvelbase_x", "0"); + cgi.Cvar_Set("cg_te_randvelbase_y", "0"); + cgi.Cvar_Set("cg_te_randvelbase_z", "0"); + cgi.Cvar_Set("cg_te_randvelamp_x", "0"); + cgi.Cvar_Set("cg_te_randvelamp_y", "0"); + cgi.Cvar_Set("cg_te_randvelamp_z", "0"); + cgi.Cvar_Set("cg_te_clampvelmin_x", "-9999"); + cgi.Cvar_Set("cg_te_clampvelmax_x", "9999"); + cgi.Cvar_Set("cg_te_clampvelmin_y", "-9999"); + cgi.Cvar_Set("cg_te_clampvelmax_y", "9999"); + cgi.Cvar_Set("cg_te_clampvelmin_z", "-9999"); + cgi.Cvar_Set("cg_te_clampvelmax_z", "9999"); + cgi.Cvar_Set("cg_te_clampvelaxis", "0"); + cgi.Cvar_Set("cg_te_volumetric", "0"); + cgi.Cvar_Set("cg_te_randaxis", "0"); + cgi.Cvar_Set("cg_te_axisoffsbase_x", "0"); + cgi.Cvar_Set("cg_te_axisoffsbase_y", "0"); + cgi.Cvar_Set("cg_te_axisoffsbase_z", "0"); + cgi.Cvar_Set("cg_te_axisoffsamp_x", "0"); + cgi.Cvar_Set("cg_te_axisoffsamp_y", "0"); + cgi.Cvar_Set("cg_te_axisoffsamp_z", "0"); + cgi.Cvar_Set("cg_te_swarm_freq", "0"); + cgi.Cvar_Set("cg_te_swarm_maxspeed", "0"); + cgi.Cvar_Set("cg_te_swarm_delta", "0"); + cgi.Cvar_Set("cg_te_avelbase_p", "0"); + cgi.Cvar_Set("cg_te_avelbase_y", "0"); + cgi.Cvar_Set("cg_te_avelbase_r", "0"); + cgi.Cvar_Set("cg_te_avelamp_p", "0"); + cgi.Cvar_Set("cg_te_avelamp_y", "0"); + cgi.Cvar_Set("cg_te_avelamp_r", "0"); + cgi.Cvar_Set("cg_te_radial_scale", "0"); + cgi.Cvar_Set("cg_te_radial_min", "0"); + cgi.Cvar_Set("cg_te_radial_max", "0"); + cgi.Cvar_Set("cg_te_friction", "0"); + cgi.Cvar_Set("cg_te_spin", "0"); // Added in 2.0 + cgi.Cvar_Set("cg_te_varycolor", "0"); + cgi.Cvar_Set("cg_te_spritegridlighting", "0"); + cgi.Cvar_Set("cg_te_spawnrange_a", "0"); + cgi.Cvar_Set("cg_te_spawnrange_b", "0"); + cgi.Cvar_Set("cg_te_cone_height", "0"); + cgi.Cvar_Set("cg_te_alignstretch_scale", "0"); + cgi.Cvar_Set("cg_te_command_time", "0"); + cgi.Cvar_Set("cg_te_singlelinecommand", ""); + cgi.Cvar_Set("cg_te_tag", ""); } void CG_SetTestEmitterValues() { - // FIXME: unimplemented + int i; + int iTagNum; + vec3_t vAngles; + vec3_t vOrigin; + vec3_t axis[3]; + + pCurrSpawnthing->cgd.flags2 |= T2_ACCEL | T2_AMOVE | T2_MOVE; + + if (te_refEnt.scale > 0 && Q_stricmp(cg_te_tag->string, "") && cg_te_mode->integer != TE_MODE_SFX) { + iTagNum = cgi.Tag_NumForName(te_refEnt.tiki, cg_te_tag->string); + } else { + iTagNum = -1; + } + + VectorCopy(te_vEmitterOrigin, vOrigin); + + if (iTagNum != -1) { + orientation_t oTag; + + oTag = cgi.TIKI_Orientation(&te_refEnt, iTagNum); + for (i = 0; i < 3; ++i) { + VectorMA(vOrigin, oTag.origin[i], te_refEnt.axis[i], vOrigin); + } + + R_ConcatRotations(oTag.axis, te_refEnt.axis, axis); + } else { + vAngles[0] = cg_te_xangles->value; + vAngles[1] = cg_te_yangles->value; + vAngles[2] = cg_te_zangles->value; + AnglesToAxis(vAngles, axis); + } + + VectorCopy(vOrigin, pCurrSpawnthing->cgd.origin); + pCurrSpawnthing->SetModel(cg_te_model->string); + + AxisCopy(axis, pCurrSpawnthing->axis); + + pCurrSpawnthing->cgd.alpha = cg_te_alpha->value; + pCurrSpawnthing->cgd.color[3] = cg_te_alpha->value; + pCurrSpawnthing->cgd.bouncefactor = cg_te_bouncefactor->value; + pCurrSpawnthing->cgd.scale = cg_te_scale->value; + pCurrSpawnthing->cgd.life = cg_te_life->value * 1000.0; + pCurrSpawnthing->cgd.color[0] = cg_te_color_r->value; + pCurrSpawnthing->cgd.color[1] = cg_te_color_g->value; + pCurrSpawnthing->cgd.color[2] = cg_te_color_b->value; + + if (cg_te_varycolor->integer) { + pCurrSpawnthing->cgd.flags2 |= T2_VARYCOLOR; + } else { + pCurrSpawnthing->cgd.flags2 &= ~T2_VARYCOLOR; + } + + if (cg_te_spritegridlighting->integer) { + pCurrSpawnthing->cgd.flags2 |= T2_SPRITEGRIDLIGHTING; + } else { + pCurrSpawnthing->cgd.flags2 &= ~T2_SPRITEGRIDLIGHTING; + } + + pCurrSpawnthing->cgd.accel[0] = cg_te_accel_x->value; + pCurrSpawnthing->cgd.accel[1] = cg_te_accel_y->value; + pCurrSpawnthing->cgd.accel[2] = cg_te_accel_z->value; + + pCurrSpawnthing->count = cg_te_count->value; + pCurrSpawnthing->spawnRate = 1.0 / cg_te_spawnrate->value * 1000.0; + + if (cg_te_spawnrange_a->value || cg_te_spawnrange_b->value) { + vAngles[0] = Square(cg_te_spawnrange_a->value); + vAngles[1] = Square(cg_te_spawnrange_b->value); + + if (vAngles[0] > vAngles[1]) { + pCurrSpawnthing->fMaxRangeSquared = vAngles[0]; + pCurrSpawnthing->fMinRangeSquared = vAngles[1]; + } else { + pCurrSpawnthing->fMinRangeSquared = vAngles[0]; + pCurrSpawnthing->fMaxRangeSquared = vAngles[2]; + } + } else { + pCurrSpawnthing->fMinRangeSquared = 0.0; + pCurrSpawnthing->fMaxRangeSquared = 9.9999997e37f; + } + + pCurrSpawnthing->cgd.scaleRate = cg_te_scalerate->value; + pCurrSpawnthing->sphereRadius = cg_te_radius->value; + + if (cg_te_cone_height->value) { + pCurrSpawnthing->cgd.flags2 |= T2_CONE; + pCurrSpawnthing->coneHeight = cg_te_cone_height->value; + } else { + pCurrSpawnthing->cgd.flags2 &= ~T2_CONE; + } + + pCurrSpawnthing->forwardVelocity = cg_te_forwardvel->value; + if (cg_te_friction->value) { + pCurrSpawnthing->cgd.flags2 |= T2_FRICTION; + } else { + pCurrSpawnthing->cgd.flags2 &= ~T2_FRICTION; + } + + // + // Added in 2.0 + // + if (cg_te_spin->value) { + pCurrSpawnthing->cgd.flags2 |= T2_SPIN; + } else { + pCurrSpawnthing->cgd.flags2 &= ~T2_SPIN; + } + + pCurrSpawnthing->origin_offset_base[0] = cg_te_offsbase_x->value; + pCurrSpawnthing->origin_offset_base[1] = cg_te_offsbase_y->value; + pCurrSpawnthing->origin_offset_base[2] = cg_te_offsbase_z->value; + pCurrSpawnthing->origin_offset_amplitude[0] = cg_te_offsamp_x->value; + pCurrSpawnthing->origin_offset_amplitude[1] = cg_te_offsamp_y->value; + pCurrSpawnthing->origin_offset_amplitude[2] = cg_te_offsamp_z->value; + + pCurrSpawnthing->axis_offset_base[0] = cg_te_axisoffsbase_x->value; + pCurrSpawnthing->axis_offset_base[1] = cg_te_axisoffsbase_y->value; + pCurrSpawnthing->axis_offset_base[2] = cg_te_axisoffsbase_z->value; + pCurrSpawnthing->axis_offset_amplitude[0] = cg_te_axisoffsamp_x->value; + pCurrSpawnthing->axis_offset_amplitude[1] = cg_te_axisoffsamp_y->value; + pCurrSpawnthing->axis_offset_amplitude[2] = cg_te_axisoffsamp_z->value; + + pCurrSpawnthing->cgd.angles[0] = cg_te_anglesbase_p->value; + pCurrSpawnthing->cgd.angles[1] = cg_te_anglesbase_y->value; + pCurrSpawnthing->cgd.angles[2] = cg_te_anglesbase_r->value; + pCurrSpawnthing->angles_amplitude[0] = cg_te_anglesamp_p->value; + pCurrSpawnthing->angles_amplitude[1] = cg_te_anglesamp_y->value; + pCurrSpawnthing->angles_amplitude[2] = cg_te_anglesamp_r->value; + + if (!VectorCompare(pCurrSpawnthing->cgd.angles, vec_zero) + || !VectorCompare(pCurrSpawnthing->angles_amplitude, vec_zero)) { + pCurrSpawnthing->cgd.flags |= T_ANGLES; + } else { + pCurrSpawnthing->cgd.flags &= ~T_ANGLES; + } + + pCurrSpawnthing->avelocity_base[0] = cg_te_avelbase_p->value; + pCurrSpawnthing->avelocity_base[1] = cg_te_avelbase_y->value; + pCurrSpawnthing->avelocity_base[2] = cg_te_avelbase_r->value; + pCurrSpawnthing->avelocity_amplitude[0] = cg_te_avelamp_p->value; + pCurrSpawnthing->avelocity_amplitude[1] = cg_te_avelamp_y->value; + pCurrSpawnthing->avelocity_amplitude[2] = cg_te_avelamp_r->value; + + pCurrSpawnthing->randvel_base[0] = cg_te_randvelbase_x->value; + pCurrSpawnthing->randvel_base[1] = cg_te_randvelbase_y->value; + pCurrSpawnthing->randvel_base[2] = cg_te_randvelbase_z->value; + pCurrSpawnthing->randvel_amplitude[0] = cg_te_randvelamp_x->value; + pCurrSpawnthing->randvel_amplitude[1] = cg_te_randvelamp_y->value; + pCurrSpawnthing->randvel_amplitude[2] = cg_te_randvelamp_z->value; + + if (cg_te_randaxis->integer) { + pCurrSpawnthing->cgd.flags |= T_RANDVELAXIS; + } else { + pCurrSpawnthing->cgd.flags &= ~T_RANDVELAXIS; + } + + if (cg_te_radial_scale->value || cg_te_radial_min->value || cg_te_radial_max->value) { + pCurrSpawnthing->cgd.velocity[0] = cg_te_radial_scale->value; + pCurrSpawnthing->cgd.velocity[1] = cg_te_radial_min->value; + pCurrSpawnthing->cgd.velocity[2] = cg_te_radial_max->value; + pCurrSpawnthing->cgd.velocity[2] -= pCurrSpawnthing->cgd.velocity[1]; + + pCurrSpawnthing->cgd.flags2 |= T2_RADIALVELOCITY; + } else { + pCurrSpawnthing->cgd.flags2 &= ~T2_RADIALVELOCITY; + } + + pCurrSpawnthing->cgd.minVel[0] = cg_te_clampvelmin_x->value; + pCurrSpawnthing->cgd.maxVel[0] = cg_te_clampvelmax_x->value; + pCurrSpawnthing->cgd.minVel[1] = cg_te_clampvelmin_y->value; + pCurrSpawnthing->cgd.maxVel[1] = cg_te_clampvelmax_y->value; + pCurrSpawnthing->cgd.minVel[2] = cg_te_clampvelmin_z->value; + pCurrSpawnthing->cgd.maxVel[2] = cg_te_clampvelmax_z->value; + pCurrSpawnthing->cgd.flags &= ~(T_GLOBALFADEIN | T_GLOBALFADEOUT); + + if (pCurrSpawnthing->cgd.minVel[0] > -9999 || pCurrSpawnthing->cgd.minVel[1] > -9999 + || pCurrSpawnthing->cgd.minVel[2] > -9999 || pCurrSpawnthing->cgd.maxVel[0] < 9999 + || pCurrSpawnthing->cgd.maxVel[1] < 9999 || pCurrSpawnthing->cgd.maxVel[2] < 9999) { + if (cg_te_clampvelaxis->value) { + pCurrSpawnthing->cgd.flags |= T_GLOBALFADEOUT; + } else { + pCurrSpawnthing->cgd.flags |= T_GLOBALFADEIN; + } + } + + pCurrSpawnthing->cgd.scalemin = cg_te_scalemin->value; + pCurrSpawnthing->cgd.scalemax = cg_te_scalemax->value; + if (pCurrSpawnthing->cgd.scalemin || pCurrSpawnthing->cgd.scalemax) { + pCurrSpawnthing->cgd.flags |= T_RANDSCALE; + } else { + pCurrSpawnthing->cgd.flags &= ~T_RANDSCALE; + } + + if (cg_te_dietouch->integer) { + pCurrSpawnthing->cgd.flags |= T_DIETOUCH; + } else { + pCurrSpawnthing->cgd.flags &= ~T_DIETOUCH; + } + + if (cg_te_fade->integer) { + pCurrSpawnthing->cgd.flags |= T_FADE; + } else { + pCurrSpawnthing->cgd.flags &= ~T_FADE; + } + + if (cg_te_fadedelay->integer > 0) { + pCurrSpawnthing->cgd.flags |= T_FADE; + pCurrSpawnthing->cgd.fadedelay = cg_te_fadedelay->value * 1000.0; + } + + if (cg_te_fadein->integer > 0) { + pCurrSpawnthing->cgd.flags |= T_FADEIN; + pCurrSpawnthing->cgd.fadeintime = cg_te_fadein->value * 1000.0; + } else { + pCurrSpawnthing->cgd.flags &= ~T_FADEIN; + } + + if (cg_te_circle->integer) { + pCurrSpawnthing->cgd.flags |= T_CIRCLE; + } else { + pCurrSpawnthing->cgd.flags &= ~T_CIRCLE; + } + + if (cg_te_sphere->integer) { + pCurrSpawnthing->cgd.flags |= T_SPHERE; + } else { + pCurrSpawnthing->cgd.flags &= ~T_SPHERE; + } + + if (cg_te_insphere->integer) { + pCurrSpawnthing->cgd.flags |= T_INWARDSPHERE; + } else { + pCurrSpawnthing->cgd.flags &= ~T_INWARDSPHERE; + } + + if (cg_te_align->integer) { + pCurrSpawnthing->cgd.flags |= T_ALIGN; + } else { + pCurrSpawnthing->cgd.flags &= ~T_ALIGN; + } + + if (cg_te_alignstretch_scale->integer) { + pCurrSpawnthing->cgd.flags |= T_ALIGN; + pCurrSpawnthing->cgd.flags2 |= T2_ALIGNSTRETCH; + pCurrSpawnthing->cgd.scale2 = cg_te_alignstretch_scale->value; + } else { + pCurrSpawnthing->cgd.flags2 &= ~T2_ALIGNSTRETCH; + } + + if (cg_te_flickeralpha->integer) { + pCurrSpawnthing->cgd.flags |= T_FLICKERALPHA; + } else { + pCurrSpawnthing->cgd.flags &= ~T_FLICKERALPHA; + } + + if (cg_te_randomroll->integer) { + pCurrSpawnthing->cgd.flags |= T_RANDOMROLL; + } else { + pCurrSpawnthing->cgd.flags &= ~T_RANDOMROLL; + } + + if (cg_te_volumetric->integer) { + pCurrSpawnthing->cgd.flags2 |= T2_VOLUMETRIC; + } else { + pCurrSpawnthing->cgd.flags2 &= ~T2_VOLUMETRIC; + } + + if (cg_te_collision->integer == 2) { + pCurrSpawnthing->cgd.flags |= T_COLLISION; + pCurrSpawnthing->cgd.collisionmask = CONTENTS_TRIGGER | CONTENTS_FENCE | CONTENTS_WATER | CONTENTS_SOLID; + } else if (cg_te_collision->integer == 1 || (pCurrSpawnthing->cgd.flags & T_DIETOUCH)) { + pCurrSpawnthing->cgd.flags &= ~T_COLLISION; + pCurrSpawnthing->cgd.collisionmask = CONTENTS_TRIGGER | CONTENTS_FENCE | CONTENTS_SOLID; + } else { + pCurrSpawnthing->cgd.flags &= ~T_COLLISION; + pCurrSpawnthing->cgd.collisionmask = 0; + } + + if (cg_te_swarm_freq->integer > 0 && cg_te_swarm_maxspeed->value > 0 && cg_te_swarm_delta->value > 0) { + pCurrSpawnthing->cgd.swarmfreq = cg_te_swarm_freq->integer; + pCurrSpawnthing->cgd.swarmmaxspeed = cg_te_swarm_maxspeed->value; + pCurrSpawnthing->cgd.swarmdelta = cg_te_swarm_delta->value; + pCurrSpawnthing->cgd.flags |= T_SWARM; + pCurrSpawnthing->cgd.flags &= ~T_SPHERE; + } + + if (pCurrCommand) { + Event *pEvent; + int argcount; + + pCurrCommand->fCommandTime = cg_te_command_time->value; + pCurrCommand->endfcn = &ClientGameCommandManager::TestEffectEndFunc; + + if (pCurrCommand->pEvent) { + delete pCurrCommand->pEvent; + pCurrCommand->pEvent = NULL; + } + + if (Q_stricmp(cg_te_singlelinecommand->string, "")) { + cgi.Cmd_TokenizeString(cg_te_singlelinecommand->string); + + pEvent = new Event(cgi.Argv(0)); + + argcount = cgi.Argc(); + for (i = 1; i < argcount; i++) { + pEvent->AddToken(cgi.Argv(i)); + } + + pCurrCommand->pEvent = pEvent; + } + } } void CG_UpdateTestEmitter(void) { - // FIXME: unimplemented + int count; + Vector vAng; + Vector delta; + Vector end, end2; + Vector axis[3]; + emittertime_t *et = NULL; + + if (VectorCompare(te_vEmitterOrigin, vec_zero) || te_iNumCommands < 1) { + if (Q_stricmp(cg_te_mode_name->string, "Temp Emitter Off")) { + cgi.Cvar_Set("cg_te_mode_name", "Temp Emitter Off"); + } + return; + } + + cgi.Cvar_Set("cg_te_currCommand", va("%i", te_iCurrCommand + 1)); + cgi.Cvar_Set("cg_te_numCommands", va("%i", te_iNumCommands)); + + switch (cg_te_mode->integer) { + case TE_MODE_MODEL_ANIM: + cgi.Cvar_Set("cg_te_mode_name", "Model Anim Mode"); + break; + case TE_MODE_MODEL_INIT: + cgi.Cvar_Set("cg_te_mode_name", "Model Init Mode"); + break; + case TE_MODE_SFX: + cgi.Cvar_Set("cg_te_mode_name", "SFX Mode"); + break; + default: + cgi.Cvar_Set("cg_te_mode_name", "Emitter Mode"); + break; + } + + vAng[0] = cg_te_xangles->value; + vAng[1] = cg_te_yangles->value; + vAng[2] = cg_te_zangles->value; + AnglesToAxis(vAng, (vec3_t *)axis); + + end = te_vEmitterOrigin + axis[0] * 50; + cgi.R_DebugLine(te_vEmitterOrigin, end, 1.0, 0.0, 0.0, 1.0); + + end2 = end + axis[1] * 16 + axis[0] * -16; + cgi.R_DebugLine(end, end2, 1.0, 0.0, 0.0, 1.0); + + end2 = end + axis[1] * -16 + axis[0] * -16; + cgi.R_DebugLine(end, end2, 1.0, 0.0, 0.0, 1.0); + + if (cg_te_emittermodel->string[0]) { + // + // Initialize the entity + // + + memset(&te_refEnt, 0, sizeof(te_refEnt)); + te_refEnt.parentEntity = ENTITYNUM_NONE; + te_refEnt.scale = 1.0; + te_refEnt.shaderRGBA[0] = -1; + te_refEnt.shaderRGBA[1] = -1; + te_refEnt.shaderRGBA[2] = -1; + te_refEnt.shaderRGBA[3] = -1; + + // + // Setup transforms + // + + AxisCopy((const vec3_t *)axis, te_refEnt.axis); + VectorCopy(te_vEmitterOrigin, te_refEnt.origin); + VectorCopy(te_vEmitterOrigin, te_refEnt.lightingOrigin); + + // + // Setup the model + // + + te_refEnt.radius = 4.0; + te_refEnt.hModel = cgi.R_RegisterModel(cg_te_emittermodel->string); + te_refEnt.tiki = cgi.R_Model_GetHandle(te_refEnt.hModel); + + // + // Setup the shader + // + + if (!Q_stricmp(cg_te_emittermodel->string, "*beam")) { + te_refEnt.reType = RT_BEAM; + te_refEnt.customShader = cgi.R_RegisterShader("beamshader"); + } else if (strstr(cg_te_emittermodel->string, ".spr")) { + te_refEnt.reType = RT_SPRITE; + } else { + te_refEnt.reType = RT_MODEL; + } + + // + // Setup the animation + // + + te_refEnt.frameInfo[0].index = cgi.Anim_NumForName(te_refEnt.tiki, "idle"); + ; + if (te_refEnt.frameInfo[0].index < 0) { + te_refEnt.frameInfo[0].index = 0; + } + te_refEnt.frameInfo[0].weight = 1.0; + te_refEnt.frameInfo[0].time = 0.0; + te_refEnt.actionWeight = 1.0; + te_refEnt.entityNumber = ENTITYNUM_NONE; + + if (te_refEnt.reType == RT_SPRITE) { + cgi.R_AddRefSpriteToScene(&te_refEnt); + } else { + cgi.R_AddRefEntityToScene(&te_refEnt, ENTITYNUM_NONE); + } + } else { + te_refEnt.scale = 0.0; + } + + cg_te_currCommand = cgi.Cvar_Get("cg_te_currCommand", "0", 0); + cg_te_numCommands = cgi.Cvar_Get("cg_te_numCommands", "0", 0); + + if (cg_te_mode->integer != TE_MODE_EMITTER) { + return; + } + + pCurrCommand = pTesteffect->m_commands[te_iCurrCommand]; + if (!pCurrCommand) { + return; + } + + pCurrSpawnthing = pCurrCommand->emitter; + if (!pCurrSpawnthing) { + return; + } + + CG_SetTestEmitterValues(); + + et = pCurrSpawnthing->GetEmitTime(1); + if (!et->active) { + return; + } + + pCurrSpawnthing->cgd.createTime = cg.time; + + if (et->last_emit_time > 0 && pCurrSpawnthing->spawnRate != 0) { + float dtime; + float lerp; + float lerpfrac; + + dtime = cg.time - et->last_emit_time; + count = dtime / pCurrSpawnthing->spawnRate; + if (!count) { + return; + } + + if (count == 1) { + commandManager.SpawnEffect(1, pCurrSpawnthing); + et->last_emit_time = cg.time; + } else { + lerpfrac = 1.0 / count; + for (lerp = 0.0;; lerp = lerp + lerpfrac) { + if (dtime <= pCurrSpawnthing->spawnRate) { + break; + } + + et->last_emit_time = cg.time; + dtime = dtime - pCurrSpawnthing->spawnRate; + if (et->lerp_emitter) { + pCurrSpawnthing->cgd.origin = et->oldorigin + delta * lerp; + } + + commandManager.SpawnEffect(1, pCurrSpawnthing); + } + } + } else { + et->last_emit_time = cg.time; + } + + pCurrCommand = NULL; + pCurrSpawnthing = NULL; } void CG_SortEffectCommands() { - // FIXME: unimplemented + int j, k; + + for (j = 1; j < pTesteffect->m_iCommandCount; j++) { + for (k = 0; k < j; k++) { + if (pTesteffect->m_commands[k] > pTesteffect->m_commands[k + 1]) { + specialeffectcommand_t *command = pTesteffect->m_commands[k]; + + pTesteffect->m_commands[k] = pTesteffect->m_commands[k + 1]; + pTesteffect->m_commands[k + 1] = command; + } + } + } } void CG_TriggerTestEmitter_f(void) { - // FIXME: unimplemented + int i; + vec3_t axis[3]; + + if (!cg_te_mode->integer) { + return; + } + + if (!te_iNumCommands) { + return; + } + + CG_SaveEffectCommandCvars(te_iCurrCommand); + + for (i = 0; i < te_iNumCommands; ++i) { + pCurrCommand = pTesteffect->m_commands[i]; + if (!pCurrCommand) { + return; + } + + pCurrSpawnthing = pCurrCommand->emitter; + if (!pCurrSpawnthing) { + return; + } + + CG_GetEffectCommandCvars(i); + CG_SetTestEmitterValues(); + } + + CG_GetEffectCommandCvars(te_iCurrCommand); + CG_SortEffectCommands(); + + pCurrCommand = pTesteffect->m_commands[0]; + pCurrSpawnthing = pCurrCommand->emitter; + AxisCopy(pCurrSpawnthing->axis, axis); + + // Spawn the effect + sfxManager.MakeEffect_Axis(SFX_TEST_EFFECT, pCurrSpawnthing->cgd.origin, axis); + + pCurrCommand = NULL; + pCurrSpawnthing = NULL; } -void CG_DumpBaseAndAmplitude(str *buff, char *prefix, Vector *base, Vector *amplitude) +void CG_DumpBaseAndAmplitude(str *buff, const char *prefix, Vector *base, Vector *amplitude) { - // FIXME: unimplemented + int i; + + if ((*amplitude)[0] || (*amplitude)[1] || (*amplitude)[2]) { + *buff += prefix; + + for (i = 0; i < 3; i++) { + if (!(*amplitude)[i]) { + *buff += va(" %g", (*base)[i]); + } else if (!(*base)[i]) { + *buff += va(" random %g", (*amplitude)[i]); + } else if (-(*base)[i] == (*base)[i] + (*amplitude)[i]) { + *buff += va(" crandom %g", (*amplitude)[i] * 0.5); + } else { + *buff += va(" range %g %g", (*base)[i], (*amplitude)[i]); + } + } + + *buff += "\n"; + } else if ((*base)[0] || (*base)[1] || (*base)[2]) { + *buff += prefix; + *buff += va(" %g %g %g\n", (*base)[0], (*base)[1], (*base)[2]); + } } void CG_DumpEmitter_f(void) { - // FIXME: unimplemented + cvar_t *filename; + str buff; + str sTabbing; + str old_buff; + int iCurrCommand; + int iTagNum; + + if (te_iNumCommands < 1) { + return; + } + + filename = cgi.Cvar_Get("cg_te_filename", "dump/emitter.txt", 0); + switch (cg_te_mode->integer) { + case TE_MODE_MODEL_ANIM: + sTabbing = "\t\t\t"; + break; + case TE_MODE_MODEL_INIT: + sTabbing = "\t\t"; + break; + case TE_MODE_SFX: + sTabbing = "\t\t"; + break; + default: + sTabbing = "\t\t"; + break; + } + CG_SaveEffectCommandCvars(te_iCurrCommand); + + if (cg_te_mode->integer == TE_MODE_EMITTER) { + iCurrCommand = te_iCurrCommand; + } else { + iCurrCommand = 0; + } + + do { + pCurrCommand = pTesteffect->m_commands[iCurrCommand]; + if (!pCurrCommand) { + return; + } + + pCurrSpawnthing = pCurrCommand->emitter; + if (!pCurrSpawnthing) { + return; + } + + CG_GetEffectCommandCvars(iCurrCommand); + CG_SetTestEmitterValues(); + + if (te_refEnt.scale > 0 && Q_stricmp(cg_te_tag->string, "") && cg_te_mode->integer != TE_MODE_SFX) { + iTagNum = cgi.Tag_NumForName(te_refEnt.tiki, cg_te_tag->string); + } else { + iTagNum = -1; + } + + switch (cg_te_mode->integer) { + case TE_MODE_MODEL_ANIM: + buff += va("%s0", sTabbing.c_str()); + + if (pCurrCommand->fCommandTime > 0) { + buff += va("commanddelay %g ", pCurrCommand->fCommandTime); + } + + if (iTagNum != -1) { + buff += va("tagspawn %s\n", cg_te_tag->string); + } else { + buff += "originspawn\n"; + } + break; + case TE_MODE_MODEL_INIT: + buff += sTabbing; + + if (pCurrCommand->fCommandTime > 0) { + buff += va("commanddelay %g ", pCurrCommand->fCommandTime); + } + + if (iTagNum != -1) { + buff += va("tagspawn %s\n", cg_te_tag->string); + } else { + buff += "originspawn\n"; + } + break; + case TE_MODE_SFX: + buff += sTabbing; + + if (pCurrCommand->fCommandTime > 0) { + buff += va("delayedsfx %.3g originspawn\n", pCurrCommand->fCommandTime); + } else { + buff += "sfx originspawn\n"; + } + break; + default: + if (iTagNum != -1) { + buff += va("%stagemitter %s name%i\n", sTabbing.c_str(), cg_te_tag->string, iCurrCommand + 1); + } else { + buff += va("%soriginemitter name%i\n", sTabbing.c_str(), iCurrCommand + 1); + } + break; + } + + buff += sTabbing + "(\n"; + + if (pCurrSpawnthing->fMinRangeSquared > 0) { + buff += + va("%s\tspawnrange %i %i\n", + sTabbing.c_str(), + (int)sqrt(pCurrSpawnthing->fMinRangeSquared), + (int)sqrt(pCurrSpawnthing->fMaxRangeSquared)); + } else if (pCurrSpawnthing->fMaxRangeSquared > 0) { + buff += va("%s\tspawnrange %i\n", sTabbing.c_str(), (int)sqrt(pCurrSpawnthing->fMaxRangeSquared)); + } + + if (pCurrSpawnthing->cgd.flags2 & T2_VOLUMETRIC) { + buff += sTabbing + "\tvolumetric\n"; + } + + buff += va("%s\tspawnrate %g\n", sTabbing.c_str(), cg_te_spawnrate->value); + buff += va("%s\tmodel %s\n", sTabbing.c_str(), pCurrSpawnthing->m_modellist.ObjectAt(1).c_str()); + + if (!(pCurrSpawnthing->cgd.flags2 & T2_VOLUMETRIC) && pCurrSpawnthing->count > 1) { + buff += va("%s\tcount %i\n", sTabbing.c_str(), pCurrSpawnthing->count); + } + + if (pCurrSpawnthing->cgd.alpha != 1.0) { + buff += va("%s\talpha %g\n", sTabbing.c_str(), pCurrSpawnthing->cgd.alpha); + } + + buff += + va("%s\tcolor %g %g %g\n", + sTabbing.c_str(), + pCurrSpawnthing->cgd.color[0], + pCurrSpawnthing->cgd.color[1], + pCurrSpawnthing->cgd.color[2]); + + if (!(pCurrSpawnthing->cgd.flags2 & T2_VOLUMETRIC)) { + if (pCurrSpawnthing->cgd.flags2 & T2_VARYCOLOR) { + buff += sTabbing + "\tvarycolor\n"; + } + if (pCurrSpawnthing->cgd.flags2 & T2_SPRITEGRIDLIGHTING) { + buff += sTabbing + "\tspritegridlighting\n"; + } + } + + if (pCurrSpawnthing->cgd.flags & T_COLLISION) { + if (pCurrSpawnthing->cgd.collisionmask & CONTENTS_WATER) { + buff += sTabbing + "\tcollision water\n"; + } else { + buff += sTabbing + "\tcollision\n"; + } + } + + if (!(pCurrSpawnthing->cgd.flags2 & T2_VOLUMETRIC) && (pCurrSpawnthing->cgd.flags & T_COLLISION)) { + buff += va("%s\tbouncefactor %g\n", sTabbing.c_str(), pCurrSpawnthing->cgd.bouncefactor); + } + + if (pCurrSpawnthing->cgd.scale != 1.0) { + buff += va("%s\tscale %g\n", sTabbing.c_str(), pCurrSpawnthing->cgd.scale); + } + + buff += va("%s\tlife %g\n", sTabbing.c_str(), cg_te_life->value); + + if (!(pCurrSpawnthing->cgd.flags2 & T2_VOLUMETRIC) && pCurrSpawnthing->cgd.scaleRate) { + buff + va("%s\tscalerate %g\n", sTabbing.c_str(), pCurrSpawnthing->cgd.scaleRate); + } + + if (pCurrSpawnthing->sphereRadius) { + if (cg_te_cone_height->value) { + buff += + va("%s\tcone %g %g\n", sTabbing.c_str(), pCurrSpawnthing->coneHeight, pCurrSpawnthing->sphereRadius + ); + } else { + buff += va("%s\tradius %g\n", sTabbing.c_str(), pCurrSpawnthing->sphereRadius); + } + } + + if (pCurrSpawnthing->forwardVelocity) { + buff += va("%s\tvelocity %g\n", sTabbing.c_str(), pCurrSpawnthing->forwardVelocity); + } + + if (pCurrSpawnthing->cgd.flags2 & T2_RADIALVELOCITY) { + buff += + va("%s\tradialvelocity %g %g %g\n", + sTabbing.c_str(), + pCurrSpawnthing->cgd.velocity[0], + pCurrSpawnthing->cgd.velocity[1], + pCurrSpawnthing->cgd.velocity[2]); + } + + if (pCurrSpawnthing->cgd.flags & T_RANDVELAXIS) { + CG_DumpBaseAndAmplitude( + &buff, + va("%s\trandvelaxis", sTabbing.c_str()), + &pCurrSpawnthing->randvel_base, + &pCurrSpawnthing->randvel_amplitude + ); + } else { + CG_DumpBaseAndAmplitude( + &buff, + va("%s\trandvel", sTabbing.c_str()), + &pCurrSpawnthing->randvel_base, + &pCurrSpawnthing->randvel_amplitude + ); + } + + if (pCurrSpawnthing->cgd.flags2 & T2_CLAMP_VEL) { + buff += + va("%s\tclampvel %g %g %g %g %g %g\n", + sTabbing.c_str(), + pCurrSpawnthing->cgd.minVel[0], + pCurrSpawnthing->cgd.maxVel[0], + pCurrSpawnthing->cgd.minVel[1], + pCurrSpawnthing->cgd.maxVel[1], + pCurrSpawnthing->cgd.minVel[2], + pCurrSpawnthing->cgd.maxVel[2]); + } else if (pCurrSpawnthing->cgd.flags2 & T2_CLAMP_VEL_AXIS) { + buff += + va("%s\tclampvelaxis %g %g %g %g %g %g\n", + sTabbing.c_str(), + pCurrSpawnthing->cgd.minVel[0], + pCurrSpawnthing->cgd.maxVel[0], + pCurrSpawnthing->cgd.minVel[1], + pCurrSpawnthing->cgd.maxVel[1], + pCurrSpawnthing->cgd.minVel[2], + pCurrSpawnthing->cgd.maxVel[2]); + } + + if (pCurrSpawnthing->cgd.flags2 & T2_VOLUMETRIC) { + if (pCurrSpawnthing->cgd.accel[0] || pCurrSpawnthing->cgd.accel[1] || pCurrSpawnthing->cgd.accel[2]) { + buff += + va("%s\tsmokeparms %g %g %g\n", + sTabbing.c_str(), + pCurrSpawnthing->cgd.accel[0], + pCurrSpawnthing->cgd.accel[1], + pCurrSpawnthing->cgd.accel[2]); + } + } else { + if (pCurrSpawnthing->cgd.accel[0] || pCurrSpawnthing->cgd.accel[1] || pCurrSpawnthing->cgd.accel[2]) { + buff += + va("%s\taccel %g %g %g\n", + sTabbing.c_str(), + pCurrSpawnthing->cgd.accel[0], + pCurrSpawnthing->cgd.accel[1], + pCurrSpawnthing->cgd.accel[2]); + } + } + + if (pCurrSpawnthing->cgd.flags2 & T2_FRICTION) { + buff += va("%s\tfriction %g\n", sTabbing.c_str(), pCurrSpawnthing->cgd.friction); + } + + if (pCurrSpawnthing->cgd.flags2 & T2_SPIN) { + buff += va("%s\tfriction %g\n", sTabbing.c_str(), pCurrSpawnthing->cgd.spin_rotation); + } + + CG_DumpBaseAndAmplitude( + &buff, + va("%s\toffset", sTabbing.c_str()), + &pCurrSpawnthing->origin_offset_base, + &pCurrSpawnthing->origin_offset_amplitude + ); + CG_DumpBaseAndAmplitude( + &buff, + va("%s\toffsetalongaxis", sTabbing.c_str()), + &pCurrSpawnthing->axis_offset_base, + &pCurrSpawnthing->axis_offset_amplitude + ); + + if (!(pCurrSpawnthing->cgd.flags2 & T2_VOLUMETRIC) && (pCurrSpawnthing->cgd.flags & T_ANGLES)) { + CG_DumpBaseAndAmplitude( + &buff, + va("%s\tangles", sTabbing.c_str()), + &pCurrSpawnthing->cgd.angles, + &pCurrSpawnthing->angles_amplitude + ); + } + + if (pCurrSpawnthing->cgd.flags2 & T2_AMOVE) { + CG_DumpBaseAndAmplitude( + &buff, + va("%s\tavelocity", sTabbing.c_str()), + &pCurrSpawnthing->avelocity_base, + &pCurrSpawnthing->avelocity_amplitude + ); + } + + if (pCurrSpawnthing->cgd.scalemin) { + buff += va("%s\tscalemin %g\n", sTabbing.c_str(), pCurrSpawnthing->cgd.scalemin); + } + if (pCurrSpawnthing->cgd.scalemax) { + buff += va("%s\tscalemax %g\n", sTabbing.c_str(), pCurrSpawnthing->cgd.scalemax); + } + + if (pCurrSpawnthing->cgd.flags & T_DIETOUCH) { + buff += sTabbing + "\tdietouch\n"; + } + + if (!(pCurrSpawnthing->cgd.flags2 & T2_VOLUMETRIC)) { + if (pCurrSpawnthing->cgd.fadedelay > 0) { + buff += va("%s\tfadedelay %g\n", sTabbing.c_str(), pCurrSpawnthing->cgd.fadedelay / 1000.0); + } else if (pCurrSpawnthing->cgd.flags & T_FADE) { + buff += sTabbing + "\tfade\n"; + } + + if (pCurrSpawnthing->cgd.flags & T_FADEIN) { + buff += va("%s\tfadein %g\n", sTabbing.c_str(), pCurrSpawnthing->cgd.fadeintime / 1000.0); + } + } + + if (pCurrSpawnthing->cgd.flags & T_CIRCLE) { + buff += sTabbing + "\tcircle\n"; + } + if (pCurrSpawnthing->cgd.flags & T_SPHERE) { + buff += sTabbing + "\tsphere\n"; + } + if (pCurrSpawnthing->cgd.flags & T_INWARDSPHERE) { + buff += sTabbing + "\tinwardsphere\n"; + } + + if (!(pCurrSpawnthing->cgd.flags2 & T2_VOLUMETRIC)) { + if (pCurrSpawnthing->cgd.flags2 & T2_ALIGNSTRETCH) { + buff += va("%s\talignstretch %g", sTabbing.c_str(), pCurrSpawnthing->cgd.scale2); + } else if (pCurrSpawnthing->cgd.flags & T_ALIGN) { + buff += sTabbing + "\talign\n"; + } + + if (pCurrSpawnthing->cgd.flags & T_FLICKERALPHA) { + buff += sTabbing + "\tflickeralpha\n"; + } + } + + if (pCurrSpawnthing->cgd.flags & T_RANDOMROLL) { + buff += sTabbing + "\trandomroll\n"; + } + + if (!(pCurrSpawnthing->cgd.flags2 & T2_VOLUMETRIC) && (pCurrSpawnthing->cgd.flags & T_SWARM)) { + buff += + va("%s\tswarm %i %g %g\n", + sTabbing.c_str(), + pCurrSpawnthing->cgd.swarmfreq, + pCurrSpawnthing->cgd.swarmmaxspeed, + pCurrSpawnthing->cgd.swarmdelta); + } + + buff += sTabbing + ")\n\n"; + + iCurrCommand++; + } while (iCurrCommand < te_iNumCommands && cg_te_mode->integer != TE_MODE_EMITTER); + + char *buffer; + str szTmp; + int iLen; + + iLen = cgi.FS_ReadFile(filename->string, (void **)&buffer, qfalse); + if (iLen != -1) { + char FBuf[512]; + + COM_StripExtension(filename->string, FBuf, sizeof(FBuf)); + szTmp = FBuf; + szTmp += ".old"; + + cgi.FS_WriteFile(szTmp.c_str(), buffer, iLen); + } + + cgi.FS_WriteTextFile(filename->string, buff.c_str(), buff.length()); + + pCurrSpawnthing = NULL; + + CG_GetEffectCommandCvars(te_iCurrCommand); } void CG_LoadBaseAndAmplitude( - char **pBufer, char *szCvarX, char *szCvarY, char *szCvarZ, char *szCvarXAmp, char *szCvarYAmp, char *szCvarZAmp + char **pBufer, + const char *szCvarX, + const char *szCvarY, + const char *szCvarZ, + const char *szCvarXAmp, + const char *szCvarYAmp, + const char *szCvarZAmp ) { - // FIXME: unimplemented + char com_token[MAX_TOKEN_CHARS]; + + const char *szCvarList[] = {szCvarX, szCvarY, szCvarZ}; + const char *szCvarAmpList[] = {szCvarXAmp, szCvarYAmp, szCvarZAmp}; + int i; + + // Fixed in OPM + // Use a loop rather than a copy-paste + + for (i = 0; i < 3; i++) { + Q_strncpyz(com_token, COM_ParseExt(pBufer, qfalse), sizeof(com_token)); + if (!com_token[0]) { + return; + } + + if (!Q_stricmp(com_token, "random")) { + Q_strncpyz(com_token, COM_ParseExt(pBufer, qfalse), sizeof(com_token)); + if (!com_token[0]) { + return; + } + + cgi.Cvar_Set(szCvarAmpList[i], com_token); + } else if (!Q_stricmp(com_token, "crandom")) { + float fTmp; + + Q_strncpyz(com_token, COM_ParseExt(pBufer, qfalse), sizeof(com_token)); + if (!com_token[0]) { + return; + } + + fTmp = atof(com_token); + cgi.Cvar_Set(szCvarList[i], va("%g", -fTmp)); + cgi.Cvar_Set(szCvarAmpList[i], va("%g", fTmp * 2.0)); + } else if (!Q_stricmp(com_token, "range")) { + Q_strncpyz(com_token, COM_ParseExt(pBufer, qfalse), sizeof(com_token)); + if (!com_token[0]) { + return; + } + cgi.Cvar_Set(szCvarList[i], com_token); + + Q_strncpyz(com_token, COM_ParseExt(pBufer, qfalse), sizeof(com_token)); + if (!com_token[0]) { + return; + } + cgi.Cvar_Set(szCvarAmpList[i], com_token); + } + } } void CG_LoadEmitter_f(void) { - // FIXME: unimplemented + int iCommandCount; + char *buffer; + char *bufstart; + char com_token[MAX_TOKEN_CHARS]; + cvar_t *filename; + + if (te_iNumCommands <= 0) { + CG_TestEmitter_f(); + } else { + CG_SaveEffectCommandCvars(te_iCurrCommand); + } + filename = cgi.Cvar_Get("cg_te_filename", "dump/emitter.txt", 0); + + if (cgi.FS_ReadFile(filename->string, (void **)&buffer, qfalse) == -1) { + return; + } + + Com_Printf("Loading emitter dump '%s'\n", filename->string); + bufstart = buffer; + iCommandCount = 0; + + while ((Q_strncpyz(com_token, COM_ParseExt(&buffer, qtrue), sizeof(com_token))), com_token[0]) { + iCommandCount++; + if (te_iNumCommands < iCommandCount) { + CG_NewEmitterCommand_f(); + } + + te_iCurrCommand = iCommandCount - 1; + pCurrCommand = pTesteffect->m_commands[iCommandCount - 1]; + if (!pCurrCommand) { + Com_Printf("Error loading effect dump\n"); + break; + } + + pCurrSpawnthing = pCurrCommand->emitter; + commandManager.InitializeSpawnthing(pCurrSpawnthing); + pCurrCommand->fCommandTime = 0.0; + CG_ResetEffectCommandCvars(); + + if (com_token[0] == '0') { + cgi.Cvar_Set("cg_te_mode", va("%i", 1)); + Q_strncpyz(com_token, COM_ParseExt(&buffer, qtrue), sizeof(com_token)); + if (!com_token[0]) { + Com_Printf("Error loading effect dump\n"); + break; + } + } else if (!Q_stricmp(com_token, "delayedsfx") || !Q_stricmp(com_token, "sfx")) { + cgi.Cvar_Set("cg_te_mode", va("%i", 3)); + if (!Q_stricmp(com_token, "delayedsfx")) { + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (!com_token[0]) { + Com_Printf("Error loading effect dump\n"); + break; + } + cgi.Cvar_Set("cg_te_command_time", com_token); + + Q_strncpyz(com_token, COM_ParseExt(&buffer, qtrue), sizeof(com_token)); + if (!com_token[0]) { + Com_Printf("Error loading effect dump\n"); + break; + } + } + } else if (!Q_stricmp(com_token, "tagemitter") || !Q_stricmp(com_token, "originemitter")) { + cgi.Cvar_Set("cg_te_mode", va("%i", 0)); + } else { + cgi.Cvar_Set("cg_te_mode", va("%i", 2)); + } + + if (!Q_stricmp(com_token, "commanddelay")) { + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (!com_token[0]) { + Com_Printf("Error loading effect dump\n"); + break; + } + cgi.Cvar_Set("cg_te_command_time", com_token); + + Q_strncpyz(com_token, COM_ParseExt(&buffer, qtrue), sizeof(com_token)); + if (!com_token[0]) { + Com_Printf("Error loading effect dump\n"); + break; + } + } + + if (!Q_stricmpn(com_token, "tag", 3)) { + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (!com_token[0]) { + Com_Printf("Error loading effect dump\n"); + break; + } + cgi.Cvar_Set("cg_te_tag", com_token); + } + + while (COM_ParseExt(&buffer, qfalse)) {} + + Q_strncpyz(com_token, COM_ParseExt(&buffer, qtrue), sizeof(com_token)); + if (Q_stricmp(com_token, "(")) { + Com_Printf("Error loading effect dump\n"); + break; + } + + Q_strncpyz(com_token, COM_ParseExt(&buffer, qtrue), sizeof(com_token)); + if (!com_token[0]) { + Com_Printf("Error loading effect dump\n"); + break; + } + + while (Q_stricmp(com_token, ")")) { + if (!Q_stricmp(com_token, "spawnrange")) { + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_spawnrange_a", com_token); + + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_spawnrange_b", com_token); + } + } + } else if (!Q_stricmp(com_token, "volumetric")) { + cgi.Cvar_Set("cg_te_volumetric", "1"); + } else if (!Q_stricmp(com_token, "spawnrate")) { + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_spawnrate", com_token); + } + } else if (!Q_stricmp(com_token, "model")) { + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_model", com_token); + } + } else if (!Q_stricmp(com_token, "count")) { + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_count", com_token); + } + } else if (!Q_stricmp(com_token, "alpha")) { + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_alpha", com_token); + } + } else if (!Q_stricmp(com_token, "color")) { + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_color_r", com_token); + + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_color_g", com_token); + + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_color_b", com_token); + } + } + } + } else if (!Q_stricmp(com_token, "varycolor")) { + cgi.Cvar_Set("cg_te_varycolor", "1"); + } else if (!Q_stricmp(com_token, "spritegridlighting")) { + cgi.Cvar_Set("cg_te_spritegridlighting", "1"); + } else if (!Q_stricmp(com_token, "collision")) { + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_collision", "1"); + } else { + cgi.Cvar_Set("cg_te_collision", "1"); + } + } else if (!Q_stricmp(com_token, "bouncefactor")) { + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_alpha", com_token); + } + } else if (!Q_stricmp(com_token, "scale")) { + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_alpha", com_token); + } + } else if (!Q_stricmp(com_token, "life")) { + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_life", com_token); + } + } else if (!Q_stricmp(com_token, "scalerate")) { + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_scalerate", com_token); + } + } else if (!Q_stricmp(com_token, "radius")) { + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_radius", com_token); + } + } else if (!Q_stricmp(com_token, "cone")) { + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_cone_height", com_token); + + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_radius", com_token); + } + } + } else if (!Q_stricmp(com_token, "velocity")) { + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_forwardvel", com_token); + } + } else if (!Q_stricmp(com_token, "radialvelocity")) { + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_radial_scale", com_token); + + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_radial_min", com_token); + + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_radial_max", com_token); + } + } + } + } else if (!Q_stricmp(com_token, "randvelaxis") || !Q_stricmp(com_token, "randvel")) { + if (!Q_stricmp(com_token, "randvelaxis")) { + cgi.Cvar_Set("cg_te_randaxis", "1"); + + CG_LoadBaseAndAmplitude( + &buffer, + "cg_te_randvelbase_x", + "cg_te_randvelbase_y", + "cg_te_randvelbase_z", + "cg_te_randvelamp_x", + "cg_te_randvelamp_y", + "cg_te_randvelamp_z" + ); + } + } else if (!Q_stricmp(com_token, "clampvel") || !Q_stricmp(com_token, "clampvelaxis")) { + if (!Q_stricmp(com_token, "clampvelaxis")) { + cgi.Cvar_Set("cg_te_clampvelaxis", "1"); + } + + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_clampvelmin_x", com_token); + + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_clampvelmax_x", com_token); + + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_clampvelmin_y", com_token); + + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_clampvelmax_y", com_token); + + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_clampvelmin_z", com_token); + + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_clampvelmax_z", com_token); + } + } + } + } + } + } + } else if (!Q_stricmp(com_token, "accel") || !Q_stricmp(com_token, "smokeparms")) { + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_accel_x", com_token); + + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_accel_y", com_token); + + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_accel_z", com_token); + } + } + } + } else if (!Q_stricmp(com_token, "friction")) { + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_friction", com_token); + } + // Added in 2.0 + // spin + } else if (!Q_stricmp(com_token, "spin")) { + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_spin", com_token); + } + } else if (!Q_stricmp(com_token, "offset")) { + CG_LoadBaseAndAmplitude( + &buffer, + "cg_te_offsbase_x", + "cg_te_offsbase_y", + "cg_te_offsbase_z", + "cg_te_offsamp_x", + "cg_te_offsamp_y", + "cg_te_offsamp_z" + ); + } else if (!Q_stricmp(com_token, "offsetalongaxis")) { + CG_LoadBaseAndAmplitude( + &buffer, + "cg_te_axisoffsbase_x", + "cg_te_axisoffsbase_y", + "cg_te_axisoffsbase_z", + "cg_te_axisoffsamp_x", + "cg_te_axisoffsamp_y", + "cg_te_axisoffsamp_z" + ); + } else if (!Q_stricmp(com_token, "angles")) { + CG_LoadBaseAndAmplitude( + &buffer, + "cg_te_anglesbase_p", + "cg_te_anglesbase_y", + "cg_te_anglesbase_r", + "cg_te_anglesamp_p", + "cg_te_anglesamp_y", + "cg_te_anglesamp_r" + ); + } else if (!Q_stricmp(com_token, "avelocity")) { + CG_LoadBaseAndAmplitude( + &buffer, + "cg_te_avelbase_p", + "cg_te_avelbase_y", + "cg_te_avelbase_r", + "cg_te_avelamp_p", + "cg_te_avelamp_y", + "cg_te_avelamp_r" + ); + } else if (!Q_stricmp(com_token, "scalemin")) { + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_scalemin", com_token); + } + } else if (!Q_stricmp(com_token, "scalemax")) { + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_scalemax", com_token); + } + } else if (!Q_stricmp(com_token, "dietouch")) { + cgi.Cvar_Set("cg_te_dietouch", "1"); + } else if (!Q_stricmp(com_token, "fade")) { + cgi.Cvar_Set("cg_te_fade", "1"); + } else if (!Q_stricmp(com_token, "fadedelay")) { + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_fadedelay", com_token); + } + } else if (!Q_stricmp(com_token, "fadein")) { + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_fadein", com_token); + } + } else if (!Q_stricmp(com_token, "circle")) { + cgi.Cvar_Set("cg_te_circle", "1"); + } else if (!Q_stricmp(com_token, "sphere")) { + cgi.Cvar_Set("cg_te_sphere", "1"); + } else if (!Q_stricmp(com_token, "inwardsphere")) { + cgi.Cvar_Set("cg_te_insphere", "1"); + } else if (!Q_stricmp(com_token, "align")) { + cgi.Cvar_Set("cg_te_align", "1"); + } else if (!Q_stricmp(com_token, "alignstretch")) { + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_alignstretch_scale", com_token); + } + } else if (!Q_stricmp(com_token, "flickeralpha")) { + cgi.Cvar_Set("cg_te_flickeralpha", "1"); + } else if (!Q_stricmp(com_token, "randomroll")) { + cgi.Cvar_Set("cg_te_randomroll", "1"); + } else if (!Q_stricmp(com_token, "swarm")) { + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_swarm_freq", com_token); + + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_swarm_maxspeed", com_token); + + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); + if (com_token[0]) { + cgi.Cvar_Set("cg_te_swarm_delta", com_token); + } + } + } + } + } + + CG_SaveEffectCommandCvars(te_iCurrCommand); + } + + cgi.FS_FreeFile(bufstart); + return; } void CG_TestEmitter_f(void) { - // FIXME: unimplemented + vec3_t angles; + + if (!pTesteffect->m_iCommandCount) { + pCurrCommand = pTesteffect->AddNewCommand(); + if (!pCurrCommand) { + return; + } + + pCurrSpawnthing = new spawnthing_t(); + pCurrCommand->emitter = pCurrSpawnthing; + commandManager.InitializeSpawnthing(pCurrSpawnthing); + + te_iNumCommands++; + } + + assert(pCurrSpawnthing); + + VectorMA(cg.refdef.vieworg, 100.0, cg.refdef.viewaxis[0], te_vEmitterOrigin); + VectorSet(angles, 0, cg.refdefViewAngles[1], 0); + AnglesToAxis(angles, pCurrSpawnthing->axis); + + pCurrSpawnthing->cgd.tiki = NULL; + CG_SetTestEmitterValues(); + + pCurrCommand = NULL; + pCurrSpawnthing = NULL; } void CG_PrevEmitterCommand_f(void) { - // FIXME: unimplemented + CG_SaveEffectCommandCvars(te_iCurrCommand); + + te_iCurrCommand--; + if (te_iCurrCommand < 0) { + te_iCurrCommand = te_iNumCommands - 1; + } + + CG_GetEffectCommandCvars(te_iCurrCommand); } void CG_NextEmitterCommand_f(void) { - // FIXME: unimplemented + CG_SaveEffectCommandCvars(te_iCurrCommand); + + te_iCurrCommand++; + if (te_iCurrCommand >= te_iNumCommands) { + te_iCurrCommand = 0; + } + + CG_GetEffectCommandCvars(te_iCurrCommand); } void CG_NewEmitterCommand_f(void) { - // FIXME: unimplemented + if (te_iNumCommands >= MAX_TESTEMITTERS_SAVE) { + Com_Printf("Test effect can not have more than %i effect commands\n", MAX_TESTEMITTERS_SAVE); + return; + } + + pCurrCommand = pTesteffect->AddNewCommand(); + if (!pCurrCommand) { + return; + } + + pCurrSpawnthing = new spawnthing_t(); + pCurrCommand->emitter = pCurrSpawnthing; + commandManager.InitializeSpawnthing(pCurrSpawnthing); + + te_iNumCommands++; + CG_SaveEffectCommandCvars(te_iCurrCommand); + + te_iCurrCommand = te_iNumCommands - 1; + CG_GetEffectCommandCvars(te_iCurrCommand); + + Com_Printf("Test effect now has %i effect commands\n", te_iNumCommands); } -void CG_DeleteEmitterCommand_f(void) -{ - // FIXME: unimplemented -} +void CG_DeleteEmitterCommand_f(void) {} void CG_InitTestEmitter(void) { @@ -452,6 +2063,7 @@ void CG_InitTestEmitter(void) cg_te_radial_min = cgi.Cvar_Get("cg_te_radial_min", "0", 0); cg_te_radial_max = cgi.Cvar_Get("cg_te_radial_max", "0", 0); cg_te_friction = cgi.Cvar_Get("cg_te_friction", "0", 0); + cg_te_spin = cgi.Cvar_Get("cg_te_spin", "0", 0); // Added in 2.0 cg_te_varycolor = cgi.Cvar_Get("cg_te_varycolor", "0", 0); cg_te_spritegridlighting = cgi.Cvar_Get("cg_te_spritegridlighting", "0", 0); cg_te_spawnrange_a = cgi.Cvar_Get("cg_te_spawnrange_a", "0", 0); @@ -473,14 +2085,12 @@ void CG_InitTestEmitter(void) cg_te_mode = cgi.Cvar_Get("cg_te_mode", "0", 0); cg_te_mode_name = cgi.Cvar_Get("cg_te_mode_name", "Emitter Mode", 0); cg_te_currCommand = cgi.Cvar_Get("cg_te_currCommand", "0", 0); + cg_te_numCommands = cgi.Cvar_Get("cg_te_numCommands", "0", 0); - te_vEmitterOrigin[2] = 0.0; - te_vEmitterOrigin[1] = 0.0; - te_vEmitterOrigin[0] = 0.0; - te_refEnt.scale = 0.0; - cg_te_numCommands = cgi.Cvar_Get("cg_te_numCommands", "0", 0); - te_iNumCommands = 0; - te_iCurrCommand = 0; + VectorClear(te_vEmitterOrigin); + te_refEnt.scale = 0.0; + te_iNumCommands = 0; + te_iCurrCommand = 0; pTesteffect = sfxManager.GetTestEffectPointer(); } diff --git a/code/cgame/cg_ui.cpp b/code/cgame/cg_ui.cpp index 5c011963..c884fc97 100644 --- a/code/cgame/cg_ui.cpp +++ b/code/cgame/cg_ui.cpp @@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "cg_local.h" #include "str.h" +#include "../client/keycodes.h" void CG_MessageMode_f(void) { @@ -61,8 +62,8 @@ void CG_MessageMode_Private_f(void) return; } - clientNum = atoi(cgi.Argv(1)) - 1; - if (clientNum < 0 || clientNum >= MAX_CLIENTS) { + clientNum = atoi(cgi.Argv(1)); + if (clientNum < 1 || clientNum >= MAX_CLIENTS) { cgi.Printf(HUD_MESSAGE_CHAT_WHITE "Message Error: %s is a bad client number\n", cgi.Argv(1)); return; } @@ -119,7 +120,7 @@ void CG_MessageSingleClient_f(void) // copy the rest for (i = 2; i < cgi.Argc(); i++) { - sString += va("%s", cgi.Argv(i)); + sString += va(" %s", cgi.Argv(i)); } sString += "\n"; @@ -192,8 +193,36 @@ void CG_HudPrint_f(void) cgi.Printf("\x1%s", cgi.Argv(1)); } -int CG_CheckCaptureKey(int key, qboolean down, unsigned int time) +qboolean CG_CheckCaptureKey(int key, qboolean down, unsigned int time) { - // FIXME: unimplemented - return 0; + char minKey = '1', maxKey = '9'; + + if (!cg.iInstaMessageMenu || !down) { + return qfalse; + } + + if (cg_protocol >= protocol_e::PROTOCOL_MOHTA_MIN) { + maxKey = '8'; + } + + if (key < minKey || key > maxKey) { + if (key == K_ESCAPE || key == '0') { + cg.iInstaMessageMenu = 0; + return qtrue; + } + return qfalse; + } + + if (cg.iInstaMessageMenu == -1) { + if (key > '6') { + cg.iInstaMessageMenu = 0; + } else { + cg.iInstaMessageMenu = key - '0'; + } + } else if (cg.iInstaMessageMenu > 0) { + cgi.SendClientCommand(va("dmmessage 0 *%i%i\n", cg.iInstaMessageMenu, key - '0')); + cg.iInstaMessageMenu = 0; + } + + return qtrue; } diff --git a/code/cgame/cg_view.c b/code/cgame/cg_view.c index 6e7a63ef..8da21cac 100644 --- a/code/cgame/cg_view.c +++ b/code/cgame/cg_view.c @@ -242,6 +242,7 @@ void CG_OffsetFirstPersonView(refEntity_t *pREnt, qboolean bUseWorldPosition) float mat[3][3]; vec3_t vOldOrigin; vec3_t vStart, vEnd, vMins, vMaxs; + vec3_t vVelocity; trace_t trace; VectorSet(vMins, -6, -6, -6); @@ -297,6 +298,15 @@ void CG_OffsetFirstPersonView(refEntity_t *pREnt, qboolean bUseWorldPosition) VectorCopy(origin, vOldOrigin); + if (!cg.predicted_player_state.walking || (!(cg.predicted_player_state.pm_flags & PMF_FROZEN) && !(cg.predicted_player_state.pm_flags & PMF_NO_MOVE))) { + VectorCopy(cg.predicted_player_state.velocity, vVelocity); + } else { + // + // Added in OPM + // When frozen, there must be no movement at all + VectorClear(vVelocity); + } + if (bUseWorldPosition) { iMask = MASK_VIEWSOLID; } else { @@ -367,7 +377,7 @@ void CG_OffsetFirstPersonView(refEntity_t *pREnt, qboolean bUseWorldPosition) } if (cg.predicted_player_state.walking) { - fVel = VectorLength(cg.predicted_player_state.velocity); + fVel = VectorLength(vVelocity); fPhase = fVel * 0.0015 + 0.9; cg.fCurrentViewBobPhase += (cg.frametime / 1000.0 + cg.frametime / 1000.0) * M_PI * fPhase; @@ -446,7 +456,7 @@ void CG_OffsetFirstPersonView(refEntity_t *pREnt, qboolean bUseWorldPosition) AngleVectorsLeft(vDelta, mat[0], mat[1], mat[2]); CG_CalcViewModelMovement( - cg.fCurrentViewBobPhase, cg.fCurrentViewBobAmp, cg.predicted_player_state.velocity, vDelta + cg.fCurrentViewBobPhase, cg.fCurrentViewBobAmp, vVelocity, vDelta ); VectorMA(pREnt->origin, vDelta[0], mat[0], pREnt->origin); @@ -475,9 +485,16 @@ static int CG_CalcFov(void) int contents; float fov_x, fov_y; int inwater; + float fov_ratio; - fov_x = cg.camera_fov; - x = cg.refdef.width / tan(fov_x / 360 * M_PI); + fov_ratio = (float)cg.refdef.width / (float)cg.refdef.height * (3.0 / 4.0); + if (fov_ratio == 1) { + fov_x = cg.camera_fov; + } else { + fov_x = RAD2DEG(atan(tan(DEG2RAD(cg.camera_fov / 2.0)) * fov_ratio)) * 2.0; + } + + x = cg.refdef.width / tan(fov_x / 360 * M_PI); fov_y = atan2(cg.refdef.height, x); fov_y = fov_y * 360 / M_PI; @@ -560,17 +577,6 @@ static int CG_CalcViewValues(void) CG_CalcVrect(); CG_SetupFog(); - // setup fog and far clipping plane - cg.refdef.farplane_distance = cg.farplane_distance; - VectorCopy(cg.farplane_color, cg.refdef.farplane_color); - cg.refdef.farplane_cull = cg.farplane_cull; - - // setup portal sky - cg.refdef.sky_alpha = cg.sky_alpha; - cg.refdef.sky_portal = cg.sky_portal; - memcpy(cg.refdef.sky_axis, cg.sky_axis, sizeof(cg.sky_axis)); - VectorCopy(cg.sky_origin, cg.refdef.sky_origin); - ps = &cg.predicted_player_state; VectorCopy(ps->origin, cg.refdef.vieworg); @@ -723,7 +729,37 @@ float CG_SensitivityScale() void CG_AddLightShow() { - // FIXME: unimplemented + int i; + float fSlopeY, fSlopeZ; + float x, y, z; + vec3_t vOrg; + float r, g, b; + float fMax; + + fSlopeY = tan(cg.refdef.fov_x * 0.5); + fSlopeZ = tan(cg.refdef.fov_y * 0.5); + + for (i = 0; i < cg_acidtrip->integer; i++) { + x = pow(random(), 1.0 / 3.0) * 2048.0; + y = crandom() * x * fSlopeY; + z = crandom() * x * fSlopeZ; + + VectorCopy(cg.refdef.vieworg, vOrg); + VectorMA(vOrg, x, cg.refdef.viewaxis[0], vOrg); + VectorMA(vOrg, y, cg.refdef.viewaxis[1], vOrg); + VectorMA(vOrg, z, cg.refdef.viewaxis[2], vOrg); + + r = random(); + g = random(); + b = random(); + + fMax = Q_max(r, Q_max(g, b)); + r /= fMax; + g /= fMax; + b /= fMax; + + cgi.R_AddLightToScene(vOrg, (rand() & 0x1FF) + 0x80, r, g, b, 0); + } } qboolean CG_FrustumCullSphere(const vec3_t vPos, float fRadius) { @@ -811,6 +847,15 @@ void CG_DrawActiveFrame(int serverTime, int frameTime, stereoFrame_t stereoView, // no entities should be marked as interpolating } + // + // Added in OPM + // Clamp the fov to avoid artifacts + if (cg_fov->value < 65) { + cgi.Cvar_Set("cg_fov", "65"); + } else if (cg_fov->value > 120) { + cgi.Cvar_Set("cg_fov", "120"); + } + // update cg.predicted_player_state CG_PredictPlayerState(); @@ -882,13 +927,13 @@ void CG_DrawActiveFrame(int serverTime, int frameTime, stereoFrame_t stereoView, { default: case 0: - cgi.UI_HideMenu("mission_success_1", CVAR_ARCHIVE); + cgi.UI_HideMenu("mission_success_1", qtrue); break; case 2: - cgi.UI_HideMenu("mission_success_2", CVAR_ARCHIVE); + cgi.UI_HideMenu("mission_success_2", qtrue); break; case 3: - cgi.UI_HideMenu("mission_success_3", CVAR_ARCHIVE); + cgi.UI_HideMenu("mission_success_3", qtrue); break; } } else { @@ -896,21 +941,21 @@ void CG_DrawActiveFrame(int serverTime, int frameTime, stereoFrame_t stereoView, { default: case 0: - cgi.UI_HideMenu("mission_failed_1", CVAR_ARCHIVE); + cgi.UI_HideMenu("mission_failed_1", qtrue); break; case 2: - cgi.UI_HideMenu("mission_failed_2", CVAR_ARCHIVE); + cgi.UI_HideMenu("mission_failed_2", qtrue); break; case 3: - cgi.UI_HideMenu("mission_failed_3", CVAR_ARCHIVE); + cgi.UI_HideMenu("mission_failed_3", qtrue); break; } } } else { if (cgi.Cvar_Get("g_success", "", 0)->integer) { - cgi.UI_HideMenu("StatsScreen_Success", qfalse); + cgi.UI_HideMenu("StatsScreen_Success", qtrue); } else { - cgi.UI_HideMenu("StatsScreen_Failed", qfalse); + cgi.UI_HideMenu("StatsScreen_Failed", qtrue); } } } @@ -918,6 +963,9 @@ void CG_DrawActiveFrame(int serverTime, int frameTime, stereoFrame_t stereoView, cg.bIntermissionDisplay = qfalse; } + // Added in OPM + CG_ProcessPlayerModel(); + // build the render lists if (!cg.hyperspace) { CG_AddPacketEntities(); // after calcViewValues, so predicted player state is correct diff --git a/code/cgame/cg_viewmodelanim.c b/code/cgame/cg_viewmodelanim.c index e53fe7ef..c3bb9f73 100644 --- a/code/cgame/cg_viewmodelanim.c +++ b/code/cgame/cg_viewmodelanim.c @@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA static const char *AnimPrefixList[] = { "", + "unarmed", "papers", "colt45", "p38", @@ -45,7 +46,6 @@ static const char *AnimPrefixList[] = { "bazooka", "panzerschreck", "shotgun", - "unarmed", // // Team Assault and Team Tactics weapons "mg42portable", @@ -82,6 +82,7 @@ static const char *AnimPrefixList[] = { enum animPrefix_e { WPREFIX_NONE, + WPREFIX_UNARMED, WPREFIX_PAPERS, WPREFIX_COLT45, WPREFIX_P38, @@ -99,7 +100,6 @@ enum animPrefix_e { WPREFIX_BAZOOKA, WPREFIX_PANZERSCHRECK, WPREFIX_SHOTGUN, - WPREFIX_UNARMED, // // Team Assault and Team Tactics weapons WPREFIX_MG42_PORTABLE, @@ -308,6 +308,9 @@ int CG_GetVMAnimPrefixIndex() if (!Q_stricmp(szWeaponName, "Panzerschreck")) { return WPREFIX_PANZERSCHRECK; } + if (!Q_stricmp(szWeaponName, "Gewehrgranate")) { + return WPREFIX_KAR98_MORTAR; + } if (!Q_stricmp(szWeaponName, "Shotgun")) { return WPREFIX_SHOTGUN; } @@ -335,9 +338,11 @@ void CG_ViewModelAnimation(refEntity_t *pModel) char szAnimName[MAX_QPATH]; dtiki_t *pTiki; qboolean bAnimChanged; + qboolean bWeaponChanged; fCrossblendFrac = 0.0; - bAnimChanged = 0; + bAnimChanged = qfalse; + bWeaponChanged = qfalse; // Added in OPM pTiki = pModel->tiki; if (cgi.anim->g_iLastEquippedWeaponStat == cg.snap->ps.stats[STAT_EQUIPPED_WEAPON] @@ -346,13 +351,15 @@ void CG_ViewModelAnimation(refEntity_t *pModel) } else { iAnimPrefixIndex = CG_GetVMAnimPrefixIndex(); cgi.anim->g_iLastEquippedWeaponStat = cg.snap->ps.stats[STAT_EQUIPPED_WEAPON]; - strcpy(cgi.anim->g_szLastActiveItem, CG_ConfigString(CS_WEAPONS + cg.snap->ps.activeItems[1])); + Q_strncpyz(cgi.anim->g_szLastActiveItem, CG_ConfigString(CS_WEAPONS + cg.snap->ps.activeItems[1]), sizeof(cgi.anim->g_szLastActiveItem)); cgi.anim->g_iLastAnimPrefixIndex = iAnimPrefixIndex; - bAnimChanged = qtrue; + + bAnimChanged = qtrue; + bWeaponChanged = qtrue; } if (cgi.anim->g_iLastVMAnim == -1) { - sprintf(szAnimName, "%s_idle", AnimPrefixList[iAnimPrefixIndex]); + Com_sprintf(szAnimName, sizeof(szAnimName), "%s_idle", AnimPrefixList[iAnimPrefixIndex]); cgi.anim->g_VMFrameInfo[cgi.anim->g_iCurrentVMAnimSlot].index = cgi.Anim_NumForName(pTiki, szAnimName); if (cgi.anim->g_VMFrameInfo[cgi.anim->g_iCurrentVMAnimSlot].index == -1) { @@ -421,21 +428,28 @@ void CG_ViewModelAnimation(refEntity_t *pModel) break; } - sprintf(szAnimName, "%s_%s", AnimPrefixList[iAnimPrefixIndex], pszAnimSuffix); - fCrossblendTime = cgi.Anim_CrossblendTime(pTiki, cgi.anim->g_VMFrameInfo[cgi.anim->g_iCurrentVMAnimSlot].index); - fCrossblendAmount = cgi.anim->g_iCurrentVMDuration / 1000.0; + Com_sprintf(szAnimName, sizeof(szAnimName), "%s_%s", AnimPrefixList[iAnimPrefixIndex], pszAnimSuffix); + if (!bWeaponChanged) { + fCrossblendTime = + cgi.Anim_CrossblendTime(pTiki, cgi.anim->g_VMFrameInfo[cgi.anim->g_iCurrentVMAnimSlot].index); + fCrossblendAmount = cgi.anim->g_iCurrentVMDuration / 1000.0; - if (fCrossblendAmount < fCrossblendTime && fCrossblendAmount > 0.0) { - fCrossblendFrac = fCrossblendAmount / fCrossblendTime; - for (i = 0; i < MAX_FRAMEINFOS; ++i) { - if (cgi.anim->g_VMFrameInfo[i].weight) { - if (i == cgi.anim->g_iCurrentVMAnimSlot) { - cgi.anim->g_VMFrameInfo[i].weight = fCrossblendFrac; - } else { - cgi.anim->g_VMFrameInfo[i].weight *= (1.0 - fCrossblendFrac); + if (fCrossblendAmount < fCrossblendTime && fCrossblendAmount > 0.0) { + fCrossblendFrac = fCrossblendAmount / fCrossblendTime; + for (i = 0; i < MAX_FRAMEINFOS; ++i) { + if (cgi.anim->g_VMFrameInfo[i].weight) { + if (i == cgi.anim->g_iCurrentVMAnimSlot) { + cgi.anim->g_VMFrameInfo[i].weight = fCrossblendFrac; + } else { + cgi.anim->g_VMFrameInfo[i].weight *= (1.0 - fCrossblendFrac); + } } } } + } else { + fCrossblendTime = 0; + fCrossblendAmount = 0; + fCrossblendFrac = 0; } cgi.anim->g_iCurrentVMAnimSlot = (cgi.anim->g_iCurrentVMAnimSlot + 1) % MAX_FRAMEINFOS; @@ -450,17 +464,31 @@ void CG_ViewModelAnimation(refEntity_t *pModel) cgi.anim->g_VMFrameInfo[cgi.anim->g_iCurrentVMAnimSlot].weight = 1.0; cgi.anim->g_iCurrentVMDuration = 0; - fCrossblendTime = cgi.Anim_CrossblendTime(pTiki, cgi.anim->g_VMFrameInfo[cgi.anim->g_iCurrentVMAnimSlot].index); - if (!fCrossblendTime) { + if (!bWeaponChanged) { + fCrossblendTime = + cgi.Anim_CrossblendTime(pTiki, cgi.anim->g_VMFrameInfo[cgi.anim->g_iCurrentVMAnimSlot].index); + if (!fCrossblendTime) { + for (i = 0; i < MAX_FRAMEINFOS; ++i) { + if (i != cgi.anim->g_iCurrentVMAnimSlot) { + cgi.anim->g_VMFrameInfo[i].weight = 0.0; + } + } + + cgi.anim->g_bCrossblending = qfalse; + } else { + cgi.anim->g_bCrossblending = qtrue; + } + } else { + // Added in OPM + // If there is a new weapon, don't do any crossblend + cgi.anim->g_bCrossblending = qfalse; + + // clear crossblend values for (i = 0; i < MAX_FRAMEINFOS; ++i) { if (i != cgi.anim->g_iCurrentVMAnimSlot) { cgi.anim->g_VMFrameInfo[i].weight = 0.0; } } - - cgi.anim->g_bCrossblending = qfalse; - } else { - cgi.anim->g_bCrossblending = qtrue; } } diff --git a/code/cgame/cg_volumetricsmoke.cpp b/code/cgame/cg_volumetricsmoke.cpp index 33cf3769..eeb6a3ce 100644 --- a/code/cgame/cg_volumetricsmoke.cpp +++ b/code/cgame/cg_volumetricsmoke.cpp @@ -42,7 +42,9 @@ const char *cg_vsstypes[] = { "debris" }; -cvssource_t *vss_sorttable[16384]; +#define MAX_VSS_SORTS 16384 + +cvssource_t *vss_sorttable[MAX_VSS_SORTS]; static int lastVSSFrameTime; static constexpr float MAX_VSS_COORDS = 8096.0; @@ -78,56 +80,57 @@ void VSS_AddRepulsion(cvssource_t *pA, cvssource_t *pB) VectorSubtract(pA->newOrigin, pB->newOrigin, vPush); - if (vPush[0] || vPush[1] || vPush[2]) { - fDist = VectorNormalize(vPush); - f = fDist - pB->newRadius; - - if (f > 0.0) { - f *= pA->ooRadius; - if (f > 1.49) { - f = 0.0; - } else { - f = f * (f * 0.0161 + -0.3104) + 1.2887; - } - - if (f < 0.0) { - f = f * 1.1; - } - - fForce = f; - } else { - fForce = 1.0; - } - - f = fDist - pA->newRadius; - if (f > 0.0) { - f *= pB->ooRadius; - if (f > 1.49) { - f = 0.0; - } else { - f = f * (f * 0.0161 + -0.3104) + 1.2887; - } - - if (f < 0.0) { - f = f * 1.1; - } - - fForce += f; - } else { - fForce += 1.0; - } - - if (fForce <= -0.05 && fForce >= 0.05) { - fForce = (pA->newRadius + pB->newRadius) * 0.03 * fForce; - VectorScale(vPush, fForce, vPush); - - VectorAdd(pA->repulsion, vPush, pA->repulsion); - VectorSubtract(pB->repulsion, vPush, pB->repulsion); - } - } else { + if (!vPush[0] && !vPush[1] && !vPush[2]) { VectorSet(vPush, crandom(), crandom(), crandom()); VectorAdd(pA->repulsion, vPush, pA->repulsion); VectorSubtract(pB->repulsion, vPush, pB->repulsion); + return; + } + + fDist = VectorNormalize(vPush); + f = fDist - pB->newRadius; + + if (f > 0.0f) { + f *= pA->ooRadius; + if (f > 1.49f) { + f = 0.0f; + } else { + f = f * (f * 0.0161f + -0.3104f) + 1.2887f; + } + + if (f < 0.0) { + f *= 1.1f; + } + + fForce = f; + } else { + fForce = 1.0; + } + + f = fDist - pA->newRadius; + if (f > 0.0) { + f *= pB->ooRadius; + if (f > 1.49f) { + f = 0.0f; + } else { + f = f * (f * 0.0161f + -0.3104f) + 1.2887f; + } + + if (f < 0.0) { + f *= 1.1f; + } + + fForce += f; + } else { + fForce += 1.0f; + } + + if (fForce <= -0.05f || fForce >= 0.05f) { + fForce = (pA->newRadius + pB->newRadius) * 0.03f * fForce; + VectorScale(vPush, fForce, vPush); + + VectorAdd(pA->repulsion, vPush, pA->repulsion); + VectorSubtract(pB->repulsion, vPush, pB->repulsion); } } @@ -206,7 +209,7 @@ void ClientGameCommandManager::ResetVSSSources() void ClientGameCommandManager::ResetVSSSources(Event *ev) { - // FIXME: stub?? + ResetVSSSources(); } void CG_ResetVSSSources() @@ -286,13 +289,13 @@ qboolean VSS_SourcePhysics(cvssource_t *pSource, float ftime) fWind = 0.0; - if ((pSource->flags2 & 5) != 0) { + if ((pSource->flags2 & (T2_ACCEL | T2_MOVE)) != 0) { VectorMA(pSource->velocity, ftime, pSource->repulsion, pSource->velocity); } pSource->lastOrigin = pSource->newOrigin; - if (pSource->flags & 0x800) { + if (pSource->flags & T_COLLISION) { trace.allsolid = qfalse; CG_ClipMoveToEntities( pSource->newOrigin, vec3_origin, vec3_origin, pSource->newOrigin, -1, MASK_VOLUMETRIC_SMOKE, &trace, qfalse @@ -312,11 +315,11 @@ qboolean VSS_SourcePhysics(cvssource_t *pSource, float ftime) } } - if (pSource->flags2 & 5) { + if (pSource->flags2 & (T2_ACCEL | T2_MOVE)) { VectorMA(pSource->newOrigin, ftime, pSource->velocity, pSource->newOrigin); } - if (pSource->flags & 0x800) { + if (pSource->flags & T_COLLISION) { CG_Trace( &trace, pSource->lastOrigin, @@ -334,6 +337,8 @@ qboolean VSS_SourcePhysics(cvssource_t *pSource, float ftime) float fDot; vec3_t vNorm; + VectorCopy(trace.plane.normal, vNorm); + VectorAdd(trace.endpos, trace.plane.normal, pSource->newOrigin); fDot = DotProduct(vNorm, pSource->velocity); VectorMA(pSource->velocity, fDot, vNorm, pSource->velocity); @@ -358,7 +363,7 @@ qboolean VSS_SourcePhysics(cvssource_t *pSource, float ftime) } iSmokeType = abs(pSource->smokeType); - if (pSource->flags2 & 5) { + if (pSource->flags2 & (T2_ACCEL | T2_MOVE)) { VectorCopy(pSource->velocity, vVel); for (i = 0; i < 3; i++) { @@ -619,7 +624,7 @@ qboolean VSS_LerpSource(cvssource_t *pCurrent, cvssourcestate_t *pState, float f { int i; - if (pCurrent->flags & 0xA0000) { + if (pCurrent->flags & (T_HARDLINK | T_PARENTLINK)) { Vector parentOrigin; for (i = 0; i < 3; i++) { @@ -638,7 +643,7 @@ qboolean VSS_LerpSource(cvssource_t *pCurrent, cvssourcestate_t *pState, float f parentOrigin = e->origin; VectorAdd(pState->origin, parentOrigin, pState->origin); - } else if (pCurrent->flags2 & 5) { + } else if (pCurrent->flags2 & (T2_ACCEL | T2_MOVE)) { for (i = 0; i < 3; i++) { pState->origin[i] = (pCurrent->newOrigin[i] - pCurrent->lastOrigin[i]) * fLerpFrac + pCurrent->lastOrigin[i]; @@ -741,9 +746,8 @@ void ClientGameCommandManager::SpawnVSSSource(int count, int timealive) pSource->startAlpha = (random() * 0.15 + 0.85) * fDensity; pSource->newDensity = 0.0; - if (m_spawnthing->cgd.flags & 1) { + if (m_spawnthing->cgd.flags & T_RANDSCALE) { pSource->newRadius = RandomizeRange(m_spawnthing->cgd.scalemin, m_spawnthing->cgd.scalemax); - ; if (pSource->newRadius > 32.0) { pSource->newRadius = 32.0; } @@ -772,16 +776,16 @@ void ClientGameCommandManager::SpawnVSSSource(int count, int timealive) pSource->roll = anglemod(fAngle); if (random() < 0.5) { - pSource->flags |= 0x40000; + pSource->flags |= T_RANDOMROLL; } VectorCopy(m_spawnthing->axis[0], vNewForward); - if (m_spawnthing->cgd.flags & 4) { + if (m_spawnthing->cgd.flags & T_SPHERE) { VectorCopy(m_spawnthing->cgd.origin, pSource->newOrigin); do { vNewForward = Vector(crandom(), crandom(), crandom()); } while (Vector::Dot(vNewForward, vNewForward) < 1.0); - } else if (m_spawnthing->cgd.flags & 0x10) { + } else if (m_spawnthing->cgd.flags & T_CIRCLE) { if (m_spawnthing->sphereRadius != 0.0) { Vector dst, end; @@ -794,7 +798,7 @@ void ClientGameCommandManager::SpawnVSSSource(int count, int timealive) fAngle += fAngleStep; } - } else if (m_spawnthing->cgd.flags & 8) { + } else if (m_spawnthing->cgd.flags & T_INWARDSPHERE) { Vector dir, end; do { dir = Vector(crandom(), crandom(), crandom()); @@ -803,7 +807,7 @@ void ClientGameCommandManager::SpawnVSSSource(int count, int timealive) end = m_spawnthing->cgd.origin + dir * m_spawnthing->sphereRadius; VectorCopy(end, pSource->newOrigin); vNewForward = dir * -1.0; - } else if (m_spawnthing->cgd.flags2 & 0x20000) { + } else if (m_spawnthing->cgd.flags2 & T2_CONE) { float fHeight, fRadius; float fAngle; float sina, cosa; @@ -825,8 +829,6 @@ void ClientGameCommandManager::SpawnVSSSource(int count, int timealive) VectorMA(m_spawnthing->cgd.origin, fRadius * cosa, m_spawnthing->axis[1], pSource->newOrigin); VectorMA(m_spawnthing->cgd.origin, fRadius * sina, m_spawnthing->axis[2], pSource->newOrigin); } else if (m_spawnthing->sphereRadius) { - VectorCopy(m_spawnthing->cgd.origin, pSource->newOrigin); - } else { Vector dir, end; do { dir = Vector(crandom(), crandom(), crandom()); @@ -836,6 +838,8 @@ void ClientGameCommandManager::SpawnVSSSource(int count, int timealive) end = m_spawnthing->cgd.origin + dir * m_spawnthing->sphereRadius; VectorCopy(end, pSource->newOrigin); vNewForward = dir; + } else { + VectorCopy(m_spawnthing->cgd.origin, pSource->newOrigin); } for (i = 0; i < 3; i++) { @@ -869,15 +873,14 @@ void ClientGameCommandManager::SpawnVSSSource(int count, int timealive) for (i = 0; i < 3; ++i) { float fDist = m_spawnthing->axis_offset_base[i] + random() * m_spawnthing->axis_offset_amplitude[i]; - if (pSource->flags2 & 0x80) { + if (pSource->flags2 & T2_PARALLEL) { pSource->newOrigin += Vector(m_spawnthing->axis[i]) * fDist; } else { pSource->newOrigin += Vector(m_spawnthing->tag_axis[i]) * fDist; } } - pSource->velocity *= pSource->lifeTime / 1000.0; - pSource->newOrigin += pSource->velocity; + pSource->newOrigin += pSource->velocity * (pSource->lifeTime / 1000.0); if (vss_lighting_fps->integer) { cgi.R_GetLightingForSmoke(pSource->newLighting, pSource->newOrigin); } @@ -890,251 +893,249 @@ void VSS_CalcRepulsionForces(cvssource_t *pActiveSources) { cvssource_t *pCurrent; cvssource_t *pComp; + qboolean bXUp, bXDown; + qboolean bYUp, bYDown; + qboolean bZDown; + int i; + int iIndex; + int iX, iY, iZ; + int iMinX, iMinY, iMinZ; + int iMaxX, iMaxY, iMaxZ; + float fOfs; + cvssource_t *pSTLatch; pCurrent = pActiveSources->prev; - if (pCurrent != pActiveSources) { - qboolean bXUp, bXDown; - qboolean bYUp, bYDown; - qboolean bZDown; - int i; - int iIndex; - int iX, iY, iZ; - int iMinX, iMinY, iMinZ; - int iMaxX, iMaxY, iMaxZ; - float fOfs; - cvssource_t *pSTLatch; + if (pCurrent == pActiveSources) { + return; + } - memset(vss_sorttable, 0, sizeof(vss_sorttable)); + memset(vss_sorttable, 0, sizeof(vss_sorttable)); - while (pCurrent != pActiveSources) { - VectorClear(pCurrent->repulsion); + for (pCurrent = pActiveSources->prev; pCurrent != pActiveSources; pCurrent = pCurrent->prev) { + VectorClear(pCurrent->repulsion); - iIndex = ((int)floor(pCurrent->newOrigin[0] + 8192.0 + 0.5) / 96) % 32; - iIndex |= ((int)floor(pCurrent->newOrigin[1] + 8192.0 + 0.5) / 96) % 32; - iIndex |= (((int)floor(pCurrent->newOrigin[2] + 8192.0 + 0.5) / 96) % 16) << 10; + iIndex = ((int)floor(pCurrent->newOrigin[0] + 8192.0 + 0.5) / 96) % 32; + iIndex |= (((int)floor(pCurrent->newOrigin[1] + 8192.0 + 0.5) / 96) % 32) << 5; + iIndex |= (((int)floor(pCurrent->newOrigin[2] + 8192.0 + 0.5) / 96) % 16) << 10; - pCurrent->stnext = vss_sorttable[iIndex]; - vss_sorttable[iIndex] = pCurrent; - pCurrent->stindex = iIndex; - pCurrent = pCurrent->prev; + pCurrent->stnext = vss_sorttable[iIndex]; + vss_sorttable[iIndex] = pCurrent; + pCurrent->stindex = iIndex; + } + + for (pCurrent = pActiveSources->prev; pCurrent != pActiveSources; pCurrent = pCurrent->prev) { + if (vss_sorttable[pCurrent->stindex] == pCurrent) { + pSTLatch = (cvssource_t *)-1; + pComp = pCurrent->stnext; + } else { + pSTLatch = 0; + pComp = vss_sorttable[pCurrent->stindex]; } - for (pCurrent = pActiveSources->prev; pCurrent != pActiveSources; pCurrent = pCurrent->prev) { - if (vss_sorttable[pCurrent->stindex] == pCurrent) { - pSTLatch = (cvssource_t *)-1; - pComp = pCurrent->stnext; - } else { - pSTLatch = 0; - pComp = vss_sorttable[pCurrent->stindex]; + for(; pComp; pComp = pComp->stnext) { + VSS_AddRepulsion(pCurrent, pComp); + if (!pSTLatch && pComp->stnext == pCurrent) { + pSTLatch = pComp; + // skip current + pComp = pComp->stnext; + } + } + + iX = ((int)floor(pCurrent->newOrigin[0] + 8192.0 + 0.5) / 96) % 32; + iY = (((int)floor(pCurrent->newOrigin[1] + 8192.0 + 0.5) / 96) % 32) << 5; + iZ = (((int)floor(pCurrent->newOrigin[2] + 8192.0 + 0.5) / 96) % 16) << 10; + + fOfs = pCurrent->newRadius + 1.49 + 48.0; + iMaxX = ((int)floor(pCurrent->newOrigin[0] + fOfs + 8192.0 + 0.5) / 96) % 32; + iMaxY = (((int)floor(pCurrent->newOrigin[1] + fOfs + 8192.0 + 0.5) / 96) % 32) << 5; + iMaxZ = (((int)floor(pCurrent->newOrigin[2] + fOfs + 8192.0 + 0.5) / 96) % 16) << 10; + + iMinX = ((int)floor(pCurrent->newOrigin[0] - fOfs + 8192.0 + 0.5) / 96) % 32; + iMinY = (((int)floor(pCurrent->newOrigin[1] - fOfs + 8192.0 + 0.5) / 96) % 32) << 5; + iMinZ = (((int)floor(pCurrent->newOrigin[2] - fOfs + 8192.0 + 0.5) / 96) % 16) << 10; + + bXUp = (iMaxX | (pCurrent->stindex & 0xFFFFFFE0)) != pCurrent->stindex; + bXDown = (iMinX | (pCurrent->stindex & 0xFFFFFFE0)) != pCurrent->stindex; + bYUp = (iMaxY | (pCurrent->stindex & 0xFFFFFC1F)) != pCurrent->stindex; + bYDown = (iMinY | (pCurrent->stindex & 0xFFFFFC1F)) != pCurrent->stindex; + + iIndex = iMinZ | (pCurrent->stindex & 0xFFFFC3FF); + bZDown = iIndex != pCurrent->stindex; + + if (iIndex == pCurrent->stindex) { + iIndex = iMaxY | (pCurrent->stindex & 0xFFFFFC1F); + + i = 9; + } else { + i = 0; + } + + for (; i < (bZDown ? 26 : 17); i++) { + switch (i) { + case 0: + iIndex = iMaxZ | (pCurrent->stindex & 0xFFFFC3FF); + break; + case 1: + iIndex = iMaxX | (iIndex & 0xFFFFFFE0); + if (bXUp) { + break; + } + continue; + case 2: + iIndex = iMaxY | (iIndex & 0xFFFFFC1F); + if (bXUp && bYUp) { + break; + } + continue; + case 3: + iIndex = iMinY | (iIndex & 0xFFFFFC1F); + if (bXUp && bYDown) { + break; + } + continue; + case 4: + iIndex = iMinY | (iIndex & 0xFFFFFFE0); + if (bYDown) { + break; + } + continue; + case 5: + iIndex = iMinX | (iIndex & 0xFFFFFFE0); + if (bXDown && bYDown) { + break; + } + continue; + case 6: + iIndex = iY | (iIndex & 0xFFFFFC1F); + if (bXDown) { + break; + } + continue; + case 7: + iIndex = iMaxY | (iIndex & 0xFFFFFC1F); + if (bXDown && bYUp) { + break; + } + continue; + case 8: + iIndex = iX | (iIndex & 0xFFFFFFE0); + if (bYUp) { + break; + } + continue; + case 9: + iIndex = iZ | (iIndex & 0xFFFFFFC3); + if (bYUp) { + break; + } + continue; + case 10: + iIndex = iMaxX | (iIndex & 0xFFFFFFE0); + if (bXUp && bYUp) { + break; + } + continue; + case 11: + iIndex = iMinX | (iIndex & 0xFFFFFFE0); + if (bXDown && bYUp) { + break; + } + continue; + case 12: + iIndex = iY | (iIndex & 0xFFFFFC1F); + if (bXDown) { + break; + } + continue; + case 13: + iIndex = iMinY | (iIndex & 0xFFFFFC1F); + if (bXDown && bYDown) { + break; + } + continue; + case 14: + iIndex = iX | (iIndex & 0xFFFFFFE0); + if (bYDown) { + break; + } + continue; + case 15: + iIndex = iMaxX | (iIndex & 0xFFFFFFE0); + if (bXUp && bYDown) { + break; + } + continue; + case 16: + iIndex = iY | (iIndex & 0xFFFFFC1F); + if (bXUp) { + break; + } + continue; + case 17: + iIndex = iMinZ | (iIndex & 0xFFFFFCC3); + if (bXUp) { + break; + } + continue; + case 18: + iIndex = iMaxY | (iIndex & 0xFFFFFC1F); + if (bXUp && bYUp) { + break; + } + continue; + case 19: + iIndex = iMinY | (iIndex & 0xFFFFFC1F); + if (bXUp && bYDown) { + break; + } + continue; + case 20: + iIndex = iX | (iIndex & 0xFFFFFFE0); + if (bYDown) { + break; + } + continue; + case 21: + iIndex = iMinX | (iIndex & 0xFFFFFFE0); + if (bXDown && bYDown) { + break; + } + continue; + case 22: + iIndex = iY | (iIndex & 0xFFFFFC1F); + if (bXDown) { + break; + } + continue; + case 23: + iIndex = iMaxY | (iIndex & 0xFFFFFC1F); + if (bXDown && bYUp) { + break; + } + continue; + case 24: + iIndex = iX | (iIndex & 0xFFFFFFE0); + if (bYUp) { + break; + } + continue; + case 25: + iIndex = iY | (iIndex & 0xFFFFFC1F); + break; + default: + assert(0); // This can't happen + break; } - while (pComp) { + for (pComp = vss_sorttable[iIndex]; pComp; pComp = pComp->stnext) { VSS_AddRepulsion(pCurrent, pComp); - if (!pSTLatch && pComp->stnext == pCurrent) { - pSTLatch = pComp; - pComp = pComp->stnext; - } - - pComp = pComp->stnext; } - iX = ((int)floor(pCurrent->newOrigin[0] + 8192.0 + 0.5) / 96) % 32; - iY = ((int)floor(pCurrent->newOrigin[1] + 8192.0 + 0.5) / 96) % 32; - iY *= 2; - iZ = ((int)floor(pCurrent->newOrigin[2] + 8192.0 + 0.5) / 96) % 16; - iZ <<= 10; + } - fOfs = pCurrent->newRadius + 1.49 + 48.0; - iMaxX = ((int)floor(pCurrent->newOrigin[0] + 8192.0 + 0.5 + fOfs) / 96) % 32; - iMaxY = ((int)floor(pCurrent->newOrigin[1] + 8192.0 + 0.5 + fOfs) / 96) % 32; - iMaxY *= 2; - iMaxZ = ((int)floor(pCurrent->newOrigin[2] + 8192.0 + 0.5 + fOfs) / 96) % 16; - iMaxZ <<= 10; - - iMinX = ((int)floor(pCurrent->newOrigin[0] + 8192.0 + 0.5 - fOfs) / 96) % 32; - iMinY = ((int)floor(pCurrent->newOrigin[1] + 8192.0 + 0.5 - fOfs) / 96) % 32; - iMinY *= 2; - iMinZ = ((int)floor(pCurrent->newOrigin[2] + 8192.0 + 0.5 - fOfs) / 96) % 16; - iMinZ <<= 10; - - bXUp = (iMaxX | (pCurrent->stindex & 0xFFFFFFE0)) != pCurrent->stindex; - bXDown = (iMinX | (pCurrent->stindex & 0xFFFFFFE0)) != pCurrent->stindex; - bYUp = (iMaxY | (pCurrent->stindex & 0xFFFFFC1F)) != pCurrent->stindex; - bYDown = (iMinY | (pCurrent->stindex & 0xFFFFFC1F)) != pCurrent->stindex; - - iIndex = iMinZ | (pCurrent->stindex & 0xFFFFFCC3); - bZDown = iIndex != pCurrent->stindex; - - if (iIndex == pCurrent->stindex) { - iIndex = iMaxY | pCurrent->stindex & 0xFFFFFC1F; - i = 9; - } else { - i = 0; - } - - for(; i < (bZDown ? 26 : 17); i++) { - switch (i) { - case 0: - iIndex = iMaxZ | (pCurrent->stindex & 0xFFFFFCC3); - break; - case 1: - iIndex = iMaxX | (iIndex & 0xFFFFFFE0); - if (bXUp) { - break; - } - continue; - case 2: - iIndex = iMaxY | (iIndex & 0xFFFFFC1F); - if (bXUp && bYUp) { - break; - } - continue; - case 3: - iIndex = iMinY | (iIndex & 0xFFFFFC1F); - if (bXUp && bYDown) { - break; - } - continue; - case 4: - iIndex = iMinY | (iIndex & 0xFFFFFFE0); - if (bYDown) { - break; - } - continue; - case 5: - iIndex = iMinX | (iIndex & 0xFFFFFFE0); - if (bXDown && bYDown) { - break; - } - continue; - case 6: - iIndex = iY | (iIndex & 0xFFFFFC1F); - if (bXDown) { - break; - } - continue; - case 7: - iIndex = iMaxY | (iIndex & 0xFFFFFC1F); - if (bXDown && bYUp) { - break; - } - continue; - case 8: - iIndex = iX | (iIndex & 0xFFFFFFE0); - if (bYUp) { - break; - } - continue; - case 9: - iIndex = iZ | (iIndex & 0xFFFFFFC3); - if (bYUp) { - break; - } - continue; - case 10: - iIndex = iMaxX | (iIndex & 0xFFFFFFE0); - if (bXUp && bYUp) { - break; - } - continue; - case 11: - iIndex = iMinX | (iIndex & 0xFFFFFFE0); - if (bXDown && bYUp) { - break; - } - continue; - case 12: - iIndex = iY | (iIndex & 0xFFFFFC1F); - if (bXDown) { - break; - } - continue; - case 13: - iIndex = iMinY | (iIndex & 0xFFFFFC1F); - if (bXDown && bYDown) { - break; - } - continue; - case 14: - iIndex = iX | (iIndex & 0xFFFFFFE0); - if (bYDown) { - break; - } - continue; - case 15: - iIndex = iMaxX | (iIndex & 0xFFFFFFE0); - if (bXUp && bYDown) { - break; - } - continue; - case 16: - iIndex = iY | (iIndex & 0xFFFFFC1F); - if (bXUp) { - break; - } - continue; - case 17: - iIndex = iMinZ | (iIndex & 0xFFFFFCC3); - if (bXUp) { - break; - } - continue; - case 18: - iIndex = iMaxY | (iIndex & 0xFFFFFC1F); - if (bXUp && bYUp) { - break; - } - continue; - case 19: - iIndex = iMinY | (iIndex & 0xFFFFFC1F); - if (bXUp && bYDown) { - break; - } - continue; - case 20: - iIndex = iX | (iIndex & 0xFFFFFFE0); - if (bYDown) { - break; - } - continue; - case 21: - iIndex = iMinX | (iIndex & 0xFFFFFFE0); - if (bXDown && bYDown) { - break; - } - continue; - case 22: - iIndex = iY | (iIndex & 0xFFFFFC1F); - if (bXDown) { - break; - } - continue; - case 23: - iIndex = iMaxY | (iIndex & 0xFFFFFC1F); - if (bXDown && bYUp) { - break; - } - continue; - case 24: - iIndex = iX | (iIndex & 0xFFFFFFE0); - if (bYUp) { - break; - } - continue; - case 25: - iIndex = iY | (iIndex & 0xFFFFFC1F); - break; - } - - for (pComp = vss_sorttable[iIndex]; pComp; pComp = pComp->stnext) { - VSS_AddRepulsion(pCurrent, pComp); - } - } - - if (pSTLatch == (cvssource_t *)-1) { - vss_sorttable[pCurrent->stindex] = pCurrent->stnext; - } else { - pSTLatch->stnext = pCurrent->stnext; - } + if (pSTLatch == (cvssource_t *)-1) { + vss_sorttable[pCurrent->stindex] = pCurrent->stnext; + } else { + pSTLatch->stnext = pCurrent->stnext; } } } @@ -1222,13 +1223,13 @@ void ClientGameCommandManager::AddVSSSources() pComp = pCurrent->prev; newEnt.renderfx = 0; - if (pCurrent->flags < 0 && !cg_detail->integer) { + if ((pCurrent->flags & T_DETAIL) && !cg_detail->integer) { FreeVSSSource(pCurrent); continue; } - if ((pCurrent->flags2 & 0x4000) != 0) { - newEnt.renderfx = 0x4000000; + if ((pCurrent->flags2 & T2_ALWAYSDRAW) != 0) { + newEnt.renderfx = RF_ALWAYSDRAW; } if (pCurrent->lastPhysicsTime) { @@ -1237,8 +1238,8 @@ void ClientGameCommandManager::AddVSSSources() mstime = physics_rate; } - if (mstime >= physics_rate || (pCurrent->flags2 & 0x10) != 0) { - if (!VSS_SourcePhysics(pCurrent, (float)mstime * 0.001)) { + if (mstime >= physics_rate || (pCurrent->flags2 & T2_PHYSICS_EVERYFRAME) != 0) { + if (!VSS_SourcePhysics(pCurrent, (float)mstime / 1000.0)) { FreeVSSSource(pCurrent); continue; } @@ -1262,26 +1263,18 @@ void ClientGameCommandManager::AddVSSSources() } } - fLerpFrac = (cg.time - pCurrent->lastPhysicsTime) / physics_rate; - if (fLerpFrac > 1.0) { - fLerpFrac = 1.0; - } else if (fLerpFrac < 0.0) { - fLerpFrac = 0.0; - } + fLerpFrac = (float)(cg.time - pCurrent->lastPhysicsTime) / (float)physics_rate; + fLerpFrac = Q_clamp_float(fLerpFrac, 0, 1); - fLightingFrac = (cg.time - pCurrent->lastLightingTime) / lighting_rate; - if (fLightingFrac > 1.0) { - fLightingFrac = 1.0; - } else if (fLightingFrac < 0.0) { - fLightingFrac = 0.0; - } + fLightingFrac = (float)(cg.time - pCurrent->lastLightingTime) / (float)lighting_rate; + fLightingFrac = Q_clamp_float(fLightingFrac, 0, 1); if (lastVSSFrameTime) { pCurrent->lifeTime += frameTime; } if (!pCurrent->lastValid) { - if (!VSS_SourcePhysics(pCurrent, (float)physics_rate * 0.001)) { + if (!VSS_SourcePhysics(pCurrent, (float)physics_rate / 1000)) { ClientGameCommandManager::FreeVSSSource(pCurrent); continue; } @@ -1335,12 +1328,12 @@ void ClientGameCommandManager::AddVSSSources() pCurrent->roll -= j; } - if ((pCurrent->flags & 0x40000) != 0) { + if ((pCurrent->flags & T_RANDOMROLL) != 0) { newEnt.hModel = hModel; } else { newEnt.hModel = hModel2; } - } else if ((pCurrent->flags & 0x40000) != 0) { + } else if ((pCurrent->flags & T_RANDOMROLL) != 0) { newEnt.hModel = hModel; } else { newEnt.hModel = hModel2; diff --git a/code/cgame/memarchiver.cpp b/code/cgame/memarchiver.cpp index f934fe65..a07c4211 100644 --- a/code/cgame/memarchiver.cpp +++ b/code/cgame/memarchiver.cpp @@ -42,23 +42,23 @@ MemArchiver::~MemArchiver() void MemArchiver::SetupForWriting(size_t initialSize) { - state = MEMARC_WRITING; - buffer = (byte*)cgi.Malloc(initialSize); - allocatedSize = initialSize; - bufferSize = 0; + this->state = MEMARC_WRITING; + this->buffer = (byte*)cgi.Malloc(initialSize); + this->allocatedSize = initialSize; + this->bufferSize = 0; } void MemArchiver::SetupForReading(byte* buffer, size_t size) { - state = MEMARC_READING; - buffer = buffer; - allocatedSize = size; - bufferSize = 0; + this->state = MEMARC_READING; + this->buffer = buffer; + this->allocatedSize = size; + this->bufferSize = 0; } void MemArchiver::SetBaseTime(unsigned int time) { - svsTime = time; + this->svsTime = time; } size_t MemArchiver::BufferSize() const diff --git a/code/client/CMakeLists.txt b/code/client/CMakeLists.txt index babaf736..259e055b 100644 --- a/code/client/CMakeLists.txt +++ b/code/client/CMakeLists.txt @@ -1,49 +1,84 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) + project(omohclient) add_subdirectory("../cgame" "./cgame") -file(GLOB_RECURSE SOURCES_CLIENT "./*.c*") +file(GLOB SOURCES_CLIENT "./*.c*") file(GLOB_RECURSE SOURCES_UILIB "../uilib/*.c*") +set(SOURCES_CLIENT ${SOURCES_CLIENT} + # Gamespy + "${CMAKE_SOURCE_DIR}/code/gamespy/cl_gamespy.c" +) + # Made as an interface and not static, as static only links used methods add_library(omohclient INTERFACE) target_compile_definitions(omohclient INTERFACE APP_MODULE) target_compile_features(omohclient INTERFACE cxx_nullptr) target_compile_features(omohclient INTERFACE c_variadic_macros) -target_link_libraries(omohclient INTERFACE omohsdl) +target_link_libraries(omohclient INTERFACE omohsdl_client) target_link_libraries(omohclient INTERFACE gcd) # Sound stuff target_compile_definitions(omohclient INTERFACE USE_CODEC_MP3) -if (USE_SOUND_NEW) - # Try to use OpenAL - find_package(OpenAL) +if (NOT NO_MODERN_DMA) + # Use OpenAL + find_package(OpenAL REQUIRED) + if (OPENAL_FOUND) - target_compile_definitions(omohclient INTERFACE USE_SOUND_NEW=1) + target_compile_definitions(omohclient INTERFACE USE_OPENAL=1 NO_MODERN_DMA=0) if (MSVC) target_include_directories(omohclient INTERFACE ${OPENAL_INCLUDE_DIR}/AL) else() target_include_directories(omohclient INTERFACE ${OPENAL_INCLUDE_DIR}) endif() - target_link_libraries(omohclient INTERFACE ${OPENAL_LIBRARY}) + + if(NOT USE_SYSTEM_LIBS) + target_compile_definitions(omohclient INTERFACE USE_OPENAL_DLOPEN=1) + else() + # Link against system OpenAL + target_link_libraries(omohclient INTERFACE OpenAL::OpenAL) + endif() endif() list(FILTER SOURCES_CLIENT EXCLUDE REGEX "./snd_([a-zA-Z0-9_]+)\.c$") + file(GLOB SOURCES_CLIENT_SND "./snd_*_new.c*" "./snd_codec*.c*") + list(APPEND SOURCES_CLIENT ${SOURCES_CLIENT_SND}) +else() + # + # Fallback to old DMA sound system + # + message(NOTICE "OpenAL was explicitly disabled - fallback to old SDL sound system") + target_compile_definitions(omohclient INTERFACE NO_MODERN_DMA=1) + set(NO_MODERN_DMA TRUE) + + list(FILTER SOURCES_CLIENT EXCLUDE REGEX "./snd_([a-zA-Z0-9_]+)\.cpp$") + file(GLOB_RECURSE SOURCES_CLIENT_SND "./new/*.c*") + list(APPEND SOURCES_CLIENT ${SOURCES_CLIENT_SND}) endif() -if (USE_OPENAL) - # Try to use OpenAL - find_package(OpenAL) - if (OPENAL_FOUND) - target_compile_definitions(omohclient INTERFACE USE_OPENAL=1) - target_include_directories(omohclient INTERFACE ${OPENAL_INCLUDE_DIR}/AL) - target_link_libraries(omohclient INTERFACE ${OPENAL_LIBRARY}) - endif() +set(OLD_VALUE ${BUILD_SHARED_LIBS}) +set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE) + +if(USE_INTERNAL_MAD) + add_subdirectory("../libmad" "./libmad" EXCLUDE_FROM_ALL) + target_link_libraries(omohclient INTERFACE mad) +else() + include(FindPackageHandleStandardArgs) + find_path(LIBMAD_INCLUDE_DIRS mad.h) + find_library(LIBMAD_LIBRARIES mad) + find_package_handle_standard_args( + LibMad + DEFAULT_MSG + LIBMAD_LIBRARIES + LIBMAD_INCLUDE_DIRS + ) + target_include_directories(omohclient INTERFACE ${LIBMAD_INCLUDE_DIRS}) + target_link_libraries(omohclient INTERFACE ${LIBMAD_LIBRARIES}) endif() +set(BUILD_SHARED_LIBS ${OLD_VALUE} CACHE BOOL "" FORCE) + target_sources(omohclient INTERFACE ${SOURCES_CLIENT} ${SOURCES_UILIB}) - -add_subdirectory("../libmad-0.15.1b" "./libmad") -target_link_libraries(omohclient INTERFACE libmad) \ No newline at end of file diff --git a/code/client/cl_cgame.cpp b/code/client/cl_cgame.cpp index 13471caa..e6737760 100644 --- a/code/client/cl_cgame.cpp +++ b/code/client/cl_cgame.cpp @@ -211,20 +211,20 @@ qboolean CL_GetSnapshot( int snapshotNumber, snapshot_t *snapshot ) { } snapshot->numEntities = 0; - for ( i = 0 ; i < count ; i++ ) { + for(i = 0; i < MAX_ENTITIES_IN_SNAPSHOT; i++) { + parents[i] = -1; + } + + for (i = 0; i < count; i++) { s1 = &cl.parseEntities[(clSnap->parseEntitiesNum + i) & (MAX_PARSE_ENTITIES - 1)]; pnum = s1->parent; if (pnum == ENTITYNUM_NONE) { parents[s1->number] = -2; - } - else - { + } else { if (parents[pnum] == -2) { parents[s1->number] = -2; - } - else - { + } else { // add it later parents[s1->number] = pnum; continue; @@ -234,33 +234,37 @@ qboolean CL_GetSnapshot( int snapshotNumber, snapshot_t *snapshot ) { snapshot->entities[snapshot->numEntities++] = *s1; } - for(pcount = 0; pcount < 8 && snapshot->numEntities != count; pcount++) - { - for (i = 0; i < count; i++) - { + for(pcount = 0; pcount < 8 && snapshot->numEntities != count; pcount++) { + for (i = 0; i < count; i++) { s1 = &cl.parseEntities[(clSnap->parseEntitiesNum + i) & (MAX_PARSE_ENTITIES - 1)]; pnum = parents[s1->number]; if (pnum >= 0 && parents[pnum] == -2) { + parents[s1->number] = -2; snapshot->entities[snapshot->numEntities++] = *s1; } } } - if (pcount >= 8) - { - for (i = count; i < snapshot->numEntities; i++) + if (snapshot->numEntities != count) { + Com_DPrintf("CL_GetSnapshot: Not all children could find their parents.\n"); + + for (i = snapshot->numEntities; i < count; i++) { - s1 = &cl.parseEntities[(clSnap->parseEntitiesNum + i) & (MAX_PARSE_ENTITIES - 1)]; - if (parents[s1->number] >= 0) { - Com_DPrintf( - "CL_GetSnapshot: entity %d with parent %d and model '%s' at %.2f %.2f %.2f, could not find parent.\n", - s1->number, - s1->parent, - CL_ConfigString(CS_MODELS + s1->modelindex), - s1->origin[0], - s1->origin[1], - s1->origin[2] - ); + for (pnum = 0; pnum < count; pnum++) { + s1 = &cl.parseEntities[(clSnap->parseEntitiesNum + pnum) & (MAX_PARSE_ENTITIES - 1)]; + if (parents[s1->number] >= 0) { + Com_DPrintf( + "CL_GetSnapshot: entity %d with parent %d and model '%s' at %.2f %.2f %.2f, could not find parent.\n", + s1->number, + s1->parent, + CL_ConfigString(CS_MODELS + s1->modelindex), + s1->origin[0], + s1->origin[1], + s1->origin[2] + ); + + parents[s1->number] = -2; + } } } } @@ -358,7 +362,9 @@ qboolean CL_ProcessServerCommand(const char* origString, const char* cmd, qboole // because this function might be called from a module that would be unloaded // inside Com_Error UI_ForceMenuOff(1); - Cbuf_AddText("disconnect;pushmenu disconnected"); + // Fixed in OPM + // Added a newline for next commands + Cbuf_AddText("disconnect;pushmenu disconnected\n"); return qtrue; } @@ -578,7 +584,7 @@ CL_RestoreSavedCgameState */ void CL_RestoreSavedCgameState() { if (cls.savedCgameState) { - cge->CG_LoadStateToBuffer(&cls.savedCgameState, cls.savedCgameStateSize, cl.snap.serverTime); + cge->CG_LoadStateToBuffer(cls.savedCgameState, cls.savedCgameStateSize, cl.snap.serverTime); } } @@ -621,7 +627,9 @@ void CL_InitCGameDLL( clientGameImport_t *cgi, clientGameExport_t **cge ) { cgi->LV_ConvertString = Sys_LV_CL_ConvertString; cgi->Cvar_Get = Cvar_Get; + cgi->Cvar_Find = Cvar_FindVar; cgi->Cvar_Set = Cvar_Set; + cgi->Cvar_CheckRange = Cvar_CheckRange; cgi->Argc = Cmd_Argc; cgi->Args = Cmd_Args; @@ -765,7 +773,9 @@ void CL_InitCGameDLL( clientGameImport_t *cgi, clientGameExport_t **cge ) { cgi->UI_ShowMenu = UI_ShowMenu; cgi->UI_HideMenu = UI_HideMenu; - cgi->UI_FontStringWidth = uie.FontStringWidth; + cgi->UI_FontStringWidth = CL_FontStringWidth; + cgi->UI_GetObjectivesTop = UI_GetObjectivesTop; + cgi->UI_GetHighResolutionScale = UI_GetHighResolutionScale; cgi->Key_StringToKeynum = Key_StringToKeynum; cgi->Key_KeynumToBindString = Key_KeynumToBindString; cgi->Key_GetKeysForCommand = Key_GetKeysForCommand; @@ -813,6 +823,8 @@ void CL_InitCGameDLL( clientGameImport_t *cgi, clientGameExport_t **cge ) { cgi->CL_RestoreSavedCgameState = CL_RestoreSavedCgameState; cgi->CL_ClearSavedCgameState = CL_ClearSavedCgameState; + cgi->getConfigStringIdNormalized = CPT_NormalizeConfigstring; + cgi->fsDebug = fs_debug; cgi->HudDrawElements = cls.HudDrawElements; cgi->anim = &cls.anim; @@ -912,7 +924,13 @@ void CL_InitCGame( void ) { // find the current mapname info = cl.gameState.stringData + cl.gameState.stringOffsets[ CS_SERVERINFO ]; mapname = Info_ValueForKey( info, "mapname" ); - Com_sprintf( cl.mapname, sizeof( cl.mapname ), "maps/%s.bsp", mapname ); + + if (CL_UseLargeLightmap(mapname)) { + Com_sprintf(cl.mapname, sizeof(cl.mapname), "maps/%s.bsp", mapname); + } else { + // Added in 2.0 + Com_sprintf(cl.mapname, sizeof(cl.mapname), "maps/%s_sml.bsp", mapname); + } S_BeginRegistration(); CL_ShutdownCGame(); @@ -927,10 +945,17 @@ void CL_InitCGame( void ) { CL_InitClientSavedData(); } - // init for this gamestate - // use the lastExecutedServerCommand instead of the serverCommandSequence - // otherwise server commands sent just before a gamestate are dropped - cge->CG_Init( &cgi, clc.serverMessageSequence, clc.lastExecutedServerCommand, clc.clientNum ); + if (cl.snap.valid) { + // init for this gamestate + // use the lastExecutedServerCommand instead of the serverCommandSequence + // otherwise server commands sent just before a gamestate are dropped + cge->CG_Init(&cgi, clc.serverMessageSequence, clc.lastExecutedServerCommand, clc.clientNum); + } else { + // executing client commands from previous map/server might be an issue, some commands might be cs commands, + // like old CS_SYSTEMINFO configstrings which still contain the sv_serverId from previous map. + // It would cause the client to lose the game state number + cge->CG_Init(&cgi, clc.serverMessageSequence, clc.serverCommandSequence, clc.clientNum); + } ClearNewConfigFlag(); TIKI_FinishLoad(); @@ -1105,6 +1130,42 @@ void CL_FirstSnapshot( void ) { Cbuf_AddText( cl_activeAction->string ); Cvar_Set( "activeAction", "" ); } + +#ifdef USE_MUMBLE + if ((cl_useMumble->integer) && !mumble_islinked()) { + int ret = mumble_link(CLIENT_WINDOW_TITLE); + Com_Printf("Mumble: Linking to Mumble application %s\n", ret==0?"ok":"failed"); + } +#endif + +#ifdef USE_VOIP + if (!clc.voipCodecInitialized) { + int i; + int error; + + clc.opusEncoder = opus_encoder_create(48000, 1, OPUS_APPLICATION_VOIP, &error); + + if ( error ) { + Com_DPrintf("VoIP: Error opus_encoder_create %d\n", error); + return; + } + + for (i = 0; i < MAX_CLIENTS; i++) { + clc.opusDecoder[i] = opus_decoder_create(48000, 1, &error); + if ( error ) { + Com_DPrintf("VoIP: Error opus_decoder_create(%d) %d\n", i, error); + return; + } + clc.voipIgnore[i] = qfalse; + clc.voipGain[i] = 1.0f; + } + clc.voipCodecInitialized = qtrue; + clc.voipMuteAll = qfalse; + Cmd_AddCommand ("voip", CL_Voip_f); + Cvar_Set("cl_voipSendTarget", "spatial"); + Com_Memset(clc.voipTargets, ~0, sizeof(clc.voipTargets)); + } +#endif } static int lastSnapFlags; @@ -1155,7 +1216,12 @@ void CL_SetCGameTime( void ) { // allow pause in single player if ( paused->integer && com_sv_running->integer ) { // paused - CL_AdjustTimeDelta(); + //CL_AdjustTimeDelta(); + // Fixed in OPM + // Keep in sync with the server time. + // In OG, the game could lag for a short time + // when pausing and unpausing frequently + cl.serverTimeDelta = cl.snap.serverTime - cls.realtime; return; } diff --git a/code/client/cl_cin.cpp b/code/client/cl_cin.cpp index 38d7a0d6..667a7ef2 100644 --- a/code/client/cl_cin.cpp +++ b/code/client/cl_cin.cpp @@ -35,6 +35,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "../uilib/ui_public.h" #include "snd_local.h" +#include "cl_ui.h" + #define MAXSIZE 8 #define MINSIZE 4 @@ -55,6 +57,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA static void RoQ_init( void ); +static void CL_FinishedCinematic(); /****************************************************************************** * @@ -126,6 +129,10 @@ typedef struct { int playonwalls; byte* buf; long drawX, drawY; + + long realTime; + long currTime; + long soundTime; } cin_cache; static cinematics_t cin; @@ -133,6 +140,10 @@ static cin_cache cinTable[MAX_VIDEO_HANDLES]; static int currentHandle = -1; static int CL_handle = -1; +static connstate_t oldClientState; + +static int audioStartTime = 0; + extern "C" int s_soundtime; // sample PAIRS @@ -160,7 +171,7 @@ static int CIN_HandleForVideo(void) { } -extern "C" int CL_ScaledMilliseconds(void); +extern "C" int Com_Milliseconds(void); //----------------------------------------------------------------------------- // RllSetupTable @@ -1091,8 +1102,6 @@ static void RoQReset( void ) { static void RoQInterrupt(void) { - // Removed in OPM -#if 0 byte *framedata; short sbuf[32768]; int ssize; @@ -1144,24 +1153,20 @@ redump: case ZA_SOUND_MONO: if (!cinTable[currentHandle].silent) { ssize = RllDecodeMonoToStereo( framedata, sbuf, cinTable[currentHandle].RoQFrameSize, 0, (unsigned short)cinTable[currentHandle].roq_flags); - S_RawSamples(0, ssize, 22050, 2, 1, (byte *)sbuf, 1.0f, -1); + // S_RawSamples(0, ssize, 22050, 2, 1, (byte *)sbuf, 1.0f, -1); } break; case ZA_SOUND_STEREO: if (!cinTable[currentHandle].silent) { - if (cinTable[currentHandle].numQuads == -1) { - S_Update(); - s_rawend[0] = s_soundtime; - } ssize = RllDecodeStereoToStereo( framedata, sbuf, cinTable[currentHandle].RoQFrameSize, 0, (unsigned short)cinTable[currentHandle].roq_flags); - S_RawSamples(0, ssize, 22050, 2, 2, (byte *)sbuf, 1.0f, -1); + // S_RawSamples(0, ssize, 22050, 2, 2, (byte *)sbuf, 1.0f, -1); } break; case ROQ_QUAD_INFO: if (cinTable[currentHandle].numQuads == -1) { readQuadInfo( framedata ); setupQuad( 0, 0 ); - cinTable[currentHandle].startTime = cinTable[currentHandle].lastTime = CL_ScaledMilliseconds(); + cinTable[currentHandle].startTime = cinTable[currentHandle].lastTime = Com_Milliseconds(); } if (cinTable[currentHandle].numQuads != 1) cinTable[currentHandle].numQuads = 0; break; @@ -1216,7 +1221,6 @@ redump: // assert(cinTable[currentHandle].RoQFrameSize <= 65536); // r = FS_Read( cin.file, cinTable[currentHandle].RoQFrameSize+8, cinTable[currentHandle].iFile ); cinTable[currentHandle].RoQPlayed += cinTable[currentHandle].RoQFrameSize+8; -#endif } /****************************************************************************** @@ -1229,7 +1233,10 @@ redump: static void RoQ_init( void ) { - cinTable[currentHandle].startTime = cinTable[currentHandle].lastTime = CL_ScaledMilliseconds(); + cinTable[currentHandle].startTime = cinTable[currentHandle].lastTime = Com_Milliseconds(); + cinTable[currentHandle].realTime = Com_Milliseconds(); + cinTable[currentHandle].currTime = 0; + cinTable[currentHandle].soundTime = 0; cinTable[currentHandle].RoQPlayed = 24; @@ -1276,8 +1283,10 @@ static void RoQShutdown( void ) { cinTable[currentHandle].iFile = 0; } + S_StopMovieAudio(); + if (cinTable[currentHandle].alterGameState) { - clc.state = CA_DISCONNECTED; + clc.state = oldClientState; // we can't just do a vstr nextmap, because // if we are aborting the intro cinematic with // a devmap command, nextmap would be valid by @@ -1289,8 +1298,29 @@ static void RoQShutdown( void ) { } CL_handle = -1; } + cinTable[currentHandle].fileName[0] = 0; currentHandle = -1; + + CL_FinishedCinematic(); +} + +static void CL_FinishedCinematic() +{ + const char* s; + + if (!CL_FinishedIntro()) + { + CL_FinishedStartStage(); + return; + } + + s = Cvar_VariableString("nextmap"); + if (*s) + { + Cbuf_ExecuteText(EXEC_APPEND, va("%s\n", s)); + Cvar_Set("nextmap", ""); + } } /* @@ -1331,8 +1361,11 @@ Fetch and decompress the pending frame e_status CIN_RunCinematic (int handle) { - int start = 0; - int thisTime = 0; + int deltaTime; + int frameTime; + int soundTime; + int newTime; + long tfps; if (handle < 0 || handle>= MAX_VIDEO_HANDLES || cinTable[handle].status == FMV_EOF) return FMV_EOF; @@ -1360,24 +1393,46 @@ e_status CIN_RunCinematic (int handle) return cinTable[currentHandle].status; } - thisTime = CL_ScaledMilliseconds(); - if (cinTable[currentHandle].shader && (abs(thisTime - cinTable[currentHandle].lastTime))>100) { - cinTable[currentHandle].startTime += thisTime - cinTable[currentHandle].lastTime; + frameTime = Com_Milliseconds(); + deltaTime = frameTime - cinTable[currentHandle].realTime; + if (deltaTime > 100) { + deltaTime = 100; } - cinTable[currentHandle].tfps = (((CL_ScaledMilliseconds() - cinTable[currentHandle].startTime)*3)/100); - start = cinTable[currentHandle].startTime; - while( (cinTable[currentHandle].tfps != cinTable[currentHandle].numQuads) + newTime = cinTable[currentHandle].currTime + deltaTime; + if (cl_movieaudio->integer) { + soundTime = S_CurrentMoviePosition(); + if (soundTime > cinTable[currentHandle].currTime || soundTime > cinTable[currentHandle].soundTime) { + cinTable[currentHandle].currTime = newTime + (deltaTime * (soundTime - newTime)) / 100; + } + else { + cinTable[currentHandle].currTime = newTime; + } + + cinTable[currentHandle].soundTime = soundTime; + } else { + // + // Fixed in OPM + // + cinTable[currentHandle].currTime = newTime; + } + + cinTable[currentHandle].realTime = frameTime; + + tfps = (cinTable[currentHandle].currTime * 3) / 100; + + while( (tfps != cinTable[currentHandle].numQuads) && (cinTable[currentHandle].status == FMV_PLAY) ) { RoQInterrupt(); - if (start != cinTable[currentHandle].startTime) { - cinTable[currentHandle].tfps = (((CL_ScaledMilliseconds() - cinTable[currentHandle].startTime)*3)/100); - start = cinTable[currentHandle].startTime; + + cinTable[currentHandle].realTime = Com_Milliseconds(); + if (cinTable[currentHandle].realTime > frameTime + 66) { + break; } } - cinTable[currentHandle].lastTime = thisTime; + cinTable[currentHandle].lastTime = frameTime; if (cinTable[currentHandle].status == FMV_LOOPED) { cinTable[currentHandle].status = FMV_PLAY; @@ -1400,9 +1455,6 @@ CIN_PlayCinematic ================== */ int CIN_PlayCinematic( const char *arg, int x, int y, int w, int h, int systemBits ) { - return 0; - // Removed in OPM -#if 0 unsigned short RoQID; char name[MAX_OSPATH]; int i; @@ -1428,7 +1480,7 @@ int CIN_PlayCinematic( const char *arg, int x, int y, int w, int h, int systemBi cin.currentHandle = currentHandle; - strcpy(cinTable[currentHandle].fileName, name); + Q_strncpyz(cinTable[currentHandle].fileName, name, sizeof(cinTable[currentHandle].fileName)); cinTable[currentHandle].ROQSize = 0; cinTable[currentHandle].ROQSize = FS_FOpenFileRead (cinTable[currentHandle].fileName, &cinTable[currentHandle].iFile, qtrue, qtrue); @@ -1474,17 +1526,12 @@ int CIN_PlayCinematic( const char *arg, int x, int y, int w, int h, int systemBi clc.state = CA_CINEMATIC; } - if (!cinTable[currentHandle].silent) { - s_rawend[0] = s_soundtime; - } - return currentHandle; } Com_DPrintf("trFMV::play(), invalid RoQ ID\n"); RoQShutdown(); return -1; -#endif } void CIN_SetExtents (int handle, int x, int y, int w, int h) { @@ -1600,33 +1647,96 @@ void CIN_DrawCinematic (int handle) { cinTable[handle].dirty = qfalse; } +static unsigned short CL_PlayRoQ(const char* name, const char* arg, const char* s) { + unsigned short RoQID; + + Com_Memset(&cin, 0, sizeof(cinematics_t) ); + currentHandle = CIN_HandleForVideo(); + + cin.currentHandle = currentHandle; + + Q_strncpyz(cinTable[currentHandle].fileName, name, sizeof(cinTable[currentHandle].fileName)); + + cinTable[currentHandle].ROQSize = 0; + cinTable[currentHandle].ROQSize = FS_FOpenFileRead (cinTable[currentHandle].fileName, &cinTable[currentHandle].iFile, qtrue, qtrue); + + if (cinTable[currentHandle].ROQSize<=0) { + Com_DPrintf("Can not find RoQ cinematic '%s'\n", name); + CL_FinishedCinematic(); + return -1; + } + + if ((s && s[0] == '1') || Q_stricmp(arg,"demoend.roq")==0 || Q_stricmp(arg,"end.roq")==0) { + cinTable[currentHandle].holdAtEnd = qtrue; + } + + CIN_SetExtents(currentHandle, 0, 0, 640, 480); + cinTable[currentHandle].alterGameState = qtrue; + + initRoQ(); + + FS_Read (cin.file, 16, cinTable[currentHandle].iFile); + + RoQID = (unsigned short)(cin.file[0]) + (unsigned short)(cin.file[1])*256; + if (RoQID == 0x1084) + { + RoQ_init(); +// FS_Read (cin.file, cinTable[currentHandle].RoQFrameSize+8, cinTable[currentHandle].iFile); + + cinTable[currentHandle].status = FMV_PLAY; + Com_DPrintf("trFMV::play(), playing %s\n", arg); + + if (cl_movieaudio->integer) { + audioStartTime = Com_Milliseconds(); + S_SetupMovieAudio(name); + } + + oldClientState = clc.state; + clc.state = CA_CINEMATIC; + + if (cls.glconfig.maxTextureSize <= 256 || s && *s == '2') { + //cinTable[currentHandle].interlaced = qtrue; + } + + CL_handle = currentHandle; + + do { + SCR_RunCinematic(); + } while (!cinTable[currentHandle].buf && cinTable[currentHandle].status == FMV_PLAY); + + UI_CloseConsole(); + + return currentHandle; + } + Com_DPrintf("trFMV::play(), invalid RoQ ID\n"); + + RoQShutdown(); + return -1; +} + void CL_PlayCinematic_f(void) { char *arg, *s; - int bits = CIN_system; + char name[256]; - Com_DPrintf("CL_PlayCinematic_f\n"); if (clc.state == CA_CINEMATIC) { SCR_StopCinematic(); } arg = Cmd_Argv( 1 ); + Com_DPrintf("CL_PlayCinematic( %s )\n", arg); s = Cmd_Argv(2); - if ((s && s[0] == '1') || Q_stricmp(arg,"demoend.roq")==0 || Q_stricmp(arg,"end.roq")==0) { - bits |= CIN_hold; - } - if (s && s[0] == '2') { - bits |= CIN_loop; + CL_StartHunkUsers(qfalse); + S_StopAllSounds2(qtrue); + + Com_sprintf(name, sizeof(name), "video/%s", arg); + + if (Q_stricmp(&name[strlen(name) - 4], ".roq")) { + Com_Printf("Bad or missing cinematic extension.\n"); + return; } - S_StopAllSounds2( qtrue ); - - CL_handle = CIN_PlayCinematic( arg, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, bits ); - if (CL_handle >= 0) { - do { - SCR_RunCinematic(); - } while (cinTable[currentHandle].buf == NULL && cinTable[currentHandle].status == FMV_PLAY); // wait for first frame (load codebook and sound) - } + CL_PlayRoQ(name, arg, s); } @@ -1646,7 +1756,5 @@ void SCR_RunCinematic (void) void SCR_StopCinematic(void) { if (CL_handle >= 0 && CL_handle < MAX_VIDEO_HANDLES) { CIN_StopCinematic(CL_handle); - S_StopAllSounds2( qtrue ); - CL_handle = -1; } } diff --git a/code/client/cl_input.cpp b/code/client/cl_input.cpp index 7f763b44..e2f89d1f 100644 --- a/code/client/cl_input.cpp +++ b/code/client/cl_input.cpp @@ -56,6 +56,10 @@ qboolean in_guimouse; kbutton_t in_up, in_down; +#ifdef USE_VOIP +kbutton_t in_voiprecord; +#endif + kbutton_t in_buttons[16]; qboolean in_mlooking; @@ -258,6 +262,20 @@ void IN_SpeedUp(void) {IN_KeyUp(&in_speed);} void IN_StrafeDown(void) {IN_KeyDown(&in_strafe);} void IN_StrafeUp(void) {IN_KeyUp(&in_strafe);} +#ifdef USE_VOIP +void IN_VoipRecordDown(void) +{ + IN_KeyDown(&in_voiprecord); + Cvar_Set("cl_voipSend", "1"); +} + +void IN_VoipRecordUp(void) +{ + IN_KeyUp(&in_voiprecord); + Cvar_Set("cl_voipSend", "0"); +} +#endif + void IN_Button0Down(void) {IN_KeyDown(&in_buttons[0]);} void IN_Button0Up(void) {IN_KeyUp(&in_buttons[0]);} void IN_Button1Down(void) {IN_KeyDown(&in_buttons[1]);} @@ -432,7 +450,7 @@ void CL_MouseEvent( int dx, int dy, int time ) { if( cl.mousey > cls.glconfig.vidHeight ) cl.mousey = cls.glconfig.vidHeight; } - else + else if ( !paused->integer ) { cl.mouseDx[cl.mouseIndex] += dx; cl.mouseDy[cl.mouseIndex] += dy; @@ -461,6 +479,16 @@ CL_JoystickMove void CL_JoystickMove( usercmd_t *cmd ) { float anglespeed; + float yaw = j_yaw->value * cl.joystickAxis[j_yaw_axis->integer]; + float right = j_side->value * cl.joystickAxis[j_side_axis->integer]; + float forward = j_forward->value * cl.joystickAxis[j_forward_axis->integer]; + float pitch = j_pitch->value * cl.joystickAxis[j_pitch_axis->integer]; + float up = j_up->value * cl.joystickAxis[j_up_axis->integer]; + + if ( in_speed.active ^ cl_run->integer ) { + cmd->buttons |= BUTTON_RUN; + } + if ( in_speed.active ) { anglespeed = 0.001 * cls.frametime * cl_anglespeedkey->value; } else { @@ -468,18 +496,22 @@ void CL_JoystickMove( usercmd_t *cmd ) { } if ( !in_strafe.active ) { - cl.viewangles[YAW] += anglespeed * cl_yawspeed->value * cl.joystickAxis[AXIS_SIDE]; + cl.viewangles[YAW] += anglespeed * yaw; + cmd->rightmove = ClampChar( cmd->rightmove + (int)right ); } else { - cmd->rightmove = ClampChar( cmd->rightmove + cl.joystickAxis[AXIS_SIDE] ); + cl.viewangles[YAW] += anglespeed * right; + cmd->rightmove = ClampChar( cmd->rightmove + (int)yaw ); } if ( in_mlooking ) { - cl.viewangles[PITCH] += anglespeed * cl_pitchspeed->value * cl.joystickAxis[AXIS_FORWARD]; + cl.viewangles[PITCH] += anglespeed * forward; + cmd->forwardmove = ClampChar( cmd->forwardmove + (int)pitch ); } else { - cmd->forwardmove = ClampChar( cmd->forwardmove + cl.joystickAxis[AXIS_FORWARD] ); + cl.viewangles[PITCH] += anglespeed * pitch; + cmd->forwardmove = ClampChar( cmd->forwardmove + (int)forward ); } - cmd->upmove = ClampChar( cmd->upmove + cl.joystickAxis[AXIS_UP] ); + cmd->upmove = ClampChar( cmd->upmove + (int)up ); } /* @@ -565,6 +597,8 @@ void CL_MouseMove( usercmd_t *cmd ) { mx *= cgameSensitivity; my *= cgameSensitivity; + cmd->buttons |= BUTTON_ANY; + // add mouse X/Y movement to cmd if(in_strafe.active) cmd->rightmove = ClampChar(cmd->rightmove + m_side->value * mx); @@ -577,9 +611,9 @@ void CL_MouseMove( usercmd_t *cmd ) { cmd->forwardmove = ClampChar(cmd->forwardmove - m_forward->value * my); if (!isfinite(cl.viewangles[PITCH]) || !isfinite(cl.viewangles[YAW])) { - Com_Printf("Invalid client viewangles encountered!\n"); - Com_Printf("cgameSensitivity: %f - mx: %f - my: %f - m_pitch: %f - m_yaw: %f", cgameSensitivity, mx, my, m_pitch->value, m_yaw->value); - Com_Printf("Resetting client viewangles"); + Com_DPrintf("Invalid client viewangles encountered (view pitch: %f, view yaw: %f)!\n", cl.viewangles[PITCH], cl.viewangles[YAW]); + Com_DPrintf("cgameSensitivity: %f | mx: %f | my: %f | m_pitch: %f | m_yaw: %f\n", cgameSensitivity, mx, my, m_pitch->value, m_yaw->value); + Com_DPrintf("Resetting client viewangles\n"); cl.viewangles[PITCH] = 0; cl.viewangles[YAW] = 0; } @@ -617,8 +651,8 @@ void CL_CmdButtons( usercmd_t *cmd ) { if (UI_MenuActive() || UI_ConsoleIsOpen()) { cmd->buttons |= BUTTON_TALK; } - - if (in_speed.active == !cl_run->integer) { + + if ( in_speed.active ^ cl_run->integer ) { cmd->buttons |= BUTTON_RUN; } @@ -726,6 +760,12 @@ void CL_CreateNewCommands( void ) { frame_msec = com_frameTime - old_com_frameTime; + // if running over 1000fps, act as if each frame is 1ms + // prevents divisions by zero + if ( frame_msec < 1 ) { + frame_msec = 1; + } + // if running less than 5fps, truncate the extra time to prevent // unexpected moves after a hitch if ( frame_msec > 200 ) { @@ -826,8 +866,8 @@ qboolean CL_ReadyToSendPacket( void ) { } // check for exceeding cl_maxpackets - if ( cl_maxpackets->integer < 15 ) { - Cvar_Set( "cl_maxpackets", "15" ); + if ( cl_maxpackets->integer < 30 ) { + Cvar_Set( "cl_maxpackets", "30" ); } else if ( cl_maxpackets->integer > 125 ) { Cvar_Set( "cl_maxpackets", "125" ); } @@ -917,6 +957,58 @@ void CL_WritePacket( void ) { count = MAX_PACKET_USERCMDS; Com_Printf("MAX_PACKET_USERCMDS\n"); } + +#ifdef USE_VOIP + if (clc.voipOutgoingDataSize > 0) + { + if((clc.voipFlags & VOIP_SPATIAL) || Com_IsVoipTarget(clc.voipTargets, sizeof(clc.voipTargets), -1)) + { + MSG_WriteByte (&buf, clc_voipOpus); + MSG_WriteByte (&buf, clc.voipOutgoingGeneration); + MSG_WriteLong (&buf, clc.voipOutgoingSequence); + MSG_WriteByte (&buf, clc.voipOutgoingDataFrames); + MSG_WriteData (&buf, clc.voipTargets, sizeof(clc.voipTargets)); + MSG_WriteByte(&buf, clc.voipFlags); + MSG_WriteShort (&buf, clc.voipOutgoingDataSize); + MSG_WriteData (&buf, clc.voipOutgoingData, clc.voipOutgoingDataSize); + + // If we're recording a demo, we have to fake a server packet with + // this VoIP data so it gets to disk; the server doesn't send it + // back to us, and we might as well eliminate concerns about dropped + // and misordered packets here. + if(clc.demorecording && !clc.demowaiting) + { + const int voipSize = clc.voipOutgoingDataSize; + msg_t fakemsg; + byte fakedata[MAX_MSGLEN]; + MSG_Init (&fakemsg, fakedata, sizeof (fakedata)); + MSG_Bitstream (&fakemsg); + MSG_WriteLong (&fakemsg, clc.reliableAcknowledge); + MSG_WriteByte (&fakemsg, svc_voipOpus); + MSG_WriteShort (&fakemsg, clc.clientNum); + MSG_WriteByte (&fakemsg, clc.voipOutgoingGeneration); + MSG_WriteLong (&fakemsg, clc.voipOutgoingSequence); + MSG_WriteByte (&fakemsg, clc.voipOutgoingDataFrames); + MSG_WriteShort (&fakemsg, clc.voipOutgoingDataSize ); + MSG_WriteBits (&fakemsg, clc.voipFlags, VOIP_FLAGCNT); + MSG_WriteData (&fakemsg, clc.voipOutgoingData, voipSize); + MSG_WriteByte (&fakemsg, svc_EOF); + CL_WriteDemoMessage (&fakemsg, 0); + } + + clc.voipOutgoingSequence += clc.voipOutgoingDataFrames; + clc.voipOutgoingDataSize = 0; + clc.voipOutgoingDataFrames = 0; + } + else + { + // We have data, but no targets. Silently discard all data + clc.voipOutgoingDataSize = 0; + clc.voipOutgoingDataFrames = 0; + } + } +#endif + if ( count >= 1 ) { if ( cl_showSend->integer ) { Com_Printf( "(%i)", count ); @@ -973,16 +1065,6 @@ void CL_WritePacket( void ) { } CL_Netchan_Transmit (&clc.netchan, &buf); - - // clients never really should have messages large enough - // to fragment, but in case they do, fire them all off - // at once - // TTimo: this causes a packet burst, which is bad karma for winsock - // added a WARNING message, we'll see if there are legit situations where this happens - while ( clc.netchan.unsentFragments ) { - Com_DPrintf( "WARNING: #462 unsent fragments (not supposed to happen!)\n" ); - CL_Netchan_TransmitNextFragment( &clc.netchan ); - } } /* @@ -999,7 +1081,7 @@ void CL_SendCmd( void ) { } // don't send commands if paused - if ( com_sv_running->integer && paused->integer && paused->integer ) { + if ( com_sv_running->integer && paused->integer ) { return; } @@ -1094,6 +1176,85 @@ void CL_InitInput( void ) { Cmd_AddCommand("+mlook", IN_MLookDown); Cmd_AddCommand("-mlook", IN_MLookUp); +#ifdef USE_VOIP + Cmd_AddCommand ("+voiprecord", IN_VoipRecordDown); + Cmd_AddCommand ("-voiprecord", IN_VoipRecordUp); +#endif + cl_nodelta = Cvar_Get ("cl_nodelta", "0", 0); cl_debugMove = Cvar_Get ("cl_debugMove", "0", 0); } + +/* +============ +CL_ShutdownInput +============ +*/ +void CL_ShutdownInput(void) +{ + Cmd_RemoveCommand("centerview"); + + Cmd_RemoveCommand("+moveup"); + Cmd_RemoveCommand("-moveup"); + Cmd_RemoveCommand("+movedown"); + Cmd_RemoveCommand("-movedown"); + Cmd_RemoveCommand("+left"); + Cmd_RemoveCommand("-left"); + Cmd_RemoveCommand("+right"); + Cmd_RemoveCommand("-right"); + Cmd_RemoveCommand("+forward"); + Cmd_RemoveCommand("-forward"); + Cmd_RemoveCommand("+back"); + Cmd_RemoveCommand("-back"); + Cmd_RemoveCommand("+lookup"); + Cmd_RemoveCommand("-lookup"); + Cmd_RemoveCommand("+lookdown"); + Cmd_RemoveCommand("-lookdown"); + Cmd_RemoveCommand("+strafe"); + Cmd_RemoveCommand("-strafe"); + Cmd_RemoveCommand("+moveleft"); + Cmd_RemoveCommand("-moveleft"); + Cmd_RemoveCommand("+moveright"); + Cmd_RemoveCommand("-moveright"); + Cmd_RemoveCommand("+speed"); + Cmd_RemoveCommand("-speed"); + Cmd_RemoveCommand("+attack"); + Cmd_RemoveCommand("-attack"); + Cmd_RemoveCommand("+button0"); + Cmd_RemoveCommand("-button0"); + Cmd_RemoveCommand("+button1"); + Cmd_RemoveCommand("-button1"); + Cmd_RemoveCommand("+button2"); + Cmd_RemoveCommand("-button2"); + Cmd_RemoveCommand("+button3"); + Cmd_RemoveCommand("-button3"); + Cmd_RemoveCommand("+button4"); + Cmd_RemoveCommand("-button4"); + Cmd_RemoveCommand("+button5"); + Cmd_RemoveCommand("-button5"); + Cmd_RemoveCommand("+button6"); + Cmd_RemoveCommand("-button6"); + Cmd_RemoveCommand("+button7"); + Cmd_RemoveCommand("-button7"); + Cmd_RemoveCommand("+button8"); + Cmd_RemoveCommand("-button8"); + Cmd_RemoveCommand("+button9"); + Cmd_RemoveCommand("-button9"); + Cmd_RemoveCommand("+button10"); + Cmd_RemoveCommand("-button10"); + Cmd_RemoveCommand("+button11"); + Cmd_RemoveCommand("-button11"); + Cmd_RemoveCommand("+button12"); + Cmd_RemoveCommand("-button12"); + Cmd_RemoveCommand("+button13"); + Cmd_RemoveCommand("-button13"); + Cmd_RemoveCommand("+button14"); + Cmd_RemoveCommand("-button14"); + Cmd_RemoveCommand("+mlook"); + Cmd_RemoveCommand("-mlook"); + +#ifdef USE_VOIP + Cmd_RemoveCommand("+voiprecord"); + Cmd_RemoveCommand("-voiprecord"); +#endif +} diff --git a/code/client/cl_instantAction.cpp b/code/client/cl_instantAction.cpp new file mode 100644 index 00000000..1501121a --- /dev/null +++ b/code/client/cl_instantAction.cpp @@ -0,0 +1,640 @@ +/* +=========================================================================== +Copyright (C) 2025 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA source code 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. + +OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "cl_ui.h" +#include "cl_instantAction.h" +#include "cl_uiserverlist.h" +#include "../gamespy/sv_gamespy.h" + +Event EV_UIInstantAction_AcceptServer +( + "acceptserver", + EV_DEFAULT, + NULL, + NULL, + "Connect to the current server" +); + +Event EV_UIInstantAction_RejectServer +( + "rejectserver", + EV_DEFAULT, + NULL, + NULL, + "Reject the current server" +); + +Event EV_UIInstantAction_Cancel +( + "ia_cancel", + EV_DEFAULT, + NULL, + NULL, + "cancel the server update" +); + +Event EV_UIInstantAction_Refresh +( + "ia_refresh", + EV_DEFAULT, + NULL, + NULL, + "Refresh the server list" +); + +CLASS_DECLARATION(UIWidget, UIInstantAction, NULL) { + {&EV_UIInstantAction_AcceptServer, &UIInstantAction::Connect }, + {&EV_UIInstantAction_RejectServer, &UIInstantAction::Reject }, + {&EV_UIInstantAction_Cancel, &UIInstantAction::CancelRefresh}, + {&EV_UIInstantAction_Refresh, &UIInstantAction::Refresh }, + {NULL, NULL } +}; + +struct ServerListInstance { + int iServerType; + UIInstantAction *pServerList; +}; + +ServerListInstance g_IAServerListInst[2]; + +UIInstantAction::UIInstantAction() +{ + state = IA_INITIALIZE; + numFoundServers = 0; + numServers = 0; + minPlayers = 3; + startingMaxPing = 100; + endingMaxPing = 1500; + maxServers = -1; + servers = NULL; + doneList[0] = false; + doneList[1] = false; + serverList[0] = NULL; + serverList[1] = NULL; + + ReadIniFile(); + EnableServerInfo(false); + + menuManager.PassEventToWidget("ia_cancel_button", new Event(EV_Widget_Disable)); + menuManager.PassEventToWidget("ia_refresh_button", new Event(EV_Widget_Disable)); +} + +UIInstantAction::~UIInstantAction() +{ + CleanUp(); +} + +void UIInstantAction::CleanUp() +{ + if (serverList[0]) { + ServerListFree(serverList[0]); + serverList[0] = NULL; + } + + if (serverList[1]) { + ServerListFree(serverList[1]); + serverList[1] = NULL; + } + + if (servers) { + delete[] servers; + servers = NULL; + } +} + +void UIInstantAction::Init() +{ + const char *secret_key; + const char *game_name; + + static const unsigned int iNumConcurrent = 10; + + numFoundServers = 0; + numServers = 0; + doneList[0] = false; + doneList[1] = false; + + EnableServerInfo(false); + + menuManager.PassEventToWidget("ia_cancel_button", new Event(EV_Widget_Disable)); + menuManager.PassEventToWidget("ia_refresh_button", new Event(EV_Widget_Disable)); + menuManager.PassEventToWidget("ia_noserverfound", new Event(EV_Widget_Disable)); + + Cvar_Set("ia_search_percentage", va("%d %%", 0)); + + if (com_target_game->integer < target_game_e::TG_MOHTT) { + g_IAServerListInst[0].iServerType = com_target_game->integer; + g_IAServerListInst[0].pServerList = this; + + game_name = GS_GetGameName(com_target_game->integer); + secret_key = GS_GetGameKey(com_target_game->integer); + + serverList[0] = ServerListNew( + game_name, + game_name, + secret_key, + iNumConcurrent, + (void *)&IAServerListCallBack, + 1, + (void *)&g_IAServerListInst[0] + ); + + ServerListClear(serverList[0]); + } else { + g_IAServerListInst[0].iServerType = target_game_e::TG_MOHTT; + g_IAServerListInst[0].pServerList = this; + + game_name = GS_GetGameName(target_game_e::TG_MOHTT); + secret_key = GS_GetGameKey(target_game_e::TG_MOHTT); + + serverList[0] = ServerListNew( + game_name, + game_name, + secret_key, + iNumConcurrent, + (void *)&IAServerListCallBack, + 1, + (void *)&g_IAServerListInst[0] + ); + + ServerListClear(serverList[0]); + + g_IAServerListInst[1].iServerType = target_game_e::TG_MOHTA; + g_IAServerListInst[1].pServerList = this; + + game_name = GS_GetGameName(target_game_e::TG_MOHTA); + secret_key = GS_GetGameKey(target_game_e::TG_MOHTA); + + serverList[1] = ServerListNew( + game_name, + game_name, + secret_key, + iNumConcurrent, + (void *)&IAServerListCallBack, + 1, + (void *)&g_IAServerListInst[1] + ); + + ServerListClear(serverList[1]); + } + + state = IA_WAITING; + numFoundServers = 0; + + ServerListUpdate(serverList[0], true); + + if (serverList[1]) { + ServerListUpdate(serverList[1], true); + } + + menuManager.PassEventToWidget("ia_cancel_button", new Event(EV_Widget_Enable)); + menuManager.PassEventToWidget("searchstatus", new Event(EV_Widget_Enable)); + menuManager.PassEventToWidget("searchstatuslable", new Event(EV_Widget_Enable)); +} + +int UIInstantAction::GetServerIndex(int maxPing, int gameType) +{ + int bestPing = 1500; + int bestServer = -1; + int i; + + for (i = 0; i < numFoundServers; i++) { + const IAServer_t& IAServer = servers[i]; + + char *gameVer; + float fGameVer; + int ping; + int numPlayers; + + if (IAServer.rejected) { + continue; + } + + // Skip servers that don't match the provided game type + if (ServerGetIntValue(IAServer.server, "g_gametype_i", 1) != gameType) { + continue; + } + + // Skip servers with high ping + ping = ServerGetPing(IAServer.server); + if (ping > maxPing) { + continue; + } + + gameVer = ServerGetStringValue(IAServer.server, "gamever", "1.00"); + if (com_target_demo->integer && *gameVer != 'd') { + // Skip retail servers on demo game + continue; + } else if (!com_target_demo->integer && *gameVer == 'd') { + // Skip demo servers on retail game + continue; + } + + // Skip incompatible servers + fGameVer = atof(gameVer); + if (com_target_game->integer >= target_game_e::TG_MOHTT) { + if (IAServer.serverGame.serverType == target_game_e::TG_MOHTT) { + if (fabs(fGameVer) < 2.3f) { + continue; + } + } else { + if (fabs(fGameVer) < 2.1f) { + continue; + } + } + } else { + if (fabs(fGameVer - com_target_version->value) > 0.1f) { + continue; + } + } + + // Skip servers with a password + if (ServerGetIntValue(IAServer.server, "password", 0)) { + continue; + } + + // Skip servers that don't match the minimum number of players + numPlayers = ServerGetIntValue(IAServer.server, "numplayers", 0); + if (numPlayers < minPlayers) { + continue; + } + + // Skip full servers + if (numPlayers == ServerGetIntValue(IAServer.server, "maxplayers", 0)) { + continue; + } + + // Skip servers with an higher ping than the best one + if (ping >= bestPing) { + continue; + } + + // + // Found a potential server + // + + bestPing = ping; + bestServer = i; + } + + return bestServer; +} + +void UIInstantAction::ReadIniFile() +{ + char *buffer; + const char *p; + const char *pVal; + int intValue; + char value[32]; + + if (!FS_ReadFileEx("iaction.ini", (void **)&buffer, qtrue)) { + return; + } + + for (p = buffer; p; p = strstr(pVal, "\n")) { + if (sscanf(p, "%31s", value) != 1) { + break; + } + + pVal = strstr(p, "="); + if (!pVal) { + break; + } + + pVal++; + + if (sscanf(pVal, "%d", &intValue) != 1) { + break; + } + + if (!Q_stricmpn(value, "MinPlayers", 10)) { + minPlayers = intValue; + } + + if (!Q_stricmpn(value, "StartingMaxPing", 15)) { + startingMaxPing = intValue; + } + + if (!Q_stricmpn(value, "EndingMaxPing", 13)) { + endingMaxPing = intValue; + } + + if (!Q_stricmpn(value, "MaxServers", 10)) { + maxServers = intValue; + } + } +} + +void UIInstantAction::FindServer() +{ + int ping; + int i; + + currentServer = -1; + state = IA_NONE; + + for (ping = startingMaxPing; ping < endingMaxPing; ping += 100) { + // + // Find the best server starting from FFA gametype first + // + for (i = 1; i < 7; i++) { + currentServer = GetServerIndex(ping, i); + if (currentServer >= 0) { + break; + } + } + + if (currentServer >= 0) { + break; + } + } + + menuManager.PassEventToWidget("ia_refresh_button", new Event(EV_Widget_Enable)); + menuManager.PassEventToWidget("ia_cancel_button", new Event(EV_Widget_Disable)); + menuManager.PassEventToWidget("searchstatus", new Event(EV_Widget_Disable)); + menuManager.PassEventToWidget("searchstatuslable", new Event(EV_Widget_Disable)); + + if (currentServer < 0) { + EnableServerInfo(false); + + menuManager.PassEventToWidget("ia_noserverfound", new Event(EV_Widget_Enable)); + return; + } + + const IAServer_t& IAServer = servers[currentServer]; + const char *hostname = ServerGetStringValue(IAServer.server, "hostname", "(NONE)"); + const char *gametype = ServerGetStringValue(IAServer.server, "gametype", "(NONE)"); + int numplayers = ServerGetIntValue(IAServer.server, "numplayers", 0); + int maxplayers = ServerGetIntValue(IAServer.server, "maxplayers", 0); + ping = ServerGetPing(IAServer.server); + + Cvar_Set("ia_servername", va(" %s", hostname)); + Cvar_Set("ia_ping", va("%d", ping)); + Cvar_Set("ia_gametype", va("%s", gametype)); + Cvar_Set("ia_players", va("%d", numplayers)); + Cvar_Set("ia_maxplayers", va("%d", maxplayers)); + + EnableServerInfo(true); +} + +void UIInstantAction::Connect(Event *ev) +{ + char *gameVer; + float fGameVer; + bool bDiffVersion; + char command[256]; + + if (currentServer < 0 || currentServer < numServers) { + return; + } + + const IAServer_t& IAServer = servers[currentServer]; + + gameVer = ServerGetStringValue(IAServer.server, "gamever", "1.00"); + if (gameVer[0] == 'd') { + gameVer++; + } + + // Skip incompatible servers + fGameVer = atof(gameVer); + bDiffVersion = false; + if (com_target_game->integer >= target_game_e::TG_MOHTT) { + if (IAServer.serverGame.serverType == target_game_e::TG_MOHTT) { + if (fabs(fGameVer) < 2.3f) { + bDiffVersion = true; + } + } else { + if (fabs(fGameVer) < 2.1f) { + bDiffVersion = true; + } + } + } else { + if (fabs(fGameVer - com_target_version->value) > 0.1f) { + bDiffVersion = true; + } + } + + if (bDiffVersion) { + if (fGameVer - com_target_version->value > 0) { + // Older version + UI_SetReturnMenuToCurrent(); + Cvar_Set("com_errormessage", va("Server is version %s, you are using %s", gameVer, "2.40")); + UI_PushMenu("wrongversion"); + } else { + // Server version is newer + Cvar_Set("dm_serverstatus", va("Can not connect to v%s server, you are using v%s", gameVer, "2.40")); + } + } + + UI_SetReturnMenuToCurrent(); + Cvar_Set("g_servertype", va("%d", servers[currentServer].serverGame.serverType)); + + Com_sprintf( + command, + sizeof(command), + "connect %s:%i\n", + ServerGetAddress(IAServer.server), + ServerGetIntValue(IAServer.server, "hostport", PORT_SERVER) + ); + Cbuf_AddText(command); +} + +void UIInstantAction::Reject(Event *ev) +{ + servers[currentServer].rejected = 1; + FindServer(); +} + +void UIInstantAction::Draw() +{ + switch (state) { + case IA_INITIALIZE: + Init(); + break; + case IA_UPDATE: + Update(); + break; + case IA_FINISHED: + FindServer(); + break; + default: + break; + } + + if (serverList[0]) { + ServerListThink(serverList[0]); + } + + if (serverList[1]) { + ServerListThink(serverList[1]); + } +} + +void UIInstantAction::Update() +{ + numFoundServers = 0; + + // count the total number of servers from both server list + numServers = ServerListCount(serverList[0]); + if (serverList[1]) { + numServers += ServerListCount(serverList[1]); + } + + state = IA_FINISHED; + servers = new IAServer_t[numServers]; + + ServerListHalt(serverList[0]); + if (serverList[1]) { + ServerListHalt(serverList[1]); + } + + ServerListThink(serverList[0]); + if (serverList[1]) { + ServerListThink(serverList[1]); + } + + state = IA_SEARCHING; + + // Start updating the first list + doneList[0] = false; + ServerListClear(serverList[0]); + ServerListUpdate(serverList[0], true); + + // Update the second optional list + if (serverList[1]) { + doneList[1] = false; + ServerListClear(serverList[1]); + ServerListUpdate(serverList[1], true); + } +} + +int UIInstantAction::AddServer(GServer server, const ServerGame_t& serverGame) +{ + servers[numFoundServers].server = server; + servers[numFoundServers].serverGame = serverGame; + servers[numFoundServers].rejected = false; + numFoundServers++; + + return numFoundServers; +} + +void UIInstantAction::CancelRefresh(Event *ev) +{ + state = IA_FINISHED; + ServerListHalt(serverList[0]); + ServerListHalt(serverList[1]); +} + +void UIInstantAction::Refresh(Event *ev) +{ + state = IA_INITIALIZE; +} + +void UIInstantAction::EnableServerInfo(bool enable) +{ + if (enable) { + menuManager.PassEventToWidget("iaservername_label", new Event(EV_Widget_Enable)); + menuManager.PassEventToWidget("ia_servername_field", new Event(EV_Widget_Enable)); + menuManager.PassEventToWidget("ia_ping_label", new Event(EV_Widget_Enable)); + menuManager.PassEventToWidget("ia_ping_field", new Event(EV_Widget_Enable)); + menuManager.PassEventToWidget("ia_gametype_label", new Event(EV_Widget_Enable)); + menuManager.PassEventToWidget("ia_gametype_field", new Event(EV_Widget_Enable)); + menuManager.PassEventToWidget("ia_players_label", new Event(EV_Widget_Enable)); + menuManager.PassEventToWidget("ia_players_field", new Event(EV_Widget_Enable)); + menuManager.PassEventToWidget("ia_maxplayers_label", new Event(EV_Widget_Enable)); + menuManager.PassEventToWidget("ia_maxplayers_field", new Event(EV_Widget_Enable)); + menuManager.PassEventToWidget("acceptserver", new Event(EV_Widget_Enable)); + menuManager.PassEventToWidget("rejectserver", new Event(EV_Widget_Enable)); + } else { + menuManager.PassEventToWidget("iaservername_label", new Event(EV_Widget_Disable)); + menuManager.PassEventToWidget("ia_servername_field", new Event(EV_Widget_Disable)); + menuManager.PassEventToWidget("ia_ping_label", new Event(EV_Widget_Disable)); + menuManager.PassEventToWidget("ia_ping_field", new Event(EV_Widget_Disable)); + menuManager.PassEventToWidget("ia_gametype_label", new Event(EV_Widget_Disable)); + menuManager.PassEventToWidget("ia_gametype_field", new Event(EV_Widget_Disable)); + menuManager.PassEventToWidget("ia_players_label", new Event(EV_Widget_Disable)); + menuManager.PassEventToWidget("ia_players_field", new Event(EV_Widget_Disable)); + menuManager.PassEventToWidget("ia_maxplayers_label", new Event(EV_Widget_Disable)); + menuManager.PassEventToWidget("ia_maxplayers_field", new Event(EV_Widget_Disable)); + menuManager.PassEventToWidget("acceptserver", new Event(EV_Widget_Disable)); + menuManager.PassEventToWidget("rejectserver", new Event(EV_Widget_Disable)); + } +} + +void UIInstantAction::IAServerListCallBack(GServerList serverlist, int msg, void *instance, void *param1, void *param2) +{ + const ServerListInstance *pInstance = (const ServerListInstance *)instance; + UIInstantAction *pServerList = pInstance->pServerList; + + if (msg == LIST_PROGRESS) { + if (pServerList->state == IA_WAITING) { + if (pInstance->iServerType == com_target_game->integer) { + pServerList->doneList[0] = true; + } + + if (com_target_game->integer >= target_game_e::TG_MOHTT && pInstance->iServerType == target_game_e::TG_MOHTA) { + pServerList->doneList[1] = true; + } + + if (pServerList->doneList[0] && (!pServerList->serverList[1] || pServerList->doneList[1])) { + pServerList->state = IA_UPDATE; + } + } else if (pServerList->state == IA_SEARCHING) { + ServerGame_t serverGame; + serverGame.serverType = pInstance->iServerType; + const int serverIndex = pServerList->AddServer((GServer)param1, serverGame); + + Cvar_Set("ia_search_percentage", va("%d %%", 100 * serverIndex / pServerList->numServers)); + + if (pServerList->maxServers >= 0 && serverIndex >= pServerList->maxServers) { + // Reached the maximum number of servers, stop there + pServerList->doneList[0] = true; + ServerListHalt(pServerList->serverList[0]); + + if (pServerList->serverList[1]) { + pServerList->doneList[1] = true; + ServerListHalt(pServerList->serverList[1]); + } + + pServerList->state = IA_FINISHED; + } + } + } else if (msg == LIST_STATECHANGED && ServerListState(serverlist) == GServerListState::sl_idle) { + if (pInstance->iServerType == com_target_game->integer) { + pServerList->doneList[0] = true; + } + + if (com_target_game->integer >= target_game_e::TG_MOHTT && pInstance->iServerType == target_game_e::TG_MOHTA) { + pServerList->doneList[1] = true; + } + + if (pServerList->doneList[0] && (!pServerList->serverList[1] || pServerList->doneList[1])) { + if (pServerList->state == IA_WAITING) { + pServerList->state = IA_UPDATE; + } + if (pServerList->state == IA_SEARCHING) { + pServerList->state = IA_FINISHED; + } + } + } +} diff --git a/code/client/cl_instantAction.h b/code/client/cl_instantAction.h new file mode 100644 index 00000000..9a838dc5 --- /dev/null +++ b/code/client/cl_instantAction.h @@ -0,0 +1,103 @@ +/* +=========================================================================== +Copyright (C) 2025 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA source code 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. + +OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// Added in 2.30 +// Instantly find a server matching common criterias + +#pragma once + +#include "../gamespy/goaceng.h" + +typedef struct { + int serverType; +} ServerGame_t; + +typedef struct { + GServer server; + ServerGame_t serverGame; + bool rejected; +} IAServer_t; + +enum IAState_e { + IA_NONE, + IA_INITIALIZE, + IA_WAITING, + IA_UPDATE, + IA_SEARCHING, + IA_FINISHED +}; + +class UIInstantAction : public UIWidget +{ +public: + CLASS_PROTOTYPE(UIInstantAction); + +public: + UIInstantAction(); + ~UIInstantAction() override; + + void CleanUp(); + void Init(); + + int GetServerIndex(int maxPing, int gameType); + void ReadIniFile(); + void FindServer(); + void Connect(Event *ev); + void Reject(Event *ev); + void Draw(); + void Update(); + int AddServer(GServer server, const ServerGame_t& serverGame); + void CancelRefresh(Event *ev); + void Refresh(Event *ev); + void EnableServerInfo(bool enable); + +private: + static void IAServerListCallBack(GServerList serverlist, int msg, void *instance, void *param1, void *param2); + +private: + // + // List + // + bool doneList[2]; + GServerList serverList[2]; + int maxServers; + + // + // Current states + // + IAState_e state; + int numServers; + int numFoundServers; + + // + // Filters + // + int minPlayers; + int startingMaxPing; + int endingMaxPing; + + // + // Servers + // + IAServer_t *servers; + int currentServer; +}; diff --git a/code/client/cl_inv.cpp b/code/client/cl_inv.cpp index a4c50dd4..850d766d 100644 --- a/code/client/cl_inv.cpp +++ b/code/client/cl_inv.cpp @@ -23,8 +23,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "cl_ui.h" typedef struct { - char *string; - int value; + const char *string; + int value; } equipment_event_table_t; static equipment_event_table_t s_equipTable[] = { diff --git a/code/client/cl_invrender.cpp b/code/client/cl_invrender.cpp index 0b5bd6f9..cfbdb3f1 100644 --- a/code/client/cl_invrender.cpp +++ b/code/client/cl_invrender.cpp @@ -148,7 +148,7 @@ void CL_Draw3DModel( hModel[iCurrNum] = model; iIndex[iCurrNum] = -1; - strcpy(szAnimName[iCurrNum], anim); + Q_strncpyz(szAnimName[iCurrNum], anim, sizeof(szAnimName[iCurrNum])); } else { iCurrNum = i; @@ -164,7 +164,7 @@ void CL_Draw3DModel( } } else { iIndex[iCurrNum] = -1; - strcpy(szAnimName[iCurrNum], anim); + Q_strncpyz(szAnimName[iCurrNum], anim, sizeof(szAnimName[iCurrNum])); } } @@ -295,7 +295,7 @@ void UI_DoInventory(qboolean activate_mouse) if (client_inv.align == INV_ALIGN_RIGHT) { s_main_inv->InitFrame( NULL, - client_inv.horizoffset + cls.glconfig.vidWidth - client_inv.typewidth, + client_inv.horizoffset + uid.vidWidth - client_inv.typewidth, client_inv.vertoffset, client_inv.typewidth, client_inv.typeheight * client_inv.types.NumObjects(), diff --git a/code/client/cl_keys.cpp b/code/client/cl_keys.cpp index 660ab4e2..39474cb9 100644 --- a/code/client/cl_keys.cpp +++ b/code/client/cl_keys.cpp @@ -984,6 +984,8 @@ CL_InitKeyCommands */ void CL_InitKeyCommands(void) { + int i; + // register our functions Cmd_AddCommand("bind", Key_Bind_f); Cmd_AddCommand("unbind", Key_Unbind_f); @@ -997,6 +999,10 @@ void CL_InitKeyCommands(void) Cmd_AddCommand("ctrlbindlist", Key_AltBindlist_f); memset(menubound, 0, sizeof(menubound)); + + for (i = K_F1; i <= K_F15; i++) { + menubound[i] = qtrue; + } } /* @@ -1089,7 +1095,7 @@ void CL_KeyEvent(int key, qboolean down, unsigned time) if (clc.state > CA_DISCONNECTED && cge && !Key_GetCatcher() && cge->CG_CheckCaptureKey(key, down, time) && key != K_ESCAPE) { - if (key == K_CONSOLE || (keys[K_SHIFT].down && key == K_ESCAPE)) { + if (key != K_CONSOLE && (!keys[K_SHIFT].down || key != K_ESCAPE)) { return; } } @@ -1134,9 +1140,9 @@ void CL_KeyEvent(int key, qboolean down, unsigned time) if (key >= K_MOUSE1 && key <= K_MOUSE5) { if (down) { - cl.mouseButtons |= (1 << (key + (256 - K_MOUSE1))); + cl.mouseButtons |= (1 << (key - K_MOUSE1)); } else { - cl.mouseButtons &= ~(1 << (key + (256 - K_MOUSE1))); + cl.mouseButtons &= ~(1 << (key - K_MOUSE1)); } if (in_guimouse) { @@ -1346,5 +1352,5 @@ Key_SetCatcher */ void Key_SetCatcher(int catcher) { - keyCatchers = catcher; + cls.keyCatchers = catcher; } diff --git a/code/client/cl_main.cpp b/code/client/cl_main.cpp index 5f836f81..dd4ff10c 100644 --- a/code/client/cl_main.cpp +++ b/code/client/cl_main.cpp @@ -29,14 +29,21 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "../qcommon/localization.h" #include "../qcommon/bg_compat.h" #include "../sys/sys_local.h" -#ifdef USE_RENDERER_DLL -#include "../sys/sys_loadlib.h" -#endif +#include "../sys/sys_update_checker.h" +#include "../uilib/uimessage.h" + +extern "C" { + #include "../sys/sys_loadlib.h" +} #include "../gamespy/gcdkey/gcdkeyc.h" #include +#ifdef USE_RENDERER_DLOPEN +cvar_t* cl_renderer; +#endif + cvar_t *cl_nodelta; cvar_t *cl_debugMove; @@ -56,6 +63,8 @@ cvar_t *cl_showTimeDelta; cvar_t *cl_freezeDemo; cvar_t *cl_shownet; +cvar_t *cl_netprofile; +cvar_t *cl_netprofileoverlay; cvar_t *cl_showSend; cvar_t *cl_timedemo; cvar_t *cl_timedemoLog; @@ -118,6 +127,7 @@ cvar_t *cl_r_fullscreen; cvar_t *cl_consoleKeys; cvar_t *name; +cvar_t *cl_rate; clientActive_t cl; clientConnection_t clc; @@ -127,19 +137,14 @@ clientGameExport_t *cge; // Structure containing functions exported from refresh DLL refexport_t re; +#ifdef USE_RENDERER_DLOPEN +static void *rendererLib = NULL; +#endif qboolean camera_reset; qboolean camera_active; vec3_t camera_offset; -#ifdef USE_RENDERER_DLL -// su44: for plugable renderer system -refexport_t* (*DGetRefAPI)(int apiVersion, refimport_t * rimp) = NULL; -static cvar_t *cl_renderer = NULL; -static void *rendererLib = NULL; -#endif // USE_RENDERER_DLL - - ping_t cl_pinglist[MAX_PINGREQUESTS]; typedef struct serverStatus_s @@ -167,9 +172,28 @@ void CL_ShowIP_f(void); void CL_ServerStatus_f(void); void CL_ServerStatusResponse( netadr_t from, msg_t *msg ); -void CL_GamespyServers_f( void ); - static qboolean cl_bCLSystemStarted = qfalse; +static qboolean cl_updateNotified = qfalse; + +/* +=============== +CL_UseLargeLightmap + +Added in 2.0 +Returns true if the standard BSP file should be used, false if the smaller lightmap BSP file should be used +=============== +*/ +qboolean CL_UseLargeLightmap(const char* mapName) { + char buffer[MAX_QPATH]; + + Com_sprintf(buffer, sizeof(buffer), "maps/%s_sml.bsp", mapName); + + if (FS_ReadFileEx(buffer, NULL, qtrue) == -1) { + return qtrue; + } + + return Cvar_Get("r_largemap", "0", 0)->integer; +} /* =============== @@ -706,7 +730,7 @@ void CL_PlayDemo_f( void ) { clc.state = CA_CONNECTED; clc.demoplaying = qtrue; - Q_strncpyz( cls.servername, Cmd_Argv(1), sizeof( cls.servername ) ); + Q_strncpyz( clc.servername, Cmd_Argv(1), sizeof( clc.servername ) ); // read demo messages until connected while ( clc.state >= CA_CONNECTED && clc.state < CA_PRIMED ) { @@ -769,7 +793,7 @@ void CL_ShutdownAll(qboolean shutdownRef) { CL_cURL_Shutdown(); #endif // clear sounds -#if !defined(USE_SOUND_NEW) || !USE_SOUND_NEW +#if defined(NO_MODERN_DMA) && NO_MODERN_DMA S_DisableSounds(); #endif // shutdown CGame @@ -781,9 +805,10 @@ void CL_ShutdownAll(qboolean shutdownRef) { TIKI_FreeAll(); // shutdown the renderer - if ( re.Shutdown ) { - re.Shutdown( qfalse ); // don't destroy window or context - } + if(shutdownRef) + CL_ShutdownRef(); + else if(re.Shutdown) + re.Shutdown(qfalse); // don't destroy window or context cls.uiStarted = qfalse; cls.cgameStarted = qfalse; @@ -832,7 +857,7 @@ void CL_MapLoading( qboolean flush, const char *pszMapName ) { if (pszMapName) { // if we are already connected to the local host, stay connected - if (clc.state >= CA_CONNECTED && !Q_stricmp(cls.servername, "localhost")) { + if (clc.state >= CA_CONNECTED && !Q_stricmp(clc.servername, "localhost")) { clc.state = CA_CONNECTED; // so the connect screen is drawn Com_Memset(cls.updateInfoString, 0, sizeof(cls.updateInfoString)); Com_Memset(clc.serverMessage, 0, sizeof(clc.serverMessage)); @@ -843,11 +868,11 @@ void CL_MapLoading( qboolean flush, const char *pszMapName ) { // clear nextmap so the cinematic shutdown doesn't execute it Cvar_Set("nextmap", ""); CL_Disconnect(); - Q_strncpyz(cls.servername, "localhost", sizeof(cls.servername)); + Q_strncpyz(clc.servername, "localhost", sizeof(clc.servername)); clc.state = CA_CHALLENGING; // so the connect screen is drawn clc.connectStartTime = cls.realtime; clc.connectTime = -RETRANSMIT_TIMEOUT; - NET_StringToAdr(cls.servername, &clc.serverAddress, NA_UNSPEC); + NET_StringToAdr(clc.servername, &clc.serverAddress, NA_UNSPEC); // we don't need a challenge on the localhost CL_CheckForResend(); @@ -912,6 +937,8 @@ This is also called on Com_Error and Com_Quit, so it shouldn't cause any errors ===================== */ void CL_Disconnect() { + int mouseX, mouseY; + if ( !com_cl_running || !com_cl_running->integer ) { return; } @@ -947,8 +974,16 @@ void CL_Disconnect() { CL_WritePacket(); } + // Fixed in OPM + // Don't reset the mouse every time the client disconnects + mouseX = cl.mousex; + mouseY = cl.mousey; + CL_ClearState (); + cl.mousex = mouseX; + cl.mousey = mouseY; + // wipe the client connection Com_Memset( &clc, 0, sizeof( clientConnection_t ) ); @@ -1049,7 +1084,7 @@ void CL_RequestMotd( void ) { Info_SetValueForKey( info, "renderer", cls.glconfig.renderer_string ); Info_SetValueForKey( info, "version", com_version->string ); - NET_OutOfBandPrint( NS_CLIENT, cls.updateServer, "getmotd \"%s\"\n", info ); + CL_NET_OutOfBandPrint( cls.updateServer, "getmotd \"%s\"\n", info ); } /* @@ -1132,7 +1167,7 @@ void CL_RequestAuthorization( void ) { fs = Cvar_Get ("cl_anonymous", "0", CVAR_INIT|CVAR_SYSTEMINFO ); - NET_OutOfBandPrint(NS_CLIENT, cls.authorizeServer, "getKeyAuthorize %i %s", fs->integer, nums ); + CL_NET_OutOfBandPrint(cls.authorizeServer, "getKeyAuthorize %i %s", fs->integer, nums ); } /* @@ -1174,12 +1209,12 @@ void CL_Setenv_f( void ) { char buffer[1024]; int i; - strcpy( buffer, Cmd_Argv(1) ); - strcat( buffer, "=" ); + Q_strncpyz( buffer, Cmd_Argv(1), sizeof( buffer ) ); + Q_strcat( buffer, sizeof( buffer ), "=" ); for ( i = 2; i < argc; i++ ) { - strcat( buffer, Cmd_Argv( i ) ); - strcat( buffer, " " ); + Q_strcat( buffer, sizeof( buffer ), Cmd_Argv( i ) ); + Q_strcat( buffer, sizeof( buffer ), " " ); } putenv( buffer ); @@ -1201,28 +1236,32 @@ CL_Disconnect_f ================== */ void CL_Disconnect_f( void ) { - if ( clc.state != CA_DISCONNECTED ) { - qboolean bConsoleState = UI_ConsoleIsOpen(); + qboolean bConsoleState; - Com_Printf("\nDisconnected from server\n"); - SV_Shutdown("Disconnected from server\n"); + if ( clc.state == CA_DISCONNECTED ) { + return; + } - if (com_cl_running && com_cl_running->integer) - { - CL_AbnormalDisconnect(); - CL_FlushMemory(); - CL_StartHunkUsers(qfalse); - S_StopAllSounds2(1); - S_TriggeredMusic_PlayIntroMusic(); - } + bConsoleState = UI_ConsoleIsOpen(); - UI_FocusMenuIfExists(); + Com_Printf("\nDisconnected from server\n"); + SV_Shutdown("Disconnected from server\n"); - if (bConsoleState) { - UI_OpenConsole(); - } else { - UI_CloseConsole(); - } + if (com_cl_running && com_cl_running->integer) + { + CL_AbnormalDisconnect(); + CL_FlushMemory(); + CL_StartHunkUsers(qfalse); + S_StopAllSounds2(1); + S_TriggeredMusic_PlayIntroMusic(); + } + + UI_FocusMenuIfExists(); + + if (bConsoleState) { + UI_OpenConsole(); + } else { + UI_CloseConsole(); } } @@ -1234,12 +1273,12 @@ CL_Reconnect_f ================ */ void CL_Reconnect_f( void ) { - if ( !strlen( cls.servername ) || !strcmp( cls.servername, "localhost" ) ) { + if ( !strlen( clc.servername ) || !strcmp( clc.servername, "localhost" ) ) { Com_Printf( "Can't reconnect to localhost.\n" ); return; } Cvar_Set("ui_singlePlayerActive", "0"); - Cbuf_AddText( va("connect %s\n", cls.servername ) ); + Cbuf_AddText( va("connect %s\n", clc.servername ) ); } /* @@ -1275,9 +1314,9 @@ void CL_Connect( const char *server, netadrtype_t family ) { CL_FlushMemory( ); */ - Q_strncpyz( cls.servername, server, sizeof( cls.servername ) ); + Q_strncpyz( clc.servername, server, sizeof( clc.servername ) ); - if( !NET_StringToAdr( cls.servername, &clc.serverAddress, family ) ) { + if( !NET_StringToAdr( clc.servername, &clc.serverAddress, family ) ) { Com_Printf( "Bad server address\n" ); clc.state = CA_DISCONNECTED; UI_PushMenu("badserveraddy"); @@ -1288,7 +1327,7 @@ void CL_Connect( const char *server, netadrtype_t family ) { } serverString = NET_AdrToStringwPort(clc.serverAddress); - Com_Printf( "%s resolved to %s\n", cls.servername, serverString ); + Com_Printf( "%s resolved to %s\n", clc.servername, serverString ); if (cl_guidServerUniq->integer) CL_UpdateGUID(serverString, strlen(serverString)); @@ -1464,7 +1503,11 @@ void CL_Rcon_f( void ) { } } - NET_SendPacket (NS_CLIENT, strlen(message)+1, message, to); + NET_SendPacket (NS_CLIENT, strlen(message) + 1, message, to); + + if (cl_netprofile->integer) { + NetProfileAddPacket(&cls.netprofile.inPackets, strlen(message) + 1, NETPROF_PACKET_MESSAGE); + } } /* @@ -1483,10 +1526,9 @@ void CL_SendPureChecksums( void ) { // "cp" // "Yf" Com_sprintf(cMsg, sizeof(cMsg), "Yf "); - Q_strcat(cMsg, sizeof(cMsg), va("%d ", cl.serverId) ); Q_strcat(cMsg, sizeof(cMsg), pChecksums); for (i = 0; i < 2; i++) { - cMsg[i] += 10; + cMsg[i] += '\n'; } CL_AddReliableCommand( cMsg, qfalse ); } @@ -1515,6 +1557,12 @@ because the renderer doesn't know what graphics to reload ================= */ void CL_Vid_Restart_f( void ) { + soundsystemsavegame_t save; + char tm_filename[MAX_RES_NAME]; + int tm_loopcount; + int tm_offset; + char current_soundtrack[128]; + if (!CL_Allowed_Vid_Restart()) { return; } @@ -1522,38 +1570,59 @@ void CL_Vid_Restart_f( void ) { Com_Printf("-------- CL_Vid_Restart_f --------\n"); cls.vid_restart = qtrue; - // don't let them loop during the restart - S_StopAllSounds2(qtrue); + // + // Save the current music + // + Q_strncpyz(tm_filename, S_GetMusicFilename(), sizeof(tm_filename)); + tm_loopcount = S_GetMusicLoopCount(); + tm_offset = S_GetMusicOffset(); SV_ClearSvsTimeFixups(); + S_SaveData(&save); + Q_strncpyz(current_soundtrack, S_CurrentSoundtrack(), sizeof(current_soundtrack)); + S_BeginRegistration(); + // shutdown the UI + //CL_ShutdownUI(); // shutdown the renderer and clear the renderer interface - CL_ShutdownRef(); + CL_ShutdownRef(); + + cls.rendererRegistered = qfalse; + // shutdown the CGame CL_ShutdownCGame(); // initialize the renderer interface CL_InitRef(); + // initialize the UI + //CL_InitializeUI(); // initialize the ui library UI_ResolutionChange(); // clear aliases Alias_Clear(); - cls.rendererRegistered = qfalse; - // unpause so the cgame definately gets a snapshot and renders a frame Com_Unpause(); CL_StartHunkUsers(qfalse); +#if !defined(NO_MODERN_DMA) || !NO_MODERN_DMA + s_bSoundPaused = true; + S_LoadData(&save); +#else + S_Init(); +#endif + SV_FinishSvsTimeFixups(); -#if !defined(USE_SOUND_NEW) || !USE_SOUND_NEW - S_Init(); -#else - S_Init(qtrue); -#endif + S_ReLoad(&save); + + if (tm_filename[0]) { + S_TriggeredMusic_SetupHandle(tm_filename, tm_loopcount, tm_offset, 0); + } + + MUSIC_NewSoundtrack(current_soundtrack); if (clc.state > CA_CONNECTED && clc.state != CA_CINEMATIC) { @@ -1575,15 +1644,52 @@ handles will be invalid ================= */ void CL_Snd_Restart_f( void ) { -#if !defined(USE_SOUND_NEW) || !USE_SOUND_NEW +#if defined(NO_MODERN_DMA) && NO_MODERN_DMA S_Shutdown(); S_Init(); + CL_Vid_Restart_f(); #else + qboolean full; + soundsystemsavegame_t save; + char tm_filename[MAX_RES_NAME]; + int tm_loopcount; + int tm_offset; + char current_soundtrack[128]; + + full = S_NeedFullRestart(); + + // + // Save the current music + // + Q_strncpyz(tm_filename, S_GetMusicFilename(), sizeof(tm_filename)); + tm_loopcount = S_GetMusicLoopCount(); + tm_offset = S_GetMusicOffset(); + + SV_ClearSvsTimeFixups(); + + S_SaveData(&save); + Q_strncpyz(current_soundtrack, S_CurrentSoundtrack(), sizeof(current_soundtrack)); + S_Shutdown(qfalse); S_Init(qfalse); -#endif - CL_Vid_Restart_f(); + s_bSoundPaused = true; + + S_LoadData(&save); + + SV_FinishSvsTimeFixups(); + S_ReLoad(&save); + + if (tm_filename[0]) { + S_TriggeredMusic_SetupHandle(tm_filename, tm_loopcount, tm_offset, 0); + } + + MUSIC_NewSoundtrack(current_soundtrack); + + if (full) { + CL_Vid_Restart_f(); + } +#endif } @@ -1648,7 +1754,7 @@ CL_Clientinfo_f void CL_Clientinfo_f( void ) { Com_Printf( "--------- Client Information ---------\n" ); Com_Printf( "state: %i\n", clc.state ); - Com_Printf( "Server: %s\n", cls.servername ); + Com_Printf( "Server: %s\n", clc.servername ); Com_Printf ("User info settings:\n"); Info_Print( Cvar_InfoString( CVAR_USERINFO ) ); Com_Printf( "--------------------------------------\n" ); @@ -1849,7 +1955,7 @@ void CL_InitDownloads(void) { if (FS_ComparePaks( missingfiles, sizeof( missingfiles ), qfalse ) ) { // NOTE TTimo I would rather have that printed as a modal message box - // but at this point while joining the game we don't know wether we will successfully join or not + // but at this point while joining the game we don't know whether we will successfully join or not Com_Printf( "\nWARNING: You are missing some files referenced by the server:\n%s" "You might not be able to join the game\n" "Go to the setting menu to turn on autodownload, or get the file elsewhere\n\n", missingfiles ); @@ -1908,12 +2014,12 @@ void CL_CheckForResend( void ) { // if ( !Sys_IsLANAddress( clc.serverAddress ) ) { // CL_RequestAuthorization(); // } - NET_OutOfBandPrint(NS_CLIENT, clc.serverAddress, "getchallenge"); + CL_NET_OutOfBandPrint(clc.serverAddress, "getchallenge"); break; case CA_AUTHORIZING: // resend the cd key authorization gcd_compute_response(cl_cdkey, Cmd_Argv(1), cls.gcdResponse, CDResponseMethod_REAUTH); - NET_OutOfBandPrint(NS_CLIENT, clc.serverAddress, "authorizeThis %s", cls.gcdResponse); + CL_NET_OutOfBandPrint(clc.serverAddress, "authorizeThis %s", cls.gcdResponse); break; case CA_CHALLENGING: /* @@ -1937,13 +2043,13 @@ wombat: sending conect here: an example connect string from MOHAA looks like thi Info_SetValueForKey(info, "protocol", va("%i", com_protocol->integer)); Info_SetValueForKey( info, "qport", va("%i", port ) ); Info_SetValueForKey(info, "challenge", va("%i", clc.challenge)); - Info_SetValueForKey(info, "version", com_shortversion->string); + Info_SetValueForKey(info, "version", com_target_version->string); if (com_target_game->integer == target_game_e::TG_MOHTT) { // only send if maintt is loaded Info_SetValueForKey(info, "clientType", "Breakthrough"); } - strcpy(data, "connect "); + Q_strncpyz(data, "connect ", sizeof(data)); // TTimo adding " " around the userinfo string to avoid truncated userinfo on the server // (Com_TokenizeString tokenizes around spaces) data[8] = '"'; @@ -2176,6 +2282,10 @@ void CL_ConnectionlessPacket( netadr_t from, msg_t *msg ) { char *s; char *c; const char *reason; + + if (cl_netprofile->integer) { + NetProfileAddPacket(&cls.netprofile.inPackets, msg->cursize, NETPROF_PACKET_MESSAGE); + } MSG_BeginReadingOOB( msg ); MSG_ReadLong( msg ); // skip the -1 @@ -2260,7 +2370,7 @@ void CL_ConnectionlessPacket( netadr_t from, msg_t *msg ) { // echo request from server if ( !Q_stricmp(c, "echo") ) { - NET_OutOfBandPrint( NS_CLIENT, from, "%s", Cmd_Argv(1) ); + CL_NET_OutOfBandPrint(from, "%s", Cmd_Argv(1) ); return; } @@ -2268,7 +2378,7 @@ void CL_ConnectionlessPacket( netadr_t from, msg_t *msg ) { if ( !Q_stricmp(c, "getKey") ) { clc.state = CA_AUTHORIZING; gcd_compute_response(cl_cdkey, Cmd_Argv(1), cls.gcdResponse, CDResponseMethod_NEWAUTH); - NET_OutOfBandPrint(NS_CLIENT, from, "authorizeThis %s", cls.gcdResponse); + CL_NET_OutOfBandPrint(from, "authorizeThis %s", cls.gcdResponse); return; } @@ -2383,6 +2493,13 @@ CL_CheckTimeout ================== */ void CL_CheckTimeout( void ) { + if (com_sv_running->integer) { + // Added in OPM + // Timeout should not be possible if the client is hosting the game + // (like in single-player mode) + return; + } + // // check timeout // @@ -2390,10 +2507,37 @@ void CL_CheckTimeout( void ) { && clc.state >= CA_CONNECTED && clc.state != CA_CINEMATIC && cls.realtime - clc.lastPacketTime > cl_timeout->value*1000) { if (++cl.timeoutcount > 5) { // timeoutcount saves debugger - Com_Printf ("\nServer connection timed out.\n"); - Cbuf_AddText( "pushmenu servertimeout\n" ); - CL_Disconnect(); - return; + const char* info; + const char* maxclients; + + info = &cl.gameState.stringData[cl.gameState.stringOffsets[CS_SERVERINFO]]; + maxclients = Info_ValueForKey(info, "maxclients"); + // + // Disconnect if the player isn't alone (single-player mode) + // + if (!maxclients || atoi(maxclients) != 1) { + qboolean bConsoleState; + + bConsoleState = UI_ConsoleIsOpen(); + + Com_Printf("\nServer connection timed out.\n"); + SV_Shutdown("\nServer connection timed out\n"); + + if (com_cl_running && com_cl_running->integer) { + CL_AbnormalDisconnect(); + CL_FlushMemory(); + CL_StartHunkUsers(qfalse); + } + + UI_ForceMenuOff(qtrue); + UI_PushMenu("servertimeout"); + + if (bConsoleState) { + UI_OpenConsole(); + } else { + UI_CloseConsole(); + } + } } } else { cl.timeoutcount = 0; @@ -2439,7 +2583,7 @@ void CL_CheckUserinfo( void ) { // send a reliable userinfo update if needed if(cvar_modifiedFlags & CVAR_USERINFO) { - if (Com_SanitizeName(name->string, szSanitizedName)) { + if (Com_SanitizeName(name->string, szSanitizedName, sizeof(szSanitizedName))) { Cvar_Set("name", szSanitizedName); } @@ -2449,9 +2593,43 @@ void CL_CheckUserinfo( void ) { } void CL_SetFrameNumber(int frameNumber) { + if (!re.SetFrameNumber) { + return; + } + re.SetFrameNumber(frameNumber); } +/* +================== +CL_VerifyUpdate + +Check for a new version and display a message box +when a new version is available +================== +*/ +void CL_VerifyUpdate() { + if (cl_updateNotified) { + return; + } + + int lastMajor, lastMinor, lastPatch; + if (updateChecker.CheckNewVersion(lastMajor, lastMinor, lastPatch)) { + cl_updateNotified = true; + + const char *updateText = + va("A new update is available!\n" + "The latest version is v%d.%d.%d (you are running v%s).\n" + "Check https://github.com/openmoh/openmohaa for more.", + lastMajor, + lastMinor, + lastPatch, + PRODUCT_VERSION_NUMBER_STRING); + + UIMessageDialog::ShowMessageBox("Update available", updateText); + } +} + /* ================== CL_Frame @@ -2482,11 +2660,19 @@ void CL_Frame ( int msec ) { } #endif - if ( clc.state == CA_DISCONNECTED && !UI_MenuActive() - && !com_sv_running->integer ) { - // if disconnected, bring up the menu - S_StopAllSounds2( qtrue ); - UI_MenuEscape( "main" ); + if (CL_FinishedIntro()) { + if (clc.state == CA_DISCONNECTED) { + if (!UI_MenuActive() && !com_sv_running->integer) { + // if disconnected, bring up the menu + S_StopAllSounds2(qtrue); + S_TriggeredMusic_PlayIntroMusic(); + UI_MenuEscape("main"); + } + + CL_VerifyUpdate(); + } else if (clc.state == CA_CINEMATIC) { + UI_ForceMenuOff(qtrue); + } } // if recording an avi, lock to a fixed fps @@ -2521,7 +2707,7 @@ void CL_Frame ( int msec ) { now.tm_min, now.tm_sec ); - Q_strncpyz( serverName, cls.servername, MAX_OSPATH ); + Q_strncpyz( serverName, clc.servername, MAX_OSPATH ); // Replace the ":" in the address as it is not a valid // file name character p = strstr( serverName, ":" ); @@ -2555,6 +2741,31 @@ void CL_Frame ( int msec ) { cls.timeScaled = com_timescale->integer != 1; + // + // Added in 2.0: network profiling + // + if (cl_netprofile->integer) { + if (!cls.netprofile.initialized) { + memset(&cls.netprofile, 0, sizeof(cls.netprofile)); + cls.netprofile.initialized = qtrue; + } + + if (cls.netprofile.rate != cl_rate->integer) { + cls.netprofile.rate = cl_rate->integer; + + if (cls.netprofile.rate < 1000) { + cls.netprofile.rate = 1000; + } else if (cls.netprofile.rate > 90000) { + cls.netprofile.rate = 90000; + } + } + + cls.netprofile.outPackets.updateTime = Com_Milliseconds(); + cls.netprofile.inPackets.updateTime = cls.netprofile.outPackets.updateTime; + } else { + cls.netprofile.initialized = qfalse; + } + // see if we need to update any userinfo CL_CheckUserinfo(); @@ -2643,15 +2854,15 @@ CL_ShutdownRef ============ */ void CL_ShutdownRef( void ) { - if ( !re.Shutdown ) { - return; + if ( re.Shutdown ) { + re.Shutdown( qtrue ); } - re.Shutdown( qtrue ); + Com_Memset( &re, 0, sizeof( re ) ); -#ifdef USE_RENDERER_DLL - // su44: remember to unload renderer library - if(rendererLib) { - Sys_UnloadLibrary(rendererLib); + +#ifdef USE_RENDERER_DLOPEN + if ( rendererLib ) { + Sys_UnloadLibrary( rendererLib ); rendererLib = NULL; } #endif @@ -2765,7 +2976,7 @@ void CL_RefStaticClear( void ) { CL_CG_PermanentMark ============ */ -int CL_CG_PermanentMark(const vec3_t origin, const vec3_t dir, float orientation, +int CL_CG_PermanentMark(vec3_t origin, vec3_t dir, float orientation, float fSScale, float fTScale, float red, float green, float blue, float alpha, qboolean dolighting, float fSCenter, float fTCenter, markFragment_t *pMarkFragments, void *pPolyVerts ) @@ -2828,22 +3039,105 @@ void CL_CG_EndTiki( dtiki_t *tiki ) { } } +/* +============ +CL_CG_EndTiki +============ +*/ extern "C" int CL_ScaledMilliseconds(void) { return Sys_Milliseconds()*com_timescale->value; } +/* +============ +CL_RefFS_WriteFile +============ +*/ void CL_RefFS_WriteFile(const char* qpath, const void* buffer, int size) { FS_WriteFile(qpath, buffer, size); } +/* +============ +CL_RefFS_ListFiles +============ +*/ char** CL_RefFS_ListFiles(const char* name, const char* extension, int* numfilesfound) { return FS_ListFiles(name, extension, qtrue, numfilesfound); } +/* +============ +CL_RefCIN_UploadCinematic +============ +*/ void CL_RefCIN_UploadCinematic(int handle) { } +/* +============ +CL_RefTIKI_GetNumChannels +============ +*/ +int CL_RefTIKI_GetNumChannels(dtiki_t* tiki) { + return tiki->m_boneList.NumChannels(); +} + +/* +============ +CL_RefTIKI_GetLocalChannel +============ +*/ +int CL_RefTIKI_GetLocalChannel(dtiki_t* tiki, int channel) { + return tiki->m_boneList.LocalChannel(channel); +} + +/* +============ +CL_RefTIKI_GetLocalFromGlobal +============ +*/ +int CL_RefTIKI_GetLocalFromGlobal(dtiki_t* tiki, int channel) { + return tiki->m_boneList.GetLocalFromGlobal(channel); +} + +/* +============ +CL_RefSKEL_GetMorphWeightFrame +============ +*/ +int CL_RefSKEL_GetMorphWeightFrame(void* skeletor, int index, float time, int* data) { + return ((skeletor_c*)skeletor)->GetMorphWeightFrame(index, time, data); +} + +/* +============ +CL_RefSKEL_GetBoneParent +============ +*/ +int CL_RefSKEL_GetBoneParent(void* skeletor, int boneIndex) { + return ((skeletor_c*)skeletor)->GetBoneParent(boneIndex); +} + +/* +============ +CL_GetRefSequence +============ +*/ +int CL_GetRefSequence(void) { + return cls.refSequence; +} + +/* +============ +CL_IsRendererLoaded +============ +*/ +qboolean CL_IsRendererLoaded(void) { + return re.Shutdown != NULL; +} + /* ============ CL_InitRef @@ -2852,12 +3146,40 @@ CL_InitRef void CL_InitRef( void ) { refimport_t ri; refexport_t *ret; -#ifdef USE_RENDERER_DLL - char dllName[256]; +#ifdef USE_RENDERER_DLOPEN + GetRefAPI_t GetRefAPI; + char dllName[MAX_OSPATH]; #endif Com_Printf( "----- Initializing Renderer ----\n" ); +#ifdef USE_RENDERER_DLOPEN + cl_renderer = Cvar_Get("cl_renderer", "opengl1", CVAR_ARCHIVE | CVAR_LATCH); + + Com_sprintf(dllName, sizeof(dllName), "renderer_%s" ARCH_SUFFIX DLL_SUFFIX DLL_EXT, cl_renderer->string); + + if(!(rendererLib = Sys_LoadDll(dllName, qfalse)) && strcmp(cl_renderer->string, cl_renderer->resetString)) + { + Com_Printf("failed:\n\"%s\"\n", Sys_LibraryError()); + Cvar_ForceReset("cl_renderer"); + + Com_sprintf(dllName, sizeof(dllName), "renderer_opengl1" ARCH_SUFFIX DLL_SUFFIX DLL_EXT); + rendererLib = Sys_LoadDll(dllName, qfalse); + } + + if(!rendererLib) + { + Com_Printf("failed:\n\"%s\"\n", Sys_LibraryError()); + Com_Error(ERR_FATAL, "Failed to load renderer"); + } + + GetRefAPI = (GetRefAPI_t)Sys_LoadFunction(rendererLib, "GetRefAPI"); + if(!GetRefAPI) + { + Com_Error(ERR_FATAL, "Can't load symbol GetRefAPI: '%s'", Sys_LibraryError()); + } +#endif + ri.Cmd_AddCommand = Cmd_AddCommand; ri.Cmd_RemoveCommand = Cmd_RemoveCommand; ri.Cmd_Argc = Cmd_Argc; @@ -2881,8 +3203,10 @@ void CL_InitRef( void ) { ri.CM_DrawDebugSurface = CM_DrawDebugSurface; ri.FS_OpenFile = FS_FOpenFileRead; + ri.FS_OpenFileWrite = FS_FOpenFileWrite; ri.FS_CloseFile = FS_FCloseFile; ri.FS_Read = FS_Read; + ri.FS_Write = FS_Write; ri.FS_Seek = FS_Seek; ri.FS_ReadFile = FS_ReadFile; ri.FS_ReadFileEx = FS_ReadFileEx; @@ -2892,8 +3216,10 @@ void CL_InitRef( void ) { ri.FS_ListFiles = CL_RefFS_ListFiles; ri.FS_FileIsInPAK = FS_FileIsInPAK; ri.FS_FileExists = FS_FileExists; + ri.FS_CanonicalFilename = FS_CanonicalFilename; ri.Cvar_Get = Cvar_Get; ri.Cvar_Set = Cvar_Set; + ri.Cvar_SetValue = Cvar_SetValue; ri.Cvar_SetDefault = Cvar_SetDefault; ri.CM_EntityString = CM_EntityString; @@ -2942,40 +3268,30 @@ void CL_InitRef( void ) { ri.Sys_GLimpInit = Sys_GLimpInit; ri.Sys_LowPhysicalMemory = Sys_LowPhysicalMemory; -#ifdef USE_RENDERER_DLL - // su44: load renderer dll - cl_renderer = Cvar_Get("cl_renderer", "glom", CVAR_ARCHIVE); - Q_snprintf(dllName, sizeof(dllName), "renderer_%s" ARCH_STRING DLL_EXT, cl_renderer->string); - Com_Printf("Loading \"%s\"...", dllName); - if((rendererLib = Sys_LoadLibrary(dllName)) == 0) { -#ifdef _WIN32 - Com_Error(ERR_FATAL, "failed:\n\"%s\"\n", Sys_LibraryError()); -#else - char fn[1024]; + // + // Added in OPM + // + ri.UI_LoadResource = UI_LoadResource; + ri.CM_PointLeafnum = CM_PointLeafnum; + ri.CM_LeafCluster = CM_LeafCluster; - Q_strncpyz(fn, Sys_Cwd(), sizeof(fn)); - strncat(fn, "/", sizeof(fn) - strlen(fn) - 1); - strncat(fn, dllName, sizeof(fn) - strlen(fn) - 1); + ri.TIKI_CalcLodConsts = TIKI_CalcLodConsts; + ri.TIKI_CalculateBounds = TIKI_CalculateBounds; + ri.TIKI_FindTiki = TIKI_FindTiki; + ri.TIKI_RegisterTikiFlags = TIKI_RegisterTikiFlags; + ri.TIKI_GetSkeletor = TIKI_GetSkeletor; + ri.TIKI_GetSkel = TIKI_GetSkel; + ri.TIKI_GetSkelAnimFrame = TIKI_GetSkelAnimFrame; + ri.TIKI_GlobalRadius = TIKI_GlobalRadius; + ri.TIKI_FindSkelByHeader = TIKI_FindSkelByHeader; + ri.TIKI_GetNumChannels = CL_RefTIKI_GetNumChannels; + ri.TIKI_GetLocalChannel = CL_RefTIKI_GetLocalChannel; + ri.TIKI_GetLocalFromGlobal = CL_RefTIKI_GetLocalFromGlobal; - Com_Printf("Loading \"%s\"...", fn); - if((rendererLib = Sys_LoadLibrary(fn)) == 0) - { - Com_Error(ERR_FATAL, "failed:\n\"%s\"", Sys_LibraryError()); - } -#endif /* _WIN32 */ - } + ri.SKEL_GetBoneParent = CL_RefSKEL_GetBoneParent; + ri.SKEL_GetMorphWeightFrame = CL_RefSKEL_GetMorphWeightFrame; - Com_Printf("done\n"); - - DGetRefAPI = Sys_LoadFunction(rendererLib, "GetRefAPI"); - if(!DGetRefAPI) - { - Com_Error(ERR_FATAL, "Can't load symbol GetRefAPI: '%s'", Sys_LibraryError()); - } - ret = DGetRefAPI( REF_API_VERSION, &ri ); -#else ret = GetRefAPI( REF_API_VERSION, &ri ); -#endif #if defined __USEA3D && defined __A3D_GEOM hA3Dg_ExportRenderGeom (ret); @@ -2991,6 +3307,8 @@ void CL_InitRef( void ) { // unpause so the cgame definately gets a snapshot and renders a frame Cvar_Set( "cl_paused", "0" ); + + cls.refSequence++; } @@ -3029,7 +3347,7 @@ void CL_VidMode_f( void ) { mode = atoi( Cmd_Argv( 1 ) ); if( CL_SetVidMode( mode ) ) { - sprintf( text, "%d", mode ); + Com_sprintf( text, sizeof( text ), "%d", mode ); Cvar_Set( "r_mode", text ); } } @@ -3048,10 +3366,10 @@ void CL_TikiInfoCommand_f( void ) { name = Cmd_Argv( 1 ); if( strchr( name, '/' ) ) { - strcpy( modelname, name ); + Q_strncpyz( modelname, name, sizeof( modelname ) ); } else { - strcpy( modelname, "models/" ); - strcat( modelname, name ); + Q_strncpyz( modelname, "models/", sizeof( modelname ) ); + Q_strcat( modelname, sizeof( modelname ), name ); } COM_DefaultExtension( modelname, sizeof( modelname ), ".tik" ); @@ -3143,8 +3461,6 @@ it by filling it with 2048 bytes of random data. */ static void CL_GenerateQKey(void) { - // FIXME: unimplemented - /* int len = 0; unsigned char buff[ QKEY_SIZE ]; fileHandle_t f; @@ -3174,7 +3490,6 @@ static void CL_GenerateQKey(void) FS_FCloseFile( f ); Com_Printf( "QKEY generated\n" ); } - */ } /* @@ -3222,6 +3537,8 @@ void CL_Init( void ) { cl_master = Cvar_Get ("cl_master", MASTER_SERVER_NAME, CVAR_ARCHIVE); cl_timeNudge = Cvar_Get ("cl_timeNudge", "0", CVAR_TEMP ); cl_shownet = Cvar_Get ("cl_shownet", "0", CVAR_TEMP ); + cl_netprofile = Cvar_Get("cl_netprofile", "0", CVAR_TEMP); + cl_netprofileoverlay = Cvar_Get("cl_netprofileoverlay", "0", CVAR_TEMP); cl_showSend = Cvar_Get ("cl_showSend", "0", CVAR_TEMP ); cl_showTimeDelta = Cvar_Get ("cl_showTimeDelta", "0", CVAR_TEMP ); cl_freezeDemo = Cvar_Get ("cl_freezeDemo", "0", CVAR_TEMP ); @@ -3336,21 +3653,13 @@ void CL_Init( void ) { cl_consoleKeys = Cvar_Get( "cl_consoleKeys", "~ ` 0x7e 0x60", CVAR_ARCHIVE ); // userinfo - name = Cvar_Get ("name", "UnnamedSoldier", CVAR_USERINFO | CVAR_ARCHIVE ); - Cvar_Get ("rate", "5000", CVAR_USERINFO | CVAR_ARCHIVE ); + name = Cvar_Get ("name", va("UnnamedSoldier#%d", rand() % 100000), CVAR_USERINFO | CVAR_ARCHIVE); + cl_rate = Cvar_Get ("rate", "25000", CVAR_USERINFO | CVAR_ARCHIVE ); Cvar_Get ("snaps", "20", CVAR_USERINFO | CVAR_ARCHIVE ); Cvar_Get ("password", "", CVAR_USERINFO); Cvar_Get ("dm_playermodel", "american_army", CVAR_USERINFO | CVAR_ARCHIVE ); Cvar_Get ("dm_playergermanmodel", "german_wehrmacht_soldier", CVAR_USERINFO | CVAR_ARCHIVE ); - Cvar_Get ("cg_predictItems", "1", CVAR_USERINFO | CVAR_ARCHIVE ); - - - // cgame might not be initialized before menu is used - Cvar_Get ("cg_viewsize", "100", CVAR_ARCHIVE ); - - Cvar_Get ("cg_running", "0", CVAR_ROM ); - // // register our commands // @@ -3369,7 +3678,6 @@ void CL_Init( void ) { Cmd_AddCommand ("reconnect", CL_Reconnect_f); Cmd_AddCommand ("localservers", CL_LocalServers_f); Cmd_AddCommand ("globalservers", CL_GlobalServers_f); - Cmd_AddCommand ("refreshserverlist", CL_GamespyServers_f); // wombat: gamespy query Cmd_AddCommand ("rcon", CL_Rcon_f); Cmd_AddCommand ("setenv", CL_Setenv_f ); Cmd_AddCommand ("ping", CL_Ping_f ); @@ -3398,11 +3706,12 @@ void CL_Init( void ) { Cvar_Set( "cl_running", "1" ); -#if !defined(USE_SOUND_NEW) || !USE_SOUND_NEW +#if defined(NO_MODERN_DMA) && NO_MODERN_DMA S_Init2(); +#else + S_Init(qtrue); #endif - // fixme: should we leave it? CL_GenerateQKey(); Cvar_Get( "cl_guid", "", CVAR_USERINFO | CVAR_ROM ); CL_UpdateGUID( NULL, 0 ); @@ -3411,6 +3720,12 @@ void CL_Init( void ) { end = Sys_Milliseconds(); + if (com_gotOriginalConfig) { + // Added in OPM + // Apply config tweaks after loading the original config + CL_ApplyOriginalConfigTweaks(); + } + Com_Printf( "----- Client Initialization Complete ----- %i ms\n", start - end ); } @@ -3441,7 +3756,7 @@ void CL_Shutdown(const char* finalmsg, qboolean disconnect, qboolean quit) { if(disconnect) CL_Disconnect(); -#if !defined(USE_SOUND_NEW) || !USE_SOUND_NEW +#if defined(NO_MODERN_DMA) && NO_MODERN_DMA S_Shutdown(); #else S_Shutdown(qtrue); @@ -3473,6 +3788,8 @@ void CL_Shutdown(const char* finalmsg, qboolean disconnect, qboolean quit) { Cmd_RemoveCommand ("video"); Cmd_RemoveCommand ("stopvideo"); + CL_ShutdownInput(); + Cvar_Set( "cl_running", "0" ); recursive = qfalse; @@ -3492,6 +3809,7 @@ static void CL_SetServerInfo(serverInfo_t *server, const char *info, int ping) { server->maxClients = atoi(Info_ValueForKey(info, "sv_maxclients")); Q_strncpyz(server->game,Info_ValueForKey(info, "game"), MAX_NAME_LENGTH); server->gameType = atoi(Info_ValueForKey(info, "gametype")); + Q_strncpyz(server->gameTypeString, Info_ValueForKey(info, "gametypestring"), sizeof(server->gameTypeString)); server->netType = atoi(Info_ValueForKey(info, "nettype")); server->minPing = atoi(Info_ValueForKey(info, "minping")); server->maxPing = atoi(Info_ValueForKey(info, "maxping")); @@ -3540,6 +3858,8 @@ void CL_ServerInfoPacket( netadr_t from, msg_t *msg ) { char *infoString; int prot; char *gamename; + char *pszVersion; + char *pszServerType; qboolean gameMismatch; infoString = MSG_ReadString( msg ); @@ -3568,12 +3888,42 @@ void CL_ServerInfoPacket( netadr_t from, msg_t *msg ) { #ifdef LEGACY_PROTOCOL && prot != com_legacyprotocol->integer #endif + && (com_target_demo->integer || prot != protocol_version_demo) ) { Com_DPrintf( "Different protocol info packet: %s\n", infoString ); return; } + if (!com_target_demo->integer && protocol_version_demo != protocol_version_full && prot == protocol_version_demo) { + Com_DPrintf("Full version found compatible demo protocol version. %s\n", infoString); + } + + pszVersion = Info_ValueForKey(infoString, "gamever"); + pszServerType = Info_ValueForKey(infoString, "serverType"); + + if (*pszVersion) { + if (*pszVersion == 'd') { + pszVersion++; + } + + if (com_target_game->integer >= target_game_e::TG_MOHTT) { + if (atoi(pszServerType) == target_game_e::TG_MOHTT) { + if (fabs(atof(pszVersion)) < 2.3f) { + return; + } + } else { + if (fabs(atof(pszVersion)) < 2.1f) { + return; + } + } + } else { + if (fabs(atof(pszVersion) - com_target_version->value) > 0.1f) { + return; + } + } + } + // iterate servers waiting for ping response for (i=0; iretrieved = qfalse; serverStatus->time = 0; serverStatus->startTime = Com_Milliseconds(); - NET_OutOfBandPrint( NS_CLIENT, to, "getstatus" ); + CL_NET_OutOfBandPrint(to, "getstatus" ); return qfalse; } } @@ -3731,7 +4081,7 @@ int CL_ServerStatus( const char *serverAddress, char *serverStatusString, int ma serverStatus->retrieved = qfalse; serverStatus->startTime = Com_Milliseconds(); serverStatus->time = 0; - NET_OutOfBandPrint( NS_CLIENT, to, "getstatus" ); + CL_NET_OutOfBandPrint(to, "getstatus" ); return qfalse; } return qfalse; @@ -3743,10 +4093,10 @@ CL_ServerStatusResponse =================== */ void CL_ServerStatusResponse( netadr_t from, msg_t *msg ) { - char *s; - char info[MAX_INFO_STRING]; - int i, l, score, ping; - int len; + const char *s; + char info[MAX_INFO_STRING]; + int i, l, ping; + int len; serverStatus_t *serverStatus; serverStatus = NULL; @@ -3799,7 +4149,7 @@ void CL_ServerStatusResponse( netadr_t from, msg_t *msg ) { if (serverStatus->print) { Com_Printf("\nPlayers:\n"); - Com_Printf("num: score: ping: name:\n"); + Com_Printf("num: ping: name:\n"); } for (i = 0, s = MSG_ReadStringLine( msg ); *s; s = MSG_ReadStringLine( msg ), i++) { @@ -3807,16 +4157,14 @@ void CL_ServerStatusResponse( netadr_t from, msg_t *msg ) { Com_sprintf(&serverStatus->string[len], sizeof(serverStatus->string)-len, "\\%s", s); if (serverStatus->print) { - score = ping = 0; - sscanf(s, "%d %d", &score, &ping); + ping = 0; + sscanf(s, "%d", &ping); s = strchr(s, ' '); - if (s) - s = strchr(s+1, ' '); if (s) s++; else s = "unknown"; - Com_Printf("%-2d %-3d %-3d %s\n", i, score, ping, s ); + Com_Printf("%-2d %-3d %s\n", i, ping, s ); } } len = strlen(serverStatus->string); @@ -3870,133 +4218,22 @@ void CL_LocalServers_f( void ) { to.type = NA_BROADCAST; NET_SendPacket( NS_CLIENT, strlen( message ), message, to ); + + if (cl_netprofile->integer) { + NetProfileAddPacket(&cls.netprofile.inPackets, strlen( message ), NETPROF_PACKET_MESSAGE); + } + // Added in OPM (from ioquake3) to.type = NA_MULTICAST6; NET_SendPacket( NS_CLIENT, strlen( message ), message, to ); + + if (cl_netprofile->integer) { + NetProfileAddPacket(&cls.netprofile.inPackets, strlen(message), NETPROF_PACKET_MESSAGE); + } } } } -/* -================== -CL_GamespyServers_f -================== -*/ -// currently about 1000 mohaa servers at a time. when set higher, buffer must be increased! -#define MAX_GAMESPYSERVERS 16 - -void CL_GamespyServers_f( void ) { - // FIXME: unimplemented -#if 0 - char buffer[10240]; - int bytesRead; - - int i, count, max, total; - serverAddress_t addresses[MAX_GAMESPYSERVERS]; - int numservers; - byte* buffptr; - byte* buffend; - -// if ( Cmd_Argc() < 1) { -// Com_Printf( "usage: gamespyservers [keywords]\n"); -// return; -// } - - Com_Printf( "Requesting servers from the GameSpy master...\n" ); - Cvar_Set( "dm_serverstatus", "Getting List."); - - - if (!NETGS_CreateMasterSocket()) { - Com_Printf( "CL_GamespyServers_f: could not create socket.\n" ); - return; - } - if (!NETGS_SendMasterRequest()) { - Com_Printf( "CL_GamespyServers_f: could not send master request.\n" ); - return; - } - bytesRead = NETGS_ReceiveMasterResponse( buffer, sizeof(buffer) ); - if (!bytesRead) { - Com_Printf( "CL_GamespyServers_f: Error in Response.\n" ); - return; - } - - // parse through server response string - numservers = 0; - buffptr = ( byte * )buffer; - buffend = buffptr + bytesRead; - - while (buffptr+1 < buffend) { - if ( buffptr >= buffend - 6 ) { - break; - } - - // parse out ip - addresses[numservers].ip[0] = *buffptr++; - addresses[numservers].ip[1] = *buffptr++; - addresses[numservers].ip[2] = *buffptr++; - addresses[numservers].ip[3] = *buffptr++; - - // parse out port - addresses[numservers].port = *buffptr++; - addresses[numservers].port += (*buffptr++) << 8; - - Com_DPrintf( "server: %d ip: %d.%d.%d.%d:%d\n",numservers, - addresses[numservers].ip[0], - addresses[numservers].ip[1], - addresses[numservers].ip[2], - addresses[numservers].ip[3], - BigShort(addresses[numservers].port) ); - - numservers++; - if (numservers >= MAX_GAMESPYSERVERS) { - break; - } - - // parse out "\\final\\" - if (buffptr[0] == '\\' && buffptr[1] == 'f' && buffptr[2] == 'i' && buffptr[3] == 'n' && buffptr[4] == 'a' && buffptr[6] == 'l' && buffptr[6] == '\\') { - break; - } - } - - cls.numglobalservers = 0; - cls.numGlobalServerAddresses = 0; - - count = cls.numglobalservers; - max = MAX_GLOBAL_SERVERS; - for (i = 0; i < numservers && count < max; i++) { - // build net address - serverInfo_t *server = &cls.globalServers[count]; - - CL_InitServerInfo( server, &addresses[i] ); - // advance to next slot - count++; - } - - - if ( cls.numGlobalServerAddresses < MAX_GLOBAL_SERVERS ) { - // if we couldn't store the servers in the main list anymore - for (; i < numservers && count >= max; i++) { - serverAddress_t *addr; - // just store the addresses in an additional list - addr = &cls.globalServerAddresses[cls.numGlobalServerAddresses++]; - addr->ip[0] = addresses[i].ip[0]; - addr->ip[1] = addresses[i].ip[1]; - addr->ip[2] = addresses[i].ip[2]; - addr->ip[3] = addresses[i].ip[3]; - addr->port = addresses[i].port; - } - } - - cls.numglobalservers = count; - total = count + cls.numGlobalServerAddresses; - - Com_Printf("%d servers parsed (total %d)\n", numservers, total); - Cvar_Set( "dm_serverstatus", "Server List Received."); - Cvar_SetValue( "dm_servercount", total ); -#endif -} - - /* ================== CL_GlobalServers_f @@ -4022,7 +4259,7 @@ void CL_GlobalServers_f( void ) { int numAddress = 0; for ( i = 1; i <= MAX_MASTER_SERVERS; i++ ) { - sprintf(command, "sv_master%d", i); + Com_sprintf(command, sizeof(command), "sv_master%d", i); masteraddress = Cvar_VariableString(command); if(!*masteraddress) @@ -4040,7 +4277,7 @@ void CL_GlobalServers_f( void ) { return; } - sprintf(command, "sv_master%d", masterNum); + Com_sprintf(command, sizeof(command), "sv_master%d", masterNum); masteraddress = Cvar_VariableString(command); if(!*masteraddress) @@ -4096,7 +4333,7 @@ void CL_GlobalServers_f( void ) { Q_strcat(command, sizeof(command), Cmd_Argv(i)); } - NET_OutOfBandPrint( NS_SERVER, to, "%s", command ); + CL_NET_OutOfBandPrint( to, "%s", command ); } @@ -4316,7 +4553,7 @@ void CL_Ping_f( void ) { CL_SetServerInfoByAddress(pingptr->adr, NULL, 0); - NET_OutOfBandPrint( NS_CLIENT, to, "\x02getinfo xxx" ); + CL_NET_OutOfBandPrint( to, "\x02getinfo xxx" ); } /* @@ -4369,10 +4606,10 @@ void CL_Dialog_f( void ) { return; } - strcpy( title, Cmd_Argv( 1 ) ); - strcpy( cvar, Cmd_Argv( 2 ) ); - strcpy( command, Cmd_Argv( 3 ) ); - strcpy( cancelCommand, Cmd_Argv( 4 ) ); + Q_strncpyz( title, Cmd_Argv( 1 ), sizeof( title ) ); + Q_strncpyz( cvar, Cmd_Argv( 2 ), sizeof( cvar ) ); + Q_strncpyz( command, Cmd_Argv( 3 ), sizeof( command ) ); + Q_strncpyz( cancelCommand, Cmd_Argv( 4 ), sizeof( cancelCommand ) ); if( Cmd_Argc() > 5 ) { width = atoi( Cmd_Argv( 5 ) ); @@ -4386,17 +4623,17 @@ void CL_Dialog_f( void ) { } if( Cmd_Argc() > 7 ) { - strcpy( shader, Cmd_Argv( 7 ) ); + Q_strncpyz( shader, Cmd_Argv( 7 ), sizeof( shader ) ); } else { shader[ 0 ] = 0; } if( Cmd_Argc() > 8 ) { - strcpy( okshader, Cmd_Argv( 8 ) ); + Q_strncpyz( okshader, Cmd_Argv( 8 ), sizeof(okshader) ); } else { okshader[ 0 ] = 0; } if( Cmd_Argc() > 9 ) { - strcpy( cancelshader, Cmd_Argv( 9 ) ); + Q_strncpyz( cancelshader, Cmd_Argv( 9 ), sizeof(cancelshader) ); } else { cancelshader[ 0 ] = 0; } @@ -4410,7 +4647,10 @@ CL_ServerRestarted ================== */ void CL_ServerRestarted( void ) { - S_StopAllSounds2( qfalse ); + //S_StopAllSounds2( qfalse ); + // Fixed in OPM + // Also stop the music + S_StopAllSounds2( qtrue ); UI_ServerLoaded(); UI_ClearState(); @@ -4483,7 +4723,7 @@ qboolean CL_UpdateVisiblePings_f(int source) { memcpy(&cl_pinglist[j].adr, &server[i].adr, sizeof(netadr_t)); cl_pinglist[j].start = Sys_Milliseconds(); cl_pinglist[j].time = 0; - NET_OutOfBandPrint( NS_CLIENT, cl_pinglist[j].adr, "getinfo xxx" ); + CL_NET_OutOfBandPrint( cl_pinglist[j].adr, "getinfo xxx" ); slots++; } } @@ -4571,7 +4811,7 @@ void CL_ServerStatus_f(void) { return; } - NET_OutOfBandPrint( NS_CLIENT, *toptr, "getstatus" ); + CL_NET_OutOfBandPrint( *toptr, "getstatus" ); serverStatus = CL_GetServerStatus( *toptr ); serverStatus->address = *toptr; @@ -4640,7 +4880,7 @@ qboolean CL_CDKeyValidate( const char *key, const char *checksum ) { } } - sprintf(chs, "%02x", sum); + Com_sprintf(chs, sizeof(chs), "%02x", sum); if (checksum && !Q_stricmp(chs, checksum)) { return qtrue; @@ -4662,3 +4902,15 @@ void TIKI_CG_Command_ProcessFile(char* filename, qboolean quiet, dtiki_t* curTik Com_Printf("NO CGE \n"); } + +void CL_ApplyOriginalConfigTweaks() +{ + cvar_t* snaps = Cvar_Get("snaps", "", 0); + + // Those variables are not editable via UI so reset them + // snaps/maxpackets can also have wrong values due to them being changed + // via stufftext + + Cvar_Set("snaps", snaps->resetString); + Cvar_Set("cl_maxpackets", cl_maxpackets->resetString); +} diff --git a/code/client/cl_net_chan.cpp b/code/client/cl_net_chan.cpp index 1433c434..102d5524 100644 --- a/code/client/cl_net_chan.cpp +++ b/code/client/cl_net_chan.cpp @@ -132,7 +132,7 @@ CL_Netchan_TransmitNextFragment ================= */ void CL_Netchan_TransmitNextFragment( netchan_t *chan ) { - Netchan_TransmitNextFragment( chan ); + Netchan_TransmitNextFragment( chan, cl_netprofile->integer ? &cls.netprofile.inPackets : NULL ); } /* @@ -144,7 +144,7 @@ void CL_Netchan_Transmit( netchan_t *chan, msg_t* msg ) { MSG_WriteByte( msg, clc_EOF ); CL_Netchan_Encode( msg ); - Netchan_Transmit( chan, msg->cursize, msg->data ); + Netchan_Transmit( chan, msg->cursize, msg->data, cl_netprofile->integer ? &cls.netprofile.inPackets : NULL ); } extern int oldsize; @@ -158,10 +158,30 @@ CL_Netchan_Process qboolean CL_Netchan_Process( netchan_t *chan, msg_t *msg ) { int ret; - ret = Netchan_Process( chan, msg ); + ret = Netchan_Process( chan, msg, cl_netprofile->integer ? &cls.netprofile.outPackets : NULL ); if (!ret) return qfalse; CL_Netchan_Decode( msg ); newsize += msg->cursize; return qtrue; } + +/* +================= +CL_NET_OutOfBandPrint +================= +*/ +void CL_NET_OutOfBandPrint(netadr_t adr, const char* format, ...) { + va_list argptr; + char string[MAX_MSGLEN]; + + va_start(argptr, format); + Q_vsnprintf(string, sizeof(string), format, argptr); + va_end(argptr); + + NET_OutOfBandPrint(NS_CLIENT, adr, "%s", string); + + if (cl_netprofile->integer) { + NetProfileAddPacket(&cls.netprofile.inPackets, strlen(string), NETPROF_PACKET_MESSAGE); + } +} diff --git a/code/client/cl_parse.cpp b/code/client/cl_parse.cpp index 76a17cf4..68a9cc7e 100644 --- a/code/client/cl_parse.cpp +++ b/code/client/cl_parse.cpp @@ -223,13 +223,13 @@ qboolean CL_UnpackNonPVSClient(int* packed, radarUnpacked_t* unpacked) { range = 0; } - unpacked->x = x * range / 63.f; - unpacked->y = y * range / 63.f; + unpacked->x = x * range / (MAX_CLIENTS - 1); + unpacked->y = y * range / (MAX_CLIENTS - 1); if (!bValid) { - unpacked->x = x * range / 63.f * 1024; - unpacked->y = y * range / 63.f * 1024; + unpacked->x = x * range / (MAX_CLIENTS - 1) * 1024.0; + unpacked->y = y * range / (MAX_CLIENTS - 1) * 1024.0; } unpacked->yaw = yaw * 11.25f; @@ -429,12 +429,24 @@ void CL_SystemInfoChanged( void ) { // in some cases, outdated cp commands might get sent with this news serverId cl.serverId = atoi( Info_ValueForKey( systemInfo, "sv_serverid" ) ); +#ifdef USE_VOIP +#ifdef LEGACY_PROTOCOL + if(clc.compat) + clc.voipEnabled = qfalse; + else +#endif + { + s = Info_ValueForKey( systemInfo, "sv_voipProtocol" ); + clc.voipEnabled = !Q_stricmp(s, "opus"); + } +#endif + // don't set any vars when playing a demo if ( clc.demoplaying ) { return; } - s = Info_ValueForKey( systemInfo, "sv_cheats" ); + s = Info_ValueForKey( systemInfo, "cheats" ); cl_connectedToCheatServer = atoi( s ); if ( !cl_connectedToCheatServer ) { Cvar_SetCheatState(); @@ -556,6 +568,7 @@ void CL_ParseGamestate( msg_t *msg ) { csNum = CPT_NormalizeConfigstring(i); if (csNum < 0 || csNum >= MAX_CONFIGSTRINGS) { Com_Error(ERR_DROP, "configstring > MAX_CONFIGSTRINGS"); + return; } s = MSG_ReadScrambledBigString(msg); len = strlen(s); @@ -576,8 +589,7 @@ void CL_ParseGamestate( msg_t *msg ) { //Com_Memset (&nullstate, 0, sizeof(nullstate)); MSG_GetNullEntityState(&nullstate); es = &cl.entityBaselines[ newnum ]; - // FIXME: frametime - MSG_ReadDeltaEntity( msg, &nullstate, es, newnum, 0.0); + MSG_ReadDeltaEntity( msg, &nullstate, es, newnum, cls.serverFrameTime); } else { Com_Error( ERR_DROP, "CL_ParseGamestate: bad command byte %i", cmd ); } @@ -594,16 +606,25 @@ void CL_ParseGamestate( msg_t *msg ) { // stop recording now so the demo won't have an unnecessary level load at the end. if(cl_autoRecordDemo->integer && clc.demorecording) CL_StopRecord_f(); - - // reinitialize the filesystem if the game directory has changed - FS_ConditionalRestart( clc.checksumFeed, qfalse ); + + if (clc.state == CA_CONNECTED && !Cvar_Get("sv_paks", "", 0)->string[0]) { + // Added in 2.30 + FS_Restart(clc.checksumFeed); + } else { + // reinitialize the filesystem if the game directory has changed + FS_ConditionalRestart(clc.checksumFeed, qfalse); + } clc.state = CA_LOADING; if (!com_sv_running->integer) { const char *info = cl.gameState.stringData + cl.gameState.stringOffsets[CS_SERVERINFO]; - UI_ClearState(); - UI_BeginLoad(Info_ValueForKey(info, "mapname")); + const char *mapname = Info_ValueForKey(info, "mapname"); + // Added in 2.0 + Cvar_Set("mapname", mapname); + + UI_ClearState(); + UI_BeginLoad(mapname); } // This used to call CL_StartHunkUsers, but now we enter the download state before loading the @@ -784,6 +805,178 @@ void CL_ParseDownload ( msg_t *msg ) { } } +#ifdef USE_VOIP +static +qboolean CL_ShouldIgnoreVoipSender(int sender) +{ + if (!cl_voip->integer) + return qtrue; // VoIP is disabled. + else if ((sender == clc.clientNum) && (!clc.demoplaying)) + return qtrue; // ignore own voice (unless playing back a demo). + else if (clc.voipMuteAll) + return qtrue; // all channels are muted with extreme prejudice. + else if (clc.voipIgnore[sender]) + return qtrue; // just ignoring this guy. + else if (clc.voipGain[sender] == 0.0f) + return qtrue; // too quiet to play. + + return qfalse; +} + +/* +===================== +CL_PlayVoip + +Play raw data +===================== +*/ + +static void CL_PlayVoip(int sender, int samplecnt, const byte *data, int flags) +{ + if(flags & VOIP_DIRECT) + { + S_RawSamples(sender + 1, samplecnt, 48000, 2, 1, + data, clc.voipGain[sender], -1); + } + + if(flags & VOIP_SPATIAL) + { + S_RawSamples(sender + MAX_CLIENTS + 1, samplecnt, 48000, 2, 1, + data, 1.0f, sender); + } +} + +/* +===================== +CL_ParseVoip + +A VoIP message has been received from the server +===================== +*/ +static +void CL_ParseVoip ( msg_t *msg, qboolean ignoreData ) { + static short decoded[VOIP_MAX_PACKET_SAMPLES*4]; // !!! FIXME: don't hard code + + const int sender = MSG_ReadShort(msg); + const int generation = MSG_ReadByte(msg); + const int sequence = MSG_ReadLong(msg); + const int frames = MSG_ReadByte(msg); + const int packetsize = MSG_ReadShort(msg); + const int flags = MSG_ReadBits(msg, VOIP_FLAGCNT); + unsigned char encoded[4000]; + int numSamples; + int seqdiff; + int written = 0; + int i; + + Com_DPrintf("VoIP: %d-byte packet from client %d\n", packetsize, sender); + + if (sender < 0) + return; // short/invalid packet, bail. + else if (generation < 0) + return; // short/invalid packet, bail. + else if (sequence < 0) + return; // short/invalid packet, bail. + else if (frames < 0) + return; // short/invalid packet, bail. + else if (packetsize < 0) + return; // short/invalid packet, bail. + + if (packetsize > sizeof (encoded)) { // overlarge packet? + int bytesleft = packetsize; + while (bytesleft) { + int br = bytesleft; + if (br > sizeof (encoded)) + br = sizeof (encoded); + MSG_ReadData(msg, encoded, br); + bytesleft -= br; + } + return; // overlarge packet, bail. + } + + MSG_ReadData(msg, encoded, packetsize); + + if (ignoreData) { + return; // just ignore legacy speex voip data + } else if (!clc.voipCodecInitialized) { + return; // can't handle VoIP without libopus! + } else if (sender >= MAX_CLIENTS) { + return; // bogus sender. + } else if (CL_ShouldIgnoreVoipSender(sender)) { + return; // Channel is muted, bail. + } + + // !!! FIXME: make sure data is narrowband? Does decoder handle this? + + Com_DPrintf("VoIP: packet accepted!\n"); + + seqdiff = sequence - clc.voipIncomingSequence[sender]; + + // This is a new "generation" ... a new recording started, reset the bits. + if (generation != clc.voipIncomingGeneration[sender]) { + Com_DPrintf("VoIP: new generation %d!\n", generation); + opus_decoder_ctl(clc.opusDecoder[sender], OPUS_RESET_STATE); + clc.voipIncomingGeneration[sender] = generation; + seqdiff = 0; + } else if (seqdiff < 0) { // we're ahead of the sequence?! + // This shouldn't happen unless the packet is corrupted or something. + Com_DPrintf("VoIP: misordered sequence! %d < %d!\n", + sequence, clc.voipIncomingSequence[sender]); + // reset the decoder just in case. + opus_decoder_ctl(clc.opusDecoder[sender], OPUS_RESET_STATE); + seqdiff = 0; + } else if (seqdiff * VOIP_MAX_PACKET_SAMPLES*2 >= sizeof (decoded)) { // dropped more than we can handle? + // just start over. + Com_DPrintf("VoIP: Dropped way too many (%d) frames from client #%d\n", + seqdiff, sender); + opus_decoder_ctl(clc.opusDecoder[sender], OPUS_RESET_STATE); + seqdiff = 0; + } + + if (seqdiff != 0) { + Com_DPrintf("VoIP: Dropped %d frames from client #%d\n", + seqdiff, sender); + // tell opus that we're missing frames... + for (i = 0; i < seqdiff; i++) { + assert((written + VOIP_MAX_PACKET_SAMPLES) * 2 < sizeof (decoded)); + numSamples = opus_decode(clc.opusDecoder[sender], NULL, 0, decoded + written, VOIP_MAX_PACKET_SAMPLES, 0); + if ( numSamples <= 0 ) { + Com_DPrintf("VoIP: Error decoding frame %d from client #%d\n", i, sender); + continue; + } + written += numSamples; + } + } + + numSamples = opus_decode(clc.opusDecoder[sender], encoded, packetsize, decoded + written, ARRAY_LEN(decoded) - written, 0); + + if ( numSamples <= 0 ) { + Com_DPrintf("VoIP: Error decoding voip data from client #%d\n", sender); + numSamples = 0; + } + + #if 0 + static FILE *encio = NULL; + if (encio == NULL) encio = fopen("voip-incoming-encoded.bin", "wb"); + if (encio != NULL) { fwrite(encoded, packetsize, 1, encio); fflush(encio); } + static FILE *decio = NULL; + if (decio == NULL) decio = fopen("voip-incoming-decoded.bin", "wb"); + if (decio != NULL) { fwrite(decoded+written, numSamples*2, 1, decio); fflush(decio); } + #endif + + written += numSamples; + + Com_DPrintf("VoIP: playback %d bytes, %d samples, %d frames\n", + written * 2, written, frames); + + if(written > 0) + CL_PlayVoip(sender, written, (const byte *) decoded, flags); + + clc.voipIncomingSequence[sender] = sequence + frames; +} +#endif + + /* ===================== CL_ParseCommandString @@ -932,8 +1125,16 @@ void CL_ParseServerMessage( msg_t *msg ) { } CL_ParseCGMessage( msg ); break; + case svc_voipSpeex: +#ifdef USE_VOIP + CL_ParseVoip( msg, qtrue ); +#endif + break; + case svc_voipOpus: +#ifdef USE_VOIP + CL_ParseVoip( msg, !clc.voipEnabled ); +#endif + break; } } } - - diff --git a/code/client/cl_scrn.cpp b/code/client/cl_scrn.cpp index 0f97ef05..a14769a1 100644 --- a/code/client/cl_scrn.cpp +++ b/code/client/cl_scrn.cpp @@ -343,7 +343,7 @@ void SCR_DrawDemoRecording( void ) { } pos = FS_FTell( clc.demofile ); - sprintf( string, "RECORDING %s: %ik", clc.demoName, pos / 1024 ); + Com_sprintf( string, sizeof( string ), "RECORDING %s: %ik", clc.demoName, pos / 1024 ); SCR_DrawStringExt( 320 - strlen( string ) * 4, 20, 8, string, g_color_table[7], qtrue, qfalse ); } @@ -520,16 +520,18 @@ text to the screen. ================== */ void SCR_UpdateScreen( void ) { - static int recursive; + static qboolean screen_recursive; if ( !scr_initialized ) { return; // not initialized yet } - if ( ++recursive > 2 ) { - Com_Error( ERR_FATAL, "SCR_UpdateScreen: recursively called" ); + if (screen_recursive) { + // already called + return; } - recursive = 1; + + screen_recursive = qtrue; CL_StartHunkUsers(qfalse); SCR_SimpleUpdateScreen(); @@ -553,6 +555,6 @@ void SCR_UpdateScreen( void ) { } } - recursive = 0; + screen_recursive = qfalse; } diff --git a/code/client/cl_ui.cpp b/code/client/cl_ui.cpp index 56e01306..e8cef7f9 100644 --- a/code/client/cl_ui.cpp +++ b/code/client/cl_ui.cpp @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -29,6 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "../qcommon/q_version.h" #include "cl_ui.h" +#include "cl_uigamespy.h" #include @@ -136,18 +137,26 @@ static unsigned int startCountHigh; static unsigned int loadCountLow; static unsigned int loadCountHigh; static unsigned int loadCount; -static unsigned int lastTime; +static unsigned int lastTime = 0; +static unsigned int updateTime = 0; static unsigned int loadNumber; static unsigned int totalLoadTime; static unsigned int currentLoadTime; unsigned char UIListCtrlItem[8]; +static const float maxWidthRes = 1920; +static const float maxHeightRes = 1080; + inventory_t client_inv; bind_t client_bind; static str scoreboard_menuname; static str ui_sCurrentLoadingMenu; static Container hudList; +const UColor UWhiteChatMessageColor(0.75, 0.75, 0.75); +const UColor URedChatMessageColor(1.0, 0.25, 0.25); +const UColor UGreenChatMessageColor(0.0, 1.0, 0.25, 1.0); + void UI_MultiplayerMenuWidgetsUpdate(void); void UI_MultiplayerMainMenuWidgetsUpdate(void); void UI_MainMenuWidgetsUpdate(void); @@ -211,15 +220,15 @@ static UIRect2D getDefaultConsoleRectangle(void) f[i] = floor(f[i]); } - rect.pos.x = f[0] - cls.glconfig.vidWidth; - rect.pos.y = f[1] - cls.glconfig.vidHeight; + rect.pos.x = f[0] - uid.vidWidth; + rect.pos.y = f[1] - uid.vidHeight; rect.size.width = f[2] + 50.0; rect.size.height = f[3] + 50.0; } else { rect.pos.x = 25.0; rect.pos.y = 25.0; - rect.size.width = (cls.glconfig.vidWidth - 50); - rect.size.height = (cls.glconfig.vidHeight / 2); + rect.size.width = (uid.vidWidth - 50); + rect.size.height = (uid.vidHeight / 2); } return rect; @@ -265,7 +274,7 @@ static void GetClientState(uiClientState_t *state) { state->connectPacketCount = clc.connectPacketCount; state->connState = clc.state; - Q_strncpyz(state->servername, cls.servername, sizeof(state->servername)); + Q_strncpyz(state->servername, clc.servername, sizeof(state->servername)); Q_strncpyz(state->updateInfoString, cls.updateInfoString, sizeof(state->updateInfoString)); Q_strncpyz(state->messageString, clc.serverMessage, sizeof(state->messageString)); state->clientNum = cl.snap.ps.clientNum; @@ -966,15 +975,15 @@ static UIRect2D getDefaultDMConsoleRectangle(void) f[i] = floor(f[i]); } - rect.pos.x = f[0] - cls.glconfig.vidWidth; - rect.pos.y = f[1] - cls.glconfig.vidHeight; + rect.pos.x = f[0] - uid.vidWidth; + rect.pos.y = f[1] - uid.vidHeight; rect.size.width = f[2] + 50.0; rect.size.height = f[3] + 50.0; } else { rect.pos.x = 0; - rect.pos.y = cls.glconfig.vidHeight * 0.58; - rect.size.width = cls.glconfig.vidWidth; - rect.size.height = cls.glconfig.vidHeight * 0.415; + rect.pos.y = uid.vidHeight * 0.58; + rect.size.width = uid.vidWidth; + rect.size.height = uid.vidHeight * 0.415; } return rect; @@ -996,15 +1005,19 @@ static UIRect2D getQuickMessageDMConsoleRectangle(void) f[i] = floor(f[i]); } - rect.pos.x = f[0] - cls.glconfig.vidWidth; - rect.pos.y = f[1] - cls.glconfig.vidHeight; + rect.pos.x = f[0] - uid.vidWidth; + rect.pos.y = f[1] - uid.vidHeight; rect.size.width = f[2] + 50.0; rect.size.height = f[3] + 50.0; } else { - rect.pos.x = 0; - rect.pos.y = cls.glconfig.vidHeight * 0.65; - rect.size.width = cls.glconfig.vidWidth; - rect.size.height = 38.0; + rect.pos.x = 0; + rect.pos.y = uid.vidHeight * 0.66; + rect.size.width = uid.vidWidth; + // Fixed in 2.0 + // Was 38.0 in 1.11 and below + // This prevents characters to be seen from the DM console + // in the quick message console + rect.size.height = 36.0 * uid.scaleRes[1]; } return rect; @@ -1017,7 +1030,7 @@ UI_DMMessageModesMatch */ static qboolean UI_DMMessageModesMatch(int iMode) { - qboolean bQuickMessage; + qboolean bQuickMessage = qfalse; if (iMode && (iMode != 300 || dm_console->GetQuickMessageMode())) { if (iMode < 0) { @@ -1048,13 +1061,15 @@ static void UI_SetDMConsoleMode(int iMode) return; } + bQuickMessage = qfalse; + if (iMode < 0) { bQuickMessage = qtrue; iMode = -iMode; } if (iMode == 300) { - bQuickMessage = dm_console->GetMessageMode(); + iMode = dm_console->GetMessageMode(); } if (dm_console->GetQuickMessageMode()) { @@ -1064,8 +1079,8 @@ static void UI_SetDMConsoleMode(int iMode) } } else { if (bQuickMessage) { - dm_console->setFrame(getDefaultDMConsoleRectangle()); - dm_console->SetQuickMessageMode(qfalse); + dm_console->setFrame(getQuickMessageDMConsoleRectangle()); + dm_console->SetQuickMessageMode(bQuickMessage); } } @@ -1086,7 +1101,7 @@ static void UI_SetDMConsoleMode(int iMode) dm_console->setTitle(Sys_LV_CL_ConvertString( "Chat Window (Enter to send/close) (all|team|private to change mode) : Messaging to All" )); - } else if (iMode == 100) { + } else if (iMode == 200) { dm_console->setTitle(Sys_LV_CL_ConvertString( "Chat Window (Enter to send/close) (all|team|private to change mode) : Messaging to Team" )); @@ -1121,6 +1136,20 @@ static void DMConsoleCommandHandler(const char *txt) CL_AddReliableCommand(szStringOut, qfalse); } +/* +==================== +getScreenWidth +==================== +*/ +static float getScreenWidth() +{ + if (uid.bHighResScaling) { + return maxWidthRes; + } else { + return uid.vidWidth; + } +} + /* ==================== getNewConsole @@ -1182,14 +1211,14 @@ getDefaultGMBoxRectangle static UIRect2D getDefaultGMBoxRectangle(void) { UIRect2D dmRect = getDefaultDMBoxRectangle(); - float height = cls.glconfig.vidHeight * ui_compass_scale->value * 0.25f; + float height = uid.vidHeight * ui_compass_scale->value * 0.25f; float y = dmRect.size.height + dmRect.pos.y; if (height < y) { height = y; } - return UIRect2D(20.0f, height, cls.glconfig.vidWidth - 20, 128.0f); + return UIRect2D(20.0f, height, (getScreenWidth() - 20) * uid.scaleRes[0], 128.0f * uid.scaleRes[1]); } /* @@ -1199,9 +1228,37 @@ getDefaultDMBoxRectangle */ static UIRect2D getDefaultDMBoxRectangle(void) { - float width = cls.glconfig.vidWidth * ui_compass_scale->value * 0.2f; + float width; + float screenWidth = getScreenWidth(); + + width = screenWidth * uid.scaleRes[0] * ui_compass_scale->value * 0.2f; - return UIRect2D(width, 0, cls.glconfig.vidWidth - (width + 192.0f), 120.0f); + return UIRect2D(width, 0, (screenWidth - (width + 192.0f)) * uid.scaleRes[0], 120.0f * uid.scaleRes[1]); +} + +/* +==================== +UI_GetObjectivesTop +==================== +*/ +float UI_GetObjectivesTop(void) +{ + return getDefaultGMBoxRectangle().pos.y; +} + +/* +==================== +UI_GetObjectivesTop +==================== +*/ +void UI_GetHighResolutionScale(vec2_t scale) +{ + if (uid.bHighResScaling) { + scale[0] = uid.scaleRes[0]; + scale[1] = uid.scaleRes[1]; + } else { + scale[0] = scale[1] = 1.0; + } } /* @@ -1251,11 +1308,11 @@ UI_PrintConsole */ void UI_PrintConsole(const char *msg) { - UColor *pColor = NULL; - const char *pszString; - char szString[1024]; - char szBlah[1024]; - qboolean bPrintedDMBox = qfalse; + const UColor *pColor = NULL; + const char *pszString; + char szString[1024]; + char szBlah[1024]; + qboolean bPrintedDMBox = qfalse; pszString = msg; strncpy(szString, msg, 1024); @@ -1273,7 +1330,7 @@ void UI_PrintConsole(const char *msg) break; case MESSAGE_CHAT_WHITE: bDMMessage = qtrue; - pColor = &UGrey; + pColor = &UWhiteChatMessageColor; break; case MESSAGE_WHITE: bBold = qtrue; @@ -1281,15 +1338,17 @@ void UI_PrintConsole(const char *msg) break; case MESSAGE_CHAT_RED: bDeathMessage = MESSAGE_CHAT_RED; - pColor = &ULightRed; + pColor = &URedChatMessageColor; break; case MESSAGE_CHAT_GREEN: bDeathMessage = MESSAGE_CHAT_GREEN; - pColor = &UGreen; + pColor = &UGreenChatMessageColor; break; } - pszString++; + if (*pszString != 0) { + pszString++; + } // // print to the deathmatch console @@ -1458,7 +1517,7 @@ void UI_FocusMenuIfExists(void) currentMenu->ActivateMenu(); if (ui_newvidmode->integer == -1) { - Cvar_Get("ui_newvidmode", va("%d", r_mode), CVAR_SERVER_CREATED); + Cvar_Get("ui_newvidmode", va("%d", r_mode), CVAR_RESETSTRING); Cvar_SetValue("ui_newvidmode", r_mode); } } else { @@ -1662,11 +1721,11 @@ UI_ClearBackground void UI_ClearBackground(void) { re.Set2DWindow( - 0, 0, cls.glconfig.vidWidth, cls.glconfig.vidHeight, 0, cls.glconfig.vidWidth, cls.glconfig.vidHeight, 0, -1, -1 + 0, 0, uid.vidWidth, uid.vidHeight, 0, uid.vidWidth, uid.vidHeight, 0, -1, 1 ); - re.Scissor(0, 0, cls.glconfig.vidWidth, cls.glconfig.vidHeight); + re.Scissor(0, 0, uid.vidWidth, uid.vidHeight); re.SetColor(g_color_table[0]); - re.DrawBox(0, 0, cls.glconfig.vidWidth, cls.glconfig.vidHeight); + re.DrawBox(0, 0, uid.vidWidth, uid.vidHeight); re.SetColor(NULL); } @@ -1700,7 +1759,36 @@ void UI_DrawIntro(void) view3d->setShow(false); UI_ClearBackground(); - // FIXME: draw intro + if (cls.startStage < 3 || cls.startStage >= 12) { + return; + } + + if (intro_stage.material->GetMaterial()) { + float swidth; + float sheight; + vec4_t color; + + VectorSet4(color, 1, 1, 1, 1); + if (intro_stage.fadetime) { + float frac; + + frac = Q_clamp_float((cls.realtime - intro_stage.starttime) / intro_stage.fadetime, 0, 1); + color[0] = color[1] = color[2] = + intro_stage.alpha_start + frac * (intro_stage.alpha_end - intro_stage.alpha_start); + } + + swidth = view3d->getFrame().getMaxX(); + sheight = view3d->getFrame().getMaxY(); + + re.SetColor(color); + + re.DrawStretchPic(0.0, 0.0, swidth, sheight, 0.0, 0.0, 1.0, 1.0, intro_stage.material->GetMaterial()); + re.SetColor(NULL); + } + + if (cls.realtime >= intro_stage.endtime) { + CL_FinishedStartStage(); + } } /* @@ -1775,6 +1863,8 @@ void UI_Update(void) hud_compass->GetContainerWidget()->Display(frame, 1.0); } } + + return; } if (fakk_console) { @@ -1805,17 +1895,9 @@ void UI_Update(void) } // don't care about the intro - /* - if( CL_FinishedIntro() ) - { - } - else - { - UI_DrawIntro(); - } - */ - - if (!server_loading && (clc.state == CA_CONNECTING || clc.state == CA_CHALLENGING) && ui_pConnectingMenu) { + if (!CL_FinishedIntro()) { + UI_DrawIntro(); + } else if (!server_loading && (clc.state == CA_CONNECTING || clc.state == CA_CHALLENGING) && ui_pConnectingMenu) { view3d->setShow(false); UI_ClearBackground(); @@ -1853,7 +1935,7 @@ void UI_Update(void) if (clc.state <= CA_PRIMED) { view3d->setShow(false); UI_ClearBackground(); - } else if (clc.state == CA_PRIMED || clc.state == CA_ACTIVE) { + } else if (clc.state == CA_ACTIVE || clc.state == CA_CINEMATIC) { Com_FakeUnpause(); view3d->setShow(true); } else { @@ -1887,7 +1969,7 @@ void UI_Update(void) UI_CloseConsole(); } } else if (ui_static_materials.loading) { - ui_static_materials.loading->ReregisterMaterial(); + ui_static_materials.loading->GetMaterial(); } } } @@ -2634,7 +2716,7 @@ void UI_PushMenuSP_f(void) } if ((!com_cl_running || !com_cl_running->integer || clc.state == CA_DISCONNECTED || !cg_gametype->integer) - && (!com_sv_running || !com_sv_running->integer || !g_gametype->integer)) { + && (!com_sv_running || !com_sv_running->integer || g_gametype->integer == GT_SINGLE_PLAYER)) { UI_PushMenu(Cmd_Argv(1)); } } @@ -2655,7 +2737,7 @@ void UI_PushMenuMP_f(void) } if (com_cl_running && com_cl_running->integer && clc.state != CA_DISCONNECTED && cg_gametype->integer - && com_sv_running && com_sv_running->integer && g_gametype->integer) { + && com_sv_running && com_sv_running->integer && g_gametype->integer != GT_SINGLE_PLAYER) { cmd = Cmd_Argv(1); // @@ -3009,14 +3091,14 @@ void CL_PingServers_f(void) if (!noudp->integer) { adr.type = NA_BROADCAST; adr.port = BigShort(12203); - NET_OutOfBandPrint(NS_SERVER, adr, "info %i", 8); + CL_NET_OutOfBandPrint(adr, "info %i", 8); } noipx = Cvar_Get("noipx", "0", CVAR_INIT); if (!noipx->integer) { adr.type = NA_BROADCAST_IPX; adr.port = BigShort(12203); - NET_OutOfBandPrint(NS_SERVER, adr, "info %i", 8); + CL_NET_OutOfBandPrint(adr, "info %i", 8); } for (i = 0; i < 16; i++) { @@ -3031,7 +3113,7 @@ void CL_PingServers_f(void) adr.port = BigShort(12203); } - NET_OutOfBandPrint(NS_SERVER, adr, "info %i", 8); + CL_NET_OutOfBandPrint(adr, "info %i", 8); } else { Com_Printf("Bad address: %s\n", adrstring); } @@ -3056,7 +3138,7 @@ void UI_MapList_f(void) MapRunnerClass *map = new MapRunnerClass; map->Setup("maps", mappath, ".bsp", "_sml"); - CL_SetMousePos(cls.glconfig.vidWidth / 2, cls.glconfig.vidHeight / 2); + CL_SetMousePos(uid.vidWidth / 2, uid.vidHeight / 2); } /* @@ -3096,7 +3178,7 @@ void UI_DMMapSelect_f(void) MpMapPickerClass *map = new MpMapPickerClass; map->Setup(basepath, mappath, gametype); - CL_SetMousePos(cls.glconfig.vidWidth / 2, cls.glconfig.vidHeight / 2); + CL_SetMousePos(uid.vidWidth / 2, uid.vidHeight / 2); } /* @@ -3280,7 +3362,7 @@ void UI_PlayerModel_f(void) PlayerModelPickerClass *picker = new PlayerModelPickerClass; picker->Setup("models/player", modelpath, bGermanModel); - CL_SetMousePos(cls.glconfig.vidWidth / 2, cls.glconfig.vidHeight / 2); + CL_SetMousePos(uid.vidWidth / 2, uid.vidHeight / 2); } /* @@ -3333,6 +3415,7 @@ void UI_GetPlayerModel_f(void) Cvar_Set("ui_dm_playergermanmodel_set", pszUIPlayerModel); if (!strncmp(pszUIPlayerModel, "german_waffen_", 14)) { + Q_strncpyz(donotshowssindeorfr, "german_waffenss_", sizeof(donotshowssindeorfr)); Q_strcat(donotshowssindeorfr, sizeof(donotshowssindeorfr), pszUIPlayerModel + 14); Cvar_Set("ui_disp_playergermanmodel", va("models/player/%s.tik", donotshowssindeorfr)); } else { @@ -3544,7 +3627,7 @@ UI_WantsKeyboard */ void UI_WantsKeyboard() { - cls.keyCatchers |= KEYCATCH_UI; + Key_SetCatcher(Key_GetCatcher() | KEYCATCH_UI); } struct widgettrans_s { @@ -3669,12 +3752,13 @@ void CL_FillUIImports(void) uii.Rend_Scissor = re.Scissor; uii.Rend_Set2D = re.Set2DWindow; uii.Rend_SetColor = re.SetColor; + uii.Rend_ImageExists = re.ImageExists; uii.Cmd_Stuff = Cbuf_AddText; uii.Cvar_GetString = CvarGetForUI; uii.Cvar_Reset = Cvar_Reset; uii.Cvar_Find = Cvar_FindVar; - uii.Cvar_Set = Cvar_Set; + uii.Cvar_Set = UI_Cvar_Set; uii.File_PickFile = PickFile; uii.File_FreeFile = FS_FreeFile; uii.File_ListFiles = ListFilesForUI; @@ -3708,101 +3792,8 @@ void CL_FillUIImports(void) uii.GetConfigstring = CL_ConfigString; uii.UI_CloseDMConsole = UI_CloseDMConsole; -#if 0 - uii.TIKI_RegisterModel = TIKI_RegisterTiki; - - uii.Cvar_Get = Cvar_Get; - uii.Argc = Cmd_Argc; - uii.Argv = Cmd_Argv; - uii.Cmd_ExecuteText = Cbuf_ExecuteText; - uii.FS_FOpenFile = FS_FOpenFileByMode; - uii.FS_Read = FS_Read; - uii.FS_Write = FS_Write; - uii.FS_FCloseFile = FS_FCloseFile; - uii.FS_GetFileList = FS_GetFileList; - uii.FS_Seek = FS_Seek; - uii.R_RegisterModel = re.RegisterModel; - uii.R_RegisterSkin = re.RegisterShader; - uii.R_RegisterShader = re.RegisterShader; - uii.R_RegisterShaderNoMip = re.RegisterShaderNoMip; - uii.R_ClearScene = re.ClearScene; - uii.R_AddRefEntityToScene = re.AddRefEntityToScene; - uii.R_AddPolyToScene = re.AddPolyToScene; - uii.R_AddLightToScene = re.AddLightToScene; - uii.R_RenderScene = re.RenderScene; - uii.R_SetColor = re.SetColor; - uii.R_DrawStretchPic = re.DrawStretchPic; - uii.UpdateScreen = SCR_UpdateScreen; - uii.S_StartLocalSound = S_StartLocalSound; - uii.S_RegisterSound = S_RegisterSound; - uii.Key_KeynumToStringBuf = Key_KeynumToStringBuf; - uii.Key_KeynumToString = Key_KeynumToString; - uii.Key_GetBindingBuf = Key_GetBindingBuf; - uii.Key_IsDown = Key_IsDown; - uii.Key_GetOverstrikeMode = Key_GetOverstrikeMode; - uii.Key_SetOverstrikeMode = Key_SetOverstrikeMode; - uii.Key_ClearStates = Key_ClearStates; - uii.Key_GetCatcher = Key_GetCatcher; - uii.Key_SetCatcher = Key_SetCatcher; - uii.GetClipboardData = CL_GetClipboardData; - uii.GetClientState = GetClientState; - uii.GetGlconfig = CL_GetGlconfig; - uii.GetConfigString = GetConfigString; - uii.LAN_GetServerCount = LAN_GetServerCount; - uii.LAN_GetServerAddressString = LAN_GetServerAddressString; - uii.LAN_GetServerInfo = LAN_GetServerInfo; - uii.LAN_GetPingQueueCount = LAN_GetPingQueueCount; - uii.LAN_ServerStatus = LAN_GetServerStatus; - uii.LAN_ClearPing = LAN_ClearPing; - uii.LAN_GetPing = LAN_GetPing; - uii.LAN_GetPingInfo = LAN_GetPingInfo; - uii.LAN_GetServerPing = LAN_GetServerPing; - uii.LAN_MarkServerVisible = LAN_MarkServerVisible; - uii.LAN_UpdateVisiblePings = LAN_UpdateVisiblePings; - uii.GetCDKey = CLUI_GetCDKey; - uii.SetCDKey = CLUI_SetCDKey; - uii.R_RegisterFont = re.RegisterFont; - uii.R_Text_Width = re.Text_Width; - uii.R_Text_Height = re.Text_Height; - uii.R_Text_Paint = re.Text_Paint; - uii.R_Text_PaintChar = re.Text_PaintChar; - uii.R_GetShaderName = re.GetShaderName; - - uii.Cmd_Stuff = Cbuf_AddText; - uii.Cvar_GetString = CvarGetForUI; - uii.Cvar_Reset = Cvar_Reset; - uii.Cvar_Find = Cvar_FindVar; - uii.Cvar_Set = UI_Cvar_Set; - uii.File_PickFile = PickFile; - uii.File_FreeFile = FS_FreeFile; - uii.File_ListFiles = ListFilesForUI; - uii.File_OpenFile = FS_ReadFile; - uii.File_WriteFile = FS_WriteTextFile; - uii.Rend_SetColor = re.SetColor; - uii.Snd_PlaySound = UI_StartLocalSound; - uii.Snd_RegisterSound = UI_RegisterSound; - uii.Alias_Add = Alias_Add; - uii.Alias_FindRandom = Alias_FindRandom; - uii.Sys_Error = Com_Error; - uii.Sys_IsKeyDown = IsKeyDown; - uii.Sys_Milliseconds = Sys_Milliseconds; - uii.Sys_Printf = Com_Printf; - uii.Sys_DPrintf = Com_DPrintf; - uii.Sys_GetClipboard = Sys_GetWholeClipboard; - uii.Sys_SetClipboard = Sys_SetClipboard; - uii.Cmd_CompleteCommandByNumber = Cmd_CompleteCommandByNumber; - uii.Cvar_CompleteCvarByNumber = Cvar_CompleteVariableByNumber; - uii.UI_WantsKeyboard = UI_WantsKeyboard; - uii.Client_TranslateWidgetName = TranslateWidgetName; - uii.Connect = CL_Connect; - uii.Key_GetKeynameForCommand = Key_GetKeynameForCommand; - uii.Key_GetCommandForKey = Key_GetBinding; - uii.Key_SetBinding = Key_SetBinding; - uii.Key_GetKeysForCommand = Key_GetKeysForCommand; - uii.Key_KeynumToString = Key_KeynumToBindString; - uii.GetConfigstring = CL_ConfigString; - uii.UI_CloseDMConsole = UI_CloseDMConsole; -#endif + uii.GetRefSequence = CL_GetRefSequence; + uii.IsRendererLoaded = CL_IsRendererLoaded; } /* @@ -3859,7 +3850,7 @@ void UI_CreateDialog( { UIDialog *dlg = new UIDialog; UIRect2D rect = - UIRect2D((cls.glconfig.vidWidth - width) >> 1, (cls.glconfig.vidHeight - height) >> 1, width, height); + UIRect2D((uid.vidWidth - width) / 2, (uid.vidHeight - height) / 2, width, height); UColor bgColor = UWindowColor; dlg->Create(NULL, rect, title, bgColor, UHudColor); @@ -3885,10 +3876,32 @@ void UI_ResolutionChange(void) { UIRect2D frame; - ui_compass_scale = Cvar_Get("ui_compass_scale", "0.75", CVAR_ARCHIVE | CVAR_LATCH); + if (com_target_game->integer >= TG_MOHTA) { + ui_compass_scale = Cvar_Get("ui_compass_scale", "0.75", CVAR_ARCHIVE | CVAR_LATCH); + } else { + // Older version doesn't have an adjustable compass, so assume 0.5 by default + ui_compass_scale = Cvar_Get("ui_compass_scale", "0.55", CVAR_ARCHIVE | CVAR_LATCH); + } + CL_FillUIImports(); CL_FillUIDef(); + // Added in OPM + // Scaling for high resolutions + if (uid.vidWidth > maxWidthRes && uid.vidHeight > maxHeightRes) { + const float vidRatio = (float)uid.vidWidth / (float)uid.vidHeight; + + uid.scaleRes[0] = (float)uid.vidWidth / (maxHeightRes * vidRatio); + uid.scaleRes[1] = (float)uid.vidHeight / maxHeightRes; + //uid.scaleRes[0] = (float)uid.vidWidth / maxWidthRes; + //uid.scaleRes[1] = (float)uid.vidHeight / maxHeightRes; + uid.bHighResScaling = qtrue; + } else { + uid.scaleRes[0] = 1; + uid.scaleRes[1] = 1; + uid.bHighResScaling = qfalse; + } + if (!uie.ResolutionChange) { return; } @@ -3923,7 +3936,7 @@ void UI_ResolutionChange(void) menuManager.RealignMenus(); if (view3d) { - frame = UIRect2D(0, 0, cls.glconfig.vidWidth, cls.glconfig.vidHeight); + frame = UIRect2D(0, 0, uid.vidWidth, uid.vidHeight); view3d->setFrame(frame); } @@ -3971,13 +3984,13 @@ void S_ServerLoaded(void) Com_DPrintf("Loading Previous Sound State.\n"); S_StopAllSounds2(qfalse); - //S_TriggeredMusic_Stop(); - //s_bSoundPaused = qtrue; - //S_ReLoad( &svs.soundSystem ); - // - //if( svs.tm_filename[ 0 ] ) { - // S_TriggeredMusic_SetupHandle( svs.tm_filename, svs.tm_loopcount, svs.tm_offset, 0 ); - //} + S_TriggeredMusic_Stop(); + s_bSoundPaused = qtrue; + S_ReLoad(&svs.soundSystem); + + if (svs.tm_filename[0]) { + S_TriggeredMusic_SetupHandle(svs.tm_filename, svs.tm_loopcount, svs.tm_offset, 0); + } } /* @@ -4022,6 +4035,11 @@ void UI_ServerLoaded(void) return; } + if (ui_sCurrentLoadingMenu == "loading_default") { + UI_FinishLoadingScreen_f(); + return; + } + server_loading_waiting = qtrue; event = new Event(EV_Widget_Enable); @@ -4317,7 +4335,7 @@ public: void UpdateStats(Event *ev); }; -Event EV_StatsUpdater_UpdateStats; +Event EV_StatsUpdater_UpdateStats("updatestats", EV_DEFAULT, NULL, NULL, "Update the stats on the missionLog"); CLASS_DECLARATION(Listener, StatsUpdater, NULL) { {NULL, NULL} @@ -4354,10 +4372,8 @@ UI_ShowScoreboard_f void UI_ShowScoreboard_f(const char *pszMenuName) { if (pszMenuName) { - if (scoreboard_menuname.length()) { - if (str::icmp(scoreboard_menuname, pszMenuName)) { - scoreboard_menu->ForceHide(); - } + if (scoreboard_menuname.length() && str::icmp(scoreboard_menuname, pszMenuName) && scoreboard_menu) { + scoreboard_menu->ForceHide(); } scoreboard_menuname = pszMenuName; @@ -4406,7 +4422,10 @@ void UI_HideScoreboard_f(void) } if (scoreboard_menuname.length()) { - scoreboard_menu->ForceHide(); + // Fixed in 2.30 (scoreboard_menu check) + if (scoreboard_menu) { + scoreboard_menu->ForceHide(); + } } } @@ -4451,7 +4470,7 @@ void ScoreboardListItem::DrawListItem(int iColumn, const UIRect2D& drawRect, boo { DrawBox(drawRect, backColor, 1.0); pFont->setColor(textColor); - pFont->Print(drawRect.pos.x + 1, drawRect.pos.y, Sys_LV_CL_ConvertString(getListItemString(iColumn)), -1, qfalse); + pFont->Print((drawRect.pos.x + 1) / uid.scaleRes[0], drawRect.pos.y / uid.scaleRes[1], Sys_LV_CL_ConvertString(getListItemString(iColumn)), -1, uid.scaleRes); if (bTitleItem) { UIRect2D lineRect; @@ -4504,7 +4523,7 @@ void UI_CreateScoreboard(void) scoreboard_h = h; SCR_AdjustFrom640(&x, &y, &w, &h); - fColumnScale = cls.glconfig.vidWidth / 640.0; + fColumnScale = uid.vidWidth / 640.0; cge->CG_GetScoreBoardColor(&fR, &fG, &fB, &fA); cge->CG_GetScoreBoardFontColor(&fFontR, &fFontG, &fFontB, &fFontA); @@ -4728,7 +4747,7 @@ CL_FinishedIntro */ qboolean CL_FinishedIntro(void) { - return !cls.startStage; + return cls.startStage == 0; } /* @@ -4738,7 +4757,87 @@ CL_FinishedStartStage */ void CL_FinishedStartStage(void) { - // FIXME: stub + int wait; + + switch (cls.startStage++) { + case 1: + Cbuf_ExecuteText(EXEC_NOW, "cinematic EAlogo.RoQ\n"); + break; + case 2: + intro_stage.alpha_start = 0.0; + intro_stage.alpha_end = 1.0; + + wait = ui_titlescreen_fadein->value * 1000.0; + intro_stage.fadetime = wait; + intro_stage.starttime = cls.realtime; + intro_stage.endtime = cls.realtime + wait; + + intro_stage.material = uWinMan.RegisterShader("mohaa_title"); + break; + case 3: + intro_stage.alpha_start = 1.0; + intro_stage.alpha_end = 1.0; + + wait = ui_legalscreen_stay->value * 1000.0; + intro_stage.fadetime = 0.0; + intro_stage.starttime = cls.realtime; + intro_stage.endtime = cls.realtime + wait; + break; + case 4: + intro_stage.alpha_start = 1.0; + intro_stage.alpha_end = 0.0; + + wait = ui_titlescreen_fadeout->value * 1000.0; + intro_stage.fadetime = wait; + intro_stage.starttime = cls.realtime; + intro_stage.endtime = cls.realtime + wait; + break; + case 5: + intro_stage.alpha_start = 0.0; + intro_stage.alpha_end = 1.0; + + wait = ui_legalscreen_fadein->value * 1000.0; + intro_stage.fadetime = wait; + intro_stage.starttime = cls.realtime; + intro_stage.endtime = cls.realtime + wait; + + intro_stage.material = uWinMan.RegisterShader("legal"); + break; + case 6: + intro_stage.alpha_start = 1.0; + intro_stage.alpha_end = 1.0; + + wait = ui_legalscreen_stay->value * 1000.0; + intro_stage.fadetime = 0.0; + intro_stage.starttime = cls.realtime; + intro_stage.endtime = cls.realtime + wait; + break; + case 7: + intro_stage.alpha_start = 1.0; + intro_stage.alpha_end = 0.0; + + wait = ui_legalscreen_fadeout->value * 1000.0; + intro_stage.fadetime = wait; + intro_stage.starttime = cls.realtime; + intro_stage.endtime = cls.realtime + wait; + break; + case 8: + if (com_target_game->integer >= target_game_e::TG_MOHTA) { + cls.startStage = 0; + return; + } + + Cbuf_ExecuteText(EXEC_NOW, "cinematic 2015intro.RoQ\n"); + break; + case 9: + Cbuf_ExecuteText(EXEC_NOW, "cinematic intro.RoQ\n"); + break; + case 10: + cls.startStage = 0; + break; + default: + break; + } } /* @@ -4754,9 +4853,6 @@ void UI_StartStageKeyEvent(void) SCR_StopCinematic(); } break; - case 12: - SCR_StopCinematic(); - break; case 3: case 4: case 5: @@ -4775,11 +4871,9 @@ void UI_StartStageKeyEvent(void) break; case 9: case 10: - case 11: - if (ui_skip_legalscreen->integer) { - cls.startStage = 11; - CL_FinishedStartStage(); - } + SCR_StopCinematic(); + break; + default: break; } } @@ -4807,8 +4901,8 @@ void CL_TryStartIntro(void) UI_ToggleConsole(); } else { // FIXME: no intro from now - //Cvar_Set( cl_playintro->name, "0" ); - //UI_StartIntro_f(); + Cvar_Set(cl_playintro->name, "0"); + UI_StartIntro_f(); } } @@ -4969,6 +5063,20 @@ void UI_HideStatistics_f() statsUpdater.CancelEventsOfType(EV_StatsUpdater_UpdateStats); } +/* +==================== +UI_SalesScreen_f +==================== +*/ +void UI_SalesScreen_f() +{ + if (random() > 0.5) { + Cbuf_AddText("pushmenu sales_splash1\n"); + } else { + Cbuf_AddText("pushmenu sales_splash2\n"); + } +} + /* ==================== CL_ShutdownUI @@ -5164,7 +5272,7 @@ void CL_InitializeUI(void) ui_success = Cvar_Get("ui_success", "0", 0); ui_failed = Cvar_Get("ui_failed", "0", 0); ui_returnmenu = Cvar_Get("ui_returnmenu", "0", 0); - ui_skip_eamovie = Cvar_Get("ui_skip_eamovie", "0", 0); + ui_skip_eamovie = Cvar_Get("ui_skip_eamovie", "1", 0); ui_skip_titlescreen = Cvar_Get("ui_skip_titlescreen", "1", 0); ui_skip_legalscreen = Cvar_Get("ui_skip_legalscreen", "1", 0); ui_titlescreen_fadein = Cvar_Get("ui_titlescreen_fadein", "1", 0); @@ -5239,6 +5347,8 @@ void CL_InitializeUI(void) Cmd_AddCommand("-statistics", UI_HideStatistics_f); Cmd_AddCommand("setreturnmenu", UI_SetReturnMenuToCurrent); Cmd_AddCommand("gotoreturnmenu", UI_PushReturnMenu_f); + Cmd_AddCommand("salesscreen", UI_SalesScreen_f); + Cmd_AddCommand("launchgamespy", UI_LaunchGameSpy_f); if (developer->integer) { UColor bgColor; @@ -5260,7 +5370,7 @@ void CL_InitializeUI(void) // Create the 3D view view3d = new View3D; view3d->setAlwaysOnBottom(true); - view3d->InitFrame(NULL, 0, 0, cls.glconfig.vidWidth, cls.glconfig.vidHeight, -1, "facfont-20"); + view3d->InitFrame(NULL, 0, 0, uid.vidWidth, uid.vidHeight, -1, "facfont-20"); view3d->setName("view3d"); view3d->InitSubtitle(); @@ -5360,6 +5470,10 @@ void CL_InitializeUI(void) CL_ClearButtons(); cls.uiStarted = qtrue; + + if (!com_dedicated->integer) { + CL_TryStartIntro(); + } } static char **loadStrings; @@ -5397,7 +5511,16 @@ void UI_BeginLoadResource(void) UI_EndLoadResource ==================== */ -void UI_EndLoadResource(void) {} +void UI_EndLoadResource(void) +{ + clock_t time; + + time = clock() - (((clock_t)startCountHigh << 32) | startCountLow) + (((clock_t)loadCountHigh << 32) | loadCountLow); + + loadCountHigh = time >> 32; + loadCountLow = time; + loadCount = time >> 25; +} /* ==================== @@ -5443,7 +5566,7 @@ qboolean UI_IsResourceLoaded(const char *name) case 107: return S_IsSoundRegistered(name + 1); case 110: - return R_ImageExists(name + 1); + return uii.Rend_ImageExists(name + 1); default: return qfalse; } @@ -5463,19 +5586,17 @@ void UI_RegisterLoadResource(const char *name) high = loadNumber - 1; while (low <= high) { - i = (high + low) / 2; + i = (low + high) / 2; j = strcmp(name, loadStrings[i]); - if (j >= 0) { - if (j <= 0) { - currentLoadTime += loadTimes[i]; - loadTimes[i] = 0; - return; - } - + if (j < 0) { + high = i - 1; + } else if (j > 0) { low = i + 1; } else { - high = i - 1; + currentLoadTime += loadTimes[i]; + loadTimes[i] = 0; + break; } } } @@ -5488,12 +5609,19 @@ UI_TestUpdateScreen void UI_TestUpdateScreen(unsigned int timeout) { unsigned int newTime = Sys_Milliseconds(); + unsigned int startRenderTime, endRenderTime; - if (newTime - lastTime >= timeout) { - lastTime = newTime; - Sys_PumpMessageLoop(); - SCR_UpdateScreen(); + if (timeout > 0 && (newTime - lastTime) < (timeout + updateTime)) { + return; } + + startRenderTime = Sys_Milliseconds(); + Sys_PumpMessageLoop(); + SCR_UpdateScreen(); + endRenderTime = Sys_Milliseconds(); + + updateTime = Q_min(endRenderTime - startRenderTime, 1000); + lastTime = endRenderTime; } /* @@ -5531,7 +5659,7 @@ void UI_LoadResource(const char *name) Cvar_SetValue("loadingbar", (float)currentLoadTime / (float)totalLoadTime); } - UI_TestUpdateScreen(333u); + UI_TestUpdateScreen(33); } /* @@ -5699,8 +5827,15 @@ void UI_BeginLoad(const char *pszMapName) loadName = "maps/"; loadName += pszMapName; + mapfile = loadName; loadName += ".min"; - mapfile = loadName + ".bsp"; + + if (CL_UseLargeLightmap(pszMapName)) { + mapfile += ".bsp"; + } else { + // Added in 2.0 + mapfile += "_sml.bsp"; + } if (UI_ArchiveLoadMapinfo(mapfile)) { cls.loading = SS_LOADING2; @@ -5807,12 +5942,12 @@ void UI_EndLoad(void) } file = FS_FOpenFileWrite(loadName); - sprintf(buf, "%d\n%d %d\n", 3, loadNumber, size); + Com_sprintf(buf, sizeof(buf), "%d\n%d %d\n", 3, loadNumber, size); FS_Write(buf, strlen(buf), file); for (i = 0; i < loadNumber; i++) { - sprintf(buf, "%s\n%d\n", base[i]->name, base[i]->loadCount); + Com_sprintf(buf, sizeof(buf), "%s\n%d\n", base[i]->name, base[i]->loadCount); FS_Write(buf, strlen(buf), file); } diff --git a/code/client/cl_ui.h b/code/client/cl_ui.h index 257161a7..ab3a001e 100644 --- a/code/client/cl_ui.h +++ b/code/client/cl_ui.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2023-2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -35,6 +35,7 @@ typedef struct { extern cvar_t *ui_health_start; extern cvar_t *ui_health_end; extern cvar_t *sound_overlay; +extern cvar_t *cl_movieaudio; // // initialization @@ -46,14 +47,20 @@ void CL_ShutdownUI(void); // // general ui stuff // -extern inventory_t client_inv; -extern bind_t client_bind; -extern cvar_t *cl_greenfps; +extern inventory_t client_inv; +extern bind_t client_bind; +extern cvar_t *cl_greenfps; +extern qboolean server_loading; +extern const UColor UWhiteChatMessageColor; +extern const UColor URedChatMessageColor; +extern const UColor UGreenChatMessageColor; const char *CvarGetForUI(const char *name, const char *defval); void UI_ClearState(void); void CL_BeginRegistration(void); void CL_EndRegistration(void); +float UI_GetObjectivesTop(void); +void UI_GetHighResolutionScale(vec2_t scale); // // menu @@ -110,6 +117,7 @@ void UI_DeleteScoreBoardItems(int iMaxIndex); void UI_BeginLoad(const char *pszMapName); void UI_EndLoad(void); void UI_AbortLoad(void); +int CL_FontStringWidth(fontheader_t* pFont, const char* pszString, int iMaxLen); void UI_BeginLoadResource(void); void UI_EndLoadResource(void); void UI_EndLoadResource(const char *name); diff --git a/code/client/cl_uidmbox.cpp b/code/client/cl_uidmbox.cpp index 357d7571..c55afa08 100644 --- a/code/client/cl_uidmbox.cpp +++ b/code/client/cl_uidmbox.cpp @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -21,6 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "cl_ui.h" +#include "../qcommon/localization.h" Event EV_DMBox_Goin ( @@ -40,126 +41,116 @@ Event EV_DMBox_Decay "Event to make the dmbox console line decay" ); -static float s_dmboxWidth = 384.0; +static float s_dmboxWidth = 384.0; static float s_dmboxOffsetX = 3.0f; static float s_dmboxOffsetY = 8.0f; -CLASS_DECLARATION( UIWidget, UIDMBox, NULL ) -{ - { &W_SizeChanged, &UIDMBox::OnSizeChanged }, - { &EV_DMBox_Goin, &UIDMBox::MoveInEvent }, - { &EV_DMBox_Decay, &UIDMBox::DecayEvent }, - { NULL, NULL } +CLASS_DECLARATION(UIWidget, UIDMBox, NULL) { + {&W_SizeChanged, &UIDMBox::OnSizeChanged}, + {&EV_DMBox_Goin, &UIDMBox::MoveInEvent }, + {&EV_DMBox_Decay, &UIDMBox::DecayEvent }, + {NULL, NULL } }; UIDMBox::UIDMBox() { - m_numitems = 0; - m_reallyshown = true; - m_fontbold = NULL; - m_boxstate = boxstate_t::box_out; - m_iBeginDecay = 0; - m_boxtime = uid.time; - m_movespeed = 500; + m_numitems = 0; + m_reallyshown = true; + m_fontbold = NULL; + m_boxstate = boxstate_t::box_out; + m_iBeginDecay = 0; + m_boxtime = uid.time; + m_movespeed = 500; + m_drawoutline = com_target_game->integer >= target_game_e::TG_MOHTA; } -void UIDMBox::VerifyBoxOut( void ) +void UIDMBox::VerifyBoxOut(void) { - PostMoveinEvent(); - if (m_boxstate != boxstate_t::box_moving_out && m_boxstate != boxstate_t::box_out) - { - ChangeBoxState(boxstate_t::box_moving_out); - } + PostMoveinEvent(); + if (m_boxstate != boxstate_t::box_moving_out && m_boxstate != boxstate_t::box_out) { + ChangeBoxState(boxstate_t::box_moving_out); + } } -void UIDMBox::ChangeBoxState( boxstate_t state ) +void UIDMBox::ChangeBoxState(boxstate_t state) { - m_boxstate = state; - m_boxtime = uid.time; - setShowState(); + m_boxstate = state; + m_boxtime = uid.time; + setShowState(); - if (state == box_out) { - PostMoveinEvent(); - } + if (state == box_out) { + PostMoveinEvent(); + } } -void UIDMBox::HandleBoxMoving( void ) +void UIDMBox::HandleBoxMoving(void) { - int delta; - UIRect2D newRect; + int delta; + UIRect2D newRect; - if (m_boxstate != boxstate_t::box_moving_out && m_boxstate != boxstate_t::box_moving_in) { - return; - } + if (m_boxstate != boxstate_t::box_moving_out && m_boxstate != boxstate_t::box_moving_in) { + return; + } - delta = m_movespeed * (uid.time - m_boxtime) / 1000; - m_boxtime = 1000 * delta / m_movespeed + m_boxtime; - if (m_boxstate == boxstate_t::box_moving_out) - { - newRect.size.width = m_frame.size.width; - newRect.size.height = m_frame.size.height; - newRect.pos.x = m_frame.pos.x; - newRect.pos.y = delta + m_frame.pos.y; + delta = m_movespeed * (uid.time - m_boxtime) / 1000; + m_boxtime = 1000 * delta / m_movespeed + m_boxtime; + if (m_boxstate == boxstate_t::box_moving_out) { + newRect.size.width = m_frame.size.width; + newRect.size.height = m_frame.size.height; + newRect.pos.x = m_frame.pos.x; + newRect.pos.y = delta + m_frame.pos.y; - if (newRect.pos.y <= 0.0) - { - newRect.pos.y = 0.0; - ChangeBoxState(boxstate_t::box_out); - } - } - else if (m_boxstate == boxstate_t::box_moving_in) - { - newRect.size.width = m_frame.size.width; - newRect.size.height = m_frame.size.height; - newRect.pos.x = m_frame.pos.x; - newRect.pos.y = delta - m_frame.pos.y; + if (newRect.pos.y <= 0.0) { + newRect.pos.y = 0.0; + ChangeBoxState(boxstate_t::box_out); + } + } else if (m_boxstate == boxstate_t::box_moving_in) { + newRect.size.width = m_frame.size.width; + newRect.size.height = m_frame.size.height; + newRect.pos.x = m_frame.pos.x; + newRect.pos.y = delta - m_frame.pos.y; - if (newRect.pos.y <= -newRect.size.height) - { - newRect.pos.y = -newRect.size.height; - ChangeBoxState(boxstate_t::box_in); - } - } - else { - newRect = m_frame; - } + if (newRect.pos.y <= -newRect.size.height) { + newRect.pos.y = -newRect.size.height; + ChangeBoxState(boxstate_t::box_in); + } + } else { + newRect = m_frame; + } - setFrame(newRect); + setFrame(newRect); } -void UIDMBox::PostMoveinEvent( void ) +void UIDMBox::PostMoveinEvent(void) { - if (m_boxstate != boxstate_t::box_out) { - return; - } + if (m_boxstate != boxstate_t::box_out) { + return; + } - if (!EventPending(EV_DMBox_Goin)) { - PostEvent(EV_DMBox_Goin, 10.0); - } - else { - PostponeEvent(EV_DMBox_Goin, 10.0); - } + if (!EventPending(EV_DMBox_Goin)) { + PostEvent(EV_DMBox_Goin, 10.0); + } else { + PostponeEvent(EV_DMBox_Goin, 10.0); + } } -void UIDMBox::PostDecayEvent( void ) +void UIDMBox::PostDecayEvent(void) { - if (!EventPending(EV_DMBox_Decay)) - { - float fDelayTime; - int iNumLines; - int i; - const char* pszString = m_items[0].string.c_str(); + if (!EventPending(EV_DMBox_Decay)) { + float fDelayTime; + int iNumLines; + int i; + const char *pszString = m_items[0].string.c_str(); - // - // Calculate the number of lines - // - iNumLines = 1; - for (i = 0; pszString[i]; i++) - { - if (pszString[i] == '\n') { - iNumLines++; - } - } + // + // Calculate the number of lines + // + iNumLines = 1; + for (i = 0; pszString[i]; i++) { + if (pszString[i] == '\n') { + iNumLines++; + } + } if (m_items[0].flags & DMBOX_ITEM_FLAG_BOLD) { fDelayTime = iNumLines * 8.0; @@ -167,265 +158,268 @@ void UIDMBox::PostDecayEvent( void ) // // Bold as twice more decay // - else if (m_items[0].flags & DMBOX_ITEM_FLAG_DEATH) { - fDelayTime = iNumLines * 6.0; - } - else { - fDelayTime = iNumLines * 5.0; - } + else if (m_items[0].flags & DMBOX_ITEM_FLAG_DEATH) { + fDelayTime = iNumLines * 6.0; + } else { + fDelayTime = iNumLines * 5.0; + } - m_iBeginDecay = cls.realtime; - m_iEndDecay = (int)(fDelayTime * 1000.0); + m_iBeginDecay = cls.realtime; + m_iEndDecay = (int)(fDelayTime * 1000.0); - PostEvent(EV_DMBox_Decay, fDelayTime); - } + PostEvent(EV_DMBox_Decay, fDelayTime); + } } -void UIDMBox::setShowState( void ) +void UIDMBox::setShowState(void) { - if (m_reallyshown) { - setShow(m_boxstate != box_in); - } else { - setShow(false); - } + if (m_reallyshown) { + setShow(m_boxstate != box_in); + } else { + setShow(false); + } } -void UIDMBox::RemoveTopItem( void ) +void UIDMBox::RemoveTopItem(void) { - int i; + int i; - if (m_numitems > 0) { - for (i = 0; i < m_numitems - 1; i++) { - m_items[i] = m_items[i + 1]; - } + if (m_numitems > 0) { + for (i = 0; i < m_numitems - 1; i++) { + m_items[i] = m_items[i + 1]; + } - m_numitems--; - } + m_numitems--; + } } -str UIDMBox::CalculateBreaks( UIFont *font, str text, float max_width ) +str UIDMBox::CalculateBreaks(UIFont *font, str text, float max_width) { - str newText, sTmp; - int i; - float fX; - float fwX, fsX; + str newText; + float fX; + float fwX; + const char *current; + int count; - Cmd_TokenizeString(text.c_str()); - if (Cmd_Argc()) - { - fX = 0.0; - fsX = font->getCharWidth(' '); + current = text; + fX = 0.0; - for (i = 0; i < Cmd_Argc(); i++) - { - sTmp = Cmd_Argv(i); + for (count = font->DBCSGetWordBlockCount(current, -1); count; + current += count, count = font->DBCSGetWordBlockCount(current, -1)) { + fwX = font->getWidth(current, count); - fwX = font->getWidth(sTmp.c_str(), -1); - if (fwX + i <= max_width) - { - if (fwX + i + fX <= max_width) - { - newText += sTmp + " "; - } else { - newText += "\n" + sTmp + " "; - } - } - else - { - sTmp += "\n"; - fX = 0.0; - } - } - } else { - newText = ""; - } + if (fX + fwX > max_width) { + newText += "\n" + str(current, 0, count); + fX = 0; + } else { + newText += str(current, 0, count); + } - return newText; + fX += fwX; + } + + return newText; } -float UIDMBox::PrintWrap( UIFont *font, float x, float y, str text ) +float UIDMBox::PrintWrap(UIFont *font, float x, float y, str text) { - const char* p1, * p2; - size_t n, l; - float fY; + const char *p1, *p2; + size_t n, l; + float fY; - fY = y; - p1 = text.c_str(); - l = text.length(); + fY = y; + p1 = text.c_str(); + l = text.length(); - for (;;) - { - p2 = strchr(p1, '\n'); - if (!p2) { - break; - } + for (;;) { + p2 = strchr(p1, '\n'); + if (!p2) { + break; + } - n = p2 - p1; - if (n >= l) { - break; - } + n = p2 - p1; + if (n >= l) { + break; + } - font->Print(x, fY, p1, p2 - p1, qfalse); - p1 = p2 + 1; - l -= n; - fY += font->getHeight(qfalse); - } + font->Print(x, fY, p1, p2 - p1, getHighResScale()); + p1 = p2 + 1; + l -= n; + fY += font->getHeight(); + } - font->Print(x, fY, p1, l, qfalse); + if (*p1) { + font->Print(x, fY, p1, l, getHighResScale()); + fY += font->getHeight(); + } - return font->getHeight(qfalse) + (fY - y); + return fY - y; } -float UIDMBox::DrawItem( item_t *in, float x, float y, float alpha ) +float UIDMBox::DrawItem(item_t *in, float x, float y, float alpha) { - in->font->setColor(in->color); - in->font->setAlpha(alpha); + if (m_drawoutline) { + // + // Draw an outline + // - return PrintWrap(in->font, x, y, in->string); + in->font->setColor(UBlack); + in->font->setAlpha(alpha); + + PrintWrap(in->font, x + 1, y + 2, in->string); + PrintWrap(in->font, x + 2, y + 1, in->string); + PrintWrap(in->font, x - 1, y + 2, in->string); + PrintWrap(in->font, x - 2, y + 1, in->string); + PrintWrap(in->font, x - 1, y - 2, in->string); + PrintWrap(in->font, x - 2, y - 1, in->string); + PrintWrap(in->font, x + 1, y - 2, in->string); + PrintWrap(in->font, x + 2, y - 1, in->string); + PrintWrap(in->font, x + 2, y, in->string); + PrintWrap(in->font, x - 2, y, in->string); + PrintWrap(in->font, x, y + 2, in->string); + PrintWrap(in->font, x, y - 2, in->string); + } + + in->font->setColor(in->color); + in->font->setAlpha(alpha); + + return PrintWrap(in->font, x, y, in->string); } -void UIDMBox::Print( const char *text ) +void UIDMBox::Print(const char *text) { - const char* text1 = text; + const char *text1 = text; - if (m_numitems > 5) - { - // - // Overwrite an item - // - RemoveTopItem(); - } + if (m_numitems > 5) { + // + // Overwrite an item + // + RemoveTopItem(); + } - m_items[m_numitems].flags = 0; + m_items[m_numitems].flags = 0; - if (*text == MESSAGE_CHAT_WHITE) - { - m_items[m_numitems].color = UGrey; - m_items[m_numitems].font = m_fontbold; - m_items[m_numitems].flags |= DMBOX_ITEM_FLAG_BOLD; + if (*text == MESSAGE_CHAT_WHITE) { + m_items[m_numitems].color = UWhiteChatMessageColor; + m_items[m_numitems].font = m_fontbold; + m_items[m_numitems].flags |= DMBOX_ITEM_FLAG_BOLD; - text1 = text + 1; - } - else if (*text == MESSAGE_CHAT_RED) - { - m_items[m_numitems].color = ULightRed; - m_items[m_numitems].font = m_fontbold; - m_items[m_numitems].flags |= DMBOX_ITEM_FLAG_DEATH; + text1 = text + 1; + } else if (*text == MESSAGE_CHAT_RED) { + m_items[m_numitems].color = URedChatMessageColor; + m_items[m_numitems].font = m_fontbold; + m_items[m_numitems].flags |= DMBOX_ITEM_FLAG_DEATH; - text1 = text + 1; - } - else if (*text == MESSAGE_CHAT_GREEN) - { - m_items[m_numitems].color = UGreen; + text1 = text + 1; + } else if (*text == MESSAGE_CHAT_GREEN) { + m_items[m_numitems].color = UGreenChatMessageColor; m_items[m_numitems].font = m_fontbold; m_items[m_numitems].flags |= DMBOX_ITEM_FLAG_DEATH; - text1 = text + 1; - } - else - { - m_items[m_numitems].color = m_foreground_color; - m_items[m_numitems].font = m_font; - } + text1 = text + 1; + } else { + m_items[m_numitems].color = m_foreground_color; + m_items[m_numitems].font = m_font; + } - m_items[m_numitems].string = CalculateBreaks(m_items[m_numitems].font, text1, s_dmboxWidth); + m_items[m_numitems].string = CalculateBreaks(m_items[m_numitems].font, Sys_LV_CL_ConvertString(text1), s_dmboxWidth); - m_numitems++; - VerifyBoxOut(); - PostDecayEvent(); + m_numitems++; + VerifyBoxOut(); + PostDecayEvent(); } -void UIDMBox::OnSizeChanged( Event *ev ) +void UIDMBox::OnSizeChanged(Event *ev) { - s_dmboxWidth = m_frame.size.width; + s_dmboxWidth = m_frame.size.width; } -void UIDMBox::Create( const UIRect2D& rect, const UColor& fore, const UColor& back, float alpha ) +void UIDMBox::Create(const UIRect2D& rect, const UColor& fore, const UColor& back, float alpha) { - InitFrame(NULL, rect, 0, "facfont-20"); + InitFrame(NULL, rect, 0, "facfont-20"); - if (!m_fontbold) { - m_fontbold = new UIFont("facfont-20"); - } + if (!m_fontbold) { + m_fontbold = new UIFont("facfont-20"); + } - m_fontbold->setColor(URed); - setBackgroundColor(back, true); - setForegroundColor(fore); - setBackgroundAlpha(alpha); + m_fontbold->setColor(URed); + setBackgroundColor(back, true); + setForegroundColor(fore); + setBackgroundAlpha(alpha); - Connect(this, W_SizeChanged, W_SizeChanged); - OnSizeChanged(NULL); + Connect(this, W_SizeChanged, W_SizeChanged); + OnSizeChanged(NULL); - m_movespeed = rect.size.height * 3.0; + m_movespeed = rect.size.height * 3.0; - setShowState(); + setShowState(); } -void UIDMBox::MoveInEvent( Event *ev ) +void UIDMBox::MoveInEvent(Event *ev) {} + +void UIDMBox::DecayEvent(Event *ev) { + RemoveTopItem(); + if (m_numitems) { + PostDecayEvent(); + } } -void UIDMBox::DecayEvent( Event *ev ) +void UIDMBox::Draw(void) { - RemoveTopItem(); - if (m_numitems) { - PostDecayEvent(); - } + float fsY; + int i; + float alpha; + float alphaScale; + + alphaScale = 0.8f; + HandleBoxMoving(); + + if (!m_numitems) { + // + // Nothing to show + // + return; + } + + m_font->setColor(m_foreground_color); + alpha = (float)(cls.realtime - m_iBeginDecay) / (float)m_iEndDecay; + if (alpha > 1.0) { + alpha = 1.0; + } + + alpha = (1.0 - alpha) * 4.0; + if (alpha > 1.0) { + alpha = 1.0; + } + + if (cge) { + alphaScale = 1.0 - cge->CG_GetObjectiveAlpha(); + } + + fsY = DrawItem(m_items, s_dmboxOffsetX, s_dmboxOffsetY, alpha * alphaScale); + fsY = alpha <= 0.2 ? s_dmboxOffsetY : fsY + s_dmboxOffsetY; + + for (i = 1; i < m_numitems; i++) { + fsY += DrawItem(&m_items[i], s_dmboxOffsetX, fsY, alphaScale); + if (fsY > m_frame.size.height) { + if (EventPending(EV_DMBox_Decay)) { + CancelEventsOfType(EV_DMBox_Decay); + } + + PostEvent(EV_DMBox_Decay, 0.0); + break; + } + } } -void UIDMBox::Draw( void ) +void UIDMBox::setRealShow(bool b) { - float fsY; - int i; - float alpha; - float alphaScale; - - alphaScale = 0.8f; - HandleBoxMoving(); - - if (!m_numitems) { - // - // Nothing to show - // - return; - } - - m_font->setColor(m_foreground_color); - alpha = (float)(cls.realtime - m_iBeginDecay) / (float)m_iEndDecay; - if (alpha > 1.0) alpha = 1.0; - - alpha = (1.0 - alpha) * 4.0; - if (alpha > 1.0) alpha = 1.0; - - if (cge) { - alphaScale = 1.0 - cge->CG_GetObjectiveAlpha(); - } - - fsY = DrawItem(m_items, s_dmboxOffsetX, s_dmboxOffsetY, alpha * alphaScale); - fsY = alpha <= 0.2 ? s_dmboxOffsetY : fsY + s_dmboxOffsetY; - - for (i = 1; i < m_numitems; i++) - { - fsY += DrawItem(&m_items[i], s_dmboxOffsetX, fsY, alphaScale); - if (fsY > m_frame.size.height) - { - if (EventPending(EV_DMBox_Decay)) { - CancelEventsOfType(EV_DMBox_Decay); - } - - PostEvent(EV_DMBox_Decay, 0.0); - break; - } - } + this->m_reallyshown = b; + setShowState(); } -void UIDMBox::setRealShow( bool b ) +void UIDMBox::Clear(void) { - this->m_reallyshown = b; - setShowState(); -} - -void UIDMBox::Clear( void ) -{ - m_numitems = 0; + m_numitems = 0; } diff --git a/code/client/cl_uidmbox.h b/code/client/cl_uidmbox.h index cf8660e1..a02dab84 100644 --- a/code/client/cl_uidmbox.h +++ b/code/client/cl_uidmbox.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2015-2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -20,8 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -#ifndef __CL_UIDMBOX_H__ -#define __CL_UIDMBOX_H__ +#pragma once static constexpr unsigned int DMBOX_ITEM_FLAG_BOLD = 2u; static constexpr unsigned int DMBOX_ITEM_FLAG_DEATH = 4u; @@ -47,6 +46,8 @@ protected: int m_movespeed; int m_iBeginDecay; int m_iEndDecay; + // Added in OPM + bool m_drawoutline; public: CLASS_PROTOTYPE( UIDMBox ); @@ -75,5 +76,3 @@ public: void setRealShow( bool b ); void Clear( void ); }; - -#endif /* __CL_UIDMBOX_H__ */ diff --git a/code/client/cl_uifilepicker.cpp b/code/client/cl_uifilepicker.cpp index 4a368691..ad8914c9 100644 --- a/code/client/cl_uifilepicker.cpp +++ b/code/client/cl_uifilepicker.cpp @@ -47,7 +47,7 @@ FilePickerClass::FilePickerClass() window = new UIFloatingWindow(); window->Create( NULL, - UIRect2D((cls.glconfig.vidWidth - 400) / 2, (cls.glconfig.vidHeight - 300) / 2, 400, 300), + UIRect2D((uid.vidWidth - 400) / 2, (uid.vidHeight - 300) / 2, 400, 300), "File Picker", UColor(0.15f, 0.195f, 0.278f), UHudColor @@ -104,8 +104,10 @@ void FilePickerClass::Initialize( currentDirectory += "/"; } - extension = ext; - ignoredFiles = ignore_files; + extension = ext; + if (ignore_files) { + ignoredFiles = ignore_files; + } SetupFiles(); } diff --git a/code/client/cl_uigamespy.cpp b/code/client/cl_uigamespy.cpp new file mode 100644 index 00000000..843ae75c --- /dev/null +++ b/code/client/cl_uigamespy.cpp @@ -0,0 +1,118 @@ +/* +=========================================================================== +Copyright (C) 2025 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA source code 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. + +OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// cl_uigamespy.cpp +#include "cl_uigamespy.h" + +CLASS_DECLARATION(UIFloatingWindow, GameSpyDialog, NULL) { + {&W_Deactivated, &UIFloatingWindow::ClosePressed}, + {NULL, NULL } +}; + +GameSpyDialog::GameSpyDialog() + : overlay(NULL) + , label(NULL) + , closeButton(NULL) +{ + AddFlag(WF_ALWAYS_TOP); +} + +GameSpyDialog::~GameSpyDialog() +{ + if (overlay) { + delete overlay; + overlay = NULL; + } + + if (label) { + delete label; + label = NULL; + } + + if (closeButton) { + delete closeButton; + closeButton = NULL; + } +} + +void GameSpyDialog::FrameInitialized(void) +{ + UIFloatingWindow::FrameInitialized(); + + label = new UILabel(); + + label->InitFrame(getChildSpace(), getChildSpace()->getClientFrame(), 0); + label->setTitle( + "GameSpy's multiplayer matchmaking\n" + "and server browsing services, which were\n" + "essential for online gaming in many classic\n" + "titles including Medal of Honor: Allied Assault,\n" + "were permanently shut down in 2014." + ); + label->setForegroundColor(UHudColor); + + closeButton = new UIButton(); + closeButton->InitFrame(getChildSpace(), UIRect2D(100, 150, 100, 30), 0); + closeButton->setTitle("Close"); + closeButton->AllowActivate(true); + closeButton->Connect(this, W_Button_Pressed, W_Deactivated); + + overlay = new UIButton(); + overlay->InitFrame(NULL, UIRect2D(0, 0, uid.vidWidth, uid.vidHeight), 0); + overlay->setBackgroundColor(UColor(0, 0, 0, 0.5f), true); + overlay->AllowActivate(true); + + overlay->Connect(this, W_Button_Pressed, W_Deactivated); +} + +void GameSpyDialog::Create( + UIWidget *parent, const UIRect2D& rect, const char *title, const UColor& bgColor, const UColor& fgColor +) +{ + // First call parent's Create + UIFloatingWindow::Create(parent, rect, title, bgColor, fgColor); + + // After creation, find minimize button by name and hide it + for (UIWidget *child = getFirstChild(); child; child = getNextChild(child)) { + if (strcmp(child->getName(), "minimizebutton") == 0) { + child->setShow(false); + break; + } + } +} + +void UI_LaunchGameSpy_f(void) +{ + GameSpyDialog *dialog = new GameSpyDialog(); + + dialog->Create( + NULL, + UIRect2D((uid.vidWidth - 300) / 2, (uid.vidHeight - 200) / 2, 300, 200), + "GameSpy", + UColor(0.15f, 0.195f, 0.278f), + UHudColor + ); + + uWinMan.ActivateControl(dialog); + + dialog->Connect(dialog, W_Deactivated, W_Deactivated); +} diff --git a/code/client/cl_uigamespy.h b/code/client/cl_uigamespy.h new file mode 100644 index 00000000..8d1117d4 --- /dev/null +++ b/code/client/cl_uigamespy.h @@ -0,0 +1,50 @@ +/* +=========================================================================== +Copyright (C) 2025 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA source code 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. + +OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// cl_gamespy.h +#ifndef __CL_GAMESPY_H__ +#define __CL_GAMESPY_H__ + +#include "cl_ui.h" +#include "keycodes.h" + +class GameSpyDialog : public UIFloatingWindow +{ +private: + UIButton *overlay; + UILabel *label; + UIButton *closeButton; + +protected: + void FrameInitialized(void) override; + +public: + GameSpyDialog(); + ~GameSpyDialog(); + void + Create(UIWidget *parent, const UIRect2D& rect, const char *title, const UColor& bgColor, const UColor& fgColor); + + CLASS_PROTOTYPE(GameSpyDialog); +}; + +void UI_LaunchGameSpy_f(void); +#endif diff --git a/code/client/cl_uigmbox.cpp b/code/client/cl_uigmbox.cpp index 82761c1b..18962d4a 100644 --- a/code/client/cl_uigmbox.cpp +++ b/code/client/cl_uigmbox.cpp @@ -21,6 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "cl_ui.h" +#include "../qcommon/localization.h" Event EV_GMBox_Goin ( @@ -40,371 +41,370 @@ Event EV_GMBox_Decay "Event to make the gmbox console line decay" ); -static float s_gmboxWidth = 640.0; +static float s_gmboxWidth = 640.0; static float s_gmboxOffsetX = 3.0f; static float s_gmboxOffsetY = 0.0f; -CLASS_DECLARATION( UIWidget, UIGMBox, NULL ) -{ - { &W_SizeChanged, &UIGMBox::OnSizeChanged }, - { &EV_GMBox_Goin, &UIGMBox::MoveInEvent }, - { &EV_GMBox_Decay, &UIGMBox::DecayEvent }, - { NULL, NULL } +CLASS_DECLARATION(UIWidget, UIGMBox, NULL) { + {&W_SizeChanged, &UIGMBox::OnSizeChanged}, + {&EV_GMBox_Goin, &UIGMBox::MoveInEvent }, + {&EV_GMBox_Decay, &UIGMBox::DecayEvent }, + {NULL, NULL } }; UIGMBox::UIGMBox() { - m_numitems = 0; - m_reallyshown = true; - m_fontbold = NULL; - m_boxstate = boxstate_t::box_out; - m_iBeginDecay = 0; - m_boxtime = uid.time; - m_movespeed = 500; + m_numitems = 0; + m_reallyshown = true; + m_fontbold = NULL; + m_boxstate = boxstate_t::box_out; + m_iBeginDecay = 0; + m_boxtime = uid.time; + m_movespeed = 500; + m_drawoutline = com_target_game->integer >= target_game_e::TG_MOHTA; } -void UIGMBox::VerifyBoxOut( void ) +void UIGMBox::VerifyBoxOut(void) { - PostMoveinEvent(); - if (m_boxstate != boxstate_t::box_moving_out && m_boxstate != boxstate_t::box_out) - { - ChangeBoxState(boxstate_t::box_moving_out); - } + PostMoveinEvent(); + if (m_boxstate != boxstate_t::box_moving_out && m_boxstate != boxstate_t::box_out) { + ChangeBoxState(boxstate_t::box_moving_out); + } } -void UIGMBox::ChangeBoxState( boxstate_t state ) +void UIGMBox::ChangeBoxState(boxstate_t state) { - m_boxstate = state; - m_boxtime = uid.time; - setShowState(); + m_boxstate = state; + m_boxtime = uid.time; + setShowState(); - if (state == box_out) { - PostMoveinEvent(); - } + if (state == box_out) { + PostMoveinEvent(); + } } -void UIGMBox::HandleBoxMoving( void ) +void UIGMBox::HandleBoxMoving(void) { - int delta; - UIRect2D newRect; + int delta; + UIRect2D newRect; - if (m_boxstate != boxstate_t::box_moving_out && m_boxstate != boxstate_t::box_moving_in) { - return; - } + if (m_boxstate != boxstate_t::box_moving_out && m_boxstate != boxstate_t::box_moving_in) { + return; + } - delta = m_movespeed * (uid.time - m_boxtime) / 1000; - m_boxtime = 1000 * delta / m_movespeed + m_boxtime; - if (m_boxstate == boxstate_t::box_moving_out) - { - newRect.size.width = m_frame.size.width; - newRect.size.height = m_frame.size.height; - newRect.pos.x = m_frame.pos.x; - newRect.pos.y = delta + m_frame.pos.y; + delta = m_movespeed * (uid.time - m_boxtime) / 1000; + m_boxtime = 1000 * delta / m_movespeed + m_boxtime; + if (m_boxstate == boxstate_t::box_moving_out) { + newRect.size.width = m_frame.size.width; + newRect.size.height = m_frame.size.height; + newRect.pos.x = m_frame.pos.x; + newRect.pos.y = delta + m_frame.pos.y; - if (newRect.pos.y <= 0.0) - { - newRect.pos.y = 0.0; - ChangeBoxState(boxstate_t::box_out); - } - } - else if (m_boxstate == boxstate_t::box_moving_in) - { - newRect.size.width = m_frame.size.width; - newRect.size.height = m_frame.size.height; - newRect.pos.x = m_frame.pos.x; - newRect.pos.y = delta - m_frame.pos.y; + if (newRect.pos.y <= 0.0) { + newRect.pos.y = 0.0; + ChangeBoxState(boxstate_t::box_out); + } + } else if (m_boxstate == boxstate_t::box_moving_in) { + newRect.size.width = m_frame.size.width; + newRect.size.height = m_frame.size.height; + newRect.pos.x = m_frame.pos.x; + newRect.pos.y = delta - m_frame.pos.y; - if (newRect.pos.y <= -newRect.size.height) - { - newRect.pos.y = -newRect.size.height; - ChangeBoxState(boxstate_t::box_in); - } - } else { - newRect = m_frame; - } + if (newRect.pos.y <= -newRect.size.height) { + newRect.pos.y = -newRect.size.height; + ChangeBoxState(boxstate_t::box_in); + } + } else { + newRect = m_frame; + } - setFrame(newRect); + setFrame(newRect); } -void UIGMBox::PostMoveinEvent( void ) +void UIGMBox::PostMoveinEvent(void) { - if (m_boxstate != boxstate_t::box_out) { - return; - } + if (m_boxstate != boxstate_t::box_out) { + return; + } - if (!EventPending(EV_GMBox_Goin)) { - PostEvent(EV_GMBox_Goin, 10.0); - } else { - PostponeEvent(EV_GMBox_Goin, 10.0); - } + if (!EventPending(EV_GMBox_Goin)) { + PostEvent(EV_GMBox_Goin, 10.0); + } else { + PostponeEvent(EV_GMBox_Goin, 10.0); + } } -void UIGMBox::PostDecayEvent( void ) +void UIGMBox::PostDecayEvent(void) { - if (!EventPending(EV_GMBox_Decay)) - { - float fDelayTime; - int iNumLines; - int i; - const char* pszString = m_items[0].string.c_str(); + if (!EventPending(EV_GMBox_Decay)) { + float fDelayTime; + int iNumLines; + int i; + const char *pszString = m_items[0].string.c_str(); - // - // Calculate the number of lines - // - iNumLines = 1; - for (i = 0; pszString[i]; i++) - { - if (pszString[i] == '\n') { - iNumLines++; - } - } + // + // Calculate the number of lines + // + iNumLines = 1; + for (i = 0; pszString[i]; i++) { + if (pszString[i] == '\n') { + iNumLines++; + } + } - // - // Bold as twice more decay - // - if (m_items[0].flags & GMBOX_ITEM_FLAG_BOLD) { - fDelayTime = iNumLines * 10.0; - } else { - fDelayTime = iNumLines * 5.0; - } + // + // Bold as twice more decay + // + if (m_items[0].flags & GMBOX_ITEM_FLAG_BOLD) { + fDelayTime = iNumLines * 10.0; + } else { + fDelayTime = iNumLines * 5.0; + } - m_iBeginDecay = cls.realtime; - m_iEndDecay = (int)(fDelayTime * 1000.0); + m_iBeginDecay = cls.realtime; + m_iEndDecay = (int)(fDelayTime * 1000.0); - PostEvent(EV_GMBox_Decay, fDelayTime); - } + PostEvent(EV_GMBox_Decay, fDelayTime); + } } -void UIGMBox::setShowState( void ) +void UIGMBox::setShowState(void) { - if (m_reallyshown) { - setShow(m_boxstate != box_in); - } else { - setShow(false); - } + if (m_reallyshown) { + setShow(m_boxstate != box_in); + } else { + setShow(false); + } } -void UIGMBox::RemoveTopItem( void ) +void UIGMBox::RemoveTopItem(void) { - int i; + int i; - if (m_numitems > 0) { - for (i = 0; i < m_numitems - 1; i++) { - m_items[i] = m_items[i + 1]; - } + if (m_numitems > 0) { + for (i = 0; i < m_numitems - 1; i++) { + m_items[i] = m_items[i + 1]; + } - m_numitems--; - } + m_numitems--; + } } -str UIGMBox::CalculateBreaks( UIFont *font, str text, float max_width ) +str UIGMBox::CalculateBreaks(UIFont *font, str text, float max_width) { - str newText, sTmp; - int i; - float fX; - float fwX, fsX; + str newText; + float fX; + float fwX; + const char *current; + int count; - Cmd_TokenizeString(text.c_str()); - if (Cmd_Argc()) - { - fX = 0.0; - fsX = font->getCharWidth(' '); + current = text; + fX = 0.0; - for (i = 0; i < Cmd_Argc(); i++) - { - sTmp = Cmd_Argv(i); + for (count = font->DBCSGetWordBlockCount(current, -1); count; + current += count, count = font->DBCSGetWordBlockCount(current, -1)) { + fwX = font->getWidth(current, count); - fwX = font->getWidth(sTmp.c_str(), -1); - if (fwX + i <= max_width) - { - if (fwX + i + fX <= max_width) - { - newText += sTmp + " "; - } else { - newText += "\n" + sTmp + " "; - } - } - else - { - sTmp += "\n"; - fX = 0.0; - } - } - } else { - newText = ""; - } + if (fX + fwX > max_width) { + newText += "\n" + str(current, 0, count); + fX = 0; + } else { + newText += str(current, 0, count); + } - return newText; + fX += fwX; + } + + return newText; } -float UIGMBox::PrintWrap( UIFont *font, float x, float y, str text ) +float UIGMBox::PrintWrap(UIFont *font, float x, float y, str text) { - const char* p1, * p2; - size_t n, l; - float fY; + const char *p1, *p2; + size_t n, l; + float fY; - fY = y; - p1 = text.c_str(); - l = text.length(); + fY = y; + p1 = text.c_str(); + l = text.length(); - for (;;) - { - p2 = strchr(p1, '\n'); - if (!p2) { - break; - } + for (;;) { + p2 = strchr(p1, '\n'); + if (!p2) { + break; + } - n = p2 - p1; - if (n >= l) { - break; - } + n = p2 - p1; + if (n >= l) { + break; + } - font->Print(x, fY, p1, p2 - p1, qfalse); - p1 = p2 + 1; - l -= n; - fY += font->getHeight(qfalse); - } + font->Print(x, fY, p1, p2 - p1, getHighResScale()); + p1 = p2 + 1; + l -= n; + fY += font->getHeight(); + } - font->Print(x, fY, p1, l, qfalse); + if (*p1) { + font->Print(x, fY, p1, l, getHighResScale()); + fY += font->getHeight(); + } - return font->getHeight(qfalse) + (fY - y); + return fY - y; } -float UIGMBox::DrawItem( item_t *in, float x, float y, float alpha ) +float UIGMBox::DrawItem(item_t *in, float x, float y, float alpha) { - in->font->setColor(in->color); - in->font->setAlpha(alpha); + if (m_drawoutline) { + // + // Draw an outline + // - return PrintWrap(in->font, x, y, in->string); + in->font->setColor(UBlack); + in->font->setAlpha(alpha); + + PrintWrap(in->font, x + 1, y + 2, in->string); + PrintWrap(in->font, x + 2, y + 1, in->string); + PrintWrap(in->font, x - 1, y + 2, in->string); + PrintWrap(in->font, x - 2, y + 1, in->string); + PrintWrap(in->font, x - 1, y - 2, in->string); + PrintWrap(in->font, x - 2, y - 1, in->string); + PrintWrap(in->font, x + 1, y - 2, in->string); + PrintWrap(in->font, x + 2, y - 1, in->string); + PrintWrap(in->font, x + 2, y, in->string); + PrintWrap(in->font, x - 2, y, in->string); + PrintWrap(in->font, x, y + 2, in->string); + PrintWrap(in->font, x, y - 2, in->string); + } + + in->font->setColor(in->color); + in->font->setAlpha(alpha); + + return PrintWrap(in->font, x, y, in->string); } -void UIGMBox::Print( const char *text ) +void UIGMBox::Print(const char *text) { - const char* text1 = text; + const char *text1 = text; - if (m_numitems > 4) - { - // - // Overwrite an item - // - RemoveTopItem(); - } + if (m_numitems > 4) { + // + // Overwrite an item + // + RemoveTopItem(); + } - m_items[m_numitems].flags = 0; + m_items[m_numitems].flags = 0; - if (*text == 3) - { - m_items[m_numitems].color = UWhite; - m_items[m_numitems].font = m_fontbold; - m_items[m_numitems].flags |= GMBOX_ITEM_FLAG_BOLD; + if (*text == MESSAGE_WHITE) { + m_items[m_numitems].color = UWhite; + m_items[m_numitems].font = m_fontbold; + m_items[m_numitems].flags |= GMBOX_ITEM_FLAG_BOLD; - text1 = text + 1; - } - else - { - m_items[m_numitems].color = m_foreground_color; - m_items[m_numitems].font = m_font; - } + text1 = text + 1; + } else { + m_items[m_numitems].color = m_foreground_color; + m_items[m_numitems].font = m_font; + } - m_items[m_numitems].string = CalculateBreaks(m_items[m_numitems].font, text1, s_gmboxWidth); + m_items[m_numitems].string = CalculateBreaks(m_items[m_numitems].font, Sys_LV_CL_ConvertString(text1), s_gmboxWidth); - m_numitems++; - VerifyBoxOut(); - PostDecayEvent(); + m_numitems++; + VerifyBoxOut(); + PostDecayEvent(); } -void UIGMBox::OnSizeChanged( Event *ev ) +void UIGMBox::OnSizeChanged(Event *ev) { - s_gmboxWidth = m_frame.size.width; + s_gmboxWidth = m_frame.size.width; } -void UIGMBox::Create( const UIRect2D& rect, const UColor& fore, const UColor& back, float alpha ) +void UIGMBox::Create(const UIRect2D& rect, const UColor& fore, const UColor& back, float alpha) { - InitFrame(NULL, rect, 0, "facfont-20"); + InitFrame(NULL, rect, 0, "facfont-20"); - if (!m_fontbold) { - m_fontbold = new UIFont("facfont-20"); - } + if (!m_fontbold) { + m_fontbold = new UIFont("facfont-20"); + } - m_fontbold->setColor(URed); - setBackgroundColor(back, true); - setForegroundColor(fore); - setBackgroundAlpha(alpha); + m_fontbold->setColor(URed); + setBackgroundColor(back, true); + setForegroundColor(fore); + setBackgroundAlpha(alpha); - Connect(this, W_SizeChanged, W_SizeChanged); - OnSizeChanged(NULL); + Connect(this, W_SizeChanged, W_SizeChanged); + OnSizeChanged(NULL); - m_movespeed = rect.size.height * 3.0; + m_movespeed = rect.size.height * 3.0; - setShowState(); + setShowState(); } -void UIGMBox::MoveInEvent( Event *ev ) +void UIGMBox::MoveInEvent(Event *ev) {} + +void UIGMBox::DecayEvent(Event *ev) { + RemoveTopItem(); + if (m_numitems) { + PostDecayEvent(); + } } -void UIGMBox::DecayEvent( Event *ev ) +void UIGMBox::Draw(void) { - RemoveTopItem(); - if (m_numitems) { - PostDecayEvent(); - } + float fsY; + int i; + float alpha; + float alphaScale; + + alphaScale = 1.0; + HandleBoxMoving(); + + if (!m_numitems) { + // + // Nothing to show + // + return; + } + + m_font->setColor(m_foreground_color); + alpha = (float)(cls.realtime - m_iBeginDecay) / (float)m_iEndDecay; + if (alpha > 1.0) { + alpha = 1.0; + } + + alpha = (1.0 - alpha) * 4.0; + if (alpha > 1.0) { + alpha = 1.0; + } + + if (cge) { + alphaScale = 1.0 - cge->CG_GetObjectiveAlpha(); + } + + fsY = DrawItem(m_items, s_gmboxOffsetX, s_gmboxOffsetY, alpha * alphaScale); + fsY = alpha <= 0.2 ? s_gmboxOffsetY : fsY + s_gmboxOffsetY; + + for (i = 1; i < m_numitems; i++) { + fsY += DrawItem(&m_items[i], s_gmboxOffsetX, fsY, alphaScale); + if (fsY > m_frame.size.height) { + if (EventPending(EV_GMBox_Decay)) { + CancelEventsOfType(EV_GMBox_Decay); + } + + PostEvent(EV_GMBox_Decay, 0.0); + break; + } + } } -void UIGMBox::Draw( void ) +void UIGMBox::setRealShow(bool b) { - float fsY; - int i; - float alpha; - float alphaScale; - - alphaScale = 1.0; - HandleBoxMoving(); - - if (!m_numitems) { - // - // Nothing to show - // - return; - } - - m_font->setColor(m_foreground_color); - alpha = (float)(cls.realtime - m_iBeginDecay) / (float)m_iEndDecay; - if (alpha > 1.0) alpha = 1.0; - - alpha = (1.0 - alpha) * 4.0; - if (alpha > 1.0) alpha = 1.0; - - if (cge) { - alphaScale = 1.0 - cge->CG_GetObjectiveAlpha(); - } - - fsY = DrawItem(m_items, s_gmboxOffsetX, s_gmboxOffsetY, alpha * alphaScale); - fsY = alpha <= 0.2 ? s_gmboxOffsetY : fsY + s_gmboxOffsetY; - - for (i = 1; i < m_numitems; i++) - { - fsY += DrawItem(&m_items[i], s_gmboxOffsetX, fsY, alphaScale); - if (fsY > m_frame.size.height) - { - if (EventPending(EV_GMBox_Decay)) { - CancelEventsOfType(EV_GMBox_Decay); - } - - PostEvent(EV_GMBox_Decay, 0.0); - break; - } - } + this->m_reallyshown = b; + setShowState(); } -void UIGMBox::setRealShow( bool b ) +void UIGMBox::Clear(void) { - this->m_reallyshown = b; - setShowState(); + m_numitems = 0; } - -void UIGMBox::Clear( void ) -{ - m_numitems = 0; -} - diff --git a/code/client/cl_uigmbox.h b/code/client/cl_uigmbox.h index 6a904515..4090b45d 100644 --- a/code/client/cl_uigmbox.h +++ b/code/client/cl_uigmbox.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2015-2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -20,8 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -#ifndef __CL_UIGMBOX_H__ -#define __CL_UIGMBOX_H__ +#pragma once static constexpr unsigned int GMBOX_ITEM_FLAG_BOLD = 1u; @@ -44,6 +43,8 @@ protected: int m_movespeed; int m_iBeginDecay; int m_iEndDecay; + // Added in OPM + bool m_drawoutline; public: CLASS_PROTOTYPE( UIGMBox ); @@ -72,5 +73,3 @@ public: void setRealShow( bool b ); void Clear( void ); }; - -#endif diff --git a/code/client/cl_uilangame.cpp b/code/client/cl_uilangame.cpp index 5b301b68..e821a464 100644 --- a/code/client/cl_uilangame.cpp +++ b/code/client/cl_uilangame.cpp @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2023-2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -25,12 +25,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA class LANGameItem : public UIListCtrlItem { - str strings[5]; + str strings[6]; public: LANGameItem(); LANGameItem( - const str& hostName, const str& mapName, const str& players, const str& gameTypeString, const str& ping + const str& hostName, const str& mapName, const str& players, const str& gameTypeString, const str& ping, const str& ipAddress ); int getListItemValue(int which) const override; @@ -65,6 +65,11 @@ UILANGameClass::UILANGameClass() m_iLastUpdateTime = 0; m_noservers_mat = uWinMan.RegisterShader("textures/menu/noservers"); + + // + // Added in OPM + // + m_bVirtual = false; } void UILANGameClass::Draw(void) @@ -102,11 +107,12 @@ void UILANGameClass::UpdateUIElement(void) width = getClientFrame().size.width - 16.f; - AddColumn(Sys_LV_CL_ConvertString("Server Name"), 0, width * 0.4f, false, false); - AddColumn(Sys_LV_CL_ConvertString("Map"), 1, width * 0.15f, false, false); - AddColumn(Sys_LV_CL_ConvertString("Players"), 2, width * 0.165f, true, true); - AddColumn(Sys_LV_CL_ConvertString("GameType"), 3, width * 0.22f, false, false); - AddColumn(Sys_LV_CL_ConvertString("Ping"), 4, width * 0.065f, true, false); + AddColumn(Sys_LV_CL_ConvertString("Server Name"), 0, width * 0.27f, false, false); // was 0.4 + AddColumn(Sys_LV_CL_ConvertString("Map"), 1, width * 0.12f, false, false); // was 0.15 + AddColumn(Sys_LV_CL_ConvertString("Players"), 2, width * 0.08f, true, true); // was 0.165 + AddColumn(Sys_LV_CL_ConvertString("GameType"), 3, width * 0.118f, false, false); // was 0.22 + AddColumn(Sys_LV_CL_ConvertString("Ping"), 4, width * 0.052f, true, false); // was 0.065 + AddColumn(Sys_LV_CL_ConvertString("IP"), 5, width * 0.36f, false, false); // Added in OPM uWinMan.ActivateControl(this); @@ -134,7 +140,9 @@ void UILANGameClass::SetupServers(void) pServerInfo->mapName, va("%02i/%02i", pServerInfo->clients, pServerInfo->maxClients), pServerInfo->gameTypeString, - str(pServerInfo->ping) + str(pServerInfo->ping), + // Added in OPM + NET_AdrToStringwPort(pServerInfo->adr) ); } @@ -167,7 +175,7 @@ void UILANGameClass::JoinServer(Event *ev) const serverInfo_t& serverInfo = cls.localServers[getCurrentItem() - 1]; UI_SetReturnMenuToCurrent(); - CL_Connect(NET_AdrToString(serverInfo.adr), netadrtype_t::NA_UNSPEC); + CL_Connect(NET_AdrToStringwPort(serverInfo.adr), netadrtype_t::NA_UNSPEC); } qboolean UILANGameClass::KeyEvent(int key, unsigned int time) @@ -197,7 +205,7 @@ qboolean UILANGameClass::KeyEvent(int key, unsigned int time) LANGameItem::LANGameItem() {} LANGameItem::LANGameItem( - const str& hostName, const str& mapName, const str& players, const str& gameTypeString, const str& ping + const str& hostName, const str& mapName, const str& players, const str& gameTypeString, const str& ping, const str& ipAddress ) { strings[0] = hostName; @@ -205,6 +213,12 @@ LANGameItem::LANGameItem( strings[2] = players; strings[3] = gameTypeString; strings[4] = ping; + + // + // Added in OPM + // + + strings[5] = ipAddress; } int LANGameItem::getListItemValue(int which) const diff --git a/code/client/cl_uiloadsave.cpp b/code/client/cl_uiloadsave.cpp index a0b8e566..206bb38b 100644 --- a/code/client/cl_uiloadsave.cpp +++ b/code/client/cl_uiloadsave.cpp @@ -95,7 +95,7 @@ UIFAKKLoadGameClass::UIFAKKLoadGameClass() { Connect(this, EV_UIListBase_ItemDoubleClicked, EV_UIListBase_ItemDoubleClicked); Connect(this, EV_UIListBase_ItemSelected, EV_UIListBase_ItemSelected); - AllowActivate(false); + AllowActivate(true); m_bRemovePending = false; setHeaderFont("facfont-20"); @@ -155,12 +155,17 @@ void UIFAKKLoadGameClass::SetupFiles(void) FS_Read(&save, sizeof(savegamestruct_t), f); FS_FCloseFile(f); + Com_SwapSaveStruct(&save); if (save.version != SAVEGAME_STRUCT_VERSION) { // wrong save game version continue; } + if (save.type != com_target_game->integer) { + continue; + } + gametime = (save.mapTime / 1000); date = save.time; @@ -282,7 +287,7 @@ qboolean UIFAKKLoadGameClass::KeyEvent(int key, unsigned int time) } break; default: - return UIListBase::KeyEvent(key, time); + return UIListCtrl::KeyEvent(key, time); } return qfalse; @@ -328,6 +333,7 @@ str FAKKLoadGameItem::getListItemString(int which) const { int numseconds; int numseconds_hours; + int seconds; // hours numseconds = atol(strings[1]); @@ -336,17 +342,18 @@ str FAKKLoadGameItem::getListItemString(int which) const // minutes numseconds_hours = numseconds % 3600; - if (numseconds_hours / 60 <= 9) { + if (numseconds_hours / 60 < 10) { itemstring += "0"; } itemstring += (numseconds_hours / 60); itemstring += ":"; // seconds - if (numseconds_hours / 60 <= 9) { + seconds = numseconds_hours % 60; + if (seconds < 10) { itemstring += "0"; } - itemstring += (numseconds_hours % 60); + itemstring += seconds; } break; case 2: @@ -355,7 +362,7 @@ str FAKKLoadGameItem::getListItemString(int which) const char buffer[2048]; time = atol(strings[2]); - strftime(buffer, sizeof(buffer), "%a %b %d %H:%M:%S %Y", localtime(&time)); + strftime(buffer, sizeof(buffer), "%a %b %d %Y %H:%M:%S", localtime(&time)); itemstring = buffer; } break; diff --git a/code/client/cl_uimaprotationsetup.cpp b/code/client/cl_uimaprotationsetup.cpp index 98ec6861..3189d19f 100644 --- a/code/client/cl_uimaprotationsetup.cpp +++ b/code/client/cl_uimaprotationsetup.cpp @@ -76,7 +76,7 @@ void UIMapRotationListBox::PopulateRotationList() maplistVar = Cvar_Get("ui_maplist_ffa", "", 0); } - strcpy(mapBuffer, maplistVar->string); + Q_strncpyz(mapBuffer, maplistVar->string, sizeof(mapBuffer)); for (token = strtok(mapBuffer, " /"); token; token = strtok(NULL, " /")) { if (!Q_stricmp(token, "dm")) { @@ -143,7 +143,7 @@ void UIMapListBox::PopulateMapList() bool bHasTOW = false; bool bHasLib = false; - strcpy(mapName, filename); + Q_strncpyz(mapName, filename, sizeof(mapName)); mapName[strlen(mapName) - 4] = 0; if (!COM_IsMapValid(mapName)) { @@ -151,7 +151,7 @@ void UIMapListBox::PopulateMapList() } if (bTugOfWar || bLiberation) { - strcpy(tokenized, mapName); + Q_strncpyz(tokenized, mapName, sizeof(tokenized)); for (token = strtok(tokenized, "_"); token; token = strtok(NULL, "_")) { if (bLiberation) { @@ -181,7 +181,7 @@ void UIMapListBox::PopulateMapList() } } } else if (bObjective) { - strcpy(tokenized, mapName); + Q_strncpyz(tokenized, mapName, sizeof(tokenized)); for (token = strtok(tokenized, "_"); token; token = strtok(NULL, "_")) { if (!Q_stricmp(token, "obj")) { @@ -209,9 +209,9 @@ void UIMapListBox::PopulateMapList() char mapName[256]; char tokenized[256]; - strcpy(mapName, filename); + Q_strncpyz(mapName, filename, sizeof(mapName)); mapName[strlen(mapName) - 4] = 0; - strcpy(tokenized, mapName); + Q_strncpyz(tokenized, mapName, sizeof(tokenized)); token = strtok(tokenized, "_"); if (!Q_stricmp(token, "obj") || !Q_stricmp(mapName, "mp_ship_lib")) { @@ -237,7 +237,7 @@ void UIMapListBox::PopulateMapList() const char *filename = filenames[i]; char mapName[256]; - strcpy(mapName, filename); + Q_strncpyz(mapName, filename, sizeof(mapName)); mapName[strlen(mapName) - 4] = 0; if (!COM_IsMapValid(mapName)) { @@ -277,20 +277,27 @@ void UIAddToRotationButton::Released(Event *ev) if (mapList && rotationList) { size_t mapLength = 0; - int item = mapList->getCurrentItem(); + int item = mapList->getCurrentItem(); + str currentItemText; + + if (item) { + currentItemText = mapList->getItemText(item); + } for (i = 1; i <= rotationList->getNumItems(); i++) { str text = rotationList->getItemText(i); + if (text == currentItemText) { + // Added in OPM + // Prevent adding duplicates + item = 0; + break; + } mapLength += text.length(); } - if (item) { - str text = mapList->getItemText(item); - - if (prefixLength + mapLength + text.length() < 256) { - rotationList->AddItem(text, NULL); - } + if (item && prefixLength + mapLength + currentItemText.length() < 256) { + rotationList->AddItem(currentItemText, NULL); } } @@ -356,7 +363,7 @@ void UIRotationApplyButton::Released(Event *ev) char map[256]; bool bHasTOW = false, bHasObj = false, bHasLib = false, bHasShip = false; - strcpy(map, text); + Q_strncpyz(map, text, sizeof(map)); for (token = strtok(map, "_"); token; token = strtok(NULL, "_")) { if (!Q_stricmp(token, "TOW")) { bHasTOW = true; @@ -387,11 +394,12 @@ void UIRotationApplyButton::Released(Event *ev) } maplistStr += text; - maplistStr += " "; if (i == 1) { Cvar_Set("ui_dmmap", maplistStr); } + + maplistStr += " "; } } @@ -413,10 +421,10 @@ void UIRotationMoveItemUpButton::Released(Event *ev) list = static_cast(uWinMan.FindWidget("Rotation List")); item = list->getCurrentItem(); - if (item < list->getNumItems() && list->getNumItems() > 1) { - str text = list->getItemText(item + 1); + if (item > 1 && list->getNumItems() > 1) { + str text = list->getItemText(item - 1); - list->DeleteItem(list->getCurrentItem() - 1); + list->DeleteItem(item - 1); list->InsertItem(text, item); list->setCurrentItem(item - 1); } @@ -440,7 +448,7 @@ void UIRotationMoveItemDownButton::Released(Event *ev) if (item < list->getNumItems() && list->getNumItems() > 1) { str text = list->getItemText(item + 1); - list->DeleteItem(list->getCurrentItem() + 1); + list->DeleteItem(item + 1); list->InsertItem(text, item); list->setCurrentItem(item + 1); } diff --git a/code/client/cl_uimaprunner.cpp b/code/client/cl_uimaprunner.cpp index 6a5cf205..20f4fbb9 100644 --- a/code/client/cl_uimaprunner.cpp +++ b/code/client/cl_uimaprunner.cpp @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2023-2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -83,7 +83,7 @@ void PickFile(const char *name, Listener *obj, Event& event) if (name && *name && strchr(name, '/')) { currentpath = name; - for (i = currentpath.length(); i > 0; i--) { + for (i = currentpath.length() - 1; i > 0; i--) { if (currentpath[i] == '/') { break; } @@ -94,7 +94,7 @@ void PickFile(const char *name, Listener *obj, Event& event) currentpath = ""; } - picker->Setup("", currentpath, ".*"); + picker->Setup("", currentpath, ".*", ""); } CLASS_DECLARATION(FilePickerClass, ViewSpawnerClass, NULL) { diff --git a/code/client/cl_uiminicon.cpp b/code/client/cl_uiminicon.cpp index d0d02723..c1c8e6db 100644 --- a/code/client/cl_uiminicon.cpp +++ b/code/client/cl_uiminicon.cpp @@ -112,7 +112,7 @@ void FakkMiniconsole::PostMoveinEvent(void) void FakkMiniconsole::OnSizeChanged(Event *ev) { - m_maxlines = m_frame.size.height / m_font->getHeight(false); + m_maxlines = m_frame.size.height / m_font->getHeight(getHighResScale()); } void FakkMiniconsole::MoveInEvent(Event *ev) @@ -163,14 +163,14 @@ void FakkMiniconsole::Draw(void) HandleBoxMoving(); m_font->setColor(m_foreground_color); - aty = m_frame.size.height - m_font->getHeight(false); + aty = m_frame.size.height - m_font->getHeight(getHighResScale()); for (i = m_lines.NumObjects(); i > 0; i--) { - if (-m_font->getHeight(false) >= aty) { + if (-m_font->getHeight(getHighResScale()) >= aty) { break; } - m_font->Print(0, aty, m_lines.ObjectAt(i), -1, false); - aty -= m_font->getHeight(false); + m_font->Print(0, aty / getHighResScale()[1], m_lines.ObjectAt(i), -1, getHighResScale()); + aty -= m_font->getHeight(getHighResScale()); } } diff --git a/code/client/cl_uimpmappicker.cpp b/code/client/cl_uimpmappicker.cpp index 577f9b48..8146459f 100644 --- a/code/client/cl_uimpmappicker.cpp +++ b/code/client/cl_uimpmappicker.cpp @@ -51,7 +51,7 @@ MpMapPickerClass::MpMapPickerClass() window = new UIFloatingWindow(); window->Create( NULL, - UIRect2D((cls.glconfig.vidWidth - 300) / 2, (cls.glconfig.vidHeight - 200) / 2, 300, 200), + UIRect2D((uid.vidWidth - 300) / 2, (uid.vidHeight - 200) / 2, 300, 200), "Select a Map", UColor(0.15f, 0.195f, 0.278f), UHudColor @@ -180,12 +180,14 @@ void MpMapPickerClass::SetupFiles(void) FS_FreeFileList(filenames); } - if (currentDirectory.length()) { - if (currentDirectory == "maps/-/") { - SetupSecondaryFiles(currentDirectory, bTugOfWar, bObjective, bLiberation); - } else { - SetupSecondaryFiles("maps/obj/", bTugOfWar, bObjective, bLiberation); - SetupSecondaryFiles("maps/lib/", bTugOfWar, bObjective, bLiberation); + if (com_target_game->integer > target_game_e::TG_MOH) { + if (currentDirectory.length()) { + if (currentDirectory == "maps/-/") { + SetupSecondaryFiles(currentDirectory, bTugOfWar, bObjective, bLiberation); + } else { + SetupSecondaryFiles("maps/obj/", bTugOfWar, bObjective, bLiberation); + SetupSecondaryFiles("maps/lib/", bTugOfWar, bObjective, bLiberation); + } } } @@ -278,9 +280,9 @@ void MpMapPickerClass::FileSelected(Event *ev) uii.Snd_PlaySound("sound/menu/apply.wav"); - UIListCtrlItem* item = listbox->GetItem(listbox->getCurrentItem()); - str name = item->getListItemString(0); - str directory = item->getListItemString(1); + UIListCtrlItem *item = listbox->GetItem(listbox->getCurrentItem()); + str name = item->getListItemString(0); + str directory = item->getListItemString(1); FileSelected(directory, name, directory + name); } @@ -305,9 +307,9 @@ void MpMapPickerClass::FileChosen(Event *ev) uii.Snd_PlaySound("sound/menu/apply.wav"); - UIListCtrlItem* item = listbox->GetItem(listbox->getCurrentItem()); - str name = item->getListItemString(0); - str directory = item->getListItemString(1); + UIListCtrlItem *item = listbox->GetItem(listbox->getCurrentItem()); + str name = item->getListItemString(0); + str directory = item->getListItemString(1); FileSelected(directory, name, directory + name); } diff --git a/code/client/cl_uiplayermodelpicker.cpp b/code/client/cl_uiplayermodelpicker.cpp index 1ef4e1e5..ca89a42d 100644 --- a/code/client/cl_uiplayermodelpicker.cpp +++ b/code/client/cl_uiplayermodelpicker.cpp @@ -155,7 +155,7 @@ PlayerModelPickerClass::PlayerModelPickerClass() window = new UIFloatingWindow(); window->Create( NULL, - UIRect2D((cls.glconfig.vidWidth - 400) / 2, (cls.glconfig.vidHeight - 300) / 2, 400, 300), + UIRect2D((uid.vidWidth - 400) / 2, (uid.vidHeight - 300) / 2, 400, 300), "Player Model Select...", UColor(0.15f, 0.195f, 0.278f), UHudColor @@ -295,7 +295,7 @@ void PlayerModelPickerClass::FileSelected(Event *ev) fullname = PM_DisplaynameToFilename(name); if (!Q_stricmpn(fullname, "german_waffen_", 14)) { - Q_strncpyz(donotshowssindeorfr, "german_waffen_", sizeof(donotshowssindeorfr)); + Q_strncpyz(donotshowssindeorfr, "german_waffenss_", sizeof(donotshowssindeorfr)); Q_strcat(donotshowssindeorfr, sizeof(donotshowssindeorfr), fullname.c_str() + 14); } else { Q_strncpyz(donotshowssindeorfr, fullname, sizeof(donotshowssindeorfr)); diff --git a/code/client/cl_uiradar.cpp b/code/client/cl_uiradar.cpp index be2c80ce..654ecc26 100644 --- a/code/client/cl_uiradar.cpp +++ b/code/client/cl_uiradar.cpp @@ -58,7 +58,7 @@ void UIRadar::Draw(void) float inv; float iconSize; int blinkTime, speakTime; - float origin[2], axis[2]; + vec2_t origin, axis; float halfScale; int i; @@ -105,17 +105,17 @@ void UIRadar::Draw(void) halfScale = iconSize * 0.5f; for (i = 0; i < MAX_CLIENTS; i++) { - float delta[2]; - float newOrg[2]; - float screenOrg[2]; - float length; + vec2_t delta; + vec2_t newOrg; + vec2_t screenOrg; + float length; radar = &g_radarClients[i]; if (i == g_radarClientNum) { continue; } - if (!g_radarClients[i].time) { + if (!radar->time) { continue; } @@ -128,10 +128,13 @@ void UIRadar::Draw(void) // make the icon blink if (delta >= 0 && delta < speakTime && ((delta / blinkTime) % 2) == 0) { continue; + } + + if (delta < 0 || delta >= speakTime) { + radar->lastSpeakTime = 0; } } - radar->lastSpeakTime = 0; delta[0] = radar->origin[0] - origin[0]; delta[1] = radar->origin[1] - origin[1]; newOrg[0] = -(delta[0] * axis[0] + delta[1] * axis[1]) * inv; @@ -140,12 +143,12 @@ void UIRadar::Draw(void) if (length > 1) { - newOrg[0] = -(delta[0] * axis[0] + delta[1] * axis[1]) * inv * (1.f / length); - newOrg[1] = (delta[0] * axis[1] + delta[1] * -axis[0]) * inv * (1.f / length); + newOrg[0] *= 1.f / length; + newOrg[1] *= 1.f / length; } - screenOrg[0] = -((halfScale * (1.141f * newOrg[1] + m_vVirtualScale[0])) - ((1.f + newOrg[1]) * 0.5f * m_frame.size.width)); - screenOrg[1] = -((halfScale * (1.141f * newOrg[0] + m_vVirtualScale[1])) - ((1.f + newOrg[0]) * 0.5f * m_frame.size.height)); + screenOrg[0] = -((halfScale * (1.414f * newOrg[1] + m_vVirtualScale[0])) - ((1.f + newOrg[1]) * 0.5f * m_frame.size.width)); + screenOrg[1] = -((halfScale * (1.414f * newOrg[0] + m_vVirtualScale[1])) - ((1.f + newOrg[0]) * 0.5f * m_frame.size.height)); uii.Rend_DrawPicStretched2( screenOrg[0], diff --git a/code/client/cl_uiserverlist.cpp b/code/client/cl_uiserverlist.cpp index c6bd8278..28e87c9b 100644 --- a/code/client/cl_uiserverlist.cpp +++ b/code/client/cl_uiserverlist.cpp @@ -25,7 +25,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "../gamespy/sv_gamespy.h" #include "../gamespy/common/gsPlatformSocket.h" -Event EV_FAKKServerList_Connect( +Event EV_FAKKServerList_Connect +( "connect", EV_DEFAULT, NULL, @@ -33,7 +34,8 @@ Event EV_FAKKServerList_Connect( "Connect to the specified server" ); -Event EV_FAKKServerList_RefreshServerList( +Event EV_FAKKServerList_RefreshServerList +( "refreshserverlist", EV_DEFAULT, NULL, @@ -41,7 +43,8 @@ Event EV_FAKKServerList_RefreshServerList( "Refresh the serverlist" ); -Event EV_FAKKServerList_RefreshLANServerList( +Event EV_FAKKServerList_RefreshLANServerList +( "refreshlanserverlist", EV_DEFAULT, NULL, @@ -49,7 +52,8 @@ Event EV_FAKKServerList_RefreshLANServerList( "Refresh the LAN serverlist" ); -Event EV_FAKKServerList_CancelRefresh( +Event EV_FAKKServerList_CancelRefresh +( "cancelrefresh", EV_DEFAULT, NULL, @@ -57,7 +61,8 @@ Event EV_FAKKServerList_CancelRefresh( "Cancel serverlist Refresh" ); -Event EV_FAKKServerList_LANListing( +Event EV_FAKKServerList_LANListing +( "lanlisting", EV_DEFAULT, NULL, @@ -65,7 +70,8 @@ Event EV_FAKKServerList_LANListing( "Makes this server list to LAN stuff when there's a choice between Internet & LAN servers" ); -Event EV_FAKKServerList_UpdateServer( +Event EV_FAKKServerList_UpdateServer +( "updateserver", EV_DEFAULT, NULL, @@ -74,73 +80,83 @@ Event EV_FAKKServerList_UpdateServer( ); struct ServerListInstance { - int iServerType; - UIFAKKServerList* serverList; + int iServerType; + UIFAKKServerList *serverList; }; -class FAKKServerListItem : public UIListCtrlItem { - UIFAKKServerList* m_parent; // Added in OPM - str m_strings[6]; - str m_sVersion; - bool m_bDifferentVersion; - bool m_bFavorite; - bool m_bQueryDone; - bool m_bQueryFailed; - int m_iNumPlayers; +class FAKKServerListItem : public UIListCtrlItem +{ + UIFAKKServerList *m_parent; // Added in OPM + str m_strings[6]; + str m_sVersion; + bool m_bDifferentVersion; + bool m_bFavorite; + bool m_bQueryDone; + bool m_bQueryFailed; + int m_iNumPlayers; public: - str m_sIP; + str m_sIP; unsigned int m_uiRealIP; - int m_iPort; - int m_iGameSpyPort; + int m_iPort; + int m_iGameSpyPort; public: - FAKKServerListItem(UIFAKKServerList* parent, str string1, str string2, str string3, str string4, str string5, str string6, str ver); + FAKKServerListItem( + UIFAKKServerList *parent, str string1, str string2, str string3, str string4, str string5, str string6, str ver + ); griditemtype_t getListItemType(int index) const override; - int getListItemValue(int i) const override; - str getListItemString(int i) const override; - void setListItemString(int i, str sNewString); - void DrawListItem(int iColumn, const UIRect2D& drawRect, bool bSelected, UIFont* pFont) override; - qboolean IsHeaderEntry() const override; - bool IsQueried() const; - void SetQueried(bool bIsQueried); - bool IfQueryFailed() const; - void SetQueryFailed(bool bFailed); - void SetNumPlayers(int iNum); - bool IsFavorite() const; - void SetFavorite(bool bIsFavorite); - str GetListItemVersion() const; - void SetListItemVersion(str sNewVer); - void SetDifferentVersion(bool bIsDifferentVersion); - bool IsDifferentVersion() const; + int getListItemValue(int i) const override; + str getListItemString(int i) const override; + void setListItemString(int i, str sNewString); + void DrawListItem(int iColumn, const UIRect2D& drawRect, bool bSelected, UIFont *pFont) override; + qboolean IsHeaderEntry() const override; + bool IsQueried() const; + void SetQueried(bool bIsQueried); + bool IfQueryFailed() const; + void SetQueryFailed(bool bFailed); + void SetNumPlayers(int iNum); + bool IsFavorite() const; + void SetFavorite(bool bIsFavorite); + str GetListItemVersion() const; + void SetListItemVersion(str sNewVer); + void SetDifferentVersion(bool bIsDifferentVersion); + bool IsDifferentVersion() const; }; -static int g_iTotalNumPlayers; -qboolean g_bNumericSort = qfalse; -qboolean g_bReverseSort = qfalse; -qboolean g_NeedAdditionalLANSearch = qfalse; -qboolean g_bDoneUpdating[2]; +static int g_iTotalNumPlayers; +qboolean g_bNumericSort = qfalse; +qboolean g_bReverseSort = qfalse; +qboolean g_NeedAdditionalLANSearch = qfalse; +qboolean g_bDoneUpdating[2]; ServerListInstance g_ServerListInst[2]; -void UpdateServerListCallBack(GServerList serverlist, int msg, void* instance, void* param1, void* param2); -static void AddFilter(char* filter, const char* value); +// Fixed in OPM +// It was a static vaariable inside UpdateServerListCallBack +// that was set to 0 when the mode changed. This caused some issues +static int g_iServerQueryCount = 0; +static int g_iServerTotalCount = 0; -FAKKServerListItem::FAKKServerListItem(UIFAKKServerList* parent, str string1, str string2, str string3, str string4, str string5, str string6, str ver) +static void AddFilter(char *filter, const char *value); + +FAKKServerListItem::FAKKServerListItem( + UIFAKKServerList *parent, str string1, str string2, str string3, str string4, str string5, str string6, str ver +) { - m_parent = parent; + m_parent = parent; m_strings[0] = string1; m_strings[1] = string2; m_strings[2] = string3; m_strings[3] = string4; m_strings[4] = string5; m_strings[5] = string6; - m_sVersion = ver; + m_sVersion = ver; - m_bFavorite = false; - m_bQueryDone = false; + m_bFavorite = false; + m_bQueryDone = false; m_bQueryFailed = false; - m_iNumPlayers = 0; + m_iNumPlayers = 0; } griditemtype_t FAKKServerListItem::getListItemType(int index) const @@ -163,11 +179,11 @@ void FAKKServerListItem::setListItemString(int i, str sNewString) m_strings[i] = sNewString; } -void FAKKServerListItem::DrawListItem(int iColumn, const UIRect2D& drawRect, bool bSelected, UIFont* pFont) +void FAKKServerListItem::DrawListItem(int iColumn, const UIRect2D& drawRect, bool bSelected, UIFont *pFont) { static cvar_t *pColoringType = Cvar_Get("cl_browserdetailedcolors", "0", CVAR_ARCHIVE); - UIRect2D newRect = drawRect; - vec2_t virtualScale = { 1.f, 1.f }; + UIRect2D newRect = drawRect; + vec2_t virtualScale = {1.f, 1.f}; /* if (m_parent->isVirtual()) { @@ -177,7 +193,10 @@ void FAKKServerListItem::DrawListItem(int iColumn, const UIRect2D& drawRect, boo newRect.size.height *= uid.vidHeight / 768; } */ - + + virtualScale[0] = m_parent->getHighResScale()[0]; + virtualScale[1] = m_parent->getHighResScale()[1]; + if (!pColoringType->integer) { if (IfQueryFailed() || (IsDifferentVersion() && IsQueried())) { if (bSelected) { @@ -210,7 +229,7 @@ void FAKKServerListItem::DrawListItem(int iColumn, const UIRect2D& drawRect, boo newRect.pos.y / virtualScale[1], getListItemString(iColumn).c_str(), -1, - false //m_parent->isVirtual() + virtualScale ); } else { if (IsDifferentVersion()) { @@ -266,7 +285,7 @@ void FAKKServerListItem::DrawListItem(int iColumn, const UIRect2D& drawRect, boo newRect.pos.y / virtualScale[1], getListItemString(iColumn).c_str(), -1, - false //m_parent->isVirtual() + virtualScale ); if (IsDifferentVersion()) { @@ -356,66 +375,69 @@ bool FAKKServerListItem::IsDifferentVersion() const return m_bDifferentVersion; } -CLASS_DECLARATION( UIListCtrl, UIFAKKServerList, NULL ) -{ - { &EV_UIListBase_ItemSelected, &UIFAKKServerList::SelectServer }, - { &EV_UIListBase_ItemDoubleClicked, &UIFAKKServerList::ConnectServer }, - { &EV_FAKKServerList_RefreshServerList, &UIFAKKServerList::RefreshServerList }, - { &EV_FAKKServerList_RefreshLANServerList, &UIFAKKServerList::RefreshLANServerList }, - { &EV_FAKKServerList_CancelRefresh, &UIFAKKServerList::CancelRefresh }, - { &EV_FAKKServerList_Connect, &UIFAKKServerList::ConnectServer }, - { &EV_FAKKServerList_LANListing, &UIFAKKServerList::MakeLANListing }, - { &EV_FAKKServerList_UpdateServer, &UIFAKKServerList::UpdateServer }, - { NULL, NULL } +CLASS_DECLARATION(UIListCtrl, UIFAKKServerList, NULL) { + {&EV_UIListBase_ItemSelected, &UIFAKKServerList::SelectServer }, + {&EV_UIListBase_ItemDoubleClicked, &UIFAKKServerList::ConnectServer }, + {&EV_FAKKServerList_RefreshServerList, &UIFAKKServerList::RefreshServerList }, + {&EV_FAKKServerList_RefreshLANServerList, &UIFAKKServerList::RefreshLANServerList}, + {&EV_FAKKServerList_CancelRefresh, &UIFAKKServerList::CancelRefresh }, + {&EV_FAKKServerList_Connect, &UIFAKKServerList::ConnectServer }, + {&EV_FAKKServerList_LANListing, &UIFAKKServerList::MakeLANListing }, + {&EV_FAKKServerList_UpdateServer, &UIFAKKServerList::UpdateServer }, + {NULL, NULL } }; UIFAKKServerList::UIFAKKServerList() { - setBackgroundColor(UWhite, true); + setBackgroundColor(UWhite, true); Connect(this, EV_UIListBase_ItemDoubleClicked, EV_UIListBase_ItemDoubleClicked); Connect(this, EV_UIListBase_ItemSelected, EV_UIListBase_ItemSelected); - AllowActivate(true); - setHeaderFont("facfont-20"); - m_serverList[0] = NULL; - m_serverList[1] = NULL; - m_bHasList = false; - m_bGettingList[0] = false; - m_bGettingList[1] = false; - m_bUpdatingList = false; - m_bLANListing = false; - m_iLastSortColumn = 2; + AllowActivate(true); + setHeaderFont("facfont-20"); + m_serverList[0] = NULL; + m_serverList[1] = NULL; + m_bHasList = false; + m_bGettingList[0] = false; + m_bGettingList[1] = false; + m_bUpdatingList = false; + m_bLANListing = false; + m_iLastSortColumn = 2; } -void UIFAKKServerList::SelectServer( Event *ev ) -{ -} +void UIFAKKServerList::SelectServer(Event *ev) {} -void UIFAKKServerList::ConnectServer( Event *ev ) +void UIFAKKServerList::ConnectServer(Event *ev) { - const FAKKServerListItem* pItem; + const FAKKServerListItem *pItem; if (getCurrentItem() <= 0) { return; } - pItem = static_cast(GetItem(getCurrentItem())); + pItem = static_cast(GetItem(getCurrentItem())); if (pItem->IsDifferentVersion()) { - const char* message; - float neededVersion = com_target_version->value; - float serverVersion = atof(pItem->GetListItemVersion().c_str()); + const char *message; + float neededVersion = com_target_version->value; + float serverVersion = atof(pItem->GetListItemVersion().c_str()); // Tolerate patch version if (fabs(neededVersion - serverVersion) >= 0.1) { UI_SetReturnMenuToCurrent(); - message = va("Server is version %s, you are targeting %s", pItem->GetListItemVersion().c_str(), com_target_version->string); + message = + va("Server is version %s, you are targeting %s", + pItem->GetListItemVersion().c_str(), + com_target_version->string); Cvar_Set("com_errormessage", message); UI_PushMenu("wrongversion"); } else { - message = va("Can not connect to v%s server, you are targeting v%s", pItem->GetListItemVersion().c_str(), com_target_version->string); - + message = + va("Can not connect to v%s server, you are targeting v%s", + pItem->GetListItemVersion().c_str(), + com_target_version->string); + Cvar_Set("dm_serverstatus", message); } } else { @@ -429,10 +451,9 @@ void UIFAKKServerList::ConnectServer( Event *ev ) } } -qboolean UIFAKKServerList::KeyEvent( int key, unsigned int time ) +qboolean UIFAKKServerList::KeyEvent(int key, unsigned int time) { - switch (key) - { + switch (key) { case K_ENTER: case K_KP_ENTER: ConnectServer(NULL); @@ -453,17 +474,17 @@ qboolean UIFAKKServerList::KeyEvent( int key, unsigned int time ) SelectServer(NULL); return qtrue; - } - else { + } else { return qfalse; } break; case 'u': case 'U': - if (getCurrentItem() > 0) - { - const FAKKServerListItem* pItem = static_cast(GetItem(getCurrentItem())); - ServerListAuxUpdate(m_serverList[0], pItem->m_sIP.c_str(), pItem->m_iGameSpyPort, true, GQueryType::qt_status); + if (getCurrentItem() > 0) { + const FAKKServerListItem *pItem = static_cast(GetItem(getCurrentItem())); + ServerListAuxUpdate( + m_serverList[0], pItem->m_sIP.c_str(), pItem->m_iGameSpyPort, true, GQueryType::qt_status + ); } return UIListCtrl::KeyEvent(key, time); case 'c': @@ -473,25 +494,33 @@ qboolean UIFAKKServerList::KeyEvent( int key, unsigned int time ) case 'i': case 'I': { - int i, j; - const FAKKServerListItem* pServerItem1; - const FAKKServerListItem* pServerItem2; - int iNumErrors = 0; + int i, j; + const FAKKServerListItem *pServerItem1; + const FAKKServerListItem *pServerItem2; + int iNumErrors = 0; for (i = 1; i <= getNumItems(); i++) { - pServerItem1 = static_cast(GetItem(i)); + pServerItem1 = static_cast(GetItem(i)); for (j = i + 1; j <= getNumItems(); j++) { - pServerItem2 = static_cast(GetItem(j)); + pServerItem2 = static_cast(GetItem(j)); if (!str::icmp(pServerItem1->m_sIP.c_str(), pServerItem2->m_sIP.c_str())) { if (pServerItem1->m_iPort == pServerItem2->m_iPort) { - Com_DPrintf("*#*#* Duplicate server address: %s:%i\n", pServerItem1->m_sIP.c_str(), pServerItem1->m_iPort); + Com_DPrintf( + "*#*#* Duplicate server address: %s:%i\n", + pServerItem1->m_sIP.c_str(), + pServerItem1->m_iPort + ); iNumErrors++; } if (pServerItem1->m_iGameSpyPort == pServerItem2->m_iGameSpyPort) { - Com_DPrintf("*#*#* servers at IP %s sharing GameSpy port %i\n", pServerItem1->m_sIP.c_str(), pServerItem1->m_iGameSpyPort); + Com_DPrintf( + "*#*#* servers at IP %s sharing GameSpy port %i\n", + pServerItem1->m_sIP.c_str(), + pServerItem1->m_iGameSpyPort + ); iNumErrors++; } } @@ -506,7 +535,7 @@ qboolean UIFAKKServerList::KeyEvent( int key, unsigned int time ) } } -void UIFAKKServerList::UpdateUIElement( void ) +void UIFAKKServerList::UpdateUIElement(void) { float width; @@ -524,13 +553,24 @@ void UIFAKKServerList::UpdateUIElement( void ) uWinMan.ActivateControl(this); } -void UIFAKKServerList::RefreshServerList( Event *ev ) +void UIFAKKServerList::RefreshServerList(Event *ev) { - int i; - FAKKServerListItem* pNewServerItem; + int i; + FAKKServerListItem *pNewServerItem; + + if (m_serverList[0] && ServerListState(m_serverList[0]) != sl_idle) { + // Fixed in OPM + // Only free the server list if it isn't currently being queried. + // The server list must not be queried + return; + } + + if (m_serverList[1] && ServerListState(m_serverList[1]) != sl_idle) { + return; + } for (i = 1; i <= getNumItems(); i++) { - pNewServerItem = static_cast(GetItem(i)); + pNewServerItem = static_cast(GetItem(i)); pNewServerItem->SetQueried(false); pNewServerItem->SetNumPlayers(0); pNewServerItem->SetQueryFailed(false); @@ -538,6 +578,8 @@ void UIFAKKServerList::RefreshServerList( Event *ev ) if (m_serverList[0]) { ServerListClear(m_serverList[0]); + // Added in 2.0: Free the server list + // Since 2.0, the UI no longer refreshes the server list when clicking "Browse Internet Servers" ServerListFree(m_serverList[0]); m_serverList[0] = NULL; } @@ -547,8 +589,8 @@ void UIFAKKServerList::RefreshServerList( Event *ev ) ServerListFree(m_serverList[1]); m_serverList[1] = NULL; } - - if (!m_serverList[0]) { + + if (!m_serverList[0] && (com_target_game->integer < target_game_e::TG_MOHTT || !m_serverList[1])) { NewServerList(); } @@ -557,14 +599,14 @@ void UIFAKKServerList::RefreshServerList( Event *ev ) Cvar_Set("dm_playercount", "0"); { - char filter[2048] = { 0 }; - static cvar_t* dm_max_players = Cvar_Get("dm_max_players", "0", CVAR_ARCHIVE); - static cvar_t* dm_min_players = Cvar_Get("dm_min_players", "0", CVAR_ARCHIVE); - static cvar_t* dm_show_demo_servers = Cvar_Get("dm_show_demo_servers", "1", CVAR_ARCHIVE); - static cvar_t* dm_realism_mode = Cvar_Get("dm_realism_mode", "0", CVAR_ARCHIVE); - static cvar_t* dm_filter_listen = Cvar_Get("dm_filter_listen", "1", CVAR_ARCHIVE); - static cvar_t* dm_filter_empty = Cvar_Get("dm_filter_empty", "0", CVAR_ARCHIVE); - static cvar_t* dm_filter_full = Cvar_Get("dm_filter_full", "0", CVAR_ARCHIVE); + char filter[2048] = {0}; + static cvar_t *dm_max_players = Cvar_Get("dm_max_players", "0", CVAR_ARCHIVE); + static cvar_t *dm_min_players = Cvar_Get("dm_min_players", "0", CVAR_ARCHIVE); + static cvar_t *dm_show_demo_servers = Cvar_Get("dm_show_demo_servers", "1", CVAR_ARCHIVE); + static cvar_t *dm_realism_mode = Cvar_Get("dm_realism_mode", "0", CVAR_ARCHIVE); + static cvar_t *dm_filter_listen = Cvar_Get("dm_filter_listen", "1", CVAR_ARCHIVE); + static cvar_t *dm_filter_empty = Cvar_Get("dm_filter_empty", "0", CVAR_ARCHIVE); + static cvar_t *dm_filter_full = Cvar_Get("dm_filter_full", "0", CVAR_ARCHIVE); if (dm_min_players->integer) { AddFilter(filter, va("numplayers >= %d", dm_min_players->integer)); @@ -604,43 +646,46 @@ void UIFAKKServerList::RefreshServerList( Event *ev ) m_bUpdatingList = true; } -void UIFAKKServerList::RefreshLANServerList( Event *ev ) +void UIFAKKServerList::RefreshLANServerList(Event *ev) { - int i; - FAKKServerListItem* pNewServerItem; + int i; + FAKKServerListItem *pNewServerItem; for (i = 1; i <= getNumItems(); i++) { - pNewServerItem = static_cast(GetItem(i)); + pNewServerItem = static_cast(GetItem(i)); pNewServerItem->SetQueried(false); pNewServerItem->SetNumPlayers(0); pNewServerItem->SetQueryFailed(false); } + if (m_serverList[0]) { + ServerListClear(m_serverList[0]); + } + if (m_serverList[1]) { ServerListClear(m_serverList[1]); } - if (m_serverList[0]) { - ServerListClear(m_serverList[0]); - } else { + if (!m_serverList[0] && (com_target_game->integer < target_game_e::TG_MOHTT || !m_serverList[1])) { NewServerList(); } - g_bDoneUpdating[0] = false; - g_bDoneUpdating[1] = false; + g_bDoneUpdating[0] = false; + g_bDoneUpdating[1] = false; g_NeedAdditionalLANSearch = true; Cvar_Set("dm_playercount", "0"); // Search all LAN servers from port 12300 to 12316 ServerListLANUpdate(m_serverList[0], true, 12300, 12316, 1); - + if (m_serverList[1]) { // If another game is supported search for it ServerListLANUpdate(m_serverList[1], true, 12300, 12316, 1); } } -static void AddFilter(char* filter, const char* value) { +static void AddFilter(char *filter, const char *value) +{ if (*filter) { strcat(filter, va(" and %s", value)); } else { @@ -648,17 +693,20 @@ static void AddFilter(char* filter, const char* value) { } } -void UIFAKKServerList::CancelRefresh( Event *ev ) +void UIFAKKServerList::CancelRefresh(Event *ev) { - ServerListHalt(m_serverList[0]); + ServerListHalt(m_serverList[0]); + if (m_serverList[1]) { + ServerListHalt(m_serverList[1]); + } } -void UIFAKKServerList::NewServerList( void ) +void UIFAKKServerList::NewServerList(void) { - int iNumConcurrent; - const char* secret_key; - const char* game_name; - cvar_t* pRateCvar = Cvar_Get("rate", "5000", CVAR_ARCHIVE | CVAR_USERINFO); + int iNumConcurrent; + const char *secret_key; + const char *game_name; + cvar_t *pRateCvar = Cvar_Get("rate", "5000", CVAR_ARCHIVE | CVAR_USERINFO); if (pRateCvar->integer <= 3000) { iNumConcurrent = 4; @@ -670,105 +718,111 @@ void UIFAKKServerList::NewServerList( void ) iNumConcurrent = 15; } + g_iServerQueryCount = 0; + g_iServerTotalCount = 0; + if (com_target_game->integer < target_game_e::TG_MOHTT) { - game_name = GS_GetCurrentGameName(); + game_name = GS_GetCurrentGameName(); secret_key = GS_GetCurrentGameKey(); // standard mohaa server g_ServerListInst[0].iServerType = com_target_game->integer; - g_ServerListInst[0].serverList = this; + g_ServerListInst[0].serverList = this; m_serverList[0] = ServerListNew( game_name, game_name, secret_key, iNumConcurrent, - (void*)&UpdateServerListCallBack, + (void *)&UpdateServerListCallBack, 1, - (void*)&g_ServerListInst[0] + (void *)&g_ServerListInst[0] ); m_serverList[1] = NULL; } else { - static cvar_t* dm_omit_spearhead = Cvar_Get("dm_omit_spearhead", "0", 1); + static cvar_t *dm_omit_spearhead = Cvar_Get("dm_omit_spearhead", "0", 1); - game_name = GS_GetGameName(target_game_e::TG_MOHTT); + game_name = GS_GetGameName(target_game_e::TG_MOHTT); secret_key = GS_GetGameKey(target_game_e::TG_MOHTT); g_ServerListInst[0].iServerType = target_game_e::TG_MOHTT; - g_ServerListInst[0].serverList = this; + g_ServerListInst[0].serverList = this; m_serverList[0] = ServerListNew( game_name, game_name, secret_key, iNumConcurrent, - (void*)&UpdateServerListCallBack, + (void *)&UpdateServerListCallBack, 1, - (void*)&g_ServerListInst[0] + (void *)&g_ServerListInst[0] ); - + if (!dm_omit_spearhead->integer) { // Since mohtt is compatible with mohta // Search for both type of servers - game_name = GS_GetGameName(target_game_e::TG_MOHTA); + game_name = GS_GetGameName(target_game_e::TG_MOHTA); secret_key = GS_GetGameKey(target_game_e::TG_MOHTA); g_ServerListInst[1].iServerType = target_game_e::TG_MOHTA; - g_ServerListInst[1].serverList = this; + g_ServerListInst[1].serverList = this; m_serverList[1] = ServerListNew( game_name, game_name, secret_key, iNumConcurrent, - (void*)&UpdateServerListCallBack, + (void *)&UpdateServerListCallBack, 1, - (void*)&g_ServerListInst[1] + (void *)&g_ServerListInst[1] ); } } } -void UIFAKKServerList::MakeLANListing( Event *ev ) +void UIFAKKServerList::MakeLANListing(Event *ev) { - m_bLANListing = true; + m_bLANListing = true; } -void UIFAKKServerList::UpdateServer( Event *ev ) +void UIFAKKServerList::UpdateServer(Event *ev) { - if (m_currentItem <= 0) { - return; - } + if (m_currentItem <= 0) { + return; + } - FAKKServerListItem* item = (FAKKServerListItem*)GetItem(getCurrentItem()); + FAKKServerListItem *item = (FAKKServerListItem *)GetItem(getCurrentItem()); ServerListAuxUpdate(m_serverList[0], item->m_sIP.c_str(), item->m_iGameSpyPort, true, GQueryType::qt_status); if (com_target_game->integer >= target_game_e::TG_MOHTT) { - const cvar_t* dm_omit_spearhead = Cvar_Get("dm_omit_spearhead", "0", CVAR_ARCHIVE); + const cvar_t *dm_omit_spearhead = Cvar_Get("dm_omit_spearhead", "0", CVAR_ARCHIVE); // check for Spearhead if (!dm_omit_spearhead->integer) { - ServerListAuxUpdate(m_serverList[1], item->m_sIP.c_str(), item->m_iGameSpyPort, true, GQueryType::qt_status); + ServerListAuxUpdate( + m_serverList[1], item->m_sIP.c_str(), item->m_iGameSpyPort, true, GQueryType::qt_status + ); } } } -int UIFAKKServerList::ServerCompareFunction( const UIListCtrlItem *i1, const UIListCtrlItem *i2, int columnname ) +int UIFAKKServerList::ServerCompareFunction(const UIListCtrlItem *i1, const UIListCtrlItem *i2, int columnname) { - int iCompResult; - int val1, val2; - const FAKKServerListItem* fi1 = static_cast(i1); - const FAKKServerListItem* fi2 = static_cast(i2); + int iCompResult; + int val1, val2; + const FAKKServerListItem *fi1 = static_cast(i1); + const FAKKServerListItem *fi2 = static_cast(i2); - if (fi1->IsFavorite() != fi2->IsFavorite()) - { + if (fi1->IsFavorite() != fi2->IsFavorite()) { if (fi1->IsFavorite()) { iCompResult = -1; } else { iCompResult = 1; } - if (g_bReverseSort) iCompResult = -iCompResult; + if (g_bReverseSort) { + iCompResult = -iCompResult; + } } else if (fi1->IsQueried() != fi2->IsQueried()) { if (fi1->IsQueried()) { iCompResult = -1; @@ -776,16 +830,19 @@ int UIFAKKServerList::ServerCompareFunction( const UIListCtrlItem *i1, const UIL iCompResult = 1; } - if (g_bReverseSort) iCompResult = -iCompResult; + if (g_bReverseSort) { + iCompResult = -iCompResult; + } } else if (fi1->IsDifferentVersion() != fi2->IsDifferentVersion()) { - if (fi1->IsDifferentVersion()) { iCompResult = 1; } else { iCompResult = -1; } - if (g_bReverseSort) iCompResult = -iCompResult; + if (g_bReverseSort) { + iCompResult = -iCompResult; + } } else if (fi1->IfQueryFailed() != fi2->IfQueryFailed()) { if (fi1->IfQueryFailed()) { iCompResult = 1; @@ -793,7 +850,9 @@ int UIFAKKServerList::ServerCompareFunction( const UIListCtrlItem *i1, const UIL iCompResult = -1; } - if (g_bReverseSort) iCompResult = -iCompResult; + if (g_bReverseSort) { + iCompResult = -iCompResult; + } } else if (g_bNumericSort) { val1 = fi1->getListItemValue(columnname); val2 = fi2->getListItemValue(columnname); @@ -809,8 +868,7 @@ int UIFAKKServerList::ServerCompareFunction( const UIListCtrlItem *i1, const UIL iCompResult = str::icmp(fi1->getListItemString(columnname), fi2->getListItemString(columnname)); } - if (!iCompResult) - { + if (!iCompResult) { if (columnname != -2) { val1 = fi1->getListItemValue(2); val2 = fi2->getListItemValue(2); @@ -843,11 +901,9 @@ int UIFAKKServerList::ServerCompareFunction( const UIListCtrlItem *i1, const UIL if (val1 < val2) { iCompResult = 1; - } - else if (val1 > val2) { + } else if (val1 > val2) { iCompResult = -1; - } - else { + } else { iCompResult = 0; } } @@ -865,16 +921,17 @@ int UIFAKKServerList::ServerCompareFunction( const UIListCtrlItem *i1, const UIL } } - if (g_bReverseSort) iCompResult = -iCompResult; + if (g_bReverseSort) { + iCompResult = -iCompResult; + } } return iCompResult; } -void UIFAKKServerList::Draw( void ) +void UIFAKKServerList::Draw(void) { - if (m_serverList[0]) - { + if (m_serverList[0]) { GServerListState listState[2]; ServerListThink(m_serverList[0]); @@ -884,22 +941,17 @@ void UIFAKKServerList::Draw( void ) listState[0] = ServerListState(m_serverList[0]); listState[1] = m_serverList[1] ? ServerListState(m_serverList[1]) : GServerListState::sl_idle; - if (listState[0] != GServerListState::sl_idle || listState[1] != GServerListState::sl_idle) - { + if (listState[0] != GServerListState::sl_idle || listState[1] != GServerListState::sl_idle) { menuManager.PassEventToWidget("refresh", new Event(EV_Widget_Disable)); menuManager.PassEventToWidget("cancelrefresh", new Event(EV_Widget_Enable)); - } - else - { + } else { menuManager.PassEventToWidget("refresh", new Event(EV_Widget_Enable)); menuManager.PassEventToWidget("cancelrefresh", new Event(EV_Widget_Disable)); } } else if (!m_bHasList) { - if (m_bLANListing) { RefreshLANServerList(NULL); - } - else { + } else { RefreshServerList(NULL); } @@ -921,14 +973,14 @@ void UIFAKKServerList::Draw( void ) UIListCtrl::Draw(); } -void UIFAKKServerList::SortByColumn( int column ) +void UIFAKKServerList::SortByColumn(int column) { - int i; - bool exists = 0; - bool numeric = 0; - bool reverse = 0; - UIListCtrlItem* selected = NULL; - bool selvisible = false; + int i; + bool exists = 0; + bool numeric = 0; + bool reverse = 0; + UIListCtrlItem *selected = NULL; + bool selvisible = false; for (i = 1; i <= m_columnlist.NumObjects(); i++) { const columndef_t& def = m_columnlist.ObjectAt(i); @@ -936,7 +988,7 @@ void UIFAKKServerList::SortByColumn( int column ) // found one numeric = def.numeric; reverse = def.reverse_sort; - exists = true; + exists = true; break; } } @@ -947,11 +999,11 @@ void UIFAKKServerList::SortByColumn( int column ) } m_iLastSortColumn = column; - s_qsortcolumn = column; - s_qsortobject = this; - s_qsortreverse = reverse; - g_bNumericSort = numeric; - g_bReverseSort = reverse; + s_qsortcolumn = column; + s_qsortobject = this; + s_qsortreverse = reverse; + g_bNumericSort = numeric; + g_bReverseSort = reverse; if (getCurrentItem()) { selected = m_itemlist.ObjectAt(getCurrentItem()); @@ -977,47 +1029,44 @@ void UIFAKKServerList::SortByColumn( int column ) } } -void UpdateServerListCallBack(GServerList serverlist, int msg, void* instance, void* param1, void* param2) +void UIFAKKServerList::UpdateServerListCallBack(GServerList serverlist, int msg, void *instance, void *param1, void *param2) { - int i, j; - int iPort, iGameSpyPort; - unsigned int iRealIP; - str sAddress; - GServer server; - FAKKServerListItem* pNewServerItem; - static int iServerQueryCount = 0; - static int iServerTotalCount = 0; - UIFAKKServerList* uiServerList; - int iServerType; + int i, j; + int iPort, iGameSpyPort; + unsigned int iRealIP; + str sAddress; + GServer server; + FAKKServerListItem *pNewServerItem; + UIFAKKServerList *uiServerList; + int iServerType; // filters - static cvar_t* dm_filter_empty = Cvar_Get("dm_filter_empty", "0", CVAR_ARCHIVE); - static cvar_t* dm_filter_full = Cvar_Get("dm_filter_full", "0", CVAR_ARCHIVE); - static cvar_t* dm_filter_pure = Cvar_Get("dm_filter_pure", "0", CVAR_ARCHIVE); - static cvar_t* dm_max_ping = Cvar_Get("dm_max_ping", "0", CVAR_ARCHIVE); - static cvar_t* dm_free_for_all = Cvar_Get("dm_free_for_all", "1", CVAR_ARCHIVE); - static cvar_t* dm_objective_match = Cvar_Get("dm_objective_match", "1", CVAR_ARCHIVE); - static cvar_t* dm_round_based_match = Cvar_Get("dm_round_based_match", "1", CVAR_ARCHIVE); - static cvar_t* dm_team_match = Cvar_Get("dm_team_match", "1", CVAR_ARCHIVE); - static cvar_t* dm_tow_match = Cvar_Get("dm_tow_match", "1", CVAR_ARCHIVE); - static cvar_t* dm_liberation_match = Cvar_Get("dm_liberation_match", "1", CVAR_ARCHIVE); - static cvar_t* dm_run_fast = Cvar_Get("dm_run_fast", "1", CVAR_ARCHIVE); - static cvar_t* dm_run_normal = Cvar_Get("dm_run_normal", "1", CVAR_ARCHIVE); - static cvar_t* dm_omit_spearhead = Cvar_Get("dm_omit_spearhead", "0", CVAR_ARCHIVE); + static cvar_t *dm_filter_empty = Cvar_Get("dm_filter_empty", "0", CVAR_ARCHIVE); + static cvar_t *dm_filter_full = Cvar_Get("dm_filter_full", "0", CVAR_ARCHIVE); + static cvar_t *dm_filter_pure = Cvar_Get("dm_filter_pure", "0", CVAR_ARCHIVE); + static cvar_t *dm_max_ping = Cvar_Get("dm_max_ping", "0", CVAR_ARCHIVE); + static cvar_t *dm_free_for_all = Cvar_Get("dm_free_for_all", "1", CVAR_ARCHIVE); + static cvar_t *dm_objective_match = Cvar_Get("dm_objective_match", "1", CVAR_ARCHIVE); + static cvar_t *dm_round_based_match = Cvar_Get("dm_round_based_match", "1", CVAR_ARCHIVE); + static cvar_t *dm_team_match = Cvar_Get("dm_team_match", "1", CVAR_ARCHIVE); + static cvar_t *dm_tow_match = Cvar_Get("dm_tow_match", "1", CVAR_ARCHIVE); + static cvar_t *dm_liberation_match = Cvar_Get("dm_liberation_match", "1", CVAR_ARCHIVE); + static cvar_t *dm_run_fast = Cvar_Get("dm_run_fast", "1", CVAR_ARCHIVE); + static cvar_t *dm_run_normal = Cvar_Get("dm_run_normal", "1", CVAR_ARCHIVE); + static cvar_t *dm_omit_spearhead = Cvar_Get("dm_omit_spearhead", "0", CVAR_ARCHIVE); - iServerType = ((ServerListInstance*)instance)->iServerType; - uiServerList = ((ServerListInstance*)instance)->serverList; + iServerType = ((ServerListInstance *)instance)->iServerType; + uiServerList = ((ServerListInstance *)instance)->serverList; pNewServerItem = NULL; - server = (GServer)param1; + server = (GServer)param1; - if (param2) - { - if (msg == LIST_PROGRESS && param2 == (void*)-1) { + if (param2) { + if (msg == LIST_PROGRESS && param2 == (void *)-1) { iRealIP = inet_addr(ServerGetAddress(server)); ServerGetIntValue(server, "hostport", PORT_SERVER); iGameSpyPort = ServerGetQueryPort(server); for (i = 1; i <= uiServerList->getNumItems(); i++) { - pNewServerItem = static_cast(uiServerList->GetItem(i)); + pNewServerItem = static_cast(uiServerList->GetItem(i)); if (pNewServerItem->m_uiRealIP == iRealIP && pNewServerItem->m_iGameSpyPort == iGameSpyPort) { break; } @@ -1030,68 +1079,80 @@ void UpdateServerListCallBack(GServerList serverlist, int msg, void* instance, v return; } - Cvar_Set("dm_serverstatusbar", va("%i", (int)(uintptr_t)param2)); + //Cvar_Set("dm_serverstatusbar", va("%i", (int)(uintptr_t)param2)); + // Fixed in OPM + // As both lists are combined, show the correct percentage + Cvar_Set("dm_serverstatusbar", va("%i", 100 * g_iServerQueryCount / g_iServerTotalCount)); } - if (msg == LIST_PROGRESS) - { - const char* pszHostName; - bool bDiffVersion; - str sServerName; - str sPlayers; - const char* pszGameVer; - const char* pszGameVerNumber; + if (msg == LIST_PROGRESS) { + const char *pszHostName; + bool bDiffVersion; + bool bIsDemo; + str sServerName; + str sPlayers; + const char *pszGameVer; + const char *pszGameVerNumber; + float fGameVer; - pszHostName = ServerGetStringValue(server, "hostname", "(NONE)"); - bDiffVersion = false; - pszGameVer = ServerGetStringValue(server, "gamever", "1.00"); + pszHostName = ServerGetStringValue(server, "hostname", "(NONE)"); + bDiffVersion = false; + bIsDemo = false; + pszGameVer = ServerGetStringValue(server, "gamever", "1.00"); pszGameVerNumber = pszGameVer; if (pszGameVerNumber[0] == 'd') { // demo server pszGameVerNumber++; + bIsDemo = true; } + fGameVer = atof(pszGameVerNumber); + if (com_target_game->integer >= target_game_e::TG_MOHTT) { if (iServerType == target_game_e::TG_MOHTT) { - //if (fabs(atof(pszGameVerNumber) - com_target_version->value) > 0.1f) { + //if (fabs(fGameVer - com_target_version->value) > 0.1f) { // bDiffVersion = true; //} - if (fabs(atof(pszGameVerNumber)) < 2.3f) { + if (fabs(fGameVer) < 2.3f) { bDiffVersion = true; } } else { - //if (fabs(atof(pszGameVerNumber) - com_target_version->value) > 0.3f) { + //if (fabs(fGameVer - com_target_version->value) > 0.3f) { // bDiffVersion = true; //} - if (fabs(atof(pszGameVerNumber)) < 2.1f) { + if (fabs(fGameVer) < 2.1f) { bDiffVersion = true; } } } else { - if (fabs(atof(pszGameVerNumber) - com_target_version->value) > 0.1f) { + if (fabs(fGameVer - com_target_version->value) > 0.1f) { bDiffVersion = true; } } // always show the version - sServerName = va(" (%s) %s", pszGameVer, pszHostName); + if (!bIsDemo) { + sServerName = va(" (%s) %s", pszGameVerNumber, pszHostName); + } else { + sServerName = va(" (d%s) %s", pszGameVerNumber, pszHostName); + } - iRealIP = inet_addr(ServerGetAddress(server)); - iPort = ServerGetIntValue(server, "hostport", PORT_SERVER); + iRealIP = inet_addr(ServerGetAddress(server)); + iPort = ServerGetIntValue(server, "hostport", PORT_SERVER); iGameSpyPort = ServerGetQueryPort(server); - sAddress = va("%s:%i", ServerGetAddress(server), iPort); + sAddress = va("%s:%i", ServerGetAddress(server), iPort); sPlayers = va("%d/%d", ServerGetIntValue(server, "numplayers", 0), ServerGetIntValue(server, "maxplayers", 0)); - + for (i = 1; i <= uiServerList->getNumItems(); i++) { - pNewServerItem = static_cast(uiServerList->GetItem(i)); + pNewServerItem = static_cast(uiServerList->GetItem(i)); if (pNewServerItem->m_uiRealIP == iRealIP && pNewServerItem->m_iGameSpyPort == iGameSpyPort) { break; } } if (i > uiServerList->getNumItems() || !pNewServerItem) { - pNewServerItem = new FAKKServerListItem(uiServerList, "?", sAddress, "?", "?/?", "?", "?", "?"); - pNewServerItem->m_sIP = ServerGetAddress(server); + pNewServerItem = new FAKKServerListItem(uiServerList, "?", sAddress, "?", "?/?", "?", "?", "?"); + pNewServerItem->m_sIP = ServerGetAddress(server); pNewServerItem->m_uiRealIP = iRealIP; pNewServerItem->m_iGameSpyPort = iGameSpyPort; @@ -1111,15 +1172,12 @@ void UpdateServerListCallBack(GServerList serverlist, int msg, void* instance, v pNewServerItem->SetQueried(true); pNewServerItem->SetNumPlayers(ServerGetIntValue(server, "numplayers", 0)); - iServerQueryCount++; - Cvar_Set("dm_servercount", va("%d/%d", iServerQueryCount, iServerTotalCount)); + g_iServerQueryCount++; + Cvar_Set("dm_servercount", va("%d/%d", g_iServerQueryCount, g_iServerTotalCount)); uiServerList->SortByLastSortColumn(); - } - else if (msg == LIST_STATECHANGED) - { - switch (ServerListState(serverlist)) - { + } else if (msg == LIST_STATECHANGED) { + switch (ServerListState(serverlist)) { case GServerListState::sl_idle: if (com_target_game->integer >= target_game_e::TG_MOHTT) { if (iServerType == target_game_e::TG_MOHTT) { @@ -1143,14 +1201,17 @@ void UpdateServerListCallBack(GServerList serverlist, int msg, void* instance, v case GServerListState::sl_listxfer: Cvar_Set("dm_serverstatus", "Getting List."); if (com_target_game->integer >= target_game_e::TG_MOHTT) { - if (iServerType == target_game_e::TG_MOHTT) uiServerList->m_bGettingList[0] = true; - if (iServerType == target_game_e::TG_MOHTA) uiServerList->m_bGettingList[1] = true; + if (iServerType == target_game_e::TG_MOHTT) { + uiServerList->m_bGettingList[0] = true; + } + if (iServerType == target_game_e::TG_MOHTA) { + uiServerList->m_bGettingList[1] = true; + } } else { uiServerList->m_bGettingList[0] = true; uiServerList->m_bGettingList[1] = false; } uiServerList->m_bUpdatingList = true; - iServerQueryCount = 0; return; case GServerListState::sl_lanlist: Cvar_Set("dm_serverstatus", "Searching LAN."); @@ -1159,18 +1220,27 @@ void UpdateServerListCallBack(GServerList serverlist, int msg, void* instance, v case GServerListState::sl_querying: Cvar_Set("dm_serverstatus", "Querying Servers."); uiServerList->m_bUpdatingList = true; - iServerQueryCount = 0; - iServerTotalCount = 0; break; default: break; } - if (!uiServerList->m_bGettingList[0] && !uiServerList->m_bGettingList[1]) { - return; + //if (!uiServerList->m_bGettingList[0] && !uiServerList->m_bGettingList[1]) { + // return; + //} + + // Rebuild the number of servers + g_iServerTotalCount = 0; + for(i = 0; i < ARRAY_LEN(uiServerList->m_serverList); i++) { + if (uiServerList->m_bGettingList[i] && uiServerList->m_serverList[i]) { + g_iServerTotalCount += ServerListCount(uiServerList->m_serverList[i]); + } } - iServerTotalCount += ServerListCount(serverlist); + // Removed in 2.0 + // Only add entries for servers that are queried successfully + // it avoids unnecessary entries +#if 0 for (j = 0; j < ServerListCount(serverlist); j++) { GServer arrayServer = ServerListGetServer(serverlist, j); @@ -1198,6 +1268,7 @@ void UpdateServerListCallBack(GServerList serverlist, int msg, void* instance, v uiServerList->AddItem(pNewServerItem); } +#endif /* for (i = 1; i <= uiServerList->getNumItems(); i++) @@ -1225,4 +1296,4 @@ void UpdateServerListCallBack(GServerList serverlist, int msg, void* instance, v } */ } -} \ No newline at end of file +} diff --git a/code/client/cl_uiserverlist.h b/code/client/cl_uiserverlist.h index d8638b32..91c46016 100644 --- a/code/client/cl_uiserverlist.h +++ b/code/client/cl_uiserverlist.h @@ -22,6 +22,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #pragma once +#include "../gamespy/goaceng.h" + class UIFAKKServerList : public UIListCtrl { protected: // need a new struct instead of gamespy @@ -47,6 +49,7 @@ protected: void MakeLANListing( Event *ev ); void UpdateServer( Event *ev ); static int ServerCompareFunction( const UIListCtrlItem *i1, const UIListCtrlItem *i2, int columnname ); + static void UpdateServerListCallBack(GServerList serverlist, int msg, void *instance, void *param1, void *param2); public: UIFAKKServerList(); diff --git a/code/client/cl_uistd.cpp b/code/client/cl_uistd.cpp index d3780aa8..4fd41c6e 100644 --- a/code/client/cl_uistd.cpp +++ b/code/client/cl_uistd.cpp @@ -439,8 +439,11 @@ void UIFakkLabel::LayoutRenderModelAnim(Event *ev) void UIFakkLabel::DrawStatbar(float frac) { - vec4_t col; - float alpha; + vec4_t col; + float alpha; + qhandle_t hMat; + float w, h; + float fvWidth, fvHeight; col[0] = col[1] = col[2] = col[3] = 1.0; @@ -475,11 +478,7 @@ void UIFakkLabel::DrawStatbar(float frac) m_lastfrac = frac; alpha = 1.0 - ((float)uid.time - m_flashtime) / 1500.0; - if (alpha < 0.0) { - alpha = 0.0; - } else if (alpha > 1.0) { - alpha = 1.0; - } + alpha = Q_clamp_float(alpha, 0, 1); col[3] = alpha; @@ -490,13 +489,38 @@ void UIFakkLabel::DrawStatbar(float frac) { float width = frac * m_frame.size.width; - m_statbar_material->ReregisterMaterial(); - re.DrawTilePic(0.0, 0.0, width, m_frame.size.height, m_statbar_material->GetMaterial()); + fvWidth = m_frame.size.width / m_vVirtualScale[0] / uii.Rend_GetShaderWidth(m_statbar_material->GetMaterial()); + fvHeight = m_frame.size.height / m_vVirtualScale[1] / uii.Rend_GetShaderHeight(m_statbar_material->GetMaterial()); + + re.DrawStretchPic(0.0, 0.0, width, m_frame.size.height, 0, 0, fvWidth, fvHeight, m_statbar_material->GetMaterial()); + //re.DrawTilePic(0.0, 0.0, width, m_frame.size.height, m_statbar_material->GetMaterial()); if (alpha != 0.0 && m_statbar_material_flash) { re.SetColor(col); - m_statbar_material_flash->ReregisterMaterial(); - re.DrawTilePic(0.0, 0.0, width, m_frame.size.height, m_statbar_material_flash->GetMaterial()); + + fvWidth = m_frame.size.width / m_vVirtualScale[0] / uii.Rend_GetShaderWidth(m_statbar_material_flash->GetMaterial()); + fvHeight = m_frame.size.height / m_vVirtualScale[1] / uii.Rend_GetShaderHeight(m_statbar_material_flash->GetMaterial()); + + re.DrawStretchPic(0.0, 0.0, width, m_frame.size.height, 0, 0, fvWidth, fvHeight, m_statbar_material_flash->GetMaterial()); + //re.DrawTilePic(0.0, 0.0, width, m_frame.size.height, m_statbar_material_flash->GetMaterial()); + } + + if (m_statbar_material_marker) { + hMat = m_statbar_material_marker->GetMaterial(); + w = re.GetShaderWidth(hMat); + h = re.GetShaderHeight(hMat); + + re.DrawStretchPic( + m_frame.size.width * frac - w * 0.5, + m_frame.size.height * 0.5 - h * 0.5, + w, + h, + 0, + 0, + 1, + 1, + hMat + ); } break; } @@ -507,14 +531,39 @@ void UIFakkLabel::DrawStatbar(float frac) { float y = m_frame.size.height * (1.0 - frac); - m_statbar_material->ReregisterMaterial(); - re.DrawTilePic(0.0, y, m_frame.size.width, m_frame.size.height, m_statbar_material->GetMaterial()); + fvWidth = m_frame.size.width / m_vVirtualScale[0] / uii.Rend_GetShaderWidth(m_statbar_material->GetMaterial()); + fvHeight = m_frame.size.height / m_vVirtualScale[1] / uii.Rend_GetShaderHeight(m_statbar_material->GetMaterial()); + + re.DrawStretchPic(0.0, y, m_frame.size.width, m_frame.size.height, 0, 0, fvWidth, fvHeight, m_statbar_material->GetMaterial()); + //re.DrawTilePic(0.0, y, m_frame.size.width, m_frame.size.height, m_statbar_material->GetMaterial()); if (alpha != 0.0 && m_statbar_material_flash) { re.SetColor(col); - m_statbar_material_flash->ReregisterMaterial(); - re.DrawTilePic( - 0.0, y, m_frame.size.width, m_frame.size.height, m_statbar_material_flash->GetMaterial() + + fvWidth = m_frame.size.width / m_vVirtualScale[0] / uii.Rend_GetShaderWidth(m_statbar_material_flash->GetMaterial()); + fvHeight = m_frame.size.height / m_vVirtualScale[1] / uii.Rend_GetShaderHeight(m_statbar_material_flash->GetMaterial()); + + re.DrawStretchPic(0.0, y, m_frame.size.width, m_frame.size.height, 0, 0, fvWidth, fvHeight, m_statbar_material_flash->GetMaterial()); + //re.DrawTilePic( + // 0.0, y, m_frame.size.width, m_frame.size.height, m_statbar_material_flash->GetMaterial() + //); + } + + if (m_statbar_material_marker) { + hMat = m_statbar_material_marker->GetMaterial(); + w = re.GetShaderWidth(hMat); + h = re.GetShaderHeight(hMat); + + re.DrawStretchPic( + m_frame.size.width * frac - w * 0.5, + m_frame.size.height * 0.5 - h * 0.5, + w, + h, + 0, + 0, + 1, + 1, + hMat ); } break; @@ -528,14 +577,12 @@ void UIFakkLabel::DrawStatbar(float frac) { float width = frac * m_frame.size.width; - m_statbar_material->ReregisterMaterial(); re.DrawStretchPic( 0.0, 0.0, width, m_frame.size.height, 0.0, 0.0, 1.0, 1.0, m_statbar_material->GetMaterial() ); if (alpha != 0.0 && m_statbar_material_flash) { re.SetColor(col); - m_statbar_material_flash->ReregisterMaterial(); re.DrawStretchPic( 0.0, 0.0, @@ -548,6 +595,24 @@ void UIFakkLabel::DrawStatbar(float frac) m_statbar_material_flash->GetMaterial() ); } + + if (m_statbar_material_marker) { + hMat = m_statbar_material_marker->GetMaterial(); + w = re.GetShaderWidth(hMat); + h = re.GetShaderHeight(hMat); + + re.DrawStretchPic( + m_frame.size.width * frac - w * 0.5, + m_frame.size.height * 0.5 - h * 0.5, + w, + h, + 0, + 0, + 1, + 1, + hMat + ); + } break; } case L_STATBAR_VERTICAL: @@ -557,14 +622,12 @@ void UIFakkLabel::DrawStatbar(float frac) float y = m_frame.size.height * (1.0 - frac); float height = m_frame.size.height * frac; - m_statbar_material->ReregisterMaterial(); re.DrawStretchPic( 0.0, y, m_frame.size.width, height, 0.0, 1.0 - frac, 1.0, 1.0, m_statbar_material->GetMaterial() ); if (alpha != 0.0 && m_statbar_material_flash) { re.SetColor(col); - m_statbar_material_flash->ReregisterMaterial(); re.DrawStretchPic( 0.0, y, @@ -577,20 +640,36 @@ void UIFakkLabel::DrawStatbar(float frac) m_statbar_material_flash->GetMaterial() ); } + + if (m_statbar_material_marker) { + hMat = m_statbar_material_marker->GetMaterial(); + w = re.GetShaderWidth(hMat); + h = re.GetShaderHeight(hMat); + + re.DrawStretchPic( + m_frame.size.width * frac - w * 0.5, + m_frame.size.height * 0.5 - h * 0.5, + w, + h, + 0, + 0, + 1, + 1, + hMat + ); + } break; } case L_STATBAR_VERTICAL_REVERSE: { float height = m_frame.size.height * frac; - m_statbar_material->ReregisterMaterial(); re.DrawStretchPic( 0.0, 0.0, m_frame.size.width, height, 0.0, 0.0, 1.0, frac, m_statbar_material->GetMaterial() ); if (alpha != 0.0 && m_statbar_material_flash) { re.SetColor(col); - m_statbar_material_flash->ReregisterMaterial(); re.DrawStretchPic( 0.0, 0.0, @@ -686,12 +765,10 @@ void UIFakkLabel::DrawStatCircle(float frac) re.SetColor(m_foreground_color); } - m_statbar_material->ReregisterMaterial(); re.DrawTrianglePic(vVerts, vTexCoords, m_statbar_material->GetMaterial()); if (alpha && m_statbar_material_flash) { re.SetColor(col); - m_statbar_material_flash->ReregisterMaterial(); re.DrawTrianglePic(vVerts, vTexCoords, m_statbar_material_flash->GetMaterial()); } } else { @@ -709,12 +786,10 @@ void UIFakkLabel::DrawStatCircle(float frac) re.SetColor(m_foreground_color); } - m_statbar_material->ReregisterMaterial(); re.DrawTrianglePic(vVerts, vTexCoords, m_statbar_material->GetMaterial()); if (alpha && m_statbar_material_flash) { re.SetColor(col); - m_statbar_material_flash->ReregisterMaterial(); re.DrawTrianglePic(vVerts, vTexCoords, m_statbar_material_flash->GetMaterial()); } @@ -739,12 +814,10 @@ void UIFakkLabel::DrawStatCircle(float frac) re.SetColor(m_foreground_color); } - m_statbar_material->ReregisterMaterial(); re.DrawTrianglePic(vVerts, vTexCoords, m_statbar_material->GetMaterial()); if (alpha && m_statbar_material_flash) { re.SetColor(col); - m_statbar_material_flash->ReregisterMaterial(); re.DrawTrianglePic(vVerts, vTexCoords, m_statbar_material_flash->GetMaterial()); } } else { @@ -766,12 +839,10 @@ void UIFakkLabel::DrawStatCircle(float frac) re.SetColor(m_foreground_color); } - m_statbar_material->ReregisterMaterial(); re.DrawTrianglePic(vVerts, vTexCoords, m_statbar_material->GetMaterial()); if (alpha && m_statbar_material_flash) { re.SetColor(col); - m_statbar_material_flash->ReregisterMaterial(); re.DrawTrianglePic(vVerts, vTexCoords, m_statbar_material_flash->GetMaterial()); } @@ -846,12 +917,10 @@ void UIFakkLabel::DrawStatNeedle(float frac) re.SetColor(m_foreground_color); } - m_statbar_material->ReregisterMaterial(); re.DrawTrianglePic(vVerts, vTexCoords, m_statbar_material->GetMaterial()); if (alpha != 0.f && m_statbar_material_flash) { re.SetColor(col); - m_statbar_material_flash->ReregisterMaterial(); re.DrawTrianglePic(vVerts, vTexCoords, m_statbar_material_flash->GetMaterial()); } @@ -867,11 +936,9 @@ void UIFakkLabel::DrawStatNeedle(float frac) re.SetColor(m_foreground_color); } - m_statbar_material->ReregisterMaterial(); re.DrawTrianglePic(vVerts, vTexCoords, m_statbar_material->GetMaterial()); if (alpha != 0.f && m_statbar_material_flash) { - m_statbar_material_flash->ReregisterMaterial(); re.DrawTrianglePic(vVerts, vTexCoords, m_statbar_material_flash->GetMaterial()); } } @@ -913,8 +980,8 @@ void UIFakkLabel::DrawStatRotator(float frac) vNeedleDir[0] = fSinVal; vNeedleDir[1] = -fCosVal; - vSize[0] = (m_frame.size.width + m_frame.size.height) / m_frame.size.width * m_angles[2] * m_vVirtualScale[0]; - vSize[1] = (m_frame.size.width + m_frame.size.height) / m_frame.size.height * m_scale * m_vVirtualScale[1]; + vSize[0] = (m_frame.size.width + m_frame.size.height) / m_frame.size.width * m_angles[2] * getVirtualScale()[0]; + vSize[1] = (m_frame.size.width + m_frame.size.height) / m_frame.size.height * m_scale * getVirtualScale()[1]; vCenter[0] = (m_frame.size.width * 0.5f - vSize[0]) * vNeedleDir[0] + m_frame.size.width * 0.5f; vCenter[1] = (m_frame.size.height * 0.5f - vSize[1]) * vNeedleDir[1] + m_frame.size.height * 0.5f; @@ -937,11 +1004,9 @@ void UIFakkLabel::DrawStatRotator(float frac) re.SetColor(m_foreground_color); } - m_statbar_material->ReregisterMaterial(); re.DrawTrianglePic(vVerts, vTexCoords, m_statbar_material->GetMaterial()); if (alpha != 0.f && m_statbar_material_flash) { - m_statbar_material_flash->ReregisterMaterial(); re.DrawTrianglePic(vVerts, vTexCoords, m_statbar_material_flash->GetMaterial()); } @@ -959,11 +1024,9 @@ void UIFakkLabel::DrawStatRotator(float frac) re.SetColor(m_foreground_color); } - m_statbar_material->ReregisterMaterial(); re.DrawTrianglePic(vVerts, vTexCoords, m_statbar_material->GetMaterial()); if (alpha != 0.f && m_statbar_material_flash) { - m_statbar_material_flash->ReregisterMaterial(); re.DrawTrianglePic(vVerts, vTexCoords, m_statbar_material_flash->GetMaterial()); } } @@ -1137,7 +1200,6 @@ void UIFakkLabel::DrawStatCompass(float frac) vVerts[1][1] = vCenter[1] + vCompassDir[1] * vCenter[1] + fSinVal * vCenter[0]; vVerts[2][1] = vCenter[1] - vCompassDir[1] * vCenter[1] - fSinVal * vCenter[0]; - m_statbar_material->ReregisterMaterial(); re.DrawTrianglePic(vVerts, vTexCoords, m_statbar_material->GetMaterial()); vVerts[0][0] = vVerts[2][0]; @@ -1150,7 +1212,6 @@ void UIFakkLabel::DrawStatCompass(float frac) vVerts[2][0] = vCenter[0] + fCosVal * vCenter[1] - vCompassDir[0] * vCenter[0]; vVerts[2][1] = vCenter[1] * fSinVal + vCenter[0] - vCompassDir[1] * vCenter[1]; - m_statbar_material->ReregisterMaterial(); re.DrawTrianglePic(vVerts, vTexCoords, m_statbar_material->GetMaterial()); } @@ -1227,11 +1288,9 @@ void UIFakkLabel::DrawStatSpinner(float frac) re.SetColor(m_foreground_color); } - m_statbar_material->ReregisterMaterial(); re.DrawTrianglePic(vVerts, vTexCoords, m_statbar_material->GetMaterial()); if (alpha != 0.f && m_statbar_material_flash) { - m_statbar_material_flash->ReregisterMaterial(); re.DrawTrianglePic(vVerts, vTexCoords, m_statbar_material_flash->GetMaterial()); } @@ -1249,11 +1308,9 @@ void UIFakkLabel::DrawStatSpinner(float frac) re.SetColor(m_foreground_color); } - m_statbar_material->ReregisterMaterial(); re.DrawTrianglePic(vVerts, vTexCoords, m_statbar_material->GetMaterial()); if (alpha != 0.f && m_statbar_material_flash) { - m_statbar_material_flash->ReregisterMaterial(); re.DrawTrianglePic(vVerts, vTexCoords, m_statbar_material_flash->GetMaterial()); } } @@ -1319,7 +1376,7 @@ void UIFakkLabel::Draw(void) m_iFontAlignmentVertical, Sys_LV_CL_ConvertString(va("%s", CL_ConfigString(cl.snap.ps.stats[m_stat_configstring]))), UBlack, - m_bVirtual ? m_vVirtualScale : NULL + getVirtualScale() ); } else { m_font->PrintJustified( @@ -1327,7 +1384,7 @@ void UIFakkLabel::Draw(void) m_iFontAlignmentHorizontal, m_iFontAlignmentVertical, Sys_LV_CL_ConvertString(va("%s", CL_ConfigString(cl.snap.ps.stats[m_stat_configstring]))), - m_bVirtual ? m_vVirtualScale : NULL + getVirtualScale() ); } return; @@ -1346,7 +1403,7 @@ void UIFakkLabel::Draw(void) m_iFontAlignmentVertical, va("%d", delta), UBlack, - m_bVirtual ? m_vVirtualScale : NULL + getVirtualScale() ); } else { m_font->PrintJustified( @@ -1354,7 +1411,7 @@ void UIFakkLabel::Draw(void) m_iFontAlignmentHorizontal, m_iFontAlignmentVertical, va("%d", delta), - m_bVirtual ? m_vVirtualScale : NULL + getVirtualScale() ); } return; @@ -1425,6 +1482,12 @@ void UIFakkLabel::Draw(void) return; } + if (cl.snap.ps.activeItems[m_itemindex] < 0 || cl.snap.ps.activeItems[m_itemindex] >= MAX_WEAPONS) { + // Fixed in OPM + // Make sure to not overflow configstrings + return; + } + m_font->setColor(m_foreground_color); if (m_bOutlinedText) { @@ -1434,7 +1497,7 @@ void UIFakkLabel::Draw(void) m_iFontAlignmentVertical, Sys_LV_CL_ConvertString(va("%s", CL_ConfigString(CS_WEAPONS + cl.snap.ps.activeItems[m_itemindex]))), UBlack, - m_bVirtual ? m_vVirtualScale : NULL + getVirtualScale() ); } else { m_font->PrintJustified( @@ -1442,7 +1505,7 @@ void UIFakkLabel::Draw(void) m_iFontAlignmentHorizontal, m_iFontAlignmentVertical, Sys_LV_CL_ConvertString(va("%s", CL_ConfigString(CS_WEAPONS + cl.snap.ps.activeItems[m_itemindex]))), - m_bVirtual ? m_vVirtualScale : NULL + getVirtualScale() ); } diff --git a/code/client/cl_uiview3d.cpp b/code/client/cl_uiview3d.cpp index 71a127b6..98440439 100644 --- a/code/client/cl_uiview3d.cpp +++ b/code/client/cl_uiview3d.cpp @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -23,6 +23,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "cl_ui.h" #include "../qcommon/localization.h" +#include "../server/server.h" + CLASS_DECLARATION(UIWidget, View3D, NULL) { {&W_Activated, &View3D::OnActivate }, {&W_Deactivated, &View3D::OnDeactivate}, @@ -30,8 +32,6 @@ CLASS_DECLARATION(UIWidget, View3D, NULL) { {NULL, NULL } }; -#define MAX_SUBTITLES 4 - cvar_t *subs[MAX_SUBTITLES]; cvar_t *teams[MAX_SUBTITLES]; float fadeTime[MAX_SUBTITLES]; @@ -52,16 +52,6 @@ View3D::View3D() m_locationprint = qfalse; } -void View3D::UpdateLocationPrint(int x, int y, const char *s, float alpha) -{ - m_printstring = s; - m_printalpha = alpha; - m_printfadetime = 4000.0; - m_x_coord = x; - m_y_coord = y; - m_locationprint = qtrue; -} - void View3D::UpdateCenterPrint(const char *s, float alpha) { m_printstring = s; @@ -77,41 +67,20 @@ void View3D::UpdateCenterPrint(const char *s, float alpha) m_locationprint = qfalse; } -void View3D::PrintSound(int channel, const char *name, float vol, int rvol, float pitch, float base, int& line) +void View3D::UpdateLocationPrint(int x, int y, const char *s, float alpha) { - char buf[255]; - float x; - float xStep; - float height; + m_printstring = s; + m_printalpha = alpha; + m_printfadetime = 4000.0; + m_x_coord = x; + m_y_coord = y; + m_locationprint = qtrue; +} - height = m_font->getHeight(false); - xStep = height; - - x = 0; - sprintf(buf, "%d", channel); - m_font->Print(x, height * line + m_frame.pos.y, buf, -1, false); - - x += xStep + xStep; - sprintf(buf, "%s", name); - m_font->Print(x, height * line + m_frame.pos.y, buf, -1, false); - - x += xStep * 30.0; - sprintf(buf, "vol:%.2f", vol); - m_font->Print(x, height * line + m_frame.pos.y, buf, -1, false); - - x += xStep * 8; - sprintf(buf, "rvol:%.2f", (float)(rvol / 128.f)); - m_font->Print(x, height * line + m_frame.pos.y, buf, -1, false); - - x += xStep * 5; - sprintf(buf, "pit:%.2f", pitch); - m_font->Print(x, height * line + m_frame.pos.y, buf, -1, false); - - x += xStep * 5; - sprintf(buf, "base:%d", (int)base); - m_font->Print(x, height * line + m_frame.pos.y, buf, -1, false); - - line++; +void View3D::FrameInitialized(void) +{ + Connect(this, W_Activated, W_Activated); + Connect(this, W_Deactivated, W_Deactivated); } void View3D::Pressed(Event *ev) @@ -120,18 +89,13 @@ void View3D::Pressed(Event *ev) OnActivate(ev); } -void View3D::OnDeactivate(Event *ev) -{ - cls.keyCatchers |= KEYCATCH_UI; -} - void View3D::OnActivate(Event *ev) { UIWidget *wid; UList widgets; UI_CloseInventory(); - cls.keyCatchers &= ~KEYCATCH_UI; + Key_SetCatcher(Key_GetCatcher() & ~KEYCATCH_UI); for (wid = getParent()->getFirstChild(); wid; wid = getParent()->getNextChild(wid)) { if (wid->getAlwaysOnBottom() && wid != this) { @@ -146,262 +110,9 @@ void View3D::OnActivate(Event *ev) } } -void View3D::LocationPrint(void) +void View3D::OnDeactivate(Event *ev) { - fonthorzjustify_t horiz; - fontvertjustify_t vert; - int x, y; - const char *p; - float alpha; - UIRect2D frame; - - if (!m_printfadetime) { - m_locationprint = false; - return; - } - - horiz = FONT_JUSTHORZ_LEFT; - vert = FONT_JUSTVERT_TOP; - - p = Sys_LV_CL_ConvertString(m_printstring); - if (m_printfadetime > 3250) { - alpha = 1.f - (m_printfadetime - 3250.f) / 750.f * m_printalpha; - } else if (m_printfadetime >= 750) { - alpha = 1.f; - } else { - alpha = m_printfadetime / 750.f * m_printalpha; - } - - alpha = Q_clamp_float(alpha, 0, 1); - - x = m_x_coord / 640.f * m_screenframe.size.width; - y = (480 - m_font->getHeight(false) - m_y_coord) / 480.f * m_screenframe.size.height; - - if (m_x_coord == -1) { - horiz = FONT_JUSTHORZ_CENTER; - x = 0; - } - if (m_y_coord == -1) { - vert = FONT_JUSTVERT_CENTER; - y = 0; - } - - m_font->setColor(UColor(0, 0, 0, alpha)); - frame = getClientFrame(); - - m_font->PrintJustified( - UIRect2D(frame.pos.x + x + 1, frame.pos.y + y + 1, frame.size.width, frame.size.height), - horiz, - vert, - p, - m_bVirtual ? m_vVirtualScale : NULL - ); - - m_font->setColor(UColor(1, 1, 1, alpha)); - frame = getClientFrame(); - - m_font->PrintJustified( - UIRect2D(frame.pos.x + x, frame.pos.y + y, frame.size.width, frame.size.height), - horiz, - vert, - p, - m_bVirtual ? m_vVirtualScale : NULL - ); - - m_font->setColor(UBlack); - m_printfadetime -= cls.frametime; - - if (m_printfadetime < 0) { - m_printfadetime = 0; - } -} - -qboolean View3D::LetterboxActive(void) -{ - return m_letterbox_active; -} - -float avWidth = 0.0; - -void View3D::InitSubtitle(void) -{ - float totalWidth; - - for (int i = 0; i < 4; i++) { - subs[i] = Cvar_Get(va("subtitle%d", i), "", 0); - teams[i] = Cvar_Get(va("subteam%d", i), "0", 0); - strcpy(oldStrings[i], subs[i]->string); - fadeTime[i] = 4000.0; - subLife[i] = 4000.0; - } - - totalWidth = 0.0; - for (char j = 'A'; j <= 'Z'; j++) { - totalWidth += m_font->getCharWidth(j); - } - - avWidth = totalWidth / 26.0; -} - -void View3D::FrameInitialized(void) -{ - Connect(this, W_Activated, W_Activated); - Connect(this, W_Deactivated, W_Deactivated); -} - -void View3D::DrawSubtitleOverlay(void) -{ - cvar_t *subAlpha; - int i; - float minX, maxY; - int line; - - subAlpha = Cvar_Get("subAlpha", "0.5", 0); - - setFont("facfont-20"); - m_font->setColor(URed); - - for (i = 0; i < MAX_SUBTITLES; i++) { - if (strcmp(oldStrings[i], subs[i]->string)) { - fadeTime[i] = 2500 * ((strlen(subs[i]->string) / 68) + 1.f) + 1500; - subLife[i] = fadeTime[i]; - Q_strncpyz(oldStrings[i], subs[i]->string, sizeof(oldStrings[i])); - } - - if (fadeTime[i] > subLife[i] - 750.f) { - alpha[i] = 1.f - (fadeTime[i] - (subLife[i] - 750.f)) / 750.f; - } else if (fadeTime[i] < 750) { - alpha[i] = fadeTime[i] / 750.f; - } else { - alpha[i] = 1.f; - } - - fadeTime[i] -= cls.frametime; - if (fadeTime[i] < 0) { - // Clear the subtitle - fadeTime[i] = 0; - oldStrings[i][0] = 0; - Cvar_Set(va("subtitle%d", i), ""); - } - } - - minX = m_screenframe.size.height - m_font->getHeight(false) * 10; - maxY = (m_frame.pos.x + m_frame.size.width) - (m_frame.pos.x + m_frame.size.width) * 0.2f; - line = 0; - - for (i = 0; i < MAX_SUBTITLES; i++) { - if (m_font->getWidth(subs[i]->string, sizeof(oldStrings[i])) > maxY) { - char buf[2048]; - char *c; - char *end; - char *start; - float total; - int blockcount; - - c = buf; - strcpy(buf, subs[i]->string); - - total = 0; - end = NULL; - start = buf; - while (*c) { - blockcount = m_font->DBCSGetWordBlockCount(c, -1); - if (!blockcount) { - break; - } - - total += m_font->getWidth(c, blockcount); - c += blockcount; - - if (total > maxY) { - total = 0; - if (end < start) { - Com_Printf("ERROR - word longer than possible line\n"); - break; - } - - m_font->setColor(UColor(0, 0, 0, alpha[i] * subAlpha->value)); - m_font->Print(18, m_font->getHeight(false) * line + minX + 1.f, start, -1, false); - - m_font->setColor(UColor(1, 1, 1, alpha[i] * subAlpha->value)); - m_font->Print(20, m_font->getHeight(false) * line + minX, start, -1, false); - - start = end + 1; - c = end + 1; - line++; - } - } - - m_font->setColor(UColor(0, 0, 0, alpha[i] * subAlpha->value)); - m_font->Print(18, m_font->getHeight(false) * line + minX + 1.f, start, -1, qfalse); - - m_font->setColor(UColor(1, 1, 1, alpha[i] * subAlpha->value)); - m_font->Print(20, m_font->getHeight(false) * line + minX, start, -1, qfalse); - line++; - } else { - m_font->setColor(UColor(0, 0, 0, alpha[i] * subAlpha->value)); - m_font->Print(18, m_font->getHeight(false) * line + minX + 1.f, subs[i]->string, -1, qfalse); - - m_font->setColor(UColor(1, 1, 1, alpha[i] * subAlpha->value)); - m_font->Print(20, m_font->getHeight(false) * line + minX, subs[i]->string, -1, qfalse); - - line++; - } - } -} - -void View3D::DrawSoundOverlay(void) -{ - setFont("verdana-14"); - m_font->setColor(UWhite); - - // FIXME: TODO - if (sound_overlay->integer) { - Com_Printf("sound_overlay isn't supported with OpenAL/SDL right now.\n"); - Cvar_Set("sound_overlay", "0"); - } -} - -void View3D::DrawProf(void) -{ - // Normal empty function -} - -void View3D::DrawLetterbox(void) -{ - float frac; - vec4_t col; - - col[0] = col[1] = col[2] = 0; - col[3] = 1; - - frac = cl.snap.ps.stats[STAT_LETTERBOX] / 32767.0; - if (frac > 0.0) { - m_letterbox_active = true; - re.SetColor(col); - - re.DrawBox(0.0, 0.0, m_screenframe.size.width, m_screenframe.size.height); - re.DrawBox( - 0.0, - m_screenframe.size.height - m_screenframe.size.height * frac, - m_screenframe.size.width, - m_screenframe.size.height - ); - } else { - m_letterbox_active = false; - } -} - -void View3D::DrawFades(void) -{ - if (cl.snap.ps.blend[3] > 0) { - re.SetColor(cl.snap.ps.blend); - if (cl.snap.ps.stats[STAT_ADDFADE]) { - re.AddBox(0.0, 0.0, m_screenframe.size.width, m_screenframe.size.height); - } else { - re.DrawBox(0.0, 0.0, m_screenframe.size.width, m_screenframe.size.height); - } - } + Key_SetCatcher(Key_GetCatcher() | KEYCATCH_UI); } void View3D::DrawFPS(void) @@ -413,13 +124,13 @@ void View3D::DrawFPS(void) re.SetColor(UBlack); re.DrawBox( 0.0, - m_frame.pos.y + m_frame.size.height - m_font->getHeight(qfalse) * 4.0, + m_frame.pos.y + m_frame.size.height - m_font->getHeight() * 4.0, m_frame.pos.x + m_frame.size.width, - m_font->getHeight(qfalse) * 4.0 + m_font->getHeight() * 4.0 ); } - sprintf(string, "FPS %4.1f", currentfps); + Com_sprintf(string, sizeof(string), "FPS %4.1f", currentfps); if (currentfps > 23.94) { if (cl_greenfps->integer) { m_font->setColor(UGreen); @@ -434,11 +145,11 @@ void View3D::DrawFPS(void) } m_font->Print( - m_font->getHeight(qfalse) * 10.0, - m_frame.pos.y + m_frame.size.height - m_font->getHeight(qfalse) * 3.0, + m_font->getHeight(getHighResScale()) * 10.0 / getHighResScale()[0], + (m_frame.pos.y + m_frame.size.height - m_font->getHeight(getHighResScale()) * 3.0) / getHighResScale()[1], string, -1, - qfalse + getHighResScale() ); // Draw elements count @@ -448,29 +159,343 @@ void View3D::DrawFPS(void) m_font->setColor(UWhite); } - sprintf(string, "wt%5d wv%5d cl%d", cls.world_tris, cls.world_verts, cls.character_lights); + Com_sprintf(string, sizeof(string), "wt%5d wv%5d cl%d", cls.world_tris, cls.world_verts, cls.character_lights); m_font->Print( - m_font->getHeight(qfalse) * 10.0, - m_frame.pos.y + m_frame.size.height - m_font->getHeight(qfalse) * 2.0, + (m_font->getHeight(getHighResScale()) * 10.0) / getHighResScale()[0], + (m_frame.pos.y + m_frame.size.height - m_font->getHeight(getHighResScale()) * 2.0) / getHighResScale()[1], string, -1, - qfalse + getHighResScale() ); - sprintf(string, "t%5d v%5d Mtex%5.2f", cls.total_tris, cls.total_verts, (float)cls.total_texels * 0.00000095367432); + Com_sprintf( + string, + sizeof(string), + "t%5d v%5d Mtex%5.2f", + cls.total_tris, + cls.total_verts, + (float)cls.total_texels * 0.00000095367432 + ); m_font->Print( - m_font->getHeight(qfalse) * 10.0, - m_frame.pos.y + m_frame.size.height - m_font->getHeight(qfalse), + (m_font->getHeight(getHighResScale()) * 10.0) / getHighResScale()[0], + (m_frame.pos.y + m_frame.size.height - m_font->getHeight(getHighResScale())) / getHighResScale()[1], string, -1, - qfalse + getHighResScale() ); m_font->setColor(UBlack); } +/* +void ProfPrint(UIFont* m_font, float minY, int line, char* label, prof_var_t* var, int level) +{ + +} +*/ + +void View3D::DrawProf(void) +{ + // FIXME: unimplemented +} + +void View3D::PrintSound(int channel, const char *name, float vol, int rvol, float pitch, float base, int& line) +{ + char buf[255]; + float x; + float xStep; + float height; + + height = m_font->getHeight(getHighResScale()); + xStep = height; + + x = 0; + Com_sprintf(buf, sizeof(buf), "%d", channel); + m_font->Print(x, height * line + m_frame.pos.y, buf, -1, getHighResScale()); + + x += xStep + xStep; + Com_sprintf(buf, sizeof(buf), "%s", name); + m_font->Print(x, height * line + m_frame.pos.y, buf, -1, getHighResScale()); + + x += xStep * 30.0; + Com_sprintf(buf, sizeof(buf), "vol:%.2f", vol); + m_font->Print(x, height * line + m_frame.pos.y, buf, -1, getHighResScale()); + + x += xStep * 8; + Com_sprintf(buf, sizeof(buf), "rvol:%.2f", (float)(rvol / 128.f)); + m_font->Print(x, height * line + m_frame.pos.y, buf, -1, getHighResScale()); + + x += xStep * 5; + Com_sprintf(buf, sizeof(buf), "pit:%.2f", pitch); + m_font->Print(x, height * line + m_frame.pos.y, buf, -1, getHighResScale()); + + x += xStep * 5; + Com_sprintf(buf, sizeof(buf), "base:%d", (int)base); + m_font->Print(x, height * line + m_frame.pos.y, buf, -1, getHighResScale()); + + line++; +} + +void View3D::DrawSoundOverlay(void) +{ + setFont("verdana-14"); + m_font->setColor(UWhite); + + // FIXME: Unimplemented + if (sound_overlay->integer) { + Com_Printf("sound_overlay isn't supported with OpenAL/SDL right now.\n"); + Cvar_Set("sound_overlay", "0"); + } +} + +void DisplayServerNetProfileInfo(UIFont *font, float y, netprofclient_t *netprofile) +{ + font->Print(104, y, va("%i", netprofile->inPackets.packetsPerSec)); + font->Print(144, y, va("%i", netprofile->outPackets.packetsPerSec)); + font->Print(184, y, va("%i", netprofile->inPackets.packetsPerSec + netprofile->outPackets.packetsPerSec)); + font->Print(234, y, va("%i", netprofile->inPackets.percentFragmented)); + font->Print(264, y, va("%i", netprofile->outPackets.percentFragmented)); + font->Print( + 294, + y, + va("%i", + (unsigned int)((float)(netprofile->outPackets.numFragmented + netprofile->inPackets.numFragmented) + / (float)(netprofile->inPackets.totalProcessed + netprofile->outPackets.totalProcessed) + )), + -1 + ); + font->Print(334, y, va("%i", netprofile->inPackets.percentDropped)); + font->Print(364, y, va("%i", netprofile->outPackets.percentDropped)); + font->Print( + 394, + y, + va("%i", + (unsigned int)((float)(netprofile->outPackets.numDropped + netprofile->inPackets.numDropped) + / (float)(netprofile->inPackets.totalProcessed + netprofile->outPackets.totalProcessed) + )), + -1 + ); + font->Print(434, y, va("%i", netprofile->inPackets.percentDropped)); + font->Print(464, y, va("%i", netprofile->outPackets.percentDropped)); + font->Print( + 494, + y, + va("%i", + (unsigned int)((float)(netprofile->outPackets.totalLengthConnectionLess + + netprofile->inPackets.totalLengthConnectionLess) + / (float)(netprofile->outPackets.totalSize + netprofile->inPackets.totalSize))), + -1 + ); + font->Print(534, y, va("%i", netprofile->inPackets.bytesPerSec)); + font->Print(594, y, va("%i", netprofile->outPackets.bytesPerSec)); + font->Print(654, y, va("%i", netprofile->outPackets.bytesPerSec + netprofile->inPackets.bytesPerSec)); + font->Print(714, y, va("%i", netprofile->rate)); +} + +void DisplayClientNetProfile(UIFont *font, float x, float y, netprofclient_t *netprofile) +{ + float columns[5]; + float fontHeight; + float columnHeight; + + fontHeight = font->getHeight(); + columns[0] = x + 120; + columns[1] = x + 230; + columns[2] = x + 330; + columns[3] = x + 430; + columns[4] = x + 530; + columnHeight = y; + + font->Print(x, y, va("Rate: %i", netprofile->rate)); + + columnHeight += fontHeight * 1.5; + font->Print(x, columnHeight, "Data Type"); + font->Print(columns[0], columnHeight, "Packets per Sec"); + font->Print(columns[1], columnHeight, "% Fragmented"); + font->Print(columns[2], columnHeight, "% Dropped"); + font->Print(columns[3], columnHeight, "% OOB data"); + font->Print(columns[4], columnHeight, "Data per Sec"); + + columnHeight += fontHeight * 0.5; + font->Print(x, columnHeight, "----------"); + font->Print(columns[0], columnHeight, "----------"); + font->Print(columns[1], columnHeight, "----------"); + font->Print(columns[2], columnHeight, "----------"); + font->Print(columns[3], columnHeight, "----------"); + font->Print(columns[4], columnHeight, "----------"); + + columnHeight += fontHeight; + font->Print(x, columnHeight, "Data In"); + font->Print(columns[0], columnHeight, va("%i", netprofile->outPackets.packetsPerSec)); + font->Print(columns[1], columnHeight, va("%i%%", netprofile->outPackets.percentFragmented)); + font->Print(columns[2], columnHeight, va("%i%%", netprofile->outPackets.percentDropped)); + font->Print(columns[3], columnHeight, va("%i%%", netprofile->outPackets.percentConnectionLess)); + font->Print(columns[4], columnHeight, va("%i", netprofile->outPackets.bytesPerSec)); + + columnHeight += fontHeight; + font->Print(x, columnHeight, "Data Out"); + font->Print(columns[0], columnHeight, va("%i", netprofile->inPackets.packetsPerSec)); + font->Print(columns[1], columnHeight, va("%i%%", netprofile->inPackets.percentFragmented)); + font->Print(columns[2], columnHeight, va("%i%%", netprofile->inPackets.percentDropped)); + font->Print(columns[3], columnHeight, va("%i%%", netprofile->inPackets.percentConnectionLess)); + font->Print(columns[4], columnHeight, va("%i", netprofile->inPackets.bytesPerSec)); + + columnHeight += fontHeight; + + font->Print(x, columnHeight, "Total Data"); + + font->Print( + columns[0], + columnHeight, + va("%i", netprofile->inPackets.packetsPerSec + netprofile->outPackets.packetsPerSec) + ); + font->Print( + columns[1], + columnHeight, + va("%i%%", + (unsigned int)((float)(netprofile->outPackets.numFragmented + netprofile->inPackets.numFragmented) + / (float)(netprofile->inPackets.totalProcessed + netprofile->outPackets.totalProcessed) + )) + ); + font->Print( + columns[2], + columnHeight, + va("%i%%", + (unsigned int)((float)(netprofile->outPackets.numDropped + netprofile->inPackets.numDropped) + / (double)(netprofile->inPackets.totalProcessed + netprofile->outPackets.totalProcessed + ))) + ); + font->Print( + columns[3], + columnHeight, + va("%i%%", + (unsigned int)((float)(netprofile->outPackets.totalLengthConnectionLess + + netprofile->inPackets.totalLengthConnectionLess) + / (float)(netprofile->outPackets.totalSize + netprofile->inPackets.totalSize))) + ); + font->Print( + columns[4], + columnHeight, + va("%i", netprofile->inPackets.bytesPerSec + netprofile->outPackets.bytesPerSec) + ); +} + +void View3D::DrawNetProfile(void) +{ + float fontHeight; + float yOffset; + int i; + + if (sv_netprofileoverlay->integer && sv_netprofile->integer && com_sv_running->integer) { + float columnHeight; + float valueHeight; + float separatorHeight; + float categoryHeight; + float currentHeight; + netprofclient_t netproftotal; + + setFont("verdana-14"); + m_font->setColor(UWhite); + + fontHeight = m_font->getHeight(); + yOffset = sv_netprofileoverlay->integer + 8; + + if (svs.netprofile.rate) { + m_font->Print(8, yOffset, va("Server Net Profile Max Rate: %i", svs.netprofile.rate), -1); + } else { + m_font->Print(8, yOffset, "Server Net Profile Max Rate: none", -1); + } + + columnHeight = fontHeight + fontHeight + yOffset; + valueHeight = columnHeight + fontHeight; + separatorHeight = fontHeight * 1.5 + columnHeight; + categoryHeight = fontHeight * 0.5 + columnHeight; + + m_font->Print(8, categoryHeight, "Data Source"); + m_font->Print(8, separatorHeight, "---------------"); + m_font->Print(104, columnHeight, "Packets per Sec"); + m_font->Print(104, valueHeight, "In"); + m_font->Print(144, valueHeight, "Out"); + m_font->Print(184, valueHeight, "Total"); + m_font->Print(104, separatorHeight, "---"); + m_font->Print(144, separatorHeight, "-----"); + m_font->Print(184, separatorHeight, "------"); + m_font->Print(234, columnHeight, "% Fragmented"); + m_font->Print(234, valueHeight, "In"); + m_font->Print(264, valueHeight, "Out"); + m_font->Print(294, valueHeight, "Total"); + m_font->Print(234, separatorHeight, "---"); + m_font->Print(264, separatorHeight, "-----"); + m_font->Print(294, separatorHeight, "------"); + m_font->Print(334, columnHeight, "% Dropped"); + m_font->Print(334, valueHeight, "In"); + m_font->Print(364, valueHeight, "Out"); + m_font->Print(394, valueHeight, "Total"); + m_font->Print(334, separatorHeight, "---"); + m_font->Print(364, separatorHeight, "-----"); + m_font->Print(394, separatorHeight, "------"); + m_font->Print(434, columnHeight, "% OOB Data"); + m_font->Print(434, valueHeight, "In"); + m_font->Print(464, valueHeight, "Out"); + m_font->Print(494, valueHeight, "Total"); + m_font->Print(434, separatorHeight, "---"); + m_font->Print(464, separatorHeight, "-----"); + m_font->Print(494, separatorHeight, "------"); + m_font->Print(534, columnHeight, "Data per Sec"); + m_font->Print(534, valueHeight, "In"); + m_font->Print(594, valueHeight, "Out"); + m_font->Print(654, valueHeight, "Total"); + m_font->Print(534, separatorHeight, "---"); + m_font->Print(594, separatorHeight, "-----"); + m_font->Print(654, separatorHeight, "------"); + m_font->Print(714, categoryHeight, "Rate"); + m_font->Print(714, separatorHeight, "------"); + + currentHeight = fontHeight * 2.5 + columnHeight; + SV_NET_CalcTotalNetProfile(&netproftotal, qfalse); + m_font->Print(8, columnHeight + fontHeight * 2.5, "Total"); + DisplayServerNetProfileInfo(m_font, currentHeight, &netproftotal); + + currentHeight += fontHeight * 1.5; + m_font->Print(8, currentHeight, "Clientless"); + DisplayServerNetProfileInfo(m_font, currentHeight, &svs.netprofile); + + currentHeight += fontHeight; + + for (i = 0; i < svs.iNumClients; i++) { + client_t *client = &svs.clients[i]; + if (client->state != CS_ACTIVE || !client->gentity) { + continue; + } + + if (client->netchan.remoteAddress.type == NA_LOOPBACK) { + m_font->Print(8.0, currentHeight, va("#%i-Loopback", i), -1, 0); + + } else { + m_font->Print(8.0, currentHeight, va("Client #%i", i), -1, 0); + } + + DisplayServerNetProfileInfo(m_font, currentHeight, &client->netprofile); + currentHeight = currentHeight + fontHeight; + } + } else if (cl_netprofileoverlay->integer && cl_netprofile->integer && com_cl_running->integer) { + setFont("verdana-14"); + m_font->setColor(UWhite); + + fontHeight = m_font->getHeight(); + yOffset = cl_netprofileoverlay->integer + 16; + + m_font->Print(16, yOffset, "Client Net Profile", -1); + + NetProfileCalcStats(&cls.netprofile.outPackets, 500); + NetProfileCalcStats(&cls.netprofile.inPackets, 500); + + DisplayClientNetProfile(m_font, 16, yOffset + fontHeight * 2, &cls.netprofile); + } +} + void View3D::Draw2D(void) { if (!cls.no_menus) { @@ -494,6 +519,7 @@ void View3D::Draw2D(void) if (!cls.no_menus) { DrawSoundOverlay(); + DrawNetProfile(); DrawSubtitleOverlay(); } } @@ -504,24 +530,6 @@ void View3D::Draw2D(void) } } -void View3D::Draw(void) -{ - if (clc.state != CA_DISCONNECTED) { - SCR_DrawScreenField(); - } - - set2D(); - - re.SavePerformanceCounters(); - - Draw2D(); -} - -void View3D::ClearCenterPrint(void) -{ - m_printfadetime = 0.0; -} - void View3D::CenterPrint(void) { float alpha; @@ -556,7 +564,7 @@ void View3D::CenterPrint(void) m_iFontAlignmentHorizontal, m_iFontAlignmentVertical, p, - m_bVirtual ? m_vVirtualScale : NULL + getVirtualScale() ); m_font->setColor(UColor(1, 1, 1, alpha)); @@ -564,7 +572,7 @@ void View3D::CenterPrint(void) frame = getClientFrame(); m_font->PrintJustified( - frame, m_iFontAlignmentHorizontal, m_iFontAlignmentVertical, p, m_bVirtual ? m_vVirtualScale : NULL + frame, m_iFontAlignmentHorizontal, m_iFontAlignmentVertical, p, getVirtualScale() ); m_font->setColor(UBlack); @@ -588,6 +596,275 @@ void View3D::CenterPrint(void) } } +void View3D::LocationPrint(void) +{ + fonthorzjustify_t horiz; + fontvertjustify_t vert; + int x, y; + const char *p; + float alpha; + UIRect2D frame; + + if (!m_printfadetime) { + m_locationprint = false; + return; + } + + horiz = FONT_JUSTHORZ_LEFT; + vert = FONT_JUSTVERT_TOP; + + p = Sys_LV_CL_ConvertString(m_printstring); + if (m_printfadetime > 3250) { + alpha = 1.f - (m_printfadetime - 3250.f) / 750.f * m_printalpha; + } else if (m_printfadetime >= 750) { + alpha = 1.f; + } else { + alpha = m_printfadetime / 750.f * m_printalpha; + } + + alpha = Q_clamp_float(alpha, 0, 1); + + x = m_x_coord / 640.f * m_screenframe.size.width; + y = (480 - m_font->getHeight(getHighResScale()) - m_y_coord) / 480.f * m_screenframe.size.height; + + if (m_x_coord == -1) { + horiz = FONT_JUSTHORZ_CENTER; + x = 0; + } + if (m_y_coord == -1) { + vert = FONT_JUSTVERT_CENTER; + y = 0; + } + + m_font->setColor(UColor(0, 0, 0, alpha)); + frame = getClientFrame(); + + m_font->PrintJustified( + UIRect2D(frame.pos.x + x + 1, frame.pos.y + y + 1, frame.size.width, frame.size.height), + horiz, + vert, + p, + getVirtualScale() + ); + + m_font->setColor(UColor(1, 1, 1, alpha)); + frame = getClientFrame(); + + m_font->PrintJustified( + UIRect2D(frame.pos.x + x, frame.pos.y + y, frame.size.width, frame.size.height), + horiz, + vert, + p, + getVirtualScale() + ); + + m_font->setColor(UBlack); + m_printfadetime -= cls.frametime; + + if (m_printfadetime < 0) { + m_printfadetime = 0; + } +} + +void View3D::DrawLetterbox(void) +{ + float frac; + vec4_t col; + + col[0] = col[1] = col[2] = 0; + col[3] = 1; + + frac = (float)cl.snap.ps.stats[STAT_LETTERBOX] / MAX_LETTERBOX_SIZE; + if (frac <= 0) { + m_letterbox_active = false; + return; + } + + m_letterbox_active = true; + re.SetColor(col); + + re.DrawBox(0.0, 0.0, m_screenframe.size.width, m_screenframe.size.height * frac); + re.DrawBox( + 0.0, + m_screenframe.size.height - m_screenframe.size.height * frac, + m_screenframe.size.width, + m_screenframe.size.height + ); +} + +void View3D::DrawFades(void) +{ + if (cl.snap.ps.blend[3] > 0) { + re.SetColor(cl.snap.ps.blend); + if (cl.snap.ps.stats[STAT_ADDFADE]) { + re.AddBox(0.0, 0.0, m_screenframe.size.width, m_screenframe.size.height); + } else { + re.DrawBox(0.0, 0.0, m_screenframe.size.width, m_screenframe.size.height); + } + } +} + +void View3D::Draw(void) +{ + if (clc.state != CA_DISCONNECTED) { + SCR_DrawScreenField(); + } + + set2D(); + + re.SavePerformanceCounters(); + + Draw2D(); +} + +float avWidth = 0.0; + +void View3D::InitSubtitle(void) +{ + float totalWidth; + + for (int i = 0; i < 4; i++) { + subs[i] = Cvar_Get(va("subtitle%d", i), "", 0); + teams[i] = Cvar_Get(va("subteam%d", i), "0", 0); + Q_strncpyz(oldStrings[i], subs[i]->string, sizeof(oldStrings[i])); + fadeTime[i] = 4000.0; + subLife[i] = 4000.0; + } + + totalWidth = 0.0; + for (char j = 'A'; j <= 'Z'; j++) { + totalWidth += m_font->getCharWidth(j); + } + + avWidth = totalWidth / 26.0; +} + +void View3D::DrawSubtitleOverlay(void) +{ + cvar_t *subAlpha; + int i; + float minX, maxX; + int line; + + subAlpha = Cvar_Get("subAlpha", "0.5", 0); + + setFont("facfont-20"); + m_font->setColor(URed); + + for (i = 0; i < MAX_SUBTITLES; i++) { + if (strcmp(oldStrings[i], subs[i]->string)) { + fadeTime[i] = 2500 * ((strlen(subs[i]->string) / 68) + 1.f) + 1500; + subLife[i] = fadeTime[i]; + Q_strncpyz(oldStrings[i], subs[i]->string, sizeof(oldStrings[i])); + } + + if (fadeTime[i] > subLife[i] - 750.f) { + alpha[i] = 1.f - (fadeTime[i] - (subLife[i] - 750.f)) / 750.f; + } else if (fadeTime[i] < 750) { + alpha[i] = fadeTime[i] / 750.f; + } else { + alpha[i] = 1.f; + } + + fadeTime[i] -= cls.frametime; + if (fadeTime[i] < 0) { + // Clear the subtitle + fadeTime[i] = 0; + oldStrings[i][0] = 0; + + if (subs[i]->string && subs[i]->string[0]) { + Cvar_Set(va("subtitle%d", i), ""); + } + } + } + + minX = m_screenframe.size.height - m_font->getHeight(getHighResScale()) * 10; + maxX = ((m_frame.pos.x + m_frame.size.width) - (m_frame.pos.x + m_frame.size.width) * 0.2f) / getHighResScale()[0]; + line = 0; + + for (i = 0; i < MAX_SUBTITLES; i++) { + if (fadeTime[i] <= 0) { + continue; + } + + if (m_font->getWidth(subs[i]->string, sizeof(oldStrings[i])) > maxX) { + char buf[2048]; + char *c; + char *end; + char *start; + float total; + float width; + int blockcount; + + c = subs[i]->string; + + total = 0; + end = NULL; + start = buf; + + while (*c) { + blockcount = m_font->DBCSGetWordBlockCount(c, -1); + if (!blockcount) { + break; + } + + width = m_font->getWidth(c, blockcount); + + if (total + width > maxX) { + m_font->setColor(UColor(0, 0, 0, alpha[i] * subAlpha->value)); + m_font->Print(18, (m_font->getHeight(getHighResScale()) * line + minX + 1.f) / getHighResScale()[1], buf, -1, getHighResScale()); + + m_font->setColor(UColor(1, 1, 1, alpha[i] * subAlpha->value)); + m_font->Print(20, (m_font->getHeight(getHighResScale()) * line + minX) / getHighResScale()[1], buf, -1, getHighResScale()); + + line++; + + total = 0; + start = buf; + } + + end = start + blockcount + 1; + if (end > buf + MAX_STRING_CHARS) { + Com_DPrintf("ERROR - word longer than possible line\n"); + break; + } + + memcpy(start, c, blockcount); + start += blockcount; + total += width; + *start = 0; + + c += blockcount; + } + + m_font->setColor(UColor(0, 0, 0, alpha[i] * subAlpha->value)); + m_font->Print(18, (m_font->getHeight(getHighResScale()) * line + minX + 1.f) / getHighResScale()[1], buf, -1, getHighResScale()); + + m_font->setColor(UColor(1, 1, 1, alpha[i] * subAlpha->value)); + m_font->Print(20, (m_font->getHeight(getHighResScale()) * line + minX) / getHighResScale()[1], buf, -1, getHighResScale()); + line++; + } else { + m_font->setColor(UColor(0, 0, 0, alpha[i] * subAlpha->value)); + m_font->Print(18, (m_font->getHeight(getHighResScale()) * line + minX + 1.f) / getHighResScale()[1], subs[i]->string, -1, getHighResScale()); + + m_font->setColor(UColor(1, 1, 1, alpha[i] * subAlpha->value)); + m_font->Print(20, (m_font->getHeight(getHighResScale()) * line + minX) / getHighResScale()[1], subs[i]->string, -1, getHighResScale()); + + line++; + } + } +} + +void View3D::ClearCenterPrint(void) +{ + m_printfadetime = 0.0; +} + +qboolean View3D::LetterboxActive(void) +{ + return m_letterbox_active; +} + CLASS_DECLARATION(UIWidget, ConsoleView, NULL) { {NULL, NULL} }; diff --git a/code/client/cl_uiview3d.h b/code/client/cl_uiview3d.h index fc908a9f..ef11c986 100644 --- a/code/client/cl_uiview3d.h +++ b/code/client/cl_uiview3d.h @@ -51,6 +51,9 @@ protected: void OnDeactivate(Event *ev); void DrawSubtitleOverlay(void); + // Added in 2.0 + void DrawNetProfile(void); + public: View3D(); diff --git a/code/client/client.h b/code/client/client.h index 6fe6eed4..c693fbe8 100644 --- a/code/client/client.h +++ b/code/client/client.h @@ -36,6 +36,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "cl_curl.h" #endif /* USE_CURL */ +#ifdef USE_VOIP +#include +#endif + // file full of random crap that gets used to create cl_guid #define QKEY_FILE "qkey" #define QKEY_SIZE 2048 @@ -174,6 +178,7 @@ typedef struct { int lastPacketSentTime; // for retransmits during connection int lastPacketTime; // for timeouts + char servername[MAX_OSPATH]; // name of server from original connect (used by reconnect) netadr_t serverAddress; int connectTime; // for connection retransmits int connectStartTime; @@ -239,15 +244,42 @@ typedef struct { int timeDemoMaxDuration; // maximum frame duration unsigned char timeDemoDurations[ MAX_TIMEDEMO_DURATIONS ]; // log of frame durations + float aviVideoFrameRemainder; + float aviSoundFrameRemainder; + +#ifdef USE_VOIP + qboolean voipEnabled; + qboolean voipCodecInitialized; + + // incoming data... + // !!! FIXME: convert from parallel arrays to array of a struct. + OpusDecoder *opusDecoder[MAX_CLIENTS]; + byte voipIncomingGeneration[MAX_CLIENTS]; + int voipIncomingSequence[MAX_CLIENTS]; + float voipGain[MAX_CLIENTS]; + qboolean voipIgnore[MAX_CLIENTS]; + qboolean voipMuteAll; + + // outgoing data... + // if voipTargets[i / 8] & (1 << (i % 8)), + // then we are sending to clientnum i. + uint8_t voipTargets[(MAX_CLIENTS + 7) / 8]; + uint8_t voipFlags; + OpusEncoder *opusEncoder; + int voipOutgoingDataSize; + int voipOutgoingDataFrames; + int voipOutgoingSequence; + byte voipOutgoingGeneration; + byte voipOutgoingData[1024]; + float voipPower; +#endif + #ifdef LEGACY_PROTOCOL qboolean compat; #endif // big stuff at end of structure so most offsets are 15 bits or less netchan_t netchan; - - float aviVideoFrameRemainder; - float aviSoundFrameRemainder; } clientConnection_t; extern clientConnection_t clc; @@ -297,8 +329,6 @@ typedef struct { qboolean cddialog; // bring up the cd needed dialog next frame qboolean no_menus; - char servername[MAX_OSPATH]; // name of server from original connect (used by reconnect) - // when the server clears the hunk, all of these must be restarted qboolean rendererRegistered; qboolean cgameStarted; @@ -353,12 +383,14 @@ typedef struct { void* savedCgameState; size_t savedCgameStateSize; char gcdResponse[73]; - int unknown3_0; - int currentRate; + // Added in 2.0 + netprofclient_t netprofile; qhandle_t charSetShader; qhandle_t whiteShader; qhandle_t consoleShader; fontInfo_t consoleFont; + + int refSequence; } clientStatic_t; extern clientStatic_t cls; @@ -385,6 +417,8 @@ extern cvar_t *cl_connect_timeout; extern cvar_t *cl_maxpackets; extern cvar_t *cl_packetdup; extern cvar_t *cl_shownet; +extern cvar_t *cl_netprofile; +extern cvar_t *cl_netprofileoverlay; extern cvar_t *cl_showSend; extern cvar_t *cl_timeNudge; extern cvar_t *cl_showTimeDelta; @@ -445,6 +479,32 @@ extern cvar_t *cl_r_fullscreen; extern cvar_t *cl_consoleKeys; +#ifdef USE_MUMBLE +extern cvar_t *cl_useMumble; +extern cvar_t *cl_mumbleScale; +#endif + +#ifdef USE_VOIP +// cl_voipSendTarget is a string: "all" to broadcast to everyone, "none" to +// send to no one, or a comma-separated list of client numbers: +// "0,7,2,23" ... an empty string is treated like "all". +extern cvar_t *cl_voipUseVAD; +extern cvar_t *cl_voipVADThreshold; +extern cvar_t *cl_voipSend; +extern cvar_t *cl_voipSendTarget; +extern cvar_t *cl_voipGainDuringCapture; +extern cvar_t *cl_voipCaptureMult; +extern cvar_t *cl_voipShowMeter; +extern cvar_t *cl_voip; + +// 20ms at 48k +#define VOIP_MAX_FRAME_SAMPLES ( 20 * 48 ) + +// 3 frame is 60ms of audio, the max opus will encode at once +#define VOIP_MAX_PACKET_FRAMES 3 +#define VOIP_MAX_PACKET_SAMPLES ( VOIP_MAX_FRAME_SAMPLES * VOIP_MAX_PACKET_FRAMES ) +#endif + extern cvar_t *cg_gametype; extern cvar_t* j_pitch; @@ -499,6 +559,10 @@ void UI_LoadResource( const char *name ); qboolean CL_CheckPaused(void); +int CL_GetRefSequence(void); +qboolean CL_IsRendererLoaded(void); +void CL_ApplyOriginalConfigTweaks(); + // // cl_input // @@ -520,6 +584,7 @@ void IN_MouseOn( void ); void IN_MouseOff( void ); void CL_InitInput (void); +void CL_ShutdownInput(void); void CL_SendCmd (void); void CL_ClearState (void); void CL_ReadPackets (void); @@ -545,6 +610,10 @@ extern int cl_connectedToPureServer; extern int cl_connectedToCheatServer; extern msg_t *cl_currentMSG; +#ifdef USE_VOIP +void CL_Voip_f( void ); +#endif + void CL_SystemInfoChanged( void ); void CL_ParseServerMessage( msg_t *msg ); @@ -583,6 +652,7 @@ void Con_DrawCharacter (int cx, int line, int num); void Con_CheckResize (void); void Con_Init (void); +void Con_Shutdown (void); void Con_Clear_f (void); void Con_ToggleConsole_f (void); void Con_DrawNotify (void); @@ -670,6 +740,7 @@ void LAN_SaveServersToCache( void ); void CL_Netchan_Transmit( netchan_t *chan, msg_t* msg); //int length, const byte *data ); void CL_Netchan_TransmitNextFragment( netchan_t *chan ); qboolean CL_Netchan_Process( netchan_t *chan, msg_t *msg ); +void CL_NET_OutOfBandPrint( netadr_t adr, const char* format, ... ); // // cl_avi.c diff --git a/code/client/new/snd_local_new.h b/code/client/new/snd_local_new.h index 1f336208..69ae7dcf 100644 --- a/code/client/new/snd_local_new.h +++ b/code/client/new/snd_local_new.h @@ -59,6 +59,9 @@ typedef struct { void S_ChannelFree_Callback(channel_t* v); void S_LoadData(soundsystemsavegame_t* pSave); void S_SaveData(soundsystemsavegame_t* pSave); +void S_ReLoad(soundsystemsavegame_t* pSave); + +extern qboolean s_bSoundPaused; #ifdef __cplusplus } diff --git a/code/client/new/snd_main_new.cpp b/code/client/new/snd_main_new.cpp index 3490119d..2bb4aa37 100644 --- a/code/client/new/snd_main_new.cpp +++ b/code/client/new/snd_main_new.cpp @@ -21,8 +21,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "../snd_local.h" +#include "../client.h" -#if !defined(USE_SOUND_NEW) || !USE_SOUND_NEW +#if defined(NO_MODERN_DMA) && NO_MODERN_DMA + +qboolean s_bSoundPaused = qfalse; void S_Init2() { @@ -32,6 +35,10 @@ void S_Init2() // HACK: S_RegisterSound returns 0 when unsuccessful, or it returns the the sfx handle // But the first sfx handle is also 0... S_RegisterSound("sound/null.wav", qfalse); + + Cmd_AddCommand("tmstart", S_TriggeredMusic_Start); + Cmd_AddCommand("tmstartloop", S_TriggeredMusic_StartLoop); + Cmd_AddCommand("tmstop", S_TriggeredMusic_Stop); } /* @@ -52,7 +59,18 @@ S_AddLoopingSound */ void S_AddLoopingSound(const vec3_t origin, const vec3_t velocity, sfxHandle_t sfxHandle, float volume, float minDist, float maxDist, float pitch, int flags) { + if (!sfxHandle) { + return; + } + // FIXME: unimplemented + + if (VectorCompare(origin, vec3_origin)) { + // Consider it to be a local sound, uses the player origin + S_AddLoopingSound(cl.snap.ps.clientNum, cl.snap.ps.origin, velocity, sfxHandle); + return; + } + S_AddLoopingSound(ENTITYNUM_WORLD, origin, velocity, sfxHandle); } @@ -363,6 +381,16 @@ void MUSIC_CheckForStoppedSongs(void) STUB(); } +/* +============== +S_CurrentSoundtrack +============== +*/ +const char* S_CurrentSoundtrack() +{ + return ""; +} + /* ================= S_IsSoundRegistered @@ -427,28 +455,166 @@ void S_FadeSound(float fTime) // FIXME: unimplemented } +/* +============== +S_TriggeredMusic_Start +============== +*/ +void S_TriggeredMusic_Start() +{ + if (Cmd_Argc() != 2) { + Com_Printf("tmstart \n"); + return; + } + + S_StartBackgroundTrack(Cmd_Argv(1), ""); +} + +/* +============== +S_TriggeredMusic_StartLoop +============== +*/ +void S_TriggeredMusic_StartLoop() +{ + if (Cmd_Argc() != 2) { + Com_Printf("tmstartloop \n"); + return; + } + + S_StartBackgroundTrack(Cmd_Argv(1), Cmd_Argv(1)); +} + +/* +============== +S_TriggeredMusic_Stop +============== +*/ +void S_TriggeredMusic_Stop() +{ + S_StopBackgroundTrack(); +} + +/* +============== +S_TriggeredMusic_PlayIntroMusic +============== +*/ void S_TriggeredMusic_PlayIntroMusic() { + S_StartBackgroundTrack("sound/music/mus_MainTheme.mp3", ""); +} + +/* +============== +S_TriggeredMusic_SetupHandle +============== +*/ +void S_TriggeredMusic_SetupHandle(const char* pszName, int iLoopCount, int iOffset, qboolean autostart) { // FIXME: unimplemented } +/* +============== +S_GetMusicFilename +============== +*/ +const char* S_GetMusicFilename() { + // FIXME: unimplemented + return ""; +} + +/* +============== +S_GetMusicLoopCount +============== +*/ +int S_GetMusicLoopCount() { + // FIXME: unimplemented + return 0; +} + +/* +============== +S_GetMusicOffset +============== +*/ +unsigned int S_GetMusicOffset() { + // FIXME: unimplemented + return 0; +} + +/* +============== +callbackServer +============== +*/ void callbackServer(int entnum, int channel_number, const char* name) { if (com_sv_running->integer) { SV_SoundCallback(entnum, channel_number, name); } } +/* +============== +S_ChannelFree_Callback +============== +*/ void S_ChannelFree_Callback(channel_t* v) { if (v->entnum & S_FLAG_DO_CALLBACK) { callbackServer(v->entnum & ~S_FLAG_DO_CALLBACK, v - s_channels, v->thesfx->soundName); } } +/* +============== +S_LoadData +============== +*/ void S_LoadData(soundsystemsavegame_t* pSave) { // FIXME: unimplemented } +/* +============== +S_SaveData +============== +*/ void S_SaveData(soundsystemsavegame_t* pSave) { // FIXME: unimplemented } +/* +============== +S_ReLoad +============== +*/ +void S_ReLoad(soundsystemsavegame_t* pSave) { + // FIXME: unimplemented +} + +/* +============== +S_StopMovieAudio +============== +*/ +void S_StopMovieAudio() { +} + +/* +============== +S_CurrentMoviePosition +============== +*/ +int S_CurrentMoviePosition() { + return 0; +} + +/* +============== +S_SetupMovieAudio +============== +*/ +void S_SetupMovieAudio(const char* pszMovieName) { +} + #endif diff --git a/code/client/new/snd_public_new.h b/code/client/new/snd_public_new.h index 0b298c01..4b98fb86 100644 --- a/code/client/new/snd_public_new.h +++ b/code/client/new/snd_public_new.h @@ -64,6 +64,12 @@ qboolean MUSIC_PlaySong(const char* alias); void MUSIC_UpdateMusicVolumes(void); void MUSIC_CheckForStoppedSongs(void); +void S_TriggeredMusic_Start(); +void S_TriggeredMusic_StartLoop(); +void S_TriggeredMusic_Stop(); + +const char* S_CurrentSoundtrack(); + void S_StopSound(int entnum, int channel); void S_StopAllSounds2(qboolean stop_music); float S_GetSoundTime(sfxHandle_t handle); @@ -74,6 +80,15 @@ qboolean S_IsSoundPlaying(int channelNumber, const char* name); void S_UpdateEntity(int entityNum, const vec3_t origin, const vec3_t velocity, qboolean use_listener); void S_FadeSound(float fTime); void S_TriggeredMusic_PlayIntroMusic(); +void S_TriggeredMusic_SetupHandle(const char* pszName, int iLoopCount, int iOffset, qboolean autostart); + +const char* S_GetMusicFilename(); +int S_GetMusicLoopCount(); +unsigned int S_GetMusicOffset(); + +void S_StopMovieAudio(); +int S_CurrentMoviePosition(); +void S_SetupMovieAudio(const char* pszMovieName); #ifdef __cplusplus } diff --git a/code/client/qal.c b/code/client/qal.c index 5cc40de2..78e0b80e 100644 --- a/code/client/qal.c +++ b/code/client/qal.c @@ -66,6 +66,7 @@ LPALGETSOURCEF qalGetSourcef; LPALGETSOURCE3F qalGetSource3f; LPALGETSOURCEFV qalGetSourcefv; LPALGETSOURCEI qalGetSourcei; +LPALGETSOURCEIV qalGetSourceiv; LPALSOURCEPLAYV qalSourcePlayv; LPALSOURCESTOPV qalSourceStopv; LPALSOURCEREWINDV qalSourceRewindv; @@ -80,7 +81,9 @@ LPALGENBUFFERS qalGenBuffers; LPALDELETEBUFFERS qalDeleteBuffers; LPALISBUFFER qalIsBuffer; LPALBUFFERDATA qalBufferData; +LPALBUFFERI qalBufferi; LPALGETBUFFERF qalGetBufferf; +LPALGETBUFFERFV qalGetBufferfv; LPALGETBUFFERI qalGetBufferi; LPALDOPPLERFACTOR qalDopplerFactor; LPALSPEEDOFSOUND qalSpeedOfSound; @@ -184,6 +187,7 @@ qboolean QAL_Init(const char *libname) qalGetSource3f = GPA("alGetSource3f"); qalGetSourcefv = GPA("alGetSourcefv"); qalGetSourcei = GPA("alGetSourcei"); + qalGetSourceiv = GPA("alGetSourceiv"); qalSourcePlayv = GPA("alSourcePlayv"); qalSourceStopv = GPA("alSourceStopv"); qalSourceRewindv = GPA("alSourceRewindv"); @@ -198,7 +202,9 @@ qboolean QAL_Init(const char *libname) qalDeleteBuffers = GPA("alDeleteBuffers"); qalIsBuffer = GPA("alIsBuffer"); qalBufferData = GPA("alBufferData"); + qalBufferi = GPA("alBufferi"); qalGetBufferf = GPA("alGetBufferf"); + qalGetBufferfv = GPA("alGetBufferfv"); qalGetBufferi = GPA("alGetBufferi"); qalDopplerFactor = GPA("alDopplerFactor"); qalSpeedOfSound = GPA("alSpeedOfSound"); @@ -283,6 +289,7 @@ void QAL_Shutdown( void ) qalGetSource3f = NULL; qalGetSourcefv = NULL; qalGetSourcei = NULL; + qalGetSourceiv = NULL; qalSourcePlayv = NULL; qalSourceStopv = NULL; qalSourceRewindv = NULL; @@ -298,6 +305,7 @@ void QAL_Shutdown( void ) qalIsBuffer = NULL; qalBufferData = NULL; qalGetBufferf = NULL; + qalGetBufferfv = NULL; qalGetBufferi = NULL; qalDopplerFactor = NULL; qalSpeedOfSound = NULL; diff --git a/code/client/qal.h b/code/client/qal.h index a478eb53..c676b195 100644 --- a/code/client/qal.h +++ b/code/client/qal.h @@ -36,15 +36,18 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #ifdef USE_LOCAL_HEADERS #include "../AL/al.h" #include "../AL/alc.h" +#include "../AL/alext.h" #else #if defined(_MSC_VER) || defined(__APPLE__) // MSVC users must install the OpenAL SDK which doesn't use the AL/*.h scheme. // OSX framework also needs this #include #include + #include #else #include #include + #include #endif #endif @@ -55,6 +58,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # define ALC_ALL_DEVICES_SPECIFIER 0x1013 #endif +#ifdef __cplusplus +extern "C" { +#endif + #ifdef USE_OPENAL_DLOPEN extern LPALENABLE qalEnable; extern LPALDISABLE qalDisable; @@ -116,7 +123,7 @@ extern LPALBUFFERDATA qalBufferData; extern LPALBUFFERF qalBufferf; extern LPALBUFFER3F qalBuffer3f; extern LPALBUFFERFV qalBufferfv; -extern LPALBUFFERF qalBufferi; +extern LPALBUFFERI qalBufferi; extern LPALBUFFER3F qalBuffer3i; extern LPALBUFFERFV qalBufferiv; extern LPALGETBUFFERF qalGetBufferf; @@ -248,4 +255,8 @@ extern LPALCCAPTURESAMPLES qalcCaptureSamples; qboolean QAL_Init(const char *libname); void QAL_Shutdown( void ); +#ifdef __cplusplus +} +#endif + #endif // __QAL_H__ diff --git a/code/client/snd_codec.h b/code/client/snd_codec.h index 49970dff..8551827d 100644 --- a/code/client/snd_codec.h +++ b/code/client/snd_codec.h @@ -27,14 +27,19 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "../qcommon/q_shared.h" #include "../qcommon/qcommon.h" +#ifdef __cplusplus +extern "C" { +#endif + typedef struct snd_info_s { int rate; - int width; + float width; int channels; int samples; int size; int dataofs; + int dataalign; } snd_info_t; typedef struct snd_codec_s snd_codec_t; @@ -113,4 +118,8 @@ void S_OggOpus_CodecCloseStream(snd_stream_t *stream); int S_OggOpus_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer); #endif // USE_CODEC_OPUS +#ifdef __cplusplus +} +#endif + #endif // !_SND_CODEC_H_ diff --git a/code/client/snd_codec_mp3.c b/code/client/snd_codec_mp3.c index 80a02326..bcb60e60 100644 --- a/code/client/snd_codec_mp3.c +++ b/code/client/snd_codec_mp3.c @@ -31,7 +31,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "snd_codec.h" // includes for the MP3 codec -#include "../libmad-0.15.1b/synth.h" +#include "mad.h" #define MP3_SAMPLE_WIDTH 2 #define MP3_PCMSAMPLES_PERSLICE 32 @@ -622,7 +622,7 @@ int S_MP3_CodecReadStream(snd_stream_t* stream, int bytes, void* buffer) mp3info = stream->ptr; // Make sure we get complete frames all the way through. - bytes -= bytes % (stream->info.channels * stream->info.width); + bytes -= fmod(bytes, (stream->info.channels * stream->info.width)); if (mp3info->buflen) { diff --git a/code/client/snd_codec_wav.c b/code/client/snd_codec_wav.c index 7fcdea59..7fed9bf3 100644 --- a/code/client/snd_codec_wav.c +++ b/code/client/snd_codec_wav.c @@ -133,6 +133,7 @@ static qboolean S_ReadRIFFHeader(fileHandle_t file, snd_info_t *info) char dump[16]; int bits; int fmtlen = 0; + int bytealign; // skip the riff wav header FS_Read(dump, 12, file); @@ -149,17 +150,22 @@ static qboolean S_ReadRIFFHeader(fileHandle_t file, snd_info_t *info) info->channels = FGetLittleShort(file); info->rate = FGetLittleLong(file); FGetLittleLong(file); - FGetLittleShort(file); + bytealign = FGetLittleShort(file); bits = FGetLittleShort(file); - if( bits < 8 ) - { - Com_Printf( S_COLOR_RED "ERROR: Less than 8 bit sound is not supported\n"); - return qfalse; - } + //if( bits < 8 ) + //{ + // Com_Printf( S_COLOR_RED "ERROR: Less than 8 bit sound is not supported\n"); + // return qfalse; + //} - info->width = bits / 8; + info->width = bits / 8.0; info->dataofs = 0; + if (bits == 16) { + info->dataalign = 1; + } else { + info->dataalign = (bytealign / info->channels - 4) / 4 * 8 + 1; + } // Skip the rest of the format chunk if required if(fmtlen > 16) diff --git a/code/client/snd_dma.c b/code/client/snd_dma.c index dd0fbfca..cfb0ca28 100644 --- a/code/client/snd_dma.c +++ b/code/client/snd_dma.c @@ -161,12 +161,12 @@ void S_Base_SoundList( void ) { char type[4][16]; char mem[2][16]; - strcpy(type[0], "16bit"); - strcpy(type[1], "adpcm"); - strcpy(type[2], "daub4"); - strcpy(type[3], "mulaw"); - strcpy(mem[0], "paged out"); - strcpy(mem[1], "resident "); + Q_strncpyz(type[0], "16bit", sizeof(type[0])); + Q_strncpyz(type[1], "adpcm", sizeof(type[1])); + Q_strncpyz(type[2], "daub4", sizeof(type[2])); + Q_strncpyz(type[3], "mulaw", sizeof(type[3])); + Q_strncpyz(mem[0], "paged out", sizeof(mem[0])); + Q_strncpyz(mem[1], "resident ", sizeof(mem[1])); total = 0; for (sfx=s_knownSfx, i=0 ; isoundLength; @@ -303,7 +303,7 @@ static sfx_t *S_FindName( const char *name ) { sfx = &s_knownSfx[i]; Com_Memset (sfx, 0, sizeof(*sfx)); - strcpy (sfx->soundName, name); + Q_strncpyz (sfx->soundName, name, sizeof(sfx->soundName)); sfx->next = sfxHash[hash]; sfxHash[hash] = sfx; @@ -785,7 +785,11 @@ void S_Base_AddLoopingSound( int entityNum, const vec3_t origin, const vec3_t ve } if ( !sfx->soundLength ) { - Com_Error( ERR_DROP, "%s has length 0", sfx->soundName ); + // Fixed in OPM + // Why should it crash??? + //Com_Error( ERR_DROP, "%s has length 0", sfx->soundName ); + Com_Printf( "%s has length 0\n", sfx->soundName ); + return; } VectorCopy( origin, loopSounds[entityNum].origin ); @@ -848,7 +852,11 @@ void S_Base_AddRealLoopingSound( int entityNum, const vec3_t origin, const vec3_ } if ( !sfx->soundLength ) { - Com_Error( ERR_DROP, "%s has length 0", sfx->soundName ); + // Fixed in OPM + // Why should it crash??? + //Com_Error( ERR_DROP, "%s has length 0", sfx->soundName ); + Com_Printf( "%s has length 0", sfx->soundName ); + return; } VectorCopy( origin, loopSounds[entityNum].origin ); VectorCopy( velocity, loopSounds[entityNum].velocity ); diff --git a/code/client/snd_dma_new.cpp b/code/client/snd_dma_new.cpp index f08bb524..47fb79eb 100644 --- a/code/client/snd_dma_new.cpp +++ b/code/client/snd_dma_new.cpp @@ -20,10 +20,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -#if USE_SOUND_NEW - #include "snd_local.h" #include "snd_openal_new.h" +#include "client.h" +#include "cl_ui.h" typedef struct { vec3_t origin; @@ -32,10 +32,6 @@ typedef struct { int mergeFrame; } loopSound_t; -# define MAX_SFX 1400 -# define MAX_SFX_INFOS 1000 -# define MAX_LOOP_SOUNDS 64 - qboolean s_bLastInitSound = qfalse; qboolean s_bSoundStarted = qfalse; qboolean s_bSoundPaused = qfalse; @@ -70,81 +66,412 @@ cvar_t *s_dialogscale; int numLoopSounds; loopSound_t loopSounds[MAX_LOOP_SOUNDS]; +/* +============== +S_SoundInfo_f +============== +*/ void S_SoundInfo_f() { - // FIXME: unimplemented + S_PrintInfo(); } +/* +============== +S_SoundDump_f +============== +*/ void S_SoundDump_f() { - // FIXME: unimplemented + S_DumpInfo(); } +/* +============== +S_Init +============== +*/ void S_Init(qboolean full_startup) { - // FIXME: unimplemented + int iStart, iEnd; + cvar_t *cv; + + Com_Printf("------- Sound Initialization (%s) -------\n", full_startup ? "full" : "partial"); + + iStart = Sys_Milliseconds(); + + s_volume = Cvar_Get("s_volume", "0.9", CVAR_ARCHIVE); + s_musicVolume = Cvar_Get("s_musicvolume", "0.9", CVAR_ARCHIVE); + s_ambientVolume = Cvar_Get("s_ambientvolume", "1.00", CVAR_ARCHIVE); + s_separation = Cvar_Get("s_separation", "0.5", CVAR_ARCHIVE); + s_khz = Cvar_Get("s_khz", "44", CVAR_ARCHIVE | CVAR_SOUND_LATCH); + s_loadas8bit = Cvar_Get("s_loadas8bit", "0", CVAR_ARCHIVE | CVAR_LATCH); + s_mixPreStep = Cvar_Get("s_mixPreStep", "0.05", CVAR_ARCHIVE); + s_show = Cvar_Get("s_show", "0", CVAR_CHEAT); + s_testsound = Cvar_Get("s_testsound", "0", CVAR_CHEAT); + s_dialogscale = Cvar_Get("s_dialogscale", "1", CVAR_ARCHIVE); + s_bLastInitSound = false; + + cv = Cvar_Get("s_initsound", "1", 0); + + if (cv->integer) { + Cmd_AddCommand("play", S_Play); + Cmd_AddCommand("soundlist", S_SoundList); + Cmd_AddCommand("soundinfo", S_SoundInfo_f); + Cmd_AddCommand("sounddump", S_SoundDump_f); + + if (S_Driver_Init()) { + s_bLastInitSound = true; + s_bSoundStarted = true; + + if (full_startup) { + s_numSfx = 0; + S_StopAllSounds(true); + } + + S_FindName("***DEFAULT***", -1); + S_SoundInfo_f(); + } + } else { + Com_Printf("Sound Not Initializing.\n"); + s_bSoundStarted = 0; + } + + iEnd = Sys_Milliseconds(); + Com_Printf("------- Sound Initialization Complete ------- %i ms\n", iEnd - iStart); } +/* +============== +S_Shutdown +============== +*/ void S_Shutdown(qboolean full_shutdown) { - // FIXME: unimplemented + int i; + sfx_t *sfx; + + if (!s_bSoundStarted) { + return; + } + + Com_Printf("------- Sound Shutdown (%s) -------\n", full_shutdown ? "full" : "partial"); + + S_Driver_Shutdown(); + s_bSoundStarted = false; + + Cmd_RemoveCommand("play"); + Cmd_RemoveCommand("music"); + Cmd_RemoveCommand("stopsound"); + Cmd_RemoveCommand("soundlist"); + Cmd_RemoveCommand("soundinfo"); + + if (full_shutdown) { + for (i = 0; i < s_numSfx; i++) { + sfx = &s_knownSfx[i]; + + if (sfx->name[0]) { + if (sfx->data) { + Z_Free(sfx->data); + } + + *sfx = {}; + } + } + + s_numSfx = 0; + } + + Com_Printf("------- Sound Shutdown Complete -------\n"); } +/* +============== +S_NameExists +============== +*/ qboolean S_NameExists(const char *name) { - // FIXME: unimplemented + int i; + + if (strlen(name) >= MAX_RES_NAME) { + Com_DPrintf("Sound name too long: %s", name); + return qfalse; + } + + for (i = 0; i < s_numSfx; i++) { + if (!strcmp(s_knownSfx[i].name, name)) { + return qtrue; + } + } + return qfalse; } +/* +============== +S_FindName +============== +*/ sfx_t *S_FindName(const char *name, int sequenceNumber) { - // FIXME: unimplemented - return NULL; + int i; + sfx_t *sfx; + + if (!name) { + Com_DPrintf("S_FindName: NULL\n"); + return NULL; + } + + if (!name[0]) { + Com_DPrintf("S_FindName: empty name\n"); + return NULL; + } + + if (strlen(name) >= MAX_RES_NAME) { + Com_DPrintf("Sound name too long: %s", name); + return NULL; + } + + for (i = 0; i < s_numSfx; i++) { + sfx = &s_knownSfx[i]; + + if (!strcmp(sfx->name, name)) { + if (sfx->registration_sequence != -1) { + sfx->registration_sequence = sequenceNumber; + } + + return sfx; + } + } + + sfx = &s_knownSfx[0]; + + for (i = 0; i < s_numSfx; i++) { + sfx = &s_knownSfx[i]; + if (!sfx->name[0]) { + break; + } + } + + if (i == s_numSfx) { + if (i == MAX_SFX) { + Com_Error(ERR_FATAL, "S_FindName: out of sfx_t"); + } + + sfx = &s_knownSfx[s_numSfx]; + s_numSfx++; + } + + *sfx = {}; + // Fixed in OPM + // strcpy was used before + //strcpy(sfx->name, name); + Q_strncpyz(sfx->name, name, sizeof(sfx->name)); + sfx->registration_sequence = sequenceNumber; + + return sfx; } +/* +============== +S_BeginRegistration +============== +*/ void S_BeginRegistration() { - // FIXME: unimplemented + int i; + + Com_Printf("------- Sound Begin Registration -------\n"); + + S_StopAllSounds(true); + + s_registrationSequence++; + s_inRegistration = true; + s_knownSfx[0].registration_sequence = s_registrationSequence; + + Com_Printf("------- Sound Begin Registration Complete -------\n"); + + // Added in OPM + // Reset all sound entities + // OG doesn't do this but this makes sure + // entities don't leak info from previous sessions + for (i = 0; i < ARRAY_LEN(s_entity); i++) { + s_entity[i] = s_entity_t{}; + } } +/* +============== +S_DefaultSound +============== +*/ void S_DefaultSound(sfx_t *sfx) { - // FIXME: unimplemented + sfx->data = NULL; + sfx->iFlags |= SFX_FLAG_DEFAULT_SOUND; } +/* +============== +S_IsSoundRegistered +============== +*/ qboolean S_IsSoundRegistered(const char *name) { - // FIXME: unimplemented - return qfalse; + char szCacheName[MAX_QPATH]; + int i; + + if (!s_bSoundStarted) { + return qfalse; + } + + for (i = 0; name[i] && i < MAX_QPATH; i++) { + szCacheName[i] = tolower(name[i]); + } + szCacheName[i] = 0; + + if (i >= MAX_QPATH) { + Com_Printf("Sound name exceeds MAX_QPATH\n"); + return qfalse; + } + + return S_NameExists(szCacheName); } +/* +============== +S_RegisterSound +============== +*/ sfxHandle_t S_RegisterSound(const char *name, int streamed, qboolean force_load) { - // FIXME: unimplemented - return 0; + char szCacheName[MAX_QPATH]; + sfx_t *sfx; + int i; + + if (!s_bSoundStarted) { + Com_Printf("ERROR: Trying to register sound %s when soundsystem hasn't started.\n", name); + return 0; + } + + if (!name) { + return 0; + } + + for (i = 0; name[i] && i < MAX_QPATH; i++) { + szCacheName[i] = tolower(name[i]); + } + szCacheName[i] = 0; + + if (i >= MAX_QPATH) { + Com_Printf("Sound name exceeds MAX_QPATH\n"); + return 0; + } + + sfx = S_FindName(szCacheName, s_registrationSequence); + if (!sfx) { + return 0; + } + + if (!sfx->data) { + if (!S_LoadSound(sfx->name, sfx, streamed, force_load)) { + Com_DPrintf("Couldn't load sound: %s\n", sfx->name); + if (!S_LoadSound("sound/default.wav", sfx, streamed, 0)) { + Com_DPrintf("Couldn't load sound: sound/default.wav\n"); + sfx->iFlags |= SFX_FLAG_DEFAULT_SOUND; + return 0; + } + } + + sfx->iFlags &= ~SFX_FLAG_DEFAULT_SOUND; + sfx->sfx_info_index = 0; + + for (i = 0; i < number_of_sfx_infos; i++) { + if (!Q_stricmp(sfx->name, sfx_infos[i].name)) { + sfx->sfx_info_index = i; + break; + } + } + } + + return sfx - s_knownSfx; } +/* +============== +S_GetSoundTime +============== +*/ float S_GetSoundTime(sfxHandle_t handle) { - // FIXME: unimplemented - return 0; + return s_knownSfx[handle].time_length; } +/* +============== +S_EndRegistration +============== +*/ void S_EndRegistration() { - // FIXME: unimplemented + int i; + sfx_t *sfx; + + Com_Printf("------- Sound End Registration -------\n"); + s_inRegistration = qfalse; + + for (i = 0; i < s_numSfx; i++) { + sfx = &s_knownSfx[i]; + + if (!sfx->name[0]) { + continue; + } + + if (sfx->registration_sequence && sfx->registration_sequence != s_registrationSequence) { + if (sfx->data) { + Z_Free(sfx->data); + } + + *sfx = {}; + } + } + + Com_Printf("------- Sound End Registration Complete -------\n"); } +/* +============== +S_UpdateEntity +============== +*/ void S_UpdateEntity(int entityNum, const vec3_t origin, const vec3_t vel, qboolean use_listener) { - // FIXME: unimplemented + if (entityNum > MAX_GENTITIES) { + Com_Error(ERR_DROP, "S_UpdateEntityPosition: bad entitynum %i", entityNum); + } + + VectorCopy(origin, s_entity[entityNum].position); + VectorCopy(vel, s_entity[entityNum].velocity); + s_entity[entityNum].use_listener = use_listener; + s_entity[entityNum].time = cl.serverTime; } +/* +============== +S_SetGlobalAmbientVolumeLevel +============== +*/ void S_SetGlobalAmbientVolumeLevel(float volume) { - // FIXME: unimplemented + s_fAmbientVolume = volume; } +/* +============== +S_StartSound +============== +*/ void S_StartSound( const vec3_t origin, int entnum, @@ -157,29 +484,171 @@ void S_StartSound( int streamed ) { - // FIXME: unimplemented + if (s_show_sounds->integer > 0 && sfxHandle > 0 && sfxHandle < s_numSfx) { + Com_DPrintf("S_StartSound: %s\n", s_knownSfx[sfxHandle].name); + } + + if (!s_bSoundStarted) { + if (s_show_sounds->integer > 0) { + Com_DPrintf("^~^~^ sound system not yet started\n"); + } + return; + } + + if (server_loading) { + if (s_show_sounds->integer > 0) { + Com_DPrintf("^~^~^ cannot start sounds while loading a server\n"); + } + return; + } + + if (sfxHandle < 0 || sfxHandle >= s_numSfx) { + Com_Error(ERR_DROP, "S_StartSound: handle %i out of range", sfxHandle); + } + + if (!sfxHandle) { + if (s_show_sounds->integer > 0) { + Com_DPrintf("^~^~^ null handle\n"); + } + return; + } + + if (entnum && (entchannel == CHAN_DIALOG || entchannel == CHAN_DIALOG_SECONDARY) && s_dialogscale->value > 0) { + volume *= s_dialogscale->value; + } + + S_Driver_StartSound(origin, entnum, entchannel, sfxHandle, volume, min_dist, pitch, maxDist, streamed); } +/* +============== +S_StartLocalSound +============== +*/ void S_StartLocalSound(const char *sound_name, qboolean force_load) { - // FIXME: unimplemented + sfxHandle_t sfxHandle; + const char *name; + AliasListNode_t *pSoundAlias = NULL; + + if (!s_bSoundStarted) { + return; + } + + if (!sound_name) { + return; + } + + name = Alias_FindRandom(sound_name, &pSoundAlias); + if (!name) { + name = sound_name; + } + + sfxHandle = S_RegisterSound(name, pSoundAlias ? pSoundAlias->streamed : qfalse, force_load); + + if (!pSoundAlias) { + S_StartSound(NULL, s_iListenerNumber, CHAN_MENU, sfxHandle, -1.0, -1.0, 1.0, -1.0, qfalse); + return; + } + + S_StartSound( + NULL, + s_iListenerNumber, + CHAN_MENU, + sfxHandle, + pSoundAlias->volume + random() * pSoundAlias->volumeMod, + -1.0, + pSoundAlias->pitch + random() * pSoundAlias->pitchMod, + pSoundAlias->maxDist, + pSoundAlias->streamed + ); } +/* +============== +S_StartLocalSoundChannel + +Added in 2.0 +Starts a local sound, with the specified channel +============== +*/ void S_StartLocalSoundChannel(const char *sound_name, qboolean force_load, soundChannel_t channel) { - // FIXME: unimplemented + sfxHandle_t sfxHandle; + const char *name; + AliasListNode_t *pSoundAlias = NULL; + + if (!s_bSoundStarted) { + return; + } + + if (!sound_name) { + return; + } + + name = Alias_FindRandom(sound_name, &pSoundAlias); + if (!name) { + name = sound_name; + } + + sfxHandle = S_RegisterSound(name, pSoundAlias ? pSoundAlias->streamed : qfalse, force_load); + + if (!pSoundAlias) { + S_StartSound(NULL, s_iListenerNumber, channel, sfxHandle, -1.0, -1.0, 1.0, -1.0, qfalse); + return; + } + + S_StartSound( + 0, + s_iListenerNumber, + channel, + sfxHandle, + pSoundAlias->volume + random() * pSoundAlias->volumeMod, + -1.0, + pSoundAlias->pitch + random() * pSoundAlias->pitchMod, + pSoundAlias->maxDist, + pSoundAlias->streamed + ); } +/* +============== +S_StopAllSounds +============== +*/ void S_StopAllSounds(qboolean stop_music) { - // FIXME: unimplemented + if (!s_bSoundStarted) { + return; + } + + Com_Printf("------- S_StopAllSounds (%s) -------\n", stop_music ? "stop music" : "don't stop music"); + + // Tell the driver to stop all sounds + S_Driver_StopAllSounds(stop_music); + + Com_Printf("------- S_StopAllSounds Complete-------\n"); } +/* +============== +S_ClearLoopingSounds +============== +*/ void S_ClearLoopingSounds() { - // FIXME: unimplemented + if (!s_bSoundStarted) { + return; + } + + S_Driver_ClearLoopingSounds(); } +/* +============== +S_AddLoopingSound +============== +*/ void S_AddLoopingSound( const vec3_t origin, const vec3_t velocity, @@ -191,42 +660,171 @@ void S_AddLoopingSound( int flags ) { - // FIXME: unimplemented + if (!s_bSoundStarted) { + return; + } + + if (sfxHandle < 0 || sfxHandle >= s_numSfx) { + Com_Error(ERR_DROP, "S_AddLoopingSound: handle %i out of range", sfxHandle); + } + + if (!sfxHandle) { + return; + } + + S_Driver_AddLoopingSound(origin, velocity, sfxHandle, volume, min_dist, max_dist, pitch, flags); } +/* +============== +S_Respatialize +============== +*/ void S_Respatialize(int entityNum, const vec3_t head, vec3_t axis[3]) { - // FIXME: unimplemented + if (!s_bSoundStarted) { + return; + } + + S_Driver_Respatialize(entityNum, head, axis); } +/* +============== +S_Update +============== +*/ void S_Update() { - // FIXME: unimplemented + if (!s_bSoundStarted) { + return; + } + + if (server_loading) { + return; + } + + S_Driver_Update(); } +/* +============== +S_StopSound +============== +*/ void S_StopSound(int entnum, int channel) { - // FIXME: unimplemented + if (!s_bSoundStarted) { + return; + } + + if (channel == CHAN_AUTO) { + return; + } + + S_Driver_StopSound(entnum, channel); } +/* +============== +S_SetReverb +============== +*/ void S_SetReverb(int reverb_type, float reverb_level) { - // FIXME: unimplemented + if (!s_bSoundStarted) { + return; + } + + S_Driver_SetReverb(reverb_type, reverb_level); } +/* +============== +S_Play +============== +*/ void S_Play() { - // FIXME: unimplemented + int i; + char name[MAX_QPATH]; + + if (Cmd_Argc() < 2) { + return; + } + + for (i = 1; i < Cmd_Argc(); i++) { + if (strrchr(Cmd_Argv(i), '.')) { + Q_strncpyz(name, Cmd_Argv(i), sizeof(name)); + } else { + Com_sprintf(name, sizeof(name), "%s.wav", Cmd_Argv(1)); + } + } + + S_StartLocalSound(name, qfalse); } +/* +============== +S_SoundList +============== +*/ void S_SoundList() { - // FIXME: unimplemented + int i; + sfx_t *sfx; + int size; + int total = 0; + + for (i = 0; i < s_numSfx; i++) { + sfx = &s_knownSfx[i]; + + if (sfx->registration_sequence) { + size = sfx->length * sfx->width; + total += size; + Com_Printf("(%2db) %6i : %s\n", sfx->width * 8, size, sfx->name); + } + } + + Com_Printf("Total resident: %i\n", total); } +/* +============== +S_ClearSoundBuffer +============== +*/ void S_ClearSoundBuffer() { // TODO: Remove once AL is fully implemented } -#endif +/* +============== +S_GetMusicFilename +============== +*/ +const char* S_GetMusicFilename() +{ + return S_Driver_GetMusicFilename(); +} + +/* +============== +S_GetMusicLoopCount +============== +*/ +int S_GetMusicLoopCount() +{ + return S_Driver_GetMusicLoopCount(); +} + +/* +============== +S_GetMusicOffset +============== +*/ +unsigned int S_GetMusicOffset() +{ + return S_Driver_GetMusicOffset(); +} diff --git a/code/client/snd_info.cpp b/code/client/snd_info.cpp new file mode 100644 index 00000000..0d994107 --- /dev/null +++ b/code/client/snd_info.cpp @@ -0,0 +1,95 @@ +/* +=========================================================================== +Copyright (C) 2024 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA source code 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. + +OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "snd_local.h" +#include "../qcommon/tiki.h" + +void load_sfx_info() +{ + TikiScript tiki; + const char *token; + int current_sound_file; + char file_name[MAX_QPATH]; + + sfx_infos[0].name[0] = 0; + sfx_infos[0].max_factor = -1.0; + sfx_infos[0].loop_start = -1; + sfx_infos[0].loop_end = -1; + sfx_infos[0].max_number_playing = DEFAULT_SFX_NUMBER_PLAYING; + number_of_sfx_infos = 1; + + for (current_sound_file = 0; current_sound_file < 10; current_sound_file++) { + Com_sprintf(file_name, sizeof(file_name), "global/sound%d.txt", current_sound_file); + + if (!tiki.LoadFile(file_name, qtrue)) { + continue; + } + + Com_Printf("Loading %s\n", file_name); + + while (tiki.TokenAvailable(qtrue)) { + token = tiki.GetToken(qtrue); + + if (!Q_stricmp(token, "sound")) { + if (tiki.TokenAvailable(qtrue)) { + token = tiki.GetToken(qtrue); + + if (number_of_sfx_infos == 1000) { + Com_DPrintf("Too many sound infos specified\n"); + break; + } + + Q_strncpyz(sfx_infos[number_of_sfx_infos].name, token, sizeof(sfx_infos[number_of_sfx_infos].name)); + sfx_infos[number_of_sfx_infos].max_factor = -1.f; + sfx_infos[number_of_sfx_infos].loop_start = -1; + sfx_infos[number_of_sfx_infos].loop_end = -1; + sfx_infos[number_of_sfx_infos].max_number_playing = DEFAULT_SFX_NUMBER_PLAYING; + number_of_sfx_infos++; + } + } else if (!Q_stricmp(token, "loopstart")) { + if (!tiki.TokenAvailable(qtrue)) { + token = tiki.GetToken(qtrue); + sfx_infos[number_of_sfx_infos - 1].loop_start = atoi(token); + } + } else if (!Q_stricmp(token, "loopend")) { + if (!tiki.TokenAvailable(qtrue)) { + token = tiki.GetToken(qtrue); + sfx_infos[number_of_sfx_infos - 1].loop_end = atoi(token); + } + } else if (!Q_stricmp(token, "maxnumber")) { + if (!tiki.TokenAvailable(qtrue)) { + token = tiki.GetToken(qtrue); + sfx_infos[number_of_sfx_infos - 1].max_number_playing = atoi(token); + } + } else if (!Q_stricmp(token, "maxfactor")) { + if (!tiki.TokenAvailable(qtrue)) { + token = tiki.GetToken(qtrue); + sfx_infos[number_of_sfx_infos - 1].max_factor = atoi(token); + } + } + } + } + + tiki.Close(); + + sfx_infos[0].name[0] = 0; +} diff --git a/code/client/snd_local.h b/code/client/snd_local.h index e0ec8609..04c6ba9f 100644 --- a/code/client/snd_local.h +++ b/code/client/snd_local.h @@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "../qcommon/qcommon.h" #include "snd_public.h" -#if !defined(USE_SOUND_NEW) || !USE_SOUND_NEW +#if defined(NO_MODERN_DMA) && NO_MODERN_DMA #define PAINTBUFFER_SIZE 4096 // this is in samples diff --git a/code/client/snd_local_new.h b/code/client/snd_local_new.h index 8707f56c..877df120 100644 --- a/code/client/snd_local_new.h +++ b/code/client/snd_local_new.h @@ -29,6 +29,29 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA extern "C" { #endif +extern cvar_t *s_volume; +extern cvar_t *s_khz; +extern cvar_t *s_loadas8bit; +extern cvar_t *s_separation; +extern cvar_t *s_musicVolume; +extern cvar_t *s_ambientVolume; + +#define MAX_SOUNDSYSTEM_CHANNELS_3D 32 +#define MAX_SOUNDSYSTEM_CHANNELS_2D 32 +#define MAX_SOUNDSYSTEM_CHANNELS_2D_STREAM 32 +#define MAX_SOUNDSYSTEM_POSITION_CHANNELS (MAX_SOUNDSYSTEM_CHANNELS_3D + MAX_SOUNDSYSTEM_CHANNELS_2D + MAX_SOUNDSYSTEM_CHANNELS_2D_STREAM) +#define MAX_SOUNDSYSTEM_SONGS 2 +#define MAX_SOUNDSYSTEM_MISC_CHANNELS 3 +#define MAX_SOUNDSYSTEM_CHANNELS \ + (MAX_SOUNDSYSTEM_CHANNELS_3D + MAX_SOUNDSYSTEM_CHANNELS_2D + MAX_SOUNDSYSTEM_CHANNELS_2D_STREAM + MAX_SOUNDSYSTEM_SONGS \ + + MAX_SOUNDSYSTEM_MISC_CHANNELS) +#define MAX_SOUNDSYSTEM_LOOP_SOUNDS 64 + +#define SOUNDSYSTEM_CHANNEL_MP3_ID \ + (MAX_SOUNDSYSTEM_CHANNELS_3D + MAX_SOUNDSYSTEM_CHANNELS_2D + MAX_SOUNDSYSTEM_CHANNELS_2D_STREAM + MAX_SOUNDSYSTEM_SONGS) +#define SOUNDSYSTEM_CHANNEL_TRIGGER_MUSIC_ID (SOUNDSYSTEM_CHANNEL_MP3_ID + 1) +#define SOUNDSYSTEM_CHANNEL_MOVIE_ID (SOUNDSYSTEM_CHANNEL_TRIGGER_MUSIC_ID + 1) + typedef struct { int format; float rate; @@ -39,6 +62,7 @@ typedef struct { int dataofs; int datasize; + int dataalign; } wavinfo_t; typedef struct sfx_s { @@ -127,13 +151,61 @@ typedef struct { } channelbasesavegame_t; typedef struct { - channelbasesavegame_t Channels[96]; + channelbasesavegame_t Channels[MAX_SOUNDSYSTEM_CHANNELS]; } soundsystemsavegame_t; +enum channel_flags_t { + CHANNEL_FLAG_PLAY_DEFERRED = 1, + CHANNEL_FLAG_LOCAL_LISTENER = 16, + CHANNEL_FLAG_NO_ENTITY = 32, + CHANNEL_FLAG_PAUSED = 64, + CHANNEL_FLAG_LOOPING = 128, + // Added in OPM + CHANNEL_FLAG_MISSING_ENT = 256, +}; + +enum sfx_flags_t { + SFX_FLAG_DEFAULT_SOUND = 1, + SFX_FLAG_MP3 = 2, + SFX_FLAG_STREAMED = 4, + SFX_FLAG_NO_OFFSET = 8, + SFX_FLAG_NULL = 16, +}; + +enum loopsound_flags_t { + LOOPSOUND_FLAG_NO_PAN = 1 +}; + +#define MAX_SFX 1400 +#define MAX_SFX_INFOS 1000 +#define MAX_LOOP_SOUNDS 64 +#define DEFAULT_SFX_NUMBER_PLAYING 10 //5 + +extern qboolean s_bLastInitSound; +extern qboolean s_bSoundStarted; +extern qboolean s_bSoundPaused; +extern qboolean s_bTryUnpause; +extern int s_iListenerNumber; +extern float s_fAmbientVolume; +extern int number_of_sfx_infos; +extern sfx_info_t sfx_infos[]; +extern sfx_t s_knownSfx[]; +extern int s_numSfx; +extern s_entity_t s_entity[]; + // The current sound driver. // Currently OPENAL #define SOUND_DRIVER OPENAL +// +// snd_info.cpp +// +void load_sfx_info(); + +// +// snd_dma_new.cpp +// + sfx_t *S_FindName(const char *name, int sequenceNumber); void S_DefaultSound(sfx_t *sfx); @@ -141,6 +213,11 @@ void S_LoadData(soundsystemsavegame_t *pSave); void S_SaveData(soundsystemsavegame_t *pSave); void S_ClearSoundBuffer(); +// +// snd_mem.c +// +qboolean S_LoadSound(const char *fileName, sfx_t *sfx, int streamed, qboolean force_load); + #define S_StopAllSounds2 S_StopAllSounds // @@ -150,6 +227,7 @@ void S_ClearSoundBuffer(); #define S_Call_SndDriverX(driver, func) S_Call_SndDriver(driver, func) #define S_Driver_Init S_Call_SndDriverX(SOUND_DRIVER, Init) +#define S_Driver_Shutdown S_Call_SndDriverX(SOUND_DRIVER, Shutdown) #define S_Driver_StartSound S_Call_SndDriverX(SOUND_DRIVER, StartSound) #define S_Driver_AddLoopingSound S_Call_SndDriverX(SOUND_DRIVER, AddLoopingSound) #define S_Driver_ClearLoopingSounds S_Call_SndDriverX(SOUND_DRIVER, ClearLoopingSounds) @@ -158,6 +236,16 @@ void S_ClearSoundBuffer(); #define S_Driver_Respatialize S_Call_SndDriverX(SOUND_DRIVER, Respatialize) #define S_Driver_SetReverb S_Call_SndDriverX(SOUND_DRIVER, SetReverb) #define S_Driver_Update S_Call_SndDriverX(SOUND_DRIVER, Update) +#define S_Driver_GetMusicFilename S_Call_SndDriverX(SOUND_DRIVER, GetMusicFilename) +#define S_Driver_GetMusicLoopCount S_Call_SndDriverX(SOUND_DRIVER, GetMusicLoopCount) +#define S_Driver_GetMusicOffset S_Call_SndDriverX(SOUND_DRIVER, GetMusicOffset) + +void S_PrintInfo(); +void S_DumpInfo(); +qboolean S_NeedFullRestart(); +void S_ReLoad(soundsystemsavegame_t* pSave); + +extern cvar_t *s_show_sounds; #ifdef __cplusplus } diff --git a/code/client/snd_mem_new.cpp b/code/client/snd_mem_new.cpp new file mode 100644 index 00000000..0bf2dd63 --- /dev/null +++ b/code/client/snd_mem_new.cpp @@ -0,0 +1,566 @@ +/* +=========================================================================== +Copyright (C) 2024 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA source code 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. + +OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "snd_local.h" +#include "cl_ui.h" + +byte *data_p; +byte *iff_end; +byte *last_chunk; +byte *iff_data; +int iff_chunk_len; + +qboolean S_LoadMP3(const char *fileName, sfx_t *sfx); + +/* +============== +GetLittleShort +============== +*/ +short int GetLittleShort() +{ + union { + short value; + byte bytes[2]; + } val; + +#ifdef Q3_LITTLE_ENDIAN + val.bytes[0] = data_p[0]; + val.bytes[1] = data_p[1]; +#else + val.bytes[0] = data_p[1]; + val.bytes[1] = data_p[0]; +#endif + + data_p += sizeof(short); + return val.value; +} + +/* +============== +GetLittleLong +============== +*/ +int GetLittleLong() +{ + union { + int value; + byte bytes[4]; + } val; + +#ifdef Q3_LITTLE_ENDIAN + val.bytes[0] = data_p[0]; + val.bytes[1] = data_p[1]; + val.bytes[2] = data_p[2]; + val.bytes[3] = data_p[3]; +#else + val.bytes[0] = data_p[3]; + val.bytes[1] = data_p[2]; + val.bytes[2] = data_p[1]; + val.bytes[3] = data_p[0]; +#endif + + data_p += sizeof(int); + return val.value; +} + +/* +============== +SetLittleShort +============== +*/ +void SetLittleShort(int i) +{ + union { + short value; + byte bytes[2]; + } val; + + val.value = i; + +#ifdef Q3_LITTLE_ENDIAN + data_p[0] = val.bytes[0]; + data_p[1] = val.bytes[1]; +#else + data_p[0] = val.bytes[1]; + data_p[1] = val.bytes[0]; +#endif + + data_p += sizeof(short); +} + +/* +============== +SetLittleLong +============== +*/ +void SetLittleLong(int i) +{ + union { + int value; + byte bytes[4]; + } val; + + val.value = i; + +#ifdef Q3_LITTLE_ENDIAN + data_p[0] = val.bytes[0]; + data_p[1] = val.bytes[1]; + data_p[2] = val.bytes[2]; + data_p[3] = val.bytes[3]; +#else + data_p[0] = val.bytes[3]; + data_p[1] = val.bytes[2]; + data_p[2] = val.bytes[1]; + data_p[3] = val.bytes[0]; +#endif + + data_p += sizeof(int); +} + +/* +============== +FindNextChunk +============== +*/ +void FindNextChunk(const char *name) +{ + int value; + + while (1) { + data_p = last_chunk; + + if (last_chunk >= (byte *)iff_end) { + break; + } + + data_p = last_chunk + 4; + value = GetLittleLong(); + + iff_chunk_len = value; + if (value < 0) { + break; + } + + data_p -= 8; + value++; + value &= ~1; + + last_chunk = data_p + value + 8; + if (!strncmp((const char *)data_p, name, 4u)) { + return; + } + } + + data_p = NULL; +} + +/* +============== +FindChunk +============== +*/ +void FindChunk(const char *name) +{ + last_chunk = iff_data; + FindNextChunk(name); +} + +/* +============== +DumpChunks +============== +*/ +void DumpChunks() +{ + char str[5]; + + str[4] = 0; + + data_p = iff_data; + do { + memcpy(str, data_p, 4); + data_p += 4; + + iff_chunk_len = GetLittleLong(); + + Com_Printf("0x%p : %s (%d)\n", data_p - 4, str, iff_chunk_len); + + data_p += (iff_chunk_len + 1) & ~1; + } while (data_p < (byte *)iff_end); +} + +/* +============== +GetWavinfo +============== +*/ +wavinfo_t GetWavinfo(const char *name, byte *wav, int wavlength) +{ + wavinfo_t info; + int samples; + short bytealign; + + memset(&info, 0, sizeof(wavinfo_t)); + + if (!wav) { + return info; + } + + iff_data = wav; + iff_end = &wav[wavlength]; + FindChunk("RIFF"); + + if (!data_p || strncmp((const char *)data_p + 8, "WAVE", 4u)) { + Com_Printf("Missing RIFF/WAVE chunks\n"); + return info; + } + + iff_data = data_p + 12; + FindChunk("fmt "); + if (!data_p) { + Com_Printf("Missing fmt chunk\n"); + return info; + } + + data_p += 8; + + info.format = GetLittleShort(); + if (info.format == 17) { + info.channels = GetLittleShort(); + info.rate = (float)GetLittleLong(); + data_p += 4; + + bytealign = GetLittleShort(); + info.width = (float)GetLittleShort() / 8.f; + data_p += 2; + + FindChunk("data"); + if (!data_p) { + Com_Printf("Missing data chunk\n"); + return info; + } + + data_p += 4; + if (info.width >= 1.0) { + samples = (int)((float)GetLittleLong() / info.width); + } else { + samples = (int)((float)GetLittleLong() * info.width); + } + + if (!info.samples) { + info.samples = samples; + } else if (samples < info.samples) { + Com_Error(ERR_DROP, "Sound %s has a bad loop length", name); + } + + info.dataofs = data_p - wav; + info.datasize = iff_chunk_len - bytealign + info.dataofs; + info.dataalign = (bytealign / info.channels - 4) / 4 * 8 + 1; + } else if (info.format == 1) { + info.channels = GetLittleShort(); + info.rate = (float)GetLittleLong(); + data_p += 4; + + bytealign = GetLittleShort(); + info.width = (float)GetLittleShort() / 8.f; + + FindChunk("data"); + if (!data_p) { + Com_Printf("Missing data chunk\n"); + return info; + } + + data_p += 4; + samples = (float)GetLittleLong() / info.width; + + if (!info.samples) { + info.samples = samples; + } else if (samples < info.samples) { + Com_Error(ERR_DROP, "Sound %s has a bad loop length", name); + } + + info.dataofs = data_p - wav; + info.datasize = iff_chunk_len; + info.dataalign = (bytealign / info.channels - 4) / 4 * 8 + 1; + // dataalign should always be 1 + assert(info.dataalign == 1); + } else { + Com_Printf("Microsoft PCM format only\n"); + return info; + } + + return info; +} + +/* +============== +DownSampleWav +============== +*/ +qboolean DownSampleWav(wavinfo_t *info, byte *wav, int wavlength, int newkhz, byte **newdata) +{ + int newdatasize; + byte *datap; + int i; + int ii; + int error; + int width; + int oldsamples; + int oldrate; + + newdatasize = 0; + datap = &wav[info->dataofs]; + + if (info->channels > 1) { + Com_DPrintf("Could not downsample WAV file. Stereo WAVs not supported!\n"); + return 0; + } + + if (info->format != 1 || !info->dataofs) { + Com_DPrintf("Could not downsample WAV file. Not PCM format!\n"); + return 0; + } + + if (info->rate <= newkhz) { + return 0; + } + + error = 0; + width = info->width; + for (i = 0; i < info->samples; i++) { + error += newkhz; + while (error > info->rate) { + error -= info->rate; + newdatasize += width; + } + } + + oldsamples = info->samples; + oldrate = info->rate; + info->samples = newdatasize / width; + info->rate = (float)newkhz; + newdatasize += info->dataofs; + + *newdata = (byte *)Z_TagMalloc(newdatasize, TAG_SOUND); + memcpy(*newdata, wav, info->dataofs); + + iff_data = *newdata; + iff_end = *newdata + newdatasize; + FindChunk("RIFF"); + + if (!data_p || strncmp((const char *)data_p + 8, "WAVE", 4u)) { + Com_DPrintf("Missing RIFF/WAVE chunks\n"); + return 0; + } + + iff_data = data_p + 12; + FindChunk("fmt "); + if (!data_p) { + Com_DPrintf("Missing fmt chunk\n"); + return 0; + } + + data_p += 12; + SetLittleShort((int)info->rate); + data_p += 8; + + FindChunk("data"); + if (!data_p) { + Com_DPrintf("Missing data chunk\n"); + return 0; + } + + data_p += 4; + SetLittleLong((int)(info->samples * info->width)); + + error = 0; + for (i = 0; i < oldsamples; i++) { + error += newkhz; + while (error > oldrate) { + error -= oldrate; + for (ii = 0; ii < width; ii++) { + data_p[ii] = datap[ii]; + } + + data_p += width; + } + + datap += width; + } + + assert(iff_end - data_p == 0); + + return newdatasize; +} + +/* +============== +DownSampleWav_MILES +============== +*/ +int DownSampleWav_MILES(wavinfo_t *info, byte *wav, int wavlength, int newkhz, byte **newdata) +{ + // Fallback to software downsampling + return DownSampleWav(info, wav, wavlength, newkhz, newdata); +} + +/* +============== +S_LoadSound +============== +*/ +qboolean S_LoadSound(const char *fileName, sfx_t *sfx, int streamed, qboolean force_load) +{ + int size; + fileHandle_t file_handle; + char tempName[MAX_RES_NAME + 1]; + int realKhz; + + sfx->buffer = 0; + + if (fileName[0] == '*') { + return qfalse; + } + + if (streamed) { + sfx->length = 5000; + sfx->width = 1; + sfx->iFlags |= SFX_FLAG_STREAMED; + sfx->time_length = 5000.0; + sfx->data = NULL; + return qtrue; + } + + if (clc.state != CA_LOADING && !force_load) { + Com_Printf("**************S_LoadSound: %s\n", fileName); + } + + if (strstr(fileName, ".mp3")) { + return S_LoadMP3(fileName, sfx); + } + + size = FS_FOpenFileRead(fileName, &file_handle, qfalse, qtrue); + if (size <= 0) { + if (file_handle) { + FS_FCloseFile(file_handle); + } + return qfalse; + } + + sfx->data = (byte *)Z_TagMalloc(size, TAG_SOUND); + + FS_Read(sfx->data, size, file_handle); + FS_FCloseFile(file_handle); + sfx->info = GetWavinfo(fileName, sfx->data, size); + + if (sfx->info.channels != 1 && !streamed) { + Com_Printf("%s is a stereo wav file\n", fileName); + Z_Free(sfx->data); + sfx->data = NULL; + return qfalse; + } + + if (!sfx->info.dataofs) { + sfx->iFlags |= SFX_FLAG_NO_OFFSET; + } + + switch (s_khz->integer) { + case 11: + realKhz = 11025; + break; + case 22: + default: + realKhz = 22050; + break; + case 44: + realKhz = 44100; + break; + } + + if (!(sfx->iFlags & SFX_FLAG_STREAMED) && realKhz < sfx->info.rate) { + byte *newdata; + int newdatasize; + + newdata = NULL; + if (sfx->iFlags & SFX_FLAG_NO_OFFSET) { + newdatasize = DownSampleWav_MILES(&sfx->info, sfx->data, size, realKhz, &newdata); + } else { + newdatasize = DownSampleWav(&sfx->info, sfx->data, size, realKhz, &newdata); + } + + if (newdatasize) { + Z_Free(sfx->data); + sfx->data = newdata; + sfx->info.datasize = newdatasize; + } + } + + sfx->length = sfx->info.samples; + sfx->width = sfx->info.width; + sfx->time_length = sfx->info.samples / sfx->info.rate * 1000.f; + + if (sfx->iFlags & SFX_FLAG_STREAMED) { + Z_Free(sfx->data); + sfx->data = NULL; + } + + Com_sprintf(tempName, sizeof(tempName), "k%s", fileName); + UI_LoadResource(tempName); + + if (strstr(fileName, "sound/null.wav")) { + sfx->iFlags |= SFX_FLAG_NULL; + return qtrue; + } + + return qtrue; +} + +/* +============== +S_LoadMP3 +============== +*/ +qboolean S_LoadMP3(const char *fileName, sfx_t *sfx) +{ + int length; + fileHandle_t file_handle; + + length = FS_FOpenFileRead(fileName, &file_handle, 0, 1); + if (length <= 0) { + if (file_handle) { + FS_FCloseFile(file_handle); + } + return qfalse; + } + + memset(&sfx->info, 0, sizeof(sfx->info)); + sfx->data = (byte *)Z_TagMalloc(length, TAG_SOUND); + sfx->length = length; + sfx->width = 1; + FS_Read(sfx->data, length, file_handle); + FS_FCloseFile(file_handle); + + sfx->iFlags |= SFX_FLAG_MP3; + + return qtrue; +} diff --git a/code/client/snd_openal.c b/code/client/snd_openal.c index a5f4dadf..236f859a 100644 --- a/code/client/snd_openal.c +++ b/code/client/snd_openal.c @@ -233,7 +233,7 @@ static sfxHandle_t S_AL_BufferFind(const char *filename) ptr = &knownSfx[sfx]; memset(ptr, 0, sizeof(*ptr)); ptr->masterLoopSrc = -1; - strcpy(ptr->filename, filename); + Q_strncpyz(ptr->filename, filename, sizeof(ptr->filename)); } // Return the handle diff --git a/code/client/snd_openal_new.cpp b/code/client/snd_openal_new.cpp index e2146254..2e35801c 100644 --- a/code/client/snd_openal_new.cpp +++ b/code/client/snd_openal_new.cpp @@ -20,18 +20,19 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -#if USE_SOUND_NEW - -# include "snd_local.h" -# include "snd_openal_new.h" +#include "snd_local.h" +#include "snd_openal_new.h" +#include "client.h" +#include "../server/server.h" +#include "snd_codec.h" typedef struct { - char *funcname; - void **funcptr; - bool required; + const char *funcname; + void **funcptr; + bool required; } extensions_table_t; -# define MAX_MUSIC_SONGS 16 +#define MAX_MUSIC_SONGS 16 static int s_iNextLoopingWarning = 0; static int s_iReverbType = 0; @@ -39,6 +40,9 @@ static float s_fReverbLevel = 0; static bool s_bReverbChanged = false; static bool s_bFading = false; static float s_fFadeVolume = 1.f; +static float s_fVelocityScale = 0.005f; + +static constexpr float s_fVolumeGain = 1.f; // = 84.f; cvar_t *s_milesdriver; cvar_t *s_openaldevice; @@ -49,6 +53,9 @@ cvar_t *s_show_sounds; cvar_t *s_speaker_type; cvar_t *s_obstruction_cal_time; cvar_t *s_lastSoundTime; +// Added in OPM +cvar_t *s_openaldriver; +cvar_t *s_alAvailableDevices; static float reverb_table[] = { 0.5f, 0.25f, 0.417f, 0.653f, 0.208f, 0.5f, 0.403f, 0.5f, 0.5f, @@ -56,15 +63,17 @@ static float reverb_table[] = { 1.0f, 0.097000003f, 0.208f, 0.65200001f, 1.0f, 0.875f, 0.139f, 0.486f, }; -static vec3_t vec_zero = {0, 0, 0}; -int s_iNumMilesAudioProviders = 0; -bool s_bProvidersEmunerated = false; -static bool al_initialized = false; -static bool al_use_reverb = false; -static float al_current_volume = 0; -static unsigned int al_frequency = 22050; -static void *al_context_id = NULL; -static ALCdevice *al_device = NULL; +static vec3_t vec_zero = {0, 0, 0}; +int s_iNumMilesAudioProviders = 0; +bool s_bProvidersEmunerated = false; +static bool al_initialized = false; +static bool al_use_reverb = false; +static float al_current_volume = 0; +static unsigned int al_frequency = 22050; +static ALCcontext *al_context_id = NULL; +static ALCdevice *al_device = NULL; +static ALsizei al_default_resampler_index = 0; +static ALsizei al_resampler_index = 0; static ALboolean (*_alutLoadMP3_LOKI)(unsigned int buffer, const byte *data, int length); static void (*_alReverbScale_LOKI)(); @@ -84,180 +93,1228 @@ int music_loaded = 0; int music_numsongs = 0; int music_currentsong = 0; +static qboolean enumeration_ext = qfalse; +static qboolean enumeration_all_ext = qfalse; + +static qboolean ima4_ext = qfalse; +static qboolean soft_block_align = qfalse; + song_t music_songs[MAX_MUSIC_SONGS]; openal_internal_t openal; static float s_fFadeStartTime; static float s_fFadeStopTime; static char current_soundtrack[128]; -static void __alDieIfError(char *file) +static void S_OPENAL_PlayMP3(); +static void S_OPENAL_StopMP3(); +static void S_OPENAL_Pitch(); +static int +S_OPENAL_SpatializeStereoSound(const vec3_t listener_origin, const vec3_t listener_left, const vec3_t origin); +static void S_OPENAL_reverb(int iChannel, int iReverbType, float fReverbLevel); +static bool S_OPENAL_LoadMP3_Codec(const char *_path, sfx_t *pSfx); +static ALuint S_OPENAL_Format(float width, int channels); + +#define alDieIfError() __alDieIfError(__FILE__, __LINE__) + +#if defined(_WIN64) +# define ALDRIVER_DEFAULT "OpenAL64.dll" +#elif defined(_WIN32) +# define ALDRIVER_DEFAULT "OpenAL32.dll" +#elif defined(__APPLE__) +# define ALDRIVER_DEFAULT "libopenal.1.dylib" +#elif defined(__OpenBSD__) +# define ALDRIVER_DEFAULT "libopenal.so" +#else +# define ALDRIVER_DEFAULT "libopenal.so.1" +#endif + +// +// alext +// +#ifdef AL_SOFT_source_resampler +LPALGETSTRINGISOFT qalGetStringiSOFT; +#endif + +/* +============== +__alDieIfError +============== +*/ +static void __alDieIfError(const char *file, int line) { - // FIXME: unimplemented + ALint alErr = qalGetError(); + if (alErr) { + if (s_show_sounds->integer) { + Com_DPrintf("OpenAL error, %s, line %i: [%s].\n", file, line, qalGetString(alErr)); + } + } } +/* +============== +S_OPENAL_NukeSource +============== +*/ static void S_OPENAL_NukeSource(ALuint *srcptr) { - // FIXME: unimplemented + ALuint source; + + source = *srcptr; + if (!*srcptr) { + return; + } + + if (!qalIsSource(*srcptr)) { + return; + } + + alDieIfError(); + qalSourceStop(source); + + alDieIfError(); + qalSourcei(source, AL_BUFFER, 0); + + alDieIfError(); + qalDeleteSources(1, srcptr); + + alDieIfError(); + *srcptr = 0; } +/* +============== +S_OPENAL_NukeBuffer +============== +*/ static void S_OPENAL_NukeBuffer(ALuint *bufptr) { - // FIXME: unimplemented + if (!*bufptr) { + return; + } + + if (!qalIsBuffer(*bufptr)) { + return; + } + + alDieIfError(); + qalDeleteBuffers(1, bufptr); + + alDieIfError(); + *bufptr = 0; } +/* +============== +S_OPENAL_NukeChannel +============== +*/ static void S_OPENAL_NukeChannel(openal_channel *channel) { - // FIXME: unimplemented + if (!channel) { + return; + } + + S_OPENAL_NukeSource(&channel->source); + S_OPENAL_NukeBuffer(&channel->buffer); + + if (channel->bufferdata) { + delete[] channel->bufferdata; + } } +/* +============== +S_OPENAL_NukeContext +============== +*/ static void S_OPENAL_NukeContext() { - // FIXME: unimplemented + int i; + + Com_Printf("OpenAL: Destroying channels...\n"); + + for (i = 0; i < MAX_SOUNDSYSTEM_CHANNELS; ++i) { + S_OPENAL_NukeChannel(openal.channel[i]); + } + + Com_Printf("OpenAL: Channels destroyed successfully.\n"); + + for (i = 0; i < s_numSfx; i++) { + S_OPENAL_NukeBuffer(&s_knownSfx[i].buffer); + } + + S_OPENAL_NukeBuffer(&openal.movieSFX.buffer); + + if (al_context_id) { + Com_Printf("OpenAL: Destroying context...\n"); + + qalcSuspendContext(al_context_id); + qalcMakeContextCurrent(NULL); + qalcDestroyContext(al_context_id); + al_context_id = NULL; + + Com_Printf("OpenAL: Context destroyed successfully.\n"); + } + + if (al_device) { + Com_Printf("OpenAL: Closing device...\n"); + + qalcCloseDevice(al_device); + al_device = NULL; + + Com_Printf("OpenAL: Device closed successfully.\n"); + } } +/* +============== +S_OPENAL_InitContext +============== +*/ static bool S_OPENAL_InitContext() { - // FIXME: unimplemented - return false; + const char *dev; + int attrlist[12]; + + Com_DPrintf("OpenAL: Context initialization\n"); + + dev = NULL; + if (s_openaldevice) { + dev = s_openaldevice->string; + } + + if (dev && !*dev) { + dev = NULL; + } + + // Device enumeration support + enumeration_all_ext = qalcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT"); + enumeration_ext = qalcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT"); + + if (enumeration_ext || enumeration_all_ext) { + char devicenames[16384] = ""; + const char *devicelist; +#ifdef _WIN32 + const char *defaultdevice; +#endif + int curlen; + + // get all available devices + the default device name. + if (enumeration_all_ext) { + devicelist = qalcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER); +#ifdef _WIN32 + defaultdevice = qalcGetString(NULL, ALC_DEFAULT_ALL_DEVICES_SPECIFIER); +#endif + } else { + // We don't have ALC_ENUMERATE_ALL_EXT but normal enumeration. + devicelist = qalcGetString(NULL, ALC_DEVICE_SPECIFIER); +#ifdef _WIN32 + defaultdevice = qalcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER); +#endif + enumeration_ext = qtrue; + } + +#ifdef _WIN32 + Com_DPrintf("OpenAL: Default playback device: \"%s\"\n", defaultdevice); +#endif + +#ifdef _WIN32 + // check whether the default device is generic hardware. If it is, change to + // Generic Software as that one works more reliably with various sound systems. + // If it's not, use OpenAL's default selection as we don't want to ignore + // native hardware acceleration. + if (!dev && defaultdevice && !strcmp(defaultdevice, "Generic Hardware")) { + dev = "Generic Software"; + } +#endif + + // dump a list of available devices to a cvar for the user to see. + + if (devicelist) { + while ((curlen = strlen(devicelist))) { + Q_strcat(devicenames, sizeof(devicenames), devicelist); + Q_strcat(devicenames, sizeof(devicenames), "\n"); + + devicelist += curlen + 1; + } + } + + Com_Printf("OpenAL: List of available devices:\n%s\n", devicenames); + + s_alAvailableDevices = Cvar_Get("s_alAvailableDevices", devicenames, CVAR_ROM | CVAR_NORESTART); + } + + Com_Printf("OpenAL: Opening device \"%s\"...\n", dev ? dev : "{default}"); + + al_device = qalcOpenDevice(dev); + if (!al_device && dev) { + Com_Printf("Failed to open OpenAL device '%s', trying default.\n", dev); + al_device = qalcOpenDevice(NULL); + } + + if (!al_device) { + Com_Printf("OpenAL: Could not open device\n"); + S_OPENAL_NukeContext(); + return false; + } + + Com_Printf("OpenAL: Device opened successfully.\n"); + switch (s_khz->integer) { + case 11: + al_frequency = 11025; + break; + default: + case 22: + al_frequency = 22050; + break; + case 44: + al_frequency = 44100; + break; + } + + attrlist[0] = ALC_FREQUENCY; + attrlist[1] = al_frequency; + attrlist[2] = ALC_SYNC; + attrlist[3] = qfalse; + + s_speaker_type->modified = false; + +#ifdef ALC_SOFT_output_mode + attrlist[4] = ALC_OUTPUT_MODE_SOFT; + // Disable HRTF by default + // For example, actual speakers that are recognized as headphones by the OS + // will not get forced HRTF + attrlist[6] = ALC_HRTF_SOFT; + attrlist[7] = ALC_FALSE; + + switch (s_speaker_type->integer) { + // Two speakers + default: + case 0: + attrlist[5] = ALC_STEREO_SOFT; + break; + // Headphones + case 1: + attrlist[5] = ALC_STEREO_HRTF_SOFT; + // Allow HRTF mixing (without forcing in case it's unsupported) + attrlist[7] = ALC_DONT_CARE_SOFT; + break; + // Surround + case 2: + attrlist[5] = ALC_SURROUND_5_1_SOFT; + break; + // Quad speakers + case 3: + attrlist[5] = ALC_QUAD_SOFT; + break; + } +#else +# pragma message("OpenAL: ALC_OUTPUT_MODE_SOFT unavailable") + + Com_Printf( + "OpenAL: ALC_OUTPUT_MODE_SOFT is unavailable. The speaker type will be ignored, fallback to normal stereo.\n" + ); + attrlist[4] = 0; + attrlist[5] = 0; +#endif + +#ifdef ALC_SOFT_output_limiter + // Disable limiter + attrlist[8] = ALC_OUTPUT_LIMITER_SOFT; + attrlist[9] = ALC_FALSE; +#endif + attrlist[10] = 0; + attrlist[11] = 0; + + Com_Printf("OpenAL: Creating AL context...\n"); + al_context_id = qalcCreateContext(al_device, attrlist); + if (!al_context_id) { + Com_Printf("OpenAL: Could not create context\n"); + S_OPENAL_NukeContext(); + return false; + } + + Com_Printf("OpenAL: Context created successfully.\n"); + + qalcMakeContextCurrent(al_context_id); + alDieIfError(); + + Com_Printf("AL_VENDOR: %s\n", qalGetString(AL_VENDOR)); + alDieIfError(); + + Com_Printf("AL_VERSION: %s\n", qalGetString(AL_VERSION)); + alDieIfError(); + + Com_Printf("AL_RENDERER: %s\n", qalGetString(AL_RENDERER)); + alDieIfError(); + + Com_Printf("AL_EXTENSIONS: %s\n", qalGetString(AL_EXTENSIONS)); + alDieIfError(); + + qalDistanceModel(AL_INVERSE_DISTANCE_CLAMPED); + alDieIfError(); + + qalcProcessContext(al_context_id); + alDieIfError(); + + return true; } +/* +============== +S_OPENAL_InitExtensions +============== +*/ static bool S_OPENAL_InitExtensions() { - // FIXME: unimplemented - return false; + /* + extensions_table_t extensions_table[4] = { + "alutLoadMP3_LOKI", + (void **)&_alutLoadMP3_LOKI, + true, + "alReverbScale_LOKI", + (void **)&_alReverbScale_LOKI, + true, + "alReverbDelay_LOKI", + (void **)&_alReverbDelay_LOKI, + true + }; + */ + + extensions_table_t extensions_table[] = { +#ifdef AL_SOFT_source_resampler + extensions_table_t { + "alGetStringiSOFT", (void **)&qalGetStringiSOFT, + false, }, +#endif + extensions_table_t {NULL, NULL, NULL} + }; + + extensions_table_t *i; + + for (i = extensions_table; i->funcname; ++i) { + *i->funcptr = NULL; + } + + for (i = extensions_table; i->funcname; ++i) { + Com_Printf("AL extension: Looking up %ssymbol \"%s\"...", i->required ? "required " : "", i->funcname); + + *i->funcptr = qalGetProcAddress(i->funcname); + if (!*i->funcptr) { + Com_Printf("...not found! %d [%s]\n", qalGetError(), qalGetString(qalGetError())); + if (i->required) { + S_OPENAL_NukeContext(); + return false; + } + continue; + } + + Com_Printf("...found.\n"); + } + + ima4_ext = qalIsExtensionPresent("AL_EXT_IMA4"); + soft_block_align = qalIsExtensionPresent("AL_SOFT_block_alignment"); + + qalGetError(); + return true; } +/* +============== +S_OPENAL_InitChannel +============== +*/ static bool S_OPENAL_InitChannel(int idx, openal_channel *chan) { - // FIXME: unimplemented - return false; + openal.channel[idx] = chan; + VectorClear(chan->vOrigin); + chan->fVolume = 1.0; + chan->fNewPitchMult = 0.0; + chan->fMinDist = 0.0; + chan->fMaxDist = 0.0; + chan->pSfx = 0; + chan->iEntNum = 0; + chan->iEntChannel = 0; + chan->iBaseRate = 0; + chan->iStartTime = 0; + chan->iTime = 0; + chan->iEndTime = 0; + chan->iFlags = 0; + chan->iPausedOffset = 0; + chan->source = 0; + chan->buffer = 0; + chan->bufferdata = 0; + chan->fading = FADE_NONE; + chan->fade_time = 0; + chan->fade_start_time = 0; + chan->song_number = 0; + + qalGenSources(1, &chan->source); + alDieIfError(); + qalSourcei(chan->source, AL_SOURCE_RELATIVE, true); + alDieIfError(); + +#ifdef AL_SOFT_source_resampler + qalSourcei(chan->source, AL_SOURCE_RESAMPLER_SOFT, al_resampler_index); + alDieIfError(); +#endif + + return true; } +/* +============== +S_OPENAL_Init +============== +*/ qboolean S_OPENAL_Init() { - // FIXME: unimplemented - return qfalse; + int i; + + if (al_initialized) { + Com_DPrintf("S_OPENAL_Init(): Called when sound is already initialized!\n"); + return qtrue; + } + + for (i = 0; i < MAX_SOUNDSYSTEM_CHANNELS; i++) { + openal.channel[i] = NULL; + } + + for (i = 0; i < MAX_SOUNDSYSTEM_LOOP_SOUNDS; i++) { + openal.loop_sounds[i] = {}; + } + + s_milesdriver = Cvar_Get("s_milesdriver", "auto", CVAR_SOUND_LATCH | CVAR_ARCHIVE); + s_openaldevice = Cvar_Get("s_openaldevice", "", CVAR_SOUND_LATCH); + s_reverb = Cvar_Get("s_reverb", "0", CVAR_SOUND_LATCH | CVAR_ARCHIVE); + s_show_cpu = Cvar_Get("s_show_cpu", "0", 0); + s_show_num_active_sounds = Cvar_Get("s_show_num_active_sounds", "0", 0); + s_show_sounds = Cvar_Get("s_show_sounds", "0", 0); + s_speaker_type = Cvar_Get("s_speaker_type", "0", CVAR_ARCHIVE); + s_obstruction_cal_time = Cvar_Get("s_obstruction_cal_time", "500", CVAR_ARCHIVE); + // + // Added in OPM + // Initialize the AL driver DLL + s_openaldriver = Cvar_Get("s_openaldriver", ALDRIVER_DEFAULT, CVAR_LATCH | CVAR_PROTECTED); + + if (!QAL_Init(s_openaldriver->string)) { + Com_Printf("Failed to load library: \"%s\".\n", s_openaldriver->string); + if (!Q_stricmp(s_openaldriver->string, ALDRIVER_DEFAULT) || !QAL_Init(ALDRIVER_DEFAULT)) { + return qfalse; + } + } + + if (!Cvar_Get("s_initsound", "1", 0)->integer) { + Com_Printf("OpenAL: s_initsound set to zero...disabling audio.\n"); + return true; + } + + if (!S_OPENAL_InitContext()) { + Com_Printf("OpenAL: initialization failed. No audio will play.\n"); + return false; + } + + if (!S_OPENAL_InitExtensions()) { + Com_Printf("OpenAL: A required extension is missing. No audio will play.\n"); + return false; + } + + al_use_reverb = false; + if (s_reverb->integer) { + STUB_DESC("reenable reverb support later."); + + if (al_use_reverb) { + S_OPENAL_SetReverb(s_iReverbType, s_fReverbLevel); + } else { + Com_Printf("OpenAL: No reverb support. Reverb is disabled.\n"); + } + } + s_reverb->modified = false; + + al_current_volume = Square(s_volume->value); + qalListenerf(AL_GAIN, al_current_volume); + alDieIfError(); + +#ifdef AL_SOFT_source_resampler + if (qalGetStringiSOFT) { + size_t numResamplers; + size_t i; + + al_default_resampler_index = qalGetInteger(AL_DEFAULT_RESAMPLER_SOFT); + alDieIfError(); + al_resampler_index = al_default_resampler_index; + numResamplers = qalGetInteger(AL_NUM_RESAMPLERS_SOFT); + alDieIfError(); + + for (i = 0; i < numResamplers; i++) { + const ALchar *resamplerName = qalGetStringiSOFT(AL_RESAMPLER_NAME_SOFT, i); + if (Q_stristr(resamplerName, "spline")) { + Com_Printf("OpenAL: Using %s as the resampler.\n", resamplerName); + al_resampler_index = i; + break; + } + } + } +#endif + + for (i = 0; i < MAX_SOUNDSYSTEM_CHANNELS_3D; i++) { + if (!S_OPENAL_InitChannel(i, &openal.chan_3D[i])) { + return false; + } + } + + for (i = 0; i < MAX_SOUNDSYSTEM_CHANNELS_2D; i++) { + if (!S_OPENAL_InitChannel(i + MAX_SOUNDSYSTEM_CHANNELS_3D, &openal.chan_2D[i])) { + return false; + } + } + + for (i = 0; i < MAX_SOUNDSYSTEM_CHANNELS_2D_STREAM; i++) { + if (!S_OPENAL_InitChannel( + i + MAX_SOUNDSYSTEM_CHANNELS_3D + MAX_SOUNDSYSTEM_CHANNELS_2D, &openal.chan_2D_stream[i] + )) { + return false; + } + } + + for (i = 0; i < MAX_SOUNDSYSTEM_SONGS; i++) { + if (!S_OPENAL_InitChannel( + i + MAX_SOUNDSYSTEM_CHANNELS_3D + MAX_SOUNDSYSTEM_CHANNELS_2D + MAX_SOUNDSYSTEM_CHANNELS_2D_STREAM, + &openal.chan_song[i] + )) { + return false; + } + } + + if (!S_OPENAL_InitChannel(SOUNDSYSTEM_CHANNEL_MP3_ID, &openal.chan_mp3)) { + return false; + } + + if (!S_OPENAL_InitChannel(SOUNDSYSTEM_CHANNEL_TRIGGER_MUSIC_ID, &openal.chan_trig_music)) { + return false; + } + + if (!S_OPENAL_InitChannel(SOUNDSYSTEM_CHANNEL_MOVIE_ID, &openal.chan_movie)) { + return false; + } + + // + // Disable sound virtualization on special channels + // (triggered music, ambient sounds...) + // + for (i = 0; i < MAX_SOUNDSYSTEM_SONGS; i++) { + openal.chan_song[i].set_no_virtualization(); + } + openal.chan_mp3.set_no_virtualization(); + openal.chan_trig_music.set_no_virtualization(); + openal.chan_movie.set_no_virtualization(); + + Cmd_AddCommand("playmp3", S_OPENAL_PlayMP3); + Cmd_AddCommand("stopmp3", S_OPENAL_StopMP3); + Cmd_AddCommand("loadsoundtrack", S_loadsoundtrack); + Cmd_AddCommand("playsong", S_PlaySong); + Cmd_AddCommand("pitch", S_OPENAL_Pitch); + Cmd_AddCommand("tmstart", S_TriggeredMusic_Start); + Cmd_AddCommand("tmstartloop", S_TriggeredMusic_StartLoop); + Cmd_AddCommand("tmstop", S_TriggeredMusic_Stop); + // Added in 2.0 + Cmd_AddCommand("tmvolume", S_TriggeredMusic_Volume); + + S_OPENAL_ClearLoopingSounds(); + load_sfx_info(); + s_bProvidersEmunerated = true; + al_initialized = true; + + // Added in OPM + S_CodecInit(); + + return true; } +/* +============== +S_OPENAL_Shutdown +============== +*/ void S_OPENAL_Shutdown() { - // FIXME: unimplemented + if (!al_initialized) { + Com_DPrintf("S_OPENAL_Shutdown(): Called when sound is NOT initialized!\n"); + return; + } + + S_OPENAL_StopAllSounds(true); + + Cmd_RemoveCommand("playmp3"); + Cmd_RemoveCommand("stopmp3"); + Cmd_RemoveCommand("loadsoundtrack"); + Cmd_RemoveCommand("playsong"); + Cmd_RemoveCommand("pitch"); + Cmd_RemoveCommand("tmstart"); + Cmd_RemoveCommand("tmstartloop"); + Cmd_RemoveCommand("tmstop"); + // Added in 2.0 + Cmd_RemoveCommand("tmvolume"); + + S_OPENAL_NukeContext(); + + s_bProvidersEmunerated = false; + al_initialized = false; + + QAL_Shutdown(); } +/* +============== +S_FadeSound +============== +*/ void S_FadeSound(float fTime) { - // FIXME: unimplemented + Com_Printf("Called FadeSound with: %f\n", fTime); + + if (fTime > 0) { + s_bFading = true; + s_fFadeStartTime = cls.realtime; + s_fFadeVolume = 1; + s_fFadeStopTime = cls.realtime + fTime; + } else { + s_fFadeVolume = 1; + s_bFading = false; + // Fixed in OPM + // Make sure to restore the music volume + // in case the map restarts immediately after the intermission + music_volume_changed = true; + } } +/* +============== +S_GetBaseVolume +============== +*/ float S_GetBaseVolume() { - // FIXME: unimplemented - return 0; + return s_volume->value * s_fFadeVolume; } +/* +============== +S_NeedFullRestart +============== +*/ qboolean S_NeedFullRestart() { - // FIXME: unimplemented - return qfalse; + return Cvar_Get("s_initsound", "1", 0)->integer != s_bLastInitSound; } +/* +============== +S_PrintInfo +============== +*/ void S_PrintInfo() { - // FIXME: unimplemented + const char *dev; + + Com_Printf("----- Sound Info -----\n"); + + if (s_bSoundStarted) { + dev = NULL; + if (s_openaldevice) { + dev = s_openaldevice->string; + } + if (!dev || !*dev) { + dev = "{default}"; + } + Com_Printf("device - %s\n", dev); + if (al_use_reverb) { + Com_Printf("reverb - ON\n"); + } else { + Com_Printf("reverb - OFF\n"); + } + Com_Printf("samplebits - 16\n"); + Com_Printf("speed - %d\n", al_frequency); + if (s_loadas8bit->integer) { + Com_Printf("Can NOT force all sounds to 8 bit in OpenAL, I think.\n"); + } + } else { + Com_Printf("sound system not started\n"); + } + + Com_Printf("----------------------\n"); } +/* +============== +S_DumpStatus +============== +*/ static void S_DumpStatus(const char *pszChanName, int iChanNum, openal_channel *channel) { - // FIXME: unimplemented + sfx_t *sfx; + ALint status; + + sfx = channel->pSfx; + + qalGetSourceiv(channel->source, AL_SOURCE_STATE, &status); + alDieIfError(); + + if (status == AL_PLAYING || status == AL_PAUSED) { + const char *pszMode = status == AL_PLAYING ? "playing" : "paused"; + + if (sfx) { + if (sfx != (sfx_t *)-16 && sfx->name[0]) { + Com_Printf("%s channel %i - %s sfx %s\n", pszChanName, iChanNum, pszMode, sfx->name); + } else { + Com_Printf("%s channel %i - %s with nameless sfx\n", pszChanName, iChanNum, pszMode); + } + } else { + Com_Printf("%s channel %i - %s with NULL sfx\n", pszChanName, iChanNum, pszMode); + } + } } +/* +============== +S_DumpInfo +============== +*/ void S_DumpInfo() { - // FIXME: unimplemented + int i; + + for (i = 0; i < MAX_SOUNDSYSTEM_CHANNELS_3D; i++) { + S_DumpStatus("3D", i, openal.channel[i]); + } + + for (i = 0; i < MAX_SOUNDSYSTEM_CHANNELS_2D; i++) { + S_DumpStatus("2D", i, openal.channel[MAX_SOUNDSYSTEM_CHANNELS_3D + i]); + } + + for (i = 0; i < MAX_SOUNDSYSTEM_CHANNELS_2D_STREAM; i++) { + S_DumpStatus("2D stream", i, openal.channel[MAX_SOUNDSYSTEM_CHANNELS_3D + MAX_SOUNDSYSTEM_CHANNELS_2D + i]); + } + + for (i = 0; i < MAX_SOUNDSYSTEM_MISC_CHANNELS; i++) { + S_DumpStatus( + "Misc", + i, + openal.channel + [MAX_SOUNDSYSTEM_CHANNELS_3D + MAX_SOUNDSYSTEM_CHANNELS_2D + MAX_SOUNDSYSTEM_CHANNELS_2D_STREAM + i] + ); + } } +/* +============== +S_OPENAL_Pitch +============== +*/ static void S_OPENAL_Pitch() { - // FIXME: unimplemented + Com_Printf("S_OPENAL_Pitch() needs to be implemented!\n"); } +/* +============== +S_OPENAL_LoadMP3 +============== +*/ static bool S_OPENAL_LoadMP3(const char *_path, openal_channel *chan) { - // FIXME: unimplemented - return false; + char path[MAX_QPATH]; + snd_info_t info; + ALuint format; + + chan->stop(); + + qalSourcei(chan->source, AL_BUFFER, 0); + alDieIfError(); + + Q_strncpyz(path, _path, sizeof(path)); + path[MAX_QPATH - 1] = 0; + + FS_CorrectCase(path); + + // Try to load + chan->bufferdata = (ALubyte *)S_CodecLoad(path, &info); + if (!chan->bufferdata) { + return false; + } + + format = S_OPENAL_Format(info.width, info.channels); + + // Create a buffer + qalGenBuffers(1, &chan->buffer); + alDieIfError(); + + // Fill the buffer + if (info.size == 0) { + // We have no data to buffer, so buffer silence + byte dummyData[2] = {0}; + + qalBufferData(chan->buffer, AL_FORMAT_MONO16, (void *)dummyData, 2, 22050); + } else { + qalBufferData(chan->buffer, format, chan->bufferdata, info.size, info.rate); + } + + alDieIfError(); + + // Free the memory + Hunk_FreeTempMemory(chan->bufferdata); + chan->bufferdata = NULL; + + qalSourcei(chan->source, AL_BUFFER, chan->buffer); + alDieIfError(); + + chan->set_no_3d(); + + return true; } +/* +============== +S_OPENAL_PlayMP3 +============== +*/ static void S_OPENAL_PlayMP3() { - // FIXME: unimplemented + const char *path; + + if (Cmd_Argc() != 2) { + Com_Printf("playmp3 \n"); + return; + } + + path = Cmd_Argv(1); + if (!S_OPENAL_LoadMP3(path, &openal.chan_mp3)) { + Com_Printf("Failed to play mp3 - %s\n", path); + return; + } + + openal.chan_mp3.play(); + Com_Printf("Playing mp3 - %s\n", path); } +/* +============== +S_OPENAL_StopMP3 +============== +*/ static void S_OPENAL_StopMP3() { - // FIXME: unimplemented + S_OPENAL_NukeChannel(&openal.chan_mp3); } +/* +============== +MUSIC_Pause +============== +*/ void MUSIC_Pause() { - // FIXME: unimplemented + int i; + + for (i = 0; i < MAX_SOUNDSYSTEM_SONGS; i++) { + openal.chan_song[i].pause(); + } } +/* +============== +MUSIC_Unpause +============== +*/ void MUSIC_Unpause() { - // FIXME: unimplemented + int i; + + for (i = 0; i < MAX_SOUNDSYSTEM_SONGS; i++) { + if (openal.chan_song[i].is_paused()) { + openal.chan_song[i].play(); + } + } } +/* +============== +S_PauseSound +============== +*/ void S_PauseSound() { - // FIXME: unimplemented + int i; + + if (!s_bSoundStarted) { + return; + } + + s_bSoundPaused = true; + + for (i = 0; i < MAX_SOUNDSYSTEM_POSITION_CHANNELS; i++) { + openal_channel *pChannel = openal.channel[i]; + if (!pChannel) { + continue; + } + + if (pChannel->iEntChannel == CHAN_MENU) { + continue; + } + + if (!pChannel->is_playing()) { + continue; + } + + pChannel->pause(); + } + + if (openal.chan_mp3.is_playing()) { + openal.chan_mp3.pause(); + } + + MUSIC_Pause(); + S_TriggeredMusic_Pause(); } +/* +============== +S_UnpauseSound +============== +*/ void S_UnpauseSound() { - // FIXME: unimplemented + int i; + + if (!s_bSoundStarted) { + return; + } + + for (i = 0; i < MAX_SOUNDSYSTEM_POSITION_CHANNELS; i++) { + openal_channel *pChannel = openal.channel[i]; + if (!pChannel) { + continue; + } + + if (pChannel->is_paused() || (pChannel->iFlags & CHANNEL_FLAG_PLAY_DEFERRED)) { + pChannel->iFlags &= ~CHANNEL_FLAG_PLAY_DEFERRED; + pChannel->play(); + } + } + + if (openal.chan_mp3.is_paused()) { + openal.chan_mp3.play(); + } + + MUSIC_Unpause(); + S_TriggeredMusic_Unpause(); + + s_bSoundPaused = false; } +/* +============== +S_OPENAL_ShouldPlay +============== +*/ static qboolean S_OPENAL_ShouldPlay(sfx_t *pSfx) { - // FIXME: unimplemented - return qfalse; + if (sfx_infos[pSfx->sfx_info_index].max_number_playing <= 0) { + return qtrue; + } + + int iRemainingTimesToPlay; + int i; + + iRemainingTimesToPlay = sfx_infos[pSfx->sfx_info_index].max_number_playing; + + for (i = 0; i < MAX_SOUNDSYSTEM_POSITION_CHANNELS; i++) { + openal_channel *pChannel = openal.channel[i]; + if (!pChannel) { + continue; + } + + if (pChannel->pSfx == pSfx && pChannel->is_playing()) { + iRemainingTimesToPlay--; + if (!iRemainingTimesToPlay) { + return qfalse; + } + } + } + + return qtrue; } +/* +============== +S_OPENAL_ShouldStart +============== +*/ static qboolean S_OPENAL_ShouldStart(const vec3_t vOrigin, float fMinDist, float fMaxDist) { - // FIXME: unimplemented - return qfalse; + vec3_t vDir; + vec3_t vListenerOrigin; + vec3_t alvec; + + if (!al_initialized) { + return false; + } + + qalGetListenerfv(AL_POSITION, alvec); + + VectorCopy(alvec, vListenerOrigin); + VectorSubtract(vOrigin, vListenerOrigin, vDir); + + return Square(fMaxDist) > VectorLengthSquared(vDir); } +/* +============== +S_OPENAL_PickChannelBase +============== +*/ static int S_OPENAL_PickChannelBase(int iEntNum, int iEntChannel, int iFirstChannel, int iLastChannel) { - // FIXME: unimplemented - return 0; + int i; + int iBestChannel; + openal_channel *pChannel; + + iBestChannel = -1; + if (iEntNum != ENTITYNUM_NONE && iEntChannel) { + bool bStoppedChannel = false; + + for (i = iFirstChannel; i <= iLastChannel; i++) { + pChannel = openal.channel[i]; + if (!pChannel) { + continue; + } + + if (pChannel->is_free()) { + iBestChannel = i; + continue; + } + + if (pChannel->iEntNum == iEntNum && pChannel->iEntChannel == iEntChannel) { + pChannel->end_sample(); + bStoppedChannel = 1; + iBestChannel = i; + break; + } + } + + if (!bStoppedChannel) { + for (i = 0; i < iFirstChannel; ++i) { + pChannel = openal.channel[i]; + if (!pChannel || pChannel->is_free()) { + continue; + } + + if (pChannel->iEntNum == iEntNum && pChannel->iEntChannel == iEntChannel) { + bStoppedChannel = 1; + break; + } + } + + if (!bStoppedChannel) { + for (i = iLastChannel + 1; i < MAX_SOUNDSYSTEM_POSITION_CHANNELS; i++) { + pChannel = openal.channel[i]; + if (!pChannel || pChannel->is_free()) { + continue; + } + + if (pChannel->iEntNum == iEntNum && pChannel->iEntChannel == iEntChannel) { + break; + } + } + } + } + } + + if (iBestChannel < 0) { + int iBestTime = 0x7FFFFFFF; + + for (i = iFirstChannel; i <= iLastChannel; i++) { + pChannel = openal.channel[i]; + if (!pChannel) { + continue; + } + + if (pChannel->is_free()) { + return i; + } + + if (pChannel->iEntNum == s_iListenerNumber && iEntNum != pChannel->iEntNum) { + continue; + } + + if (pChannel->iEntChannel < iEntChannel + || (pChannel->iEntChannel == iEntChannel && pChannel->iStartTime < iBestTime)) { + iBestChannel = i; + iEntChannel = pChannel->iEntChannel; + iBestTime = pChannel->iStartTime; + } + } + } + + return iBestChannel; } +/* +============== +S_OPENAL_PickChannel3D +============== +*/ static int S_OPENAL_PickChannel3D(int iEntNum, int iEntChannel) { - // FIXME: unimplemented - return 0; + return S_OPENAL_PickChannelBase(iEntNum, iEntChannel, 0, MAX_SOUNDSYSTEM_CHANNELS_3D - 1); } +/* +============== +S_OPENAL_PickChannel2D +============== +*/ static int S_OPENAL_PickChannel2D(int iEntNum, int iEntChannel) { - // FIXME: unimplemented - return 0; + return S_OPENAL_PickChannelBase( + iEntNum, iEntChannel, MAX_SOUNDSYSTEM_CHANNELS_3D, MAX_SOUNDSYSTEM_CHANNELS_3D + MAX_SOUNDSYSTEM_CHANNELS_2D - 1 + ); } +/* +============== +S_OPENAL_PickChannel2DStreamed +============== +*/ static int S_OPENAL_PickChannel2DStreamed(int iEntNum, int iEntChannel) { - // FIXME: unimplemented - return 0; + return S_OPENAL_PickChannelBase( + iEntNum, + iEntChannel, + MAX_SOUNDSYSTEM_CHANNELS_3D + MAX_SOUNDSYSTEM_CHANNELS_2D, + MAX_SOUNDSYSTEM_CHANNELS_3D + MAX_SOUNDSYSTEM_CHANNELS_2D + MAX_SOUNDSYSTEM_CHANNELS_2D_STREAM - 1 + ); } +/* +============== +callbackServer +============== +*/ void callbackServer(int entnum, int channel_number, const char *name) { - // FIXME: unimplemented + if (!com_sv_running->integer) { + return; + } + + SV_SoundCallback(entnum, channel_number, name); } +/* +============== +S_OPENAL_Start2DSound +============== +*/ static void S_OPENAL_Start2DSound( const vec3_t vOrigin, int iEntNum, @@ -269,9 +1326,138 @@ static void S_OPENAL_Start2DSound( float fMaxDistance ) { - // FIXME: unimplemented + int iRealEntNum; + int iFreeChannel; + openal_channel *pChannel; + float fRealVolume; + bool bSupportWaitTillSoundDone; + + iRealEntNum = iEntNum & ~S_FLAG_DO_CALLBACK; + + if (pSfx->iFlags & SFX_FLAG_STREAMED) { + iFreeChannel = S_OPENAL_PickChannel2DStreamed(iRealEntNum, iEntChannel); + } else { + iFreeChannel = S_OPENAL_PickChannel2D(iRealEntNum, iEntChannel); + } + + if (iFreeChannel < 0) { + Com_DPrintf( + "OpenAL: Couldn't play %s sound '%s' for entity %i on channel %s\n", + (pSfx->iFlags & SFX_FLAG_STREAMED) ? "2Dstreamed" : "2D", + pSfx->name, + iRealEntNum, + S_ChannelNumToName(iEntChannel) + ); + return; + } + + if (iEntNum & S_FLAG_DO_CALLBACK) { + callbackServer(iRealEntNum, iFreeChannel, pSfx->name); + } + + pChannel = openal.channel[iFreeChannel]; + pChannel->force_free(); + + if (fVolume < 0) { + fVolume = 1; + } + + fRealVolume = S_GetBaseVolume() * fVolume; + pChannel->fVolume = fVolume; + + if (pChannel->iEntChannel == CHAN_LOCAL) { + pChannel->iFlags |= CHANNEL_FLAG_LOCAL_LISTENER; + } else { + pChannel->iFlags &= ~CHANNEL_FLAG_LOCAL_LISTENER; + } + pChannel->iFlags &= ~CHANNEL_FLAG_PAUSED; + + if (fMinDistance < 0.0) { + fMinDistance = 200.0; + } + pChannel->fMinDist = fMinDistance; + + if (fMaxDistance < 0.0) { + fMaxDistance = pChannel->fMinDist * 64; + } + pChannel->fMaxDist = fMaxDistance; + + pChannel->fNewPitchMult = fPitch; + pChannel->pSfx = pSfx; + pChannel->iEntNum = iRealEntNum; + pChannel->iEntChannel = iEntChannel; + if (iRealEntNum == ENTITYNUM_NONE) { + VectorClear(pChannel->vOrigin); + pChannel->iFlags |= CHANNEL_FLAG_NO_ENTITY; + pChannel->iEntNum = 0; + + if (vOrigin) { + VectorCopy(vOrigin, pChannel->vOrigin); + } + } else { + pChannel->iFlags &= ~CHANNEL_FLAG_NO_ENTITY; + pChannel->iEntNum = iRealEntNum; + if (vOrigin) { + VectorCopy(vOrigin, pChannel->vOrigin); + + bSupportWaitTillSoundDone = cl.serverTime - 1 < 0; + pChannel->iTime = cl.serverTime - 1; + if (bSupportWaitTillSoundDone) { + pChannel->iTime = 0; + } + + if (s_entity[iEntNum].time < pChannel->iTime) { + // Fixed in OPM + // Not sure if it's the real solution, but script_origin entities are usually + // never sent to client so the sound will immediately get stopped + pChannel->iFlags |= CHANNEL_FLAG_MISSING_ENT; + } + } else { + VectorClear(pChannel->vOrigin); + pChannel->iTime = 0; + } + } + + pChannel->iStartTime = cl.serverTime; + pChannel->iEndTime = (int)(cl.serverTime + pSfx->time_length + 250.f); + + if (iFreeChannel > MAX_SOUNDSYSTEM_CHANNELS_3D + MAX_SOUNDSYSTEM_CHANNELS_2D) { + // streamed + if (!pChannel->set_sfx(pSfx)) { + Com_DPrintf("OpenAL: Set stream error - %s\n", pSfx->name); + return; + } + + pChannel->iBaseRate = pChannel->sample_playback_rate(); + pChannel->set_no_3d(); + fRealVolume = fRealVolume * s_fVolumeGain; + } else { + pChannel->stop(); + pChannel->set_no_3d(); + pChannel->set_sfx(pSfx); + } + + pChannel->set_gain(fRealVolume); + pChannel->play(); + + if (s_show_sounds->integer > 0) { + Com_DPrintf( + "OpenAL: 2D - %d (#%i) - %s (vol %f, mindist %f, maxdist %f)\n", + cl.serverTime, + iFreeChannel, + pSfx->name, + fVolume, + fMinDistance, + fMaxDistance + ); + } } +/* +============== +S_OPENAL_StartSound +============== +*/ void S_OPENAL_StartSound( const vec3_t vOrigin, int iEntNum, @@ -284,9 +1470,172 @@ void S_OPENAL_StartSound( qboolean bStreamed ) { - // FIXME: unimplemented + int iChannel; + openal_channel *pChannel; + sfx_info_t *pSfxInfo; + sfx_t *pSfx; + ALint state; + bool bOnlyUpdate; + bool bSupportWaitTillSoundDone; + + bOnlyUpdate = false; + pSfx = &s_knownSfx[sfxHandle]; + if (bStreamed) { + pSfx->iFlags |= SFX_FLAG_STREAMED; + } + + if (!S_OPENAL_ShouldPlay(pSfx)) { + Com_DPrintf("OpenAL: ^~^~^ Not playing sound '%s'\n", pSfx->name); + return; + } + + if ((pSfx->iFlags & (SFX_FLAG_NO_OFFSET) || pSfx->iFlags & (SFX_FLAG_STREAMED | SFX_FLAG_MP3)) + || iEntChannel == CHAN_MENU || iEntChannel == CHAN_LOCAL) { + S_OPENAL_Start2DSound(vOrigin, iEntNum, iEntChannel, pSfx, fVolume, fMinDist, fPitch, fMaxDist); + return; + } + + bSupportWaitTillSoundDone = (iEntNum & S_FLAG_DO_CALLBACK) != 0; + iEntNum &= ~S_FLAG_DO_CALLBACK; + + pSfxInfo = &sfx_infos[pSfx->sfx_info_index]; + if (pSfx->iFlags & SFX_FLAG_STREAMED) { + Com_DPrintf("OpenAL: 3D sounds not supported - couldn't play '%s'\n", pSfx->name); + return; + } + + iChannel = S_OPENAL_PickChannel3D(iEntNum, iEntChannel); + if (iChannel < 0) { + Com_DPrintf( + "OpenAL: Couldn't play %s sound '%s' for entity %i on channel %s\n", + (pSfx->iFlags & SFX_FLAG_STREAMED) ? "3Dstreamed" : "3D", + pSfx->name, + iEntNum, + S_ChannelNumToName(iEntChannel) + ); + return; + } + + if (bSupportWaitTillSoundDone) { + callbackServer(iEntNum, iChannel, pSfx->name); + } + + pChannel = &openal.chan_3D[iChannel]; + pChannel->fNewPitchMult = fPitch; + pChannel->iEntChannel = iEntChannel; + pChannel->iFlags &= ~(CHANNEL_FLAG_PAUSED | CHANNEL_FLAG_LOCAL_LISTENER); + state = pChannel->sample_status(); + + if (pChannel->iEntNum == iEntNum && (state == AL_PLAYING || state == AL_PAUSED) && pChannel->pSfx == pSfx) { + bOnlyUpdate = true; + } else { + pChannel->stop(); + pChannel->iFlags &= ~(CHANNEL_FLAG_LOOPING | CHANNEL_FLAG_PAUSED | CHANNEL_FLAG_LOCAL_LISTENER); + if (!pChannel->set_sfx(pSfx)) { + Com_DPrintf("OpenAL: Set sample error - %s\n", pSfx->name); + return; + } + } + + if (fMinDist < 0.0) { + fMinDist = 200.0; + fMaxDist = 12800.0; + } + pChannel->fMinDist = fMinDist; + pChannel->fMaxDist = fMaxDist; + + if (fVolume < 0.0) { + fVolume = 1.0; + } + + pChannel->fVolume = S_GetBaseVolume() * fVolume; + pChannel->set_gain(pChannel->fVolume); + + // Fixed in OPM + // Setup the channel for 3D + pChannel->set_3d(); + + if (s_show_sounds->integer > 0) { + Com_DPrintf( + "OpenAL: %d (#%i) - %s (vol %f, mindist %f, maxdist %f)\n", + cl.serverTime, + iChannel, + pSfx->name, + pChannel->fVolume, + fMinDist, + fMaxDist + ); + } + + pChannel->set_velocity(0, 0, 0); + if (iEntNum == ENTITYNUM_NONE) { + if (vOrigin) { + VectorCopy(vOrigin, pChannel->vOrigin); + } else { + //VectorClear(vOrigin); + // Fixed in OPM + // Tiny mistake found in original where the vOrigin parameter is set to 0 + VectorClear(pChannel->vOrigin); + } + + pChannel->set_position(pChannel->vOrigin[0], pChannel->vOrigin[1], pChannel->vOrigin[2]); + pChannel->iFlags |= CHANNEL_FLAG_NO_ENTITY; + pChannel->iEntNum = 0; + } else { + pChannel->iFlags &= ~CHANNEL_FLAG_NO_ENTITY; + pChannel->iEntNum = iEntNum; + if (vOrigin) { + VectorCopy(vOrigin, pChannel->vOrigin); + + bSupportWaitTillSoundDone = cl.serverTime - 1 < 0; + pChannel->iTime = cl.serverTime - 1; + if (bSupportWaitTillSoundDone) { + pChannel->iTime = 0; + } + + if (s_entity[iEntNum].time < pChannel->iTime) { + // Fixed in OPM + // Not sure if it's the real solution, but script_origin entities are usually + // never sent to client so the sound will immediately get stopped + pChannel->iFlags |= CHANNEL_FLAG_MISSING_ENT; + } + } else { + VectorClear(pChannel->vOrigin); + pChannel->iTime = 0; + } + pChannel->set_position(pChannel->vOrigin[0], pChannel->vOrigin[1], pChannel->vOrigin[2]); + } + + if (pSfxInfo->loop_start != -1) { + pChannel->set_sample_loop_block(pSfxInfo->loop_start, pSfxInfo->loop_end); + pChannel->set_sample_loop_count(0); + + pChannel->iFlags |= CHANNEL_FLAG_LOOPING; + if (s_show_sounds->integer) { + Com_DPrintf("OpenAL: loopblock - %d to %d\n", pSfxInfo->loop_start, pSfxInfo->loop_end); + } + } else { + pChannel->set_sample_loop_count(1); + } + + if (!bOnlyUpdate && S_OPENAL_ShouldStart(pChannel->vOrigin, pChannel->fMinDist, pChannel->fMaxDist)) { + // Fixed in OPM + // Make sure to set the pitch before playing the sound + pChannel->iBaseRate = pSfx->info.rate; + pChannel->set_sample_playback_rate(pChannel->iBaseRate * pChannel->fNewPitchMult); + pChannel->fNewPitchMult = 0; + + pChannel->play(); + pChannel->iEndTime = cl.serverTime + (int)pChannel->pSfx->time_length + 250; + pChannel->iStartTime = cl.serverTime; + } } +/* +============== +S_OPENAL_AddLoopingSound +============== +*/ void S_OPENAL_AddLoopingSound( const vec3_t vOrigin, const vec3_t vVelocity, @@ -298,42 +1647,263 @@ void S_OPENAL_AddLoopingSound( int iFlags ) { - // FIXME: unimplemented + int i; + int iFreeLoopSound; + sfx_t *pSfx; + openal_loop_sound_t *pLoopSound; + + iFreeLoopSound = -1; + pSfx = &s_knownSfx[sfxHandle]; + if (!pSfx || !pSfx->length) { + return; + } + + for (i = 0; i < (MAX_SOUNDSYSTEM_CHANNELS_3D + MAX_SOUNDSYSTEM_CHANNELS_2D); i++) { + pLoopSound = &openal.loop_sounds[i]; + if (pLoopSound->pSfx == pSfx && !pLoopSound->bInUse) { + iFreeLoopSound = i; + break; + } + } + + if (iFreeLoopSound < 0) { + for (i = 0; i < (MAX_SOUNDSYSTEM_CHANNELS_3D + MAX_SOUNDSYSTEM_CHANNELS_2D); i++) { + pLoopSound = &openal.loop_sounds[i]; + if (!pLoopSound->pSfx && !pLoopSound->bInUse) { + iFreeLoopSound = i; + pLoopSound->bPlaying = false; + break; + } + } + } + + if (iFreeLoopSound < 0) { + if (cls.realtime >= s_iNextLoopingWarning) { + Com_DPrintf("OpenAL: Too many looping sounds\n"); + s_iNextLoopingWarning = cls.realtime + 1000; + } + return; + } + + pLoopSound = &openal.loop_sounds[iFreeLoopSound]; + VectorCopy(vOrigin, pLoopSound->vOrigin); + VectorCopy(vVelocity, pLoopSound->vVelocity); + pLoopSound->pSfx = pSfx; + pLoopSound->bInUse = true; + pLoopSound->iStartTime = cls.realtime; + pLoopSound->fBaseVolume = fVolume; + pLoopSound->fMinDist = fMinDist; + pLoopSound->fMaxDist = fMaxDist; + pLoopSound->fPitch = fPitch; + pLoopSound->iFlags = iFlags; + pLoopSound->bCombine = VectorCompare(vVelocity, vec_zero) == 0; + + if (pLoopSound->bCombine) { + for (i = 0; i < (MAX_SOUNDSYSTEM_CHANNELS_3D + MAX_SOUNDSYSTEM_CHANNELS_2D); i++) { + if (openal.loop_sounds[i].pSfx == pSfx && openal.loop_sounds[i].bInUse) { + pLoopSound->iStartTime = openal.loop_sounds[i].iStartTime; + if (openal.loop_sounds[i].bPlaying) { + pLoopSound->bPlaying = true; + pLoopSound->iChannel = openal.loop_sounds[i].iChannel; + } + } + } + } } +/* +============== +S_OPENAL_StopLoopingSound +============== +*/ void S_OPENAL_StopLoopingSound(openal_loop_sound_t *pLoopSound) { - // FIXME: unimplemented + bool bMayStop; + int i; + openal_channel *pChannel; + + if (!pLoopSound->bPlaying) { + return; + } + bMayStop = true; + + if (pLoopSound->bCombine) { + for (i = 0; i < (MAX_SOUNDSYSTEM_CHANNELS_3D + MAX_SOUNDSYSTEM_CHANNELS_2D); i++) { + if (openal.loop_sounds[i].pSfx == pLoopSound->pSfx && openal.loop_sounds[i].bInUse) { + bMayStop = false; + break; + } + } + } + + if (bMayStop) { + if (s_show_sounds->integer > 0) { + Com_DPrintf( + "OpenAL: %d (#%i) - stopped loop - %s\n", + cl.serverTime, + pLoopSound->iChannel, + openal.channel[pLoopSound->iChannel]->pSfx->name + ); + } + openal.channel[pLoopSound->iChannel]->force_free(); + } + pLoopSound->pSfx = NULL; + pLoopSound->bPlaying = false; + + if (pLoopSound->bCombine) { + for (i = 0; i < (MAX_SOUNDSYSTEM_CHANNELS_3D + MAX_SOUNDSYSTEM_CHANNELS_2D); i++) { + if (openal.loop_sounds[i].pSfx == pLoopSound->pSfx) { + openal.loop_sounds[i].bPlaying = false; + openal.loop_sounds[i].pSfx = NULL; + } + } + } } +/* +============== +S_OPENAL_ClearLoopingSounds +============== +*/ void S_OPENAL_ClearLoopingSounds() { - // FIXME: unimplemented + int i; + + for (i = 0; i < (MAX_SOUNDSYSTEM_CHANNELS_3D + MAX_SOUNDSYSTEM_CHANNELS_2D); i++) { + openal.loop_sounds[i].bInUse = false; + } } +/* +============== +S_OPENAL_StopLoopingSounds +============== +*/ void S_OPENAL_StopLoopingSounds() { - // FIXME: unimplemented + int i; + + for (i = 0; i < (MAX_SOUNDSYSTEM_CHANNELS_3D + MAX_SOUNDSYSTEM_CHANNELS_2D); i++) { + openal.loop_sounds[i].bInUse = false; + S_OPENAL_StopLoopingSound(&openal.loop_sounds[i]); + } } -void S_OPENAL_StopSound(int iEntNum) +/* +============== +S_OPENAL_StopSound +============== +*/ +void S_OPENAL_StopSound(int iEntNum, int iEntChannel) { - // FIXME: unimplemented + int i; + + for (i = 0; i < MAX_SOUNDSYSTEM_POSITION_CHANNELS; i++) { + openal_channel *pChannel = openal.channel[i]; + if (!pChannel->is_free() && pChannel->iEntNum == iEntNum && pChannel->iEntChannel == iEntChannel) { + pChannel->end_sample(); + break; + } + } } +/* +============== +S_OPENAL_StopAllSounds +============== +*/ void S_OPENAL_StopAllSounds(qboolean bStopMusic) { - // FIXME: unimplemented + int i; + + if (!s_bSoundStarted) { + return; + } + + S_OPENAL_StopLoopingSounds(); + + for (i = 0; i < MAX_SOUNDSYSTEM_POSITION_CHANNELS; i++) { + openal_channel *pChannel = openal.channel[i]; + if (pChannel) { + pChannel->force_free(); + } + } + + if (bStopMusic) { + MUSIC_FreeAllSongs(); + S_TriggeredMusic_Stop(); + } } +/* +============== +S_OPENAL_Start2DLoopSound +============== +*/ static int S_OPENAL_Start2DLoopSound( openal_loop_sound_t *pLoopSound, float fVolume, float fVolumeToPlay, float fMinDistance, const vec3_t vLoopOrigin ) { - // FIXME: unimplemented - return 0; + int iChannel; + int iSoundOffset; + openal_channel *pChannel; + + if (pLoopSound->pSfx->iFlags & SFX_FLAG_STREAMED) { + iChannel = S_OPENAL_PickChannel2DStreamed(0, 0); + } else { + iChannel = S_OPENAL_PickChannel2D(0, 0); + } + + if (iChannel < 0) { + Com_DPrintf("OpenAL: Could not find a free 2D sound channel\n"); + return iChannel; + } + + pChannel = openal.channel[iChannel]; + pChannel->force_free(); + pChannel->fVolume = fVolume; + + if (pLoopSound->iFlags & LOOPSOUND_FLAG_NO_PAN) { + pChannel->iFlags |= CHANNEL_FLAG_LOCAL_LISTENER; + } else { + pChannel->iFlags &= ~CHANNEL_FLAG_LOCAL_LISTENER; + } + pChannel->fMinDist = fMinDistance; + + if (!pChannel->set_sfx(pLoopSound->pSfx)) { + Com_DPrintf("OpenAL: Set sample error (loopsound) - %s\n", pLoopSound->pSfx->name); + pChannel->iFlags &= ~CHANNEL_FLAG_PLAY_DEFERRED; + return -1; + } + + pChannel->iEntNum = 0; + pChannel->iEntChannel = 0; + pChannel->pSfx = pLoopSound->pSfx; + pChannel->iFlags |= CHANNEL_FLAG_PAUSED | CHANNEL_FLAG_NO_ENTITY; + pChannel->iBaseRate = pChannel->sample_playback_rate(); + VectorCopy(vLoopOrigin, pChannel->vOrigin); + + iSoundOffset = (int)(pLoopSound->pSfx->info.width * pLoopSound->pSfx->info.rate + * (float)(cls.realtime - pLoopSound->iStartTime) / 1000.0); + pChannel->set_sample_offset(iSoundOffset % pLoopSound->pSfx->length); + pChannel->set_sample_loop_count(0); + pChannel->fVolume = fVolumeToPlay; + pChannel->set_gain(fVolumeToPlay); + pChannel->start_sample(); + if (s_show_sounds->integer > 0) { + Com_DPrintf( + "OpenAL: %d (#%i) - %s (vol %f)\n", cl.serverTime, pLoopSound->iChannel, pLoopSound->pSfx->name, fVolume + ); + } + + return iChannel; } +/* +============== +S_OPENAL_Start3DLoopSound +============== +*/ static int S_OPENAL_Start3DLoopSound( openal_loop_sound_t *pLoopSound, float fVolumeToPlay, @@ -343,10 +1913,64 @@ static int S_OPENAL_Start3DLoopSound( const vec3_t vListenerOrigin ) { - // FIXME: unimplemented - return 0; + int iChannel; + vec3_t vDir; + int iSoundOffset; + openal_channel *pChan3D; + + if (pLoopSound->pSfx->iFlags & SFX_FLAG_STREAMED) { + return -1; + } + + if (!pLoopSound->pSfx->data || !pLoopSound->pSfx->length) { + return -1; + } + + iChannel = S_OPENAL_PickChannel3D(0, 0); + if (iChannel < 0) { + Com_DPrintf("OpenAL: Could not find a free channel\n"); + return iChannel; + } + + pChan3D = &openal.chan_3D[iChannel]; + pChan3D->force_free(); + pChan3D->iEntNum = 0; + pChan3D->iEntChannel = 0; + pChan3D->fMinDist = fMinDistance; + pChan3D->fMaxDist = fMaxDistance; + pChan3D->set_3d(); + + if (!pChan3D->set_sfx(pLoopSound->pSfx)) { + Com_DPrintf("OpenAL: Set sample error - %s\n", pLoopSound->pSfx->name); + return -1; + } + + pChan3D->set_position(vLoopOrigin[0], vLoopOrigin[1], vLoopOrigin[2]); + VectorScale(pLoopSound->vVelocity, s_fVelocityScale, pLoopSound->vVelocity); + pChan3D->set_velocity(pLoopSound->vVelocity[0], pLoopSound->vVelocity[1], pLoopSound->vVelocity[2]); + pChan3D->pSfx = pLoopSound->pSfx; + pChan3D->iFlags |= CHANNEL_FLAG_PAUSED | CHANNEL_FLAG_NO_ENTITY; + pChan3D->iBaseRate = pChan3D->sample_playback_rate(); + + iSoundOffset = (int)((int)pLoopSound->pSfx->info.width * pLoopSound->pSfx->info.rate + * (float)(cls.realtime - pLoopSound->iStartTime) / 1000.0) + % pLoopSound->pSfx->length; + pChan3D->set_sample_offset(iSoundOffset); + pChan3D->set_sample_loop_count(0); + pChan3D->fVolume = fVolumeToPlay; + pChan3D->set_gain(fVolumeToPlay); + pChan3D->play(); + + S_OPENAL_reverb(iChannel, s_iReverbType, s_fReverbLevel); + + return iChannel; } +/* +============== +S_OPENAL_UpdateLoopSound +============== +*/ static bool S_OPENAL_UpdateLoopSound( openal_loop_sound_t *pLoopSound, float fVolumeToPlay, @@ -357,401 +1981,3065 @@ static bool S_OPENAL_UpdateLoopSound( const vec3_t vLoopOrigin ) { - // FIXME: unimplemented - return false; + openal_channel *pChannel; + float fVolume; + float fMaxVolume; + vec3_t vDir; + float fDistance; + + pChannel = openal.channel[pLoopSound->iChannel]; + if (!pChannel) { + return false; + } + + if (pChannel->pSfx != pLoopSound->pSfx) { + pLoopSound->bPlaying = 0; + return false; + } + + pChannel->iStartTime = cl.serverTime; + + if (pLoopSound->pSfx->iFlags & (SFX_FLAG_NO_OFFSET) || pLoopSound->pSfx->iFlags & (SFX_FLAG_STREAMED | SFX_FLAG_MP3) + || (pLoopSound->iFlags & LOOPSOUND_FLAG_NO_PAN)) { + vec3_t vOrigin; + int iPan; + + pChannel->fVolume = fVolumeToPlay / s_fVolumeGain; + fVolume = S_GetBaseVolume() * pChannel->fVolume; + fMaxVolume = fVolume; + + if (pLoopSound->iFlags & LOOPSOUND_FLAG_NO_PAN) { + // Center the sound + iPan = 64; + } else { + VectorCopy(vLoopOrigin, vOrigin); + iPan = S_OPENAL_SpatializeStereoSound(vListenerOrigin, vTempAxis, vOrigin); + + VectorSubtract(vListenerOrigin, vOrigin, vDir); + // Clamp the volume by distance + fDistance = VectorLength(vDir); + if (pChannel->fMinDist >= fDistance) { + fVolume = fMaxVolume; + } else { + fVolume = pChannel->fMinDist / fDistance * fMaxVolume; + } + } + + pChannel->set_gain(fVolume); + pChannel->set_sample_pan(iPan); + } else { + pChannel->set_position(vLoopOrigin[0], vLoopOrigin[1], vLoopOrigin[2]); + pChannel->fVolume = fVolumeToPlay; + pChannel->set_gain(fVolumeToPlay); + } + + if (s_bReverbChanged) { + // Make sure to update the reverb + S_OPENAL_reverb(pLoopSound->iChannel, s_iReverbType, s_fReverbLevel); + } + + return true; } +/* +============== +S_OPENAL_AddLoopSounds +============== +*/ void S_OPENAL_AddLoopSounds(const vec3_t vTempAxis) { - // FIXME: unimplemented + int i, j; + static int iLoopFrame = 0; + float fDistance; + int iChannel; + vec3_t vListenerOrigin; + vec3_t vLoopOrigin; + openal_loop_sound_t *pLoopSound; + float fTotalVolume; + float fVolumeToPlay; + float fMinDistance, fMaxDistance; + float fVolume; + float fPitch; + float fMaxVolume, fMaxFactor; + openal_channel *pChannel; + bool bAlreadyAdded[MAX_SOUNDSYSTEM_LOOP_SOUNDS] = {false}; + vec3_t alvec; + + qalGetListenerfv(AL_POSITION, alvec); + VectorCopy(alvec, vListenerOrigin); + + for (i = 0; i < MAX_SOUNDSYSTEM_LOOP_SOUNDS; i++) { + vec3_t vDir; + + if (bAlreadyAdded[i]) { + continue; + } + + pLoopSound = &openal.loop_sounds[i]; + if (!pLoopSound->pSfx) { + continue; + } + pChannel = openal.channel[pLoopSound->iChannel]; + + fMinDistance = pLoopSound->fMinDist; + if (fMinDistance < 0) { + fMinDistance = 200; + } + + fMaxDistance = pLoopSound->fMaxDist; + if (fMaxDistance < 0) { + fMaxDistance = fMinDistance * 64; + } + + fVolume = pLoopSound->fBaseVolume; + if (fVolume < 0) { + fVolume = 1; + } + fVolume = fVolume * s_fAmbientVolume; + + fTotalVolume = 0.0; + fMaxVolume = 0.0; + + if (pLoopSound->bPlaying) { + pChannel->fNewPitchMult = pLoopSound->fPitch; + } + + if (pLoopSound->bCombine) { + for (j = 0; j < MAX_LOOP_SOUNDS; j++) { + openal_loop_sound_t *pLoopSound2 = &openal.loop_sounds[j]; + + if (pLoopSound2->pSfx == pLoopSound->pSfx) { + VectorSubtract(pLoopSound2->vOrigin, vListenerOrigin, vDir); + VectorCopy(vDir, pLoopSound2->vRelativeOrigin); + fDistance = VectorLength(pLoopSound2->vRelativeOrigin); + + if (fDistance <= fMinDistance) { + fVolumeToPlay = fVolume; + } else if (fDistance >= fMaxDistance) { + fVolumeToPlay = 0; + } else { + fVolumeToPlay = fMinDistance * fMinDistance * fVolume / (fDistance * fDistance); + } + + if (fMaxVolume < fVolumeToPlay) { + fMaxVolume = fVolumeToPlay; + } + fTotalVolume += fVolumeToPlay; + bAlreadyAdded[j] = true; + } + } + } else { + VectorSubtract(pLoopSound->vOrigin, vListenerOrigin, vDir); + VectorCopy(vDir, pLoopSound->vRelativeOrigin); + fDistance = VectorLength(pLoopSound->vRelativeOrigin); + + if (fDistance <= fMinDistance) { + fTotalVolume = fVolume; + } else if (fDistance >= fMaxDistance) { + fTotalVolume = 0; + } else { + fTotalVolume = fMinDistance * fMinDistance * fVolume / (fDistance * fDistance); + } + pLoopSound->fVolume = fTotalVolume; + fMaxVolume = fTotalVolume; + } + + fMaxFactor = sfx_infos[pLoopSound->pSfx->sfx_info_index].max_factor; + if (fMaxFactor >= 1 && fMaxVolume * fMaxFactor < fTotalVolume) { + fTotalVolume = fMaxVolume * fMaxFactor; + } + + if (fTotalVolume <= 0 && !(pLoopSound->iFlags & LOOPSOUND_FLAG_NO_PAN)) { + if (pLoopSound->bPlaying) { + if (s_show_sounds->integer > 0) { + Com_DPrintf( + "OpenAL: %d (#%i) - stopped loop - %s\n", + cl.serverTime, + pLoopSound->iChannel, + openal.channel[pLoopSound->iChannel]->pSfx->name + ); + } + + pChannel->stop(); + pLoopSound->bPlaying = false; + if (pLoopSound->bCombine) { + for (j = 0; j < MAX_LOOP_SOUNDS; j++) { + openal_loop_sound_t *pLoopSound2 = &openal.loop_sounds[j]; + + if (pLoopSound2->pSfx == pLoopSound->pSfx) { + pLoopSound2->bPlaying = false; + } + } + } + } + + continue; + } + + VectorClear(vLoopOrigin); + + if (pLoopSound->bCombine) { + for (j = 0; j < MAX_LOOP_SOUNDS; j++) { + openal_loop_sound_t *pLoopSound2 = &openal.loop_sounds[j]; + + if (pLoopSound2->pSfx == pLoopSound->pSfx) { + VectorNormalize(pLoopSound2->vRelativeOrigin); + + VectorScale( + pLoopSound2->vRelativeOrigin, pLoopSound2->fVolume / fTotalVolume, pLoopSound2->vRelativeOrigin + ); + VectorAdd(pLoopSound2->vRelativeOrigin, vLoopOrigin, vLoopOrigin); + } + } + + VectorNormalize(vLoopOrigin); + VectorMA(vListenerOrigin, fMinDistance * 0.5f, vLoopOrigin, vLoopOrigin); + } else { + VectorCopy(pLoopSound->vOrigin, vLoopOrigin); + } + + if (pLoopSound->bPlaying) { + S_OPENAL_UpdateLoopSound( + pLoopSound, + S_GetBaseVolume() * s_fVolumeGain * fTotalVolume, + fMinDistance, + fMaxDistance, + vListenerOrigin, + vTempAxis, + vLoopOrigin + ); + + continue; + } + + if (s_show_sounds->integer > 0) { + Com_DPrintf( + "OpenAL: %d (#%i) - started loop - %s\n", cl.serverTime, pLoopSound->iChannel, pLoopSound->pSfx->name + ); + } + + if (pLoopSound->pSfx->iFlags & (SFX_FLAG_NO_OFFSET) + || pLoopSound->pSfx->iFlags & (SFX_FLAG_STREAMED | SFX_FLAG_MP3) + || (pLoopSound->iFlags & LOOPSOUND_FLAG_NO_PAN)) { + iChannel = S_OPENAL_Start2DLoopSound( + pLoopSound, fVolume, S_GetBaseVolume() * s_fVolumeGain * fTotalVolume, fMinDistance, vLoopOrigin + ); + } else { + iChannel = S_OPENAL_Start3DLoopSound( + pLoopSound, + S_GetBaseVolume() * s_fVolumeGain * fTotalVolume, + fMinDistance, + fMaxDistance, + vLoopOrigin, + vListenerOrigin + ); + } + + if (iChannel < 0) { + continue; + } + + pLoopSound->bPlaying = true; + pLoopSound->iChannel = iChannel; + + if (pLoopSound->bCombine) { + for (j = 0; j < MAX_LOOP_SOUNDS; j++) { + openal_loop_sound_t *pLoopSound2 = &openal.loop_sounds[j]; + + if (pLoopSound2->pSfx == pLoopSound->pSfx) { + pLoopSound2->bPlaying = true; + pLoopSound2->iChannel = iChannel; + } + } + } + } } +/* +============== +S_OPENAL_Respatialize +============== +*/ void S_OPENAL_Respatialize(int iEntNum, const vec3_t vHeadPos, const vec3_t vAxis[3]) { - // FIXME: unimplemented + int i; + vec3_t vOrigin; + vec3_t vVelocity; + vec3_t vEntOrigin; + vec3_t vEntVelocity; + vec3_t vDir; + vec3_t vUp; + vec3_t vListenerOrigin; + int iPan; + vec3_t vTempAxis; + float fMaxVolume; + float fVolume; + float fDist; + openal_channel *pChannel; + vec3_t alvec {0}; + vec3_t alorientation[2]; + + if (cls.no_menus) { + return; + } + + s_iListenerNumber = iEntNum; + + // + // Velocity + // + VectorCopy(s_entity[iEntNum].velocity, alvec); + VectorScale(alvec, s_fVelocityScale, alvec); + qalListenerfv(AL_VELOCITY, alvec); + alDieIfError(); + + // + // Position + // + VectorCopy(vHeadPos, alvec); + VectorCopy(alvec, vListenerOrigin); + qalListenerfv(AL_POSITION, alvec); + alDieIfError(); + + // + // Orientation + // + alorientation[0][0] = vAxis[0][0]; + alorientation[0][1] = vAxis[0][1]; + alorientation[0][2] = vAxis[0][2]; + alorientation[1][0] = vAxis[2][0]; + alorientation[1][1] = vAxis[2][1]; + alorientation[1][2] = vAxis[2][2]; + qalListenerfv(AL_ORIENTATION, (const ALfloat *)alorientation); + alDieIfError(); + + VectorCopy(vAxis[1], vTempAxis); + + fVolume = 1; + iPan = 64; + + for (i = 0; i < MAX_SOUNDSYSTEM_POSITION_CHANNELS; i++) { + pChannel = openal.channel[i]; + fMaxVolume = S_GetBaseVolume() * pChannel->fVolume; + + if (!pChannel) { + continue; + } + + if (!pChannel->is_playing()) { + continue; + } + + if (pChannel->iFlags & CHANNEL_FLAG_PAUSED) { + continue; + } + + if (pChannel->iFlags & CHANNEL_FLAG_NO_ENTITY) { + VectorCopy(pChannel->vOrigin, vOrigin); + + if (pChannel->iFlags & CHANNEL_FLAG_LOCAL_LISTENER) { + VectorCopy(vListenerOrigin, vOrigin); + if (i >= MAX_SOUNDSYSTEM_CHANNELS_3D) { + fVolume = fMaxVolume; + iPan = 64; + } else { + pChannel->set_position(vOrigin[0], vOrigin[1], vOrigin[2]); + } + } else { + if (i >= MAX_SOUNDSYSTEM_CHANNELS_3D) { + iPan = S_OPENAL_SpatializeStereoSound(vListenerOrigin, vTempAxis, vOrigin); + VectorSubtract(vListenerOrigin, vOrigin, vDir); + + fDist = VectorLength(vDir); + if (fDist <= pChannel->fMinDist + 0.001f) { + fVolume = fMaxVolume; + } else if (fDist >= pChannel->fMaxDist - 0.001f) { + fVolume = 0; + } else { + fVolume = (1.0 - (fDist - pChannel->fMinDist) / (pChannel->fMaxDist - pChannel->fMinDist)) + * fMaxVolume; + } + } else { + pChannel->set_position(vOrigin[0], vOrigin[1], vOrigin[2]); + } + } + } else if (pChannel->iFlags & CHANNEL_FLAG_LOCAL_LISTENER) { + VectorCopy(vListenerOrigin, vOrigin); + if (i >= MAX_SOUNDSYSTEM_CHANNELS_3D) { + fVolume = fMaxVolume; + iPan = 64; + } else { + pChannel->set_position(vOrigin[0], vOrigin[1], vOrigin[2]); + } + } else { + if (s_entity[pChannel->iEntNum].time < pChannel->iTime) { + VectorCopy(pChannel->vOrigin, vOrigin); + if (!(pChannel->iFlags & CHANNEL_FLAG_LOOPING) && !(pChannel->iFlags & (CHANNEL_FLAG_MISSING_ENT))) { + pChannel->end_sample(); + continue; + } + } else { + pChannel->iFlags &= ~CHANNEL_FLAG_MISSING_ENT; + + VectorCopy(s_entity[pChannel->iEntNum].position, vEntOrigin); + VectorCopy(vEntOrigin, vOrigin); + VectorCopy(vOrigin, pChannel->vOrigin); + pChannel->iTime = s_entity[pChannel->iEntNum].time; + } + + if (s_entity[pChannel->iEntNum].use_listener) { + VectorCopy(vListenerOrigin, vOrigin); + } + + if (pChannel->iEntNum == s_iListenerNumber) { + if (vListenerOrigin[0] == vOrigin[0] && vListenerOrigin[2] == vOrigin[2]) { + float fDelta = vListenerOrigin[1] - vOrigin[1]; + + if (fDelta > 89.9f && fDelta < 90.09f) { + VectorCopy(vListenerOrigin, vOrigin); + } + } + } + + if (i >= MAX_SOUNDSYSTEM_CHANNELS_3D) { + iPan = S_OPENAL_SpatializeStereoSound(vListenerOrigin, vTempAxis, vOrigin); + VectorSubtract(vListenerOrigin, vOrigin, vDir); + fDist = VectorLength(vDir); + if (fDist <= pChannel->fMinDist + 0.001f) { + fVolume = fMaxVolume; + } else if (fDist >= pChannel->fMaxDist - 0.001f) { + fVolume = 0; + } else { + fVolume = + (1.0 - (fDist - pChannel->fMinDist) / (pChannel->fMaxDist - pChannel->fMinDist)) * fMaxVolume; + } + } else { + pChannel->set_position(vOrigin[0], vOrigin[1], vOrigin[2]); + VectorCopy(s_entity[pChannel->iEntNum].velocity, vEntVelocity); + VectorCopy(vEntVelocity, vVelocity); + VectorScale(vVelocity, s_fVelocityScale, vVelocity); + pChannel->set_velocity(vVelocity[0], vVelocity[1], vVelocity[2]); + } + } + + if (i >= MAX_SOUNDSYSTEM_CHANNELS_3D) { + pChannel->set_gain(fVolume); + pChannel->set_sample_pan(iPan); + } + + if (s_bReverbChanged) { + S_OPENAL_reverb(i, s_iReverbType, s_fReverbLevel); + } + } + + S_OPENAL_AddLoopSounds(vTempAxis); + s_bReverbChanged = false; } +/* +============== +S_OPENAL_SpatializeStereoSound +============== +*/ static int S_OPENAL_SpatializeStereoSound(const vec3_t listener_origin, const vec3_t listener_left, const vec3_t origin) { - // FIXME: unimplemented - return 0; + float lscale, rscale; + vec3_t source_vec; + float pan; + + VectorSubtract(origin, listener_origin, source_vec); + VectorNormalize(source_vec); + + pan = s_separation->value + (1.f - s_separation->value) * -DotProduct(listener_left, source_vec); + + if (pan < 0) { + pan = 0; + } + + return ceilf(pan * 127); } +/* +============== +S_OPENAL_reverb +============== +*/ static void S_OPENAL_reverb(int iChannel, int iReverbType, float fReverbLevel) { - // FIXME: unimplemented + // FIXME: Connect source to effect slot + // see https://github.com/kcat/openal-soft/blob/master/examples/alreverb.c + + // No reverb currently. } +/* +============== +S_OPENAL_SetReverb +============== +*/ void S_OPENAL_SetReverb(int iType, float fLevel) { - // FIXME: unimplemented + s_fReverbLevel = fLevel; + s_iReverbType = iType; + if (al_use_reverb) { + s_bReverbChanged = true; + } + + // FIXME: generate effect and auxiliary effect slot + // or destroy them + // see https://github.com/kcat/openal-soft/blob/master/examples/alreverb.c } +/* +============== +S_OPENAL_Update +============== +*/ void S_OPENAL_Update() { - // FIXME: unimplemented + int i; + openal_channel *pChannel; + + if (cl.snap.ps.stats[STAT_CINEMATIC]) { + S_SetGlobalAmbientVolumeLevel(0.5f); + } else { + S_SetGlobalAmbientVolumeLevel(1.f); + } + + if (paused->integer && !s_bSoundPaused) { + S_PauseSound(); + } else if (!paused->integer && s_bSoundPaused) { + S_UnpauseSound(); + } + + if (s_bFading) { + s_fFadeVolume = 1.f - (cls.realtime - s_fFadeStartTime) / (s_fFadeStopTime - s_fFadeStartTime); + if (s_fFadeVolume < 0) { + s_fFadeVolume = 0; + } + music_volume_changed = true; + } + + if (s_volume->modified) { + if (s_volume->value > 1) { + Cvar_Set("s_volume", "1.0"); + } else if (s_volume->value < 0) { + Cvar_Set("s_volume", "0.0"); + } + + music_volume_changed = true; + s_volume->modified = 0; + al_current_volume = Square(s_volume->value); + qalListenerf(AL_GAIN, al_current_volume); + alDieIfError(); + } + + for (i = 0; i < MAX_SOUNDSYSTEM_POSITION_CHANNELS; i++) { + pChannel = openal.channel[i]; + if (!pChannel) { + continue; + } + + if (!pChannel->is_playing()) { + continue; + } + + if (pChannel->fNewPitchMult <= 0) { + continue; + } + + pChannel->set_sample_playback_rate(pChannel->iBaseRate * pChannel->fNewPitchMult); + pChannel->fNewPitchMult = 0; + } + + if (s_speaker_type->modified) { + Cbuf_AddText("snd_restart\n"); + s_speaker_type->modified = false; + } + + if (s_reverb->modified) { + s_reverb->modified = false; + + if (s_reverb->integer) { + if (al_use_reverb) { + S_OPENAL_SetReverb(s_iReverbType, s_fReverbLevel); + } else { + Com_Printf("OpenAL: No reverb support. Reverb is disabled.\n"); + } + } else if (al_use_reverb) { + S_OPENAL_SetReverb(0, 0); + } + } + + if (s_show_num_active_sounds->integer == 1) { + int num = 0; + + for (i = 0; i < MAX_SOUNDSYSTEM_POSITION_CHANNELS; i++) { + pChannel = openal.channel[i]; + if (pChannel && pChannel->is_playing()) { + ++num; + } + } + Com_DPrintf("OpenAL: Number of active sounds = %d\n", num); + } + + Music_Update(); + + for (i = 0; i < MAX_LOOP_SOUNDS; i++) { + if (!openal.loop_sounds[i].bInUse) { + S_OPENAL_StopLoopingSound(&openal.loop_sounds[i]); + } + } + + for (i = 0; i < MAX_SOUNDSYSTEM_CHANNELS; i++) { + openal.channel[i]->update(); + } } +/* +============== +S_OPENAL_GetMusicFilename +============== +*/ +const char *S_OPENAL_GetMusicFilename() +{ + // Don't call into the channel if QAL initialisation did not succeed. + if (!al_initialized) { + return ""; + } + + if (!openal.chan_trig_music.is_playing() && !openal.chan_trig_music.is_paused()) { + return ""; + } + + return openal.tm_filename; +} + +/* +============== +S_OPENAL_GetMusicLoopCount +============== +*/ +int S_OPENAL_GetMusicLoopCount() +{ + return openal.tm_loopcount; +} + +/* +============== +S_OPENAL_GetMusicOffset +============== +*/ +unsigned int S_OPENAL_GetMusicOffset() +{ + return openal.chan_trig_music.sample_offset(); +} + +/* +============== +S_IsSoundPlaying +============== +*/ qboolean S_IsSoundPlaying(int channel_number, const char *sfxName) { - // FIXME: unimplemented - return qfalse; + openal_channel *pChannel = openal.channel[channel_number]; + if (!pChannel) { + return false; + } + + if (s_bSoundPaused) { + return false; + } + + if (!pChannel->is_playing()) { + return false; + } + + if (!pChannel->pSfx) { + return false; + } + + if (strcmp(sfxName, pChannel->pSfx->name)) { + return false; + } + + return true; } +/* +============== +S_StoreBase +============== +*/ static void S_StoreBase(channelbasesavegame_t *pBase, openal_channel *pChannel) { - // FIXME: unimplemented + if (!pChannel) { + return; + } + + if (pChannel->iEntChannel == CHAN_MENU || pChannel->is_free()) { + pBase->bPlaying = false; + pBase->iOffset = 0; + pBase->iLoopCount = 0; + pBase->sfx.szName[0] = 0; + pBase->sfx.iFlags = 0; + pBase->fNewPitchMult = 1.f; + pBase->iBaseRate = pChannel->iBaseRate; + pBase->iStatus = 0; + } else { + pBase->bPlaying = true; + pBase->iOffset = pChannel->sample_offset(); + pBase->iLoopCount = pChannel->sample_loop_count(); + memcpy(pBase->sfx.szName, pChannel->pSfx->name, sizeof(pBase->sfx.szName)); + pBase->sfx.iFlags = pChannel->pSfx->iFlags; + pBase->iBaseRate = pChannel->iBaseRate; + pBase->iStatus = 0; + pBase->fNewPitchMult = (float)pBase->iBaseRate / (float)pChannel->sample_playback_rate(); + } + + pBase->iStartTime = pChannel->iStartTime - cl.serverTime; + pBase->iEndTime = pChannel->iEndTime - cl.serverTime; + pBase->iEntChannel = pChannel->iEntChannel; + pBase->iEntNum = pChannel->iEntNum; + pBase->iFlags = pChannel->iFlags; + pBase->fMaxDist = pChannel->fMaxDist; + pBase->fMinDist = pChannel->fMinDist; + pBase->iNextCheckObstructionTime = 0; + VectorCopy(pChannel->vOrigin, pBase->vOrigin); + pBase->iTime = pChannel->iTime - cl.serverTime; + pBase->fVolume = pChannel->fVolume; } +/* +============== +S_StartSoundFromBase +============== +*/ static void S_StartSoundFromBase(channelbasesavegame_t *pBase, openal_channel *pChannel, sfx_t *pSfx, bool bStartUnpaused) { - // FIXME: unimplemented + if (!pChannel->set_sfx(pSfx)) { + Com_DPrintf("OpenAL: Set sample error - %s\n", pSfx->name); + pChannel->iFlags &= ~CHANNEL_FLAG_PLAY_DEFERRED; + return; + } + + pChannel->iBaseRate = pChannel->sample_playback_rate(); + + if (sfx_infos[pSfx->sfx_info_index].loop_start != -1) { + pChannel->set_sample_loop_block( + sfx_infos[pSfx->sfx_info_index].loop_start, sfx_infos[pSfx->sfx_info_index].loop_end + ); + pChannel->set_sample_loop_count(1); + pChannel->iFlags |= CHANNEL_FLAG_LOOPING; + if (s_show_sounds->integer > 0) { + Com_DPrintf( + "OpenAL: loopblock - %d to %d\n", + sfx_infos[pSfx->sfx_info_index].loop_start, + sfx_infos[pSfx->sfx_info_index].loop_end + ); + } + } else { + pChannel->set_sample_loop_count(1); + } + + pChannel->set_gain(pChannel->fVolume); + pChannel->set_sample_offset(pBase->iOffset); + pChannel->set_sample_playback_rate(pChannel->iBaseRate * pBase->fNewPitchMult); + + if (bStartUnpaused) { + pChannel->resume_sample(); + } else { + pChannel->iFlags |= CHANNEL_FLAG_PLAY_DEFERRED; + } + + if (pChannel->iEntNum != ENTITYNUM_NONE) { + s_entity[pChannel->iEntNum].time = pChannel->iTime; + VectorCopy(pChannel->vOrigin, s_entity[pChannel->iEntNum].position); + } } +/* +============== +S_LoadBase +============== +*/ static void S_LoadBase(channelbasesavegame_t *pBase, openal_channel *pChannel, bool bStartUnpaused) { - // FIXME: unimplemented + sfxHandle_t handle; + + if (!pChannel) { + return; + } + + if (!pBase->bPlaying) { + return; + } + + if (strstr(pBase->sfx.szName, "null.wav")) { + return; + } + + handle = S_RegisterSound(pBase->sfx.szName, (pBase->sfx.iFlags & SFX_FLAG_STREAMED), false); + + pChannel->iBaseRate = pBase->iBaseRate; + pChannel->iStartTime = pBase->iStartTime; + pChannel->iEndTime = pBase->iEndTime; + pChannel->iEntChannel = pBase->iEntChannel; + pChannel->iEntNum = pBase->iEntNum; + pChannel->iFlags = pBase->iFlags; + pChannel->fMaxDist = pBase->fMaxDist; + pChannel->fMinDist = pBase->fMinDist; + pChannel->fNewPitchMult = pBase->fNewPitchMult; + VectorCopy(pBase->vOrigin, pChannel->vOrigin); + pChannel->iTime = pBase->iTime; + pChannel->fVolume = pBase->fVolume; + pChannel->pSfx = &s_knownSfx[handle]; + + S_StartSoundFromBase(pBase, pChannel, &s_knownSfx[handle], bStartUnpaused); } +/* +============== +S_SaveData +============== +*/ void S_SaveData(soundsystemsavegame_t *pSave) { - // FIXME: unimplemented + int i; + bool bSoundWasUnpaused; + + bSoundWasUnpaused = !s_bSoundPaused; + if (!s_bSoundPaused) { + S_PauseSound(); + } + + for (i = 0; i < MAX_SOUNDSYSTEM_POSITION_CHANNELS; i++) { + S_StoreBase(&pSave->Channels[i], openal.channel[i]); + } + + if (bSoundWasUnpaused) { + S_UnpauseSound(); + } } +/* +============== +S_ReLoad +============== +*/ void S_ReLoad(soundsystemsavegame_t *pSave) { - // FIXME: unimplemented + int i; + bool bSoundWasUnpaused; + + bSoundWasUnpaused = !s_bSoundPaused; + if (!s_bSoundPaused) { + S_PauseSound(); + } + + for (i = 0; i < MAX_SOUNDSYSTEM_POSITION_CHANNELS; i++) { + S_LoadBase(&pSave->Channels[i], openal.channel[i], bSoundWasUnpaused); + } + + if (bSoundWasUnpaused) { + S_UnpauseSound(); + } } +/* +============== +S_InitBase +============== +*/ static void S_InitBase(channelbasesavegame_t *pBase) { - // FIXME: unimplemented + if (!pBase->bPlaying) { + return; + } + + if (strstr(pBase->sfx.szName, "null.wav")) { + return; + } + + SV_AddSvsTimeFixup(&pBase->iStartTime); + SV_AddSvsTimeFixup(&pBase->iEndTime); + SV_AddSvsTimeFixup(&pBase->iTime); } +/* +============== +S_LoadData +============== +*/ void S_LoadData(soundsystemsavegame_t *pSave) { - // FIXME: unimplemented + int i; + + for (i = 0; i < MAX_SOUNDSYSTEM_POSITION_CHANNELS; i++) { + S_InitBase(&pSave->Channels[i]); + } } +/* +============== +openal_channel::set_velocity +============== +*/ void openal_channel::set_velocity(float v0, float v1, float v2) { - // FIXME: unimplemented + qalSource3f(source, AL_VELOCITY, v0, v1, v2); + alDieIfError(); } +/* +============== +openal_channel::set_position +============== +*/ void openal_channel::set_position(float v0, float v1, float v2) { - // FIXME: unimplemented + qalSource3f(source, AL_POSITION, v0, v1, v2); + alDieIfError(); } +/* +============== +openal_channel::set_gain +============== +*/ void openal_channel::set_gain(float gain) { - // FIXME: unimplemented + qalSourcef(source, AL_GAIN, gain); + alDieIfError(); } +/* +============== +openal_channel::set_no_3d +============== +*/ void openal_channel::set_no_3d() { - // FIXME: unimplemented + qalSource3f(source, AL_POSITION, 0, 0, 0); + alDieIfError(); + qalSource3f(source, AL_VELOCITY, 0, 0, 0); + alDieIfError(); + qalSourcei(source, AL_SOURCE_RELATIVE, true); + alDieIfError(); + qalSourcei(source, AL_LOOPING, false); + alDieIfError(); + qalSourcei(source, AL_ROLLOFF_FACTOR, 0); + alDieIfError(); + qalSourcef(source, AL_GAIN, S_GetBaseVolume()); + alDieIfError(); } +/* +============== +openal_channel::set_3d +============== +*/ void openal_channel::set_3d() { - // FIXME: unimplemented + qalSourcei(source, AL_SOURCE_RELATIVE, false); + alDieIfError(); + qalSourcei(source, AL_LOOPING, false); + alDieIfError(); + qalSourcef(source, AL_ROLLOFF_FACTOR, 1.0f); + alDieIfError(); + qalSourcef(source, AL_GAIN, S_GetBaseVolume()); + alDieIfError(); + qalSourcei(source, AL_DISTANCE_MODEL, AL_LINEAR_DISTANCE_CLAMPED); + alDieIfError(); + // + // Added in OPM + // + if (fMinDist > 0) { + qalSourcef(source, AL_REFERENCE_DISTANCE, fMinDist); + alDieIfError(); + } + if (fMaxDist > 0) { + qalSourcef(source, AL_MAX_DISTANCE, fMaxDist); + alDieIfError(); + } } +/* +============== +openal_channel::play +============== +*/ void openal_channel::play() { - // FIXME: unimplemented + qalSourcePlay(source); + alDieIfError(); } +/* +============== +openal_channel::set_no_virtualization +============== +*/ +void openal_channel::set_no_virtualization() +{ +#if AL_SOFT_direct_channels_remix + qalSourcei(source, AL_DIRECT_CHANNELS_SOFT, AL_REMIX_UNMATCHED_SOFT); + alDieIfError(); +#elif AL_SOFT_direct_channels + qalSourcei(source, AL_DIRECT_CHANNELS_SOFT, AL_TRUE); + alDieIfError(); +#endif +} + +/* +============== +openal_channel::set_virtualization +============== +*/ +void openal_channel::set_virtualization() +{ +#if AL_SOFT_direct_channels_remix || AL_SOFT_direct_channels + qalSourcei(source, AL_DIRECT_CHANNELS_SOFT, AL_FALSE); + alDieIfError(); +#endif +} + +/* +============== +openal_channel::pause +============== +*/ void openal_channel::pause() { - // FIXME: unimplemented + qalSourcePause(source); + alDieIfError(); } +/* +============== +openal_channel::stop +============== +*/ void openal_channel::stop() { - // FIXME: unimplemented -} - -ALint openal_channel::get_state() -{ - // FIXME: unimplemented - return 0; + qalSourceStop(source); + alDieIfError(); } +/* +============== +openal_channel::is_free +============== +*/ bool openal_channel::is_free() { - // FIXME: unimplemented - return false; + ALint state = sample_status(); + + return state == AL_INITIAL || state == AL_STOPPED; } +/* +============== +openal_channel::is_paused +============== +*/ bool openal_channel::is_paused() { - // FIXME: unimplemented - return false; + ALint state = sample_status(); + + return state == AL_PAUSED; } +/* +============== +openal_channel::is_playing +============== +*/ bool openal_channel::is_playing() { - // FIXME: unimplemented - return false; + ALint state = sample_status(); + + return state == AL_PLAYING; } +/* +============== +openal_channel::force_free +============== +*/ void openal_channel::force_free() { - // FIXME: unimplemented + stop(); + iFlags = 0; } +/* +============== +openal_channel::set_sfx +============== +*/ bool openal_channel::set_sfx(sfx_t *pSfx) { - // FIXME: unimplemented - return false; + ALint freq = 0; + + assert(pSfx->length); + + this->pSfx = pSfx; + if (!pSfx->buffer || !qalIsBuffer(pSfx->buffer)) { + if (pSfx->iFlags & SFX_FLAG_MP3) { + qalGenBuffers(1, &pSfx->buffer); + alDieIfError(); + + if (!S_OPENAL_LoadMP3_Codec(pSfx->name, pSfx)) { + qalDeleteBuffers(1, &pSfx->buffer); + alDieIfError(); + + Com_DPrintf("OpenAL: Failed to load MP3.\n"); + return false; + } + + alDieIfError(); + } else { + ALenum fmt = S_OPENAL_Format(pSfx->info.width, pSfx->info.channels); + + if (!fmt) { + Com_Printf( + "OpenAL: Bad Wave file (%d channels, %d bits) [%s].\n", + pSfx->info.channels, + (int)(pSfx->info.width * 8), + pSfx->name + ); + return false; + } + + if (pSfx->info.dataalign > 1 && !soft_block_align) { + Com_DPrintf( + "OpenAL: Alignment specified but AL doesn't support block alignment (%d).", pSfx->info.dataalign + ); + return false; + } + + qalGenBuffers(1, &pSfx->buffer); + alDieIfError(); + +#if AL_SOFT_block_alignment + if (pSfx->info.dataalign > 1) { + qalBufferi(pSfx->buffer, AL_UNPACK_BLOCK_ALIGNMENT_SOFT, pSfx->info.dataalign); + alDieIfError(); + } +#endif + + qalBufferData( + pSfx->buffer, + fmt, + &pSfx->data[pSfx->info.dataofs], + pSfx->info.datasize - pSfx->info.dataofs, + pSfx->info.rate + ); + alDieIfError(); + } + } + + qalSourceStop(source); + alDieIfError(); + + qalSourcei(source, AL_BUFFER, pSfx->buffer); + alDieIfError(); + + qalSourcef(source, AL_PITCH, 1.0); + alDieIfError(); + + // Get the base frequency + qalGetBufferi(pSfx->buffer, AL_FREQUENCY, &freq); + alDieIfError(); + + iBaseRate = freq; + + return true; } +/* +============== +openal_channel::start_sample +============== +*/ void openal_channel::start_sample() { - // FIXME: unimplemented + play(); } +/* +============== +openal_channel::stop_sample +============== +*/ void openal_channel::stop_sample() { - // FIXME: unimplemented + pause(); } +/* +============== +openal_channel::resume_sample +============== +*/ void openal_channel::resume_sample() { - // FIXME: unimplemented + play(); } +/* +============== +openal_channel::end_sample +============== +*/ void openal_channel::end_sample() { - // FIXME: unimplemented + stop(); } +/* +============== +openal_channel::set_sample_pan +============== +*/ void openal_channel::set_sample_pan(S32 pan) { - // FIXME: unimplemented + const float panning = (pan - 64) / 127.f; + const ALfloat sourcePosition[3] = {panning, 0, sqrtf(1.f - Square(panning))}; + + qalSourcef(source, AL_ROLLOFF_FACTOR, 0); + qalSourcei(source, AL_SOURCE_RELATIVE, AL_TRUE); + qalSourcefv(source, AL_POSITION, sourcePosition); } +/* +============== +openal_channel::set_sample_playback_rate +============== +*/ void openal_channel::set_sample_playback_rate(S32 rate) { - // FIXME: unimplemented + // Fixed in OPM + // Set the pitch in OpenAL + qalSourcef(source, AL_PITCH, rate / (float)iBaseRate); + alDieIfError(); } +/* +============== +openal_channel::sample_playback_rate +============== +*/ S32 openal_channel::sample_playback_rate() { - // FIXME: unimplemented - return 0; + float pitch = 1; + ALint freq = 0; + + // Fixed in OPM + // The sample rate varies according to the pitch + qalGetSourcef(source, AL_PITCH, &pitch); + alDieIfError(); + + return buffer_frequency() * pitch; } +/* +============== +openal_channel::buffer_frequency +============== +*/ +U32 openal_channel::buffer_frequency() const +{ + ALint freq = 0; + + if (buffer) { + qalGetBufferi(buffer, AL_FREQUENCY, &freq); + alDieIfError(); + } else if (pSfx) { + qalGetBufferi(pSfx->buffer, AL_FREQUENCY, &freq); + alDieIfError(); + } else { + freq = 22050; + } + + return freq; +} + +/* +============== +openal_channel::sample_volume +============== +*/ S32 openal_channel::sample_volume() { - // FIXME: unimplemented - return 0; + ALfloat gain = 0; + + qalGetSourcef(source, AL_GAIN, &gain); + alDieIfError(); + + return (gain / S_GetBaseVolume()) * 100; } +/* +============== +openal_channel::sample_offset +============== +*/ U32 openal_channel::sample_offset() { - // FIXME: unimplemented - return 0; + ALint offset = 0; + + qalGetSourcei(source, AL_SAMPLE_OFFSET, &offset); + alDieIfError(); + + return offset; } +/* +============== +openal_channel::sample_ms_offset +============== +*/ U32 openal_channel::sample_ms_offset() { - // FIXME: unimplemented - return 0; + if (!is_playing()) { + return 0; + } + + return sample_offset() * 1000ull / sample_playback_rate(); } +/* +============== +openal_channel::sample_loop_count +============== +*/ U32 openal_channel::sample_loop_count() { - // FIXME: unimplemented - return 0; + ALuint queued; + ALuint processed; + S32 left; + + qalGetSourceiv(source, AL_BUFFERS_QUEUED, (ALint *)&queued); + alDieIfError(); + qalGetSourcei(source, AL_BUFFERS_PROCESSED, (ALint *)&processed); + alDieIfError(); + + left = queued + ~processed; + if (left < 0) { + left = 0; + } + return left; } +/* +============== +openal_channel::set_sample_offset +============== +*/ void openal_channel::set_sample_offset(U32 offset) { - // FIXME: unimplemented + qalSourcei(source, AL_SAMPLE_OFFSET, offset); + alDieIfError(); } +/* +============== +openal_channel::set_sample_ms_offset +============== +*/ void openal_channel::set_sample_ms_offset(U32 offset) { - // FIXME: unimplemented + set_sample_offset(offset * sample_playback_rate() / 1000); } +/* +============== +openal_channel::set_sample_loop_count +============== +*/ void openal_channel::set_sample_loop_count(S32 count) { - // FIXME: unimplemented + ALuint processed = 0; + + stop(); + + qalGetSourceiv(source, AL_BUFFERS_PROCESSED, (ALint *)&processed); + alDieIfError(); + + for (ALuint i = 0; i < processed; i++) { + ALuint bufName; + + qalSourceUnqueueBuffers(source, 1, &bufName); + alDieIfError(); + } + + if (buffer) { + for (S32 i = 0; i < count; i++) { + qalSourceQueueBuffers(source, 1, &buffer); + alDieIfError(); + } + } + + if (count == 0) { + qalSourcei(source, AL_LOOPING, true); + alDieIfError(); + } else { + qalSourcei(source, AL_LOOPING, false); + alDieIfError(); + } } +/* +============== +openal_channel::set_sample_loop_block +============== +*/ void openal_channel::set_sample_loop_block(S32 start_offset, S32 end_offset) { // FIXME: unimplemented + STUB_DESC("sample_loop_block"); } +/* +============== +openal_channel::sample_status +============== +*/ U32 openal_channel::sample_status() { - // FIXME: unimplemented - return 0; + ALint retval; + + qalGetSourcei(source, AL_SOURCE_STATE, &retval); + alDieIfError(); + + return retval; } +/* +============== +MUSIC_LoadSoundtrackFile +============== +*/ qboolean MUSIC_LoadSoundtrackFile(const char *filename) { - // FIXME: unimplemented - return qfalse; + song_t *psong = NULL; + char args[MAX_MUSIC_SONGS][MAX_RES_NAME]; + int numargs; + char com_token[MAX_STRING_CHARS]; + char alias[128]; + char file[128]; + char load_path[128]; + char *buffer; + char path[MAX_RES_NAME]; + int i; + byte *data; + + if (strrchr(filename, '.')) { + Com_sprintf(path, sizeof(path), "%s", filename); + } else { + Com_sprintf(path, sizeof(path), "%s.mus", filename); + } + + music_numsongs = 0; + + FS_ReadFile(path, (void **)&data); + if (!data) { + Com_DPrintf("OpenAL: Couldn't load %s\n", path); + return false; + } + Com_DPrintf("SOUNDTRACK: Loading %s\n", path); + + MUSIC_StopAllSongs(); + + buffer = (char *)data; + load_path[0] = 0; + + while (1) { + Q_strncpyz(com_token, COM_GetToken(&buffer, true), sizeof(com_token)); + if (!com_token[0]) { + break; + } + + if (strlen(com_token) >= MAX_RES_NAME) { + Com_Printf("MUSIC_LoadSoundtrackFile: argument too long, truncating in %s\n", path); + com_token[MAX_RES_NAME - 1] = 0; + } + + numargs = 1; + Q_strncpyz(args[0], com_token, sizeof(args[0])); + + while (1) { + Q_strncpyz(com_token, COM_GetToken(&buffer, false), sizeof(com_token)); + if (!com_token[0]) { + break; + } + + if (strlen(com_token) >= MAX_RES_NAME) { + Com_Printf("MUSIC_LoadSoundtrackFile: argument too long, truncating in %s\n", path); + com_token[MAX_RES_NAME - 1] = 0; + } + + Q_strncpyz(args[numargs], com_token, sizeof(args[numargs])); + numargs++; + } + + if (!Q_stricmp(args[0], "path")) { + Q_strncpyz(load_path, args[1], sizeof(load_path)); + if (load_path[strlen(load_path) - 1] != '/' && load_path[strlen(load_path) - 1] != '\\') { + Q_strcat(load_path, sizeof(load_path), "/"); + } + } else if (args[0][0] == '!') { + for (i = 0; i < music_numsongs; i++) { + psong = &music_songs[i]; + if (!Q_stricmp(psong->alias, &args[0][1])) { + break; + } + } + + if (i == music_numsongs) { + Com_Printf("MUSIC_LoadSoundtrackFile: song %s not found, command skipped in %s.\n", &args[0][1], path); + continue; + } + + if (!Q_stricmp(args[1], "volume")) { + psong->volume = atof(args[2]); + } else if (!Q_stricmp(args[1], "fadetime")) { + psong->fadetime = atof(args[2]); + } else if (!Q_stricmp(args[1], "loop")) { + psong->flags |= 1; + } else if (!Q_stricmp(args[1], "restart")) { + psong->flags |= 2; + } else if (!Q_stricmp(args[1], "interrupt")) { + psong->fadetime = 0; + psong->flags |= 4 | 2; + } else { + Com_Printf( + "MUSIC_LoadSoundtrackFile: unknown command %s for song %s in %s.\n", args[1], &args[0][1], path + ); + } + } else { + if (numargs > 1) { + Q_strncpyz(alias, args[0], sizeof(alias)); + Q_strncpyz(file, load_path, sizeof(file)); + Q_strcat(file, sizeof(file), args[1]); + } else { + size_t len; + + Q_strncpyz(file, load_path, sizeof(file)); + Q_strcat(file, sizeof(file), args[1]); + + len = strlen(args[0]); + if (len >= 4) { + Q_strncpyz(alias, args[0], len - 4); + } else { + alias[0] = 0; + } + } + + if (music_numsongs >= MAX_MUSIC_SONGS) { + Com_Printf("MUSIC_LoadSoundtrackFile: Too many songs in %s, skipping %s.\n", path, alias); + continue; + } + + psong = &music_songs[music_numsongs]; + Q_strncpyz(psong->alias, alias, sizeof(psong->alias)); + Q_strncpyz(psong->path, file, sizeof(psong->path)); + music_songs[music_numsongs].fadetime = 1.0; + music_songs[music_numsongs].volume = 1.0; + music_songs[music_numsongs].flags = 0; + music_songs[music_numsongs].current_pos = 0; + music_songs[music_numsongs].mood_num = MusicMood_NameToNum(alias); + music_numsongs++; + } + } + + if (!music_numsongs) { + Com_Printf("MUSIC_LoadSoundtrackFile: could not load %s, no songs defined.\n", path); + FS_FreeFile(data); + return false; + } + + music_currentsong = -1; + FS_FreeFile(data); + + if (music_current_mood == mood_none) { + MUSIC_UpdateMood(mood_normal, mood_normal); + } + + return true; } +/* +============== +MUSIC_SongValid +============== +*/ qboolean MUSIC_SongValid(const char *mood) { - // FIXME: unimplemented - return qfalse; + return MUSIC_FindSong(mood) != -1; } +/* +============== +MUSIC_Loaded +============== +*/ qboolean MUSIC_Loaded() { - // FIXME: unimplemented - return qfalse; + return music_loaded; } +/* +============== +Music_Update +============== +*/ void Music_Update() { - // FIXME: unimplemented + int currentsong; + + if (!s_bSoundStarted) { + return; + } + + if (!music_active) { + return; + } + + if (s_bSoundPaused) { + return; + } + + MUSIC_CheckForStoppedSongs(); + + if (!MUSIC_Loaded() && music_active && strlen(current_soundtrack)) { + MUSIC_LoadSoundtrackFile(current_soundtrack); + music_loaded = true; + } + + if (music_currentsong >= 0) { + currentsong = music_songs[music_currentsong].mood_num; + } else { + currentsong = -1; + } + + if (music_current_mood == mood_none) { + if (MUSIC_Playing()) { + MUSIC_StopAllSongs(); + } + } else if (music_current_mood != currentsong) { + const char *mood = MusicMood_NumToName(music_current_mood); + if (MUSIC_SongValid(mood) && MUSIC_Loaded() && strlen(current_soundtrack)) { + Com_DebugPrintf("Playing %s.\n", mood); + MUSIC_PlaySong(mood); + } + } + + if (new_music_volume != music_volume) { + if (music_volume_fade_time > 0) { + if (music_volume_direction == 0) { + music_volume = (cls.realtime - music_volume_start_time) * (new_music_volume - old_music_volume) + / (music_volume_fade_time * 1000.f) + + old_music_volume; + + if (music_volume > new_music_volume) { + music_volume = new_music_volume; + music_volume_changed = 1; + } else { + music_volume_changed = 1; + } + } else if (music_volume_direction == 1) { + music_volume = 1.0 + - (cls.realtime - music_volume_start_time) * (old_music_volume - new_music_volume) + / (music_volume_fade_time * 1000.f); + + if (music_volume >= new_music_volume) { + music_volume_changed = true; + } else { + music_volume = new_music_volume; + music_volume_changed = true; + } + } else { + music_volume_changed = true; + } + } else { + music_volume = new_music_volume; + music_volume_changed = true; + } + } + + MUSIC_UpdateMusicVolumes(); } +/* +============== +MUSIC_SongEnded +============== +*/ void MUSIC_SongEnded() { - // FIXME: unimplemented + Com_DPrintf( + "MUSIC: Song ended, changing from [ %s ] to [ %s ]\n", + MusicMood_NumToName(music_current_mood), + MusicMood_NumToName(music_fallback_mood) + ); + music_current_mood = music_fallback_mood; } +/* +============== +MUSIC_NewSoundtrack +============== +*/ void MUSIC_NewSoundtrack(const char *name) { - // FIXME: unimplemented + if (!s_bSoundStarted) { + return; + } + + if (!Q_stricmp(name, current_soundtrack)) { + return; + } + + // Fixed in OPM + // Make sure to not get past the end of the buffer + //strcpy(current_soundtrack, name); + Q_strncpyz(current_soundtrack, name, sizeof(current_soundtrack)); + + if (!Q_stricmp(current_soundtrack, "none") || !Q_stricmp(current_soundtrack, "")) { + music_active = qfalse; + if (MUSIC_Playing()) { + MUSIC_StopAllSongs(); + } + } else { + music_active = qtrue; + MUSIC_LoadSoundtrackFile(name); + music_loaded = qtrue; + } } +/* +============== +MUSIC_UpdateMood +============== +*/ void MUSIC_UpdateMood(int current, int fallback) { - // FIXME: unimplemented + static int last_current_mood = -1; + static int last_fallback_mood = -1; + static int current_mood = -1; + static int fallback_mood = -1; + qboolean was_action; + + if (current == current_mood && fallback == fallback_mood) { + return; + } + + was_action = current == last_current_mood && fallback == last_fallback_mood && current_mood == mood_action; + last_current_mood = current_mood; + last_fallback_mood = fallback_mood; + current_mood = current; + music_current_mood = current; + fallback_mood = fallback; + music_fallback_mood = fallback; + music_active = qtrue; + + Com_DPrintf( + "MUSIC: changing from [ %s | %s ] to [ %s | %s ]\n", + MusicMood_NumToName(last_current_mood), + MusicMood_NumToName(last_fallback_mood), + MusicMood_NumToName(current_mood), + MusicMood_NumToName(fallback) + ); + + if (was_action) { + int songnum = MUSIC_FindSong(MusicMood_NumToName(current_mood)); + + if (songnum != -1 && (music_songs[songnum].flags & 4)) { + Com_DPrintf( + "MUSIC: restoring music from action state, skipping [ %s ] for [ %s ]\n", + MusicMood_NumToName(current_mood), + MusicMood_NumToName(fallback_mood) + ); + music_current_mood = music_fallback_mood; + } + } } +/* +============== +MUSIC_UpdateVolume +============== +*/ void MUSIC_UpdateVolume(float volume, float fade_time) { - // FIXME: unimplemented + if (new_music_volume == volume && music_volume_fade_time == fade_time) { + return; + } + + old_music_volume = music_volume; + new_music_volume = volume; + music_volume_fade_time = fade_time; + music_volume_start_time = cls.realtime; + + if (volume > music_volume) { + music_volume_direction = 0; + } else if (volume < music_volume) { + music_volume_direction = 1; + } } +/* +============== +MUSIC_StopAllSongs +============== +*/ void MUSIC_StopAllSongs() { - // FIXME: unimplemented + for (int i = 0; i < MAX_SOUNDSYSTEM_SONGS; i++) { + MUSIC_StopChannel(i); + } + + music_currentsong = -1; } +/* +============== +MUSIC_FreeAllSongs +============== +*/ void MUSIC_FreeAllSongs() { - // FIXME: unimplemented + MUSIC_StopAllSongs(); + MUSIC_UpdateMood(mood_none, mood_none); + current_soundtrack[0] = 0; + music_loaded = false; + + // Added in OPM + // Clear the list of songs so the songs from previous maps + // won't get played + music_numsongs = 0; } +/* +============== +MUSIC_Playing +============== +*/ qboolean MUSIC_Playing() { - // FIXME: unimplemented - return qfalse; + return MUSIC_CurrentSongChannel() != -1; } +/* +============== +MUSIC_FindSong +============== +*/ int MUSIC_FindSong(const char *name) { - // FIXME: unimplemented - return 0; + int i; + + for (i = 0; i < music_numsongs; i++) { + if (!Q_stricmp(music_songs[i].alias, name)) { + return i; + } + } + + return -1; } +/* +============== +S_loadsoundtrack +============== +*/ void S_loadsoundtrack() { - // FIXME: unimplemented + if (Cmd_Argc() != 2) { + Com_Printf("loadsoundtrack \n"); + return; + } + + MUSIC_LoadSoundtrackFile(Cmd_Argv(1)); + music_loaded = true; + Q_strncpyz(current_soundtrack, Cmd_Argv(1), sizeof(current_soundtrack)); } +/* +============== +S_CurrentSoundtrack +============== +*/ const char *S_CurrentSoundtrack() { - // FIXME: unimplemented - return NULL; + return current_soundtrack; } +/* +============== +S_PlaySong +============== +*/ void S_PlaySong() { - // FIXME: unimplemented + if (Cmd_Argc() != 2) { + Com_Printf("playsong \n"); + return; + } + + MUSIC_PlaySong(Cmd_Argv(1)); + music_active = true; } +/* +============== +MUSIC_CurrentSongChannel +============== +*/ int MUSIC_CurrentSongChannel() { - // FIXME: unimplemented - return 0; + int channel_number = -1; + int ch_idx = 0; + + for (ch_idx = 0; ch_idx < MAX_SOUNDSYSTEM_SONGS; ch_idx++) { + if (openal.chan_song[ch_idx].is_playing() && openal.chan_song[ch_idx].song_number == music_currentsong) { + channel_number = ch_idx; + } + } + + return channel_number; } +/* +============== +MUSIC_StopChannel +============== +*/ void MUSIC_StopChannel(int channel_number) { - // FIXME: unimplemented + openal_channel *channel = &openal.chan_song[channel_number]; + + channel->pause(); + if (music_songs[channel->song_number].flags & 2) { + music_songs[channel->song_number].current_pos = 0; + } else { + music_songs[channel->song_number].current_pos = channel->sample_ms_offset(); + } + + channel->stop(); } +/* +============== +MUSIC_PlaySong +============== +*/ qboolean MUSIC_PlaySong(const char *alias) { - // FIXME: unimplemented - return qfalse; + int channel_number; + song_t *song; + int songnum; + int channel_to_play_on; + int fading_song; + openal_channel_two_d_stream *song_channel; + unsigned int loop_start; + int rate; + + fading_song = 0; + songnum = MUSIC_FindSong(alias); + + if (songnum == -1) { + return true; + } + + song = &music_songs[songnum]; + + if (MUSIC_Playing() && songnum == music_currentsong) { + return true; + } + + channel_number = MUSIC_CurrentSongChannel(); + music_currentsong = songnum; + + if (channel_number != -1) { + if (song->flags & 4) { + MUSIC_StopChannel(channel_number); + } else { + song_channel = &openal.chan_song[channel_number]; + song_channel->fading = FADE_OUT; + song_channel->fade_time = (int)song->fadetime; + song_channel->fade_start_time = cls.realtime; + fading_song = true; + } + } + channel_to_play_on = (fading_song != 0) && (channel_number == 0); + song_channel = &openal.chan_song[channel_to_play_on]; + + if (song_channel->is_playing() || song_channel->is_paused()) { + MUSIC_StopChannel(channel_to_play_on); + } + + if (!song_channel->queue_stream(song->path)) { + Com_DPrintf("Could not start music file '%s'!", song->path); + return false; + } + + rate = song_channel->sample_playback_rate(); + + song_channel->song_number = songnum; + if (song->current_pos) { + song_channel->set_sample_ms_offset(song->current_pos); + } else { + song_channel->set_sample_offset(rate * 0.063f); + } + + if (song->flags & 1) { + song_channel->set_sample_loop_count(0); + song_channel->set_sample_loop_block(rate * 0.063f, -1); + } else { + song_channel->set_sample_loop_count(1); + } + + if (fading_song) { + song_channel->fading = FADE_IN; + song_channel->fade_time = (int)song->fadetime; + song_channel->set_gain(0.0); + song_channel->fade_start_time = cls.realtime; + } else { + song_channel->fading = FADE_NONE; + song_channel->set_gain(S_GetBaseVolume() * (song->volume * s_ambientVolume->value) * s_fVolumeGain); + } + + song_channel->play(); + + return true; } +/* +============== +MUSIC_UpdateMusicVolumes +============== +*/ void MUSIC_UpdateMusicVolumes() { - // FIXME: unimplemented + int i; + unsigned int current_time; + float new_volume, max_volume; + + if (s_ambientVolume->modified || music_volume_changed) { + s_ambientVolume->modified = false; + + for (i = 0; i < MAX_SOUNDSYSTEM_SONGS; i++) { + if (!openal.chan_song[i].is_playing() && !openal.chan_song[i].is_paused()) { + continue; + } + + if (openal.chan_song[i].fading != FADE_NONE) { + continue; + } + + openal.chan_song[i].set_gain( + S_GetBaseVolume() * (music_songs[openal.chan_song[i].song_number].volume * s_ambientVolume->value) + * s_fVolumeGain * music_volume + ); + } + } + + for (i = 0; i < MAX_SOUNDSYSTEM_SONGS; i++) { + if (!openal.chan_song[i].is_playing() && !openal.chan_song[i].is_paused()) { + continue; + } + + switch (openal.chan_song[i].fading) { + case fade_t::FADE_IN: + max_volume = music_songs[openal.chan_song[i].song_number].volume * s_ambientVolume->value; + new_volume = (unsigned int)(cls.realtime - openal.chan_song[i].fade_start_time) + / (openal.chan_song[i].fade_time * 1000.f) * max_volume; + + if (new_volume > max_volume) { + openal.chan_song[i].set_gain(S_GetBaseVolume() * (max_volume * s_fVolumeGain * music_volume)); + openal.chan_song[i].fading = FADE_NONE; + } else { + openal.chan_song[i].set_gain(S_GetBaseVolume() * (new_volume * s_fVolumeGain * music_volume)); + } + break; + case fade_t::FADE_OUT: + max_volume = music_songs[openal.chan_song[i].song_number].volume * s_ambientVolume->value; + new_volume = (unsigned int)(cls.realtime - openal.chan_song[i].fade_start_time) + / (openal.chan_song[i].fade_time * 1000.f) * max_volume; + + if (new_volume > 0) { + openal.chan_song[i].set_gain(S_GetBaseVolume() * (new_volume * s_fVolumeGain * music_volume)); + } else { + MUSIC_StopChannel(i); + } + break; + default: + break; + } + } + + if (s_musicVolume->modified || music_volume_changed) { + s_musicVolume->modified = false; + if (openal.chan_trig_music.is_playing() || openal.chan_trig_music.is_paused()) { + openal.chan_trig_music.set_gain( + S_GetBaseVolume() * (openal.chan_trig_music.fVolume * s_musicVolume->value) * s_fVolumeGain + ); + } + } + + music_volume_changed = false; } +/* +============== +MUSIC_CheckForStoppedSongs +============== +*/ void MUSIC_CheckForStoppedSongs() { - // FIXME: unimplemented + int i; + + for (i = 0; i < MAX_SOUNDSYSTEM_SONGS; i++) { + if (!openal.chan_song[i].is_playing()) { + continue; + } + + if (openal.chan_song[i].sample_loop_count()) { + continue; + } + + MUSIC_FindSong(MusicMood_NumToName(music_fallback_mood)); + if (!openal.chan_song[i].is_playing() && !openal.chan_song[i].is_paused()) { + MUSIC_SongEnded(); + } + } } +/* +============== +S_TriggeredMusic_SetupHandle +============== +*/ void S_TriggeredMusic_SetupHandle(const char *pszName, int iLoopCount, int iOffset, qboolean autostart) { - // FIXME: unimplemented + char *pszFilename; + const char *pszRealName; + float fVolume = 1.0; + AliasListNode_t *pSoundAlias = NULL; + void *stream = NULL; + + if (!s_bSoundStarted) { + return; + } + + if (openal.chan_trig_music.is_playing() || openal.chan_trig_music.is_paused()) { + Com_DPrintf("Didn't start new triggered music because some was already playing\n"); + return; + } + + openal.chan_trig_music.stop(); + // Fixed in OPM + // Use strncpy instead + //strcpy(openal.tm_filename, pszName); + Q_strncpyz(openal.tm_filename, pszName, sizeof(openal.tm_filename)); + + openal.tm_loopcount = iLoopCount; + openal.chan_trig_music.set_sample_loop_count(iLoopCount); + pszRealName = Alias_FindRandom(pszName, &pSoundAlias); + + if (!pszRealName) { + pszRealName = pszName; + } else if (pSoundAlias) { + fVolume = random() * pSoundAlias->volumeMod + pSoundAlias->volume; + } + + pszFilename = FS_BuildOSPath(Cvar_VariableString("fs_basepath"), FS_Gamedir(), pszRealName); + + if (!openal.chan_trig_music.queue_stream(pszRealName)) { + S_OPENAL_InitChannel(SOUNDSYSTEM_CHANNEL_TRIGGER_MUSIC_ID, &openal.chan_trig_music); + Com_DPrintf("Could not start triggered music '%s'\n", pszName); + return; + } + + openal.chan_trig_music.fVolume = fVolume; + openal.chan_trig_music.set_gain(S_GetBaseVolume() * (fVolume * s_musicVolume->value) * s_fVolumeGain); + openal.chan_trig_music.set_sample_loop_count(iLoopCount); + openal.chan_trig_music.set_sample_offset(iOffset); + + // Fixed in OPM + // Play the sound then pause it immediately + // So it can be unpaused upon loading from save + openal.chan_trig_music.play(); + + if (!autostart) { + openal.chan_trig_music.pause(); + } } +/* +============== +S_TriggeredMusic_Start +============== +*/ void S_TriggeredMusic_Start() { - // FIXME: unimplemented + if (Cmd_Argc() != 2) { + Com_Printf("tmstart \n"); + return; + } + + S_TriggeredMusic_SetupHandle(Cmd_Argv(1), 1, 0, true); } +/* +============== +S_TriggeredMusic_StartLoop +============== +*/ void S_TriggeredMusic_StartLoop() { - // FIXME: unimplemented + if (Cmd_Argc() != 2) { + Com_Printf("tmstartloop \n"); + return; + } + + S_TriggeredMusic_SetupHandle(Cmd_Argv(1), 0, 0, true); } +/* +============== +S_TriggeredMusic_Stop +============== +*/ void S_TriggeredMusic_Stop() { - // FIXME: unimplemented + if (!s_bSoundStarted) { + return; + } + + openal.chan_trig_music.stop(); + // Fixed in OPM + // Make sure to clear the triggered music in case snd_restart is called + openal.tm_filename[0] = 0; + openal.tm_loopcount = 0; } +/* +============== +S_TriggeredMusic_Volume + +Added in 2.0 +============== +*/ +void S_TriggeredMusic_Volume() +{ + if (!s_bSoundStarted) { + return; + } + + if (Cmd_Argc() != 2) { + Com_Printf("tmvolume <0-1>\n\n"); + return; + } + + openal.chan_trig_music.fVolume = atof(Cmd_Argv(1)); + music_volume_changed = true; +} + +/* +============== +S_TriggeredMusic_Pause +============== +*/ void S_TriggeredMusic_Pause() { - // FIXME: unimplemented + if (!s_bSoundStarted) { + return; + } + + if (openal.chan_trig_music.is_playing()) { + openal.chan_trig_music.pause(); + } } +/* +============== +S_TriggeredMusic_Unpause +============== +*/ void S_TriggeredMusic_Unpause() { - // FIXME: unimplemented + if (!s_bSoundStarted) { + return; + } + + if (openal.chan_trig_music.is_paused()) { + openal.chan_trig_music.play(); + } + + openal.chan_trig_music.set_gain( + S_GetBaseVolume() * (openal.chan_trig_music.fVolume * s_musicVolume->value) * s_fVolumeGain + ); } +/* +============== +S_TriggeredMusic_PlayIntroMusic +============== +*/ void S_TriggeredMusic_PlayIntroMusic() { - // FIXME: unimplemented + S_TriggeredMusic_SetupHandle("sound/music/mus_MainTheme.mp3", 0, 0, true); } +/* +============== +S_StopMovieAudio +============== +*/ void S_StopMovieAudio() { - // FIXME: unimplemented + openal.chan_movie.stop(); } +/* +============== +S_SetupMovieAudio +============== +*/ void S_SetupMovieAudio(const char *pszMovieName) { - // FIXME: unimplemented + char filename[MAX_QPATH]; + + S_StopMovieAudio(); + + COM_StripExtension(pszMovieName, filename, sizeof(filename)); + Q_strcat(filename, sizeof(filename), ".mp3"); + + if (!openal.chan_movie.queue_stream(filename)) { + COM_StripExtension(pszMovieName, filename, sizeof(filename)); + Q_strcat(filename, sizeof(filename), ".wav"); + + if (!openal.chan_movie.queue_stream(filename)) { + Com_DPrintf("Can't find any matching audio file for movie: %s\n", pszMovieName); + return; + } + } + + openal.chan_movie.set_gain(S_GetBaseVolume() * 1.5f); + openal.chan_movie.play(); + + Com_DPrintf("Movie Audio setup: %s\n", filename); } +/* +============== +S_CurrentMoviePosition +============== +*/ int S_CurrentMoviePosition() { - // FIXME: unimplemented - return 0; + return openal.chan_movie.sample_ms_offset(); } +/* +================= +S_AL_Format +================= +*/ +static ALuint S_OPENAL_Format(float width, int channels) +{ + ALuint format = AL_FORMAT_MONO16; + + // Work out format + if (width == 1) { + if (channels == 1) { + format = AL_FORMAT_MONO8; + } else if (channels == 2) { + format = AL_FORMAT_STEREO8; + } + } else if (width == 2) { + if (channels == 1) { + format = AL_FORMAT_MONO16; + } else if (channels == 2) { + format = AL_FORMAT_STEREO16; + } + } else if (width == 0.5) { + if (ima4_ext && soft_block_align) { + if (channels == 1) { + format = AL_FORMAT_MONO_IMA4; + } else if (channels == 2) { + format = AL_FORMAT_STEREO_IMA4; + } + } else { + // unsupported + format = 0; + } + } + + return format; +} + +/* +============== +S_OPENAL_LoadMP3_Codec +============== +*/ +static bool S_OPENAL_LoadMP3_Codec(const char *_path, sfx_t *pSfx) +{ + void *data; + snd_info_t info; + ALuint format; + + // Try to load + data = S_CodecLoad(_path, &info); + if (!data) { + return false; + } + + format = S_OPENAL_Format(info.width, info.channels); + + // Create a buffer + qalGenBuffers(1, &pSfx->buffer); + alDieIfError(); + + // Fill the buffer + if (info.size == 0) { + // We have no data to buffer, so buffer silence + byte dummyData[2] = {0}; + + qalBufferData(pSfx->buffer, AL_FORMAT_MONO16, (void *)dummyData, 2, 22050); + } else { + qalBufferData(pSfx->buffer, format, data, info.size, info.rate); + } + + alDieIfError(); + + // Free the memory + Hunk_FreeTempMemory(data); + + return true; +} + +/* +============== +openal_channel::update +============== +*/ +void openal_channel::update() {} + +/* +============== +openal_channel_two_d_stream::stop +============== +*/ +void openal_channel_two_d_stream::stop() +{ + openal_channel::stop(); + + clear_stream(); +} + +/* +============== +openal_channel_two_d_stream::set_sfx +============== +*/ +bool openal_channel_two_d_stream::set_sfx(sfx_t *pSfx) +{ + snd_stream_t *stream; + unsigned int bytesToRead, bytesRead; + ALint freq = 0; + char rawData[MAX_BUFFER_SAMPLES * 2 * 2]; + + stop(); + + sampleLoopCount = 1; + + this->pSfx = pSfx; + Q_strncpyz(this->fileName, pSfx->name, sizeof(this->fileName)); + + streamHandle = S_CodecLoad(pSfx->name, NULL); + if (!streamHandle) { + Com_DPrintf("OpenAL: Failed to load sound file.\n"); + return false; + } + + stream = (snd_stream_t *)streamHandle; + pSfx->info.channels = stream->info.channels; + pSfx->info.dataofs = stream->info.dataofs; + pSfx->info.datasize = stream->info.size; + pSfx->info.rate = stream->info.rate; + pSfx->info.samples = stream->info.samples; + pSfx->info.width = stream->info.width; + + pSfx->info.format = S_OPENAL_Format(stream->info.width, stream->info.channels); + if (!pSfx->info.format) { + Com_DPrintf( + "OpenAL: Bad Wave file (%d channels, %d bits) [%s].\n", + pSfx->info.channels, + (int)(pSfx->info.width * 8.f), + pSfx->name + ); + + S_CodecCloseStream(stream); + return false; + } + + qalSourceStop(source); + alDieIfError(); + + qalGenBuffers(MAX_STREAM_BUFFERS, buffers); + alDieIfError(); + + // Read a smaller sample + bytesToRead = Q_min(MAX_BUFFER_SAMPLES * stream->info.width * stream->info.channels, sizeof(rawData)); + bytesRead = S_CodecReadStream(stream, bytesToRead, rawData); + streamNextOffset = bytesRead; + if (!bytesRead) { + // Valid stream but no data? + S_CodecCloseStream(stream); + return true; + } + +#if AL_SOFT_block_alignment + if (stream->info.dataalign > 1 && soft_block_align) { + qalBufferi(buffers[currentBuf], AL_UNPACK_BLOCK_ALIGNMENT_SOFT, stream->info.dataalign); + alDieIfError(); + } #endif + + qalBufferData(buffers[currentBuf], pSfx->info.format, rawData, bytesRead, stream->info.rate); + alDieIfError(); + + qalSourceQueueBuffers(source, 1, &buffers[currentBuf]); + alDieIfError(); + + iBaseRate = stream->info.rate; + currentBuf = (currentBuf + 1) % MAX_STREAM_BUFFERS; + streaming = true; + + return true; +} + +/* +============== +openal_channel_two_d_stream::set_sample_loop_count +============== +*/ +void openal_channel_two_d_stream::set_sample_loop_count(S32 count) +{ + sampleLoopCount = count; + sampleLooped = 0; +} + +/* +============== +openal_channel_two_d_stream::openal_channel_two_d_stream +============== +*/ +openal_channel_two_d_stream::openal_channel_two_d_stream() +{ + int i; + + streamHandle = NULL; + for (i = 0; i < MAX_STREAM_BUFFERS; i++) { + buffers[i] = 0; + } + currentBuf = 0; + sampleLoopCount = 0; + sampleLooped = 0; + streamNextOffset = 0; + streaming = false; +} + +/* +============== +openal_channel_two_d_stream::openal_channel_two_d_stream +============== +*/ +openal_channel_two_d_stream::~openal_channel_two_d_stream() +{ + clear_stream(); +} + +/* +============== +openal_channel_two_d_stream::update +============== +*/ +void openal_channel_two_d_stream::update() +{ + snd_stream_t *stream = (snd_stream_t *)streamHandle; + unsigned int bytesToRead, bytesRead; + ALuint format; + ALint numProcessedBuffers = 0, numQueuedBuffers = 0; + ALint state = sample_status(); + // 2 channels with a width of 2 + char rawData[MAX_BUFFER_SAMPLES * 2 * 2]; + + if (!streaming || is_paused() || state == AL_INITIAL) { + return; + } + + qalGetSourcei(source, AL_BUFFERS_PROCESSED, &numProcessedBuffers); + alDieIfError(); + + qalGetSourcei(source, AL_BUFFERS_QUEUED, &numQueuedBuffers); + alDieIfError(); + + // Remove processed buffers after half of the queued buffers has been processed + if (numProcessedBuffers >= Q_max(numQueuedBuffers / 2, 1)) { + while (numProcessedBuffers-- > 0) { + ALuint tmpBuffer; + qalSourceUnqueueBuffers(source, 1, &tmpBuffer); + } + } + + if (numQueuedBuffers >= MAX_STREAM_BUFFERS) { + return; + } + + if (sampleLoopCount && sampleLooped >= sampleLoopCount) { + if (!is_playing()) { + // Can clear the stream + clear_stream(); + } + return; + } + + bytesToRead = Q_min(MAX_BUFFER_SAMPLES * stream->info.width * stream->info.channels, sizeof(rawData)); + + format = S_OPENAL_Format(stream->info.width, stream->info.channels); + + bytesRead = S_CodecReadStream(stream, bytesToRead, rawData); + streamNextOffset += bytesRead; + if (!bytesRead) { + S_CodecCloseStream(stream); + + sampleLooped++; + if (sampleLoopCount && sampleLooped >= sampleLoopCount) { + // Finished the last loop + streamHandle = NULL; + return; + } + + // + // Looped, start again from the beginning + // + streamHandle = S_CodecLoad(this->fileName, NULL); + if (!streamHandle) { + clear_stream(); + return; + } + + stream = (snd_stream_t *)streamHandle; + // + // Re-read the format, we never know... + // + format = S_OPENAL_Format(stream->info.width, stream->info.channels); + + bytesRead = S_CodecReadStream(stream, bytesToRead, rawData); + streamNextOffset = bytesRead; + if (!bytesRead) { + S_CodecCloseStream(stream); + streamHandle = NULL; + return; + } + } + +#if AL_SOFT_block_alignment + if (stream->info.dataalign > 1 && soft_block_align) { + qalBufferi(buffers[currentBuf], AL_UNPACK_BLOCK_ALIGNMENT_SOFT, stream->info.dataalign); + alDieIfError(); + } +#endif + + qalBufferData(buffers[currentBuf], format, rawData, bytesRead, stream->info.rate); + alDieIfError(); + + qalSourceQueueBuffers(source, 1, &buffers[currentBuf]); + alDieIfError(); + + if (!is_playing()) { + // The sample has stopped during stream + // Could be because the storage is slow enough for the buffer + // or because the storage was powering on after standby + play(); + } + + currentBuf = (currentBuf + 1) % MAX_STREAM_BUFFERS; +} + +/* +============== +openal_channel_two_d_stream::sample_offset +============== +*/ +U32 openal_channel_two_d_stream::sample_offset() +{ + snd_stream_t *stream = (snd_stream_t *)streamHandle; + ALint playerByteOffset = 0; + ALint numProcessedBuffers = 0; + ALint numQueuedBuffers = 0; + unsigned int totalQueueLength = 0; + unsigned int bitsPerSample = 0; + unsigned int offset = 0; + ALint bits = 0, channels = 0; + + if (!streaming) { + // no stream + return 0; + } + + // Get the byte offset in the queue + qalGetSourcei(source, AL_BYTE_OFFSET, &playerByteOffset); + alDieIfError(); + + totalQueueLength = getQueueLength(); + bitsPerSample = getBitsPerSample(); + + assert(playerByteOffset < totalQueueLength); + assert(streamNextOffset >= totalQueueLength || stream); + + if (streamNextOffset >= totalQueueLength) { + offset = streamNextOffset - totalQueueLength + playerByteOffset; + } else if (stream) { + // it probably means the sound is looped and will restart from the beginning + if (streamNextOffset + playerByteOffset <= totalQueueLength) { + // near the end of the stream + if (stream->info.size > totalQueueLength) { + offset = stream->info.size + streamNextOffset - totalQueueLength + playerByteOffset; + } else { + // the buffer is really small + offset = (streamNextOffset - totalQueueLength + playerByteOffset) % stream->info.size; + } + } else { + // it is past end of stream + // so, start from the beginning of the stream + offset = streamNextOffset + playerByteOffset - totalQueueLength; + } + + assert(offset < stream->info.size); + } else { + offset = totalQueueLength - streamNextOffset + playerByteOffset; + } + + return offset * 8 / bitsPerSample; +} + +/* +============== +openal_channel_two_d_stream::buffer_frequency +============== +*/ +U32 openal_channel_two_d_stream::buffer_frequency() const +{ + unsigned int bufferId; + ALint freq = 0; + + bufferId = (currentBuf - 1) % MAX_STREAM_BUFFERS; + qalGetBufferi(buffers[bufferId], AL_FREQUENCY, &freq); + alDieIfError(); + + return freq; +} + +/* +============== +openal_channel_two_d_stream::set_sample_offset +============== +*/ +void openal_channel_two_d_stream::set_sample_offset(U32 offset) +{ + snd_stream_t *stream; + unsigned int bytesToRead, bytesRead; + unsigned int byteOffset; + unsigned int bitsPerSample; + unsigned int streamPosition; + ALuint format; + ALint numQueuedBuffers; + bool bWasPlaying; + char rawData[MAX_BUFFER_SAMPLES * 2 * 2]; + + if (!streaming) { + return; + } + + stream = (snd_stream_t *)streamHandle; + streamPosition = getCurrentStreamPosition(); + bitsPerSample = getBitsPerSample(); + byteOffset = offset * bitsPerSample / 8; + + if (byteOffset >= streamPosition && byteOffset < streamNextOffset) { + // + // Sample is in the currently streamed data + // + qalSourcei(source, AL_BYTE_OFFSET, byteOffset - streamPosition); + alDieIfError(); + + return; + } + + bWasPlaying = is_playing(); + + if (stream) { + if (byteOffset < streamPosition) { + // + // New offset is before the current offset, + // reload the stream from the beginning + // + S_CodecCloseStream(stream); + streamHandle = NULL; + } else if (byteOffset >= stream->info.size) { + // + // This shouldn't happen unless the file is different + // from the one used while saving + // + byteOffset %= stream->info.size; + S_CodecCloseStream(stream); + streamHandle = NULL; + } + } + + if (!streamHandle) { + streamHandle = S_CodecLoad(this->fileName, NULL); + if (!streamHandle) { + clear_stream(); + return; + } + + stream = (snd_stream_t *)streamHandle; + streamNextOffset = 0; + } + + while (streamNextOffset <= byteOffset) { + streamPosition = streamNextOffset; + + bytesToRead = Q_min(MAX_BUFFER_SAMPLES * stream->info.width * stream->info.channels, sizeof(rawData)); + bytesRead = S_CodecReadStream(stream, bytesToRead, rawData); + if (!bytesRead) { + clear_stream(); + return; + } + + streamNextOffset += bytesRead; + } + + // + // Stop the sound and remove all buffers from the queue + // + qalSourceStop(source); + alDieIfError(); + + // + // Remove all buffers from the queue + // + numQueuedBuffers = 0; + qalGetSourcei(source, AL_BUFFERS_QUEUED, &numQueuedBuffers); + alDieIfError(); + + while (numQueuedBuffers--) { + ALuint b; + qalSourceUnqueueBuffers(source, 1, &b); + alDieIfError(); + } + + format = S_OPENAL_Format(stream->info.width, stream->info.channels); + + qalBufferData(buffers[currentBuf], format, rawData, bytesRead, stream->info.rate); + alDieIfError(); + + qalSourceQueueBuffers(source, 1, &buffers[currentBuf]); + alDieIfError(); + currentBuf = (currentBuf + 1) % MAX_STREAM_BUFFERS; + + // + // Now set the source offset + // + qalSourcei(source, AL_BYTE_OFFSET, byteOffset - streamPosition); + alDieIfError(); + + if (bWasPlaying) { + // + // The sound was stopped when re-streaming + // + play(); + } +} + +/* +============== +openal_channel_two_d_stream::queue_stream +============== +*/ +bool openal_channel_two_d_stream::queue_stream(const char *fileName) +{ + snd_stream_t *stream; + unsigned int bytesToRead, bytesRead; + ALint freq = 0; + ALuint format = 0; + ALuint old = 0; + char rawData[MAX_BUFFER_SAMPLES * 2 * 2]; + + // Store the filename so it can be looped later + Q_strncpyz(this->fileName, fileName, sizeof(this->fileName)); + clear_stream(); + + sampleLoopCount = 1; + + // + // Load the file + // + streamHandle = S_CodecLoad(this->fileName, NULL); + if (!streamHandle) { + return false; + } + stream = (snd_stream_t *)streamHandle; + + iStartTime = cl.serverTime; + iEndTime = (int)(cl.serverTime + (stream->info.samples / stream->info.rate * 1000.f)); + + format = S_OPENAL_Format(stream->info.width, stream->info.channels); + if (!format) { + Com_Printf( + "OpenAL: Bad Wave file (%d channels, %d bits) [%s].\n", + pSfx->info.channels, + (int)(pSfx->info.width * 8.f), + pSfx->name + ); + + S_CodecCloseStream(stream); + return false; + } + + qalGenBuffers(MAX_STREAM_BUFFERS, buffers); + alDieIfError(); + + // Read a smaller sample + bytesToRead = Q_min(MAX_BUFFER_SAMPLES * stream->info.width * stream->info.channels, sizeof(rawData)); + bytesRead = S_CodecReadStream(stream, bytesToRead, rawData); + if (!bytesRead) { + // Valid stream but no data? + return true; + } + + streamNextOffset = bytesRead; + + qalBufferData(buffers[currentBuf], format, rawData, bytesRead, stream->info.rate); + alDieIfError(); + + qalSourceQueueBuffers(source, 1, &buffers[currentBuf]); + alDieIfError(); + + currentBuf = (currentBuf + 1) % MAX_STREAM_BUFFERS; + + streaming = true; + + return true; +} + +/* +============== +openal_channel_two_d_stream::clear_stream +============== +*/ +void openal_channel_two_d_stream::clear_stream() +{ + if (!streaming) { + return; + } + + qalSourceStop(source); + qalSourcei(source, AL_BUFFER, 0); + qalDeleteBuffers(MAX_STREAM_BUFFERS, buffers); + + if (streamHandle) { + S_CodecCloseStream((snd_stream_t *)streamHandle); + } + + fileName[0] = 0; + streamHandle = NULL; + + currentBuf = 0; + streamNextOffset = 0; + streaming = false; + sampleLooped = 0; +} + +/* +============== +openal_channel_two_d_stream::getQueueLength + +Return the total length of all buffers being streamed. +============== +*/ +unsigned int openal_channel_two_d_stream::getQueueLength() const +{ + ALint numQueuedBuffers = 0; + unsigned int totalQueueLength = 0; + unsigned int bufferId; + unsigned int i; + + qalGetSourcei(source, AL_BUFFERS_QUEUED, &numQueuedBuffers); + alDieIfError(); + + for (i = 0; i < numQueuedBuffers; i++) { + ALint bufferSize = 0; + + bufferId = (currentBuf - i - 1) % MAX_STREAM_BUFFERS; + qalGetBufferi(buffers[bufferId], AL_SIZE, &bufferSize); + + totalQueueLength += bufferSize; + } + + return totalQueueLength; +} + +/* +============== +openal_channel_two_d_stream::getCurrentStreamPosition + +Return the current position in the sound being streamed. +============== +*/ +unsigned int openal_channel_two_d_stream::getCurrentStreamPosition() const +{ + unsigned int queueLength = getQueueLength(); + + if (streamNextOffset >= queueLength) { + return streamNextOffset - queueLength; + } else if (streamHandle) { + snd_stream_t *stream = (snd_stream_t *)streamHandle; + return (stream->info.size + streamNextOffset - queueLength) % stream->info.size; + } else { + return queueLength - streamNextOffset; + } +} + +/* +============== +openal_channel_two_d_stream::getBitsPerSample + +Return the number of bytes per sample. +It assumes that all pending buffers have the same channels and bits. +============== +*/ +unsigned int openal_channel_two_d_stream::getBitsPerSample() const +{ + unsigned int bufferId; + ALint bits = 0, channels = 0; + + bufferId = (currentBuf - 1) % MAX_STREAM_BUFFERS; + qalGetBufferi(buffers[bufferId], AL_BITS, &bits); + alDieIfError(); + qalGetBufferi(buffers[bufferId], AL_CHANNELS, &channels); + alDieIfError(); + + return bits * channels; +} diff --git a/code/client/snd_openal_new.h b/code/client/snd_openal_new.h index a7b54ace..a22e2d6f 100644 --- a/code/client/snd_openal_new.h +++ b/code/client/snd_openal_new.h @@ -29,6 +29,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA typedef int S32; typedef unsigned int U32; +#define MAX_STREAM_BUFFERS 16 +#define MAX_BUFFER_SAMPLES 16384 + typedef enum { FADE_NONE, FADE_IN, @@ -36,53 +39,64 @@ typedef enum { } fade_t; typedef struct { - vec3_t vOrigin; - vec3_t vRelativeOrigin; - vec3_t vVelocity; + vec3_t vOrigin; + vec3_t vRelativeOrigin; + vec3_t vVelocity; + sfx_t *pSfx; qboolean bPlaying; - int iChannel; - float fVolume; - float fPitch; + + int iChannel; + float fVolume; + float fPitch; + int iStartTime; qboolean bInUse; qboolean bCombine; - float fBaseVolume; - float fMinDist; - float fMaxDist; - int iFlags; + + float fBaseVolume; + float fMinDist; + float fMaxDist; + int iFlags; } openal_loop_sound_t; struct openal_channel { - sfx_t *pSfx; - int iEntNum; - int iEntChannel; - vec3_t vOrigin; - float fVolume; - int iBaseRate; - float fNewPitchMult; - float fMinDist; - float fMaxDist; - int iStartTime; - int iTime; - int iEndTime; - int iFlags; - int iPausedOffset; - int song_number; - fade_t fading; - int fade_time; - int fade_start_time; + sfx_t *pSfx; + int iEntNum; + int iEntChannel; + vec3_t vOrigin; + + float fVolume; + int iBaseRate; + float fNewPitchMult; + float fMinDist; + float fMaxDist; + + int iStartTime; + int iTime; + int iEndTime; + int iFlags; + int iPausedOffset; + + int song_number; + + fade_t fading; + int fade_time; + int fade_start_time; + ALuint source; ALuint buffer; ALubyte *bufferdata; - void play(); - void stop(); - void pause(); +public: + void play(); + virtual void stop(); + void pause(); void set_no_3d(); void set_3d(); - ALint get_state(); + void set_no_virtualization(); + void set_virtualization(); void set_gain(float gain); void set_velocity(float v0, float v1, float v2); @@ -92,8 +106,8 @@ struct openal_channel { bool is_paused(); bool is_playing(); - void force_free(); - bool set_sfx(sfx_t *pSfx); + void force_free(); + virtual bool set_sfx(sfx_t *pSfx); void start_sample(); void stop_sample(); @@ -104,66 +118,120 @@ struct openal_channel { void set_sample_playback_rate(S32 pan); S32 sample_playback_rate(); - S32 sample_volume(); - U32 sample_offset(); - U32 sample_ms_offset(); - U32 sample_loop_count(); - void set_sample_offset(U32 offset); - void set_sample_ms_offset(U32 offset); - void set_sample_loop_count(S32 count); - void set_sample_loop_block(S32 start_offset, S32 end_offset); + S32 sample_volume(); + virtual U32 sample_offset(); + U32 sample_ms_offset(); + U32 sample_loop_count(); + virtual void set_sample_offset(U32 offset); + void set_sample_ms_offset(U32 offset); + virtual void set_sample_loop_count(S32 count); + void set_sample_loop_block(S32 start_offset, S32 end_offset); U32 sample_status(); + +public: + virtual void update(); + + virtual U32 buffer_frequency() const; +}; + +struct openal_channel_two_d_stream : public openal_channel { +private: + char fileName[64]; + void *streamHandle; + unsigned int buffers[MAX_STREAM_BUFFERS]; + unsigned int currentBuf; + unsigned int sampleLoopCount; + unsigned int sampleLooped; + unsigned int streamNextOffset; + bool streaming; + +public: + openal_channel_two_d_stream(); + ~openal_channel_two_d_stream(); + + void stop() override; + bool set_sfx(sfx_t *pSfx) override; + void set_sample_loop_count(S32 count) override; + void update() override; + U32 sample_offset() override; + void set_sample_offset(U32 offset) override; + + bool queue_stream(const char *fileName); + +protected: + U32 buffer_frequency() const override; + +private: + void clear_stream(); + + unsigned int getQueueLength() const; + unsigned int getCurrentStreamPosition() const; + unsigned int getBitsPerSample() const; +}; + +struct openal_movie_channel : public openal_channel { + }; struct openal_internal_t { - openal_channel chan_3D[32]; - openal_channel chan_2D[32]; - openal_channel chan_2D_stream[32]; - openal_channel chan_song[2]; - openal_channel chan_mp3; - openal_channel chan_trig_music; - openal_channel chan_movie; - openal_channel *channel[101]; - openal_loop_sound_t loop_sounds[64]; - openal_channel movieChannel; - sfx_t movieSFX; - char tm_filename[64]; - int tm_loopcount; + openal_channel chan_3D[MAX_SOUNDSYSTEM_CHANNELS_3D]; + openal_channel chan_2D[MAX_SOUNDSYSTEM_CHANNELS_2D]; + openal_channel_two_d_stream chan_2D_stream[MAX_SOUNDSYSTEM_CHANNELS_2D_STREAM]; + openal_channel_two_d_stream chan_song[MAX_SOUNDSYSTEM_SONGS]; + openal_channel_two_d_stream chan_mp3; + openal_channel_two_d_stream chan_trig_music; + openal_channel_two_d_stream chan_movie; + + // Pointers to channels + openal_channel *channel[MAX_SOUNDSYSTEM_CHANNELS]; + + openal_loop_sound_t loop_sounds[MAX_SOUNDSYSTEM_LOOP_SOUNDS]; + + openal_channel movieChannel; + sfx_t movieSFX; + + char tm_filename[MAX_RES_NAME]; + int tm_loopcount; }; #ifdef __cplusplus extern "C" { #endif -qboolean S_OPENAL_Init(); -void S_OPENAL_StartSound( + qboolean S_OPENAL_Init(); + void S_OPENAL_Shutdown(); + void S_OPENAL_StartSound( + const vec3_t vOrigin, + int iEntNum, + int iEntChannel, + sfxHandle_t sfxHandle, + float fVolume, + float fMinDist, + float fPitch, + float fMaxDist, + qboolean bStreamed + ); + void S_OPENAL_AddLoopingSound( const vec3_t vOrigin, - int iEntNum, - int iEntChannel, + const vec3_t vVelocity, sfxHandle_t sfxHandle, float fVolume, float fMinDist, - float fPitch, float fMaxDist, - qboolean bStreamed + float fPitch, + int iFlags ); -void S_OPENAL_AddLoopingSound( - const vec3_t vOrigin, - const vec3_t vVelocity, - sfxHandle_t sfxHandle, - float fVolume, - float fMinDist, - float fMaxDist, - float fPitch, - int iFlags -); -void S_OPENAL_ClearLoopingSounds(); -void S_OPENAL_StopSound(int iEntNum); -void S_OPENAL_StopAllSounds(qboolean bStopMusic); -void S_OPENAL_Respatialize(int iEntNum, const vec3_t vHeadPos, const vec3_t vAxis[3]); -void S_OPENAL_SetReverb(int iType, float fLevel); -void S_OPENAL_Update(); + void S_OPENAL_ClearLoopingSounds(); + void S_OPENAL_StopSound(int iEntNum, int iEntChannel); + void S_OPENAL_StopAllSounds(qboolean bStopMusic); + void S_OPENAL_Respatialize(int iEntNum, const vec3_t vHeadPos, const vec3_t vAxis[3]); + void S_OPENAL_SetReverb(int iType, float fLevel); + void S_OPENAL_Update(); + + const char *S_OPENAL_GetMusicFilename(); + int S_OPENAL_GetMusicLoopCount(); + unsigned int S_OPENAL_GetMusicOffset(); #ifdef __cplusplus } diff --git a/code/client/snd_public.h b/code/client/snd_public.h index ce3069bf..9edf4768 100644 --- a/code/client/snd_public.h +++ b/code/client/snd_public.h @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -#if !defined(USE_SOUND_NEW) || !USE_SOUND_NEW +#if defined(NO_MODERN_DMA) && NO_MODERN_DMA #ifdef __cplusplus extern "C" { @@ -150,6 +150,7 @@ void S_TriggeredMusic_SetupHandle(const char* pszName, int iLoopCount, int iOffs void S_TriggeredMusic_Start(); void S_TriggeredMusic_StartLoop(); void S_TriggeredMusic_Stop(); +void S_TriggeredMusic_Volume(); void S_TriggeredMusic_Pause(); void S_TriggeredMusic_Unpause(); void S_TriggeredMusic_PlayIntroMusic(); @@ -157,8 +158,29 @@ void S_StopMovieAudio(); void S_SetupMovieAudio(const char* pszMovieName); int S_CurrentMoviePosition(); +const char* S_GetMusicFilename(); +int S_GetMusicLoopCount(); +unsigned int S_GetMusicOffset(); + #ifdef __cplusplus } #endif #endif + + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef USE_VOIP +void S_StartCapture( void ); +int S_AvailableCaptureSamples( void ); +void S_Capture( int samples, byte *data ); +void S_StopCapture( void ); +void S_MasterGain( float gain ); +#endif + +#ifdef __cplusplus +} +#endif diff --git a/code/fgame/CMakeLists.txt b/code/fgame/CMakeLists.txt index c688fa85..ed8fdc31 100644 --- a/code/fgame/CMakeLists.txt +++ b/code/fgame/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(fgame) # Shared source files for modules @@ -27,8 +27,24 @@ file( add_library(fgame SHARED ${SOURCES_GAME}) -find_package(BISON) -find_package(FLEX) +# +# Workaround to get a recent version Flex and Bison executables in MacOS +# as Bison 2.3 shipped with MacOS doesn't work +# +if (CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin") + execute_process(COMMAND brew --prefix bison RESULT_VARIABLE APP_RESULT OUTPUT_VARIABLE APP_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE) + if (APP_RESULT EQUAL 0 AND EXISTS "${APP_PREFIX}") + set(BISON_EXECUTABLE "${APP_PREFIX}/bin/bison") + endif() + + execute_process(COMMAND brew --prefix flex RESULT_VARIABLE APP_RESULT OUTPUT_VARIABLE APP_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE) + if (APP_RESULT EQUAL 0 AND EXISTS "${APP_PREFIX}") + set(FLEX_EXECUTABLE "${APP_PREFIX}/bin/flex") + endif() +endif() + +find_package(BISON 3 REQUIRED) +find_package(FLEX REQUIRED) if (FLEX_FOUND) flex_target(fgame-lexer ${CMAKE_SOURCE_DIR}/code/parser/lex_source.txt ${CMAKE_SOURCE_DIR}/code/parser/generated/yyLexer.cpp DEFINES_FILE ${CMAKE_SOURCE_DIR}/code/parser/generated/yyLexer.h COMPILE_FLAGS "-Cem --nounistd") @@ -50,16 +66,11 @@ target_compile_features(fgame PUBLIC cxx_nullptr) target_compile_features(fgame PUBLIC c_variadic_macros) target_link_libraries(fgame PUBLIC qcommon) -set_target_properties(fgame PROPERTIES PREFIX "${TARGET_PLATFORM_PREFIX}") -set_target_properties(fgame PROPERTIES OUTPUT_NAME "game${TARGET_ARCH_SUFFIX}") -set_target_properties(fgame PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${TARGET_BASE_GAME}") +set_target_properties(fgame PROPERTIES PREFIX "") +set_target_properties(fgame PROPERTIES OUTPUT_NAME "game${TARGET_BIN_SUFFIX}") -INSTALL( - TARGETS fgame - LIBRARY DESTINATION "${TARGET_BASE_GAME}" - RUNTIME DESTINATION "${TARGET_BASE_GAME}" -) +INSTALL(TARGETS fgame DESTINATION ${CMAKE_INSTALL_LIBDIR}/${LIB_INSTALL_SUBDIR}) if(MSVC) - INSTALL(FILES $ DESTINATION "${TARGET_BASE_GAME}" OPTIONAL) + INSTALL(FILES $ DESTINATION ${CMAKE_INSTALL_LIBDIR}/${LIB_INSTALL_SUBDIR} OPTIONAL) endif() diff --git a/code/fgame/Entities.cpp b/code/fgame/Entities.cpp index 139d6e8f..25a53961 100644 --- a/code/fgame/Entities.cpp +++ b/code/fgame/Entities.cpp @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -80,7 +80,8 @@ Event EV_PG_MaxDuration "Sets the maximum duration of bursts(in seconds)\nDefault=3", EV_NORMAL ); -Event EV_PG_MinNumShots( +Event EV_PG_MinNumShots +( "MinNumShots", EV_DEFAULT, "i", @@ -88,7 +89,8 @@ Event EV_PG_MinNumShots( "Sets the minimum # of shots to fire in a cycle\nDefault=1", EV_NORMAL ); -Event EV_PG_MaxNumShots( +Event EV_PG_MaxNumShots +( "MaxNumShots", EV_DEFAULT, "i", @@ -275,7 +277,8 @@ Event EV_PG_SetPreImpactSoundTime "Set the time before impact to play the preimpact sound.", EV_NORMAL ); -Event EV_PG_SetPreImpactSoundProbability( +Event EV_PG_SetPreImpactSoundProbability +( "preimpactsoundprob", EV_DEFAULT, "f", @@ -324,7 +327,7 @@ void ClearProjectileTargets() ProjectileTarget::ProjectileTarget() { - m_iTarget = -1; + m_iID = -1; setMoveType(MOVETYPE_NONE); setSolidType(SOLID_NOT); hideModel(); @@ -334,12 +337,19 @@ ProjectileTarget::ProjectileTarget() void ProjectileTarget::EventSetId(Event *ev) { - m_iTarget = ev->GetInteger(1); + m_iID = ev->GetInteger(1); } -int ProjectileTarget::GetTarget() const +int ProjectileTarget::GetId() const { - return m_iTarget; + return m_iID; +} + +void ProjectileTarget::Archive(Archiver& arc) +{ + Entity::Archive(arc); + + arc.ArchiveInteger(&m_iID); } CLASS_DECLARATION(Animate, ProjectileGenerator, "ProjectileGenerator") { @@ -492,6 +502,7 @@ void ProjectileGenerator::TurnOn(Event *ev) if (!m_bIsTurnedOn) { CancelEventsOfType(EV_PG_BeginCycle); CancelEventsOfType(EV_TickCycle); + SetupNextCycle(); m_bIsTurnedOn = true; } } @@ -519,6 +530,7 @@ void ProjectileGenerator::SetupNextCycle() // get a random delay m_fShotsPerSec = numShots / m_fCycleTime; + delay = 0.01f; if (m_bIsTurnedOn || !m_bFireOnStartUp) { delay = G_Random(m_fMaxDelay - m_fMinDelay) + m_fMinDelay; } @@ -578,7 +590,7 @@ void ProjectileGenerator::GetLocalTargets() m_projectileTargets.ClearObjectList(); for (i = 1; i <= g_projectileTargets.NumObjects(); i++) { ProjectileTarget *target = g_projectileTargets.ObjectAt(i); - if (m_iId == target->GetTarget()) { + if (m_iId == target->GetId()) { m_projectileTargets.AddObject(target); } } @@ -1630,7 +1642,7 @@ ThrobbingBox_Explosive::ThrobbingBox_Explosive() setModel("items\\\\pulse_explosive.tik"); m_sUsedModel = "items/explosive.tik"; - m_sSound = "explose_flak88"; + m_sSound = "explode_flak88"; m_sActivateSound = "plantbomb"; m_sTickSound = "bombtick"; @@ -1804,6 +1816,7 @@ void ThrobbingBox_Explosive::OnBlowUp(Event *ev) ent = veh->QueryDriverSlotEntity(0); if (ent) { + ent->takedamage = DAMAGE_YES; ent->Damage(this, this, ent->health * 2.f, vec_zero, vec_zero, vec_zero, 50, 0, MOD_VEHICLE); } } @@ -1837,7 +1850,7 @@ void ThrobbingBox_Explosive::OnUse(Event *ev) if (m_fStopwatchDuration > 0) { Player *player = static_cast(G_FindTarget(this, "player")); - player->SetStopwatch(m_fStopwatchDuration, SWT_FUSE); + player->SetStopwatch(m_fStopwatchDuration, SWT_NORMAL); LoopSound(m_sTickSound); } @@ -1894,6 +1907,13 @@ CLASS_DECLARATION(ThrobbingBox_Explosive, ThrobbingBox_ExplodePlayerFlak88, "Thr {NULL, NULL} }; +ThrobbingBox_ExplodePlayerFlak88::ThrobbingBox_ExplodePlayerFlak88() +{ + spawnflags |= TBE_SPAWNFLAG_DESTROYED_MODEL; + m_sDestroyedModel = "statweapons/flak88_d.tik"; + m_sEffect = "fx/demodamage_flak88.tik"; +} + /*QUAKED ThrobbingBox_ExplodeFlak88 (1.0 0.0 1.0) (-12 -12 -12) (12 12 12) Explosive throbbing box. Connect to the object you want to make explode. @@ -1916,6 +1936,12 @@ CLASS_DECLARATION(ThrobbingBox_Explosive, ThrobbingBox_ExplodeFlak88, "Throbbing {NULL, NULL} }; +ThrobbingBox_ExplodeFlak88::ThrobbingBox_ExplodeFlak88() +{ + m_sDestroyedModel = "statweapons/flak88_d.tik"; + m_sEffect = "fx/demodamage_flak88.tik"; +} + /*QUAKED ThrobbingBox_ExplodeNebelwerfer (1.0 0.0 1.0) (-12 -12 -12) (12 12 12) ReplaceModel Explosive throbbing box. Connect to the object you want to make explode. @@ -1938,6 +1964,11 @@ CLASS_DECLARATION(ThrobbingBox_Explosive, ThrobbingBox_ExplodeNebelwerfer, "Thro {NULL, NULL} }; +ThrobbingBox_ExplodeNebelwerfer::ThrobbingBox_ExplodeNebelwerfer() +{ + m_sDestroyedModel = "statweapons/nebelwerfer_d.tik"; +} + /*QUAKED ThrobbingBox_ExplodePlayerNebelwerfer (1.0 0.0 1.0) (-12 -12 -12) (12 12 12) ReplaceModel Explosive throbbing box. Connect to the object you want to make explode. @@ -1956,10 +1987,16 @@ CLASS_DECLARATION(ThrobbingBox_Explosive, ThrobbingBox_ExplodeNebelwerfer, "Thro --------------------------------------------------------------------------------------------- */ -CLASS_DECLARATION(ThrobbingBox_Explosive, ThrobbingBox_ExplodePlayerNebelwerfer, "ThrobbingBox_ExplodeNebelwerfer") { +CLASS_DECLARATION(ThrobbingBox_Explosive, ThrobbingBox_ExplodePlayerNebelwerfer, "ThrobbingBox_ExplodePlayerNebelwerfer") { {NULL, NULL} }; +ThrobbingBox_ExplodePlayerNebelwerfer::ThrobbingBox_ExplodePlayerNebelwerfer() +{ + spawnflags |= TBE_SPAWNFLAG_DESTROYED_MODEL; + m_sDestroyedModel = "statweapons/nebelwerfer_d.tik"; +} + /*QUAKED ThrobbingBox_Stickybomb (1.0 0.0 1.0) (-12 -12 -12) (12 12 12) ReplaceModel WetFuse Stickybomb throbbing box. Connect to the object you want to make explode. @@ -1979,13 +2016,33 @@ CLASS_DECLARATION(ThrobbingBox_Explosive, ThrobbingBox_ExplodePlayerNebelwerfer, Event EV_StickyBombWet("stickybombwet", EV_DEFAULT, NULL, NULL, NULL); -CLASS_DECLARATION(ThrobbingBox_Explosive, ThrobbingBox_Stickybomb, "ThrobbingBox_ExplodeNebelwerfer") { +CLASS_DECLARATION(ThrobbingBox_Explosive, ThrobbingBox_Stickybomb, "ThrobbingBox_Stickybomb") { {&EV_Damage, &ThrobbingBox_Stickybomb::OnBlowUp }, {&EV_Use, &ThrobbingBox_Stickybomb::OnStickyBombUse}, {&EV_StickyBombWet, &ThrobbingBox_Stickybomb::OnStickyBombWet}, {NULL, NULL } }; +ThrobbingBox_Stickybomb::ThrobbingBox_Stickybomb() +{ + if (LoadingSavegame) { + return; + } + + setModel("items/pulse_stickybomb.tik"); + m_sUsedModel = "items/stickybomb.tik"; + m_sSound = "explode_flak88"; + m_sActivateSound = "stickybomb_plant"; + m_sTickSound = "stickybomb_fuse"; + + health = 10; + m_fStopwatchStartTime = 0; + + setSolidType(SOLID_BBOX); + takedamage = DAMAGE_NO; + setContents(CONTENTS_WEAPONCLIP); +} + void ThrobbingBox_Stickybomb::OnStickyBombWet(Event *ev) { Player *player; @@ -1997,7 +2054,7 @@ void ThrobbingBox_Stickybomb::OnStickyBombWet(Event *ev) player = static_cast(G_FindTarget(this, "player")); player->SetStopwatch(0, SWT_NORMAL); - player->SetStopwatch(m_fStopwatchDuration - (level.svsFloatTime - m_fStopwatchStartTime), SWT_FUSE); + player->SetStopwatch(m_fStopwatchDuration - (level.svsFloatTime - m_fStopwatchStartTime), SWT_FUSE_WET); } void ThrobbingBox_Stickybomb::OnStickyBombUse(Event *ev) @@ -2193,10 +2250,110 @@ int Objective::GetObjectiveIndex() const */ CLASS_DECLARATION(Entity, FencePost, "func_fencepost") { - {&EV_Killed, NULL}, - {NULL, NULL} + {&EV_Killed, &FencePost::Killed}, + {NULL, NULL } }; +FencePost::FencePost() +{ + max_health = 20; + health = 20; + damage_type = MOD_AAGUN; + + if (!LoadingSavegame) { + PostEvent(EV_BecomeSolid, EV_POSTSPAWN); + } + + takedamage = DAMAGE_YES; +} + +void FencePost::Killed(Event *ev) +{ + Vector vMins, vMaxs; + Vector vStart, vEnd; + Vector vCenter; + float fHalf; + + vCenter = mins - maxs; + vCenter *= 0.5; + + if (size.x > size.y) { + if (size.x > size.z) { + if (size.y > size.z) { + fHalf = size.y / 2.f; + } else { + fHalf = size.z / 2.f; + } + + vMins[0] = mins[0]; + vMaxs[0] = maxs[0]; + vMins[1] = vCenter[1]; + vMaxs[1] = vCenter[1]; + vMins[2] = vCenter[2]; + vMaxs[2] = vCenter[2]; + } else { + fHalf = size.x / 2.f; + + vMins[2] = mins[2]; + vMaxs[2] = maxs[2]; + vMins[1] = vCenter[1]; + vMaxs[1] = vCenter[1]; + vMins[0] = vCenter[0]; + vMaxs[0] = vCenter[0]; + } + } else { + if (size.y > size.z) { + if (size.x > size.z) { + fHalf = size.x / 2.f; + } else { + fHalf = size.z / 2.f; + } + + vMins[1] = mins[1]; + vMaxs[1] = maxs[1]; + vMins[0] = vCenter[0]; + vMaxs[0] = vCenter[0]; + vMins[2] = vCenter[2]; + vMaxs[2] = vCenter[2]; + } else { + fHalf = size.y / 2.f; + + vMins[2] = mins[2]; + vMaxs[2] = maxs[2]; + vMins[1] = vCenter[1]; + vMaxs[1] = vCenter[1]; + vMins[0] = vCenter[0]; + vMaxs[0] = vCenter[0]; + } + } + + MatrixTransformVector(vMins, orientation, vStart); + MatrixTransformVector(vMaxs, orientation, vEnd); + + vStart += origin; + vEnd += origin; + + if (fHalf > 255) { + fHalf = 255; + } + + gi.SetBroadcastVisible(vStart, vEnd); + gi.MSG_StartCGM(CGM_FENCEPOST); + gi.MSG_WriteCoord(vStart[0]); + gi.MSG_WriteCoord(vStart[1]); + gi.MSG_WriteCoord(vStart[2]); + gi.MSG_WriteCoord(vEnd[0]); + gi.MSG_WriteCoord(vEnd[1]); + gi.MSG_WriteCoord(vEnd[2]); + gi.MSG_WriteByte((int)fHalf); + gi.MSG_WriteByte(0); + gi.MSG_EndCGM(); + + deadflag = DEAD_DEAD; + + PostEvent(EV_Remove, 0); +} + Event EV_SetEnemyName ( "enemyname", @@ -2213,7 +2370,7 @@ Event EV_SetEnemyName2 "s", "enemyname", "", - EV_GETTER + EV_SETTER ); Event EV_GetEnemyName ( @@ -2222,7 +2379,7 @@ Event EV_GetEnemyName "s", "enemyname", "", - EV_SETTER + EV_GETTER ); Event EV_Sentient_GetDontDropWeapons ( @@ -2337,31 +2494,38 @@ CLASS_DECLARATION(SimpleArchivedEntity, AISpawnPoint, "info_aispawnpoint") { AISpawnPoint::AISpawnPoint() { - m_iHealth = 100; - m_iAccuracy = 20; - m_iAmmoGrenade = 0; - m_iBalconyHeight = 128; - m_iDisguiseLevel = 1; - m_fDisguisePeriod = 30000; - m_fDisguiseRange = 256; - m_fEnemyShareRange = 0; - m_fFixedLeash = 0.0; + m_iHealth = 100; + + m_iAccuracy = 20; + m_iAmmoGrenade = 0; + m_iBalconyHeight = 128; + + m_iDisguiseLevel = 1; + m_fDisguisePeriod = 30000; + m_fDisguiseRange = 256; + + m_fEnemyShareRange = 0; + m_fFixedLeash = 0.0; + m_fGrenadeAwareness = 20.0; m_fMaxNoticeTimeScale = 1; m_fSoundAwareness = 100; - m_bPatrolWaitTrigger = 0; - m_fHearing = 2048; - m_fSight = world->m_fAIVisionDistance; - m_fFov = 90; - m_fLeash = 512; - m_fMinDist = 128.0; - m_fMaxDist = 1024; - m_fInterval = 128.0; - m_bDontDropWeapons = 0; - m_bDontDropHealth = 0; - m_bNoSurprise = 0; - m_bForceDropWeapon = 0; - m_bForceDropHealth = 0; + + m_bPatrolWaitTrigger = false; + + m_fHearing = 2048; + m_fSight = world->m_fAIVisionDistance; + m_fFov = 90; + m_fLeash = 512; + m_fMinDist = 128.0; + m_fMaxDist = 1024; + m_fInterval = 128.0; + + m_bDontDropWeapons = false; + m_bDontDropHealth = false; + m_bNoSurprise = false; + m_bForceDropWeapon = false; + m_bForceDropHealth = false; } void AISpawnPoint::GetForceDropHealth(Event *ev) @@ -2371,7 +2535,10 @@ void AISpawnPoint::GetForceDropHealth(Event *ev) void AISpawnPoint::SetForceDropHealth(Event *ev) { - // This is a bug on original mohaab (2.30 and 2.40), it should be m_bForceDropHealth + // Fixed in OPM + // This does look like a mistake on original mohaab (2.30 and 2.40) + // it should be m_bForceDropHealth. + // That's the reason why AI often don't drop weapons //m_bForceDropWeapon = ev->GetBoolean(1); m_bForceDropHealth = ev->GetBoolean(1); } @@ -2538,12 +2705,12 @@ void AISpawnPoint::SetFov(Event *ev) void AISpawnPoint::SetSight(Event *ev) { - ev->AddFloat(m_fSight); + m_fSight = ev->GetFloat(1); } void AISpawnPoint::GetSight(Event *ev) { - m_fSight = ev->GetFloat(1); + ev->AddFloat(m_fSight); } void AISpawnPoint::GetHearing(Event *ev) diff --git a/code/fgame/Entities.h b/code/fgame/Entities.h index c08365f8..16ed9600 100644 --- a/code/fgame/Entities.h +++ b/code/fgame/Entities.h @@ -26,26 +26,26 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "animate.h" typedef enum { - CONTROLLER_ALLIES, - CONTROLLER_AXIS, + CONTROLLER_AXIS, + CONTROLLER_ALLIES, CONTROLLER_DRAW } eController; -#define PT_SPAWNFLAG_PLAY_FIRE_SOUND 1 -#define PT_SPAWNFLAG_PLAY_MOTION_SOUND 2 -#define PT_SPAWNFLAG_TARGET_RANDOM 4 -#define PT_SPAWNFLAG_TURN_ON 8 -#define PT_SPAWNFLAG_ROTATE_YAW 16 -#define PT_SPAWNFLAG_ROTATE_ROLL 32 -#define PT_SPAWNFLAG_TARGET_PLAYER 64 -#define PT_SPAWNFLAG_HIDDEN 128 +#define PT_SPAWNFLAG_PLAY_FIRE_SOUND 1 +#define PT_SPAWNFLAG_PLAY_MOTION_SOUND 2 +#define PT_SPAWNFLAG_TARGET_RANDOM 4 +#define PT_SPAWNFLAG_TURN_ON 8 +#define PT_SPAWNFLAG_ROTATE_YAW 16 +#define PT_SPAWNFLAG_ROTATE_ROLL 32 +#define PT_SPAWNFLAG_TARGET_PLAYER 64 +#define PT_SPAWNFLAG_HIDDEN 128 void ClearProjectileTargets(); class ProjectileTarget : public Entity { private: - int m_iTarget; + int m_iID; public: CLASS_PROTOTYPE(ProjectileTarget); @@ -53,7 +53,9 @@ public: ProjectileTarget(); void EventSetId(Event *ev); - int GetTarget() const; + int GetId() const; + + void Archive(Archiver& arc) override; }; #define MAX_PROJECTILE_GENERATOR_TARGETS 16 @@ -106,16 +108,16 @@ public: bool ShouldRotateYaw() const; bool ShouldRotateRoll() const; - void EventIsTurnedOn(Event *ev); - void EventGetTargetEntity(Event *ev); - void EventLaunchSound(Event *ev); - void SetTarget(Event *ev); - void SetTarget(Entity* ent); - void OnInitialize(Event *ev); - void TurnOff(Event *ev); - void TurnOn(Event *ev); - bool ShouldTargetRandom() const; - Entity* ChooseTarget(); + void EventIsTurnedOn(Event *ev); + void EventGetTargetEntity(Event *ev); + void EventLaunchSound(Event *ev); + void SetTarget(Event *ev); + void SetTarget(Entity *ent); + void OnInitialize(Event *ev); + void TurnOff(Event *ev); + void TurnOn(Event *ev); + bool ShouldTargetRandom() const; + Entity *ChooseTarget(); void GetLocalTargets(); bool ShouldTargetPlayer() const; @@ -123,7 +125,7 @@ public: void GetMuzzlePos(Vector& pos); void Fire(); void TryLaunchSound(); - void SetWeaponAnim(const char* name, Event* ev); + void SetWeaponAnim(const char *name, Event *ev); void EventAccuracy(Event *ev); void EventMaxDelay(Event *ev); void EventMinDelay(Event *ev); @@ -134,11 +136,11 @@ public: void EventMaxDuration(Event *ev); void EventMinDuration(Event *ev); void SetWeaponModel(Event *ev); - void EventSetId(Event* ev); - void EventmaxDonut(Event* ev); - void EventminDonut(Event* ev); - void EventarcDonut(Event* ev); - void EventisDonut(Event* ev); + void EventSetId(Event *ev); + void EventmaxDonut(Event *ev); + void EventminDonut(Event *ev); + void EventarcDonut(Event *ev); + void EventisDonut(Event *ev); virtual bool Attack(int count); void Archive(Archiver& arc) override; @@ -164,8 +166,8 @@ public: void SetProjectileModel(Event *ev); float EstimateImpactTime(const Vector& targetOrigin, const Vector& fromOrigin, float speed) const; - bool Attack(int count) override; - void Archive(Archiver& arc) override; + bool Attack(int count) override; + void Archive(Archiver& arc) override; }; class ProjectileGenerator_Gun : public ProjectileGenerator @@ -275,24 +277,36 @@ class ThrobbingBox_ExplodePlayerFlak88 : public ThrobbingBox_Explosive { public: CLASS_PROTOTYPE(ThrobbingBox_ExplodePlayerFlak88); + +public: + ThrobbingBox_ExplodePlayerFlak88(); }; class ThrobbingBox_ExplodeFlak88 : public ThrobbingBox_Explosive { public: CLASS_PROTOTYPE(ThrobbingBox_ExplodeFlak88); + +public: + ThrobbingBox_ExplodeFlak88(); }; class ThrobbingBox_ExplodeNebelwerfer : public ThrobbingBox_Explosive { public: CLASS_PROTOTYPE(ThrobbingBox_ExplodeNebelwerfer); + +public: + ThrobbingBox_ExplodeNebelwerfer(); }; class ThrobbingBox_ExplodePlayerNebelwerfer : public ThrobbingBox_Explosive { public: CLASS_PROTOTYPE(ThrobbingBox_ExplodePlayerNebelwerfer); + +public: + ThrobbingBox_ExplodePlayerNebelwerfer(); }; #define TBE_SPAWNFLAG_DESTROYED_MODEL 1 @@ -306,6 +320,8 @@ private: public: CLASS_PROTOTYPE(ThrobbingBox_Stickybomb); + ThrobbingBox_Stickybomb(); + void OnStickyBombWet(Event *ev); void OnStickyBombUse(Event *ev); @@ -325,7 +341,7 @@ public: Objective(); - void Archive(Archiver &arc) override; + void Archive(Archiver& arc) override; void TurnOn(Event *ev); void TurnOff(Event *ev); void Complete(Event *ev); @@ -340,6 +356,10 @@ class FencePost : public Entity { public: CLASS_PROTOTYPE(FencePost); + + FencePost(); + + void Killed(Event* ev) override; }; class AISpawnPoint : public SimpleArchivedEntity diff --git a/code/fgame/Tow_Entities.cpp b/code/fgame/Tow_Entities.cpp index d4b1921b..b59c2ec7 100644 --- a/code/fgame/Tow_Entities.cpp +++ b/code/fgame/Tow_Entities.cpp @@ -269,13 +269,13 @@ void TOWObjective::TakeOver(Event *ev) switch (controller) { case CONTROLLER_ALLIES: - gi.cvar_set(m_sAxisObjName.c_str(), "1"); - gi.cvar_set(m_sAlliesObjName.c_str(), "0"); - break; - case CONTROLLER_AXIS: gi.cvar_set(m_sAxisObjName.c_str(), "0"); gi.cvar_set(m_sAlliesObjName.c_str(), "1"); break; + case CONTROLLER_AXIS: + gi.cvar_set(m_sAxisObjName.c_str(), "1"); + gi.cvar_set(m_sAlliesObjName.c_str(), "0"); + break; default: break; } @@ -308,13 +308,13 @@ void TOWObjective::OnInitialize(Event *ev) switch (m_eController) { case CONTROLLER_ALLIES: - gi.cvar_set(m_sAxisObjName.c_str(), "1"); - gi.cvar_set(m_sAlliesObjName.c_str(), "0"); - break; - case CONTROLLER_AXIS: gi.cvar_set(m_sAxisObjName.c_str(), "0"); gi.cvar_set(m_sAlliesObjName.c_str(), "1"); break; + case CONTROLLER_AXIS: + gi.cvar_set(m_sAxisObjName.c_str(), "1"); + gi.cvar_set(m_sAlliesObjName.c_str(), "0"); + break; case CONTROLLER_DRAW: gi.cvar_set(m_sAxisObjName.c_str(), "0"); gi.cvar_set(m_sAlliesObjName.c_str(), "0"); diff --git a/code/fgame/Tow_Entities.h b/code/fgame/Tow_Entities.h index eee8cd6f..dca59a86 100644 --- a/code/fgame/Tow_Entities.h +++ b/code/fgame/Tow_Entities.h @@ -59,8 +59,8 @@ class TOWObjectiveMan { private: Container m_towObjectives; - int m_iNumAxisObjectives; int m_iNumAlliesObjectives; + int m_iNumAxisObjectives; public: TOWObjectiveMan(); diff --git a/code/fgame/VehicleCollisionEntity.cpp b/code/fgame/VehicleCollisionEntity.cpp index a63a51e6..8c53faa6 100644 --- a/code/fgame/VehicleCollisionEntity.cpp +++ b/code/fgame/VehicleCollisionEntity.cpp @@ -24,69 +24,77 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "VehicleCollisionEntity.h" #include "g_phys.h" -CLASS_DECLARATION( Entity, VehicleCollisionEntity, NULL ) -{ - { &EV_Damage, &VehicleCollisionEntity::EventDamage }, - { NULL, NULL } +Event EV_Owner +( + "owner", + EV_DEFAULT, + NULL, + NULL, + "owner", + EV_GETTER +); + +CLASS_DECLARATION(Entity, VehicleCollisionEntity, NULL) { + {&EV_Damage, &VehicleCollisionEntity::EventDamage}, + {&EV_Owner, &VehicleCollisionEntity::GetOwner }, + {NULL, NULL } }; -VehicleCollisionEntity::VehicleCollisionEntity - ( - Entity *ent - ) +VehicleCollisionEntity::VehicleCollisionEntity(Entity *ent) { - if( LoadingSavegame ) - { - return; - } + if (LoadingSavegame) { + return; + } - edict->s.eType = ET_GENERAL; + edict->s.eType = ET_GENERAL; - m_pOwner = ent; - takedamage = DAMAGE_YES; + m_pOwner = ent; + takedamage = DAMAGE_YES; - showModel(); - setMoveType( MOVETYPE_PUSH ); - setSolidType(SOLID_NOT); + showModel(); + setMoveType(MOVETYPE_PUSH); + setSolidType(SOLID_NOT); - edict->clipmask |= MASK_VEHICLE; - edict->s.eFlags |= EF_LINKANGLES; + edict->clipmask |= MASK_VEHICLE; + edict->s.eFlags |= EF_LINKANGLES; } -VehicleCollisionEntity::VehicleCollisionEntity - ( - void - ) +VehicleCollisionEntity::VehicleCollisionEntity(void) { - if( LoadingSavegame ) - { - return; - } + if (LoadingSavegame) { + return; + } - gi.Error( ERR_DROP, "VehicleCollisionEntity Created with no parameters!\n" ); + gi.Error(ERR_DROP, "VehicleCollisionEntity Created with no parameters!\n"); } -void VehicleCollisionEntity::EventDamage - ( - Event *ev - ) +void VehicleCollisionEntity::GetOwner(Event *ev) { - m_pOwner->ProcessEvent(*ev); + ev->AddListener(m_pOwner); } -void VehicleCollisionEntity::Solid - ( - void - ) +void VehicleCollisionEntity::Solid(void) { - setContents( CONTENTS_SOLID ); - setSolidType( SOLID_BSP ); + setContents(CONTENTS_SOLID); + setSolidType(SOLID_BSP); } -void VehicleCollisionEntity::NotSolid - ( - void - ) +void VehicleCollisionEntity::NotSolid(void) { - setSolidType( SOLID_NOT ); + setSolidType(SOLID_NOT); +} + +void VehicleCollisionEntity::EventDamage(Event *ev) +{ + m_pOwner->ProcessEvent(*ev); +} + +void VehicleCollisionEntity::Used(Event *ev) +{ + m_pOwner->ProcessEvent(*ev); +} + +Entity *VehicleCollisionEntity::GetOwner() const +{ + return m_pOwner; } diff --git a/code/fgame/VehicleCollisionEntity.h b/code/fgame/VehicleCollisionEntity.h index f2b508a1..5185fc3c 100644 --- a/code/fgame/VehicleCollisionEntity.h +++ b/code/fgame/VehicleCollisionEntity.h @@ -21,40 +21,36 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // VehicleCollisionEntity.h : MOHAA vehicle collision -#ifndef __VEHICLECOLLISIONENTITY_H__ -#define __VEHICLECOLLISIONENTITY_H__ +#pragma once #include "entity.h" class VehicleCollisionEntity : public Entity { private: - EntityPtr m_pOwner; + EntityPtr m_pOwner; private: - void EventDamage( Event *ev ); + void EventDamage(Event *ev); + void GetOwner(Event *ev); + void Used(Event *ev); public: - CLASS_PROTOTYPE( VehicleCollisionEntity ); + CLASS_PROTOTYPE(VehicleCollisionEntity); - VehicleCollisionEntity( Entity *ent ); - VehicleCollisionEntity(); + VehicleCollisionEntity(Entity *ent); + VehicleCollisionEntity(); - void Archive( Archiver& arc ) override; + void Archive(Archiver& arc) override; - void Solid( void ); - void NotSolid( void ); + void Solid(void); + void NotSolid(void); + Entity *GetOwner() const; }; -inline -void VehicleCollisionEntity::Archive - ( - Archiver& arc - ) +inline void VehicleCollisionEntity::Archive(Archiver& arc) { - Entity::Archive( arc ); + Entity::Archive(arc); - arc.ArchiveSafePointer( &m_pOwner ); + arc.ArchiveSafePointer(&m_pOwner); } - -#endif // __VEHICLECOLLISIONENTITY_H__ \ No newline at end of file diff --git a/code/fgame/VehicleHalfTrack.cpp b/code/fgame/VehicleHalfTrack.cpp index 72b83768..5e0341ad 100644 --- a/code/fgame/VehicleHalfTrack.cpp +++ b/code/fgame/VehicleHalfTrack.cpp @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2018 the OpenMoHAA team +Copyright (C) 2018-2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -22,42 +22,222 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "vehicle.h" #include "player.h" +#include "g_phys.h" -CLASS_DECLARATION(DrivableVehicle, VehicleHalfTrack, "VehicleHalfTrack") -{ - { &EV_Damage, &VehicleHalfTrack::EventDamage }, - { &EV_Killed, &VehicleHalfTrack::Killed }, - { NULL, NULL } +CLASS_DECLARATION(DrivableVehicle, VehicleHalfTrack, "VehicleHalfTrack") { + {&EV_Damage, &VehicleHalfTrack::EventDamage}, + {&EV_Killed, &VehicleHalfTrack::Killed }, + {NULL, NULL } }; VehicleHalfTrack::VehicleHalfTrack() { - - ; } void VehicleHalfTrack::Think() { - vmove_t vm; - flags |= FL_POSTTHINK; + vmove_t vm; + flags |= FL_POSTTHINK; - prev_velocity = velocity; + prev_velocity = velocity; - SetSlotsNonSolid(); + SetSlotsNonSolid(); - SetMoveInfo(&vm); - VmoveSingle(&vm); - GetMoveInfo(&vm); + SetMoveInfo(&vm); + VmoveSingle(&vm); + GetMoveInfo(&vm); - SetSlotsSolid(); + SetSlotsSolid(); } void VehicleHalfTrack::Postthink() { - // FIXME: STUB + float turn; + Vector i, j, k; + int index; + trace_t trace; + Vector normalsum; + int numnormals; + Vector temp; + Vector pitch, roll; + Vector acceleration; + Vector atmp, atmp2, aup; + VehicleBase *v; + VehicleBase *last; + float drivespeed; + Vector primal_angles; + Vector vTmp; + Vector n_angles; + + primal_angles = angles; + + if (drivable) { + if (m_bAutoPilot) { + AutoPilot(); + } + + currentspeed = moveimpulse; + turnangle = turnangle * 0.25 + turnimpulse; + turnangle = Q_clamp_float(turnangle, -maxturnrate, maxturnrate); + + real_velocity = origin - prev_origin; + prev_origin = origin; + prev_acceleration = real_acceleration; + real_acceleration = real_velocity - prev_velocity; + prev_velocity = real_velocity; + acceleration = real_acceleration - prev_acceleration; + + temp = angles; + temp.AngleVectorsLeft(&i, &j, &k); + + j = vec_zero - j; + + numnormals = 0; + for (index = 0; index < MAX_CORNERS; index++) { + Vector start, end; + Vector boxoffset; + Vector t_mins(-8, -8, -8), t_maxs(8, 8, 8); + + boxoffset = Corners[index]; + start = origin + i * boxoffset[0] + j * boxoffset[1] + k * boxoffset[2]; + end = start + Vector(0, 0, -400); + + trace = G_Trace(start, t_mins, t_maxs, end, this, MASK_VEHICLE_TIRES, false, "Vehicle::PostThink Corners"); + + if (trace.fraction != 1.0 || trace.startsolid) { + normalsum += trace.plane.normal; + } + } + + angles[2] = 0; + + if (m_iNumNormals > 1) { + temp = normalsum / numnormals; + temp.normalize(); + i = temp.CrossProduct(temp, j); + + pitch = i; + angles[0] = -pitch.toPitch(); + } + + turn = turnangle / 200.0; + if (groundentity) { + Vector newvel; + Vector flatvel; + + velocity[0] *= 0.925f; + velocity[1] *= 0.925f; + + flatvel = orientation[0]; + velocity += flatvel * currentspeed; + flatvel[2] = 0; + + drivespeed = Q_clamp_float(velocity * flatvel, -speed, speed); + + newvel = flatvel * drivespeed; + velocity[0] = newvel[0]; + velocity[1] = newvel[1]; + velocity[2] += drivespeed * jumpimpulse; + + avelocity *= 0.05f; + + if (steerinplace) { + if (drivespeed < 350) { + drivespeed = 350; + } + } + + avelocity.y += turn * drivespeed; + } else { + avelocity *= 0.1f; + } + + angles += avelocity * level.frametime; + setAngles(angles); + } + + drivespeed = acceleration * orientation[0]; + + if (drivable && driver.ent) { + str sound_name; + + if (currentspeed > 0) { + sound_name = "snd_forward"; + } else if (currentspeed < 0) { + sound_name = "snd_backward"; + } else { + sound_name = "snd_idle"; + } + + LoopSound(sound_name); + } + + i = orientation[0]; + j = orientation[1]; + k = orientation[2]; + + if (driver.ent) { + driver.ent->setOrigin(origin + i * driveroffset[0] + j * driveroffset[1] + k * driveroffset[2]); + + if (drivable) { + // clear the driver velocity + driver.ent->velocity = vec_zero; + // set the driver angles to the vehicle's angle + driver.ent->setAngles(angles); + } + } + + n_angles = (angles - primal_angles) * level.frametime; + if (n_angles.x > 180 || n_angles.x < -180) { + n_angles.x = 0; + } + if (n_angles.y > 180 || n_angles.y < -180) { + n_angles.y = 0; + } + if (n_angles.z > 180 || n_angles.z < -180) { + n_angles.z = 0; + } + + if (n_angles.x > -1 || n_angles.x < 1) { + n_angles.x = 0; + } + if (n_angles.y > -1 || n_angles.y < 1) { + n_angles.y = 0; + } + if (n_angles.z > -1 || n_angles.z < 1) { + n_angles.z = 0; + } + + avelocity = n_angles; + + for (last = this; last->vlink; last = v) { + v = last->vlink; + + v->setOrigin(origin + i * v->offset.x + j * v->offset.y + k * v->offset.z); + v->avelocity = avelocity; + v->velocity = velocity; + + v->angles[ROLL] = angles[ROLL]; + v->angles[YAW] = angles[YAW]; + v->angles[PITCH] = (int)(drivespeed / 4.f + v->angles[PITCH]) % 360; + v->setAngles(v->angles); + } + + CheckWater(); + WorldEffects(); + + last_origin = origin; + + if (!driver.ent && !velocity.length() && groundentity && !(watertype & CONTENTS_LAVA)) { + // make the vehicle stationary if it's completely immobile + flags &= ~FL_POSTTHINK; + if (drivable) { + setMoveType(MOVETYPE_STATIONARY); + } + } } -void VehicleHalfTrack::Killed(Event* ev) +void VehicleHalfTrack::Killed(Event *ev) { - deadflag = DEAD_DEAD; + deadflag = DEAD_DEAD; } diff --git a/code/fgame/VehicleSlot.cpp b/code/fgame/VehicleSlot.cpp index 8da80156..e4858da5 100644 --- a/code/fgame/VehicleSlot.cpp +++ b/code/fgame/VehicleSlot.cpp @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -31,6 +31,8 @@ cVehicleSlot::cVehicleSlot() prev_takedamage = (damage_t)-1; prev_solid = (solid_t)-1; prev_contents = -1; + + prev_num_children = 0; } void cVehicleSlot::NotSolid(void) @@ -51,23 +53,37 @@ void cVehicleSlot::NotSolid(void) prev_contents = ent->edict->r.contents; ent->takedamage = DAMAGE_NO; - ent->setSolidType(SOLID_NOT); + + prev_num_children = 0; for (i = 0; i < ent->numchildren; i++) { Entity *sub = G_GetEntity(ent->children[i]); - if (sub && !sub->IsSubclassOfWeapon()) { + // Fixed in OPM + // Check for solidity + if (sub && !sub->IsSubclassOfWeapon() && sub->getSolidType() != SOLID_NOT) { + // Fixed in OPM + // Save children solidity so it can properly be restored later + prev_children_ent[prev_num_children] = sub; + prev_children_solid[prev_num_children] = (solid_t)sub->getSolidType(); + prev_num_children++; + sub->setSolidType(SOLID_NOT); } } - if (!ent->IsSubclassOfPlayer()) { - ent->setSolidType(SOLID_NOT); - } + // Added in 2.0 + // Commented in OPM + // Not sure why since 2.0, players aren't made non-solid in slots + //if (!ent->IsSubclassOfPlayer()) { + // ent->setSolidType(SOLID_NOT); + //} + + ent->setSolidType(SOLID_NOT); } void cVehicleSlot::Solid(void) { - int i; + int i, j; if (!(flags & FL_SWIM)) { return; @@ -87,12 +103,24 @@ void cVehicleSlot::Solid(void) prev_solid = (solid_t)-1; prev_contents = -1; + // + // Fixed in OPM + // Restore children solidity + // for (i = 0; i < ent->numchildren; i++) { Entity *sub = G_GetEntity(ent->children[i]); if (sub && !sub->IsSubclassOfWeapon()) { - sub->setSolidType(SOLID_BBOX); + for (j = 0; j < prev_num_children; j++) { + if (prev_children_ent[j] == sub) { + sub->setSolidType(prev_children_solid[j]); + } + } + + //sub->setSolidType(SOLID_NOT); } } + + prev_num_children = 0; } cTurretSlot::cTurretSlot() @@ -136,9 +164,19 @@ void cTurretSlot::NotSolid(void) } } + prev_num_children = 0; + for (i = 0; i < ent->numchildren; i++) { Entity *sub = G_GetEntity(ent->children[i]); - if (sub && !sub->IsSubclassOfWeapon()) { + // Fixed in OPM + // Check for solidity + if (sub && !sub->IsSubclassOfWeapon() && sub->getSolidType() != SOLID_NOT) { + // Fixed in OPM + // Save children solidity so it can properly be restored later + prev_children_ent[prev_num_children] = sub; + prev_children_solid[prev_num_children] = (solid_t)sub->getSolidType(); + prev_num_children++; + sub->setSolidType(SOLID_NOT); } } @@ -146,7 +184,7 @@ void cTurretSlot::NotSolid(void) void cTurretSlot::Solid(void) { - int i; + int i, j; if (!(flags & FL_SWIM)) { return; @@ -177,10 +215,22 @@ void cTurretSlot::Solid(void) } } + // + // Fixed in OPM + // Restore children solidity + // for (i = 0; i < ent->numchildren; i++) { Entity *sub = G_GetEntity(ent->children[i]); if (sub && !sub->IsSubclassOfWeapon()) { - sub->setSolidType(SOLID_BBOX); + for (j = 0; j < prev_num_children; j++) { + if (prev_children_ent[j] == sub) { + sub->setSolidType(prev_children_solid[j]); + } + } + + //sub->setSolidType(SOLID_NOT); } } + + prev_num_children = 0; } diff --git a/code/fgame/VehicleSlot.h b/code/fgame/VehicleSlot.h index 48046321..509c3d31 100644 --- a/code/fgame/VehicleSlot.h +++ b/code/fgame/VehicleSlot.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -46,12 +46,19 @@ protected: solid_t prev_solid; int prev_contents; + // + // Added in OPM + // Used for properly saving and restoring children solidity + Entity *prev_children_ent[MAX_MODEL_CHILDREN]; + solid_t prev_children_solid[MAX_MODEL_CHILDREN]; + int prev_num_children; + public: cVehicleSlot(); virtual void NotSolid(void); virtual void Solid(void); - void Archive(Archiver &arc) override; + void Archive(Archiver& arc) override; }; inline void cVehicleSlot::Archive(Archiver& arc) diff --git a/code/fgame/VehicleSoundEntity.cpp b/code/fgame/VehicleSoundEntity.cpp index cc3f2c5a..284b4094 100644 --- a/code/fgame/VehicleSoundEntity.cpp +++ b/code/fgame/VehicleSoundEntity.cpp @@ -26,159 +26,128 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "vehicle.h" Event EV_VehicleSoundEntity_PostSpawn - ( - "vehiclesoundentity_post", - EV_DEFAULT, - NULL, - NULL, - "PostSpawn of a Vehicle Sound Entity" - ); +( + "vehiclesoundentity_post", + EV_DEFAULT, + NULL, + NULL, + "PostSpawn of a Vehicle Sound Entity" +); Event EV_VehicleSoundEntity_UpdateTraces - ( - "vehiclesoudnentity_updatetraces", - EV_DEFAULT, - NULL, - NULL, - "Updates the traces of a Vehicle Sound Entity" - ); +( + "vehiclesoudnentity_updatetraces", + EV_DEFAULT, + NULL, + NULL, + "Updates the traces of a Vehicle Sound Entity" +); -CLASS_DECLARATION( Entity, VehicleSoundEntity, NULL ) -{ - { &EV_VehicleSoundEntity_PostSpawn, &VehicleSoundEntity::EventPostSpawn }, - { &EV_VehicleSoundEntity_UpdateTraces, &VehicleSoundEntity::EventUpdateTraces }, - { NULL, NULL } +CLASS_DECLARATION(Entity, VehicleSoundEntity, NULL) { + {&EV_VehicleSoundEntity_PostSpawn, &VehicleSoundEntity::EventPostSpawn }, + {&EV_VehicleSoundEntity_UpdateTraces, &VehicleSoundEntity::EventUpdateTraces}, + {NULL, NULL } }; VehicleSoundEntity::VehicleSoundEntity() { - if( LoadingSavegame ) - { - return; - } + if (LoadingSavegame) { + return; + } - gi.Error( ERR_DROP, "VehicleSoundEntity Created with no parameters!\n" ); + gi.Error(ERR_DROP, "VehicleSoundEntity Created with no parameters!\n"); } -VehicleSoundEntity::VehicleSoundEntity( Vehicle *owner ) +VehicleSoundEntity::VehicleSoundEntity(Vehicle *owner) { - m_pVehicle = owner; - m_bDoSoundStuff = false; - m_iTraceSurfaceFlags = 0; + m_pVehicle = owner; + m_bDoSoundStuff = false; + m_iTraceSurfaceFlags = 0; - PostEvent( EV_VehicleSoundEntity_PostSpawn, EV_POSTSPAWN ); + PostEvent(EV_VehicleSoundEntity_PostSpawn, EV_POSTSPAWN); } -void VehicleSoundEntity::Start - ( - void - ) +void VehicleSoundEntity::Start(void) { - m_bDoSoundStuff = true; + m_bDoSoundStuff = true; } -void VehicleSoundEntity::Stop - ( - void - ) +void VehicleSoundEntity::Stop(void) { - m_bDoSoundStuff = false; + m_bDoSoundStuff = false; } -void VehicleSoundEntity::Think - ( - void - ) +void VehicleSoundEntity::Think(void) { - DoSoundStuff(); + DoSoundStuff(); } -void VehicleSoundEntity::EventPostSpawn - ( - Event *ev - ) +void VehicleSoundEntity::EventPostSpawn(Event *ev) { - setModel( "models/vehicles/vehiclesoundentity.tik" ); + setModel("models/vehicles/vehiclesoundentity.tik"); - PostEvent( EV_VehicleSoundEntity_UpdateTraces, 1.0f ); - flags |= FL_THINK; + PostEvent(EV_VehicleSoundEntity_UpdateTraces, 1.0f); + flags |= FL_THINK; } -void VehicleSoundEntity::EventUpdateTraces - ( - Event *ev - ) +void VehicleSoundEntity::EventUpdateTraces(Event *ev) { - if( m_bDoSoundStuff ) - { - m_pVehicle->SetSlotsNonSolid(); + if (m_bDoSoundStuff) { + m_pVehicle->SetSlotsNonSolid(); - trace_t trace = G_Trace( - origin, - vec3_origin, - vec3_origin, - Vector( origin[ 0 ], origin[ 1 ], origin[ 2 ] - 256.0f ), - m_pVehicle->edict, - MASK_SOUND, - qfalse, - "VehicleSoundEntity::DoSoundStuff" - ); + trace_t trace = G_Trace( + origin, + vec3_origin, + vec3_origin, + Vector(origin[0], origin[1], origin[2] - 256.0f), + m_pVehicle->edict, + MASK_SOUND, + qfalse, + "VehicleSoundEntity::DoSoundStuff" + ); - if( trace.fraction >= 1.0f ) - m_iTraceSurfaceFlags = 0; - else - m_iTraceSurfaceFlags = trace.surfaceFlags; + if (trace.fraction >= 1.0f) { + m_iTraceSurfaceFlags = 0; + } else { + m_iTraceSurfaceFlags = trace.surfaceFlags; + } - m_pVehicle->SetSlotsSolid(); - } + m_pVehicle->SetSlotsSolid(); + } - PostEvent( EV_VehicleSoundEntity_UpdateTraces, 1.0f ); + PostEvent(EV_VehicleSoundEntity_UpdateTraces, 1.0f); } -void VehicleSoundEntity::DoSoundStuff - ( - void - ) +void VehicleSoundEntity::DoSoundStuff(void) { - float pitch; + float pitch; - if( !m_bDoSoundStuff ) - { - StopLoopSound(); - return; - } + if (!m_bDoSoundStuff) { + StopLoopSound(); + return; + } - pitch = ( velocity.length() - m_pVehicle->m_fSoundMinSpeed ) / ( m_pVehicle->m_fSoundMaxSpeed - m_pVehicle->m_fSoundMinSpeed ); - if( pitch > 1.0f ) { - pitch = 1.0f; - } else if( pitch < 0.0f ) { - pitch = 0.0f; - } + pitch = (velocity.length() - m_pVehicle->m_fSoundMinSpeed) + / (m_pVehicle->m_fSoundMaxSpeed - m_pVehicle->m_fSoundMinSpeed); + if (pitch > 1.0f) { + pitch = 1.0f; + } else if (pitch < 0.0f) { + pitch = 0.0f; + } - pitch *= m_pVehicle->m_fSoundMinPitch + ( m_pVehicle->m_fSoundMaxPitch - m_pVehicle->m_fSoundMinPitch ); + pitch *= m_pVehicle->m_fSoundMinPitch + (m_pVehicle->m_fSoundMaxPitch - m_pVehicle->m_fSoundMinPitch); - if( m_iTraceSurfaceFlags & SURF_DIRT ) - { - LoopSound( m_pVehicle->m_sSoundSet + "treat_snd_dirt", -1.0f, -1.0f, -1.0f, pitch ); - } - else if( m_iTraceSurfaceFlags & SURF_GRASS ) - { - LoopSound( m_pVehicle->m_sSoundSet + "treat_snd_grass", -1.0f, -1.0f, -1.0f, pitch ); - } - else if( m_iTraceSurfaceFlags & SURF_WOOD ) - { - LoopSound( m_pVehicle->m_sSoundSet + "treat_snd_wood", -1.0f, -1.0f, -1.0f, pitch ); - } - else if( m_iTraceSurfaceFlags & SURF_MUD ) - { - LoopSound( m_pVehicle->m_sSoundSet + "treat_snd_mud", -1.0f, -1.0f, -1.0f, pitch ); - } - else if( m_iTraceSurfaceFlags & ( SURF_GRAVEL | SURF_ROCK ) ) - { - LoopSound( m_pVehicle->m_sSoundSet + "treat_snd_stone", -1.0f, -1.0f, -1.0f, pitch ); - } - else - { - StopLoopSound(); - } + if (m_iTraceSurfaceFlags & SURF_DIRT) { + LoopSound(m_pVehicle->m_sSoundSet + "tread_snd_dirt", -1.0f, -1.0f, -1.0f, pitch); + } else if (m_iTraceSurfaceFlags & SURF_GRASS) { + LoopSound(m_pVehicle->m_sSoundSet + "tread_snd_grass", -1.0f, -1.0f, -1.0f, pitch); + } else if (m_iTraceSurfaceFlags & SURF_WOOD) { + LoopSound(m_pVehicle->m_sSoundSet + "tread_snd_wood", -1.0f, -1.0f, -1.0f, pitch); + } else if (m_iTraceSurfaceFlags & SURF_MUD) { + LoopSound(m_pVehicle->m_sSoundSet + "tread_snd_mud", -1.0f, -1.0f, -1.0f, pitch); + } else if (m_iTraceSurfaceFlags & (SURF_GRAVEL | SURF_ROCK) || m_iTraceSurfaceFlags == 0) { + LoopSound(m_pVehicle->m_sSoundSet + "tread_snd_stone", -1.0f, -1.0f, -1.0f, pitch); + } else { + StopLoopSound(); + } } diff --git a/code/fgame/VehicleSoundEntity.h b/code/fgame/VehicleSoundEntity.h index fa41dc65..2b5c93d5 100644 --- a/code/fgame/VehicleSoundEntity.h +++ b/code/fgame/VehicleSoundEntity.h @@ -21,47 +21,41 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // VehicleSoundEntity.h : Sound helper for vehicles -#ifndef __VEHICLESOUNDENTITY_H__ -#define __VEHICLESOUNDENTITY_H__ +#pragma once #include "entity.h" class Vehicle; -class VehicleSoundEntity : public Entity { +class VehicleSoundEntity : public Entity +{ private: - SafePtr m_pVehicle; - bool m_bDoSoundStuff; - int m_iTraceSurfaceFlags; + SafePtr m_pVehicle; + bool m_bDoSoundStuff; + int m_iTraceSurfaceFlags; public: - CLASS_PROTOTYPE( VehicleSoundEntity ); + CLASS_PROTOTYPE(VehicleSoundEntity); - VehicleSoundEntity(); - VehicleSoundEntity( Vehicle *owner ); + VehicleSoundEntity(); + VehicleSoundEntity(Vehicle *owner); - void Start( void ); - void Stop( void ); - void Think( void ) override; - void Archive( Archiver& arc ) override; + void Start(void); + void Stop(void); + void Think(void) override; + void Archive(Archiver& arc) override; private: - void EventPostSpawn( Event *ev ); - void EventUpdateTraces( Event *ev ); - void DoSoundStuff( void ); + void EventPostSpawn(Event *ev); + void EventUpdateTraces(Event *ev); + void DoSoundStuff(void); }; -inline -void VehicleSoundEntity::Archive - ( - Archiver& arc - ) +inline void VehicleSoundEntity::Archive(Archiver& arc) { - Entity::Archive( arc ); + Entity::Archive(arc); - arc.ArchiveSafePointer( &m_pVehicle ); - arc.ArchiveBool( &m_bDoSoundStuff ); - arc.ArchiveInteger( &m_iTraceSurfaceFlags ); + arc.ArchiveSafePointer(&m_pVehicle); + arc.ArchiveBool(&m_bDoSoundStuff); + arc.ArchiveInteger(&m_iTraceSurfaceFlags); } - -#endif // __VEHICLECOLLISIONENTITY_H__ \ No newline at end of file diff --git a/code/fgame/VehicleTank.cpp b/code/fgame/VehicleTank.cpp index a215a628..bcc17fba 100644 --- a/code/fgame/VehicleTank.cpp +++ b/code/fgame/VehicleTank.cpp @@ -334,7 +334,10 @@ void VehicleTank::Postthink() // the tank was non-solid with a player driver, // instead of the driver being non-solid. //setSolidType(SOLID_NOT); - driver.ent->setSolidType(SOLID_NOT); + + // Fixed in OPM + // Driver is made non-solid in Vehicle::MoveThink + //driver.ent->setSolidType(SOLID_NOT); } else { driver.ent->takedamage = DAMAGE_NO; driver.ent->setSolidType(SOLID_NOT); @@ -503,7 +506,7 @@ void VehicleTank::UpdateSound() // This method only work when called from script. // But it is not called automatically when the player actually uses the vehicle // when that vehicle is unlocked. -// So the other native method is overriden instead +// So the other native method is overridden instead /* void VehicleTank::AttachDriverSlot(Event *ev) { diff --git a/code/fgame/actor.cpp b/code/fgame/actor.cpp index 6a5ca672..5045e93e 100644 --- a/code/fgame/actor.cpp +++ b/code/fgame/actor.cpp @@ -261,6 +261,8 @@ Event EV_Actor_AnimScript_Noclip "Play the noclip animation script", EV_NORMAL ); +// Added in 2.0 +//==== Event EV_Actor_AnimScript_Attached ( "animscript_attached", @@ -270,6 +272,7 @@ Event EV_Actor_AnimScript_Attached "Play a noclip animation even when attached", EV_NORMAL ); +//==== Event EV_Actor_Reload_mg42 ( "reload_mg42", @@ -429,7 +432,7 @@ Event EV_Actor_SetAnimFinal EV_DEFAULT, NULL, NULL, - "Whether the animation was succesfully finished", + "Whether the animation was successfully finished", EV_SETTER ); Event EV_Actor_GetWeaponType @@ -555,7 +558,7 @@ Event EV_Actor_DamagePuff EV_DEFAULT, "vv", "position direction", - "Spawns a puff of 'blood' smoke at the speficied location in the specified direction.", + "Spawns a puff of 'blood' smoke at the specified location in the specified direction.", EV_NORMAL ); Event EV_Actor_SetAngleYawSpeed @@ -918,6 +921,8 @@ Event EV_Actor_GetAlarmNode "Gets the name of the alarm node for the actor (must have type set to alarm for effect)", EV_GETTER ); +// Added in 2.30 +//==== Event EV_Actor_SetPreAlarmThread ( "prealarmthread", @@ -936,6 +941,7 @@ Event EV_Actor_SetPreAlarmThread2 "Sets the name of the pre alarm thread for the actor (must have type set to alarm for effect)", EV_SETTER ); +//==== Event EV_Actor_SetAlarmThread ( "alarmthread", @@ -2181,6 +2187,9 @@ Event EV_Actor_GetBalconyHeight "minimum height a balcony guy must fall to do special balcony death", EV_GETTER ); +// +// Added in 2.0 +//==== Event EV_Actor_SetVisibilityThreshold ( "nonvislevel", @@ -2325,6 +2334,10 @@ Event EV_Actor_GetRunAnimRate "Get the rate at which the run animation plays back", EV_GETTER ); +//==== +// +// Added in 2.30 +//==== Event EV_Actor_SetNationality ( "nationality", @@ -2379,6 +2392,7 @@ Event EV_Actor_CuriousOn "Turn on an actor's curious state", EV_NORMAL ); +//==== CLASS_DECLARATION(SimpleActor, Actor, "Actor") { {&EV_Entity_Start, &Actor::EventStart }, @@ -2399,7 +2413,10 @@ CLASS_DECLARATION(SimpleActor, Actor, "Actor") { {&EV_Actor_AnimScript, &Actor::EventAnimScript }, {&EV_Actor_AnimScript_Scripted, &Actor::EventAnimScript_Scripted }, {&EV_Actor_AnimScript_Noclip, &Actor::EventAnimScript_Noclip }, + // Added in 2.0 + //==== {&EV_Actor_AnimScript_Attached, &Actor::EventAnimScript_Attached }, + //==== {&EV_Actor_Reload_mg42, &Actor::EventReload_mg42 }, {&EV_Actor_Dumb, &Actor::Dumb }, {&EV_Actor_Physics_On, &Actor::PhysicsOn }, @@ -2510,8 +2527,11 @@ CLASS_DECLARATION(SimpleActor, Actor, "Actor") { {&EV_Actor_SetAlarmNode, &Actor::EventSetAlarmNode }, {&EV_Actor_SetAlarmNode2, &Actor::EventSetAlarmNode }, {&EV_Actor_GetAlarmNode, &Actor::EventGetAlarmNode }, + // Added in 2.30 + //==== {&EV_Actor_SetPreAlarmThread, &Actor::EventSetPreAlarmThread }, {&EV_Actor_SetPreAlarmThread2, &Actor::EventSetPreAlarmThread }, + //==== {&EV_Actor_SetAlarmThread, &Actor::EventSetAlarmThread }, {&EV_Actor_SetAlarmThread2, &Actor::EventSetAlarmThread }, {&EV_Actor_GetAlarmThread, &Actor::EventGetAlarmThread }, @@ -2538,6 +2558,8 @@ CLASS_DECLARATION(SimpleActor, Actor, "Actor") { {&EV_Actor_ShareEnemy, &Actor::EventShareEnemy }, {&EV_Actor_ShareGrenade, &Actor::EventShareGrenade }, {&EV_Actor_InterruptPoint, &Actor::EventInterruptPoint }, + // Added in 2.0 + //==== {&EV_Actor_GetVisibilityThreshold, &Actor::EventGetVisibilityThreshold }, {&EV_Actor_SetVisibilityThreshold, &Actor::EventSetVisibilityThreshold }, {&EV_Actor_SetVisibilityThreshold2, &Actor::EventSetVisibilityThreshold }, @@ -2545,6 +2567,7 @@ CLASS_DECLARATION(SimpleActor, Actor, "Actor") { {&EV_Actor_GetSuppressChance, &Actor::EventGetSuppressChance }, {&EV_Actor_SetSuppressChance, &Actor::EventSetSuppressChance }, {&EV_Actor_SetSuppressChance2, &Actor::EventSetSuppressChance }, + //==== {&EV_Actor_GetPainHandler, &Actor::EventGetPainHandler }, {&EV_Actor_SetPainHandler, &Actor::EventSetPainHandler }, {&EV_Actor_GetDeathHandler, &Actor::EventGetDeathHandler }, @@ -2598,12 +2621,14 @@ CLASS_DECLARATION(SimpleActor, Actor, "Actor") { {&EV_Actor_GetMumble, &Actor::EventGetMumble }, {&EV_Actor_SetMumble, &Actor::EventSetMumble }, {&EV_Actor_SetMumble2, &Actor::EventSetMumble }, - // FIXME: removed since 2.0? - //{&EV_Actor_GetBreathSteam, &Actor::EventGetBreathSteam }, - //{&EV_Actor_SetBreathSteam, &Actor::EventSetBreathSteam }, - //{&EV_Actor_SetBreathSteam2, &Actor::EventSetBreathSteam }, + // Removed in 2.0 + //==== + //{&EV_Actor_GetBreathSteam, &Actor::EventGetBreathSteam }, + //{&EV_Actor_SetBreathSteam, &Actor::EventSetBreathSteam }, + //{&EV_Actor_SetBreathSteam2, &Actor::EventSetBreathSteam }, + //==== {&EV_Actor_CalcGrenadeToss, &Actor::EventCalcGrenadeToss }, - {&EV_Actor_CalcGrenadeToss2, &Actor::EventCalcGrenadeToss }, + {&EV_Actor_CalcGrenadeToss2, &Actor::EventCalcGrenadeToss2 }, {&EV_Actor_GetNoSurprise, &Actor::EventGetNoSurprise }, {&EV_Actor_SetNoSurprise, &Actor::EventSetNoSurprise }, {&EV_Actor_SetNoSurprise2, &Actor::EventSetNoSurprise }, @@ -2630,6 +2655,12 @@ CLASS_DECLARATION(SimpleActor, Actor, "Actor") { {&EV_Actor_SetBalconyHeight, &Actor::EventSetBalconyHeight }, {&EV_Actor_SetBalconyHeight2, &Actor::EventSetBalconyHeight }, {&EV_Actor_GetBalconyHeight, &Actor::EventGetBalconyHeight }, + // Removed in 2.0 + //==== + //{&EV_CanSee, &Actor::CanSee }, + //==== + // Added in 2.0 + //==== {&EV_Actor_SetIgnoreBadPlace, &Actor::EventSetIgnoreBadPlace }, {&EV_Actor_SetIgnoreBadPlace2, &Actor::EventSetIgnoreBadPlace }, {&EV_Actor_GetIgnoreBadPlace, &Actor::EventGetIgnoreBadPlace }, @@ -2639,6 +2670,9 @@ CLASS_DECLARATION(SimpleActor, Actor, "Actor") { {&EV_Actor_SetRunAnimRate, &Actor::EventSetRunAnimRate }, {&EV_Actor_SetRunAnimRate2, &Actor::EventSetRunAnimRate }, {&EV_Actor_GetRunAnimRate, &Actor::EventGetRunAnimRate }, + //==== + // Added in 2.30 + //==== {&EV_Stop, &Actor::Landed }, {&EV_Actor_SetNationality, &Actor::SetNationality }, {&EV_Actor_SetNationality2, &Actor::SetNationality }, @@ -2646,6 +2680,7 @@ CLASS_DECLARATION(SimpleActor, Actor, "Actor") { {&EV_Actor_WriteStats, &Actor::EventWriteStats }, {&EV_Actor_CuriousOff, &Actor::EventCuriousOff }, {&EV_Actor_CuriousOn, &Actor::EventCuriousOn }, + //==== {NULL, NULL } }; @@ -2685,7 +2720,12 @@ const_str Actor::m_csThinkNames[NUM_THINKS] = { STRING_BALCONY_KILLED, STRING_WEAPONLESS, STRING_NOCLIP, - STRING_DEAD}; + STRING_DEAD, + // Added in 2.0 + STRING_BADPLACE, + // Added in 2.30 + STRING_RUNANDSHOOT +}; const_str Actor::m_csThinkStateNames[NUM_THINKSTATES] = { STRING_VOID, STRING_IDLE, @@ -2695,7 +2735,9 @@ const_str Actor::m_csThinkStateNames[NUM_THINKSTATES] = { STRING_CURIOUS, STRING_DISGUISE, STRING_GRENADE, - STRING_NOCLIP}; + STRING_BADPLACE, // Added in 2.0 + STRING_NOCLIP +}; SafePtr Actor::mBodyQueue[MAX_BODYQUEUE]; int Actor::mCurBody; @@ -2790,9 +2832,9 @@ Actor::Actor() m_fMinDistance = 128; m_fMinDistanceSquared = Square(m_fMinDistance); m_fMaxDistance = 1024; - m_fMaxDistanceSquared = Square(m_fMaxDistanceSquared); + m_fMaxDistanceSquared = Square(m_fMaxDistance); m_fLeash = 512; - m_fLeashSquared = Square(m_fLeashSquared); + m_fLeashSquared = Square(m_fLeash); m_iEyeUpdateTime = level.inttime; if (m_iEyeUpdateTime < 1000) { @@ -2848,7 +2890,7 @@ Actor::Actor() m_iNextDisguiseTime = 1; m_iDisguisePeriod = 30000; - m_fMaxDisguiseDistSquared = 256 * 256; + m_fMaxDisguiseDistSquared = Square(256); m_iDisguiseLevel = 1; m_patrolCurrentNode = NULL; @@ -2945,6 +2987,13 @@ Actor::Actor() } mVoiceType = -1; + + // + // Added in OPM + // The variable isn't set in original + // + m_bSilent = false; + m_bMumble = true; } /* @@ -2969,7 +3018,6 @@ Actor::~Actor() /* =============== Actor::setContentsSolid - =============== */ void Actor::setContentsSolid(void) @@ -2977,6 +3025,11 @@ void Actor::setContentsSolid(void) setContents(CONTENTS_NOBOTCLIP); } +/* +=============== +Actor::EndStates +=============== +*/ void Actor::EndStates(void) { for (int i = 0; i < NUM_THINKLEVELS; i++) { @@ -2984,6 +3037,11 @@ void Actor::EndStates(void) } } +/* +=============== +Actor::ClearStates +=============== +*/ void Actor::ClearStates(void) { for (int i = 0; i < NUM_THINKSTATES; i++) { @@ -2991,6 +3049,11 @@ void Actor::ClearStates(void) } } +/* +=============== +Actor::ResolveVoiceType +=============== +*/ void Actor::ResolveVoiceType(void) { char validVoice[128]; @@ -3063,6 +3126,11 @@ void Actor::EventStart(Event *ev) } } +/* +=============== +Actor::ClearEnemies +=============== +*/ void Actor::ClearEnemies(void) { m_PotentialEnemies.RemoveAll(); @@ -3145,7 +3213,7 @@ void Actor::GetMoveInfo(mmove_t *mm) m_Dest - Vector(0, 0, 16384), (Entity *)NULL, MASK_MOVEINFO, - qfalse, + false, "Actor::GetMoveInfo" ); @@ -3213,7 +3281,7 @@ void Actor::GetMoveInfo(mmove_t *mm) DoFailSafeMove(node->point); } - } else if (DotProduct(mm->velocity, velocity) < -0.7f && level.inttime >= m_Path.Time() + 1000) { + } else if (DotProduct2D(mm->velocity, velocity) < -0.7f && level.inttime >= m_Path.Time() + 1000) { m_Path.ReFindPath(origin, this); } break; @@ -3561,6 +3629,11 @@ void Actor::UpdateBoneControllers(void) SetControllerAngles(ARMS_TAG, new_angles); } +/* +=============== +Actor::setOriginEvent +=============== +*/ void Actor::setOriginEvent(Vector org) { float dist; @@ -3618,7 +3691,10 @@ void Actor::SafeSetOrigin(vec3_t newOrigin) if (!m_bNoPlayerCollision) { Player *p = (Player *)G_GetEntity(0); - if (p && IsTouching(p)) { + // Added in 2.30 + // Solidity check. + // If the Actor is already nonsolid the player won't get stuck + if (p && IsTouching(p) && getSolidType() != SOLID_NOT) { Com_Printf("(entnum %d, radnum %d) is going not solid to not get stuck in the player\n", entnum, radnum); m_bNoPlayerCollision = true; setSolidType(SOLID_NOT); @@ -3667,13 +3743,15 @@ void Actor::DoMove(void) MoveDest(frame_delta.length() / level.frametime); break; case ANIM_MODE_SCRIPTED: + setAngles(angles + Vector(0, angular_delta, 0)); trace = G_Trace( - origin, mins, maxs, origin + frame_delta, this, edict->clipmask & ~MASK_SCRIPT_SLAVE, qtrue, "Actor" + origin, mins, maxs, origin + frame_delta, this, edict->clipmask & ~MASK_SCRIPT_SLAVE, true, "Actor" ); SafeSetOrigin(trace.endpos); velocity = frame_delta / level.frametime; break; case ANIM_MODE_NOCLIP: + setAngles(angles + Vector(0, angular_delta, 0)); SafeSetOrigin(origin + frame_delta); velocity = frame_delta / level.frametime; break; @@ -3879,6 +3957,8 @@ bool Actor::CanShoot(Entity *ent) Vector vGunPos; if (FriendlyInLineOfFire(ent)) { + // Added in 2.0 + // Check if a friend is in sight bCanShoot = false; } else if (ent->IsSubclassOfSentient()) { Sentient *sen = static_cast(ent); @@ -3895,7 +3975,7 @@ bool Actor::CanShoot(Entity *ent) this, sen, MASK_CANSEE, - qfalse, + false, "Actor::CanShoot centroid" )) { bCanShoot = true; @@ -3907,7 +3987,7 @@ bool Actor::CanShoot(Entity *ent) this, sen, MASK_CANSEE, - qfalse, + false, "Actor::CanShoot eyes" )) { bCanShoot = true; @@ -3948,7 +4028,7 @@ bool Actor::CanSeeFrom(vec3_t pos, Entity *ent) return false; } - return G_SightTrace(pos, vec_zero, vec_zero, ent->centroid, this, ent, MASK_CANSEE, qfalse, "Actor::CanSeeFrom"); + return G_SightTrace(pos, vec_zero, vec_zero, ent->centroid, this, ent, MASK_CANSEE, false, "Actor::CanSeeFrom"); } /* @@ -4003,11 +4083,20 @@ bool Actor::CanShootEnemy(int iMaxDirtyTime) return m_bCanShootEnemy; } +/* +=============== +Actor::FriendlyInLineOfFire +=============== +*/ bool Actor::FriendlyInLineOfFire(Entity *other) { Vector delta; float inverseDot; + if (g_target_game <= target_game_e::TG_MOH) { + return false; + } + delta = other->origin - origin; inverseDot = 1.0 / (delta * delta); @@ -4021,7 +4110,7 @@ bool Actor::FriendlyInLineOfFire(Entity *other) Vector org; org = squadDot * inverseDot * delta - squadDelta; - if (org * org >= 4096) { + if (org * org >= Square(64)) { return true; } } @@ -4030,6 +4119,11 @@ bool Actor::FriendlyInLineOfFire(Entity *other) return false; } +/* +=============== +Actor::VirtualEyePosition +=============== +*/ Vector Actor::VirtualEyePosition() { if (m_pTurret && CurrentThink() == THINK_MACHINEGUNNER) { @@ -4075,7 +4169,7 @@ void Actor::ShowInfo(void) { Com_Printf("-------------------------------------------------------------------------------\n"); Com_Printf("Info for Actor:\n"); - Com_Printf("Current think type: %s %s\n", ThinkName().c_str(), ThinkStateName().c_str()); + Com_Printf("Current think type: %s %s\n", ThinkStateName().c_str(), ThinkName().c_str()); Com_Printf("leash: %f\n", m_fLeash); Com_Printf("mindist: %f\n", m_fMinDistance); Com_Printf("maxdist: %f\n", m_fMaxDistance); @@ -4207,22 +4301,32 @@ void Actor::ShowInfo(float fDot, float fDist) G_DebugLine(centroid, a, 0.0, 1.0, 0.0, 1.0); - G_DebugCircle(a, m_fLeash, 0.0, 1.0, 0.0, 1.0, qtrue); + G_DebugCircle(a, m_fLeash, 0.0, 1.0, 0.0, 1.0, true); - G_DebugCircle(centroid, m_fMinDistance, 1.0, 0.0, 0.0, 1.0, qtrue); + G_DebugCircle(centroid, m_fMinDistance, 1.0, 0.0, 0.0, 1.0, true); - G_DebugCircle(centroid, m_fMaxDistance, 0.0, 0.0, 1.0, 1.0, qtrue); + G_DebugCircle(centroid, m_fMaxDistance, 0.0, 0.0, 1.0, 1.0, true); } else if (g_entinfo->integer == 2) { - G_DebugCircle(centroid, m_fHearing, 1.0, 0.0, 0.0, 1.0, qtrue); - G_DebugCircle(centroid, m_fSight, 0.0, 0.0, 1.0, 1.0, qtrue); + G_DebugCircle(centroid, m_fHearing, 1.0, 0.0, 0.0, 1.0, true); + G_DebugCircle(centroid, m_fSight, 0.0, 0.0, 1.0, 1.0, true); } } +/* +=============== +Actor::ThinkName +=============== +*/ str Actor::ThinkName(void) const { return Director.GetString(m_csThinkNames[CurrentThink()]); } +/* +=============== +Actor::ThinkStateName +=============== +*/ str Actor::ThinkStateName(void) const { return Director.GetString(m_csThinkStateNames[m_ThinkState]); @@ -4954,7 +5058,7 @@ void Actor::HandlePain(Event *ev) //FIXME: macro SetCuriousAnimHint(7); - // m_bIsCurious check: Added in 2.30 + // Added in 2.30 the m_bIsCurous check if (m_bEnableEnemy && m_ThinkStates[THINKLEVEL_IDLE] == THINKSTATE_IDLE && m_bIsCurious) { SetEnemyPos(attacker->origin); m_pszDebugState = "from_pain"; @@ -5291,7 +5395,8 @@ void Actor::MovePath(float fMoveSpeed) if (m_WallDir) { if (level.inttime >= m_iWallDodgeTimeout) { m_WallDir = 0; - } else if (DotProduct2D(mm.desired_dir, m_PrevObstacleNormal) > 0 && CrossProduct2D(mm.desired_dir, m_PrevObstacleNormal) < 0) { + } else if (DotProduct2D(mm.desired_dir, m_PrevObstacleNormal) > 0 + && CrossProduct2D(mm.desired_dir, m_PrevObstacleNormal) < 0) { m_iWallDodgeTimeout = level.inttime + 1000; m_WallDir = -m_WallDir; } @@ -5339,7 +5444,7 @@ void Actor::MovePath(float fMoveSpeed) VectorCopy(m_groundPlaneNormal, mm.groundPlaneNormal); VectorCopy2D(mm.obstacle_normal, m_PrevObstacleNormal); - if (m_WallDir == -1) { + if (m_WallDir == (char)-1) { mm.desired_dir[0] = -mm.obstacle_normal[1]; mm.desired_dir[1] = mm.obstacle_normal[0]; } else { @@ -5400,8 +5505,6 @@ void Actor::MovePath(float fMoveSpeed) } else { m_iWallDodgeTimeout = level.inttime + 1000; } - - GetMoveInfo(&mm); } else { if (m_WallDir >= 0) { mm.desired_dir[0] = mm.obstacle_normal[1]; @@ -5418,6 +5521,8 @@ void Actor::MovePath(float fMoveSpeed) m_iWallDodgeTimeout = 0; } } + + GetMoveInfo(&mm); } } @@ -5458,7 +5563,7 @@ void Actor::MovePathGoal(float fMoveSpeed) m_eAnimMode = ANIM_MODE_NORMAL; } } - } else if (fDeltaSquareLen < Square(fMoveSpeed * 0.5f)) { + } else if (fDeltaSquareLen < Square(fMoveSpeed * 0.5 * 0.5)) { fTimeToGo = 0.5f; m_fPathGoalTime = level.time + fTimeToGo; if (m_csPathGoalEndAnimScript == STRING_EMPTY) { @@ -5543,13 +5648,20 @@ void Actor::EventSetMood(Event *ev) =============== Actor::EventDamagePuff -Spawns a puff of 'blood' smoke at the speficied location in the specified direction. +Spawns a puff of 'blood' smoke at the specified location in the specified direction. =============== */ void Actor::EventDamagePuff(Event *ev) { Vector pos = ev->GetVector(1); Vector dir = ev->GetVector(2); + int bulletbits; + + // Fixed in OPM + // Large bullet flag normally take 2 bits since 2.0. + // However, in OG Spearhead and Breakthrough, EventDamagePuff + // mistakenly uses 1 bit which causes a parse message error + bulletbits = (g_protocol >= protocol_e::PROTOCOL_MOHTA_MIN) ? 2 : 1; gi.SetBroadcastVisible(pos, NULL); @@ -5559,7 +5671,7 @@ void Actor::EventDamagePuff(Event *ev) gi.MSG_WriteCoord(pos.z); gi.MSG_WriteDir(dir); - gi.MSG_WriteBits(0, 1); + gi.MSG_WriteBits(0, bulletbits); gi.MSG_EndCGM(); } @@ -5946,7 +6058,7 @@ bool Actor::MoveOnPathWithSquad(void) } if (DotProduct2D(pvMyDir, pvHisDir) >= 0 - && (entnum == pActorSquadMate->entnum || DotProduct2D(pvHisDir, vDelta) >= 0)) { + && (entnum >= pActorSquadMate->entnum || DotProduct2D(pvHisDir, vDelta) >= 0)) { m_iSquadStandTime = level.inttime; return false; } @@ -6103,7 +6215,7 @@ bool Actor::MoveToPatrolCurrentNode(void) IdleLook(); Anim_Idle(); // tell scripts the move has failed - parm.movefail = qtrue; + parm.movefail = true; return false; } @@ -6165,6 +6277,11 @@ void Actor::EventGetAccuracy(Event *ev) ev->AddFloat(mAccuracy * 100.f); } +/* +=============== +Actor::EventSetMinDistance +=============== +*/ void Actor::EventSetMinDistance(Event *ev) { m_fMinDistance = ev->GetFloat(1); @@ -6182,11 +6299,21 @@ void Actor::EventSetMinDistance(Event *ev) m_fMinDistanceSquared = Square(m_fMinDistance); } +/* +=============== +Actor::EventGetMinDistance +=============== +*/ void Actor::EventGetMinDistance(Event *ev) { ev->AddFloat(m_fMinDistance); } +/* +=============== +Actor::EventSetMaxDistance +=============== +*/ void Actor::EventSetMaxDistance(Event *ev) { m_fMaxDistance = ev->GetFloat(1); @@ -6205,32 +6332,62 @@ void Actor::EventSetMaxDistance(Event *ev) m_fMaxDistanceSquared = Square(m_fMaxDistance); } +/* +=============== +Actor::EventGetMaxDistance +=============== +*/ void Actor::EventGetMaxDistance(Event *ev) { ev->AddFloat(m_fMaxDistance); } +/* +=============== +Actor::EventGetLeash +=============== +*/ void Actor::EventGetLeash(Event *ev) { ev->AddFloat(m_fLeash); } +/* +=============== +Actor::EventSetLeash +=============== +*/ void Actor::EventSetLeash(Event *ev) { m_fLeash = ev->GetFloat(1); m_fLeashSquared = Square(m_fLeash); } +/* +=============== +Actor::EventGetInterval +=============== +*/ void Actor::EventGetInterval(Event *ev) { ev->AddFloat(m_fInterval); } +/* +=============== +Actor::EventSetInterval +=============== +*/ void Actor::EventSetInterval(Event *ev) { m_fInterval = ev->GetFloat(1); } +/* +=============== +Actor::EventDistToEnemy +=============== +*/ void Actor::EventDistToEnemy(Event *ev) { if (!m_Enemy) { @@ -6304,7 +6461,9 @@ void Actor::Init(void) InitWeaponless(&GlobalFuncs[THINK_WEAPONLESS]); InitNoClip(&GlobalFuncs[THINK_NOCLIP]); InitDead(&GlobalFuncs[THINK_DEAD]); + // Added in 2.0 InitBadPlace(&GlobalFuncs[THINK_BADPLACE]); + // Added in 2.30 InitRunAndShoot(&GlobalFuncs[THINK_RUN_AND_SHOOT]); AddWaitTill(STRING_VISIBLE); @@ -6392,7 +6551,7 @@ void Actor::UpdateEnemyInternal(void) m_PotentialEnemies.CheckEnemies(this); - if (m_Enemy != m_PotentialEnemies.GetCurrentEnemy() && (m_bEnemySwitch || m_Enemy)) { + if (m_Enemy != m_PotentialEnemies.GetCurrentEnemy() && (m_bEnemySwitch || !m_Enemy)) { SetEnemy(m_PotentialEnemies.GetCurrentEnemy(), false); } @@ -6446,15 +6605,7 @@ void Actor::DetectSmokeGrenades(void) if (fDistSquared > Square(256) || InFOV(sprite->origin)) { if (G_SightTrace( - eyePos, - vec_zero, - vec_zero, - sprite->origin, - this, - NULL, - MASK_CANSEE, - qfalse, - "Actor::DetectSmokeGrenades" + eyePos, vec_zero, vec_zero, sprite->origin, this, NULL, MASK_CANSEE, false, "Actor::DetectSmokeGrenades" )) { m_PotentialEnemies.ConfirmEnemy(this, sprite->owner); } @@ -6546,12 +6697,12 @@ void Actor::EventSetAnim(Event *ev) int slot = 0; int anim; const_str flagVal; - qboolean flagged = qfalse; + qboolean flagged = false; switch (ev->NumArgs()) { case 4: flagVal = ev->GetConstString(4); - flagged = qtrue; + flagged = true; if (flagVal != STRING_FLAGGED) { ScriptError("unknown keyword '%s', expected 'flagged'", Director.GetString(flagVal).c_str()); } @@ -6582,11 +6733,11 @@ void Actor::EventSetAnim(Event *ev) } if (!slot) { - flagged = qtrue; + flagged = true; } if (flagged) { - parm.motionfail = qtrue; + parm.motionfail = true; } if (!m_bLevelMotionAnim) { @@ -6600,7 +6751,7 @@ void Actor::EventSetAnim(Event *ev) StartMotionAnimSlot(slot, anim, weight); if (flagged) { m_iMotionSlot = GetMotionSlot(slot); - parm.motionfail = qfalse; + parm.motionfail = false; } } } @@ -6614,10 +6765,10 @@ End action animation. */ void Actor::EventEndActionAnim(Event *ev) { - parm.upperfail = qtrue; + parm.upperfail = true; if (!m_bLevelActionAnim) { ChangeActionAnim(); - parm.upperfail = qfalse; + parm.upperfail = false; } } @@ -6644,7 +6795,7 @@ void Actor::EventSetMotionAnim(Event *ev) UnknownAnim(Director.GetString(name), edict->tiki); } - parm.motionfail = qtrue; + parm.motionfail = true; if (!m_bLevelMotionAnim) { ChangeMotionAnim(); @@ -6655,7 +6806,7 @@ void Actor::EventSetMotionAnim(Event *ev) // set the slot m_iMotionSlot = GetMotionSlot(0); - parm.motionfail = qfalse; + parm.motionfail = false; } } @@ -6693,7 +6844,7 @@ void Actor::EventSetAimMotionAnim(Event *ev) UnknownAnim(Director.GetString(name), edict->tiki); } - parm.motionfail = qtrue; + parm.motionfail = true; if (!m_bLevelMotionAnim) { ChangeMotionAnim(); @@ -6706,7 +6857,7 @@ void Actor::EventSetAimMotionAnim(Event *ev) StartAimMotionAnimSlot(2, anim_high); m_iMotionSlot = GetMotionSlot(1); - parm.motionfail = qfalse; + parm.motionfail = false; } } @@ -6757,7 +6908,7 @@ void Actor::EventSetActionAnim(Event *ev) UnknownAnim(derivedName, edict->tiki); } - parm.upperfail = qtrue; + parm.upperfail = true; if (!m_bLevelActionAnim) { ChangeActionAnim(); m_bAimAnimSet = true; @@ -6768,7 +6919,7 @@ void Actor::EventSetActionAnim(Event *ev) StartAimAnimSlot(1, anim_forward); StartAimAnimSlot(2, anim_down); m_iActionSlot = GetActionSlot(0); - parm.upperfail = qfalse; + parm.upperfail = false; } } @@ -6823,13 +6974,16 @@ void Actor::EventSetUpperAnim(Event *ev) UnknownAnim(Director.GetString(name), edict->tiki); } - parm.upperfail = qtrue; + parm.upperfail = true; + if (!m_bLevelActionAnim) { ChangeActionAnim(); m_bActionAnimSet = true; + StartActionAnimSlot(anim); - m_iActionSlot = SimpleActor::GetActionSlot(0); - parm.upperfail = qfalse; + m_iActionSlot = GetActionSlot(0); + + parm.upperfail = false; } } @@ -6857,7 +7011,7 @@ bool Actor::SoundSayAnim(const_str name, byte bLevelSayAnim) edict->tiki->a->name ); - Sound(Director.GetString(name), 0, 0, 0, NULL, 0, 1, 1, -1); + Sound(Director.GetString(name), CHAN_AUTO, 0, 0, NULL, 0, 0, 1, 1, -1); return true; } @@ -6941,7 +7095,7 @@ void Actor::EventSetSayAnim(Event *ev) } name = ev->GetConstString(1); - parm.sayfail = qtrue; + parm.sayfail = true; anim = gi.Anim_NumForName(edict->tiki, Director.GetString(name)); if (anim == -1) { @@ -6997,7 +7151,7 @@ void Actor::EventSetSayAnim(Event *ev) m_iSaySlot = GetSaySlot(); } - parm.sayfail = qfalse; + parm.sayfail = false; } /* @@ -7163,6 +7317,8 @@ void Actor::UpdateUpperAnim(void) if (!m_bActionAnimSet) { Unregister(STRING_UPPERANIMDONE); } + + return; } gi.Anim_FlagsSkel(edict->tiki, anim); @@ -7346,6 +7502,16 @@ void Actor::Think(void) Director.Unpause(); } +/* +=============== +Actor::CheckUnregister + +Notify scripts when the actor has: +- Finished moving +- Has a new enemy +- And/or if the enemy is visible +=============== +*/ void Actor::CheckUnregister(void) { m_bBecomeRunner = false; @@ -7539,10 +7705,7 @@ void Actor::SetThinkState(eThinkState state, eThinkLevel level) m_csIdleMood = STRING_NERVOUS; map = m_ThinkMap[THINKSTATE_ATTACK]; - if (map != THINK_ALARM - && map != THINK_WEAPONLESS - && map != THINK_DOG_ATTACK - && !GetWeapon(WEAPON_MAIN)) { + if (map != THINK_ALARM && map != THINK_WEAPONLESS && map != THINK_DOG_ATTACK && !GetWeapon(WEAPON_MAIN)) { Com_Printf( "^~^~^ LD ERROR: (entnum %i, radnum %i, targetname '%s'): forcing weaponless attack state.\n" "^~^~^ Level designers should specify 'type_attack weaponless' for this guy.\n", @@ -7588,6 +7751,11 @@ void Actor::ClearThinkStates(void) } } +/* +=============== +Actor::EventSetAlarmNode +=============== +*/ void Actor::EventSetAlarmNode(Event *ev) { Listener *l = ev->GetListener(1); @@ -7598,11 +7766,21 @@ void Actor::EventSetAlarmNode(Event *ev) m_AlarmNode = static_cast(l); } +/* +=============== +Actor::EventGetAlarmNode +=============== +*/ void Actor::EventGetAlarmNode(Event *ev) { ev->AddListener(m_AlarmNode); } +/* +=============== +Actor::EventSetPreAlarmThread +=============== +*/ void Actor::EventSetPreAlarmThread(Event *ev) { if (ev->IsFromScript()) { @@ -7612,6 +7790,11 @@ void Actor::EventSetPreAlarmThread(Event *ev) } } +/* +=============== +Actor::EventSetAlarmThread +=============== +*/ void Actor::EventSetAlarmThread(Event *ev) { if (ev->IsFromScript()) { @@ -7621,31 +7804,61 @@ void Actor::EventSetAlarmThread(Event *ev) } } +/* +=============== +Actor::EventGetAlarmThread +=============== +*/ void Actor::EventGetAlarmThread(Event *ev) { m_AlarmThread.GetScriptValue(&ev->GetValue()); } +/* +=============== +Actor::EventSetSoundAwareness +=============== +*/ void Actor::EventSetSoundAwareness(Event *ev) { m_fSoundAwareness = ev->GetFloat(1); } +/* +=============== +Actor::EventGetSoundAwareness +=============== +*/ void Actor::EventGetSoundAwareness(Event *ev) { ev->AddFloat(m_fSoundAwareness); } +/* +=============== +Actor::EventSetGrenadeAwareness +=============== +*/ void Actor::EventSetGrenadeAwareness(Event *ev) { m_fGrenadeAwareness = ev->GetFloat(1); } +/* +=============== +Actor::EventGetGrenadeAwareness +=============== +*/ void Actor::EventGetGrenadeAwareness(Event *ev) { ev->AddFloat(m_fGrenadeAwareness); } +/* +=============== +Actor::EventSetTypeIdle +=============== +*/ void Actor::EventSetTypeIdle(Event *ev) { bool (*AllowedState)(int state); @@ -7662,11 +7875,21 @@ void Actor::EventSetTypeIdle(Event *ev) SetThinkIdle(think); } +/* +=============== +Actor::EventGetTypeIdle +=============== +*/ void Actor::EventGetTypeIdle(Event *ev) { ev->AddConstString(m_csThinkNames[m_ThinkMap[THINKSTATE_IDLE]]); } +/* +=============== +Actor::EventSetTypeAttack +=============== +*/ void Actor::EventSetTypeAttack(Event *ev) { bool (*AllowedState)(int state); @@ -7683,11 +7906,21 @@ void Actor::EventSetTypeAttack(Event *ev) SetThink(THINKSTATE_ATTACK, think); } +/* +=============== +Actor::EventGetTypeAttack +=============== +*/ void Actor::EventGetTypeAttack(Event *ev) { ev->AddConstString(m_csThinkNames[m_ThinkMap[THINKSTATE_ATTACK]]); } +/* +=============== +Actor::EventSetTypeDisguise +=============== +*/ void Actor::EventSetTypeDisguise(Event *ev) { bool (*AllowedState)(int state); @@ -7704,6 +7937,11 @@ void Actor::EventSetTypeDisguise(Event *ev) SetThink(THINKSTATE_DISGUISE, think); } +/* +=============== +Actor::EventSetDisguiseAcceptThread +=============== +*/ void Actor::EventSetDisguiseAcceptThread(Event *ev) { if (ev->IsFromScript()) { @@ -7713,16 +7951,31 @@ void Actor::EventSetDisguiseAcceptThread(Event *ev) } } +/* +=============== +Actor::EventGetDisguiseAcceptThread +=============== +*/ void Actor::EventGetDisguiseAcceptThread(Event *ev) { m_DisguiseAcceptThread.GetScriptValue(&ev->GetValue()); } +/* +=============== +Actor::EventGetTypeDisguise +=============== +*/ void Actor::EventGetTypeDisguise(Event *ev) { ev->AddConstString(m_csThinkNames[m_ThinkMap[THINKSTATE_DISGUISE]]); } +/* +=============== +Actor::EventSetDisguiseLevel +=============== +*/ void Actor::EventSetDisguiseLevel(Event *ev) { m_iDisguiseLevel = ev->GetInteger(1); @@ -7733,11 +7986,21 @@ void Actor::EventSetDisguiseLevel(Event *ev) } } +/* +=============== +Actor::EventGetDisguiseLevel +=============== +*/ void Actor::EventGetDisguiseLevel(Event *ev) { ev->AddInteger(m_iDisguiseLevel); } +/* +=============== +Actor::EventSetTypeGrenade +=============== +*/ void Actor::EventSetTypeGrenade(Event *ev) { bool (*AllowedState)(int state); @@ -7754,6 +8017,11 @@ void Actor::EventSetTypeGrenade(Event *ev) SetThink(THINKSTATE_GRENADE, think); } +/* +=============== +Actor::EventGetTypeGrenade +=============== +*/ void Actor::EventGetTypeGrenade(Event *ev) { ev->AddConstString(m_csThinkNames[m_ThinkMap[THINKSTATE_GRENADE]]); @@ -7870,8 +8138,8 @@ void Actor::EndState(int level) { GlobalFuncs_t *think; - think = &GlobalFuncs[m_Think[level]]; - m_Think[level] = THINK_VOID; + think = &GlobalFuncs[m_Think[level]]; + m_Think[level] = THINK_VOID; if (think->EndState) { (this->*think->EndState)(); @@ -7999,8 +8267,8 @@ void Actor::FixAIParameters(void) if (m_pTetherEnt) { fMinLeash = 64; if (m_pTetherEnt->IsSubclassOfEntity()) { - fMinLeash = - m_pTetherEnt->angles.y - m_pTetherEnt->origin.y + m_pTetherEnt->angles.z + m_pTetherEnt->origin.z; + Entity *pEnt = static_cast(m_pTetherEnt.Pointer()); + fMinLeash = pEnt->maxs[0] - pEnt->mins[1] + pEnt->maxs[1] - pEnt->mins[1]; } if (m_fLeash < fMinLeash) { @@ -8122,7 +8390,7 @@ bool Actor::AttackEntryAnimation(void) m_bNewEnemy = true; return true; } - } else if (fDistSquared > Square(1024)) { + } else if (fDistSquared > Square(1024) && (rand() % 4) == 0) { Sentient *pSquadMate; for (pSquadMate = m_pNextSquadMate; pSquadMate != this; pSquadMate = pSquadMate->m_pNextSquadMate) { @@ -8332,7 +8600,7 @@ bool Actor::PassesTransitionConditions_Disguise(void) this, player, MASK_TRANSITION, - qfalse, + false, "Actor::PassesTransitionConditions_Disguise" ); } @@ -8389,11 +8657,21 @@ bool Actor::PassesTransitionConditions_Idle(void) return false; } +/* +=============== +Actor::EventGetRunAnim +=============== +*/ void Actor::EventGetRunAnim(Event *ev) { ev->AddConstString(GetRunAnim()); } +/* +=============== +Actor::EventGetWalkAnim +=============== +*/ void Actor::EventGetWalkAnim(Event *ev) { ev->AddConstString(GetWalkAnim()); @@ -8424,7 +8702,7 @@ void Actor::FaceEnemyOrMotion(int iTimeIntoMove) { vec2_t vDelta; - VectorCopy2D(origin, vDelta); + VectorSub2D(origin, m_vLastEnemyPos, vDelta); if (iTimeIntoMove <= 999) { m_bFaceEnemy = true; @@ -8447,11 +8725,14 @@ void Actor::FaceEnemyOrMotion(int iTimeIntoMove) return; } - if (vDelta[0] >= 15 || vDelta[0] <= -15 || vDelta[1] >= 15 || vDelta[1] <= -15) { - vDelta[0] = -vDelta[0]; - vDelta[1] = -vDelta[1]; - FaceDirectionDuringMotion(vDelta); + if (vDelta[0] < 15 && vDelta[0] > -15 && vDelta[1] < 15 && vDelta[1] > -15) { + FaceMotion(); + return; } + + vDelta[0] = -vDelta[0]; + vDelta[1] = -vDelta[1]; + FaceDirectionDuringMotion(vDelta); } /* @@ -8499,32 +8780,62 @@ void Actor::FaceDirectionDuringMotion(vec3_t vLook) SetDesiredYaw(yaw); } +/* +=============== +Actor::EventGetAnimName +=============== +*/ void Actor::EventGetAnimName(Event *ev) { ev->AddConstString(m_csAnimName); } +/* +=============== +Actor::EventSetAnimName +=============== +*/ void Actor::EventSetAnimName(Event *ev) { m_csAnimName = ev->GetConstString(1); } +/* +=============== +Actor::EventSetDisguiseRange +=============== +*/ void Actor::EventSetDisguiseRange(Event *ev) { m_fMaxDisguiseDistSquared = ev->GetFloat(1); m_fMaxDisguiseDistSquared = Square(m_fMaxDisguiseDistSquared); } +/* +=============== +Actor::EventGetDisguiseRange +=============== +*/ void Actor::EventGetDisguiseRange(Event *ev) { ev->AddFloat(sqrt(m_fMaxDisguiseDistSquared)); } +/* +=============== +Actor::EventSetDisguisePeriod +=============== +*/ void Actor::EventSetDisguisePeriod(Event *ev) { m_iDisguisePeriod = ev->GetFloat(1) * 1000 + 0.5; } +/* +=============== +Actor::EventGetDisguisePeriod +=============== +*/ void Actor::EventGetDisguisePeriod(Event *ev) { ev->AddFloat(m_iDisguisePeriod / 1000.0); @@ -8546,10 +8857,12 @@ void Actor::FaceMotion(void) VectorCopy2D(velocity, dir); VectorSub2D(origin, m_vOriginHistory[m_iCurrentHistory], vDelta); - if (VectorLength2DSquared(vDelta) >= 1 && DotProduct2D(velocity, vDelta) > 0) { + if (VectorLength2DSquared(vDelta) >= 1 && DotProduct2D(vDelta, dir) > 0) { VectorCopy2D(vDelta, dir); } + dir[2] = 0; + if (m_ThinkState == THINKSTATE_IDLE) { IdleLook(dir); } else { @@ -8564,12 +8877,22 @@ void Actor::FaceMotion(void) } } +/* +=============== +Actor::ForceAttackPlayer +=============== +*/ void Actor::ForceAttackPlayer(void) { m_PotentialEnemies.ConfirmEnemy(this, static_cast(G_GetEntity(0))); m_bForceAttackPlayer = true; } +/* +=============== +Actor::EventAttackPlayer +=============== +*/ void Actor::EventAttackPlayer(Event *ev) { if (!G_GetEntity(0)) { @@ -8831,7 +9154,7 @@ void Actor::CuriousSound(int iType, vec3_t sound_origin, float fDistSquared, flo } } - if ((fRangeFactor * m_fSoundAwareness) < (rand() / 21474836.0)) { + if ((fRangeFactor * m_fSoundAwareness) < random()) { return; } @@ -8911,15 +9234,14 @@ void Actor::WeaponSound(int iType, vec3_t sound_origin, float fDistSquared, floa pEnemy = pOwner->m_Enemy; } - if (pOwner->m_Team == m_Team && !pEnemy && pOwner->IsSubclassOfActor() - && originator->IsSubclassOfWeapon()) { + if (pOwner->m_Team == m_Team && !pEnemy && pOwner->IsSubclassOfActor() && originator->IsSubclassOfWeapon()) { Actor *pActor = static_cast(pOwner); Weapon *pWeapon = static_cast(originator); if (pActor->m_Think[THINKLEVEL_IDLE] == THINK_MACHINEGUNNER && pWeapon->aim_target) { if (pWeapon->aim_target->IsSubclassOfSentient()) { Sentient *pTarget = static_cast(pWeapon->aim_target.Pointer()); - if (pTarget->m_Team = m_Team) { + if (pTarget->m_Team == m_Team) { pEnemy = pTarget; } } else if (!m_Team) { @@ -9135,7 +9457,7 @@ void Actor::NotifySquadmateKilled(Sentient *pSquadMate, Sentient *pAttacker) this, pSquadMate, MASK_AI_CANSEE, - qfalse, + false, "Actor::NotifySquadmateKilled" ); } @@ -9318,7 +9640,7 @@ bool Actor::ValidGrenadePath(const Vector& vFrom, const Vector& vTo, Vector& vVe G_DebugLine(vFrom, vPoint1, 1.0, 0.5, 0.5, 1.0); } - if (!G_SightTrace(vFrom, mins, maxs, vPoint1, this, NULL, MASK_GRENADEPATH, qfalse, "Actor::ValidGrenadePath 1")) { + if (!G_SightTrace(vFrom, mins, maxs, vPoint1, this, NULL, MASK_GRENADEPATH, false, "Actor::ValidGrenadePath 1")) { return false; } @@ -9331,9 +9653,7 @@ bool Actor::ValidGrenadePath(const Vector& vFrom, const Vector& vTo, Vector& vVe G_DebugLine(vPoint1, vPoint2, 1.0, 0.5, 0.5, 1.0); } - if (!G_SightTrace( - vPoint1, mins, maxs, vPoint2, this, NULL, MASK_GRENADEPATH, qfalse, "Actor::ValidGrenadePath 2" - )) { + if (!G_SightTrace(vPoint1, mins, maxs, vPoint2, this, NULL, MASK_GRENADEPATH, false, "Actor::ValidGrenadePath 2")) { return false; } @@ -9353,16 +9673,14 @@ bool Actor::ValidGrenadePath(const Vector& vFrom, const Vector& vTo, Vector& vVe if (ai_debug_grenades->integer) { G_DebugLine(vPoint2, vPoint3, 1.0, 0.5, 0.5, 1.0); } - if (!G_SightTrace( - vPoint2, mins, maxs, vPoint3, this, NULL, MASK_GRENADEPATH, qfalse, "Actor::ValidGrenadePath 3" - )) { + if (!G_SightTrace(vPoint2, mins, maxs, vPoint3, this, NULL, MASK_GRENADEPATH, false, "Actor::ValidGrenadePath 3")) { return false; } if (ai_debug_grenades->integer) { G_DebugLine(vPoint3, vTo, 1.0, 0.5, 0.5, 1.0); } - trace = G_Trace(vPoint3, mins, maxs, vTo, this, MASK_GRENADEPATH, qfalse, "Actor::ValidGrenadePath 4"); + trace = G_Trace(vPoint3, mins, maxs, vTo, this, MASK_GRENADEPATH, false, "Actor::ValidGrenadePath 4"); if (!trace.allsolid) { if (!trace.ent) { return true; @@ -9395,7 +9713,7 @@ Vector Actor::CalcThrowVelocity(const Vector& vFrom, const Vector& vTo) vDelta = vTo - vFrom; fHorzDistSquared = vDelta.lengthXYSquared(); - fDistance = sqrt(fHorzDistSquared + vDelta.z * vDelta.z); + fDistance = sqrt(fHorzDistSquared + Square(vDelta.z)); // original irl equation: v10 = sqrt(fGravity * 0.5 * fHorzDistSquared / (fDistance * trigMult )) // trigMult = (cos(th)/ tan(al) - sin(th)/tanSquared(al)) @@ -9823,7 +10141,7 @@ void Actor::GenericGrenadeTossThink(void) eGrenadeTossMode eGrenadeMode; if (m_Enemy && level.inttime >= m_iStateTime + 200) { - if (CanGetGrenadeFromAToB(origin, m_Enemy->velocity - m_Enemy->origin, false, &vGrenadeVel, &eGrenadeMode)) { + if (CanGetGrenadeFromAToB(origin, m_Enemy->origin + m_Enemy->velocity, false, &vGrenadeVel, &eGrenadeMode)) { m_vGrenadeVel = vGrenadeVel; m_eGrenadeMode = eGrenadeMode; } @@ -9900,6 +10218,11 @@ void Actor::Grenade_EventFire(Event *ev) UseAmmo("grenade", 1); } +/* +=============== +Actor::EventSetTurret +=============== +*/ void Actor::EventSetTurret(Event *ev) { Listener *l = ev->GetListener(1); @@ -9908,26 +10231,51 @@ void Actor::EventSetTurret(Event *ev) } } +/* +=============== +Actor::EventGetTurret +=============== +*/ void Actor::EventGetTurret(Event *ev) { ev->AddListener(m_pTurret); } +/* +=============== +Actor::EventGetAmmoGrenade +=============== +*/ void Actor::EventGetAmmoGrenade(Event *ev) { ev->AddInteger(AmmoCount("grenade")); } +/* +=============== +Actor::EventSetAmmoGrenade +=============== +*/ void Actor::EventSetAmmoGrenade(Event *ev) { GiveAmmo("grenade", ev->GetInteger(1)); } +/* +=============== +Actor::EventEnableEnemy +=============== +*/ void Actor::EventEnableEnemy(Event *ev) { m_bDesiredEnableEnemy = ev->GetBoolean(1); } +/* +=============== +Actor::EventEnablePain +=============== +*/ void Actor::EventEnablePain(Event *ev) { m_bEnablePain = ev->GetBoolean(1); @@ -9936,12 +10284,22 @@ void Actor::EventEnablePain(Event *ev) } } +/* +=============== +Actor::EventActivate +=============== +*/ void Actor::EventActivate(Event *ev) { m_bPatrolWaitTrigger = false; Unregister(STRING_TRIGGER); } +/* +=============== +Actor::EventInterruptPoint +=============== +*/ void Actor::EventInterruptPoint(Event *ev) { GlobalFuncs_t *interrupt = &GlobalFuncs[m_Think[m_ThinkLevel]]; @@ -9951,11 +10309,21 @@ void Actor::EventInterruptPoint(Event *ev) } } +/* +=============== +Actor::EventGetVisibilityThreshold +=============== +*/ void Actor::EventGetVisibilityThreshold(Event *ev) { ev->AddFloat(m_fVisibilityThreshold); } +/* +=============== +Actor::EventSetVisibilityThreshold +=============== +*/ void Actor::EventSetVisibilityThreshold(Event *ev) { float threshold; @@ -9970,6 +10338,11 @@ void Actor::EventSetVisibilityThreshold(Event *ev) m_fVisibilityThreshold = threshold; } +/* +=============== +Actor::EventSetDefaultVisibilityThreshold +=============== +*/ void Actor::EventSetDefaultVisibilityThreshold(Event *ev) { float threshold; @@ -9985,11 +10358,21 @@ void Actor::EventSetDefaultVisibilityThreshold(Event *ev) } } +/* +=============== +Actor::EventGetSuppressChance +=============== +*/ void Actor::EventGetSuppressChance(Event *ev) { ev->AddInteger(m_iSuppressChance); } +/* +=============== +Actor::EventSetSuppressChance +=============== +*/ void Actor::EventSetSuppressChance(Event *ev) { m_iSuppressChance = ev->GetInteger(1); @@ -10018,6 +10401,11 @@ void Actor::EventSetSuppressChance(Event *ev) } } +/* +=============== +Actor::EventAnimScript +=============== +*/ void Actor::EventAnimScript(Event *ev) { m_csAnimScript = ev->GetConstString(1); @@ -10027,6 +10415,11 @@ void Actor::EventAnimScript(Event *ev) SetThinkIdle(THINK_ANIM); } +/* +=============== +Actor::EventAnimScript_Scripted +=============== +*/ void Actor::EventAnimScript_Scripted(Event *ev) { m_csAnimScript = ev->GetConstString(1); @@ -10036,6 +10429,11 @@ void Actor::EventAnimScript_Scripted(Event *ev) SetThinkIdle(THINK_ANIM); } +/* +=============== +Actor::EventAnimScript_Noclip +=============== +*/ void Actor::EventAnimScript_Noclip(Event *ev) { m_csAnimScript = ev->GetConstString(1); @@ -10045,6 +10443,11 @@ void Actor::EventAnimScript_Noclip(Event *ev) SetThinkIdle(THINK_ANIM); } +/* +=============== +Actor::EventAnimScript_Attached +=============== +*/ void Actor::EventAnimScript_Attached(Event *ev) { m_csAnimScript = ev->GetConstString(1); @@ -10054,6 +10457,11 @@ void Actor::EventAnimScript_Attached(Event *ev) SetThinkIdle(THINK_ANIM); } +/* +=============== +Actor::EventReload_mg42 +=============== +*/ void Actor::EventReload_mg42(Event *ev) { if (m_State != ACTOR_STATE_MACHINE_GUNNER_RELOADING) { @@ -10066,6 +10474,11 @@ void Actor::EventReload_mg42(Event *ev) } } +/* +=============== +Actor::CanMovePathWithLeash +=============== +*/ bool Actor::CanMovePathWithLeash(void) const { vec2_t delta; @@ -10075,17 +10488,18 @@ bool Actor::CanMovePathWithLeash(void) const } VectorSub2D(origin, m_vHome, delta); - if (VectorLength2DSquared(delta) >= m_fLeashSquared) { - return true; - } - - if (DotProduct2D(m_Path.CurrentDelta(), delta) >= 0) { + if (VectorLength2DSquared(delta) >= m_fLeashSquared && DotProduct2D(m_Path.CurrentDelta(), delta) >= 0) { return false; } return true; } +/* +=============== +Actor::MovePathWithLeash +=============== +*/ bool Actor::MovePathWithLeash(void) { if (!CanMovePathWithLeash()) { @@ -10099,6 +10513,11 @@ bool Actor::MovePathWithLeash(void) return true; } +/* +=============== +Actor::GunTarget +=============== +*/ Vector Actor::GunTarget(bool bNoCollision, const vec3_t position, const vec3_t forward) { static cvar_t *aifSupressScatter = gi.Cvar_Get("g_aiSupressScatter", "2.0", 0); @@ -10108,11 +10527,11 @@ Vector Actor::GunTarget(bool bNoCollision, const vec3_t position, const vec3_t f static cvar_t *aiScatterWide = gi.Cvar_Get("g_aiScatterWide", "16.0", 0); static cvar_t *aiScatterHeight = gi.Cvar_Get("g_aiScatterHeight", "45.0", 0); static cvar_t *aiRanges[4]; - static qboolean doInit = qtrue; + static qboolean doInit = true; float fAccuracy, fCoverFactor; Vector aimDir; - fCoverFactor = mAccuracy * (1.0 - m_fVisibilityAlpha) * aiMinAccuracy->value + m_fVisibilityAlpha; + fCoverFactor = mAccuracy * ((1.0 - m_fVisibilityAlpha) * aiMinAccuracy->value + m_fVisibilityAlpha); if (doInit) { aiRanges[0] = gi.Cvar_Get("g_aishortrange", "500", 0); @@ -10143,12 +10562,14 @@ Vector Actor::GunTarget(bool bNoCollision, const vec3_t position, const vec3_t f Vector dir = mTargetPos - EyePosition(); dir.normalize(); - if (DotProduct2D(forward, dir) < aiMaxDeviation->value) { - Vector vOut; + if (g_target_game > target_game_e::TG_MOH) { + if (DotProduct(forward, dir) < aiMaxDeviation->value) { + Vector vOut; - VectorMA(position, 2048, forward, vOut); + VectorMA(position, 2048, forward, vOut); - return vOut; + return vOut; + } } if (mTargetPos == vec_zero) { @@ -10190,7 +10611,7 @@ Vector Actor::GunTarget(bool bNoCollision, const vec3_t position, const vec3_t f vPos = player->centroid; if (!G_SightTrace( - GunPosition(), vec_zero, vec_zero, vPos, m_Enemy, this, MASK_CANSEE, qfalse, "Actor::GunTarget 1" + GunPosition(), vec_zero, vec_zero, vPos, m_Enemy, this, MASK_CANSEE, false, "Actor::GunTarget 1" )) { fCoverFactor *= aifCoverFactor->value; vPos = m_Enemy->EyePosition(); @@ -10228,6 +10649,11 @@ Vector Actor::GunTarget(bool bNoCollision, const vec3_t position, const vec3_t f return vPos + error; } +/* +=============== +Actor::setModel +=============== +*/ qboolean Actor::setModel(void) { str name; @@ -10263,28 +10689,53 @@ qboolean Actor::setModel(void) return success; } +/* +=============== +Actor::EventSetHeadModel +=============== +*/ void Actor::EventSetHeadModel(Event *ev) { m_csHeadModel = ev->GetConstString(1); setModel(); } +/* +=============== +Actor::EventGetHeadModel +=============== +*/ void Actor::EventGetHeadModel(Event *ev) { ev->AddConstString(m_csHeadModel); } +/* +=============== +Actor::EventSetHeadSkin +=============== +*/ void Actor::EventSetHeadSkin(Event *ev) { m_csHeadSkin = ev->GetConstString(1); setModel(); } +/* +=============== +Actor::EventGetHeadSkin +=============== +*/ void Actor::EventGetHeadSkin(Event *ev) { ev->AddConstString(m_csHeadSkin); } +/* +=============== +Actor::SetPathWithLeash +=============== +*/ void Actor::SetPathWithLeash(Vector vDestPos, const char *description, int iMaxDirtyTime) { vec2_t vDelta; @@ -10306,6 +10757,11 @@ void Actor::SetPathWithLeash(Vector vDestPos, const char *description, int iMaxD SetPath(vDestPos, description, iMaxDirtyTime, m_vHome, m_fLeashSquared); } +/* +=============== +Actor::SetPathWithLeash +=============== +*/ void Actor::SetPathWithLeash(SimpleEntity *pDestNode, const char *description, int iMaxDirtyTime) { if (!pDestNode) { @@ -10327,12 +10783,22 @@ void Actor::SetPathWithLeash(SimpleEntity *pDestNode, const char *description, i SetPathWithLeash(pDestNode->origin, description, iMaxDirtyTime); } +/* +=============== +Actor::FindPathAwayWithLeash +=============== +*/ void Actor::FindPathAwayWithLeash(vec3_t vAwayFrom, vec3_t vDirPreferred, float fMinSafeDist) { m_Path.FindPathAway(origin, vAwayFrom, vDirPreferred, this, fMinSafeDist, m_vHome, m_fLeashSquared); ShortenPathToAvoidSquadMates(); } +/* +=============== +Actor::FindPathNearWithLeash +=============== +*/ void Actor::FindPathNearWithLeash(vec3_t vNearbyTo, float fCloseDistSquared) { vec2_t vDelta; @@ -10398,6 +10864,11 @@ Vector Actor::GetAntiBunchPoint(void) } } +/* +=============== +Actor::AutoArchiveModel +=============== +*/ bool Actor::AutoArchiveModel(void) { return false; @@ -10442,21 +10913,41 @@ void Actor::ResetBodyQueue(void) mCurBody = 0; } +/* +=============== +Actor::EventSetNoIdle +=============== +*/ void Actor::EventSetNoIdle(Event *ev) { m_bNoIdleAfterAnim = ev->GetInteger(1); } +/* +=============== +Actor::EventGetNoIdle +=============== +*/ void Actor::EventGetNoIdle(Event *ev) { ev->AddInteger(m_bNoIdleAfterAnim); } +/* +=============== +Actor::EventGetEnemy +=============== +*/ void Actor::EventGetEnemy(Event *ev) { ev->AddListener(m_Enemy); } +/* +=============== +Actor::EventSetMaxNoticeTimeScale +=============== +*/ void Actor::EventSetMaxNoticeTimeScale(Event *ev) { float fScale; @@ -10470,21 +10961,41 @@ void Actor::EventSetMaxNoticeTimeScale(Event *ev) m_fMaxNoticeTimeScale = fScale * 0.01f; } +/* +=============== +Actor::EventGetMaxNoticeTimeScale +=============== +*/ void Actor::EventGetMaxNoticeTimeScale(Event *ev) { ev->AddFloat(m_fMaxNoticeTimeScale * 100); } +/* +=============== +Actor::EventSetFixedLeash +=============== +*/ void Actor::EventSetFixedLeash(Event *ev) { m_bFixedLeash = ev->GetBoolean(1); } +/* +=============== +Actor::EventGetFixedLeash +=============== +*/ void Actor::EventGetFixedLeash(Event *ev) { ev->AddInteger(m_bFixedLeash); } +/* +=============== +Actor::Holster +=============== +*/ void Actor::Holster(void) { if (activeWeaponList[WEAPON_MAIN]) { @@ -10492,6 +11003,11 @@ void Actor::Holster(void) } } +/* +=============== +Actor::HolsterOffHand +=============== +*/ void Actor::HolsterOffHand(void) { if (activeWeaponList[WEAPON_OFFHAND]) { @@ -10499,6 +11015,11 @@ void Actor::HolsterOffHand(void) } } +/* +=============== +Actor::Unholster +=============== +*/ void Actor::Unholster(void) { Weapon *weap; @@ -10512,6 +11033,11 @@ void Actor::Unholster(void) } } +/* +=============== +Actor::UnholsterOffHand +=============== +*/ void Actor::UnholsterOffHand(void) { Weapon *weap; @@ -10525,6 +11051,11 @@ void Actor::UnholsterOffHand(void) } } +/* +=============== +Actor::EventHolster +=============== +*/ void Actor::EventHolster(Event *ev) { if (ev->NumArgs() > 0 && ev->GetInteger(1) > 0) { @@ -10534,6 +11065,11 @@ void Actor::EventHolster(Event *ev) } } +/* +=============== +Actor::EventUnholster +=============== +*/ void Actor::EventUnholster(Event *ev) { if (ev->NumArgs() > 0 && ev->GetInteger(1) > 0) { @@ -10543,28 +11079,48 @@ void Actor::EventUnholster(Event *ev) } } +/* +=============== +Actor::EventIsEnemyVisible +=============== +*/ void Actor::EventIsEnemyVisible(Event *ev) { ev->AddInteger(m_bEnemyVisible); } +/* +=============== +Actor::EventGetEnemyVisibleChangeTime +=============== +*/ void Actor::EventGetEnemyVisibleChangeTime(Event *ev) { ev->AddFloat(m_iEnemyVisibleChangeTime / 100.f); } +/* +=============== +Actor::EventGetLastEnemyVisibleTime +=============== +*/ void Actor::EventGetLastEnemyVisibleTime(Event *ev) { ev->AddFloat(m_iLastEnemyVisibleTime / 100.f); } +/* +=============== +Actor::EventSoundDone +=============== +*/ void Actor::EventSoundDone(Event *ev) { int channelNum; str sfxName; channelNum = ev->GetInteger(1); - sfxName = ev->GetString(1); + sfxName = ev->GetString(2); if (gi.S_IsSoundPlaying(channelNum, sfxName)) { Event event(EV_SoundDone); @@ -10581,15 +11137,25 @@ void Actor::EventSoundDone(Event *ev) } } +/* +=============== +Actor::EventSound +=============== +*/ void Actor::EventSound(Event *ev) { if (g_gametype->integer == GT_SINGLE_PLAYER || m_Team == TEAM_AMERICAN) { - ProcessSoundEvent(ev, qtrue); + ProcessSoundEvent(ev, true); } else { - ProcessSoundEvent(ev, qfalse); + ProcessSoundEvent(ev, false); } } +/* +=============== +Actor::EventSetFallHeight +=============== +*/ void Actor::EventSetFallHeight(Event *ev) { float fHeight = ev->GetFloat(1); @@ -10604,11 +11170,21 @@ void Actor::EventSetFallHeight(Event *ev) m_Path.SetFallHeight(fHeight); } +/* +=============== +Actor::EventGetFallHeight +=============== +*/ void Actor::EventGetFallHeight(Event *ev) { ev->AddFloat(m_Path.GetFallHeight()); } +/* +=============== +Actor::EventCanMoveTo +=============== +*/ void Actor::EventCanMoveTo(Event *ev) { Vector vDest; @@ -10681,6 +11257,11 @@ void Actor::EventCanMoveTo(Event *ev) ev->AddInteger(true); } +/* +=============== +Actor::EventMoveDir +=============== +*/ void Actor::EventMoveDir(Event *ev) { vec3_t vDir; @@ -10704,6 +11285,11 @@ void Actor::EventMoveDir(Event *ev) ev->AddVector(vDir); } +/* +=============== +Actor::EventIntervalDir +=============== +*/ void Actor::EventIntervalDir(Event *ev) { if (level.inttime >= m_iIntervalDirTime + 250) { @@ -10721,17 +11307,32 @@ void Actor::EventIntervalDir(Event *ev) ev->AddVector(m_vIntervalDir); } +/* +=============== +Actor::EventResetLeash +=============== +*/ void Actor::EventResetLeash(Event *ev) { m_vHome = origin; m_pTetherEnt = NULL; } +/* +=============== +Actor::EventTether +=============== +*/ void Actor::EventTether(Event *ev) { m_pTetherEnt = ev->GetSimpleEntity(1); } +/* +=============== +Actor::ShortenPathToAttack +=============== +*/ bool Actor::ShortenPathToAttack(float fMinDist) { float fMinDistSquared; @@ -10761,6 +11362,11 @@ bool Actor::ShortenPathToAttack(float fMinDist) return false; } +/* +=============== +Actor::StrafeToAttack +=============== +*/ void Actor::StrafeToAttack(float fDist, vec3_t vDir) { static const vec3_t mins = {-16, -16, 16}; @@ -10778,7 +11384,7 @@ void Actor::StrafeToAttack(float fDist, vec3_t vDir) return; } - if (!G_SightTrace(origin, mins, maxs, vSpot, this, NULL, MASK_TARGETPATH, qtrue, "Actor::StrafeToAttack 1")) { + if (!G_SightTrace(origin, mins, maxs, vSpot, this, NULL, MASK_TARGETPATH, true, "Actor::StrafeToAttack 1")) { ClearPath(); return; } @@ -10794,7 +11400,7 @@ void Actor::StrafeToAttack(float fDist, vec3_t vDir) this, m_Enemy, MASK_CANSEE, - qfalse, + false, "Actor::StrafeToAttack 1" )) { ClearPath(); @@ -10804,28 +11410,53 @@ void Actor::StrafeToAttack(float fDist, vec3_t vDir) SetPathWithLeash(vSpot, NULL, 0); } +/* +=============== +Actor::EventGetThinkState +=============== +*/ void Actor::EventGetThinkState(Event *ev) { ev->AddConstString(m_csThinkStateNames[m_ThinkState]); } +/* +=============== +Actor::EventGetEnemyShareRange +=============== +*/ void Actor::EventGetEnemyShareRange(Event *ev) { ev->AddFloat(sqrt(m_fMaxShareDistSquared)); } +/* +=============== +Actor::EventSetEnemyShareRange +=============== +*/ void Actor::EventSetEnemyShareRange(Event *ev) { float fLength = ev->GetFloat(1); m_fMaxShareDistSquared = Square(fLength); } +/* +=============== +Actor::GetVoiceType +=============== +*/ void Actor::GetVoiceType(Event *ev) { //voice type in actor is a char. ev->AddString(va("%c", mVoiceType)); } +/* +=============== +Actor::SetVoiceType +=============== +*/ void Actor::SetVoiceType(Event *ev) { //voice type in actor is a char. @@ -10838,6 +11469,11 @@ void Actor::SetVoiceType(Event *ev) } } +/* +=============== +Actor::FindSniperNodeAndSetPath +=============== +*/ PathNode *Actor::FindSniperNodeAndSetPath(bool *pbTryAgain) { PathNode *pSniperNode; @@ -10867,6 +11503,11 @@ PathNode *Actor::FindSniperNodeAndSetPath(bool *pbTryAgain) return pSniperNode; } +/* +=============== +Actor::Remove +=============== +*/ void Actor::Remove(Event *ev) { EndStates(); @@ -10880,21 +11521,41 @@ void Actor::Remove(Event *ev) Delete(); } +/* +=============== +Actor::EventGetKickDir +=============== +*/ void Actor::EventGetKickDir(Event *ev) { ev->AddVector(m_vKickDir); } +/* +=============== +Actor::EventGetNoLongPain +=============== +*/ void Actor::EventGetNoLongPain(Event *ev) { ev->AddInteger(m_bNoLongPain || m_Team == TEAM_AMERICAN); } +/* +=============== +Actor::EventSetNoLongPain +=============== +*/ void Actor::EventSetNoLongPain(Event *ev) { m_bNoLongPain = ev->GetBoolean(1); } +/* +=============== +Actor::DontFaceWall +=============== +*/ void Actor::DontFaceWall(void) { trace_t trace; @@ -10924,15 +11585,9 @@ void Actor::DontFaceWall(void) VectorSub2D(m_vDfwPos, origin, vDelta); - if (Square(fErrorLerp * -14.0 + 16.0) > VectorLength2DSquared(vDelta)) { - if (AvoidingFacingWall()) { - SetDesiredYaw(m_fDfwDerivedYaw); - } - return; - } - - if (fabs(AngleNormalize180(m_fDfwRequestedYaw - m_DesiredYaw)) <= fErrorLerp * -29.0 + 30.0 - && fabs(AngleNormalize180(m_fDfwRequestedYaw - m_DesiredYaw)) <= fErrorLerp * -29.0 + 30.0) { + if (Square(fErrorLerp * -14.0 + 16.0) > VectorLength2DSquared(vDelta) + && (fabs(AngleNormalize180(m_fDfwRequestedYaw - m_DesiredYaw)) <= fErrorLerp * -29.0 + 30.0 + || fabs(AngleNormalize180(m_fDfwDerivedYaw - m_DesiredYaw)) <= fErrorLerp * -29.0 + 30.0)) { if (AvoidingFacingWall()) { SetDesiredYaw(m_fDfwDerivedYaw); } @@ -10952,12 +11607,12 @@ void Actor::DontFaceWall(void) start.y -= origin.y; fEyeRadius = VectorLength2D(start); start.x = origin.x + fEyeRadius * fCosAngle; - start.y = origin.x + fEyeRadius * fSinAngle; + start.y = origin.y + fEyeRadius * fSinAngle; end.x = start.x + fCosAngle * 64; end.y = start.y + fSinAngle * 64; end.z = start.z; - trace = G_Trace(start, vec_zero, vec_zero, end, this, MASK_CANSEE, qfalse, "Actor::DontFaceWall"); + trace = G_Trace(start, vec_zero, vec_zero, end, this, MASK_CANSEE, false, "Actor::DontFaceWall"); if (trace.entityNum == ENTITYNUM_NONE || trace.fraction > 0.999f || trace.startsolid) { m_eDontFaceWallMode = 3; @@ -10965,7 +11620,7 @@ void Actor::DontFaceWall(void) return; } - if (trace.entityNum != ENTITYNUM_WORLD && trace.ent->entity->AIDontFace()) { + if (trace.entityNum != ENTITYNUM_WORLD && !trace.ent->entity->AIDontFace()) { m_eDontFaceWallMode = 4; m_fDfwDerivedYaw = m_fDfwRequestedYaw; return; @@ -11001,51 +11656,101 @@ void Actor::DontFaceWall(void) m_fDfwDerivedYaw = m_DesiredYaw; } +/* +=============== +Actor::IsVoidState +=============== +*/ bool Actor::IsVoidState(int state) { return true; } +/* +=============== +Actor::IsIdleState +=============== +*/ bool Actor::IsIdleState(int state) { return state == THINKSTATE_IDLE; } +/* +=============== +Actor::IsCuriousState +=============== +*/ bool Actor::IsCuriousState(int state) { return state == THINKSTATE_CURIOUS; } +/* +=============== +Actor::IsDisguiseState +=============== +*/ bool Actor::IsDisguiseState(int state) { return state == THINKSTATE_DISGUISE; } +/* +=============== +Actor::IsAttackState +=============== +*/ bool Actor::IsAttackState(int state) { return state == THINKSTATE_ATTACK; } +/* +=============== +Actor::IsGrenadeState +=============== +*/ bool Actor::IsGrenadeState(int state) { return state == THINKSTATE_GRENADE; } +/* +=============== +Actor::IsBadPlaceState +=============== +*/ bool Actor::IsBadPlaceState(int state) { return state == THINKSTATE_BADPLACE; } +/* +=============== +Actor::IsPainState +=============== +*/ bool Actor::IsPainState(int state) { return state == THINKSTATE_PAIN; } +/* +=============== +Actor::IsKilledState +=============== +*/ bool Actor::IsKilledState(int state) { return state == THINKSTATE_KILLED; } +/* +=============== +Actor::IsNoClipState +=============== +*/ bool Actor::IsNoClipState(int state) { return state == THINKSTATE_NOCLIP; @@ -11063,6 +11768,11 @@ void Actor::InitVoid(GlobalFuncs_t *func) func->IsState = &Actor::IsVoidState; } +/* +=============== +Actor::BecomeCorpse +=============== +*/ void Actor::BecomeCorpse(void) { AddToBodyQue(); @@ -11085,16 +11795,31 @@ void Actor::BecomeCorpse(void) PostEvent(EV_DeathSinkStart, 10); } +/* +=============== +Actor::EventGetFavoriteEnemy +=============== +*/ void Actor::EventGetFavoriteEnemy(Event *ev) { ev->AddEntity(m_FavoriteEnemy); } +/* +=============== +Actor::EventSetFavoriteEnemy +=============== +*/ void Actor::EventSetFavoriteEnemy(Event *ev) { m_FavoriteEnemy = static_cast(ev->GetEntity(1)); } +/* +=============== +Actor::EventFindEnemy +=============== +*/ void Actor::EventFindEnemy(Event *ev) { if (level.inttime > m_iEnemyCheckTime + 200) { @@ -11104,26 +11829,51 @@ void Actor::EventFindEnemy(Event *ev) ev->AddEntity(m_Enemy); } +/* +=============== +Actor::EventGetMumble +=============== +*/ void Actor::EventGetMumble(Event *ev) { ev->AddInteger(m_bMumble); } +/* +=============== +Actor::EventSetMumble +=============== +*/ void Actor::EventSetMumble(Event *ev) { m_bMumble = ev->GetInteger(1) != false; } +/* +=============== +Actor::EventGetBreathSteam +=============== +*/ void Actor::EventGetBreathSteam(Event *ev) { ev->AddInteger(m_bBreathSteam); } +/* +=============== +Actor::EventSetBreathSteam +=============== +*/ void Actor::EventSetBreathSteam(Event *ev) { m_bBreathSteam = ev->GetInteger(1) != false; } +/* +=============== +Actor::EventSetNextBreathTime +=============== +*/ void Actor::EventSetNextBreathTime(Event *ev) { ScriptVariable var; @@ -11136,6 +11886,11 @@ void Actor::EventSetNextBreathTime(Event *ev) thread->Execute(&var, 1); } +/* +=============== +Actor::EventCalcGrenadeToss2 +=============== +*/ void Actor::EventCalcGrenadeToss2(Event *ev) { Vector vTargetPos; @@ -11158,8 +11913,10 @@ void Actor::EventCalcGrenadeToss2(Event *ev) } if (fDistSquared < Square(1024)) { + // See if it can roll vPoint = GrenadeThrowPoint(vFrom, vDelta, STRING_ANIM_GRENADETOSS_SCR); vVel = CanRollGrenade(vPoint, vTargetPos); + if (vVel != vPointTarget) { m_vGrenadeVel = vVel; m_eGrenadeMode = AI_GREN_TOSS_ROLL; @@ -11172,6 +11929,7 @@ void Actor::EventCalcGrenadeToss2(Event *ev) if (!speed) { vPoint = GrenadeThrowPoint(vFrom, vDelta, STRING_ANIM_GRENADETHROW_SCR); vVel = CanThrowGrenade(vPoint, vTargetPos); + if (vVel != vec_zero) { m_vGrenadeVel = vVel; m_eGrenadeMode = AI_GREN_TOSS_THROW; @@ -11188,12 +11946,19 @@ void Actor::EventCalcGrenadeToss2(Event *ev) vVel = vTargetPos - vPoint; vVel.normalize(); vVel *= speed; - m_vGrenadeVel = vVel; + + m_vGrenadeVel = vVel; + m_eGrenadeMode = AI_GREN_TOSS_THROW; ev->AddConstString(STRING_ANIM_GRENADETOSS_SCR); SetDesiredYawDir(m_vGrenadeVel); } +/* +=============== +Actor::EventCalcGrenadeToss +=============== +*/ void Actor::EventCalcGrenadeToss(Event *ev) { bool bSuccess; @@ -11228,36 +11993,71 @@ void Actor::EventCalcGrenadeToss(Event *ev) SetDesiredYawDir(m_vGrenadeVel); } +/* +=============== +Actor::EventGetNoSurprise +=============== +*/ void Actor::EventGetNoSurprise(Event *ev) { ev->AddInteger(m_bNoSurprise); } +/* +=============== +Actor::EventSetNoSurprise +=============== +*/ void Actor::EventSetNoSurprise(Event *ev) { m_bNoSurprise = ev->GetBoolean(1); } +/* +=============== +Actor::EventGetSilent +=============== +*/ void Actor::EventGetSilent(Event *ev) { ev->AddInteger(m_bSilent); } +/* +=============== +Actor::EventSetSilent +=============== +*/ void Actor::EventSetSilent(Event *ev) { m_bSilent = ev->GetBoolean(1); } +/* +=============== +Actor::EventGetAvoidPlayer +=============== +*/ void Actor::EventGetAvoidPlayer(Event *ev) { ev->AddInteger(m_bAutoAvoidPlayer); } +/* +=============== +Actor::EventSetAvoidPlayer +=============== +*/ void Actor::EventSetAvoidPlayer(Event *ev) { m_bAutoAvoidPlayer = ev->GetBoolean(1); } +/* +=============== +Actor::PathnodeClaimRevoked +=============== +*/ void Actor::PathnodeClaimRevoked(PathNode *node) { int iThinkLevel; @@ -11274,6 +12074,11 @@ void Actor::PathnodeClaimRevoked(PathNode *node) m_pCoverNode = NULL; } +/* +=============== +Actor::SetPathToNotBlockSentient +=============== +*/ void Actor::SetPathToNotBlockSentient(Sentient *pOther) { Vector vAway; @@ -11318,9 +12123,7 @@ void Actor::SetPathToNotBlockSentient(Sentient *pOther) vDest = origin + vPerp * 48; - if (G_SightTrace( - vDest, mins, maxs, vDest, this, pOther, MASK_SOLID, qfalse, "Actor::SetPathToNotBlockSentient 1" - )) { + if (G_SightTrace(vDest, mins, maxs, vDest, this, pOther, MASK_SOLID, false, "Actor::SetPathToNotBlockSentient 1")) { SetPathWithinDistance(vDest, NULL, 96, 0); } @@ -11330,9 +12133,7 @@ void Actor::SetPathToNotBlockSentient(Sentient *pOther) vDest = origin - vPerp * 48; - if (G_SightTrace( - vDest, mins, maxs, vDest, this, pOther, MASK_SOLID, qfalse, "Actor::SetPathToNotBlockSentient 2" - )) { + if (G_SightTrace(vDest, mins, maxs, vDest, this, pOther, MASK_SOLID, false, "Actor::SetPathToNotBlockSentient 2")) { SetPathWithinDistance(vDest, NULL, 96, 0); } @@ -11369,7 +12170,7 @@ void Actor::LookAround(float fFovAdd) VectorMA(vEyePos, 1024, vDest, vDest); - trace = G_Trace(EyePosition(), vec_zero, vec_zero, vDest, this, MASK_LOOK, qfalse, "Actor::LookAround"); + trace = G_Trace(EyePosition(), vec_zero, vec_zero, vDest, this, MASK_LOOK, false, "Actor::LookAround"); if (trace.fraction > 0.125) { m_bHasDesiredLookDest = true; VectorCopy(trace.endpos, m_vDesiredLookDest); @@ -11387,6 +12188,11 @@ void Actor::LookAround(float fFovAdd) } } +/* +=============== +Actor::EventGetLookAroundAngle +=============== +*/ void Actor::EventGetLookAroundAngle(Event *ev) { // Fixed in OPM @@ -11396,6 +12202,11 @@ void Actor::EventGetLookAroundAngle(Event *ev) ev->AddFloat(m_fLookAroundFov); } +/* +=============== +Actor::EventSetLookAroundAngle +=============== +*/ void Actor::EventSetLookAroundAngle(Event *ev) { float fLookAroundFov; @@ -11408,6 +12219,11 @@ void Actor::EventSetLookAroundAngle(Event *ev) m_fLookAroundFov = fLookAroundFov; } +/* +=============== +Actor::DumpAnimInfo +=============== +*/ void Actor::DumpAnimInfo(void) { vec3_t LocalLookAngles; @@ -11464,8 +12280,9 @@ const char *Actor::DumpCallTrace(const char *pszFmt, ...) const vPlayer = p->origin; } - i1 = sprintf( + i1 = Com_sprintf( szTemp, + sizeof(szTemp), "map = %s\n" "time = %i (%i:%02i)\n" "entnum = %i, targetname = '%s'\n" @@ -11500,7 +12317,7 @@ const char *Actor::DumpCallTrace(const char *pszFmt, ...) const if (pszFmt) { va_list args2; va_copy(args2, args); - i2 = i1 + vsprintf(&szTemp[i1], pszFmt, args); + i2 = i1 + Q_vsnprintf(szTemp + i1, sizeof(szTemp) - i1, pszFmt, args); } va_end(args); @@ -11511,8 +12328,9 @@ const char *Actor::DumpCallTrace(const char *pszFmt, ...) const t = time(0); ptm = localtime(&t); - sprintf( + Com_sprintf( szFile, + sizeof(szFile), "main\\ai_trace_%s_%i_%i_%02i%02i.log", sv_mapname->string, ptm->tm_mon + 1, @@ -11543,12 +12361,22 @@ const char *Actor::DumpCallTrace(const char *pszFmt, ...) const ); } +/* +=============== +Actor::EventSetMoveDoneRadius +=============== +*/ void Actor::EventSetMoveDoneRadius(Event *ev) { float radius = ev->GetFloat(1); m_fMoveDoneRadiusSquared = Square(radius); } +/* +=============== +Actor::EventGetMoveDoneRadius +=============== +*/ void Actor::EventGetMoveDoneRadius(Event *ev) { ev->AddFloat(sqrtf(m_fMoveDoneRadiusSquared)); @@ -11574,11 +12402,21 @@ void Actor::StoppedWaitFor(const_str name, bool bDeleting) g_iInThinks--; } +/* +=============== +Actor::EventHasCompleteLookahead +=============== +*/ void Actor::EventHasCompleteLookahead(Event *ev) { ev->AddInteger(PathExists() && PathHasCompleteLookahead()); } +/* +=============== +Actor::EventPathDist +=============== +*/ void Actor::EventPathDist(Event *ev) { if (!PathExists() || PathComplete()) { @@ -11589,6 +12427,11 @@ void Actor::EventPathDist(Event *ev) ev->AddFloat(PathDist()); } +/* +=============== +Actor::EventCanShootEnemyFrom +=============== +*/ void Actor::EventCanShootEnemyFrom(Event *ev) { if (!m_Enemy) { @@ -11599,26 +12442,51 @@ void Actor::EventCanShootEnemyFrom(Event *ev) ev->AddInteger(CanSeeFrom(ev->GetVector(1), m_Enemy)); } +/* +=============== +Actor::EventSetInReload +=============== +*/ void Actor::EventSetInReload(Event *ev) { m_bInReload = ev->GetBoolean(1); } +/* +=============== +Actor::EventGetInReload +=============== +*/ void Actor::EventGetInReload(Event *ev) { ev->AddInteger(m_bInReload); } +/* +=============== +Actor::EventSetReloadCover +=============== +*/ void Actor::EventSetReloadCover(Event *ev) { m_bNeedReload = ev->GetBoolean(1); } +/* +=============== +Actor::EventBreakSpecial +=============== +*/ void Actor::EventBreakSpecial(Event *ev) { mbBreakSpecialAttack = true; } +/* +=============== +Actor::EventCanShoot +=============== +*/ void Actor::EventCanShoot(Event *ev) { Entity *ent; @@ -11632,11 +12500,21 @@ void Actor::EventCanShoot(Event *ev) ev->AddInteger(CanShoot(ent)); } +/* +=============== +Actor::EventSetBalconyHeight +=============== +*/ void Actor::EventSetBalconyHeight(Event *ev) { m_fBalconyHeight = ev->GetFloat(1); } +/* +=============== +Actor::EventSetIgnoreBadPlace +=============== +*/ void Actor::EventSetIgnoreBadPlace(Event *ev) { if (m_bIgnoreBadPlace == ev->GetBoolean(1)) { @@ -11650,16 +12528,31 @@ void Actor::EventSetIgnoreBadPlace(Event *ev) } } +/* +=============== +Actor::EventGetIgnoreBadPlace +=============== +*/ void Actor::EventGetIgnoreBadPlace(Event *ev) { ev->AddInteger(m_bIgnoreBadPlace); } +/* +=============== +Actor::EventGetBalconyHeight +=============== +*/ void Actor::EventGetBalconyHeight(Event *ev) { ev->AddFloat(m_fBalconyHeight); } +/* +=============== +Actor::BecomeTurretGuy +=============== +*/ void Actor::BecomeTurretGuy(void) { SetThinkIdle(THINK_IDLE); @@ -11741,6 +12634,11 @@ void Actor::Landed(Event *ev) setMoveType(MOVETYPE_NONE); } +/* +=============== +Actor::IsOnFloor +=============== +*/ bool Actor::IsOnFloor(void) { str name = AnimName(0); @@ -11861,10 +12759,25 @@ void Actor::EventCuriousOn(Event *ev) m_bIsCurious = true; } +/* +=============== +Actor::EventSetDestIdle +=============== +*/ void Actor::EventSetDestIdle(Event *ev) {} +/* +=============== +Actor::EventSetDestIdle2 +=============== +*/ void Actor::EventSetDestIdle2(Event *ev) {} +/* +=============== +Actor::IsDisabled +=============== +*/ bool Actor::IsDisabled() const { return !m_bDoAI; diff --git a/code/fgame/actor.h b/code/fgame/actor.h index a31d4fd6..7274f8ce 100644 --- a/code/fgame/actor.h +++ b/code/fgame/actor.h @@ -1714,7 +1714,7 @@ inline bool Actor::CanSeeFOV(Entity *ent) bCanSee = false; - if (InFOV(ent->centroid) && gi.AreasConnected(edict->r.areanum, ent->edict->r.areanum)) { + if (InFOV(ent) && AreasConnected(ent)) { bCanSee = CanSee(ent, 0, 0, false); } diff --git a/code/fgame/actor_alarm.cpp b/code/fgame/actor_alarm.cpp index f485839d..57514a9e 100644 --- a/code/fgame/actor_alarm.cpp +++ b/code/fgame/actor_alarm.cpp @@ -120,6 +120,8 @@ void Actor::Think_Alarm(void) Com_Printf("Actor::Think_Alarm: invalid think state %i\n", m_State); break; } + + PostThink(true); } void Actor::FinishedAnimation_Alarm(void) diff --git a/code/fgame/actor_balcony.cpp b/code/fgame/actor_balcony.cpp index 538e6563..ab181089 100644 --- a/code/fgame/actor_balcony.cpp +++ b/code/fgame/actor_balcony.cpp @@ -264,7 +264,7 @@ bool Actor::CalcFallPath(void) loop = currentPos; mm.desired_speed = 0; - mm.groundPlane = NULL; + mm.groundPlane = qfalse; mm.walking = false; VectorSet(mm.velocity, 0, 0, -171); diff --git a/code/fgame/actor_cover.cpp b/code/fgame/actor_cover.cpp index 97701778..8350849b 100644 --- a/code/fgame/actor_cover.cpp +++ b/code/fgame/actor_cover.cpp @@ -79,7 +79,7 @@ bool Actor::Cover_SetPath(PathNode *node) fPathDist = PathDist(); fMinDistSquared = Square(fPathDist); - if ((node->origin - origin).lengthSquared() <= fMinDistSquared * 4.0f && fPathDist > 128.0f) { + if ((node->origin - origin).lengthSquared() * 4 <= fMinDistSquared && fPathDist > 128.0f) { return false; } @@ -343,7 +343,7 @@ void Actor::State_Cover_Hide(void) bool bCanShoot, bCanSee; if (m_Enemy) { - SetEnemyPos(origin); + SetEnemyPos(m_Enemy->origin); } if (!m_pCoverNode) { @@ -380,7 +380,7 @@ void Actor::State_Cover_Hide(void) return; } - if (bCanShoot || bCanShoot) { + if (bCanSee || bCanShoot) { m_pCoverNode->Relinquish(); m_pCoverNode->MarkTemporarilyBad(); m_pCoverNode = NULL; diff --git a/code/fgame/actor_curious.cpp b/code/fgame/actor_curious.cpp index ba1720ea..19e51e5d 100644 --- a/code/fgame/actor_curious.cpp +++ b/code/fgame/actor_curious.cpp @@ -31,7 +31,7 @@ void Actor::InitCurious(GlobalFuncs_t *func) func->EndState = &Actor::End_Curious; func->ResumeState = &Actor::Resume_Curious; func->SuspendState = &Actor::Suspend_Curious; - func->FinishedAnimation = &Actor::FinishedAnimation_Cover; + func->FinishedAnimation = &Actor::FinishedAnimation_Curious; func->PassesTransitionConditions = &Actor::PassesTransitionConditions_Curious; func->IsState = &Actor::IsCuriousState; } @@ -246,8 +246,8 @@ void Actor::LookAtCuriosity(void) iSeed = 0x19660D * (m_iCuriousTime - 0x2EB71B09 * ((level.inttime - m_iCuriousTime) & 0xFFFFFF00)) + 0x3C6EF35F; - vAngles[0] = m_DesiredLookAngles[0] + (float)iSeed / 0x4444444 * fLookScale; - vAngles[1] = m_DesiredLookAngles[1] + (float)iSeed / 0x2222222 * fLookScale; + vAngles[0] = m_DesiredLookAngles[0] + (float)iSeed / (float)0x4444444 * fLookScale; + vAngles[1] = m_DesiredLookAngles[1] + (float)iSeed / (float)0x2222222 * fLookScale; vAngles[2] = m_DesiredLookAngles[2]; // clamp vAngles[0] = Q_clamp_float(vAngles[0], -90, 90); diff --git a/code/fgame/actor_disguise_officer.cpp b/code/fgame/actor_disguise_officer.cpp index cb735391..8293312f 100644 --- a/code/fgame/actor_disguise_officer.cpp +++ b/code/fgame/actor_disguise_officer.cpp @@ -120,7 +120,7 @@ void Actor::Think_DisguiseOfficer(void) { Com_Printf("Actor::Think_DisguiseOfficer: invalid think state %i\n", m_State); char assertStr[16317] = {0}; - strcpy(assertStr, "\"invalid think state\"\n\tMessage: "); + Q_strncpyz(assertStr, "\"invalid think state\"\n\tMessage: ", sizeof(assertStr)); Q_strcat(assertStr, sizeof(assertStr), DumpCallTrace("thinkstate = %i", m_State)); assert(!assertStr); } diff --git a/code/fgame/actor_disguise_rover.cpp b/code/fgame/actor_disguise_rover.cpp index 14172252..d8773f24 100644 --- a/code/fgame/actor_disguise_rover.cpp +++ b/code/fgame/actor_disguise_rover.cpp @@ -124,7 +124,7 @@ void Actor::Think_DisguiseRover(void) { Com_Printf("Actor::Think_DisguiseOfficer: invalid think state %i\n", m_State); char assertStr[16317] = {0}; - strcpy(assertStr, "\"invalid think state\"\n\tMessage: "); + Q_strncpyz(assertStr, "\"invalid think state\"\n\tMessage: ", sizeof(assertStr)); Q_strcat(assertStr, sizeof(assertStr), DumpCallTrace("thinkstate = %i", m_State)); assert(!assertStr); } diff --git a/code/fgame/actor_disguise_salute.cpp b/code/fgame/actor_disguise_salute.cpp index d55235ba..75aa6041 100644 --- a/code/fgame/actor_disguise_salute.cpp +++ b/code/fgame/actor_disguise_salute.cpp @@ -31,6 +31,7 @@ void Actor::InitDisguiseSalute(GlobalFuncs_t *func) func->EndState = &Actor::End_DisguiseSalute; func->ResumeState = &Actor::Resume_DisguiseSalute; func->SuspendState = &Actor::Suspend_DisguiseSalute; + func->FinishedAnimation = &Actor::FinishedAnimation_DisguiseSalute; func->PassesTransitionConditions = &Actor::PassesTransitionConditions_Disguise; func->IsState = &Actor::IsDisguiseState; } @@ -51,7 +52,7 @@ void Actor::Begin_DisguiseSalute(void) SetDesiredYawDest(m_Enemy->origin); SetDesiredLookDir(m_Enemy->origin - origin); - DesiredAnimation(ANIM_MODE_NORMAL, STRING_ANIM_DISGUISE_PAPERS_SCR); + DesiredAnimation(ANIM_MODE_NORMAL, STRING_ANIM_DISGUISE_SALUTE_SCR); } else { SetThinkState(THINKSTATE_ATTACK, THINKLEVEL_IDLE); } @@ -85,7 +86,12 @@ void Actor::Think_DisguiseSalute(void) return; } - if ((!EnemyIsDisguised() && !(m_Enemy->flags & FL_NOTARGET)) || level.m_bAlarm != qtrue) { + if (!EnemyIsDisguised() && !(m_Enemy->flags & FL_NOTARGET)) { + SetThinkState(THINKSTATE_ATTACK, THINKLEVEL_IDLE); + return; + } + + if (level.m_bAlarm == qtrue) { SetThinkState(THINKSTATE_ATTACK, THINKLEVEL_IDLE); return; } diff --git a/code/fgame/actor_grenade.cpp b/code/fgame/actor_grenade.cpp index fe4162b1..6a6d355b 100644 --- a/code/fgame/actor_grenade.cpp +++ b/code/fgame/actor_grenade.cpp @@ -474,7 +474,7 @@ void Actor::FinishedAnimation_Grenade(void) break; default: char assertStr[16317] = {0}; - strcpy(assertStr, "\"invalid grenade state in FinishedAnimation()\"\n\tMessage: "); + Q_strncpyz(assertStr, "\"invalid grenade state in FinishedAnimation()\"\n\tMessage: ", sizeof(assertStr)); Q_strcat(assertStr, sizeof(assertStr), DumpCallTrace("state = %i", m_eGrenadeState)); assert(!assertStr); break; diff --git a/code/fgame/actor_machinegunner.cpp b/code/fgame/actor_machinegunner.cpp index 07ddaf0e..f79690f3 100644 --- a/code/fgame/actor_machinegunner.cpp +++ b/code/fgame/actor_machinegunner.cpp @@ -89,8 +89,11 @@ void Actor::End_MachineGunner(void) } Unholster(); - if (m_pTurret && m_pTurret->GetOwner() == this) { - m_pTurret->TurretEndUsed(); + if (m_pTurret) { + m_pTurret->m_bHadOwner = true; + if (m_pTurret->GetOwner() == this) { + m_pTurret->TurretEndUsed(); + } } } @@ -142,31 +145,31 @@ void Actor::ThinkHoldGun_TurretGun(void) if (m_State == ACTOR_STATE_MACHINE_GUNNER_RELOADING) { m_fCrouchWeight = 0; - temp = (origin[2] + 71.6f - m_pTurret->origin[2]) / 39.f; + temp = (origin[2] + 71.6f - m_pTurret->origin[2]) / 39.0f; if (temp >= -1.0 && temp <= 1.0) { m_pTurret->angles[0] = RAD2DEG(atan(temp / sqrt(temp * -temp + 1))); m_pTurret->setAngles(m_pTurret->angles); } } else { m_fCrouchWeight = machine_gunner_hands_up_stand / 17.1f; - if (m_fCrouchWeight < -1.0) { - m_fCrouchWeight = -1.0; + if (m_fCrouchWeight < -1.0f) { + m_fCrouchWeight = -1.0f; } } - VectorScale2D(orientation[0], m_fCrouchWeight * -9.3f + 23.4f, offset); + VectorScale2D(orientation[0], -(23.4 - m_fCrouchWeight * 9.3), offset); VectorAdd2D(newOrigin, offset, newOrigin); - VectorScale2D(orientation[1], m_fCrouchWeight * 2.6f + 10.3f, offset); + VectorScale2D(orientation[1], 10.3 + m_fCrouchWeight * 2.6, offset); VectorAdd2D(newOrigin, offset, newOrigin); } else { - m_fCrouchWeight = machine_gunner_hands_up_stand / (heightDiff - 38.7f); + m_fCrouchWeight = machine_gunner_hands_up_stand / (heightDiff - 38.7); if (m_fCrouchWeight > 1.0) { m_fCrouchWeight = 1.0; } - VectorScale2D(orientation[0], m_fCrouchWeight * -3.f + 23.4f, offset); + VectorScale2D(orientation[0], -(23.4 - m_fCrouchWeight * 3.0), offset); VectorAdd2D(newOrigin, offset, newOrigin); - VectorScale2D(orientation[1], m_fCrouchWeight * -1.6f + 10.3f, offset); + VectorScale2D(orientation[1], 10.3 - m_fCrouchWeight * 1.6, offset); VectorAdd2D(newOrigin, offset, newOrigin); } @@ -179,9 +182,11 @@ void Actor::ThinkHoldGun_TurretGun(void) UpdateAimMotion(); UpdateAnim(); + newOrigin[2] = origin[2] + 18.0; + end[0] = newOrigin[0]; end[1] = newOrigin[1]; - end[2] = newOrigin[2] - 94; + end[2] = origin[2] - 94.0; trace = G_Trace(newOrigin, MINS, MAXS, end, this, MASK_PATHSOLID, qfalse, "Actor::ThinkHoldGun_TurretGun"); if (trace.fraction != 1.0 && !trace.startsolid && !trace.allsolid && trace.ent) { @@ -207,6 +212,12 @@ void Actor::Think_MachineGunner_TurretGun(void) UpdateEnemyInternal(); + if (m_Team == TEAM_AMERICAN) { + // Added in 2.30 + ThinkHoldGun_TurretGun(); + return; + } + if (m_pTurret->AI_CanTarget(G_GetEntity(0)->centroid)) { ThinkHoldGun_TurretGun(); return; diff --git a/code/fgame/actor_patrol.cpp b/code/fgame/actor_patrol.cpp index 233a6d56..bcf9f4ac 100644 --- a/code/fgame/actor_patrol.cpp +++ b/code/fgame/actor_patrol.cpp @@ -81,6 +81,11 @@ void Actor::Think_Patrol(void) } else if (bMoveInRadius) { ClearPatrolCurrentNode(); SetThinkIdle(THINK_IDLE); + // Added in OPM + // Not sure why it was not cleared originally. + // Once you reach your goal, there is no point + // in leaving it set to true + m_bScriptGoalValid = false; parm.movedone = true; Unregister(STRING_MOVEDONE); diff --git a/code/fgame/actor_runandshoot.cpp b/code/fgame/actor_runandshoot.cpp index e8a82958..1939dbb2 100644 --- a/code/fgame/actor_runandshoot.cpp +++ b/code/fgame/actor_runandshoot.cpp @@ -21,6 +21,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // actor_runandshoot.cpp +// +// Added in 2.30 +// #include "actor.h" @@ -37,9 +40,10 @@ void Actor::InitRunAndShoot(GlobalFuncs_t *func) void Actor::Begin_RunAndShoot(void) { - m_State = ACTOR_STATE_RUN_AND_SHOOT_RUN; if (m_patrolCurrentNode) { m_State = ACTOR_STATE_RUN_AND_SHOOT_RUNNING; + } else { + m_State = ACTOR_STATE_RUN_AND_SHOOT_RUN; } } @@ -125,7 +129,7 @@ bool Actor::RunAndShoot_MoveToPatrolCurrentNode(void) { UpdatePatrolCurrentNode(); - if (!m_patrolCurrentNode && m_bPatrolWaitTrigger) { + if (!m_patrolCurrentNode || m_bPatrolWaitTrigger) { IdleLook(); Anim_Idle(); return false; @@ -143,62 +147,29 @@ bool Actor::RunAndShoot_MoveToPatrolCurrentNode(void) if (MoveOnPathWithSquad()) { if (m_Enemy) { - m_eNextAnimMode = ANIM_MODE_PATH; - m_csNextAnimString = STRING_ANIM_RUNTO_INOPEN_SCR; - m_bNextForceStart = false; - - Vector delta; - Vector lookDir; - - delta = mTargetPos - EyePosition(); - lookDir = delta; - lookDir[2] += 16; - SetDesiredLookDir(lookDir); - - m_DesiredGunDir[0] = 360 - delta.toPitch(); - m_DesiredGunDir[1] = delta.toYaw(); - m_DesiredGunDir[2] = 0; - SetDesiredYaw(m_DesiredGunDir[1]); + DesiredAnimation(ANIM_MODE_PATH, STRING_ANIM_RUNTO_INOPEN_SCR); + AimAtTargetPos(); } else { - m_eNextAnimMode = ANIM_MODE_PATH; - m_csNextAnimString = STRING_ANIM_CROUCH_RUN_SCR; - m_bNextForceStart = false; + DesiredAnimation(ANIM_MODE_PATH, STRING_ANIM_CROUCH_RUN_SCR); FaceMotion(); } } else if (m_Enemy) { - Vector delta; - Vector lookDir; - - delta = mTargetPos - EyePosition(); - lookDir = delta; - lookDir[2] += 16; - SetDesiredLookDir(lookDir); - - m_DesiredGunDir[0] = 360 - delta.toPitch(); - m_DesiredGunDir[1] = delta.toYaw(); - m_DesiredGunDir[2] = 0; - SetDesiredYaw(m_DesiredGunDir[1]); + AimAtTargetPos(); Anim_Attack(); } else { Anim_Stand(); IdleLook(); } - if (!m_fMoveDoneRadiusSquared) { - return false; + if (m_fMoveDoneRadiusSquared) { + if (PathComplete()) { + return true; + } + + if (m_Path.HasCompleteLookahead() && !m_patrolCurrentNode->Next()) { + return VectorLength2DSquared(PathDelta()) <= m_fMoveDoneRadiusSquared; + } } - if (PathComplete()) { - return true; - } - - if (!m_Path.HasCompleteLookahead() || m_patrolCurrentNode->Next()) { - return false; - } - - if (VectorLength2DSquared(PathDelta()) > m_fMoveDoneRadiusSquared) { - return false; - } - - return true; + return false; } diff --git a/code/fgame/actor_runner.cpp b/code/fgame/actor_runner.cpp index 9b98b1c2..d0c906b9 100644 --- a/code/fgame/actor_runner.cpp +++ b/code/fgame/actor_runner.cpp @@ -76,6 +76,11 @@ void Actor::Think_Runner(void) } else if (bMoveInRadius) { ClearPatrolCurrentNode(); SetThinkIdle(THINK_IDLE); + // Added in OPM + // Not sure why it was not cleared originally. + // Once you reach your goal, there is no point + // in leaving it set to true + m_bScriptGoalValid = false; parm.movedone = true; Unregister(STRING_MOVEDONE); diff --git a/code/fgame/actor_turret.cpp b/code/fgame/actor_turret.cpp index c4e48fff..8db46a58 100644 --- a/code/fgame/actor_turret.cpp +++ b/code/fgame/actor_turret.cpp @@ -233,7 +233,13 @@ void Actor::Turret_BeginRetarget(void) SetEnemyPos(m_Enemy->origin); AimAtEnemyBehavior(); - TransitionState(ACTOR_STATE_TURRET_RETARGET_SUPPRESS, 0); + // Replaced in 2.0 + // Use the Retarget_Suppress state instead of the Retarget_Sniper_Node state + if (g_target_game >= target_game_e::TG_MOHTA) { + TransitionState(ACTOR_STATE_TURRET_RETARGET_SUPPRESS, 0); + } else { + TransitionState(ACTOR_STATE_TURRET_RETARGET_SNIPER_NODE, 0); + } } void Actor::Turret_NextRetarget(void) @@ -287,28 +293,31 @@ void Actor::Turret_SideStep(int iStepSize, vec3_t vDir) AimAtEnemyBehavior(); StrafeToAttack(iStepSize, vDir); - if (!PathExists() || PathComplete() || !PathAvoidsSquadMates()) { - StrafeToAttack(-iStepSize, vDir); + if (PathExists() && !PathComplete() && PathAvoidsSquadMates()) { + TransitionState(ACTOR_STATE_TURRET_REACQUIRE); + return; } + StrafeToAttack(-iStepSize, vDir); + if (PathExists() && !PathComplete() && PathAvoidsSquadMates()) { TransitionState(ACTOR_STATE_TURRET_REACQUIRE); - } else { - Turret_NextRetarget(); + return; } + + Turret_NextRetarget(); } void Actor::State_Turret_Shoot(void) { + assert(g_target_game > target_game_e::TG_MOH); + if (CanSeeEnemy(200) || FriendlyInLineOfFire(m_Enemy)) { TransitionState(ACTOR_STATE_TURRET_COMBAT); State_Turret_Combat(); return; } - AimAtTargetPos(); - Anim_Suppress(); - if (level.inttime >= m_iStateTime + 15000) { Turret_SelectState(); if (m_State == ACTOR_STATE_TURRET_SHOOT) { @@ -321,6 +330,8 @@ void Actor::State_Turret_Retarget_Suppress(void) { trace_t trace; + assert(g_target_game > target_game_e::TG_MOH); + if (rand() % 100 >= m_iSuppressChance) { AimAtEnemyBehavior(); Turret_NextRetarget(); diff --git a/code/fgame/actor_weaponless.cpp b/code/fgame/actor_weaponless.cpp index 1fc276ee..ebc03f8e 100644 --- a/code/fgame/actor_weaponless.cpp +++ b/code/fgame/actor_weaponless.cpp @@ -121,7 +121,7 @@ void Actor::Think_Weaponless(void) } else { Com_Printf("Think_Weaponless: invalid think state %i\n", m_State); char assertStr[16317] = {0}; - strcpy(assertStr, "\"invalid think state\"\n\tMessage: "); + Q_strncpyz(assertStr, "\"invalid think state\"\n\tMessage: ", sizeof(assertStr)); Q_strcat(assertStr, sizeof(assertStr), DumpCallTrace("thinkstate = %i", m_State)); assert(!assertStr); } diff --git a/code/fgame/actorenemy.cpp b/code/fgame/actorenemy.cpp index f339e680..86733706 100644 --- a/code/fgame/actorenemy.cpp +++ b/code/fgame/actorenemy.cpp @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -142,7 +142,8 @@ int ActorEnemy::UpdateThreat(Actor *pSelf) Square(305), Square(254), Square(200), - Square(137)}; + Square(137) + }; static int iWeaponThreat[7][5] = { {5, 3, 1, 1, 1}, {8, 6, 4, 2, 1}, @@ -165,7 +166,7 @@ int ActorEnemy::UpdateThreat(Actor *pSelf) } m_iThreat = 10000; - if (m_bVisible == true) { + if (m_bVisible) { m_iThreat = 10500; } @@ -321,7 +322,7 @@ void ActorEnemySet::FlagBadEnemy(Sentient *pEnemy) // Added in 2.0. // Set the reaction time - pActorEnemy->m_iNextEnemyTime = level.inttime + 5000; + pActorEnemy->m_iNextEnemyTime = level.inttime + 5000; pActorEnemy->m_fLastLookTime = level.time; pActorEnemy->m_fVisibility = 0.0; @@ -353,7 +354,7 @@ void ActorEnemySet::CheckEnemies(Actor *pSelf) pActorEnemy = &m_Enemies[i - 1]; if (!pActorEnemy->GetEnemy() || pActorEnemy->GetEnemy()->m_Team == pSelf->m_Team || pActorEnemy->GetEnemy()->IsDead() || level.inttime > pActorEnemy->m_iAddTime + 10000 - || pActorEnemy->GetEnemy()->m_iThreatBias == THREATBIAS_IGNOREME) { + || pActorEnemy->GetEnemy()->m_iThreatBias == THREATBIAS_IGNOREME || pActorEnemy->GetEnemy()->IsDisabled()) { m_Enemies.RemoveObjectAt(i); } else { i++; @@ -420,15 +421,14 @@ void ActorEnemySet::CheckEnemies(Actor *pSelf) m_iCurrentThreat = 0; fRangeSquared = 1e37f; - if (m_fCurrentVisibility >= 1) { - iThreat = 0; - + if (m_fCurrentVisibility >= 0.999f) { for (i = 1; i <= m_Enemies.NumObjects(); i++) { pActorEnemy = &m_Enemies.ObjectAt(i); pActorEnemy->UpdateThreat(pSelf); + iThreat = pActorEnemy->GetThreat(); - if (m_iCurrentThreat >= pActorEnemy->GetThreat()) { - if (m_iCheckCount != pActorEnemy->GetThreat()) { + if (m_iCurrentThreat >= iThreat) { + if (m_iCheckCount != iThreat) { continue; } @@ -437,12 +437,10 @@ void ActorEnemySet::CheckEnemies(Actor *pSelf) } } - iThreat = pActorEnemy->GetThreat(); - m_pCurrentEnemy = pActorEnemy->GetEnemy(); - fRangeSquared = pActorEnemy->m_fCurrentRangeSquared; + m_iCurrentThreat = pActorEnemy->GetThreat(); + m_pCurrentEnemy = pActorEnemy->GetEnemy(); + fRangeSquared = pActorEnemy->m_fCurrentRangeSquared; } - - m_iCurrentThreat = iThreat; } if ((!m_pCurrentEnemy || !m_pCurrentEnemy->m_bIsDisguised) && m_iCurrentThreat <= 0) { diff --git a/code/fgame/actorpath.cpp b/code/fgame/actorpath.cpp index 1be838e8..0c90e846 100644 --- a/code/fgame/actorpath.cpp +++ b/code/fgame/actorpath.cpp @@ -399,6 +399,7 @@ void ActorPath::UpdatePos(float *origin, float fNodeRadius) m_pathpos->point[2] = m_pathpos->point[2] * s + current_path->point[2] * t; current_path->dist *= s; + assert(current_path->dist > -1e+07 && current_path->dist < 1e+07); m_Side = true; } else { @@ -457,6 +458,7 @@ void ActorPath::Shorten(float fDistRemove) // This is a bug in mohaa as it can write past the end of the class instance //m_path->point[2] += m_path->dir[2] * -fDistRemove; m_path->dist -= fDistRemove; + assert(m_path->dist > -1e+07 && m_path->dist < 1e+07); } PathInfo *ActorPath::StartNode(void) const diff --git a/code/fgame/actorpath.h b/code/fgame/actorpath.h index 0ecb0019..ced7fcc6 100644 --- a/code/fgame/actorpath.h +++ b/code/fgame/actorpath.h @@ -105,8 +105,8 @@ public: inline void ActorPath::Archive(Archiver& arc) { - int pos; - int startpathpos; + int index; + int i; arc.ArchiveInteger(&m_pathlen); @@ -115,42 +115,40 @@ inline void ActorPath::Archive(Archiver& arc) m_path = new PathInfo[m_pathlen]; } - if (m_pathlen > 0) { - for (int i = 0; i < m_pathlen; i++) { - m_path->Archive(arc); - } + for (i = 0; i < m_pathlen; i++) { + m_path[i].Archive(arc); } if (!arc.Saving()) { - arc.ArchiveInteger(&pos); - if (pos == -1) { + arc.ArchiveInteger(&index); + if (index == -1) { m_pathpos = NULL; } else { - m_pathpos = &m_path[pos]; + m_pathpos = &m_path[index]; } - arc.ArchiveInteger(&startpathpos); - if (startpathpos == -1) { + arc.ArchiveInteger(&index); + if (index == -1) { m_startpathpos = NULL; } else { - m_startpathpos = &m_path[pos]; + m_startpathpos = &m_path[index]; } } else { if (m_pathpos) { - pos = m_pathpos - m_path; + index = m_pathpos - m_path; } else { - pos = -1; + index = -1; } - arc.ArchiveInteger(&pos); + arc.ArchiveInteger(&index); if (m_startpathpos) { - pos = m_startpathpos - m_path; + index = m_startpathpos - m_path; } else { - pos = -1; + index = -1; } - arc.ArchiveInteger(&pos); + arc.ArchiveInteger(&index); } } else if (arc.Loading()) { m_pathpos = 0; diff --git a/code/fgame/ammo.cpp b/code/fgame/ammo.cpp index 8a51a007..de9b8c53 100644 --- a/code/fgame/ammo.cpp +++ b/code/fgame/ammo.cpp @@ -30,13 +30,23 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "ammo.h" #include "player.h" +#include "g_phys.h" + +Event EV_AmmoEntity_PostSpawn +( + "ammoentity_postspawn", + EV_DEFAULT, + NULL, + NULL, + "Ammo Entity Post Spawn" +); CLASS_DECLARATION(Item, AmmoEntity, NULL) { - {NULL, NULL} + {&EV_AmmoEntity_PostSpawn, &AmmoEntity::EventPostSpawn}, + {NULL, NULL } }; AmmoEntity::AmmoEntity() - { if (LoadingSavegame) { // all data will be setup by the archive function @@ -44,13 +54,14 @@ AmmoEntity::AmmoEntity() } setName("UnknownAmmo"); amount = 0; + + PostEvent(EV_AmmoEntity_PostSpawn, EV_POSTSPAWN); } Item *AmmoEntity::ItemPickup(Entity *other, qboolean add_to_inventory) - { Sentient *player; - Weapon* pWeap; + Weapon *pWeap; if (!other->IsSubclassOfPlayer()) { return NULL; @@ -86,7 +97,11 @@ Item *AmmoEntity::ItemPickup(Entity *other, qboolean add_to_inventory) Unregister(STRING_PICKUP); // Tell the player about the ammo being picked - gi.SendServerCommand(other->edict - g_entities, "print \"" HUD_MESSAGE_YELLOW "%s\"", gi.LV_ConvertString(va("Got %d %s Rounds", amount, item_name.c_str()))); + gi.SendServerCommand( + other->edict - g_entities, + "print \"" HUD_MESSAGE_YELLOW "%s\"", + gi.LV_ConvertString(va("Got %d %s Rounds", amount, item_name.c_str())) + ); // Give the ammo to the player player->GiveAmmo(item_name, amount); @@ -100,6 +115,21 @@ Item *AmmoEntity::ItemPickup(Entity *other, qboolean add_to_inventory) return NULL; // This doesn't create any items } +void AmmoEntity::EventPostSpawn(Event *ev) +{ + vec3_t fullmins; + vec3_t fullmaxs; + + setMoveType(MOVETYPE_TOSS); + if (edict->tiki) { + gi.TIKI_CalculateBounds(edict->tiki, edict->s.scale, fullmins, fullmaxs); + setSize(fullmins, fullmaxs); + link(); + } + + droptofloor(256); +} + // This is the Class that is used to keep track of ammo in the player's inventory. // It is not an entit, just a name and an amount. @@ -108,7 +138,9 @@ CLASS_DECLARATION(Class, Ammo, NULL) { }; Ammo::Ammo() - + : amount(0) + , maxamount(0) + , name_index(0) { if (LoadingSavegame) { // all data will be setup by the archive function @@ -120,7 +152,6 @@ Ammo::Ammo() } void Ammo::setAmount(int a) - { amount = a; @@ -130,38 +161,32 @@ void Ammo::setAmount(int a) } int Ammo::getAmount(void) - { return amount; } void Ammo::setMaxAmount(int a) - { maxamount = a; } int Ammo::getMaxAmount(void) - { return maxamount; } void Ammo::setName(str n) - { name = n; name_index = gi.itemindex(name) + CS_WEAPONS; } str Ammo::getName(void) - { return name; } int Ammo::getIndex(void) - { return name_index; } diff --git a/code/fgame/ammo.h b/code/fgame/ammo.h index eb1a5ad7..24cb172c 100644 --- a/code/fgame/ammo.h +++ b/code/fgame/ammo.h @@ -22,8 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // ammo.h: Base class for all ammunition for entities derived from the Weapon class. -#ifndef __AMMO_H__ -#define __AMMO_H__ +#pragma once #include "g_local.h" #include "item.h" @@ -35,6 +34,7 @@ public: AmmoEntity(); Item *ItemPickup(Entity *other, qboolean add_to_inventory) override; + void EventPostSpawn(Event *ev); }; class Ammo : public Class @@ -61,13 +61,13 @@ public: }; inline void Ammo::Archive(Archiver& arc) - { Class::Archive(arc); arc.ArchiveInteger(&amount); arc.ArchiveInteger(&maxamount); arc.ArchiveString(&name); + arc.ArchiveInteger(&name_index); // // name_index not archived, because it is auto-generated by gi.itemindex // @@ -75,5 +75,3 @@ inline void Ammo::Archive(Archiver& arc) setName(name); } } - -#endif /* ammo.h */ diff --git a/code/fgame/animate.cpp b/code/fgame/animate.cpp index 56eef6c7..5855f110 100644 --- a/code/fgame/animate.cpp +++ b/code/fgame/animate.cpp @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -315,8 +315,8 @@ void Animate::NewAnim(int animnum, int slot, float weight) const tiki_singlecmd_t& single_cmd = cmds.cmds[ii]; int eventNum; - strcpy(cmdName, "_client_"); - strcpy(cmdName + 8, single_cmd.args[0]); + Q_strncpyz(cmdName, "_client_", longest + 8 + 1); + Q_strncpyz(cmdName + 8, single_cmd.args[0], longest + 1); eventNum = Event::FindEventNum(cmdName); @@ -386,8 +386,8 @@ void Animate::NewAnim(int animnum, int slot, float weight) const tiki_singlecmd_t& single_cmd = cmds.cmds[ii]; int eventNum; - strcpy(cmdName, "_client_"); - strcpy(cmdName + 8, single_cmd.args[0]); + Q_strncpyz(cmdName, "_client_", longestAllFrames + 8 + 1); + Q_strncpyz(cmdName + 8, single_cmd.args[0], longestAllFrames + 1); eventNum = Event::FindEventNum(cmdName); @@ -508,9 +508,8 @@ void Animate::StopAnimating(int slot) edict->s.frameInfo[slot].index = 1; } - edict->s.frameInfo[slot].weight = 0.0f; - animFlags[slot] = ANIM_LOOP | ANIM_NODELTA | ANIM_NOEXIT | ANIM_PAUSED; + SetWeight(slot, 0); animtimes[slot] = 0.0f; SlotChanged(slot); @@ -555,8 +554,8 @@ void Animate::DoExitCommands(int slot) const tiki_singlecmd_t& single_cmd = cmds.cmds[ii]; int eventNum; - strcpy(cmdName, "_client_"); - strcpy(cmdName + 8, single_cmd.args[0]); + Q_strncpyz(cmdName, "_client_", longest + 8 + 1); + Q_strncpyz(cmdName + 8, single_cmd.args[0], longest + 1); eventNum = Event::FindEventNum(cmdName); @@ -597,7 +596,7 @@ int Animate::NumAnims(void) const char *Animate::AnimName(int slot) { - return gi.Anim_NameForNum(edict->tiki, edict->s.frameInfo[slot].index); + return gi.Anim_NameForNum(edict->tiki, CurrentAnim(slot)); } void Animate::AnimFinished(int slot) diff --git a/code/fgame/archive.cpp b/code/fgame/archive.cpp index 99bc9b53..a151ee7e 100644 --- a/code/fgame/archive.cpp +++ b/code/fgame/archive.cpp @@ -66,7 +66,7 @@ static const char *typenames[] = { "object", "objectpointer", "safepointer", "eventpointer", "quaternion", "entity", "bool", "position", "size"}; -#define ArchiveHeader (*(int *)"MHAA") +#define ArchiveHeader (LittleLong(*(int *)"MHAA")) #define ArchiveVersion 14 // This must be changed any time the format changes! #define ArchiveInfo "OPENMOHAA Archive Version 14" // This must be changed any time the format changes! @@ -109,6 +109,11 @@ const char *ArchiveFile::Filename(void) qboolean ArchiveFile::Compress() { +#ifdef Q3_BIG_ENDIAN + // FIXME: Decompressing crashes on big-endian architectures + return false; +#endif + byte *tempbuf; size_t out_len; size_t tempbuf_len; @@ -208,6 +213,7 @@ qboolean ArchiveFile::OpenRead(const char *name) new_len = 0; Read(&new_len, sizeof(uint32_t)); + new_len = LittleLong(new_len); tempbuf = (byte *)gi.Malloc(new_len); if (g_lz77.Decompress(pos, length - 8, tempbuf, &iCSVGLength) || iCSVGLength != new_len) { @@ -309,7 +315,7 @@ void Archiver::FileError(const char *fmt, ...) char text[1024]; va_start(argptr, fmt); - vsprintf(text, fmt, argptr); + Q_vsnprintf(text, sizeof(text), fmt, argptr); va_end(argptr); fileerror = true; @@ -487,11 +493,43 @@ File Archive functions //#define ARCHIVE_USE_TYPES 1 -#define ARCHIVE(func, type) \ - void Archiver::Archive##func(type *v) \ - \ - { \ - ArchiveData(ARC_##func, v, sizeof(type)); \ +template +void ArchiveSwapValue(v* value) { + LittleSwap(value, sizeof(v)); +} + +template +void ArchiveSwapValue(v* value, size_t size) { + for (size_t i = 0; i < size; i++) { + LittleSwap(&value[i], sizeof(value[i])); + } +} + +template<> +void ArchiveSwapValue(Vector* value) { + for (int i = 0; i < 3; i++) { + (*value)[i] = LittleFloat((*value)[i]); + } +} + +template<> +void ArchiveSwapValue(Quat* value) { + for (int i = 0; i < 4; i++) { + (*value)[i] = LittleFloat((*value)[i]); + } +} + +#define ARCHIVE(func, type) \ + void Archiver::Archive##func(type *v) \ + { \ + if (archivemode == ARCHIVE_WRITE) { \ + type nv = *v; \ + ArchiveSwapValue(&nv); \ + ArchiveData(ARC_##func, &nv, sizeof(type)); \ + } else { \ + ArchiveData(ARC_##func, v, sizeof(type)); \ + ArchiveSwapValue(v); \ + } \ } ARCHIVE(Vector, Vector); @@ -525,17 +563,38 @@ void Archiver::ArchiveSvsTime(int *time) void Archiver::ArchiveVec2(vec2_t vec) { - ArchiveData(ARC_Vec2, vec, sizeof(vec2_t)); + if (archivemode == ARCHIVE_WRITE) { + vec2_t nv = { vec[0], vec[1] }; + ArchiveSwapValue(nv, 2); + ArchiveData(ARC_Vec2, nv, sizeof(vec2_t)); + } else { + ArchiveData(ARC_Vec2, vec, sizeof(vec2_t)); + ArchiveSwapValue(vec, 2); + } } void Archiver::ArchiveVec3(vec3_t vec) { - ArchiveData(ARC_Vec3, vec, sizeof(vec3_t)); + if (archivemode == ARCHIVE_WRITE) { + vec3_t nv = { vec[0], vec[1], vec[2]}; + ArchiveSwapValue(nv, 3); + ArchiveData(ARC_Vec3, nv, sizeof(vec3_t)); + } else { + ArchiveData(ARC_Vec3, vec, sizeof(vec3_t)); + ArchiveSwapValue(vec, 3); + } } void Archiver::ArchiveVec4(vec4_t vec) { - ArchiveData(ARC_Vec4, vec, sizeof(vec4_t)); + if (archivemode == ARCHIVE_WRITE) { + vec4_t nv = { vec[0], vec[1], vec[2], vec[3] }; + ArchiveSwapValue(nv, 4); + ArchiveData(ARC_Vec4, nv, sizeof(vec4_t)); + } else { + ArchiveData(ARC_Vec4, vec, sizeof(vec4_t)); + ArchiveSwapValue(vec, 4); + } } void Archiver::ArchiveObjectPointer(LightClass **ptr) @@ -544,7 +603,9 @@ void Archiver::ArchiveObjectPointer(LightClass **ptr) if (archivemode == ARCHIVE_READ) { pointer_fixup_t *fixup; + ArchiveData(ARC_ObjectPointer, &index, sizeof(index)); + index = LittleLong(index); // // see if the variable was NULL @@ -567,6 +628,8 @@ void Archiver::ArchiveObjectPointer(LightClass **ptr) } else { index = ARCHIVE_NULL_POINTER; } + + index = LittleLong(index); ArchiveData(ARC_ObjectPointer, &index, sizeof(index)); } } @@ -577,7 +640,9 @@ void Archiver::ArchiveObjectPointer(Class **ptr) if (archivemode == ARCHIVE_READ) { pointer_fixup_t *fixup; + ArchiveData(ARC_ObjectPointer, &index, sizeof(index)); + index = LittleLong(index); // // see if the variable was NULL @@ -600,6 +665,8 @@ void Archiver::ArchiveObjectPointer(Class **ptr) } else { index = ARCHIVE_NULL_POINTER; } + + index = LittleLong(index); ArchiveData(ARC_ObjectPointer, &index, sizeof(index)); } } @@ -612,6 +679,7 @@ void Archiver::ArchiveSafePointer(SafePtrBase *ptr) pointer_fixup_t *fixup; ArchiveData(ARC_SafePointer, &index, sizeof(index)); + index = LittleLong(index); // // see if the variable was NULL @@ -638,6 +706,7 @@ void Archiver::ArchiveSafePointer(SafePtrBase *ptr) } else { index = ARCHIVE_NULL_POINTER; } + index = LittleLong(index); ArchiveData(ARC_SafePointer, &index, sizeof(index)); } } @@ -646,12 +715,13 @@ void Archiver::ArchiveEventPointer(Event **ev) { int index; +#ifdef ARCHIVE_USE_TYPES + CheckType(ARC_EventPointer); +#endif + if (archivemode == ARCHIVE_READ) { #ifndef NDEBUG CheckRead(); -#endif -#ifdef ARCHIVE_USE_TYPES - CheckType(ARC_EventPointer); #endif ArchiveInteger(&index); @@ -673,10 +743,6 @@ void Archiver::ArchiveEventPointer(Event **ev) index = ARCHIVE_NULL_POINTER; } -#ifdef ARCHIVE_USE_TYPES - WriteType(ARC_EventPointer); -#endif - ArchiveInteger(&index); if (*ev) { (*ev)->Archive(*this); @@ -691,6 +757,10 @@ void Archiver::ArchiveRaw(void *data, size_t size) void Archiver::ArchiveString(str *string) { +#ifdef ARCHIVE_USE_TYPES + CheckType(ARC_String); +#endif + if (archivemode == ARCHIVE_READ) { fileSize_t s; char *data; @@ -698,10 +768,6 @@ void Archiver::ArchiveString(str *string) #ifndef NDEBUG CheckRead(); #endif -#ifdef ARCHIVE_USE_TYPES - CheckType(ARC_String); -#endif - if (!fileerror) { s = ReadSize(); if (!fileerror) { @@ -722,10 +788,7 @@ void Archiver::ArchiveString(str *string) #ifndef NDEBUG CheckWrite(); #endif -#ifdef ARCHIVE_USE_TYPES - WriteType(ARC_String); -#endif - WriteSize((fileSize_t)string->length()); + WriteSize(string->length()); archivefile.Write(string->c_str(), string->length()); } } @@ -938,6 +1001,11 @@ void Archiver::ArchiveObject(Class *obj) } } +void Archiver::ArchiveObject(SafePtrBase* obj) +{ + ArchiveSafePointer(obj); +} + void Archiver::ArchiveObjectPosition(LightClass *obj) { int index = 0; @@ -1014,6 +1082,7 @@ fileSize_t Archiver::ReadSize(void) s = 0; if (!fileerror) { archivefile.Read(&s, sizeof(s)); + LittleSwap(&s, sizeof(s)); } return s; @@ -1034,6 +1103,7 @@ void Archiver::CheckSize(int type, fileSize_t size) void Archiver::WriteSize(fileSize_t size) { + LittleSwap(&size, sizeof(size)); archivefile.Write(&size, sizeof(fileSize_t)); } @@ -1043,6 +1113,7 @@ int Archiver::ReadType(void) if (!fileerror) { archivefile.Read(&t, sizeof(t)); + t = LittleLong(t); return t; } @@ -1052,7 +1123,8 @@ int Archiver::ReadType(void) void Archiver::WriteType(int type) { - archivefile.Write(&type, sizeof(type)); + int nt = LittleLong(type); + archivefile.Write(&nt, sizeof(nt)); } void Archiver::CheckType(int type) @@ -1061,29 +1133,34 @@ void Archiver::CheckType(int type) assert((type >= 0) && (type < ARC_NUMTYPES)); - if (!fileerror) { - t = ReadType(); - if (t != type) { - if (t < ARC_NUMTYPES) { - FileError("Expecting %s, Should be %s", typenames[type], typenames[t]); - assert(0); - } else { - FileError("Expecting %s, Should be %i (Unknown type)", typenames[type], t); + if (archivemode == ARCHIVE_READ) { + if (!fileerror) { + t = ReadType(); + if (t != type) { + if (t < ARC_NUMTYPES) { + FileError("Expecting %s, Should be %s", typenames[type], typenames[t]); + assert(0); + } + else { + FileError("Expecting %s, Should be %i (Unknown type)", typenames[type], t); + } } } + } else { + WriteType(type); } } void Archiver::ArchiveData(int type, void *data, size_t size) { +#ifdef ARCHIVE_USE_TYPES + CheckType(type); +#endif + if (archivemode == ARCHIVE_READ) { #ifndef NDEBUG CheckRead(); #endif -#ifdef ARCHIVE_USE_TYPES - CheckType(type); -#endif - if (!fileerror && size) { m_iNumBytesIO += size; archivefile.Read(data, size); @@ -1092,9 +1169,6 @@ void Archiver::ArchiveData(int type, void *data, size_t size) #ifndef NDEBUG CheckWrite(); #endif -#ifdef ARCHIVE_USE_TYPES - WriteType(type); -#endif if (!fileerror && size) { m_iNumBytesIO += size; diff --git a/code/fgame/archive.h b/code/fgame/archive.h index c2c7b120..0e584fd8 100644 --- a/code/fgame/archive.h +++ b/code/fgame/archive.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2025 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -22,8 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // archive.h: OpenMoHAA Archiver -#ifndef __ARCHIVE_H__ -#define __ARCHIVE_H__ +#pragma once #include "g_local.h" #include "class.h" @@ -154,6 +153,7 @@ public: void ArchiveRaw(void *data, size_t size); void ArchiveObject(Class *obj); + void ArchiveObject(SafePtrBase *obj); // Added in OPM qboolean ObjectPositionExists(void *obj); @@ -167,23 +167,29 @@ public: template inline void Container::Archive(Archiver& arc, void (*ArchiveFunc)(Archiver& arc, Type *obj)) { - int num; - int i; + Type *obj; + int num; + int i; if (arc.Loading()) { arc.ArchiveInteger(&num); Resize(num); - } else { - num = numobjects; - arc.ArchiveInteger(&num); - } - for (i = 1; i <= num; i++) { if (num > numobjects) { numobjects = num; } - ArchiveFunc(arc, &objlist[i - 1]); + for (i = 0; i < num; i++) { + obj = new (objlist + i) Type(); + ArchiveFunc(arc, obj); + } + } else { + num = numobjects; + arc.ArchiveInteger(&num); + + for (i = 0; i < num; i++) { + ArchiveFunc(arc, &objlist[i]); + } } } @@ -287,7 +293,7 @@ void con_set::Archive(Archiver& arc) if (arc.Loading()) { if (tableLength != 1) { - table = new Entry *[tableLength](); + table = new (NewTable(tableLength)) Entry *[tableLength](); memset(table, 0, tableLength * sizeof(Entry *)); } @@ -303,7 +309,7 @@ void con_set::Archive(Archiver& arc) defaultEntry = e; } else { -#ifndef NDEBUG +# ifndef NDEBUG int total; total = 0; @@ -316,13 +322,13 @@ void con_set::Archive(Archiver& arc) } // it must match the number of elements assert(total == count); -#else +# else for (i = 0; i < tableLength; i++) { for (e = table[i]; e != NULL; e = e->next) { e->Archive(arc); } } -#endif +# endif } } @@ -342,5 +348,3 @@ void con_map::Archive(Archiver& arc) arc.ArchiveInteger(&tempInt); \ (thing) = (type)tempInt; \ } - -#endif // __ARCHIVE_H__ diff --git a/code/fgame/armor.h b/code/fgame/armor.h index e1b97a5c..ee2f838e 100644 --- a/code/fgame/armor.h +++ b/code/fgame/armor.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -22,8 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // armor.h: Standard armor that prevents a percentage of damage per hit. -#ifndef __ARMOR_H__ -#define __ARMOR_H__ +#pragma once #include "weapon.h" @@ -40,5 +39,3 @@ class Armor : public Item qboolean Pickupable( Entity *other ) override; }; - -#endif /* armor.h */ diff --git a/code/fgame/barrels.cpp b/code/fgame/barrels.cpp index e23a0096..7d85a04b 100644 --- a/code/fgame/barrels.cpp +++ b/code/fgame/barrels.cpp @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -30,7 +30,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA /***************************************************************************** /*QUAKED func_barrel (0 0.25 0.5) ? INDESTRUCTABLE Brush model barrel object -Bashing only makes thunk or gong sounds (depending on wether it's full or not) +Bashing only makes thunk or gong sounds (depending on whether it's full or not) Bullets and explosions effects are dependant apon the type of barrel. "barreltype" sets the type of barrel that it is. Valid settings are: - "water" makes the barrel be filled with water. @@ -45,562 +45,444 @@ Does nothing special at all. It's just a poor empty barrel. aww :( ******************************************************************************/ Event EV_Barrel_Think - ( +( "_barrel_think", EV_DEFAULT, NULL, NULL, "think function for a barrel." - ); +); Event EV_Barrel_Setup - ( +( "_barrel_setup", EV_DEFAULT, NULL, NULL, "Does the post spawn setup of the barrel" - ); +); Event EV_Barrel_SetType - ( +( "barreltype", EV_DEFAULT, "s", "type", "Sets the barrel's type" - ); +); -CLASS_DECLARATION( Entity, BarrelObject, "func_barrel" ) -{ - { &EV_Barrel_Setup, &BarrelObject::BarrelSetup }, - { &EV_Barrel_Think, &BarrelObject::BarrelThink }, - { &EV_Barrel_SetType, &BarrelObject::BarrelSetType }, - { &EV_Damage, &BarrelObject::BarrelDamaged }, - { &EV_Killed, &BarrelObject::BarrelKilled }, - { NULL, NULL } +CLASS_DECLARATION(Entity, BarrelObject, "func_barrel") { + {&EV_Barrel_Setup, &BarrelObject::BarrelSetup }, + {&EV_Barrel_Think, &BarrelObject::BarrelThink }, + {&EV_Barrel_SetType, &BarrelObject::BarrelSetType}, + {&EV_Damage, &BarrelObject::BarrelDamaged}, + {&EV_Killed, &BarrelObject::BarrelKilled }, + {NULL, NULL } }; BarrelObject::BarrelObject() { + AddWaitTill(STRING_DEATH); - AddWaitTill(STRING_DEATH); + if (LoadingSavegame) { + return; + } - if (LoadingSavegame) - { - return; - } + edict->s.eType = ET_GENERAL; - edict->s.eType = ET_GENERAL; + m_iBarrelType = 0; + m_fFluidAmount = 0; + m_fHeightFluid = 0; - m_iBarrelType = 0; - m_fFluidAmount = 0; - m_fHeightFluid = 0; + for (int i = 0; i < MAX_BARREL_LEAKS; i++) { + m_bLeaksActive[i] = 0; + } - for( int i = 0; i < MAX_BARREL_LEAKS; i++ ) - { - m_bLeaksActive[ i ] = 0; - } + m_fDamageSoundTime = 0; + mass = 500; + max_health = 75; + health = 75; + deadflag = DEAD_NO; + takedamage = DAMAGE_YES; + m_vJitterAngles = vec_zero; - m_fDamageSoundTime = 0; - mass = 500; - max_health = 75; - health = 75; - deadflag = DEAD_NO; - takedamage = DAMAGE_YES; - m_vJitterAngles = vec_zero; - - PostEvent( EV_Barrel_Setup, EV_POSTSPAWN ); + PostEvent(EV_Barrel_Setup, EV_POSTSPAWN); } -int BarrelObject::PickBarrelLeak - ( - void - ) +int BarrelObject::PickBarrelLeak(void) { - int iHighest; - float fHighestHeight; + int iHighest; + float fHighestHeight; - for( int i = 0; i < MAX_BARREL_LEAKS; i++ ) - { - if( !m_bLeaksActive[ i ] ) { - return i; - } - } + for (int i = 0; i < MAX_BARREL_LEAKS; i++) { + if (!m_bLeaksActive[i]) { + return i; + } + } - fHighestHeight = m_vLeaks[ 0 ][ 2 ]; - iHighest = 0; + fHighestHeight = m_vLeaks[0][2]; + iHighest = 0; - for( int i = 1; i < MAX_BARREL_LEAKS; i++ ) - { - if( m_vLeaks[ 0 ][ 2 ] > fHighestHeight ) - { - fHighestHeight = m_vLeaks[ 0 ][ 2 ]; - iHighest = i; - } - } + for (int i = 1; i < MAX_BARREL_LEAKS; i++) { + if (m_vLeaks[0][2] > fHighestHeight) { + fHighestHeight = m_vLeaks[0][2]; + iHighest = i; + } + } - return iHighest; + return iHighest; } -void BarrelObject::BarrelSetup - ( - Event *ev - ) +void BarrelObject::BarrelSetup(Event *ev) { - setMoveType( MOVETYPE_PUSH ); - setSolidType( SOLID_BSP ); + setMoveType(MOVETYPE_PUSH); + setSolidType(SOLID_BSP); - m_vStartAngles = angles; - m_fJitterScale = 64.0f / size[ 2 ]; + m_vStartAngles = angles; + m_fJitterScale = 64.0f / size[2]; - m_fFluidAmount = size[ 0 ] * size[ 1 ] * size[ 2 ] / 150.0f; - m_fHeightFluid = m_fFluidAmount / size[ 2 ]; + m_fFluidAmount = size[0] * size[1] * size[2] / 150.0f; + m_fHeightFluid = m_fFluidAmount / size[2]; - // Position the barrel correctly - CheckGround(); + // Position the barrel correctly + CheckGround(); } -void BarrelObject::BarrelSetType - ( - Event *ev - ) +void BarrelObject::BarrelSetType(Event *ev) { - str sType = ev->GetString( 1 ); + str sType = ev->GetString(1); - if( !sType.icmp( "oil" ) ) - { - health = 75; - m_iBarrelType = BARREL_OIL; + if (!sType.icmp("oil")) { + health = 75; + m_iBarrelType = BARREL_OIL; - CacheResource( "models/fx/barrel_empty_destroyed.tik" ); - CacheResource( "models/fx/barrel_oil_destroyed.tik" ); - } - else if( !sType.icmp( "water" ) ) - { - health = 75; - m_iBarrelType = BARREL_WATER; + CacheResource("models/fx/barrel_empty_destroyed.tik"); + CacheResource("models/fx/barrel_oil_destroyed.tik"); + } else if (!sType.icmp("water")) { + health = 75; + m_iBarrelType = BARREL_WATER; - CacheResource( "models/fx/barrel_empty_destroyed.tik" ); - CacheResource( "models/fx/barrel_water_destroyed.tik" ); - } - else if( !sType.icmp( "gas" ) ) - { - spawnflags &= ~BARREL_INDESTRUCTABLE; - health = 75; - m_iBarrelType = BARREL_GAS; + CacheResource("models/fx/barrel_empty_destroyed.tik"); + CacheResource("models/fx/barrel_water_destroyed.tik"); + } else if (!sType.icmp("gas")) { + spawnflags &= ~BARREL_INDESTRUCTABLE; + health = 75; + m_iBarrelType = BARREL_GAS; - CacheResource( "models/fx/barrel_gas_destroyed.tik" ); - } - else - { - health = 75; - m_iBarrelType = BARREL_EMPTY; + CacheResource("models/fx/barrel_gas_destroyed.tik"); + } else { + health = 75; + m_iBarrelType = BARREL_EMPTY; - CacheResource( "models/fx/barrel_empty_destroyed.tik" ); - } + CacheResource("models/fx/barrel_empty_destroyed.tik"); + } - max_health = health; + max_health = health; } -void BarrelObject::BarrelThink - ( - Event *ev - ) +void BarrelObject::BarrelThink(Event *ev) { - int i; - int iBiggestLeak; - float fFluidTop; + int i; + int iBiggestLeak; + float fFluidTop; - iBiggestLeak = 0; + iBiggestLeak = 0; - fFluidTop = m_fFluidAmount / m_fHeightFluid + ( mins[ 2 ] + origin[ 2 ] ); - for( i = 0; i < MAX_BARREL_LEAKS; i++ ) - { - if( !m_bLeaksActive[ i ] ) { - continue; - } + fFluidTop = m_fFluidAmount / m_fHeightFluid + (mins[2] + origin[2]); + for (i = 0; i < MAX_BARREL_LEAKS; i++) { + if (!m_bLeaksActive[i]) { + continue; + } - // Send infos to clients - if( m_vLeaks[ i ][ 2 ] <= fFluidTop ) - { - gi.SetBroadcastVisible( m_vLeaks[ i ], m_vLeaks[ i ] ); + // Send infos to clients + if (m_vLeaks[i][2] > fFluidTop) { + gi.SetBroadcastVisible(m_vLeaks[i], m_vLeaks[i]); - if( m_vLeaks[ i ][ 2 ] <= fFluidTop - 1.3f ) - { - if( m_vLeaks[ i ][ 2 ] <= fFluidTop - 3.0f ) - { - // big leak + if (m_iBarrelType == BARREL_OIL) { + gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_MAKE_EFFECT_3)); + } else { + gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_MAKE_EFFECT_7)); + } - if( m_iBarrelType == BARREL_OIL ) - { - gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_MAKE_EFFECT_1)); - } - else - { - gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_MAKE_EFFECT_5)); - } + gi.MSG_WriteCoord(m_vLeaks[i][0]); + gi.MSG_WriteCoord(m_vLeaks[i][1]); + gi.MSG_WriteCoord(m_vLeaks[i][2]); + gi.MSG_WriteDir(m_vLeakNorms[i]); + gi.MSG_EndCGM(); - m_fFluidAmount -= 1.0f; - iBiggestLeak |= 4; - } - else - { - // medium leak + m_bLeaksActive[i] = qfalse; + } else { + gi.SetBroadcastVisible(m_vLeaks[i], m_vLeaks[i]); - if( m_iBarrelType == BARREL_OIL ) - { - gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_MAKE_EFFECT_2)); - } - else - { - gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_MAKE_EFFECT_6)); - } + if (m_vLeaks[i][2] > fFluidTop - 1.3f) { + // small leak - m_fFluidAmount -= 0.75f; - iBiggestLeak |= 2; - } - } - else - { - // small leak + if (m_iBarrelType == BARREL_OIL) { + gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_MAKE_EFFECT_3)); + } else { + gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_MAKE_EFFECT_7)); + } - if( m_iBarrelType == BARREL_OIL ) - { - gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_MAKE_EFFECT_3)); - } - else - { - gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_MAKE_EFFECT_7)); - } + m_fFluidAmount -= 0.5f; + iBiggestLeak |= 1; + } else if (m_vLeaks[i][2] > fFluidTop - 3.0f) { + // medium leak - m_fFluidAmount -= 0.5f; - iBiggestLeak |= 1; - } + if (m_iBarrelType == BARREL_OIL) { + gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_MAKE_EFFECT_2)); + } else { + gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_MAKE_EFFECT_6)); + } - gi.MSG_WriteCoord( m_vLeaks[ i ][ 0 ] ); - gi.MSG_WriteCoord( m_vLeaks[ i ][ 1 ] ); - gi.MSG_WriteCoord( m_vLeaks[ i ][ 2 ] ); - gi.MSG_WriteDir( m_vLeakNorms[ i ] ); - gi.MSG_EndCGM(); - } - else - { - gi.SetBroadcastVisible( m_vLeaks[ i ], m_vLeaks[ i ] ); + m_fFluidAmount -= 0.75f; + iBiggestLeak |= 2; + } else { + // big leak - if( m_iBarrelType == BARREL_OIL ) - { - gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_MAKE_EFFECT_3)); - } - else - { - gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_MAKE_EFFECT_7)); - } + if (m_iBarrelType == BARREL_OIL) { + gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_MAKE_EFFECT_1)); + } else { + gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_MAKE_EFFECT_5)); + } - gi.MSG_WriteCoord( m_vLeaks[ i ][ 0 ] ); - gi.MSG_WriteCoord( m_vLeaks[ i ][ 1 ] ); - gi.MSG_WriteCoord( m_vLeaks[ i ][ 2 ] ); - gi.MSG_WriteDir( m_vLeakNorms[ i ] ); - gi.MSG_EndCGM(); + m_fFluidAmount -= 1.0f; + iBiggestLeak |= 4; + } - m_bLeaksActive[ i ] = qfalse; - } - } + gi.MSG_WriteCoord(m_vLeaks[i][0]); + gi.MSG_WriteCoord(m_vLeaks[i][1]); + gi.MSG_WriteCoord(m_vLeaks[i][2]); + gi.MSG_WriteDir(m_vLeakNorms[i]); + gi.MSG_EndCGM(); + } + } - if( m_vJitterAngles[ 0 ] == 0.0f && m_vJitterAngles[ 2 ] == 0.0f ) - { - if( !VectorCompare( angles, m_vStartAngles ) ) - { - setAngles( m_vStartAngles ); - } - } + if (m_vJitterAngles[0] == 0.0f && m_vJitterAngles[2] == 0.0f) { + if (!VectorCompare(angles, m_vStartAngles)) { + setAngles(m_vStartAngles); + } + } + else { + Vector ang; - setAngles( Vector( m_vStartAngles[ 0 ] + m_vJitterAngles[ 0 ], m_vStartAngles[ 1 ], m_vStartAngles[ 2 ] + m_vJitterAngles[ 2 ] ) ); + ang = m_vStartAngles; + ang[0] += m_vJitterAngles[0]; + ang[2] += m_vJitterAngles[2]; + setAngles(ang); - if( m_vJitterAngles[ 0 ] > 0.0f ) - { - m_vJitterAngles[ 0 ] -= 1.f / 3.f * m_fJitterScale; + if (m_vJitterAngles[0] < 0) { + m_vJitterAngles[0] += 1.f / 3.f * m_fJitterScale; - if( m_vJitterAngles[ 0 ] > 0.0f ) - { - m_vJitterAngles[ 0 ] = 0.0f; - } - } - else if( m_vJitterAngles[ 0 ] < 0.0f ) - { - m_vJitterAngles[ 0 ] += 1.f / 3.f * m_fJitterScale; + if (m_vJitterAngles[0] > 0) { + m_vJitterAngles[0] = 0; + } + } else if (m_vJitterAngles[0] > 0) { + m_vJitterAngles[0] -= 1.f / 3.f * m_fJitterScale; - if( m_vJitterAngles[ 0 ] < 0.0f ) - { - m_vJitterAngles[ 0 ] = 0.0f; - } - } + if (m_vJitterAngles[0] < 0) { + m_vJitterAngles[0] = 0; + } + } - m_vJitterAngles[ 0 ] = -m_vJitterAngles[ 0 ]; + m_vJitterAngles[0] = -m_vJitterAngles[0]; - if( m_vJitterAngles[ 2 ] > 0.0f ) - { - m_vJitterAngles[ 2 ] -= 1.f / 3.f * m_fJitterScale; + if (m_vJitterAngles[2] < 0) { + m_vJitterAngles[2] += 1.f / 3.f * m_fJitterScale; - if( m_vJitterAngles[ 2 ] > 0.0f ) - { - m_vJitterAngles[ 2 ] = 0.0f; - } - } - else if( m_vJitterAngles[ 2 ] < 0.0f ) - { - m_vJitterAngles[ 2 ] += 1.f / 3.f * m_fJitterScale; + if (m_vJitterAngles[2] > 0) { + m_vJitterAngles[2] = 0; + } + } else if (m_vJitterAngles[2] > 0) { + m_vJitterAngles[2] -= 1.f / 3.f * m_fJitterScale; - if( m_vJitterAngles[ 2 ] < 0.0f ) - { - m_vJitterAngles[ 2 ] = 0.0f; - } - } + if (m_vJitterAngles[2] < 0) { + m_vJitterAngles[2] = 0; + } + } - m_vJitterAngles[ 2 ] = -m_vJitterAngles[ 2 ]; + m_vJitterAngles[2] = -m_vJitterAngles[2]; + } - // Check for at least one active leak to play a sound - for( i = 0; i < MAX_BARREL_LEAKS; i++ ) - { - if( m_bLeaksActive[ i ] ) { - break; - } - } + // Check for at least one active leak to play a sound + for (i = 0; i < MAX_BARREL_LEAKS; i++) { + if (m_bLeaksActive[i]) { + break; + } + } - // Play a leak sound - if( i != MAX_BARREL_LEAKS && iBiggestLeak ) - { - if( !( iBiggestLeak & 4 ) ) - { - if( iBiggestLeak & 2 ) - { - // medium leak - LoopSound( "liquid_leak", 0.60f, -1.0f, -1.0f, 0.90f ); - } - else - { - // small leak - LoopSound( "liquid_leak", 0.30f, -1.0f, -1.0f, 0.80f ); - } - } - else - { - // big leak - LoopSound( "liquid_leak", 1.0f, -1.0f, -1.0f, 1.0f ); - } - } + // Play a leak sound + if (i != MAX_BARREL_LEAKS && iBiggestLeak) { + if (iBiggestLeak & 4) { + // big leak + LoopSound("liquid_leak", 1, -1, -1, 1); + } else if (iBiggestLeak & 2) { + // medium leak + LoopSound("liquid_leak", 0.6, -1, -1, 0.9); + } else { + // small leak + LoopSound("liquid_leak", 0.3, -1, -1, 0.8); + } + } - if( i == MAX_BARREL_LEAKS ) { - StopLoopSound(); - } + if (i == MAX_BARREL_LEAKS) { + StopLoopSound(); + } - if( m_vJitterAngles[ 0 ] || m_vJitterAngles[ 2 ] || i < MAX_BARREL_LEAKS ) - { - m_fLastEffectTime += 0.075f; + if (m_vJitterAngles[0] || m_vJitterAngles[2] || i < MAX_BARREL_LEAKS) { + m_fLastEffectTime += 0.075f; - if( level.time >= m_fLastEffectTime ) - { - m_fLastEffectTime = level.time + 0.075f; - } + if (m_fLastEffectTime <= level.time) { + m_fLastEffectTime = level.time + 0.075f; + } - PostEvent( EV_Barrel_Think, m_fLastEffectTime - level.time ); - } + PostEvent(EV_Barrel_Think, m_fLastEffectTime - level.time); + } } -void BarrelObject::BarrelDamaged - ( - Event *ev - ) +void BarrelObject::BarrelDamaged(Event *ev) { - Vector vDir; - Vector vForward; - Vector vRight; - int iDamage; - int iMeansOfDeath; - Vector vHitPos; - Vector vHitDirection; - Vector vHitNormal; + Vector vDir; + Vector vForward; + Vector vRight; + int iDamage; + int iMeansOfDeath; + Vector vHitPos; + Vector vHitDirection; + Vector vHitNormal; - if( !takedamage ) - { - return; - } + if (!takedamage) { + return; + } - iDamage = ev->GetInteger( 2 ); - iMeansOfDeath = ev->GetInteger( 9 ); - vHitPos = ev->GetVector( 4 ); - vHitDirection = ev->GetVector( 5 ); - vHitNormal = ev->GetVector( 6 ); + iDamage = ev->GetInteger(2); + iMeansOfDeath = ev->GetInteger(9); + vHitPos = ev->GetVector(4); + vHitDirection = ev->GetVector(5); + vHitNormal = ev->GetVector(6); - vDir = ( vHitDirection - vHitNormal ) * 0.5f; - AngleVectors( angles, vForward, vRight, NULL ); + vDir = (vHitDirection - vHitNormal) * 0.5f; + AngleVectors(angles, vForward, vRight, NULL); - m_vJitterAngles[ 0 ] += DotProduct( vDir, vForward ) * m_fJitterScale * 0.0275f * ( float )iDamage; - m_vJitterAngles[ 2 ] += DotProduct( vDir, vRight ) * m_fJitterScale * 0.0275f * ( float )iDamage; + m_vJitterAngles[0] += DotProduct(vDir, vForward) * m_fJitterScale * 0.0275f * (float)iDamage; + m_vJitterAngles[2] += DotProduct(vDir, vRight) * m_fJitterScale * 0.0275f * (float)iDamage; - if( m_vJitterAngles[ 0 ] > m_fJitterScale * 1.5f ) - { - m_vJitterAngles[ 0 ] = m_fJitterScale * 1.5f; - } - else if( m_vJitterAngles[ 0 ] < -( m_fJitterScale * 1.5f ) ) - { - m_vJitterAngles[ 0 ] = -( m_fJitterScale * 1.5f ); - } + if (m_vJitterAngles[0] > m_fJitterScale * 1.5f) { + m_vJitterAngles[0] = m_fJitterScale * 1.5f; + } else if (m_vJitterAngles[0] < -(m_fJitterScale * 1.5f)) { + m_vJitterAngles[0] = -(m_fJitterScale * 1.5f); + } - if( m_vJitterAngles[ 2 ] > m_fJitterScale * 1.5f ) - { - m_vJitterAngles[ 2 ] = m_fJitterScale * 1.5f; - } - else if( m_vJitterAngles[ 2 ] < -( m_fJitterScale * 1.5f ) ) - { - m_vJitterAngles[ 2 ] = -( m_fJitterScale * 1.5f ); - } + if (m_vJitterAngles[2] > m_fJitterScale * 1.5f) { + m_vJitterAngles[2] = m_fJitterScale * 1.5f; + } else if (m_vJitterAngles[2] < -(m_fJitterScale * 1.5f)) { + m_vJitterAngles[2] = -(m_fJitterScale * 1.5f); + } - if( !( spawnflags & BARREL_INDESTRUCTABLE ) ) - { - if( ( iMeansOfDeath == MOD_VEHICLE || iMeansOfDeath == MOD_ROCKET || - iMeansOfDeath == MOD_GRENADE || iMeansOfDeath == MOD_EXPLODEWALL || - iMeansOfDeath == MOD_EXPLOSION || m_iBarrelType == BARREL_GAS ) && - iMeansOfDeath != MOD_BASH - ) - { - if( iDamage >= health ) - { - PostEvent( EV_Killed, 0.01f ); - takedamage = DAMAGE_NO; - return; - } + if (!(spawnflags & BARREL_INDESTRUCTABLE)) { + if ((iMeansOfDeath == MOD_VEHICLE || iMeansOfDeath == MOD_ROCKET || iMeansOfDeath == MOD_GRENADE + || iMeansOfDeath == MOD_EXPLODEWALL || iMeansOfDeath == MOD_EXPLOSION || m_iBarrelType == BARREL_GAS) + && iMeansOfDeath != MOD_BASH) { + if (iDamage >= health) { + PostEvent(EV_Killed, 0.01f); + takedamage = DAMAGE_NO; + return; + } - if( m_iBarrelType == BARREL_GAS ) - { - iDamage /= 2; + if (m_iBarrelType == BARREL_GAS) { + iDamage /= 2; - health -= iDamage; - if( health < 1.0f ) - health = 1.0f; - } - } - } + health -= iDamage; + if (health < 1.0f) { + health = 1.0f; + } + } + } + } - if( !EventPending( EV_Barrel_Think ) ) - { - m_fLastEffectTime = level.time - 0.075f; - ProcessEvent( EV_Barrel_Think ); - } + if (!EventPending(EV_Barrel_Think)) { + m_fLastEffectTime = level.time - 0.075f; + ProcessEvent(EV_Barrel_Think); + } - if( m_iBarrelType <= BARREL_WATER ) - { - int index = PickBarrelLeak(); + if (m_iBarrelType <= BARREL_WATER) { + int index = PickBarrelLeak(); - if( vHitPos[ 2 ] <= m_fFluidAmount / m_fHeightFluid + origin[ 2 ] + mins[ 2 ] ) - { - m_bLeaksActive[ index ] = qtrue; - m_vLeaks[ index ] = vHitPos; - m_vLeakNorms[ index ] = vHitNormal; + if (vHitPos[2] <= m_fFluidAmount / m_fHeightFluid + origin[2] + mins[2]) { + m_bLeaksActive[index] = qtrue; + m_vLeaks[index] = vHitPos; + m_vLeakNorms[index] = vHitNormal; - gi.SetBroadcastVisible( vHitPos, vHitPos ); + gi.SetBroadcastVisible(vHitPos, vHitPos); - if( m_iBarrelType == BARREL_OIL ) - gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_MAKE_EFFECT_4)); - else - gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_MAKE_EFFECT_8)); - } - else - { - gi.SetBroadcastVisible( vHitPos, vHitPos ); + if (m_iBarrelType == BARREL_OIL) { + gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_MAKE_EFFECT_4)); + } else { + gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_MAKE_EFFECT_8)); + } + } else { + gi.SetBroadcastVisible(vHitPos, vHitPos); - if( m_iBarrelType == BARREL_OIL ) - gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_MAKE_EFFECT_3)); - else - gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_MAKE_EFFECT_7)); - } + if (m_iBarrelType == BARREL_OIL) { + gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_MAKE_EFFECT_3)); + } else { + gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_MAKE_EFFECT_7)); + } + } - gi.MSG_WriteCoord( vHitPos[ 0 ] ); - gi.MSG_WriteCoord( vHitPos[ 1 ] ); - gi.MSG_WriteCoord( vHitPos[ 2 ] ); - gi.MSG_WriteDir( vHitNormal ); - gi.MSG_EndCGM(); - } + gi.MSG_WriteCoord(vHitPos[0]); + gi.MSG_WriteCoord(vHitPos[1]); + gi.MSG_WriteCoord(vHitPos[2]); + gi.MSG_WriteDir(vHitNormal); + gi.MSG_EndCGM(); + } } -void BarrelObject::BarrelKilled - ( - Event *ev - ) +void BarrelObject::BarrelKilled(Event *ev) { - float fFluidTop; - Vector vPos; - str sModel; + float fFluidTop; + Vector vPos; + str sModel; - setSolidType( SOLID_NOT ); - PostEvent( EV_Remove, 0.05f ); + setSolidType(SOLID_NOT); + PostEvent(EV_Remove, 0.05f); - vPos[ 2 ] = ( mins[ 2 ] + origin[ 2 ] ); - fFluidTop = m_fFluidAmount / m_fHeightFluid + vPos[ 2 ]; + vPos[2] = (mins[2] + origin[2]); + fFluidTop = m_fFluidAmount / m_fHeightFluid + vPos[2]; - if( m_iBarrelType == BARREL_GAS ) - { - RadiusDamage( - centroid, - this, - this, - 200, - this, - MOD_EXPLOSION, - 350, - 24 ); + if (m_iBarrelType == BARREL_GAS) { + RadiusDamage(centroid, this, this, 200, this, MOD_EXPLOSION, 350, 24); - sModel = "models/fx/barrel_gas_destroyed.tik"; - } - else if( m_iBarrelType == BARREL_WATER ) - { - if( vPos[ 2 ] + 0.25f * maxs[ 2 ] <= fFluidTop ) - { - sModel = "models/fx/barrel_water_destroyed.tik"; - } - else - { - sModel = "models/fx/barrel_empty_destroyed.tik"; - } - } - else if( m_iBarrelType == BARREL_OIL ) - { - if( vPos[ 2 ] + 0.25f * maxs[ 2 ] > fFluidTop ) - { - sModel = "models/fx/barrel_empty_destroyed.tik"; - } - else - { - RadiusDamage( - centroid, - this, - this, - 200, - this, - MOD_EXPLOSION, - 350, - 24 ); + sModel = "models/fx/barrel_gas_destroyed.tik"; + } else if (m_iBarrelType == BARREL_WATER) { + if (vPos[2] + 0.25f * maxs[2] <= fFluidTop) { + sModel = "models/fx/barrel_water_destroyed.tik"; + } else { + sModel = "models/fx/barrel_empty_destroyed.tik"; + } + } else if (m_iBarrelType == BARREL_OIL) { + if (vPos[2] + 0.25f * maxs[2] > fFluidTop) { + sModel = "models/fx/barrel_empty_destroyed.tik"; + } else { + RadiusDamage(centroid, this, this, 200, this, MOD_EXPLOSION, 350, 24); - sModel = "models/fx/barrel_oil_destroyed.tik"; - } - } - else - { - sModel = "models/fx/barrel_empty_destroyed.tik"; - } + sModel = "models/fx/barrel_oil_destroyed.tik"; + } + } else { + sModel = "models/fx/barrel_empty_destroyed.tik"; + } - Animate *exp = new Animate; + Animate *exp = new Animate; - // Spawn an explosion effect - exp->edict->s.renderfx |= RF_DONTDRAW; - exp->setModel( sModel ); + // Spawn an explosion effect + exp->edict->s.renderfx |= RF_DONTDRAW; + exp->setModel(sModel); - vPos = origin + ( maxs + mins ) * 0.5f; + vPos = origin + (maxs + mins) * 0.5f; - exp->setAngles( Vector( -90, 0, 0 ) ); - exp->setOrigin( vPos ); - exp->NewAnim( "idle" ); + exp->setAngles(Vector(-90, 0, 0)); + exp->setOrigin(vPos); + exp->NewAnim("idle"); - exp->PostEvent( EV_Remove, 0.1f ); - exp->Unregister( STRING_DEATH ); + exp->PostEvent(EV_Remove, 0.1f); + exp->Unregister(STRING_DEATH); } diff --git a/code/fgame/barrels.h b/code/fgame/barrels.h index 78caaf43..18f67451 100644 --- a/code/fgame/barrels.h +++ b/code/fgame/barrels.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -22,73 +22,66 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // barrels.h : Barrels -#ifndef __BARRELOBJECT_H__ -#define __BARRELOBJECT_H__ +#pragma once #include "entity.h" -#define BARREL_INDESTRUCTABLE 1 -#define MAX_BARREL_LEAKS 4 +#define BARREL_INDESTRUCTABLE 1 +#define MAX_BARREL_LEAKS 4 -enum -{ - BARREL_EMPTY, - BARREL_OIL, - BARREL_WATER, - BARREL_GAS +enum { + BARREL_EMPTY, + BARREL_OIL, + BARREL_WATER, + BARREL_GAS }; -class BarrelObject : public Entity { - int m_iBarrelType; - float m_fFluidAmount; - float m_fHeightFluid; - qboolean m_bLeaksActive[ MAX_BARREL_LEAKS ]; - Vector m_vLeaks[ MAX_BARREL_LEAKS ]; - Vector m_vLeakNorms[ MAX_BARREL_LEAKS ]; - Vector m_vJitterAngles; - Vector m_vStartAngles; - float m_fJitterScale; - float m_fLastEffectTime; - float m_fDamageSoundTime; +class BarrelObject : public Entity +{ + int m_iBarrelType; + float m_fFluidAmount; + float m_fHeightFluid; + qboolean m_bLeaksActive[MAX_BARREL_LEAKS]; + Vector m_vLeaks[MAX_BARREL_LEAKS]; + Vector m_vLeakNorms[MAX_BARREL_LEAKS]; + Vector m_vJitterAngles; + Vector m_vStartAngles; + float m_fJitterScale; + float m_fLastEffectTime; + float m_fDamageSoundTime; public: - CLASS_PROTOTYPE( BarrelObject ); + CLASS_PROTOTYPE(BarrelObject); - BarrelObject(); + BarrelObject(); - int PickBarrelLeak( void ); + int PickBarrelLeak(void); - void BarrelSetup( Event *ev ); - void BarrelSetType( Event *ev ); - void BarrelThink( Event *ev ); - void BarrelDamaged( Event *ev ); - void BarrelKilled( Event *ev ); + void BarrelSetup(Event *ev); + void BarrelSetType(Event *ev); + void BarrelThink(Event *ev); + void BarrelDamaged(Event *ev); + void BarrelKilled(Event *ev); - void Archive( Archiver& arc ) override; + void Archive(Archiver& arc) override; }; -inline void BarrelObject::Archive - ( - Archiver& arc - ) +inline void BarrelObject::Archive(Archiver& arc) { - Entity::Archive( arc ); + Entity::Archive(arc); - arc.ArchiveInteger( &m_iBarrelType ); - arc.ArchiveFloat( &m_fFluidAmount ); - arc.ArchiveFloat( &m_fHeightFluid ); - arc.ArchiveVector( &m_vJitterAngles ); - arc.ArchiveVector( &m_vStartAngles ); - arc.ArchiveFloat( &m_fJitterScale ); - arc.ArchiveFloat( &m_fLastEffectTime ); - arc.ArchiveFloat( &m_fDamageSoundTime ); + arc.ArchiveInteger(&m_iBarrelType); + arc.ArchiveFloat(&m_fFluidAmount); + arc.ArchiveFloat(&m_fHeightFluid); + arc.ArchiveVector(&m_vJitterAngles); + arc.ArchiveVector(&m_vStartAngles); + arc.ArchiveFloat(&m_fJitterScale); + arc.ArchiveFloat(&m_fLastEffectTime); + arc.ArchiveFloat(&m_fDamageSoundTime); - for( int i = MAX_BARREL_LEAKS - 1; i >= 0; i-- ) - { - arc.ArchiveBoolean( &m_bLeaksActive[ i ] ); - arc.ArchiveVector( &m_vLeaks[ i ] ); - arc.ArchiveVector( &m_vLeakNorms[ i ] ); - } + for (int i = MAX_BARREL_LEAKS - 1; i >= 0; i--) { + arc.ArchiveBoolean(&m_bLeaksActive[i]); + arc.ArchiveVector(&m_vLeaks[i]); + arc.ArchiveVector(&m_vLeakNorms[i]); + } } - -#endif // __BARRELOBJECT_H__ diff --git a/code/fgame/baseimp.h b/code/fgame/baseimp.h index 5eaff5e9..205a3ca1 100644 --- a/code/fgame/baseimp.h +++ b/code/fgame/baseimp.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -20,8 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -#ifndef __BASEIMP_H__ -#define __BASEIMP_H__ +#pragma once #ifdef __cplusplus extern "C" { @@ -86,5 +85,3 @@ void CacheResource( const char *name ); #ifdef __cplusplus } #endif - -#endif diff --git a/code/fgame/beam.cpp b/code/fgame/beam.cpp index 65717b76..6163ce32 100644 --- a/code/fgame/beam.cpp +++ b/code/fgame/beam.cpp @@ -104,7 +104,7 @@ Event EV_FuncBeam_Minoffset EV_DEFAULT, "f", "min_offset", - "Set the minimun offset the beam can travel above, below, forward or back of it's endpoints", + "Set the minimum offset the beam can travel above, below, forward or back of it's endpoints", EV_NORMAL ); Event EV_FuncBeam_Overlap diff --git a/code/fgame/beam.h b/code/fgame/beam.h index 5cea8b7d..abd72ee7 100644 --- a/code/fgame/beam.h +++ b/code/fgame/beam.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -22,8 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // beam.h: Beam -#ifndef __BEAM_H__ -#define __BEAM_H__ +#pragma once #include "g_local.h" #include "scriptslave.h" @@ -123,5 +122,3 @@ inline void FuncBeam::Archive SetBeamShader( shader ); } } - -#endif // __BEAM_H__ diff --git a/code/fgame/bg_local.h b/code/fgame/bg_local.h index 7db944cc..93ed4584 100644 --- a/code/fgame/bg_local.h +++ b/code/fgame/bg_local.h @@ -22,70 +22,68 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // // bg_local.h -- local definitions for the bg (both games) files -#define MIN_WALK_NORMAL 0.7f // can't walk on very steep slopes +#define MIN_WALK_NORMAL 0.7f // can't walk on very steep slopes -#define JUMP_VELOCITY 270 +#define JUMP_VELOCITY 270 -#define TIMER_LAND 130 -#define TIMER_GESTURE (34*66+50) +#define TIMER_LAND 130 +#define TIMER_GESTURE (34 * 66 + 50) -#define OVERCLIP 1.001f +#define OVERCLIP 1.001f -#define HEAD_TAG 0 -#define TORSO_TAG 1 -#define ARMS_TAG 2 -#define PELVIS_TAG 3 -#define MOUTH_TAG 4 +#define HEAD_TAG 0 +#define TORSO_TAG 1 +#define ARMS_TAG 2 +#define PELVIS_TAG 3 +#define MOUTH_TAG 4 // all of the locals will be zeroed before each // pmove, just to make damn sure we don't have // any differences when running on client or server typedef struct { - vec3_t forward, left, up; - vec3_t flat_forward, flat_left, flat_up; - float frametime; + vec3_t forward, left, up; + vec3_t flat_forward, flat_left, flat_up; + float frametime; - int msec; + int msec; - qboolean walking; - qboolean groundPlane; - trace_t groundTrace; + qboolean walking; + qboolean groundPlane; + trace_t groundTrace; - float impactSpeed; + float impactSpeed; - vec3_t previous_origin; - vec3_t previous_velocity; - int previous_waterlevel; + vec3_t previous_origin; + vec3_t previous_velocity; + int previous_waterlevel; } pml_t; -extern pmove_t *pm; -extern pml_t pml; +extern pmove_t *pm; +extern pml_t pml; // movement parameters -extern float pm_stopspeed; -extern float pm_duckScale; -extern float pm_swimScale; -extern float pm_wadeScale; +extern float pm_stopspeed; +extern float pm_duckScale; +extern float pm_swimScale; +extern float pm_wadeScale; -extern float pm_accelerate; -extern float pm_airaccelerate; -extern float pm_wateraccelerate; -extern float pm_flyaccelerate; +extern float pm_accelerate; +extern float pm_airaccelerate; +extern float pm_wateraccelerate; +extern float pm_flyaccelerate; -extern float pm_friction; -extern float pm_waterfriction; -extern float pm_flightfriction; +extern float pm_friction; +extern float pm_waterfriction; +extern float pm_flightfriction; -extern const vec3_t MINS; -extern const vec3_t MAXS; +extern const vec3_t MINS; +extern const vec3_t MAXS; -extern int c_pmove; - -void PM_ClipVelocity( vec3_t in, vec3_t normal, vec3_t out, float overbounce ); -void PM_AddTouchEnt( int entityNum ); -void PM_AddEvent( int newEvent ); - -qboolean PM_SlideMove( qboolean gravity ); -void PM_StepSlideMove( qboolean gravity ); +extern int c_pmove; +void PM_ClipVelocity(vec3_t in, vec3_t normal, vec3_t out, float overbounce); +void PM_AddTouchEnt(int entityNum); +void PM_AddEvent(int newEvent); +qboolean PM_SlideMove(qboolean gravity); +void PM_StepSlideMove(qboolean gravity); diff --git a/code/fgame/bg_misc.cpp b/code/fgame/bg_misc.cpp index 246b1e44..b7f63276 100644 --- a/code/fgame/bg_misc.cpp +++ b/code/fgame/bg_misc.cpp @@ -31,9 +31,7 @@ BG_EvaluateTrajectoryDelta For determining velocity at a given time ================ */ -void BG_EvaluateTrajectoryDelta( const trajectory_t *tr, int atTime, vec3_t result ) { - -} +void BG_EvaluateTrajectoryDelta(const trajectory_t *tr, int atTime, vec3_t result) {} // FIXME: OLD Q3 CODE #if 0 @@ -50,9 +48,9 @@ qboolean BG_CanItemBeGrabbed( int gametype, const entityState_t *ent, const play { gitem_t *item; -#ifdef MISSIONPACK +# ifdef MISSIONPACK int upperBound; -#endif +# endif if ( ent->modelindex < 1 || ent->modelindex >= bg_numItems ) { Com_Error( ERR_DROP, "BG_CanItemBeGrabbed: index out of range" ); @@ -71,7 +69,7 @@ qboolean BG_CanItemBeGrabbed( int gametype, const entityState_t *ent, const play return qtrue; case IT_ARMOR: -#ifdef MISSIONPACK +# ifdef MISSIONPACK if( bg_itemlist[ps->stats[STAT_PERSISTANT_POWERUP]].giTag == PW_SCOUT ) { return qfalse; } @@ -87,22 +85,22 @@ qboolean BG_CanItemBeGrabbed( int gametype, const entityState_t *ent, const play if ( ps->stats[STAT_ARMOR] >= upperBound ) { return qfalse; } -#else +# else if ( ps->stats[STAT_ARMOR] >= ps->stats[STAT_MAX_HEALTH] * 2 ) { return qfalse; } -#endif +# endif return qtrue; case IT_HEALTH: // small and mega healths will go over the max, otherwise // don't pick up if already at max -#ifdef MISSIONPACK +# ifdef MISSIONPACK if( bg_itemlist[ps->stats[STAT_PERSISTANT_POWERUP]].giTag == PW_GUARD ) { upperBound = ps->stats[STAT_MAX_HEALTH]; } else -#endif +# endif if ( item->quantity == 5 || item->quantity == 100 ) { if ( ps->stats[STAT_HEALTH] >= ps->stats[STAT_MAX_HEALTH] * 2 ) { return qfalse; @@ -118,7 +116,7 @@ qboolean BG_CanItemBeGrabbed( int gametype, const entityState_t *ent, const play case IT_POWERUP: return qtrue; // powerups are always picked up -#ifdef MISSIONPACK +# ifdef MISSIONPACK case IT_PERSISTANT_POWERUP: // can only hold one item at a time if ( ps->stats[STAT_PERSISTANT_POWERUP] ) { @@ -134,10 +132,10 @@ qboolean BG_CanItemBeGrabbed( int gametype, const entityState_t *ent, const play } return qtrue; -#endif +# endif case IT_TEAM: // team items, such as flags -#ifdef MISSIONPACK +# ifdef MISSIONPACK if( gametype == GT_1FCTF ) { // neutral flag can always be picked up if( item->giTag == PW_NEUTRALFLAG ) { @@ -153,7 +151,7 @@ qboolean BG_CanItemBeGrabbed( int gametype, const entityState_t *ent, const play } } } -#endif +# endif if( gametype == GT_CTF ) { // ent->modelindex2 is non-zero on items if they are dropped // we need to know this because we can pick up our dropped flag (and return it) @@ -171,11 +169,11 @@ qboolean BG_CanItemBeGrabbed( int gametype, const entityState_t *ent, const play } } -#ifdef MISSIONPACK +# ifdef MISSIONPACK if( gametype == GT_HARVESTER ) { return qtrue; } -#endif +# endif return qfalse; case IT_HOLDABLE: @@ -188,11 +186,11 @@ qboolean BG_CanItemBeGrabbed( int gametype, const entityState_t *ent, const play case IT_BAD: Com_Error( ERR_DROP, "BG_CanItemBeGrabbed: IT_BAD" ); default: -#ifndef Q3_VM -#ifndef NDEBUG +# ifndef Q3_VM +# ifndef NDEBUG Com_Printf("BG_CanItemBeGrabbed: unknown enum %d\n", item->giType ); -#endif -#endif +# endif +# endif break; } @@ -297,8 +295,7 @@ void BG_EvaluateTrajectoryDelta( const trajectory_t *tr, int atTime, vec3_t resu BG_TouchJumpPad ======================== */ -void BG_TouchJumpPad( playerState_t *ps, entityState_t *jumppad ) { -} +void BG_TouchJumpPad(playerState_t *ps, entityState_t *jumppad) {} /* ======================== @@ -308,43 +305,41 @@ This is done after each set of usercmd_t on the server, and after local prediction on the client ======================== */ -void BG_PlayerStateToEntityState( playerState_t *ps, entityState_t *s, qboolean snap ) +void BG_PlayerStateToEntityState(playerState_t *ps, entityState_t *s, qboolean snap) { - if ( ps->pm_type == PM_NOCLIP ) { - s->eType = 0;//ET_INVISIBLE; - //} else if ( ps->stats[STAT_HEALTH] <= GIB_HEALTH ) { - // s->eType = 0;//ET_INVISIBLE; - } else { - s->eType = ET_PLAYER; - } + if (ps->pm_type == PM_NOCLIP) { + s->eType = 0; //ET_INVISIBLE; + //} else if ( ps->stats[STAT_HEALTH] <= GIB_HEALTH ) { + // s->eType = 0;//ET_INVISIBLE; + } else { + s->eType = ET_PLAYER; + } - s->number = ps->clientNum; + s->number = ps->clientNum; - VectorCopy( ps->origin, s->origin ); - if ( snap ) { - SnapVector( s->origin ); - } - // set the trDelta for flag direction - VectorCopy( ps->velocity, s->pos.trDelta ); + VectorCopy(ps->origin, s->origin); + if (snap) { + SnapVector(s->origin); + } + // set the trDelta for flag direction + VectorCopy(ps->velocity, s->pos.trDelta); - VectorCopy( ps->viewangles, s->angles ); - if ( snap ) { - SnapVector( s->angles ); - } + VectorCopy(ps->viewangles, s->angles); + if (snap) { + SnapVector(s->angles); + } - //s->angles2[YAW] = ps->movementDir; - s->clientNum = ps->clientNum; // ET_PLAYER looks here instead of at number - // so corpses can also reference the proper config - //s->eFlags = ps->eFlags; - //if ( ps->stats[STAT_HEALTH] <= 0 ) { - // s->eFlags |= EF_DEAD; - //} else { - // s->eFlags &= ~EF_DEAD; - //} - - - s->groundEntityNum = ps->groundEntityNum; + //s->angles2[YAW] = ps->movementDir; + s->clientNum = ps->clientNum; // ET_PLAYER looks here instead of at number + // so corpses can also reference the proper config + //s->eFlags = ps->eFlags; + //if ( ps->stats[STAT_HEALTH] <= 0 ) { + // s->eFlags |= EF_DEAD; + //} else { + // s->eFlags &= ~EF_DEAD; + //} + s->groundEntityNum = ps->groundEntityNum; } /* @@ -355,37 +350,35 @@ This is done after each set of usercmd_t on the server, and after local prediction on the client ======================== */ -void BG_PlayerStateToEntityStateExtraPolate( playerState_t *ps, entityState_t *s, int time, qboolean snap ) +void BG_PlayerStateToEntityStateExtraPolate(playerState_t *ps, entityState_t *s, int time, qboolean snap) { - if ( ps->pm_type == PM_NOCLIP ) { - s->eType = 0;//ET_INVISIBLE; - //} else if ( ps->stats[STAT_HEALTH] <= GIB_HEALTH ) { - // s->eType = 0;//ET_INVISIBLE; - } else { - s->eType = ET_PLAYER; - } + if (ps->pm_type == PM_NOCLIP) { + s->eType = 0; //ET_INVISIBLE; + //} else if ( ps->stats[STAT_HEALTH] <= GIB_HEALTH ) { + // s->eType = 0;//ET_INVISIBLE; + } else { + s->eType = ET_PLAYER; + } - s->number = ps->clientNum; + s->number = ps->clientNum; - VectorCopy( ps->origin, s->origin ); - if ( snap ) { - SnapVector( s->origin ); - } - // set the trDelta for flag direction and linear prediction - VectorCopy( ps->velocity, s->pos.trDelta ); - // set the time for linear prediction - s->pos.trTime = time; + VectorCopy(ps->origin, s->origin); + if (snap) { + SnapVector(s->origin); + } + // set the trDelta for flag direction and linear prediction + VectorCopy(ps->velocity, s->pos.trDelta); + // set the time for linear prediction + s->pos.trTime = time; - VectorCopy( ps->viewangles, s->angles ); - if ( snap ) { - SnapVector( s->angles ); - } - s->clientNum = ps->clientNum; // ET_PLAYER looks here instead of at number - // so corpses can also reference the proper config - - - s->groundEntityNum = ps->groundEntityNum; + VectorCopy(ps->viewangles, s->angles); + if (snap) { + SnapVector(s->angles); + } + s->clientNum = ps->clientNum; // ET_PLAYER looks here instead of at number + // so corpses can also reference the proper config + s->groundEntityNum = ps->groundEntityNum; } /* @@ -398,30 +391,30 @@ and after local prediction on the client */ int BG_MapCGMToProtocol(int protocol, int messageNumber) { - int newMessageNumber = messageNumber; + int newMessageNumber = messageNumber; - if (protocol >= PROTOCOL_MOHTA_MIN) { - // no need translation - return messageNumber; - } + if (protocol >= PROTOCOL_MOHTA_MIN) { + // no need translation + return messageNumber; + } - if (messageNumber > 40) { - // unsupported... - return messageNumber; - } + if (messageNumber > 40) { + // unsupported... + return messageNumber; + } - if (messageNumber >= 17) { - return messageNumber - 3; - } + if (messageNumber >= 17) { + return messageNumber - 3; + } - if (messageNumber == 15 || messageNumber == 16) { - // return explosion effect number 2 - return 14; - } + if (messageNumber == 15 || messageNumber == 16) { + // return explosion effect number 2 + return 14; + } - if (messageNumber > 10) { - return messageNumber - 1; - } + if (messageNumber > 10) { + return messageNumber - 1; + } - return newMessageNumber; + return newMessageNumber; } \ No newline at end of file diff --git a/code/fgame/bg_pmove.cpp b/code/fgame/bg_pmove.cpp index 65018c92..613bc78b 100644 --- a/code/fgame/bg_pmove.cpp +++ b/code/fgame/bg_pmove.cpp @@ -1,6 +1,7 @@ /* =========================================================================== Copyright (C) 1999-2005 Id Software, Inc. +Copyright (C) 2024 the OpenMoHAA team This file is part of Quake III Arena source code. @@ -27,31 +28,31 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "bg_public.h" #include "bg_local.h" -pmove_t *pm; -pml_t pml; +pmove_t *pm; +pml_t pml; // movement parameters -float pm_stopspeed = 50.0f; -float pm_duckScale = 0.25f; -float pm_swimScale = 1.0f; -float pm_wadeScale = 0.70f; +float pm_stopspeed = 50.0f; +float pm_duckScale = 0.25f; +float pm_swimScale = 1.0f; +float pm_wadeScale = 0.70f; -float pm_accelerate = 8.0f; -float pm_airaccelerate = 1.0f; -float pm_wateraccelerate = 8.0f; +float pm_accelerate = 8.0f; +float pm_airaccelerate = 1.0f; +float pm_wateraccelerate = 8.0f; -float pm_friction = 6.0f; -float pm_waterfriction = 2.0f; -float pm_slipperyfriction = 0.25f; -float pm_strafespeed = 0.85f; -float pm_backspeed = 0.80f; -float pm_flightfriction = 3.0f; -float PM_NOCLIPfriction = 5.0f; +float pm_friction = 6.0f; +float pm_waterfriction = 2.0f; +float pm_slipperyfriction = 0.25f; +float pm_strafespeed = 0.85f; +float pm_backspeed = 0.80f; +float pm_flightfriction = 3.0f; +float PM_NOCLIPfriction = 5.0f; -const vec3_t MINS = { -15, -15, 0 }; -const vec3_t MAXS = { 15, 15, 94 }; +const vec3_t MINS = {-15, -15, 0}; +const vec3_t MAXS = {15, 15, 94}; -int c_pmove = 0; +int c_pmove = 0; /* =============== @@ -59,36 +60,35 @@ PM_AddEvent =============== */ -void PM_AddEvent( int newEvent ) { - -} +void PM_AddEvent(int newEvent) {} /* =============== PM_AddTouchEnt =============== */ -void PM_AddTouchEnt( int entityNum ) { - int i; +void PM_AddTouchEnt(int entityNum) +{ + int i; - if ( entityNum == ENTITYNUM_WORLD ) { - return; - } + if (entityNum == ENTITYNUM_WORLD) { + return; + } - if ( pm->numtouch == MAXTOUCH ) { - return; - } + if (pm->numtouch == MAXTOUCH) { + return; + } - // see if it is already added - for ( i = 0 ; i < pm->numtouch ; i++ ) { - if ( pm->touchents[ i ] == entityNum ) { - return; - } - } + // see if it is already added + for (i = 0; i < pm->numtouch; i++) { + if (pm->touchents[i] == entityNum) { + return; + } + } - // add it - pm->touchents[pm->numtouch] = entityNum; - pm->numtouch++; + // add it + pm->touchents[pm->numtouch] = entityNum; + pm->numtouch++; } /* @@ -96,25 +96,15 @@ void PM_AddTouchEnt( int entityNum ) { PM_StartTorsoAnim =================== */ -static void PM_StartTorsoAnim( int anim ) { +static void PM_StartTorsoAnim(int anim) {} -} -static void PM_StartLegsAnim( int anim ) { +static void PM_StartLegsAnim(int anim) {} -} +static void PM_ContinueLegsAnim(int anim) {} -static void PM_ContinueLegsAnim( int anim ) { - -} - -static void PM_ContinueTorsoAnim( int anim ) { - -} - -static void PM_ForceLegsAnim( int anim ) { - -} +static void PM_ContinueTorsoAnim(int anim) {} +static void PM_ForceLegsAnim(int anim) {} /* ================== @@ -123,48 +113,44 @@ PM_ClipVelocity Slide off of the impacting surface ================== */ -void PM_ClipVelocity( vec3_t in, vec3_t normal, vec3_t out, float overbounce ) +void PM_ClipVelocity(vec3_t in, vec3_t normal, vec3_t out, float overbounce) { - float backoff; - float dir_z; - float normal2[ 3 ]; + float backoff; + float dir_z; + float normal2[3]; - if( normal[ 2 ] >= pm_wadeScale ) - { - if( in[ 0 ] == 0.0f && in[ 1 ] == 0.0f ) - { - VectorClear( out ); - return; - } + if (normal[2] >= pm_wadeScale) { + if (in[0] == 0.0f && in[1] == 0.0f) { + VectorClear(out); + return; + } - normal2[ 0 ] = in[ 0 ] * DotProduct2D( in, normal ); - normal2[ 1 ] = in[ 1 ] * DotProduct2D( in, normal ); - normal2[ 2 ] = normal[ 2 ] * DotProduct2D( in, in ); + normal2[0] = in[0] * DotProduct2D(in, normal); + normal2[1] = in[1] * DotProduct2D(in, normal); + normal2[2] = normal[2] * DotProduct2D(in, in); - VectorNormalize( normal2 ); + VectorNormalize(normal2); - dir_z = -normal2[ 2 ]; + dir_z = -normal2[2]; - out[ 0 ] = in[ 0 ]; - out[ 1 ] = in[ 1 ]; - out[ 2 ] = DotProduct2D( in, normal2 ) / dir_z; - } - else - { - backoff = DotProduct( in, normal ); + out[0] = in[0]; + out[1] = in[1]; + out[2] = DotProduct2D(in, normal2) / dir_z; + } else { + backoff = DotProduct(in, normal); - if( backoff < 0 ) - backoff *= overbounce; - else - backoff /= overbounce; + if (backoff < 0) { + backoff *= overbounce; + } else { + backoff /= overbounce; + } - out[ 0 ] = in[ 0 ] - normal[ 0 ] * backoff; - out[ 1 ] = in[ 1 ] - normal[ 1 ] * backoff; - out[ 2 ] = in[ 2 ] - normal[ 2 ] * backoff; - } + out[0] = in[0] - normal[0] * backoff; + out[1] = in[1] - normal[1] * backoff; + out[2] = in[2] - normal[2] * backoff; + } } - /* ================== PM_Friction @@ -172,76 +158,65 @@ PM_Friction Handles both ground friction and water friction ================== */ -static void PM_Friction( void ) { - vec3_t vec; - float *vel; - float speed, newspeed, control; - float drop; +static void PM_Friction(void) +{ + vec3_t vec; + float *vel; + float speed, newspeed, control; + float drop; - vel = pm->ps->velocity; + vel = pm->ps->velocity; - VectorCopy( vel, vec ); - if( pml.walking ) - { - // ignore slope movement - vec[ 2 ] = 0; - } + VectorCopy(vel, vec); + if (pml.walking) { + // ignore slope movement + vec[2] = 0; + } - speed = VectorLength( vec ); - if( speed < 1 ) - { - // allow sinking underwater - vel[ 0 ] = 0; - vel[ 1 ] = 0; + speed = VectorLength(vec); + if (speed < 1) { + // allow sinking underwater + vel[0] = 0; + vel[1] = 0; - return; - } + return; + } - drop = 0; + drop = 0; - if( pml.walking ) - { - control = ( speed < pm_stopspeed ) ? pm_stopspeed : speed; + if (pml.walking) { + control = (speed < pm_stopspeed) ? pm_stopspeed : speed; - // if getting knocked back, no friction - if( pml.groundTrace.surfaceFlags & SURF_SLICK ) - { - drop += control * pm_slipperyfriction * pml.frametime; - } - else - { - drop += control * pm_friction * pml.frametime; - } - } + // if getting knocked back, no friction + if (pml.groundTrace.surfaceFlags & SURF_SLICK) { + drop += control * pm_slipperyfriction * pml.frametime; + } else { + drop += control * pm_friction * pml.frametime; + } + } - // apply water friction even if just wading - if( pm->waterlevel ) - { - if( pm->watertype & CONTENTS_SLIME ) - { - drop += speed * pm_waterfriction * 5 * pm->waterlevel * pml.frametime; - } - else - { - drop += speed * pm_waterfriction * pm->waterlevel * pml.frametime; - } - } + // apply water friction even if just wading + if (pm->waterlevel) { + if (pm->watertype & CONTENTS_SLIME) { + drop += speed * pm_waterfriction * 5 * pm->waterlevel * pml.frametime; + } else { + drop += speed * pm_waterfriction * pm->waterlevel * pml.frametime; + } + } - // scale the velocity - newspeed = speed - drop; - if( newspeed < 0 ) - { - newspeed = 0; - } + // scale the velocity + newspeed = speed - drop; + if (newspeed < 0) { + newspeed = 0; + } - newspeed /= speed; + newspeed /= speed; - vel[ 0 ] = vel[ 0 ] * newspeed; - vel[ 1 ] = vel[ 1 ] * newspeed; - vel[ 2 ] = vel[ 2 ] * newspeed; + vel[0] = vel[0] * newspeed; + vel[1] = vel[1] * newspeed; + vel[2] = vel[2] * newspeed; } - /* ============== PM_Accelerate @@ -249,27 +224,25 @@ PM_Accelerate Handles user intended acceleration ============== */ -static void PM_Accelerate( vec3_t wishdir, float wishspeed, float accel ) +static void PM_Accelerate(vec3_t wishdir, float wishspeed, float accel) { - vec3_t wishVelocity; - vec3_t pushDir; - float pushLen; - float canPush; + vec3_t wishVelocity; + vec3_t pushDir; + float pushLen; + float canPush; - VectorScale( wishdir, wishspeed, wishVelocity ); - VectorSubtract( wishVelocity, pm->ps->velocity, pushDir ); - pushLen = VectorNormalize( pushDir ); + VectorScale(wishdir, wishspeed, wishVelocity); + VectorSubtract(wishVelocity, pm->ps->velocity, pushDir); + pushLen = VectorNormalize(pushDir); - canPush = accel*pml.frametime*wishspeed; - if (canPush > pushLen) { - canPush = pushLen; - } + canPush = accel * pml.frametime * wishspeed; + if (canPush > pushLen) { + canPush = pushLen; + } - VectorMA( pm->ps->velocity, canPush, pushDir, pm->ps->velocity ); + VectorMA(pm->ps->velocity, canPush, pushDir, pm->ps->velocity); } - - /* ============ PM_CmdScale @@ -279,30 +252,30 @@ This allows the clients to use axial -127 to 127 values for all directions without getting a sqrt(2) distortion in speed. ============ */ -static float PM_CmdScale( usercmd_t *cmd ) { - int max; - float total; - float scale; - float fmove, smove; +static float PM_CmdScale(usercmd_t *cmd) +{ + int max; + float total; + float scale; + float fmove, smove; - PM_GetMove( &fmove, &smove ); + PM_GetMove(&fmove, &smove); - max = fabs( fmove ); - if(fabs( smove ) > max ) { - max = fabs( smove ); - } - if (fabs( cmd->upmove ) > max ) { - max = fabs( cmd->upmove ); - } - if ( !max ) { - return 0; - } + max = fabs(fmove); + if (fabs(smove) > max) { + max = fabs(smove); + } + if (fabs(cmd->upmove) > max) { + max = fabs(cmd->upmove); + } + if (!max) { + return 0; + } - total = sqrt( ( float )( fmove * fmove - + smove * smove + cmd->upmove * cmd->upmove ) ); - scale = ( float )pm->ps->speed * max / ( 127.0 * total ); + total = sqrt((float)(fmove * fmove + smove * smove + cmd->upmove * cmd->upmove)); + scale = (float)pm->ps->speed * max / (127.0 * total); - return scale; + return scale; } //============================================================================ @@ -313,33 +286,29 @@ PM_CheckTerminalVelocity ============= */ #define TERMINAL_VELOCITY 1200 -void PM_CheckTerminalVelocity - ( - void - ) + +void PM_CheckTerminalVelocity(void) { - float oldspeed; - float speed; + float oldspeed; + float speed; - // - // how fast were we falling - // - oldspeed = -pml.previous_velocity[ 2 ]; + // + // how fast were we falling + // + oldspeed = -pml.previous_velocity[2]; - // - // how fast are we falling - // - speed = -pm->ps->velocity[ 2 ]; + // + // how fast are we falling + // + speed = -pm->ps->velocity[2]; - if( speed <= 0 ) - { - return; - } + if (speed <= 0) { + return; + } - if( ( oldspeed <= TERMINAL_VELOCITY ) && ( speed > TERMINAL_VELOCITY ) ) - { - pm->pmoveEvent = EV_TERMINAL_VELOCITY; - } + if ((oldspeed <= TERMINAL_VELOCITY) && (speed > TERMINAL_VELOCITY)) { + pm->pmoveEvent = EV_TERMINAL_VELOCITY; + } } /* @@ -399,18 +368,13 @@ PM_GetMove =================== */ -void PM_GetMove - ( - float *pfForward, - float *pfRight - ) +void PM_GetMove(float *pfForward, float *pfRight) { - *pfForward = pm->cmd.forwardmove; - if( *pfForward < 0 ) - { - *pfForward *= pm_backspeed; - } - *pfRight = pm->cmd.rightmove * pm_strafespeed; + *pfForward = pm->cmd.forwardmove; + if (*pfForward < 0) { + *pfForward *= pm_backspeed; + } + *pfRight = pm->cmd.rightmove * pm_strafespeed; } /* @@ -419,184 +383,161 @@ PM_AirMove =================== */ -static void PM_AirMove( void ) +static void PM_AirMove(void) { - vec3_t wishvel; - float fmove; - float smove; - vec3_t wishdir; - float wishspeed; - float scale; - usercmd_t cmd; + vec3_t wishvel; + float fmove; + float smove; + vec3_t wishdir; + float wishspeed; + float scale; + usercmd_t cmd; - PM_GetMove( &fmove, &smove ); + PM_GetMove(&fmove, &smove); - pm->ps->pm_time = 0; + pm->ps->pm_time = 0; - cmd = pm->cmd; - scale = PM_CmdScale( &cmd ); + cmd = pm->cmd; + scale = PM_CmdScale(&cmd); - wishvel[ 0 ] = pml.flat_forward[ 0 ] * fmove - pml.flat_left[ 0 ] * smove; - wishvel[ 1 ] = pml.flat_forward[ 1 ] * fmove - pml.flat_left[ 1 ] * smove; - wishvel[ 2 ] = 0; + wishvel[0] = pml.flat_forward[0] * fmove - pml.flat_left[0] * smove; + wishvel[1] = pml.flat_forward[1] * fmove - pml.flat_left[1] * smove; + wishvel[2] = 0; - VectorCopy( wishvel, wishdir ); - wishspeed = VectorNormalize( wishdir ); - wishspeed *= scale; + VectorCopy(wishvel, wishdir); + wishspeed = VectorNormalize(wishdir); + wishspeed *= scale; - // not on ground, so little effect on velocity - PM_Accelerate( wishdir, wishspeed, pm_airaccelerate ); + // not on ground, so little effect on velocity + PM_Accelerate(wishdir, wishspeed, pm_airaccelerate); - // we may have a ground plane that is very steep, even - // though we don't have a groundentity - // slide along the steep plane - if( pml.groundPlane ) - { - PM_ClipVelocity( pm->ps->velocity, pml.groundTrace.plane.normal, pm->ps->velocity, OVERCLIP ); - } + // we may have a ground plane that is very steep, even + // though we don't have a groundentity + // slide along the steep plane + if (pml.groundPlane) { + PM_ClipVelocity(pm->ps->velocity, pml.groundTrace.plane.normal, pm->ps->velocity, OVERCLIP); + } - PM_StepSlideMove( qtrue ); + PM_StepSlideMove(qtrue); - PM_CheckTerminalVelocity(); + PM_CheckTerminalVelocity(); } -static vec3_t min3x3 = { -8, 0, 0 }; -static vec3_t max3x3 = { 4, 4, 8 }; -static vec3_t base_rightfoot_pos = { -5.25301f, -3.10885f, 0 }; -static vec3_t base_leftfoot_pos = { -0.123711f, 10.4893f, 0 }; +static vec3_t min3x3 = {-8, 0, 0}; +static vec3_t max3x3 = {4, 4, 8}; +static vec3_t base_rightfoot_pos = {-5.25301f, -3.10885f, 0}; +static vec3_t base_leftfoot_pos = {-0.123711f, 10.4893f, 0}; -qboolean PM_FeetOnGround - ( - vec3_t pos - ) +qboolean PM_FeetOnGround(vec3_t pos) { - vec3_t start; - vec3_t end; - trace_t trace; + vec3_t start; + vec3_t end; + trace_t trace; - VectorCopy( pos, start ); - VectorCopy( pos, end ); - end[ 2 ] -= 16.01f; + VectorCopy(pos, start); + VectorCopy(pos, end); + end[2] -= 16.01f; - pm->trace( &trace, start, min3x3, max3x3, end, pm->ps->clientNum, pm->tracemask, true, false ); + pm->trace(&trace, start, min3x3, max3x3, end, pm->ps->clientNum, pm->tracemask, true, false); - return trace.fraction != 1.0f; + return trace.fraction != 1.0f; } -qboolean PM_FindBestFallPos - ( - vec3_t pos, - vec3_t bestdir - ) -{ - trace_t trace; - vec3_t ang; - vec3_t dir; - vec3_t start; - vec3_t end; - vec3_t move; - int i; - qboolean set; - float radius; +qboolean PM_FindBestFallPos(vec3_t pos, vec3_t bestdir) +{ + trace_t trace; + vec3_t ang; + vec3_t dir; + vec3_t start; + vec3_t end; + vec3_t move; + int i; + qboolean set; + float radius; - VectorClear( bestdir ); + VectorClear(bestdir); - set = qfalse; + set = qfalse; - radius = pm->maxs[ 0 ] - pm->mins[ 0 ] + 1.0f; + radius = pm->maxs[0] - pm->mins[0] + 1.0f; - VectorCopy( pos, start ); - start[ 2 ] -= 16.1f; + VectorCopy(pos, start); + start[2] -= 16.1f; - VectorSet( ang, 0, pm->ps->viewangles[ 1 ], 0 ); - for( i = 0; i < 16; i++, ang[ 1 ] += 22.5f ) - { - AngleVectorsLeft( ang, dir, NULL, NULL ); - VectorMA( pos, radius, dir, move ); + VectorSet(ang, 0, pm->ps->viewangles[1], 0); + for (i = 0; i < 16; i++, ang[1] += 22.5f) { + AngleVectorsLeft(ang, dir, NULL, NULL); + VectorMA(pos, radius, dir, move); - pm->trace( &trace, pos, pm->mins, pm->maxs, move, pm->ps->clientNum, pm->tracemask, qtrue, qfalse ); + pm->trace(&trace, pos, pm->mins, pm->maxs, move, pm->ps->clientNum, pm->tracemask, qtrue, qfalse); - VectorCopy( trace.endpos, end ); - end[ 2 ] = start[ 2 ]; + VectorCopy(trace.endpos, end); + end[2] = start[2]; - pm->trace( &trace, trace.endpos, pm->mins, pm->maxs, end, pm->ps->clientNum, pm->tracemask, qtrue, qfalse ); - if( trace.fraction == 1.0f ) - { - VectorCopy( trace.endpos, end ); - pm->trace( &trace, end, pm->mins, pm->maxs, start, pm->ps->clientNum, pm->tracemask, qtrue, qfalse ); + pm->trace(&trace, trace.endpos, pm->mins, pm->maxs, end, pm->ps->clientNum, pm->tracemask, qtrue, qfalse); + if (trace.fraction == 1.0f) { + VectorCopy(trace.endpos, end); + pm->trace(&trace, end, pm->mins, pm->maxs, start, pm->ps->clientNum, pm->tracemask, qtrue, qfalse); - if( trace.fraction < 1.0f ) - { - VectorAdd( bestdir, trace.plane.normal, bestdir ); - set = qtrue; - } - } - } + if (trace.fraction < 1.0f) { + VectorAdd(bestdir, trace.plane.normal, bestdir); + set = qtrue; + } + } + } - if( !set || !VectorNormalize( bestdir ) ) - { - return qfalse; - } + if (!set || !VectorNormalize(bestdir)) { + return qfalse; + } - return qtrue; + return qtrue; } -void PM_CheckFeet - ( - vec3_t vWishdir - ) +void PM_CheckFeet(vec3_t vWishdir) { - vec3_t temp; - trace_t trace; + vec3_t temp; + trace_t trace; - if( pm->stepped ) - { - pm->ps->feetfalling = 0; - return; - } + if (pm->stepped) { + pm->ps->feetfalling = 0; + return; + } - if( !pm->ps->walking ) - { - return; - } + if (!pm->ps->walking) { + return; + } - VectorMA( pm->ps->origin, 0.2f, pm->ps->velocity, temp ); - temp[ 2 ] = pm->ps->origin[ 2 ] + 2; - if( PM_FeetOnGround( pm->ps->origin ) || PM_FeetOnGround( temp ) ) - { - pm->ps->feetfalling = 0; - return; - } + VectorMA(pm->ps->origin, 0.2f, pm->ps->velocity, temp); + temp[2] = pm->ps->origin[2] + 2; + if (PM_FeetOnGround(pm->ps->origin) || PM_FeetOnGround(temp)) { + pm->ps->feetfalling = 0; + return; + } - if( pm->ps->feetfalling > 0 ) - { - pm->ps->feetfalling--; - } + if (pm->ps->feetfalling > 0) { + pm->ps->feetfalling--; + } - if( !pm->ps->feetfalling ) - { - if( !PM_FindBestFallPos( pm->ps->origin, pm->ps->falldir ) ) { - return; - } + if (!pm->ps->feetfalling) { + if (!PM_FindBestFallPos(pm->ps->origin, pm->ps->falldir)) { + return; + } - pm->ps->feetfalling = 5; - } + pm->ps->feetfalling = 5; + } - VectorMA( pm->ps->origin, 15.0f * pml.frametime, pm->ps->falldir, temp ); + VectorMA(pm->ps->origin, 15.0f * pml.frametime, pm->ps->falldir, temp); - pm->trace( &trace, pm->ps->origin, pm->mins, pm->maxs, temp, pm->ps->clientNum, pm->tracemask, qtrue, qfalse ); - if( trace.fraction == 0 ) - { - pm->ps->feetfalling = 0; - return; - } + pm->trace(&trace, pm->ps->origin, pm->mins, pm->maxs, temp, pm->ps->clientNum, pm->tracemask, qtrue, qfalse); + if (trace.fraction == 0) { + pm->ps->feetfalling = 0; + return; + } - if( ( vWishdir[ 0 ] == 0.0f && vWishdir[ 1 ] == 0.0f ) || - DotProduct( vWishdir, pm->ps->falldir ) > 0.0f ) - { - pm->ps->walking = qfalse; - VectorCopy( trace.endpos, pm->ps->origin ); - } + if ((vWishdir[0] == 0.0f && vWishdir[1] == 0.0f) || DotProduct(vWishdir, pm->ps->falldir) > 0.0f) { + pm->ps->walking = qfalse; + VectorCopy(trace.endpos, pm->ps->origin); + } } /* @@ -605,90 +546,81 @@ PM_WalkMove =================== */ -static void PM_WalkMove( void ) { - int i; - vec3_t wishvel; - float fmove, smove; - vec3_t wishdir; - float wishspeed; - float scale; - usercmd_t cmd; - float accelerate; +static void PM_WalkMove(void) +{ + int i; + vec3_t wishvel; + float fmove, smove; + vec3_t wishdir; + float wishspeed; + float scale; + usercmd_t cmd; + float accelerate; - PM_Friction(); + PM_Friction(); - PM_GetMove( &fmove, &smove ); + PM_GetMove(&fmove, &smove); - cmd = pm->cmd; - scale = PM_CmdScale( &cmd ); + cmd = pm->cmd; + scale = PM_CmdScale(&cmd); - if( ( pm->cmd.buttons & BUTTON_RUN ) && fmove && !smove ) - { - pm->ps->pm_time += pml.msec; - } - else - { - pm->ps->pm_time = 0; - } + if ((pm->cmd.buttons & BUTTON_RUN) && fmove && !smove) { + pm->ps->pm_time += pml.msec; + } else { + pm->ps->pm_time = 0; + } - // project the forward and right directions onto the ground plane - PM_ClipVelocity( pml.flat_forward, pml.groundTrace.plane.normal, pml.flat_forward, OVERCLIP ); - PM_ClipVelocity( pml.flat_left, pml.groundTrace.plane.normal, pml.flat_left, OVERCLIP ); - // - VectorNormalize( pml.flat_forward ); - VectorNormalize( pml.flat_left ); + // project the forward and right directions onto the ground plane + PM_ClipVelocity(pml.flat_forward, pml.groundTrace.plane.normal, pml.flat_forward, OVERCLIP); + PM_ClipVelocity(pml.flat_left, pml.groundTrace.plane.normal, pml.flat_left, OVERCLIP); + // + VectorNormalize(pml.flat_forward); + VectorNormalize(pml.flat_left); - for( i = 0; i < 3; i++ ) - { - wishvel[ i ] = pml.flat_forward[ i ] * fmove - pml.flat_left[ i ] * smove; - } + for (i = 0; i < 3; i++) { + wishvel[i] = pml.flat_forward[i] * fmove - pml.flat_left[i] * smove; + } - VectorCopy( wishvel, wishdir ); - wishspeed = VectorNormalize( wishdir ); - wishspeed *= scale; + VectorCopy(wishvel, wishdir); + wishspeed = VectorNormalize(wishdir); + wishspeed *= scale; - // clamp the speed lower if wading or walking on the bottom - if( pm->waterlevel ) - { - float waterScale; + // clamp the speed lower if wading or walking on the bottom + if (pm->waterlevel) { + float waterScale; - if( pm->waterlevel == 1.0f ) - { - waterScale = 0.80f; - } - else - { - waterScale = 0.5f; - } + if (pm->waterlevel == 1.0f) { + waterScale = 0.80f; + } else { + waterScale = 0.5f; + } - if( wishspeed > pm->ps->speed * waterScale ) { - wishspeed = pm->ps->speed * waterScale; - } - } + if (wishspeed > pm->ps->speed * waterScale) { + wishspeed = pm->ps->speed * waterScale; + } + } - if( pml.groundTrace.surfaceFlags & SURF_SLICK ) { - accelerate = pm_airaccelerate; - } else { - accelerate = pm_accelerate; - } + if (pml.groundTrace.surfaceFlags & SURF_SLICK) { + accelerate = pm_airaccelerate; + } else { + accelerate = pm_accelerate; + } - PM_Accelerate( wishdir, wishspeed, accelerate ); + PM_Accelerate(wishdir, wishspeed, accelerate); - if( pml.groundTrace.surfaceFlags & SURF_SLICK ) { - pm->ps->velocity[ 2 ] -= pm->ps->gravity * pml.frametime; - } + if (pml.groundTrace.surfaceFlags & SURF_SLICK) { + pm->ps->velocity[2] -= pm->ps->gravity * pml.frametime; + } - // slide along the ground plane - PM_ClipVelocity( pm->ps->velocity, pml.groundTrace.plane.normal, - pm->ps->velocity, OVERCLIP ); + // slide along the ground plane + PM_ClipVelocity(pm->ps->velocity, pml.groundTrace.plane.normal, pm->ps->velocity, OVERCLIP); - // don't do anything if standing still - if( pm->ps->velocity[ 0 ] || pm->ps->velocity[ 1 ] ) - { - PM_StepSlideMove( qtrue ); - } + // don't do anything if standing still + if (pm->ps->velocity[0] || pm->ps->velocity[1]) { + PM_StepSlideMove(qtrue); + } - PM_CheckFeet( wishdir ); + PM_CheckFeet(wishdir); } /* @@ -696,100 +628,105 @@ static void PM_WalkMove( void ) { PM_DeadMove ============== */ -static void PM_DeadMove( void ) { - float forward; +static void PM_DeadMove(void) +{ + float forward; - if ( !pml.walking ) { - return; - } + if (!pml.walking) { + return; + } - // extra friction + // extra friction - forward = VectorLength (pm->ps->velocity); - forward -= 20; - if ( forward <= 0 ) { - VectorClear (pm->ps->velocity); - } else { - VectorNormalize (pm->ps->velocity); - VectorScale (pm->ps->velocity, forward, pm->ps->velocity); - } + forward = VectorLength(pm->ps->velocity); + forward -= 20; + if (forward <= 0) { + VectorClear(pm->ps->velocity); + } else { + VectorNormalize(pm->ps->velocity); + VectorScale(pm->ps->velocity, forward, pm->ps->velocity); + } } - /* =============== PM_NoclipMove =============== */ -static void PM_NoclipMove( void ) +static void PM_NoclipMove(void) { - float speed; - float drop; - float friction; - float control; - float newspeed; - int i; - vec3_t wishvel; - float fmove; - float smove; - vec3_t wishdir; - float wishspeed; - float scale; + float speed; + float drop; + float friction; + float control; + float newspeed; + int i; + vec3_t wishvel; + float fmove; + float smove; + vec3_t wishdir; + float wishspeed; + float scale; - pm->ps->viewheight = DEFAULT_VIEWHEIGHT; - pm->ps->groundEntityNum = ENTITYNUM_NONE; + pm->ps->viewheight = DEFAULT_VIEWHEIGHT; + pm->ps->groundEntityNum = ENTITYNUM_NONE; - // friction + // friction - speed = VectorLength( pm->ps->velocity ); - if( speed < 1 ) - { - VectorCopy( vec3_origin, pm->ps->velocity ); - } - else - { - drop = 0; + speed = VectorLength(pm->ps->velocity); + if (speed < 1) { + VectorCopy(vec3_origin, pm->ps->velocity); + } else { + drop = 0; - // extra friction - friction = pm_friction * 1.5; + // extra friction + friction = pm_friction * 1.5; - control = speed < pm_stopspeed ? pm_stopspeed : speed; - drop += control * friction * pml.frametime; + control = speed < pm_stopspeed ? pm_stopspeed : speed; + drop += control * friction * pml.frametime; - // scale the velocity - newspeed = speed - drop; - if( newspeed < 0 ) - { - newspeed = 0; - } - newspeed /= speed; + // scale the velocity + newspeed = speed - drop; + if (newspeed < 0) { + newspeed = 0; + } + newspeed /= speed; - VectorScale( pm->ps->velocity, newspeed, pm->ps->velocity ); - } + VectorScale(pm->ps->velocity, newspeed, pm->ps->velocity); + } - // accelerate - // allow the player to move twice as fast in noclip - scale = PM_CmdScale( &pm->cmd ) * 2; + // accelerate + // allow the player to move twice as fast in noclip + scale = PM_CmdScale(&pm->cmd) * 2; - PM_GetMove( &fmove, &smove ); + PM_GetMove(&fmove, &smove); - pm->ps->pm_time = 0; + pm->ps->pm_time = 0; - for( i = 0; i < 3; i++ ) - { - wishvel[ i ] = pml.flat_forward[ i ] * fmove - pml.flat_left[ i ] * smove; - } + for (i = 0; i < 3; i++) { + wishvel[i] = pml.flat_forward[i] * fmove - pml.flat_left[i] * smove; + } - wishvel[ 2 ] += pm->cmd.upmove; + wishvel[2] += pm->cmd.upmove; - VectorCopy( wishvel, wishdir ); - wishspeed = VectorNormalize( wishdir ); - wishspeed *= scale; + VectorCopy(wishvel, wishdir); + wishspeed = VectorNormalize(wishdir); + wishspeed *= scale; - PM_Accelerate( wishdir, wishspeed, pm_accelerate ); + PM_Accelerate(wishdir, wishspeed, pm_accelerate); - // move - VectorMA( pm->ps->origin, pml.frametime, pm->ps->velocity, pm->ps->origin ); + // move + VectorMA(pm->ps->origin, pml.frametime, pm->ps->velocity, pm->ps->origin); + + // Added in 2.0 + // If the player is out of bounds in noclip mode, + // teleport it back to the (0,0,0) coordinates + for (i = 0; i < 3; i++) { + if (fabs(pm->ps->origin[i]) >= MAX_MAP_BOUNDS - 512) { + VectorClear(pm->ps->origin); + break; + } + } } //============================================================================ @@ -801,74 +738,62 @@ PM_CrashLand Check for hard landings that generate sound events ================= */ -static void PM_CrashLand( void ) +static void PM_CrashLand(void) { - float delta; - float dist; - float vel; - float acc; - float t; - float a, b, c, den; + float delta; + float dist; + float vel; + float acc; + float t; + float a, b, c, den; - // calculate the exact velocity on landing - dist = pm->ps->origin[ 2 ] - pml.previous_origin[ 2 ]; - vel = pml.previous_velocity[ 2 ]; - acc = -pm->ps->gravity; + // calculate the exact velocity on landing + dist = pm->ps->origin[2] - pml.previous_origin[2]; + vel = pml.previous_velocity[2]; + acc = -pm->ps->gravity; - a = acc / 2; - b = vel; - c = -dist; + a = acc / 2; + b = vel; + c = -dist; - den = b * b - 4 * a * c; - if( den < 0 ) - { - return; - } + den = b * b - 4 * a * c; + if (den < 0) { + return; + } - //t = ( -b - sqrt( den ) ) / ( 2 * a ); - t = sqrt( den ) + vel; + //t = ( -b - sqrt( den ) ) / ( 2 * a ); + t = sqrt(den) + vel; - //delta = vel + t * acc; - delta = vel - t; - delta = delta * delta * 0.0001; + //delta = vel + t * acc; + delta = vel - t; + delta = delta * delta * 0.0001; - // reduce falling damage if there is standing water - if( pm->waterlevel == 2 ) - { - delta *= 0.25f; - } + // reduce falling damage if there is standing water + if (pm->waterlevel == 2) { + delta *= 0.25f; + } - if( pm->waterlevel == 1 ) - { - delta *= 0.5f; - } + if (pm->waterlevel == 1) { + delta *= 0.5f; + } - if( delta < 1 ) - { - return; - } + if (delta < 1) { + return; + } - // SURF_NODAMAGE is used for bounce pads where you don't ever - // want to take damage or play a crunch sound - if( !( pml.groundTrace.surfaceFlags & SURF_NODAMAGE ) ) - { - if( delta > 100 ) - { - pm->pmoveEvent = EV_FALL_FATAL; - } - else if( delta > 80 ) - { - pm->pmoveEvent = EV_FALL_FAR; - } - else if( delta > 40 ) - { - pm->pmoveEvent = EV_FALL_MEDIUM; - } - else if( delta > 20 ) - { - pm->pmoveEvent = EV_FALL_SHORT; - } - } + // SURF_NODAMAGE is used for bounce pads where you don't ever + // want to take damage or play a crunch sound + if (!(pml.groundTrace.surfaceFlags & SURF_NODAMAGE)) { + if (delta > 100) { + pm->pmoveEvent = EV_FALL_FATAL; + } else if (delta > 80) { + pm->pmoveEvent = EV_FALL_FAR; + } else if (delta > 40) { + pm->pmoveEvent = EV_FALL_MEDIUM; + } else if (delta > 20) { + pm->pmoveEvent = EV_FALL_SHORT; + } + } } /* @@ -892,43 +817,45 @@ void PM_CheckStuck(void) { PM_CorrectAllSolid ============= */ -static int PM_CorrectAllSolid( trace_t *trace ) +static int PM_CorrectAllSolid(trace_t *trace) { - int i, j, k; - vec3_t point; + int i, j, k; + vec3_t point; - if ( pm->debugLevel ) { - Com_Printf("%i:allsolid\n", c_pmove); - } + if (pm->debugLevel) { + Com_Printf("%i:allsolid\n", c_pmove); + } - // jitter around - for (i = -1; i <= 1; i++) { - for (j = -1; j <= 1; j++) { - for (k = -1; k <= 1; k++) { - VectorCopy(pm->ps->origin, point); - point[0] += (float) i; - point[1] += (float) j; - point[2] += (float) k; - pm->trace( trace, point, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask, qtrue, false ); - if ( !trace->allsolid && !trace->startsolid ) { - point[0] = pm->ps->origin[0]; - point[1] = pm->ps->origin[1]; - point[2] = pm->ps->origin[2] - 0.25; + // jitter around + for (i = -1; i <= 1; i++) { + for (j = -1; j <= 1; j++) { + for (k = -1; k <= 1; k++) { + VectorCopy(pm->ps->origin, point); + point[0] += (float)i; + point[1] += (float)j; + point[2] += (float)k; + pm->trace(trace, point, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask, qtrue, false); + if (!trace->allsolid && !trace->startsolid) { + point[0] = pm->ps->origin[0]; + point[1] = pm->ps->origin[1]; + point[2] = pm->ps->origin[2] - 0.25; - pm->trace( trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask, qtrue, false ); - pml.groundTrace = *trace; - pm->ps->groundTrace = *trace; - return qtrue; - } - } - } - } + pm->trace( + trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask, qtrue, false + ); + pml.groundTrace = *trace; + pm->ps->groundTrace = *trace; + return qtrue; + } + } + } + } - //pm->ps->groundEntityNum = ENTITYNUM_NONE; - //pml.groundPlane = qfalse; - //pml.walking = qfalse; + //pm->ps->groundEntityNum = ENTITYNUM_NONE; + //pml.groundPlane = qfalse; + //pml.walking = qfalse; - return qfalse; + return qfalse; } /* @@ -936,146 +863,140 @@ static int PM_CorrectAllSolid( trace_t *trace ) PM_GroundTrace ============= */ -static void PM_GroundTrace( void ) { - vec3_t point; - trace_t trace; +static void PM_GroundTrace(void) +{ + vec3_t point; + trace_t trace; - point[ 0 ] = pm->ps->origin[ 0 ]; - point[ 1 ] = pm->ps->origin[ 1 ]; - point[ 2 ] = pm->ps->origin[ 2 ] - 0.25f; + point[0] = pm->ps->origin[0]; + point[1] = pm->ps->origin[1]; + point[2] = pm->ps->origin[2] - 0.25f; - pm->trace( &trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask, qtrue, qfalse ); + pm->trace(&trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask, qtrue, qfalse); - pml.groundTrace = trace; - pm->ps->groundTrace = trace; + pml.groundTrace = trace; + pm->ps->groundTrace = trace; - // do something corrective if the trace starts in a solid... - if ( trace.allsolid || trace.startsolid ) - { - if( !PM_CorrectAllSolid( &trace ) ) { - trace.fraction = 1.0f; - } - } + // do something corrective if the trace starts in a solid... + if (trace.allsolid || trace.startsolid) { + if (!PM_CorrectAllSolid(&trace)) { + trace.fraction = 1.0f; + } + } - // if the trace didn't hit anything, we are in free fall - if ( trace.fraction == 1.0 ) - { - pm->ps->groundEntityNum = ENTITYNUM_NONE; - pml.groundPlane = qfalse; - pml.walking = qfalse; + // if the trace didn't hit anything, we are in free fall + if (trace.fraction == 1.0) { + pm->ps->groundEntityNum = ENTITYNUM_NONE; + pml.groundPlane = qfalse; + pml.walking = qfalse; - pm->ps->walking = pml.walking; - pm->ps->groundPlane = pml.groundPlane; - return; - } + pm->ps->walking = pml.walking; + pm->ps->groundPlane = pml.groundPlane; + return; + } - // check if getting thrown off the ground - if( pm->ps->velocity[ 2 ] > 0.0f && DotProduct( pm->ps->velocity, trace.plane.normal ) > 150.0f ) - { - if ( pm->debugLevel ) { - Com_Printf("%i:kickoff\n", c_pmove); - } + // check if getting thrown off the ground + if (pm->ps->velocity[2] > 0.0f && DotProduct(pm->ps->velocity, trace.plane.normal) > 150.0f) { + if (pm->debugLevel) { + Com_Printf("%i:kickoff\n", c_pmove); + } - pm->ps->groundEntityNum = ENTITYNUM_NONE; - pml.groundPlane = qfalse; - pml.walking = qfalse; + pm->ps->groundEntityNum = ENTITYNUM_NONE; + pml.groundPlane = qfalse; + pml.walking = qfalse; - pm->ps->walking = pml.walking; - pm->ps->groundPlane = pml.groundPlane; - return; - } + pm->ps->walking = pml.walking; + pm->ps->groundPlane = pml.groundPlane; + return; + } - // slopes that are too steep will not be considered onground - if( trace.plane.normal[ 2 ] < MIN_WALK_NORMAL ) - { - vec3_t oldvel; - float d; + // slopes that are too steep will not be considered onground + if (trace.plane.normal[2] < MIN_WALK_NORMAL) { + vec3_t oldvel; + float d; - if ( pm->debugLevel ) { - Com_Printf("%i:steep\n", c_pmove); - } + if (pm->debugLevel) { + Com_Printf("%i:steep\n", c_pmove); + } - VectorCopy( pm->ps->velocity, oldvel ); - VectorSet( pm->ps->velocity, 0, 0, -1.0f / pml.frametime ); - PM_SlideMove( qfalse ); + VectorCopy(pm->ps->velocity, oldvel); + VectorSet(pm->ps->velocity, 0, 0, -1.0f / pml.frametime); + PM_SlideMove(qfalse); - d = VectorLength( pm->ps->velocity ); - VectorCopy( oldvel, pm->ps->velocity ); + d = VectorLength(pm->ps->velocity); + VectorCopy(oldvel, pm->ps->velocity); - if( d > ( 0.1f / pml.frametime ) ) - { - pm->ps->groundEntityNum = ENTITYNUM_NONE; - pml.groundPlane = qtrue; - pml.walking = qfalse; + if (d > (0.1f / pml.frametime)) { + pm->ps->groundEntityNum = ENTITYNUM_NONE; + pml.groundPlane = qtrue; + pml.walking = qfalse; - pm->ps->walking = pml.walking; - pm->ps->groundPlane = pml.groundPlane; - return; - } - } + pm->ps->walking = pml.walking; + pm->ps->groundPlane = pml.groundPlane; + return; + } + } - pml.groundPlane = qtrue; - pml.walking = qtrue; + pml.groundPlane = qtrue; + pml.walking = qtrue; - if ( pm->ps->groundEntityNum == ENTITYNUM_NONE ) - { - // just hit the ground - if ( pm->debugLevel ) { - Com_Printf( "%i:Land\n", c_pmove ); - } + if (pm->ps->groundEntityNum == ENTITYNUM_NONE) { + // just hit the ground + if (pm->debugLevel) { + Com_Printf("%i:Land\n", c_pmove); + } - PM_CrashLand(); - } + PM_CrashLand(); + } - pm->ps->groundEntityNum = trace.entityNum; + pm->ps->groundEntityNum = trace.entityNum; - PM_AddTouchEnt( trace.entityNum ); + PM_AddTouchEnt(trace.entityNum); - pm->ps->walking = pml.walking; - pm->ps->groundPlane = pml.groundPlane; + pm->ps->walking = pml.walking; + pm->ps->groundPlane = pml.groundPlane; } - /* ============= PM_SetWaterLevel FIXME: avoid this twice? certainly if not moving ============= */ -static void PM_SetWaterLevel( void ) { - vec3_t point; - int cont; - int sample1; - int sample2; +static void PM_SetWaterLevel(void) +{ + vec3_t point; + int cont; + int sample1; + int sample2; - // - // get waterlevel, accounting for ducking - // - pm->waterlevel = 0; - pm->watertype = 0; + // + // get waterlevel, accounting for ducking + // + pm->waterlevel = 0; + pm->watertype = 0; - point[0] = pm->ps->origin[0]; - point[1] = pm->ps->origin[1]; - point[2] = pm->ps->origin[2] + MINS_Z + 1; - cont = pm->pointcontents( point, pm->ps->clientNum ); + point[0] = pm->ps->origin[0]; + point[1] = pm->ps->origin[1]; + point[2] = pm->ps->origin[2] + MINS_Z + 1; + cont = pm->pointcontents(point, pm->ps->clientNum); - if ( cont & MASK_WATER ) { - sample2 = pm->ps->viewheight - MINS_Z; - sample1 = sample2 / 2; - - pm->watertype = cont; - pm->waterlevel = 1; - point[2] = pm->ps->origin[2] + MINS_Z + sample1; - cont = pm->pointcontents (point, pm->ps->clientNum ); - if ( cont & MASK_WATER ) { - pm->waterlevel = 2; - point[2] = pm->ps->origin[2] + MINS_Z + sample2; - cont = pm->pointcontents (point, pm->ps->clientNum ); - if ( cont & MASK_WATER ){ - pm->waterlevel = 3; - } - } - } + if (cont & MASK_WATER) { + sample2 = pm->ps->viewheight - MINS_Z; + sample1 = sample2 / 2; + pm->watertype = cont; + pm->waterlevel = 1; + point[2] = pm->ps->origin[2] + MINS_Z + sample1; + cont = pm->pointcontents(point, pm->ps->clientNum); + if (cont & MASK_WATER) { + pm->waterlevel = 2; + point[2] = pm->ps->origin[2] + MINS_Z + sample2; + cont = pm->pointcontents(point, pm->ps->clientNum); + if (cont & MASK_WATER) { + pm->waterlevel = 3; + } + } + } } /* @@ -1085,159 +1006,134 @@ PM_CheckDuck Sets mins, maxs, and pm->ps->viewheight ============== */ -static void PM_CheckDuck( void ) +static void PM_CheckDuck(void) { - pm->mins[ 0 ] = -15.0f; - pm->mins[ 1 ] = -15.0f; + pm->mins[0] = -15.0f; + pm->mins[1] = -15.0f; - pm->maxs[ 0 ] = 15.0f; - pm->maxs[ 1 ] = 15.0f; + pm->maxs[0] = 15.0f; + pm->maxs[1] = 15.0f; - pm->mins[ 2 ] = MINS_Z; + pm->mins[2] = MINS_Z; - if( pm->ps->pm_type == PM_DEAD ) - { - pm->maxs[ 2 ] = DEAD_MINS_Z; - pm->ps->viewheight = CROUCH_VIEWHEIGHT; - return; - } + if (pm->ps->pm_type == PM_DEAD) { + pm->maxs[2] = DEAD_MINS_Z; + pm->ps->viewheight = CROUCH_VIEWHEIGHT; + return; + } - if (pm->protocol >= protocol_e::PROTOCOL_MOHTA_MIN) { - // - // Prone was removed in 2.0 - // - if (pm->ps->pm_flags & PMF_DUCKED) - { - pm->maxs[2] = 54.f; - pm->ps->viewheight = CROUCH_VIEWHEIGHT; - } - else if (pm->ps->pm_flags & PMF_VIEW_JUMP_START) - { - pm->maxs[2] = 94.0f; - pm->ps->viewheight = JUMP_START_VIEWHEIGHT; - } - else - { - pm->maxs[2] = 94.0f; - pm->ps->viewheight = DEFAULT_VIEWHEIGHT; - } - } else { - if ((pm->ps->pm_flags & (PMF_DUCKED | PMF_VIEW_PRONE)) == (PMF_DUCKED | PMF_VIEW_PRONE)) - { - pm->maxs[2] = 54.0f; - pm->ps->viewheight = CROUCH_VIEWHEIGHT; - } - else if (pm->ps->pm_flags & PMF_DUCKED) - { - pm->maxs[2] = 60.0f; - pm->ps->viewheight = CROUCH_VIEWHEIGHT; - } - else if (pm->ps->pm_flags & PMF_VIEW_PRONE) - { - pm->maxs[2] = 20.0f; - pm->ps->viewheight = PRONE_VIEWHEIGHT; - } - else if (pm->ps->pm_flags & PMF_VIEW_DUCK_RUN) - { - pm->maxs[2] = 94.0f; - pm->mins[2] = 54.0f; - pm->ps->viewheight = DEFAULT_VIEWHEIGHT; - } - else if (pm->ps->pm_flags & PMF_VIEW_JUMP_START) - { - pm->maxs[2] = 94.0f; - pm->ps->viewheight = JUMP_START_VIEWHEIGHT; - } - else - { - pm->maxs[2] = 94.0f; - pm->ps->viewheight = DEFAULT_VIEWHEIGHT; - } - } + if (pm->protocol >= protocol_e::PROTOCOL_MOHTA_MIN) { + // + // Prone was removed in 2.0 + // + if (pm->ps->pm_flags & PMF_DUCKED) { + pm->maxs[2] = 54.f; + pm->ps->viewheight = CROUCH_VIEWHEIGHT; + } else if (pm->ps->pm_flags & PMF_VIEW_JUMP_START) { + pm->maxs[2] = 94.0f; + pm->ps->viewheight = JUMP_START_VIEWHEIGHT; + } else { + pm->maxs[2] = 94.0f; + pm->ps->viewheight = DEFAULT_VIEWHEIGHT; + } + } else { + if ((pm->ps->pm_flags & (PMF_DUCKED | PMF_VIEW_PRONE)) == (PMF_DUCKED | PMF_VIEW_PRONE)) { + pm->maxs[2] = 54.0f; + pm->ps->viewheight = CROUCH_VIEWHEIGHT; + } else if (pm->ps->pm_flags & PMF_DUCKED) { + pm->maxs[2] = 60.0f; + pm->ps->viewheight = CROUCH_VIEWHEIGHT; + } else if (pm->ps->pm_flags & PMF_VIEW_PRONE) { + pm->maxs[2] = 20.0f; + pm->ps->viewheight = PRONE_VIEWHEIGHT; + } else if (pm->ps->pm_flags & PMF_VIEW_DUCK_RUN) { + pm->maxs[2] = 94.0f; + pm->mins[2] = 54.0f; + pm->ps->viewheight = DEFAULT_VIEWHEIGHT; + } else if (pm->ps->pm_flags & PMF_VIEW_JUMP_START) { + pm->maxs[2] = 94.0f; + pm->ps->viewheight = JUMP_START_VIEWHEIGHT; + } else { + pm->maxs[2] = 94.0f; + pm->ps->viewheight = DEFAULT_VIEWHEIGHT; + } + } } - - //=================================================================== - /* =============== PM_Footsteps =============== */ -static void PM_Footsteps( void ) { - float bobmove; - int old; - qboolean footstep; +static void PM_Footsteps(void) +{ + float bobmove; + int old; + qboolean footstep; - // - // calculate speed and cycle to be used for - // all cyclic walking effects - // - pm->xyspeed = sqrt( pm->ps->velocity[0] * pm->ps->velocity[0] - + pm->ps->velocity[1] * pm->ps->velocity[1] ); + // + // calculate speed and cycle to be used for + // all cyclic walking effects + // + pm->xyspeed = sqrt(pm->ps->velocity[0] * pm->ps->velocity[0] + pm->ps->velocity[1] * pm->ps->velocity[1]); - if ( pm->ps->groundEntityNum == ENTITYNUM_NONE ) { + if (pm->ps->groundEntityNum == ENTITYNUM_NONE) { + // if ( pm->ps->powerups[PW_INVULNERABILITY] ) { + // PM_ContinueLegsAnim( LEGS_IDLECR ); + // } + // airborne leaves position in cycle intact, but doesn't advance + if (pm->waterlevel > 1) { + // PM_ContinueLegsAnim( LEGS_SWIM ); + } + return; + } -// if ( pm->ps->powerups[PW_INVULNERABILITY] ) { -// PM_ContinueLegsAnim( LEGS_IDLECR ); -// } - // airborne leaves position in cycle intact, but doesn't advance - if ( pm->waterlevel > 1 ) { -// PM_ContinueLegsAnim( LEGS_SWIM ); - } - return; - } + // if not trying to move + if (!pm->cmd.forwardmove && !pm->cmd.rightmove) { + if (pm->xyspeed < 5) { + pm->ps->bobCycle = 0; // start at beginning of cycle again + if (pm->ps->pm_flags & PMF_DUCKED) { + // PM_ContinueLegsAnim( LEGS_IDLECR ); + } else { + // PM_ContinueLegsAnim( LEGS_IDLE ); + } + } + return; + } - // if not trying to move - if ( !pm->cmd.forwardmove && !pm->cmd.rightmove ) { - if ( pm->xyspeed < 5 ) { - pm->ps->bobCycle = 0; // start at beginning of cycle again - if ( pm->ps->pm_flags & PMF_DUCKED ) { -// PM_ContinueLegsAnim( LEGS_IDLECR ); - } else { -// PM_ContinueLegsAnim( LEGS_IDLE ); - } - } - return; - } + footstep = qfalse; + if (!(pm->cmd.buttons & BUTTON_RUN)) { + bobmove = 0.4f; // faster speeds bob faster - footstep = qfalse; + footstep = qtrue; + } else { + bobmove = 0.3f; // walking bobs slow + } + // check for footstep / splash sounds + old = pm->ps->bobCycle; + pm->ps->bobCycle = (int)(old + bobmove * pml.msec) & 255; - if( !( pm->cmd.buttons & BUTTON_RUN ) ) - { - bobmove = 0.4f; // faster speeds bob faster - - footstep = qtrue; - } else { - bobmove = 0.3f; // walking bobs slow - } - - // check for footstep / splash sounds - old = pm->ps->bobCycle; - pm->ps->bobCycle = (int)( old + bobmove * pml.msec ) & 255; - - // if we just crossed a cycle boundary, play an apropriate footstep event - if ( ( ( old + 64 ) ^ ( pm->ps->bobCycle + 64 ) ) & 128 ) { - if ( pm->waterlevel == 0 ) { - // on ground will only play sounds if running - if ( footstep && !pm->noFootsteps ) { -// PM_AddEvent( PM_FootstepForSurface() ); - } - } else if ( pm->waterlevel == 1 ) { - // splashing -// PM_AddEvent( EV_FOOTSPLASH ); - } else if ( pm->waterlevel == 2 ) { - // wading / swimming at surface -// PM_AddEvent( EV_SWIM ); - } else if ( pm->waterlevel == 3 ) { - // no sound when completely underwater - - } - } + // if we just crossed a cycle boundary, play an apropriate footstep event + if (((old + 64) ^ (pm->ps->bobCycle + 64)) & 128) { + if (pm->waterlevel == 0) { + // on ground will only play sounds if running + if (footstep && !pm->noFootsteps) { + // PM_AddEvent( PM_FootstepForSurface() ); + } + } else if (pm->waterlevel == 1) { + // splashing + // PM_AddEvent( EV_FOOTSPLASH ); + } else if (pm->waterlevel == 2) { + // wading / swimming at surface + // PM_AddEvent( EV_SWIM ); + } else if (pm->waterlevel == 3) { + // no sound when completely underwater + } + } } /* @@ -1247,62 +1143,51 @@ PM_WaterEvents Generate sound events for entering and leaving water ============== */ -static void PM_WaterEvents( void ) +static void PM_WaterEvents(void) { - // FIXME? - // - // if just entered a water volume, play a sound - // - if( !pml.previous_waterlevel && pm->waterlevel ) - { - pm->pmoveEvent = EV_WATER_TOUCH; - } + // FIXME? + // + // if just entered a water volume, play a sound + // + if (!pml.previous_waterlevel && pm->waterlevel) { + pm->pmoveEvent = EV_WATER_TOUCH; + } - // - // if just completely exited a water volume, play a sound - // - if( pml.previous_waterlevel && !pm->waterlevel ) - { - pm->pmoveEvent = EV_WATER_LEAVE; - } + // + // if just completely exited a water volume, play a sound + // + if (pml.previous_waterlevel && !pm->waterlevel) { + pm->pmoveEvent = EV_WATER_LEAVE; + } - // - // check for head just going under water - // - if( ( pml.previous_waterlevel != 3 ) && ( pm->waterlevel == 3 ) ) - { - pm->pmoveEvent = EV_WATER_UNDER; - } + // + // check for head just going under water + // + if ((pml.previous_waterlevel != 3) && (pm->waterlevel == 3)) { + pm->pmoveEvent = EV_WATER_UNDER; + } - // - // check for head just coming out of water - // - if( ( pml.previous_waterlevel == 3 ) && ( pm->waterlevel != 3 ) ) - { - pm->pmoveEvent = EV_WATER_CLEAR; - } + // + // check for head just coming out of water + // + if ((pml.previous_waterlevel == 3) && (pm->waterlevel != 3)) { + pm->pmoveEvent = EV_WATER_CLEAR; + } } - /* =============== PM_BeginWeaponChange =============== */ -static void PM_BeginWeaponChange( int weapon ) { - -} - +static void PM_BeginWeaponChange(int weapon) {} /* =============== PM_FinishWeaponChange =============== */ -static void PM_FinishWeaponChange( void ) { - -} - +static void PM_FinishWeaponChange(void) {} /* ============== @@ -1310,18 +1195,18 @@ PM_TorsoAnimation ============== */ -static void PM_TorsoAnimation( void ) { - //if ( pm->ps->weaponstate == WEAPON_READY ) { - // if ( pm->ps->weapon == WP_GAUNTLET ) { - // PM_ContinueTorsoAnim( TORSO_STAND2 ); - // } else { - // PM_ContinueTorsoAnim( TORSO_STAND ); - // } - // return; - //} +static void PM_TorsoAnimation(void) +{ + //if ( pm->ps->weaponstate == WEAPON_READY ) { + // if ( pm->ps->weapon == WP_GAUNTLET ) { + // PM_ContinueTorsoAnim( TORSO_STAND2 ); + // } else { + // PM_ContinueTorsoAnim( TORSO_STAND ); + // } + // return; + //} } - /* ============== PM_Weapon @@ -1329,9 +1214,7 @@ PM_Weapon Generates weapon events and modifes the weapon counter ============== */ -static void PM_Weapon( void ) { - -} +static void PM_Weapon(void) {} /* ================ @@ -1339,19 +1222,16 @@ PM_Animate ================ */ -static void PM_Animate( void ) { - -} - +static void PM_Animate(void) {} /* ================ PM_DropTimers ================ */ -static void PM_DropTimers( void ) +static void PM_DropTimers(void) { - pm->ps->pm_flags &= ~PMF_RESPAWNED; + pm->ps->pm_flags &= ~PMF_RESPAWNED; } /* @@ -1362,47 +1242,39 @@ This can be used as another entry point when only the viewangles are being updated isntead of a full move ================ */ -void PM_UpdateViewAngles( playerState_t *ps, const usercmd_t *cmd ) +void PM_UpdateViewAngles(playerState_t *ps, const usercmd_t *cmd) { - short temp; - int i; + short temp; + int i; - if( ps->pm_flags & PMF_FROZEN ) - { - // no view changes at all - return; - } + if (ps->pm_flags & PMF_FROZEN) { + // no view changes at all + return; + } - if( ps->stats[ STAT_HEALTH ] <= 0 ) - { - // no view changes at all - return; - } + if (ps->stats[STAT_HEALTH] <= 0) { + // no view changes at all + return; + } - // circularly clamp the angles with deltas - for( i = 0; i < 3; i++ ) - { - temp = cmd->angles[ i ] + ps->delta_angles[ i ]; - if( i == PITCH ) - { - // don't let the player look up or down more than 90 degrees - if( temp > 16000 ) - { - ps->delta_angles[ i ] = 16000 - cmd->angles[ i ]; - temp = 16000; - } - else if( temp < -16000 ) - { - ps->delta_angles[ i ] = -16000 - cmd->angles[ i ]; - temp = -16000; - } - } + // circularly clamp the angles with deltas + for (i = 0; i < 3; i++) { + temp = cmd->angles[i] + ps->delta_angles[i]; + if (i == PITCH) { + // don't let the player look up or down more than 90 degrees + if (temp > 16000) { + ps->delta_angles[i] = 16000 - cmd->angles[i]; + temp = 16000; + } else if (temp < -16000) { + ps->delta_angles[i] = -16000 - cmd->angles[i]; + temp = -16000; + } + } - ps->viewangles[ i ] = SHORT2ANGLE( temp ); - } + ps->viewangles[i] = SHORT2ANGLE(temp); + } } - /* ================ PmoveSingle @@ -1410,242 +1282,216 @@ PmoveSingle ================ */ -void PmoveSingle( pmove_t *pmove ) +void PmoveSingle(pmove_t *pmove) { - vec3_t tempVec; - qboolean walking; + vec3_t tempVec; + qboolean walking; - pm = pmove; + pm = pmove; - // this counter lets us debug movement problems with a journal - // by setting a conditional breakpoint fot the previous frame - c_pmove++; + // this counter lets us debug movement problems with a journal + // by setting a conditional breakpoint fot the previous frame + c_pmove++; - // clear results - pm->numtouch = 0; - pm->watertype = 0; - pm->waterlevel = 0; + // clear results + pm->numtouch = 0; + pm->watertype = 0; + pm->waterlevel = 0; - if( pm->ps->stats[ STAT_HEALTH ] <= 0 ) { - pm->tracemask &= ~( CONTENTS_BODY | CONTENTS_NOBOTCLIP ); // corpses can fly through bodies - } + if (pm->ps->stats[STAT_HEALTH] <= 0) { + pm->tracemask &= ~(CONTENTS_BODY | CONTENTS_NOBOTCLIP); // corpses can fly through bodies + } - if( pmove->cmd.buttons & BUTTON_TALK ) - { - pmove->cmd.forwardmove = 0; - pmove->cmd.rightmove = 0; - pmove->cmd.upmove = 0; - pmove->cmd.buttons = BUTTON_TALK; - pm->ps->fLeanAngle = 0.0f; - } + if (pmove->cmd.buttons & BUTTON_TALK) { + pmove->cmd.forwardmove = 0; + pmove->cmd.rightmove = 0; + pmove->cmd.upmove = 0; + pmove->cmd.buttons = BUTTON_TALK; + pm->ps->fLeanAngle = 0.0f; + } - if( pm->ps->pm_type == PM_CLIMBWALL ) - { - pm->ps->fLeanAngle = 0.0f; - pm->cmd.buttons &= ~( BUTTON_LEAN_LEFT | BUTTON_LEAN_RIGHT ); - } + if (pm->ps->pm_type == PM_CLIMBWALL) { + pm->ps->fLeanAngle = 0.0f; + pm->cmd.buttons &= ~(BUTTON_LEAN_LEFT | BUTTON_LEAN_RIGHT); + } - // clear all pmove local vars - memset( &pml, 0, sizeof( pml ) ); + // clear all pmove local vars + memset(&pml, 0, sizeof(pml)); - // determine the time - pml.msec = pmove->cmd.serverTime - pm->ps->commandTime; - if ( pml.msec < 1 ) { - pml.msec = 1; - } else if ( pml.msec > 200 ) { - pml.msec = 200; - } + // determine the time + pml.msec = pmove->cmd.serverTime - pm->ps->commandTime; + if (pml.msec < 1) { + pml.msec = 1; + } else if (pml.msec > 200) { + pml.msec = 200; + } - pm->ps->commandTime = pmove->cmd.serverTime; + pm->ps->commandTime = pmove->cmd.serverTime; - // save old org in case we get stuck - VectorCopy( pm->ps->origin, pml.previous_origin ); + // save old org in case we get stuck + VectorCopy(pm->ps->origin, pml.previous_origin); - // save old velocity for crashlanding - VectorCopy( pm->ps->velocity, pml.previous_velocity ); + // save old velocity for crashlanding + VectorCopy(pm->ps->velocity, pml.previous_velocity); - pml.frametime = pml.msec * 0.001; + pml.frametime = pml.msec * 0.001; - if ((pm->cmd.buttons & (BUTTON_LEAN_LEFT | BUTTON_LEAN_RIGHT) && - (pm->cmd.buttons & (BUTTON_LEAN_LEFT | BUTTON_LEAN_RIGHT)) != (BUTTON_LEAN_LEFT | BUTTON_LEAN_RIGHT)) && - (!pm->cmd.forwardmove || pm->alwaysAllowLean) && - (!pm->cmd.rightmove || pm->alwaysAllowLean) && - (!pm->cmd.upmove || pm->alwaysAllowLean)) - { - if( pm->cmd.buttons & BUTTON_LEAN_LEFT ) - { - if( pm->ps->fLeanAngle <= -pm->leanMax) - { - pm->ps->fLeanAngle = -pm->leanMax; - } - else - { - float fAngle = pml.frametime * ( -pm->leanMax - pm->ps->fLeanAngle ) * pm->leanAdd; - float fLeanAngle = pml.frametime * -pm->leanSpeed; + if ((pm->cmd.buttons & (BUTTON_LEAN_LEFT | BUTTON_LEAN_RIGHT) + && (pm->cmd.buttons & (BUTTON_LEAN_LEFT | BUTTON_LEAN_RIGHT)) != (BUTTON_LEAN_LEFT | BUTTON_LEAN_RIGHT)) + && (!pm->cmd.forwardmove || pm->alwaysAllowLean) && (!pm->cmd.rightmove || pm->alwaysAllowLean) + && (!pm->cmd.upmove || pm->alwaysAllowLean)) { + if (pm->cmd.buttons & BUTTON_LEAN_LEFT) { + if (pm->ps->fLeanAngle <= -pm->leanMax) { + pm->ps->fLeanAngle = -pm->leanMax; + } else { + float fAngle = pml.frametime * (-pm->leanMax - pm->ps->fLeanAngle) * pm->leanAdd; + float fLeanAngle = pml.frametime * -pm->leanSpeed; - if( fAngle <= fLeanAngle ) { - fLeanAngle = fAngle; - } + if (fAngle <= fLeanAngle) { + fLeanAngle = fAngle; + } - pm->ps->fLeanAngle += fLeanAngle; - } - } - else - { - if( pm->ps->fLeanAngle >= pm->leanMax ) - { - pm->ps->fLeanAngle = pm->leanMax; - } - else - { - float fAngle = pm->leanMax - pm->ps->fLeanAngle; - float fLeanAngle = pml.frametime * pm->leanSpeed; - float fMult = pml.frametime * fAngle * pm->leanAdd; + pm->ps->fLeanAngle += fLeanAngle; + } + } else { + if (pm->ps->fLeanAngle >= pm->leanMax) { + pm->ps->fLeanAngle = pm->leanMax; + } else { + float fAngle = pm->leanMax - pm->ps->fLeanAngle; + float fLeanAngle = pml.frametime * pm->leanSpeed; + float fMult = pml.frametime * fAngle * pm->leanAdd; - if( fLeanAngle <= fMult ) - { - fLeanAngle = fMult; - } - else - { - fLeanAngle = fMult; - } + if (fLeanAngle <= fMult) { + fLeanAngle = fMult; + } else { + fLeanAngle = fMult; + } - pm->ps->fLeanAngle += fLeanAngle; - } - } - } - else if( pm->ps->fLeanAngle ) - { - float fAngle = pm->ps->fLeanAngle * pml.frametime * pm->leanRecoverSpeed; + pm->ps->fLeanAngle += fLeanAngle; + } + } + } else if (pm->ps->fLeanAngle) { + float fAngle = pm->ps->fLeanAngle * pml.frametime * pm->leanRecoverSpeed; - if( pm->ps->fLeanAngle <= 0.0f ) - { - float fLeanAngle = pml.frametime * -pm->leanSpeed; + if (pm->ps->fLeanAngle <= 0.0f) { + float fLeanAngle = pml.frametime * -pm->leanSpeed; - if(fLeanAngle >= fAngle) { - fLeanAngle = fAngle; - } + if (fLeanAngle >= fAngle) { + fLeanAngle = fAngle; + } - pm->ps->fLeanAngle -= fLeanAngle; - if (pm->ps->fLeanAngle > 0) { - pm->ps->fLeanAngle = 0; - } - } - else - { - float fLeanAngle = pml.frametime * pm->leanSpeed; + pm->ps->fLeanAngle -= fLeanAngle; + if (pm->ps->fLeanAngle > 0) { + pm->ps->fLeanAngle = 0; + } + } else { + float fLeanAngle = pml.frametime * pm->leanSpeed; - if(fLeanAngle <= fAngle) { - fLeanAngle = fAngle; - } + if (fLeanAngle <= fAngle) { + fLeanAngle = fAngle; + } pm->ps->fLeanAngle -= fLeanAngle; if (pm->ps->fLeanAngle < 0) { pm->ps->fLeanAngle = 0; } - } - } + } + } - if (pm->ps->pm_flags & PMF_NO_LEAN) { - pm->ps->fLeanAngle = 0; - } + if (pm->ps->pm_flags & PMF_NO_LEAN) { + pm->ps->fLeanAngle = 0; + } - // update the viewangles - PM_UpdateViewAngles( pm->ps, &pm->cmd ); + // update the viewangles + PM_UpdateViewAngles(pm->ps, &pm->cmd); - AngleVectorsLeft( pm->ps->viewangles, pml.forward, pml.left, pml.up ); - VectorClear( tempVec ); - tempVec[ YAW ] = pm->ps->viewangles[ YAW ]; - AngleVectorsLeft( tempVec, pml.flat_forward, pml.flat_left, pml.flat_up ); + AngleVectorsLeft(pm->ps->viewangles, pml.forward, pml.left, pml.up); + VectorClear(tempVec); + tempVec[YAW] = pm->ps->viewangles[YAW]; + AngleVectorsLeft(tempVec, pml.flat_forward, pml.flat_left, pml.flat_up); - if ( pm->ps->pm_type >= PM_DEAD ) - { - pm->cmd.forwardmove = 0; - pm->cmd.rightmove = 0; - pm->cmd.upmove = 0; - pm->ps->fLeanAngle = 0.0f; - } + if (pm->ps->pm_type >= PM_DEAD) { + pm->cmd.forwardmove = 0; + pm->cmd.rightmove = 0; + pm->cmd.upmove = 0; + pm->ps->fLeanAngle = 0.0f; + } - if ( pm->ps->pm_type == PM_NOCLIP ) - { - PM_NoclipMove(); - PM_DropTimers(); - return; - } + if (pm->ps->pm_type == PM_NOCLIP) { + PM_NoclipMove(); + PM_DropTimers(); + return; + } - if( ( pm->ps->pm_flags & PMF_NO_MOVE ) || ( pm->ps->pm_flags & PMF_FROZEN ) ) - { - PM_CheckDuck(); - return; - } + if ((pm->ps->pm_flags & PMF_NO_MOVE) || (pm->ps->pm_flags & PMF_FROZEN)) { + PM_CheckDuck(); + return; + } - // set watertype, and waterlevel - PM_SetWaterLevel(); - pml.previous_waterlevel = pmove->waterlevel; + // set watertype, and waterlevel + PM_SetWaterLevel(); + pml.previous_waterlevel = pmove->waterlevel; - // set mins, maxs, and viewheight - PM_CheckDuck(); + // set mins, maxs, and viewheight + PM_CheckDuck(); - // set groundentity - PM_GroundTrace(); + // set groundentity + PM_GroundTrace(); - if ( pm->ps->pm_type == PM_DEAD ) { - PM_DeadMove(); - } + if (pm->ps->pm_type == PM_DEAD) { + PM_DeadMove(); + } - PM_DropTimers(); + PM_DropTimers(); - if ( pml.walking ) { - // walking on ground - PM_WalkMove(); - } else { - // airborne - PM_AirMove(); - } + if (pml.walking) { + // walking on ground + PM_WalkMove(); + } else { + // airborne + PM_AirMove(); + } - walking = pml.walking; + walking = pml.walking; - // set groundentity, watertype, and waterlevel - PM_GroundTrace(); - PM_SetWaterLevel(); + // set groundentity, watertype, and waterlevel + PM_GroundTrace(); + PM_SetWaterLevel(); - // don't fall down stairs or do really short falls - if( !pml.walking && ( walking || ( ( pml.previous_velocity[ 2 ] >= 0 ) && ( pm->ps->velocity[ 2 ] <= 0 ) ) ) ) - { - vec3_t point; - trace_t trace; + // don't fall down stairs or do really short falls + if (!pml.walking && (walking || ((pml.previous_velocity[2] >= 0) && (pm->ps->velocity[2] <= 0)))) { + vec3_t point; + trace_t trace; - point[ 0 ] = pm->ps->origin[ 0 ]; - point[ 1 ] = pm->ps->origin[ 1 ]; - point[ 2 ] = pm->ps->origin[ 2 ] - STEPSIZE; + point[0] = pm->ps->origin[0]; + point[1] = pm->ps->origin[1]; + point[2] = pm->ps->origin[2] - STEPSIZE; - pm->trace( &trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask, qtrue, qfalse ); - if( ( trace.fraction < 1.0f ) && ( !trace.allsolid ) ) - { - VectorCopy( trace.endpos, pm->ps->origin ); + pm->trace(&trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask, qtrue, qfalse); + if ((trace.fraction < 1.0f) && (!trace.allsolid)) { + VectorCopy(trace.endpos, pm->ps->origin); - // allow client to smooth out the step - pm->stepped = qtrue; + // allow client to smooth out the step + pm->stepped = qtrue; - // requantify the player's position - PM_GroundTrace(); - PM_SetWaterLevel(); - } - } + // requantify the player's position + PM_GroundTrace(); + PM_SetWaterLevel(); + } + } - // entering / leaving water splashes - PM_WaterEvents(); + // entering / leaving water splashes + PM_WaterEvents(); } -void Pmove_GroundTrace( pmove_t *pmove ) +void Pmove_GroundTrace(pmove_t *pmove) { - memset( &pml, 0, sizeof( pml ) ); - pml.msec = 1; - pml.frametime = 0.001f; - pm = pmove; - PM_CheckDuck(); - PM_GroundTrace(); + memset(&pml, 0, sizeof(pml)); + pml.msec = 1; + pml.frametime = 0.001f; + pm = pmove; + PM_CheckDuck(); + PM_GroundTrace(); } /* @@ -1655,219 +1501,234 @@ Pmove Can be called by either the server or the client ================ */ -void Pmove( pmove_t *pmove ) { - int finalTime; - - finalTime = pmove->cmd.serverTime; - - if( finalTime < pmove->ps->commandTime ) { - return; // should not happen - } - - if( finalTime > pmove->ps->commandTime + 1000 ) { - pmove->ps->commandTime = finalTime - 1000; - } - - // chop the move up if it is too long, to prevent framerate - // dependent behavior - while( pmove->ps->commandTime != finalTime ) { - int msec; - - msec = finalTime - pmove->ps->commandTime; - - if( pmove->pmove_fixed ) - { - if( msec > pmove->pmove_msec ) - { - msec = pmove->pmove_msec; - } - } - else if( msec > 66 ) { - msec = 66; - } - - pmove->cmd.serverTime = pmove->ps->commandTime + msec; - PmoveSingle( pmove ); - } -} -static void PmoveAdjustViewAngleSettings_OnLadder( vec_t *vViewAngles, vec_t *vAngles, playerState_t *pPlayerState, entityState_t *pEntState ) +void Pmove(pmove_t *pmove) { - float fDelta; - float deltayaw; - float yawAngle; - float temp; + int finalTime; - vAngles[ 0 ] = 0.0f; - vAngles[ 2 ] = 0.0f; + finalTime = pmove->cmd.serverTime; - if( vViewAngles[ 0 ] > 73.0f ) { - vViewAngles[ 0 ] = 73.0f; - } + if (finalTime < pmove->ps->commandTime) { + return; // should not happen + } - deltayaw = AngleSubtract( vViewAngles[ 1 ], vAngles[ 1 ] ); + if (finalTime > pmove->ps->commandTime + 1000) { + pmove->ps->commandTime = finalTime - 1000; + } - yawAngle = 70.0f; - if( deltayaw <= 70.0f ) - { - yawAngle = deltayaw; - if( deltayaw < -70.0f ) - { - yawAngle = -70.0f; - } - } + // chop the move up if it is too long, to prevent framerate + // dependent behavior + while (pmove->ps->commandTime != finalTime) { + int msec; - vViewAngles[ 1 ] = vAngles[ 1 ] + yawAngle; + msec = finalTime - pmove->ps->commandTime; - fDelta = sqrt( yawAngle * yawAngle + vViewAngles[ 0 ] * vViewAngles[ 0 ] ); + if (pmove->pmove_fixed) { + if (msec > pmove->pmove_msec) { + msec = pmove->pmove_msec; + } + } else if (msec > 66) { + msec = 66; + } - if( vViewAngles[ 0 ] <= 0.0f ) { - temp = 80.0f; - } else { - temp = 73.0f; - } - - if( fDelta > temp ) - { - float deltalimit = temp * 1.0f / fDelta; - vViewAngles[ 0 ] *= deltalimit; - vViewAngles[ 1 ] = yawAngle * deltalimit + vAngles[ 1 ]; - } + pmove->cmd.serverTime = pmove->ps->commandTime + msec; + PmoveSingle(pmove); + } } -void PmoveAdjustAngleSettings( vec_t *vViewAngles, vec_t *vAngles, playerState_t *pPlayerState, entityState_t *pEntState ) +static void PmoveAdjustViewAngleSettings_OnLadder( + vec_t *vViewAngles, vec_t *vAngles, playerState_t *pPlayerState, entityState_t *pEntState +) { - vec3_t temp, temp2; - vec3_t armsAngles, torsoAngles, headAngles; - float fTmp; + float fDelta; + float deltayaw; + float yawAngle; + float temp; - if( pPlayerState->pm_type == PM_CLIMBWALL ) - { - PmoveAdjustViewAngleSettings_OnLadder( vViewAngles, vAngles, pPlayerState, pEntState ); - VectorSet( pEntState->bone_angles[ TORSO_TAG ], 0, 0, 0 ); - VectorSet( pEntState->bone_angles[ ARMS_TAG ], 0, 0, 0 ); - VectorSet( pEntState->bone_angles[ PELVIS_TAG ], 0, 0, 0 ); - QuatSet( pEntState->bone_quat[ TORSO_TAG ], 0, 0, 0, 1 ); - QuatSet( pEntState->bone_quat[ ARMS_TAG ], 0, 0, 0, 1 ); - QuatSet( pEntState->bone_quat[ PELVIS_TAG ], 0, 0, 0, 1 ); + vAngles[0] = 0.0f; + vAngles[2] = 0.0f; - AnglesSubtract( vViewAngles, vAngles, headAngles ); - VectorScale( headAngles, 0.5f, pEntState->bone_angles[ HEAD_TAG ] ); + if (vViewAngles[0] > 73.0f) { + vViewAngles[0] = 73.0f; + } - EulerToQuat( headAngles, pEntState->bone_quat[ HEAD_TAG ] ); - return; - } + deltayaw = AngleSubtract(vViewAngles[1], vAngles[1]); - if( pPlayerState->pm_type != PM_DEAD ) - { - fTmp = AngleMod( vViewAngles[ 1 ] ); - VectorSet( vAngles, 0, fTmp, 0 ); + yawAngle = 70.0f; + if (deltayaw <= 70.0f) { + yawAngle = deltayaw; + if (deltayaw < -70.0f) { + yawAngle = -70.0f; + } + } - if( !( pPlayerState->pm_flags & PMF_VIEW_PRONE ) || ( pPlayerState->pm_flags & PMF_DUCKED ) ) - { - fTmp = AngleMod( vViewAngles[ 0 ] ); + vViewAngles[1] = vAngles[1] + yawAngle; - VectorSet( temp, fTmp, 0, pPlayerState->fLeanAngle * 0.60f ); - VectorSet( temp2, fTmp, 0, pPlayerState->fLeanAngle ); + fDelta = sqrt(yawAngle * yawAngle + vViewAngles[0] * vViewAngles[0]); - if( fTmp > 180.0f ) { - temp2[ 0 ] = fTmp - 360.0f; - } + if (vViewAngles[0] <= 0.0f) { + temp = 80.0f; + } else { + temp = 73.0f; + } - temp2[ 0 ] = 0.90f * temp2[ 0 ] * 0.70f; + if (fDelta > temp) { + float deltalimit = temp * 1.0f / fDelta; + vViewAngles[0] *= deltalimit; + vViewAngles[1] = yawAngle * deltalimit + vAngles[1]; + } +} - AnglesSubtract( temp, temp2, headAngles ); - VectorCopy( headAngles, pEntState->bone_angles[ HEAD_TAG ] ); - EulerToQuat( pEntState->bone_angles[ HEAD_TAG ], pEntState->bone_quat[ HEAD_TAG ] ); +void PmoveAdjustAngleSettings(vec_t *vViewAngles, vec_t *vAngles, playerState_t *pPlayerState, entityState_t *pEntState) +{ + vec3_t temp, temp2; + vec3_t armsAngles, torsoAngles, headAngles; + float fTmp; - if( temp2[ 0 ] <= 0.0f ) - { - fTmp = -0.1f; - } - else{ - fTmp = 0.3f; - } + if (pPlayerState->pm_type == PM_DEAD) { + // set the default angles + VectorSet(pEntState->bone_angles[HEAD_TAG], 0, 0, 0); + VectorSet(pEntState->bone_angles[TORSO_TAG], 0, 0, 0); + VectorSet(pEntState->bone_angles[ARMS_TAG], 0, 0, 0); + VectorSet(pEntState->bone_angles[PELVIS_TAG], 0, 0, 0); + QuatSet(pEntState->bone_quat[HEAD_TAG], 0, 0, 0, 1); + QuatSet(pEntState->bone_quat[TORSO_TAG], 0, 0, 0, 1); + QuatSet(pEntState->bone_quat[ARMS_TAG], 0, 0, 0, 1); + QuatSet(pEntState->bone_quat[PELVIS_TAG], 0, 0, 0, 1); + } else if (pPlayerState->pm_type == PM_CLIMBWALL) { + PmoveAdjustViewAngleSettings_OnLadder(vViewAngles, vAngles, pPlayerState, pEntState); + VectorSet(pEntState->bone_angles[TORSO_TAG], 0, 0, 0); + VectorSet(pEntState->bone_angles[ARMS_TAG], 0, 0, 0); + VectorSet(pEntState->bone_angles[PELVIS_TAG], 0, 0, 0); + QuatSet(pEntState->bone_quat[TORSO_TAG], 0, 0, 0, 1); + QuatSet(pEntState->bone_quat[ARMS_TAG], 0, 0, 0, 1); + QuatSet(pEntState->bone_quat[PELVIS_TAG], 0, 0, 0, 1); - VectorSet( temp, fTmp * temp2[ 0 ], 0, pPlayerState->fLeanAngle * 0.8f ); - VectorCopy( temp, pEntState->bone_angles[ PELVIS_TAG ] ); - EulerToQuat( pEntState->bone_angles[ PELVIS_TAG ], pEntState->bone_quat[ PELVIS_TAG ] ); + AnglesSubtract(vViewAngles, vAngles, headAngles); + VectorScale(headAngles, 0.5f, pEntState->bone_angles[HEAD_TAG]); - float fDelta = ( 1.0f - fTmp ) * temp2[ 0 ]; + EulerToQuat(headAngles, pEntState->bone_quat[HEAD_TAG]); + } else { + if (pPlayerState->pm_flags & PMF_TURRET) { + vAngles[2] = 0; + // Added in 2.0 + // Clients checking this flag will draw an icon + // above the head of teammates + pEntState->eFlags |= EF_PLAYER_ARTILLERY; + } else { + fTmp = AngleMod(vViewAngles[1]); + VectorSet(vAngles, 0, fTmp, 0); + pEntState->eFlags &= ~EF_PLAYER_ARTILLERY; + } - if( vViewAngles[ 0 ] <= 0.0f ) - { - VectorSet( torsoAngles, fDelta * 0.60f, 0, pPlayerState->fLeanAngle * 0.2f * -0.1f ); - VectorSet( armsAngles, fDelta * 0.40f, 0, pPlayerState->fLeanAngle * 0.2f * 1.1f ); - } - else - { - VectorSet( torsoAngles, fDelta * 0.70f, 0, pPlayerState->fLeanAngle * 0.2f * -0.1f ); - VectorSet( armsAngles, fDelta * 0.30f, 0, pPlayerState->fLeanAngle * 0.2f * 1.1f ); - } + if (pPlayerState->pm_flags & PMF_TURRET) { + // set the default angles + VectorSet(pEntState->bone_angles[TORSO_TAG], 0, 0, 0); + VectorSet(pEntState->bone_angles[ARMS_TAG], 0, 0, 0); + VectorSet(pEntState->bone_angles[PELVIS_TAG], 0, 0, 0); + QuatSet(pEntState->bone_quat[TORSO_TAG], 0, 0, 0, 1); + QuatSet(pEntState->bone_quat[ARMS_TAG], 0, 0, 0, 1); + QuatSet(pEntState->bone_quat[PELVIS_TAG], 0, 0, 0, 1); - VectorCopy( torsoAngles, pEntState->bone_angles[ TORSO_TAG ] ); - EulerToQuat( pEntState->bone_angles[ TORSO_TAG ], pEntState->bone_quat[ TORSO_TAG ] ); + AnglesSubtract(vViewAngles, vAngles, headAngles); + // Added in 2.0 + // Prevent rotating the player head like a monster + if (headAngles[1] > 90) { + headAngles[1] = 90; + } + if (headAngles[1] < -90) { + headAngles[1] = -90; + } - VectorCopy( armsAngles, pEntState->bone_angles[ ARMS_TAG ] ); - EulerToQuat( pEntState->bone_angles[ ARMS_TAG ], pEntState->bone_quat[ ARMS_TAG ] ); - return; - } - } + VectorCopy(headAngles, pEntState->bone_angles[HEAD_TAG]); + EulerToQuat(pEntState->bone_angles[HEAD_TAG], pEntState->bone_quat[HEAD_TAG]); + return; + } - // set the default angles - VectorSet( pEntState->bone_angles[ HEAD_TAG ], 0, 0, 0 ); - VectorSet( pEntState->bone_angles[ TORSO_TAG ], 0, 0, 0 ); - VectorSet( pEntState->bone_angles[ ARMS_TAG ], 0, 0, 0 ); - VectorSet( pEntState->bone_angles[ PELVIS_TAG ], 0, 0, 0 ); - QuatSet( pEntState->bone_quat[ HEAD_TAG ], 0, 0, 0, 1 ); - QuatSet( pEntState->bone_quat[ TORSO_TAG ], 0, 0, 0, 1 ); - QuatSet( pEntState->bone_quat[ ARMS_TAG ], 0, 0, 0, 1 ); - QuatSet( pEntState->bone_quat[ PELVIS_TAG ], 0, 0, 0, 1 ); + fTmp = AngleMod(vViewAngles[0]); + + VectorSet(temp, fTmp, 0, pPlayerState->fLeanAngle * 0.60f); + VectorSet(temp2, fTmp, 0, pPlayerState->fLeanAngle); + + if (fTmp > 180.0f) { + temp2[0] = fTmp - 360.0f; + } + + temp2[0] = 0.90f * temp2[0] * 0.70f; + + AnglesSubtract(temp, temp2, headAngles); + VectorCopy(headAngles, pEntState->bone_angles[HEAD_TAG]); + EulerToQuat(pEntState->bone_angles[HEAD_TAG], pEntState->bone_quat[HEAD_TAG]); + + if (temp2[0] <= 0.0f) { + fTmp = -0.1f; + } else { + fTmp = 0.3f; + } + + VectorSet(temp, fTmp * temp2[0], 0, pPlayerState->fLeanAngle * 0.8f); + VectorCopy(temp, pEntState->bone_angles[PELVIS_TAG]); + EulerToQuat(pEntState->bone_angles[PELVIS_TAG], pEntState->bone_quat[PELVIS_TAG]); + + float fDelta = (1.0f - fTmp) * temp2[0]; + + if (vViewAngles[0] <= 0.0f) { + VectorSet(torsoAngles, fDelta * 0.60f, 0, pPlayerState->fLeanAngle * 0.2f * -0.1f); + VectorSet(armsAngles, fDelta * 0.40f, 0, pPlayerState->fLeanAngle * 0.2f * 1.1f); + } else { + VectorSet(torsoAngles, fDelta * 0.70f, 0, pPlayerState->fLeanAngle * 0.2f * -0.1f); + VectorSet(armsAngles, fDelta * 0.30f, 0, pPlayerState->fLeanAngle * 0.2f * 1.1f); + } + + VectorCopy(torsoAngles, pEntState->bone_angles[TORSO_TAG]); + EulerToQuat(pEntState->bone_angles[TORSO_TAG], pEntState->bone_quat[TORSO_TAG]); + + VectorCopy(armsAngles, pEntState->bone_angles[ARMS_TAG]); + EulerToQuat(pEntState->bone_angles[ARMS_TAG], pEntState->bone_quat[ARMS_TAG]); + } } // Used to set arms angles accordingly, calculated client-side // Without it, the arms will look like it has latency -void PmoveAdjustAngleSettings_Client( vec_t *vViewAngles, vec_t *vAngles, playerState_t *pPlayerState, entityState_t *pEntState ) +void PmoveAdjustAngleSettings_Client( + vec_t *vViewAngles, vec_t *vAngles, playerState_t *pPlayerState, entityState_t *pEntState +) { vec3_t torsoAngles; - int i; + int i; - if (pPlayerState->pm_type == PM_DEAD) - { - for (i = 0; i < NUM_BONE_CONTROLLERS; i++) { + if (pPlayerState->pm_type == PM_DEAD) { + for (i = 0; i < NUM_BONE_CONTROLLERS; i++) { VectorClear(pEntState->bone_angles[i]); QuatClear(pEntState->bone_quat[i]); - } - } - else if (pPlayerState->pm_type == PM_CLIMBWALL) - { - vec3_t headAngles; + } + } else if (pPlayerState->pm_type == PM_CLIMBWALL) { + vec3_t headAngles; PmoveAdjustViewAngleSettings_OnLadder(vViewAngles, vAngles, pPlayerState, pEntState); - VectorSet(torsoAngles, AngleMod(vViewAngles[0]), 0.0, pPlayerState->fLeanAngle * 0.7); + VectorSet(torsoAngles, AngleMod(vViewAngles[0]), 0.0, pPlayerState->fLeanAngle * 0.7); - if (torsoAngles[0] > 180.0) { - torsoAngles[0] -= 180.0; - } + if (torsoAngles[0] > 180.0) { + torsoAngles[0] -= 180.0; + } - torsoAngles[0] += 8.0; + torsoAngles[0] += 8.0; VectorClear(pEntState->bone_angles[TORSO_TAG]); QuatClear(pEntState->bone_quat[TORSO_TAG]); VectorClear(pEntState->bone_angles[PELVIS_TAG]); QuatClear(pEntState->bone_quat[PELVIS_TAG]); - VectorCopy(torsoAngles, pEntState->bone_angles[ARMS_TAG]); - EulerToQuat(pEntState->bone_angles[ARMS_TAG], pEntState->bone_quat[ARMS_TAG]); + VectorCopy(torsoAngles, pEntState->bone_angles[ARMS_TAG]); + EulerToQuat(pEntState->bone_angles[ARMS_TAG], pEntState->bone_quat[ARMS_TAG]); - // head angles + // head angles AnglesSubtract(vViewAngles, vAngles, headAngles); headAngles[0] *= 0.5; - AnglesSubtract(headAngles, torsoAngles, headAngles); + AnglesSubtract(headAngles, torsoAngles, headAngles); VectorCopy(headAngles, pEntState->bone_angles[HEAD_TAG]); EulerToQuat(pEntState->bone_angles[HEAD_TAG], pEntState->bone_quat[HEAD_TAG]); - } - else { - // Clear the head, torso and pelvis + } else { + // Clear the head, torso and pelvis VectorClear(pEntState->bone_angles[HEAD_TAG]); QuatClear(pEntState->bone_quat[HEAD_TAG]); VectorClear(pEntState->bone_angles[TORSO_TAG]); @@ -1875,8 +1736,8 @@ void PmoveAdjustAngleSettings_Client( vec_t *vViewAngles, vec_t *vAngles, player VectorClear(pEntState->bone_angles[PELVIS_TAG]); QuatClear(pEntState->bone_quat[PELVIS_TAG]); - VectorSet(vAngles, 0, AngleMod(vViewAngles[1]), 0); - VectorSet(torsoAngles, AngleMod(vViewAngles[0]), 0, pPlayerState->fLeanAngle * 0.7); + VectorSet(vAngles, 0, AngleMod(vViewAngles[1]), 0); + VectorSet(torsoAngles, AngleMod(vViewAngles[0]), 0, pPlayerState->fLeanAngle * 0.7); if (torsoAngles[0] > 180.0) { torsoAngles[0] -= 360.0; @@ -1885,5 +1746,5 @@ void PmoveAdjustAngleSettings_Client( vec_t *vViewAngles, vec_t *vAngles, player torsoAngles[0] += 8.0; VectorCopy(torsoAngles, pEntState->bone_angles[ARMS_TAG]); EulerToQuat(pEntState->bone_angles[ARMS_TAG], pEntState->bone_quat[ARMS_TAG]); - } + } } diff --git a/code/fgame/bg_public.h b/code/fgame/bg_public.h index 079c74b7..840d1ffd 100644 --- a/code/fgame/bg_public.h +++ b/code/fgame/bg_public.h @@ -1,6 +1,7 @@ /* =========================================================================== Copyright (C) 1999-2005 Id Software, Inc. +Copyright (C) 2024 the OpenMoHAA team This file is part of Quake III Arena source code. @@ -29,15 +30,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define GAME_VERSION "mohaa-base-1" -static const unsigned int MINS_X = -15; -static const unsigned int MINS_Y = -15; -static const unsigned int MINS_Z = 0; // IneQuation: bounding box and viewheights to match MoHAA -static const unsigned int MAXS_X = 15; -static const unsigned int MAXS_Y = 15; -static const unsigned int MAXS_Z = 96; +static const int MINS_X = -15; +static const int MINS_Y = -15; +static const int MINS_Z = 0; // IneQuation: bounding box and viewheights to match MoHAA +static const int MAXS_X = 15; +static const int MAXS_Y = 15; +static const int MAXS_Z = 94; +static const int DEAD_MINS_Z = 32; +static const int CROUCH_MAXS_Z = 49; -static const unsigned int DEAD_MINS_Z = 32; -static const unsigned int CROUCH_MAXS_Z = 49; static const unsigned int DEFAULT_VIEWHEIGHT = 82; static const unsigned int CROUCH_RUN_VIEWHEIGHT = 64; static const unsigned int JUMP_START_VIEWHEIGHT = 52; @@ -257,7 +258,7 @@ movement on the server game. #define PMF_LEVELEXIT (1 << 11) #define PMF_NO_GRAVITY (1 << 12) #define PMF_NO_HUD (1 << 13) -#define PMF_UNKNOWN (1 << 14) +#define PMF_TURRET (1 << 14) #define PMF_NO_LEAN (1 << 15) // moveposflags @@ -559,7 +560,8 @@ movement on the server game. TEAM_SPECTATOR, TEAM_FREEFORALL, TEAM_ALLIES, - TEAM_AXIS + TEAM_AXIS, + TEAM_MAX } teamtype_t; typedef enum { @@ -604,32 +606,39 @@ movement on the server game. #define DM_FLAG(flag) (g_gametype->integer != GT_SINGLE_PLAYER && ((int)dmflags->integer & (flag))) -// content masks + // + // Content masks + // + #define MASK_ALL (-1) #define MASK_SOLID \ (CONTENTS_SOLID | CONTENTS_BODY | CONTENTS_UNKNOWN2 | CONTENTS_NOBOTCLIP | CONTENTS_BBOX | CONTENTS_FENCE) #define MASK_SAFESOLID (CONTENTS_BODY | CONTENTS_UNKNOWN2 | CONTENTS_NOBOTCLIP | CONTENTS_BBOX) #define MASK_USABLE (CONTENTS_SOLID | CONTENTS_BBOX | CONTENTS_NOBOTCLIP | CONTENTS_UNKNOWN2 | CONTENTS_BODY) -#define MASK_PLAYERSOLID \ - (CONTENTS_SOLID | CONTENTS_PLAYERCLIP | CONTENTS_BODY | CONTENTS_TRIGGER | CONTENTS_FENCE | CONTENTS_UNKNOWN2 \ - | CONTENTS_NOBOTCLIP | CONTENTS_BBOX) +#define MASK_PLAYERSOLID \ + (CONTENTS_TRIGGER | CONTENTS_BODY | CONTENTS_PLAYERCLIP | CONTENTS_FENCE | CONTENTS_UNKNOWN2 | CONTENTS_NOBOTCLIP \ + | CONTENTS_BBOX | CONTENTS_SOLID) #define MASK_GUNTARGET \ (CONTENTS_SOLID | CONTENTS_LADDER | CONTENTS_LAVA | CONTENTS_SLIME | CONTENTS_CLAYPIDGEON | CONTENTS_BBOX \ | CONTENTS_NOBOTCLIP | CONTENTS_UNKNOWN2 | CONTENTS_UNKNOWN3 | CONTENTS_FENCE | CONTENTS_BODY | CONTENTS_CORPSE \ | CONTENTS_TRIGGER) -#define MASK_FOOTSHADOW (CONTENTS_FENCE | CONTENTS_SLIME | CONTENTS_LAVA | CONTENTS_SOLID) -#define MASK_PLAYERSTART (CONTENTS_SOLID | CONTENTS_BBOX | CONTENTS_NOBOTCLIP | CONTENTS_UNKNOWN2 | CONTENTS_BODY) -#define MASK_VIEWSOLID (CONTENTS_SOLID | CONTENTS_PLAYERCLIP | CONTENTS_FENCE | CONTENTS_TRIGGER) -#define MASK_DEADSOLID (CONTENTS_SOLID | CONTENTS_PLAYERCLIP | CONTENTS_CORPSE | CONTENTS_NOTTEAM2 | CONTENTS_FENCE) -#define MASK_MONSTERSOLID (CONTENTS_SOLID | CONTENTS_MONSTERCLIP | CONTENTS_BODY) -#define MASK_WATER (CONTENTS_WATER | CONTENTS_LAVA | CONTENTS_SLIME) -#define MASK_OPAQUE (CONTENTS_SOLID | CONTENTS_SLIME | CONTENTS_LAVA) +#define MASK_FOOTSHADOW (CONTENTS_FENCE | CONTENTS_SLIME | CONTENTS_LAVA | CONTENTS_SOLID) +#define MASK_PLAYERSTART (CONTENTS_SOLID | CONTENTS_BBOX | CONTENTS_NOBOTCLIP | CONTENTS_UNKNOWN2 | CONTENTS_BODY) +#define MASK_VIEWSOLID (CONTENTS_SOLID | CONTENTS_PLAYERCLIP | CONTENTS_FENCE | CONTENTS_TRIGGER) +#define MASK_DEADSOLID (CONTENTS_SOLID | CONTENTS_PLAYERCLIP | CONTENTS_CORPSE | CONTENTS_NOTTEAM2 | CONTENTS_FENCE) +#define MASK_MONSTERSOLID \ + (CONTENTS_SOLID | CONTENTS_MONSTERCLIP | CONTENTS_BODY | CONTENTS_TRIGGER | CONTENTS_UNKNOWN2 | CONTENTS_BBOX) +#define MASK_WATER (CONTENTS_WATER | CONTENTS_LAVA | CONTENTS_SLIME) +#define MASK_OPAQUE (CONTENTS_SOLID | CONTENTS_SLIME | CONTENTS_LAVA) #define MASK_SHOT \ (CONTENTS_SOLID | CONTENTS_BBOX | CONTENTS_NOBOTCLIP | CONTENTS_UNKNOWN2 | CONTENTS_FENCE | CONTENTS_WEAPONCLIP \ | CONTENTS_BODY | CONTENTS_TRIGGER) #define MASK_SHOT_TRIG \ (CONTENTS_SOLID | CONTENTS_CLAYPIDGEON | CONTENTS_WATER | CONTENTS_BBOX | CONTENTS_NOBOTCLIP | CONTENTS_UNKNOWN2 \ | CONTENTS_FENCE | CONTENTS_WEAPONCLIP | CONTENTS_BODY | CONTENTS_TRIGGER) +#define MASK_SHOT_FLUID \ + (CONTENTS_SOLID | CONTENTS_WATER | CONTENTS_BBOX | CONTENTS_NOBOTCLIP | CONTENTS_UNKNOWN2 | CONTENTS_FENCE \ + | CONTENTS_WEAPONCLIP | CONTENTS_SHOOTONLY | CONTENTS_BODY | CONTENTS_TRIGGER) #define MASK_PROJECTILE \ (CONTENTS_SOLID | CONTENTS_BODY | CONTENTS_TRIGGER | CONTENTS_FENCE | CONTENTS_WEAPONCLIP | CONTENTS_UNKNOWN2 \ | CONTENTS_NOBOTCLIP | CONTENTS_BBOX) @@ -643,7 +652,7 @@ movement on the server game. #define MASK_CAMERASOLID (CONTENTS_SOLID | CONTENTS_PLAYERCLIP | CONTENTS_BODY | MASK_WATER) #define MASK_BEAM (CONTENTS_SOLID | CONTENTS_TRIGGER | CONTENTS_PLAYERCLIP | CONTENTS_BODY | CONTENTS_FENCE) #define MASK_LADDER \ - (CONTENTS_SOLID | CONTENTS_LADDER | CONTENTS_TRIGGER | CONTENTS_PLAYERCLIP | CONTENTS_BODY | CONTENTS_FENCE) + (CONTENTS_SOLID | CONTENTS_LADDER | CONTENTS_TRIGGER | CONTENTS_PLAYERCLIP | CONTENTS_BODY | CONTENTS_FENCE | CONTENTS_UNKNOWN2 | CONTENTS_NOBOTCLIP | CONTENTS_BBOX) #define MASK_AUTOCALCLIFE (CONTENTS_SOLID | CONTENTS_TRIGGER | CONTENTS_FENCE) #define MASK_EXPLOSION (CONTENTS_SOLID | CONTENTS_TRIGGER | CONTENTS_WEAPONCLIP) #define MASK_SOUND (CONTENTS_SOLID | CONTENTS_TRANSLUCENT) @@ -652,13 +661,19 @@ movement on the server game. | CONTENTS_BODY | CONTENTS_TRIGGER) #define MASK_VEHICLE_TIRES (CONTENTS_SOLID | CONTENTS_BBOX | CONTENTS_FENCE | CONTENTS_VEHICLECLIP | CONTENTS_TRIGGER) #define MASK_CLICK \ - (CONTENTS_SOLID | CONTENTS_BODY | CONTENTS_UNKNOWN3 | CONTENTS_UNKNOWN2 | CONTENTS_NOBOTCLIP | CONTENTS_BBOX) -#define MASK_CANSEE \ - (CONTENTS_SOLID | CONTENTS_LAVA | CONTENTS_SLIME | CONTENTS_FENCE | CONTENTS_WEAPONCLIP | CONTENTS_BODY) + (CONTENTS_VEHICLECLIP | CONTENTS_WEAPONCLIP | CONTENTS_MONSTERCLIP | CONTENTS_PLAYERCLIP | CONTENTS_SOLID) +#define MASK_CANSEE \ + (CONTENTS_SOLID | CONTENTS_LAVA | CONTENTS_SLIME | CONTENTS_BBOX | CONTENTS_NOBOTCLIP | CONTENTS_UNKNOWN2 \ + | CONTENTS_FENCE | CONTENTS_WEAPONCLIP | CONTENTS_BODY) #define MASK_CANSEE_NOENTS (CONTENTS_SOLID | CONTENTS_LAVA | CONTENTS_SLIME | CONTENTS_FENCE | CONTENTS_WEAPONCLIP) -#define MASK_ITEM (CONTENTS_SOLID | CONTENTS_TRIGGER | CONTENTS_PLAYERCLIP | CONTENTS_FENCE) -#define MASK_TRANSITION \ - (CONTENTS_SOLID | CONTENTS_LAVA | CONTENTS_SLIME | CONTENTS_UNKNOWN2 | CONTENTS_NOTTEAM1 | CONTENTS_WEAPONCLIP) +#define MASK_USE \ + (CONTENTS_SOLID | CONTENTS_BBOX | CONTENTS_NOBOTCLIP | CONTENTS_UNKNOWN2 | CONTENTS_FENCE | CONTENTS_WEAPONCLIP \ + | CONTENTS_BODY | CONTENTS_TRIGGER) +#define MASK_CLICKITEM (MASK_SOLID | CONTENTS_UNKNOWN3) +#define MASK_ITEM (CONTENTS_SOLID | CONTENTS_TRIGGER | CONTENTS_PLAYERCLIP | CONTENTS_FENCE) +#define MASK_TRANSITION \ + (CONTENTS_SOLID | CONTENTS_LAVA | CONTENTS_SLIME | CONTENTS_FENCE | CONTENTS_WEAPONCLIP | CONTENTS_UNKNOWN2 \ + | CONTENTS_BBOX) #define MASK_TARGETPATH \ (CONTENTS_SOLID | CONTENTS_TRIGGER | CONTENTS_MONSTERCLIP | CONTENTS_FENCE | CONTENTS_UNKNOWN2 | CONTENTS_BBOX) #define MASK_ACTORPATH (CONTENTS_SOLID | CONTENTS_FENCE | CONTENTS_MONSTERCLIP | CONTENTS_TRIGGER) @@ -699,6 +714,17 @@ movement on the server game. | CONTENTS_WEAPONCLIP) #define MASK_CORNER_NODE \ (CONTENTS_SOLID | CONTENTS_LAVA | CONTENTS_SLIME | CONTENTS_UNKNOWN2 | CONTENTS_WEAPONCLIP | CONTENTS_BODY) +#define MASK_IGNORE_ENTS \ + (CONTENTS_CORPSE | CONTENTS_BODY | CONTENTS_UNKNOWN3 | CONTENTS_UNKNOWN2 | CONTENTS_NOBOTCLIP | CONTENTS_BBOX \ + | CONTENTS_CLAYPIDGEON | CONTENTS_LADDER) + +// +// Marks +// +#define MASK_MARK (CONTENTS_TRIGGER | CONTENTS_SOLID) +#define MASK_TREADMARK \ + (CONTENTS_TRIGGER | CONTENTS_BODY | CONTENTS_PLAYERCLIP | CONTENTS_FENCE | CONTENTS_UNKNOWN2 | CONTENTS_NOBOTCLIP \ + | CONTENTS_BBOX | CONTENTS_SOLID) void BG_EvaluateTrajectoryDelta(const trajectory_t *tr, int atTime, vec3_t result); @@ -744,10 +770,10 @@ movement on the server game. CGM_HUDDRAW_ALPHA, CGM_HUDDRAW_STRING, CGM_HUDDRAW_FONT, - CGM_NOTIFY_KILL, CGM_NOTIFY_HIT, + CGM_NOTIFY_KILL, CGM_VOICE_CHAT, - CGM_UNKNOWN_1, + CGM_FENCEPOST, }; enum cg_message_ver_6_e { @@ -786,8 +812,8 @@ movement on the server game. CGM6_HUDDRAW_ALPHA, CGM6_HUDDRAW_STRING, CGM6_HUDDRAW_FONT, - CGM6_NOTIFY_KILL, CGM6_NOTIFY_HIT, + CGM6_NOTIFY_KILL, CGM6_VOICE_CHAT, }; diff --git a/code/fgame/bg_slidemove.cpp b/code/fgame/bg_slidemove.cpp index 59e79211..60d07da8 100644 --- a/code/fgame/bg_slidemove.cpp +++ b/code/fgame/bg_slidemove.cpp @@ -41,191 +41,186 @@ PM_SlideMove Returns qtrue if the velocity was clipped in some way ================== */ -#define MAX_CLIP_PLANES 5 -qboolean PM_SlideMove( qboolean gravity ) +#define MAX_CLIP_PLANES 5 + +qboolean PM_SlideMove(qboolean gravity) { - int bumpcount, numbumps; - vec3_t dir; - float d; - int numplanes; - vec3_t planes[ MAX_CLIP_PLANES ]; - vec3_t primal_velocity; - vec3_t clipVelocity; - int i, j, k; - trace_t trace; - vec3_t end; - float time_left; - float into; - vec3_t endVelocity; - vec3_t endClipVelocity; + int bumpcount, numbumps; + vec3_t dir; + float d; + int numplanes; + vec3_t planes[MAX_CLIP_PLANES]; + vec3_t clipVelocity; + int i, j, k; + trace_t trace; + vec3_t end; + float time_left; + float into; + vec3_t endVelocity; + vec3_t endClipVelocity; - numbumps = 4; + numbumps = 4; - VectorCopy( pm->ps->velocity, primal_velocity ); + VectorCopy(pm->ps->velocity, endVelocity); - if( gravity ) { - VectorCopy( pm->ps->velocity, endVelocity ); - endVelocity[ 2 ] -= pm->ps->gravity * pml.frametime; - pm->ps->velocity[ 2 ] = ( pm->ps->velocity[ 2 ] + endVelocity[ 2 ] ) * 0.5; - primal_velocity[ 2 ] = endVelocity[ 2 ]; - if( pml.groundPlane ) { - // slide along the ground plane - PM_ClipVelocity( pm->ps->velocity, pml.groundTrace.plane.normal, - pm->ps->velocity, OVERCLIP ); - } - } + if (gravity) { + endVelocity[2] -= pm->ps->gravity * pml.frametime; + pm->ps->velocity[2] = (pm->ps->velocity[2] + endVelocity[2]) * 0.5; + if (pml.groundPlane) { + // slide along the ground plane + PM_ClipVelocity(pm->ps->velocity, pml.groundTrace.plane.normal, pm->ps->velocity, OVERCLIP); + } + } - time_left = pml.frametime; + time_left = pml.frametime; - // never turn against the ground plane - if( pml.groundPlane ) { - numplanes = 1; - VectorCopy( pml.groundTrace.plane.normal, planes[ 0 ] ); - } - else { - numplanes = 0; - } + // never turn against the ground plane + if (pml.groundPlane) { + numplanes = 1; + VectorCopy(pml.groundTrace.plane.normal, planes[0]); + } else { + numplanes = 0; + } - // never turn against original velocity - VectorNormalize2( pm->ps->velocity, planes[ numplanes ] ); - numplanes++; + // never turn against original velocity + VectorNormalize2(pm->ps->velocity, planes[numplanes]); + numplanes++; - for( bumpcount = 0; bumpcount < numbumps; bumpcount++ ) { + for (bumpcount = 0; bumpcount < numbumps; bumpcount++) { + // calculate position we are trying to move to + VectorMA(pm->ps->origin, time_left, pm->ps->velocity, end); - // calculate position we are trying to move to - VectorMA( pm->ps->origin, time_left, pm->ps->velocity, end ); + // see if we can make it there + pm->trace(&trace, pm->ps->origin, pm->mins, pm->maxs, end, pm->ps->clientNum, pm->tracemask, qtrue, qfalse); - // see if we can make it there - pm->trace( &trace, pm->ps->origin, pm->mins, pm->maxs, end, pm->ps->clientNum, pm->tracemask, qtrue, qfalse ); + if (trace.allsolid) { + // entity is completely trapped in another solid + pm->ps->velocity[2] = 0; // don't build up falling damage, but allow sideways acceleration + return qtrue; + } - if( trace.allsolid ) { - // entity is completely trapped in another solid - pm->ps->velocity[ 2 ] = 0; // don't build up falling damage, but allow sideways acceleration - return qtrue; - } + if (trace.fraction > 0) { + // actually covered some distance + VectorCopy(trace.endpos, pm->ps->origin); + } - if( trace.fraction > 0 ) { - // actually covered some distance - VectorCopy( trace.endpos, pm->ps->origin ); - } + if (trace.fraction == 1) { + break; // moved the entire distance + } - if( trace.fraction == 1 ) { - break; // moved the entire distance - } + if ((trace.plane.normal[2] < MIN_WALK_NORMAL) && (trace.plane.normal[2] > 0) + && DotProduct(trace.plane.normal, pm->ps->velocity) <= 0) { + // treat steep walls as vertical + trace.plane.normal[2] = 0; + VectorNormalizeFast(trace.plane.normal); + } - if( ( trace.plane.normal[ 2 ] < MIN_WALK_NORMAL ) && ( trace.plane.normal[ 2 ] > 0 ) ) - { - // treat steep walls as vertical - trace.plane.normal[ 2 ] = 0; - VectorNormalizeFast( trace.plane.normal ); - } + // save entity for contact + PM_AddTouchEnt(trace.entityNum); - // save entity for contact - PM_AddTouchEnt( trace.entityNum ); + time_left -= time_left * trace.fraction; - time_left -= time_left * trace.fraction; + if (numplanes >= MAX_CLIP_PLANES) { + // this shouldn't really happen + VectorClear(pm->ps->velocity); + return qtrue; + } - if( numplanes >= MAX_CLIP_PLANES ) { - // this shouldn't really happen - VectorClear( pm->ps->velocity ); - return qtrue; - } + // + // if this is the same plane we hit before, nudge velocity + // out along it, which fixes some epsilon issues with + // non-axial planes + // + for (i = 0; i < numplanes; i++) { + if (DotProduct(trace.plane.normal, planes[i]) > 0.99) { + VectorAdd(trace.plane.normal, pm->ps->velocity, pm->ps->velocity); + break; + } + } + if (i < numplanes) { + continue; + } + VectorCopy(trace.plane.normal, planes[numplanes]); + numplanes++; - // - // if this is the same plane we hit before, nudge velocity - // out along it, which fixes some epsilon issues with - // non-axial planes - // - for( i = 0; i < numplanes; i++ ) { - if( DotProduct( trace.plane.normal, planes[ i ] ) > 0.99 ) { - VectorAdd( trace.plane.normal, pm->ps->velocity, pm->ps->velocity ); - break; - } - } - if( i < numplanes ) { - continue; - } - VectorCopy( trace.plane.normal, planes[ numplanes ] ); - numplanes++; + // + // modify velocity so it parallels all of the clip planes + // - // - // modify velocity so it parallels all of the clip planes - // + // find a plane that it enters + for (i = 0; i < numplanes; i++) { + into = DotProduct(pm->ps->velocity, planes[i]); + if (into >= 0.1) { + continue; // move doesn't interact with the plane + } - // find a plane that it enters - for( i = 0; i < numplanes; i++ ) { - into = DotProduct( pm->ps->velocity, planes[ i ] ); - if( into >= 0.1 ) { - continue; // move doesn't interact with the plane - } + // see how hard we are hitting things + if (-into > pml.impactSpeed) { + pml.impactSpeed = -into; + } - // see how hard we are hitting things - if( -into > pml.impactSpeed ) { - pml.impactSpeed = -into; - } + // slide along the plane + PM_ClipVelocity(pm->ps->velocity, planes[i], clipVelocity, OVERCLIP); - // slide along the plane - PM_ClipVelocity( pm->ps->velocity, planes[ i ], clipVelocity, OVERCLIP ); + // slide along the plane + PM_ClipVelocity(endVelocity, planes[i], endClipVelocity, OVERCLIP); - // slide along the plane - PM_ClipVelocity( endVelocity, planes[ i ], endClipVelocity, OVERCLIP ); + // see if there is a second plane that the new move enters + for (j = 0; j < numplanes; j++) { + if (j == i) { + continue; + } + if (DotProduct(clipVelocity, planes[j]) >= 0.1) { + continue; // move doesn't interact with the plane + } - // see if there is a second plane that the new move enters - for( j = 0; j < numplanes; j++ ) { - if( j == i ) { - continue; - } - if( DotProduct( clipVelocity, planes[ j ] ) >= 0.1 ) { - continue; // move doesn't interact with the plane - } + // try clipping the move to the plane + PM_ClipVelocity(clipVelocity, planes[j], clipVelocity, OVERCLIP); + PM_ClipVelocity(endClipVelocity, planes[j], endClipVelocity, OVERCLIP); - // try clipping the move to the plane - PM_ClipVelocity( clipVelocity, planes[ j ], clipVelocity, OVERCLIP ); - PM_ClipVelocity( endClipVelocity, planes[ j ], endClipVelocity, OVERCLIP ); + // see if it goes back into the first clip plane + if (DotProduct(clipVelocity, planes[i]) >= 0) { + continue; + } - // see if it goes back into the first clip plane - if( DotProduct( clipVelocity, planes[ i ] ) >= 0 ) { - continue; - } + // slide the original velocity along the crease + CrossProduct(planes[i], planes[j], dir); + VectorNormalize(dir); + d = DotProduct(dir, pm->ps->velocity); + VectorScale(dir, d, clipVelocity); - // slide the original velocity along the crease - CrossProduct( planes[ i ], planes[ j ], dir ); - VectorNormalize( dir ); - d = DotProduct( dir, pm->ps->velocity ); - VectorScale( dir, d, clipVelocity ); + CrossProduct(planes[i], planes[j], dir); + VectorNormalize(dir); + d = DotProduct(dir, endVelocity); + VectorScale(dir, d, endClipVelocity); - CrossProduct( planes[ i ], planes[ j ], dir ); - VectorNormalize( dir ); - d = DotProduct( dir, endVelocity ); - VectorScale( dir, d, endClipVelocity ); + // see if there is a third plane the the new move enters + for (k = 0; k < numplanes; k++) { + if (k == i || k == j) { + continue; + } + if (DotProduct(clipVelocity, planes[k]) >= 0.1) { + continue; // move doesn't interact with the plane + } - // see if there is a third plane the the new move enters - for( k = 0; k < numplanes; k++ ) { - if( k == i || k == j ) { - continue; - } - if( DotProduct( clipVelocity, planes[ k ] ) >= 0.1 ) { - continue; // move doesn't interact with the plane - } + // stop dead at a tripple plane interaction + VectorClear(pm->ps->velocity); + return qtrue; + } + } - // stop dead at a tripple plane interaction - VectorClear( pm->ps->velocity ); - return qtrue; - } - } + // if we have fixed all interactions, try another move + VectorCopy(clipVelocity, pm->ps->velocity); + VectorCopy(endClipVelocity, endVelocity); + break; + } + } - // if we have fixed all interactions, try another move - VectorCopy( clipVelocity, pm->ps->velocity ); - VectorCopy( endClipVelocity, endVelocity ); - break; - } - } + if (gravity) { + VectorCopy(endVelocity, pm->ps->velocity); + } - if( gravity ) { - VectorCopy( endVelocity, pm->ps->velocity ); - } - - return ( bumpcount != 0 ); + return (bumpcount != 0); } /* @@ -234,89 +229,80 @@ PM_StepSlideMove ================== */ -void PM_StepSlideMove( qboolean gravity ) +void PM_StepSlideMove(qboolean gravity) { - vec3_t start_o; - vec3_t start_v; - vec3_t nostep_o; - vec3_t nostep_v; - trace_t trace; - qboolean bWasOnGoodGround; - vec3_t up; - vec3_t down; + vec3_t start_o; + vec3_t start_v; + vec3_t nostep_o; + vec3_t nostep_v; + trace_t trace; + qboolean bWasOnGoodGround; + vec3_t up; + vec3_t down; - VectorCopy( pm->ps->origin, start_o ); - VectorCopy( pm->ps->velocity, start_v ); + VectorCopy(pm->ps->origin, start_o); + VectorCopy(pm->ps->velocity, start_v); - if ( PM_SlideMove( gravity ) == 0 ) { - return; // we got exactly where we wanted to go first try - } + if (PM_SlideMove(gravity) == 0) { + return; // we got exactly where we wanted to go first try + } - VectorCopy( start_o, down ); - down[ 2 ] -= STEPSIZE; - pm->trace( &trace, start_o, pm->mins, pm->maxs, down, pm->ps->clientNum, pm->tracemask, qtrue, qfalse ); - VectorSet( up, 0, 0, 1 ); + VectorCopy(start_o, down); + down[2] -= STEPSIZE; + pm->trace(&trace, start_o, pm->mins, pm->maxs, down, pm->ps->clientNum, pm->tracemask, qtrue, qfalse); + VectorSet(up, 0, 0, 1); - // never step up when you still have up velocity - if( pm->ps->velocity[ 2 ] > 0 && ( trace.fraction == 1.0f || - DotProduct( trace.plane.normal, up ) < MIN_WALK_NORMAL ) ) { - return; - } + // never step up when you still have up velocity + if (pm->ps->velocity[2] > 0 && (trace.fraction == 1.0f || DotProduct(trace.plane.normal, up) < MIN_WALK_NORMAL)) { + return; + } - if( pml.groundPlane && pml.groundTrace.plane.normal[ 2 ] >= MIN_WALK_NORMAL ) - { - bWasOnGoodGround = true; - } - else - { - bWasOnGoodGround = false; - } + if (pml.groundPlane && pml.groundTrace.plane.normal[2] >= MIN_WALK_NORMAL) { + bWasOnGoodGround = true; + } else { + bWasOnGoodGround = false; + } - VectorCopy( start_o, up ); - up[ 2 ] += STEPSIZE; + VectorCopy(start_o, up); + up[2] += STEPSIZE; - // test the player position if they were a stepheight higher - pm->trace( &trace, up, pm->mins, pm->maxs, up, pm->ps->clientNum, pm->tracemask, qtrue, qfalse ); - if( trace.allsolid ) - { - up[ 2 ] -= 9.0f; - pm->trace( &trace, up, pm->mins, pm->maxs, up, pm->ps->clientNum, pm->tracemask, qtrue, qfalse ); - if( trace.allsolid ) - { - return; - } - } + // test the player position if they were a stepheight higher + pm->trace(&trace, up, pm->mins, pm->maxs, up, pm->ps->clientNum, pm->tracemask, qtrue, qfalse); + if (trace.allsolid) { + up[2] -= 9.0f; + pm->trace(&trace, up, pm->mins, pm->maxs, up, pm->ps->clientNum, pm->tracemask, qtrue, qfalse); + if (trace.allsolid) { + return; + } + } - VectorCopy( pm->ps->origin, nostep_o ); - VectorCopy( pm->ps->velocity, nostep_v ); + VectorCopy(pm->ps->origin, nostep_o); + VectorCopy(pm->ps->velocity, nostep_v); - // try slidemove from this position - VectorCopy( up, pm->ps->origin ); - VectorCopy( start_v, pm->ps->velocity ); + // try slidemove from this position + VectorCopy(up, pm->ps->origin); + VectorCopy(start_v, pm->ps->velocity); - PM_SlideMove( gravity ); + PM_SlideMove(gravity); - // push down the final amount - VectorCopy( pm->ps->origin, down ); - down[ 2 ] -= STEPSIZE; + // push down the final amount + VectorCopy(pm->ps->origin, down); + down[2] -= STEPSIZE; - pm->trace( &trace, pm->ps->origin, pm->mins, pm->maxs, down, pm->ps->clientNum, pm->tracemask, qtrue, qfalse ); - if( !trace.allsolid ) - { - if( bWasOnGoodGround && trace.fraction < 1.0 && trace.plane.normal[ 2 ] < MIN_WALK_NORMAL ) - { - VectorCopy( nostep_o, pm->ps->origin ); - VectorCopy( nostep_v, pm->ps->velocity ); - return; - } + pm->trace(&trace, pm->ps->origin, pm->mins, pm->maxs, down, pm->ps->clientNum, pm->tracemask, qtrue, qfalse); + if (!trace.allsolid) { + if (bWasOnGoodGround && trace.fraction < 1.0 && trace.plane.normal[2] < MIN_WALK_NORMAL) { + VectorCopy(nostep_o, pm->ps->origin); + VectorCopy(nostep_v, pm->ps->velocity); + return; + } - VectorCopy( trace.endpos, pm->ps->origin ); - } + VectorCopy(trace.endpos, pm->ps->origin); + } - if ( trace.fraction < 1.0f ) { - PM_ClipVelocity( pm->ps->velocity, trace.plane.normal, pm->ps->velocity, OVERCLIP ); - } + if (trace.fraction < 1.0f) { + PM_ClipVelocity(pm->ps->velocity, trace.plane.normal, pm->ps->velocity, OVERCLIP); + } - pm->stepped = qtrue; + pm->stepped = qtrue; } - diff --git a/code/fgame/bg_voteoptions.cpp b/code/fgame/bg_voteoptions.cpp index 0edff416..8c9e20bb 100644 --- a/code/fgame/bg_voteoptions.cpp +++ b/code/fgame/bg_voteoptions.cpp @@ -114,7 +114,7 @@ void VoteOptions::SetupVoteOptions(const char *configFileName, int length, const if (length >= MAX_VOTEOPTIONS_BUFFER_LENGTH) { Com_Error( ERR_DROP, - "VoteOptions: Options file '%s' is too big. Max size is %i bytes\n", + "VoteOptions: Options file '%s' is too big. Max size is %lu bytes\n", configFileName, MAX_VOTEOPTIONS_BUFFER_LENGTH ); @@ -254,7 +254,7 @@ void VoteOptions::ParseVoteOptions() } else { newOption->m_pListItem = newListItem; } - listItem = newListItem; + listItem = newListItem; newListItem->m_sItemName = token; if (!script.TokenAvailable(false)) { @@ -568,7 +568,7 @@ void CG_PushCallVoteSubClient_f(void) VO_ExecuteCommand( va("globalwidgetcommand voteclientlist additem \"%i: %s\" \"callvote %i %i;popmenu 0\"\n", i, - cg.clientinfo[i], + cg.clientinfo[i].name, index, i) ); diff --git a/code/fgame/bg_voteoptions.h b/code/fgame/bg_voteoptions.h index 0d73ebeb..8c69377e 100644 --- a/code/fgame/bg_voteoptions.h +++ b/code/fgame/bg_voteoptions.h @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #pragma once #ifdef __cplusplus -# include "listener.h" +# include "listener.h" #endif #include "g_public.h" diff --git a/code/fgame/body.h b/code/fgame/body.h index 0abcb57a..b086ae89 100644 --- a/code/fgame/body.h +++ b/code/fgame/body.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -22,8 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // body.h: Dead bodies -#ifndef __BODY_H__ -#define __BODY_H__ +#pragma once #include "animate.h" @@ -39,5 +38,3 @@ public: CLASS_PROTOTYPE( Body ); Body(); }; - -#endif //__BODY_H__ diff --git a/code/fgame/botlib.h b/code/fgame/botlib.h index c49455ab..d96340a4 100644 --- a/code/fgame/botlib.h +++ b/code/fgame/botlib.h @@ -13,8 +13,7 @@ * *****************************************************************************/ -#ifndef __BOTLIB_H__ -#define __BOTLIB_H__ +#pragma once #define BOTLIB_API_VERSION 2 @@ -503,4 +502,3 @@ name: default: module(s): description: "max_levelitems" "256" be_ai_goal.c maximum number of level items */ -#endif diff --git a/code/fgame/bspline.cpp b/code/fgame/bspline.cpp index 91713ab4..11e41355 100644 --- a/code/fgame/bspline.cpp +++ b/code/fgame/bspline.cpp @@ -576,6 +576,8 @@ SplinePath::~SplinePath() assert(owner == this); assert(next == NULL); + + entflags &= ~ECF_SPLINEPATH; } void SplinePath::SetLoop(Event *ev) @@ -602,9 +604,18 @@ void SplinePath::CreatePath(Event *ev) target = Target(); if (target[0]) { ent = (Entity *)G_FindTarget(NULL, target); - if (ent) { - next = (SplinePath *)ent; + if (ent && ent->IsSubclassOfSplinePath()) { + next = (SplinePath *)ent; + + if (next->owner != next) { + // Fixed in OPM + // If the target already has an owner, make sure to properly remove the owner + next->owner->SetNext(NULL); + } + next->owner = this; + } else if (ent) { + ScriptError("SplinePath::CreatePath: target '%s' for '%s' not found (cannot connect to class '%s')\n", target, targetname.c_str(), ent->getClassname()); } else { ScriptError("SplinePath::CreatePath: target %s not found\n", target); } diff --git a/code/fgame/bspline.h b/code/fgame/bspline.h index e0cf70eb..50a69d82 100644 --- a/code/fgame/bspline.h +++ b/code/fgame/bspline.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -23,8 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // bspline.h: Uniform non-rational bspline class. // -#ifndef __BSPLINE_H__ -#define __BSPLINE_H__ +#pragma once #include "g_local.h" #include "entity.h" @@ -580,5 +579,3 @@ inline void SplinePath::SetTriggerTarget { triggertarget = name; } - -#endif /* __BSPLINE_H__ */ diff --git a/code/fgame/camera.cpp b/code/fgame/camera.cpp index 1f118927..83ac8b20 100644 --- a/code/fgame/camera.cpp +++ b/code/fgame/camera.cpp @@ -725,6 +725,7 @@ Camera::Camera() fadeTime = 2.0f; fovFadeTime = 1.0f; followFadeTime = 1.0f; + watchFadeTime = 1.0f; m_bShowquakes = false; setSolidType(SOLID_NOT); @@ -1410,11 +1411,11 @@ void Camera::SetAutoStateEvent(Event *ev) char com_token[MAX_QPATH]; char com_buffer[MAX_STRING_CHARS]; - strcpy(com_buffer, ev->GetString(i)); + Q_strncpyz(com_buffer, ev->GetString(i), sizeof(com_buffer)); buffer = com_buffer; // get the rest of the line while (1) { - strcpy(com_token, COM_ParseExt(&buffer, qfalse)); + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); if (!com_token[0]) { break; } diff --git a/code/fgame/camera.h b/code/fgame/camera.h index c0f077ff..fafde254 100644 --- a/code/fgame/camera.h +++ b/code/fgame/camera.h @@ -241,7 +241,7 @@ protected: Vector CalculatePosition(void); Vector CalculateOrientation(void); float CalculateFov(void); - virtual void bind(Entity *master, qboolean use_my_angles = false); + virtual void bind(Entity *master, qboolean use_my_angles = false) override; void unbind(void) override; public: diff --git a/code/fgame/characterstate.cpp b/code/fgame/characterstate.cpp index 50f558d8..e0c672ff 100644 --- a/code/fgame/characterstate.cpp +++ b/code/fgame/characterstate.cpp @@ -77,7 +77,7 @@ Conditional::Conditional() Expression::Expression() {} -Expression::Expression(Expression& exp) +Expression::Expression(const Expression& exp) { int i; @@ -373,7 +373,7 @@ void State::ParseAndProcessCommand(str command, Entity *target) script.SkipToEOL(); break; } - strcpy(args[argc], script.GetToken(false)); + Q_strncpyz(args[argc], script.GetToken(false), sizeof(args[argc])); argv[argc] = args[argc]; argc++; } diff --git a/code/fgame/characterstate.h b/code/fgame/characterstate.h index 884136e2..afc4d604 100644 --- a/code/fgame/characterstate.h +++ b/code/fgame/characterstate.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -22,8 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // characterstate.h: Character state -#ifndef __CHARACTERSTATE_H__ -#define __CHARACTERSTATE_H__ +#pragma once #include "g_local.h" #include "entity.h" @@ -185,7 +184,7 @@ private: public: Expression(); - Expression(Expression& exp); + Expression(const Expression& exp); Expression(Script& script, State& state); void operator=(const Expression& exp); @@ -359,5 +358,3 @@ StateMap *GetStatemap( qboolean cache_only = false ); void CacheStatemap(str filename, Condition *conditions); - -#endif /* !__CHARACTERSTATE_H__ */ diff --git a/code/fgame/crateobject.cpp b/code/fgame/crateobject.cpp index b7393f1a..2b161b2e 100644 --- a/code/fgame/crateobject.cpp +++ b/code/fgame/crateobject.cpp @@ -132,29 +132,25 @@ void CrateObject::TellNeighborsToFall(void) Vector vMins; Vector vMaxs; - vMins[0] = mins[0] + origin[0] + 6.0f; - vMins[1] = mins[1] + origin[1] + 6.0f; - vMins[2] = mins[2] + origin[2] + 6.0f; - - vMaxs[0] = maxs[0] + origin[0] - 6.0f; - vMaxs[1] = maxs[1] + origin[1] - 6.0f; - vMaxs[2] = maxs[2] + origin[2] + 12.0f; + vMins = origin + mins + Vector(6, 6, 6); + vMaxs = origin + maxs + Vector(-6, -6, 12); for (pEnt = G_NextEntity(NULL); pEnt != NULL; pEnt = pNext) { pNext = G_NextEntity(pEnt); + if (pEnt == this) { + continue; + } + if (!pEnt->IsSubclassOfCrateObject()) { + continue; + } - for (pEnt = G_NextEntity(NULL); pEnt != NULL; pEnt = pNext) { - pNext = G_NextEntity(pEnt); + if (vMins[0] > pEnt->absmax[0] || vMins[1] > pEnt->absmax[1] || vMins[2] > pEnt->absmax[2] + || pEnt->absmin[0] > vMaxs[0] || pEnt->absmin[1] > vMaxs[1] || pEnt->absmin[2] > vMaxs[2]) { + continue; + } - if (pEnt != this && pEnt->IsSubclassOfCrateObject()) { - if (vMins[0] <= absmax[0] && vMins[1] <= absmax[1] && vMins[2] <= absmax[2] && absmin[0] <= vMaxs[0] - && absmin[1] <= vMaxs[1] && absmin[2] <= vMaxs[2]) { - if (!pEnt->EventPending(EV_Crate_Start_Falling)) { - float time = level.frametime + level.frametime; - pEnt->PostEvent(EV_Crate_Start_Falling, time); - } - } - } + if (!pEnt->EventPending(EV_Crate_Start_Falling)) { + pEnt->PostEvent(EV_Crate_Start_Falling, level.frametime * 2); } } } @@ -166,13 +162,8 @@ void CrateObject::TellNeighborsToJitter(Vector vJitterAdd) Vector vMins; Vector vMaxs; - vMins[0] = mins[0] + origin[0] + 6.0f; - vMins[1] = mins[1] + origin[1] + 6.0f; - vMins[2] = mins[2] + origin[2] + 6.0f; - - vMaxs[0] = maxs[0] + origin[0] - 6.0f; - vMaxs[1] = maxs[1] + origin[1] - 6.0f; - vMaxs[2] = maxs[2] + origin[2] + 12.0f; + vMins = origin + mins + Vector(6, 6, 6); + vMaxs = origin + maxs + Vector(-6, -6, 12); for (pEnt = G_NextEntity(NULL); pEnt != NULL; pEnt = pNext) { CrateObject *crate = (CrateObject *)pEnt; @@ -182,17 +173,16 @@ void CrateObject::TellNeighborsToJitter(Vector vJitterAdd) if (pEnt == this) { continue; } - if (!pEnt->IsSubclassOfCrateObject()) { continue; } - if (vMins[0] > absmax[0] || vMins[1] > absmax[1] || vMins[2] > absmax[2] || absmin[0] > vMaxs[0] - || absmin[1] > vMaxs[1] || absmin[2] > vMaxs[2]) { + if (vMins[0] > pEnt->absmax[0] || vMins[1] > pEnt->absmax[1] || vMins[2] > pEnt->absmax[2] + || pEnt->absmin[0] > vMaxs[0] || pEnt->absmin[1] > vMaxs[1] || pEnt->absmin[2] > vMaxs[2]) { continue; } - crate->m_vJitterAngles[0] = m_vJitterAngles[0] + vJitterAdd[0]; + crate->m_vJitterAngles[0] += vJitterAdd[0]; if (crate->m_vJitterAngles[0] > m_fJitterScale * 1.25f || -(m_fJitterScale * 1.25f) <= crate->m_vJitterAngles[0]) { @@ -244,12 +234,8 @@ void CrateObject::CrateSetup(Event *ev) continue; } - if (vMins[0] <= pEnt->absmax[0] - && vMins[1] <= pEnt->absmax[1] - && vMins[2] <= pEnt->absmax[2] - && vMaxs[0] >= pEnt->absmin[0] - && vMaxs[1] >= pEnt->absmin[1] - && vMaxs[2] >= pEnt->absmin[2]) { + if (vMins[0] <= pEnt->absmax[0] && vMins[1] <= pEnt->absmax[1] && vMins[2] <= pEnt->absmax[2] + && vMaxs[0] >= pEnt->absmin[0] && vMaxs[1] >= pEnt->absmin[1] && vMaxs[2] >= pEnt->absmin[2]) { Com_Printf( "^~^~^ WARNING: func_crate entities %i and %i have overlapping volumes near (%g %g %g) to (%g %g %g)\n", entnum, @@ -276,9 +262,11 @@ void CrateObject::CrateDebrisType(Event *ev) void CrateObject::StartFalling(Event *ev) { - setMoveType(MOVETYPE_FLY); m_fMoveTime = 0; + setMoveType(MOVETYPE_TOSS); + setSolidType(SOLID_BBOX); + PostEvent(EV_Crate_Think, level.frametime); if (!(spawnflags & CRATE_NOTSTACKEDON)) { @@ -292,12 +280,13 @@ void CrateObject::CrateFalling(Event *ev) m_fMoveTime = level.time + 2.0f; } - if (level.time <= m_fMoveTime) { + if (m_fMoveTime >= level.time) { PostEvent(EV_Crate_Think, level.frametime); - } else { - setMoveType(MOVETYPE_PUSH); - setSolidType(SOLID_BSP); + return; } + + setMoveType(MOVETYPE_PUSH); + setSolidType(SOLID_BSP); } void CrateObject::CrateDamaged(Event *ev) @@ -419,40 +408,42 @@ void CrateObject::CrateThink(Event *ev) if (m_vJitterAngles[0] || m_vJitterAngles[2]) { setAngles(Vector(m_vStartAngles[0] * 2.0f, m_vStartAngles[1], m_vStartAngles[2] * 2.0f)); - if (m_vJitterAngles[0] > 0.0f) { - m_vJitterAngles[0] -= 1 / 3 * m_fJitterScale; + if (m_vJitterAngles[0] > 0) { + m_vJitterAngles[0] -= 1.0 / 3.0 * m_fJitterScale; - if (m_vJitterAngles[0] > 0.0f) { - m_vJitterAngles[0] = 0.0f; + if (m_vJitterAngles[0] < 0) { + m_vJitterAngles[0] = 0; } - } else if (m_vJitterAngles[0] < 0.0f) { - m_vJitterAngles[0] += 1 / 3 * m_fJitterScale; + } else if (m_vJitterAngles[0] < 0) { + m_vJitterAngles[0] += 1.0 / 3.0 * m_fJitterScale; - if (m_vJitterAngles[0] < 0.0f) { - m_vJitterAngles[0] = 0.0f; + if (m_vJitterAngles[0] > 0) { + m_vJitterAngles[0] = 0; } } m_vJitterAngles[0] = -m_vJitterAngles[0]; - if (m_vJitterAngles[2] > 0.0f) { + if (m_vJitterAngles[2] > 0) { m_vJitterAngles[2] -= 1 / 3 * m_fJitterScale; - if (m_vJitterAngles[2] > 0.0f) { - m_vJitterAngles[2] = 0.0f; + if (m_vJitterAngles[2] < 0) { + m_vJitterAngles[2] = 0; } - } else if (m_vJitterAngles[2] < 0.0f) { - m_vJitterAngles[2] += 1 / 3 * m_fJitterScale; + } else if (m_vJitterAngles[2] < 0) { + m_vJitterAngles[2] += 1.0 / 3.0 * m_fJitterScale; - if (m_vJitterAngles[2] < 0.0f) { - m_vJitterAngles[2] = 0.0f; + if (m_vJitterAngles[2] > 0) { + m_vJitterAngles[2] = 0; } } m_vJitterAngles[2] = -m_vJitterAngles[2]; - - PostEvent(EV_Crate_Think, 0.05f); } else if (!VectorCompare(angles, m_vStartAngles)) { setAngles(m_vStartAngles); } + + if (m_vJitterAngles[0] || m_vJitterAngles[2]) { + PostEvent(EV_Crate_Think, 0.05f); + } } diff --git a/code/fgame/crc32.h b/code/fgame/crc32.h index 703aca60..0b0547e5 100644 --- a/code/fgame/crc32.h +++ b/code/fgame/crc32.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2008 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -22,8 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // crc32.h: CRC32 Encryption (used by the Archiver) -#ifndef __CRC32_H__ -#define __CRC32_H8_ +#pragma once static unsigned int crc32_tab[] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, @@ -84,5 +83,3 @@ unsigned int crc32( unsigned int crc, const void *buf, size_t size ) return crc ^ ~0U; } - -#endif // __CRC32_H__ diff --git a/code/fgame/damagemodel.cpp b/code/fgame/damagemodel.cpp index 2603edb5..029ace6c 100644 --- a/code/fgame/damagemodel.cpp +++ b/code/fgame/damagemodel.cpp @@ -286,7 +286,7 @@ void DamageModel::SpawnOrientedBoundingBox(Event *ev) yawoffset = ev->GetFloat(3); boundingBoxEnt = new Entity(); - boundingBoxEnt->edict->r.svFlags |= SVF_PORTAL; + boundingBoxEnt->edict->r.svFlags |= SVF_SENDPVS; boundingBoxEnt->edict->s.eFlags |= EF_LINKANGLES; boundingBoxEnt->edict->r.contents = CONTENTS_SOLID; boundingBoxEnt->setSolidType(SOLID_BBOX); diff --git a/code/fgame/damagemodel.h b/code/fgame/damagemodel.h index eba9bf65..2190568d 100644 --- a/code/fgame/damagemodel.h +++ b/code/fgame/damagemodel.h @@ -39,7 +39,7 @@ public: void Setup(Event *ev); void Damaged(Event *ev); - void Killed(Event *ev); + void Killed(Event *ev) override; void KillTrace(Event *ev); void SpawnOrientedBoundingBox(Event *ev); void EventSetKillThread(Event *ev); diff --git a/code/fgame/debuglines.cpp b/code/fgame/debuglines.cpp index 7aa7dfa2..e75c6e09 100644 --- a/code/fgame/debuglines.cpp +++ b/code/fgame/debuglines.cpp @@ -21,371 +21,345 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // debuglines.cpp: -// +// #include "debuglines.h" #include "game.h" #define NUM_CIRCLE_SEGMENTS 24 -debugline_t *DebugLines = NULL; -debugstring_t *DebugStrings = NULL; -Vector currentVertex( 0, 0, 0 ); -Vector vertColor( 1, 1, 1 ); -float vertAlpha = 1; -float vertexIndex = 0; -float linewidth = 1; +debugline_t *DebugLines = NULL; +debugstring_t *DebugStrings = NULL; +Vector currentVertex(0, 0, 0); +Vector vertColor(1, 1, 1); +float vertAlpha = 1; +float vertexIndex = 0; +float linewidth = 1; unsigned short lineStippleFactor = 1; -unsigned short linePattern = 0xffff; -int g_iFirstLine; -int g_iCurrFrameLineCounter; -int g_iFrameLineCount[ 100 ]; +unsigned short linePattern = 0xffff; +int g_iFirstLine; +int g_iCurrFrameLineCounter; +int g_iFrameLineCount[100]; -void G_InitDebugLines - ( - void - ) +void G_InitDebugLines(void) { - if( g_numdebuglinedelays->integer <= 0 ) - { - *gi.DebugLines = DebugLines; - *gi.numDebugLines = 0; - g_iFirstLine = 0; + if (g_numdebuglinedelays->integer <= 0) { + *gi.DebugLines = DebugLines; + *gi.numDebugLines = 0; + g_iFirstLine = 0; - for( int i = 0; i < 100; i++ ) - { - g_iFrameLineCount[ i ] = 0; - } + for (int i = 0; i < 100; i++) { + g_iFrameLineCount[i] = 0; + } - g_iCurrFrameLineCounter = 0; - } - else - { - int iNumDelays = g_numdebuglinedelays->integer; - int iCount; + g_iCurrFrameLineCounter = 0; + } else { + int iNumDelays = g_numdebuglinedelays->integer; + int iCount; - if( iNumDelays > 99 ) - iNumDelays = 99; + if (iNumDelays > 99) { + iNumDelays = 99; + } - iCount = g_iFrameLineCount[ ( g_iCurrFrameLineCounter - iNumDelays + 100 ) % 100 ]; - if( iCount ) - { - g_iFirstLine += iCount; - *gi.numDebugLines -= iCount; - g_iFrameLineCount[ ( g_iCurrFrameLineCounter - iNumDelays + 100 ) % 100 ] = 0; - } + iCount = g_iFrameLineCount[(g_iCurrFrameLineCounter - (iNumDelays - 100)) % 100]; + if (iCount) { + g_iFirstLine += iCount; + *gi.numDebugLines -= iCount; + g_iFrameLineCount[(g_iCurrFrameLineCounter - (iNumDelays - 100)) % 100] = 0; + } - g_iCurrFrameLineCounter = ( g_iCurrFrameLineCounter + 1 ) % 100; - *gi.DebugLines = &DebugLines[ g_iFirstLine ]; - } + g_iCurrFrameLineCounter = (g_iCurrFrameLineCounter + 1) % 100; + *gi.DebugLines = &DebugLines[g_iFirstLine]; + } - currentVertex = vec_zero; - vertColor = Vector( 1, 1, 1 ); - vertAlpha = 1; - vertexIndex = 0; + currentVertex = vec_zero; + vertColor = Vector(1, 1, 1); + vertAlpha = 1; + vertexIndex = 0; - linewidth = 1; - lineStippleFactor = 1; - linePattern = 0xffff; + linewidth = 1; + lineStippleFactor = 1; + linePattern = 0xffff; } -void G_InitDebugStrings - ( - void - ) +void G_InitDebugStrings(void) { - *gi.DebugStrings = DebugStrings; - *gi.numDebugStrings = 0; + *gi.DebugStrings = DebugStrings; + *gi.numDebugStrings = 0; } -void G_AllocDebugLines - ( - void - ) +void G_AllocDebugLines(void) { - // we do a malloc here so that we don't interfere with the game's memory footprint - DebugLines = ( debugline_t * )malloc( ( int )g_numdebuglines->integer * sizeof( debugline_t ) ); + // we do a malloc here so that we don't interfere with the game's memory footprint + DebugLines = (debugline_t *)malloc((int)g_numdebuglines->integer * sizeof(debugline_t)); - G_InitDebugLines(); + G_InitDebugLines(); - for( int i = 0; i < 100; i++ ) - { - g_iFrameLineCount[ i ] = 0; - } + for (int i = 0; i < 100; i++) { + g_iFrameLineCount[i] = 0; + } - g_iCurrFrameLineCounter = 0; + g_iCurrFrameLineCounter = 0; } -void G_AllocDebugStrings - ( - void - ) +void G_AllocDebugStrings(void) { - DebugStrings = ( debugstring_t * )malloc( ( int )g_numdebugstrings->integer * sizeof( debugstring_t ) ); + DebugStrings = (debugstring_t *)malloc((int)g_numdebugstrings->integer * sizeof(debugstring_t)); - G_InitDebugStrings(); + G_InitDebugStrings(); } -void G_DeAllocDebugLines - ( - void - ) +void G_DeAllocDebugLines(void) { - if( DebugLines ) - { - // we do a free here, because we used malloc above - free( DebugLines ); - DebugLines = NULL; - *gi.DebugLines = DebugLines; - *gi.numDebugLines = 0; - } + if (DebugLines) { + // we do a free here, because we used malloc above + free(DebugLines); + DebugLines = NULL; + *gi.DebugLines = DebugLines; + *gi.numDebugLines = 0; + } } -void G_ShiftDebugLines - ( - void - ) +void G_ShiftDebugLines(void) { - int iNewPos; - int iOldPos; + int iNewPos; + int iOldPos; - for( iNewPos = 0; iNewPos < *gi.numDebugLines && iNewPos < g_numdebuglines->integer; iNewPos++ ) - { - iOldPos = g_iFirstLine + iNewPos; + for (iNewPos = 0; iNewPos < *gi.numDebugLines && iNewPos < g_numdebuglines->integer; iNewPos++) { + iOldPos = g_iFirstLine + iNewPos; - DebugLines[ iNewPos ] = DebugLines[ iOldPos ]; - } + DebugLines[iNewPos] = DebugLines[iOldPos]; + } - g_iFirstLine = 0; - *gi.DebugLines = DebugLines; + g_iFirstLine = 0; + *gi.DebugLines = DebugLines; } -void G_DeAllocDebugStrings - ( - void - ) +void G_DeAllocDebugStrings(void) { - if( DebugStrings ) - { - // we do a free here, because we used malloc above - free( DebugStrings ); - DebugStrings = NULL; - *gi.DebugStrings = DebugStrings; - *gi.numDebugStrings = 0; - } + if (DebugStrings) { + // we do a free here, because we used malloc above + free(DebugStrings); + DebugStrings = NULL; + *gi.DebugStrings = DebugStrings; + *gi.numDebugStrings = 0; + } } -void G_DebugLine - ( - Vector start, - Vector end, - float r, - float g, - float b, - float alpha - ) +void G_DebugLine(Vector start, Vector end, float r, float g, float b, float alpha) { - debugline_t *line; - static int printTime = 0; + debugline_t *line; + static int printTime = 0; - if( !g_numdebuglines->integer ) - { - return; - } + if (!g_numdebuglines->integer) { + return; + } - if( *gi.numDebugLines >= g_numdebuglines->integer ) - { - if( level.svsTime >= printTime ) - { - printTime = level.svsTime + 5000; - gi.DPrintf( "G_DebugLine: Exceeded MAX_DEBUG_LINES\n" ); - } + if (*gi.numDebugLines >= g_numdebuglines->integer) { + if (level.svsTime >= printTime) { + printTime = level.svsTime + 5000; + gi.DPrintf("G_DebugLine: Exceeded MAX_DEBUG_LINES\n"); + } - return; - } + return; + } - if( g_numdebuglinedelays->integer > 0 && g_iFirstLine > 0 && g_iFirstLine + *gi.numDebugLines + 1 >= g_numdebuglines->integer ) - { - G_ShiftDebugLines(); - } + if (g_numdebuglinedelays->integer > 0 && g_iFirstLine > 0 + && g_iFirstLine + *gi.numDebugLines + 1 >= g_numdebuglines->integer) { + G_ShiftDebugLines(); + } - line = &DebugLines[ *gi.numDebugLines ]; - ( *gi.numDebugLines )++; - g_iFrameLineCount[ g_iCurrFrameLineCounter ]++; + line = &DebugLines[g_iFirstLine + *gi.numDebugLines]; + (*gi.numDebugLines)++; + g_iFrameLineCount[g_iCurrFrameLineCounter]++; - VectorCopy( start, line->start ); - VectorCopy( end, line->end ); - VectorSet( line->color, r, g, b ); - line->alpha = alpha; + VectorCopy(start, line->start); + VectorCopy(end, line->end); + VectorSet(line->color, r, g, b); + line->alpha = alpha; - line->width = linewidth; - line->factor = lineStippleFactor; - line->pattern = linePattern; + line->width = linewidth; + line->factor = lineStippleFactor; + line->pattern = linePattern; } -void G_LineStipple - ( - int factor, - unsigned short pattern - ) +void G_LineStipple(int factor, unsigned short pattern) +{ + lineStippleFactor = factor; + linePattern = pattern; +} - { - lineStippleFactor = factor; - linePattern = pattern; - } +void G_LineWidth(float width) +{ + linewidth = width; +} -void G_LineWidth - ( - float width - ) - - { - linewidth = width; - } +void G_Color3f(float r, float g, float b) +{ + vertColor = Vector(r, g, b); +} -void G_Color3f - ( - float r, - float g, - float b - ) +void G_Color3v(Vector color) +{ + vertColor = color; +} - { - vertColor = Vector( r, g, b ); - } +void G_Color4f(float r, float g, float b, float alpha) +{ + vertColor = Vector(r, g, b); + vertAlpha = alpha; +} -void G_Color3v - ( - Vector color - ) +void G_Color3vf(Vector color, float alpha) +{ + vertColor = color; + vertAlpha = alpha; +} - { - vertColor = color; - } +void G_BeginLine(void) +{ + currentVertex = vec_zero; + vertexIndex = 0; +} -void G_Color4f - ( - float r, - float g, - float b, - float alpha - ) +void G_Vertex(Vector v) +{ + vertexIndex++; + if (vertexIndex > 1) { + G_DebugLine(currentVertex, v, vertColor[0], vertColor[1], vertColor[2], vertAlpha); + } + currentVertex = v; +} - { - vertColor = Vector( r, g, b ); - vertAlpha = alpha; - } +void G_EndLine(void) +{ + currentVertex = vec_zero; + vertexIndex = 0; +} -void G_Color3vf - ( - Vector color, - float alpha - ) +void G_DebugBBox(Vector org, Vector mins, Vector maxs, float r, float g, float b, float alpha) +{ + int i; + Vector points[8]; - { - vertColor = color; - vertAlpha = alpha; - } - -void G_BeginLine - ( - void - ) - - { - currentVertex = vec_zero; - vertexIndex = 0; - } - -void G_Vertex - ( - Vector v - ) - - { - vertexIndex++; - if ( vertexIndex > 1 ) - { - G_DebugLine( currentVertex, v, vertColor[ 0 ], vertColor[ 1 ], vertColor[ 2 ], vertAlpha ); - } - currentVertex = v; - } - -void G_EndLine - ( - void - ) - - { - currentVertex = vec_zero; - vertexIndex = 0; - } - -void G_DebugBBox - ( - Vector org, - Vector mins, - Vector maxs, - float r, - float g, - float b, - float alpha - ) - { - int i; - Vector points[8]; - - /* + /* ** compute a full bounding box */ - for ( i = 0; i < 8; i++ ) - { - Vector tmp; + for (i = 0; i < 8; i++) { + Vector tmp; - if ( i & 1 ) - tmp[0] = org[0] + mins[0]; - else - tmp[0] = org[0] + maxs[0]; + if (i & 1) { + tmp[0] = org[0] + mins[0]; + } else { + tmp[0] = org[0] + maxs[0]; + } - if ( i & 2 ) - tmp[1] = org[1] + mins[1]; - else - tmp[1] = org[1] + maxs[1]; + if (i & 2) { + tmp[1] = org[1] + mins[1]; + } else { + tmp[1] = org[1] + maxs[1]; + } - if ( i & 4 ) - tmp[2] = org[2] + mins[2]; - else - tmp[2] = org[2] + maxs[2]; + if (i & 4) { + tmp[2] = org[2] + mins[2]; + } else { + tmp[2] = org[2] + maxs[2]; + } - points[i] = tmp; - } + points[i] = tmp; + } - G_Color4f( r, g, b, alpha ); + G_Color4f(r, g, b, alpha); - G_BeginLine(); - G_Vertex( points[0] ); - G_Vertex( points[1] ); - G_Vertex( points[3] ); - G_Vertex( points[2] ); - G_Vertex( points[0] ); - G_EndLine(); + G_BeginLine(); + G_Vertex(points[0]); + G_Vertex(points[1]); + G_Vertex(points[3]); + G_Vertex(points[2]); + G_Vertex(points[0]); + G_EndLine(); - G_BeginLine(); - G_Vertex( points[4] ); - G_Vertex( points[5] ); - G_Vertex( points[7] ); - G_Vertex( points[6] ); - G_Vertex( points[4] ); - G_EndLine(); + G_BeginLine(); + G_Vertex(points[4]); + G_Vertex(points[5]); + G_Vertex(points[7]); + G_Vertex(points[6]); + G_Vertex(points[4]); + G_EndLine(); - for ( i = 0; i < 4; i++ ) - { - G_BeginLine(); - G_Vertex( points[i] ); - G_Vertex( points[4 + i] ); - G_EndLine(); - } - } + G_Color4f(0, 0, 1, alpha); + + for (i = 0; i < 4; i++) { + G_BeginLine(); + G_Vertex(points[i]); + G_Vertex(points[4 + i]); + G_EndLine(); + } +} + +void G_DebugRotatedBBox(Vector org, Vector ang, Vector mins, Vector maxs, float r, float g, float b, float alpha) { + int i; + Vector tmp; + Vector points[8]; + vec3_t axis[3]; + + AnglesToAxis(ang, axis); + + /* + ** compute a full bounding box + */ + for (i = 0; i < 8; i++) { + Vector tmp; + + if (i & 1) { + tmp[0] = mins[0]; + } else { + tmp[0] = maxs[0]; + } + + if (i & 2) { + tmp[1] = mins[1]; + } else { + tmp[1] = maxs[1]; + } + + if (i & 4) { + tmp[2] = mins[2]; + } else { + tmp[2] = maxs[2]; + } + + MatrixTransformVector(tmp, axis, points[i]); + points[i] += org; + } + + G_Color4f(r, g, b, alpha); + + G_BeginLine(); + G_Vertex(points[0]); + G_Vertex(points[1]); + G_Vertex(points[3]); + G_Vertex(points[2]); + G_Vertex(points[0]); + G_EndLine(); + + G_BeginLine(); + G_Vertex(points[4]); + G_Vertex(points[5]); + G_Vertex(points[7]); + G_Vertex(points[6]); + G_Vertex(points[4]); + G_EndLine(); + + G_Color4f(0, 0, 1, alpha); + + for (i = 0; i < 4; i++) { + G_BeginLine(); + G_Vertex(points[i]); + G_Vertex(points[4 + i]); + G_EndLine(); + } +} // // LED style digits @@ -401,500 +375,408 @@ void G_DebugBBox // ****3*** 12** // 11 -static int Numbers[ 12 ][ 8 ] = - { - { 1, 3, 4, 5, 6, 7, 0, 0 }, // 0 - { 4, 5, 0, 0, 0, 0, 0, 0 }, // 1 - { 1, 4, 2, 7, 3, 0, 0, 0 }, // 2 - { 1, 4, 2, 5, 3, 0, 0, 0 }, // 3 - { 6, 4, 2, 5, 0, 0, 0, 0 }, // 4 - { 1, 6, 2, 5, 3, 0, 0, 0 }, // 5 - { 1, 6, 2, 5, 7, 3, 0, 0 }, // 6 - { 1, 8, 0, 0, 0, 0, 0, 0 }, // 7 - { 1, 2, 3, 4, 5, 6, 7, 0 }, // 8 - { 1, 6, 4, 2, 5, 3, 0, 0 }, // 9 - { 9, 10, 11, 12, 0, 0, 0, 0 }, // . - { 2, 0, 0, 0, 0, 0, 0, 0 }, // - - }; +static int Numbers[12][8] = { + {1, 3, 4, 5, 6, 7, 0, 0}, // 0 + {4, 5, 0, 0, 0, 0, 0, 0}, // 1 + {1, 4, 2, 7, 3, 0, 0, 0}, // 2 + {1, 4, 2, 5, 3, 0, 0, 0}, // 3 + {6, 4, 2, 5, 0, 0, 0, 0}, // 4 + {1, 6, 2, 5, 3, 0, 0, 0}, // 5 + {1, 6, 2, 5, 7, 3, 0, 0}, // 6 + {1, 8, 0, 0, 0, 0, 0, 0}, // 7 + {1, 2, 3, 4, 5, 6, 7, 0}, // 8 + {1, 6, 4, 2, 5, 3, 0, 0}, // 9 + {9, 10, 11, 12, 0, 0, 0, 0}, // . + {2, 0, 0, 0, 0, 0, 0, 0}, // - +}; -static float Lines[ 13 ][ 4 ] = - { - { 0, 0, 0, 0 }, // Unused - { -4, 8, 4, 8 }, // 1 - { -4, 4, 4, 4 }, // 2 - { -4, 0, 4, 0 }, // 3 - { 4, 8, 4, 4 }, // 4 - { 4, 4, 4, 0 }, // 5 - { -4, 8, -4, 4 }, // 6 - { -4, 4, -4, 0 }, // 7 - { 4, 8, -4, 0 }, // 8 +static float Lines[13][4] = { + {0, 0, 0, 0}, // Unused + {-4, 8, 4, 8}, // 1 + {-4, 4, 4, 4}, // 2 + {-4, 0, 4, 0}, // 3 + {4, 8, 4, 4}, // 4 + {4, 4, 4, 0}, // 5 + {-4, 8, -4, 4}, // 6 + {-4, 4, -4, 0}, // 7 + {4, 8, -4, 0}, // 8 - { -1, 2, 1, 2 }, // 9 - { 1, 2, 1, 0 }, // 10 - { -1, 0, 1, 0 }, // 11 - { -1, 0, -1, 2 }, // 12 - }; + {-1, 2, 1, 2}, // 9 + {1, 2, 1, 0}, // 10 + {-1, 0, 1, 0}, // 11 + {-1, 0, -1, 2}, // 12 +}; -void G_DrawDebugNumber - ( - Vector org, - float number, - float scale, - float r, - float g, - float b, - int precision - ) +void G_DrawDebugNumber(Vector org, float number, float scale, float r, float g, float b, int precision) { - int i; - int j; - int l; - int num; - Vector up; - Vector left; - Vector pos; - Vector start; - Vector ang; - str text; - Vector delta; - char format[ 20 ]; + int i; + int j; + int l; + int num; + Vector up; + Vector left; + Vector pos; + Vector start; + Vector ang; + str text; + Vector delta; + char format[20]; - // only draw entity numbers within a certain radius - delta = Vector( g_entities[ 0 ].s.origin ) - org; - if( ( delta * delta ) > ( 1000 * 1000 ) ) - { - return; - } + // only draw entity numbers within a certain radius + delta = Vector(g_entities[0].s.origin) - org; + if ((delta * delta) > (1000 * 1000)) { + return; + } - G_Color4f( r, g, b, 1.0 ); + G_Color4f(r, g, b, 1.0); - ang = game.clients[ 0 ].ps.viewangles; - ang.AngleVectorsLeft( NULL, &left, &up ); + ang = game.clients[0].ps.viewangles; + ang.AngleVectorsLeft(NULL, &left, &up); - up *= scale; - left *= scale; + up *= scale; + left *= scale; - if( precision > 0 ) - { - sprintf( format, "%%.%df", precision ); - text = va( format, number ); - } - else - { - text = va( "%d", ( int )number ); - } + if (precision > 0) { + Com_sprintf(format, sizeof(format), "%%.%df", precision); + text = va(format, number); + } else { + text = va("%d", (int)number); + } - start = org + ( text.length() - 1 ) * 5 * left; + start = org + (text.length() - 1) * 5 * left; - for( i = 0; i < text.length(); i++ ) - { - if( text[ i ] == '.' ) - { - num = 10; - } - else if( text[ i ] == '-' ) - { - num = 11; - } - else - { - num = text[ i ] - '0'; - } + for (i = 0; i < text.length(); i++) { + if (text[i] == '.') { + num = 10; + } else if (text[i] == '-') { + num = 11; + } else { + num = text[i] - '0'; + } - for( j = 0; j < 8; j++ ) - { - l = Numbers[ num ][ j ]; - if( l == 0 ) - { - break; - } + for (j = 0; j < 8; j++) { + l = Numbers[num][j]; + if (l == 0) { + break; + } - G_BeginLine(); + G_BeginLine(); - pos = start - Lines[ l ][ 0 ] * left + Lines[ l ][ 1 ] * up; - G_Vertex( pos ); + pos = start - Lines[l][0] * left + Lines[l][1] * up; + G_Vertex(pos); - pos = start - Lines[ l ][ 2 ] * left + Lines[ l ][ 3 ] * up; - G_Vertex( pos ); + pos = start - Lines[l][2] * left + Lines[l][3] * up; + G_Vertex(pos); - G_EndLine(); - } + G_EndLine(); + } - start -= 10 * left; - } + start -= 10 * left; + } } -void G_DebugCircle - ( - float *org, - float radius, - float r, - float g, - float b, - float alpha, - qboolean horizontal - ) - { - int i; - float ang; - Vector angles; - Vector forward; - Vector left; - Vector pos; - Vector delta; - - // only draw circles within a certain radius - delta = Vector( g_entities[ 0 ].s.origin ) - org; - if ( ( delta * delta ) > ( ( 1000 + radius ) * ( 1000 + radius ) ) ) - { - return; - } - - G_Color4f( r, g, b, alpha ); - - if ( horizontal ) - { - forward = "1 0 0"; - left = "0 -1 0"; - } - else - { - angles = game.clients[ 0 ].ps.viewangles; - angles.AngleVectors( NULL, &left, &forward ); - } - - G_BeginLine(); - for( i = 0; i <= NUM_CIRCLE_SEGMENTS; i++ ) - { - ang = DEG2RAD( i * 360 / NUM_CIRCLE_SEGMENTS ); - pos = org + ( sin( ang ) * radius * forward ) - ( cos( ang ) * radius * left ); - G_Vertex( pos ); - } - G_EndLine(); - } - -void G_DebugOrientedCircle - ( - Vector org, - float radius, - float r, - float g, - float b, - float alpha, - Vector angles - ) - { - int i; - float ang; - Vector forward; - Vector left; - Vector pos; - Vector delta; - - // only draw circles within a certain radius - delta = Vector( g_entities[ 0 ].s.origin ) - org; - if ( ( delta * delta ) > ( ( 1000 + radius ) * ( 1000 + radius ) ) ) - { - return; - } - - G_Color4f( r, g, b, alpha ); - - angles.AngleVectors( NULL, &left, &forward ); - - G_BeginLine(); - for( i = 0; i <= NUM_CIRCLE_SEGMENTS; i++ ) - { - ang = DEG2RAD( i * 360 / NUM_CIRCLE_SEGMENTS ); - pos = org + ( sin( ang ) * radius * forward ) - ( cos( ang ) * radius * left ); - G_Vertex( pos ); - } - G_EndLine(); - - // - // Draw the cross sign - // - G_BeginLine(); - ang = DEG2RAD( 45 * 360 / NUM_CIRCLE_SEGMENTS ); - pos = org + ( sin( ang ) * radius * forward ) - ( cos( ang ) * radius * left ); - G_Vertex( pos ); - ang = DEG2RAD( 225 * 360 / NUM_CIRCLE_SEGMENTS ); - pos = org + ( sin( ang ) * radius * forward ) - ( cos( ang ) * radius * left ); - G_Vertex( pos ); - - G_BeginLine(); - ang = DEG2RAD( 315 * 360 / NUM_CIRCLE_SEGMENTS ); - pos = org + ( sin( ang ) * radius * forward ) - ( cos( ang ) * radius * left ); - G_Vertex( pos ); - ang = DEG2RAD( 135 * 360 / NUM_CIRCLE_SEGMENTS ); - pos = org + ( sin( ang ) * radius * forward ) - ( cos( ang ) * radius * left ); - G_Vertex( pos ); - } - -void G_DebugPyramid - ( - Vector org, - float radius, - float r, - float g, - float b, - float alpha - ) - { - Vector delta; - Vector points[ 4 ]; - - // only draw pyramids within a certain radius - delta = Vector( g_entities[ 0 ].s.origin ) - org; - if ( ( delta * delta ) > ( ( 1000 + radius ) * ( 1000 + radius ) ) ) - { - return; - } - - G_Color4f( r, g, b, alpha ); - - points[ 0 ] = org; - points[ 0 ].z += radius; - - points[ 1 ] = org; - points[ 1 ].z -= radius; - points[ 2 ] = points[ 1 ]; - points[ 3 ] = points[ 1 ]; - - points[ 1 ].x += cos( DEG2RAD( 0 ) ) * radius; - points[ 1 ].y += sin( DEG2RAD( 0 ) ) * radius; - points[ 2 ].x += cos( DEG2RAD( 120 ) ) * radius; - points[ 2 ].y += sin( DEG2RAD( 120 ) ) * radius; - points[ 3 ].x += cos( DEG2RAD( 240 ) ) * radius; - points[ 3 ].y += sin( DEG2RAD( 240 ) ) * radius; - - G_BeginLine(); - G_Vertex( points[ 0 ] ); - G_Vertex( points[ 1 ] ); - G_Vertex( points[ 2 ] ); - G_Vertex( points[ 0 ] ); - G_EndLine(); - - G_BeginLine(); - G_Vertex( points[ 0 ] ); - G_Vertex( points[ 2 ] ); - G_Vertex( points[ 3 ] ); - G_Vertex( points[ 0 ] ); - G_EndLine(); - - G_BeginLine(); - G_Vertex( points[ 0 ] ); - G_Vertex( points[ 3 ] ); - G_Vertex( points[ 1 ] ); - G_Vertex( points[ 0 ] ); - G_EndLine(); - - G_BeginLine(); - G_Vertex( points[ 1 ] ); - G_Vertex( points[ 2 ] ); - G_Vertex( points[ 3 ] ); - G_Vertex( points[ 1 ] ); - G_EndLine(); - } - -void G_DrawCoordSystem - ( - Vector pos, - Vector forward, - Vector right, - Vector up, - int length - ) - - { - if ( g_showaxis->integer ) - { - G_DebugLine( pos, pos + forward * length, 1,0,0,1 ); - G_DebugLine( pos, pos + right * length, 0,1,0,1 ); - G_DebugLine( pos, pos + up * length, 0,0,1,1 ); - } - } - -void G_DrawCSystem - ( - Vector pos, - Vector forward, - Vector right, - Vector up, - int length - ) +void G_DebugCircle(float *org, float radius, float r, float g, float b, float alpha, qboolean horizontal) { - G_DebugLine( pos, pos + forward * length, 1.0, 0, 0, 1 ); - G_DebugLine( pos, pos + right * length, 0, 1.0, 0, 1 ); - G_DebugLine( pos, pos + up * length, 0, 0, 1.0, 1 ); + int i; + float ang; + Vector angles; + Vector forward; + Vector left; + Vector pos; + Vector delta; + + // only draw circles within a certain radius + delta = Vector(g_entities[0].s.origin) - org; + if ((delta * delta) > ((1000 + radius) * (1000 + radius))) { + return; + } + + G_Color4f(r, g, b, alpha); + + if (horizontal) { + forward = "1 0 0"; + left = "0 -1 0"; + } else { + angles = game.clients[0].ps.viewangles; + angles.AngleVectors(NULL, &left, &forward); + } + + G_BeginLine(); + for (i = 0; i <= NUM_CIRCLE_SEGMENTS; i++) { + ang = DEG2RAD(i * 360 / NUM_CIRCLE_SEGMENTS); + pos = org + (sin(ang) * radius * forward) - (cos(ang) * radius * left); + G_Vertex(pos); + } + G_EndLine(); } -void G_DebugArrow - ( - Vector org, - Vector dir, - float length, - float r, - float g, - float b, - float alpha - ) - { - Vector right; - Vector up; - Vector startpoint; - Vector endpoint; +void G_DebugOrientedCircle(Vector org, float radius, float r, float g, float b, float alpha, Vector angles) +{ + int i; + float ang; + Vector forward; + Vector left; + Vector pos; + Vector delta; - PerpendicularVector( right, dir ); - up.CrossProduct( right, dir ); + // only draw circles within a certain radius + delta = Vector(g_entities[0].s.origin) - org; + if ((delta * delta) > ((1000 + radius) * (1000 + radius))) { + return; + } - startpoint = org; + G_Color4f(r, g, b, alpha); - endpoint = startpoint + dir * length; - length /= 6; - G_DebugLine( startpoint, endpoint, r, g, b, alpha ); - G_DebugLine( endpoint, endpoint - (right * length) - (dir * length), r, g, b, alpha ); - G_DebugLine( endpoint, endpoint + (right * length) - (dir * length), r, g, b, alpha ); - G_DebugLine( endpoint, endpoint - (up * length) - (dir * length), r, g, b, alpha ); - G_DebugLine( endpoint, endpoint + (up * length) - (dir * length), r, g, b, alpha ); - } + angles.AngleVectors(NULL, &left, &forward); -void G_DebugHighlightFacet - ( - Vector org, - Vector mins, - Vector maxs, - facet_t facet, - float r, - float g, - float b, - float alpha - ) - { - int i; - Vector points[8]; + G_BeginLine(); + for (i = 0; i <= NUM_CIRCLE_SEGMENTS; i++) { + ang = DEG2RAD(i * 360 / NUM_CIRCLE_SEGMENTS); + pos = org + (sin(ang) * radius * forward) - (cos(ang) * radius * left); + G_Vertex(pos); + } + G_EndLine(); - /* + // + // Draw the cross sign + // + G_BeginLine(); + ang = DEG2RAD(45 * 360 / NUM_CIRCLE_SEGMENTS); + pos = org + (sin(ang) * radius * forward) - (cos(ang) * radius * left); + G_Vertex(pos); + ang = DEG2RAD(225 * 360 / NUM_CIRCLE_SEGMENTS); + pos = org + (sin(ang) * radius * forward) - (cos(ang) * radius * left); + G_Vertex(pos); + + G_BeginLine(); + ang = DEG2RAD(315 * 360 / NUM_CIRCLE_SEGMENTS); + pos = org + (sin(ang) * radius * forward) - (cos(ang) * radius * left); + G_Vertex(pos); + ang = DEG2RAD(135 * 360 / NUM_CIRCLE_SEGMENTS); + pos = org + (sin(ang) * radius * forward) - (cos(ang) * radius * left); + G_Vertex(pos); +} + +void G_DebugPyramid(Vector org, float radius, float r, float g, float b, float alpha) +{ + Vector delta; + Vector points[4]; + + // only draw pyramids within a certain radius + delta = Vector(g_entities[0].s.origin) - org; + if ((delta * delta) > ((1000 + radius) * (1000 + radius))) { + return; + } + + G_Color4f(r, g, b, alpha); + + points[0] = org; + points[0].z += radius; + + points[1] = org; + points[1].z -= radius; + points[2] = points[1]; + points[3] = points[1]; + + points[1].x += cos(DEG2RAD(0)) * radius; + points[1].y += sin(DEG2RAD(0)) * radius; + points[2].x += cos(DEG2RAD(120)) * radius; + points[2].y += sin(DEG2RAD(120)) * radius; + points[3].x += cos(DEG2RAD(240)) * radius; + points[3].y += sin(DEG2RAD(240)) * radius; + + G_BeginLine(); + G_Vertex(points[0]); + G_Vertex(points[1]); + G_Vertex(points[2]); + G_Vertex(points[0]); + G_EndLine(); + + G_BeginLine(); + G_Vertex(points[0]); + G_Vertex(points[2]); + G_Vertex(points[3]); + G_Vertex(points[0]); + G_EndLine(); + + G_BeginLine(); + G_Vertex(points[0]); + G_Vertex(points[3]); + G_Vertex(points[1]); + G_Vertex(points[0]); + G_EndLine(); + + G_BeginLine(); + G_Vertex(points[1]); + G_Vertex(points[2]); + G_Vertex(points[3]); + G_Vertex(points[1]); + G_EndLine(); +} + +void G_DrawCoordSystem(Vector pos, Vector forward, Vector right, Vector up, int length) +{ + if (g_showaxis->integer) { + G_DebugLine(pos, pos + forward * length, 1, 0, 0, 1); + G_DebugLine(pos, pos + right * length, 0, 1, 0, 1); + G_DebugLine(pos, pos + up * length, 0, 0, 1, 1); + } +} + +void G_DrawCSystem(Vector pos, Vector forward, Vector right, Vector up, int length) +{ + G_DebugLine(pos, pos + forward * length, 1.0, 0, 0, 1); + G_DebugLine(pos, pos + right * length, 0, 1.0, 0, 1); + G_DebugLine(pos, pos + up * length, 0, 0, 1.0, 1); +} + +void G_DebugArrow(Vector org, Vector dir, float length, float r, float g, float b, float alpha) +{ + Vector right; + Vector up; + Vector startpoint; + Vector endpoint; + + PerpendicularVector(right, dir); + up.CrossProduct(right, dir); + + startpoint = org; + + endpoint = startpoint + dir * length; + length /= 6; + G_DebugLine(startpoint, endpoint, r, g, b, alpha); + G_DebugLine(endpoint, endpoint - (right * length) - (dir * length), r, g, b, alpha); + G_DebugLine(endpoint, endpoint + (right * length) - (dir * length), r, g, b, alpha); + G_DebugLine(endpoint, endpoint - (up * length) - (dir * length), r, g, b, alpha); + G_DebugLine(endpoint, endpoint + (up * length) - (dir * length), r, g, b, alpha); +} + +void G_DebugHighlightFacet(Vector org, Vector mins, Vector maxs, facet_t facet, float r, float g, float b, float alpha) +{ + int i; + Vector points[8]; + + /* ** compute a full bounding box */ - for ( i = 0; i < 8; i++ ) - { - Vector tmp; + for (i = 0; i < 8; i++) { + Vector tmp; - if ( i & 1 ) - tmp[0] = org[0] + mins[0]; - else - tmp[0] = org[0] + maxs[0]; + if (i & 1) { + tmp[0] = org[0] + mins[0]; + } else { + tmp[0] = org[0] + maxs[0]; + } - if ( i & 2 ) - tmp[1] = org[1] + mins[1]; - else - tmp[1] = org[1] + maxs[1]; + if (i & 2) { + tmp[1] = org[1] + mins[1]; + } else { + tmp[1] = org[1] + maxs[1]; + } - if ( i & 4 ) - tmp[2] = org[2] + mins[2]; - else - tmp[2] = org[2] + maxs[2]; + if (i & 4) { + tmp[2] = org[2] + mins[2]; + } else { + tmp[2] = org[2] + maxs[2]; + } - points[i] = tmp; - } + points[i] = tmp; + } - G_Color4f( r, g, b, alpha ); + G_Color4f(r, g, b, alpha); - switch( facet ) - { - case north: - G_BeginLine(); - G_Vertex( points[0] ); - G_Vertex( points[5] ); - G_EndLine(); - G_BeginLine(); - G_Vertex( points[1] ); - G_Vertex( points[4] ); - G_EndLine(); - break; - case south: - G_BeginLine(); - G_Vertex( points[2] ); - G_Vertex( points[7] ); - G_EndLine(); - G_BeginLine(); - G_Vertex( points[3] ); - G_Vertex( points[6] ); - G_EndLine(); - break; - case east: - G_BeginLine(); - G_Vertex( points[0] ); - G_Vertex( points[6] ); - G_EndLine(); - G_BeginLine(); - G_Vertex( points[4] ); - G_Vertex( points[2] ); - G_EndLine(); - break; - case west: - G_BeginLine(); - G_Vertex( points[1] ); - G_Vertex( points[7] ); - G_EndLine(); - G_BeginLine(); - G_Vertex( points[5] ); - G_Vertex( points[3] ); - G_EndLine(); - break; - case up: - G_BeginLine(); - G_Vertex( points[0] ); - G_Vertex( points[3] ); - G_EndLine(); - G_BeginLine(); - G_Vertex( points[1] ); - G_Vertex( points[2] ); - G_EndLine(); - break; - case down: - G_BeginLine(); - G_Vertex( points[4] ); - G_Vertex( points[7] ); - G_EndLine(); - G_BeginLine(); - G_Vertex( points[5] ); - G_Vertex( points[6] ); - G_EndLine(); - break; - } - } + switch (facet) { + case north: + G_BeginLine(); + G_Vertex(points[0]); + G_Vertex(points[5]); + G_EndLine(); + G_BeginLine(); + G_Vertex(points[1]); + G_Vertex(points[4]); + G_EndLine(); + break; + case south: + G_BeginLine(); + G_Vertex(points[2]); + G_Vertex(points[7]); + G_EndLine(); + G_BeginLine(); + G_Vertex(points[3]); + G_Vertex(points[6]); + G_EndLine(); + break; + case east: + G_BeginLine(); + G_Vertex(points[0]); + G_Vertex(points[6]); + G_EndLine(); + G_BeginLine(); + G_Vertex(points[4]); + G_Vertex(points[2]); + G_EndLine(); + break; + case west: + G_BeginLine(); + G_Vertex(points[1]); + G_Vertex(points[7]); + G_EndLine(); + G_BeginLine(); + G_Vertex(points[5]); + G_Vertex(points[3]); + G_EndLine(); + break; + case up: + G_BeginLine(); + G_Vertex(points[0]); + G_Vertex(points[3]); + G_EndLine(); + G_BeginLine(); + G_Vertex(points[1]); + G_Vertex(points[2]); + G_EndLine(); + break; + case down: + G_BeginLine(); + G_Vertex(points[4]); + G_Vertex(points[7]); + G_EndLine(); + G_BeginLine(); + G_Vertex(points[5]); + G_Vertex(points[6]); + G_EndLine(); + break; + } +} - void G_DebugString(Vector pos, float scale, float r, float g, float b, const char* pszText, ...) - { - debugstring_t* string; - va_list va; - char szTemp[32768]; +void G_DebugString(Vector pos, float scale, float r, float g, float b, const char *pszText, ...) +{ + debugstring_t *string; + va_list va; + char szTemp[32768]; - if (!g_numdebugstrings) { - return; - } + if (!g_numdebugstrings) { + return; + } - if (*gi.numDebugStrings < g_numdebugstrings->integer) { - string = (debugstring_t*)&DebugStrings[*gi.numDebugStrings]; + if (*gi.numDebugStrings < g_numdebugstrings->integer) { + string = (debugstring_t *)&DebugStrings[*gi.numDebugStrings]; - (*gi.numDebugStrings)++; + (*gi.numDebugStrings)++; - va_start(va, pszText); - vsprintf(szTemp, pszText, va); - va_end(va); + va_start(va, pszText); + Q_vsnprintf(szTemp, sizeof(szTemp), pszText, va); + va_end(va); - VectorCopy(pos, string->pos); - string->scale = scale; - string->color[0] = r; - string->color[1] = g; - string->color[2] = b; - string->color[3] = 1.0f; - strncpy(string->szText, szTemp, sizeof(string->szText)); - string->szText[sizeof(string->szText) - 1] = 0; - } - else { - gi.DPrintf("G_DebugString: Exceeded g_numdebugstrings\n"); - } - } + VectorCopy(pos, string->pos); + string->scale = scale; + string->color[0] = r; + string->color[1] = g; + string->color[2] = b; + string->color[3] = 1.0f; + strncpy(string->szText, szTemp, sizeof(string->szText)); + string->szText[sizeof(string->szText) - 1] = 0; + } else { + gi.DPrintf("G_DebugString: Exceeded g_numdebugstrings\n"); + } +} diff --git a/code/fgame/debuglines.h b/code/fgame/debuglines.h index 9d497460..e0656332 100644 --- a/code/fgame/debuglines.h +++ b/code/fgame/debuglines.h @@ -22,8 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // debuglines.h: -#ifndef __DEBUGLINES_H__ -#define __DEBUGLINES_H__ +#pragma once #include "g_local.h" @@ -40,6 +39,7 @@ void G_BeginLine( void ); void G_Vertex( Vector v ); void G_EndLine( void ); void G_DebugBBox( Vector org, Vector mins, Vector maxs, float r, float g, float b, float alpha ); +void G_DebugRotatedBBox(Vector org, Vector ang, Vector mins, Vector maxs, float r, float g, float b, float alpha); void G_DrawDebugNumber( Vector org, float number, float scale, float r, float g, float b, int precision = 0 ); void G_DebugCircle( float *org, float radius, float r, float g, float b, float alpha, qboolean horizontal = qfalse ); void G_DebugOrientedCircle( Vector org, float radius, float r, float g, float b, float alpha, Vector angles ); @@ -67,5 +67,3 @@ void G_DebugHighlightFacet( Vector org, Vector mins, Vector maxs, facet_t facet, extern debugline_t *DebugLines; extern debugstring_t *DebugStrings; - -#endif /* !__DEBUGLINES_H__ */ diff --git a/code/fgame/decals.h b/code/fgame/decals.h index 7786cf06..1ca2997a 100644 --- a/code/fgame/decals.h +++ b/code/fgame/decals.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -22,8 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // decals.h: Decal entities -#ifndef __DECAL_H__ -#define __DECAL_H__ +#pragma once #include "g_local.h" #include "entity.h" @@ -57,5 +56,3 @@ inline void Decal::Archive setShader( shader ); } } - -#endif // __DECAL_H__ diff --git a/code/fgame/dm_manager.cpp b/code/fgame/dm_manager.cpp index 65b50e78..dcd87a6d 100644 --- a/code/fgame/dm_manager.cpp +++ b/code/fgame/dm_manager.cpp @@ -42,8 +42,8 @@ typedef struct spawnsort_s { static qboolean SpotWouldTelefrag(float *origin) { - static Vector mins = Vector(-16, -16, 1); - static Vector maxs = Vector(16, 16, 97); + static Vector mins = Vector(-15, -15, 1); + static Vector maxs = Vector(15, 15, 96); trace_t trace; trace = G_Trace(Vector(origin), mins, maxs, Vector(origin), NULL, MASK_PLAYERSTART, qfalse, "SpotWouldTelefrag"); @@ -58,15 +58,12 @@ static qboolean SpotWouldTelefrag(float *origin) static int compare_spawnsort(const void *pe1, const void *pe2) { float fDelta = ((spawnsort_t *)pe1)->fMetric - ((spawnsort_t *)pe2)->fMetric; - - if (fDelta >= -0.001f) { - if (fDelta <= 0.001f) { - return 0; - } else { - return -1; - } - } else { + if (fDelta < -0.001) { return 1; + } else if (fDelta > 0.001) { + return -1; + } else { + return 0; } } @@ -83,61 +80,61 @@ static PlayerStart *GetRandomSpawnpointFromList(spawnsort_t *pSpots, int nSpots) qsort(pSpots, nSpots, sizeof(spawnsort_t), compare_spawnsort); - if (pSpots[0].fMetric > 0.0f) { - if (nSpots > 5) { - nSpots = 5; - } - - fMinPosMetric = pSpots[0].fMetric * nSpots; - fTotalMetric = fMinPosMetric; - - if (nSpots <= 1) { - fChosen = fMinPosMetric; - } else { - i = 0; - fTotalMetric = 0.0f; - - for (i = 0; i < nSpots; i++) { - if (pSpots[i].fMetric <= 0.0f) { - break; - } - - fChosen = pSpots[i].fMetric * (nSpots - i); - fTotalMetric += fChosen; - - i++; - } - - if (i < nSpots) { - fChosen = fMinPosMetric; - } - - fMinPosMetric = fTotalMetric; - } - - fTotalMetric = (fMinPosMetric - i * fChosen * 0.90f) * G_Random(); - for (i = 0; i < nSpots - 1; i++) { - fTotalMetric -= (nSpots - i) * pSpots[i].fMetric - (fChosen * 0.90f); - if (fTotalMetric <= 0.0f) { - break; - } - } - - return pSpots[i].spawnpoint; - } else { + if (pSpots[0].fMetric <= 0) { // return the spot anyway return pSpots[0].spawnpoint; } + + if (nSpots > 5) { + nSpots = 5; + } + + fMinPosMetric = pSpots[0].fMetric * nSpots; + fTotalMetric = fMinPosMetric; + + if (nSpots > 1) { + i = 0; + fTotalMetric = 0.0f; + + for (i = 0; i < nSpots; i++) { + if (pSpots[i].fMetric <= 0.0f) { + break; + } + + fChosen = pSpots[i].fMetric * (nSpots - i); + fTotalMetric += fChosen; + + i++; + } + + if (i < nSpots) { + fChosen = fMinPosMetric; + } + + fMinPosMetric = fTotalMetric; + } else { + fChosen = fMinPosMetric; + } + + fTotalMetric = (fMinPosMetric - i * fChosen * 0.9) * G_Random(); + for (i = 0; i < nSpots - 1; i++) { + fTotalMetric -= (nSpots - i) * pSpots[i].fMetric - (fChosen * 0.9); + if (fTotalMetric <= 0) { + break; + } + } + + return pSpots[i].spawnpoint; } -float SpawnpointMetric_Ffa(const float *origin, DM_Team *dmTeam, const Player *player) +float SpawnpointMetric_Ffa(const vec3_t origin, DM_Team *dmTeam, const Player *player) { - float fMinEnemyDistSquared = 23170.0f * 23170.0f; + float fMinEnemyDistSquared = Square(23170.f); int i; int nPlayers = dmManager.PlayerCount(); float fDist; - for (i = 1; i < nPlayers; i++) { + for (i = 1; i <= nPlayers; i++) { Player *teammate = dmManager.GetPlayer(i); if (teammate == player || teammate->IsDead() || teammate->IsSpectator()) { continue; @@ -150,12 +147,12 @@ float SpawnpointMetric_Ffa(const float *origin, DM_Team *dmTeam, const Player *p } } - return fMinEnemyDistSquared - (G_Random(0.25f) + 1.0f) * (1024.0f * 1024.0f); + return fMinEnemyDistSquared - Square(1024) * (G_Random(0.25) + 1.0); } -float SpawnpointMetric_Team(const float *origin, DM_Team *dmTeam, const Player *player) +float SpawnpointMetric_Team(const vec3_t origin, DM_Team *dmTeam, const Player *player) { - float fMinEnemyDistSquared = 23170.0f * 23170.0f; + float fMinEnemyDistSquared = Square(23170.f); float fSumFriendDistSquared = 0.0f; float fDistSquared; float fMetric; @@ -163,7 +160,7 @@ float SpawnpointMetric_Team(const float *origin, DM_Team *dmTeam, const Player * int nPlayers = dmManager.PlayerCount(); int nFriends = 0; - for (i = 1; i < nPlayers; i++) { + for (i = 1; i <= nPlayers; i++) { Player *teammate = dmManager.GetPlayer(i); if (teammate == player || teammate->IsDead() || teammate->IsSpectator()) { continue; @@ -174,25 +171,23 @@ float SpawnpointMetric_Team(const float *origin, DM_Team *dmTeam, const Player * if (teammate->GetDM_Team() == dmTeam) { nFriends++; fSumFriendDistSquared += fDistSquared; - } else { - if (fMinEnemyDistSquared > fDistSquared) { - fMinEnemyDistSquared = fDistSquared; - } + } else if (fMinEnemyDistSquared > fDistSquared) { + fMinEnemyDistSquared = fDistSquared; } } - fMetric = fMinEnemyDistSquared - (G_Random(0.25f) + 1.0f) * (1024.0f * 1024.0f); + fMetric = fMinEnemyDistSquared - Square(1024) * (G_Random(0.25) + 1.0); if (nFriends) { - fMetric += 0.25f * ((23170.0f * 23170.0f) - fSumFriendDistSquared / nFriends); + fMetric += Square(23170) * 0.25 - fSumFriendDistSquared / nFriends; } return fMetric; } -float SpawnpointMetric_Objective(const float *origin, DM_Team *dmTeam, const Player *player) +float SpawnpointMetric_Objective(const vec3_t origin, DM_Team *dmTeam, const Player *player) { - return rand() * 0.0000000005f; + return rand() / (float)RAND_MAX; } CLASS_DECLARATION(Listener, DM_Team, NULL) { @@ -271,7 +266,8 @@ void DM_Team::AddKills(Player *player, int numKills) if (m_teamnumber > TEAM_FREEFORALL) { m_iKills += numKills; - if ((g_gametype->integer >= GT_TEAM_ROUNDS && g_gametype->integer <= GT_TOW) || g_gametype->integer == GT_LIBERATION) { + if ((g_gametype->integer >= GT_TEAM_ROUNDS && g_gametype->integer <= GT_TOW) + || g_gametype->integer == GT_LIBERATION) { player->AddDeaths(numKills); } else { m_teamwins += numKills; @@ -285,7 +281,8 @@ void DM_Team::AddDeaths(Player *player, int numDeaths) return; } - if ((g_gametype->integer >= GT_TEAM_ROUNDS && g_gametype->integer <= GT_TOW) || g_gametype->integer == GT_LIBERATION) { + if ((g_gametype->integer >= GT_TEAM_ROUNDS && g_gametype->integer <= GT_TOW) + || g_gametype->integer == GT_LIBERATION) { return; } @@ -457,12 +454,12 @@ PlayerStart *DM_Team::GetRandomSpawnpointWithMetric( vNewSpawn, player->mins, player->maxs, vEnd, player, MASK_PLAYERSOLID, qfalse, "TempSpawnPoint" ); - if (!trace.allsolid && !trace.startsolid && trace.fraction != 1.0f && trace.fraction != 1.0f - && trace.plane.dist >= 0.8f) { + if (!trace.allsolid && !trace.startsolid && trace.fraction != 1.0f && trace.plane.dist >= 0.8f) { points[numSpots].spawnpoint = new PlayerStart; points[numSpots].spawnpoint->setOrigin(trace.endpos); points[numSpots].spawnpoint->setAngles(spot->angles); points[numSpots].fMetric = MetricFunction(vNewSpawn, this, player); + numSpots++; if (numSpots >= (sizeof(points) / sizeof(points[0]))) { break; @@ -475,8 +472,8 @@ PlayerStart *DM_Team::GetRandomSpawnpointWithMetric( spot = GetRandomSpawnpointFromList(points, numSpots); for (int i = 0; i < numSpots; i++) { // delete all created spawnpoint - if (points[numSpots].spawnpoint != spot) { - delete points[numSpots].spawnpoint; + if (points[i].spawnpoint != spot) { + delete points[i].spawnpoint; } } @@ -495,6 +492,7 @@ PlayerStart *DM_Team::GetRandomSpawnpointWithMetric( if (!SpotWouldTelefrag(spot->origin)) { points[numSpots].spawnpoint = spot; points[numSpots].fMetric = MetricFunction(spot->origin, this, player); + numSpots++; if (numSpots >= (sizeof(points) / sizeof(points[0]))) { break; @@ -532,7 +530,7 @@ bool DM_Team::IsDead(void) const return false; } - if (g_gametype->integer == GT_TOW) { + if (g_gametype->integer == GT_TOW || g_gametype->integer == GT_LIBERATION) { if (dmManager.AllowTeamRespawn(m_teamnumber)) { return false; } @@ -626,7 +624,11 @@ Event EV_DM_Manager_DoRoundTransition ); Event EV_DM_Manager_FinishRoundTransition ( - "finishroundtransition", EV_DEFAULT, NULL, NULL, "delayed function call to do the actual restart for the next round" + "finishroundtransition", + EV_DEFAULT, + NULL, + NULL, + "delayed function call to do the actual restart for the next round" ); CLASS_DECLARATION(Listener, DM_Manager, NULL) { @@ -667,10 +669,11 @@ DM_Manager::DM_Manager() m_csTeamBombPlantSide = STRING_DRAW; m_iNumTargetsToDestroy = 1; m_iNumTargetsDestroyed = 0; - m_iNumBombsPlanted = 0; + m_iNumBombsPlanted = 0; m_bAllowAxisRespawn = true; m_bAllowAlliedRespawn = true; m_bRoundActive = false; + m_iTotalMapTime = 0; } DM_Manager::~DM_Manager() {} @@ -1048,11 +1051,11 @@ void DM_Manager::InitGame(void) } for (i = 1; i <= level.m_SimpleArchivedEntities.NumObjects(); i++) { - SimpleArchivedEntity* const ent = level.m_SimpleArchivedEntities.ObjectAt(i); - const char* const classname = ent->getClassID(); + SimpleArchivedEntity *const ent = level.m_SimpleArchivedEntities.ObjectAt(i); + const char *const classname = ent->getClassID(); if (!Q_stricmp(classname, "info_player_deathmatch")) { - PlayerStart* const spawnpoint = static_cast(ent); + PlayerStart *const spawnpoint = static_cast(ent); m_team_spectator.m_spawnpoints.AddObject(spawnpoint); m_team_freeforall.m_spawnpoints.AddObject(spawnpoint); @@ -1062,16 +1065,16 @@ void DM_Manager::InitGame(void) } } else if (!Q_stricmp(classname, "info_player_allied")) { if (g_gametype->integer >= GT_TEAM) { - PlayerStart* const spawnpoint = static_cast(ent); + PlayerStart *const spawnpoint = static_cast(ent); m_team_allies.m_spawnpoints.AddObject(spawnpoint); } } else if (!Q_stricmp(classname, "info_player_axis")) { if (g_gametype->integer >= GT_TEAM) { - PlayerStart* const spawnpoint = static_cast(ent); + PlayerStart *const spawnpoint = static_cast(ent); m_team_axis.m_spawnpoints.AddObject(spawnpoint); } } else if (!Q_stricmp(classname, "info_player_intermission")) { - PlayerStart* const spawnpoint = static_cast(ent); + PlayerStart *const spawnpoint = static_cast(ent); m_team_freeforall.m_spawnpoints.AddObject(spawnpoint); } } @@ -1100,10 +1103,10 @@ void DM_Manager::InitGame(void) m_bRoundBasedGame = false; } else { if (g_gametype->integer == GT_TOW || g_gametype->integer == GT_LIBERATION) { - m_bAllowRespawns = true; + m_bAllowRespawns = true; m_bRoundBasedGame = true; } else { - m_bAllowRespawns = false; + m_bAllowRespawns = false; m_bRoundBasedGame = true; } @@ -1213,7 +1216,9 @@ bool DM_Manager::CheckEndMatch() G_BeginIntermission2(); return true; } - } else if (timelimit->integer && level.inttime >= 60000 * timelimit->integer) { + } + + if (timelimit->integer && level.inttime >= timelimit->integer * 60000) { G_BeginIntermission2(); return true; } else { @@ -1237,7 +1242,7 @@ bool DM_Manager::CheckEndMatch() if (AllowRespawn() || (!m_team_axis.IsDead() && !m_team_allies.IsDead())) { int roundLimit = GetRoundLimit(); - if (roundLimit > 0 && level.time >= m_iDefaultRoundLimit * 60 + m_fRoundTime) { + if (roundLimit > 0 && level.time >= roundLimit * 60 + m_fRoundTime) { if (m_csTeamBombPlantSide != STRING_DRAW) { if (m_bIgnoringClockForBomb) { if (m_iNumBombsPlanted > 0) { @@ -1246,7 +1251,7 @@ bool DM_Manager::CheckEndMatch() m_bIgnoringClockForBomb = false; } else if (m_iNumBombsPlanted > 0) { - G_PrintToAllClients("A bomb is still set!"); + G_PrintToAllClients(va("%s\n", gi.LV_ConvertString("A Bomb is Still Set!"))); m_bIgnoringClockForBomb = true; return false; } @@ -1320,7 +1325,7 @@ bool DM_Manager::CheckEndMatch() return true; } else if (m_iNumBombsPlanted >= m_iNumTargetsToDestroy - m_iNumTargetsDestroyed) { if (!m_bIgnoringClockForBomb) { - G_PrintToAllClients("A bomb is still set!"); + G_PrintToAllClients(va("%s\n", gi.LV_ConvertString("A Bomb is Still Set!"))); m_bIgnoringClockForBomb = true; } } else { @@ -1404,26 +1409,26 @@ void DM_Manager::EventDoRoundTransition(Event *ev) } if (m_iTeamWin == TEAM_AXIS) { - G_CenterPrintToAllClients(va("\n\n\n%s\n", gi.LV_ConvertString("Axis win!\n"))); - G_PrintToAllClients(va("%s\n", gi.LV_ConvertString("Axis win!\n"))); + G_CenterPrintToAllClients(va("\n\n\n%s\n", gi.LV_ConvertString("Axis win!"))); + G_PrintToAllClients(va("%s\n", gi.LV_ConvertString("Axis win!"))); // Play the axis victory sound world->Sound("den_victory_v"); - Unregister(STRING_AXISWIN); + level.Unregister(STRING_AXISWIN); } else if (m_iTeamWin == TEAM_ALLIES) { - G_CenterPrintToAllClients(va("\n\n\n%s\n", gi.LV_ConvertString("Allies win!\n"))); - G_PrintToAllClients(va("%s\n", gi.LV_ConvertString("Allies win!\n"))); + G_CenterPrintToAllClients(va("\n\n\n%s\n", gi.LV_ConvertString("Allies win!"))); + G_PrintToAllClients(va("%s\n", gi.LV_ConvertString("Allies win!"))); // Play the allies victory sound world->Sound("dfr_victory_v"); - Unregister(STRING_ALLIESWIN); + level.Unregister(STRING_ALLIESWIN); } else { - G_CenterPrintToAllClients(va("\n\n\n%s\n", gi.LV_ConvertString("It's a draw!\n"))); - G_PrintToAllClients(va("%s\n", gi.LV_ConvertString("It's a draw!\n"))); + G_CenterPrintToAllClients(va("\n\n\n%s\n", gi.LV_ConvertString("It's a draw!"))); + G_PrintToAllClients(va("%s\n", gi.LV_ConvertString("It's a draw!"))); - Unregister(STRING_DRAW); + level.Unregister(STRING_DRAW); } G_DisplayScoresToAllClients(); @@ -1534,7 +1539,7 @@ void DM_Manager::StartRound(void) } m_fRoundEndTime = 0.0f; - m_bRoundActive = true; + m_bRoundActive = true; // respawn all players for (i = 0, ent = g_entities; i < game.maxclients; i++, ent++) { @@ -1620,7 +1625,8 @@ float DM_Manager::GetMatchStartTime(void) return m_fRoundTime; } - if (g_gametype->integer == GT_TEAM_ROUNDS || g_gametype->integer == GT_OBJECTIVE || g_gametype->integer == GT_LIBERATION) { + if (g_gametype->integer == GT_TEAM_ROUNDS || g_gametype->integer == GT_OBJECTIVE + || g_gametype->integer == GT_LIBERATION) { if (m_fRoundTime > 0 && (m_team_allies.IsEmpty() || m_team_allies.IsEmpty())) { m_fRoundTime = 0; return -1; @@ -1711,10 +1717,10 @@ void DM_Manager::SetBombsPlanted(int num) void DM_Manager::StopTeamRespawn(eController controller) { - if (controller == CONTROLLER_AXIS) { - m_bAllowAxisRespawn = false; - } else if (controller == CONTROLLER_ALLIES) { + if (controller == CONTROLLER_ALLIES) { m_bAllowAlliedRespawn = false; + } else if (controller == CONTROLLER_AXIS) { + m_bAllowAxisRespawn = false; } } @@ -1789,22 +1795,22 @@ void DM_Manager::InsertEntry(const char *entry) size_t len = strlen(entry); if (scoreLength + len < MAX_STRING_CHARS) { - strcpy(scoreString + scoreLength, entry); + Q_strncpyz(scoreString + scoreLength, entry, sizeof(scoreString) - scoreLength); scoreLength += len; scoreEntries++; } } -void DM_Manager::InsertEntryNoCount(const char* entry) +void DM_Manager::InsertEntryNoCount(const char *entry) { - size_t len = strlen(entry); + size_t len = strlen(entry); - if (scoreLength + len < MAX_STRING_CHARS) { - strcpy(scoreString + scoreLength, entry); + if (scoreLength + len < MAX_STRING_CHARS) { + Q_strncpyz(scoreString + scoreLength, entry, sizeof(scoreString) - scoreLength); - scoreLength += len; - } + scoreLength += len; + } } void DM_Manager::InsertEmpty(void) @@ -1837,7 +1843,7 @@ void DM_Manager::BuildTeamInfo_ver6(DM_Team *dmTeam) for (int i = iNumPlayers; i > 0; i--) { pTeamPlayer = dmTeam->m_players.ObjectAt(i); - if (pTeamPlayer->IsSubclassOfBot()) { + if (pTeamPlayer->edict->r.svFlags & SVF_BOT) { continue; } @@ -1864,7 +1870,7 @@ void DM_Manager::BuildTeamInfo_ver6(DM_Team *dmTeam) Com_sprintf(entry, sizeof(entry), "%i %i \"\" \"\" \"\" \"\" ", -1, dmTeam->m_teamnumber); } } else { - Com_sprintf(entry, sizeof(entry), "%i \"\" \"\" \"\" \"\" \"\" ", -1 - dmTeam->m_teamnumber); + Com_sprintf(entry, sizeof(entry), "%i \"\" \"\" \"\" \"\" ", -1 - dmTeam->m_teamnumber); } InsertEntry(entry); @@ -1882,7 +1888,7 @@ void DM_Manager::BuildTeamInfo_ver15(DM_Team *dmTeam) for (int i = iNumPlayers; i > 0; i--) { pTeamPlayer = dmTeam->m_players.ObjectAt(i); - if (pTeamPlayer->IsSubclassOfBot()) { + if (pTeamPlayer->edict->r.svFlags & SVF_BOT) { continue; } @@ -1894,11 +1900,11 @@ void DM_Manager::BuildTeamInfo_ver15(DM_Team *dmTeam) iPing /= iNumPlayers; } - if (g_gametype->integer >= GT_TEAM_ROUNDS) { - iKills = dmTeam->m_wins_in_a_row; - iDeaths = dmTeam->m_teamwins; + if (g_gametype->integer == GT_TEAM_ROUNDS || g_gametype->integer == GT_OBJECTIVE || g_gametype->integer == GT_TOW) { + iKills = dmTeam->m_teamwins; + iDeaths = dmTeam->m_wins_in_a_row; } else { - iKills = dmTeam->m_iKills; + iKills = dmTeam->m_teamwins; iDeaths = dmTeam->m_iDeaths; } @@ -1916,7 +1922,7 @@ void DM_Manager::BuildTeamInfo_ver15(DM_Team *dmTeam) iPing ); } else { - Com_sprintf(entry, sizeof(entry), "%i %i \"\" \"\" \"\" \"\" \"\" ", -1, dmTeam->m_teamnumber); + Com_sprintf(entry, sizeof(entry), "%i %i \"\" \"\" \"\" \"\" ", -1, dmTeam->m_teamnumber); } } else { Com_sprintf(entry, sizeof(entry), "%i \"\" \"\" \"\" \"\" ", -1 - dmTeam->m_teamnumber); @@ -1956,7 +1962,7 @@ void DM_Manager::BuildPlayerTeamInfo(DM_Team *dmTeam, int *iPlayerList, DM_Team pTeamPlayer->GetNumKills(), pTeamPlayer->GetNumDeaths(), G_TimeString(level.svsFloatTime - pTeamPlayer->edict->client->pers.enterTime), - pTeamPlayer->IsSubclassOfBot() ? "bot" : va("%d", pTeamPlayer->client->ps.ping) + (pTeamPlayer->edict->r.svFlags & SVF_BOT) ? "bot" : va("%d", pTeamPlayer->client->ps.ping) ); } else { Com_sprintf( @@ -1967,7 +1973,7 @@ void DM_Manager::BuildPlayerTeamInfo(DM_Team *dmTeam, int *iPlayerList, DM_Team pTeamPlayer->GetNumKills(), pTeamPlayer->GetNumDeaths(), G_TimeString(level.svsFloatTime - pTeamPlayer->edict->client->pers.enterTime), - pTeamPlayer->IsSubclassOfBot() ? "bot" : va("%d", pTeamPlayer->client->ps.ping) + (pTeamPlayer->edict->r.svFlags & SVF_BOT) ? "bot" : va("%d", pTeamPlayer->client->ps.ping) ); } @@ -1977,7 +1983,8 @@ void DM_Manager::BuildPlayerTeamInfo(DM_Team *dmTeam, int *iPlayerList, DM_Team bool DM_Manager::IsAlivePlayer(Player *player) const { - return !player->IsDead() && !player->IsSpectator() && !player->IsInJail() || player->GetDM_Team() == &m_team_spectator; + return !player->IsDead() && !player->IsSpectator() && !player->IsInJail() + || player->GetDM_Team() == &m_team_spectator; } CTeamSpawnClock::CTeamSpawnClock() diff --git a/code/fgame/dm_manager.h b/code/fgame/dm_manager.h index 55a72e28..087ea5b0 100644 --- a/code/fgame/dm_manager.h +++ b/code/fgame/dm_manager.h @@ -179,8 +179,8 @@ private: int m_iNumBombsPlanted; int m_iTotalMapTime; - bool m_bAllowAxisRespawn; bool m_bAllowAlliedRespawn; + bool m_bAllowAxisRespawn; bool m_bRoundActive; // scoreboard data diff --git a/code/fgame/doors.cpp b/code/fgame/doors.cpp index 86296580..fe95e0a5 100644 --- a/code/fgame/doors.cpp +++ b/code/fgame/doors.cpp @@ -177,9 +177,9 @@ Event EV_Door_OpenEnd "Called when the door finishes opening.", EV_NORMAL ); -Event EV_Door_IsOpen +Event EV_Door_IsOpen // Added in 2.30 ( - "isopen", + "isOpen", EV_DEFAULT, NULL, NULL, @@ -301,6 +301,7 @@ CLASS_DECLARATION(ScriptSlave, Door, "NormalDoor") { {&EV_Door_Open, &Door::Open }, {&EV_Door_CloseEnd, &Door::CloseEnd }, {&EV_Door_OpenEnd, &Door::OpenEnd }, + {&EV_Door_IsOpen, &Door::GetIsOpen }, // Added in 2.30 {&EV_Door_Fire, &Door::DoorFire }, {&EV_Door_Link, &Door::LinkDoors }, {&EV_Door_SetTime, &Door::SetTime }, @@ -343,9 +344,6 @@ Door::Door() SetDoorType("wood"); - traveltime = 1.0f; - speed = 1.0f / traveltime; - wait = (spawnflags & DOOR_TOGGLE) ? 0 : 3; dmg = 0; @@ -393,6 +391,14 @@ void Door::SetDoorType(str s) SetCloseEndSound("door_" + s + "_close_stop"); SetLockedSound("door_" + s + "_locked"); + + if (s == "wood") { + traveltime = 1.0; + } else if (s == "metal") { + traveltime = 1.5; + } + + speed = 1.0 / traveltime; } void Door::EventDoorType(Event *ev) @@ -563,7 +569,7 @@ qboolean Door::isCompletelyClosed(void) void Door::GetIsOpen(Event *ev) { - ev->AddInteger(isOpen()); + ev->AddInteger(!isCompletelyClosed()); } void Door::OpenEnd(Event *ev) @@ -578,6 +584,10 @@ void Door::OpenEnd(Event *ev) } else { StopSound(CHAN_VOICE); } + + // Added in 2.30 + // Notify scripts that the door has finished opening + Unregister(STRING_DONE); previous_state = state; SetState(STATE_OPEN); @@ -593,6 +603,12 @@ void Door::OpenEnd(Event *ev) void Door::CloseEnd(Event *ev) { + // Fixed in 2.0 + // Since this version, the area portal state is changed before sound + if (master == this) { + gi.AdjustAreaPortalState(this->edict, false); + } + if (sound_close_end.length() > 1) { BroadcastAIEvent(); Sound(sound_close_end, CHAN_VOICE); @@ -600,15 +616,15 @@ void Door::CloseEnd(Event *ev) StopSound(CHAN_VOICE); } - if (master == this) { - gi.AdjustAreaPortalState(this->edict, false); - } - setContents(CONTENTS_SOLID); setSolidType(SOLID_BSP); previous_state = state; SetState(STATE_CLOSED); + + // Added in 2.30 + // Notify scripts that the door has finished closing + Unregister(STRING_DONE); } void Door::Close(Event *ev) @@ -734,7 +750,7 @@ void Door::DoorUse(Event *ev) if (health || (spawnflags & (DOOR_AUTO_OPEN | DOOR_TARGETED)) || other->IsSubclassOfActor()) { if (other->IsSubclassOfSentient() && (state == STATE_CLOSED)) { if (health) { - gi.SendServerCommand(0, "print \"This door is jammed.\""); + gi.SendServerCommand(other->edict - g_entities, "print \"%s.\"", gi.LV_ConvertString("This door is jammed")); } else if (spawnflags & DOOR_TARGETED) { Sound("door_triggered", CHAN_VOICE); } @@ -831,7 +847,20 @@ void Door::DoorBlocked(Event *ev) if (state == STATE_OPENING || state == STATE_OPEN) { spawnflags &= ~DOOR_START_OPEN; + + const bool bIsMoving = EventPending(EV_MoveDone); ProcessEvent(EV_Door_Close); + + if (bIsMoving) { + // Added in OPM + // Reopen to the other side so sentients can still pass. + // This avoid entities like players trying to prevent the door + // from opening in multiplayer + diropened = -diropened; + e = new Event(EV_Door_Open); + e->AddEntity(other); + ProcessEvent(e); + } } else { e = new Event(EV_Door_Open); e->AddEntity(other); @@ -843,6 +872,8 @@ void Door::DoorBlocked(Event *ev) void Door::FieldTouched(Event *ev) { Entity *other; + Actor* otherActor; + float dist; other = ev->GetEntity(1); @@ -850,41 +881,45 @@ void Door::FieldTouched(Event *ev) return; } - if (other->IsSubclassOfActor()) { - Actor* otherActor = static_cast(other); - float dist; - - otherActor->m_Path.ForceShortLookahead(); - - if (state == STATE_OPENING) { - otherActor->m_maxspeed = speed * 64; - } - - if ((state != STATE_OPEN) && !(spawnflags & DOOR_AUTO_OPEN) && !other->isSubclassOf(Actor)) { + if (!other->IsSubclassOfActor()) { + if ((spawnflags & DOOR_TOGGLE) || (state != STATE_OPEN && !(spawnflags & DOOR_AUTO_OPEN))) { return; } - dist = VectorLength2D(other->velocity) * 0.25f; - if (other->absmin[0] > absmax[0] + dist) { - return; - } - if (other->absmin[1] > absmax[1] + dist) { - return; - } - if (other->absmin[2] > absmax[2]) { - return; - } + TryOpen(ev); + return; + } - if (other->absmax[0] < absmin[0] - dist) { - return; - } - if (other->absmax[1] < absmin[1] - dist) { - return; - } - if (other->absmax[2] < absmin[2]) { - return; - } - } else if ((state != STATE_OPEN) && !(spawnflags & DOOR_AUTO_OPEN) && !other->isSubclassOf(Actor)) { + otherActor = static_cast(other); + + otherActor->m_Path.ForceShortLookahead(); + + if (state == STATE_OPENING) { + otherActor->m_maxspeed = speed * 64; + } + + if (((spawnflags & DOOR_TOGGLE) || (state != STATE_OPEN && !(spawnflags & DOOR_AUTO_OPEN))) && (state == STATE_OPEN || state == STATE_OPENING)) { + return; + } + + dist = VectorLength2D(other->velocity) * 0.25f; + if (other->absmin[0] > absmax[0] + dist) { + return; + } + if (other->absmin[1] > absmax[1] + dist) { + return; + } + if (other->absmin[2] > absmax[2]) { + return; + } + + if (other->absmax[0] < absmin[0] - dist) { + return; + } + if (other->absmax[1] < absmin[1] - dist) { + return; + } + if (other->absmax[2] < absmin[2]) { return; } @@ -1095,10 +1130,7 @@ void Door::LinkDoors(Event *ev) return; } - // Don't spawn trigger field when set to toggle - if (!(spawnflags & DOOR_TOGGLE)) { - SpawnTriggerField(cmins, cmaxs); - } + SpawnTriggerField(cmins, cmaxs); } void Door::SetTime(Event *ev) @@ -1207,13 +1239,13 @@ void Door::ShowInfo(float fDot, float fDist) return; } - i = sprintf(szText, "%i:%i", entnum, radnum); + i = Com_sprintf(szText, sizeof(szText), "%i:%i", entnum, radnum); if (TargetName().c_str() && TargetName()[0]) { - i = sprintf(szText + i, ":%s", TargetName().c_str()); + i = Com_sprintf(szText + i, sizeof(szText) - i, ":%s", TargetName().c_str()); } if (health != 0) { - i = sprintf(szText + i, ":%.1f", health); + i = Com_sprintf(szText + i, sizeof(szText) - i, ":%.1f", health); } G_DebugString(origin + Vector(0, 0, (mins.z + maxs.z) * 0.5f), 1, 1, 1, 1, szText); @@ -1311,8 +1343,6 @@ void RotatingDoor::DoOpen(Event *ev) } else { diropened = 0 - init_door_direction; } - } else { - diropened = -init_door_direction; } if (diropened < 0.0f) { @@ -1321,7 +1351,16 @@ void RotatingDoor::DoOpen(Event *ev) ang = startangle - Vector(0.0f, angle, 0.0f); } + if (localangles.yaw() + 360 <= ang.yaw()) { + localangles.setYaw(localangles.yaw() + 360); + } else if (localangles.yaw() - 360 >= ang.yaw()) { + localangles.setYaw(localangles.yaw() - 360); + } + MoveTo(origin, ang, fabs(speed * angle), EV_Door_OpenEnd); + + setContents(CONTENTS_SOLID); + setSolidType(SOLID_BSP); } void RotatingDoor::DoClose(Event *ev) diff --git a/code/fgame/doors.h b/code/fgame/doors.h index 6203e4ce..588028d5 100644 --- a/code/fgame/doors.h +++ b/code/fgame/doors.h @@ -118,7 +118,7 @@ public: Door(); qboolean isOpen(void); qboolean isCompletelyClosed(void); - void GetIsOpen(Event *ev); + void GetIsOpen(Event *ev); // Added in 2.30 qboolean CanBeOpenedBy(Entity *ent); void Archive(Archiver &arc) override; }; @@ -150,8 +150,9 @@ inline void Door::Archive(Archiver& arc) arc.ArchiveInteger(&trigger); arc.ArchiveInteger(&nextdoor); arc.ArchiveSafePointer(&master); - arc.ArchiveBoolean(&locked); arc.ArchiveFloat(&next_locked_time); + arc.ArchiveBoolean(&locked); + arc.ArchiveBool(&m_bAlwaysAway); } class RotatingDoor : public Door diff --git a/code/fgame/earthquake.cpp b/code/fgame/earthquake.cpp index 4d008b6a..835e5603 100644 --- a/code/fgame/earthquake.cpp +++ b/code/fgame/earthquake.cpp @@ -133,7 +133,7 @@ ViewJitter::ViewJitter() m_fDuration = 0; - m_bDoneDeath = qfalse; + m_bDoneDeath = false; } ViewJitter::ViewJitter( Vector vOrigin, float fRadius, float fEdgeEffect, Vector vStrength, float fDuration, Vector vTimeDecay, float fStartDecay ) @@ -154,7 +154,7 @@ ViewJitter::ViewJitter( Vector vOrigin, float fRadius, float fEdgeEffect, Vector m_fDuration = fDuration; - m_bDoneDeath = false; + m_bDoneDeath = true; m_fTimeRunning = 0; PostEvent( EV_ViewJitter_Think, fStartDecay ); diff --git a/code/fgame/earthquake.h b/code/fgame/earthquake.h index 98157027..0a6b1721 100644 --- a/code/fgame/earthquake.h +++ b/code/fgame/earthquake.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -24,8 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // The earthquake effect is visible to the user as the shaking of his screen. // -#ifndef __EARTHQUAKE_H__ -#define __EARTHQUAKE_H__ +#pragma once #include "g_local.h" #include "trigger.h" @@ -75,5 +74,3 @@ inline void ViewJitter::Archive arc.ArchiveBoolean( &m_bDoneDeath ); arc.ArchiveFloat( &m_fTimeRunning ); } - -#endif diff --git a/code/fgame/effectentity.h b/code/fgame/effectentity.h index 63c0c984..2379abee 100644 --- a/code/fgame/effectentity.h +++ b/code/fgame/effectentity.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -22,8 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // actor.cpp: Base class for character AI. -#ifndef __EFFECTENTITY_H__ -#define __EFFECTENTITY_H__ +#pragma once #include "animate.h" @@ -34,5 +33,3 @@ public: EffectEntity(); }; - -#endif // __EFFECTENTITY_H__ diff --git a/code/fgame/entity.cpp b/code/fgame/entity.cpp index fe8f1d47..6dfecf6b 100644 --- a/code/fgame/entity.cpp +++ b/code/fgame/entity.cpp @@ -677,7 +677,7 @@ Event EV_GetMins NULL, NULL, "Get the mins of the bounding box of the entity to mins.", - EV_RETURN + EV_GETTER ); Event EV_GetMaxs ( @@ -686,7 +686,7 @@ Event EV_GetMaxs NULL, NULL, "Get the maxs of the bounding box of the entity to maxs.", - EV_RETURN + EV_GETTER ); Event EV_SetAlpha ( @@ -768,7 +768,7 @@ Event EV_SetLight EV_DEFAULT, "ffff", "red green blue radius", - "Create a dynmaic light on this entity.", + "Create a dynamic light on this entity.", EV_NORMAL ); @@ -778,7 +778,7 @@ Event EV_LightOn EV_DEFAULT, NULL, NULL, - "Turn the configured dynmaic light on this entity on.", + "Turn the configured dynamic light on this entity on.", EV_NORMAL ); Event EV_LightOff @@ -805,7 +805,7 @@ Event EV_LightRed EV_DEFAULT, "f", "red", - "Set the red component of the dynmaic light on this entity.", + "Set the red component of the dynamic light on this entity.", EV_NORMAL ); Event EV_LightGreen @@ -814,7 +814,7 @@ Event EV_LightGreen EV_DEFAULT, "f", "red", - "Set the red component of the dynmaic light on this entity.", + "Set the red component of the dynamic light on this entity.", EV_NORMAL ); Event EV_LightBlue @@ -823,7 +823,7 @@ Event EV_LightBlue EV_DEFAULT, "f", "red", - "Set the red component of the dynmaic light on this entity.", + "Set the red component of the dynamic light on this entity.", EV_NORMAL ); Event EV_LightRadius @@ -832,7 +832,7 @@ Event EV_LightRadius EV_DEFAULT, "f", "red", - "Set the red component of the dynmaic light on this entity.", + "Set the red component of the dynamic light on this entity.", EV_NORMAL ); @@ -1217,6 +1217,8 @@ Event EV_CanSee "returns 1 if the entities can see eachother, 0 if not", EV_RETURN ); + +// Added in 2.0 Event EV_CanSeeNoEnts ( "canseenoents", @@ -1226,6 +1228,7 @@ Event EV_CanSeeNoEnts "returns 1 if the entities can see eachother, 0 if not; ignores any entities between them", EV_RETURN ); + Event EV_Entity_InPVS ( "inpvs", @@ -1471,6 +1474,7 @@ Event EV_Entity_SetDHack "Enable or disable depth hack.", EV_NORMAL ); +/* Event EV_Entity_GetZone ( "getzone", @@ -1498,6 +1502,8 @@ Event EV_Entity_IsInZone "Returns 1 if the entity is in the specified zone. 0 otherwise", EV_RETURN ); +*/ +#ifdef OPM_FEATURES Event EV_Entity_SetHintRequireLookAt ( "setuselookat", @@ -1526,6 +1532,7 @@ Event EV_Entity_SetShader "Sets a shader for the entity. An empty string will revert to the normal entity shader.", EV_NORMAL ); +#endif CLASS_DECLARATION(SimpleEntity, Entity, NULL) { {&EV_Damage, &Entity::DamageEvent }, @@ -1624,6 +1631,7 @@ CLASS_DECLARATION(SimpleEntity, Entity, NULL) { {&EV_IsTouching, &Entity::IsTouching }, {&EV_IsInside, &Entity::IsInside }, {&EV_CanSee, &Entity::CanSee }, + {&EV_CanSeeNoEnts, &Entity::CanSeeNoEnts }, // Added in 2.0 {&EV_Entity_InPVS, &Entity::EventInPVS }, {&EV_SetShaderData, &Entity::SetShaderData }, {&EV_GetVelocity, &Entity::GetVelocity }, @@ -1645,8 +1653,8 @@ CLASS_DECLARATION(SimpleEntity, Entity, NULL) { {&EV_ConnectPaths, &Entity::EventConnectPaths }, {&EV_DisconnectPaths, &Entity::EventDisconnectPaths }, {&EV_Remove, &Entity::Remove }, - {&EV_Delete, &Entity::Remove }, - {&EV_ScriptRemove, &Entity::Remove }, + {&EV_Delete, &Listener::ScriptRemove }, + {&EV_ScriptRemove, &Listener::ScriptRemove }, {&EV_VolumeDamage, &Entity::EventVolumeDamage }, {&EV_GetNormalHealth, &Entity::EventGetNormalHealth }, {&EV_NormalDamage, &Entity::EventNormalDamage }, @@ -1667,13 +1675,17 @@ CLASS_DECLARATION(SimpleEntity, Entity, NULL) { {&EV_ShootableOnly, &Entity::EventShootableOnly }, {&EV_SetShaderTime, &Entity::SetShaderTime }, {&EV_NoTarget, &Entity::NoTarget }, + /* {&EV_Entity_GetZone, &Entity::GetZone }, {&EV_Entity_Zone, &Entity::GetZone }, {&EV_Entity_IsInZone, &Entity::IsInZone }, + */ {&EV_Entity_SetDHack, &Entity::SetDepthHack }, +#ifdef OPM_FEATURES {&EV_Entity_SetHintRequireLookAt, &Entity::SetHintRequireLookAt }, {&EV_Entity_SetHintString, &Entity::SetHintString }, {&EV_Entity_SetShader, &Entity::SetShader }, +#endif {NULL, NULL } }; @@ -1779,7 +1791,9 @@ Entity::Entity() m_iNumBlockedPaths = 0; m_BlockedPaths = NULL; +#ifdef OPM_FEATURES m_bHintRequiresLookAt = true; +#endif } Entity::~Entity() @@ -1843,8 +1857,8 @@ Entity::~Entity() } if (m_BlockedPaths) { - delete m_BlockedPaths; - m_BlockedPaths = 0; + delete[] m_BlockedPaths; + m_BlockedPaths = NULL; } level.FreeEdict(edict); @@ -1853,13 +1867,11 @@ Entity::~Entity() } void Entity::ClassnameEvent(Event *ev) - { strncpy(edict->entname, ev->GetString(1), sizeof(edict->entname) - 1); } void Entity::SpawnFlagsEvent(Event *ev) - { // spawning variables spawnflags = ev->GetInteger(1); @@ -2123,49 +2135,21 @@ void Entity::SetTeamEvent(Event *ev) void Entity::TriggerEvent(Event *ev) { - const char *name; - Event *event; - Entity *ent; - ConSimple *tlist; - int i; - int num; + SimpleEntity *ent; + ScriptVariable arrayVar; + int i; - name = ev->GetString(1); - - // Check for object commands - if (name && name[0] == '$') { - str sName = str(name + 1); - - tlist = world->GetTargetList(sName); - num = tlist->NumObjects(); - for (i = 1; i <= num; i++) { - ent = (Entity *)tlist->ObjectAt(i).Pointer(); - - assert(ent); - - event = new Event(EV_Activate); + arrayVar = ev->GetValue(1); + arrayVar.CastConstArrayValue(); + for (i = arrayVar.arraysize(); i > 0; i--) { + const ScriptVariable *variable = arrayVar[i]; + ent = variable->simpleEntityValue(); + if (ent) { + Event* event = new Event(EV_Activate); event->AddEntity(this); ent->ProcessEvent(event); } - } else if (name[0] == '*') // Check for entnum commands - { - if (!IsNumeric(&name[1])) { - gi.Printf("Expecting numeric value for * command, but found '%s'\n", &name[1]); - } else { - ent = G_GetEntity(atoi(&name[1])); - if (ent) { - event = new Event(EV_Activate); - - event->AddEntity(this); - ent->ProcessEvent(event); - } else { - gi.Printf("Entity not found for * command\n"); - } - } - return; - } else { - gi.Printf("Invalid entity reference '%s'.\n", name); } } @@ -2689,7 +2673,7 @@ void Entity::DamageEvent(Event *ev) Vector momentum; Vector position, direction, normal; int knockback, damageflags, meansofdeath, location; - Event *event; + Event event; float m; EntityPtr This; @@ -2775,67 +2759,79 @@ void Entity::DamageEvent(Event *ev) if (health <= 0) { if (attacker) { - event = new Event(EV_GotKill); - event->AddEntity(this); - event->AddInteger(damage); - event->AddEntity(inflictor); - event->AddInteger(meansofdeath); - event->AddInteger(0); + const EntityPtr attackerPtr = attacker; - attacker->ProcessEvent(event); + event = Event(EV_GotKill, 5); + event.AddEntity(this); + event.AddInteger(damage); + event.AddEntity(inflictor); + event.AddInteger(meansofdeath); + event.AddInteger(0); + + attackerPtr->ProcessEvent(event); + if (attackerPtr) { + attackerPtr->delegate_gotKill.Execute(event); + } } if (!This) { return; } - event = new Event(EV_Killed); - event->AddEntity(attacker); - event->AddFloat(damage); - event->AddEntity(inflictor); - event->AddVector(position); - event->AddVector(direction); - event->AddVector(normal); - event->AddInteger(knockback); - event->AddInteger(damageflags); - event->AddInteger(meansofdeath); - event->AddInteger(location); + event = Event(EV_Killed, 10); + event.AddEntity(attacker); + event.AddFloat(damage); + event.AddEntity(inflictor); + event.AddVector(position); + event.AddVector(direction); + event.AddVector(normal); + event.AddInteger(knockback); + event.AddInteger(damageflags); + event.AddInteger(meansofdeath); + event.AddInteger(location); ProcessEvent(event); - if (!This) { return; } // Notify scripts Unregister(STRING_DAMAGE); + if (!This) { + return; + } + + delegate_killed.Execute(event); return; } - event = new Event(EV_Pain); - event->AddEntity(attacker); - event->AddFloat(damage); - event->AddEntity(inflictor); - event->AddVector(position); - event->AddVector(direction); - event->AddVector(normal); - event->AddInteger(knockback); - event->AddInteger(damageflags); - event->AddInteger(meansofdeath); - event->AddInteger(location); + event = Event(EV_Pain, 10); + event.AddEntity(attacker); + event.AddFloat(damage); + event.AddEntity(inflictor); + event.AddVector(position); + event.AddVector(direction); + event.AddVector(normal); + event.AddInteger(knockback); + event.AddInteger(damageflags); + event.AddInteger(meansofdeath); + event.AddInteger(location); ProcessEvent(event); - if (!This) { return; } // Notify scripts Unregister(STRING_DAMAGE); + if (!This) { + return; + } + + delegate_damage.Execute(event); } qboolean Entity::IsTouching(Entity *e1) - { if (e1->absmin.x > absmax.x) { return false; @@ -2866,20 +2862,20 @@ qboolean Entity::IsInside(Entity *e1) qboolean Entity::FovCheck(float *delta, float fovdot) { - float deltadot = delta[0] * orientation[0][0] + delta[1] * orientation[0][1]; + float deltadot = DotProduct2D(delta, orientation[0]); if (fovdot < 0.0f) { if (deltadot >= 0.0f) { return true; } - return (delta[0] * delta[0] + delta[1] * delta[1]) * fovdot * fovdot > (deltadot * deltadot); + return VectorLength2DSquared(delta) * Square(fovdot) > Square(deltadot); } else { if (deltadot < 0.0f) { return false; } - return (deltadot * deltadot) > (delta[0] * delta[0] + delta[1] * delta[1]) * fovdot * fovdot; + return VectorLength2DSquared(delta) * Square(fovdot) < Square(deltadot); } } @@ -3016,7 +3012,6 @@ void Entity::FadeIn(Event *ev) if (ev->NumArgs() > 0) { rate = ev->GetFloat(1); - assert(rate); if (rate > 0) { rate = FRAMETIME / rate; } @@ -3052,7 +3047,6 @@ void Entity::Fade(Event *ev) if (ev->NumArgs() > 0) { rate = ev->GetFloat(1); - assert(rate); if (rate > 0) { rate = FRAMETIME / rate; } @@ -3217,6 +3211,15 @@ void Entity::LoopSound(Event *ev) return; } + if (level.spawning) { + // If the server is currently spawning + // repost the event as loopsound wouldn't work properly + // on the client + Event* newev = new Event(*ev); + PostEvent(newev, level.frametime); + return; + } + // Get parameters sound_name = ev->GetString(1); @@ -3267,10 +3270,10 @@ void Entity::LoopSound(str sound_name, float volume, float min_dist, float max_d // Add the looping sound to the entity edict->s.loopSound = gi.soundindex(name, aliasstreamed); - edict->s.loopSoundVolume = aliasvolume; - edict->s.loopSoundMinDist = aliasmin_dist; - edict->s.loopSoundMaxDist = aliasmax_dist; - edict->s.loopSoundPitch = aliaspitch; + edict->s.loopSoundVolume = volume < 0 ? (aliasvolume) : (aliasvolume * volume); + edict->s.loopSoundMinDist = min_dist < 0 ? (aliasmin_dist) : (min_dist); + edict->s.loopSoundMaxDist = max_dist < 0 ? (aliasmax_dist) : (max_dist); + edict->s.loopSoundPitch = pitch < 0 ? (aliaspitch) : (aliaspitch * pitch); // Local sound will always be heard edict->s.loopSoundFlags = aliaschannel == CHAN_LOCAL; @@ -3297,7 +3300,7 @@ void Entity::ProcessSoundEvent(Event *ev, qboolean checkSubtitle) { str sound_name; str wait; - int waitTillDone = 0; + bool waitTillDone = false; float volume; int channel = 0; @@ -3317,30 +3320,24 @@ void Entity::ProcessSoundEvent(Event *ev, qboolean checkSubtitle) wait = ev->GetString(2); } - if (Q_stricmp(wait.c_str(), "wait")) { - if (!Q_stricmp(wait.c_str(), "volume")) { - if (ev->NumArgs() != 3) { - ScriptError("Entity::Sound: volume not followed by a float"); - } - - volume = ev->GetFloat(3); - } - } else { - waitTillDone = 1; + if (!Q_stricmp(wait.c_str(), "wait")) { + waitTillDone = true; if (ev->NumArgs() == 3) { volume = ev->GetFloat(3); } + } else if (!Q_stricmp(wait.c_str(), "volume")) { + if (ev->NumArgs() != 3) { + ScriptError("Entity::Sound: volume not followed by a float"); + } + + volume = ev->GetFloat(3); } if (volume == DEFAULT_VOL) { - if (wait.length()) { - channel = atoi(wait.c_str()); - } - - Sound(sound_name, channel, volume, 0, NULL, 0, 0, waitTillDone, checkSubtitle, -1.0f); + Sound(sound_name, CHAN_AUTO, volume, 0, NULL, 0, 0, waitTillDone, checkSubtitle, -1.0f); } else { - Sound(sound_name, -1.0f, volume, -1.0f, NULL, -1.0f, 1, waitTillDone, checkSubtitle, -1.0f); + Sound(sound_name, -1, volume, -1.0f, NULL, -1.0f, 1, waitTillDone, checkSubtitle, -1.0f); } } @@ -3350,7 +3347,7 @@ void Entity::Sound(Event *ev) Event *event = new Event(EV_Sound); for (int i = 1; i <= ev->NumArgs(); i++) { - event->AddValue(ev->GetValue(1)); + event->AddValue(ev->GetValue(i)); } PostEvent(event, level.frametime); @@ -3602,13 +3599,18 @@ void Entity::Sound( static cvar_t *g_subtitle = NULL; static bool _tmp = false; int num; + int aliaschannel; + float aliasvolume; + float aliasmin_dist; + float aliasmax_dist; + float aliaspitch; if (!_tmp) { g_subtitle = gi.Cvar_Get("g_subtitle", "0", CVAR_ARCHIVE); _tmp = true; } - if (doCallback && g_gametype->integer) { + if (doCallback && g_gametype->integer != GT_SINGLE_PLAYER) { Com_Printf("^~^~^ Callback of sound '%s' ignored.\n", sound_name.c_str()); doCallback = 0; } @@ -3623,79 +3625,104 @@ void Entity::Sound( } if (!name) { - name = sound_name.c_str(); + name = gi.GlobalAlias_FindRandom(sound_name.c_str(), &ret); } // Play the sound - if (name != NULL) { - if (ret) { - if (channel < 0) { - channel = ret->channel; - } + if (name && ret) { + aliaschannel = ret->channel; + aliasvolume = G_Random() * ret->volumeMod + ret->volume; + aliaspitch = G_Random() * ret->pitchMod + ret->pitch; + aliasmin_dist = ret->dist; + aliasmax_dist = ret->maxDist; - num = entnum; - if (sound_origin) { - VectorCopy(*sound_origin, org); - num = ENTITYNUM_NONE; - } else { - VectorCopy(edict->s.origin, org); - - if (doCallback) { - num |= S_FLAG_DO_CALLBACK; - } - } - - if (argstype == 0) { - volume = G_Random() * ret->volumeMod + ret->volume; - pitch = G_Random() * ret->pitchMod + ret->pitch; - min_dist = ret->dist; - max_dist = ret->maxDist; - } else if (argstype == 1) { - if (volume >= 0.0f) { - volume = G_Random() * ret->volumeMod + volume; - } else { - volume = G_Random() * ret->volumeMod + volume; - } - - if (pitch >= 0.0f) { - pitch = G_Random() * ret->pitchMod + pitch; - } else { - pitch = G_Random() * ret->pitchMod + ret->pitch; - } - } else { - if (volume <= 0.0f) { - volume = G_Random() * ret->volumeMod + ret->volume; - } - - if (pitch >= 0.0f) { - pitch = G_Random() * ret->pitchMod + pitch; - } else { - pitch = G_Random() * ret->pitchMod + ret->pitch; - } - - if (min_dist < 0.0f) { - min_dist = ret->dist; - } - - if (max_dist < 0.0f) { - max_dist = ret->maxDist; - } - } - - if (g_gametype->integer == GT_SINGLE_PLAYER && (!checkSubtitle || g_subtitle->integer) && ret->subtitle) { - Entity *p = G_GetEntity(0); - - if (g_subtitle->integer == 2 || max_dist * max_dist > DistanceSquared(org, p->edict->s.origin)) { - cvar_t *curSubtitle = gi.Cvar_Get("curSubtitle", "0", 0); - - gi.cvar_set(va("subtitle%d", curSubtitle->integer), va("%s", ret->subtitle)); - gi.cvar_set("curSubtitle", va("%d", curSubtitle->integer + 1)); - } - } - - gi.Sound(&org, num, channel, name, volume, min_dist, pitch, max_dist, ret->streamed); + if (channel < 0) { + channel = ret->channel; } + + num = entnum; + if (sound_origin) { + VectorCopy(*sound_origin, org); + num = ENTITYNUM_NONE; + } else { + VectorCopy(edict->s.origin, org); + + if (doCallback) { + num |= S_FLAG_DO_CALLBACK; + } + } + + switch (argstype) { + case 0: + volume = aliasvolume; + pitch = aliaspitch; + min_dist = aliasmin_dist; + max_dist = aliasmax_dist; + channel = aliaschannel; + break; + case 1: + if (volume >= 0.0f) { + volume = volume * aliasvolume; + } else { + volume = aliasvolume; + } + + if (pitch >= 0.0f) { + pitch = pitch * aliaspitch; + } else { + pitch = aliaspitch; + } + + if (min_dist < 0.0f) { + min_dist = aliasmin_dist; + } + + if (max_dist < 0.0f) { + max_dist = aliasmax_dist; + } + + if (channel < 0) { + channel = aliaschannel; + } + break; + default: + if (volume < 0.0) { + volume = aliasvolume; + } + if (pitch < 0.0) { + pitch = aliaspitch; + } + if (min_dist < 0.0) { + min_dist = aliasmin_dist; + } + if (max_dist < 0.0) { + max_dist = aliasmax_dist; + } + if (channel < 0) { + channel = aliaschannel; + } + break; + } + + if (g_gametype->integer == GT_SINGLE_PLAYER && (ret->forcesubtitle || !checkSubtitle || g_subtitle->integer) && ret->subtitle) { + Entity *p = G_GetEntity(0); + + if (p && (g_subtitle->integer == 2 || Square(max_dist) > DistanceSquared(org, p->edict->s.origin))) { + cvar_t *curSubtitle = gi.Cvar_Get("curSubtitle", "0", 0); + int curSub; + + gi.cvar_set(va("subtitle%d", curSubtitle->integer), va("%s", ret->subtitle)); + curSub = curSubtitle->integer + 1; + if (curSubtitle->integer + 1 < 0) { + curSub = curSubtitle->integer + MAX_SUBTITLES; + } + + gi.cvar_set("curSubtitle", va("%d", (curSubtitle->integer + 1) - MAX_SUBTITLES * (curSub >> 2))); + } + } + + gi.Sound(&org, num, channel, name, volume, min_dist, pitch, max_dist, ret->streamed); } else { gi.DPrintf( "ERROR: Entity::Sound: %s needs an alias in ubersound.scr or uberdialog.scr - Please fix.\n", @@ -4096,7 +4123,7 @@ void Entity::BroadcastAIEvent(int iType, float rad) return; } - G_BroadcastAIEvent(this, origin, iType, rad); + G_BroadcastAIEvent(this, centroid, iType, rad); } void Entity::BroadcastAIEvent(Event *ev) @@ -4380,11 +4407,17 @@ void Entity::AttachModelEvent(Event *ev) if (obj->attach(this->entnum, tagnum, true, offset)) { obj->NewAnim("idle"); } else { - delete obj; + warning("AttachModelEvent", "Could not attach model %s to tag \"%s\" on entnum #%d (targetname = %s)", modelname.c_str(), bone.c_str(), entnum, targetname.c_str()); + if (g_iInThinks) { + PostEvent(EV_Remove, 0); + } else { + delete obj; + } return; } } else { warning("AttachModelEvent", "Tag %s not found", bone.c_str()); + obj->NewAnim("idle"); } } @@ -5057,7 +5090,7 @@ void Entity::TouchTriggersEvent(Event *ev) void Entity::DeathSinkStart(Event *ev) { - if (g_gametype->integer) { + if (g_gametype->integer != GT_SINGLE_PLAYER) { PostEvent(EV_Remove, 5.0f); } else { // Start the sinking @@ -5069,7 +5102,7 @@ void Entity::DeathSink(Event *ev) { // Sink just a little - if (g_gametype->integer) { + if (g_gametype->integer != GT_SINGLE_PLAYER) { origin[2] -= 0.2f; setOrigin(origin); @@ -5268,9 +5301,6 @@ void Entity::glue(Entity *master, qboolean use_my_angles, qboolean can_duck) m_pGlueMaster = master; m_bGlueDuckable = can_duck == qtrue; master->m_iNumGlues++; - - setAngles(master->angles); - setOrigin(master->origin); } void Entity::unglue(void) @@ -5317,7 +5347,7 @@ void Entity::GetTagPositionAndOrientation(int tagnum, orientation_t *new_or) VectorCopy(origin, new_or->origin); for (i = 0; i < 3; i++) { - VectorMA(new_or->origin, tag_or.origin[i], tag_or.axis[i], new_or->origin); + VectorMA(new_or->origin, tag_or.origin[i], axis[i], new_or->origin); } MatrixMultiply(tag_or.axis, axis, new_or->axis); @@ -5461,7 +5491,7 @@ void Entity::MPrintf(const char *fmt, ...) va_list argptr; char msg[MAXPRINTMSG]; - if (g_monitorNum->integer == entnum && g_monitor->string == targetname) { + if (g_monitorNum->integer == entnum || g_monitor->string[0] && g_monitor->string == targetname) { va_start(argptr, fmt); Q_vsnprintf(msg, sizeof(msg), fmt, argptr); va_end(argptr); @@ -5579,13 +5609,13 @@ void Entity::ShowInfo(float fDot, float fDist) int i; char szText[512]; if (fDot > 0.94999999 && fDist < 1024.0 && fDist > 64.0) { - i = sprintf(szText, "%i:%i", entnum, radnum); + i = Com_sprintf(szText, sizeof(szText), "%i:%i", entnum, radnum); if (targetname.length()) { - i = sprintf(&szText[i], ":%s", targetname.c_str()); + i = Com_sprintf(szText + i, sizeof(szText) - i, ":%s", targetname.c_str()); } if (health != 0) { - sprintf(&szText[i], ":%.1f", health); + Com_sprintf(szText + i, sizeof(szText) - i, ":%.1f", health); } G_DebugString(Vector(origin.x + 0, origin.y + 0, origin.z + maxs.z + 65), 1.0, 1.0, 1.0, 1.0, szText); @@ -5624,7 +5654,7 @@ void Entity::ConnectPaths(void) m_iNumBlockedPaths = 0; if (m_BlockedPaths) { - delete m_BlockedPaths; + delete[] m_BlockedPaths; m_BlockedPaths = NULL; } } @@ -5703,6 +5733,14 @@ void Entity::Delete(void) // Delete the entity the next frame if (g_iInThinks) { + if (ProcessingEvents) { + // Fixed in OPM + // Add a slight delay because otherwise this would cause an infinite loop + // when processing pending events + PostEvent(EV_Remove, 0.001); + return; + } + PostEvent(EV_Remove, 0); } else { delete this; @@ -5773,7 +5811,7 @@ void Entity::Archive(Archiver& arc) // set the brush model edict->s.modelindex = atoi(model.c_str() + 1); } else { - setModel(model); + setModel(); } } @@ -5927,7 +5965,7 @@ void Entity::DrawBoundingBox(int showbboxes) switch (showbboxes) { case 1: if (edict->s.solid) { - G_DebugBBox(origin, mins, maxs, 1, 1, 0, 1); + G_DebugRotatedBBox(origin, angles, mins, maxs, 1, 1, 0, 1); } break; case 2: @@ -5937,25 +5975,161 @@ void Entity::DrawBoundingBox(int showbboxes) break; case 3: if (edict->tiki && !(edict->s.renderfx & RF_DONTDRAW)) { - G_DebugBBox(origin, mins, maxs, 1, 1, 0, 1); + G_DebugRotatedBBox(origin, angles, mins, maxs, 1, 1, 0, 1); } break; case 4: - G_DebugBBox(origin, mins, maxs, 1, 1, 0, 1); + G_DebugRotatedBBox(origin, angles, mins, maxs, 1, 1, 0, 1); break; - case 5: - default: - if (IsSubclassOfAnimate() && edict->tiki) { - Animate *anim; - vec3_t mins, maxs; + case 7: + if (edict->tiki && !(edict->s.renderfx & RF_DONTDRAW)) { + Vector vMins, vMaxs; - anim = (Animate *)this; - // FIXME - G_DebugBBox(origin, mins, maxs, 0, 1, 0, 1); - } else { - G_DebugBBox(origin, mins, maxs, 1, 1, 0, 1); + gi.TIKI_CalculateBounds(edict->tiki, edict->s.scale, vMins, vMaxs); + if (!VectorCompare(vMins, vec_zero) || !VectorCompare(vMaxs, vec_zero)) { + if (edict->s.parent != ENTITYNUM_NONE && edict->s.tag_num >= 0) { + int i; + Vector vAng; + orientation_t oTag, oBox; + Entity* pParent; + + pParent = G_GetEntity(edict->s.parent); + AnglesToAxis(pParent->angles, pParent->orientation); + oTag = G_TIKI_Orientation(pParent->edict, edict->s.tag_num & TAG_MASK); + + VectorCopy(pParent->origin, oBox.origin); + for (i = 0; i < 3; i++) { + VectorMA(oBox.origin, oTag.origin[i], pParent->orientation[i], oBox.origin); + } + + MatrixMultiply(oTag.axis, pParent->orientation, oBox.axis); + MatrixToEulerAngles(oBox.axis, vAng); + G_DebugRotatedBBox(oBox.origin, vAng, vMins, vMaxs, 0, 1, 1, 1); + } else { + G_DebugRotatedBBox(origin, angles, vMins, vMaxs, 0, 1, 1, 1); + } + } } break; + case 8: + if (edict->tiki && !(edict->s.renderfx & RF_DONTDRAW)) { + G_DebugRotatedBBox(origin, angles, mins, maxs, 1, 1, 0, 1); + G_DebugBBox(origin, Vector(-4, -4, -4), Vector(4, 4, 4), 0, 1, 1, 1); + } + break; + default: + break; + } + + if ((showbboxes >= 9 && showbboxes <= 28) || (showbboxes >= -28 && showbboxes <= -9)) { + qboolean bDoPlayer = qfalse; + + if (showbboxes >= 0) { + bDoPlayer = qfalse; + } else { + showbboxes = -showbboxes; + bDoPlayer = qtrue; + } + + if (edict->s.solid == SOLID_NOT) { + return; + } + + if ((edict != g_entities && !bDoPlayer) || (edict == g_entities && bDoPlayer)) { + int i, j; + int iTagNum; + int iCap; + float fRadius; + const char *pszTagName; + vec3_t vOffset; + vec3_t vPos; + vec3_t vColor; + orientation_t orTag; + orientation_t orPosition; + + if (!IsSubclassOfSentient() || !edict->tiki) { + G_DebugBBox(origin, mins, maxs, 1.0, 1.0, 0.0, 1.0); + return; + } + + AnglesToAxis(angles, orientation); + + if (showbboxes <= 9 && showbboxes >= -9) { + i = 0; + iCap = 19; + } else { + i = showbboxes - 10; + if (i >= 18) { + return; + } + + iCap = i + 1; + } + + for (; i < iCap; i++) { + pszTagName = gi.CM_GetHitLocationInfo(i, &fRadius, vOffset); + + if (sv_testloc_num->integer - 1 == i || (sv_testloc_num->integer && (showbboxes > 9 || showbboxes < -9))) { + fRadius = sv_testloc_radius->value; + vOffset[0] = sv_testloc_offset_x->value; + vOffset[1] = sv_testloc_offset_y->value; + vOffset[2] = sv_testloc_offset_z->value; + vColor[0] = 1.0; + vColor[1] = 0.5; + vColor[2] = 0.0; + } else { + vColor[0] = 0.0; + vColor[1] = 0.5; + vColor[2] = 1.0; + } + + iTagNum = gi.Tag_NumForName(edict->tiki, pszTagName); + if (iTagNum < 0) { + return; + } + + orTag = G_TIKI_Orientation(edict, iTagNum & TAG_MASK); + VectorCopy(origin, orPosition.origin); + + for (j = 0; j < 3; j++) { + VectorMA(orPosition.origin, orTag.origin[j], orientation[j], orPosition.origin); + } + + MatrixMultiply(orTag.axis, orientation, orPosition.axis); + MatrixTransformVector(vOffset, orPosition.axis, vPos); + VectorAdd(orPosition.origin, vPos, vPos); + + G_DebugCircle(vPos, fRadius, vColor[0], vColor[1], vColor[2], 1.0); + + pszTagName = gi.CM_GetHitLocationInfoSecondary(i, &fRadius, vOffset); + vColor[0] = 0.5; + vColor[1] = 0.0; + vColor[2] = 1.0; + + if (!pszTagName || sv_testloc_num->integer - 1 == i || (sv_testloc_num->integer && (showbboxes > 9 || showbboxes < -9))) { + if (!sv_testloc_secondary->integer) { + continue; + } + + if (sv_testloc_num->integer - 1 != i && (!sv_testloc_num->integer || (showbboxes <= 9 && showbboxes >= -9))) { + continue; + } + + fRadius = sv_testloc_radius2->value; + vOffset[0] = sv_testloc_offset2_x->value; + vOffset[1] = sv_testloc_offset2_y->value; + vOffset[2] = sv_testloc_offset2_z->value; + vColor[0] = 1.0; + vColor[1] = 0.0; + vColor[2] = 0.5; + } + + MatrixTransformVector(vOffset, orPosition.axis, vPos); + VectorAdd(orPosition.origin, vPos, vPos); + + G_DebugCircle(vPos, fRadius, vColor[0], vColor[1], vColor[2], 1.0); + } + } } } @@ -6078,7 +6252,7 @@ void Entity::EventGetRotatedBbox(Event *ev) void Entity::EventSinglePlayerCommand(Event *ev) { if (g_gametype->integer == GT_SINGLE_PLAYER && !g_realismmode->integer) { - Event *newev = new Event(ev->GetToken(1)); + Event *newev = new Event(ev->GetToken(1), ev->NumArgs() - 1); for (int i = 2; i <= ev->NumArgs(); i++) { newev->AddToken(ev->GetToken(i)); @@ -6091,7 +6265,7 @@ void Entity::EventSinglePlayerCommand(Event *ev) void Entity::EventMultiPlayerCommand(Event *ev) { if (g_gametype->integer != GT_SINGLE_PLAYER && !g_realismmode->integer) { - Event *newev = new Event(ev->GetToken(1)); + Event *newev = new Event(ev->GetToken(1), ev->NumArgs() - 1); for (int i = 2; i <= ev->NumArgs(); i++) { newev->AddToken(ev->GetToken(i)); @@ -6104,7 +6278,7 @@ void Entity::EventMultiPlayerCommand(Event *ev) void Entity::EventRealismModeCommand(Event *ev) { if (g_realismmode->integer) { - Event *newev = new Event(ev->GetToken(1)); + Event *newev = new Event(ev->GetToken(1), ev->NumArgs() - 1); for (int i = 2; i <= ev->NumArgs(); i++) { newev->AddToken(ev->GetToken(i)); @@ -6116,8 +6290,8 @@ void Entity::EventRealismModeCommand(Event *ev) void Entity::EventSPRealismModeCommand(Event *ev) { - if (g_realismmode->integer && g_gametype->integer == GT_SINGLE_PLAYER) { - Event *newev = new Event(ev->GetToken(1)); + if (g_gametype->integer == GT_SINGLE_PLAYER && g_realismmode->integer) { + Event *newev = new Event(ev->GetToken(1), ev->NumArgs() - 1); for (int i = 2; i <= ev->NumArgs(); i++) { newev->AddToken(ev->GetToken(i)); @@ -6129,8 +6303,8 @@ void Entity::EventSPRealismModeCommand(Event *ev) void Entity::EventDMRealismModeCommand(Event *ev) { - if (g_realismmode->integer && g_gametype->integer != GT_SINGLE_PLAYER) { - Event *newev = new Event(ev->GetToken(1)); + if (g_gametype->integer != GT_SINGLE_PLAYER && g_realismmode->integer) { + Event *newev = new Event(ev->GetToken(1), ev->NumArgs() - 1); for (int i = 2; i <= ev->NumArgs(); i++) { newev->AddToken(ev->GetToken(i)); @@ -6193,7 +6367,9 @@ void Entity::NoTarget(Event *ev) void Entity::GetZone(Event *ev) { - // FIXME: stub + ev->AddInteger(edict->r.areanum); + + // FIXME: Implement OPM feature STUB(); #if 0 @@ -6209,7 +6385,13 @@ void Entity::GetZone(Event *ev) void Entity::IsInZone(Event *ev) { - // FIXME: stub + if (edict->r.areanum == ev->GetInteger(1)) { + ev->AddInteger(1); + } else { + ev->AddInteger(0); + } + + // FIXME: Implement OPM feature STUB(); #if 0 @@ -6246,6 +6428,7 @@ void Entity::SetDepthHack(Event *ev) } } +#ifdef OPM_FEATURES void Entity::ProcessHint(gentity_t *client, bool bShow) { Player *player = (Player *)client->entity; @@ -6284,35 +6467,48 @@ void Entity::SetHintString(Event *ev) m_HintString = ev->GetString(1); } -void Entity::SetShader(Event *ev) +void Entity::SetShader(Event* ev) { str shadername = ev->GetString(1); - qboolean fReset = false; + qboolean fReset = false; if (!shadername.length()) { shadername = "default"; - fReset = true; + fReset = true; } gi.SendServerCommand(-1, "setshader %d %s %d", entnum, shadername.c_str(), fReset); } +#endif void Entity::PlayNonPvsSound(const str& soundName, float volume) { AliasListNode_t* ret; str name; + if (g_gametype->integer == GT_SINGLE_PLAYER) { + // Ignore in single-player + return; + } + + if (!sv_netoptimize->integer) { + // don't use sound indexes for nothing + return; + } + if (edict->r.num_nonpvs_sounds >= MAX_NONPVS_SOUNDS) { return; } name = GetRandomAlias(soundName, &ret); if (name.length() && ret) { - edict->r.nonpvs_sounds[edict->r.num_nonpvs_sounds].index = gi.soundindex(name.c_str(), ret->streamed); - edict->r.nonpvs_sounds[edict->r.num_nonpvs_sounds].volume = G_Random() * ret->volumeMod + ret->volume * volume; - edict->r.nonpvs_sounds[edict->r.num_nonpvs_sounds].minDist = ret->dist; - edict->r.nonpvs_sounds[edict->r.num_nonpvs_sounds].maxDist = ret->maxDist; - edict->r.nonpvs_sounds[edict->r.num_nonpvs_sounds].pitch = G_Random() * ret->pitchMod + ret->pitch; + nonpvs_sound_t* npvs = &edict->r.nonpvs_sounds[edict->r.num_nonpvs_sounds]; + + npvs->index = gi.pvssoundindex(name.c_str(), ret->streamed); + npvs->volume = G_Random() * ret->volumeMod + ret->volume * volume; + npvs->minDist = ret->dist; + npvs->maxDist = ret->maxDist; + npvs->pitch = G_Random() * ret->pitchMod + ret->pitch; edict->r.num_nonpvs_sounds++; } } diff --git a/code/fgame/entity.h b/code/fgame/entity.h index cd9b1f12..3291a791 100644 --- a/code/fgame/entity.h +++ b/code/fgame/entity.h @@ -51,6 +51,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "script.h" #include "listener.h" #include "simpleentity.h" +#include "../qcommon/delegate.h" // modification flags #define FLAG_IGNORE 0 @@ -81,7 +82,8 @@ enum eAIEvent { AI_EVENT_MISC_LOUD, AI_EVENT_FOOTSTEP, AI_EVENT_GRENADE, - AI_EVENT_BADPLACE // Added in 2.0 + AI_EVENT_BADPLACE, // Added in 2.0 + AI_EVENT_MAX }; //deadflag @@ -285,6 +287,7 @@ public: // immune list Container immunities; +#ifdef OPM_FEATURES // // Added in OPM //==== @@ -292,6 +295,13 @@ public: bool m_bHintRequiresLookAt; str m_HintString; //==== +#endif + + MulticastDelegate delegate_damage; + MulticastDelegate delegate_killed; + MulticastDelegate delegate_gotKill; + +public: Entity(); virtual ~Entity(); @@ -502,7 +512,7 @@ public: void BroadcastAIEvent(int iType = AI_EVENT_MISC, float rad = SOUND_RADIUS); void BroadcastAIEvent(Event *ev); void Kill(Event *ev); - void Killed(Event *ev); + virtual void Killed(Event *ev); void SurfaceModelEvent(Event *ev); void SurfaceCommand(const char *surf_name, const char *token); virtual void Postthink(void); @@ -640,9 +650,11 @@ public: void GetZone(Event *ev); void IsInZone(Event *ev); void SetDepthHack(Event *ev); +#ifdef OPM_FEATURES void SetHintRequireLookAt(Event *ev); void SetHintString(Event *ev); - void SetShader(Event *ev); + void SetShader(Event* ev); +#endif void PlayNonPvsSound(const str& soundName, float volume = 1); }; diff --git a/code/fgame/explosion.cpp b/code/fgame/explosion.cpp index 3f42d199..72a7b620 100644 --- a/code/fgame/explosion.cpp +++ b/code/fgame/explosion.cpp @@ -487,7 +487,7 @@ void ExplodeObject::SetDebrisModel const char *ptr; // there could be multiple space delimited models, so we need to search for the spaces. - strcpy( string, ev->GetString( 1 ) ); + Q_strncpyz( string, ev->GetString( 1 ), sizeof( string ) ); ptr = strtok( string, " " ); while ( ptr ) { diff --git a/code/fgame/explosion.h b/code/fgame/explosion.h index 19618004..4d123c49 100644 --- a/code/fgame/explosion.h +++ b/code/fgame/explosion.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -26,8 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // explosions each time they are activated. // -#ifndef __EXPLOSION_H__ -#define __EXPLOSION_H__ +#pragma once #include "g_local.h" #include "entity.h" @@ -136,5 +135,3 @@ inline void ExplodeObject::Archive arc.ArchiveInteger( &debrisamount ); debrismodels.Archive( arc ); } - -#endif /* explosion.h */ diff --git a/code/fgame/g_bot.cpp b/code/fgame/g_bot.cpp index 0942f0ce..5ee6d165 100644 --- a/code/fgame/g_bot.cpp +++ b/code/fgame/g_bot.cpp @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2025 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -26,224 +26,772 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "playerbot.h" #include "g_bot.h" -static gentity_t* firstBot = NULL; -static saved_bot_t* saved_bots = NULL; -static unsigned int current_bot_count = 0; +static saved_bot_t *saved_bots = NULL; +static unsigned int num_saved_bots = 0; +static unsigned int botId = 0; -void G_BotBegin - ( - gentity_t *ent - ) +Container alliedModelList; +Container germanModelList; + +/* +=========== +IsAlliedPlayerModel + +Return whether or not the specified filename is for allies +============ +*/ +bool IsAlliedPlayerModel(const char *filename) { - level.m_bSpawnBot = true; - G_ClientBegin( ent, NULL ); + return !Q_stricmpn(filename, "allied_", 7) || !Q_stricmpn(filename, "american_", 9); } -void G_BotThink - ( - gentity_t *ent, - int msec - ) +/* +=========== +IsGermanPlayerModel + +Return whether or not the specified filename is for axis +============ +*/ +bool IsGermanPlayerModel(const char *filename) { - usercmd_t ucmd; - usereyes_t eyeinfo; - PlayerBot *bot; - - assert( ent ); - assert( ent->entity ); - assert( ent->entity->IsSubclassOfBot() ); - - bot = ( PlayerBot * )ent->entity; - - bot->UpdateBotStates(); - bot->GetUsercmd( &ucmd ); - bot->GetEyeInfo( &eyeinfo ); - - G_ClientThink( ent, &ucmd, &eyeinfo ); + return !Q_stricmpn(filename, "german_", 7) || !Q_stricmpn(filename, "IT_", 3) || !Q_stricmpn(filename, "SC_", 3); } -gentity_t* G_GetFirstBot() +/* +=========== +IsPlayerModel + +Return whether or not the specified filename +is a player model that can be chosen +============ +*/ +bool IsPlayerModel(const char *filename) { - return firstBot; + size_t len = strlen(filename); + + if (len >= 8 && !Q_stricmp(&filename[len - 8], "_fps.tik")) { + return false; + } + + if (!IsAlliedPlayerModel(filename) && !IsGermanPlayerModel(filename)) { + return false; + } + + return true; } -void G_AddBot(unsigned int num, saved_bot_t* saved) +/* +=========== +ClearModelList + +Clear the allied and axis model list +============ +*/ +void ClearModelList() { - int n; - int i; - int clientNum = -1; - gentity_t *e; - char botName[ MAX_NETNAME ]; - char challenge[ MAX_STRING_TOKENS ]; - char userinfo[MAX_INFO_STRING]{ 0 }; - Event* teamEv; + alliedModelList.FreeObjectList(); + germanModelList.FreeObjectList(); +} - num = Q_min(num, sv_maxbots->integer); - for( n = 0; n < num; n++ ) - { - for( i = maxclients->integer; i < game.maxclients; i++ ) - { - e = &g_entities[ i ]; +/* +=========== +InitModelList - if( !e->inuse && e->client ) - { - clientNum = i; - break; - } - } +Initialize the list of allied and axis player models +that bots can use +============ +*/ +void InitModelList() +{ + char **fileList; + int numFiles; + int i; + size_t numAlliedModels = 0, numGermanModels = 0; + byte *p; - if( clientNum == -1 ) - { - gi.Printf( "No free slot for a bot\n" ); - return; - } + ClearModelList(); - if( gi.Argc() > 2 ) - { - Q_strncpyz( botName, gi.Argv( 2 ), sizeof( botName ) ); - } - else - { - sprintf( botName, "bot%d", clientNum - maxclients->integer + 1 ); - } + fileList = gi.FS_ListFiles("models/player", ".tik", qfalse, &numFiles); - sprintf( challenge, "%d", clientNum - maxclients->integer + 1 ); + for (i = 0; i < numFiles; i++) { + const char *filename = fileList[i]; - e->s.clientNum = clientNum; - e->s.number = clientNum; - - if (saved) { - strncpy(userinfo, saved->pers.userinfo, ARRAY_LEN(userinfo)); - } else { - Info_SetValueForKey(userinfo, "name", botName); - Info_SetValueForKey(userinfo, "dm_playermodel", "allied_pilot"); - Info_SetValueForKey(userinfo, "dm_playergermanmodel", "german_afrika_officer"); - Info_SetValueForKey(userinfo, "fov", "80"); - Info_SetValueForKey(userinfo, "protocol", "8"); - Info_SetValueForKey(userinfo, "ip", "0.0.0.0"); - Info_SetValueForKey(userinfo, "qport", "0"); - Info_SetValueForKey(userinfo, "challenge", challenge); - Info_SetValueForKey(userinfo, "snaps", "1"); - Info_SetValueForKey(userinfo, "rate", "1"); - Info_SetValueForKey(userinfo, "dmprimary", "smg"); - } - - current_bot_count++; - - G_BotConnect( clientNum, userinfo ); - - if (saved) { - e->client->pers = saved->pers; - } - - if( !firstBot ) - firstBot = e; - - G_BotBegin( e ); - - if (saved) { - /* - switch (saved->team) - { - case TEAM_ALLIES: - teamEv = new Event(EV_Player_JoinDMTeam); - teamEv->AddString("allies"); - break; - case TEAM_AXIS: - teamEv = new Event(EV_Player_JoinDMTeam); - teamEv->AddString("axis"); - break; - default: - teamEv = new Event(EV_Player_AutoJoinDMTeam); - break; - } - */ - } else { - teamEv = new Event(EV_Player_AutoJoinDMTeam); - e->entity->PostEvent(teamEv, level.frametime); - - Event* ev = new Event(EV_Player_PrimaryDMWeapon); - ev->AddString("smg"); - - e->entity->PostEvent(ev, level.frametime); + if (!IsPlayerModel(filename)) { + continue; } - } + + if (IsAlliedPlayerModel(filename)) { + numAlliedModels++; + } else { + numGermanModels++; + } + } + + alliedModelList.Resize(numAlliedModels); + germanModelList.Resize(numGermanModels); + + for (i = 0; i < numFiles; i++) { + const char *filename = fileList[i]; + size_t len = strlen(filename); + + if (!IsPlayerModel(filename)) { + continue; + } + + if (IsAlliedPlayerModel(filename)) { + alliedModelList.AddObject(str(filename, 0, len - 4)); + } else { + germanModelList.AddObject(str(filename, 0, len - 4)); + } + } + + gi.FS_FreeFileList(fileList); } -void G_RemoveBot(unsigned int num) +/* +=========== +G_BotBegin + +Begin spawning a new bot entity +============ +*/ +void G_BotBegin(gentity_t *ent) { - num = Q_min(atoi(gi.Argv(1)), sv_maxbots->integer); + Player *player; + BotController *controller; - for( int n = 0; n < num; n++ ) - { - gentity_t *e = &g_entities[ game.maxclients - 1 - n ]; - if( e->inuse && e->client ) - { - G_ClientDisconnect( e ); - current_bot_count--; - } - } + level.spawn_entnum = ent->s.number; + player = new Player; + + G_ClientBegin(ent, NULL); + + controller = botManager.getControllerManager().createController(player); + //player->setController(controller); } -void G_SaveBots() { - unsigned int n; +/* +=========== +G_BotThink + +Called each server frame to make bots think +============ +*/ +void G_BotThink(gentity_t *ent, int msec) +{ + /* + usercmd_t ucmd; + usereyes_t eyeinfo; + PlayerBot *bot; + + assert(ent); + assert(ent->entity); + assert(ent->entity->IsSubclassOfBot()); + + bot = (PlayerBot *)ent->entity; + + bot->UpdateBotStates(); + bot->GetUsercmd(&ucmd); + bot->GetEyeInfo(&eyeinfo); + + G_ClientThink(ent, &ucmd, &eyeinfo); + */ +} + +/* +=========== +G_FindFreeEntityForBot + +Find a free client slot +============ +*/ +gentity_t *G_FindFreeEntityForBot() +{ + gentity_t *ent; + int minNum = 0; + int i; + + if (sv_sharedbots->integer) { + minNum = 0; + } else { + minNum = maxclients->integer; + } + + for (i = minNum; i < game.maxclients; i++) { + ent = &g_entities[i]; + if (!ent->inuse && ent->client && !ent->client->pers.userinfo[0]) { + return ent; + } + } + + return NULL; +} + +/* +=========== +G_ChangeParent + +Fix parenting for entities that use the old number +============ +*/ +void G_ChangeParent(int oldNum, int newNum) +{ + gentity_t *ent; + int i; + + for (i = 0; i < game.maxentities; i++) { + ent = &g_entities[i]; + if (!ent->inuse || !ent->entity) { + continue; + } + + if (ent->s.parent == oldNum) { + ent->s.parent = newNum; + } + if (ent->r.ownerNum == oldNum) { + ent->r.ownerNum = newNum; + } + } +} + +/* +=========== +G_BotShift + +If the specified slot is used, the bot will be relocated +to the next free entity slot +============ +*/ +void G_BotShift(int clientNum) +{ + gentity_t *ent; + gentity_t *newEnt; + + ent = &g_entities[clientNum]; + if (!ent->inuse || !ent->client || !ent->entity) { + return; + } + + if (!botManager.getControllerManager().findController(ent->entity)) { + return; + } + + newEnt = G_FindFreeEntityForBot(); + if (!newEnt) { + G_RemoveBot(ent); + return; + } + + // + // Allocate the new entity + // + level.spawn_entnum = newEnt - g_entities; + level.AllocEdict(ent->entity); + + // + // Copy all fields + // + newEnt->s = ent->s; + newEnt->s.number = newEnt - g_entities; + memcpy(newEnt->client, ent->client, sizeof(*newEnt->client)); + newEnt->r = ent->r; + newEnt->solid = ent->solid; + newEnt->tiki = ent->tiki; + AxisCopy(ent->mat, newEnt->mat); + + newEnt->freetime = ent->freetime; + newEnt->spawntime = ent->spawntime; + newEnt->radius2 = ent->radius2; + memcpy(newEnt->entname, ent->entname, sizeof(newEnt->entname)); + newEnt->clipmask = ent->clipmask; + newEnt->entity = ent->entity; + newEnt->entity->edict = newEnt; + newEnt->entity->client = newEnt->client; + newEnt->entity->entnum = newEnt->s.number; + newEnt->client->ps.clientNum = newEnt->s.number; + + G_ChangeParent(ent->s.number, newEnt->s.number); + + // + // Free the old entity so the real client will use it + // + level.FreeEdict(ent); + memset(ent->client, 0, sizeof(*ent->client)); + + G_SetClientConfigString(newEnt); +} + +/* +=========== +G_GetFirstBot + +Return the first bot +============ +*/ +gentity_t *G_GetFirstBot() +{ + gentity_t *ent; + unsigned int n; + + for (n = 0; n < game.maxclients; n++) { + ent = &g_entities[n]; + if (G_IsBot(ent)) { + return ent; + } + } + + return NULL; +} + +/* +=========== +G_IsBot + +Return whether or not the gentity is a bot +============ +*/ +bool G_IsBot(gentity_t *ent) +{ + if (!ent->inuse || !ent->client) { + return false; + } + + if (!ent->entity || !botManager.getControllerManager().findController(ent->entity)) { + return false; + } + + return true; +} + +/* +=========== +G_IsPlayer + +Return whether or not the gentity is a player +============ +*/ +bool G_IsPlayer(gentity_t *ent) +{ + if (!ent->inuse || !ent->client) { + return false; + } + + if (!ent->entity || botManager.getControllerManager().findController(ent->entity)) { + return false; + } + + return true; +} + +/* +=========== +G_GetRandomAlliedPlayerModel +============ +*/ +const char *G_GetRandomAlliedPlayerModel() +{ + if (!alliedModelList.NumObjects()) { + return ""; + } + + const unsigned int index = rand() % alliedModelList.NumObjects(); + return alliedModelList[index]; +} + +/* +=========== +G_GetRandomGermanPlayerModel +============ +*/ +const char *G_GetRandomGermanPlayerModel() +{ + if (!germanModelList.NumObjects()) { + return ""; + } + + const unsigned int index = rand() % germanModelList.NumObjects(); + return germanModelList[index]; +} + +/* +=========== +G_AddBot + +Add the specified bot, optionally its saved state +============ +*/ +void G_AddBot(const saved_bot_t *saved) +{ + int i; + int clientNum; + gentity_t *e; + char botName[MAX_NETNAME]; + char challenge[MAX_STRING_TOKENS]; + Event *teamEv; + char userinfo[MAX_INFO_STRING] {0}; + + e = G_FindFreeEntityForBot(); + if (!e) { + gi.Printf("No free slot for a bot\n"); + return; + } + + clientNum = e - g_entities; + + // increase the unique ID + botId++; + + if (saved) { + G_BotConnect(clientNum, qfalse, saved->userinfo); + G_BotBegin(e); + return; + } + + if (gi.Argc() > 2) { + Q_strncpyz(botName, gi.Argv(2), sizeof(botName)); + } else { + Com_sprintf(botName, sizeof(botName), "bot%d", botId); + } + + Info_SetValueForKey(userinfo, "name", botName); + + // + // Choose a random model + // + Info_SetValueForKey(userinfo, "dm_playermodel", G_GetRandomAlliedPlayerModel()); + Info_SetValueForKey(userinfo, "dm_playergermanmodel", G_GetRandomGermanPlayerModel()); + + Info_SetValueForKey(userinfo, "fov", "80"); + Info_SetValueForKey(userinfo, "ip", "localhost"); + + // Connect the bot for the first time + // setup user info and stuff + G_BotConnect(clientNum, qtrue, userinfo); + + G_BotBegin(e); +} + +/* +=========== +G_AddBots + +Add the specified number of bots +============ +*/ +void G_AddBots(unsigned int num) +{ + int n; + + for (n = 0; n < num; n++) { + G_AddBot(NULL); + } +} + +/* +=========== +G_RemoveBot + +Remove the specified bot +============ +*/ +void G_RemoveBot(gentity_t *ent) +{ + if (ent->entity) { + BotController *controller = botManager.getControllerManager().findController(ent->entity); + + botManager.getControllerManager().removeController(controller); + } + + G_ClientDisconnect(ent); +} + +/* +=========== +G_RemoveBots + +Remove the specified number of bots +============ +*/ +void G_RemoveBots(unsigned int num) +{ + unsigned int removed = 0; + unsigned int n; + unsigned int teamCount[2] {0}; + bool bNoMoreToRemove = false; + + teamCount[0] = dmManager.GetTeamAllies()->m_players.NumObjects(); + teamCount[1] = dmManager.GetTeamAxis()->m_players.NumObjects(); + + while (!bNoMoreToRemove) { + bNoMoreToRemove = true; + + // First remove bots that are in the team + // with the higest player count + for (n = 0; n < game.maxclients && removed < num; n++) { + gentity_t *e = &g_entities[n]; + if (!G_IsBot(e)) { + continue; + } + + Player *player = static_cast(e->entity); + if (player->GetTeam() == TEAM_ALLIES || player->GetTeam() == TEAM_AXIS) { + unsigned int teamIndex = (player->GetTeam() - TEAM_ALLIES); + if (teamCount[teamIndex] < teamCount[1 - teamIndex]) { + // Not enough players in that team, don't remove the bot + continue; + } + + teamCount[teamIndex]--; + bNoMoreToRemove = false; + } + + G_RemoveBot(e); + removed++; + } + } + + // + // Remove all bots that haven't been removed earlier + // + for (n = 0; n < game.maxclients && removed < num; n++) { + gentity_t *e = &g_entities[n]; + if (!G_IsBot(e)) { + continue; + } + + G_RemoveBot(e); + removed++; + } +} + +/* +=========== +G_SaveBots + +Save bot persistent data +============ +*/ +void G_SaveBots() +{ + unsigned int count; + unsigned int n; if (saved_bots) { delete[] saved_bots; - saved_bots = NULL; + saved_bots = NULL; } - if (!current_bot_count) { - return; - } + const BotControllerManager& manager = botManager.getControllerManager(); + unsigned int numSpawnedBots = manager.getControllers().NumObjects(); - saved_bots = new saved_bot_t[current_bot_count]; - for (n = 0; n < current_bot_count; n++) { - gentity_t* e = &g_entities[game.maxclients - sv_maxbots->integer + n]; - saved_bot_t& saved = saved_bots[n]; + if (!numSpawnedBots) { + return; + } - if (e->inuse && e->client) - { - Player* player = static_cast(e->entity); + saved_bots = new saved_bot_t[numSpawnedBots]; + num_saved_bots = 0; - saved.bValid = true; - //saved.team = player->GetTeam(); - saved.pers = player->client->pers; - } - } + count = manager.getControllers().NumObjects(); + assert(count <= numSpawnedBots); + + for (n = 1; n <= count; n++) { + const BotController *controller = manager.getControllers().ObjectAt(n); + Player *player = controller->getControlledEntity(); + if (!player) { + // this shouldn't happen + continue; + } + + saved_bot_t& saved = saved_bots[num_saved_bots++]; + memcpy(saved.userinfo, player->client->pers.userinfo, sizeof(saved.userinfo)); + } } -void G_RestoreBots() { - unsigned int n; +/* +=========== +G_RestoreBots + +Restore bot persistent data, such as their team +============ +*/ +void G_RestoreBots() +{ + unsigned int n; if (!saved_bots) { - return; + return; } - for (n = 0; n < sv_numbots->integer; n++) { - saved_bot_t& saved = saved_bots[n]; + for (n = 0; n < num_saved_bots; n++) { + const saved_bot_t& saved = saved_bots[n]; - G_AddBot(1, &saved); - } + G_AddBot(&saved); + } - delete[] saved_bots; - saved_bots = NULL; + delete[] saved_bots; + saved_bots = NULL; } -void G_ResetBots() { - G_SaveBots(); +/* +=========== +G_CountPlayingClients - current_bot_count = 0; +Count the number of real clients that are playing +============ +*/ +int G_CountPlayingClients() +{ + gentity_t *other; + unsigned int n; + unsigned int count = 0; + + for (n = 0; n < game.maxclients; n++) { + other = &g_entities[n]; + if (G_IsPlayer(other)) { + Player *p = static_cast(other->entity); + // Ignore spectators + if (p->GetTeam() != teamtype_t::TEAM_NONE && p->GetTeam() != teamtype_t::TEAM_SPECTATOR) { + count++; + } + } + } + + return count; } -void G_SpawnBots() { - if (saved_bots) { - G_RestoreBots(); - } +/* +=========== +G_CountClients - if (sv_numbots->integer > current_bot_count) { - G_AddBot(sv_numbots->integer - current_bot_count); - } else if (sv_numbots->integer < current_bot_count) { - G_RemoveBot(current_bot_count - sv_numbots->integer); - } +Count the number of real clients +============ +*/ +int G_CountClients() +{ + gentity_t *other; + unsigned int n; + unsigned int count = 0; + + for (n = 0; n < game.maxclients; n++) { + other = &g_entities[n]; + if (G_IsBot(other)) { + continue; + } + + if (other->client && other->client->pers.userinfo[0]) { + count++; + } + } + + return count; +} + +/* +=========== +G_RestartBots + +Save bots +============ +*/ +void G_RestartBots() +{ + G_SaveBots(); +} + +/* +=========== +G_ResetBots + +Save and reset the bot count +============ +*/ +void G_ResetBots() +{ + botManager.Cleanup(); + + botId = 0; +} + +/* +=========== +G_BotInit + +Called to initialize bots +============ +*/ +void G_BotInit() +{ + InitModelList(); + botManager.Init(); +} + +/* +=========== +G_BotFrame + +Called each frame to manage bots +============ +*/ +void G_BotFrame() +{ + botManager.Frame(); +} + +/* +=========== +G_BotPostInit + +Called after the server has spawned +============ +*/ +void G_BotPostInit() +{ + G_RestoreBots(); + + G_SpawnBots(); +} + +/* +=========== +G_SpawnBots + +Called each frame to manage bot spawning +============ +*/ +void G_SpawnBots() +{ + unsigned int numClients; + unsigned int numBotsToSpawn; + unsigned int numSpawnedBots; + + // + // Check the minimum bot count + // + numClients = G_CountPlayingClients(); + if (numClients < sv_minPlayers->integer) { + numBotsToSpawn = sv_minPlayers->integer - numClients + sv_numbots->integer; + } else { + numBotsToSpawn = sv_numbots->integer; + } + + if (sv_sharedbots->integer) { + unsigned int numClients = G_CountClients(); + + // + // Cap to the maximum number of possible clients + // + numBotsToSpawn = Q_min(numBotsToSpawn, maxclients->integer - numClients + sv_maxbots->integer); + } else { + numBotsToSpawn = Q_min(numBotsToSpawn, sv_maxbots->integer); + } + + numSpawnedBots = botManager.getControllerManager().getControllers().NumObjects(); + + // + // Spawn bots + // + if (numBotsToSpawn > numSpawnedBots) { + G_AddBots(numBotsToSpawn - numSpawnedBots); + } else if (numBotsToSpawn < numSpawnedBots) { + G_RemoveBots(numSpawnedBots - numBotsToSpawn); + } } diff --git a/code/fgame/g_bot.h b/code/fgame/g_bot.h index f81addb1..5db1b88a 100644 --- a/code/fgame/g_bot.h +++ b/code/fgame/g_bot.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2025 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -23,18 +23,24 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #pragma once struct saved_bot_t { - client_persistant_t pers; - bool bValid; - - saved_bot_t() - : bValid(false) - {} + char userinfo[MAX_INFO_STRING]; }; -void G_BotBegin(gentity_t* ent); -void G_BotThink(gentity_t* ent, int msec); -gentity_t* G_GetFirstBot(); -void G_AddBot(unsigned int num, saved_bot_t* saved = NULL); -void G_RemoveBot(unsigned int num); -void G_ResetBots(); -void G_SpawnBots(); \ No newline at end of file +void G_BotBegin(gentity_t *ent); +void G_BotThink(gentity_t *ent, int msec); +void G_BotShift(int clientNum); +gentity_t *G_GetFirstBot(); +void G_AddBot(const saved_bot_t *saved = NULL); +void G_AddBots(unsigned int num); +void G_RemoveBot(gentity_t *ent); +void G_RemoveBots(unsigned int num); +bool G_IsBot(gentity_t *ent); +bool G_IsPlayer(gentity_t *ent); +void G_ResetBots(); +void G_RestartBots(); +void G_BotInit(); +void G_BotFrame(); +void G_BotPostInit(); +void G_SpawnBots(); +const char *G_GetRandomAlliedPlayerModel(); +const char *G_GetRandomGermanPlayerModel(); \ No newline at end of file diff --git a/code/fgame/g_client.cpp b/code/fgame/g_client.cpp index c11b7f24..3a69d78d 100644 --- a/code/fgame/g_client.cpp +++ b/code/fgame/g_client.cpp @@ -25,6 +25,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "playerbot.h" #include "playerstart.h" #include "scriptmaster.h" +#include "g_spawn.h" +#include "g_bot.h" // g_client.c -- client functions that don't happen every frame @@ -578,6 +580,10 @@ Chooses a player start, deathmatch start, etc PlayerStart *SelectSpawnPoint(Player *player) { PlayerStart *spot = NULL; + PlayerStart *spawnpoint; + const char *classID; + int i; + int nFound; switch (g_gametype->integer) { case GT_SINGLE_PLAYER: @@ -602,15 +608,41 @@ PlayerStart *SelectSpawnPoint(Player *player) // find a single player start spot if (!spot) { - while ((spot = (PlayerStart *)G_FindArchivedClass(spot, "info_player_start")) != NULL) { - if (level.spawnpoint.icmp(spot->TargetName()) == 0) { - break; + for (i = 1; i <= level.m_SimpleArchivedEntities.NumObjects(); i++) { + SimpleArchivedEntity *arc = level.m_SimpleArchivedEntities.ObjectAt(i); + + classID = arc->classinfo()->classID; + if (!Q_stricmp(classID, "info_player_start")) { + spawnpoint = static_cast(arc); + if (!str::icmp(level.spawnpoint, spawnpoint->TargetName())) { + spot = spawnpoint; + break; + } } } if (!spot && !level.spawnpoint.length()) { - // there wasn't a spawnpoint without a target, so use any - spot = (PlayerStart *)G_FindArchivedClass(NULL, "info_player_start"); + nFound = 0; + + for (i = 1; i <= level.m_SimpleArchivedEntities.NumObjects(); i++) { + SimpleArchivedEntity *arc = level.m_SimpleArchivedEntities.ObjectAt(i); + + classID = arc->classinfo()->classID; + // Fixed in OPM + // If there is no free spot, just use any random player start + // OG wants info_player_start directly + if (arc->isSubclassOf(PlayerStart)) { + int randVal; + + spawnpoint = static_cast(arc); + nFound++; + + randVal = rand(); + if (randVal == randVal / nFound * nFound) { + spot = spawnpoint; + } + } + } } if (!spot) { @@ -725,6 +757,7 @@ void G_ClientUserinfoChanged(gentity_t *ent, const char *u) char *s; gclient_t *client; int clientnum; + char oldname[MAX_NAME_LENGTH]; if (!ent) { return; @@ -740,10 +773,19 @@ void G_ClientUserinfoChanged(gentity_t *ent, const char *u) clientnum = ent - g_entities; - if (gi.SanitizeName(s, client->pers.netname)) { + Q_strncpyz(oldname, client->pers.netname, sizeof(oldname)); + if (gi.SanitizeName(s, client->pers.netname, sizeof(client->pers.netname))) { gi.Printf("WARNING: had to sanitize the name for client %i\n", clientnum); } + if (strcmp(oldname, client->pers.netname)) { + // + // Added in OPM + // Print name changes + // + gi.Printf("Client %i changed name from '%s' to '%s'\n", clientnum, oldname, client->pers.netname); + } + s = Info_ValueForKey(u, "dm_playermodel"); if (!s) { @@ -762,7 +804,7 @@ void G_ClientUserinfoChanged(gentity_t *ent, const char *u) Q_strncpyz(client->pers.dm_playergermanmodel, s, sizeof(client->pers.dm_playergermanmodel)); - gi.setConfigstring(CS_PLAYERS + clientnum, va("name\\%s", client->pers.netname)); + G_SetClientConfigString(ent); if (ent->entity) { float fov; @@ -786,7 +828,7 @@ void G_ClientUserinfoChanged(gentity_t *ent, const char *u) Q_strncpyz(client->pers.userinfo, u, sizeof(client->pers.userinfo)); } -void G_BotConnect(int clientNum, const char* userinfo) +void G_BotConnect(int clientNum, qboolean firstTime, const char *userinfo) { gclient_t *client; gentity_t *ent; @@ -795,13 +837,24 @@ void G_BotConnect(int clientNum, const char* userinfo) ent->client = game.clients + clientNum; ent->s.number = clientNum; + ent->r.svFlags |= SVF_BOT; client = ent->client; // read the session data memset(client, 0, sizeof(*client)); - G_InitSessionData(client, userinfo); + if (firstTime) { + memset(client, 0, sizeof(*client)); + if (!game.autosaved) { + G_InitClientPersistant(client, userinfo); + } + } else { + G_ReadClientSessionData(client); + } + // + // Use "localhost" as some code relies on it to check whether or not it should be kicked + // Q_strncpyz(client->pers.ip, "localhost", sizeof(client->pers.ip)); client->pers.port = 0; @@ -828,17 +881,15 @@ to the server machine, but qfalse on map changes and tournement restarts. ============ */ -const char *G_ClientConnect(int clientNum, qboolean firstTime) +const char *G_ClientConnect(int clientNum, qboolean firstTime, qboolean differentMap) { char *ip, *port, *value; gclient_t *client; gentity_t *ent; char userinfo[MAX_INFO_STRING]; - gi.DPrintf("TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT\n"); - if (!g_gametype->integer) { - return NULL; - } + // Added in OPM + G_BotShift(clientNum); ent = &g_entities[clientNum]; @@ -852,6 +903,7 @@ const char *G_ClientConnect(int clientNum, qboolean firstTime) port = Info_ValueForKey(userinfo, "port"); // FIXME: what is fucking wrong with G_FilterPacket... + // NOTE: IP banning is directly handled by the server //if ( G_FilterPacket( value ) ) { // return "Banned IP"; //} @@ -862,7 +914,8 @@ const char *G_ClientConnect(int clientNum, qboolean firstTime) if ((strcmp(ip, "localhost") != 0)) { // check for a password value = Info_ValueForKey(userinfo, "password"); - if (password->string[0] && Q_stricmp(password->string, "none") && strcmp(password->string, value) != 0) { + if (strcmp(sv_privatePassword->string, value) != 0 && *password->string + && strcmp(password->string, value) != 0) { return "Invalid password"; } } @@ -872,10 +925,23 @@ const char *G_ClientConnect(int clientNum, qboolean firstTime) // read or initialize the session data if (firstTime) { - memset(client, 0, sizeof(*client)); - G_InitSessionData(client, userinfo); + if (g_gametype->integer != GT_SINGLE_PLAYER || !cl_running->integer || clientNum != 0) { + // Added in OPM + // Accept remote clients but ignore the listen server + // so the client flags that were put during prespawn stay + memset(client, 0, sizeof(*client)); + } + if (!game.autosaved) { + G_InitClientPersistant(client, userinfo); + } } else { - G_ReadSessionData(client); + G_ReadClientSessionData(client); + // Added in 2.1 + // Let clients choose their primary weapon + // on map change + if (differentMap) { + client->pers.dm_primary[0] = 0; + } } Q_strncpyz(client->pers.ip, ip, sizeof(client->pers.ip)); @@ -895,7 +961,7 @@ const char *G_ClientConnect(int clientNum, qboolean firstTime) #endif // don't do the "xxx connected" messages if they were caried over from previous level - if (firstTime && g_gametype->integer) { + if (firstTime && g_gametype->integer != GT_SINGLE_PLAYER) { if (dedicated->integer) { gi.Printf("%s is preparing for deployment\n", client->pers.netname); } @@ -931,12 +997,7 @@ void G_ClientBegin(gentity_t *ent, usercmd_t *cmd) // a spawn point will completely reinitialize the entity level.spawn_entnum = ent->s.number; - if (level.m_bSpawnBot) { - level.m_bSpawnBot = false; - PlayerBot *player = new PlayerBot; - } else { - Player *player = new Player; - } + Player *player = new Player; } if (level.intermissiontime && ent->entity) { @@ -944,7 +1005,7 @@ void G_ClientBegin(gentity_t *ent, usercmd_t *cmd) } else { ent->client->pers.enterTime = level.svsFloatTime; - if (g_gametype->integer) { + if (g_gametype->integer != GT_SINGLE_PLAYER) { // send effect if in a multiplayer game if (dedicated->integer) { gi.Printf("%s has entered the battle\n", ent->client->pers.netname); @@ -1011,10 +1072,17 @@ void G_ClientDisconnect(gentity_t *ent) G_PrintToAllClients(va("%s has left the battle\n", ent->client->pers.netname), 2); + assert(ent->entity->IsSubclassOfPlayer()); ((Player *)ent->entity)->Disconnect(); - delete ent->entity; + if (g_iInThinks) { + ent->entity->PostEvent(EV_Remove, 0); + } else { + delete ent->entity; + } ent->entity = NULL; + + G_InitClientPersistant(ent->client); } catch (const char *error) { diff --git a/code/fgame/g_local.h b/code/fgame/g_local.h index fcf18650..ab4644ee 100644 --- a/code/fgame/g_local.h +++ b/code/fgame/g_local.h @@ -22,8 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // // g_local.h -- local definitions for game module -#ifndef __G_LOCAL_H__ -#define __G_LOCAL_H__ +#pragma once #include "q_shared.h" #include "bg_public.h" @@ -133,15 +132,6 @@ typedef struct { #define MAX_NETNAME 32 #define MAX_VOTE_COUNT 3 -typedef enum { - CS_FREE, - CS_ZOMBIE, - CS_CONNECTED, - CS_PRIMED, - CS_ACTIVE - -} clientState_t; - // // g_spawn.c // @@ -212,6 +202,7 @@ void G_PrintDeathMessage( ); void G_PrintDeathMessage_Old(const char *pszString); void G_WarnPlayer(class Player *player, const char *format, ...); +int G_NumClients(void); int G_WeaponIndex(const char *name); @@ -417,14 +408,14 @@ void G_RunThink(gentity_t *ent); void QDECL G_LogPrintf(const char *fmt, ...); void SendScoreboardMessageToAllClients(void); void QDECL G_Printf(const char *fmt, ...); -void QDECL G_Error(const char *fmt, ...); -void QDECL G_Error(errorParm_t type, const char *fmt, ...); +void QDECL G_Error(const char *fmt, ...) __attribute__ ((noreturn, format(printf, 1, 2))); +void QDECL G_Error(errorParm_t type, const char *fmt, ...) __attribute__((noreturn, format(printf, 2, 3))); // // g_client.c // -void G_BotConnect(int clientNum, const char* userinfo); -const char *G_ClientConnect(int clientNum, qboolean firstTime); +void G_BotConnect(int clientNum, qboolean firstTime, const char* userinfo); +const char *G_ClientConnect(int clientNum, qboolean firstTime, qboolean differentMap); void G_ClientUserinfoChanged(gentity_t *ent, const char *userinfo); void G_ClientDisconnect(gentity_t *ent); void G_ClientBegin(gentity_t *ent, usercmd_t *cmd); @@ -437,6 +428,8 @@ void G_ClientCommand(gentity_t *ent); void G_ClientThink(gentity_t *ent, usercmd_t *cmd, usereyes_t *eyeinfo); void ClientEndFrame(gentity_t *ent); void G_ClientEndServerFrames(void); +void G_ClientDoBlends(void); +void FindIntermissionPoint(void); void G_RunClient(gentity_t *ent); // @@ -456,8 +449,8 @@ void Svcmd_GameMem_f(void); // // g_session.c // -void G_ReadSessionData(gclient_t *client); -void G_InitSessionData(gclient_t *client, const char *userinfo); +void G_ReadClientSessionData(gclient_t *client); +void G_InitClientPersistant(gclient_t *client, const char *userinfo); void G_InitWorldSession(void); void G_WriteSessionData(void); @@ -530,5 +523,3 @@ extern gentity_t *g_entities; #define FOFS(x) ((size_t) & (((gentity_t *)0)->x)) #include "g_utils.h" - -#endif /* g_local.h */ diff --git a/code/fgame/g_main.cpp b/code/fgame/g_main.cpp index 7218e4db..ccb0e3f7 100644 --- a/code/fgame/g_main.cpp +++ b/code/fgame/g_main.cpp @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -63,12 +63,12 @@ gentity_t free_edicts; int sv_numtraces = 0; int sv_numpmtraces = 0; -int g_protocol = 0; -target_game_e g_target_game = target_game_e::TG_INVALID; -gentity_t *g_entities; -qboolean g_iInThinks = 0; -qboolean g_bBeforeThinks = qfalse; -static float g_fMsecPerClock = 0; +int g_protocol = 0; +target_game_e g_target_game = target_game_e::TG_INVALID; +gentity_t *g_entities; +qboolean g_iInThinks = 0; +qboolean g_bBeforeThinks = qfalse; +static float g_fMsecPerClock = 0; usercmd_t *current_ucmd; usereyes_t *current_eyeinfo; @@ -83,37 +83,52 @@ void (*SV_Free)(void *ptr); qboolean LevelArchiveValid(Archiver& arc); void ClosePlayerLogFile(void); +/* +=============== +G_Printf +=============== +*/ void QDECL G_Printf(const char *fmt, ...) { va_list argptr; char text[1024]; va_start(argptr, fmt); - vsprintf(text, fmt, argptr); + Q_vsnprintf(text, sizeof(text), fmt, argptr); va_end(argptr); gi.Printf(text); } +/* +=============== +G_Error +=============== +*/ void QDECL G_Error(const char *fmt, ...) { va_list argptr; char text[1024]; va_start(argptr, fmt); - vsprintf(text, fmt, argptr); + Q_vsnprintf(text, sizeof(text), fmt, argptr); va_end(argptr); gi.Error(ERR_DROP, text); } +/* +=============== +G_Error +=============== +*/ void QDECL G_Error(int type, const char *fmt, ...) { va_list argptr; char text[1024]; va_start(argptr, fmt); - vsprintf(text, fmt, argptr); + Q_vsnprintf(text, sizeof(text), fmt, argptr); va_end(argptr); // need to manually crash otherwise visual studio fuck up with the stack pointer... @@ -212,9 +227,13 @@ void G_AllocGameData(void) void G_DeAllocGameData(void) { - // Initialize debug lines + // Free up debug lines G_DeAllocDebugLines(); + // Added in OPM + // Free up debug strings + G_DeAllocDebugStrings(); + // free up the entities if (g_entities) { gi.Free(g_entities); @@ -240,7 +259,7 @@ void G_InitGame(int levelTime, int randomSeed) G_Printf("gamename: %s\n", GAMEVERSION); G_Printf("gamedate: %s\n", __DATE__); - g_protocol = gi.Cvar_Get("com_protocol", "", 0)->integer; + g_protocol = gi.Cvar_Get("com_protocol", "", 0)->integer; g_target_game = (target_game_e)gi.Cvar_Get("com_target_game", "0", 0)->integer; srand(randomSeed); @@ -251,18 +270,17 @@ void G_InitGame(int levelTime, int randomSeed) // set some level globals level.svsStartTime = levelTime; - level.specialgame = sv_specialgame->integer ? true : false; G_InitConsoleCommands(); Director.Reset(); Actor::Init(); - PlayerBot::Init(); + G_BotInit(); sv_numtraces = 0; sv_numpmtraces = 0; - if (developer->integer && !g_gametype->integer) { + if (developer->integer && g_gametype->integer == GT_SINGLE_PLAYER) { Viewmodel.Init(); LODModel.Init(); } @@ -277,6 +295,12 @@ void G_InitGame(int levelTime, int randomSeed) L_InitEvents(); G_AllocGameData(); + + if (g_target_game < TG_MOHTA) { + // Added in OPM + // This frees alias list to avoid filling up memory + gi.GlobalAlias_Clear(); + } } /* @@ -288,8 +312,6 @@ G_SpawnEntities void G_SpawnEntities(char *entities, int svsTime) { level.SpawnEntities(entities, svsTime); - - G_SpawnBots(); } /* @@ -321,7 +343,7 @@ void QDECL Com_Error(int level, const char *error, ...) char text[1024]; va_start(argptr, error); - vsprintf(text, error, argptr); + Q_vsnprintf(text, sizeof(text), error, argptr); va_end(argptr); G_Error("%s", text); @@ -333,7 +355,7 @@ void QDECL Com_Printf(const char *msg, ...) char text[1024]; va_start(argptr, msg); - vsprintf(text, msg, argptr); + Q_vsnprintf(text, sizeof(text), msg, argptr); va_end(argptr); gi.DPrintf("%s", text); @@ -360,7 +382,13 @@ Called when server finished initializating */ void G_ServerSpawned(void) { - level.ServerSpawned(); + try { + level.ServerSpawned(); + + G_BotPostInit(); + } catch (const ScriptException& e) { + G_ExitWithError(e.string.c_str()); + } } /* @@ -426,7 +454,6 @@ void G_RunFrame(int levelTime, int frameTime) qboolean showentnums; unsigned long long start; unsigned long long end; - int i; static int processed[MAX_GENTITIES] = {0}; static int processedFrameID = 0; @@ -456,16 +483,9 @@ void G_RunFrame(int levelTime, int frameTime) if (level.intermissiontime || level.died_already) { L_ProcessPendingEvents(); + G_ClientDoBlends(); - for (i = 0, edict = g_entities; i < game.maxclients; i++, edict++) { - if (!edict->inuse || !edict->client || !edict->entity) { - continue; - } - - edict->entity->CalcBlend(); - } - - if (g_gametype->integer && g_maxintermission->value != 0.0f) { + if (g_gametype->integer != GT_SINGLE_PLAYER && g_maxintermission->value != 0.0f) { if (level.time - level.intermissiontime > g_maxintermission->value) { level.exitintermission = true; } @@ -497,7 +517,7 @@ void G_RunFrame(int levelTime, int frameTime) assert(edict->inuse); assert(edict->entity); - Actor *actor = static_cast(edict->entity); + Actor *actor = static_cast(edict->entity); if (actor->IsSubclassOfActor()) { actor->m_bUpdateAnimDoneFlags = false; if (actor->m_bAnimating) { @@ -546,11 +566,7 @@ void G_RunFrame(int levelTime, int frameTime) start = clock(); } - for (edict = active_edicts.next; edict != &active_edicts; edict = edict->next) { - if (edict->entity->IsSubclassOfBot()) { - G_BotThink(edict, frameTime); - } - } + G_BotFrame(); for (edict = active_edicts.next; edict != &active_edicts; edict = edict->next) { for (num = edict->s.parent; num != ENTITYNUM_NONE; num = g_entities[num].s.parent) { @@ -688,11 +704,13 @@ void G_RunFrame(int levelTime, int frameTime) } } - // - // Added in OPM - // - // Add or delete bots that were added using addbot/removebot - G_SpawnBots(); + if (level.Spawned()) { + // + // Added in OPM + // + // Add or delete bots that were added using addbot/removebot + G_SpawnBots(); + } } catch (const char *error) { @@ -712,7 +730,7 @@ void G_ClientDrawBoundingBoxes(void) Vector eye; // don't show bboxes during deathmatch - if ((!sv_showbboxes->integer) || (g_gametype->integer && !sv_cheats->integer)) { + if ((!sv_showbboxes->integer) || (g_gametype->integer != GT_SINGLE_PLAYER && !sv_cheats->integer)) { return; } @@ -733,27 +751,89 @@ void G_ClientDrawBoundingBoxes(void) /* ================= G_ClientDrawTags + +Added in 2.0. + +This draws tag position and orientation +for entities in a radius of 1000 units. ================= */ void G_ClientDrawTags(void) { - // FIXME: unimplemented + Entity *player; + Entity *ent; + const char *tagName; + Vector origin; + orientation_t ori; + int numTags; + int i; + + if (!sv_showtags->string || !sv_showtags->string[0]) { + return; + } + + if (sv_showtags->string[0] != '*' && !sv_showtags->string[1] && sv_showtags->integer == 0) { + // The variable is defined but set to 0 + return; + } + + if (g_gametype->integer != GT_SINGLE_PLAYER && !sv_cheats->integer) { + return; + } + + player = G_GetEntity(0); + origin = player->origin; + + for (ent = findradius(NULL, origin, 1000); ent; ent = findradius(ent, origin, 1000)) { + if (!ent->edict->tiki) { + continue; + } + + if (ent == player) { + continue; + } + + numTags = gi.TIKI_NumTags(ent->edict->tiki); + for (i = 0; i < numTags; i++) { + tagName = gi.Tag_NameForNum(ent->edict->tiki, i); + + if (Q_stricmp(sv_showtags->string, "*")) { + // + // If it's not a wildcard, check to see if + // the tag name partially matches + // + if (Q_stricmpn(tagName, sv_showtags->string, strlen(sv_showtags->string))) { + continue; + } + } + + ent->GetTagPositionAndOrientation(i, &ori); + + G_DebugString(ori.origin + Vector(0, 0, 8), 1, 1, 1, 0, "%s", tagName); + G_DebugCircle(ori.origin, 10, 1, 1, 1, 1, true); + G_DebugLine(ori.origin, ori.origin + Vector(ori.axis[0]) * 32, 1, 0, 0, 1); + G_DebugLine(ori.origin, ori.origin + Vector(ori.axis[1]) * 32, 0, 1, 0, 1); + G_DebugLine(ori.origin, ori.origin + Vector(ori.axis[2]) * 32, 0, 0, 1, 1); + } + } } // Used to tell the server about the edict pose, such as the player pose // so that G_Trace with tracedeep will set the location void G_UpdatePoseInternal(gentity_t *edict) { - if (edict->s.number == ENTITYNUM_NONE || level.frame_skel_index != level.skel_index[edict->s.number]) { - gi.TIKI_SetPoseInternal( - edict->tiki, - edict->s.number, - edict->s.frameInfo, - edict->s.bone_tag, - edict->s.bone_quat, - edict->s.actionWeight - ); + if (edict->s.number != ENTITYNUM_NONE) { + if (level.skel_index[edict->s.number] == level.frame_skel_index) { + // no need to update + return; + } + + level.skel_index[edict->s.number] = level.frame_skel_index; } + + gi.TIKI_SetPoseInternal( + edict->tiki, edict->s.number, edict->s.frameInfo, edict->s.bone_tag, edict->s.bone_quat, edict->s.actionWeight + ); } orientation_t G_TIKI_Orientation(gentity_t *edict, int num) @@ -781,35 +861,55 @@ qboolean G_TIKI_IsOnGround(gentity_t *edict, int num, float threshold) void G_PrepFrame(void) {} -void G_RegisterSounds(void) +void G_RegisterSoundsForFile(const char *name) { int startTime; int endTime; - Com_Printf("\n\n-----------PARSING UBERSOUND (SERVER)------------\n"); + Com_Printf("\n\n-----------PARSING '%s' (SERVER)------------\n", name); Com_Printf( "Any SetCurrentTiki errors means that tiki wasn't prefetched and tiki-specific sounds for it won't work. To " "fix prefetch the tiki. Ignore if you don't use that tiki on this level.\n" ); startTime = gi.Milliseconds(); - G_Command_ProcessFile("ubersound/ubersound.scr", qfalse); + G_Command_ProcessFile(name, qfalse); endTime = gi.Milliseconds(); Com_Printf("Parse/Load time: %f seconds.\n", (float)(endTime - startTime) / 1000.0); - Com_Printf("-------------UBERSOUND DONE (SERVER)---------------\n\n"); - Com_Printf("\n\n-----------PARSING UBERDIALOG (SERVER)------------\n"); - Com_Printf( - "Any SetCurrentTiki errors means that tiki wasn't prefetched and tiki-specific sounds for it won't work. To " - "fix prefetch the tiki. Ignore if you don't use that tiki on this level.\n" - ); + Com_Printf("-------------PARSING '%s' DONE (SERVER)---------------\n\n", name); +} - startTime = gi.Milliseconds(); - G_Command_ProcessFile("ubersound/uberdialog.scr", qfalse); - endTime = gi.Milliseconds(); +int qsort_compare_strings(const void *s1, const void *s2) +{ + return Q_stricmp(*(const char **)s1, *(const char **)s2); +} - Com_Printf("Parse/Load time: %f seconds.\n", (float)(endTime - startTime) / 1000.0); - Com_Printf("-------------UBERDIALOG DONE (SERVER)---------------\n\n"); +void G_RegisterSounds(void) +{ + char **fileList; + int numFiles; + int i; + + if (g_target_game >= TG_MOHTA) { + gi.GlobalAlias_Clear(); + } else if (!dedicated->integer) { + // In 1.11 and below, the entire ubersound folder is parsed + // only in dedicated mode + return; + } + + fileList = gi.FS_ListFiles("ubersound/", "scr", qfalse, &numFiles); + qsort(fileList, numFiles, sizeof(char *), &qsort_compare_strings); + + for (i = 0; i < numFiles; i++) { + // Added in 2.0 + // Since 2.0, all files in the ubersound folder + // are parsed + G_RegisterSoundsForFile(va("ubersound/%s", fileList[i])); + } + + gi.FS_FreeFileList(fileList); } void G_Restart(void) @@ -818,6 +918,9 @@ void G_Restart(void) // Added in 2.0 G_ResetSmokeSprites(); + + // Added in OPM + G_RestartBots(); } void G_SetFrameNumber(int framenum) @@ -893,6 +996,7 @@ qboolean G_Command_ProcessFile(const char *filename, qboolean quiet) const char *bufstart; const char *token; int numTokens = 0; + char tempName[65]; if (gi.FS_ReadFile(filename, (void **)&buffer, quiet) == -1) { return qfalse; @@ -904,6 +1008,9 @@ qboolean G_Command_ProcessFile(const char *filename, qboolean quiet) bufstart = buffer; + Com_sprintf(tempName, sizeof(tempName), "m%s", filename); + gi.LoadResource(tempName); + while (1) { // grab each line as we go token = COM_ParseExt(&buffer, qtrue); @@ -940,6 +1047,9 @@ qboolean G_Command_ProcessFile(const char *filename, qboolean quiet) gi.FS_FreeFile((void *)bufstart); + Com_sprintf(tempName, sizeof(tempName), "o%s", filename); + gi.LoadResource(tempName); + return qtrue; } @@ -1024,11 +1134,11 @@ void G_ArchivePersistant(const char *name, qboolean loading) arc.ArchiveInteger(&version); if (version < PERSISTANT_VERSION) { - gi.Printf("Persistant data from an older version (%d) of MOHAA.\n", version); + gi.Printf("Persistent data from an older version (%d) of MOHAA.\n", version); arc.Close(); return; } else if (version > PERSISTANT_VERSION) { - gi.DPrintf("Persistant data from newer version %d of MOHAA.\n", version); + gi.DPrintf("Persistent data from newer version %d of MOHAA.\n", version); arc.Close(); return; } @@ -1211,7 +1321,9 @@ G_ArchiveLevel ================= */ -qboolean G_ArchiveLevel(const char *filename, qboolean autosave, qboolean loading) +qboolean G_ArchiveLevel( + const char *filename, byte **savedCgameState, size_t *savedCgameStateSize, qboolean autosave, qboolean loading +) { try { int i; @@ -1255,19 +1367,34 @@ qboolean G_ArchiveLevel(const char *filename, qboolean autosave, qboolean loadin L_ArchiveEvents(arc); } + if (!arc.Saving()) { + arc.ArchiveInteger(&num); + *savedCgameStateSize = num; + + if (*savedCgameStateSize) { + *savedCgameState = (byte *)gi.Malloc(*savedCgameStateSize); + } else { + *savedCgameState = NULL; + } + } else { + num = (int)*savedCgameStateSize; + arc.ArchiveInteger(&num); + } + arc.ArchiveRaw(*savedCgameState, *savedCgameStateSize); + if (arc.Saving()) { str s; num = 0; for (cvar = gi.NextCvar(NULL); cvar != NULL; cvar = gi.NextCvar(cvar)) { - if (cvar->flags & CVAR_ROM) { + if (cvar->flags & CVAR_SAVEGAME) { num++; } } arc.ArchiveInteger(&num); for (cvar = gi.NextCvar(NULL); cvar != NULL; cvar = gi.NextCvar(cvar)) { - if (cvar->flags & CVAR_ROM) { + if (cvar->flags & CVAR_SAVEGAME) { s = cvar->name; arc.ArchiveString(&s); @@ -1318,11 +1445,12 @@ qboolean G_ArchiveLevel(const char *filename, qboolean autosave, qboolean loadin if (arc.Saving()) { // count the entities num = 0; - for (i = 0; i < globals.num_entities; i++) { - edict = &g_entities[i]; - if (edict->inuse && edict->entity && !(edict->entity->flags & FL_DONTSAVE)) { - num++; + for (edict = active_edicts.next; edict != &active_edicts; edict = edict->next) { + if (edict == world->edict || !edict->entity || (edict->entity->flags & FL_DONTSAVE)) { + continue; } + + num++; } } @@ -1334,11 +1462,12 @@ qboolean G_ArchiveLevel(const char *filename, qboolean autosave, qboolean loadin // write out the world arc.ArchiveObject(world); - for (i = 0; i < globals.num_entities; i++) { - edict = &g_entities[i]; - if (edict->inuse && edict->entity && !(edict->entity->flags & FL_DONTSAVE)) { - arc.ArchiveObject(edict->entity); + for (edict = active_edicts.next; edict != &active_edicts; edict = edict->next) { + if (edict == world->edict || !edict->entity || (edict->entity->flags & FL_DONTSAVE)) { + continue; } + + arc.ArchiveObject(edict->entity); } } else { // Tell the server about our data @@ -1357,23 +1486,35 @@ qboolean G_ArchiveLevel(const char *filename, qboolean autosave, qboolean loadin } } + // + // simple archived entities + // + if (!arc.Loading()) { + num = level.m_SimpleArchivedEntities.NumObjects(); + } + arc.ArchiveInteger(&num); + + if (arc.Saving()) { + for (i = 1; i <= num; i++) { + arc.ArchiveObject(level.m_SimpleArchivedEntities.ObjectAt(i)); + } + } else { + for (i = 1; i <= num; i++) { + arc.ReadObject(); + } + } + ArchiveAliases(arc); + // Added in 2.0 + G_ArchiveSmokeSprites(arc); + currentArc = &arc; gi.ArchiveLevel(arc.Loading()); currentArc = NULL; PathSearch::ArchiveDynamic(arc); - if (arc.Loading()) { - arc.Close(); - LoadingSavegame = false; - gi.Printf(HUD_MESSAGE_YELLOW "%s\n", gi.LV_ConvertString("Game Loaded")); - } else { - arc.Close(); - gi.Printf(HUD_MESSAGE_YELLOW "%s\n", gi.LV_ConvertString("Game Saved")); - } - if (arc.Loading()) { // Make sure all code that needs to setup the player after they have been loaded is run @@ -1387,6 +1528,15 @@ qboolean G_ArchiveLevel(const char *filename, qboolean autosave, qboolean loadin } } + if (arc.Loading()) { + arc.Close(); + LoadingSavegame = false; + gi.Printf(HUD_MESSAGE_YELLOW "%s\n", gi.LV_ConvertString("Game Loaded")); + } else { + arc.Close(); + gi.Printf(HUD_MESSAGE_YELLOW "%s\n", gi.LV_ConvertString("Game Saved")); + } + return qtrue; } @@ -1402,10 +1552,10 @@ G_WriteLevel ================= */ -void G_WriteLevel(const char *filename, qboolean autosave) +void G_WriteLevel(const char *filename, qboolean autosave, byte **savedCgameState, size_t *savedCgameStateSize) { game.autosaved = autosave; - G_ArchiveLevel(filename, autosave, qfalse); + G_ArchiveLevel(filename, savedCgameState, savedCgameStateSize, autosave, qfalse); game.autosaved = false; } @@ -1424,11 +1574,11 @@ calling ReadLevel. No clients are connected yet. ================= */ -qboolean G_ReadLevel(const char *filename) +qboolean G_ReadLevel(const char *filename, byte **savedCgameState, size_t *savedCgameStateSize) { qboolean status; - status = G_ArchiveLevel(filename, qfalse, qtrue); + status = G_ArchiveLevel(filename, savedCgameState, savedCgameStateSize, qfalse, qtrue); // if the level load failed make sure that these variables are not set if (!status) { LoadingSavegame = false; @@ -1535,32 +1685,95 @@ void G_ClientEndServerFrames(void) } } -void G_ClientDoBlends() +/* +=============== +G_ClientDoBlends +=============== +*/ +void G_ClientDoBlends(void) { - // FIXME: unimplemented + gentity_t *edict; + int i; + + for (i = 0, edict = g_entities; i < game.maxclients; i++, edict++) { + if (!edict->inuse || !edict->client || !edict->entity) { + continue; + } + + edict->entity->CalcBlend(); + } } -void FindIntermissionPoint() +/* +=============== +FindIntermissionPoint +=============== +*/ +void FindIntermissionPoint(void) { - // FIXME: unimplemented + SimpleEntity *sent; + SimpleEntity *starget; + vec3_t dir; + + sent = static_cast(G_FindClass(NULL, "info_player_intermission")); + if (!sent) { + level.m_intermission_origin = vec_zero; + level.m_intermission_angle = vec_zero; + return; + } + + level.m_intermission_origin = sent->origin; + level.m_intermission_angle = sent->angles; + + if (!sent->target.length()) { + return; + } + + starget = static_cast(G_FindTarget(NULL, sent->Target())); + if (!starget) { + return; + } + + VectorSubtract(starget->origin, level.m_intermission_origin, dir); + vectoangles(dir, level.m_intermission_angle); } +/* +=============== +G_MoveClientToIntermission +=============== +*/ void G_MoveClientToIntermission(Entity *ent) { G_DisplayScores(ent); ent->flags |= FL_IMMOBILE; } +/* +=============== +G_DisplayScores +=============== +*/ void G_DisplayScores(Entity *ent) { ent->client->ps.pm_flags |= PMF_INTERMISSION; } +/* +=============== +G_HideScores +=============== +*/ void G_HideScores(Entity *ent) { ent->client->ps.pm_flags &= ~PMF_INTERMISSION; } +/* +=============== +G_BeginIntermission2 +=============== +*/ void G_BeginIntermission2(void) { gentity_t *client; @@ -1589,13 +1802,15 @@ void G_BeginIntermission2(void) continue; } - ent = client->entity; - - G_DisplayScores(ent); - ent->flags |= FL_IMMOBILE; + G_MoveClientToIntermission(client->entity); } } +/* +=============== +G_BeginIntermission +=============== +*/ void G_BeginIntermission(const char *map_name, INTTYPE_e transtype, bool no_fade) { Entity *camera; @@ -1604,7 +1819,7 @@ void G_BeginIntermission(const char *map_name, INTTYPE_e transtype, bool no_fade gentity_t *client; int i; - if (level.intermissiontime || g_gametype->integer) { + if (level.intermissiontime || g_gametype->integer != GT_SINGLE_PLAYER) { return; } @@ -1643,6 +1858,11 @@ void G_BeginIntermission(const char *map_name, INTTYPE_e transtype, bool no_fade } } +/* +=============== +G_ExitLevel +=============== +*/ void G_ExitLevel(void) { static const char *seps = " ,\n\r"; @@ -1663,13 +1883,13 @@ void G_ExitLevel(void) Com_sprintf(command, sizeof(command), "stopsound\n"); gi.SendConsoleCommand(command); - if (g_gametype->integer) { + if (g_gametype->integer != GT_SINGLE_PLAYER) { if (strlen(sv_nextmap->string)) { // The nextmap cvar was set (possibly by a vote - so go ahead and use it) level.nextmap = sv_nextmap->string; gi.cvar_set("nextmap", ""); - } else // Use the next map in the maplist - { + } else { + // Use the next map in the maplist char *s, *f, *t; f = NULL; @@ -1679,19 +1899,17 @@ void G_ExitLevel(void) if (!Q_stricmp(t, level.mapname.c_str())) { // it's in the list, go to the next one t = strtok(NULL, seps); - if (t == NULL) // end of list, go to first one - { - if (f == NULL) // there isn't a first one, same level - { - level.nextmap = level.mapname; - } else { - level.nextmap = f; - } - } else { + if (t) { level.nextmap = t; + } else if (f) { + // end of list, go to first one + level.nextmap = f; + } else { + // there isn't a first one, same level + level.nextmap = level.mapname; } - free(s); - goto out; + + break; } // set the first map @@ -1702,7 +1920,7 @@ void G_ExitLevel(void) } free(s); } - out: + // level.nextmap should be set now, but if it isn't use the same map if (level.nextmap.length() == 0) { // Stay on the same map since no nextmap was set @@ -1714,10 +1932,10 @@ void G_ExitLevel(void) gi.SendConsoleCommand(command); } else if (!Q_stricmpn(level.nextmap, "vstr", 4)) { // alias on another map - strcpy(command, level.nextmap); + Q_strncpyz(command, level.nextmap, sizeof(command)); gi.SendConsoleCommand(command); - } else // use the level.nextmap variable - { + } else { + // use the level.nextmap variable Com_sprintf(command, sizeof(command), "gamemap \"%s\"\n", level.nextmap.c_str()); gi.SendConsoleCommand(command); } @@ -1744,6 +1962,11 @@ void G_ExitLevel(void) G_ClientEndServerFrames(); } +/* +=============== +G_CheckIntermissionExit +=============== +*/ void G_CheckIntermissionExit(void) { if (!level.exitintermission && g_maxintermission->value > level.time - level.intermissiontime) { @@ -1761,11 +1984,21 @@ void G_CheckIntermissionExit(void) } } +/* +=============== +G_ExitIntermission +=============== +*/ void G_ExitIntermission(void) { level.exitintermission = qtrue; } +/* +=============== +G_CheckStartRules +=============== +*/ void G_CheckStartRules(void) { if ((!dmManager.IsGameActive()) && (!dmManager.WaitingForPlayers())) { @@ -1773,9 +2006,14 @@ void G_CheckStartRules(void) } } +/* +=============== +G_CheckExitRules +=============== +*/ void G_CheckExitRules(void) { - if (g_gametype->integer) { + if (g_gametype->integer != GT_SINGLE_PLAYER) { if (level.intermissiontime == 0.0f) { dmManager.CheckEndMatch(); } else { @@ -1784,6 +2022,11 @@ void G_CheckExitRules(void) } } +/* +=============== +G_DisplayScoresToAllClients +=============== +*/ void G_DisplayScoresToAllClients(void) { gentity_t *ent; @@ -1798,6 +2041,11 @@ void G_DisplayScoresToAllClients(void) } } +/* +=============== +G_HideScoresToAllClients +=============== +*/ void G_HideScoresToAllClients(void) { gentity_t *ent; diff --git a/code/fgame/g_main.h b/code/fgame/g_main.h index 1c31728d..7f57e781 100644 --- a/code/fgame/g_main.h +++ b/code/fgame/g_main.h @@ -22,8 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // // g_main.h -- Global header file for g_main.cpp -#ifndef __G_MAIN_H__ -#define __G_MAIN_H__ +#pragma once #include "g_local.h" #include "gamecvars.h" @@ -55,5 +54,3 @@ void G_AllocGameData(void); void G_DeAllocGameData(void); void G_ClientDrawBoundingBoxes(void); void G_ClientDrawTags(void); - -#endif /* g_main.h */ diff --git a/code/fgame/g_mmove.cpp b/code/fgame/g_mmove.cpp index 9bdcdb90..785324c4 100644 --- a/code/fgame/g_mmove.cpp +++ b/code/fgame/g_mmove.cpp @@ -49,8 +49,8 @@ void MM_ClipVelocity(float *in, float *normal, float *out, float overbounce) return; } - normal2[0] = in[0] + DotProduct2D(in, normal); - normal2[1] = in[1] + DotProduct2D(in, normal); + normal2[0] = in[0] * DotProduct2D(in, normal); + normal2[1] = in[1] * DotProduct2D(in, normal); normal2[2] = normal[2] * DotProduct2D(in, in); VectorNormalize(normal2); @@ -211,6 +211,8 @@ qboolean MM_SlideMove(qboolean gravity) // // modify velocity so it parallels all of the clip planes // + VectorCopy(trace.plane.normal, planes[numplanes]); + numplanes++; // find a plane that it enters for (i = 0; i < numplanes; i++) { @@ -227,10 +229,14 @@ qboolean MM_SlideMove(qboolean gravity) continue; } - // slide along the plane - MM_ClipVelocity(mm->velocity, planes[j], clipVelocity, OVERCLIP); + if (DotProduct(clipVelocity, planes[j]) >= 0.1) { + continue; // move doesn't interact with the plane + } - if (DotProduct(clipVelocity, planes[j]) >= 0.0f) { + // slide along the plane + MM_ClipVelocity(clipVelocity, planes[j], clipVelocity, OVERCLIP); + + if (DotProduct(clipVelocity, planes[i]) >= 0) { continue; // move doesn't interact with the plane } @@ -246,7 +252,7 @@ qboolean MM_SlideMove(qboolean gravity) continue; } - if (DotProduct(clipVelocity, planes[k]) >= 0.1f) { + if (DotProduct(clipVelocity, planes[k]) >= 0.1) { continue; // move doesn't interact with the plane } @@ -359,6 +365,7 @@ void MM_StepSlideMove(void) vec3_t start_hit_origin; vec3_t first_hit_origin; trace_t nostep_groundTrace; + qboolean nostep_validGroundTrace; VectorCopy(mm->origin, start_o); VectorCopy(mm->velocity, start_v); @@ -398,12 +405,17 @@ void MM_StepSlideMove(void) bWasOnGoodGround = qfalse; } - start_o[2] += 18; + VectorCopy(start_o, up); + up[2] += 18; + VectorCopy(mm->origin, nostep_o); VectorCopy(mm->velocity, nostep_v); memcpy(&nostep_groundTrace, &mml.groundTrace, sizeof(trace_t)); + // Fixed in OPM + // Save the valid ground trace + nostep_validGroundTrace = mml.validGroundTrace; - VectorCopy(start_o, mm->origin); + VectorCopy(up, mm->origin); VectorCopy(start_v, mm->velocity); first_hit_wall = mm->hit_obstacle; @@ -419,11 +431,15 @@ void MM_StepSlideMove(void) down[2] -= STEPSIZE * 2; // test the player position if they were a stepheight higher - gi.trace(&trace, start_o, mm->mins, mm->maxs, down, mm->entityNum, mm->tracemask, qtrue, qfalse); + gi.trace(&trace, mm->origin, mm->mins, mm->maxs, down, mm->entityNum, mm->tracemask, qtrue, qfalse); if (trace.entityNum != ENTITYNUM_WORLD && trace.entityNum != ENTITYNUM_NONE) { VectorCopy(nostep_o, mm->origin); VectorCopy(nostep_v, mm->velocity); memcpy(&mml.groundTrace, &nostep_groundTrace, sizeof(mml.groundTrace)); + // Fixed in OPM + // Do not use the ground trace as it's invalid and would have an invalid entity number + mml.validGroundTrace = nostep_validGroundTrace; + mm->hit_obstacle = first_hit_wall; VectorCopy(first_hit_origin, mm->hit_origin); VectorCopy(first_wall_normal, mm->obstacle_normal); @@ -481,8 +497,8 @@ void MM_ClipVelocity2D(float *in, float *normal, float *out, float overbounce) return; } - normal2[0] = in[0] + DotProduct2D(in, normal); - normal2[1] = in[1] + DotProduct2D(in, normal); + normal2[0] = in[0] * DotProduct2D(in, normal); + normal2[1] = in[1] * DotProduct2D(in, normal); normal2[2] = normal[2] * DotProduct2D(in, in); VectorNormalize(normal2); diff --git a/code/fgame/g_phys.cpp b/code/fgame/g_phys.cpp index af01704d..3ca3115c 100644 --- a/code/fgame/g_phys.cpp +++ b/code/fgame/g_phys.cpp @@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "sentient.h" #include "actor.h" #include "player.h" +#include "debuglines.h" /* @@ -47,7 +48,7 @@ solid_edge items only clip against bsp models. */ -pushed_t pushed[ MAX_GENTITIES ]; +pushed_t pushed[MAX_GENTITIES]; pushed_t *pushed_p; Entity *obstacle; @@ -58,123 +59,101 @@ G_FixEntityPosition ============ */ -Entity *G_FixEntityPosition - ( - Entity *ent - ) +Entity *G_FixEntityPosition(Entity *ent) { - int mask; - trace_t trace; - Vector start; - float radius; + int mask; + trace_t trace; + Vector start; + float radius; - if( ent->size.x > ent->size.z ) - { - radius = ent->size.z * 0.5f; - } - else - { - radius = ent->size.x * 0.5f; - } + if (ent->size.x > ent->size.z) { + radius = ent->size.z * 0.5f; + } else { + radius = ent->size.x * 0.5f; + } - mask = ent->edict->clipmask; - if( !mask ) - { - mask = MASK_SOLID; - } + mask = ent->edict->clipmask; + if (!mask) { + mask = MASK_SOLID; + } - start = ent->origin; - start.z += radius; - if( ent->IsSubclassOfPlayer() ) - { - trace = G_Trace( start, ent->mins, ent->maxs, ent->origin, ent, mask, true, "G_FixEntityPosition1" ); - } - else - { - trace = G_Trace( start, ent->mins, ent->maxs, ent->origin, ent, mask, false, "G_FixEntityPosition2" ); - } + start = ent->origin; + start.z += radius; + if (ent->IsSubclassOfSentient()) { + trace = G_Trace(start, ent->mins, ent->maxs, ent->origin, ent, mask, true, "G_FixEntityPosition1"); + } else { + trace = G_Trace(start, ent->mins, ent->maxs, ent->origin, ent, mask, false, "G_FixEntityPosition2"); + } - if( trace.startsolid ) - { - //return g_entities->entity; - assert( trace.ent ); - assert( trace.ent->entity ); - return trace.ent->entity; - } + if (trace.startsolid) { + if (!trace.ent) { + // Fixed in OPM + // I don't understand why they just prefer the game crashing + // rather than ignoring the entity + return NULL; + } + //assert( trace.ent ); + //assert( trace.ent->entity ); + return trace.ent->entity; + } - ent->setOrigin( trace.endpos ); + ent->setOrigin(trace.endpos); - return NULL; + return NULL; } - /* ============ G_TestEntityPosition ============ */ -Entity *G_TestEntityPosition - ( - Entity *ent - ) +Entity *G_TestEntityPosition(Entity *ent) { - int mask; - trace_t trace; + int mask; + trace_t trace; - mask = ent->edict->clipmask; - if( !mask ) - mask = MASK_SOLID; + mask = ent->edict->clipmask; + if (!mask) { + mask = MASK_SOLID; + } - if( ent->IsSubclassOfPlayer() ) - { - trace = G_Trace( ent->origin, ent->mins, ent->maxs, ent->origin, ent, mask, true, "G_TestEntityPosition1" ); - } - else - { - trace = G_Trace( ent->origin, ent->mins, ent->maxs, ent->origin, ent, mask, false, "G_TestEntityPosition2" ); - } + if (ent->IsSubclassOfPlayer()) { + trace = G_Trace(ent->origin, ent->mins, ent->maxs, ent->origin, ent, mask, true, "G_TestEntityPosition1"); + } else { + trace = G_Trace(ent->origin, ent->mins, ent->maxs, ent->origin, ent, mask, false, "G_TestEntityPosition2"); + } - if( trace.startsolid ) - { - //return g_entities->entity; - assert( trace.ent ); - assert( trace.ent->entity ); - return trace.ent->entity; - } + if (trace.startsolid) { + //return g_entities->entity; + assert(trace.ent); + assert(trace.ent->entity); + return trace.ent->entity; + } - return NULL; + return NULL; } - /* ================ G_CheckVelocity ================ */ -void G_CheckVelocity - ( - Entity *ent - ) +void G_CheckVelocity(Entity *ent) +{ + int i; - { - int i; - - // - // bound velocity - // - for( i = 0; i < 3; i++ ) - { - if ( ent->velocity[ i ] > sv_maxvelocity->value ) - { - ent->velocity[ i ] = sv_maxvelocity->value; - } - else if ( ent->velocity[ i ] < -sv_maxvelocity->value ) - { - ent->velocity[ i ] = -sv_maxvelocity->value; - } - } - } + // + // bound velocity + // + for (i = 0; i < 3; i++) { + if (ent->velocity[i] > sv_maxvelocity->value) { + ent->velocity[i] = sv_maxvelocity->value; + } else if (ent->velocity[i] < -sv_maxvelocity->value) { + ent->velocity[i] = -sv_maxvelocity->value; + } + } +} /* ================== @@ -183,54 +162,30 @@ G_Impact Two entities have touched, so run their touch functions ================== */ -void G_Impact - ( - Entity *e1, - trace_t *trace - ) +void G_Impact(Entity *e1, trace_t *trace) { - gentity_t *e2; - Event *ev; - SafePtr< Entity > safe1; - SafePtr< Entity > safe2; + gentity_t *e2; + Event *ev; - e2 = trace->ent; + e2 = trace->ent; - safe1 = e1; - safe2 = e2->entity; + level.impact_trace = *trace; - level.impact_trace = *trace; + // touch anything, including the world + if (e1->edict->solid != SOLID_NOT) { + ev = new Event(EV_Touch); + ev->AddEntity(e2->entity); + e1->ProcessEvent(ev); + } - // touch anything, including the world - if( e1->edict->solid != SOLID_NOT ) - { - ev = new Event( EV_Touch ); - ev->AddEntity( e2->entity ); - e1->ProcessEvent( ev ); + // entity could have been removed, so check if he's in use before sending the event + if (e2->entity && (e2->solid != SOLID_NOT) && (!(e2->r.contents & CONTENTS_SHOOTONLY)) && (e2->entity != world)) { + ev = new Event(EV_Touch); + ev->AddEntity(e1); + e2->entity->ProcessEvent(ev); + } - if( safe1 ) { - safe1->Unregister( "touch" ); - } - } - - // entity could have been removed, so check if he's in use before sending the event - if( - e2->entity && - ( e2->solid != SOLID_NOT ) && - ( !( e2->r.contents & CONTENTS_SHOOTONLY ) ) && - ( e2->entity != world ) - ) - { - ev = new Event( EV_Touch ); - ev->AddEntity( e1 ); - e2->entity->ProcessEvent( ev ); - - if( safe2 ) { - safe2->Unregister( "touch" ); - } - } - - memset( &level.impact_trace, 0, sizeof( level.impact_trace ) ); + memset(&level.impact_trace, 0, sizeof(level.impact_trace)); } /* @@ -239,36 +194,29 @@ G_TestEntityPosition ============ */ -Entity *G_TestEntityPosition - ( - Entity *ent, - Vector vOrg - ) +Entity *G_TestEntityPosition(Entity *ent, Vector vOrg) { - int mask; - trace_t trace; + int mask; + trace_t trace; - mask = ent->edict->clipmask; - if( !mask ) - mask = MASK_SOLID; + mask = ent->edict->clipmask; + if (!mask) { + mask = MASK_SOLID; + } - if( ent->IsSubclassOfSentient() ) - { - trace = G_Trace( vOrg, ent->mins, ent->maxs, vOrg, ent, mask, true, "G_TestEntityPosition1" ); - } - else - { - trace = G_Trace( vOrg, ent->mins, ent->maxs, vOrg, ent, mask, false, "G_TestEntityPosition2" ); - } + if (ent->IsSubclassOfSentient()) { + trace = G_Trace(vOrg, ent->mins, ent->maxs, vOrg, ent, mask, true, "G_TestEntityPosition1"); + } else { + trace = G_Trace(vOrg, ent->mins, ent->maxs, vOrg, ent, mask, false, "G_TestEntityPosition2"); + } - if( trace.startsolid ) - { - assert( trace.ent ); - assert( trace.ent->entity ); - return trace.ent->entity; - } + if (trace.startsolid) { + assert(trace.ent); + assert(trace.ent->entity); + return trace.ent->entity; + } - return NULL; + return NULL; } /* @@ -281,46 +229,34 @@ returns the blocked flags (1 = floor, 2 = step / wall) */ #define STOP_EPSILON 0.1 -int G_ClipVelocity - ( - Vector& in, - Vector& normal, - Vector& out, - float overbounce - ) +int G_ClipVelocity(Vector& in, Vector& normal, Vector& out, float overbounce) +{ + int i; + int blocked; + float backoff; - { - int i; - int blocked; - float backoff; + blocked = 0; - blocked = 0; + if (normal[2] > 0) { + // floor + blocked |= 1; + } + if (!normal[2]) { + // step + blocked |= 2; + } - if ( normal[ 2 ] > 0 ) - { - // floor - blocked |= 1; - } - if ( !normal[ 2 ] ) - { - // step - blocked |= 2; - } + backoff = (in * normal) * overbounce; - backoff = ( in * normal ) * overbounce; - - out = in - normal * backoff; - for( i = 0; i < 3; i++ ) - { - if ( out[ i ] > -STOP_EPSILON && out[ i ] < STOP_EPSILON ) - { - out[ i ] = 0; - } - } - - return blocked; - } + out = in - normal * backoff; + for (i = 0; i < 3; i++) { + if (out[i] > -STOP_EPSILON && out[i] < STOP_EPSILON) { + out[i] = 0; + } + } + return blocked; +} /* ============ @@ -335,218 +271,179 @@ Returns the clipflags if the velocity was modified (hit something solid) */ #define MAX_CLIP_PLANES 5 -int G_FlyMove - ( - Entity *ent, - Vector basevel, - float time, - int mask - ) +int G_FlyMove(Entity *ent, Vector basevel, float time, int mask) { - Entity *hit; - gentity_t *edict; - int bumpcount, numbumps; - Vector dir; - float d; - int numplanes; - vec3_t planes[ MAX_CLIP_PLANES ]; - Vector primal_velocity, original_velocity, new_velocity; - int i, j; - trace_t trace; - Vector end; - float time_left; - int blocked; + Entity *hit; + gentity_t *edict; + int bumpcount, numbumps; + Vector dir; + float d; + int numplanes; + vec3_t planes[MAX_CLIP_PLANES]; + Vector primal_velocity, original_velocity, new_velocity; + int i, j; + trace_t trace; + Vector end; + float time_left; + int blocked; #if 0 Vector move; Vector v; #endif - edict = ent->edict; + edict = ent->edict; - numbumps = 4; + numbumps = 4; - blocked = 0; - original_velocity = ent->velocity; - primal_velocity = ent->velocity; - numplanes = 0; + blocked = 0; + original_velocity = ent->velocity; + primal_velocity = ent->velocity; + numplanes = 0; #if 1 - time_left = time; + time_left = time; #else - time_left = 1.0;//time; + time_left = 1.0; //time; - v = ent->total_delta; - v[ 1 ] = -v[ 1 ]; // sigh... - MatrixTransformVector( v, ent->orientation, move ); - move += ent->velocity * time; - ent->total_delta = vec_zero; + v = ent->total_delta; + v[1] = -v[1]; // sigh... + MatrixTransformVector(v, ent->orientation, move); + move += ent->velocity * time; + ent->total_delta = vec_zero; #endif - ent->groundentity = NULL; - for( bumpcount = 0; bumpcount < numbumps; bumpcount++ ) - { + ent->groundentity = NULL; + for (bumpcount = 0; bumpcount < numbumps; bumpcount++) { #if 1 - end = ent->origin + time_left * ( ent->velocity + basevel ); + end = ent->origin + time_left * (ent->velocity + basevel); #else - end = ent->origin + time_left * move; + end = ent->origin + time_left * move; #endif - trace = G_Trace( ent->origin, ent->mins, ent->maxs, end, ent, mask, false, "G_FlyMove" ); + trace = G_Trace(ent->origin, ent->mins, ent->maxs, end, ent, mask, false, "G_FlyMove"); - if( - ( trace.allsolid ) || - ( - ( trace.startsolid ) && - ( ent->movetype == MOVETYPE_VEHICLE ) - ) - ) - { - // entity is trapped in another solid - ent->velocity = vec_zero; - return 3; - } + if ((trace.allsolid) || ((trace.startsolid) && (ent->movetype == MOVETYPE_VEHICLE))) { + // entity is trapped in another solid + ent->velocity = vec_zero; + return 3; + } - if( trace.fraction > 0 ) - { - // actually covered some distance - ent->setOrigin( trace.endpos ); - original_velocity = ent->velocity; - numplanes = 0; - } + if (trace.fraction > 0) { + // actually covered some distance + ent->setOrigin(trace.endpos); + original_velocity = ent->velocity; + numplanes = 0; + } - if( trace.fraction == 1 ) - { - // moved the entire distance - break; - } + if (trace.fraction == 1) { + // moved the entire distance + break; + } - assert( trace.ent ); - hit = trace.ent->entity; + assert(trace.ent); + hit = trace.ent->entity; - if( trace.plane.normal[ 2 ] > 0.7 ) - { - // floor - blocked |= 1; - if( hit->getSolidType() == SOLID_BSP ) - { - ent->groundentity = hit->edict; - ent->groundplane = trace.plane; - ent->groundcontents = trace.contents; - } - } + if (trace.plane.normal[2] > 0.7) { + // floor + blocked |= 1; + if (hit->getSolidType() == SOLID_BSP) { + ent->groundentity = hit->edict; + ent->groundplane = trace.plane; + ent->groundcontents = trace.contents; + } + } - if( !trace.plane.normal[ 2 ] ) - { - // step - blocked |= 2; - } + if (!trace.plane.normal[2]) { + // step + blocked |= 2; + } - // - // run the impact function - // - G_Impact( ent, &trace ); - if( !edict->inuse ) - { - break; // removed by the impact function - } + // + // run the impact function + // + G_Impact(ent, &trace); + if (!edict->inuse) { + break; // removed by the impact function + } - time_left -= time_left * trace.fraction; + time_left -= time_left * trace.fraction; - // cliped to another plane - if( numplanes >= MAX_CLIP_PLANES ) - { - // this shouldn't really happen - ent->velocity = vec_zero; - return 3; - } + // cliped to another plane + if (numplanes >= MAX_CLIP_PLANES) { + // this shouldn't really happen + ent->velocity = vec_zero; + return 3; + } - VectorCopy( trace.plane.normal, planes[ numplanes ] ); - numplanes++; + VectorCopy(trace.plane.normal, planes[numplanes]); + numplanes++; - // - // modify original_velocity so it parallels all of the clip planes - // - for( i = 0; i < numplanes; i++ ) - { - Vector normal = planes[ i ]; + // + // modify original_velocity so it parallels all of the clip planes + // + for (i = 0; i < numplanes; i++) { + Vector normal = planes[i]; - G_ClipVelocity( original_velocity, normal, new_velocity, 1.01f ); - for( j = 0; j < numplanes; j++ ) - { - if( j != i ) - { - if( ( new_velocity * planes[ j ] ) < 0 ) - { - // not ok - break; - } - } - } + G_ClipVelocity(original_velocity, normal, new_velocity, 1.01f); + for (j = 0; j < numplanes; j++) { + if (j != i) { + if ((new_velocity * planes[j]) < 0) { + // not ok + break; + } + } + } - if( j == numplanes ) - { - break; - } - } + if (j == numplanes) { + break; + } + } - if( i != numplanes ) - { - // go along this plane - ent->velocity = new_velocity; - } - else - { - // go along the crease - if( numplanes != 2 ) - { - ent->velocity = vec_zero; - return 7; - } - CrossProduct( planes[ 0 ], planes[ 1 ], dir ); - d = dir * ent->velocity; - ent->velocity = dir * d; - } + if (i != numplanes) { + // go along this plane + ent->velocity = new_velocity; + } else { + // go along the crease + if (numplanes != 2) { + ent->velocity = vec_zero; + return 7; + } + CrossProduct(planes[0], planes[1], dir); + d = dir * ent->velocity; + ent->velocity = dir * d; + } - // - // if original velocity is against the original velocity, stop dead - // to avoid tiny occilations in sloping corners - // - if( ( ent->velocity * primal_velocity ) <= 0 ) - { - ent->velocity = vec_zero; - return blocked; - } - } + // + // if original velocity is against the original velocity, stop dead + // to avoid tiny occilations in sloping corners + // + if ((ent->velocity * primal_velocity) <= 0) { + ent->velocity = vec_zero; + return blocked; + } + } - return blocked; + return blocked; } - /* ============ G_AddGravity ============ */ -void G_AddGravity - ( - Entity *ent - ) +void G_AddGravity(Entity *ent) +{ + float grav; - { - float grav; + if (ent->waterlevel > 2) { + grav = ent->gravity * 60 * level.frametime; + } else { + grav = ent->gravity * sv_gravity->value * level.frametime; + } - if ( ent->waterlevel > 2 ) - { - grav = ent->gravity * 60 * level.frametime; - } - else - { - grav = ent->gravity * sv_gravity->value * level.frametime; - } - - ent->velocity[ 2 ] -= grav; - } + ent->velocity[2] -= grav; +} /* =============================================================================== @@ -563,59 +460,48 @@ G_PushEntity Does not change the entities velocity at all ============ */ -trace_t G_PushEntity - ( - Entity *ent, - Vector push - ) +trace_t G_PushEntity(Entity *ent, Vector push) { - trace_t trace; - Vector start; - Vector end; - int mask; - gentity_t *edict; + trace_t trace; + Vector start; + Vector end; + int mask; + gentity_t *edict; - start = ent->origin; - end = start + push; + start = ent->origin; + end = start + push; retry: - if( ent->edict->clipmask ) - { - mask = ent->edict->clipmask; - } - else - { - mask = MASK_SOLID; - } + if (ent->edict->clipmask) { + mask = ent->edict->clipmask; + } else { + mask = MASK_SOLID; + } - trace = G_Trace( start, ent->mins, ent->maxs, end, ent, mask, true, "G_PushEntity" ); + trace = G_Trace(start, ent->mins, ent->maxs, end, ent, mask, true, "G_PushEntity"); - edict = ent->edict; + edict = ent->edict; - ent->setOrigin( trace.endpos ); + ent->setOrigin(trace.endpos); - if( trace.fraction != 1.0 ) - { - G_Impact( ent, &trace ); + if (trace.fraction != 1.0) { + G_Impact(ent, &trace); - // if the pushed entity went away and the pusher is still there - if( ( !trace.ent || !trace.ent->inuse ) && edict->inuse ) - { - // move the pusher back and try again - ent->setOrigin( start ); - goto retry; - } - } + // if the pushed entity went away and the pusher is still there + if ((!trace.ent || !trace.ent->inuse) && edict->inuse) { + // move the pusher back and try again + ent->setOrigin(start); + goto retry; + } + } - if( edict && ( edict != ent->edict ) ) - { - if( ent->flags & FL_TOUCH_TRIGGERS ) - { - G_TouchTriggers( ent ); - } - } + if (edict && (edict != ent->edict)) { + if (ent->flags & FL_TOUCH_TRIGGERS) { + G_TouchTriggers(ent); + } + } - return trace; + return trace; } /* @@ -623,37 +509,28 @@ retry: G_SlideEntity ============ */ -trace_t G_SlideEntity - ( - Entity *ent, - Vector push - ) +trace_t G_SlideEntity(Entity *ent, Vector push) +{ + trace_t trace; + Vector start; + Vector end; + int mask; - { - trace_t trace; - Vector start; - Vector end; - int mask; + start = ent->origin; + end = start + push; - start = ent->origin; - end = start + push; + if (ent->edict->clipmask) { + mask = ent->edict->clipmask; + } else { + mask = MASK_SOLID; + } - if ( ent->edict->clipmask ) - { - mask = ent->edict->clipmask; - } - else - { - mask = MASK_SOLID; - } + trace = G_Trace(start, ent->mins, ent->maxs, end, ent, mask, false, "G_SlideEntity"); - trace = G_Trace( start, ent->mins, ent->maxs, end, ent, mask, false, "G_SlideEntity" ); - - ent->setOrigin( trace.endpos ); - - return trace; - } + ent->setOrigin(trace.endpos); + return trace; +} /* ================ @@ -709,185 +586,157 @@ Objects need to be moved back on a failed push, otherwise riders would continue to slide. ============ */ -qboolean G_Push - ( - Entity *pusher, - Vector pushermove, - Vector pusheramove - ) +qboolean G_Push(Entity *pusher, Vector pushermove, Vector pusheramove) +{ + Entity *check, *block; + gentity_t *edict; + Vector move, amove; + Vector mins, maxs; + Vector save; + pushed_t *p; + Vector org, org2, move2, neworg; + Vector norm; + float mat[3][3]; + pushed_t *pusher_p; + float radius; + int i, num; + int j; + int touch[MAX_GENTITIES]; + Event *ev; - { - Entity *check, *block; - gentity_t *edict; - Vector move, amove; - Vector mins, maxs; - Vector save; - pushed_t *p; - Vector org, org2, move2, neworg; - Vector norm; - float mat[ 3 ][ 3 ]; - pushed_t *pusher_p; - float radius; - int i, num; - int touch[ MAX_GENTITIES ]; - Event *ev; + // save the pusher's original position + pusher_p = pushed_p; + pushed_p->ent = pusher; + pushed_p->localorigin = pusher->localorigin; + pushed_p->origin = pusher->origin; + pushed_p->localangles = pusher->localangles; + pushed_p->angles = pusher->angles; - // save the pusher's original position - pusher_p = pushed_p; - pushed_p->ent = pusher; - pushed_p->localorigin = pusher->localorigin; - pushed_p->origin = pusher->origin; - pushed_p->localangles = pusher->localangles; - pushed_p->angles = pusher->angles; + if (pusher->client) { + pushed_p->deltayaw = pusher->client->ps.delta_angles[YAW]; + } - if( pusher->client ) - { - pushed_p->deltayaw = pusher->client->ps.delta_angles[ YAW ]; - } + pushed_p++; - pushed_p++; + if (pushed_p >= &pushed[MAX_GENTITIES]) { + gi.Error(ERR_FATAL, "Pushed too many entities."); + } - if( pushed_p >= &pushed[ MAX_GENTITIES ] ) - { - gi.Error( ERR_FATAL, "Pushed too many entities." ); - } + if (pusher->IsSubclassOfPlayer()) { + pusher->setAngles(); + pusher->setOrigin(); + } else { + // move the pusher to it's final position + pusher->addAngles(pusheramove); + pusher->addOrigin(pushermove); + } - if( pusher->IsSubclassOfPlayer() ) - { - pusher->setAngles(); - pusher->setOrigin(); - } - else - { - // move the pusher to it's final position - pusher->addAngles( pusheramove ); - pusher->addOrigin( pushermove ); - } + if (pusher->edict->solid == SOLID_NOT) { + // Doesn't push anything + return true; + } + // change the move to worldspace + move = pusher->origin - pusher_p->origin; + amove = pusher->angles - pusher_p->angles; - if( pusher->edict->solid == SOLID_NOT ) - { - // Doesn't push anything - return true; - } + // we need this for pushing things later + AnglesToAxis(amove, mat); - // change the move to worldspace - move = pusher->origin - pusher_p->origin; - amove = pusher->angles - pusher_p->angles; + // find the bounding box + mins = pusher->absmin; + maxs = pusher->absmax; - // we need this for pushing things later - AnglesToAxis( amove, mat ); + // Add in entities that are within the pusher - // find the bounding box - mins = pusher->absmin; - maxs = pusher->absmax; + num = gi.AreaEntities(mins, maxs, touch, MAX_GENTITIES); - // Add in entities that are within the pusher + for (i = 0; i < num; i++) { + edict = &g_entities[touch[i]]; + assert(edict); + assert(edict->inuse); + assert(edict->entity); + check = edict->entity; - num = gi.AreaEntities( mins, maxs, touch, MAX_GENTITIES ); + if ((check->movetype == MOVETYPE_PUSH) || (check->movetype == MOVETYPE_STOP) + || (check->movetype == MOVETYPE_NONE) || (check->movetype == MOVETYPE_NOCLIP)) { + continue; + } - for( i = 0; i < num; i++ ) - { - edict = &g_entities[ touch[ i ] ]; - assert( edict ); - assert( edict->inuse ); - assert( edict->entity ); - check = edict->entity; + if (check->edict->r.contents == CONTENTS_SHOOTONLY) { + continue; + } - if( ( check->movetype == MOVETYPE_PUSH ) || - ( check->movetype == MOVETYPE_STOP ) || - ( check->movetype == MOVETYPE_NONE ) || - ( check->movetype == MOVETYPE_NOCLIP ) ) - { - continue; - } + // if the entity is standing on the pusher, it will definitely be moved + if (check->groundentity != pusher->edict) { + // Only move triggers and non-solid objects if they're sitting on a moving object + if ((check->edict->solid == SOLID_TRIGGER) || (check->edict->solid == SOLID_NOT)) { + continue; + } - if( check->edict->r.contents == CONTENTS_SHOOTONLY ) - continue; + // see if the ent needs to be tested + if ((check->absmin[0] >= maxs[0]) || (check->absmin[1] >= maxs[1]) || (check->absmin[2] >= maxs[2]) + || (check->absmax[0] <= mins[0]) || (check->absmax[1] <= mins[1]) || (check->absmax[2] <= mins[2])) { + continue; + } - // if the entity is standing on the pusher, it will definitely be moved - if( check->groundentity != pusher->edict ) - { - // Only move triggers and non-solid objects if they're sitting on a moving object - if( ( check->edict->solid == SOLID_TRIGGER ) || ( check->edict->solid == SOLID_NOT ) ) - { - continue; - } + // see if the ent's bbox is inside the pusher's final position + if (!G_TestEntityPosition(check, check->origin)) { + continue; + } - // see if the ent needs to be tested - if( ( check->absmin[ 0 ] >= maxs[ 0 ] ) || - ( check->absmin[ 1 ] >= maxs[ 1 ] ) || - ( check->absmin[ 2 ] >= maxs[ 2 ] ) || - ( check->absmax[ 0 ] <= mins[ 0 ] ) || - ( check->absmax[ 1 ] <= mins[ 1 ] ) || - ( check->absmax[ 2 ] <= mins[ 2 ] ) ) - { - continue; - } + ev = new Event(EV_Touch); + ev->AddEntity(pusher); + check->ProcessEvent(ev); - // see if the ent's bbox is inside the pusher's final position - if( !G_TestEntityPosition( check, check->origin ) ) - { - continue; - } + ev = new Event(EV_Touch); + ev->AddEntity(check); + pusher->ProcessEvent(ev); + } - ev = new Event( EV_Touch ); - ev->AddEntity( pusher ); - check->ProcessEvent( ev ); + pushed_p->localorigin = check->localorigin; + pushed_p->localangles = check->localangles; + // move this entity + pushed_p->ent = check; + pushed_p->origin = check->origin; + pushed_p->angles = check->angles; + pushed_p++; - ev = new Event( EV_Touch ); - ev->AddEntity( check ); - pusher->ProcessEvent( ev ); - } + if (pushed_p >= &pushed[MAX_GENTITIES]) { + gi.Error(ERR_FATAL, "Pushed too many entities."); + } - pushed_p->localorigin = check->localorigin; - pushed_p->localangles = check->localangles; - // move this entity - pushed_p->ent = check; - pushed_p->origin = check->origin; - pushed_p->angles = check->angles; - pushed_p++; + // save off the origin + save = check->localorigin; - if( pushed_p >= &pushed[ MAX_GENTITIES ] ) - { - gi.Error( ERR_FATAL, "Pushed too many entities." ); - } + // try moving the contacted entity + move2 = move; - // save off the origin - save = check->localorigin; + // FIXME: doesn't rotate monsters? + if (check->client && amove[YAW]) { + Sentient *sent = (Sentient *)check; + Vector a = sent->GetViewAngles() + Vector(0, amove[YAW], 0); + sent->SetViewAngles(a); + } - // try moving the contacted entity - move2 = move; + // get the radius of the entity + if (check->size.x > check->size.z) { + radius = check->size.z * 0.5f; + } else { + radius = check->size.x * 0.5f; + } - // FIXME: doesn't rotate monsters? - /*if( check->client && amove[ YAW ] ) - { - Sentient *sent = ( Sentient * )check; - Vector a = sent->GetViewAngles() + Vector( 0, amove[ YAW ], 0 ); - sent->SetViewAngles( a ); - }*/ + // figure movement due to the pusher's amove + org = check->origin - pusher->origin; + org.z += radius; - // get the radius of the entity - if( check->size.x > check->size.z ) - { - radius = check->size.z * 0.5f; - } - else - { - radius = check->size.x * 0.5f; - } + MatrixTransformVector(org, mat, org2); - // figure movement due to the pusher's amove - org = check->origin - pusher->origin; - org.z += radius; + move2 += org2 - org; - MatrixTransformVector( org, mat, org2 ); + neworg = move2 + check->origin; - move2 += org2 - org; - - neworg = move2 + check->origin; - - /* + /* // This one seems to be better for the bind command if( G_TestEntityPosition( check, check->origin ) ) { @@ -906,66 +755,96 @@ qboolean G_Push } */ - if( G_TestEntityPosition( check, neworg ) ) - { - trace_t trace; - Vector end; - Vector fwd; - float length; + if (G_TestEntityPosition(check, neworg)) { + trace_t trace; + Vector end; + Vector fwd; + float length; - length = VectorNormalize2( move2, fwd ); + length = VectorNormalize2(move2, fwd); - end = check->origin + fwd * ( length + 64.0f ); + end = check->origin + fwd * (length + 64.0f); - if( check->IsSubclassOfPlayer() ) - { - trace = G_Trace( check->origin, check->mins, check->maxs, end, check, check->edict->clipmask, true, "G_Push" ); - } - else - { - trace = G_Trace( check->origin, check->mins, check->maxs, end, check, check->edict->clipmask, false, "G_Push" ); - } + if (check->IsSubclassOfSentient()) { + trace = G_Trace( + check->origin, check->mins, check->maxs, end, check, check->edict->clipmask, true, "G_Push" + ); + } else { + trace = G_Trace( + check->origin, check->mins, check->maxs, end, check, check->edict->clipmask, false, "G_Push" + ); + } - if( !trace.allsolid ) - { - if( check->IsSubclassOfPlayer() ) - { - trace = G_Trace( Vector( trace.endpos ), check->mins, check->maxs, neworg, check, check->edict->clipmask, true, "G_Push" ); - } - else - { - trace = G_Trace( Vector( trace.endpos ), check->mins, check->maxs, neworg, check, check->edict->clipmask, false, "G_Push" ); - } + if (!trace.allsolid) { + if (check->IsSubclassOfSentient()) { + trace = G_Trace( + Vector(trace.endpos), + check->mins, + check->maxs, + neworg, + check, + check->edict->clipmask, + true, + "G_Push" + ); + } else { + trace = G_Trace( + Vector(trace.endpos), + check->mins, + check->maxs, + neworg, + check, + check->edict->clipmask, + false, + "G_Push" + ); + } - move2 = trace.endpos - check->origin; - } - } + move2 = trace.endpos - check->origin; + } + } - check->addOrigin( check->getParentVector( move2 ) ); + check->addOrigin(check->getParentVector(move2)); - // may have pushed them off an edge - if( check->groundentity ) - { - if( check->groundentity != pusher->edict ) - check->groundentity = NULL; - } + // may have pushed them off an edge + if (check->groundentity) { + if (check->groundentity != pusher->edict) { + check->groundentity = NULL; + } + } else { + move2 *= 1.f / level.frametime; - block = G_TestEntityPosition( check, check->origin ); - if( block ) - { - block = G_FixEntityPosition( check ); - } - if( !block ) - { - // pushed ok - check->link(); + for (j = 0; j < 3; j++) { + if (!move2[j]) { + continue; + } - // impact? - continue; - } + if (move2[j] < 0) { + if (check->velocity[j] > move2[j]) { + check->velocity[j] = move2[j]; + } + } else { + if (check->velocity[j] < move2[j]) { + check->velocity[j] = move2[j]; + } + } + } + } - // try to snap it to a good position - /* + block = G_TestEntityPosition(check, check->origin); + if (block) { + block = G_FixEntityPosition(check); + } + if (!block) { + // pushed ok + check->link(); + + // impact? + continue; + } + + // try to snap it to a good position + /* if ( G_SnapPosition( check ) ) { // snapped ok. we don't have to link since G_SnapPosition does it for us. @@ -973,67 +852,55 @@ qboolean G_Push } */ - // if it is ok to leave in the old position, do it - // this is only relevent for riding entities, not pushed - check->setLocalOrigin( save ); - block = G_TestEntityPosition( check, check->origin ); - if( !block ) - { - pushed_p--; - continue; - } + // if it is ok to leave in the old position, do it + // this is only relevent for riding entities, not pushed + check->setLocalOrigin(save); + block = G_TestEntityPosition(check, check->origin); + if (!block) { + pushed_p--; + continue; + } - if( check->edict->solid == SOLID_NOT ) - continue; + if (check->edict->solid == SOLID_NOT) { + continue; + } - // L: don't make the pusher teleport through anything that block - if( block != pusher ) - { - pusher_p->ent->setOrigin( pusher_p->origin ); - continue; - } + // save off the obstacle so we can call the block function + obstacle = check; - // save off the obstacle so we can call the block function - obstacle = check; + // move back any entities we already moved + // go backwards, so if the same entity was pushed + // twice, it goes back to the original position + for (p = pushed_p - 1; p >= pushed; p--) { + p->ent->angles = p->angles; + p->ent->origin = p->origin; - // move back any entities we already moved - // go backwards, so if the same entity was pushed - // twice, it goes back to the original position - for( p = pushed_p - 1; p >= pushed; p-- ) - { - p->ent->angles = p->angles; - p->ent->origin = p->origin; + p->ent->localangles = p->localangles; + p->ent->localorigin = p->localorigin; - p->ent->localangles = p->localangles; - p->ent->localorigin = p->localorigin; + if (p->ent->client) { + p->ent->client->ps.delta_angles[YAW] = (int)p->deltayaw; + } + } - if( p->ent->client ) - { - p->ent->client->ps.delta_angles[ YAW ] = ( int )p->deltayaw; - } - } + // Only "really" move it in order so that the bound coordinate system is correct + for (p = pushed; p < pushed_p; p++) { + p->ent->setAngles(); + p->ent->setOrigin(); + } - // Only "really" move it in order so that the bound coordinate system is correct - for( p = pushed; p < pushed_p; p++ ) - { - p->ent->setAngles(); - p->ent->setOrigin(); - } + return false; + } - return false; - } + //FIXME: is there a better way to handle this? + // see if anything we moved has touched a trigger + for (p = pushed_p - 1; p >= pushed; p--) { + if (p->ent->flags & FL_TOUCH_TRIGGERS) { + G_TouchTriggers(p->ent); + } + } - //FIXME: is there a better way to handle this? - // see if anything we moved has touched a trigger - for( p = pushed_p - 1; p >= pushed; p-- ) - { - if( p->ent->flags & FL_TOUCH_TRIGGERS ) - { - G_TouchTriggers( p->ent ); - } - } - - return true; + return true; } /* @@ -1041,39 +908,37 @@ qboolean G_Push G_PushMove ================ */ -qboolean G_PushMove( Entity *ent, Vector move, Vector amove ) +qboolean G_PushMove(Entity *ent, Vector move, Vector amove) { - Entity *part; - Vector m, a; - Event *ev; + Entity *part; + Vector m, a; + Event *ev; - m = move; - a = amove; + m = move; + a = amove; - pushed_p = pushed; + pushed_p = pushed; - part = ent; + part = ent; - while( part ) - { - if( !G_Push( part, m, a ) ) - { - // move was blocked - // call the pusher's "blocked" function - // otherwise, just stay in place until the obstacle is gone - ev = new Event( EV_Blocked ); - ev->AddEntity( obstacle ); - part->ProcessEvent( ev ); - return false; - } + while (part) { + if (!G_Push(part, m, a)) { + // move was blocked + // call the pusher's "blocked" function + // otherwise, just stay in place until the obstacle is gone + ev = new Event(EV_Blocked); + ev->AddEntity(obstacle); + part->ProcessEvent(ev); + return false; + } - m = vec_zero; - a = vec_zero; + m = vec_zero; + a = vec_zero; - part = part->teamchain; - } + part = part->teamchain; + } - return true; + return true; } /* @@ -1084,65 +949,55 @@ Bmodel objects don't interact with each other, but push all box objects ================ */ -void G_Physics_Pusher - ( - Entity *ent - ) +void G_Physics_Pusher(Entity *ent) { - Vector move, amove; - Entity *part, *mv; - Event *ev; + Vector move, amove; + Entity *part, *mv; + Event *ev; - // team slaves are only moved by their captains - if( ent->flags & FL_TEAMSLAVE ) - { - return; - } + // team slaves are only moved by their captains + if (ent->flags & FL_TEAMSLAVE) { + return; + } - // Check if anyone on the team is moving - for( part = ent; part; part = part->teamchain ) - { - if( part->velocity != vec_zero || part->avelocity != vec_zero ) - { - break; - } - } + // Check if anyone on the team is moving + for (part = ent; part; part = part->teamchain) { + if (part->velocity != vec_zero || part->avelocity != vec_zero) { + break; + } + } - // make sure all team slaves can move before commiting - // any moves or calling any think functions - // if the move is blocked, all moved objects will be backed out - pushed_p = pushed; - while( part ) - { - move = part->velocity * level.frametime; - amove = part->avelocity * level.frametime; + // make sure all team slaves can move before commiting + // any moves or calling any think functions + // if the move is blocked, all moved objects will be backed out + pushed_p = pushed; + while (part) { + move = part->velocity * level.frametime; + amove = part->avelocity * level.frametime; - if( !G_Push( part, move, amove ) ) - { - // move was blocked - break; - } + if (!G_Push(part, move, amove)) { + // move was blocked + break; + } - part = part->teamchain; - } + part = part->teamchain; + } - if( part ) - { - // the move failed, bump all movedone times - for( mv = ent; mv; mv = mv->teamchain ) - { - mv->PostponeEvent( EV_MoveDone, FRAMETIME ); - } + if (part) { + // the move failed, bump all movedone times + for (mv = ent; mv; mv = mv->teamchain) { + mv->PostponeEvent(EV_MoveDone, FRAMETIME); + } - // if the pusher has a "blocked" function, call it - // otherwise, just stay in place until the obstacle is gone - ev = new Event( EV_Blocked ); - ev->AddEntity( obstacle ); - part->ProcessEvent( ev ); - } + // if the pusher has a "blocked" function, call it + // otherwise, just stay in place until the obstacle is gone + ev = new Event(EV_Blocked); + ev->AddEntity(obstacle); + part->ProcessEvent(ev); + } - ent->velocity += ent->accel; - ent->avelocity += ent->aaccel; + ent->velocity += ent->accel; + ent->avelocity += ent->aaccel; } //================================================================== @@ -1154,16 +1009,12 @@ G_Physics_Noclip A moving object that doesn't obey physics ============= */ -void G_Physics_Noclip - ( - Entity *ent - ) - - { - ent->angles += ent->avelocity * level.frametime; - ent->origin += ent->velocity * level.frametime; - ent->link(); - } +void G_Physics_Noclip(Entity *ent) +{ + ent->angles += ent->avelocity * level.frametime; + ent->origin += ent->velocity * level.frametime; + ent->link(); +} /* ============================================================================== @@ -1180,190 +1031,172 @@ G_Physics_Toss Toss, bounce, and fly movement. When onground, do nothing. ============= */ -void G_Physics_Toss - ( - Entity *ent - ) +void G_Physics_Toss(Entity *ent) { - trace_t trace; - Vector move; - float backoff; - Entity *slave; - qboolean wasinwater; - qboolean isinwater; - Vector origin2; - Vector basevel; - gentity_t *edict; - qboolean onconveyor; + trace_t trace; + Vector move; + float backoff; + Entity *slave; + qboolean wasinwater; + qboolean isinwater; + Vector origin2; + Vector basevel; + gentity_t *edict; + qboolean onconveyor; - // if not a team captain, so movement will be handled elsewhere - if( ent->flags & FL_TEAMSLAVE ) - { - return; - } + // if not a team captain, so movement will be handled elsewhere + if (ent->flags & FL_TEAMSLAVE) { + return; + } - if( ent->velocity[ 2 ] > 0 ) - { - ent->groundentity = NULL; - } + if (ent->velocity[2] > 0) { + ent->groundentity = NULL; + } - // check for the groundentity going away - if( ent->groundentity && !ent->groundentity->inuse ) - { - ent->groundentity = NULL; - } + // check for the groundentity going away + if (ent->groundentity && !ent->groundentity->inuse) { + ent->groundentity = NULL; + } - onconveyor = ( basevel != vec_zero ); + onconveyor = (basevel != vec_zero); - // if onground, return without moving - if( ent->groundentity && ent->groundentity->entity->movetype == MOVETYPE_NONE && !onconveyor && ( ent->movetype != MOVETYPE_VEHICLE ) ) - { - if( ent->avelocity.length() ) - { - // move angles - ent->setAngles( ent->angles + ent->avelocity * level.frametime ); - } - ent->velocity = vec_zero; - return; - } + // if onground, return without moving + if (ent->groundentity && ent->groundentity->entity->movetype == MOVETYPE_NONE && !onconveyor + && (ent->movetype != MOVETYPE_VEHICLE)) { + if (ent->avelocity.length()) { + // move angles + ent->setAngles(ent->angles + ent->avelocity * level.frametime); + } + ent->velocity = vec_zero; + return; + } - origin2 = ent->origin; + origin2 = ent->origin; - G_CheckVelocity( ent ); + G_CheckVelocity(ent); - // add gravity - if( !onconveyor && ent->movetype != MOVETYPE_FLY && ent->movetype != MOVETYPE_FLYMISSILE ) - { - G_AddGravity( ent ); - } + // add gravity + if (!onconveyor && ent->movetype != MOVETYPE_FLY && ent->movetype != MOVETYPE_FLYMISSILE) { + G_AddGravity(ent); + } - // move angles - ent->setAngles( ent->angles + ent->avelocity * level.frametime ); + if (ent->avelocity.lengthSquared()) { + // move angles + ent->setAngles(ent->angles + ent->avelocity * level.frametime); + } - // move origin - move = ( ent->velocity + basevel ) * level.frametime; + // move origin + move = (ent->velocity + basevel) * level.frametime; - edict = ent->edict; - if( ent->movetype == MOVETYPE_VEHICLE ) - { - int mask; + edict = ent->edict; + if (ent->movetype == MOVETYPE_VEHICLE) { + int mask; - if( ent->edict->clipmask ) - { - mask = ent->edict->clipmask; - } - else - { - mask = MASK_MONSTERSOLID; - } - G_FlyMove( ent, basevel, FRAMETIME, mask ); - if( ent->flags & FL_TOUCH_TRIGGERS ) - { - G_TouchTriggers( ent ); - } - return; - } - else - { - trace = G_PushEntity( ent, move ); - } + if (ent->edict->clipmask) { + mask = ent->edict->clipmask; + } else { + mask = MASK_MONSTERSOLID; + } + G_FlyMove(ent, basevel, FRAMETIME, mask); + if (ent->flags & FL_TOUCH_TRIGGERS) { + G_TouchTriggers(ent); + } + return; + } else { + trace = G_PushEntity(ent, move); + } - if( ( trace.fraction == 0 ) && ( ent->movetype == MOVETYPE_SLIDE ) ) - { - // Check for slide by removing the downward velocity - Vector slide; + if ((trace.fraction == 0) && (ent->movetype == MOVETYPE_SLIDE || ent->movetype == MOVETYPE_BOUNCE)) { + // Check for slide by removing the downward velocity + Vector slide; - slide[ 0 ] = move[ 0 ] * 0.7f; - slide[ 1 ] = move[ 1 ] * 0.7f; - slide[ 2 ] = 0; - G_PushEntity( ent, slide ); - } + slide[0] = move[0] * level.frametime * 15; + slide[1] = move[1] * level.frametime * 15; + slide[2] = 0; + G_PushEntity(ent, slide); + } - if( !edict->inuse ) - { - return; - } + if (!edict->inuse) { + return; + } - if( trace.fraction < 1 ) - { - if( ent->movetype == MOVETYPE_BOUNCE || ent->movetype == MOVETYPE_GIB ) - { - backoff = 1.5; - } - else - { - backoff = 1; - } + if (trace.fraction < 1) { + if (ent->movetype == MOVETYPE_BOUNCE) { + backoff = 1.4f; + } else if (ent->movetype == MOVETYPE_GIB) { + backoff = 1.6f; + } else { + backoff = 1; + } - Vector normal = trace.plane.normal; + Vector normal = trace.plane.normal; - G_ClipVelocity( ent->velocity, normal, ent->velocity, backoff ); + G_ClipVelocity(ent->velocity, normal, ent->velocity, backoff); - // stop if on ground - if( trace.plane.normal[ 2 ] > 0.7 ) - { - if( ( ent->velocity[ 2 ] < 60 || ( ent->movetype != MOVETYPE_BOUNCE && ent->movetype != MOVETYPE_GIB ) ) && - ( ent->movetype != MOVETYPE_SLIDE ) ) - { - ent->groundentity = trace.ent; - ent->groundplane = trace.plane; - ent->groundcontents = trace.contents; - ent->velocity = vec_zero; - ent->avelocity = vec_zero; - ent->ProcessEvent( EV_Stop ); - } - else if( ent->movetype == MOVETYPE_GIB ) - { - // Stop spinning after we bounce on the ground - ent->avelocity = vec_zero; - } - } - } + if (ent->movetype == MOVETYPE_BOUNCE) { + // Reduce the velocity when bouncing + ent->velocity[0] -= ent->velocity[0] * level.frametime * 1.75f; + ent->velocity[1] -= ent->velocity[1] * level.frametime * 1.75f; + } - if( ( move[ 2 ] == 0 ) && onconveyor ) - { - // Check if we still have a ground - ent->CheckGround(); - } + // stop if on ground + if (trace.plane.normal[2] > 0.7) { + ent->groundentity = trace.ent; + ent->groundplane = trace.plane; + ent->groundcontents = trace.contents; - // check for water transition - wasinwater = ( ent->watertype & MASK_WATER ); - ent->watertype = gi.pointcontents( ent->origin, 0 ); - isinwater = ent->watertype & MASK_WATER; + if (((ent->movetype == MOVETYPE_GIB && ent->velocity[2] < 60) + || (ent->movetype == MOVETYPE_BOUNCE && ent->velocity.length() < 40)) + && (ent->movetype != MOVETYPE_SLIDE)) { + ent->velocity = vec_zero; + ent->avelocity = vec_zero; + ent->ProcessEvent(EV_Stop); + } else if (ent->movetype == MOVETYPE_TOSS || ent->movetype == MOVETYPE_GIB) { + // Stop spinning after we bounce on the ground + ent->avelocity = vec_zero; + ent->ProcessEvent(EV_Stop); + } + } + } - if( isinwater ) - { - ent->waterlevel = 1; - } - else - { - ent->waterlevel = 0; - } + if ((move[2] == 0) && onconveyor) { + // Check if we still have a ground + ent->CheckGround(); + } - if( ( edict->spawntime < ( level.time - FRAMETIME ) ) && ( ent->mass > 0 ) ) - { - if( !wasinwater && isinwater ) - { - ent->Sound( "impact_watersplash", CHAN_BODY, DEFAULT_VOL, DEFAULT_MIN_DIST, &origin2 ); - } - else if( wasinwater && !isinwater ) - { - ent->Sound( "impact_leavewater", CHAN_BODY, DEFAULT_VOL, DEFAULT_MIN_DIST, &origin2 ); - } - } + // check for water transition + wasinwater = (ent->watertype & MASK_WATER); + ent->watertype = gi.pointcontents(ent->origin, 0); + isinwater = ent->watertype & MASK_WATER; - // GAMEFIX - Is this necessary? - // move teamslaves - for( slave = ent->teamchain; slave; slave = slave->teamchain ) - { - slave->setLocalOrigin( slave->localorigin ); - slave->setAngles( slave->localangles ); - } + if (isinwater) { + ent->waterlevel = 1; + } else { + ent->waterlevel = 0; + } - if( ent->flags & FL_TOUCH_TRIGGERS ) - { - G_TouchTriggers( ent ); - } + if ((edict->spawntime < (level.time - FRAMETIME)) && (ent->mass > 0)) { + if (!wasinwater && isinwater) { + ent->Sound("impact_watersplash", CHAN_BODY, DEFAULT_VOL, DEFAULT_MIN_DIST, &origin2); + } else if (wasinwater && !isinwater) { + ent->Sound("impact_leavewater", CHAN_BODY, DEFAULT_VOL, DEFAULT_MIN_DIST, &origin2); + } + } + + // GAMEFIX - Is this necessary? + // move teamslaves + for (slave = ent->teamchain; slave; slave = slave->teamchain) { + slave->setLocalOrigin(slave->localorigin); + slave->setAngles(slave->localangles); + } + + if (ent->flags & FL_TOUCH_TRIGGERS) { + G_TouchTriggers(ent); + } + + if (ai_debug_grenades->integer && ent->movetype == MOVETYPE_BOUNCE) { + G_DebugLine(origin2, ent->origin, 1, 1, 0, 1); + } } /* @@ -1374,37 +1207,27 @@ STEPPING MOVEMENT =============================================================================== */ -void G_AddRotationalFriction - ( - Entity *ent - ) +void G_AddRotationalFriction(Entity *ent) +{ + int n; + float adjustment; - { - int n; - float adjustment; - - ent->angles += level.frametime * ent->avelocity; - adjustment = level.frametime * sv_stopspeed->value * sv_friction->value; - for( n = 0; n < 3; n++ ) - { - if ( ent->avelocity[ n ] > 0) - { - ent->avelocity[ n ] -= adjustment; - if ( ent->avelocity[ n ] < 0 ) - { - ent->avelocity[ n ] = 0; - } - } - else - { - ent->avelocity[ n ] += adjustment; - if ( ent->avelocity[ n ] > 0 ) - { - ent->avelocity[ n ] = 0; - } - } - } - } + ent->angles += level.frametime * ent->avelocity; + adjustment = level.frametime * sv_stopspeed->value * sv_friction->value; + for (n = 0; n < 3; n++) { + if (ent->avelocity[n] > 0) { + ent->avelocity[n] -= adjustment; + if (ent->avelocity[n] < 0) { + ent->avelocity[n] = 0; + } + } else { + ent->avelocity[n] += adjustment; + if (ent->avelocity[n] > 0) { + ent->avelocity[n] = 0; + } + } + } +} /* ============= @@ -1413,21 +1236,14 @@ G_CheckWater ============= */ -void G_CheckWater - ( - Entity *ent - ) +void G_CheckWater(Entity *ent) { - ent->watertype = gi.pointcontents( ent->origin, 0 ); - if( ent->watertype & MASK_WATER ) - { - ent->waterlevel = 1; - } - else - { - ent->waterlevel = 0; - } - + ent->watertype = gi.pointcontents(ent->origin, 0); + if (ent->watertype & MASK_WATER) { + ent->waterlevel = 1; + } else { + ent->waterlevel = 0; + } } /* @@ -1443,146 +1259,121 @@ FIXME: is this true? ============= */ -void G_Physics_Step - ( - Entity *ent - ) +void G_Physics_Step(Entity *ent) +{ + qboolean wasonground; + qboolean hitsound = false; + Vector vel; + float speed, newspeed, control; + float friction; + int mask; + Vector basevel; - { - qboolean wasonground; - qboolean hitsound = false; - Vector vel; - float speed, newspeed, control; - float friction; - int mask; - Vector basevel; + // airborn monsters should always check for ground + if (!ent->groundentity) { + ent->CheckGround(); + } - // airborn monsters should always check for ground - if ( !ent->groundentity ) - { - ent->CheckGround(); - } + if (ent->groundentity) { + wasonground = true; + } else { + wasonground = false; + } - if ( ent->groundentity ) - { - wasonground = true; - } - else - { - wasonground = false; - } + G_CheckVelocity(ent); - G_CheckVelocity( ent ); + if (ent->avelocity != vec_zero) { + G_AddRotationalFriction(ent); + } - if ( ent->avelocity != vec_zero ) - { - G_AddRotationalFriction( ent ); - } + // add gravity except: + // flying monsters + // swimming monsters who are in the water + if (!wasonground) { + if (!(ent->flags & FL_FLY)) { + if (!((ent->flags & FL_SWIM) && (ent->waterlevel > 2))) { + if (ent->velocity[2] < sv_gravity->value * ent->gravity * -0.1f) { + hitsound = true; + } - // add gravity except: - // flying monsters - // swimming monsters who are in the water - if ( !wasonground ) - { - if( !( ent->flags & FL_FLY ) ) - { - if( !( ( ent->flags & FL_SWIM ) && ( ent->waterlevel > 2 ) ) ) - { - if ( ent->velocity[ 2 ] < sv_gravity->value * ent->gravity * -0.1f ) - { - hitsound = true; - } + // Testing water gravity. If this doesn't work, just restore the uncommented lines + //if ( ent->waterlevel == 0 ) + //{ + G_AddGravity(ent); + //} + } + } + } - // Testing water gravity. If this doesn't work, just restore the uncommented lines - //if ( ent->waterlevel == 0 ) - //{ - G_AddGravity( ent ); - //} - } - } - } + // friction for flying monsters that have been given vertical velocity + if ((ent->flags & FL_FLY) && (ent->velocity.z != 0)) { + speed = fabs(ent->velocity.z); + control = speed < sv_stopspeed->value ? sv_stopspeed->value : speed; + friction = sv_friction->value / 3; + newspeed = speed - (level.frametime * control * friction); + if (newspeed < 0) { + newspeed = 0; + } + newspeed /= speed; + ent->velocity.z *= newspeed; + } - // friction for flying monsters that have been given vertical velocity - if( ( ent->flags & FL_FLY ) && ( ent->velocity.z != 0 ) ) - { - speed = fabs( ent->velocity.z ); - control = speed < sv_stopspeed->value ? sv_stopspeed->value : speed; - friction = sv_friction->value / 3; - newspeed = speed - ( level.frametime * control * friction ); - if ( newspeed < 0 ) - { - newspeed = 0; - } - newspeed /= speed; - ent->velocity.z *= newspeed; - } + // friction for flying monsters that have been given vertical velocity + if ((ent->flags & FL_SWIM) && (ent->velocity.z != 0)) { + speed = fabs(ent->velocity.z); + control = speed < sv_stopspeed->value ? sv_stopspeed->value : speed; + newspeed = speed - (level.frametime * control * sv_waterfriction->value * ent->waterlevel); + if (newspeed < 0) { + newspeed = 0; + } + newspeed /= speed; + ent->velocity.z *= newspeed; + } - // friction for flying monsters that have been given vertical velocity - if( ( ent->flags & FL_SWIM ) && ( ent->velocity.z != 0 ) ) - { - speed = fabs( ent->velocity.z ); - control = speed < sv_stopspeed->value ? sv_stopspeed->value : speed; - newspeed = speed - ( level.frametime * control * sv_waterfriction->value * ent->waterlevel ); - if ( newspeed < 0 ) - { - newspeed = 0; - } - newspeed /= speed; - ent->velocity.z *= newspeed; - } + if (ent->velocity != vec_zero) { + // apply friction + // let dead monsters who aren't completely onground slide + if ((wasonground) || (ent->flags & (FL_SWIM | FL_FLY))) { + if (!(ent->health <= 0.0 && !M_CheckBottom(ent))) { + vel = ent->velocity; + vel.z = 0; + speed = vel.length(); + if (speed) { + friction = sv_friction->value; - if ( ent->velocity != vec_zero ) - { - // apply friction - // let dead monsters who aren't completely onground slide - if( ( wasonground ) || ( ent->flags & ( FL_SWIM | FL_FLY ) ) ) - { - if ( !( ent->health <= 0.0 && !M_CheckBottom( ent ) ) ) - { - vel = ent->velocity; - vel.z = 0; - speed = vel.length(); - if ( speed ) - { - friction = sv_friction->value; + control = speed < sv_stopspeed->value ? sv_stopspeed->value : speed; + newspeed = speed - level.frametime * control * friction; - control = speed < sv_stopspeed->value ? sv_stopspeed->value : speed; - newspeed = speed - level.frametime * control * friction; + if (newspeed < 0) { + newspeed = 0; + } - if ( newspeed < 0 ) - { - newspeed = 0; - } + newspeed /= speed; - newspeed /= speed; + ent->velocity.x *= newspeed; + ent->velocity.y *= newspeed; + } + } + } + } - ent->velocity.x *= newspeed; - ent->velocity.y *= newspeed; - } - } - } - } + if ((basevel != vec_zero) || (ent->velocity != vec_zero)) { + mask = MASK_SOLID; - if ( ( basevel != vec_zero ) || ( ent->velocity != vec_zero ) ) - { - mask = MASK_SOLID; + G_FlyMove(ent, basevel, level.frametime, mask); - G_FlyMove( ent, basevel, level.frametime, mask ); + ent->link(); - ent->link(); + G_CheckWater(ent); + if (ent->flags & FL_TOUCH_TRIGGERS) { + G_TouchTriggers(ent); + } - G_CheckWater( ent ); - if( ent->flags & FL_TOUCH_TRIGGERS ) - { - G_TouchTriggers( ent ); - } - - if ( ent->groundentity && !wasonground && hitsound ) - { - ent->Sound( "impact_softland", CHAN_BODY, 0.5f ); - } - } - } + if (ent->groundentity && !wasonground && hitsound) { + ent->Sound("impact_softland", CHAN_BODY, 0.5f); + } + } +} //============================================================================ @@ -1592,68 +1383,60 @@ G_RunEntity ================ */ -void G_RunEntity( Entity *ent ) +void G_RunEntity(Entity *ent) { - gentity_t *edict; + gentity_t *edict; - edict = ent->edict; + edict = ent->edict; - if( !edict->inuse ) - { - return; - } + if (!edict->inuse) { + return; + } - if( ent->flags & FL_ANIMATE ) - { - ent->PreAnimate(); - } + if (ent->flags & FL_ANIMATE) { + ent->PreAnimate(); + } - if( ent->flags & FL_THINK ) - { - ent->Think(); - } + if (ent->flags & FL_THINK) { + ent->Think(); + } - if( ent->flags & FL_ANIMATE ) - { - ent->PostAnimate(); - } + if (ent->flags & FL_ANIMATE) { + ent->PostAnimate(); + } - // only run physics if in use and not bound and not immobilized - if( ( edict->s.parent == ENTITYNUM_NONE ) && !( ent->flags & FL_IMMOBILE ) && !( ent->flags & FL_PARTIAL_IMMOBILE ) ) - { - switch( ent->movetype ) - { - case MOVETYPE_NONE: - case MOVETYPE_STATIONARY: - case MOVETYPE_WALK: - case MOVETYPE_FLYMISSILE: - case MOVETYPE_SLIDE: - case MOVETYPE_GIB: - case MOVETYPE_VEHICLE: - case MOVETYPE_TURRET: - break; - case MOVETYPE_PUSH: - case MOVETYPE_STOP: - G_Physics_Pusher( ent ); - break; - case MOVETYPE_NOCLIP: - G_Physics_Noclip( ent ); - break; - case MOVETYPE_FLY: - G_FlyMove( ent, ent->velocity, level.frametime, MASK_LINE ); - break; - case MOVETYPE_TOSS: - case MOVETYPE_BOUNCE: - G_Physics_Toss( ent ); - break; - default: - gi.Error( ERR_DROP, "G_Physics: bad movetype %i", ent->movetype ); - } - } + // only run physics if in use and not bound and not immobilized + if ((edict->s.parent == ENTITYNUM_NONE) && !(ent->flags & FL_IMMOBILE) && !(ent->flags & FL_PARTIAL_IMMOBILE)) { + switch (ent->movetype) { + case MOVETYPE_NONE: + case MOVETYPE_STATIONARY: + case MOVETYPE_WALK: + case MOVETYPE_FLYMISSILE: + case MOVETYPE_SLIDE: + case MOVETYPE_GIB: + case MOVETYPE_VEHICLE: + case MOVETYPE_TURRET: + break; + case MOVETYPE_PUSH: + case MOVETYPE_STOP: + G_Physics_Pusher(ent); + break; + case MOVETYPE_NOCLIP: + G_Physics_Noclip(ent); + break; + case MOVETYPE_FLY: + G_FlyMove(ent, ent->velocity, level.frametime, MASK_LINE); + break; + case MOVETYPE_TOSS: + case MOVETYPE_BOUNCE: + G_Physics_Toss(ent); + break; + default: + gi.Error(ERR_DROP, "G_Physics: bad movetype %i", ent->movetype); + } + } - if( ent->flags & FL_POSTTHINK ) - { - ent->Postthink(); - } + if (ent->flags & FL_POSTTHINK) { + ent->Postthink(); + } } - diff --git a/code/fgame/g_phys.h b/code/fgame/g_phys.h index 6690ff68..64dc5f2f 100644 --- a/code/fgame/g_phys.h +++ b/code/fgame/g_phys.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2008 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -22,62 +22,56 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // g_phys.h: Header for g_phys.cpp -#ifndef __G_PHYS_H__ -#define __G_PHYS_H__ +#pragma once #include "g_local.h" #include "vector.h" class Entity; -typedef enum -{ - STEPMOVE_OK, - STEPMOVE_BLOCKED_BY_ENTITY, - STEPMOVE_BLOCKED_BY_WORLD, - STEPMOVE_BLOCKED_BY_WATER, - STEPMOVE_BLOCKED_BY_FALL, - STEPMOVE_BLOCKED_BY_DOOR, - STEPMOVE_STUCK +typedef enum { + STEPMOVE_OK, + STEPMOVE_BLOCKED_BY_ENTITY, + STEPMOVE_BLOCKED_BY_WORLD, + STEPMOVE_BLOCKED_BY_WATER, + STEPMOVE_BLOCKED_BY_FALL, + STEPMOVE_BLOCKED_BY_DOOR, + STEPMOVE_STUCK } stepmoveresult_t; // movetype values -typedef enum -{ - MOVETYPE_NONE, // never moves - MOVETYPE_STATIONARY, // never moves but does collide agains push objects - MOVETYPE_NOCLIP, // origin and angles change with no interaction - MOVETYPE_PUSH, // no clip to world, push on box contact - MOVETYPE_STOP, // no clip to world, stops on box contact - MOVETYPE_WALK, // gravity - MOVETYPE_FLY, - MOVETYPE_TOSS, // gravity - MOVETYPE_FLYMISSILE, // extra size to monsters - MOVETYPE_BOUNCE, - MOVETYPE_SLIDE, - MOVETYPE_GIB, - MOVETYPE_VEHICLE, - MOVETYPE_TURRET, - MOVETYPE_PORTABLE_TURRET +typedef enum { + MOVETYPE_NONE, // never moves + MOVETYPE_STATIONARY, // never moves but does collide agains push objects + MOVETYPE_NOCLIP, // origin and angles change with no interaction + MOVETYPE_PUSH, // no clip to world, push on box contact + MOVETYPE_STOP, // no clip to world, stops on box contact + MOVETYPE_WALK, // gravity + MOVETYPE_FLY, + MOVETYPE_TOSS, // gravity + MOVETYPE_FLYMISSILE, // extra size to monsters + MOVETYPE_BOUNCE, + MOVETYPE_SLIDE, + MOVETYPE_GIB, + MOVETYPE_VEHICLE, + MOVETYPE_TURRET, + MOVETYPE_PORTABLE_TURRET } movetype_t; -typedef struct -{ - Entity *ent; - Vector localorigin; - Vector origin; - Vector localangles; - Vector angles; - float deltayaw; +typedef struct { + Entity *ent; + Vector localorigin; + Vector origin; + Vector localangles; + Vector angles; + float deltayaw; } pushed_t; -extern pushed_t pushed[]; +extern pushed_t pushed[]; extern pushed_t *pushed_p; -void G_RunEntity( Entity *ent ); -void G_Impact( Entity *e1, trace_t *trace ); -qboolean G_PushMove( Entity *pusher, Vector move, Vector amove ); -void G_CheckWater( Entity *ent ); -Entity *G_TestEntityPosition( Entity *ent, Vector vOrg ); - -#endif /* g_phys.h */ +void G_RunEntity(Entity *ent); +void G_Impact(Entity *e1, trace_t *trace); +qboolean G_PushMove(Entity *pusher, Vector move, Vector amove); +void G_CheckWater(Entity *ent); +Entity *G_TestEntityPosition(Entity *ent, Vector vOrg); diff --git a/code/fgame/g_public.h b/code/fgame/g_public.h index 31a7b373..e4f235d3 100644 --- a/code/fgame/g_public.h +++ b/code/fgame/g_public.h @@ -36,29 +36,28 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // the server does not know how to interpret most of the values // in entityStates (level eType), so the game must explicitly flag // special server behaviors -#define SVF_NOCLIENT 0x00000001 // don't send entity to clients, even if it has effects +#define SVF_NOCLIENT (1<<0) // don't send entity to clients, even if it has effects +#define SVF_BOT (1<<1) +#define SVF_BROADCAST (1<<2) // send to all connected clients +#define SVF_PORTAL (1<<3) // merge a second pvs at origin2 into snapshots +#define SVF_SENDPVS (1<<4) // even though it doesn't have a sound or modelindex, still run it through the pvs +#define SVF_USE_CURRENT_ORIGIN (1<<5) // entity->currentOrigin instead of entity->s.origin + // for link position (missiles and movers) +#define SVF_NOTSINGLECLIENT (1<<6) // send entity to everyone but one client + // (entityShared_t->singleClient) +#define SVF_MONSTER (1<<7) // treat as CONTENTS_MONSTER for collision +#define SVF_SINGLECLIENT (1<<8) // only send to a single client (entityShared_t->singleClient) +#define SVF_USEBBOX (1<<9) // do not perform perfect collision use the bbox instead +#define SVF_NOFARPLANE (1<<10) // only send this entity to its parent +#define SVF_HIDEOWNER (1<<11) // hide the owner of the client +#define SVF_MONSTERCLIP (1<<12) // treat as CONTENTS_MONSTERCLIP for collision +#define SVF_PLAYERCLIP (1<<13) // treat as CONTENTS_PLAYERCLIP for collision +#define SVF_SENDONCE (1<<14) // Send this entity over the network at least one time +#define SVF_SENT (1<<15) // This flag is set when the entity has been sent over at least one time -// TTimo -// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=551 -#define SVF_CLIENTMASK 0x00000002 - -#define SVF_BROADCAST 0x00000004 // send to all connected clients -#define SVF_SENDPVS 0x00000008 -#define SVF_PORTAL 0x00000010 // merge a second pvs at origin2 -#define SVF_NOTSINGLECLIENT \ - 0x00000040 // send entity to everyone but one client \ - // (entityShared_t->singleClient) -#define SVF_MONSTER 0x00000080 // set if the entity is a bot into snapshots -#define SVF_SINGLECLIENT 0x00000100 // only send to a single client (entityShared_t->singleClient) -#define SVF_USEBBOX 0x00000200 -#define SVF_NOFARPLANE 0x00000400 -#define SVF_NOSERVERINFO \ - 0x00000800 // don't send CS_SERVERINFO updates to this client \ - // so that it can be updated for ping tools without \ - // lagging clients -#define SVF_SENDONCE 0x00004000 - -#define SVF_SENT 0x00008000 +#define SVF_NOSERVERINFO (1<<16) // don't send CS_SERVERINFO updates to this client + // so that it can be updated for ping tools without + // lagging clients typedef struct gclient_s gclient_t; typedef struct dtiki_s dtiki_t; @@ -239,13 +238,18 @@ typedef struct gameImport_s { void (*Error)(int level, const char *format, ...); int (*Milliseconds)(); const char *(*LV_ConvertString)(const char *string); + + // Added in 2.0 const char *(*CL_LV_ConvertString)(const char *string); + void *(*Malloc)(size_t size); void (*Free)(void *ptr); cvar_t *(*Cvar_Get)(const char *varName, const char *varValue, int varFlags); void (*cvar_set)(const char *varName, const char *varValue); cvar_t *(*cvar_set2)(const char *varName, const char *varValue, qboolean force); cvar_t *(*NextCvar)(cvar_t *var); + void (*Cvar_CheckRange)(cvar_t* var, float min, float max, qboolean integral); + int (*Argc)(); char *(*Argv)(int arg); char *(*Args)(); @@ -255,12 +259,13 @@ typedef struct gameImport_s { int (*FS_WriteFile)(const char *qpath, const void *buffer, int size); fileHandle_t (*FS_FOpenFileWrite)(const char *fileName); fileHandle_t (*FS_FOpenFileAppend)(const char *fileName); + long (*FS_FOpenFile)(const char* qpath, fileHandle_t *file, qboolean uniqueFILE, qboolean quiet); const char *(*FS_PrepFileWrite)(const char *fileName); size_t (*FS_Write)(const void *buffer, size_t size, fileHandle_t fileHandle); size_t (*FS_Read)(void *buffer, size_t len, fileHandle_t fileHandle); void (*FS_FCloseFile)(fileHandle_t fileHandle); int (*FS_Tell)(fileHandle_t fileHandle); - int (*FS_Seek)(fileHandle_t fileHandle, long int offset, fsOrigin_t origin); + int (*FS_Seek)(fileHandle_t fileHandle, long int offset, int origin); void (*FS_Flush)(fileHandle_t fileHandle); int (*FS_FileNewer)(const char *source, const char *destination); void (*FS_CanonicalFilename)(char *fileName); @@ -268,7 +273,10 @@ typedef struct gameImport_s { void (*FS_FreeFileList)(char **list); const char *(*GetArchiveFileName)(const char *fileName, const char *extension); void (*SendConsoleCommand)(const char *text); + + // Added in 2.0 void (*ExecuteConsoleCommand)(int exec_when, const char *text); + void (*DebugGraph)(float value); void (*SendServerCommand)(int client, const char *format, ...); void (*DropClient)(int client, const char *reason); @@ -326,7 +334,10 @@ typedef struct gameImport_s { qboolean cylinder, qboolean traceDeep ); + + // Added in 2.0 float (*CM_VisualObfuscation)(const vec3_t start, const vec3_t end); + baseshader_t *(*GetShader)(int shaderNum); int (*pointcontents)(const vec3_t p, int passEntityNum); int (*PointBrushnum)(const vec3_t p, clipHandle_t model); @@ -346,7 +357,10 @@ typedef struct gameImport_s { int entityNum, int contentMask ); + + // Added in 2.0 qboolean (*HitEntity)(gentity_t *pEnt, gentity_t *pOther); + int (*imageindex)(const char *name); int (*itemindex)(const char *name); int (*soundindex)(const char *name, int streamed); @@ -370,9 +384,16 @@ typedef struct gameImport_s { float (*Anim_Frametime)(dtiki_t *tiki, int animNum); float (*Anim_CrossTime)(dtiki_t *tiki, int animNum); void (*Anim_Delta)(dtiki_t *tiki, int animNum, float *delta); + + // Added in 2.0 + void (*Anim_AngularDelta)(dtiki_t *tiki, int animNum, float *delta); + qboolean (*Anim_HasDelta)(dtiki_t *tiki, int animNum); void (*Anim_DeltaOverTime)(dtiki_t *tiki, int animNum, float time1, float time2, float *delta); + + // Added in 2.0 void (*Anim_AngularDeltaOverTime)(dtiki_t *tiki, int animNum, float time1, float time2, float *delta); + int (*Anim_Flags)(dtiki_t *tiki, int animNum); int (*Anim_FlagsSkel)(dtiki_t *tiki, int animNum); qboolean (*Anim_HasCommands)(dtiki_t *tiki, int animNum); @@ -452,7 +473,7 @@ typedef struct gameImport_s { void (*Key_GetKeysForCommand)(const char *command, int *key1, int *key2); void (*ArchiveLevel)(qboolean loading); void (*AddSvsTimeFixup)(int *piTime); - void (*HudDrawShader)(int info, char *name); + void (*HudDrawShader)(int info, const char *name); void (*HudDrawAlign)(int info, int horizontalAlign, int verticalAlign); void (*HudDrawRect)(int info, int x, int y, int width, int height); void (*HudDrawVirtualSize)(int info, qboolean virtualScreen); @@ -460,7 +481,13 @@ typedef struct gameImport_s { void (*HudDrawAlpha)(int info, float alpha); void (*HudDrawString)(int info, const char *string); void (*HudDrawFont)(int info, const char *fontName); - qboolean (*SanitizeName)(const char *oldName, char *newName); + qboolean (*SanitizeName)(const char *oldName, char *newName, size_t bufferSize); + + // + // Added in OPM + // + + int (*pvssoundindex)(const char* name, int streamed); cvar_t *fsDebug; @@ -490,7 +517,7 @@ typedef struct gameExport_s { // return NULL if the client is allowed to connect, otherwise return // a text string with the reason for denial - const char *(*ClientConnect)(int clientNum, qboolean firstTime); + const char *(*ClientConnect)(int clientNum, qboolean firstTime, qboolean differentMap); void (*ClientBegin)(gentity_t *ent, usercmd_t *cmd); void (*ClientUserinfoChanged)(gentity_t *ent, const char *userinfo); @@ -520,8 +547,8 @@ typedef struct gameExport_s { // ReadLevel is called after the default map information has been // loaded with SpawnEntities, so any stored client spawn spots will // be used when the clients reconnect. - void (*WriteLevel)(const char *filename, qboolean autosave); - qboolean (*ReadLevel)(const char *filename); + void (*WriteLevel)(const char *filename, qboolean autosave, byte** savedCgameState, size_t* savedCgameStateSize); + qboolean (*ReadLevel)(const char *filename, byte** savedCgameState, size_t* savedCgameStateSize); qboolean (*LevelArchiveValid)(const char *filename); void (*ArchiveInteger)(int *i); diff --git a/code/fgame/g_session.cpp b/code/fgame/g_session.cpp index 7056c800..f133c2e5 100644 --- a/code/fgame/g_session.cpp +++ b/code/fgame/g_session.cpp @@ -58,9 +58,10 @@ G_ReadSessionData Called on a reconnect ================ */ -void G_ReadSessionData( gclient_t *client ) +void G_ReadClientSessionData( gclient_t *client ) { cvar_t *session; + int teamnum; if( g_bNewSession ) { return; @@ -68,11 +69,12 @@ void G_ReadSessionData( gclient_t *client ) session = gi.Cvar_Get(va("session%zi", client - game.clients), "", 0); - sscanf( session->string, "%s %i %i", client->pers.dm_primary, &client->pers.teamnum, &client->pers.round_kills); + sscanf( session->string, "%s %i %i", client->pers.dm_primary, &teamnum, &client->pers.round_kills); if( client->pers.dm_primary[ 0 ] == '-' ) { client->pers.dm_primary[ 0 ] = 0; } + client->pers.teamnum = (teamtype_t)teamnum; } @@ -83,8 +85,15 @@ G_InitSessionData Called on a first-time connect ================ */ -void G_InitSessionData( gclient_t *client, const char *userinfo ) +void G_InitClientPersistant( gclient_t *client, const char *userinfo ) { + // Clear the persistent data + client->pers = {}; + + // Added in OPM + // Reset the persistent session data. + // This fixes some bugs like the player getting score + // from previous maps G_WriteClientSessionData( client ); } @@ -96,16 +105,13 @@ G_InitWorldSession ================== */ void G_InitWorldSession( void ) { - char s[MAX_STRING_CHARS]; - int gt; + int gt; - cvar_t *v = gi.Cvar_Get( "session", "", 0 ); - - gt = atoi( s ); + cvar_t *v = gi.Cvar_Get( "session", "-1", 0 ); // if the gametype changed since the last session, don't use any // client sessions - if ( g_gametype->integer != gt ) { + if ( g_gametype->integer != v->integer ) { G_Printf( "Gametype changed, clearing session data.\n" ); } } diff --git a/code/fgame/g_spawn.cpp b/code/fgame/g_spawn.cpp index 4ec7a182..6875eb29 100644 --- a/code/fgame/g_spawn.cpp +++ b/code/fgame/g_spawn.cpp @@ -316,12 +316,20 @@ Returns pointer to Entity Listener *SpawnArgs::Spawn(void) { - Listener *ent = (Listener *)SpawnInternal(); + SafePtr ent = (Listener *)SpawnInternal(); + if (!ent) { + return NULL; + } - if (ent) { - ent->ProcessPendingEvents(); - ent->ProcessEvent(EV_Entity_Start); - } + ent->ProcessPendingEvents(); + if (!ent) { + // Fixed in OPM + // Make sure to check the entity after processing events, + // the ent could be deleted due to a posted remove event + return NULL; + } + + ent->ProcessEvent(EV_Entity_Start); return ent; } @@ -543,7 +551,7 @@ Listener *SpawnArgs::SpawnInternal(void) } t2 = gi.Milliseconds(); - if (t2 - t2 >= 100) { + if (t2 - t1 >= 100) { // // above 100 ms send a message to console // @@ -853,8 +861,8 @@ const char *G_FixTIKIPath(const char *in) { if(gi.FS_ReadFile( in, &buffer ) > 0) { return in; } - strcpy(path,"models/"); - strcat(path,in); + Q_strncpyz(path,"models/", sizeof(path)); + Q_strcat(path,sizeof(path),in); if( gi.FS_ReadFile( in, &buffer ) > 0 ) { return path; } diff --git a/code/fgame/g_utils.cpp b/code/fgame/g_utils.cpp index 7eb27bf1..c7ed568e 100644 --- a/code/fgame/g_utils.cpp +++ b/code/fgame/g_utils.cpp @@ -96,7 +96,6 @@ G_TouchTriggers ============ */ void G_TouchTriggers(Entity *ent) - { int i; int num; @@ -142,7 +141,6 @@ to force all entities it covers to immediately touch it ============ */ void G_TouchSolids(Entity *ent) - { int i; int num; @@ -171,7 +169,6 @@ void G_TouchSolids(Entity *ent) } void G_ShowTrace(trace_t *trace, const gentity_t *passent, const char *reason) - { str text; str pass; @@ -237,7 +234,6 @@ void G_ShowSightTrace(gentity_t *passent1, gentity_t *passent2, const char *reas } void G_CalcBoundsOfMove(Vector& start, Vector& end, Vector& mins, Vector& maxs, Vector *minbounds, Vector *maxbounds) - { Vector bmin; Vector bmax; @@ -378,7 +374,6 @@ trace_t G_Trace( const char *reason, qboolean tracedeep ) - { int entnum; trace_t trace; @@ -420,7 +415,6 @@ trace_t G_Trace( const char *reason, qboolean tracedeep ) - { gentity_t *ent; int entnum; @@ -466,7 +460,6 @@ void G_TraceEntities( int contentmask, qboolean bIncludeTriggers ) - { trace_t trace; vec3_t boxmins; @@ -544,7 +537,6 @@ Returns the distance to the nearest player from the given spot ================ */ float PlayersRangeFromSpot(Entity *spot) - { Entity *player; float bestplayerdistance; @@ -583,7 +575,6 @@ to other players ================ */ Entity *SelectRandomDeathmatchSpawnPoint(void) - { Entity *spot, *spot1, *spot2; int count = 0; @@ -642,7 +633,6 @@ SelectFarthestDeathmatchSpawnPoint ================ */ Entity *SelectFarthestDeathmatchSpawnPoint(void) - { Entity *bestspot; float bestdistance; @@ -672,7 +662,6 @@ Entity *SelectFarthestDeathmatchSpawnPoint(void) } Entity *SelectDeathmatchSpawnPoint(void) - { if (DM_FLAG(DF_SPAWN_FARTHEST)) { return SelectFarthestDeathmatchSpawnPoint(); @@ -693,7 +682,6 @@ is not a staircase. int c_yes, c_no; qboolean M_CheckBottom(Entity *ent) - { Vector mins, maxs, start, stop; trace_t trace; @@ -766,7 +754,6 @@ realcheck: } Entity *G_FindClass(Entity *ent, const char *classname) - { int entnum; gentity_t *from; @@ -790,7 +777,6 @@ Entity *G_FindClass(Entity *ent, const char *classname) } Entity *G_FindTarget(Entity *ent, const char *name) - { SimpleEntity *next; @@ -845,7 +831,6 @@ Entity *G_FindRandomTarget(const char *name) } Entity *G_NextEntity(Entity *ent) - { gentity_t *from; @@ -879,7 +864,6 @@ Entity *G_NextEntity(Entity *ent) // just constant angles. // Vector G_GetMovedir(float angle) - { if (angle == -1) { return Vector(0, 0, 1); @@ -918,6 +902,34 @@ void G_SetMovedir(vec3_t angles, vec3_t movedir) VectorClear(angles); } +/* +================= +G_GetAngle + +Return the yaw angle +================= +*/ +float G_GetAngle(Vector movedir) +{ + float angle; + + if (movedir == Vector(0, 0, 1)) { + return -1; + } + + if (movedir == Vector(0, 0, -1)) { + return -2; + } + + angle = RAD2DEG(atan(1.0) * 2 + atan(-movedir[0] / sqrt(-movedir[0] * movedir[0] + 1.0))); + + if (movedir[1] < 0) { + return (int)((360 - angle) * 10000) / 10000.0; + } + + return (int)(angle * 10000) / 10000.0; +} + /* ================= KillBox @@ -927,7 +939,6 @@ of ent. Ent should be unlinked before calling this! ================= */ qboolean KillBox(Entity *ent) - { int i; int num; @@ -979,9 +990,8 @@ qboolean KillBox(Entity *ent) } qboolean IsNumeric(const char *str) - { - int len; + size_t len; int i; qboolean dot; @@ -1014,7 +1024,6 @@ findradius (org, radius) ================= */ Entity *findradius(Entity *startent, Vector org, float rad) - { Vector eorg; gentity_t *from; @@ -1069,7 +1078,6 @@ findclientinradius (org, radius) ================= */ Entity *findclientsinradius(Entity *startent, Vector org, float rad) - { Vector eorg; gentity_t *ed; @@ -1104,7 +1112,6 @@ Entity *findclientsinradius(Entity *startent, Vector org, float rad) } Vector G_CalculateImpulse(Vector start, Vector end, float speed, float gravity) - { float traveltime, vertical_speed; Vector dir, xydir, velocity; @@ -1122,7 +1129,6 @@ Vector G_CalculateImpulse(Vector start, Vector end, float speed, float gravity) } Vector G_PredictPosition(Vector start, Vector target, Vector targetvelocity, float speed) - { Vector projected; float traveltime; @@ -1137,13 +1143,128 @@ Vector G_PredictPosition(Vector start, Vector target, Vector targetvelocity, flo return projected; } +/* +============== +G_ArchiveTrace +============== +*/ +void G_ArchivePlayerState(Archiver& arc, playerState_t *ps) +{ + int i; + + // Movement + arc.ArchiveInteger(&ps->commandTime); + arc.ArchiveInteger(&ps->pm_type); + arc.ArchiveInteger(&ps->pm_flags); + arc.ArchiveInteger(&ps->pm_time); + arc.ArchiveVec3(ps->origin); + arc.ArchiveVec3(ps->velocity); + arc.ArchiveInteger(&ps->gravity); + arc.ArchiveInteger(&ps->speed); + arc.ArchiveInteger(&ps->delta_angles[0]); + arc.ArchiveInteger(&ps->delta_angles[1]); + arc.ArchiveInteger(&ps->delta_angles[2]); + + // Trace + arc.ArchiveInteger(&ps->groundEntityNum); + arc.ArchiveBoolean(&ps->walking); + arc.ArchiveBoolean(&ps->groundPlane); + arc.ArchiveInteger(&ps->feetfalling); + arc.ArchiveVec3(ps->falldir); + G_ArchiveTrace(arc, &ps->groundTrace); + arc.ArchiveVec3(ps->viewangles); + arc.ArchiveInteger(&ps->viewheight); + + // View + arc.ArchiveFloat(&ps->fLeanAngle); + arc.ArchiveInteger(&ps->iViewModelAnim); + arc.ArchiveInteger(&ps->iViewModelAnimChanged); + + // Stats + for (i = 0; i < ARRAY_LEN(ps->stats); i++) { + arc.ArchiveInteger(&ps->stats[i]); + } + for (i = 0; i < ARRAY_LEN(ps->activeItems); i++) { + arc.ArchiveInteger(&ps->activeItems[i]); + } + for (i = 0; i < ARRAY_LEN(ps->ammo_name_index); i++) { + arc.ArchiveInteger(&ps->ammo_name_index[i]); + } + for (i = 0; i < ARRAY_LEN(ps->ammo_amount); i++) { + arc.ArchiveInteger(&ps->ammo_amount[i]); + } + for (i = 0; i < ARRAY_LEN(ps->max_ammo_amount); i++) { + arc.ArchiveInteger(&ps->max_ammo_amount[i]); + } + + // Music + arc.ArchiveInteger(&ps->current_music_mood); + arc.ArchiveInteger(&ps->fallback_music_mood); + arc.ArchiveFloat(&ps->music_volume); + arc.ArchiveFloat(&ps->music_volume_fade_time); + arc.ArchiveInteger(&ps->reverb_type); + arc.ArchiveFloat(&ps->reverb_level); + + // View + arc.ArchiveVec4(ps->blend); + arc.ArchiveFloat(&ps->fov); + + // Camera + arc.ArchiveVec3(ps->camera_origin); + arc.ArchiveFloat(&ps->camera_time); + arc.ArchiveVec3(ps->camera_angles); + arc.ArchiveVec3(ps->camera_offset); + arc.ArchiveVec3(ps->camera_posofs); + arc.ArchiveInteger(&ps->camera_flags); + arc.ArchiveVec3(ps->damage_angles); + + if (arc.Loading()) { + VectorCopy(ps->origin, ps->vEyePos); + ps->vEyePos[2] += ps->viewheight; + } +} + +/* +============== +G_ArchiveTrace +============== +*/ +void G_ArchiveTrace(Archiver& arc, trace_t *trace) +{ + arc.ArchiveBoolean(&trace->allsolid); + arc.ArchiveBoolean(&trace->startsolid); + arc.ArchiveFloat(&trace->fraction); + arc.ArchiveVec3(trace->endpos); + arc.ArchiveVec3(trace->plane.normal); + arc.ArchiveFloat(&trace->plane.dist); + arc.ArchiveByte(&trace->plane.type); + arc.ArchiveByte(&trace->plane.signbits); + arc.ArchiveInteger(&trace->surfaceFlags); + arc.ArchiveInteger(&trace->shaderNum); + arc.ArchiveInteger(&trace->contents); + arc.ArchiveInteger(&trace->entityNum); + arc.ArchiveInteger(&trace->location); +} + +/* +============== +G_ArchiveClient +============== +*/ +void G_ArchiveClient(Archiver& arc, gclient_t *client) +{ + G_ArchivePlayerState(arc, &client->ps); + arc.ArchiveVec3(client->cmd_angles); + arc.ArchiveInteger(&client->lastActiveTime); + arc.ArchiveInteger(&client->activeWarning); +} + /* ============== G_ArchiveEdict ============== */ void G_ArchiveEdict(Archiver& arc, gentity_t *edict) - { int i; str tempStr; @@ -1155,7 +1276,10 @@ void G_ArchiveEdict(Archiver& arc, gentity_t *edict) // if (edict->client) { - arc.ArchiveRaw(edict->client, sizeof(*edict->client)); + // Removed in OPM + // Commented out because clients are already archived + // by Game::Archive() + //G_ArchiveClient(arc, edict->client); } arc.ArchiveInteger(&edict->s.beam_entnum); @@ -1197,7 +1321,9 @@ void G_ArchiveEdict(Archiver& arc, gentity_t *edict) arc.ArchiveString(&tempStr); if (tempStr.length()) { - edict->s.loopSound = gi.soundindex(tempStr.c_str(), true); + qboolean streamed = tempStr[tempStr.length() - 1] != '0'; + tempStr[tempStr.length() - 1] = 0; + edict->s.loopSound = gi.soundindex(tempStr.c_str(), streamed); } else { edict->s.loopSound = 0; } @@ -1331,7 +1457,6 @@ Sets the pos trajectory for a fixed position =============== */ void G_SetTrajectory(gentity_t *ent, vec3_t org) - { ent->s.pos.trTime = 0; VectorClear(ent->s.pos.trDelta); @@ -1347,7 +1472,6 @@ Sets the encoded constant light parameter for entities =============== */ void G_SetConstantLight(int *constantlight, float *red, float *green, float *blue, float *radius, int *lightStyle) - { int ir, ig, ib, iradius; @@ -1402,9 +1526,9 @@ char *CanonicalTikiName(const char *szInName) static char filename[1024]; if (*szInName && Q_stricmpn("models/", szInName, 7)) { - sprintf(filename, "models/%s", szInName); + Com_sprintf(filename, sizeof(filename), "models/%s", szInName); } else { - strcpy(filename, szInName); + Q_strncpyz(filename, szInName, sizeof(filename)); } gi.FS_CanonicalFilename(filename); @@ -1443,46 +1567,45 @@ void G_ProcessCacheInitCommands(dtiki_t *tiki) } void CacheResource(const char *stuff) - { AliasListNode_t *ret; qboolean streamed = qfalse; char filename[MAX_STRING_TOKENS]; + assert(stuff); if (!stuff) { return; } + if (gi.fsDebug->integer == 2) { + Com_Printf("server cache: %s\n", stuff); + } + if (!strchr(stuff, '.')) { // must be a global alias stuff = gi.GlobalAlias_FindRandom(stuff, &ret); if (!stuff) { - if (gi.fsDebug->integer) { + if (gi.fsDebug->integer == 2) { Com_Printf("alias not found\n"); } return; } streamed = ret->streamed; + if (gi.fsDebug->integer == 2) { + Com_Printf("=> %s\n", stuff); + } } - strcpy(filename, stuff); + Q_strncpyz(filename, stuff, sizeof(filename)); gi.FS_CanonicalFilename(filename); - if (strstr(filename, ".wav")) { - gi.soundindex(filename, streamed); - } else if (strstr(filename, ".mp3")) { + if (strstr(filename, ".wav") || strstr(filename, ".mp3")) { gi.soundindex(filename, streamed); } else if (strstr(filename, ".tik")) { dtiki_t *tiki; - if (*stuff && strncmp("models/", stuff, 7)) { - sprintf(filename, "models/%s", stuff); - } else { - strcpy(filename, stuff); - } - - gi.FS_CanonicalFilename(filename); + Q_strncpyz(filename, CanonicalTikiName(stuff), sizeof(filename)); tiki = gi.TIKI_RegisterModel(filename); @@ -1549,22 +1672,25 @@ void RestoreMusicVolume(float fade_time) } void ChangeSoundtrack(const char *soundtrack) - { level.saved_soundtrack = level.current_soundtrack; level.current_soundtrack = soundtrack; - gi.setConfigstring(CS_SOUNDTRACK, soundtrack); + // Force the soundtrack to be sent again by setting it to empty first + // so it gets sent to clients again especially when loading + // from a saved game + gi.setConfigstring(CS_MUSIC, ""); + gi.setConfigstring(CS_MUSIC, soundtrack); + gi.DPrintf("soundtrack switched to %s.\n", soundtrack); } void RestoreSoundtrack(void) - { if (level.saved_soundtrack.length()) { level.current_soundtrack = level.saved_soundtrack; level.saved_soundtrack = ""; - gi.setConfigstring(CS_SOUNDTRACK, level.current_soundtrack.c_str()); + gi.setConfigstring(CS_MUSIC, level.current_soundtrack.c_str()); gi.DPrintf("soundtrack restored %s.\n", level.current_soundtrack.c_str()); } } @@ -1643,14 +1769,30 @@ int G_AIEventTypeFromString(const char *pszType) float G_AIEventRadius(int iType) { static float fRadius[] = { - 2048.0f, 384.0f, 4096.0f, 1024.0f, 1024.0f, 1536.0f, 1536.0f, 1500.0f, 2250.0f, 512.0f, 384.0f, 0, 0, 0, 0}; + 0, + 2048, + 384, + 4096, + 1024, + 1024, + 1536, + 1536, + 1500, + 2250, + 512, + 384, + 32768, + 0, + 0, + 0 + }; - if (iType <= AI_EVENT_GRENADE) { - return fRadius[iType]; - } else { + if (iType >= AI_EVENT_MAX) { Com_Printf("G_AIEventRadius: invalid event type\n"); return 1500.0f; } + + return fRadius[iType]; } void G_BroadcastAIEvent(Entity *originator, Vector origin, char *pszType) @@ -1692,15 +1834,13 @@ void G_BroadcastAIEvent(Entity *originator, Vector origin, int iType, float radi continue; } - if (!ent->IsSubclassOfActor() && !ent->IsSubclassOfBot()) { + if (!ent->IsSubclassOfActor()) { continue; } - if (ent->IsSubclassOfActor()) { - act = static_cast(ent); - if (act->IgnoreSound(iType)) { - continue; - } + act = static_cast(ent); + if (act->IgnoreSound(iType)) { + continue; } delta = origin - ent->centroid; @@ -1722,15 +1862,10 @@ void G_BroadcastAIEvent(Entity *originator, Vector origin, int iType, float radi continue; } - if (ent->IsSubclassOfActor()) { - act->ReceiveAIEvent(origin, iType, originator, dist2, r2); - } else if (ent->IsSubclassOfBot()) { - PlayerBot *bot = static_cast(ent); - - bot->NoticeEvent(origin, iType, originator, dist2, r2); - } + act->ReceiveAIEvent(origin, iType, originator, dist2, r2); } + botManager.BroadcastEvent(originator, origin, iType, radius); #if 0 gi.DPrintf("Broadcast event %s to %d entities\n", ev->getName(), count); #endif @@ -1776,7 +1911,6 @@ void CloneEntity(Entity *dest, Entity *src) } weaponhand_t WeaponHandNameToNum(str side) - { if (!side.length()) { gi.DPrintf("WeaponHandNameToNum : Weapon hand not specified\n"); @@ -1793,7 +1927,6 @@ weaponhand_t WeaponHandNameToNum(str side) } const char *WeaponHandNumToName(weaponhand_t hand) - { switch (hand) { case WEAPON_MAIN: @@ -1806,7 +1939,6 @@ const char *WeaponHandNumToName(weaponhand_t hand) } firemode_t WeaponModeNameToNum(str mode) - { if (!mode.length()) { gi.DPrintf("WeaponModeNameToNum : Weapon mode not specified\n"); @@ -1898,7 +2030,6 @@ str G_WeaponClassNumToName(int num) } void G_DebugTargets(Entity *e, str from) - { gi.DPrintf("DEBUGTARGETS:%s ", from.c_str()); @@ -1916,7 +2047,6 @@ void G_DebugTargets(Entity *e, str from) } void G_DebugDamage(float damage, Entity *victim, Entity *attacker, Entity *inflictor) - { gi.DPrintf( "Victim:%s Attacker:%s Inflictor:%s Damage:%f\n", @@ -1939,7 +2069,6 @@ void G_FadeOut(float delaytime) } void G_AutoFadeIn(void) - { level.m_fade_time_start = 1; level.m_fade_time = 1; @@ -1952,7 +2081,6 @@ void G_AutoFadeIn(void) } void G_ClearFade(void) - { level.m_fade_time = -1; level.m_fade_type = fadein; @@ -1971,29 +2099,10 @@ void G_RestartLevelWithDelay(float delaytime) { int i; - if (level.died_already) { + if (g_gametype->integer != GT_SINGLE_PLAYER) { return; } - level.died_already = true; - - // Restart the level soon - for (i = 0; i < game.maxclients; i++) { - if (g_entities[i].inuse) { - if (g_entities[i].entity) { - g_entities[i].entity->PostEvent(EV_Player_Respawn, delaytime); - } - } - } -} - -// -// restarts the game after delaytime -// -void G_PlayerDied(float delaytime) -{ - int i; - if (level.died_already) { return; } @@ -2001,7 +2110,6 @@ void G_PlayerDied(float delaytime) level.died_already = true; // Restart the level soon - for (i = 0; i < game.maxclients; i++) { if (g_entities[i].inuse) { if (g_entities[i].entity) { @@ -2015,34 +2123,42 @@ void G_PlayerDied(float delaytime) } void G_MissionFailed(void) - { - // Make the music system play the failure music for this level - ChangeMusic("failure", "normal", true); - - G_PlayerDied(3); - - // tell the player they f'd up - gi.centerprintf(&g_entities[0], "@textures/menu/mission.tga"); + G_RestartLevelWithDelay(0); level.mission_failed = true; } void G_StartCinematic(void) - { level.cinematic = true; gi.cvar_set("sv_cinematic", "1"); } void G_StopCinematic(void) - { // clear out the skip thread level.cinematic = false; gi.cvar_set("sv_cinematic", "0"); } +int G_NumClients(void) +{ + gentity_t *ent; + int i; + int count = 0; + + for (i = 0, ent = g_entities; i < game.maxclients; ent++, i++) { + if (!ent->inuse || !ent->entity) { + continue; + } + + count++; + } + + return count; +} + void G_PrintToAllClients(const char *pszString, int iType) { if (g_protocol >= protocol_e::PROTOCOL_MOHTA_MIN) { @@ -2055,9 +2171,9 @@ void G_PrintToAllClients(const char *pszString, int iType) } } else { if (iType == 0) { - gi.SendServerCommand(-1, "print \"" HUD_MESSAGE_YELLOW "%s\n\"", pszString); + gi.SendServerCommand(-1, "print \"" HUD_MESSAGE_YELLOW "%s\"", pszString); } else { - gi.SendServerCommand(-1, "print \"" HUD_MESSAGE_WHITE "%s\n\"", pszString); + gi.SendServerCommand(-1, "print \"" HUD_MESSAGE_WHITE "%s\"", pszString); } } } @@ -2116,9 +2232,12 @@ G_PrintDeathMessageEmulated(const char *s1, const char *s2, char *attackerName, result2 = NULL; if (type == tolower(type)) { + // Enemy hudColor = 4; } else { - hudColor = 5; + // Friend + //hudColor = 5; + hudColor = 4; } if (*s1 != 'x') { @@ -2131,7 +2250,11 @@ G_PrintDeathMessageEmulated(const char *s1, const char *s2, char *attackerName, return va("%c%s %s\n", hudColor, victimName, result1); } else if (tolower(type) == 'p') { if (*s2 == 'x') { - return va("%c%s %s %s\n", hudColor, victimName, result1, attackerName); + if (s2[1] && s2[2]) { + return va("%c%s %s %s %s\n", hudColor, victimName, result1, attackerName, s2 + 2); + } else { + return va("%c%s %s %s\n", hudColor, victimName, result1, attackerName); + } } else { return va("%c%s %s %s%s\n", hudColor, victimName, result1, attackerName, result2); } @@ -2207,7 +2330,7 @@ void G_PrintDeathMessage_Old(const char *pszString) continue; } - gi.SendServerCommand(ent - g_entities, "print \"" HUD_MESSAGE_CHAT_RED "%s\"", pszString); + gi.SendServerCommand(ent - g_entities, "print \"%s\"", pszString); } } @@ -2240,7 +2363,7 @@ void G_WarnPlayer(Player *player, const char *format, ...) va_list va; va_start(va, format); - vsprintf(buffer, format, va); + Q_vsnprintf(buffer, sizeof(buffer), format, va); va_end(va); gi.SendServerCommand(player->client->ps.clientNum, "print \"%s\"\n", buffer); @@ -2329,3 +2452,7 @@ gentity_t *G_GetGEntity(int ent_num) return ent; } + +unsigned int G_GetWeaponCommand(unsigned int buttons) { + return GetWeaponCommand(buttons, g_protocol >= PROTOCOL_MOHTA_MIN ? WEAPON_COMMAND_MAX_VER17 : WEAPON_COMMAND_MAX_VER6); +} diff --git a/code/fgame/g_utils.h b/code/fgame/g_utils.h index caaf1174..7d5fb4be 100644 --- a/code/fgame/g_utils.h +++ b/code/fgame/g_utils.h @@ -30,6 +30,9 @@ class SimpleEntity; class SimpleArchivedEntity; class ScriptThread; +void G_ArchivePlayerState(Archiver& arc, playerState_t* ps); +void G_ArchiveTrace(Archiver& arc, trace_t* trace); +void G_ArchiveClient(Archiver& arc, gclient_t* client); void G_ArchiveEdict(Archiver& arc, gentity_t *edict); void G_AllocDebugLines(void); @@ -124,6 +127,7 @@ Entity *G_NextEntity(Entity *ent); qboolean M_CheckBottom(Entity *ent); Vector G_GetMovedir(float angle); +float G_GetAngle(Vector movedir); qboolean KillBox(Entity *ent); qboolean IsNumeric(const char *str); @@ -143,7 +147,6 @@ void G_MissionFailed(void); void G_FadeOut(float delaytime); void G_FadeSound(float delaytime); void G_RestartLevelWithDelay(float delaytime); -void G_PlayerDied(float delaytime); void G_AutoFadeIn(void); void G_ClearFade(void); void G_StartCinematic(void); @@ -324,3 +327,4 @@ const char *WeaponHandNumToName(weaponhand_t hand); weaponhand_t WeaponHandNameToNum(str side); void G_DebugTargets(Entity *e, str from); void G_DebugDamage(float damage, Entity *victim, Entity *attacker, Entity *inflictor); +unsigned int G_GetWeaponCommand(unsigned int buttons); diff --git a/code/fgame/g_vmove.cpp b/code/fgame/g_vmove.cpp index ec762b88..1cdbb4a8 100644 --- a/code/fgame/g_vmove.cpp +++ b/code/fgame/g_vmove.cpp @@ -179,18 +179,16 @@ qboolean VM_SlideMove(qboolean gravity) break; } - if (trace.plane.normal[2] >= 0.7f) { + if (trace.plane.normal[2] >= MIN_WALK_NORMAL) { memcpy(&vm->vs->groundTrace, &trace, sizeof(vm->vs->groundTrace)); vml.validGroundTrace = qtrue; - } else if (trace.plane.normal[2] > -0.999f) { - if (vm->vs->groundPlane) { - if (!vm->vs->hit_obstacle) { - vm->vs->hit_obstacle = qtrue; - VectorCopy(vm->vs->origin, vm->vs->hit_origin); - } - - VectorAdd(vm->vs->obstacle_normal, trace.plane.normal, vm->vs->obstacle_normal); + } else if (trace.plane.normal[2] > -0.999f && vm->vs->groundPlane) { + if (!vm->vs->hit_obstacle) { + vm->vs->hit_obstacle = qtrue; + VectorCopy(vm->vs->origin, vm->vs->hit_origin); } + + VectorAdd(vm->vs->obstacle_normal, trace.plane.normal, vm->vs->obstacle_normal); } // save entity for contact @@ -239,8 +237,8 @@ qboolean VM_SlideMove(qboolean gravity) } // slide along the plane - VM_ClipVelocity(vm->vs->velocity, planes[j], clipVelocity, OVERCLIP); - VM_ClipVelocity(endVelocity, planes[j], endClipVelocity, OVERCLIP); + VM_ClipVelocity(clipVelocity, planes[j], clipVelocity, OVERCLIP); + VM_ClipVelocity(endClipVelocity, planes[j], endClipVelocity, OVERCLIP); if (DotProduct(clipVelocity, planes[j]) >= 0.0f) { continue; // move doesn't interact with the plane @@ -439,11 +437,14 @@ void VM_StepSlideMove(void) bWasOnGoodGround = qfalse; } + VectorCopy(start_o, up); + up[2] += STEPSIZE; + VectorCopy(vm->vs->origin, nostep_o); VectorCopy(vm->vs->velocity, nostep_v); memcpy(&nostep_groundTrace, &vm->vs->groundTrace, sizeof(trace_t)); - VectorCopy(start_o, vm->vs->origin); + VectorCopy(up, vm->vs->origin); VectorCopy(start_v, vm->vs->velocity); first_hit_wall = vm->vs->hit_obstacle; @@ -453,7 +454,7 @@ void VM_StepSlideMove(void) vm->vs->hit_obstacle = start_hit_wall; VectorCopy(start_hit_origin, vm->vs->hit_origin); VectorCopy(start_wall_normal, vm->vs->obstacle_normal); - VM_SlideMove(qtrue); + VM_SlideMove(vm->vs->useGravity); VectorCopy(vm->vs->origin, down); down[2] -= STEPSIZE * 2; diff --git a/code/fgame/game.cpp b/code/fgame/game.cpp index 00030a35..29d5c47b 100644 --- a/code/fgame/game.cpp +++ b/code/fgame/game.cpp @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2023 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -31,18 +31,109 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "player.h" #include "dm_manager.h" +Event EV_Game_Detail +( + "skill", + EV_DEFAULT, + NULL, + NULL, + "game.skill", + EV_GETTER +); + +Event EV_Game_Skill +( + "detail", + EV_DEFAULT, + NULL, + NULL, + "game.detail", + EV_GETTER +); + Game game; +void Game::GetSkill(Event *ev) +{ + switch (skill->integer) { + case 0: + case 1: + ev->AddString("easy"); + break; + case 2: + ev->AddString("hard"); + break; + default: + ev->AddString("unknown"); + break; + } +} + +void Game::GetDetail(Event *ev) +{ + ev->AddFloat(detail->value); +} + +void Game::Init() +{ + clients = NULL; + autosaved = qfalse; + maxentities = 0; + maxclients = 0; +} + +void Game::Archive(Archiver& arc) +{ + static cvar_t *g_maxplayerhealth = gi.Cvar_Get("g_maxplayerhealth", "250", 0); + int i; + + if (arc.Saving()) { + Vars()->MakePrimitive(); + } + + Listener::Archive(arc); + + if (arc.Saving()) { + float fTmp; + int iTmp; + + fTmp = skill->value; + arc.ArchiveFloat(&fTmp); + + iTmp = g_maxplayerhealth->integer; + arc.ArchiveInteger(&iTmp); + } else { + float fTmp; + int iTmp; + + arc.ArchiveFloat(&fTmp); + gi.cvar_set("skill", va("%f", fTmp)); + arc.ArchiveInteger(&iTmp); + gi.cvar_set("g_maxplayerhealth", va("%d", iTmp)); + } + + arc.ArchiveBoolean(&autosaved); + arc.ArchiveInteger(&maxentities); + arc.ArchiveInteger(&maxclients); + + if (arc.Loading()) { + G_AllocGameData(); + } + + for (i = 0; i < maxclients; i++) { + G_ArchiveClient(arc, &clients[i]); + } +} + Game::Game() { - clients = NULL; - maxclients = 0; + Init(); } Game::~Game() {} -void Game::Archive(Archiver& arc) {} - CLASS_DECLARATION(Listener, Game, NULL) { - {NULL, NULL} + {&EV_Game_Skill, &Game::GetSkill }, + {&EV_Game_Detail, &Game::GetDetail}, + {NULL, NULL } }; diff --git a/code/fgame/game.h b/code/fgame/game.h index b97c59d0..61f7821a 100644 --- a/code/fgame/game.h +++ b/code/fgame/game.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2023 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -39,10 +39,16 @@ public: public: CLASS_PROTOTYPE(Game); - void Archive(Archiver& arc) override; +protected: + void GetSkill(Event *ev); + void GetDetail(Event *ev); +public: Game(); ~Game(); + + void Init(); + void Archive(Archiver& arc) override; }; class SimpleArchivedEntity; diff --git a/code/fgame/gamecmds.cpp b/code/fgame/gamecmds.cpp index 1f931aa8..69f94876 100644 --- a/code/fgame/gamecmds.cpp +++ b/code/fgame/gamecmds.cpp @@ -42,6 +42,11 @@ typedef struct { qboolean allclients; } consolecmd_t; +typedef struct { + const char* prefix; + SafePtr master; +} commandmaster_t; + consolecmd_t G_ConsoleCmds[] = { // command name function available in multiplayer? {"say", G_SayCmd, qtrue }, @@ -60,16 +65,22 @@ consolecmd_t G_ConsoleCmds[] = { {"levelvars", G_LevelVarsCmd, qfalse}, {"gamevars", G_GameVarsCmd, qfalse}, {"script", G_ScriptCmd, qfalse}, + // Added in 2.0 {"reloadmap", G_ReloadMap, qfalse}, + // Added in OPM + //==== {"compilescript", G_CompileScript, qfalse}, {"addbot", G_AddBotCommand, qfalse}, {"removebot", G_RemoveBotCommand, qfalse}, #ifdef _DEBUG {"bot", G_BotCommand, qfalse}, #endif + //==== {NULL, NULL, qfalse} }; +Container commandMasters; + void G_InitConsoleCommands(void) { consolecmd_t *cmds; @@ -127,7 +138,11 @@ qboolean G_ConsoleCommand(void) } } - result = G_ProcessClientCommand(ent); + if (cl_running->integer) { + // Don't execute the command in multiplayer + // otherwise, the command will be executed "by" the first client + result = G_ProcessClientCommand(ent); + } } catch (const char *error) { G_ExitWithError(error); } @@ -155,14 +170,18 @@ qboolean G_ProcessClientCommand(gentity_t *ent) consolecmd_t *cmds; int i; int n; - ConsoleEvent *ev; Player *player; + qboolean allowDev; if (!ent || !ent->client || !ent->entity) { // not fully in game yet return qfalse; } + // Added in 2.1 + // Prevent players from messing with the server with developer commands + allowDev = g_gametype->integer == GT_SINGLE_PLAYER; + cmd = gi.Argv(0); player = (Player *)ent->entity; @@ -180,20 +199,36 @@ qboolean G_ProcessClientCommand(gentity_t *ent) } if (Event::Exists(cmd)) { - ev = new ConsoleEvent(cmd); - ev->SetConsoleEdict(ent); + ConsoleEvent ev(cmd); + ev.SetConsoleEdict(ent); n = gi.Argc(); for (i = 1; i < n; i++) { - ev->AddToken(gi.Argv(i)); + ev.AddToken(gi.Argv(i)); } if (!Q_stricmpn(cmd, "lod_", 4)) { + if (!allowDev) { + return false; + } return LODModel.ProcessEvent(ev); } else if (!Q_stricmpn(cmd, "view", 4)) { + if (!allowDev) { + return false; + } return Viewmodel.ProcessEvent(ev); - } else if (ent->entity->CheckEventFlags(ev)) { + } else { + // + // Added in OPM + // + Listener* master = G_FindMaster(cmd); + if (master) { + return master->ProcessEvent(ev); + } + } + + if (ent->entity->CheckEventFlags(&ev)) { return ent->entity->ProcessEvent(ev); } } @@ -201,13 +236,72 @@ qboolean G_ProcessClientCommand(gentity_t *ent) return qfalse; } +/* +================== +G_CreateMaster +================== +*/ +void G_CreateMaster(const char* prefix, Listener* master) +{ + commandmaster_t commandMaster; + + int i; + + for (i = 1; i <= commandMasters.NumObjects(); i++) { + const commandmaster_t& commandMaster = commandMasters.ObjectAt(i); + if (!str::icmp(commandMaster.prefix, prefix)) { + return; + } + } + + commandMaster.prefix = prefix; + commandMaster.master = master; + commandMasters.AddObject(commandMaster); +} + +/* +================== +G_MasterMatches +================== +*/ +bool G_MasterMatches(const commandmaster_t& commandMaster, const char* command) { + const char* s1, *s2; + + s2 = commandMaster.prefix; + for (s1 = command; *s1 && *s2; s1++, s2++) { + if (tolower(*s1) != tolower(*s2)) { + return false; + } + } + + return *s1 == '_'; +} + +/* +================== +G_FindMaster +================== +*/ +Listener* G_FindMaster(const char* command) +{ + int i; + + for (i = 1; i <= commandMasters.NumObjects(); i++) { + const commandmaster_t& commandMaster = commandMasters.ObjectAt(i); + if (G_MasterMatches(commandMaster, command)) { + return commandMaster.master; + } + } + + return NULL; +} + /* ================== Cmd_Say_f ================== */ void G_Say(gentity_t *ent, qboolean team, qboolean arg0) - { int j; gentity_t *other; @@ -271,7 +365,6 @@ void G_Say(gentity_t *ent, qboolean team, qboolean arg0) } qboolean G_CameraCmd(gentity_t *ent) - { Event *ev; const char *cmd; @@ -330,7 +423,6 @@ qboolean G_SoundCmd(gentity_t *ent) } qboolean G_SayCmd(gentity_t *ent) - { G_Say(ent, false, false); @@ -338,7 +430,6 @@ qboolean G_SayCmd(gentity_t *ent) } qboolean G_EventListCmd(gentity_t *ent) - { const char *mask; @@ -347,13 +438,12 @@ qboolean G_EventListCmd(gentity_t *ent) mask = gi.Argv(1); } - //Event::ListCommands( mask ); + Event::ListCommands( mask ); return qtrue; } qboolean G_PendingEventsCmd(gentity_t *ent) - { const char *mask; @@ -362,13 +452,12 @@ qboolean G_PendingEventsCmd(gentity_t *ent) mask = gi.Argv(1); } - //Event::PendingEvents( mask ); + Event::PendingEvents( mask ); return qtrue; } qboolean G_EventHelpCmd(gentity_t *ent) - { const char *mask; @@ -377,13 +466,12 @@ qboolean G_EventHelpCmd(gentity_t *ent) mask = gi.Argv(1); } - //Event::ListDocumentation( mask, false ); + Event::ListDocumentation( mask, false ); return qtrue; } qboolean G_DumpEventsCmd(gentity_t *ent) - { const char *mask; @@ -392,13 +480,12 @@ qboolean G_DumpEventsCmd(gentity_t *ent) mask = gi.Argv(1); } - //Event::ListDocumentation( mask, true ); + Event::ListDocumentation( mask, true ); return qtrue; } qboolean G_ClassEventsCmd(gentity_t *ent) - { const char *className; @@ -408,13 +495,12 @@ qboolean G_ClassEventsCmd(gentity_t *ent) className = gi.Argv(1); } else { className = gi.Argv(1); - //ClassEvents( className ); + ClassEvents( className, qfalse ); } return qtrue; } qboolean G_DumpClassEventsCmd(gentity_t *ent) - { const char *className; @@ -424,31 +510,28 @@ qboolean G_DumpClassEventsCmd(gentity_t *ent) className = gi.Argv(1); } else { className = gi.Argv(1); - //ClassEvents( className, qtrue ); + ClassEvents( className, qtrue ); } return qtrue; } qboolean G_DumpAllClassesCmd(gentity_t *ent) - { DumpAllClasses(); return qtrue; } qboolean G_ClassListCmd(gentity_t *ent) - { - //listAllClasses(); + listAllClasses(); return qtrue; } qboolean G_ClassTreeCmd(gentity_t *ent) - { if (gi.Argc() > 1) { - //listInheritanceOrder( gi.Argv( 1 ) ); + listInheritanceOrder( gi.Argv( 1 ) ); } else { gi.SendServerCommand(ent - g_entities, "print \"Syntax: classtree [classname].\n\""); } @@ -464,7 +547,6 @@ qboolean G_ShowVarCmd(gentity_t *ent) void PrintVariableList(ScriptVariableList *list) {} qboolean G_LevelVarsCmd(gentity_t *ent) - { gi.Printf("Level Variables\n"); PrintVariableList(level.vars); @@ -473,7 +555,6 @@ qboolean G_LevelVarsCmd(gentity_t *ent) } qboolean G_GameVarsCmd(gentity_t *ent) - { gi.Printf("Game Variables\n"); PrintVariableList(game.vars); @@ -489,12 +570,11 @@ qboolean G_ScriptCmd(gentity_t *ent) ConsoleEvent *event; int numArgs; int i; - bool recompile; numArgs = gi.Argc(); if (numArgs <= 1) { - gi.Printf("Usage: script [filename] ([recompile])\n"); + gi.Printf("Usage: script [filename]\n"); return qtrue; } @@ -531,7 +611,8 @@ qboolean G_ScriptCmd(gentity_t *ent) return scriptEnt->ProcessEvent(event); } -qboolean G_ReloadMap(gentity_t* ent) { +qboolean G_ReloadMap(gentity_t* ent) +{ char name[256]; Com_sprintf(name, sizeof(name), "gamemap \"%s\"\n", level.mapname.c_str()); @@ -563,12 +644,13 @@ qboolean G_AddBotCommand(gentity_t *ent) } numbots = atoi(gi.Argv(1)); - if (numbots > sv_maxbots->integer) { - gi.Printf("addbot must be between 1-%d\n", sv_maxbots->integer); + + if (numbots > game.maxclients) { + gi.Printf("addbot must be between 1-%d\n", game.maxclients); return qfalse; } - totalnumbots = Q_min(numbots + sv_numbots->integer, sv_maxbots->integer); + totalnumbots = Q_min(numbots + sv_numbots->integer, game.maxclients); gi.cvar_set("sv_numbots", va("%d", totalnumbots)); return qtrue; @@ -596,9 +678,9 @@ qboolean G_RemoveBotCommand(gentity_t *ent) qboolean G_BotCommand(gentity_t *ent) { const char *command; - PlayerBot *bot; + BotController *bot; - if (!G_GetFirstBot() || !G_GetFirstBot()->entity) { + if (botManager.getControllerManager().getControllers().NumObjects() < 1) { gi.Printf("No bot spawned.\n"); return qfalse; } @@ -608,12 +690,12 @@ qboolean G_BotCommand(gentity_t *ent) return qfalse; } - bot = (PlayerBot *)G_GetFirstBot()->entity; + bot = botManager.getControllerManager().getControllers().ObjectAt(1); command = gi.Argv(1); if (!Q_stricmp(command, "movehere")) { - bot->MoveTo(ent->entity->origin); + bot->GetMovement().MoveTo(ent->entity->origin); } else if (!Q_stricmp(command, "moveherenear")) { float rad = 256.0f; @@ -621,7 +703,7 @@ qboolean G_BotCommand(gentity_t *ent) rad = atof(gi.Argv(2)); } - bot->MoveNear(ent->entity->origin, rad); + bot->GetMovement().MoveNear(ent->entity->origin, rad); } else if (!Q_stricmp(command, "avoidhere")) { float rad = 256.0f; @@ -629,9 +711,9 @@ qboolean G_BotCommand(gentity_t *ent) rad = atof(gi.Argv(2)); } - bot->AvoidPath(ent->entity->origin, rad); + bot->GetMovement().AvoidPath(ent->entity->origin, rad); } else if (!Q_stricmp(command, "telehere")) { - bot->setOrigin(ent->s.origin); + bot->getControlledEntity()->setOrigin(ent->s.origin); } return qtrue; diff --git a/code/fgame/gamecmds.h b/code/fgame/gamecmds.h index 97725eb1..a45ebc73 100644 --- a/code/fgame/gamecmds.h +++ b/code/fgame/gamecmds.h @@ -30,6 +30,12 @@ void G_InitConsoleCommands(void); qboolean G_ProcessClientCommand(gentity_t *ent); +//=============== +// Added in OPM +void G_CreateMaster(const char* prefix, class Listener* master); +Listener* G_FindMaster(const char* command); +//=============== + void G_Say(gentity_t *ent, qboolean team, qboolean arg0); qboolean G_CameraCmd(gentity_t *ent); qboolean G_SoundCmd(gentity_t *ent); diff --git a/code/fgame/gamecvars.cpp b/code/fgame/gamecvars.cpp index f0fd97d2..2ce8fe5c 100644 --- a/code/fgame/gamecvars.cpp +++ b/code/fgame/gamecvars.cpp @@ -26,7 +26,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "gamecvars.h" cvar_t *developer; -cvar_t *sv_specialgame; cvar_t *deathmatch; cvar_t *dmflags; @@ -59,7 +58,7 @@ cvar_t *sv_rollspeed; cvar_t *sv_rollangle; cvar_t *sv_cheats; cvar_t *sv_showbboxes; -cvar_t *sv_showbtags; +cvar_t *sv_showtags; cvar_t *sv_testloc_num; cvar_t *sv_testloc_secondary; @@ -258,20 +257,52 @@ cvar_t *g_no_seasick; cvar_t *g_aistats; -cvar_t* g_obituarylocation; +// +// Added in OPM +// + +cvar_t *sv_netoptimize; + +cvar_t *g_obituarylocation; cvar_t *sv_scriptfiles; +// The maximum number of allocated bot clients cvar_t *sv_maxbots; +// The number of bots that should be spawned cvar_t *sv_numbots; +// The minimum number of players that should be present in-game. +// If the number of real players is below this number, +// the game will automatically add bots to fill the gap cvar_t *sv_minPlayers; +// Whether or not the bots use a shared player slots +// NOTE: Setting this cvar is not recommended +// because when a client connects and the slot is used by a bot +// the bot will be relocated to a free entity slot +cvar_t *sv_sharedbots; + cvar_t *g_rankedserver; cvar_t *g_spectatefollow_firstperson; +cvar_t *cl_running; + +// Whether or instant messages are allowed +cvar_t *g_instamsg_allowed; +// Minimum delay, in milliseconds, between instant messages +cvar_t *g_instamsg_minDelay; +// Whether or not text messages are allowed +cvar_t *g_textmsg_allowed; +// Minimum delay, in milliseconds, between messages +cvar_t *g_textmsg_minDelay; + +// Whether or not to prevent teams from being unbalanced +cvar_t *g_teambalance; + void CVAR_Init(void) { + int i; + developer = gi.Cvar_Get("developer", "0", 0); - sv_specialgame = gi.Cvar_Get("sv_specialgame", "0", CVAR_LATCH | CVAR_SERVERINFO); precache = gi.Cvar_Get("sv_precache", "1", 0); @@ -310,7 +341,7 @@ void CVAR_Init(void) sv_traceinfo = gi.Cvar_Get("sv_traceinfo", "0", 0); sv_drawtrace = gi.Cvar_Get("sv_drawtrace", "0", 0); sv_showbboxes = gi.Cvar_Get("sv_showbboxes", "0", 0); - sv_showbtags = gi.Cvar_Get("sv_showtags", "0", 0); + sv_showtags = gi.Cvar_Get("sv_showtags", "0", 0); sv_testloc_num = gi.Cvar_Get("sv_testloc_num", "0", 0); sv_testloc_secondary = gi.Cvar_Get("sv_testloc_secondary", "0", 0); @@ -332,7 +363,7 @@ void CVAR_Init(void) sv_waterspeed = gi.Cvar_Get("sv_waterspeed", "400", 0); sv_cheats = gi.Cvar_Get("cheats", "0", CVAR_USERINFO | CVAR_SERVERINFO | CVAR_LATCH); - sv_fps = gi.Cvar_Get("sv_fps", "20", CVAR_SAVEGAME); + sv_fps = gi.Cvar_Get("sv_fps", "20", CVAR_SAVEGAME); sv_cinematic = gi.Cvar_Get("sv_cinematic", "0", CVAR_ROM); sv_maplist = gi.Cvar_Get("sv_maplist", "", CVAR_ARCHIVE | CVAR_SERVERINFO); @@ -348,8 +379,8 @@ void CVAR_Init(void) sv_sprinttime_dm = gi.Cvar_Get("sv_sprinttime_dm", "5.0", 0); sv_sprintmult_dm = gi.Cvar_Get("sv_sprintmult_dm", "1.20", 0); - if (g_protocol >= protocol_e::PROTOCOL_MOHTA_MIN) { - sv_sprinton = gi.Cvar_Get("sv_sprinton", "1", 0); + if (g_target_game >= target_game_e::TG_MOHTA) { + sv_sprinton = gi.Cvar_Get("sv_sprinton", "1", 0); } else { // mohaa doesn't have sprint support sv_sprinton = gi.Cvar_Get("sv_sprinton", "0", 0); @@ -359,8 +390,13 @@ void CVAR_Init(void) gi.cvar_set("sv_runspeed", "250"); } - sv_invulnerabletime = gi.Cvar_Get("sv_invulnerabletime", "3.0", CVAR_ARCHIVE | CVAR_SERVERINFO); - sv_team_spawn_interval = gi.Cvar_Get("sv_team_spawn_interval", "15", CVAR_ARCHIVE | CVAR_SERVERINFO); + if (g_target_game >= target_game_e::TG_MOHTA) { + sv_invulnerabletime = gi.Cvar_Get("sv_invulnerabletime", "3.0", CVAR_ARCHIVE | CVAR_SERVERINFO); + sv_team_spawn_interval = gi.Cvar_Get("sv_team_spawn_interval", "15", CVAR_ARCHIVE | CVAR_SERVERINFO); + } else { + sv_invulnerabletime = gi.Cvar_Get("sv_invulnerabletime", "0", CVAR_ARCHIVE | CVAR_SERVERINFO); + sv_team_spawn_interval = gi.Cvar_Get("sv_team_spawn_interval", "0", CVAR_ARCHIVE | CVAR_SERVERINFO); + } g_showmem = gi.Cvar_Get("g_showmem", "0", 0); g_timeents = gi.Cvar_Get("g_timeents", "0", 0); @@ -428,8 +464,15 @@ void CVAR_Init(void) g_teamdamage = gi.Cvar_Get("g_teamdamage", "0", 0); g_healthdrop = gi.Cvar_Get("g_healthdrop", "1", 0); - g_healrate = gi.Cvar_Get("g_healrate", "10", 0); - g_allowvote = gi.Cvar_Get("g_allowvote", "1", 0); + if (g_protocol >= protocol_e::PROTOCOL_MOHTA_MIN) { + g_healrate = gi.Cvar_Get("g_healrate", "10", 0); + } else { + // + // By default, no healrate on 1.11 and below + // + g_healrate = gi.Cvar_Get("g_healrate", "0", 0); + } + g_allowvote = gi.Cvar_Get("g_allowvote", "1", CVAR_SERVERINFO); g_maprotation_filter = gi.Cvar_Get("g_maprotation_filter", "ffa", 0); g_warmup = gi.Cvar_Get("g_warmup", "20", CVAR_ARCHIVE); g_doWarmup = gi.Cvar_Get("g_doWarmup", "1", 0); @@ -447,11 +490,14 @@ void CVAR_Init(void) g_teamkillwarn = gi.Cvar_Get("g_teamkillwarn", "3", CVAR_ARCHIVE); g_teamkillkick = gi.Cvar_Get("g_teamkillkick", "5", CVAR_ARCHIVE); g_teamswitchdelay = gi.Cvar_Get("g_teamswitchdelay", "15", CVAR_ARCHIVE); - if (developer->integer) { - g_shownpc = gi.Cvar_Get("g_shownpc", "1", 0); - } else { - g_shownpc = gi.Cvar_Get("g_shownpc", "0", 0); - } + g_shownpc = gi.Cvar_Get("g_shownpc", "0", 0); + + // Removed in OPM + //if (developer->integer) { + // g_shownpc = gi.Cvar_Get("g_shownpc", "1", 0); + //} else { + // g_shownpc = gi.Cvar_Get("g_shownpc", "0", 0); + //} s_debugmusic = gi.Cvar_Get("s_debugmusic", "0", 0); @@ -461,7 +507,7 @@ void CVAR_Init(void) gi.cvar_set("deathmatch", "1"); } - if (g_protocol >= PROTOCOL_MOHTA_MIN) { + if (g_protocol >= protocol_e::PROTOCOL_MOHTA_MIN) { if (gi.Cvar_Get("com_target_game", "", 0)->integer == target_game_e::TG_MOHTT) { // Set the server type to mohaab gi.cvar_set("g_servertype", va("%d", target_game_e::TG_MOHTT)); @@ -557,16 +603,12 @@ void CVAR_Init(void) g_voiceChatTime = gi.Cvar_Get("g_voiceChatTime", "2.5", 0); g_textChatTime = gi.Cvar_Get("g_textChatTime", "1", 0); g_debugsmoke = gi.Cvar_Get("g_debugsmoke", "0", CVAR_CHEAT); - gi.Cvar_Get("g_obj_alliedtext1", "", CVAR_SERVERINFO); - gi.Cvar_Get("g_obj_alliedtext2", "", CVAR_SERVERINFO); - gi.Cvar_Get("g_obj_alliedtext3", "", CVAR_SERVERINFO); - gi.Cvar_Get("g_obj_alliedtext4", "", CVAR_SERVERINFO); - gi.Cvar_Get("g_obj_alliedtext5", "", CVAR_SERVERINFO); - gi.Cvar_Get("g_obj_axistext1", "", CVAR_SERVERINFO); - gi.Cvar_Get("g_obj_axistext2", "", CVAR_SERVERINFO); - gi.Cvar_Get("g_obj_axistext3", "", CVAR_SERVERINFO); - gi.Cvar_Get("g_obj_axistext4", "", CVAR_SERVERINFO); - gi.Cvar_Get("g_obj_axistext5", "", CVAR_SERVERINFO); + + for (i = 1; i <= 5; i++) { + gi.Cvar_Get(va("g_obj_alliedtext%d", i), "", CVAR_SERVERINFO); + gi.Cvar_Get(va("g_obj_axistext%d", i), "", CVAR_SERVERINFO); + } + gi.Cvar_Get("g_scoreboardpic", "", CVAR_SERVERINFO); gi.Cvar_Get("g_scoreboardpicover", "", CVAR_SERVERINFO); @@ -591,16 +633,29 @@ void CVAR_Init(void) g_rifles_for_sweepers = gi.Cvar_Get("g_rifles_for_sweepers", "0", 0); g_no_seasick = gi.Cvar_Get("g_no_seasick", "0", 0); - if (g_protocol >= protocol_e::PROTOCOL_MOHTA_MIN) { - g_obituarylocation = gi.Cvar_Get("g_obituarylocation", "0", 0); + // + // Added in OPM + // Clear the text objectives and the scoreboard pic + // + for (i = 1; i <= 5; i++) { + gi.cvar_set(va("g_obj_alliedtext%d", i), ""); + gi.cvar_set(va("g_obj_axistext%d", i), ""); + } + gi.cvar_set("g_scoreboardpic", ""); + + sv_netoptimize = gi.Cvar_Get("sv_netoptimize", "0", 0); + + if (g_target_game >= target_game_e::TG_MOHTA) { + g_obituarylocation = gi.Cvar_Get("g_obituarylocation", "0", 0); } else { // Defaults to 1 on vanilla mohaa - g_obituarylocation = gi.Cvar_Get("g_obituarylocation", "1", 0); + g_obituarylocation = gi.Cvar_Get("g_obituarylocation", "1", 0); } sv_scriptfiles = gi.Cvar_Get("sv_scriptfiles", "0", 0); sv_maxbots = gi.Cvar_Get("sv_maxbots", "0", CVAR_LATCH); - sv_numbots = gi.Cvar_Get("sv_numbots", "0", CVAR_LATCH); + sv_sharedbots = gi.Cvar_Get("sv_sharedbots", "0", CVAR_LATCH); + sv_numbots = gi.Cvar_Get("sv_numbots", "0", 0); sv_minPlayers = gi.Cvar_Get("sv_minPlayers", "0", 0); g_rankedserver = gi.Cvar_Get("g_rankedserver", "0", 0); g_spectatefollow_firstperson = gi.Cvar_Get("g_spectatefollow_firstperson", "0", 0); @@ -614,8 +669,12 @@ void CVAR_Init(void) gi.Printf("sv_maxbots reached max clients, lowering the value to %u\n", lowered); } - if (sv_numbots->integer > sv_maxbots->integer) { - gi.Printf("numbots overflow, setting to %d\n", sv_maxbots->integer); - gi.cvar_set("sv_numbots", sv_maxbots->string); - } + g_instamsg_allowed = gi.Cvar_Get("g_instamsg_allowed", "1", 0); + g_instamsg_minDelay = gi.Cvar_Get("g_instamsg_minDelay", "1000", 0); + g_textmsg_allowed = gi.Cvar_Get("g_textmsg_allowed", "1", 0); + g_textmsg_minDelay = gi.Cvar_Get("g_textmsg_minDelay", "1000", 0); + + g_teambalance = gi.Cvar_Get("g_teambalance", "0", 0); + + cl_running = gi.Cvar_Get("cl_running", "", 0); } diff --git a/code/fgame/gamecvars.h b/code/fgame/gamecvars.h index 8103ae5e..1f03a1dd 100644 --- a/code/fgame/gamecvars.h +++ b/code/fgame/gamecvars.h @@ -31,7 +31,6 @@ extern "C" { #endif extern cvar_t *developer; -extern cvar_t *sv_specialgame; extern cvar_t *deathmatch; extern cvar_t *dmflags; @@ -64,7 +63,7 @@ extern cvar_t *sv_rollspeed; extern cvar_t *sv_rollangle; extern cvar_t *sv_cheats; extern cvar_t *sv_showbboxes; -extern cvar_t *sv_showbtags; +extern cvar_t *sv_showtags; extern cvar_t *sv_testloc_num; extern cvar_t *sv_testloc_secondary; @@ -263,16 +262,28 @@ extern cvar_t *g_no_seasick; extern cvar_t *g_aistats; -extern cvar_t* g_obituarylocation; +extern cvar_t *sv_netoptimize; + +extern cvar_t *g_obituarylocation; extern cvar_t *sv_scriptfiles; extern cvar_t *sv_maxbots; extern cvar_t *sv_numbots; extern cvar_t *sv_minPlayers; +extern cvar_t *sv_sharedbots; extern cvar_t *g_rankedserver; extern cvar_t *g_spectatefollow_firstperson; +extern cvar_t *cl_running; + +extern cvar_t *g_instamsg_allowed; +extern cvar_t *g_instamsg_minDelay; +extern cvar_t *g_textmsg_allowed; +extern cvar_t *g_textmsg_minDelay; + +extern cvar_t *g_teambalance; + void CVAR_Init(void); #ifdef __cplusplus diff --git a/code/fgame/gamescript.cpp b/code/fgame/gamescript.cpp index fd3a18eb..fe5999c0 100644 --- a/code/fgame/gamescript.cpp +++ b/code/fgame/gamescript.cpp @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2025 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -45,24 +45,54 @@ const_str AbstractScript::ConstFilename(void) bool AbstractScript::GetSourceAt(size_t sourcePos, str *sourceLine, int& column, int& line) { + size_t posLine; + size_t i; + size_t start; + char *p; + char old_token; + sourceinfo_t *minCachedInfo = NULL; + if (!m_SourceBuffer || sourcePos >= m_SourceLength) { return false; } - line = 1; - column = 0; - int posLine = 0; + line = 1; + column = 0; + posLine = 0; + start = 0; - char *p = m_SourceBuffer; - char old_token; + p = m_SourceBuffer; - for (int i = 0; i < sourcePos; i++, p++) { + if (sourcePos > 128) { + // Start caching above certain values + + for (i = 0; i < ARRAY_LEN(cachedInfo); i++) { + sourceinfo_t *info = &cachedInfo[i]; + + if (info->line && sourcePos > info->sourcePos + && (!minCachedInfo || info->sourcePos > minCachedInfo->sourcePos)) { + minCachedInfo = info; + } + } + + if (minCachedInfo) { + start = minCachedInfo->sourcePos; + line = minCachedInfo->line; + column = minCachedInfo->column; + posLine = minCachedInfo->startLinePos; + } + } + + for (i = start; i < sourcePos; i++) { + p = m_SourceBuffer + i; column++; if (*p == '\n') { line++; - column = 0; - posLine = i + 1; + column = 0; + if (i + 1 != sourcePos) { + posLine = i + 1; + } } else if (*p == '\0') { break; } @@ -81,6 +111,12 @@ bool AbstractScript::GetSourceAt(size_t sourcePos, str *sourceLine, int& column, *p = old_token; + cachedInfo[cachedInfoIndex].sourcePos = sourcePos; + cachedInfo[cachedInfoIndex].line = line; + cachedInfo[cachedInfoIndex].column = column; + cachedInfo[cachedInfoIndex].startLinePos = posLine; + cachedInfoIndex = (cachedInfoIndex + 1) % ARRAY_LEN(cachedInfo); + return true; } @@ -104,7 +140,7 @@ void AbstractScript::PrintSourcePos(sourceinfo_t *sourcePos, bool dev) if (GetSourceAt(sourcePos->sourcePos, &sourceLine, column, line)) { PrintSourcePos(sourceLine, column, line, dev); } else { - glbs.DPrintf( + gi.DPrintf( "file '%s', source pos %d line %d column %d:\n", Filename().c_str(), sourcePos->sourcePos, @@ -123,7 +159,7 @@ void AbstractScript::PrintSourcePos(size_t sourcePos, bool dev) if (GetSourceAt(sourcePos, &sourceLine, column, line)) { PrintSourcePos(sourceLine, column, line, dev); } else { - glbs.DPrintf("file '%s', source pos %d:\n", Filename().c_str(), sourcePos); + gi.DPrintf("file '%s', source pos %d:\n", Filename().c_str(), sourcePos); } } @@ -153,14 +189,15 @@ void AbstractScript::PrintSourcePos(str sourceLine, int column, int line, bool d markerLine.append("^"); - glbs.DPrintf("(%s, %d):\n%s\n%s\n", Filename().c_str(), line, sourceLine.c_str(), markerLine.c_str()); + gi.DPrintf("(%s, %d):\n%s\n%s\n", Filename().c_str(), line, sourceLine.c_str(), markerLine.c_str()); } AbstractScript::AbstractScript() { - m_ProgToSource = NULL; - m_SourceBuffer = NULL; - m_SourceLength = 0; + m_ProgToSource = NULL; + m_SourceBuffer = NULL; + m_SourceLength = 0; + cachedInfoIndex = 0; } StateScript::StateScript() @@ -493,7 +530,7 @@ void GameScript::Archive(Archiver& arc) } else { - m_ProgBuffer = ( unsigned char * )glbs.Malloc( m_ProgLength ); + m_ProgBuffer = ( unsigned char * )gi.Malloc( m_ProgLength ); code_pos = m_ProgBuffer; code_end = m_ProgBuffer + m_ProgLength; @@ -591,14 +628,14 @@ void GameScript::Archive(Archiver& arc) { fileHandle_t filehandle = NULL; - m_SourceLength = glbs.FS_ReadFile( Filename().c_str(), ( void ** )&m_SourceBuffer, true ); + m_SourceLength = gi.FS_ReadFile( Filename().c_str(), ( void ** )&m_SourceBuffer, true ); if( m_SourceLength > 0 ) { - m_SourceBuffer = ( char * )glbs.Malloc( m_SourceLength ); + m_SourceBuffer = ( char * )gi.Malloc( m_SourceLength ); - glbs.FS_Read( m_SourceBuffer, m_SourceLength, filehandle ); - glbs.FS_FCloseFile( filehandle ); + gi.FS_Read( m_SourceBuffer, m_SourceLength, filehandle ); + gi.FS_FCloseFile( filehandle ); } } @@ -649,10 +686,17 @@ void GameScript::ArchiveCodePos(Archiver& arc, unsigned char **codePos) void GameScript::Close(void) { + // Free up catch blocks for (int i = m_CatchBlocks.NumObjects(); i > 0; i--) { delete m_CatchBlocks.ObjectAt(i); } + // Added in OPM + // Free up allocated state scripts + for (int i = m_StateScripts.NumObjects(); i > 0; i--) { + delete m_StateScripts.ObjectAt(i); + } + m_CatchBlocks.FreeObjectList(); if (m_ProgToSource) { @@ -661,12 +705,12 @@ void GameScript::Close(void) } if (m_ProgBuffer) { - glbs.Free(m_ProgBuffer); + gi.Free(m_ProgBuffer); m_ProgBuffer = NULL; } if (m_SourceBuffer) { - glbs.Free(m_SourceBuffer); + gi.Free(m_SourceBuffer); m_SourceBuffer = NULL; } @@ -680,7 +724,7 @@ void GameScript::Load(const void *sourceBuffer, size_t sourceLength) size_t nodeLength; char *m_PreprocessedBuffer; - m_SourceBuffer = (char *)glbs.Malloc(sourceLength + 2); + m_SourceBuffer = (char *)gi.Malloc(sourceLength + 2); m_SourceLength = sourceLength; // Original mohaa doesn't reallocate the input string to append a newline @@ -694,19 +738,24 @@ void GameScript::Load(const void *sourceBuffer, size_t sourceLength) Compiler.Reset(); m_PreprocessedBuffer = Compiler.Preprocess(m_SourceBuffer); - nodeLength = Compiler.Parse(this, m_PreprocessedBuffer, "script"); - Compiler.Preclean(m_PreprocessedBuffer); - - if (!nodeLength) { - glbs.DPrintf2("^~^~^ Script file compile error: Couldn't parse '%s'\n", Filename().c_str()); + if (!Compiler.Parse(this, m_PreprocessedBuffer, "script", nodeLength)) { + gi.DPrintf2("^~^~^ Script file compile error: Couldn't parse '%s'\n", Filename().c_str()); return Close(); } - m_ProgBuffer = (unsigned char *)glbs.Malloc(nodeLength); - m_ProgLength = Compiler.Compile(this, m_ProgBuffer); + if (nodeLength == 0) { + // No code, assume success + requiredStackSize = 0; + successCompile = true; + return; + } - if (!m_ProgLength) { - glbs.DPrintf2("^~^~^ Script file compile error: Couldn't compile '%s'\n", Filename().c_str()); + Compiler.Preclean(m_PreprocessedBuffer); + + m_ProgBuffer = (unsigned char *)gi.Malloc(nodeLength); + + if (!Compiler.Compile(this, m_ProgBuffer, m_ProgLength)) { + gi.DPrintf2("^~^~^ Script file compile error: Couldn't compile '%s'\n", Filename().c_str()); return Close(); } @@ -772,7 +821,11 @@ StateScript *GameScript::CreateCatchStateScript(unsigned char *try_begin_code_po StateScript *GameScript::CreateSwitchStateScript(void) { - return new StateScript; + StateScript *stateScript = new StateScript; + + m_StateScripts.AddObject(stateScript); + + return stateScript; } StateScript *GameScript::GetCatchStateScript(unsigned char *in, unsigned char *& out) @@ -824,7 +877,7 @@ ScriptThreadLabel::ScriptThreadLabel() m_Label = STRING_EMPTY; } -ScriptThread *ScriptThreadLabel::Create(Listener *listener) +ScriptThread *ScriptThreadLabel::Create(Listener *listener) const { ScriptClass *scriptClass; ScriptThread *thread; @@ -854,7 +907,7 @@ ScriptThread *ScriptThreadLabel::Create(Listener *listener) return thread; } -void ScriptThreadLabel::Execute(Listener *listener) +void ScriptThreadLabel::Execute(Listener *listener) const { if (!m_Script) { return; @@ -867,12 +920,7 @@ void ScriptThreadLabel::Execute(Listener *listener) } } -void ScriptThreadLabel::Execute(Listener *listener, Event& ev) -{ - Execute(listener, &ev); -} - -void ScriptThreadLabel::Execute(Listener *listener, Event *ev) +void ScriptThreadLabel::Execute(Listener *listener, Event& ev) const { if (!m_Script) { return; @@ -885,7 +933,13 @@ void ScriptThreadLabel::Execute(Listener *listener, Event *ev) } } -void ScriptThreadLabel::Execute(Listener* pSelf, const SafePtr& listener, const SafePtr& param) +void ScriptThreadLabel::Execute(Listener *listener, Event *ev) const +{ + Execute(listener, *ev); +} + +void ScriptThreadLabel::Execute(Listener *pSelf, const SafePtr& listener, const SafePtr& param) + const { if (!m_Script) { return; @@ -924,7 +978,7 @@ void ScriptThreadLabel::Set(const char *label) return; } - strcpy(buffer, label); + Q_strncpyz(buffer, label, sizeof(buffer)); while (true) { if (p[0] == ':' && p[1] == ':') { @@ -978,28 +1032,46 @@ void ScriptThreadLabel::Set(const_str label) void ScriptThreadLabel::SetScript(const ScriptVariable& label) { - if (label.GetType() == VARIABLE_STRING || label.GetType() == VARIABLE_CONSTSTRING) { + switch (label.GetType()) { + case VARIABLE_STRING: m_Script = Director.GetGameScript(label.stringValue()); m_Label = STRING_EMPTY; - } else if (label.GetType() == VARIABLE_CONSTARRAY && label.arraysize() > 1) { - ScriptVariable *script = label[1]; - ScriptVariable *labelname = label[2]; + break; + case VARIABLE_CONSTSTRING: + m_Script = Director.GetGameScript(label.constStringValue()); + m_Label = STRING_EMPTY; + break; + case VARIABLE_NONE: + m_Script = NULL; + m_Label = STRING_EMPTY; + break; + case VARIABLE_CONSTARRAY: + if (label.arraysize() > 1) { + ScriptVariable *script = label[1]; + ScriptVariable *labelname = label[2]; - m_Script = Director.GetGameScript(script->stringValue()); - m_Label = labelname->constStringValue(); + if (script->GetType() == VARIABLE_CONSTSTRING) { + m_Script = Director.GetGameScript(script->constStringValue()); + } else { + m_Script = Director.GetGameScript(script->stringValue()); + } - if (!m_Script->m_State.FindLabel(m_Label)) { - m_Script = NULL; - m_Label = STRING_EMPTY; - - ScriptError( - "^~^~^ Could not find label '%s' in '%s'", - labelname->stringValue().c_str(), - script->stringValue().c_str() - ); + m_Label = labelname->constStringValue(); + break; } - } else { + default: ScriptError("ScriptThreadLabel::SetScript: bad label type '%s'", label.GetTypeName()); + break; + } + + if (m_Script && !m_Script->m_State.FindLabel(m_Label)) { + const str& scriptName = m_Script->Filename(); + const str& labelName = Director.GetString(m_Label); + + m_Script = NULL; + m_Label = STRING_EMPTY; + + ScriptError("^~^~^ Could not find label '%s' in '%s'", scriptName.c_str(), labelName.c_str()); } } @@ -1017,7 +1089,7 @@ void ScriptThreadLabel::SetScript(const char *label) return; } - strcpy(buffer, label); + Q_strncpyz(buffer, label, sizeof(buffer)); script = buffer; while (true) { @@ -1066,30 +1138,43 @@ void ScriptThreadLabel::SetScript(const_str label) void ScriptThreadLabel::SetThread(const ScriptVariable& label) { - ScriptThread *thread = NULL; - - if (label.GetType() == VARIABLE_STRING || label.GetType() == VARIABLE_CONSTSTRING) { + switch (label.GetType()) { + case VARIABLE_STRING: + case VARIABLE_CONSTSTRING: m_Script = Director.CurrentScriptClass()->GetScript(); m_Label = label.constStringValue(); - } else if (label.GetType() == VARIABLE_CONSTARRAY && label.arraysize() > 1) { - ScriptVariable *script = label[1]; - ScriptVariable *labelname = label[2]; + break; + case VARIABLE_NONE: + m_Script = NULL; + m_Label = STRING_EMPTY; + break; + case VARIABLE_CONSTARRAY: + if (label.arraysize() > 1) { + ScriptVariable *script = label[1]; + ScriptVariable *labelname = label[2]; - m_Script = Director.GetGameScript(script->stringValue()); - m_Label = labelname->constStringValue(); + if (script->GetType() == VARIABLE_CONSTSTRING) { + m_Script = Director.GetGameScript(script->constStringValue()); + } else { + m_Script = Director.GetGameScript(script->stringValue()); + } - if (!m_Script->m_State.FindLabel(m_Label)) { - m_Script = NULL; - m_Label = STRING_EMPTY; - - ScriptError( - "^~^~^ Could not find label '%s' in '%s'", - labelname->stringValue().c_str(), - script->stringValue().c_str() - ); + m_Label = labelname->constStringValue(); + break; } - } else { - ScriptError("ScriptThreadLabel::SetThread bad label type '%s'", label.GetTypeName()); + default: + ScriptError("ScriptThreadLabel::SetThread: bad label type '%s'", label.GetTypeName()); + break; + } + + if (m_Script && !m_Script->m_State.FindLabel(m_Label)) { + const str& scriptName = m_Script->Filename(); + const str& labelName = Director.GetString(m_Label); + + m_Script = NULL; + m_Label = STRING_EMPTY; + + ScriptError("^~^~^ Could not find label '%s' in '%s'", scriptName.c_str(), labelName.c_str()); } } @@ -1141,7 +1226,7 @@ bool ScriptThreadLabel::TrySetScript(const_str label) return true; } -void ScriptThreadLabel::GetScriptValue(ScriptVariable *var) +void ScriptThreadLabel::GetScriptValue(ScriptVariable *var) const { if (!m_Script) { var->Clear(); @@ -1155,12 +1240,12 @@ void ScriptThreadLabel::GetScriptValue(ScriptVariable *var) var->setConstArrayValue(var_array, 2); } -bool ScriptThreadLabel::IsSet(void) +bool ScriptThreadLabel::IsSet(void) const { return m_Script != NULL; } -bool ScriptThreadLabel::IsFile(const_str filename) +bool ScriptThreadLabel::IsFile(const_str filename) const { return m_Script && m_Script->ConstFilename() == filename && m_Label == STRING_EMPTY; } diff --git a/code/fgame/gamescript.h b/code/fgame/gamescript.h index f4fc1f6b..80af333b 100644 --- a/code/fgame/gamescript.h +++ b/code/fgame/gamescript.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2025 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -39,11 +39,18 @@ typedef struct { bool isprivate; // new script engine implementation } script_label_t; -typedef struct { +struct sourceinfo_t { unsigned int sourcePos; + unsigned int startLinePos; int column; int line; -} sourceinfo_t; + + sourceinfo_t() + : sourcePos(0) + , column(0) + , line(0) + {} +}; class AbstractScript { @@ -56,13 +63,16 @@ public: // Developper variable con_set *m_ProgToSource; + sourceinfo_t cachedInfo[16]; + size_t cachedInfoIndex; + public: AbstractScript(); - str & Filename(void); + str& Filename(void); const_str ConstFilename(void); - bool GetSourceAt(size_t sourcePos, str *sourceLine, int &column, int &line); - bool GetSourceAt(const unsigned char *sourcePos, str *sourceLine, int &column, int &line); + bool GetSourceAt(size_t sourcePos, str *sourceLine, int& column, int& line); + bool GetSourceAt(const unsigned char *sourcePos, str *sourceLine, int& column, int& line); void PrintSourcePos(sourceinfo_t *sourcePos, bool dev); void PrintSourcePos(size_t sourcePos, bool dev); void PrintSourcePos(unsigned char *m_pCodePos, bool dev); @@ -108,7 +118,8 @@ class GameScript : public AbstractScript { protected: // try/throw variable - Container m_CatchBlocks; + Container m_CatchBlocks; + Container m_StateScripts; public: // program variables @@ -128,9 +139,9 @@ public: GameScript(const char *filename); ~GameScript(); - void Archive(Archiver &arc); + void Archive(Archiver& arc); static void Archive(Archiver& arc, GameScript *& scr); - void ArchiveCodePos(Archiver &arc, unsigned char **codePos); + void ArchiveCodePos(Archiver& arc, unsigned char **codePos); void Close(void); void Load(const void *sourceBuffer, size_t sourceLength); @@ -159,11 +170,11 @@ private: public: ScriptThreadLabel(); - ScriptThread *Create(Listener *listener); - void Execute(Listener *listener = NULL); - void Execute(Listener *listener, Event &ev); - void Execute(Listener *listener, Event *ev); - void Execute(Listener* pSelf, const SafePtr &listener, const SafePtr ¶m); + ScriptThread *Create(Listener *listener) const; + void Execute(Listener *listener = NULL) const; + void Execute(Listener *listener, Event& ev) const; + void Execute(Listener *listener, Event *ev) const; + void Execute(Listener *pSelf, const SafePtr& listener, const SafePtr& param) const; void Clear(); void Set(const char *label); @@ -178,10 +189,10 @@ public: bool TrySetScript(const_str label); bool TrySetScript(const char *label); - bool IsSet(void); - bool IsFile(const_str filename); + bool IsSet(void) const; + bool IsFile(const_str filename) const; - void GetScriptValue(ScriptVariable *var); + void GetScriptValue(ScriptVariable *var) const; void Archive(Archiver& arc); diff --git a/code/fgame/gibs.cpp b/code/fgame/gibs.cpp index e53b3546..6ee01738 100644 --- a/code/fgame/gibs.cpp +++ b/code/fgame/gibs.cpp @@ -147,7 +147,7 @@ void Gib::Splat ) { - if ( g_gametype->integer ) + if ( g_gametype->integer != GT_SINGLE_PLAYER ) return; if ( sprayed > 3 ) diff --git a/code/fgame/gibs.h b/code/fgame/gibs.h index 382d201d..364ee54e 100644 --- a/code/fgame/gibs.h +++ b/code/fgame/gibs.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -22,8 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // gibs.h: Gibs - nuff said -#ifndef __GIBS_H__ -#define __GIBS_H__ +#pragma once #include "g_local.h" #include "mover.h" @@ -88,5 +87,3 @@ void CreateGibs ); extern Event EV_ThrowGib; - -#endif // gibs.h diff --git a/code/fgame/glb_local.h b/code/fgame/glb_local.h index 673a55f3..588f975d 100644 --- a/code/fgame/glb_local.h +++ b/code/fgame/glb_local.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -20,8 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -#ifndef __GLB_LOCAL_H__ -#define __GLB_LOCAL_H__ +#pragma once #if defined( GAME_DLL ) @@ -79,5 +78,3 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #endif #endif - -#endif /* glb_local.h */ diff --git a/code/fgame/gravpath.h b/code/fgame/gravpath.h index efa56b6f..d3a6380e 100644 --- a/code/fgame/gravpath.h +++ b/code/fgame/gravpath.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -22,8 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // gravpath.h: Gravity path - Used for underwater currents and wells. -#ifndef __GRAVPATH_H__ -#define __GRAVPATH_H__ +#pragma once #include "g_local.h" #include "class.h" @@ -202,5 +201,3 @@ inline void GravPathManager::Archive } extern GravPathManager gravPathManager; - -#endif /* gravpath.h */ diff --git a/code/fgame/grenadehint.h b/code/fgame/grenadehint.h index 48bc9803..0661f769 100644 --- a/code/fgame/grenadehint.h +++ b/code/fgame/grenadehint.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -22,8 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // grenadehint.h: Grenade hint for actors. -#ifndef __GRENADEHINT_H__ -#define __GRENADEHINT_H__ +#pragma once #include "g_local.h" #include "archive.h" @@ -53,5 +52,3 @@ inline void GrenadeHint::Archive arc.ArchiveObjectPointer( ( Class ** )&m_pNext ); } - -#endif diff --git a/code/fgame/health.cpp b/code/fgame/health.cpp index 5af8fd15..a7d19f33 100644 --- a/code/fgame/health.cpp +++ b/code/fgame/health.cpp @@ -44,12 +44,22 @@ SafePtr Health::mHealthQueue[MAX_HEALTH_QUEUE]; Health::Health() { + if (LoadingSavegame) { + return; + } + if (DM_FLAG(DF_NO_HEALTH)) { PostEvent(EV_Remove, EV_REMOVE); return; } setAmount(20); + + // Added in 2.0 + // Set the targetname to health by default + SetTargetName("health"); + + PostEvent(EV_Health_PostSpawn, EV_POSTSPAWN); } void Health::PickupHealth(Event *ev) @@ -64,8 +74,19 @@ void Health::PickupHealth(Event *ev) player = (Player *)other; - if (player->health >= player->max_health) { - return; + if (g_healrate->value && other->IsSubclassOfPlayer()) { + // Added in OPM + // OG doesn't check if the future health will be full + // which is problematic as other can pickup the item + // will healing + if (player->m_fHealRate + player->health >= player->max_health) { + // will be healing to 100% + return; + } + } else { + if (player->health >= player->max_health) { + return; + } } if (!ItemPickup(other, qfalse)) { @@ -93,7 +114,7 @@ void Health::PickupHealth(Event *ev) gi.SendServerCommand( player->edict - g_entities, - "print \"" HUD_MESSAGE_YELLOW "%s \"", + "print \"" HUD_MESSAGE_YELLOW "%s\n\"", gi.LV_ConvertString(va("Recovered %d Health", amount)) ); } diff --git a/code/fgame/health.h b/code/fgame/health.h index d32e77fe..a9064b62 100644 --- a/code/fgame/health.h +++ b/code/fgame/health.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -23,8 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // health.h: Health powerup // -#ifndef __HEALTH_H__ -#define __HEALTH_H__ +#pragma once #include "g_local.h" #include "item.h" @@ -52,5 +51,3 @@ public: private: static SafePtr mHealthQueue[MAX_HEALTH_QUEUE]; }; - -#endif /* health.h */ diff --git a/code/fgame/hud.cpp b/code/fgame/hud.cpp index 1417d75d..46a93c37 100644 --- a/code/fgame/hud.cpp +++ b/code/fgame/hud.cpp @@ -779,7 +779,7 @@ void Hud::TimerThink() #else if( !*shader ) { #endif - sprintf( buffer, string, minutes, seconds ); + Com_sprintf( buffer, sizeof( buffer ), string, minutes, seconds ); SetText( buffer ); } else { @@ -1001,7 +1001,6 @@ void Hud::MoveOverTime( float time ) void Hud::Refresh( int clientNumber ) { -#ifdef GAME_DLL SetBroadcast( clientNumber ); gi.MSG_StartCGM( BG_MapCGMToProtocol(g_protocol, CGM_HUDDRAW_ALIGN )); @@ -1093,13 +1092,13 @@ void Hud::Refresh( int clientNumber ) gi.MSG_WriteBits( virtualSize, 1 ); gi.MSG_EndCGM(); +#ifdef OPM_FEATURES if( sv_specialgame->integer ) { if( isDimensional ) { SetBroadcast(); - /* gi.MSG_StartCGM( BG_MapCGMToProtocol(g_protocol, CGM_HUDDRAW_3D )); WriteNumber(); gi.MSG_WriteCoord( org[ 0 ] ); @@ -1111,19 +1110,16 @@ void Hud::Refresh( int clientNumber ) gi.MSG_WriteBits( !!always_show, 1 ); gi.MSG_WriteBits( !!depth, 1 ); gi.MSG_EndCGM(); - */ } if( fade_alpha ) { SetBroadcast(); - /* gi.MSG_StartCGM( BG_MapCGMToProtocol(g_protocol, CGM_HUDDRAW_FADE )); WriteNumber(); gi.MSG_WriteFloat( fade_alpha_current ); gi.MSG_EndCGM(); - */ SetBroadcast(); @@ -1137,7 +1133,6 @@ void Hud::Refresh( int clientNumber ) { SetBroadcast(); - /* gi.MSG_StartCGM( BG_MapCGMToProtocol(g_protocol, CGM_HUDDRAW_MOVE )); WriteNumber(); gi.MSG_WriteFloat( fade_move_current ); @@ -1150,12 +1145,10 @@ void Hud::Refresh( int clientNumber ) gi.MSG_WriteShort( ( short )fade_move_x_target ); gi.MSG_WriteShort( ( short )fade_move_y_target ); gi.MSG_EndCGM(); - */ } if( fade_timer_flags & TIMER_ACTIVE ) { - /* SetBroadcast(); gi.MSG_StartCGM( BG_MapCGMToProtocol(g_protocol, CGM_HUDDRAW_TIMER )); @@ -1170,7 +1163,6 @@ void Hud::Refresh( int clientNumber ) } gi.MSG_EndCGM(); - */ } } #endif @@ -1232,11 +1224,15 @@ void Hud::SetBroadcast( int clientNumber ) void Hud::WriteNumber() { +#ifdef OPM_FEATURES if(sv_specialgame->integer ) { gi.MSG_WriteShort( number ); } else { gi.MSG_WriteByte( number ); } +#else + gi.MSG_WriteByte(number); +#endif } #endif diff --git a/code/fgame/hud.h b/code/fgame/hud.h index 155915cc..61b53a54 100644 --- a/code/fgame/hud.h +++ b/code/fgame/hud.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -23,8 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // hud.h: New HUD handler for MoHAA // -#ifndef __HUD_H__ -#define __HUD_H__ +#pragma once #include "listener.h" #include "container.h" @@ -208,5 +207,3 @@ public: }; extern Container< Hud * > hudElements; - -#endif /* __HUD_H__ */ diff --git a/code/fgame/huddraw.cpp b/code/fgame/huddraw.cpp index 89bb209f..79784439 100644 --- a/code/fgame/huddraw.cpp +++ b/code/fgame/huddraw.cpp @@ -28,11 +28,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA void HudWriteNumber( int num ) { +#ifdef OPM_FEATURES if(sv_specialgame->integer ) { gi.MSG_WriteShort( num ); } else { gi.MSG_WriteByte( num ); } +#else + gi.MSG_WriteByte(num); +#endif } void HudDrawShader( int info, const char *name ) @@ -41,7 +45,11 @@ void HudDrawShader( int info, const char *name ) gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_HUDDRAW_SHADER)); HudWriteNumber( info ); // c = info gi.MSG_WriteString(name); // s = name (shader_name) - gi.MSG_EndCGM(); + gi.MSG_EndCGM(); + + if (g_gametype->integer == GT_SINGLE_PLAYER) { + gi.HudDrawShader(info, name); + } } void HudDrawAlign( int info, int horizontalAlign, int verticalAlign ) @@ -61,6 +69,10 @@ void HudDrawAlign( int info, int horizontalAlign, int verticalAlign ) gi.MSG_EndCGM(); + if (g_gametype->integer == GT_SINGLE_PLAYER) { + gi.HudDrawAlign(info, horizontalAlign, verticalAlign); + } + } void HudDrawRect(int info, int x, int y, int width, int height) @@ -73,7 +85,10 @@ void HudDrawRect(int info, int x, int y, int width, int height) gi.MSG_WriteShort(width); // c = probably "width" gi.MSG_WriteShort(height); // c = probably "height" gi.MSG_EndCGM(); - + + if (g_gametype->integer == GT_SINGLE_PLAYER) { + gi.HudDrawRect(info, x, y, width, height); + } } void HudDrawVirtualSize(int info, int virtualScreen) @@ -81,20 +96,7 @@ void HudDrawVirtualSize(int info, int virtualScreen) gi.SetBroadcastAll(); gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_HUDDRAW_VIRTUALSIZE)); HudWriteNumber( info ); // c = info - - /*__asm - { - pushad - pushfd - mov eax, virtualScreen - NEG eax - SBB eax, eax - NEG eax - mov virtualScreen, eax - popfd - popad - }*/ - + gi.MSG_WriteBits(!!virtualScreen, 1); // value = ? bits = 1 // value = esi // esi = virtualScreen @@ -104,7 +106,10 @@ void HudDrawVirtualSize(int info, int virtualScreen) // call gi.MSG_EndCGM(); - + + if (g_gametype->integer == GT_SINGLE_PLAYER) { + gi.HudDrawVirtualSize(info, virtualScreen); + } } void HudDrawColor(int info, float *color) @@ -121,7 +126,11 @@ void HudDrawColor(int info, float *color) gi.MSG_WriteByte(temp[0]); // c = color[2] gi.MSG_WriteByte(temp[1]); // c = color[1] - Values can be messed up. To be tested. gi.MSG_WriteByte(temp[2]); // c = color[3] / - gi.MSG_EndCGM(); + gi.MSG_EndCGM(); + + if (g_gametype->integer == GT_SINGLE_PLAYER) { + gi.HudDrawColor(info, color); + } // Note: Each float value is multiplied by 255.0 and converted to long using ftol function, thats why it's using WriteByte } @@ -137,6 +146,10 @@ void HudDrawAlpha(int info, float alpha) gi.MSG_WriteByte(temp); // c = alpha gi.MSG_EndCGM(); + if (g_gametype->integer == GT_SINGLE_PLAYER) { + gi.HudDrawAlpha(info, alpha); + } + // Note: alpha is multiplied by 255.0 and converted to long using ftol function } @@ -149,6 +162,9 @@ void HudDrawString(int info, const char *string) gi.MSG_WriteString(string); // s = string (to show) gi.MSG_EndCGM(); + if (g_gametype->integer == GT_SINGLE_PLAYER) { + gi.HudDrawString(info, string); + } } void HudDrawFont(int info, const char *fontName) @@ -158,7 +174,10 @@ void HudDrawFont(int info, const char *fontName) HudWriteNumber( info ); // c = info gi.MSG_WriteString(fontName); // s = fontName (to use) gi.MSG_EndCGM(); - + + if (g_gametype->integer == GT_SINGLE_PLAYER) { + gi.HudDrawFont(info, fontName); + } } void HudDraw3d( int index, vec3_t vector, int ent_num, qboolean bAlwaysShow, qboolean depth ) diff --git a/code/fgame/huddraw.h b/code/fgame/huddraw.h index d924394d..3d15bb82 100644 --- a/code/fgame/huddraw.h +++ b/code/fgame/huddraw.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -23,8 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // huddraw.cpp : This is a HudDraw Functions Code section with huddraw functions reversed for // altering clients HUD -#ifndef __HUDDRAW_H__ -#define __HUDDRAW_H__ +#pragma once #include "g_local.h" @@ -49,5 +48,3 @@ void iHudDrawAlpha( int cl_num, int info, float alpha ); void iHudDrawString( int cl_num, int info, const char *string ); void iHudDrawFont( int cl_num, int info, const char *fontName ); void iHudDrawTimer( int cl_num, int index, float duration, float fade_out_time ); - -#endif // __HUDDRAW_H__ diff --git a/code/fgame/inventoryitem.h b/code/fgame/inventoryitem.h index f9cbd738..b14129ce 100644 --- a/code/fgame/inventoryitem.h +++ b/code/fgame/inventoryitem.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -23,8 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // inventoryitem.h: Items that are visible in the player's inventory -#ifndef __INVITEM_H__ -#define __INVITEM_H__ +#pragma once #include "weapon.h" @@ -52,5 +51,3 @@ class AntiSBJuice : public InventoryItem void UseEvent( Event *ev ); }; - -#endif /* inventoryitem.h */ diff --git a/code/fgame/ipfilter.cpp b/code/fgame/ipfilter.cpp index 1e73af6e..c823702e 100644 --- a/code/fgame/ipfilter.cpp +++ b/code/fgame/ipfilter.cpp @@ -298,7 +298,7 @@ void SVCmd_WriteIP_f byte b[ 4 ]; int i; - sprintf( name, "%s/listip.cfg", GAMEVERSION ); + Com_sprintf( name, sizeof( name ), "%s/listip.cfg", GAMEVERSION ); gi.SendServerCommand( 0, "print \"Writing %s.\n\"", name ); f = fopen( name, "wb" ); diff --git a/code/fgame/ipfilter.h b/code/fgame/ipfilter.h index a09c9216..28fb7a69 100644 --- a/code/fgame/ipfilter.h +++ b/code/fgame/ipfilter.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -23,11 +23,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // ipfilter.h: DESCRIPTION: // -#ifndef __IPFILTER_H__ -#define __IPFILTER_H__ +#pragma once #include "g_local.h" qboolean SV_FilterPacket( const char *from ); - -#endif /* !__IPFILTER_H__ */ diff --git a/code/fgame/item.cpp b/code/fgame/item.cpp index 63d1a350..5c4a3bfc 100644 --- a/code/fgame/item.cpp +++ b/code/fgame/item.cpp @@ -291,6 +291,7 @@ Event EV_Item_SetPickupSound EV_NORMAL ); +#ifdef OPM_FEATURES Event EV_Item_ViewModelPrefix ( "viewmodelprefix", @@ -310,6 +311,7 @@ Event EV_Item_UpdatePrefix "internal event - update the custom viewmodel prefix", EV_NORMAL ); +#endif CLASS_DECLARATION(Trigger, Item, NULL) { {&EV_Trigger_Effect, &Item::ItemTouch }, @@ -332,8 +334,10 @@ CLASS_DECLARATION(Trigger, Item, NULL) { {&EV_Item_SetDMAmount, &Item::SetDMAmountEvent }, {&EV_Item_SetDMMaxAmount, &Item::SetDMMaxAmount }, {&EV_Item_SetPickupSound, &Item::SetPickupSound }, +#ifdef OPM_FEATURES {&EV_Item_ViewModelPrefix, &Item::EventViewModelPrefix }, {&EV_Item_UpdatePrefix, &Item::updatePrefix }, +#endif {NULL, NULL } }; @@ -414,15 +418,11 @@ void Item::RemoveFromOwner(void) void Item::Delete(void) { - if (g_iInThinks) { - if (owner) { - RemoveFromOwner(); - } - - PostEvent(EV_Remove, 0); - } else { - delete this; + if (g_iInThinks && owner) { + RemoveFromOwner(); } + + Animate::Delete(); } void Item::SetNoRemove(Event *ev) @@ -555,10 +555,12 @@ void Item::SetOwner(Sentient *ent) CancelEventsOfType(EV_Item_DropToFloor); CancelEventsOfType(EV_Remove); +#ifdef OPM_FEATURES Event *ev = new Event(EV_Item_UpdatePrefix); ev->AddEntity(ent); PostEvent(ev, EV_POSTSPAWN); +#endif } Sentient *Item::GetOwner(void) @@ -751,7 +753,7 @@ void Item::setName(const char *i) item_name = i; item_index = gi.itemindex(i); - strcpy(edict->entname, i); + Q_strncpyz(edict->entname, i, sizeof(edict->entname)); prefix = GetItemPrefix(item_name); if (prefix) { @@ -806,7 +808,7 @@ void Item::SetMaxAmount(Event *ev) void Item::SetDMAmountEvent(Event *ev) { - if (!g_gametype->integer) { + if (g_gametype->integer == GT_SINGLE_PLAYER) { return; } setAmount(ev->GetInteger(1)); @@ -814,7 +816,7 @@ void Item::SetDMAmountEvent(Event *ev) void Item::SetDMMaxAmount(Event *ev) { - if (!g_gametype->integer) { + if (g_gametype->integer == GT_SINGLE_PLAYER) { return; } setAmount(ev->GetInteger(1)); @@ -897,6 +899,22 @@ void Item::Landed(Event *ev) setMoveType(MOVETYPE_NONE); } +Listener *Item::GetScriptOwner() +{ + return owner; +} + +void Item::SetScriptOwner(Listener *newOwner) +{ + if (!newOwner || !newOwner->isSubclassOf(Sentient)) { + owner = NULL; + return; + } + + owner = static_cast(newOwner); +} + +#ifdef OPM_FEATURES void Item::EventViewModelPrefix(Event *ev) { int i; @@ -922,7 +940,7 @@ void Item::EventViewModelPrefix(Event *ev) void Item::updatePrefix(Event *ev) { - if (!level.specialgame) { + if (!sv_specialgame->integer) { return; } @@ -930,8 +948,6 @@ void Item::updatePrefix(Event *ev) return; } - // FIXME: delete - /* Entity *ent = ev->GetEntity( 1 ); gi.MSG_SetClient( ent->edict - g_entities ); @@ -940,8 +956,8 @@ void Item::updatePrefix(Event *ev) gi.MSG_WriteString( item_name.c_str() ); gi.MSG_WriteString( m_sVMprefix.c_str() ); gi.MSG_EndCGM(); - */ } +#endif CLASS_DECLARATION(Item, DynItem, NULL) { {&EV_Kill, &DynItem::UnlinkItem}, diff --git a/code/fgame/item.h b/code/fgame/item.h index 647f69f6..69516ca5 100644 --- a/code/fgame/item.h +++ b/code/fgame/item.h @@ -121,11 +121,21 @@ public: void Archive(Archiver& arc) override; +public: + // + // Added in OPM + // + + Listener *GetScriptOwner() override; + void SetScriptOwner(Listener *newOwner) override; + +#ifdef OPM_FEATURES // // Custom openmohaa stuff // void EventViewModelPrefix(Event *ev); void updatePrefix(Event *ev); +#endif }; inline void Item::Archive(Archiver& arc) diff --git a/code/fgame/level.cpp b/code/fgame/level.cpp index c98d4fa4..05ee31ac 100644 --- a/code/fgame/level.cpp +++ b/code/fgame/level.cpp @@ -120,7 +120,7 @@ Event EV_Level_SetNoDropHealth Event EV_Level_SetNoDropWeapons ( - "nodropweapon", + "nodropweapons", EV_DEFAULT, "i", "alarm_status", @@ -391,7 +391,7 @@ Event EV_Level_GetRoundBased EV_DEFAULT, NULL, NULL, - "Gets wether or not the game is currently round based or not", + "Gets whether or not the game is currently round based or not", EV_GETTER ); @@ -401,7 +401,7 @@ Event EV_Level_GetObjectiveBased EV_DEFAULT, NULL, NULL, - "Gets wether or not the game is currently objective based or not", + "Gets whether or not the game is currently objective based or not", EV_GETTER ); @@ -695,8 +695,8 @@ CLASS_DECLARATION(Listener, Level, NULL) { {&EV_Level_Rain_Width_Get, &Level::EventRainWidthGet }, {&EV_Level_Rain_Shader_Set, &Level::EventRainShaderSet }, {&EV_Level_Rain_Shader_Get, &Level::EventRainShaderGet }, - {&EV_Level_Rain_NumShaders_Set, &Level::EventRainShaderSet }, - {&EV_Level_Rain_NumShaders_Get, &Level::EventRainShaderGet }, + {&EV_Level_Rain_NumShaders_Set, &Level::EventRainNumShadersSet }, + {&EV_Level_Rain_NumShaders_Get, &Level::EventRainNumShadersGet }, {&EV_Level_AddBadPlace, &Level::EventAddBadPlace }, {&EV_Level_RemoveBadPlace, &Level::EventRemoveBadPlace }, {&EV_Level_IgnoreClock, &Level::EventIgnoreClock }, @@ -834,7 +834,6 @@ void Level::Init(void) m_pAIStats = NULL; - m_bSpawnBot = false; m_bScriptSpawn = false; m_bRejectSpawn = false; } @@ -970,8 +969,8 @@ void Level::CleanUp(qboolean samemap, qboolean resetConfigStrings) gi.setConfigstring(CS_RAIN_NUMSHADERS, "0"); gi.setConfigstring(CS_CURRENT_OBJECTIVE, ""); - for (int i = CS_OBJECTIVES; i < CS_OBJECTIVES + MAX_OBJECTIVES; i++) { - gi.setConfigstring(i, ""); + for (i = 0; i < MAX_OBJECTIVES; i++) { + gi.setConfigstring(CS_OBJECTIVES + i, ""); } gi.setConfigstring(CS_VOTE_TIME, ""); @@ -1098,6 +1097,12 @@ void Level::SpawnEntities(char *entities, int svsTime) int start, end; char name[128]; + if (gi.Cvar_Get("g_invulnoverride", "0", 0)->integer == 1) { + // Added in 2.30 + // Clear the invulnerable override when loading + gi.cvar_set("g_invulnoverride", "0"); + } + Com_Printf("-------------------- Spawning Entities -----------------------\n"); t1 = gi.Milliseconds(); @@ -1164,7 +1169,7 @@ void Level::SpawnEntities(char *entities, int svsTime) Q_strncpyz(ent->edict->entname, ent->getClassID(), sizeof(ent->edict->entname)); ent->PostEvent(EV_Entity_Start, -1.0, 0); - sprintf(name, "i%d", radnum); + Com_sprintf(name, sizeof(name), "i%d", radnum); gi.LoadResource(name); } } @@ -1506,9 +1511,9 @@ void Level::ServerSpawned(void) void Level::SetMap(const char *themapname) { - char *spawnpos; - int i; - str text; + const char *spawnpos; + int i; + str text; Init(); @@ -1517,8 +1522,8 @@ void Level::SetMap(const char *themapname) // set a specific spawnpoint if the map was started with a $ spawnpos = strchr((char *)themapname, '$'); if (spawnpos) { - mapname = (const char *)(spawnpos - themapname); - spawnpoint = mapname; + mapname = str(themapname, 0, spawnpos - themapname); + spawnpoint = spawnpos + 1; } else { mapname = themapname; spawnpoint = ""; @@ -1583,6 +1588,30 @@ void Level::Precache(void) LoadAllScripts("global", ".scr"); InitVoteOptions(); + + // Added in OPM + // Cache all player models in multi-player + // This avoids using precache scripts + if (g_gametype->integer != GT_SINGLE_PLAYER) { + char **fileList; + int numFiles; + int i; + + fileList = gi.FS_ListFiles("models/player", ".tik", qfalse, &numFiles); + + for (i = 0; i < numFiles; i++) { + const char *filename = fileList[i]; + const size_t filelen = strlen(filename); + + if (!Q_stricmpn(filename, "allied_", 7) || !Q_stricmpn(filename, "american_", 9) + || !Q_stricmpn(filename, "german_", 7) || !Q_stricmpn(filename, "IT_", 3) + || !Q_stricmpn(filename, "SC_", 3)) { + CacheResource(va("models/player/%s", filename)); + } + } + + gi.FS_FreeFileList(fileList); + } } /* @@ -1725,6 +1754,10 @@ void Level::FreeEdict(gentity_t *ed) { gclient_t *client; + // clear the model so it decreases the user count + // and free memory if the model is not used anywhere + gi.clearmodel(ed); + // unlink from world gi.unlinkentity(ed); @@ -1911,6 +1944,8 @@ void Level::CheckVote(void) level.m_voteNo++; } } + + numVoters++; } level.m_numVoters = numVoters; @@ -1957,7 +1992,7 @@ void Level::SetupMaplist() return; } - strcpy(buffer, m_voteString.c_str()); + Q_strncpyz(buffer, m_voteString.c_str(), sizeof(buffer)); for (p = strtok(buffer, delim); p; p = strtok(NULL, delim)) { if (strstr(p, "g_gametype")) { @@ -2312,6 +2347,12 @@ void Level::EventRainShaderGet(Event *ev) void Level::EventRainNumShadersSet(Event *ev) { + if (g_protocol <= protocol_e::PROTOCOL_MOH) { + // There is a mistake in 1.11 and below where the NumShader event doesn't work + // Because the response points to EventRainShaderSet + return; + } + gi.setConfigstring(CS_RAIN_NUMSHADERS, ev->GetString(1)); } @@ -2483,19 +2524,19 @@ void Level::Archive(Archiver& arc) Listener::Archive(arc); if (arc.Saving()) { - prespawn = classinfo()->WaitTillDefined("prespawn"); - spawn = classinfo()->WaitTillDefined("spawn"); + prespawn = WaitTillDefined(STRING_PRESPAWN); + spawn = WaitTillDefined(STRING_SPAWN); } arc.ArchiveBool(&prespawn); arc.ArchiveBool(&spawn); if (arc.Loading()) { - if (prespawn) { + if (!prespawn) { RemoveWaitTill(STRING_PRESPAWN); } - if (spawn) { + if (!spawn) { RemoveWaitTill(STRING_SPAWN); } } diff --git a/code/fgame/level.h b/code/fgame/level.h index 0f53ef03..5748b1e6 100644 --- a/code/fgame/level.h +++ b/code/fgame/level.h @@ -251,11 +251,6 @@ public: // New Stuff - // don't put in the game class because it can be changed in another level - qboolean specialgame; - - bool m_bSpawnBot; - // Script stuff bool m_bScriptSpawn; bool m_bRejectSpawn; diff --git a/code/fgame/light.h b/code/fgame/light.h index 9bbcaa66..08d5ac87 100644 --- a/code/fgame/light.h +++ b/code/fgame/light.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -23,8 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // light.h: Classes for creating and controlling lights. // -#ifndef __LIGHT_H__ -#define __LIGHT_H__ +#pragma once #include "g_local.h" #include "entity.h" @@ -36,5 +35,3 @@ class Light : public Entity Light(); }; - -#endif /* light.h */ diff --git a/code/fgame/lodthing.cpp b/code/fgame/lodthing.cpp index 74be7738..b9a68ff8 100644 --- a/code/fgame/lodthing.cpp +++ b/code/fgame/lodthing.cpp @@ -129,6 +129,9 @@ void LODMaster::Spawn gi.cvar_set( "lod_tool", "1" ); ent = g_entities->entity; + if (!ent) { + return; + } if( ent->IsSubclassOfPlayer() ) { diff --git a/code/fgame/misc.cpp b/code/fgame/misc.cpp index c2e95139..14eb47ac 100644 --- a/code/fgame/misc.cpp +++ b/code/fgame/misc.cpp @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2025 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -91,7 +91,7 @@ Used as a positional target for spotlights, etc. ******************************************************************************/ -CLASS_DECLARATION(Entity, InfoNull, "info_null") { +CLASS_DECLARATION(Listener, InfoNull, "info_null") { {NULL, NULL} }; @@ -144,14 +144,55 @@ If PROJECTILES is set, the trigger will respond to projectiles (rockets, grenade #define ACCUMULATIVE (1 << 6) #define TWOSTAGE (1 << 7) -Event EV_ExplodingWall_StopRotating("stoprotating", EV_DEFAULT, NULL, NULL, "Stop rotating the wall.", EV_NORMAL); -Event EV_ExplodingWall_OnGround( - "checkonground", EV_DEFAULT, NULL, NULL, "Check if exploding wall is on ground.", EV_NORMAL +Event EV_ExplodingWall_StopRotating +( + "stoprotating", EV_DEFAULT, + NULL, + NULL, + "Stop rotating the wall.", + EV_NORMAL +); +Event EV_ExplodingWall_OnGround +( + "checkonground", EV_DEFAULT, + NULL, + NULL, + "Check if exploding wall is on ground.", + EV_NORMAL + +); +Event EV_ExplodingWall_AngleSpeed +( + "anglespeed", EV_DEFAULT, + "f", + "speed", + "Set the angle speed.", + EV_NORMAL +); +Event EV_ExplodingWall_LandRadius +( + "land_radius", EV_DEFAULT, + "f", + "radius", + "Set the land radius.", + EV_NORMAL +); +Event EV_ExplodingWall_LandAngles +( + "land_angles", EV_DEFAULT, + "v", + "angles", + "Set the land angles.", + EV_NORMAL +); +Event EV_ExplodingWall_BaseVelocity +( + "base_velocity", EV_DEFAULT, + "v", + "velocity", + "Set the base velocity.", + EV_NORMAL ); -Event EV_ExplodingWall_AngleSpeed("anglespeed", EV_DEFAULT, "f", "speed", "Set the angle speed.", EV_NORMAL); -Event EV_ExplodingWall_LandRadius("land_radius", EV_DEFAULT, "f", "radius", "Set the land radius.", EV_NORMAL); -Event EV_ExplodingWall_LandAngles("land_angles", EV_DEFAULT, "v", "angles", "Set the land angles.", EV_NORMAL); -Event EV_ExplodingWall_BaseVelocity("base_velocity", EV_DEFAULT, "v", "velocity", "Set the base velocity.", EV_NORMAL); Event EV_ExplodingWall_RandomVelocity( "random_velocity", EV_DEFAULT, @@ -160,11 +201,31 @@ Event EV_ExplodingWall_RandomVelocity( "Set the amount of random variation of the base velocity.", EV_NORMAL ); -Event EV_ExplodingWall_SetDmg("dmg", EV_DEFAULT, "i", "dmg", "Set the damage from the exploding wall.", EV_NORMAL); -Event EV_ExplodingWall_SetExplosions( - "explosions", EV_DEFAULT, "i", "explosions", "Set the number of explosions.", EV_NORMAL +Event EV_ExplodingWall_SetDmg +( + "dmg", EV_DEFAULT, + "i", + "dmg", + "Set the damage from the exploding wall.", + EV_NORMAL +); +Event EV_ExplodingWall_SetExplosions +( + "explosions", EV_DEFAULT, + "i", + "explosions", + "Set the number of explosions.", + EV_NORMAL + +); +Event EV_ExplodingWall_Setup +( + "setup", EV_CODEONLY, + NULL, + NULL, + "Initializes the exploding wall.", + EV_NORMAL ); -Event EV_ExplodingWall_Setup("setup", EV_CODEONLY, NULL, NULL, "Initializes the exploding wall.", EV_NORMAL); CLASS_DECLARATION(Trigger, ExplodingWall, "func_explodingwall") { {&EV_ExplodingWall_Setup, &ExplodingWall::Setup }, @@ -184,49 +245,41 @@ CLASS_DECLARATION(Trigger, ExplodingWall, "func_explodingwall") { }; void ExplodingWall::AngleSpeed(Event *ev) - { angle_speed = ev->GetFloat(1); } void ExplodingWall::LandRadius(Event *ev) - { land_radius = ev->GetFloat(1); } void ExplodingWall::LandAngles(Event *ev) - { land_angles = ev->GetVector(1); } void ExplodingWall::BaseVelocity(Event *ev) - { base_velocity = ev->GetVector(1); } void ExplodingWall::RandomVelocity(Event *ev) - { random_velocity = ev->GetVector(1); } void ExplodingWall::SetDmg(Event *ev) - { dmg = ev->GetInteger(1); } void ExplodingWall::SetExplosions(Event *ev) - { explosions = ev->GetInteger(1); } void ExplodingWall::Explode(Event *ev) - { Entity *other; Vector pos; @@ -321,7 +374,6 @@ void ExplodingWall::Explode(Event *ev) } void ExplodingWall::DamageEvent(Event *ev) - { Event *event; Entity *inflictor; @@ -358,7 +410,6 @@ void ExplodingWall::DamageEvent(Event *ev) } void ExplodingWall::GroundDamage(Event *ev) - { Entity *inflictor; Entity *attacker; @@ -398,14 +449,12 @@ void ExplodingWall::GroundDamage(Event *ev) } void ExplodingWall::SetupSecondStage(void) - { health = max_health; takedamage = DAMAGE_YES; } void ExplodingWall::StopRotating(Event *ev) - { avelocity = vec_zero; setAngles(land_angles); @@ -415,7 +464,6 @@ void ExplodingWall::StopRotating(Event *ev) } void ExplodingWall::CheckOnGround(Event *ev) - { if ((velocity == vec_zero) && groundentity) { Vector delta; @@ -463,7 +511,6 @@ void ExplodingWall::CheckOnGround(Event *ev) } void ExplodingWall::TouchFunc(Event *ev) - { Entity *other; @@ -499,7 +546,6 @@ void ExplodingWall::TouchFunc(Event *ev) } void ExplodingWall::Setup(Event *ev) - { if (spawnflags & INVISIBLE) { if (Targeted()) { @@ -564,13 +610,27 @@ If NO_EFFECTS is set, the special effect will not happen and the teleport will b #define NO_EFFECTS (1 << 5) -Event EV_Teleporter_Teleport("teleport", EV_CODEONLY, "e", "entity", "Teleports the entity to destination.", EV_NORMAL); - -Event EV_Teleporter_StopTeleport( - "stopteleport", EV_CODEONLY, "e", "entity", "Releases the entity at the end of the teleport.", EV_NORMAL +Event EV_Teleporter_Teleport +( + "teleport", + EV_CODEONLY, + "e", + "entity", + "Teleports the entity to destination.", + EV_NORMAL ); +Event EV_Teleporter_StopTeleport +( + "stopteleport", + EV_CODEONLY, + "e", + "entity", + "Releases the entity at the end of the teleport.", + EV_NORMAL -Event EV_Teleporter_SetThread( +); +Event EV_Teleporter_SetThread +( "teleportthread", EV_CODEONLY, "s", @@ -677,7 +737,6 @@ void Teleporter::StartTeleport(Event *ev) } void Teleporter::Teleport(Event *ev) - { Entity *dest; int i; @@ -791,7 +850,6 @@ void Teleporter::Teleport(Event *ev) } void Teleporter::StopTeleport(Event *ev) - { Entity *other; @@ -884,19 +942,37 @@ it waits until the player has left the trigger field. ******************************************************************************/ -Event EV_UseAnim_Reset( - "_reset", EV_CODEONLY, NULL, NULL, "Reset's the Use Anim after it has no longer been touched.", EV_NORMAL -); +Event EV_UseAnim_Reset +( + "_reset", + EV_CODEONLY, + NULL, + NULL, + "Reset's the Use Anim after it has no longer been touched.", + EV_NORMAL -Event EV_UseAnim_Thread( - "setthread", EV_DEFAULT, "s", "label", "Sets which thread to use when this UseAnim is triggered.", EV_NORMAL ); +Event EV_UseAnim_Thread +( + "setthread", + EV_DEFAULT, + "s", + "label", + "Sets which thread to use when this UseAnim is triggered.", + EV_NORMAL -Event EV_UseAnim_Count( - "count", EV_DEFAULT, "i", "newCount", "Sets how many times the UseAnim can be triggered.", EV_NORMAL ); +Event EV_UseAnim_Count +( + "count", EV_DEFAULT, + "i", + "newCount", + "Sets how many times the UseAnim can be triggered.", + EV_NORMAL -Event EV_UseAnim_TriggerTarget( +); +Event EV_UseAnim_TriggerTarget +( "triggertarget", EV_DEFAULT, "s", @@ -904,15 +980,34 @@ Event EV_UseAnim_TriggerTarget( "Sets what should be triggered, when this UseAnim is triggered.", EV_NORMAL ); - -Event EV_UseAnim_SetAnim("anim", EV_DEFAULT, "s", "animName", "set the animation to use for player.", EV_NORMAL); - -Event EV_UseAnim_SetKey( - "key", EV_DEFAULT, "s", "keyName", "set the key needed to make this UseAnim function.", EV_NORMAL +Event EV_UseAnim_SetAnim +( + "anim", + EV_DEFAULT, + "s", + "animName", + "set the animation to use for player.", + EV_NORMAL ); +Event EV_UseAnim_SetKey +( + "key", + EV_DEFAULT, + "s", + "keyName", + "set the key needed to make this UseAnim function.", + EV_NORMAL -Event EV_UseAnim_SetState("state", EV_CHEAT, "s", "stateName", "set the state to use for the player.", EV_NORMAL); - +); +Event EV_UseAnim_SetState +( + "state", + EV_CHEAT, + "s", + "stateName", + "set the state to use for the player.", + EV_NORMAL +); Event EV_UseAnim_SetCamera( "camera", EV_DEFAULT, @@ -922,11 +1017,16 @@ Event EV_UseAnim_SetCamera( "topdown, behind, front, side, behind_fixed, side_left, side_right", EV_NORMAL ); +Event EV_UseAnim_SetNumLoops +( + "num_loops", + EV_DEFAULT, + "i", + "loopCount", + "set the number of times to loop an animation per use.", + EV_NORMAL -Event EV_UseAnim_SetNumLoops( - "num_loops", EV_DEFAULT, "i", "loopCount", "set the number of times to loop an animation per use.", EV_NORMAL ); - Event EV_UseAnim_SetDelay( "delay", EV_DEFAULT, @@ -998,7 +1098,6 @@ UseAnim::UseAnim() } void UseAnim::Touched(Event *ev) - { Entity *other; @@ -1020,7 +1119,6 @@ void UseAnim::Touched(Event *ev) } bool UseAnim::canBeUsed(Entity *activator) - { Entity *dest; @@ -1088,7 +1186,6 @@ bool UseAnim::canBeUsed(Entity *activator) bool UseAnim::GetInformation( Entity *activator, Vector *org, Vector *angles, str *animation, int *loopcount, str *state, str *camera ) - { Entity *dest; UseAnimDestination *uadest; @@ -1160,7 +1257,6 @@ bool UseAnim::GetInformation( } void UseAnim::TriggerTargets(Entity *activator) - { // // fire off our trigger target if appropriate @@ -1190,7 +1286,6 @@ void UseAnim::TriggerTargets(Entity *activator) } void UseAnim::Reset(Event *ev) - { // // find out if our triggertarget is of type door and only reset if the door is closed @@ -1241,25 +1336,21 @@ void UseAnim::Reset(Event *ev) } void UseAnim::SetThread(Event *ev) - { thread.SetThread(ev->GetValue(1)); } void UseAnim::SetDelay(Event *ev) - { delay = ev->GetFloat(1); } void UseAnim::SetTriggerTarget(Event *ev) - { triggertarget = ev->GetString(1); } void UseAnim::SetCount(Event *ev) - { count = ev->GetInteger(1); } @@ -1379,7 +1470,8 @@ int UseAnimDestination::GetNumLoops(void) return num_loops; } -Event EV_UseObject_MoveThread( +Event EV_UseObject_MoveThread +( "move_thread", EV_DEFAULT, "s", @@ -1387,38 +1479,87 @@ Event EV_UseObject_MoveThread( "Sets which move thread to use when this UseObject has finshed looping.", EV_NORMAL ); +Event EV_UseObject_StopThread +( + "stop_thread", + EV_DEFAULT, + "s", + "label", + "Sets which stop thread to use when this UseObject is finished.", + EV_NORMAL -Event EV_UseObject_StopThread( - "stop_thread", EV_DEFAULT, "s", "label", "Sets which stop thread to use when this UseObject is finished.", EV_NORMAL ); +Event EV_UseObject_ResetThread +( + "reset_thread", + EV_DEFAULT, + "s", + "label", + "Sets which thread to call when resetting.", + EV_NORMAL -Event EV_UseObject_ResetThread( - "reset_thread", EV_DEFAULT, "s", "label", "Sets which thread to call when resetting.", EV_NORMAL ); +Event EV_UseObject_Count +( + "count", + EV_DEFAULT, + "i", + "newCount", + "Sets how many times the UseObject can be triggered.", + EV_NORMAL -Event EV_UseObject_Count( - "count", EV_DEFAULT, "i", "newCount", "Sets how many times the UseObject can be triggered.", EV_NORMAL ); +Event EV_UseObject_Cone +( + "cone", + EV_DEFAULT, + "f", + "newCone", + "Sets the cone in angles of where the Useobject can be used.", + EV_NORMAL -Event EV_UseObject_Cone( - "cone", EV_DEFAULT, "f", "newCone", "Sets the cone in angles of where the Useobject can be used.", EV_NORMAL ); +Event EV_UseObject_Offset +( + "offset", + EV_DEFAULT, + "v", + "newOffset", + "Sets the offset to use for this UseObject.", + EV_NORMAL -Event EV_UseObject_Offset( - "offset", EV_DEFAULT, "v", "newOffset", "Sets the offset to use for this UseObject.", EV_NORMAL ); +Event EV_UseObject_YawOffset +( + "yaw_offset", + EV_DEFAULT, + "f", + "newYawOffset", + "Sets the yaw offset to use for this UseObject.", + EV_NORMAL -Event EV_UseObject_YawOffset( - "yaw_offset", EV_DEFAULT, "f", "newYawOffset", "Sets the yaw offset to use for this UseObject.", EV_NORMAL ); - -Event EV_UseObject_State("state", EV_DEFAULT, "s", "newState", "Sets the state to use for this UseObject.", EV_NORMAL); - -Event EV_UseObject_StateBackwards( - "state_backwards", EV_DEFAULT, "s", "newState", "Sets the backward state to use for this UseObject.", EV_NORMAL +Event EV_UseObject_State +( + "state", + EV_DEFAULT, + "s", + "newState", + "Sets the state to use for this UseObject.", + EV_NORMAL ); +Event EV_UseObject_StateBackwards +( + "state_backwards", + EV_DEFAULT, + "s", + "newState", + "Sets the backward state to use for this UseObject.", + EV_NORMAL -Event EV_UseObject_TriggerTarget( +); +Event EV_UseObject_TriggerTarget +( "triggertarget", EV_DEFAULT, "s", @@ -1426,8 +1567,8 @@ Event EV_UseObject_TriggerTarget( "Sets what should be triggered, when this UseObject is triggered.", EV_NORMAL ); - -Event EV_UseObject_ResetTime( +Event EV_UseObject_ResetTime +( "reset_time", EV_DEFAULT, "f", @@ -1435,8 +1576,8 @@ Event EV_UseObject_ResetTime( "Sets the time it takes for the UseObject to reset itself.", EV_NORMAL ); - -Event EV_UseObject_DamageType( +Event EV_UseObject_DamageType +( "damage_type", EV_DEFAULT, "s", @@ -1444,8 +1585,8 @@ Event EV_UseObject_DamageType( "Sets what kind of damage is needed to activate the trigger.", EV_NORMAL ); - -Event EV_UseObject_Reset( +Event EV_UseObject_Reset +( "_useobject_reset", EV_DEFAULT, NULL, @@ -1453,12 +1594,18 @@ Event EV_UseObject_Reset( "Resets the useobject to the start state after a certain amount of time.", EV_NORMAL ); +Event EV_UseObject_Resetting +( + "_useobject_resetting", + EV_DEFAULT, + NULL, + NULL, + "Intermediate function for useobject reset.", + EV_NORMAL -Event EV_UseObject_Resetting( - "_useobject_resetting", EV_DEFAULT, NULL, NULL, "Intermediate function for useobject reset.", EV_NORMAL ); - -Event EV_UseObject_DamageTriggered( +Event EV_UseObject_DamageTriggered +( "_useobject_damagetriggered", EV_DEFAULT, "e", @@ -1466,18 +1613,43 @@ Event EV_UseObject_DamageTriggered( "Intermediate function for when the useobject was triggered by damage.", EV_NORMAL ); - -Event EV_UseObject_Activate("activate", EV_DEFAULT, NULL, NULL, "Allow the useobject to be used.", EV_NORMAL); - -Event - EV_UseObject_Deactivate("deactivate", EV_DEFAULT, NULL, NULL, "Do not allow the useobject to be used.", EV_NORMAL); - -Event EV_UseObject_UseMaterial( - "usematerial", EV_DEFAULT, "s", "nameOfUseMaterial", "the name of the material that glows when active.", EV_NORMAL +Event EV_UseObject_Activate +( + "activate", + EV_DEFAULT, + NULL, + NULL, + "Allow the useobject to be used.", + EV_NORMAL ); +Event EV_UseObject_Deactivate +( + "deactivate", + EV_DEFAULT, + NULL, + NULL, + "Do not allow the useobject to be used.", + EV_NORMAL +); +Event EV_UseObject_UseMaterial +( + "usematerial", + EV_DEFAULT, + "s", + "nameOfUseMaterial", + "the name of the material that glows when active.", + EV_NORMAL + +); +Event EV_UseObject_SetActiveState +( + "_setactivestate", + EV_DEFAULT, + NULL, + NULL, + "event that sets up the proper skin for the useobject.", + EV_NORMAL -Event EV_UseObject_SetActiveState( - "_setactivestate", EV_DEFAULT, NULL, NULL, "event that sets up the proper skin for the useobject.", EV_NORMAL ); #define MULTI_STATE (1 << 0) @@ -1628,87 +1800,73 @@ void UseObject::SetActiveState(Event *ev) } void UseObject::SetMoveThread(Event *ev) - { move_thread.SetThread(ev->GetValue(1)); } void UseObject::SetStopThread(Event *ev) - { stop_thread.SetThread(ev->GetValue(1)); } void UseObject::SetResetThread(Event *ev) - { reset_thread.SetThread(ev->GetValue(1)); } void UseObject::ActivateEvent(Event *ev) - { active = qtrue; PostEvent(EV_UseObject_SetActiveState, 0); } void UseObject::DeactivateEvent(Event *ev) - { active = qfalse; PostEvent(EV_UseObject_SetActiveState, 0); } void UseObject::SetTriggerTarget(Event *ev) - { triggertarget = ev->GetString(1); } void UseObject::SetOffset(Event *ev) - { offset = ev->GetVector(1); } void UseObject::SetYawOffset(Event *ev) - { yaw_offset = ev->GetFloat(1); } void UseObject::SetCount(Event *ev) - { count = ev->GetInteger(1); } void UseObject::SetCone(Event *ev) - { cone = cos(DEG2RAD(ev->GetFloat(1))); } void UseObject::SetState(Event *ev) - { state = ev->GetString(1); } void UseObject::SetBackwardsState(Event *ev) - { state_backwards = ev->GetString(1); } void UseObject::UseMaterialEvent(Event *ev) - { useMaterial = ev->GetString(1); } void UseObject::SetResetTime(Event *ev) - { reset_time = ev->GetFloat(1); } @@ -1719,7 +1877,6 @@ void UseObject::Reset(Event *ev) } void UseObject::Resetting(Event *ev) - { SetActiveState(NULL); NewAnim("start"); @@ -1755,7 +1912,6 @@ void UseObject::Resetting(Event *ev) } bool UseObject::canBeUsed(Vector org, Vector dir) - { float dot; Vector forward; @@ -1799,7 +1955,6 @@ bool UseObject::canBeUsed(Vector org, Vector dir) } void UseObject::DamageFunc(Event *ev) - { Event *e; Entity *attacker; @@ -1836,14 +1991,12 @@ void UseObject::DamageFunc(Event *ev) } void UseObject::DamageTriggered(Event *ev) - { // grab the attacker from our event Stop(ev->GetEntity(1)); } void UseObject::Setup(Entity *activator, Vector *org, Vector *ang, str *newstate) - { if ((spawnflags & MULTI_STATE) && objectState) { *newstate = state_backwards; @@ -1867,7 +2020,6 @@ void UseObject::Setup(Entity *activator, Vector *org, Vector *ang, str *newstate } void UseObject::Start(Event *ev) - { // // fire off the move_thread @@ -1886,7 +2038,6 @@ void UseObject::Start(Event *ev) } bool UseObject::Loop(void) - { if (!count) { return qfalse; @@ -1896,7 +2047,6 @@ bool UseObject::Loop(void) } void UseObject::Stop(Entity *activator) - { if ((spawnflags & MULTI_STATE) && objectState) { NewAnim("start"); @@ -1979,7 +2129,14 @@ Like info_waypoints, but with spawnflags for vehicles. ******************************************************************************/ -Event EV_VehiclePoint_SetSpawnFlags("spawnflags", EV_DEFAULT, "i", "spawn_flags", "Sets the spawn flags."); +Event EV_VehiclePoint_SetSpawnFlags +( + "spawnflags", + EV_DEFAULT, + "i", + "spawn_flags", + "Sets the spawn flags." +); CLASS_DECLARATION(Waypoint, VehiclePoint, "info_vehiclepoint") { {&EV_VehiclePoint_SetSpawnFlags, &VehiclePoint::SetSpawnFlags}, @@ -2022,7 +2179,6 @@ MonkeyBars::MonkeyBars() } void MonkeyBars::SetAngleEvent(Event *ev) - { dir = ev->GetFloat(1); } @@ -2052,7 +2208,6 @@ HorizontalPipe::HorizontalPipe() } void HorizontalPipe::SetAngleEvent(Event *ev) - { dir = ev->GetFloat(1); } @@ -2061,10 +2216,16 @@ void HorizontalPipe::SetAngleEvent(Event *ev) // TossObject /*****************************************************************************/ -Event EV_TossObject_SetBounceSound( - "bouncesound", EV_DEFAULT, "s", "sound", "When bouncing, what sound to play on impact", EV_NORMAL -); +Event EV_TossObject_SetBounceSound +( + "bouncesound", + EV_DEFAULT, + "s", + "sound", + "When bouncing, what sound to play on impact", + EV_NORMAL +); Event EV_TossObject_SetBounceSoundChance( "bouncesoundchance", EV_DEFAULT, @@ -2104,31 +2265,26 @@ TossObject::TossObject(str model) } void TossObject::SetBounceSound(str bounce) - { bouncesound = bounce; } void TossObject::SetBounceSound(Event *ev) - { bouncesound = ev->GetString(1); } void TossObject::SetBounceSoundChance(float chance) - { bouncesoundchance = chance; } void TossObject::SetBounceSoundChance(Event *ev) - { bouncesoundchance = ev->GetFloat(1); } void TossObject::Stop(Event *ev) - { setMoveType(MOVETYPE_NONE); setSolidType(SOLID_NOT); @@ -2140,7 +2296,6 @@ void TossObject::Stop(Event *ev) } void TossObject::Touch(Event *ev) - { Entity *ent; @@ -2163,7 +2318,6 @@ void TossObject::Touch(Event *ev) } void TossObject::SetVelocity(float severity) - { setSolidType(SOLID_BBOX); velocity[0] = 100.0 * crandom(); @@ -2206,11 +2360,32 @@ Pushable object ******************************************************************************/ -Event EV_PushObject_Start("start", EV_DEFAULT, NULL, NULL, "Sets up the pushobject.", EV_NORMAL); +Event EV_PushObject_Start +( + "start", EV_DEFAULT, + NULL, + NULL, + "Sets up the pushobject.", + EV_NORMAL +); -Event EV_PushObject_SetDamage("dmg", EV_DEFAULT, "i", "damage", "Set the damage.", EV_NORMAL); +Event EV_PushObject_SetDamage +( + "dmg", EV_DEFAULT, + "i", + "damage", + "Set the damage.", + EV_NORMAL +); -Event EV_PushObject_SetPushSound("pushsound", EV_DEFAULT, "s", "sound", "Set the pushing sound", EV_NORMAL); +Event EV_PushObject_SetPushSound +( + "pushsound", EV_DEFAULT, + "s", + "sound", + "Set the pushing sound", + EV_NORMAL +); CLASS_DECLARATION(Entity, PushObject, "func_pushobject") { {&EV_PushObject_Start, &PushObject::Start }, @@ -2235,13 +2410,11 @@ PushObject::PushObject() } void PushObject::SetPushSound(Event *ev) - { pushsound = ev->GetString(1); } void PushObject::Start(Event *ev) - { // make sure that this touches triggers flags |= FL_TOUCH_TRIGGERS; @@ -2254,7 +2427,6 @@ void PushObject::Start(Event *ev) } qboolean PushObject::canPush(Vector dir) - { trace_t trace; @@ -2265,7 +2437,6 @@ qboolean PushObject::canPush(Vector dir) } qboolean PushObject::Push(Entity *pusher, Vector move) - { trace_t trace; @@ -2295,13 +2466,11 @@ qboolean PushObject::Push(Entity *pusher, Vector move) } Entity *PushObject::getOwner(void) - { return (Entity *)owner; } void PushObject::BlockFunc(Event *ev) - { Entity *other; @@ -2315,7 +2484,6 @@ void PushObject::BlockFunc(Event *ev) } void PushObject::SetDamage(Event *ev) - { dmg = ev->GetInteger(1); } @@ -2341,21 +2509,69 @@ REMOVE_ON_GROUND - remove the rocks when done ******************************************************************************/ -Event EV_FallingRock_Bounce("bounce", EV_DEFAULT, NULL, NULL, "sent to entity when touched.", EV_NORMAL); +Event EV_FallingRock_Bounce +( + "bounce", + EV_DEFAULT, + NULL, + NULL, + "sent to entity when touched.", + EV_NORMAL +); +Event EV_FallingRock_Rotate +( + "rotate", + EV_DEFAULT, + NULL, + NULL, + "rotates the falling rock.", + EV_NORMAL +); +Event EV_FallingRock_SetWait +( + "wait", + EV_DEFAULT, + "f", + "wait", + "How long to wait before rock starts falling.", + EV_NORMAL +); +Event EV_FallingRock_Start +( + "start", + EV_DEFAULT, + NULL, + NULL, + "Starts rock falling.", + EV_NORMAL +); +Event EV_FallingRock_SetDmg +( + "dmg", + EV_DEFAULT, + "i", + "dmg", + "Set the damage from the rock.", + EV_NORMAL +); +Event EV_FallingRock_SetSpeed +( + "speed", + EV_DEFAULT, + "f", + "speed", + "Set the speed that the rock moves at.", + EV_NORMAL +); +Event EV_FallingRock_SetBounceSound +( + "noise", + EV_DEFAULT, + "s", + "sound", + "Set the sound to play when the rock bounces", + EV_NORMAL -Event EV_FallingRock_Rotate("rotate", EV_DEFAULT, NULL, NULL, "rotates the falling rock.", EV_NORMAL); - -Event - EV_FallingRock_SetWait("wait", EV_DEFAULT, "f", "wait", "How long to wait before rock starts falling.", EV_NORMAL); - -Event EV_FallingRock_Start("start", EV_DEFAULT, NULL, NULL, "Starts rock falling.", EV_NORMAL); - -Event EV_FallingRock_SetDmg("dmg", EV_DEFAULT, "i", "dmg", "Set the damage from the rock.", EV_NORMAL); - -Event EV_FallingRock_SetSpeed("speed", EV_DEFAULT, "f", "speed", "Set the speed that the rock moves at.", EV_NORMAL); - -Event EV_FallingRock_SetBounceSound( - "noise", EV_DEFAULT, "s", "sound", "Set the sound to play when the rock bounces", EV_NORMAL ); CLASS_DECLARATION(Entity, FallingRock, "func_fallingrock") { @@ -2390,7 +2606,6 @@ FallingRock::FallingRock() } Entity *FallingRock::SetNextBounceDir(void) - { Entity *ent; @@ -2410,7 +2625,6 @@ Entity *FallingRock::SetNextBounceDir(void) } void FallingRock::NextBounce(void) - { float time; float distance; @@ -2453,7 +2667,6 @@ void FallingRock::NextBounce(void) } void FallingRock::Rotate(Event *ev) - { float mat[3][3]; float ang; @@ -2471,19 +2684,16 @@ void FallingRock::Rotate(Event *ev) } void FallingRock::SetWait(Event *ev) - { wait = ev->GetFloat(1); } void FallingRock::SetSpeed(Event *ev) - { speed = ev->GetFloat(1); } void FallingRock::SetDmg(Event *ev) - { dmg = ev->GetInteger(1); } @@ -2496,13 +2706,11 @@ void FallingRock::SetBounceSound(str sound) } void FallingRock::SetBounceSound(Event *ev) - { SetBounceSound(ev->GetString(1)); } void FallingRock::Activate(Event *ev) - { if (active == 1) { return; @@ -2526,7 +2734,6 @@ void FallingRock::Activate(Event *ev) } void FallingRock::StartFalling(Event *ev) - { if (current) { return; @@ -2551,7 +2758,6 @@ void FallingRock::StartFalling(Event *ev) } void FallingRock::Touch(Event *ev) - { Entity *other; @@ -2582,7 +2788,6 @@ void FallingRock::Touch(Event *ev) } void FallingRock::Bounce(Event *ev) - { Vector delta; @@ -2622,7 +2827,14 @@ Ladder trigger volume ******************************************************************************/ -Event EV_LadderSetup("_ladder_setup", EV_CODEONLY, NULL, NULL, "Does the post spawn setup of the ladder"); +Event EV_LadderSetup +( + "_ladder_setup", + EV_CODEONLY, + NULL, + NULL, + "Does the post spawn setup of the ladder" +); CLASS_DECLARATION(Entity, FuncLadder, "func_ladder") { {&EV_Use, NULL }, @@ -2652,6 +2864,14 @@ void FuncLadder::LadderSetup(Event *ev) edict->r.svFlags |= SVF_NOCLIENT; } +void FuncLadder::SetLadderFacing(Event *ev) +{ + m_vFacingAngles = vec_zero; + m_vFacingAngles[1] = AngleMod(ev->GetFloat(1)); + + AngleVectorsLeft(m_vFacingAngles, m_vFacingDir, NULL, NULL); +} + qboolean FuncLadder::CanUseLadder(Entity *pUser) { int iMask; @@ -2764,14 +2984,6 @@ void FuncLadder::PositionOnLadder(Entity *pUser) pUser->setAngles(m_vFacingAngles); } -void FuncLadder::SetLadderFacing(Event *ev) -{ - m_vFacingAngles = vec_zero; - m_vFacingAngles[1] = AngleMod(ev->GetFloat(1)); - - AngleVectorsLeft(m_vFacingAngles, m_vFacingDir, NULL, NULL); -} - void FuncLadder::AdjustPositionOnLadder(Entity *pUser) { float fHeight; @@ -2785,7 +2997,7 @@ void FuncLadder::AdjustPositionOnLadder(Entity *pUser) fHeight = ((int)(pUser->origin[2] + 8.0f) & ~15); - if (vDelta.length() > 16.0f && pUser->origin[2] == fHeight) { + if (vDelta.length() == 16.0f && pUser->origin[2] == fHeight) { return; } @@ -2872,8 +3084,32 @@ void FuncLadder::EnsureForwardOffLadder(Entity *pUser) pUser->setOrigin(trace.endpos); } -Event EV_InfoLandmark_Name("landmark_name", EV_DEFAULT, "s", "name", "Set the name of this landmark", EV_NORMAL); -Event EV_InfoLandmark_SetOrigin("origin", EV_DEFAULT, "v", "origin", "Set the origin of the landmark.", EV_NORMAL); +const Vector& FuncLadder::getFacingAngles() const +{ + return m_vFacingAngles; +} + +const Vector& FuncLadder::getFacingDir() const +{ + return m_vFacingDir; +} + +Event EV_InfoLandmark_Name +( + "landmark_name", EV_DEFAULT, + "s", + "name", + "Set the name of this landmark", + EV_NORMAL +); +Event EV_InfoLandmark_SetOrigin +( + "origin", EV_DEFAULT, + "v", + "origin", + "Set the origin of the landmark.", + EV_NORMAL +); CLASS_DECLARATION(Listener, InfoLandmark, "info_landmark") { {&EV_InfoLandmark_Name, &InfoLandmark::SetLandmarkName}, diff --git a/code/fgame/misc.h b/code/fgame/misc.h index 924fad3b..95f4d2c2 100644 --- a/code/fgame/misc.h +++ b/code/fgame/misc.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2025 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -35,7 +35,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "mover.h" #include "animate.h" -class InfoNull : public Entity +class InfoNull : public Listener { public: CLASS_PROTOTYPE(InfoNull); @@ -133,7 +133,7 @@ public: virtual void Teleport(Event *ev); virtual void StopTeleport(Event *ev); void SetThread(Event *ev); - void Archive(Archiver &arc) override; + void Archive(Archiver& arc) override; }; inline void Teleporter::Archive(Archiver& arc) @@ -488,7 +488,7 @@ private: Entity *SetNextBounceDir(void); void SetBounceSound(str sound); void SetBounceSound(Event *ev); - void Archive(Archiver &arc) override; + void Archive(Archiver& arc) override; public: CLASS_PROTOTYPE(FallingRock); @@ -564,8 +564,21 @@ public: void EnsureOverLadder(Entity *pUser); void EnsureForwardOffLadder(Entity *pUser); + + const Vector& getFacingAngles() const; + const Vector& getFacingDir() const; + + void Archive(Archiver& arc) override; }; +inline void FuncLadder::Archive(Archiver& arc) +{ + Entity::Archive(arc); + + arc.ArchiveVector(&m_vFacingAngles); + arc.ArchiveVector(&m_vFacingDir); +} + class InfoLandmark : public Listener { private: diff --git a/code/fgame/movegrid.cpp b/code/fgame/movegrid.cpp index ee755b89..feb60248 100644 --- a/code/fgame/movegrid.cpp +++ b/code/fgame/movegrid.cpp @@ -82,7 +82,7 @@ void cMoveGrid::CalculateBoxPoints(void) for (z = 0; z < m_iZRes; z++) { gridpoint_t *gridPoint = GetGridPoint(x, y, z); - gridPoint->origin = Vector(xdelta - rx, ydelta - ry, zdelta + rz / 2); + gridPoint->origin = Vector(xdelta - rx, ydelta - ry, zdelta + rz / 2.f); zdelta += rz; } zdelta = 0; @@ -107,18 +107,18 @@ void cMoveGrid::CalculateBoxPoints(void) if (rx >= ry) { Vector vec; - vec = Vector(-ry / 2, -ry / 2, -rz / 2); + vec = Vector(-ry / 2.f, -ry / 2.f, -rz / 2.f); vec.copyTo(gridPoint->vm.mins); - vec = Vector(ry / 2, ry / 2, rz / 2); + vec = Vector(ry / 2.f, ry / 2.f, rz / 2.f); vec.copyTo(gridPoint->vm.maxs); } else { Vector vec; - vec = Vector(-rx / 2, -rx / 2, -rz / 2); + vec = Vector(-rx / 2.f, -rx / 2.f, -rz / 2.f); vec.copyTo(gridPoint->vm.mins); - vec = Vector(rx / 2, rx / 2, rz / 2); + vec = Vector(rx / 2.f, rx / 2.f, rz / 2.f); vec.copyTo(gridPoint->vm.maxs); } } @@ -218,10 +218,23 @@ qboolean cMoveGrid::CheckStuck(void) void cMoveGrid::Archive(Archiver& arc) { + int i; + arc.ArchiveInteger(&m_iXRes); arc.ArchiveInteger(&m_iYRes); arc.ArchiveInteger(&m_iZRes); - arc.ArchiveRaw(&v, sizeof(vmove_t)); + + arc.ArchiveFloat(&v.frametime); + arc.ArchiveFloat(&v.desired_speed); + arc.ArchiveInteger(&v.tracemask); + arc.ArchiveInteger(&v.numtouch); + + for (i = 0; i < ARRAY_LEN(v.touchents); i++) { + arc.ArchiveInteger(&v.touchents[i]); + } + arc.ArchiveVec3(v.mins); + arc.ArchiveVec3(v.maxs); + arc.ArchiveVec3(orientation[0]); arc.ArchiveVec3(orientation[1]); arc.ArchiveVec3(orientation[2]); diff --git a/code/fgame/movegrid.h b/code/fgame/movegrid.h index 4740aaab..6847d1b2 100644 --- a/code/fgame/movegrid.h +++ b/code/fgame/movegrid.h @@ -39,7 +39,7 @@ typedef struct vehicleState_s { int entityNum; vec2_t desired_dir; qboolean hit_obstacle; - float hit_origin[3]; + vec3_t hit_origin; vec3_t obstacle_normal; qboolean useGravity; } vehicleState_t; diff --git a/code/fgame/mover.cpp b/code/fgame/mover.cpp index 47e31d40..3b99e3df 100644 --- a/code/fgame/mover.cpp +++ b/code/fgame/mover.cpp @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2025 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -35,90 +35,81 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define MOVE_ANGLES 1 #define MOVE_ORIGIN 2 -CLASS_DECLARATION( Trigger, Mover, "mover" ) - { - { &EV_MoveDone, &Mover::MoveDone }, - { NULL, NULL } - }; - +CLASS_DECLARATION(Trigger, Mover, "mover") { + {&EV_MoveDone, &Mover::MoveDone}, + {NULL, NULL } +}; Mover::Mover() - { - endevent = NULL; - } - -Mover::~Mover() - { - } - -void Mover::MoveDone - ( - Event *ev - ) { - Event * event; - Vector move; - Vector amove; + endevent = NULL; +} - // zero out the movement - if( moveflags & MOVE_ANGLES ) - { - avelocity = vec_zero; - amove = angledest - localangles; - } - else - { - amove = vec_zero; - } +Mover::~Mover() {} - if( moveflags & MOVE_ORIGIN ) - { - velocity = vec_zero; - move = finaldest - localorigin; - } - else - { - move = vec_zero; - } +void Mover::MoveDone(Event *ev) +{ + Event *event; + Vector move; + Vector amove; - if( !G_PushMove( this, move, amove ) ) - { - // Delay finish till we can move into the final position - PostEvent( EV_MoveDone, FRAMETIME ); - return; - } + // zero out the movement + avelocity = vec_zero; + if (moveflags & MOVE_ANGLES) { + amove = angledest - localangles; + } else { + amove = vec_zero; + } - // - // After moving, set origin to exact final destination - // - if( moveflags & MOVE_ORIGIN ) - { - setLocalOrigin( finaldest ); - } + velocity = vec_zero; + if (moveflags & MOVE_ORIGIN) { + move = finaldest - localorigin; + } else { + move = vec_zero; + } - if( moveflags & MOVE_ANGLES ) - { - localangles = angledest; + accel = vec_zero; + aaccel = vec_zero; - if( ( localangles.x >= 360 ) || ( localangles.x < 0 ) ) - { - localangles.x -= ( ( int )localangles.x / 360 ) * 360; - } - if( ( localangles.y >= 360 ) || ( localangles.y < 0 ) ) - { - localangles.y -= ( ( int )localangles.y / 360 ) * 360; - } - if( ( localangles.z >= 360 ) || ( localangles.z < 0 ) ) - { - localangles.z -= ( ( int )localangles.z / 360 ) * 360; - } - } + if (!G_PushMove(this, move, amove)) { + // Added in OPM + // Check to make sure the event isn't pending + // blocked events called by G_PushMove() might alter + // the mover + if (!EventPending(EV_MoveDone)) { + // Delay finish till we can move into the final position + PostEvent(EV_MoveDone, FRAMETIME); + } + return; + } - event = endevent; - endevent = NULL; + // + // After moving, set origin to exact final destination + // + if (moveflags & MOVE_ORIGIN) { + setLocalOrigin(finaldest); + } - if( event ) - ProcessEvent( event ); + if (moveflags & MOVE_ANGLES) { + localangles = angledest; + + if ((localangles.x >= 360) || (localangles.x < 0)) { + localangles.x -= ((int)localangles.x / 360) * 360; + } + if ((localangles.y >= 360) || (localangles.y < 0)) { + localangles.y -= ((int)localangles.y / 360) * 360; + } + if ((localangles.z >= 360) || (localangles.z < 0)) { + localangles.z -= ((int)localangles.z / 360) * 360; + } + } + + event = endevent; + endevent = NULL; + + if (event) { + ProcessEvent(event); + } } /* @@ -129,99 +120,87 @@ calculate self.velocity and self.nextthink to reach dest from self.origin traveling at speed =============== */ -void Mover::MoveTo( Vector tdest, Vector angdest, float tspeed, Event& event ) +void Mover::MoveTo(Vector tdest, Vector angdest, float tspeed, Event& event) { - Vector vdestdelta; - Vector angdestdelta; - float len; - float traveltime; + Vector vdestdelta; + Vector angdestdelta; + float len; + float traveltime; - assert( tspeed >= 0.0f ); + assert(tspeed >= 0.0f); - if( !tspeed ) - { - error( "MoveTo", "No speed is defined!" ); - } + if (!tspeed) { + error("MoveTo", "No speed is defined!"); + } - if( tspeed < 0.0f ) - { - error( "MoveTo", "Speed is negative!" ); - } + if (tspeed < 0.0f) { + error("MoveTo", "Speed is negative!"); + } - // Cancel previous moves - CancelEventsOfType( EV_MoveDone ); + // Cancel previous moves + CancelEventsOfType(EV_MoveDone); - moveflags = 0; + moveflags = 0; - if( endevent ) - { - delete endevent; - } + if (endevent) { + delete endevent; + } - endevent = new Event( event ); + endevent = new Event(event); - finaldest = tdest; - angledest = angdest; + finaldest = tdest; + angledest = angdest; - if( finaldest != localorigin ) - { - moveflags |= MOVE_ORIGIN; - } - if( angledest != localangles ) - { - moveflags |= MOVE_ANGLES; - } + if (finaldest != localorigin) { + moveflags |= MOVE_ORIGIN; + } + if (angledest != localangles) { + moveflags |= MOVE_ANGLES; + } - if( !moveflags ) - { - // stop the object from moving - velocity = vec_zero; - avelocity = vec_zero; + if (!moveflags) { + // stop the object from moving + velocity = vec_zero; + avelocity = vec_zero; - // post the event so we don't wait forever - PostEvent( EV_MoveDone, FRAMETIME ); - return; - } + // post the event so we don't wait forever + PostEvent(EV_MoveDone, FRAMETIME); + return; + } - // set destdelta to the vector needed to move - vdestdelta = tdest - localorigin; - angdestdelta[ 0 ] = angledist( angdest[ 0 ] - localangles[ 0 ] ); - angdestdelta[ 1 ] = angledist( angdest[ 1 ] - localangles[ 1 ] ); - angdestdelta[ 2 ] = angledist( angdest[ 2 ] - localangles[ 2 ] ); + // set destdelta to the vector needed to move + vdestdelta = tdest - localorigin; + angdestdelta[0] = angledist(angdest[0] - localangles[0]); + angdestdelta[1] = angledist(angdest[1] - localangles[1]); + angdestdelta[2] = angledist(angdest[2] - localangles[2]); - if( tdest == localorigin ) - { - // calculate length of vector based on angles - len = angdestdelta.length(); - } - else - { - // calculate length of vector based on distance - len = vdestdelta.length(); - } + if (tdest == localorigin) { + // calculate length of vector based on angles + len = angdestdelta.length(); + } else { + // calculate length of vector based on distance + len = vdestdelta.length(); + } - // divide by speed to get time to reach dest - traveltime = len / tspeed; + // divide by speed to get time to reach dest + traveltime = len / tspeed; - if( traveltime < level.frametime ) - { - traveltime = level.frametime; - vdestdelta = vec_zero; - angdestdelta = vec_zero; - } + if (traveltime < level.frametime) { + traveltime = level.frametime; + vdestdelta = vec_zero; + angdestdelta = vec_zero; + } - // scale the destdelta vector by the time spent traveling to get velocity - if( moveflags & MOVE_ORIGIN ) - { - velocity = vdestdelta * ( 1.0f / traveltime ); - } + // scale the destdelta vector by the time spent traveling to get velocity + if (moveflags & MOVE_ORIGIN) { + velocity = vdestdelta * (1.0f / traveltime); + } - if( moveflags & MOVE_ANGLES ) - { - avelocity = angdestdelta * ( 1.0f / traveltime ); - } + if (moveflags & MOVE_ANGLES) { + avelocity = angdestdelta * (1.0f / traveltime); + } - PostEvent( EV_MoveDone, traveltime ); + PostEvent(EV_MoveDone, traveltime); } /* @@ -229,55 +208,66 @@ void Mover::MoveTo( Vector tdest, Vector angdest, float tspeed, Event& event ) LinearInterpolate =============== */ -void Mover::LinearInterpolate - ( - Vector tdest, - Vector angdest, - float time, - Event &event - ) +void Mover::LinearInterpolate(Vector tdest, Vector angdest, float time, Event& event) { - Vector vdestdelta; - Vector angdestdelta; - float t; + Vector vdestdelta; + Vector angdestdelta; + float t; - if( endevent ) - { - delete endevent; - } - endevent = new Event( event ); - finaldest = tdest; - angledest = angdest; + if (endevent) { + delete endevent; + } + endevent = new Event(event); + finaldest = tdest; + angledest = angdest; - // Cancel previous moves - CancelEventsOfType( EV_MoveDone ); + // Cancel previous moves + CancelEventsOfType(EV_MoveDone); - // Quantize to FRAMETIME - if( time < FRAMETIME ) - { - time = FRAMETIME; - } + // Quantize to FRAMETIME + if (time < FRAMETIME) { + time = FRAMETIME; + } - moveflags = 0; - t = 1 / time; - // scale the destdelta vector by the time spent traveling to get velocity - if( finaldest != localorigin ) - { - vdestdelta = tdest - localorigin; - velocity = vdestdelta * t; - moveflags |= MOVE_ORIGIN; - } + moveflags = 0; + t = 1 / time; + // scale the destdelta vector by the time spent traveling to get velocity + if (finaldest != localorigin) { + vdestdelta = tdest - localorigin; + velocity = vdestdelta * t; + moveflags |= MOVE_ORIGIN; + } - if( angledest != localangles ) - { - angdestdelta = angdest - localangles; - avelocity = angdestdelta * t; - moveflags |= MOVE_ANGLES; - } + if (angledest != localangles) { + angdestdelta = angdest - localangles; + avelocity = angdestdelta * t; + moveflags |= MOVE_ANGLES; + } - if( g_bBeforeThinks ) - time -= FRAMETIME; + if (g_bBeforeThinks) { + time -= FRAMETIME; + } - PostEvent( EV_MoveDone, time ); + PostEvent(EV_MoveDone, time); } +/* +============= +Stop +=============== +*/ +void Mover::Stop() +{ + if (endevent) { + delete endevent; + endevent = NULL; + } + + CancelEventsOfType(EV_MoveDone); + + moveflags = 0; + avelocity = vec_zero; + velocity = vec_zero; + accel = vec_zero; + aaccel = vec_zero; +} diff --git a/code/fgame/mover.h b/code/fgame/mover.h index d39eed77..f128a334 100644 --- a/code/fgame/mover.h +++ b/code/fgame/mover.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2025 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -24,45 +24,40 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // Base class for any object that needs to move to specific locations over a // period of time. This class is kept separate from most entities to keep // class size down for objects that don't need such behavior. -// +// -#ifndef __MOVER_H__ -#define __MOVER_H__ +#pragma once #include "g_local.h" #include "entity.h" #include "trigger.h" class Mover : public Trigger - { - private: - Vector finaldest; - Vector angledest; - Event *endevent; - int moveflags; +{ +private: + Vector finaldest; + Vector angledest; + Event *endevent; + int moveflags; - public: - CLASS_PROTOTYPE( Mover ); +public: + CLASS_PROTOTYPE(Mover); - Mover(); - virtual ~Mover(); - void MoveDone( Event *ev ); - void MoveTo( Vector tdest, Vector angdest, float tspeed, Event &event ); - void LinearInterpolate( Vector tdest, Vector angdest, float time, Event &event ); - void Archive( Archiver &arc ) override; - }; + Mover(); + virtual ~Mover(); + void MoveDone(Event *ev); + void MoveTo(Vector tdest, Vector angdest, float tspeed, Event& event); + void LinearInterpolate(Vector tdest, Vector angdest, float time, Event& event); + void Stop(); + void Archive(Archiver& arc) override; +}; -inline void Mover::Archive - ( - Archiver &arc - ) - { - Trigger::Archive( arc ); +inline void Mover::Archive(Archiver& arc) +{ + Trigger::Archive(arc); - arc.ArchiveVector( &finaldest ); - arc.ArchiveVector( &angledest ); - arc.ArchiveEventPointer( &endevent ); - arc.ArchiveInteger( &moveflags ); - } - -#endif + arc.ArchiveVector(&finaldest); + arc.ArchiveVector(&angledest); + arc.ArchiveEventPointer(&endevent); + arc.ArchiveInteger(&moveflags); +} diff --git a/code/fgame/navigate.cpp b/code/fgame/navigate.cpp index 4d786a95..e8a8f24d 100644 --- a/code/fgame/navigate.cpp +++ b/code/fgame/navigate.cpp @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -31,6 +31,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "player.h" #include "debuglines.h" #include "scriptexception.h" +#include "gamecmds.h" #define PATHFILE_VERSION 103 @@ -45,6 +46,7 @@ cvar_t *ai_fallheight; cvar_t *ai_debugpath; cvar_t *ai_pathchecktime; cvar_t *ai_pathcheckdist; +cvar_t *ai_editmode; // Added in OPM static const vec_t *path_start; static const vec_t *path_end; @@ -148,6 +150,7 @@ PathInfo *PathSearch::GeneratePath(PathInfo *path) VectorCopy2D(pathway->dir, current_path->dir); current_path->dist = pathway->dist; current_path->bAccurate = true; + assert(current_path->dist > -1e+07 && current_path->dist < 1e+07); current_path++; } @@ -157,7 +160,8 @@ PathInfo *PathSearch::GeneratePath(PathInfo *path) if (pathway->dist) { VectorCopy(pathway->pos2, current_path->point); VectorCopy2D(pathway->dir, current_path->dir); - current_path->dist = pathway->dist; + current_path->dist = pathway->dist; + assert(current_path->dist > -1e+07 && current_path->dist < 1e+07); current_path->bAccurate = true; current_path++; } @@ -166,6 +170,7 @@ PathInfo *PathSearch::GeneratePath(PathInfo *path) VectorCopy(pathway->pos1, current_path->point); VectorCopy2D(path_startdir, current_path->dir); current_path->dist = Node->g; + assert(current_path->dist > -1e+07 && current_path->dist < 1e+07); } else { VectorCopy2D(path_totaldir, current_path->dir); path->dist = Node->h; @@ -214,6 +219,7 @@ PathInfo *PathSearch::GeneratePathNear(PathInfo *path) VectorCopy2D(pathway->dir, current_path->dir); current_path->dist = pathway->dist; current_path->bAccurate = true; + assert(current_path->dist > -1e+07 && current_path->dist < 1e+07); current_path++; } } @@ -252,11 +258,12 @@ PathInfo *PathSearch::GeneratePathAway(PathInfo *path) pathway = &ParentNode->Child[Node->pathway]; if (pathway->dist) { - VectorCopy(pathway->pos2, path->point); - VectorCopy2D(pathway->dir, path->dir); - path->dist = pathway->dist; + VectorCopy(pathway->pos2, current_path->point); + VectorCopy2D(pathway->dir, current_path->dir); + current_path->dist = pathway->dist; current_path->bAccurate = true; + assert(current_path->dist > -1e+07 && current_path->dist < 1e+07); current_path++; } @@ -268,6 +275,7 @@ PathInfo *PathSearch::GeneratePathAway(PathInfo *path) VectorCopy2D(pathway->dir, current_path->dir); current_path->dist = pathway->dist; current_path->bAccurate = true; + assert(current_path->dist > -1e+07 && current_path->dist < 1e+07); current_path++; } } @@ -314,8 +322,10 @@ int PathSearch::FindPath( PathNode *to; if (ent) { + // Added in OPM + // Check for simple actor if (ent->IsSubclassOfActor()) { - Node = NearestStartNode(start, (SimpleActor *)ent); + Node = NearestStartNode(start, static_cast(ent)); } else { Node = DebugNearestStartNode(start, ent); } @@ -380,6 +390,9 @@ int PathSearch::FindPath( pathway = &Node->Child[i]; NewNode = pathnodes[pathway->node]; + if (!NewNode) { + continue; + } if (vLeashHome) { VectorSub2D(pathway->pos2, vLeashHome, vDist); @@ -423,7 +436,8 @@ int PathSearch::FindPath( } if (pathway->fallheight <= fallheight - && (!ent->IsSubclassOfSentient() || !pathway->badPlaceTeam[static_cast(ent)->m_Team])) { + && (!ent || !ent->IsSubclassOfSentient() || !pathway->badPlaceTeam[static_cast(ent)->m_Team] + )) { NewNode->m_Depth = Node->m_Depth + 1; NewNode->Parent = Node; NewNode->pathway = i; @@ -493,8 +507,10 @@ int PathSearch::FindPathNear( vec2_t delta; if (ent) { + // Added in OPM + // Check for simple actor if (ent->IsSubclassOfActor()) { - Node = NearestStartNode(start, (SimpleActor *)ent); + Node = NearestStartNode(start, static_cast(ent)); } else { Node = DebugNearestStartNode(start, ent); } @@ -553,6 +569,9 @@ int PathSearch::FindPathNear( pathway = &Node->Child[i]; NewNode = pathnodes[pathway->node]; + if (!NewNode) { + continue; + } g = (int)(pathway->dist + Node->g + 1.0f); @@ -589,7 +608,8 @@ int PathSearch::FindPathNear( } if (pathway->fallheight <= fallheight - && (!ent->IsSubclassOfSentient() || !pathway->badPlaceTeam[static_cast(ent)->m_Team])) { + && (!ent || !ent->IsSubclassOfSentient() || !pathway->badPlaceTeam[static_cast(ent)->m_Team] + )) { NewNode->m_Depth = Node->m_Depth + 1; NewNode->Parent = Node; NewNode->pathway = i; @@ -656,15 +676,16 @@ int PathSearch::FindPathAway( PathNode *next; int f; float fBias; - vec2_t dir; vec2_t delta; float fMinSafeDistSquared; fMinSafeDistSquared = fMinSafeDist * fMinSafeDist; if (ent) { + // Added in OPM + // Check for simple actor if (ent->IsSubclassOfActor()) { - Node = NearestStartNode(start, (SimpleActor *)ent); + Node = NearestStartNode(start, static_cast(ent)); } else { Node = DebugNearestStartNode(start, ent); } @@ -681,13 +702,13 @@ int PathSearch::FindPathAway( open = NULL; VectorSub2D(Node->origin, start, path_startdir); - VectorSub2D(start, avoid, dir); + VectorSub2D(start, avoid, delta); fBias = VectorLength2D(vPreferredDir); Node->inopen = true; Node->g = VectorNormalize2D(path_startdir); - Node->h = fMinSafeDist - VectorNormalize2D(dir); + Node->h = fMinSafeDist - VectorNormalize2D(delta); Node->h += fBias - DotProduct2D(vPreferredDir, delta); Node->Parent = NULL; Node->m_Depth = 2; @@ -720,6 +741,9 @@ int PathSearch::FindPathAway( pathway = &Node->Child[i]; NewNode = pathnodes[pathway->node]; + if (!NewNode) { + continue; + } if (vLeashHome) { VectorSub2D(pathway->pos2, vLeashHome, vDist); @@ -752,9 +776,9 @@ int PathSearch::FindPathAway( } } - VectorSub2D(pathway->pos2, avoid, dir); - NewNode->h = VectorNormalize2D(dir); - NewNode->h += fBias - DotProduct2D(dir, vPreferredDir); + VectorSub2D(pathway->pos2, avoid, delta); + NewNode->h = VectorNormalize2D(delta); + NewNode->h += fBias - DotProduct2D(delta, vPreferredDir); f = (int)((float)g + NewNode->h); @@ -807,7 +831,7 @@ int PathSearch::FindPathAway( } PathNode *PathSearch::FindCornerNodeForWall( - const vec3_t start, const vec3_t end, SimpleActor *ent, float maxPath, const vec4_t plane + const vec3_t start, const vec3_t end, Entity *ent, float maxPath, const vec4_t plane ) { int i, g; @@ -818,7 +842,18 @@ PathNode *PathSearch::FindCornerNodeForWall( vec2_t delta; vec2_t dir; - Node = NearestStartNode(start, ent); + if (ent) { + // Added in OPM + // Check for simple actor + if (ent->IsSubclassOfActor()) { + Node = NearestStartNode(start, static_cast(ent)); + } else { + Node = DebugNearestStartNode(start, ent); + } + } else { + Node = DebugNearestStartNode(start); + } + if (!Node) { last_error = "couldn't find start node"; return NULL; @@ -880,7 +915,11 @@ PathNode *PathSearch::FindCornerNodeForWall( pathway = &Node->Child[i]; NewNode = pathnodes[pathway->node]; - g = (int)(pathway->dist + Node->g + 1.0f); + if (!NewNode) { + continue; + } + + g = (int)(pathway->dist + Node->g + 1.0f); if (NewNode->findCount == findFrame) { if (NewNode->g <= g) { @@ -960,9 +999,9 @@ PathNode *PathSearch::FindCornerNodeForWall( return NULL; } -PathNode *PathSearch::FindCornerNodeForExactPath(SimpleActor *pSelf, Sentient *enemy, float fMaxPath) +PathNode *PathSearch::FindCornerNodeForExactPath(Entity *pSelf, Sentient *enemy, float fMaxPath) { - PathNode *pPathNode[4096]; + PathNode *pPathNode[MAX_PATHNODES]; PathNode *pParentNode; size_t i, iDepth; Vector vEnd; @@ -974,7 +1013,12 @@ PathNode *PathSearch::FindCornerNodeForExactPath(SimpleActor *pSelf, Sentient *e return NULL; } - vEyePos = pSelf->EyePosition(); + if (pSelf->IsSubclassOfActor()) { + vEyePos = static_cast(pSelf)->EyePosition(); + } else { + vEyePos = pSelf->origin + Vector(0, 0, pSelf->maxs.z); + } + vEyeDelta = vEyePos - pSelf->origin; for (pParentNode = Node->Parent, i = 0; pParentNode; pParentNode = pParentNode->Parent, i++) { @@ -1026,8 +1070,8 @@ void PathSearch::ResetNodes(void) m_LoadIndex = -1; if (!startBulkNavMemory && nodecount) { - for (x = PATHMAP_GRIDSIZE - 1; x >= 0; x--) { - for (y = PATHMAP_GRIDSIZE - 1; y >= 0; y--) { + for (x = 0; x < PATHMAP_GRIDSIZE; x++) { + for (y = 0; y < PATHMAP_GRIDSIZE; y++) { if (PathMap[x][y].nodes) { gi.Free(PathMap[x][y].nodes); } @@ -1035,22 +1079,23 @@ void PathSearch::ResetNodes(void) } for (i = 0; i < nodecount; i++) { - if (pathnodes[i]->Child) { + if (pathnodes[i] && pathnodes[i]->Child) { gi.Free(pathnodes[i]->Child); } } } - for (x = PATHMAP_GRIDSIZE - 1; x >= 0; x--) { - for (y = PATHMAP_GRIDSIZE - 1; y >= 0; y--) { - PathMap[x][y].numnodes = 0; - PathMap[x][y].nodes = NULL; + for (x = 0; x < PATHMAP_GRIDSIZE; x++) { + for (y = 0; y < PATHMAP_GRIDSIZE; y++) { + PathMap[x][y] = MapCell(); } } for (i = 0; i < nodecount; i++) { - delete pathnodes[i]; - pathnodes[i] = NULL; + if (pathnodes[i]) { + delete pathnodes[i]; + pathnodes[i] = NULL; + } } nodecount = 0; @@ -1063,6 +1108,76 @@ void PathSearch::ResetNodes(void) } } +void PathSearch::ClearNodes(void) +{ + int i, j; + int x; + int y; + + m_bNodesloaded = false; + m_LoadIndex = -1; + + if (!startBulkNavMemory && nodecount) { + for (x = 0; x < PATHMAP_GRIDSIZE; x++) { + for (y = 0; y < PATHMAP_GRIDSIZE; y++) { + if (PathMap[x][y].nodes) { + gi.Free(PathMap[x][y].nodes); + } + } + } + + for (i = 0; i < nodecount; i++) { + if (pathnodes[i] && pathnodes[i]->Child) { + gi.Free(pathnodes[i]->Child); + } + } + } + + for (x = 0; x < PATHMAP_GRIDSIZE; x++) { + for (y = 0; y < PATHMAP_GRIDSIZE; y++) { + PathMap[x][y] = MapCell(); + } + } + + for (i = 0; i < nodecount; i++) { + if (pathnodes[i]) { + pathnodes[i]->Child = NULL; + pathnodes[i]->virtualNumChildren = 0; + pathnodes[i]->numChildren = 0; + pathnodes[i]->findCount = 0; + } + } + + // Rebuild node list + for (i = 0; i < nodecount; i++) { + PathNode *node1 = pathnodes[i]; + if (node1) { + continue; + } + + for (j = i + 1; j < nodecount; j++) { + PathNode *node2 = pathnodes[j]; + if (node2) { + pathnodes[i] = node2; + pathnodes[j] = NULL; + node2->nodenum = i; + break; + } + } + } + + while (nodecount > 0 && !pathnodes[nodecount - 1]) { + nodecount--; + } + + // Free the bulk nav' memory + if (startBulkNavMemory) { + gi.Free(startBulkNavMemory); + bulkNavMemory = NULL; + startBulkNavMemory = NULL; + } +} + void PathSearch::UpdatePathwaysForBadPlace(const Vector& origin, float radius, int dir, int team) { float radiusSqr; @@ -1072,6 +1187,9 @@ void PathSearch::UpdatePathwaysForBadPlace(const Vector& origin, float radius, i for (i = 0; i < nodecount; i++) { PathNode *node = pathnodes[i]; + if (!node) { + continue; + } for (j = node->virtualNumChildren; j > 0; j--) { pathway_t& pathway = node->Child[j - 1]; @@ -1088,21 +1206,47 @@ void PathSearch::UpdatePathwaysForBadPlace(const Vector& origin, float radius, i void AI_AddNode(PathNode *node) { - int i = PathSearch::nodecount; + int i; assert(node); - if (i < MAX_PATHNODES) { - if (i > ai_maxnode) { - ai_maxnode = i; + // + // Find a free slot + // + for (i = 0; i < PathSearch::nodecount; i++) { + if (!PathSearch::pathnodes[i]) { + PathSearch::pathnodes[i] = node; + node->nodenum = i; + return; } - PathSearch::pathnodes[i] = node; - node->nodenum = i; - PathSearch::nodecount++; + } + + if (i > ai_maxnode) { + ai_maxnode = i; + } + + if (i >= MAX_PATHNODES) { + gi.Error(ERR_DROP, "Exceeded MAX_PATHNODES!\n"); return; } - gi.Error(ERR_DROP, "Exceeded MAX_PATHNODES!\n"); + PathSearch::pathnodes[i] = node; + node->nodenum = i; + + PathSearch::nodecount++; +} + +void AI_RemoveNode(PathNode *node) +{ + int num; + + num = node->nodenum; + delete node; + + PathSearch::pathnodes[num] = NULL; + if (num == PathSearch::nodecount) { + PathSearch::nodecount--; + } } /*****************************************************************************/ @@ -1138,7 +1282,8 @@ Event EV_Path_SetLowWallArc EV_DEFAULT, "f", "arc_half_angle", - "Marks this node as good for low-wall behavior, and gives the arc" + "Marks this node as good for low-wall behavior" + "and gives the arc" ); CLASS_DECLARATION(SimpleEntity, PathNode, "info_pathnode") { @@ -1218,7 +1363,7 @@ void PathNode::SetLowWallArc(Event *ev) void PathNode::ConnectTo(PathNode *node) { - Child[virtualNumChildren].node = nodenum; + Child[virtualNumChildren].node = node->nodenum; Child[virtualNumChildren].numBlockers = 0; Child[virtualNumChildren].badPlaceTeam[0] = 0; Child[virtualNumChildren].badPlaceTeam[1] = 0; @@ -1287,6 +1432,9 @@ void PathNode::DrawConnections(void) for (i = 0; i < numChildren; i++) { path = &Child[i]; node = PathSearch::pathnodes[path->node]; + if (!node) { + continue; + } G_DebugLine(origin + Vector("0 0 24"), node->origin + Vector("0 0 24"), 0.7f, 0.7f, 0, 1); } @@ -1308,27 +1456,32 @@ static void droptofloor(Vector& vec, PathNode *node) static bool IsValidPathnode(int spawnflags) { - if ((spawnflags & AI_DUCK) && (spawnflags & AI_COVERFLAGS2)) { + if ((spawnflags & AI_DUCK) + && (spawnflags & (AI_CONCEALMENT | AI_CORNER_LEFT | AI_CORNER_RIGHT | AI_SNIPER | AI_CRATE))) { return false; } - if ((spawnflags & AI_CONCEALMENT) && (spawnflags & AI_SNIPERFLAGS)) { + if ((spawnflags & AI_CONCEALMENT) && (spawnflags & (AI_COVER | AI_CORNER_LEFT | AI_CORNER_RIGHT | AI_SNIPER))) { return false; } - if ((spawnflags & AI_CORNER_LEFT) && (spawnflags & AI_COVER_LEFT_FLAGS)) { + if ((spawnflags & AI_CORNER_LEFT) + && (spawnflags & (AI_DUCK | AI_CONCEALMENT | AI_CORNER_RIGHT | AI_SNIPER | AI_CRATE))) { return false; } - if ((spawnflags & AI_CORNER_RIGHT) && (spawnflags & AI_COVER_RIGHT_FLAGS)) { + if ((spawnflags & AI_CORNER_RIGHT) + && (spawnflags & (AI_DUCK | AI_CONCEALMENT | AI_CORNER_LEFT | AI_SNIPER | AI_CRATE))) { return false; } - if ((spawnflags & AI_SNIPER) && (spawnflags & AI_CRATEFLAGS)) { + if ((spawnflags & AI_SNIPER) + && (spawnflags & (AI_DUCK | AI_COVER | AI_CONCEALMENT | AI_CORNER_LEFT | AI_CORNER_RIGHT | AI_CRATE))) { return false; } - if ((spawnflags & AI_ALL) && (spawnflags & AI_COVERFLAGS3)) { + if ((spawnflags & AI_CRATE) + && (spawnflags & (AI_DUCK | AI_CONCEALMENT | AI_CORNER_LEFT | AI_CORNER_RIGHT | AI_SNIPER))) { return false; } @@ -1337,27 +1490,51 @@ static bool IsValidPathnode(int spawnflags) static void GetPathnodeColor(int spawnflags, vec3_t color) { - if (IsValidPathnode(spawnflags)) { - if (spawnflags & AI_CORNER_LEFT) { - VectorCopy(COLOR_PATHNODE_CORNER_LEFT, color); - } else if (spawnflags & AI_CORNER_RIGHT) { - VectorCopy(COLOR_PATHNODE_CORNER_RIGHT, color); - } else if (spawnflags & AI_DUCK) { - VectorCopy(COLOR_PATHNODE_DUCK, color); - } else if (spawnflags & AI_SNIPER) { - VectorCopy(COLOR_PATHNODE_SNIPER, color); - } else if (spawnflags & AI_CONCEALMENT) { - VectorCopy(COLOR_PATHNODE_CONCEALMENT, color); - } else if (spawnflags & AI_COVER) { - VectorCopy(COLOR_PATHNODE_COVER, color); - } else if (spawnflags & AI_CRATE) { - VectorCopy(COLOR_PATHNODE_CRATE, color); - } else { - VectorCopy(COLOR_PATHNODE_DEFAULT, color); - } - } else { + if (!IsValidPathnode(spawnflags)) { VectorCopy(COLOR_PATHNODE_ERROR, color); + return; } + + if (spawnflags & AI_CORNER_LEFT) { + VectorCopy(COLOR_PATHNODE_CORNER_LEFT, color); + } else if (spawnflags & AI_CORNER_RIGHT) { + VectorCopy(COLOR_PATHNODE_CORNER_RIGHT, color); + } else if (spawnflags & AI_DUCK) { + VectorCopy(COLOR_PATHNODE_DUCK, color); + } else if (spawnflags & AI_SNIPER) { + VectorCopy(COLOR_PATHNODE_SNIPER, color); + } else if (spawnflags & AI_CONCEALMENT) { + VectorCopy(COLOR_PATHNODE_CONCEALMENT, color); + } else if (spawnflags & AI_COVER) { + VectorCopy(COLOR_PATHNODE_COVER, color); + } else if (spawnflags & AI_CRATE) { + VectorCopy(COLOR_PATHNODE_CRATE, color); + } else { + VectorCopy(COLOR_PATHNODE_DEFAULT, color); + } +} + +static int GetNodeTypeFromName(const char *name) +{ + if (!str::icmp(name, "corner_left")) { + return AI_CORNER_LEFT; + } else if (!str::icmp(name, "corner_right")) { + return AI_CORNER_RIGHT; + } else if (!str::icmp(name, "duck")) { + return AI_DUCK; + } else if (!str::icmp(name, "sniper")) { + return AI_SNIPER; + } else if (!str::icmp(name, "concealment")) { + return AI_CONCEALMENT; + } else if (!str::icmp(name, "cover")) { + return AI_COVER; + } else if (!str::icmp(name, "crate")) { + return AI_CRATE; + } else if (!str::icmp(name, "none")) { + return 0; + } + + return -1; } void DrawNode(int iNodeCount) @@ -1377,7 +1554,7 @@ void DrawNode(int iNodeCount) Vector aStart; Vector aEnd; PathNode *node; - PathNode *nodelist[4096]; + PathNode *nodelist[MAX_PATHNODES]; Vector end; Vector start; Vector p; @@ -1385,8 +1562,8 @@ void DrawNode(int iNodeCount) playerorigin = g_entities[0].client->ps.origin; - if (iNodeCount > 4096) { - iNodeCount = 4096; + if (iNodeCount > MAX_PATHNODES) { + iNodeCount = MAX_PATHNODES; } if (ai_showallnode->integer) { @@ -1492,6 +1669,9 @@ void DrawAllConnections(void) for (int i = 0; i < PathSearch::nodecount; i++) { node = PathSearch::pathnodes[i]; + if (!node) { + continue; + } if (Vector(node->origin - playerorigin).length() > ai_showroutes_distance->integer) { continue; @@ -1509,7 +1689,11 @@ void DrawAllConnections(void) } reverse = false; - to = PathSearch::pathnodes[path->node]; + + to = PathSearch::pathnodes[path->node]; + if (!to) { + continue; + } for (int k = to->numChildren - 1; k >= 0; k--) { path2 = &to->Child[k]; @@ -1713,10 +1897,12 @@ int PathSearch::DebugNearestNodeList(const vec3_t pos, PathNode **nodelist, int int node_count = NearestNodeSetup(pos, cell, nodes, deltas); int n = 0; - int j = 0; - for (i = 0; i < node_count && j < iMaxNodes; i++) { + for (i = 0; i < node_count && n < iMaxNodes; i++) { node = pathnodes[cell->nodes[nodes[i]]]; + if (!node) { + continue; + } VectorCopy(pos, start); VectorCopy(pos, end); @@ -1769,6 +1955,9 @@ int PathSearch::DebugNearestNodeList2(const vec3_t pos, PathNode **nodelist, int for (i = 0; i < node_count; i++) { node = pathnodes[i]; + if (!node) { + continue; + } if (pos[2] > node->origin[2] + 94.0f) { continue; @@ -1825,6 +2014,9 @@ PathNode *PathSearch::DebugNearestStartNode(const vec3_t pos, Entity *ent) for (i = 0; i < node_count; i++) { node = pathnodes[cell->nodes[nodes[i]]]; + if (!node) { + continue; + } VectorCopy(start, end); VectorAdd(end, deltas[nodes[i]], end); @@ -1875,6 +2067,9 @@ PathNode *PathSearch::NearestStartNode(const vec3_t pos, SimpleActor *ent) for (i = 0; i < node_count; i++) { node = pathnodes[cell->nodes[nodes[i]]]; + if (!node) { + continue; + } VectorAdd(start, deltas[nodes[i]], end); @@ -1942,6 +2137,9 @@ PathNode *PathSearch::NearestEndNode(const vec3_t pos) for (i = 0; i < node_count; i++) { node = pathnodes[cell->nodes[nodes[i]]]; + if (!node) { + continue; + } VectorAdd(start, deltas[nodes[i]], end); @@ -2016,6 +2214,8 @@ void PathSearch::ShowNodes(void) } } } + + navMaster.Frame(); } qboolean PathSearch::ArchiveSaveNodes(void) @@ -2088,21 +2288,32 @@ void PathSearch::Init(void) ai_debugpath = gi.Cvar_Get("ai_debugpath", "0", 0); ai_pathchecktime = gi.Cvar_Get("ai_pathchecktime", "1.5", CVAR_CHEAT); ai_pathcheckdist = gi.Cvar_Get("ai_pathcheckdist", "4096", CVAR_CHEAT); + + // + // Added in OPM + // + ai_editmode = gi.Cvar_Get("ai_editmode", "0", CVAR_LATCH); + + navMaster.Init(); } void *PathSearch::AllocPathNode(void) { if (!bulkNavMemory) { return gi.Malloc(sizeof(PathNode)); + } else { + bulkNavMemory -= sizeof(PathNode); + if (ai_editmode->integer) { + return gi.Malloc(sizeof(PathNode)); + } } - bulkNavMemory -= sizeof(PathNode); return bulkNavMemory; } void PathSearch::FreePathNode(void *ptr) { - if (!bulkNavMemory) { + if (!bulkNavMemory || ai_editmode->integer) { gi.Free(ptr); } } @@ -2117,7 +2328,7 @@ void PathSearch::PlayerCover(Player *pPlayer) for (i = 0; i < nodecount; i++) { node = pathnodes[i]; - if (!node || !(node->nodeflags & AI_COVERFLAGS)) { + if (!node || !(node->nodeflags & AI_MOVE_MASK)) { continue; } @@ -2156,20 +2367,20 @@ int node_compare(const void *pe1, const void *pe2) nodeinfo *Pe2 = (nodeinfo *)pe2; int iConcealment; - iConcealment = (Pe1->pNode->nodeflags & AI_CONCEALMENT_MASK) != 0; + iConcealment = (Pe1->pNode->nodeflags & AI_CONCEALMENT_MASK) ? 1 : 0; if (Pe2->pNode->nodeflags & AI_CONCEALMENT_MASK) { - --iConcealment; + iConcealment--; } return ( - (Pe1->fDistSquared) + (iConcealment << 23) + *(unsigned int*)&Pe1->fDistSquared + (iConcealment << 23) + (((Pe1->pNode->nodeflags & AI_CONCEALMENT) - (Pe2->pNode->nodeflags & AI_CONCEALMENT)) << 21) - - (Pe2->fDistSquared) + - *(unsigned int*)&Pe2->fDistSquared ); } int PathSearch::FindPotentialCover( - SimpleActor *pEnt, Vector& vPos, Entity *pEnemy, PathNode **ppFoundNodes, int iMaxFind + Entity *pEnt, Vector& vPos, Entity *pEnemy, PathNode **ppFoundNodes, int iMaxFind ) { nodeinfo nodes[MAX_PATHNODES]; @@ -2225,7 +2436,7 @@ int PathSearch::FindPotentialCover( return nNodes; } -PathNode *PathSearch::FindNearestSniperNode(SimpleActor *pEnt, Vector& vPos, Entity *pEnemy) +PathNode *PathSearch::FindNearestSniperNode(Entity*pEnt, Vector& vPos, Entity *pEnemy) { Actor *pSelf = (Actor *)pEnt; PathNode *pNode; @@ -2289,7 +2500,10 @@ PathNode *PathSearch::FindNearestSniperNode(SimpleActor *pEnt, Vector& vPos, Ent PathNode *PathSearch::GetSpawnNode(ClassDef *cls) { - if (m_bNodesloaded) { + if (m_bNodesloaded + // Fixed in OPM + && m_LoadIndex < nodecount + ) { return pathnodes[m_LoadIndex++]; } else { // Otherwise create a new node @@ -2360,6 +2574,9 @@ void PathSearch::CreatePaths(void) for (i = 0; i < nodecount; i++) { node = pathnodes[i]; + if (!node) { + continue; + } droptofloor(node->origin, node); node->centroid = node->origin; @@ -2370,6 +2587,9 @@ void PathSearch::CreatePaths(void) for (j = i - 1; j >= 0; j--) { PathNode *node2 = pathnodes[j]; + if (!node2) { + continue; + } if (node->origin == node2->origin) { Com_Printf( @@ -2391,7 +2611,7 @@ void PathSearch::CreatePaths(void) for (i = 0; i < nodecount; i++) { node = pathnodes[i]; - if (node->nodeflags & PATH_DONT_LINK) { + if (!node || (node->nodeflags & PATH_DONT_LINK)) { continue; } @@ -2401,7 +2621,7 @@ void PathSearch::CreatePaths(void) for (i = 0; i < nodecount; i++) { node = pathnodes[i]; - if (node->nodeflags & PATH_DONT_LINK) { + if (!node || (node->nodeflags & PATH_DONT_LINK)) { continue; } @@ -2603,6 +2823,9 @@ bool PathSearch::Connect(PathNode *node, int x, int y) for (i = 0; i < cell->numnodes; i++) { node2 = pathnodes[cell->nodes[i]]; + if (!node2) { + continue; + } if (node2->findCount != findFrame) { node2->findCount = findFrame; @@ -2667,15 +2890,14 @@ qboolean CheckMove(Vector& origin, Vector& pos, short int *path_fallheight, floa mm.mins[2] = 0; mm.maxs[0] = size; mm.maxs[1] = size; - mm.maxs[2] = 94.0f; + mm.maxs[2] = MAXS_Z; testcount = 0; fallheight = 0.0f; air_z = mm.origin[2]; - for (i = 200; i != 1; i--) { - testpos[i - 1] = mm.origin; - testcount++; + for (i = 0; i < 200; i++) { + testpos[testcount++] = mm.origin; MmoveSingle(&mm); @@ -2683,6 +2905,32 @@ qboolean CheckMove(Vector& origin, Vector& pos, short int *path_fallheight, floa test_fallheight = air_z - mm.origin[2]; if (test_fallheight > fallheight) { + if (test_fallheight > MAXS_Z) { + Vector start; + + // + // Added in OPM + // Check to make sure that the target is reachable enough + // so that AIs don't block trying to move to the target position + + start = origin; + start.z += MAXS_Z; + + if (!G_SightTrace( + start, + vec_zero, + vec_zero, + pos, + (gentity_t *)NULL, + (gentity_t *)NULL, + MASK_PATHSOLID, + qfalse, + "CheckMove" + )) { + return false; + } + } + if (test_fallheight > 1024.0f) { return false; } @@ -2698,10 +2946,8 @@ qboolean CheckMove(Vector& origin, Vector& pos, short int *path_fallheight, floa if (DotProduct2D(dir, mm.desired_dir) <= 0.1f) { error = mm.origin[2] - pos[2]; - gi.Printf("error = %f\n", error); - *path_fallheight = (short)fallheight; - if (fabs(error) <= 94.0f) { + if (fabs(error) <= MAXS_Z) { if (error <= 0.0f || mm.groundPlane) { return true; } @@ -2718,8 +2964,6 @@ qboolean CheckMove(Vector& origin, Vector& pos, short int *path_fallheight, floa *path_fallheight = (short)test_fallheight + fallheight; return test_fallheight + fallheight <= 1024.0f; } - } else { - return true; } if (mm.groundPlane) { @@ -3033,6 +3277,9 @@ int PathSearch::NearestNodeSetup(const vec3_t pos, MapCell *cell, int *nodes, ve for (i = 0; i < node_count; i++) { node = pathnodes[cell->nodes[i]]; + if (!node) { + continue; + } if (pos[2] > node->origin[2] + 94.0f) { continue; @@ -3064,12 +3311,323 @@ int PathSearch::NearestNodeSetup(const vec3_t pos, MapCell *cell, int *nodes, ve return n; } -PathNode *PathSearch::FindNearestCover(SimpleActor *pEnt, Vector& vPos, Entity *pEnemy) +PathNode *PathSearch::FindNearestCover(Entity *pEnt, Vector& vPos, Entity *pEnemy) { // not found in ida return NULL; } +//=============== +// Added in OPM +//=============== + +Event EV_NavMaster_CreatePaths +( + "nav_build", + EV_CHEAT, + NULL, + NULL, + "Build navigation path" +); +Event EV_NavMaster_SpawnNode +( + "nav_create", + EV_CHEAT, + "S", + "type", + "Create a new node at the player's origin" +); +Event EV_NavMaster_SetNodeFlags +( + "nav_node_set_type", + EV_CHEAT, + "sSS", + "type1 type2 ...", + "Set the selected node type. Type can be one of the following values:\n" + "- corner_left\n" + "- corner_right\n" + "- duck\n" + "- sniper\n" + "- concealment\n" + "- cover\n" + "- crate\n" + "- none\n" +); +Event EV_NavMaster_SetNodeTargetName +( + "nav_node_set_targetname", + EV_CHEAT, + "S", + "targetname", + "Set the selected node target name" +); +Event EV_NavMaster_SetNodeTarget +( + "nav_node_set_target", + EV_CHEAT, + "S", + "target", + "Set the selected node target" +); +Event EV_NavMaster_RemoveNode +( + "nav_node_remove", + EV_CHEAT, + NULL, + NULL, + "Delete the selected node" +); + +CLASS_DECLARATION(Listener, NavMaster, NULL) { + {&EV_NavMaster_CreatePaths, &NavMaster::CreatePaths }, + {&EV_NavMaster_SpawnNode, &NavMaster::CreateNode }, + {&EV_NavMaster_SetNodeFlags, &NavMaster::SetNodeFlags }, + {&EV_NavMaster_SetNodeTargetName, &NavMaster::SetNodeTargetName}, + {&EV_NavMaster_SetNodeTarget, &NavMaster::SetNodeTarget }, + {&EV_NavMaster_RemoveNode, &NavMaster::RemoveNode }, + {NULL, NULL } +}; + +NavMaster navMaster; + +NavMaster::NavMaster() {} + +void NavMaster::Init() +{ + G_CreateMaster("nav", this); + + if (ai_editmode->integer) { + // show routes by default + gi.cvar_set("ai_showroutes", "1"); + gi.cvar_set("ai_shownode", "30"); + } +} + +void NavMaster::CreatePaths(Event *ev) +{ + if (!ai_editmode->integer) { + return; + } + PathSearch::ClearNodes(); + PathSearch::CreatePaths(); +} + +void NavMaster::CreateNode(Event *ev) +{ + str type; + int spawnflags = 0; + PathNode *node; + Entity *ent; + + if (ev->NumArgs() > 0) { + type = ev->GetString(1); + spawnflags = GetNodeTypeFromName(type); + if (spawnflags == -1) { + ScriptError("Unrecognized node type '%s'", type.c_str()); + } + } + + ent = g_entities->entity; + if (!ent) { + return; + } + + node = new PathNode; + + node->nodeflags = spawnflags; + node->setOrigin(ent->origin); +} + +void NavMaster::SetNodeFlags(Event *ev) +{ + str type; + str typelist; + int spawnflags; + int i; + + CheckNodeSelected(); + + if (ev->NumArgs() < 1) { + ScriptError("A type is required"); + return; + } + + spawnflags = 0; + + for (i = 1; i <= ev->NumArgs(); i++) { + int flags; + + type = ev->GetString(i); + + flags = GetNodeTypeFromName(type); + if (flags == -1) { + ScriptError("Unrecognized node type '%s'", type.c_str()); + } + + spawnflags |= flags; + + if (i != 1) { + typelist += ", "; + } + typelist += "'" + type + "'"; + } + + selectedNode->nodeflags = spawnflags; + + gi.Printf("Node %d set type %s\n", selectedNode->nodenum, typelist.c_str()); +} + +void NavMaster::SetNodeTargetName(Event *ev) +{ + CheckNodeSelected(); + + selectedNode->targetname = ev->GetString(1); + + gi.Printf("Node %d got new targetname '%s'\n", selectedNode->nodenum, selectedNode->targetname.c_str()); +} + +void NavMaster::SetNodeTarget(Event *ev) +{ + CheckNodeSelected(); + + selectedNode->target = ev->GetString(1); + + gi.Printf("Node %d got new target '%s'\n", selectedNode->nodenum, selectedNode->target.c_str()); +} + +void NavMaster::RemoveNode(Event *ev) +{ + str targetname; + int num; + + CheckNodeSelected(); + + num = selectedNode->nodenum; + targetname = selectedNode->targetname; + AI_RemoveNode(selectedNode); + + gi.Printf("Node %d removed\n", num, targetname.c_str()); +} + +void NavMaster::CheckNodeSelected() +{ + if (!selectedNode) { + ScriptError("No node selected"); + } +} + +void NavMaster::Frame() +{ + float phase; + vec3_t color; + + if (!ai_editmode->integer) { + return; + } + + phase = fmod(level.time * 2, 2.0); + if (phase > 1.0) { + phase = 2.0 - phase; + } + //phase = (sin(level.time * 5) + 1) / 2.0; + + selectedNode = DetermineCurrentNode(); + if (selectedNode) { + Vector mins, maxs; + Vector org; + vec3_t colorPhase; + + GetPathnodeColor(selectedNode->nodeflags, color); + + colorPhase[0] = 0; + colorPhase[1] = (1.0 - phase) * 0.5; + colorPhase[2] = phase; + color[1] = Q_max(color[1], colorPhase[1]) - Q_min(color[1], colorPhase[1]); + color[2] = Q_max(color[2], colorPhase[2]) - Q_min(color[2], colorPhase[2]); + + mins = Vector(-24, -24, -24); + maxs = Vector(24, 24, 24); + org = selectedNode->centroid; + org.z += 24; + + G_DebugBBox(org, mins, maxs, color[0], color[1], color[2], 1.0); + } +} + +PathNode *NavMaster::DetermineCurrentNode() const +{ + Entity *ent; + PathNode *bestnode; + float bestdist; + Vector delta; + Vector dir; + int i; + + ent = g_entities->entity; + if (!ent) { + return NULL; + } + + if (ent->IsSubclassOfSentient()) { + Sentient *sent = static_cast(ent); + const Vector viewAngles = sent->GetViewAngles(); + + Vector forward; + viewAngles.AngleVectorsLeft(&dir); + } else { + dir = ent->orientation[0]; + } + + bestdist = 1e+12f; + bestnode = NULL; + + for (i = 0; i < PathSearch::nodecount; i++) { + PathNode *node = PathSearch::pathnodes[i]; + float dist; + + if (!node) { + continue; + } + + delta = node->centroid - ent->centroid; + if (abs(delta.z) > (MAXS_Z * 2)) { + continue; + } + + if (!FovCheck(dir, delta, 45)) { + continue; + } + + dist = delta.lengthSquared(); + if (dist < bestdist) { + bestdist = dist; + bestnode = node; + } + } + + return bestnode; +} + +bool NavMaster::FovCheck(const Vector& dir, const Vector& delta, float fov) const +{ + float fovdot = cos(DEG2RAD(fov / 2.f)); + float deltadot = DotProduct(delta, dir); + + if (fovdot < 0.0f) { + if (deltadot >= 0.0f) { + return true; + } + + return VectorLengthSquared(delta) * Square(fovdot) > Square(deltadot); + } else { + if (deltadot < 0.0f) { + return false; + } + + return VectorLengthSquared(delta) * Square(fovdot) < Square(deltadot); + } +} + Event EV_AttractiveNode_GetPriority ( "priority", @@ -3079,7 +3637,6 @@ Event EV_AttractiveNode_GetPriority "Get the node priority", EV_GETTER ); - Event EV_AttractiveNode_SetPriority ( "priority", @@ -3089,7 +3646,6 @@ Event EV_AttractiveNode_SetPriority "Set the node priority", EV_SETTER ); - Event EV_AttractiveNode_GetDistance ( "max_dist", @@ -3099,7 +3655,6 @@ Event EV_AttractiveNode_GetDistance "Get the max distance for this node", EV_GETTER ); - Event EV_AttractiveNode_SetDistance ( "max_dist", @@ -3109,7 +3664,6 @@ Event EV_AttractiveNode_SetDistance "Set the max distance for this node to be attracted, -1 for unlimited distance.", EV_SETTER ); - Event EV_AttractiveNode_GetStayTime ( "stay_time", @@ -3119,7 +3673,6 @@ Event EV_AttractiveNode_GetStayTime "Get the max stay time for this node", EV_GETTER ); - Event EV_AttractiveNode_SetStayTime ( "stay_time", @@ -3129,7 +3682,6 @@ Event EV_AttractiveNode_SetStayTime "Set the maximum stay time AI will stay on this node", EV_SETTER ); - Event EV_AttractiveNode_GetRespawnTime ( "respawn_time", @@ -3139,7 +3691,6 @@ Event EV_AttractiveNode_GetRespawnTime "Get the how much time will this node re-attract already attracted AIs", EV_GETTER ); - Event EV_AttractiveNode_SetRespawnTime ( "respawn_time", @@ -3150,7 +3701,6 @@ Event EV_AttractiveNode_SetRespawnTime "AI will get stuck.", EV_SETTER ); - Event EV_AttractiveNode_GetTeam ( "team", @@ -3160,7 +3710,6 @@ Event EV_AttractiveNode_GetTeam "Get the attractive node team. 'none' for no team.", EV_GETTER ); - Event EV_AttractiveNode_SetTeam ( "team", @@ -3170,8 +3719,14 @@ Event EV_AttractiveNode_SetTeam "Set the attractive node team. 'none' for no team.", EV_SETTER ); - -Event EV_AttractiveNode_SetUse("setuse", EV_DEFAULT, "b", "use", "Set if AI should use or not"); +Event EV_AttractiveNode_SetUse +( + "setuse", + EV_DEFAULT, + "b", + "use", + "Set if AI should use or not" +); CLASS_DECLARATION(SimpleArchivedEntity, AttractiveNode, NULL) { {&EV_AttractiveNode_GetPriority, &AttractiveNode::GetPriority }, diff --git a/code/fgame/navigate.h b/code/fgame/navigate.h index 8d6934df..3404aebc 100644 --- a/code/fgame/navigate.h +++ b/code/fgame/navigate.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -66,6 +66,7 @@ extern int path_checksthisframe; class Path; class PathNode; +class SimpleActor; #define NUM_WIDTH_VALUES 16 #define WIDTH_STEP 8 @@ -103,9 +104,18 @@ public: vec2_t dir; public: + PathInfo(); + void Archive(Archiver& arc); }; +inline PathInfo::PathInfo() + : bAccurate(false) + , point {0, 0, 0} + , dist(0) + , dir {0, 0} +{} + inline void PathInfo::Archive(Archiver& arc) { arc.ArchiveBool(&bAccurate); @@ -131,17 +141,10 @@ typedef enum { // Added in 2.0 #define AI_LOW_WALL_ARC 256 -#define AI_COVERFLAGS \ - (AI_CRATE | AI_SNIPER | AI_CORNER_RIGHT | AI_CORNER_LEFT | AI_CONCEALMENT | AI_COVER | AI_LOW_WALL_ARC) -#define AI_COVERFLAGS2 (AI_SNIPER | AI_CORNER_RIGHT | AI_CORNER_LEFT | AI_CONCEALMENT) -#define AI_COVERFLAGS3 (AI_SNIPER | AI_CORNER_RIGHT | AI_CORNER_LEFT | AI_CONCEALMENT | AI_DUCK | AI_CONCEALMENT) -#define AI_SNIPERFLAGS (AI_SNIPER | AI_CORNER_RIGHT | AI_CORNER_LEFT | AI_COVER) -#define AI_CRATEFLAGS (AI_CRATE | AI_CORNER_LEFT | AI_CORNER_RIGHT | AI_CONCEALMENT | AI_COVER | AI_DUCK) -#define AI_COVER_LEFT_FLAGS (AI_CRATE | AI_SNIPER | AI_CORNER_LEFT | AI_CONCEALMENT | AI_DUCK) -#define AI_COVER_RIGHT_FLAGS (AI_CRATE | AI_SNIPER | AI_CORNER_RIGHT | AI_CONCEALMENT | AI_DUCK) -#define AI_COVER_MASK (AI_CRATE | AI_CORNER_RIGHT | AI_CORNER_LEFT | AI_CONCEALMENT | AI_COVER) -#define AI_CONCEALMENT_MASK (AI_CRATE | AI_CORNER_RIGHT | AI_CONCEALMENT | AI_LOW_WALL_ARC) -#define AI_ALL (AI_DUCK | AI_COVER | AI_CONCEALMENT | AI_CORNER_LEFT | AI_CORNER_RIGHT | AI_SNIPER | AI_CRATE) +#define AI_MOVE_MASK \ + (AI_COVER | AI_CONCEALMENT | AI_CORNER_LEFT | AI_CORNER_RIGHT | AI_SNIPER | AI_CRATE | AI_LOW_WALL_ARC) +#define AI_COVER_MASK (AI_COVER | AI_CONCEALMENT | AI_CORNER_LEFT | AI_CORNER_RIGHT | AI_CRATE | AI_LOW_WALL_ARC) +#define AI_CONCEALMENT_MASK (AI_CORNER_LEFT | AI_CORNER_RIGHT | AI_CRATE | AI_LOW_WALL_ARC) void DrawNode(int iNodeCount); void DrawAllConnections(void); @@ -249,7 +252,7 @@ private: static int m_LoadIndex; public: - static PathNode *pathnodes[4096]; + static PathNode *pathnodes[MAX_PATHNODES]; static int nodecount; static float total_dist; static const char *last_error; @@ -283,7 +286,7 @@ public: static MapCell *GetNodesInCell(const vec3_t pos); static class PathNode *DebugNearestStartNode(const vec3_t pos, Entity *ent = NULL); - static class PathNode *NearestStartNode(const vec3_t pos, class SimpleActor *ent); + static class PathNode *NearestStartNode(const vec3_t pos, SimpleActor *ent); static class PathNode *NearestEndNode(const vec3_t pos); static int DebugNearestNodeList(const vec3_t pos, PathNode **nodelist, int iMaxNodes); static int DebugNearestNodeList2(const vec3_t pos, PathNode **nodelist, int iMaxNodes); @@ -294,8 +297,9 @@ public: static void *AllocPathNode(void); static void FreePathNode(void *); static void ResetNodes(void); + static void ClearNodes(void); // Added in OPM - static void UpdatePathwaysForBadPlace(const Vector &origin, float radius, int dir, int team); + static void UpdatePathwaysForBadPlace(const Vector& origin, float radius, int dir, int team); static PathInfo *GeneratePath(PathInfo *path); static PathInfo *GeneratePathNear(PathInfo *path); static PathInfo *GeneratePathAway(PathInfo *path); @@ -331,15 +335,14 @@ public: float fLeashDistSquared, int fallheight ); - static class PathNode *FindCornerNodeForWall( - const vec3_t start, const vec3_t end, class SimpleActor *ent, float maxPath, const vec4_t plane - ); - static class PathNode *FindCornerNodeForExactPath(class SimpleActor *self, Sentient *enemy, float fMaxPath); - static int - FindPotentialCover(class SimpleActor *pEnt, Vector& vPos, Entity *pEnemy, PathNode **ppFoundNodes, int iMaxFind); - static void PlayerCover(class Player *pPlayer); - static class PathNode *FindNearestCover(class SimpleActor *pEnt, Vector& vPos, Entity *pEnemy); - static class PathNode *FindNearestSniperNode(class SimpleActor *pEnt, Vector& vPos, Entity *pEnemy); + + static class PathNode * + FindCornerNodeForWall(const vec3_t start, const vec3_t end, Entity *ent, float maxPath, const vec4_t plane); + static class PathNode *FindCornerNodeForExactPath(Entity *self, Sentient *enemy, float fMaxPath); + static int FindPotentialCover(Entity *pEnt, Vector& vPos, Entity *pEnemy, PathNode **ppFoundNodes, int iMaxFind); + static void PlayerCover(class Player *pPlayer); + static class PathNode *FindNearestCover(Entity *pEnt, Vector& vPos, Entity *pEnemy); + static class PathNode *FindNearestSniperNode(Entity *pEnt, Vector& vPos, Entity *pEnemy); private: static int NearestNodeSetup(const vec3_t pos, MapCell *cell, int *nodes, vec3_t *deltas); @@ -357,6 +360,34 @@ extern PathSearch PathManager; // Added in OPM //=============== +class NavMaster : public Listener +{ +public: + CLASS_PROTOTYPE(NavMaster); + + NavMaster(); + + void Init(void); + + void CreatePaths(Event *ev); + void CreateNode(Event *ev); + void SetNodeFlags(Event *ev); + void SetNodeTargetName(Event *ev); + void SetNodeTarget(Event *ev); + void RemoveNode(Event *ev); + void Frame(); + +private: + void CheckNodeSelected(); + PathNode *DetermineCurrentNode() const; + bool FovCheck(const Vector& dir, const Vector& delta, float fov) const; + +private: + SafePtr selectedNode; +}; + +extern NavMaster navMaster; + PathNode *AI_FindNode(const char *name); void AI_AddNode(PathNode *node); void AI_RemoveNode(PathNode *node); diff --git a/code/fgame/object.cpp b/code/fgame/object.cpp index fdf81e4a..0cd08c65 100644 --- a/code/fgame/object.cpp +++ b/code/fgame/object.cpp @@ -31,6 +31,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "specialfx.h" #include "g_phys.h" #include "game.h" +#include "../script/scriptexception.h" Event EV_Object_HandleSetModel ( @@ -46,7 +47,14 @@ CLASS_DECLARATION(Animate, Object, NULL) { {NULL, NULL} }; -Event EV_InteractObject_Setup("_setup", EV_DEFAULT, NULL, NULL, "Sets up an object."); +Event EV_InteractObject_Setup +( + "_setup", + EV_DEFAULT, + NULL, + NULL, + "Sets up an object." +); Event EV_InteractObject_KilledEffect ( @@ -118,10 +126,10 @@ void InteractObject::Damaged(Event *ev) void InteractObject::Killed(Event *ev) { - Entity *ent; - Entity *attacker; - Vector dir; - const char *name; + Entity *ent; + Entity *attacker; + Vector dir; + const char *name; takedamage = DAMAGE_NO; deadflag = DEAD_NO; @@ -213,7 +221,7 @@ Event EV_ThrowObject_ThrowSound EV_NORMAL ); -CLASS_DECLARATION(Object, ThrowObject, "func_throwobject") { +CLASS_DECLARATION(Animate, ThrowObject, "func_throwobject") { {&EV_Touch, &ThrowObject::Touch }, {&EV_ThrowObject_Pickup, &ThrowObject::Pickup }, {&EV_ThrowObject_Throw, &ThrowObject::Throw }, @@ -242,7 +250,6 @@ void ThrowObject::ThrowSound(Event *ev) } void ThrowObject::Touch(Event *ev) - { Entity *other; @@ -283,7 +290,6 @@ void ThrowObject::Touch(Event *ev) } void ThrowObject::Throw(Event *ev) - { Entity *owner; Sentient *targetent; @@ -300,6 +306,7 @@ void ThrowObject::Throw(Event *ev) assert(owner); if (!owner) { + ScriptError("owner == NULL"); return; } @@ -311,6 +318,7 @@ void ThrowObject::Throw(Event *ev) targetent = (Sentient *)ev->GetEntity(3); assert(targetent); if (!targetent) { + ScriptError("targetent == NULL"); return; } @@ -328,8 +336,12 @@ void ThrowObject::Throw(Event *ev) gravity = grav; - target = targetent->origin; - target.z += targetent->viewheight; + if (targetent->IsSubclassOfSentient()) { + target = targetent->origin; + target.z += targetent->viewheight; + } else { + target = targetent->centroid; + } setMoveType(MOVETYPE_BOUNCE); setSolidType(SOLID_BBOX); @@ -359,7 +371,6 @@ void ThrowObject::Throw(Event *ev) } void ThrowObject::Pickup(Event *ev) - { Entity *ent; Event *e; @@ -385,7 +396,7 @@ void ThrowObject::Pickup(Event *ev) void ThrowObject::Archive(Archiver& arc) { - Object::Archive(arc); + Animate::Archive(arc); arc.ArchiveInteger(&owner); arc.ArchiveVector(&pickup_offset); diff --git a/code/fgame/object.h b/code/fgame/object.h index 310edf76..fe3fedfe 100644 --- a/code/fgame/object.h +++ b/code/fgame/object.h @@ -46,7 +46,7 @@ public: InteractObject(); void Damaged(Event *ev); - void Killed(Event *ev); + void Killed(Event *ev) override; void Setup(Event *ev); void EventHitEffect(Event *ev); void EventKilledEffect(Event *ev); @@ -56,7 +56,10 @@ public: extern Event EV_ThrowObject_Pickup; extern Event EV_ThrowObject_Throw; -class ThrowObject : public Object +// Fixed in 2.0 +// Before 2.0, ThrowObject was inheriting from Object. +// This caused issue when spawning the ThrowObject from script. +class ThrowObject : public Animate { private: int owner; diff --git a/code/fgame/parm.cpp b/code/fgame/parm.cpp index 9b90a719..76fd8513 100644 --- a/code/fgame/parm.cpp +++ b/code/fgame/parm.cpp @@ -30,63 +30,135 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Parm parm; -Event EV_Parm_GetOther -( - "other", - EV_DEFAULT, - NULL, - NULL, - "other", - EV_GETTER -); - -Event EV_Parm_GetOwner -( - "owner", - EV_DEFAULT, - NULL, - NULL, - "owner", - EV_GETTER -); - Event EV_Parm_GetPreviousThread ( - "previousthread", - EV_DEFAULT, - NULL, - NULL, - "previousthread", - EV_GETTER + "previousthread", + EV_DEFAULT, + NULL, + NULL, + "previousthread", + EV_GETTER +); +Event EV_Parm_GetOther +( + "other", + EV_DEFAULT, + NULL, + NULL, + "other", + EV_GETTER +); +Event EV_Parm_GetOwner +( + "owner", + EV_DEFAULT, + NULL, + NULL, + "owner", + EV_GETTER +); +Event EV_Parm_Movedone +( + "movedone", + EV_DEFAULT, + NULL, + NULL, + "movedone", + EV_GETTER +); +Event EV_Parm_Movefail +( + "movefail", + EV_DEFAULT, + NULL, + NULL, + "movefail", + EV_GETTER +); +Event EV_Parm_Motionfail +( + "motionfail", + EV_DEFAULT, + NULL, + NULL, + "motionfail", + EV_GETTER +); +Event EV_Parm_Upperfail +( + "upperfail", + EV_DEFAULT, + NULL, + NULL, + "upperfail", + EV_GETTER +); +Event EV_Parm_Sayfail +( + "sayfail", + EV_DEFAULT, + NULL, + NULL, + "sayfail", + EV_GETTER ); -void Parm::Archive( Archiver& arc ) +void Parm::Archive(Archiver& arc) { - Listener::Archive( arc ); + Listener::Archive(arc); - arc.ArchiveSafePointer( &other ); - arc.ArchiveSafePointer( &owner ); + arc.ArchiveSafePointer(&other); + arc.ArchiveSafePointer(&owner); } -void Parm::GetOther( Event *ev ) +void Parm::GetMotionFail(Event *ev) { - ev->AddListener( other ); + ev->AddInteger(motionfail); } -void Parm::GetOwner( Event *ev ) +void Parm::GetMovedone(Event *ev) { - ev->AddListener( owner ); + ev->AddInteger(movedone); } -void Parm::GetPreviousThread( Event *ev ) +void Parm::GetMovefail(Event *ev) { - ev->AddListener( Director.PreviousThread() ); + ev->AddInteger(movefail); } -CLASS_DECLARATION( Listener, Parm, NULL ) +void Parm::GetOther(Event *ev) { - { &EV_Parm_GetOther, &Parm::GetOther }, - { &EV_Parm_GetOwner, &Parm::GetOwner }, - { &EV_Parm_GetPreviousThread, &Parm::GetPreviousThread }, - { NULL, NULL } + ev->AddListener(other); +} + +void Parm::GetOwner(Event *ev) +{ + ev->AddListener(owner); +} + +void Parm::GetPreviousThread(Event *ev) +{ + ev->AddListener(Director.PreviousThread()); +} + +void Parm::GetSayFail(Event *ev) +{ + ev->AddInteger(sayfail); +} + +void Parm::GetUpperFail(Event *ev) +{ + ev->AddInteger(upperfail); +} + +CLASS_DECLARATION(Listener, Parm, NULL) { + {&EV_Parm_GetPreviousThread, &Parm::GetPreviousThread}, + {&EV_Parm_GetOther, &Parm::GetOther }, + {&EV_Parm_GetOwner, &Parm::GetOwner }, + {&EV_Parm_Movedone, &Parm::GetMovedone }, + {&EV_Parm_Movefail, &Parm::GetMovefail }, + {&EV_Parm_Motionfail, &Parm::GetMotionFail }, + {&EV_Parm_Upperfail, &Parm::GetUpperFail }, + {&EV_Parm_Sayfail, &Parm::GetSayFail }, + {NULL, NULL } }; diff --git a/code/fgame/parm.h b/code/fgame/parm.h index b942324d..aa8ae00b 100644 --- a/code/fgame/parm.h +++ b/code/fgame/parm.h @@ -22,34 +22,38 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // parm.h: Event parameters -#ifndef __PARM_H__ -#define __PARM_H__ +#pragma once #include "listener.h" -class Parm : public Listener { +class Parm : public Listener +{ public: - // General trigger variables - SafePtr< Listener > other; - SafePtr< Listener > owner; + // General trigger variables + SafePtr other; + SafePtr owner; - // Failure variables - qboolean movedone; - qboolean movefail; - qboolean motionfail; - qboolean upperfail; - qboolean sayfail; + // Failure variables + qboolean movedone; + qboolean movefail; + qboolean motionfail; + qboolean upperfail; + qboolean sayfail; public: - CLASS_PROTOTYPE( Parm ); + CLASS_PROTOTYPE(Parm); - void Archive( Archiver& arc ) override; + void GetPreviousThread(Event *ev); + void GetOther(Event *ev); + void GetOwner(Event *ev); + void GetPath(Event *ev); + void GetMovedone(Event *ev); + void GetMovefail(Event *ev); + void GetMotionFail(Event *ev); + void GetUpperFail(Event *ev); + void GetSayFail(Event *ev); - void GetOther( Event *ev ); - void GetOwner( Event *ev ); - void GetPreviousThread( Event *ev ); + void Archive(Archiver& arc) override; }; extern Parm parm; - -#endif /* __PARM_H__ */ diff --git a/code/fgame/player.cpp b/code/fgame/player.cpp index f94913bf..7b10c5bb 100644 --- a/code/fgame/player.cpp +++ b/code/fgame/player.cpp @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -58,6 +58,13 @@ const Vector power_color(0.0, 1.0, 0.0); const Vector acolor(1.0, 1.0, 1.0); const Vector bcolor(1.0, 0.0, 0.0); +ScriptDelegate Player::scriptDelegate_connected("player_connected", "Sent once when the player connected"); +ScriptDelegate Player::scriptDelegate_disconnecting("player_disconnecting", "The player is disconnecting"); +ScriptDelegate Player::scriptDelegate_spawned("player_spawned", "The player has spawned"); +ScriptDelegate Player::scriptDelegate_damage("player_damaged", "The player got hit"); +ScriptDelegate Player::scriptDelegate_kill("player_killed", "The player got killed"); +ScriptDelegate Player::scriptDelegate_textMessage("player_textMessage", "The player just sent a text message"); + // // mohaas 2.0 and above // @@ -87,7 +94,7 @@ const char *pInstantMsgEng[6][9] = { "You mess with the best, you die like the rest.", "Watch that friendly fire!", "Hey! I'm on your team!", "Come on out you cowards!", "Where are you hiding?", NULL}, - // Added in 2.30 + // Added in 2.30 {"Guard our jail!", "Capture the enemy jail!", "I'm defending our jail!", "I'm attacking the enemy jail!", "Rescue the Prisoners!", @@ -278,7 +285,7 @@ Event EV_Player_CorrectWeaponAttachments EV_CONSOLE, NULL, NULL, - "makes sure the weapons is properly attached when interupting a reload", + "makes sure the weapons is properly attached when interrupting a reload", EV_NORMAL ); Event EV_Player_GiveCheat @@ -1174,19 +1181,22 @@ Event EV_GetFireHeld EV_GETTER ); Event EV_GetPrimaryFireHeld // Added in 2.30 - ("primaryfireheld", +( + "primaryfireheld", EV_DEFAULT, NULL, NULL, "returns 1 if this player is holding the primary fire, or 0 if not", EV_GETTER); Event EV_GetSecondaryFireHeld // Added in 2.30 - ("secondaryfireheld", +( + "secondaryfireheld", EV_DEFAULT, NULL, NULL, "returns 1 if this player is holding the secondary fire, or 0 if not", - EV_GETTER); + EV_GETTER +); Event EV_Player_GetReady ( "ready", @@ -1278,7 +1288,7 @@ Event EV_Player_SetPerferredWeapon EV_DEFAULT, "s", "weapon_name", - "Overrides your perferred weapon that is displayed in the stats screen.", + "Overrides your preferred weapon that is displayed in the stats screen.", EV_NORMAL ); Event EV_Player_SetVoiceType @@ -1352,6 +1362,15 @@ Event EV_Player_AdminRights "returns client admin rights", EV_GETTER ); +Event EV_Player_IsAdmin +( + "isadmin", + EV_DEFAULT, + NULL, + NULL, + "checks if player is logged as admin", + EV_RETURN +); Event EV_Player_BindWeap ( "bindweap", @@ -1361,24 +1380,6 @@ Event EV_Player_BindWeap "binds weapon to player and sets him as weapon owner", EV_NORMAL ); -Event EV_Player_CanSwitchTeams -( - "canswitchteams", - EV_DEFAULT, - "bB", - "allow_team_change allow_spectate", - "Specify if this player is allowed to switch teams and spectate. Doesn't override global canswitchteams.", - EV_NORMAL -); -Event EV_Player_ClearCommand -( - "clearcommand", - EV_DEFAULT, - "S", - "command", - "Clears any or a specific client command", - EV_NORMAL -); Event EV_Player_Dive ( "dive", @@ -1388,15 +1389,6 @@ Event EV_Player_Dive "Makes the player dive into prone position.", EV_NORMAL ); -Event EV_Player_Earthquake -( - "earthquake2", - EV_DEFAULT, - "ffbbVF", - "duration magnitude no_rampup no_rampdown location radius", - "Create a smooth realistic earthquake for a player. Requires sv_reborn to be set.", - EV_NORMAL -); Event EV_Player_FreezeControls ( "freezecontrols", @@ -1478,15 +1470,6 @@ Event EV_Player_GetTorsoState "Gets the player's current torso state name", EV_RETURN ); -Event EV_Player_HideEnt -( - "hideent", - EV_DEFAULT, - "e", - "entity", - "Hides the specified entity to the player.", - EV_NORMAL -); Event EV_Player_Inventory ( "inventory", @@ -1505,15 +1488,6 @@ Event EV_Player_InventorySet "Set up the player's inventory", EV_SETTER ); -Event EV_Player_IsAdmin -( - "isadmin", - EV_DEFAULT, - NULL, - NULL, - "checks if player is logged as admin", - EV_RETURN -); Event EV_Player_LeanLeftHeld ( "leanleftheld", @@ -1560,15 +1534,6 @@ Event EV_Player_PlayLocalSound "sounds.", EV_NORMAL ); -Event EV_Player_Replicate -( - "replicate", - EV_DEFAULT, - "s", - "variable", - "Replicate a variable to the client (needs patch 1.12).", - EV_NORMAL -); Event EV_Player_RunHeld ( "runheld", @@ -1585,7 +1550,7 @@ Event EV_Player_SecFireHeld EV_DEFAULT, NULL, NULL, - "returns EV_RETURN if this player is holding secondary fire, or 0 if he is not", + "returns 1 if this player is holding secondary fire, or 0 if he is not", EV_GETTER ); Event EV_Player_SetAnimSpeed @@ -1616,33 +1581,6 @@ Event EV_Player_SetKillHandler "killed event handler.", EV_SETTER ); -Event EV_Player_SetClientFlag -( - "setclientflag", - EV_DEFAULT, - "s", - "name", - "Calls a flag to the script client.", - EV_NORMAL -); -Event EV_Player_SetEntityShader -( - "setentshader", - EV_DEFAULT, - "es", - "entity shadername", - "Sets an entity shader for this player. An empty string will revert to the normal entity shader.", - EV_NORMAL -); -Event EV_Player_SetLocalSoundRate -( - "setlocalsoundrate", - EV_DEFAULT, - "sfF", - "name rate time", - "Sets the local sound rate.", - EV_NORMAL -); Event EV_Player_SetSpeed ( "setspeed", @@ -1671,13 +1609,13 @@ Event EV_Player_SetTeam "Available team names are 'none', 'spectator', 'freeforall', 'axis' and 'allies'.", EV_NORMAL ); -Event EV_Player_SetViewModelAnimSpeed +Event EV_Player_HideEnt ( - "setvmaspeed", + "hideent", EV_DEFAULT, - "sf", - "name speed", - "Sets the player's animation speed when playing it.", + "e", + "entity", + "Hides the specified entity to the player.", EV_NORMAL ); Event EV_Player_ShowEnt @@ -1734,6 +1672,62 @@ Event EV_Player_ViewModelAnimValid "True if the view model animation is valid.", EV_RETURN ); + +#ifdef OPM_FEATURES +Event EV_Player_Earthquake +( + "earthquake2", + EV_DEFAULT, + "ffbbVF", + "duration magnitude no_rampup no_rampdown location radius", + "Create a smooth realistic earthquake for a player. Requires sv_reborn to be set.", + EV_NORMAL +); +Event EV_Player_Replicate +( + "replicate", + EV_DEFAULT, + "s", + "variable", + "Replicate a variable to the client (needs patch 1.12).", + EV_NORMAL +); +Event EV_Player_SetClientFlag +( + "setclientflag", + EV_DEFAULT, + "s", + "name", + "Calls a flag to the script client.", + EV_NORMAL +); +Event EV_Player_SetEntityShader +( + "setentshader", + EV_DEFAULT, + "es", + "entity shadername", + "Sets an entity shader for this player. An empty string will revert to the normal entity shader.", + EV_NORMAL +); +Event EV_Player_SetLocalSoundRate +( + "setlocalsoundrate", + EV_DEFAULT, + "sfF", + "name rate time", + "Sets the local sound rate.", + EV_NORMAL +); +Event EV_Player_SetViewModelAnimSpeed +( + "setvmaspeed", + EV_DEFAULT, + "sf", + "name speed", + "Sets the player's animation speed when playing it.", + EV_NORMAL +); Event EV_Player_VisionSetBlur ( "visionsetblur", @@ -1762,6 +1756,7 @@ Event EV_Player_VisionSetNaked "an empty string, it will revert to the current global vision.", EV_NORMAL ); +#endif qboolean TryPush(int entnum, vec3_t move_origin, vec3_t move_end); @@ -1915,11 +1910,7 @@ CLASS_DECLARATION(Sentient, Player, "player") { {&EV_Player_AddDeaths, &Player::AddDeaths }, {&EV_Player_AdminRights, &Player::AdminRights }, {&EV_Player_BindWeap, &Player::BindWeap }, - {&EV_Player_CanSwitchTeams, &Player::CanSwitchTeams }, - {&EV_Player_ClearCommand, &Player::ClearCommand }, {&EV_Player_Dive, &Player::Dive }, - {&EV_Player_DMMessage, &Player::EventDMMessage }, - {&EV_Player_Earthquake, &Player::EventEarthquake }, {&EV_Player_FreezeControls, &Player::FreezeControls }, {&EV_Player_SetTeam, &Player::EventSetTeam }, {&EV_Player_GetConnState, &Player::GetConnState }, @@ -1943,13 +1934,9 @@ CLASS_DECLARATION(Sentient, Player, "player") { {&EV_Player_RunHeld, &Player::RunHeld }, {&EV_Player_SecFireHeld, &Player::SecFireHeld }, {&EV_Player_SetAnimSpeed, &Player::SetAnimSpeed }, - {&EV_Player_SetClientFlag, &Player::SetClientFlag }, - {&EV_Player_SetEntityShader, &Player::SetEntityShader }, {&EV_Player_SetKillHandler, &Player::SetKillHandler }, - {&EV_Player_SetLocalSoundRate, &Player::SetLocalSoundRate }, {&EV_Player_SetSpeed, &Player::SetSpeed }, {&EV_Player_SetStateFile, &Player::SetStateFile }, - {&EV_Player_SetViewModelAnimSpeed, &Player::SetVMASpeed }, {&EV_Player_ShowEnt, &Player::ShowEntity }, {&EV_Player_Spectator, &Player::Spectator }, {&EV_Player_StopLocalSound, &Player::StopLocalSound }, @@ -1957,9 +1944,16 @@ CLASS_DECLARATION(Sentient, Player, "player") { {&EV_Player_ViewModelAnimFinished, &Player::EventGetViewModelAnimFinished}, {&EV_Player_ViewModelGetAnim, &Player::EventGetViewModelAnim }, {&EV_Player_ViewModelAnimValid, &Player::EventGetViewModelAnimValid }, +#ifdef OPM_FEATURES + {&EV_Player_Earthquake, &Player::EventEarthquake }, + {&EV_Player_SetClientFlag, &Player::SetClientFlag }, + {&EV_Player_SetEntityShader, &Player::SetEntityShader }, + {&EV_Player_SetLocalSoundRate, &Player::SetLocalSoundRate }, + {&EV_Player_SetViewModelAnimSpeed, &Player::SetVMASpeed }, {&EV_Player_VisionGetNaked, &Player::VisionGetNaked }, {&EV_Player_VisionSetBlur, &Player::VisionSetBlur }, {&EV_Player_VisionSetNaked, &Player::VisionSetNaked }, +#endif {NULL, NULL } }; @@ -2033,11 +2027,14 @@ Player::Player() // // Added in OPM //==== - m_bShowingHint = false; - disable_spectate = false; - disable_team_change = false; - m_fpsTiki = NULL; - m_bConnected = false; +#ifdef OPM_FEATURES + m_bShowingHint = false; +#endif + m_fpsTiki = NULL; + m_bConnected = false; + + m_iInstantMessageTime = 0; + m_iTextChatTime = 0; //==== if (LoadingSavegame) { @@ -2213,6 +2210,17 @@ Player::~Player() legs_conditionals.FreeObjectList(); torso_conditionals.FreeObjectList(); + // Added in 2.11 + // Make sure to clean turret stuff up + // when the player is deleted + RemoveFromVehiclesAndTurrets(); + + // Added in OPM + // Remove the player at destructor + if (g_gametype->integer != GT_SINGLE_PLAYER && dmManager.PlayerCount()) { + dmManager.RemovePlayer(this); + } + entflags &= ~ECF_PLAYER; } @@ -2262,6 +2270,8 @@ void Player::Init(void) Event *ev = new Event; ev->AddEntity(this); + + scriptDelegate_connected.Trigger(this, *ev); scriptedEvents[SE_CONNECTED].Trigger(ev); } @@ -2304,7 +2314,6 @@ void Player::InitEdict(void) } void Player::InitSound(void) - { // // reset the music @@ -2361,7 +2370,9 @@ void Player::InitClient(void) SetStopwatch(0); +#ifdef OPM_FEATURES m_bShowingHint = false; +#endif } void Player::InitState(void) @@ -2390,7 +2401,6 @@ void Player::InitState(void) } void Player::InitHealth(void) - { static cvar_t *pMaxHealth = gi.Cvar_Get("g_maxplayerhealth", "250", 0); static cvar_t *pDMHealth = gi.Cvar_Get("g_playerdmhealth", "100", 0); @@ -2401,28 +2411,28 @@ void Player::InitHealth(void) return; } - if (g_gametype->integer != GT_SINGLE_PLAYER) { - if (pDMHealth->integer > 0) { - max_health = pDMHealth->integer; - } else { - max_health = 100.f; - } - - health = max_health; - } else if (!g_realismmode->integer) { + if (g_gametype->integer == GT_SINGLE_PLAYER && !g_realismmode->integer) { max_health = pMaxHealth->integer; - health = max_health; + } else if (g_gametype->integer != GT_SINGLE_PLAYER && pDMHealth->integer > 0) { + max_health = pDMHealth->integer; } else { // reset the health values - health = 100; - max_health = health; + max_health = 100; } + health = max_health; + // 2.0: // Make sure to clear the heal rate and the dead flag when respawning // m_fHealRate = 0; edict->s.eFlags &= ~EF_DEAD; + + // Fixed in OPM + // This avoid losing weapons when dying and then immediately respawning + CancelEventsOfType(EV_Player_DMDeathDrop); + // And this prevents the player from dying when respawning immediately after getting killed + CancelEventsOfType(EV_Player_Dead); } void Player::InitModel(void) @@ -2438,8 +2448,8 @@ void Player::InitModel(void) if (g_gametype->integer == GT_SINGLE_PLAYER) { setModel("models/player/" + str(g_playermodel->string) + ".tik"); } else if (dm_team == TEAM_AXIS) { - if (Q_stricmpn(client->pers.dm_playermodel, "german", 6) - && Q_stricmpn(client->pers.dm_playermodel, "axis", 4) + if (Q_stricmpn(client->pers.dm_playergermanmodel, "german", 6) + && Q_stricmpn(client->pers.dm_playergermanmodel, "axis", 4) // // 2.30 models // @@ -2530,12 +2540,12 @@ void Player::InitModelFps(void) char model_name[MAX_STRING_TOKENS]; char *model_replace; - strcpy(model_name, model.c_str()); + Q_strncpyz(model_name, model.c_str(), sizeof(model_name)); size_t len = strlen(model_name); model_replace = model_name + len - 4; - strcpy(model_replace, "_fps.tik"); + Q_strncpyz(model_replace, "_fps.tik", sizeof(model_name) - (model_replace - model_name)); m_fpsTiki = gi.modeltiki(model_name); } @@ -2562,7 +2572,6 @@ void Player::InitPhysics(void) } void Player::InitPowerups(void) - { // powerups poweruptimer = 0; @@ -2586,17 +2595,21 @@ void Player::InitMaxAmmo(void) GiveAmmo("heavy", 0, 5); GiveAmmo("shotgun", 0, 50); - // - // Team tactics ammunition - // - GiveAmmo("landmine", 0, 5); + if (g_target_game >= target_game_e::TG_MOHTT) { + // + // Team tactics ammunition + // + GiveAmmo("landmine", 0, 5); + } - // - // Team assault ammunition - // - GiveAmmo("smokegrenade", 0, 5); - GiveAmmo("asmokegrenade", 0, 5); - GiveAmmo("riflegrenade", 0, 3); + if (g_target_game >= target_game_e::TG_MOHTA) { + // + // Team assault ammunition + // + GiveAmmo("smokegrenade", 0, 5); + GiveAmmo("asmokegrenade", 0, 5); + GiveAmmo("riflegrenade", 0, 3); + } } void Player::InitWeapons(void) @@ -2663,8 +2676,12 @@ void Player::ChooseSpawnPoint(void) } void Player::EndLevel(Event *ev) - { + if (IsDead()) { + ScriptError("cannot do player.endlevel if the player is dead"); + return; + } + InitPowerups(); if (health > max_health) { health = max_health; @@ -2721,7 +2738,6 @@ void Player::Respawn(Event *ev) } void Player::SetDeltaAngles(void) - { int i; @@ -2800,13 +2816,13 @@ void Player::Obituary(Entity *attacker, Entity *inflictor, int meansofdeath, int } if (bDispLocation && g_obituarylocation->integer) { - str szConv1 = s1 + str(" ") + G_LocationNumToDispString(iLocation); + str szConv2 = s2 + " in the " + G_LocationNumToDispString(iLocation); if (dedicated->integer) { - gi.Printf("%s %s\n", client->pers.netname, gi.LV_ConvertString(szConv1.c_str())); + gi.Printf("%s %s\n", client->pers.netname, gi.LV_ConvertString(szConv2.c_str())); } - G_PrintDeathMessage(szConv1, s2.c_str(), "x", client->pers.netname, this, "s"); + G_PrintDeathMessage(s1, szConv2.c_str(), "x", client->pers.netname, this, "s"); } else { if (dedicated->integer) { gi.Printf("%s %s\n", client->pers.netname, gi.LV_ConvertString(s1.c_str())); @@ -2921,20 +2937,20 @@ void Player::Obituary(Entity *attacker, Entity *inflictor, int meansofdeath, int } if (bDispLocation && g_obituarylocation->integer) { - str szConv1 = s1 + str(" ") + G_LocationNumToDispString(iLocation); + str szConv2 = s2 + " in the " + G_LocationNumToDispString(iLocation); G_PrintDeathMessage( - szConv1.c_str(), s2.c_str(), attacker->client->pers.netname, client->pers.netname, this, "p" + s1.c_str(), szConv2.c_str(), attacker->client->pers.netname, client->pers.netname, this, "p" ); if (dedicated->integer) { str szLoc1, szLoc2; - szLoc1 = gi.LV_ConvertString(szConv1.c_str()); + szLoc1 = gi.LV_ConvertString(s1.c_str()); if (s2 == 'x') { gi.Printf("%s %s %s\n", client->pers.netname, szLoc1.c_str(), attacker->client->pers.netname); } else { - szLoc2 = gi.LV_ConvertString(s2.c_str()); + szLoc2 = gi.LV_ConvertString(szConv2.c_str()); gi.Printf( "%s %s %s%s\n", client->pers.netname, @@ -3008,9 +3024,9 @@ void Player::Obituary(Entity *attacker, Entity *inflictor, int meansofdeath, int } if (bDispLocation && g_obituarylocation->integer) { - str szConv1 = s1 + str(" ") + G_LocationNumToDispString(iLocation); + str szConv2 = s2 + " in the " + G_LocationNumToDispString(iLocation); - G_PrintDeathMessage(szConv1.c_str(), s2.c_str(), "x", client->pers.netname, this, "w"); + G_PrintDeathMessage(s1.c_str(), szConv2.c_str(), "x", client->pers.netname, this, "w"); if (dedicated->integer) { gi.Printf("%s %s\n", client->pers.netname, gi.LV_ConvertString(s1.c_str())); @@ -3120,7 +3136,7 @@ void Player::Killed(Event *ev) RemoveFromVehiclesAndTurrets(); if (g_gametype->integer != GT_SINGLE_PLAYER && attacker && attacker->IsSubclassOfPlayer()) { - ((Player *)attacker)->KilledPlayerInDeathmatch(this); + static_cast(attacker)->KilledPlayerInDeathmatch(this, (meansOfDeath_t)meansofdeath); } deadflag = DEAD_DYING; @@ -3209,6 +3225,7 @@ void Player::Killed(Event *ev) event->AddInteger(ev->GetInteger(10)); event->AddEntity(this); + scriptDelegate_kill.Trigger(this, *event); scriptedEvents[SE_KILL].Trigger(event); Unregister(STRING_DEATH); @@ -3279,49 +3296,59 @@ void Player::SetStopwatch(int iDuration, stopWatchType_t type) } } - sprintf(szCmd, "stopwatch %i %i %i", iStartTime, iDuration, type); + Com_sprintf(szCmd, sizeof(szCmd), "stopwatch %i %i %i", iStartTime, iDuration, type); } else { iStartTime = 0; if (iDuration) { iStartTime = (int)level.svsFloatTime; } - sprintf(szCmd, "stopwatch %i %i", iStartTime, iDuration); + Com_sprintf(szCmd, sizeof(szCmd), "stopwatch %i %i", iStartTime, iDuration); } gi.SendServerCommand(edict - g_entities, szCmd); } -void Player::KilledPlayerInDeathmatch(Player *killed) +void Player::KilledPlayerInDeathmatch(Player *killed, meansOfDeath_t meansofdeath) { DM_Team *pDMTeam; pDMTeam = killed->GetDM_Team(); + if (meansofdeath == MOD_TELEFRAG) { + // + // Added in OPM + // Telefrag isn't the fault of anyone + // so don't count any kill + // + return; + } + if (killed == this) { pDMTeam->AddKills(this, -1); gi.SendServerCommand( edict - g_entities, "print \"" HUD_MESSAGE_WHITE "%s\n\"", gi.LV_ConvertString("You killed yourself") ); - } else { - if (pDMTeam != GetDM_Team() || g_gametype->integer <= GT_FFA || g_gametype->integer >= GT_MAX_GAME_TYPE) { - current_team->AddKills(this, 1); - } else { - // - // A teammate was killed - // - current_team->AddKills(this, -1); - num_team_kills++; - } - - gi.SendServerCommand( - edict - g_entities, - "print \"" HUD_MESSAGE_WHITE "%s %s\n\"", - gi.LV_ConvertString("You killed"), - killed->client->pers.netname - ); + return; } + + if (pDMTeam == GetDM_Team() && g_gametype->integer >= GT_TEAM) { + // + // A teammate was killed + // + current_team->AddKills(this, -1); + num_team_kills++; + } else { + current_team->AddKills(this, 1); + } + + gi.SendServerCommand( + edict - g_entities, + "print \"" HUD_MESSAGE_WHITE "%s %s\n\"", + gi.LV_ConvertString("You killed"), + killed->client->pers.netname + ); } void Player::Pain(Event *ev) @@ -3364,7 +3391,7 @@ void Player::Pain(Event *ev) pain_location = iLocation; // Only set the regular pain level if enough time since last pain has passed - if ((level.time > nextpaintime) && take_pain) { + if (((level.time > nextpaintime) && take_pain) || IsDead()) { pain = damage; } @@ -3417,6 +3444,7 @@ void Player::DoUse(Event *ev) int touch[MAX_GENTITIES]; int num; int i; + bool bWasInTurretOrVehicle; if (g_gametype->integer != GT_SINGLE_PLAYER && IsSpectator()) { // Prevent using stuff while spectating @@ -3428,39 +3456,76 @@ void Player::DoUse(Event *ev) return; } - if (m_pVehicle || m_pTurret) { + if (edict->r.svFlags & SVF_NOCLIENT) { + // Fixed in OPM + // Clients that are not sent to other clients cannot use objects. + // Some mods make players non-solid, hide them and turn physics off + // as a way to spectate other players or for cinematics. + // This prevent players to use objects such as doors + return; + } + + bWasInTurretOrVehicle = m_pVehicle || m_pTurret; + + if (bWasInTurretOrVehicle) { RemoveFromVehiclesAndTurretsInternal(); return; } - if ((buttons & BUTTON_ATTACKLEFT) || (buttons & BUTTON_ATTACKRIGHT)) { - // - // Added in 2.0 - // Only allow use if the player isn't holding attack buttons - // - return; + if (g_protocol >= protocol_e::PROTOCOL_MOHTA_MIN) { + if ((buttons & BUTTON_ATTACKLEFT) || (buttons & BUTTON_ATTACKRIGHT)) { + // + // Added in 2.0 + // Only allow use if the player isn't holding attack buttons + // + return; + } } num = getUseableEntities(touch, MAX_GENTITIES, true); - for (i = 0; i < num; i++) { - hit = &g_entities[touch[i]]; + if (g_protocol >= protocol_e::PROTOCOL_MOHTA_MIN) { + // Fixed in 2.0 + // Since 2.0, the loop stops when the player + // uses a turret, this prevents the turret from being deleted + // after being attached to the player + // + for (i = 0; i < num; i++) { + hit = &g_entities[touch[i]]; - if (!hit->inuse) { - continue; + if (!hit->inuse) { + continue; + } + + Event *event = new Event(EV_Use); + event->AddListener(this); + + hit->entity->ProcessEvent(event); + + if (m_pVehicle || m_pTurret) { + break; + } } + } else { + // + // Backward compatibility + // It still allows 1.11 SP to work properly + // Such as in m1l1 when the player must man the mounted machine gun + for (i = 0; i < num; i++) { + hit = &g_entities[touch[i]]; - Event *event = new Event(EV_Use); - event->AddListener(this); + if (!hit->inuse) { + continue; + } - hit->entity->ProcessEvent(event); + Event *event = new Event(EV_Use); + event->AddListener(this); - if (m_pVehicle || m_pTurret) { - break; + hit->entity->ProcessEvent(event); } } - if (i < num && m_pVehicle) { + if (!bWasInTurretOrVehicle && m_pVehicle) { // // Added in 2.30 // Make the vehicle also invincible if the player is invincible @@ -3568,6 +3633,10 @@ void Player::GetMoveInfo(pmove_t *pm) if (groundentity->entity && groundentity->entity != this && groundentity->entity->velocity[2] != 0) { pm->ps->pm_flags |= PMF_NO_PREDICTION; } + } else if (m_pGlueMaster) { + // Added in OPM + // Use the glue master for the ground entity to make the viewmodel will stay still + pm->ps->groundEntityNum = m_pGlueMaster->entnum; } velocity = Vector(pm->ps->velocity[0], pm->ps->velocity[1], pm->ps->velocity[2]); @@ -3656,14 +3725,23 @@ void Player::SetMoveInfo(pmove_t *pm, usercmd_t *ucmd) pm->leanSpeed = 2.f; } else { pm->alwaysAllowLean = qtrue; + if (g_gametype->integer != GT_SINGLE_PLAYER) { + pm->leanMax = 40.f; + } else { + // Don't allow lean in single-player, like in the original game + pm->leanMax = 0; + } - pm->leanMax = 40.f; pm->leanAdd = 10.f; pm->leanRecoverSpeed = 15.f; pm->leanSpeed = 4.f; } pm->protocol = g_protocol; + + // Added in OPM + // Initialize the ground entity + pm->ps->groundEntityNum = ENTITYNUM_NONE; } pmtype_t Player::GetMovePlayerMoveType(void) @@ -3737,7 +3815,6 @@ qboolean Player::AnimMove(Vector& move, Vector *endpos) } qboolean Player::TestMove(Vector& move, Vector *endpos) - { trace_t trace; Vector pos(origin + move); @@ -3790,7 +3867,6 @@ qboolean Player::TestMove(Vector& move, Vector *endpos) } float Player::TestMoveDist(Vector& move) - { Vector endpos; @@ -3876,7 +3952,6 @@ qboolean Player::CheckMove(Vector& move, Vector *endpos) } float Player::CheckMoveDist(Vector& move) - { Vector endpos; @@ -3891,7 +3966,7 @@ void Player::ClientMove(usercmd_t *ucmd) pmove_t pm; Vector move; -#if 0 +#ifdef OPM_FEATURES int touch[MAX_GENTITIES]; int num = getUseableEntities(touch, MAX_GENTITIES, true); bool bHintShown = false; @@ -3910,13 +3985,12 @@ void Player::ClientMove(usercmd_t *ucmd) m_bShowingHint = false; // FIXME: delete - if (sv_specialgame->integer) - { + if (sv_specialgame->integer) { gi.MSG_SetClient(edict - g_entities); // Send the hint string once gi.MSG_StartCGM(CGM_HINTSTRING); - gi.MSG_WriteString(""); + gi.MSG_WriteString(""); gi.MSG_EndCGM(); } } @@ -3927,8 +4001,8 @@ void Player::ClientMove(usercmd_t *ucmd) client->ps.pm_type = GetMovePlayerMoveType(); // set move flags client->ps.pm_flags &= - ~(PMF_FROZEN | PMF_NO_PREDICTION | PMF_NO_MOVE | PMF_DUCKED | PMF_NO_GRAVITY | PMF_VIEW_PRONE - | PMF_VIEW_DUCK_RUN | PMF_VIEW_JUMP_START); + ~(PMF_FROZEN | PMF_NO_PREDICTION | PMF_NO_MOVE | PMF_DUCKED | PMF_TURRET | PMF_VIEW_PRONE | PMF_VIEW_DUCK_RUN + | PMF_VIEW_JUMP_START); if (level.playerfrozen || m_bFrozen) { client->ps.pm_flags |= PMF_FROZEN; @@ -3948,23 +4022,24 @@ void Player::ClientMove(usercmd_t *ucmd) client->ps.pm_flags |= PMF_NO_MOVE; } - /* - if (maxs.z == 60.0f) { - client->ps.pm_flags |= PMF_DUCKED; - } else if (maxs.z == 54.0f) { - client->ps.pm_flags |= PMF_DUCKED | PMF_VIEW_PRONE; - } else if (maxs.z == 20.0f) { - client->ps.pm_flags |= PMF_VIEW_PRONE; - } else if (maxs.z == 53.0f) { - client->ps.pm_flags |= PMF_VIEW_DUCK_RUN; - } else if (viewheight == 52) { - client->ps.pm_flags |= PMF_VIEW_JUMP_START; - } - */ - if (maxs.z == 54.0f || maxs.z == 60.0f) { - client->ps.pm_flags |= PMF_DUCKED; - } else if (viewheight == 52) { - client->ps.pm_flags |= PMF_VIEW_JUMP_START; + if (g_protocol >= protocol_e::PROTOCOL_MOHTA_MIN) { + if (maxs.z == 54.0f || maxs.z == 60.0f) { + client->ps.pm_flags |= PMF_DUCKED; + } else if (viewheight == JUMP_START_VIEWHEIGHT) { + client->ps.pm_flags |= PMF_VIEW_JUMP_START; + } + } else { + if (maxs.z == 60.0f) { + client->ps.pm_flags |= PMF_DUCKED; + } else if (maxs.z == 54.0f) { + client->ps.pm_flags |= PMF_DUCKED | PMF_VIEW_PRONE; + } else if (maxs.z == 20.0f) { + client->ps.pm_flags |= PMF_VIEW_PRONE; + } else if (maxs.z == 53.0f) { + client->ps.pm_flags |= PMF_VIEW_DUCK_RUN; + } else if (viewheight == JUMP_START_VIEWHEIGHT) { + client->ps.pm_flags |= PMF_VIEW_JUMP_START; + } } switch (movecontrol) { @@ -4008,9 +4083,9 @@ void Player::ClientMove(usercmd_t *ucmd) // Also use the weapon movement speed // if (!IsZoomed()) { - client->ps.speed = (float)client->ps.speed * pWeap->m_fMovementSpeed; + client->ps.speed = (float)client->ps.speed * pWeap->GetMovementSpeed(); } else { - client->ps.speed = (float)client->ps.speed * pWeap->m_fZoomMovement * pWeap->m_fMovementSpeed; + client->ps.speed = (float)client->ps.speed * pWeap->GetZoomMovement(); } } } @@ -4115,11 +4190,11 @@ void Player::VehicleMove(usercmd_t *ucmd) // set move flags client->ps.pm_flags &= - ~(PMF_FROZEN | PMF_NO_PREDICTION | PMF_NO_MOVE | PMF_DUCKED | PMF_NO_GRAVITY | PMF_VIEW_PRONE - | PMF_VIEW_DUCK_RUN | PMF_VIEW_JUMP_START); + ~(PMF_FROZEN | PMF_NO_PREDICTION | PMF_NO_MOVE | PMF_DUCKED | PMF_TURRET | PMF_VIEW_PRONE | PMF_VIEW_DUCK_RUN + | PMF_VIEW_JUMP_START); // disable prediction - client->ps.pm_flags |= PMF_NO_GRAVITY | PMF_NO_PREDICTION; + client->ps.pm_flags |= PMF_TURRET | PMF_NO_PREDICTION; if (level.playerfrozen || m_bFrozen) { client->ps.pm_flags |= PMF_FROZEN; @@ -4129,6 +4204,10 @@ void Player::VehicleMove(usercmd_t *ucmd) if (m_pVehicle->Drive(current_ucmd)) { client->ps.commandTime = ucmd->serverTime; + // Added in OPM + // The player can't walk while attached to a vehicle + client->ps.groundEntityNum = ENTITYNUM_NONE; + client->ps.walking = false; } else { ClientMove(ucmd); } @@ -4146,13 +4225,13 @@ void Player::TurretMove(usercmd_t *ucmd) // set move flags client->ps.pm_flags &= - ~(PMF_FROZEN | PMF_NO_PREDICTION | PMF_NO_MOVE | PMF_DUCKED | PMF_NO_GRAVITY | PMF_VIEW_PRONE - | PMF_VIEW_DUCK_RUN | PMF_VIEW_JUMP_START); + ~(PMF_FROZEN | PMF_NO_PREDICTION | PMF_NO_MOVE | PMF_DUCKED | PMF_TURRET | PMF_VIEW_PRONE | PMF_VIEW_DUCK_RUN + | PMF_VIEW_JUMP_START); // disable prediction - client->ps.pm_flags |= PMF_NO_GRAVITY | PMF_NO_PREDICTION; + client->ps.pm_flags |= PMF_TURRET | PMF_NO_PREDICTION; if (getMoveType() == MOVETYPE_PORTABLE_TURRET) { - client->ps.pm_flags |= PMF_NO_GRAVITY; + client->ps.pm_flags |= PMF_TURRET; } if (level.playerfrozen || m_bFrozen) { @@ -4161,10 +4240,19 @@ void Player::TurretMove(usercmd_t *ucmd) client->ps.gravity = gravity * sv_gravity->value; - if (!m_pTurret->IsSubclassOfTurretGun() || !m_pTurret->UserAim(current_ucmd)) { - ClientMove(ucmd); - } else { + if (m_pVehicle) { + // Added in 2.30 + m_pVehicle->PathDrive(current_ucmd); + } + + if (m_pTurret->IsSubclassOfTurretGun() && m_pTurret->UserAim(current_ucmd)) { client->ps.commandTime = ucmd->serverTime; + // Added in OPM + // The player can't walk while attached to a turret + client->ps.groundEntityNum = ENTITYNUM_NONE; + client->ps.walking = false; + } else { + ClientMove(ucmd); } } @@ -4188,7 +4276,7 @@ void Player::ClientInactivityTimer(void) // // The player reached maximum team kills // - G_PrintToAllClients(va("%s %s", client->pers.netname, message.c_str()), qfalse); + G_PrintToAllClients(va("%s %s\n", client->pers.netname, message.c_str()), 2); if (Q_stricmp(Info_ValueForKey(client->pers.userinfo, "ip"), "localhost")) { // @@ -4217,7 +4305,7 @@ void Player::ClientInactivityTimer(void) ); } - if (current_ucmd->buttons & BUTTON_MOUSE || (!g_inactivespectate->integer && !g_inactivekick->integer) + if (current_ucmd->buttons & BUTTON_ANY || (!g_inactivespectate->integer && !g_inactivekick->integer) || current_ucmd->forwardmove || current_ucmd->rightmove || current_ucmd->upmove || (m_bTempSpectator && client->lastActiveTime >= level.inttime - 5000)) { client->lastActiveTime = level.inttime; @@ -4432,7 +4520,7 @@ void Player::ClientThink(void) client->cmd_angles[1] = SHORT2ANGLE(current_ucmd->angles[1]); client->cmd_angles[2] = SHORT2ANGLE(current_ucmd->angles[2]); - if (g_gametype->integer != GT_SINGLE_PLAYER && g_smoothClients->integer && !IsSubclassOfBot()) { + if (g_gametype->integer != GT_SINGLE_PLAYER && g_smoothClients->integer) { VectorCopy(client->ps.velocity, edict->s.pos.trDelta); edict->s.pos.trTime = client->ps.commandTime; } else { @@ -4445,6 +4533,7 @@ void Player::ClientThink(void) if (g_gametype->integer != GT_SINGLE_PLAYER) { client->ps.pm_flags |= PMF_FROZEN; client->ps.pm_flags |= PMF_INTERMISSION; + VectorClear(client->ps.velocity); if (level.time - level.intermissiontime > 5.0f && (new_buttons & (BUTTON_ATTACKLEFT | BUTTON_ATTACKRIGHT))) { @@ -4466,12 +4555,13 @@ void Player::ClientThink(void) || g_medalbt3->modificationCount > 1 || g_medalbt4->modificationCount > 1 || g_medalbt5->modificationCount > 1 || g_eogmedal0->modificationCount > 1 || g_eogmedal1->modificationCount > 1 || g_eogmedal2->modificationCount > 1) { - gi.cvar_set("g_gotmedal", "0"); - } else { gi.cvar_set("g_gotmedal", "1"); + } else { + gi.cvar_set("g_gotmedal", "0"); } client->ps.pm_flags |= PMF_FROZEN; + VectorClear(client->ps.velocity); if (level.time - level.intermissiontime > 4.0f) { if (level.intermissiontype) { @@ -4643,10 +4733,16 @@ void Player::Think(void) gi.SendServerCommand(edict - g_entities, "stufftext \"pushmenu_teamselect\""); } } + // Removed in 2.0 + //else if (level.time > m_fWeapSelectTime + 10.0) { + // m_fWeapSelectTime = level.time; + // gi.centerprintf(edict, "\n\n\n%s", gi.LV_ConvertString("Press fire to join the battle!")); + //} } else if (!client->pers.dm_primary[0]) { Spectator(); if (m_fWeapSelectTime < level.time) { - gi.SendServerCommand(edict - g_entities, "stufftext \"pushmenu_weaponselect\""); + m_fWeapSelectTime = level.time + 1.0; + UserSelectWeapon(false); } } @@ -4672,7 +4768,7 @@ void Player::Think(void) } } else { if ((server_new_buttons & BUTTON_USE)) { - SetPlayerSpectateRandom(); + SetPlayerSpectate(true); } } @@ -4685,7 +4781,8 @@ void Player::Think(void) if (!ent->inuse || !ent->entity) { // Invalid spectate entity SetPlayerSpectateRandom(); - } else if (ent->entity->deadflag >= DEAD_DEAD || static_cast(ent->entity)->IsSpectator() || IsValidSpectatePlayer(static_cast(ent->entity))) { + } else if (ent->entity->deadflag >= DEAD_DEAD || static_cast(ent->entity)->IsSpectator() + || !IsValidSpectatePlayer(static_cast(ent->entity))) { SetPlayerSpectateRandom(); } } @@ -4708,9 +4805,11 @@ void Player::Think(void) if (!ent->inuse || !ent->entity) { // Invalid spectate entity SetPlayerSpectateRandom(); - } else if (ent->entity->deadflag >= DEAD_DEAD || static_cast(ent->entity)->IsSpectator() || !IsValidSpectatePlayer(static_cast(ent->entity))) { + } else if (ent->entity->deadflag >= DEAD_DEAD || static_cast(ent->entity)->IsSpectator() + || !IsValidSpectatePlayer(static_cast(ent->entity))) { SetPlayerSpectateRandom(); - } else if (g_gametype->integer >= GT_TEAM && GetTeam() > TEAM_FREEFORALL && static_cast(ent->entity)->GetTeam() != GetTeam()) { + } else if (g_gametype->integer >= GT_TEAM && GetTeam() > TEAM_FREEFORALL + && static_cast(ent->entity)->GetTeam() != GetTeam()) { SetPlayerSpectateRandom(); } } @@ -4728,7 +4827,7 @@ void Player::Think(void) } if (!IsDead()) { - m_iClientWeaponCommand = (server_new_buttons & WEAPON_COMMAND_MASK) >> 7; + m_iClientWeaponCommand = G_GetWeaponCommand(server_new_buttons); switch (m_iClientWeaponCommand) { case 0: @@ -4844,9 +4943,9 @@ void Player::Think(void) // Added in 2.0: talk icon // if (buttons & BUTTON_TALK) { - edict->s.eFlags |= EF_PLAYER_TALKING; + edict->s.eFlags |= EF_PLAYER_IN_MENU; } else { - edict->s.eFlags &= ~EF_PLAYER_TALKING; + edict->s.eFlags &= ~EF_PLAYER_IN_MENU; } if (m_fTalkTime > level.time) { @@ -4889,6 +4988,8 @@ void Player::Think(void) } server_new_buttons = 0; + + edict->r.svFlags &= ~(SVF_SINGLECLIENT | SVF_NOTSINGLECLIENT); } void Player::InitLegsStateTable(void) @@ -4920,16 +5021,32 @@ void Player::InitTorsoStateTable(void) void Player::LoadStateTable(void) { + int i; + Conditional *cond; + statemap_Legs = NULL; statemap_Torso = NULL; + // + // Free existing conditionals + // + for (i = legs_conditionals.NumObjects(); i > 0; i--) { + cond = legs_conditionals.ObjectAt(i); + delete cond; + } legs_conditionals.FreeObjectList(); + + for (i = torso_conditionals.NumObjects(); i > 0; i--) { + cond = torso_conditionals.ObjectAt(i); + delete cond; + } torso_conditionals.FreeObjectList(); statemap_Legs = - GetStatemap(str(g_statefile->string) + "_Legs.st", (Condition *)Conditions, &legs_conditionals, false); - statemap_Torso = - GetStatemap(str(g_statefile->string) + "_Torso.st", (Condition *)Conditions, &torso_conditionals, false); + GetStatemap(str(g_statefile->string) + "_Legs.st", (Condition *)m_conditions, &legs_conditionals, false); + statemap_Torso = GetStatemap( + str(g_statefile->string) + "_Torso.st", (Condition *)m_conditions, &torso_conditionals, false + ); movecontrol = MOVECONTROL_LEGS; @@ -4973,7 +5090,6 @@ void Player::ResetState(Event *ev) } void Player::StartPush(void) - { trace_t trace; Vector end(origin + yaw_forward * 64.0f); @@ -4989,7 +5105,6 @@ void Player::StartPush(void) } void Player::StartClimbLadder(void) - { trace_t trace; Vector end(origin + yaw_forward * 20.0f); @@ -5066,13 +5181,11 @@ void Player::StartUseAnim(void) } void Player::StartLoopUseAnim(void) - { useanim_numloops--; } void Player::FinishUseAnim(Event *ev) - { UseAnim *ua; @@ -5086,7 +5199,6 @@ void Player::FinishUseAnim(Event *ev) } void Player::SetupUseObject(void) - { UseObject *uo; Vector neworg; @@ -5136,7 +5248,6 @@ void Player::SetupUseObject(void) } void Player::StartUseObject(Event *ev) - { UseObject *uo; @@ -5149,7 +5260,6 @@ void Player::StartUseObject(Event *ev) } void Player::FinishUseObject(Event *ev) - { UseObject *uo; @@ -5163,7 +5273,6 @@ void Player::FinishUseObject(Event *ev) } void Player::Turn(Event *ev) - { float yaw; Vector oldang(v_angle); @@ -5187,7 +5296,6 @@ void Player::Turn(Event *ev) } void Player::TurnUpdate(Event *ev) - { float yaw; float timeleft; @@ -5216,7 +5324,6 @@ void Player::TurnUpdate(Event *ev) } void Player::TurnLegs(Event *ev) - { float yaw; @@ -5239,6 +5346,19 @@ void Player::EvaluateState(State *forceTorso, State *forceLegs) return; } + if (flags & FL_IMMOBILE) { + // Don't evaluate state when immobile + return; + } + + if (getMoveType() == MOVETYPE_PORTABLE_TURRET) { + // Added in 2.0 + // Animations are handled hardcodedly + currentState_Torso = NULL; + currentState_Legs = NULL; + return; + } + // Evaluate the current state. // When the state changes, we reevaluate the state so that if the // conditions aren't met in the new state, we don't play one frame of @@ -5260,15 +5380,31 @@ void Player::EvaluateState(State *forceTorso, State *forceLegs) laststate_Torso = currentState_Torso; - if (forceTorso) { - currentState_Torso = forceTorso; + if (currentState_Torso) { + laststate_Torso = currentState_Torso; + + if (forceTorso) { + currentState_Torso = forceTorso; + } else { + currentState_Torso = currentState_Torso->Evaluate(*this, &torso_conditionals); + } } else { - currentState_Torso = currentState_Torso->Evaluate(*this, &torso_conditionals); + // Added in 2.0 + // Switch to the default torso state if it's NULL + if (forceTorso) { + currentState_Torso = forceTorso; + } else { + currentState_Torso = statemap_Torso->FindState("STAND"); + } + + laststate_Torso = NULL; } if (currentState_Torso) { - // Process exit commands of the last state - laststate_Torso->ProcessExitCommands(this); + if (laststate_Torso) { + // Process exit commands of the last state + laststate_Torso->ProcessExitCommands(this); + } // Process entry commands of the new state currentState_Torso->ProcessEntryCommands(this); @@ -5304,6 +5440,13 @@ void Player::EvaluateState(State *forceTorso, State *forceLegs) StopPartAnimating(torso); animdone_Torso = true; } else if (torsoAnim != "") { + if (torsoAnim == partAnim[torso]) { + // Fixed in OPM + // Stop the part if it's the same animation + // so the new animation can play and make some action + // like activate the new weapon. + StopPartAnimating(torso); + } SetPartAnim(torsoAnim.c_str(), torso); } } else { @@ -5311,6 +5454,11 @@ void Player::EvaluateState(State *forceTorso, State *forceLegs) StopPartAnimating(torso); animdone_Torso = true; } else if (torsoAnim != "") { + if (torsoAnim == partAnim[torso]) { + // Fixed in OPM + // See above + StopPartAnimating(torso); + } SetPartAnim(torsoAnim.c_str(), torso); } @@ -5321,6 +5469,16 @@ void Player::EvaluateState(State *forceTorso, State *forceLegs) } else { SetPartAnim(legsAnim.c_str(), legs); } + + // Fixed in OPM + // Clear the legs state, so the torso state can reset it to STAND + // in subsequent iterations. + // As the legs animation is stopped, there would be no anim to wait on. + // + // This prevents the current legs state to be stuck + // when the move control is set to non-legs and then to legs + // in the same iteration before the legs state is being processed. + currentState_Legs = NULL; } if (movecontrol != move) { @@ -5362,26 +5520,33 @@ void Player::EvaluateState(State *forceTorso, State *forceLegs) } } - if (!laststate_Legs) { - if ((m_iMovePosFlags & MPF_POSITION_CROUCHING)) { + if (currentState_Legs) { + laststate_Legs = currentState_Legs; + + if (forceLegs) { + currentState_Legs = forceLegs; + } else { + currentState_Legs = currentState_Legs->Evaluate(*this, &legs_conditionals); + } + } else { + // Added in 2.0 + // Switch to the default legs state if it's NULL + if (forceLegs) { + currentState_Legs = forceLegs; + } else if ((m_iMovePosFlags & MPF_POSITION_CROUCHING)) { currentState_Legs = statemap_Legs->FindState("CROUCH_IDLE"); } else { currentState_Legs = statemap_Legs->FindState("STAND"); } + + laststate_Legs = NULL; } - laststate_Legs = currentState_Legs; - - if (forceLegs) { - currentState_Legs = forceLegs; - } else { - currentState_Legs = currentState_Legs->Evaluate(*this, &legs_conditionals); - } - - animdone_Legs = false; if (currentState_Legs) { - // Process exit commands of the last state - laststate_Legs->ProcessExitCommands(this); + if (laststate_Legs) { + // Process exit commands of the last state + laststate_Legs->ProcessExitCommands(this); + } // Process entry commands of the new state currentState_Legs->ProcessEntryCommands(this); @@ -5397,7 +5562,26 @@ void Player::EvaluateState(State *forceTorso, State *forceLegs) StopPartAnimating(legs); animdone_Legs = true; } else if (legsAnim != "") { - SetPartAnim(legsAnim, legs); + float oldTime; + + if (currentState_Legs == laststate_Legs) { + // + // Added in OPM + // This allows different animations in the same state + // to be continued at the same moment. + // This is used to avoid "ghost walking" where the player + // would switch weapons indefinitely to avoid footstep sounds + // + + oldTime = GetTime(m_iPartSlot[legs]); + SetPartAnim(legsAnim, legs); + + if (animtimes[m_iPartSlot[legs]] > 0) { + SetTime(m_iPartSlot[legs], fmod(oldTime, animtimes[m_iPartSlot[legs]])); + } + } else { + SetPartAnim(legsAnim, legs); + } } } else { currentState_Legs = laststate_Legs; @@ -5408,21 +5592,25 @@ void Player::EvaluateState(State *forceTorso, State *forceLegs) } if (g_showplayeranim->integer) { - if (last_leg_anim_name != AnimName(legs)) { - gi.DPrintf("Legs change from %s to %s\n", last_leg_anim_name.c_str(), AnimName(legs)); - last_leg_anim_name = AnimName(legs); + str sNewAnim; + + sNewAnim = AnimName(m_iPartSlot[legs]); + if (last_leg_anim_name != sNewAnim) { + gi.DPrintf("Legs anim change from %s to %s\n", last_leg_anim_name.c_str(), sNewAnim.c_str()); + last_leg_anim_name = sNewAnim; } - if (last_torso_anim_name != AnimName(torso)) { - gi.DPrintf("Torso change from %s to %s\n", last_torso_anim_name.c_str(), AnimName(torso)); - last_torso_anim_name = AnimName(torso); + sNewAnim = AnimName(m_iPartSlot[torso]); + if (last_torso_anim_name != sNewAnim) { + gi.DPrintf("Torso anim change from %s to %s\n", last_torso_anim_name.c_str(), sNewAnim.c_str()); + last_torso_anim_name = sNewAnim; } } if (g_showplayerstate->integer) { if (startstate_Legs != currentState_Legs) { gi.DPrintf( - "Legs change from %s to %s\n", + "Legs state change from %s to %s\n", startstate_Legs ? startstate_Legs->getName() : "NULL", currentState_Legs ? currentState_Legs->getName() : "NULL" ); @@ -5430,7 +5618,7 @@ void Player::EvaluateState(State *forceTorso, State *forceLegs) if (startstate_Torso != currentState_Torso) { gi.DPrintf( - "Torso change from %s to %s\n", + "Torso state change from %s to %s\n", startstate_Torso ? startstate_Torso->getName() : "NULL", currentState_Torso ? currentState_Torso->getName() : "NULL" ); @@ -5473,26 +5661,38 @@ void Player::SelectNextItem(Event *ev) void Player::SelectPreviousWeapon(Event *ev) { + Weapon *weapon; + Weapon *initialWeapon; + Weapon *activeWeapon; + if (deadflag) { return; } - Weapon *weapon = GetActiveWeapon(WEAPON_MAIN); - Weapon *activeWeapon = weapon; + activeWeapon = GetActiveWeapon(WEAPON_MAIN); + if (activeWeapon && activeWeapon->IsSubclassOfInventoryItem()) { + activeWeapon = NULL; + } - if (weapon) { - weapon = PreviousWeapon(weapon); + if (!activeWeapon) { + activeWeapon = newActiveWeapon.weapon; + if (activeWeapon && activeWeapon->IsSubclassOfInventoryItem()) { + activeWeapon = NULL; + } + } - if (g_gametype->integer != GT_SINGLE_PLAYER) { - while (weapon && weapon != activeWeapon && weapon->IsSubclassOfInventoryItem()) { - Weapon *prev = PreviousWeapon(weapon); - // Added in OPM - // Fixes the bug that cause infinite loop when the last weapon has no ammo - // and the only weapon is an inventory item - if (prev == weapon) { - break; - } - weapon = prev; + if (activeWeapon) { + // Fixed in OPM + // Fixes the bug that cause infinite loop when the last weapon has no ammo + // and the only weapon is an inventory item + for (weapon = initialWeapon = PreviousWeapon(activeWeapon); weapon && weapon != activeWeapon;) { + if (g_gametype->integer == GT_SINGLE_PLAYER || !weapon->IsSubclassOfInventoryItem()) { + break; + } + + weapon = PreviousWeapon(weapon); + if (weapon == initialWeapon) { + break; } } } else { @@ -5502,30 +5702,46 @@ void Player::SelectPreviousWeapon(Event *ev) if (weapon && weapon != activeWeapon) { useWeapon(weapon); } + + if (deadflag) { + return; + } } void Player::SelectNextWeapon(Event *ev) { + Weapon *weapon; + Weapon *initialWeapon; + Weapon *activeWeapon; + if (deadflag) { return; } - Weapon *weapon = GetActiveWeapon(WEAPON_MAIN); - Weapon *activeWeapon = weapon; + activeWeapon = GetActiveWeapon(WEAPON_MAIN); + if (activeWeapon && activeWeapon->IsSubclassOfInventoryItem()) { + activeWeapon = NULL; + } - if (weapon) { - weapon = NextWeapon(weapon); + if (!activeWeapon) { + activeWeapon = newActiveWeapon.weapon; + if (activeWeapon && activeWeapon->IsSubclassOfInventoryItem()) { + activeWeapon = NULL; + } + } - if (g_gametype->integer != GT_SINGLE_PLAYER) { - while (weapon && weapon != activeWeapon && weapon->IsSubclassOfInventoryItem()) { - Weapon *next = NextWeapon(weapon); - // Added in OPM - // Fixes the bug that cause infinite loop when the last weapon has no ammo - // and the only weapon is an inventory item - if (next == weapon) { - break; - } - weapon = next; + if (activeWeapon) { + // Fixed in OPM + // Fixes the bug that cause infinite loop when the last weapon has no ammo + // and the only weapon is an inventory item + for (weapon = initialWeapon = NextWeapon(activeWeapon); weapon && weapon != activeWeapon;) { + if (g_gametype->integer == GT_SINGLE_PLAYER || !weapon->IsSubclassOfInventoryItem()) { + break; + } + + weapon = NextWeapon(weapon); + if (weapon == initialWeapon) { + break; } } } else { @@ -5591,13 +5807,11 @@ void Player::DropCurrentWeapon(Event *ev) } void Player::GiveWeaponCheat(Event *ev) - { giveItem(ev->GetString(1)); } void Player::GiveCheat(Event *ev) - { str name; @@ -5627,7 +5841,7 @@ void Player::GiveAllCheat(Event *ev) if (gi.FS_ReadFile("global/giveall.scr", (void **)&buf, true) != -1) { buffer = buf; while (1) { - strcpy(com_token, COM_ParseExt(&buffer, qtrue)); + Q_strncpyz(com_token, COM_ParseExt(&buffer, qtrue), sizeof(com_token)); if (!com_token[0]) { break; @@ -5638,7 +5852,7 @@ void Player::GiveAllCheat(Event *ev) // get the rest of the line while (1) { - strcpy(com_token, COM_ParseExt(&buffer, qfalse)); + Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token)); if (!com_token[0]) { break; } @@ -5774,6 +5988,7 @@ void Player::NoclipCheat(Event *ev) // reset the state machine so that his animations are correct ResetState(NULL); + charge_start_time = 0; } else { client->ps.feetfalling = false; movecontrol = MOVECONTROL_LEGS; @@ -5786,7 +6001,6 @@ void Player::NoclipCheat(Event *ev) } void Player::GameVersion(Event *ev) - { gi.SendServerCommand(edict - g_entities, "print \"%s : %s\n\"", GAMEVERSION, __DATE__); } @@ -5804,13 +6018,18 @@ void Player::SetFov(float newFov) void Player::EventSetSelectedFov(Event *ev) { + float fOldSelectedFov; + if (ev->NumArgs() < 1) { gi.SendServerCommand(edict - g_entities, "print \"Fov = %d\n\"", (unsigned int)fov); return; } + fOldSelectedFov = selectedfov; SetSelectedFov(ev->GetFloat(1)); - SetFov(selectedfov); + if (fov == fOldSelectedFov) { + SetFov(selectedfov); + } } void Player::SetSelectedFov(float newFov) @@ -5845,7 +6064,6 @@ CalcRoll =============== */ float Player::CalcRoll(void) - { float sign; float side; @@ -5956,7 +6174,6 @@ AddBlend ============= */ void Player::AddBlend(float r, float g, float b, float a) - { float a2; float a3; @@ -5983,7 +6200,6 @@ CalcBlend ============= */ void Player::CalcBlend(void) - { int contents; Vector vieworg; @@ -6154,151 +6370,157 @@ void Player::DamageFeedback(void) damage_blend += (damage_blood / realcount) * bcolor; } - // - // Since 2.0: Try to find and play pain animation - // - if (getMoveType() == MOVETYPE_PORTABLE_TURRET) { - // use mg42 pain animation - painAnim = "mg42_tripod_"; - } else { - Weapon *pWeap; - const char *itemName; - // try to find an animation + if (g_target_game >= target_game_e::TG_MOHTA) { + // + // Since 2.0: Try to find and play pain animation + // + if (getMoveType() == MOVETYPE_PORTABLE_TURRET) { + // use mg42 pain animation + painAnim = "mg42_tripod_"; + } else { + Weapon *pWeap; + const char *itemName; + // try to find an animation - pWeap = GetActiveWeapon(WEAPON_MAIN); - if (pWeap) { - int weapon_class; + pWeap = GetActiveWeapon(WEAPON_MAIN); + if (pWeap) { + int weapon_class; - weapon_class = pWeap->GetWeaponClass(); - if (weapon_class & WEAPON_CLASS_PISTOL) { - painAnim = "pistol_"; - } else if (weapon_class & WEAPON_CLASS_RIFLE) { - painAnim = "rifle_"; - } else if (weapon_class & WEAPON_CLASS_SMG) { - // get the animation name from the item name - itemName = pWeap->GetItemName(); + weapon_class = pWeap->GetWeaponClass(); + if (weapon_class & WEAPON_CLASS_PISTOL) { + painAnim = "pistol_"; + } else if (weapon_class & WEAPON_CLASS_RIFLE) { + painAnim = "rifle_"; + } else if (weapon_class & WEAPON_CLASS_SMG) { + // get the animation name from the item name + itemName = pWeap->GetItemName(); - if (!Q_stricmp(itemName, "MP40")) { - painAnim = "mp40_"; - } else if (!Q_stricmp(itemName, "Sten Mark II")) { - painAnim = "sten_"; + if (!Q_stricmp(itemName, "MP40")) { + painAnim = "mp40_"; + } else if (!Q_stricmp(itemName, "Sten Mark II")) { + painAnim = "sten_"; + } else { + painAnim = "smg_"; + } + } else if (weapon_class & WEAPON_CLASS_MG) { + itemName = pWeap->GetItemName(); + + if (!Q_stricmp(itemName, "StG 44")) { + painAnim = "mp44_"; + } else { + painAnim = "mg_"; + } + } else if (weapon_class & WEAPON_CLASS_GRENADE) { + itemName = pWeap->GetItemName(); + + // 2.30: use landmine animations + if (!Q_stricmp(itemName, "Minedetector")) { + painAnim = "minedetector_"; + } else if (!Q_stricmp(itemName, "Minensuchgerat")) { + painAnim = "minedetectoraxis_"; + } else if (!Q_stricmp(itemName, "LandmineAllies")) { + painAnim = "mine_"; + } else if (!Q_stricmp(itemName, "LandmineAxis")) { + painAnim = "mine_"; + } else if (!Q_stricmp(itemName, "LandmineAxis")) { + painAnim = "grenade_"; + } + } else if (weapon_class & WEAPON_CLASS_HEAVY) { + itemName = pWeap->GetItemName(); + + if (!Q_stricmp(itemName, "Shotgun")) { + painAnim = "shotgun_"; + } else { + // Defaults to bazooka + painAnim = "bazooka_"; + } } else { - painAnim = "smg_"; - } - } else if (weapon_class & WEAPON_CLASS_MG) { - itemName = pWeap->GetItemName(); + itemName = pWeap->GetItemName(); - if (!Q_stricmp(itemName, "StG 44")) { - painAnim = "mp44_"; - } else { - painAnim = "mg_"; - } - } else if (weapon_class & WEAPON_CLASS_GRENADE) { - itemName = pWeap->GetItemName(); - - // 2.30: use landmine animations - if (!Q_stricmp(itemName, "Minedetector")) { - painAnim = "minedetector_"; - } else if (!Q_stricmp(itemName, "Minensuchgerat")) { - painAnim = "minedetectoraxis_"; - } else if (!Q_stricmp(itemName, "LandmineAllies")) { - painAnim = "mine_"; - } else if (!Q_stricmp(itemName, "LandmineAxis")) { - painAnim = "mine_"; - } else if (!Q_stricmp(itemName, "LandmineAxis")) { - painAnim = "grenade_"; - } - } else if (weapon_class & WEAPON_CLASS_HEAVY) { - itemName = pWeap->GetItemName(); - - if (!Q_stricmp(itemName, "Shotgun")) { - painAnim = "shotgun_"; - } else { - // Defaults to bazooka - painAnim = "bazooka_"; + if (!Q_stricmp(itemName, "Packed MG42 Turret")) { + painAnim = "mg42_"; + } else { + // Default animation if not found + painAnim = "unarmed_"; + } } } else { - itemName = pWeap->GetItemName(); - - if (!Q_stricmp(itemName, "Packed MG42 Turret")) { - painAnim = "mg42_"; - } else { - // Default animation if not found - painAnim = "unarmed_"; - } + painAnim = "unarmed_"; } + + // use the animation based on the movement + if (m_iMovePosFlags & MPF_POSITION_CROUCHING) { + painAnim += "crouch_"; + } else { + painAnim += "stand_"; + } + } + + painAnim += "hit_"; + + if (pain_dir == PAIN_REAR || pain_location == HITLOC_TORSO_MID || HITLOC_TORSO_LOWER) { + painAnim += "back"; } else { - painAnim = "unarmed_"; + switch (pain_location) { + case HITLOC_HEAD: + case HITLOC_HELMET: + case HITLOC_NECK: + painAnim += "head"; + break; + case HITLOC_TORSO_UPPER: + case HITLOC_TORSO_MID: + painAnim += "uppertorso"; + break; + case HITLOC_TORSO_LOWER: + case HITLOC_PELVIS: + painAnim += "lowertorso"; + break; + case HITLOC_R_ARM_UPPER: + case HITLOC_R_ARM_LOWER: + case HITLOC_R_HAND: + painAnim += "rarm"; + break; + case HITLOC_L_ARM_UPPER: + case HITLOC_L_ARM_LOWER: + case HITLOC_L_HAND: + painAnim += "larm"; + break; + case HITLOC_R_LEG_UPPER: + case HITLOC_L_LEG_UPPER: + case HITLOC_R_LEG_LOWER: + case HITLOC_L_LEG_LOWER: + case HITLOC_R_FOOT: + case HITLOC_L_FOOT: + painAnim += "leg"; + break; + default: + painAnim += "uppertorso"; + break; + } } - // use the animation based on the movement - if (m_iMovePosFlags & MPF_POSITION_CROUCHING) { - painAnim += "crouch_"; + animnum = gi.Anim_NumForName(edict->tiki, painAnim.c_str()); + if (animnum == -1) { + gi.DPrintf("WARNING: Could not find player pain animation '%s'\n", painAnim.c_str()); } else { - painAnim += "stand_"; + NewAnim(animnum, EV_Player_AnimLoop_Pain, ANIMSLOT_PAIN); + RestartAnimSlot(ANIMSLOT_PAIN); + m_sPainAnim = painAnim; + m_fPainBlend = 1.f; + animdone_Pain = false; } } - painAnim += "hit_"; - - if (pain_dir == PAIN_REAR || pain_location == HITLOC_TORSO_MID || HITLOC_TORSO_LOWER) { - painAnim += "back"; - } else { - switch (pain_location) { - case HITLOC_HEAD: - case HITLOC_HELMET: - case HITLOC_NECK: - painAnim += "head"; - break; - case HITLOC_TORSO_UPPER: - case HITLOC_TORSO_MID: - painAnim += "uppertorso"; - break; - case HITLOC_TORSO_LOWER: - case HITLOC_PELVIS: - painAnim += "lowertorso"; - break; - case HITLOC_R_ARM_UPPER: - case HITLOC_R_ARM_LOWER: - case HITLOC_R_HAND: - painAnim += "rarm"; - break; - case HITLOC_L_ARM_UPPER: - case HITLOC_L_ARM_LOWER: - case HITLOC_L_HAND: - painAnim += "larm"; - break; - case HITLOC_R_LEG_UPPER: - case HITLOC_L_LEG_UPPER: - case HITLOC_R_LEG_LOWER: - case HITLOC_L_LEG_LOWER: - case HITLOC_R_FOOT: - case HITLOC_L_FOOT: - painAnim += "leg"; - break; - default: - painAnim += "uppertorso"; - break; - } - } - - animnum = gi.Anim_NumForName(edict->tiki, painAnim.c_str()); - if (animnum == -1) { - gi.DPrintf("WARNING: Could not find player pain animation '%s'\n", painAnim.c_str()); - } else { - NewAnim(animnum, EV_Player_AnimLoop_Pain, ANIMSLOT_PAIN); - RestartAnimSlot(ANIMSLOT_PAIN); - m_sPainAnim = painAnim; - m_fPainBlend = 1.f; - animdone_Pain = false; - } - // // clear totals // damage_blood = 0; - if (IsSubclassOfPlayer()) { + // + // Added in 2.0 + // Don't show damage when in god mode + // + if (flags & FL_GODMODE) { damage_count = 0; damage_blood = 0; damage_alpha = 0; @@ -6741,7 +6963,6 @@ void Player::SetupView(void) } Vector Player::GetAngleToTarget(Entity *ent, str tag, float yawclamp, float pitchclamp, Vector baseangles) - { assert(ent); @@ -6786,7 +7007,6 @@ Vector Player::GetAngleToTarget(Entity *ent, str tag, float yawclamp, float pitc } void Player::DebugWeaponTags(int controller_tag, Weapon *weapon, str weapon_tagname) - { int i; orientation_t bone_or, tag_weapon_or, barrel_or, final_barrel_or; @@ -6901,7 +7121,7 @@ void Player::FinishMove(void) DamageFeedback(); CalcBlend(); - if (g_gametype->integer != GT_SINGLE_PLAYER && g_smoothClients->integer && !IsSubclassOfBot()) { + if (g_gametype->integer != GT_SINGLE_PLAYER && g_smoothClients->integer) { VectorCopy(client->ps.velocity, edict->s.pos.trDelta); edict->s.pos.trTime = client->ps.commandTime; } else { @@ -6932,11 +7152,8 @@ void Player::CopyStats(Player *player) VectorCopy(player->client->ps.origin, client->ps.origin); VectorCopy(player->client->ps.velocity, client->ps.velocity); - if (client->ps.iViewModelAnim != player->client->ps.iViewModelAnim) { - ViewModelAnim(player->m_sVMcurrent, qfalse, 0); - } else if (client->ps.iViewModelAnimChanged != player->client->ps.iViewModelAnimChanged) { - ViewModelAnim(player->m_sVMcurrent, qtrue, 0); - } + client->ps.iViewModelAnim = player->client->ps.iViewModelAnim; + client->ps.iViewModelAnimChanged = player->client->ps.iViewModelAnimChanged; client->ps.gravity = player->client->ps.gravity; client->ps.speed = player->client->ps.speed; @@ -6969,7 +7186,7 @@ void Player::CopyStats(Player *player) edict->r.svFlags &= ~SVF_NOCLIENT; edict->s.renderfx &= ~RF_DONTDRAW; - player->edict->r.svFlags |= SVF_PORTAL; + player->edict->r.svFlags |= SVF_NOTSINGLECLIENT; player->edict->r.singleClient = client->ps.clientNum; edict->r.svFlags |= SVF_SINGLECLIENT; @@ -6998,9 +7215,6 @@ void Player::CopyStats(Player *player) CloneEntity(dest, ent->entity); - dest->edict->r.svFlags |= SVF_SINGLECLIENT; - dest->edict->r.singleClient = client->ps.clientNum; - dest->edict->s.modelindex = ent->entity->edict->s.modelindex; dest->edict->tiki = ent->entity->edict->tiki; dest->edict->s.actionWeight = ent->entity->edict->s.actionWeight; @@ -7122,7 +7336,7 @@ void Player::UpdateStats(void) trace = G_Trace(m_vViewPos, vec_zero, vec_zero, vEnd, this, MASK_BEAM, qfalse, "infoclientcheck"); - if (trace.ent && trace.ent->entity->IsSubclassOfPlayer()) { + if (trace.ent && trace.ent->entity->IsSubclassOfPlayer() && !(trace.ent->r.svFlags & SVF_NOCLIENT)) { Player *p = static_cast(trace.ent->entity); if (IsSpectator() || p->GetTeam() == GetTeam()) { @@ -7207,7 +7421,7 @@ void Player::UpdateStats(void) healthfrac = (health / max_health * 100.0f); if (m_pVehicle && !m_pTurret) { - if (m_pVehicle->isSubclassOf(FixedTurret)) { + if (!m_pVehicle->isSubclassOf(FixedTurret)) { healthfrac = (m_pVehicle->health / m_pVehicle->max_health * 100.f); } } @@ -7453,7 +7667,7 @@ void Player::UpdateStats(void) float frac; - level.m_letterbox_time -= level.intframetime; + level.m_letterbox_time -= level.frametime; frac = level.m_letterbox_time / level.m_letterbox_time_start; @@ -7484,14 +7698,12 @@ void Player::UpdateMusic(void) } void Player::SetReverb(int type, float level) - { reverb_type = type; reverb_level = level; } void Player::SetReverb(str type, float level) - { reverb_type = EAXMode_NameToNum(type); reverb_level = level; @@ -7569,7 +7781,6 @@ void Player::EndFrame(void) } void Player::GotKill(Event *ev) - { /* Entity *victim; @@ -7592,7 +7803,6 @@ void Player::GotKill(Event *ev) } void Player::SetPowerupTimer(Event *ev) - { Event *event; @@ -7603,7 +7813,6 @@ void Player::SetPowerupTimer(Event *ev) } void Player::UpdatePowerupTimer(Event *ev) - { poweruptimer -= 1; if (poweruptimer > 0) { @@ -7641,7 +7850,6 @@ void Player::ChangeMusic(const char *current, const char *fallback, qboolean for } void Player::ChangeMusicVolume(float volume, float fade_time) - { music_volume_fade_time = fade_time; music_saved_volume = music_current_volume; @@ -7649,7 +7857,6 @@ void Player::ChangeMusicVolume(float volume, float fade_time) } void Player::RestoreMusicVolume(float fade_time) - { music_volume_fade_time = fade_time; music_current_volume = music_saved_volume; @@ -7666,18 +7873,37 @@ void Player::addOrigin(Vector org) } void Player::Jump(Event *ev) - { float maxheight; + if (m_pTurret || m_pVehicle) { + // Don't jump when inside a vehicle or turret + return; + } + + if (g_gametype->integer != GT_SINGLE_PLAYER) { + // Added in 2.0 + // Don't jump when on top of another sentient + if (groundentity && groundentity->entity && groundentity->entity->IsSubclassOfSentient()) { + return; + } + } + maxheight = ev->GetFloat(1); if (maxheight > 16) { // v^2 = 2ad velocity[2] += sqrt(2 * sv_gravity->integer * maxheight); + if (client->ps.groundEntityNum != ENTITYNUM_NONE) { + velocity += m_vPushVelocity; + } + // make sure the player leaves the ground client->ps.walking = qfalse; + + // Added in 2.0 + m_bHasJumped = true; } } @@ -7689,6 +7915,11 @@ void Player::JumpXY(Event *ev) float time; float speed; + if (m_pTurret || m_pVehicle) { + // Don't jump when inside a vehicle or turret + return; + } + forwardmove = ev->GetFloat(1); sidemove = ev->GetFloat(2); speed = ev->GetFloat(3); @@ -7699,6 +7930,10 @@ void Player::JumpXY(Event *ev) time = distance / speed; velocity[2] = sv_gravity->integer * time * 0.5f; + if (client->ps.groundEntityNum != ENTITYNUM_NONE) { + velocity += G_GetEntity(client->ps.groundEntityNum)->velocity; + } + airspeed = distance; // make sure the player leaves the ground @@ -7713,6 +7948,10 @@ void Player::SetViewAngles(Vector newViewangles) client->ps.delta_angles[2] = ANGLE2SHORT(newViewangles.z - client->cmd_angles[2]); v_angle = newViewangles; + // Fixed in OPM + // Normalize angles to the range (-180, +180) + // so interpolation is done properly client-side + v_angle.EulerNormalize(); // get the pitch and roll from our leg angles newViewangles.x = angles.x; @@ -7728,7 +7967,6 @@ void Player::SetTargetViewAngles(Vector angles) } void Player::DumpState(Event *ev) - { gi.DPrintf( "Legs: %s Torso: %s\n", currentState_Legs ? currentState_Legs->getName() : "NULL", currentState_Torso->getName() @@ -7882,7 +8120,6 @@ void Player::Holster(Event *ev) } void Player::WatchActor(Event *ev) - { if (camera || currentState_Torso->getCameraType() != CAMERA_BEHIND) { return; @@ -7892,7 +8129,6 @@ void Player::WatchActor(Event *ev) } void Player::StopWatchingActor(Event *ev) - { Actor *old_actor; @@ -7915,7 +8151,6 @@ void Player::setAngles(Vector ang) } painDirection_t Player::Pain_string_to_int(str pain) - { if (!pain.icmp(pain, "Front")) { return PAIN_FRONT; @@ -7933,6 +8168,7 @@ painDirection_t Player::Pain_string_to_int(str pain) void Player::ArchivePersistantData(Archiver& arc) { str model_name; + str name; Sentient::ArchivePersistantData(arc); @@ -7944,11 +8180,9 @@ void Player::ArchivePersistantData(Archiver& arc) // set the cvar gi.cvar_set("g_playermodel", model_name.c_str()); - model_name += ".tik"; - setModel(model_name.c_str()); + setModel("models/player/" + model_name + ".tik"); } - str name; if (arc.Saving()) { if (holsteredWeapon) { name = holsteredWeapon->getName(); @@ -7956,11 +8190,10 @@ void Player::ArchivePersistantData(Archiver& arc) name = "none"; } } + arc.ArchiveString(&name); - if (arc.Loading()) { - if (name != "none") { - holsteredWeapon = (Weapon *)FindItem(name); - } + if (arc.Loading() && name != "none") { + holsteredWeapon = (Weapon *)FindItem(name); } UpdateWeapons(); @@ -8601,49 +8834,49 @@ void Player::EnsurePlayerHasAllowedWeapons() return; } - strcpy(client->pers.dm_primary, "rifle"); + Q_strncpyz(client->pers.dm_primary, "rifle", sizeof(client->pers.dm_primary)); } else if (!Q_stricmp(client->pers.dm_primary, "rifle")) { if (!(dmflags->integer & DF_WEAPON_NO_RIFLE)) { return; } - strcpy(client->pers.dm_primary, "smg"); + Q_strncpyz(client->pers.dm_primary, "smg", sizeof(client->pers.dm_primary)); } else if (!Q_stricmp(client->pers.dm_primary, "smg")) { - if (!(dmflags->integer & DF_WEAPON_NO_RIFLE)) { + if (!(dmflags->integer & DF_WEAPON_NO_SMG)) { return; } - strcpy(client->pers.dm_primary, "mg"); + Q_strncpyz(client->pers.dm_primary, "mg", sizeof(client->pers.dm_primary)); } else if (!Q_stricmp(client->pers.dm_primary, "mg")) { - if (!(dmflags->integer & DF_WEAPON_NO_RIFLE)) { + if (!(dmflags->integer & DF_WEAPON_NO_MG)) { return; } - strcpy(client->pers.dm_primary, "shotgun"); + Q_strncpyz(client->pers.dm_primary, "shotgun", sizeof(client->pers.dm_primary)); } else if (!Q_stricmp(client->pers.dm_primary, "shotgun")) { - if (!(dmflags->integer & DF_WEAPON_NO_RIFLE)) { + if (!(dmflags->integer & DF_WEAPON_NO_SHOTGUN)) { return; } - strcpy(client->pers.dm_primary, "heavy"); + Q_strncpyz(client->pers.dm_primary, "heavy", sizeof(client->pers.dm_primary)); } else if (!Q_stricmp(client->pers.dm_primary, "heavy")) { - if (!(dmflags->integer & DF_WEAPON_NO_RIFLE)) { + if (!(dmflags->integer & DF_WEAPON_NO_ROCKET)) { return; } - strcpy(client->pers.dm_primary, "landmine"); + Q_strncpyz(client->pers.dm_primary, "landmine", sizeof(client->pers.dm_primary)); } else if (!Q_stricmp(client->pers.dm_primary, "landmine")) { if (QueryLandminesAllowed()) { return; } - strcpy(client->pers.dm_primary, "sniper"); + Q_strncpyz(client->pers.dm_primary, "sniper", sizeof(client->pers.dm_primary)); } } gi.cvar_set("dmflags", va("%i", dmflags->integer & ~DF_WEAPON_NO_RIFLE)); Com_Printf("No valid weapons -- re-allowing the rifle\n"); - strcpy(client->pers.dm_primary, "rifle"); + Q_strncpyz(client->pers.dm_primary, "rifle", sizeof(client->pers.dm_primary)); } void Player::EquipWeapons() @@ -8696,7 +8929,12 @@ void Player::EquipWeapons() } break; case NA_GERMAN: - if (g_target_game < target_game_e::TG_MOHTA || dmflags->integer & DF_OLD_SNIPER) { + if (g_target_game < target_game_e::TG_MOHTA + || dmflags->integer & DF_OLD_SNIPER + // Added in OPM + // This was also a feature of Daven's fixes + // Use KAR98 for panzer skins + || !Q_stricmpn(client->pers.dm_playergermanmodel, "german_panzer", 13)) { // Old snipers are forced older versions of the game giveItem("weapons/kar98sniper.tik"); event->AddString("KAR98 - Sniper"); @@ -8904,27 +9142,37 @@ void Player::EquipWeapons() switch (nationality) { case NA_BRITISH: giveItem("weapons/mills_grenade.tik"); - giveItem("weapons/M18_smoke_grenade.tik"); + if (g_target_game >= target_game_e::TG_MOHTA) { + giveItem("weapons/M18_smoke_grenade.tik"); + } giveItem("weapons/Webley_Revolver.tik"); break; case NA_RUSSIAN: giveItem("weapons/Russian_F1_grenade.tik"); - giveItem("weapons/RDG-1_Smoke_grenade.tik"); + if (g_target_game >= target_game_e::TG_MOHTA) { + giveItem("weapons/RDG-1_Smoke_grenade.tik"); + } giveItem("weapons/Nagant_revolver.tik"); break; case NA_GERMAN: giveItem("weapons/steilhandgranate.tik"); - giveItem("weapons/nebelhandgranate.tik"); + if (g_target_game >= target_game_e::TG_MOHTA) { + giveItem("weapons/nebelhandgranate.tik"); + } giveItem("weapons/p38.tik"); break; case NA_ITALIAN: giveItem("weapons/it_w_bomba.tik"); - giveItem("weapons/it_w_bombabreda.tik"); + if (g_target_game >= target_game_e::TG_MOHTA) { + giveItem("weapons/it_w_bombabreda.tik"); + } giveItem("weapons/it_w_beretta.tik"); break; default: giveItem("weapons/m2frag_grenade.tik"); - giveItem("weapons/M18_smoke_grenade.tik"); + if (g_target_game >= target_game_e::TG_MOHTA) { + giveItem("weapons/M18_smoke_grenade.tik"); + } giveItem("weapons/colt45.tik"); break; } @@ -9074,10 +9322,6 @@ void Player::SetPlayerSpectate(bool bNext) } } - if (m_iPlayerSpectating >= game.maxclients) { - m_iPlayerSpectating = 0; - } - for (i = num; i < game.maxclients && i >= 0; i += dir) { ent = &g_entities[i]; if (!ent->inuse || !ent->entity) { @@ -9092,12 +9336,6 @@ void Player::SetPlayerSpectate(bool bNext) client->ps.camera_flags |= (client->ps.camera_flags & CF_CAMERA_CUT_BIT) ^ CF_CAMERA_CUT_BIT; return; } - - if (!m_iPlayerSpectating) { - return; - } - - m_iPlayerSpectating = 0; } if (m_iPlayerSpectating) { @@ -9227,9 +9465,13 @@ void Player::Join_DM_Team(Event *ev) teamtype_t team; str teamname; const char *join_message; - float startTime; Entity *ent; + if (ev->isSubclassOf(ConsoleEvent) && disable_team_change) { + // Added in OPM + return; + } + teamname = ev->GetString(1); if (!teamname.icmp("allies")) { @@ -9252,19 +9494,7 @@ void Player::Join_DM_Team(Event *ev) return; } - startTime = dmManager.GetMatchStartTime(); - - if (startTime >= 0.0f && (level.time - startTime) > 30.0 - && (level.time - m_fTeamSelectTime) < g_teamswitchdelay->integer) { - int seconds = g_teamswitchdelay->integer - (level.time - m_fTeamSelectTime); - - gi.SendServerCommand( - edict - g_entities, - "print \"" HUD_MESSAGE_WHITE "%s %i %s\n\"", - gi.LV_ConvertString("Can not change teams again for another"), - seconds + 1, - gi.LV_ConvertString("seconds") - ); + if (ev->isSubclassOf(ConsoleEvent) && !CheckCanSwitchTeam(team)) { return; } @@ -9450,7 +9680,7 @@ void Player::ArmorDamage(Event *ev) if (attacker && attacker->IsSubclassOfPlayer()) { if (attacker != this) { - if (g_gametype->integer > 1 && !g_teamdamage->integer) { + if (g_gametype->integer >= GT_TEAM && !g_teamdamage->integer) { // check for team damage if (attacker->GetDM_Team() == GetDM_Team() && mod != MOD_TELEFRAG) { return; @@ -9481,19 +9711,21 @@ void Player::ArmorDamage(Event *ev) event->AddInteger(ev->GetInteger(10)); event->AddEntity(this); + scriptDelegate_damage.Trigger(this, *event); scriptedEvents[SE_DAMAGE].Trigger(event); } void Player::Disconnect(void) { Event *ev = new Event; - ev->AddListener(this); + + scriptDelegate_disconnecting.Trigger(this, *ev); scriptedEvents[SE_DISCONNECTED].Trigger(ev); - if (g_gametype->integer != GT_SINGLE_PLAYER) { - dmManager.RemovePlayer(this); - } + // if (g_gametype->integer != GT_SINGLE_PLAYER) { + // dmManager.RemovePlayer(this); + // } } void Player::CallVote(Event *ev) @@ -9870,6 +10102,41 @@ void Player::EventPrimaryDMWeapon(Event *ev) bIsBanned = (dmflags->integer & DF_WEAPON_NO_ROCKET); } else if (!str::icmp(dm_weapon, "landmine")) { bIsBanned = (dmflags->integer & DF_WEAPON_NO_LANDMINE) || !QueryLandminesAllowed(); + } else if (!str::icmp(dm_weapon, "auto")) { + const char *primaryList[7]; + size_t numPrimaries = 0; + + // + // Added in OPM + // Choose a random allowed weapon + // + if (!(dmflags->integer & DF_WEAPON_NO_SHOTGUN)) { + primaryList[numPrimaries++] = "shotgun"; + } + if (!(dmflags->integer & DF_WEAPON_NO_RIFLE)) { + primaryList[numPrimaries++] = "rifle"; + } + if (!(dmflags->integer & DF_WEAPON_NO_SNIPER)) { + primaryList[numPrimaries++] = "sniper"; + } + if (!(dmflags->integer & DF_WEAPON_NO_SMG)) { + primaryList[numPrimaries++] = "smg"; + } + if (!(dmflags->integer & DF_WEAPON_NO_MG)) { + primaryList[numPrimaries++] = "mg"; + } + if (!(dmflags->integer & DF_WEAPON_NO_ROCKET)) { + primaryList[numPrimaries++] = "heavy"; + } + if (!(dmflags->integer & DF_WEAPON_NO_LANDMINE) && QueryLandminesAllowed()) { + primaryList[numPrimaries++] = "landmine"; + } + + if (numPrimaries) { + dm_weapon = primaryList[rand() % numPrimaries]; + } else { + bIsBanned = qtrue; + } } if (bIsBanned) { @@ -9960,6 +10227,12 @@ void Player::EventGetCurrentDMWeaponType(Event *ev) void Player::PhysicsOff(Event *ev) { + if (g_target_game > TG_MOH || g_gametype->integer != GT_SINGLE_PLAYER) { + // Added in 2.0 + // Reset the state to STAND before disabling physics + EvaluateState(statemap_Torso->FindState("STAND"), statemap_Legs->FindState("STAND")); + } + flags |= FL_IMMOBILE; } @@ -10097,7 +10370,9 @@ void Player::Stats(Event *ev) } } - szPreferredWeapon = m_sPerferredWeaponOverride; + if (m_sPerferredWeaponOverride.length()) { + szPreferredWeapon = m_sPerferredWeaponOverride; + } if (iNumHits) { Com_sprintf( @@ -10109,7 +10384,7 @@ void Player::Stats(Event *ev) m_iObjectivesCompleted, iNumShotsFired, iNumHits, - (iNumHits / iNumShotsFired * 100.f), + ((float)iNumHits / (float)iNumShotsFired * 100.f), szPreferredWeapon.c_str(), m_iNumHitsTaken, m_iNumObjectsDestroyed, @@ -10163,39 +10438,58 @@ void Player::EventStuffText(Event *ev) Event *event = new Event(EV_Player_StuffText); event->AddValue(ev->GetValue(1)); PostEvent(event, level.frametime, 0); - } else { - gi.SendServerCommand(edict - g_entities, "stufftext \"%s\"", ev->GetString(1).c_str()); + return; } + + gi.SendServerCommand(edict - g_entities, "stufftext \"%s\"", ev->GetString(1).c_str()); + + delegate_stufftext.Execute(ev->GetString(1)); } void Player::EventSetVoiceType(Event *ev) { str sVoiceName = ev->GetString(1); - if (!sVoiceName.icmp("airborne")) { - m_voiceType = PVT_ALLIED_AIRBORNE; - } else if (!sVoiceName.icmp("manon")) { - m_voiceType = PVT_ALLIED_MANON; - } else if (!sVoiceName.icmp("SAS")) { - m_voiceType = PVT_ALLIED_SAS; - } else if (!sVoiceName.icmp("pilot")) { - m_voiceType = PVT_ALLIED_PILOT; - } else if (!sVoiceName.icmp("army")) { - m_voiceType = PVT_ALLIED_ARMY; - } else if (!sVoiceName.icmp("ranger")) { - m_voiceType = PVT_ALLIED_RANGER; - } else if (!sVoiceName.icmp("axis1")) { - m_voiceType = PVT_AXIS_AXIS1; - } else if (!sVoiceName.icmp("axis2")) { - m_voiceType = PVT_AXIS_AXIS2; - } else if (!sVoiceName.icmp("axis3")) { - m_voiceType = PVT_AXIS_AXIS3; - } else if (!sVoiceName.icmp("axis4")) { - m_voiceType = PVT_AXIS_AXIS4; - } else if (!sVoiceName.icmp("axis5")) { - m_voiceType = PVT_AXIS_AXIS5; + if (g_protocol >= protocol_e::PROTOCOL_MOHTA_MIN) { + if (!sVoiceName.icmp("american")) { + m_voiceType = PVT_ALLIED_AMERICAN; + } else if (!sVoiceName.icmp("british")) { + m_voiceType = PVT_ALLIED_BRITISH; + } else if (!sVoiceName.icmp("russian")) { + m_voiceType = PVT_ALLIED_RUSSIAN; + } else if (!sVoiceName.icmp("german")) { + m_voiceType = PVT_AXIS_GERMAN; + } else if (!sVoiceName.icmp("italian")) { + m_voiceType = PVT_AXIS_ITALIAN; + } else { + m_voiceType = PVT_NONE_SET; + } } else { - m_voiceType = PVT_NONE_SET; + if (!sVoiceName.icmp("airborne")) { + m_voiceType = PVT_ALLIED_AIRBORNE; + } else if (!sVoiceName.icmp("manon")) { + m_voiceType = PVT_ALLIED_MANON; + } else if (!sVoiceName.icmp("SAS")) { + m_voiceType = PVT_ALLIED_SAS; + } else if (!sVoiceName.icmp("pilot")) { + m_voiceType = PVT_ALLIED_PILOT; + } else if (!sVoiceName.icmp("army")) { + m_voiceType = PVT_ALLIED_ARMY; + } else if (!sVoiceName.icmp("ranger")) { + m_voiceType = PVT_ALLIED_RANGER; + } else if (!sVoiceName.icmp("axis1")) { + m_voiceType = PVT_AXIS_AXIS1; + } else if (!sVoiceName.icmp("axis2")) { + m_voiceType = PVT_AXIS_AXIS2; + } else if (!sVoiceName.icmp("axis3")) { + m_voiceType = PVT_AXIS_AXIS3; + } else if (!sVoiceName.icmp("axis4")) { + m_voiceType = PVT_AXIS_AXIS4; + } else if (!sVoiceName.icmp("axis5")) { + m_voiceType = PVT_AXIS_AXIS5; + } else { + m_voiceType = PVT_NONE_SET; + } } } @@ -10314,11 +10608,12 @@ void Player::PlayInstantMessageSound(const char *name) void Player::EventDMMessage(Event *ev) { - int i; - int iStringLength; + int i; + //int iStringLength; int iMode = 0; str sToken; char szPrintString[MAX_SAY_TEXT]; // it's MAX_STRING_CHARS in mohaa + size_t iStringLength; const char *pTmpInstantMsg = ""; qboolean bInstaMessage = qfalse; AliasListNode_t *pSoundAlias = NULL; @@ -10335,6 +10630,17 @@ void Player::EventDMMessage(Event *ev) return; } + if (!Q_stricmp(client->pers.netname, "console")) { + // Added in OPM + // Reserved name + gi.Printf( + "Client %d trying to send a message using a reserved name ('%s')\n", + edict - g_entities, + client->pers.netname + ); + return; + } + sToken = ev->GetString(2); // Check for taunts @@ -10347,8 +10653,31 @@ void Player::EventDMMessage(Event *ev) return; } + if (edict->r.svFlags & SVF_NOCLIENT) { + // Changed in OPM + // Don't send a voice chat message if the entity is not sent to client + return; + } + + if (!g_instamsg_allowed->integer) { + // Added in OPM + return; + } + + if (g_instamsg_minDelay->integer > 0 && level.inttime < m_iInstantMessageTime + g_instamsg_minDelay->integer) { + // Added in OPM + return; + } + GetTeamDialogPrefix(sAliasName); - sAliasName += va("%c%c", (sToken[1] + '0'), (sToken[2] + '0')); + if (g_target_game >= target_game_e::TG_MOHTT && sToken[1] == '6') { + // Added in 2.30 + // Liberation messages + sAliasName += va("lib%c", (sToken[2] + '0')); + } else { + sAliasName += va("%c%c", (sToken[1] + '0'), (sToken[2] + '0')); + } + sRandomAlias = GetRandomAlias(sAliasName, &pSoundAlias); // find a random alias @@ -10392,26 +10721,48 @@ void Player::EventDMMessage(Event *ev) } else { iMode = -1; } + } + } else { + if (!g_textmsg_allowed->integer) { + // Added in OPM - if (g_voiceChatTime->value > 0) { - m_fTalkTime = g_voiceChatTime->value + level.time; - } + str errorString = gi.LV_ConvertString("Message Error"); + str reasonString = gi.LV_ConvertString("Text chat is disabled on this server"); + + gi.SendServerCommand( + edict - g_entities, + "print \"" HUD_MESSAGE_CHAT_WHITE "%s: %s.\n\"", + errorString.c_str(), + reasonString.c_str() + ); + return; + } + + if (g_textmsg_minDelay->integer > 0 && level.inttime < m_iTextChatTime + g_textmsg_minDelay->integer) { + // Added in OPM + return; } } - if (!bInstaMessage) { + if (bInstaMessage) { + if (g_voiceChatTime->value > 0) { + m_fTalkTime = g_voiceChatTime->value + level.time; + } + m_iInstantMessageTime = level.inttime; + } else { iMode = ev->GetInteger(1); if (g_textChatTime->value > 0) { m_fTalkTime = g_textChatTime->value + level.time; } + m_iTextChatTime = level.inttime; } - strcpy(szPrintString, "print \"" HUD_MESSAGE_CHAT_WHITE); + Q_strncpyz(szPrintString, "print \"" HUD_MESSAGE_CHAT_WHITE, sizeof(szPrintString)); if (m_bSpectator) { if (iMode <= 0) { - strcat(szPrintString, gi.CL_LV_ConvertString("(spectator)")); - strcat(szPrintString, " "); + Q_strcat(szPrintString, sizeof(szPrintString), gi.CL_LV_ConvertString("(spectator)")); + Q_strcat(szPrintString, sizeof(szPrintString), " "); } else if (iMode <= game.maxclients) { ent = &g_entities[iMode - 1]; @@ -10431,8 +10782,8 @@ void Player::EventDMMessage(Event *ev) } } else if (IsDead() || m_bTempSpectator) { if (iMode <= 0) { - strcat(szPrintString, gi.CL_LV_ConvertString("(dead)")); - strcat(szPrintString, " "); + Q_strcat(szPrintString, sizeof(szPrintString), gi.CL_LV_ConvertString("(dead)")); + Q_strcat(szPrintString, sizeof(szPrintString), " "); } else if (iMode <= game.maxclients) { ent = &g_entities[iMode - 1]; @@ -10451,24 +10802,31 @@ void Player::EventDMMessage(Event *ev) } } } else if (iMode < 0) { - strcat(szPrintString, gi.CL_LV_ConvertString("(team)")); - strcat(szPrintString, " "); + Q_strcat(szPrintString, sizeof(szPrintString), gi.CL_LV_ConvertString("(team)")); + Q_strcat(szPrintString, sizeof(szPrintString), " "); } else if (iMode > 0) { - strcat(szPrintString, gi.CL_LV_ConvertString("(private)")); - strcat(szPrintString, " "); + Q_strcat(szPrintString, sizeof(szPrintString), gi.CL_LV_ConvertString("(private)")); + Q_strcat(szPrintString, sizeof(szPrintString), " "); } - strcat(szPrintString, client->pers.netname); + Q_strcat(szPrintString, sizeof(szPrintString), client->pers.netname); if (bInstaMessage) { - strcat(szPrintString, ": "); - strcat(szPrintString, gi.LV_ConvertString(pTmpInstantMsg)); + Q_strcat(szPrintString, sizeof(szPrintString), ": "); + Q_strcat(szPrintString, sizeof(szPrintString), gi.LV_ConvertString(pTmpInstantMsg)); } else { - bool met_comment; + bool met_comment = false; - strcat(szPrintString, ":"); + Q_strcat(szPrintString, sizeof(szPrintString), ":"); iStringLength = strlen(szPrintString); + // Added in OPM. + // Checks for comments in string (as COM_Parse will parse them) + // This was fixed in 2.0 but make the fix compatible with older versions + if (g_protocol < protocol_e::PROTOCOL_MOHTA_MIN && strstr(client->pers.netname, "/*")) { + met_comment = true; + } + for (i = 2; i <= ev->NumArgs(); i++) { sToken = ev->GetString(i); // Added in 2.40 @@ -10480,34 +10838,57 @@ void Player::EventDMMessage(Event *ev) break; } - // Added in OPM. - // Checks for comments in string (as COM_Parse will parse them) - if (strstr(sToken, "/*")) { - met_comment = true; - } - - if (strstr(sToken, "*/") && met_comment) { + if (met_comment && strstr(sToken, "*/")) { // ignore messages containing comments return; } - strcat(szPrintString, " "); - strcat(szPrintString, gi.LV_ConvertString(sToken)); + Q_strcat(szPrintString, sizeof(szPrintString), " "); + Q_strcat(szPrintString, sizeof(szPrintString), gi.LV_ConvertString(sToken)); } } - strcat(szPrintString, "\n"); + Q_strcat(szPrintString, sizeof(szPrintString), "\n"); // ignore names containing comments - if (strstr(client->pers.netname, "//") - || (strstr(client->pers.netname, "/*") && strstr(client->pers.netname, "*/"))) { - return; + if (g_protocol < protocol_e::PROTOCOL_MOHTA_MIN) { + if (strstr(client->pers.netname, "//") + || (strstr(client->pers.netname, "/*") && strstr(client->pers.netname, "*/"))) { + return; + } } + // + // Added in OPM + //============= + // Print the dm message to console + sToken = ""; + + for (i = 2; i <= ev->NumArgs(); i++) { + if (i != 2) { + sToken += " "; + } + + sToken += ev->GetString(i); + } + //============= + if (iMode == 0) { // - // team message + // everyone // + + // Added in OPM + if (bInstaMessage) { + gi.Printf( + "%s (%zu) says (voice) to everyone: %s\n", client->pers.netname, edict - g_entities, pTmpInstantMsg + ); + } else { + gi.Printf( + "%s (%zu) says (text) to everyone: %s\n", client->pers.netname, edict - g_entities, sToken.c_str() + ); + } + if (!IsSpectator() || g_spectate_allow_full_chat->integer) { for (i = 0; i < game.maxclients; i++) { ent = &g_entities[i]; @@ -10548,10 +10929,27 @@ void Player::EventDMMessage(Event *ev) gi.SendServerCommand(i, "%s", szPrintString); } } + + if (!bInstaMessage) { + Event event; + // sent to everyone (not a team) + event.AddString(sToken); + event.AddInteger(false); + + scriptDelegate_textMessage.Trigger(this, event); + } } else if (iMode < 0) { // // team message // + + // Added in OPM + if (bInstaMessage) { + gi.Printf("%s (%zu) says (voice) to team: %s\n", client->pers.netname, edict - g_entities, pTmpInstantMsg); + } else { + gi.Printf("%s (%zu) says (text) to team: %s\n", client->pers.netname, edict - g_entities, sToken.c_str()); + } + if (IsSpectator()) { for (i = 0; i < game.maxclients; i++) { ent = &g_entities[i]; @@ -10568,41 +10966,41 @@ void Player::EventDMMessage(Event *ev) } } else { for (i = 0; i < game.maxclients; i++) { + bool bSameTeam; + ent = &g_entities[i]; if (!ent->inuse || !ent->entity) { continue; } - if (static_cast(ent->entity)->GetTeam() != GetTeam()) { - gi.MSG_SetClient(i); - gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_VOICE_CHAT)); - gi.MSG_WriteCoord(m_vViewPos[0]); - gi.MSG_WriteCoord(m_vViewPos[1]); - gi.MSG_WriteCoord(m_vViewPos[2]); - gi.MSG_WriteBits(qtrue, 1); - gi.MSG_WriteBits(edict - g_entities, 6); - gi.MSG_WriteString(sAliasName.c_str()); - gi.MSG_EndCGM(); - - continue; + bSameTeam = static_cast(ent->entity)->GetTeam() == GetTeam(); + if (bSameTeam) { + gi.SendServerCommand(i, "%s", szPrintString); } - gi.SendServerCommand(i, "%s", szPrintString); - if (bInstaMessage) { gi.MSG_SetClient(i); gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_VOICE_CHAT)); gi.MSG_WriteCoord(m_vViewPos[0]); gi.MSG_WriteCoord(m_vViewPos[1]); gi.MSG_WriteCoord(m_vViewPos[2]); - gi.MSG_WriteBits(qfalse, 1); + gi.MSG_WriteBits(!bSameTeam, 1); gi.MSG_WriteBits(edict - g_entities, 6); gi.MSG_WriteString(sAliasName.c_str()); gi.MSG_EndCGM(); } } } + + if (!bInstaMessage) { + Event event; + // sent to team + event.AddString(sToken); + event.AddInteger(true); + + scriptDelegate_textMessage.Trigger(this, event); + } } else if (iMode <= game.maxclients) { ent = &g_entities[iMode - 1]; @@ -10620,6 +11018,25 @@ void Player::EventDMMessage(Event *ev) return; } + // Added in OPM + if (bInstaMessage) { + gi.Printf( + "%s (%zu) says (voice) to client #%d: %s\n", + client->pers.netname, + edict - g_entities, + iMode - 1, + pTmpInstantMsg + ); + } else { + gi.Printf( + "%s (%zu) says (text) to client #%d: %s\n", + client->pers.netname, + edict - g_entities, + iMode - 1, + sToken.c_str() + ); + } + gi.SendServerCommand(iMode - 1, "%s", szPrintString); if (ent->entity != this) { @@ -10663,7 +11080,7 @@ str Player::GetBattleLanguageCondition() const case 0: return "almost dead"; case 1: - return "severly wounded"; + return "severely wounded"; case 2: return "wounded"; case 3: @@ -10735,7 +11152,7 @@ str Player::GetBattleLanguageLocalFolks() break; } - strcpy(p, ", "); + Q_strncpyz(p, ", ", sizeof(buf) - (p - buf)); p += 2; curP = p; remaining -= 2; @@ -10746,7 +11163,7 @@ str Player::GetBattleLanguageLocalFolks() break; } - strcpy(p, client->pers.netname); + Q_strncpyz(p, client->pers.netname, sizeof(buf) - (p - buf)); p += length; remaining -= length; pFolk = pPlayer; @@ -10754,8 +11171,8 @@ str Player::GetBattleLanguageLocalFolks() } if (curP && remaining >= 2) { - strcpy(curP, "and "); - strcpy(curP + strlen(curP), pFolk->client->pers.netname); + Q_strncpyz(curP, "and ", sizeof(buf) - (curP - buf)); + Q_strncpyz(curP + strlen(curP), pFolk->client->pers.netname, sizeof(buf) - (curP + strlen(curP) - buf)); } else if (!pFolk) { return "nobody"; } @@ -10888,7 +11305,7 @@ str Player::TranslateBattleLanguageTokens(const char *string) } if (!string) { - return NULL; + return str(); } if (string[0] != '$') { @@ -10939,9 +11356,13 @@ void Player::EventIPrint(Event *ev) } if (iBold) { - gi.SendServerCommand(edict - g_entities, "print \"" HUD_MESSAGE_WHITE "%s\n\"", sString.c_str()); + gi.SendServerCommand( + edict - g_entities, "print \"" HUD_MESSAGE_WHITE "%s\n\"", gi.LV_ConvertString(sString.c_str()) + ); } else { - gi.SendServerCommand(edict - g_entities, "print \"" HUD_MESSAGE_YELLOW "%s\n\"", sString.c_str()); + gi.SendServerCommand( + edict - g_entities, "print \"" HUD_MESSAGE_YELLOW "%s\n\"", gi.LV_ConvertString(sString.c_str()) + ); } } @@ -11167,7 +11588,6 @@ void Player::EventSetPerferredWeapon(Event *ev) } void Player::SetMouthAngle(Event *ev) - { int tag_num; float angle_percent; @@ -11200,6 +11620,59 @@ int Player::GetMoveResult(void) return moveresult; } +qboolean Player::CheckCanSwitchTeam(teamtype_t team) +{ + float startTime; + + startTime = dmManager.GetMatchStartTime(); + + if (startTime >= 0.0f && (level.time - startTime) > 30.0 + && (level.time - m_fTeamSelectTime) < g_teamswitchdelay->integer) { + int seconds = g_teamswitchdelay->integer - (level.time - m_fTeamSelectTime); + + gi.SendServerCommand( + edict - g_entities, + "print \"" HUD_MESSAGE_WHITE "%s %i %s\n\"", + gi.LV_ConvertString("Can not change teams again for another"), + seconds + 1, + gi.LV_ConvertString("seconds") + ); + return qfalse; + } + + // Added in OPM + // Check and prevent joining the team with the highest number of players + if (g_teambalance->integer && g_gametype->integer >= GT_TEAM && !dmManager.WaitingForPlayers()) { + DM_Team *pNewTeam = dmManager.GetTeam(team); + int i; + + for (i = 0; i < 2; i++) { + DM_Team *pTeam = dmManager.GetTeam((teamtype_t)(TEAM_ALLIES + i)); + int numTeamPlayers = pTeam->m_players.NumObjects(); + + if (pTeam->m_players.IndexOfObject(this)) { + // Don't count the current player + numTeamPlayers--; + } + + if (pNewTeam->m_players.NumObjects() > numTeamPlayers) { + const char *message = gi.LV_ConvertString( + "That team has enough players. Choose the team that has the lowest number of players." + ); + + gi.SendServerCommand( + edict - g_entities, "print \"" HUD_MESSAGE_WHITE "%s\n\"", gi.LV_ConvertString(message) + ); + + gi.centerprintf(edict, message); + return qfalse; + } + } + } + + return qtrue; +} + qboolean Player::ViewModelAnim(str anim, qboolean force_restart, qboolean bFullAnim) { Unregister(STRING_VIEWMODELANIM_DONE); @@ -11367,6 +11840,13 @@ void Player::FireWeapon(int number, firemode_t mode) return; } + if (G_GetWeaponCommand(last_ucmd.buttons)) { + // Added in OPM + // If there is a weapon command (like DROP), then just don't fire + // this prevent tricky behaviors, like silent firing + return; + } + Sentient::FireWeapon(number, mode); if (g_gametype->integer != GT_SINGLE_PLAYER) { @@ -11541,9 +12021,9 @@ void Player::UserSelectWeapon(bool bWait) } if (bWait) { - strcpy(buf, "stufftext \"wait 250;pushmenu "); + Q_strncpyz(buf, "stufftext \"wait 250;pushmenu ", sizeof(buf)); } else { - strcpy(buf, "stufftext \"pushmenu "); + Q_strncpyz(buf, "stufftext \"pushmenu ", sizeof(buf)); } if (dmflags->integer & DF_WEAPON_NO_RIFLE && dmflags->integer & DF_WEAPON_NO_SNIPER @@ -11552,24 +12032,24 @@ void Player::UserSelectWeapon(bool bWait) && dmflags->integer & DF_WEAPON_NO_LANDMINE && !QueryLandminesAllowed()) { gi.cvar_set("dmflags", va("%i", dmflags->integer & ~DF_WEAPON_NO_RIFLE)); Com_Printf("No valid weapons -- re-allowing the rifle\n"); - strcpy(client->pers.dm_primary, "rifle"); + Q_strncpyz(client->pers.dm_primary, "rifle", sizeof(client->pers.dm_primary)); } switch (nationality) { case NA_BRITISH: - strcat(buf, "SelectPrimaryWeapon_british\""); + Q_strcat(buf, sizeof(buf), "SelectPrimaryWeapon_british\""); break; case NA_RUSSIAN: - strcat(buf, "SelectPrimaryWeapon_russian\""); + Q_strcat(buf, sizeof(buf), "SelectPrimaryWeapon_russian\""); break; case NA_GERMAN: - strcat(buf, "SelectPrimaryWeapon_german\""); + Q_strcat(buf, sizeof(buf), "SelectPrimaryWeapon_german\""); break; case NA_ITALIAN: - strcat(buf, "SelectPrimaryWeapon_italian\""); + Q_strcat(buf, sizeof(buf), "SelectPrimaryWeapon_italian\""); break; default: - strcat(buf, "SelectPrimaryWeapon\""); + Q_strcat(buf, sizeof(buf), "SelectPrimaryWeapon\""); break; } @@ -11664,51 +12144,160 @@ bool Player::IsReady(void) const void Player::Spawned(void) { Event *ev = new Event; - ev->AddEntity(this); + + scriptDelegate_spawned.Trigger(this, *ev); scriptedEvents[SE_SPAWN].Trigger(ev); } -// reborn stuff - -void Player::AddDeaths(Event *ev) +void Player::AddKills(int num) { - AddDeaths(ev->GetInteger(1)); + num_kills += num; +} + +void Player::AddDeaths(int num) +{ + num_deaths += num; +} + +//////////////////////////// +// +// Added in OPM +// +//////////////////////////// + +qboolean Player::canUse() +{ + int touch[MAX_GENTITIES]; + int num = getUseableEntities(touch, MAX_GENTITIES); + + return num ? true : false; +} + +qboolean Player::canUse(Entity *entity, bool requiresLookAt) +{ + gentity_t *hit; + int touch[MAX_GENTITIES]; + int num; + int i; + + num = getUseableEntities(touch, MAX_GENTITIES, requiresLookAt); + + for (i = 0; i < num; i++) { + hit = &g_entities[touch[i]]; + + if (!hit->inuse || hit->entity == NULL) { + continue; + } + + if (hit->entity == entity) { + return true; + } + } + + return false; +} + +int Player::getUseableEntities(int *touch, int maxcount, bool requiresLookAt) +{ + Vector end; + Vector start; + trace_t trace; + Vector offset; + Vector max; + Vector min; + + if ((g_gametype->integer != GT_SINGLE_PLAYER && IsSpectator()) || IsDead()) { + return 0; + } + + if (m_pTurret) { + *touch = m_pTurret->entnum; + return 1; + } + + if (m_pTurret) { + return 0; + } + + AngleVectors(client->ps.viewangles, offset, NULL, NULL); + + start = origin; + start.z += client->ps.viewheight; + + if (requiresLookAt) { + min = Vector(-4.f, -4.f, -4.f); + max = Vector(4.f, 4.f, 4.f); + + end[0] = start[0] + (offset[0] * 64.f); + end[1] = start[1] + (offset[1] * 64.f); + + if (v_angle[0] <= 0.0f) { + end[2] = start[2] + (offset[2] * 40.f); + } else { + end[2] = start[2] + (offset[2] * 88.f); + } + + trace = G_Trace(start, min, max, end, this, MASK_USE, false, "Player::getUseableEntity"); + + offset = trace.endpos; + + min = offset - Vector(16.f, 16.f, 16.f); + max = offset + Vector(16.f, 16.f, 16.f); + } else { + min = start - Vector(31.f, 31.f, 31.f); + max = start + Vector(31.f, 31.f, 31.f); + } + + return gi.AreaEntities(min, max, touch, maxcount); +} + +void Player::Postthink(void) +{ + if (bindmaster) { + SetViewAngles(GetViewAngles() + Vector(0, bindmaster->avelocity[YAW] * level.frametime, 0)); + } } void Player::AdminRights(Event *ev) { // FIXME: Admin manager ? ev->AddInteger(0); + UNIMPLEMENTED(); +} + +void Player::IsAdmin(Event *ev) +{ + // FIXME: Admin manager ? + ev->AddInteger(0); + UNIMPLEMENTED(); } void Player::BindWeap(Event *ev) { - // FIXME: TODO -} + Entity *ent = ev->GetEntity(1); + Listener *scriptOwner; -void Player::CanSwitchTeams(Event *ev) -{ - qboolean bAllow = ev->GetBoolean(1); + // + // FIXME: deprecate and use something else instead + // like implement this in the Item class directly + // this is dangerous to use especially if the weapon + // is a VehicleTurretGun, could easily mess up the camera - disable_team_change = !bAllow; - if (ev->NumArgs() > 1) { - qboolean bAllow2 = ev->GetBoolean(2); + if (ent) { + scriptOwner = ent->GetScriptOwner(); - disable_spectate = !bAllow2; + if (scriptOwner != this) { + ent->SetScriptOwner(this); + } else { + ent->SetScriptOwner(NULL); + } } } -void Player::ClearCommand(Event *ev) +void Player::AddDeaths(Event *ev) { - str command; - int clientNum = G_GetClientNumber(this); - - if (ev->NumArgs() > 0) { - command = ev->GetString(1); - } - - m_lastcommand = ""; + AddDeaths(ev->GetInteger(1)); } void Player::Dive(Event *ev) @@ -11732,39 +12321,6 @@ void Player::Dive(Event *ev) velocity[2] += height * speed / 6.80f; } -void Player::EventEarthquake(Event *ev) -{ - float duration = ev->GetFloat(1); - float magnitude = ev->GetFloat(2); - qboolean no_rampup = ev->GetBoolean(3); - qboolean no_rampdown = ev->GetBoolean(4); - - // full realistic, smooth earthquake - if (ev->NumArgs() > 4) { - Vector location = ev->GetVector(5); - float radius = 1.0f; - - if (ev->NumArgs() > 5) { - radius = ev->GetFloat(6); - } - - gi.SendServerCommand( - edict - g_entities, - "eq %f %f %d %d %f %f %f %f", - duration, - magnitude, - no_rampup, - no_rampdown, - location[0], - location[1], - location[2], - radius - ); - } else { - gi.SendServerCommand(edict - g_entities, "eq %f %f %d %d", duration, magnitude, no_rampup, no_rampdown); - } -} - void Player::EventSetTeam(Event *ev) { str team_name; @@ -11793,7 +12349,7 @@ void Player::EventSetTeam(Event *ev) SetTeam(teamType); - gi.Printf("Player::SetTeam : Player is now on team \"%s\"\n", team_name.c_str()); + gi.DPrintf("Player::SetTeam : Player is now on team \"%s\"\n", team_name.c_str()); } void Player::EventGetViewModelAnim(Event *ev) @@ -11847,7 +12403,13 @@ void Player::FreezeControls(Event *ev) void Player::GetConnState(Event *ev) { - ScriptDeprecated("Player::GetConnState"); + // Assume CS_ACTIVE + ev->AddInteger(4); + + gi.DPrintf( + "getconnstate is deprecated and will always return 4 (CS_ACTIVE).\nThe player is created only when the client " + "begins (CS_ACTIVE state).\n" + ); } void Player::GetDamageMultiplier(Event *ev) @@ -11919,11 +12481,13 @@ void Player::GetTorsoState(Event *ev) void Player::HideEntity(Event *ev) { // FIXME: todo + UNIMPLEMENTED(); } void Player::ShowEntity(Event *ev) { // FIXME: REDO + UNIMPLEMENTED(); } void Player::Inventory(Event *ev) @@ -12002,12 +12566,6 @@ void Player::InventorySet(Event *ev) array.Clear(); } -void Player::IsAdmin(Event *ev) -{ - // FIXME: Admin manager ? - ev->AddInteger(0); -} - void Player::LeanLeftHeld(Event *ev) { Player *player = NULL; @@ -12057,19 +12615,18 @@ void Player::PlayLocalSound(Event *ev) return; } - // FIXME... - /* - gi.MSG_SetClient( client->ps.clientNum ); +#ifdef OPM_FEATURES + gi.MSG_SetClient(client->ps.clientNum); - gi.MSG_StartCGM( CGM_PLAYLOCALSOUND ); - gi.MSG_WriteString( found ); - gi.MSG_WriteBits( !!loop, 1 ); - gi.MSG_WriteFloat( time ); - gi.MSG_WriteFloat( alias->volume ); - gi.MSG_EndCGM(); + gi.MSG_StartCGM(CGM_PLAYLOCALSOUND); + gi.MSG_WriteString(found); + gi.MSG_WriteBits(!!loop, 1); + gi.MSG_WriteFloat(time); + gi.MSG_WriteFloat(alias->volume); + gi.MSG_EndCGM(); - return; - */ + return; +#endif if (loop) { edict->s.loopSound = gi.soundindex(found, alias->streamed); @@ -12118,32 +12675,7 @@ void Player::SetAnimSpeed(Event *ev) speed = 0.0f; } - //player->baseSentient.baseAnimate.baseEntity.client->customanimspeed = speed; -} - -void Player::SetClientFlag(Event *ev) -{ - str name = ev->GetString(1); - - gi.SendServerCommand(client->ps.clientNum, "cf %s", name.c_str()); -} - -void Player::SetEntityShader(Event *ev) -{ - Entity *entity = ev->GetEntity(1); - str shadername = ev->GetString(2); - qboolean fReset = false; - - if (entity == NULL) { - ScriptError("Invalid entity !"); - } - - if (!shadername.length()) { - shadername = "default"; - fReset = true; - } - - gi.SendServerCommand(edict - g_entities, "setshader %d %s %d", entity->entnum, shadername.c_str(), fReset); + UNIMPLEMENTED(); } void Player::SetKillHandler(Event *ev) @@ -12155,38 +12687,6 @@ void Player::SetKillHandler(Event *ev) } } -void Player::SetLocalSoundRate(Event *ev) -{ - str name = ev->GetString(1); - float rate = ev->GetFloat(2); - float time; - - if (ev->NumArgs() > 2) { - time = ev->GetFloat(3); - } else { - time = 0.0f; - } - - AliasListNode_t *alias = NULL; - const char *found = gi.GlobalAlias_FindRandom(name, &alias); - - if (found == NULL) { - gi.DPrintf("ERROR: Player::SetLocalSoundRate: %s needs to be aliased - Please fix.\n", name.c_str()); - return; - } - - gi.MSG_SetClient(client->ps.clientNum); - - // FIXME... - /* - gi.MSG_StartCGM( CGM_SETLOCALSOUNDRATE ); - gi.MSG_WriteString( found ); - gi.MSG_WriteFloat( rate ); - gi.MSG_WriteFloat( time ); - gi.MSG_EndCGM(); - */ -} - void Player::SetSpeed(Event *ev) { float speed; @@ -12237,35 +12737,6 @@ void Player::SetStateFile(Event *ev) } } -void Player::SetVMASpeed(Event *ev) -{ - str name = ev->GetString(1); - float speed = ev->GetFloat(2); - - if (!client || !level.specialgame) { - return; - } - - vma_t *vma = &vmalist[name]; - - if (speed < 0.0f) { - speed = 0.0f; - } - - vma->name = name; - vma->speed = speed; - - // FIXME... - /* - gi.MSG_SetClient( edict - g_entities ); - - gi.MSG_StartCGM( CGM_SETVMASPEED ); - gi.MSG_WriteString( name ); - gi.MSG_WriteFloat( speed ); - gi.MSG_EndCGM(); - */ -} - void Player::StopLocalSound(Event *ev) { str soundName = ev->GetString(1); @@ -12299,6 +12770,137 @@ void Player::Userinfo(Event *ev) ev->AddString(client->pers.userinfo); } +int Player::GetNumKills(void) const +{ + return num_kills; +} + +int Player::GetNumDeaths(void) const +{ + return num_deaths; +} + +#ifdef OPM_FEATURES + +void Player::EventEarthquake(Event *ev) +{ + float duration = ev->GetFloat(1); + float magnitude = ev->GetFloat(2); + qboolean no_rampup = ev->GetBoolean(3); + qboolean no_rampdown = ev->GetBoolean(4); + + // full realistic, smooth earthquake + if (ev->NumArgs() > 4) { + Vector location = ev->GetVector(5); + float radius = 1.0f; + + if (ev->NumArgs() > 5) { + radius = ev->GetFloat(6); + } + + gi.SendServerCommand( + edict - g_entities, + "eq %f %f %d %d %f %f %f %f", + duration, + magnitude, + no_rampup, + no_rampdown, + location[0], + location[1], + location[2], + radius + ); + } else { + gi.SendServerCommand(edict - g_entities, "eq %f %f %d %d", duration, magnitude, no_rampup, no_rampdown); + } +} + +void Player::SetClientFlag(Event *ev) +{ + str name = ev->GetString(1); + + gi.SendServerCommand(client->ps.clientNum, "cf %s", name.c_str()); +} + +void Player::SetEntityShader(Event *ev) +{ + Entity *entity = ev->GetEntity(1); + str shadername = ev->GetString(2); + qboolean fReset = false; + + if (entity == NULL) { + ScriptError("Invalid entity !"); + } + + if (!shadername.length()) { + shadername = "default"; + fReset = true; + } + + gi.SendServerCommand(edict - g_entities, "setshader %d %s %d", entity->entnum, shadername.c_str(), fReset); +} + +void Player::SetLocalSoundRate(Event *ev) +{ + str name = ev->GetString(1); + float rate = ev->GetFloat(2); + float time; + + if (ev->NumArgs() > 2) { + time = ev->GetFloat(3); + } else { + time = 0.0f; + } + + AliasListNode_t *alias = NULL; + const char *found = gi.GlobalAlias_FindRandom(name, &alias); + + if (found == NULL) { + gi.DPrintf("ERROR: Player::SetLocalSoundRate: %s needs to be aliased - Please fix.\n", name.c_str()); + return; + } + + gi.MSG_SetClient(client->ps.clientNum); + + // FIXME... + /* + gi.MSG_StartCGM( CGM_SETLOCALSOUNDRATE ); + gi.MSG_WriteString( found ); + gi.MSG_WriteFloat( rate ); + gi.MSG_WriteFloat( time ); + gi.MSG_EndCGM(); + */ +} + +void Player::SetVMASpeed(Event *ev) +{ + str name = ev->GetString(1); + float speed = ev->GetFloat(2); + + if (!client || !sv_specialgame->integer) { + return; + } + + vma_t *vma = &vmalist[name]; + + if (speed < 0.0f) { + speed = 0.0f; + } + + vma->name = name; + vma->speed = speed; + + // FIXME... + /* + gi.MSG_SetClient( edict - g_entities ); + + gi.MSG_StartCGM( CGM_SETVMASPEED ); + gi.MSG_WriteString( name ); + gi.MSG_WriteFloat( speed ); + gi.MSG_EndCGM(); + */ +} + void Player::VisionGetNaked(Event *ev) { // return the global vision @@ -12353,120 +12955,4 @@ void Player::VisionSetNaked(Event *ev) gi.SendServerCommand(edict - g_entities, "vsn %s %f %f", vision.c_str(), fade_time, phase); } - -int Player::GetNumKills(void) const -{ - return num_kills; -} - -int Player::GetNumDeaths(void) const -{ - return num_deaths; -} - -void Player::AddKills(int num) -{ - num_kills += num; - - if (g_gametype->integer >= GT_TEAM_ROUNDS) { - num_deaths += num; - } -} - -void Player::AddDeaths(int num) -{ - num_deaths += num; -} - -qboolean Player::canUse() -{ - int touch[MAX_GENTITIES]; - int num = getUseableEntities(touch, MAX_GENTITIES); - - return num ? true : false; -} - -qboolean Player::canUse(Entity *entity, bool requiresLookAt) -{ - gentity_t *hit; - int touch[MAX_GENTITIES]; - int num; - int i; - - num = getUseableEntities(touch, MAX_GENTITIES, requiresLookAt); - - for (i = 0; i < num; i++) { - hit = &g_entities[touch[i]]; - - if (!hit->inuse || hit->entity == NULL) { - continue; - } - - if (hit->entity == entity) { - return true; - } - } - - return false; -} - -int Player::getUseableEntities(int *touch, int maxcount, bool requiresLookAt) -{ - Vector end; - Vector start; - trace_t trace; - Vector offset; - Vector max; - Vector min; - - if ((g_gametype->integer != GT_SINGLE_PLAYER && IsSpectator()) || IsDead()) { - return 0; - } - - if (m_pTurret) { - *touch = m_pTurret->entnum; - return 1; - } - - if (m_pTurret) { - return 0; - } - - AngleVectors(client->ps.viewangles, offset, NULL, NULL); - - start = origin; - start.z += client->ps.viewheight; - - if (requiresLookAt) { - min = Vector(-4.f, -4.f, -4.f); - max = Vector(4.f, 4.f, 4.f); - - end[0] = start[0] + (offset[0] * 64.f); - end[1] = start[1] + (offset[1] * 64.f); - - if (v_angle[0] <= 0.0f) { - end[2] = start[2] + (offset[2] * 40.f); - } else { - end[2] = start[2] + (offset[2] * 88.f); - } - - trace = G_Trace(start, min, max, end, this, MASK_SOLID, false, "Player::getUseableEntity"); - - offset = trace.endpos; - - min = offset - Vector(16.f, 16.f, 16.f); - max = offset + Vector(16.f, 16.f, 16.f); - } else { - min = start - Vector(31.f, 31.f, 31.f); - max = start + Vector(31.f, 31.f, 31.f); - } - - return gi.AreaEntities(min, max, touch, maxcount); -} - -void Player::Postthink(void) -{ - if (bindmaster) { - SetViewAngles(GetViewAngles() + Vector(0, bindmaster->avelocity[YAW] * level.frametime, 0)); - } -} +#endif diff --git a/code/fgame/player.h b/code/fgame/player.h index 03501e3c..93a7986b 100644 --- a/code/fgame/player.h +++ b/code/fgame/player.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -37,6 +37,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "actor.h" #include "vehicle.h" #include "dm_manager.h" +#include "scriptdelegate.h" extern Event EV_Player_EndLevel; extern Event EV_Player_GiveCheat; @@ -68,7 +69,8 @@ enum painDirection_t { }; typedef enum { - ANIMSLOT_PAIN = 4 + ANIMSLOT_PAIN = 4, + ANIMSLOT_TESTANIM = 7 } playerAnimSlot_t; typedef enum { @@ -129,7 +131,7 @@ class Player : public Sentient friend class VehicleTurretGun; private: - static Condition Conditions[]; + static Condition m_conditions[]; static movecontrolfunc_t MoveStartFuncs[]; StateMap *statemap_Legs; @@ -305,7 +307,19 @@ private: bool m_bDeathSpectator; jailstate_t m_jailstate; +#ifdef OPM_FEATURES bool m_bShowingHint; +#endif + +public: + MulticastDelegate delegate_stufftext; + + static ScriptDelegate scriptDelegate_connected; + static ScriptDelegate scriptDelegate_disconnecting; + static ScriptDelegate scriptDelegate_spawned; + static ScriptDelegate scriptDelegate_damage; + static ScriptDelegate scriptDelegate_kill; + static ScriptDelegate scriptDelegate_textMessage; public: int m_iNumObjectives; @@ -342,12 +356,12 @@ public: bool m_bWaitingForRespawn; bool m_bShouldRespawn; - // new variables + // + // Added in OPM + // str m_sVision; // current vision str m_sStateFile; // custom statefile - bool disable_spectate; - bool disable_team_change; - bool m_bFrozen; // if player is frozen + bool m_bFrozen; // if player is frozen bool animDoneVM; float speed_multiplier[MAX_SPEED_MULTIPLIERS]; ScriptThreadLabel m_killedLabel; @@ -359,6 +373,10 @@ public: bool m_bConnected; str m_lastcommand; +private: + int m_iInstantMessageTime; + int m_iTextChatTime; + public: qboolean CondTrue(Conditional& condition); qboolean CondChance(Conditional& condition); @@ -539,7 +557,7 @@ public: void DoUse(Event *ev); void Obituary(Entity *attacker, Entity *inflictor, int meansofdeath, int iLocation); - void Killed(Event *ev); + void Killed(Event *ev) override; void Dead(Event *ev); void Pain(Event *ev); @@ -800,7 +818,7 @@ public: void SetPlayerSpectate(bool bNext); void SetPlayerSpectateRandom(void); // Added in 2.0 bool IsValidSpectatePlayer(Player *pPlayer); - void GetSpectateFollowOrientation(Player *pPlayer, Vector &vPos, Vector &vAng); + void GetSpectateFollowOrientation(Player *pPlayer, Vector& vPos, Vector& vAng); void UpdateStatus(const char *s); void SetDM_Team(DM_Team *team); DM_Team *GetDM_Team(); @@ -843,7 +861,7 @@ public: void EventDMDeathDrop(Event *ev); void EventStopwatch(Event *ev); - void KilledPlayerInDeathmatch(Player *killed); + void KilledPlayerInDeathmatch(Player *killed, meansOfDeath_t meansofdeath); void SetStopwatch(int iDuration, stopWatchType_t type = SWT_NORMAL); void BeginTempSpectator(void); void EndSpectator(void); @@ -906,19 +924,18 @@ public: bool HasVotedNo() const; //============================= - // Custom openmohaa stuff + // Added in OPM //============================= + qboolean CheckCanSwitchTeam(teamtype_t team); + qboolean ViewModelAnim(str anim, qboolean force_restart, qboolean bFullAnim); virtual void Spawned(void); void AddDeaths(Event *ev); void AdminRights(Event *ev); void BindWeap(Event *ev); - void CanSwitchTeams(Event *ev); - void ClearCommand(Event *ev); void Dive(Event *ev); - void EventEarthquake(Event *ev); void EventSetTeam(Event *ev); void EventGetViewModelAnim(Event *ev); void EventGetViewModelAnimFinished(Event *ev); @@ -933,7 +950,6 @@ public: void GetLegsState(Event *ev); void GetStateFile(Event *ev); void GetTorsoState(Event *ev); - void HideEntity(Event *ev); void Inventory(Event *ev); void InventorySet(Event *ev); void IsAdmin(Event *ev); @@ -945,19 +961,23 @@ public: void RunHeld(Event *ev); void SecFireHeld(Event *ev); void SetAnimSpeed(Event *ev); - void SetClientFlag(Event *ev); - void SetEntityShader(Event *ev); void SetKillHandler(Event *ev); - void SetLocalSoundRate(Event *ev); void SetSpeed(Event *ev); void SetStateFile(Event *ev); - void SetVMASpeed(Event *ev); + void HideEntity(Event *ev); void ShowEntity(Event *ev); void StopLocalSound(Event *ev); void Userinfo(Event *ev); +#ifdef OPM_FEATURES + void EventEarthquake(Event *ev); + void SetClientFlag(Event *ev); + void SetEntityShader(Event *ev); + void SetLocalSoundRate(Event *ev); + void SetVMASpeed(Event *ev); void VisionGetNaked(Event *ev); void VisionSetBlur(Event *ev); void VisionSetNaked(Event *ev); +#endif void Postthink() override; void GibEvent(Event *ev); @@ -978,7 +998,7 @@ inline void Player::Archive(Archiver& arc) arc.ArchiveFloat(&m_fPartBlends[0]); arc.ArchiveFloat(&m_fPartBlends[1]); arc.ArchiveFloat(&partBlendMult[0]); - arc.ArchiveFloat(&partBlendMult[0]); + arc.ArchiveFloat(&partBlendMult[1]); arc.ArchiveString(&last_torso_anim_name); arc.ArchiveString(&last_leg_anim_name); @@ -1123,12 +1143,20 @@ inline void Player::Archive(Archiver& arc) arc.ArchiveInteger(&m_iNumLeftArmShots); arc.ArchiveInteger(&m_iNumRightArmShots); + // Added in 2.30 + //==== + ArchiveEnum(m_jailstate, jailstate_t); + arc.ArchiveString(&m_sDmPrimary); + arc.ArchiveBool(&m_bIsInJail); + //==== + arc.ArchiveFloat(&m_fLastDeltaTime); - // make sure we have the state machine loaded up - if (arc.Loading()) { - LoadStateTable(); - } + // Added in 2.0 + //==== + arc.ArchiveFloat(&m_fLastSprintTime); + arc.ArchiveBool(&m_bHasJumped); + //==== if (arc.Saving()) { if (currentState_Legs) { @@ -1145,6 +1173,13 @@ inline void Player::Archive(Archiver& arc) } arc.ArchiveString(&tempStr); } else { + statemap_Legs = GetStatemap( + str(g_statefile->string) + "_Legs.st", (Condition *)m_conditions, &legs_conditionals, false + ); + statemap_Torso = GetStatemap( + str(g_statefile->string) + "_Torso.st", (Condition *)m_conditions, &torso_conditionals, false + ); + arc.ArchiveString(&tempStr); if (tempStr != "NULL") { currentState_Legs = statemap_Legs->FindState(tempStr); @@ -1157,10 +1192,31 @@ inline void Player::Archive(Archiver& arc) } else { currentState_Torso = NULL; } + + for (int i = 1; i <= legs_conditionals.NumObjects(); i++) { + Conditional *c = legs_conditionals.ObjectAt(i); + + if (Q_stricmp(c->getName(), "PAIN") && !c->parmList.NumObjects()) { + m_pLegsPainCond = c; + break; + } + } + + for (int i = 1; i <= torso_conditionals.NumObjects(); i++) { + Conditional *c = torso_conditionals.ObjectAt(i); + + if (Q_stricmp(c->getName(), "PAIN") && !c->parmList.NumObjects()) { + m_pTorsoPainCond = c; + break; + } + } } if (arc.Loading()) { UpdateWeapons(); + SetViewAngles(v_angle); + + // Added in OPM InitModelFps(); } diff --git a/code/fgame/player_animation.cpp b/code/fgame/player_animation.cpp index a8098fe1..2f46c15e 100644 --- a/code/fgame/player_animation.cpp +++ b/code/fgame/player_animation.cpp @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -61,13 +61,17 @@ void Player::SetPartAnim(const char *anim, bodypart_t slot) { int animnum; - if (getMoveType() == MOVETYPE_NOCLIP && slot) { - StopPartAnimating(torso); - return; + if (getMoveType() == MOVETYPE_NOCLIP) { + if (slot) { + StopPartAnimating(torso); + return; + } + + anim = "idle"; } animnum = gi.Anim_NumForName(edict->tiki, anim); - if (animnum == CurrentAnim() && partAnim[slot] == anim) { + if (animnum == CurrentAnim(m_iPartSlot[slot]) && partAnim[slot] == anim) { return; } @@ -89,21 +93,19 @@ void Player::SetPartAnim(const char *anim, bodypart_t slot) if (m_fPartBlends[slot] < 0.5f) { SetAnimDoneEvent(NULL, m_iPartSlot[slot]); - float m_fCrossTime = gi.Anim_CrossTime(edict->tiki, animnum); - - partBlendMult[slot] = m_fCrossTime; - if (m_fCrossTime <= 0.0f) { - partOldAnim[slot] = ""; - m_fPartBlends[slot] = 0.0f; - } else { + partBlendMult[slot] = gi.Anim_CrossTime(edict->tiki, animnum); + if (partBlendMult[slot] > 0.0f) { m_iPartSlot[slot] ^= 1; - partBlendMult[slot] = 1.0f / m_fCrossTime; + partBlendMult[slot] = 1.0f / partBlendMult[slot]; partOldAnim[slot] = partAnim[slot]; m_fPartBlends[slot] = 1.0f; + } else { + partOldAnim[slot] = ""; + m_fPartBlends[slot] = 0.0f; } } - if (slot) { + if (slot != legs) { animdone_Torso = false; } else { animdone_Legs = false; @@ -113,7 +115,7 @@ void Player::SetPartAnim(const char *anim, bodypart_t slot) partAnim[slot] = anim; - if (slot) { + if (slot != legs) { NewAnim(animnum, EV_Player_AnimLoop_Torso, m_iPartSlot[slot]); } else { NewAnim(animnum, EV_Player_AnimLoop_Legs, m_iPartSlot[legs]); @@ -143,7 +145,7 @@ void Player::StopPartAnimating(bodypart_t part) StopAnimating(m_iPartSlot[part]); - if (part) { + if (part != legs) { animdone_Torso = false; } else { animdone_Legs = false; @@ -158,7 +160,7 @@ void Player::PausePartAnim(bodypart_t part) int Player::CurrentPartAnim(bodypart_t part) const { - if (!*partAnim[part]) { + if (partAnim[part] == "") { return -1; } @@ -345,18 +347,12 @@ void Player::AdjustAnimBlends(void) if (m_fPartBlends[legs] <= 0.0f) { if (partOldAnim[legs] != "") { StopAnimating(iOldPartSlot); + } - if (partAnim[legs] == "") { - SetWeight(iPartSlot, 0.0); - } else { - SetWeight(iPartSlot, 1.0); - } + if (partAnim[legs] == "") { + SetWeight(iPartSlot, 0.0); } else { - if (partAnim[legs] == "") { - SetWeight(iPartSlot, 0.0); - } else { - SetWeight(iPartSlot, 1.0); - } + SetWeight(iPartSlot, 1.0); } } else { m_fPartBlends[legs] -= level.frametime * partBlendMult[legs]; @@ -387,12 +383,14 @@ void Player::AdjustAnimBlends(void) if (partOldAnim[torso] != "") { StopAnimating(iOldPartSlot); partOldAnim[torso] = ""; + } - if (partAnim[torso] == "") { - SetWeight(iPartSlot, 0.0); - } else { - SetWeight(iPartSlot, 1.0); - } + if (partAnim[torso] == "") { + SetWeight(iPartSlot, 0.0); + edict->s.actionWeight = 0.0; + } else { + SetWeight(iPartSlot, 1.0); + edict->s.actionWeight = 1.0; } } else { m_fPartBlends[torso] = m_fPartBlends[torso] - level.frametime * partBlendMult[torso]; @@ -404,8 +402,8 @@ void Player::AdjustAnimBlends(void) fWeightTotal += m_fPartBlends[torso]; } if (partAnim[torso] != "") { - SetWeight(iPartSlot, m_fPartBlends[torso]); - fWeightTotal += 1.0f - m_fPartBlends[torso]; + SetWeight(iPartSlot, 1.0 - m_fPartBlends[torso]); + fWeightTotal += 1.0 - m_fPartBlends[torso]; } edict->s.actionWeight = fWeightTotal; @@ -427,16 +425,16 @@ void Player::AdjustAnimBlends(void) if (m_fPainBlend) { if (m_sPainAnim == "") { StopAnimating(ANIMSLOT_PAIN); - edict->s.frameInfo[ANIMSLOT_PAIN].weight = 0; - m_fPainBlend = 0; - animdone_Pain = false; + SetWeight(ANIMSLOT_PAIN, 0); + m_fPainBlend = 0; + animdone_Pain = false; } else if (animdone_Pain) { m_fPainBlend -= level.frametime * (10.0 / 3.0); if (m_fPainBlend < 0.01f) { StopAnimating(ANIMSLOT_PAIN); - edict->s.frameInfo[ANIMSLOT_PAIN].weight = 0; - m_fPainBlend = 0; - animdone_Pain = false; + SetWeight(ANIMSLOT_PAIN, 0); + m_fPainBlend = 0; + animdone_Pain = false; } } @@ -444,12 +442,12 @@ void Player::AdjustAnimBlends(void) int i; float w; - edict->s.frameInfo[ANIMSLOT_PAIN].weight = m_fPainBlend; - w = 1.0 - m_fPainBlend * 0.5; + SetWeight(ANIMSLOT_PAIN, m_fPainBlend); + w = 1.0 - m_fPainBlend * 0.5; for (i = 0; i < ANIMSLOT_PAIN; i++) { - if (edict->s.frameInfo[i].weight) { - edict->s.frameInfo[i].weight *= w; + if (GetWeight(i)) { + SetWeight(i, GetWeight(i) * w); } } @@ -490,7 +488,7 @@ void Player::PlayerAnimDelta(float *vDelta) // get the anim delta gi.Anim_DeltaOverTime(edict->tiki, animnum, fBackTime, fTime, vNewDelta); - VectorMA(vDelta, edict->s.frameInfo[m_iPartSlot[legs]].weight, vNewDelta, vDelta); + VectorMA(vDelta, GetWeight(m_iPartSlot[legs]), vNewDelta, vDelta); } animnum = -1; @@ -509,11 +507,34 @@ void Player::PlayerAnimDelta(float *vDelta) gi.Anim_DeltaOverTime(edict->tiki, animnum, fBackTime, fTime, vNewDelta); - VectorMA(vDelta, edict->s.frameInfo[m_iPartSlot[torso]].weight, vNewDelta, vDelta); + VectorMA(vDelta, GetWeight(m_iPartSlot[torso]), vNewDelta, vDelta); } } void Player::EventTestAnim(Event *ev) { - // FIXME: unimplemented + str name; + float weight; + int animNum; + + weight = ev->GetFloat(1); + if (weight <= 0) { + SetWeight(ANIMSLOT_TESTANIM, 0); + StopAnimating(ANIMSLOT_TESTANIM); + return; + } + + if (ev->NumArgs() > 1) { + name = ev->GetString(1); + animNum = gi.Anim_NumForName(edict->tiki, name.c_str()); + if (animNum == -1) { + gi.Printf("Couldn't find anim '%s'\n", name.c_str()); + return; + } + + NewAnim(animNum, ANIMSLOT_TESTANIM, weight); + RestartAnimSlot(ANIMSLOT_TESTANIM); + } + + SetWeight(ANIMSLOT_TESTANIM, weight); } diff --git a/code/fgame/player_conditionals.cpp b/code/fgame/player_conditionals.cpp index c0b59831..ef2af238 100644 --- a/code/fgame/player_conditionals.cpp +++ b/code/fgame/player_conditionals.cpp @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -63,7 +63,6 @@ qboolean Player::CondTrue(Conditional& condition) } qboolean Player::CondChance(Conditional& condition) - { float percent_chance; @@ -73,7 +72,6 @@ qboolean Player::CondChance(Conditional& condition) } qboolean Player::CondHealth(Conditional& condition) - { return health < atoi(condition.getParm(1)); } @@ -96,9 +94,8 @@ qboolean Player::CondBlocked(Conditional& condition) } qboolean Player::CondPain(Conditional& condition) - { - return (pain != 0 || knockdown != 0); + return pain != 0 && level.time > nextpaintime; } qboolean Player::CondOnGround(Conditional& condition) @@ -112,13 +109,11 @@ qboolean Player::CondOnGround(Conditional& condition) } qboolean Player::CondHasWeapon(Conditional& condition) - { return WeaponsOut(); } qboolean Player::CondNewWeapon(Conditional& condition) - { Weapon *weapon; @@ -144,7 +139,6 @@ qboolean Player::CondImmediateSwitch(Conditional& condition) // Check to see if a weapon has been raised qboolean Player::CondUseWeapon(Conditional& condition) - { const char *weaponName; const char *parm; @@ -367,7 +361,7 @@ qboolean Player::CondVehicleType(Conditional& condition) { str sType = condition.getParm(1); if (m_pVehicle && m_pVehicle->IsSubclassOfVehicle()) { - return !str::cmp(sType, "vehicle"); + return !str::cmp(sType, m_pVehicle->getName()); } else { return !str::cmp(sType, "none"); } @@ -439,7 +433,90 @@ qboolean Player::CondNearLandmine(Conditional& condition) void Player::MeasureLandmineDistances() { - // FIXME: unimplemented + Weapon* weapon; + float previousMineDist; + float maxrange; + int i; + + if (m_fMineCheckTime == level.time) { + return; + } + m_fMineCheckTime = level.time; + previousMineDist = m_fMineDist; + m_fMineDist = 1000; + + weapon = GetActiveWeapon(WEAPON_MAIN); + if (!weapon) { + weapon = GetActiveWeapon(WEAPON_OFFHAND); + } + + maxrange = 40; + if (weapon) { + maxrange = weapon->GetMaxRange(); + } + + for (i = 0; i < globals.max_entities; i++) { + TriggerLandmine* landmine; + Entity* ent; + vec3_t forward; + Vector delta; + float radius; + + ent = G_GetEntity(i); + if (!ent) { + continue; + } + + if (!ent->isSubclassOf(TriggerLandmine)) { + continue; + } + + landmine = static_cast(ent); + // This could be from an allied player + if (landmine->IsImmune(this)) { + continue; + } + + AngleVectorsLeft(angles, forward, NULL, NULL); + delta = landmine->origin - origin; + radius = delta.length(); + + if (radius < maxrange) { + ent->PostEvent(EV_Show, level.frametime); + } + + if (radius > m_fMineDist) { + continue; + } + + if (radius >= 40) { + float dot; + + delta.normalize(); + + dot = DotProduct(delta, forward); + if (dot > 0 && radius / Square(dot) < m_fMineDist) { + m_fMineDist = radius / Square(dot); + } + } else if (radius < m_fMineDist) { + m_fMineDist = radius; + } + } + + m_fMineDist /= maxrange; + + if (m_fMineDist > 3) { + StopLoopSound(); + return; + } + + if (floorf(previousMineDist * 20) != floorf(m_fMineDist * 20)) { + float pitch; + + pitch = 2.f - log(m_fMineDist + 1.0); + + LoopSound("minedetector_on", -1, -1, -1, pitch); + } } qboolean Player::CondIsAssistingEscape(Conditional& condition) @@ -507,7 +584,6 @@ qboolean Player::CondPutAwayMain(Conditional& condition) // Check to see if any of the active weapons need to be put away qboolean Player::CondPutAwayOffHand(Conditional& condition) - { Weapon *weapon = GetActiveWeapon(WEAPON_OFFHAND); @@ -516,7 +592,6 @@ qboolean Player::CondPutAwayOffHand(Conditional& condition) // Checks to see if any weapon is active in the specified hand qboolean Player::CondAnyWeaponActive(Conditional& condition) - { weaponhand_t hand; Weapon *weap; @@ -532,7 +607,6 @@ qboolean Player::CondAnyWeaponActive(Conditional& condition) } qboolean Player::CondAttackBlocked(Conditional& condition) - { if (attack_blocked) { attack_blocked = qfalse; @@ -618,14 +692,12 @@ qboolean Player::CondMaxChargeTime(Conditional& condition) } qboolean Player::CondBlockDelay(Conditional& condition) - { float t = atof(condition.getParm(1)); return (level.time > (attack_blocked_time + t)); } qboolean Player::CondMuzzleClear(Conditional& condition) - { weaponhand_t hand; @@ -641,7 +713,6 @@ qboolean Player::CondMuzzleClear(Conditional& condition) // Checks to see if any weapon is active in the specified hand qboolean Player::CondWeaponHasAmmo(Conditional& condition) - { weaponhand_t hand; Weapon *weap; @@ -779,24 +850,36 @@ qboolean Player::CondStrafeLeft(Conditional& condition) } qboolean Player::CondStrafeRight(Conditional& condition) - { return last_ucmd.rightmove > 0; } qboolean Player::CondJump(Conditional& condition) - { + if (client->ps.pm_flags & PMF_NO_MOVE) { + return false; + } + return last_ucmd.upmove > 0; } qboolean Player::CondCrouch(Conditional& condition) { + // Added in 2.0 + // Don't crouch if the player is not moving + if (client->ps.pm_flags & PMF_NO_MOVE + && (g_target_game > target_game_e::TG_MOH || g_gametype->integer != GT_SINGLE_PLAYER)) { + // Added in 2.30 + // Allow ducking if specified + if (!m_pGlueMaster || !m_bGlueDuckable) { + return viewheight != DEFAULT_VIEWHEIGHT; + } + } + return (last_ucmd.upmove) < 0; } qboolean Player::CondJumpFlip(Conditional& condition) - { return velocity.z < (sv_gravity->value * 0.5f); } @@ -813,6 +896,8 @@ qboolean Player::CondAnimDoneTorso(Conditional& condition) qboolean Player::CondAttackPrimary(Conditional& condition) { + Weapon *weapon; + if (level.playerfrozen || m_bFrozen || (flags & FL_IMMOBILE)) { return false; } @@ -821,21 +906,19 @@ qboolean Player::CondAttackPrimary(Conditional& condition) return false; } - if (last_ucmd.buttons & BUTTON_ATTACKLEFT) { - Weapon *weapon; - - last_attack_button = BUTTON_ATTACKLEFT; - - weapon = GetActiveWeapon(WEAPON_MAIN); - if (weapon) { - return true; - } - - // No ammo - return false; - } else { + if (!(last_ucmd.buttons & BUTTON_ATTACKLEFT)) { return false; } + + last_attack_button = BUTTON_ATTACKLEFT; + + weapon = GetActiveWeapon(WEAPON_MAIN); + if (weapon) { + return true; + } + + // No ammo + return false; } qboolean Player::CondAttackButtonPrimary(Conditional& condition) @@ -853,6 +936,8 @@ qboolean Player::CondAttackButtonPrimary(Conditional& condition) qboolean Player::CondAttackSecondary(Conditional& condition) { + Weapon *weapon; + if (level.playerfrozen || m_bFrozen || (flags & FL_IMMOBILE)) { return false; } @@ -861,21 +946,19 @@ qboolean Player::CondAttackSecondary(Conditional& condition) return false; } - if (last_ucmd.buttons & BUTTON_ATTACKRIGHT) { - Weapon *weapon; - - last_attack_button = BUTTON_ATTACKRIGHT; - - weapon = GetActiveWeapon(WEAPON_MAIN); - if (weapon) { - return true; - } - - // No ammo - return false; - } else { + if (!(last_ucmd.buttons & BUTTON_ATTACKRIGHT)) { return false; } + + last_attack_button = BUTTON_ATTACKRIGHT; + + weapon = GetActiveWeapon(WEAPON_MAIN); + if (weapon) { + return true; + } + + // No ammo + return false; } qboolean Player::CondAttackButtonSecondary(Conditional& condition) @@ -935,13 +1018,11 @@ qboolean Player::CondRun(Conditional& condition) } qboolean Player::CondUse(Conditional& condition) - { return (last_ucmd.buttons & BUTTON_USE) != 0; } qboolean Player::CondCanTurn(Conditional& condition) - { float yaw; Vector oldang(v_angle); @@ -1042,7 +1123,6 @@ qboolean Player::CondHasVelocity(Conditional& condition) } qboolean Player::Cond22DegreeSlope(Conditional& condition) - { if (client->ps.walking && client->ps.groundPlane && (client->ps.groundTrace.plane.normal[2] < SLOPE_22_MAX) && (client->ps.groundTrace.plane.normal[2] >= SLOPE_22_MIN)) { @@ -1053,7 +1133,6 @@ qboolean Player::Cond22DegreeSlope(Conditional& condition) } qboolean Player::Cond45DegreeSlope(Conditional& condition) - { if (client->ps.walking && client->ps.groundPlane && (client->ps.groundTrace.plane.normal[2] < SLOPE_45_MAX) && (client->ps.groundTrace.plane.normal[2] >= SLOPE_45_MIN)) { @@ -1064,7 +1143,6 @@ qboolean Player::Cond45DegreeSlope(Conditional& condition) } qboolean Player::CondRightLegHigh(Conditional& condition) - { float groundyaw; float yawdelta; @@ -1078,7 +1156,6 @@ qboolean Player::CondRightLegHigh(Conditional& condition) } qboolean Player::CondLeftLegHigh(Conditional& condition) - { float groundyaw; float yawdelta; @@ -1092,7 +1169,6 @@ qboolean Player::CondLeftLegHigh(Conditional& condition) } qboolean Player::CondFacingUpSlope(Conditional& condition) - { float groundyaw; float yawdelta; @@ -1106,7 +1182,6 @@ qboolean Player::CondFacingUpSlope(Conditional& condition) } qboolean Player::CondFacingDownSlope(Conditional& condition) - { float groundyaw; float yawdelta; @@ -1120,13 +1195,11 @@ qboolean Player::CondFacingDownSlope(Conditional& condition) } qboolean Player::CondFalling(Conditional& condition) - { return falling; } qboolean Player::CondGroundEntity(Conditional& condition) - { return (groundentity != NULL); } @@ -1147,14 +1220,12 @@ qboolean Player::CondCanFall(Conditional& condition) } qboolean Player::CondAtDoor(Conditional& condition) - { // Check if the player is at a door return (atobject && atobject->isSubclassOf(Door)); } qboolean Player::CondAtUseAnim(Conditional& condition) - { // Check if the player is at a useanim if (atobject && atobject->isSubclassOf(UseAnim)) { @@ -1165,7 +1236,6 @@ qboolean Player::CondAtUseAnim(Conditional& condition) } qboolean Player::CondTouchUseAnim(Conditional& condition) - { if (toucheduseanim) { return ((UseAnim *)(Entity *)toucheduseanim)->canBeUsed(this); @@ -1175,13 +1245,11 @@ qboolean Player::CondTouchUseAnim(Conditional& condition) } qboolean Player::CondUseAnimFinished(Conditional& condition) - { return (useanim_numloops <= 0); } qboolean Player::CondAtUseObject(Conditional& condition) - { // Check if the player is at a useanim if (atobject && atobject->isSubclassOf(UseObject)) { @@ -1192,7 +1260,6 @@ qboolean Player::CondAtUseObject(Conditional& condition) } qboolean Player::CondLoopUseObject(Conditional& condition) - { // Check if the player is at a useanim if (useitem_in_use && useitem_in_use->isSubclassOf(UseObject)) { @@ -1203,13 +1270,11 @@ qboolean Player::CondLoopUseObject(Conditional& condition) } qboolean Player::CondDead(Conditional& condition) - { return (deadflag); } qboolean Player::CondKnockDown(Conditional& condition) - { if (knockdown) { knockdown = false; @@ -1294,7 +1359,6 @@ qboolean Player::CondPainLocation(Conditional& condition) } qboolean Player::CondPainThreshold(Conditional& condition) - { float threshold = atof(condition.getParm(1)); @@ -1307,7 +1371,6 @@ qboolean Player::CondPainThreshold(Conditional& condition) } qboolean Player::CondLegsState(Conditional& condition) - { if (currentState_Legs) { str current = currentState_Legs->getName(); @@ -1322,7 +1385,6 @@ qboolean Player::CondLegsState(Conditional& condition) } qboolean Player::CondTorsoState(Conditional& condition) - { if (currentState_Torso) { str current = currentState_Torso->getName(); @@ -1337,7 +1399,6 @@ qboolean Player::CondTorsoState(Conditional& condition) } qboolean Player::CondStateName(Conditional& condition) - { str part = condition.getParm(1); str statename = condition.getParm(2); @@ -1352,7 +1413,6 @@ qboolean Player::CondStateName(Conditional& condition) } qboolean Player::CondPush(Conditional& condition) - { // Check if the player is at a pushobject if (atobject && atobject->isSubclassOf(PushObject) && (atobject_dist < (PUSH_OBJECT_DISTANCE + 15.0f))) { @@ -1366,7 +1426,6 @@ qboolean Player::CondPush(Conditional& condition) } qboolean Player::CondPull(Conditional& condition) - { // Check if the player is at a pushobject if (atobject && atobject->isSubclassOf(PushObject) && (atobject_dist < (PUSH_OBJECT_DISTANCE + 15.0f))) { @@ -1379,8 +1438,6 @@ qboolean Player::CondPull(Conditional& condition) return qfalse; } -#define LADDER_HAND_HEIGHT (MAXS_X - MINS_X) - qboolean Player::CondLadder(Conditional& condition) { trace_t trace; @@ -1458,7 +1515,7 @@ qboolean Player::CondCanGetOffLadderTop(Conditional& condition) angles.AngleVectorsLeft(&vForward); - vStart = origin - vForward * 12.0f; + vStart = origin - vForward * 12.0f * 1.005f; vStart[2] += maxs[2] - 8.0f; vEnd = vStart + vForward * 40.0f; @@ -1511,7 +1568,6 @@ qboolean Player::CondLookingUp(Conditional& condition) } qboolean Player::CondCanStand(Conditional& condition) - { Vector newmins(mins); Vector newmaxs(maxs); @@ -1857,7 +1913,7 @@ CLASS_DECLARATION(Class, Conditional, NULL) { {NULL, NULL} }; -Condition Player::Conditions[] = { +Condition Player::m_conditions[] = { {"default", &Player::CondTrue }, {"CHANCE", &Player::CondChance }, {"HEALTH", &Player::CondHealth }, @@ -1975,7 +2031,7 @@ Condition Player::Conditions[] = { {"ATTACK_SECONDARY_BUTTON", &Player::CondAttackButtonSecondary }, {"CHECK_MOVEMENT_SPEED", &Player::CondCheckMovementSpeed }, - // Weapon conditions + // Weapon conditions {"ANIMDONE_VM", &Player::CondAnimDoneVM }, {"CLIENT_COMMAND", &Player::CondClientCommand }, {"IS_VM_ANIM", &Player::CondVMAnim }, diff --git a/code/fgame/player_util.cpp b/code/fgame/player_util.cpp index aaf043e4..eda69045 100644 --- a/code/fgame/player_util.cpp +++ b/code/fgame/player_util.cpp @@ -94,8 +94,8 @@ void Player::WhatIs(Event *ev) const char *animname; animname = NULL; - if (gi.modeltiki(ent->model)) { - animname = gi.Anim_NameForNum(ent->edict->tiki, ent->edict->s.frameInfo[0].index); + if (ent->edict->tiki) { + animname = AnimName(0); } if (!animname) { @@ -326,17 +326,18 @@ void Player::TestThread(Event *ev) void Player::SpawnEntity(Event *ev) { - Entity *ent; - str name; - ClassDef *cls; - str text; - Vector forward; - Vector up; - Vector delta; - Vector v; - int n; - int i; - Event *e; + SimpleEntity *ent; + str name; + ClassDef *cls; + str text; + Vector forward; + Vector up; + Vector delta; + Vector v; + int n; + int i; + Event *e; + bool bModelSet; if (ev->NumArgs() < 1) { ScriptError("Usage: spawn entityname [keyname] [value]..."); @@ -360,16 +361,12 @@ void Player::SpawnEntity(Event *ev) cls = &Entity::ClassInfo; } - if (!checkInheritance(&Entity::ClassInfo, cls)) { - ScriptError("%s is not a valid Entity", name.c_str()); + if (!checkInheritance(&SimpleEntity::ClassInfo, cls)) { + ScriptError("%s is not a valid SimpleEntity", name.c_str()); return; } - ent = (Entity *)cls->newInstance(); - - e = new Event(EV_Model); - e->AddString(name.c_str()); - ent->PostEvent(e, EV_PRIORITY_SPAWNARG); + ent = (SimpleEntity *)cls->newInstance(); angles.AngleVectors(&forward, NULL, &up); v = origin + (forward + up) * 40; @@ -387,21 +384,36 @@ void Player::SpawnEntity(Event *ev) e->AddVector(v); ent->PostEvent(e, EV_SPAWNARG); + bModelSet = false; + if (ev->NumArgs() > 2) { n = ev->NumArgs(); for (i = 2; i <= n; i += 2) { - e = new Event(ev->GetString(i)); + str name = ev->GetString(i); + float priority = EV_SPAWNARG; + + if (!str::icmp(name, "model")) { + bModelSet = true; + priority = EV_PRIORITY_SPAWNARG; + } + + e = new Event(name); e->AddToken(ev->GetString(i + 1)); - ent->PostEvent(e, EV_SPAWNARG); + ent->PostEvent(e, priority); } } - e = new Event(EV_SetAnim); - e->AddString("idle"); - ent->PostEvent(e, EV_SPAWNARG); + if (ent->IsSubclassOfEntity() && !bModelSet) { + e = new Event(EV_Model); + e->AddString(name.c_str()); + ent->PostEvent(e, EV_PRIORITY_SPAWNARG); + } ent->ProcessPendingEvents(); - ent->ProcessEvent(EV_Entity_Start); + + if (ent->IsSubclassOfEntity()) { + ent->ProcessEvent(EV_Entity_Start); + } } //==================== @@ -596,7 +608,11 @@ void Player::EventJailEscape(Event* ev) void Player::EventFace(Event *ev) { - SetViewAngles(Vector(ev->GetFloat(1), ev->GetFloat(2), ev->GetFloat(3))); + if (ev->NumArgs() == 1) { + SetViewAngles(ev->GetVector(1)); + } else { + SetViewAngles(Vector(ev->GetFloat(1), ev->GetFloat(2), ev->GetFloat(3))); + } } void Player::EventCoord(Event *ev) diff --git a/code/fgame/playerbot.cpp b/code/fgame/playerbot.cpp index 1241d9df..958e4ce4 100644 --- a/code/fgame/playerbot.cpp +++ b/code/fgame/playerbot.cpp @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -27,34 +27,27 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "consoleevent.h" #include "debuglines.h" #include "scriptexception.h" +#include "vehicleturret.h" +#include "weaputils.h" +#include "g_bot.h" // We assume that we have limited access to the server-side // and that most logic come from the playerstate_s structure cvar_t *bot_manualmove; -CLASS_DECLARATION(Player, PlayerBot, NULL) { - {&EV_Killed, &PlayerBot::Killed }, - {&EV_GotKill, &PlayerBot::GotKill }, - {&EV_Player_StuffText, &PlayerBot::EventStuffText}, - {NULL, NULL } +CLASS_DECLARATION(Listener, BotController, NULL) { + {NULL, NULL} }; -PlayerBot::botfunc_t PlayerBot::botfuncs[MAX_BOT_FUNCTIONS]; +BotController::botfunc_t BotController::botfuncs[MAX_BOT_FUNCTIONS]; -PlayerBot::PlayerBot() +BotController::BotController() { - entflags |= ECF_BOT; - if (LoadingSavegame) { return; } - m_Path.SetFallHeight(96); - m_bPathing = false; - m_bTempAway = false; - m_bDeltaMove = true; - m_botCmd.serverTime = 0; m_botCmd.msec = 0; m_botCmd.buttons = 0; @@ -70,379 +63,164 @@ PlayerBot::PlayerBot() m_botEyes.angles[1] = 0; m_botEyes.ofs[0] = 0; m_botEyes.ofs[1] = 0; - m_botEyes.ofs[2] = viewheight; + m_botEyes.ofs[2] = DEFAULT_VIEWHEIGHT; - m_vAngSpeed = vec_zero; - m_vTargetAng = vec_zero; - m_vCurrentAng = vec_zero; - m_iCheckPathTime = 0; - m_iTempAwayTime = 0; - m_fYawSpeedMult = 1.0f; + m_iCuriousTime = 0; + m_iAttackTime = 0; + m_iConfirmTime = 0; + m_iEnemyEyesTag = -1; - m_iCuriousTime = 0; - m_iAttackTime = 0; + m_iNextTauntTime = 0; m_StateFlags = 0; m_RunLabel.TrySetScript("global/bot_run.scr"); } -void PlayerBot::Init(void) +BotController::~BotController() +{ + if (controlledEnt) { + controlledEnt->delegate_gotKill.Remove(delegateHandle_gotKill); + controlledEnt->delegate_killed.Remove(delegateHandle_killed); + controlledEnt->delegate_stufftext.Remove(delegateHandle_stufftext); + } +} + +BotMovement& BotController::GetMovement() +{ + return movement; +} + +void BotController::Init(void) { bot_manualmove = gi.Cvar_Get("bot_manualmove", "0", 0); for (int i = 0; i < MAX_BOT_FUNCTIONS; i++) { - botfuncs[i].BeginState = &PlayerBot::State_DefaultBegin; - botfuncs[i].EndState = &PlayerBot::State_DefaultEnd; + botfuncs[i].BeginState = &BotController::State_DefaultBegin; + botfuncs[i].EndState = &BotController::State_DefaultEnd; } InitState_Attack(&botfuncs[0]); InitState_Curious(&botfuncs[1]); InitState_Grenade(&botfuncs[2]); InitState_Idle(&botfuncs[3]); - InitState_Weapon(&botfuncs[4]); + //InitState_Weapon(&botfuncs[4]); } -float AngleDifference(float ang1, float ang2) -{ - float diff; - - diff = ang1 - ang2; - if (ang1 > ang2) { - if (diff > 180.0) { - diff -= 360.0; - } - } else { - if (diff < -180.0) { - diff += 360.0; - } - } - return diff; -} - -void PlayerBot::TurnThink(void) -{ - float diff, factor, maxchange, anglespeed, desired_speed; - int i; - - if (m_vTargetAng[PITCH] > 180) { - m_vTargetAng[PITCH] -= 360; - } - - factor = 0.25f; - maxchange = 360; - - if (maxchange < 240) { - maxchange = 240; - } - - maxchange *= level.frametime; - - for (i = 0; i < 2; i++) { - //over reaction view model - m_vCurrentAng[i] = AngleMod(m_vCurrentAng[i]); - m_vTargetAng[i] = AngleMod(m_vTargetAng[i]); - diff = AngleDifference(m_vCurrentAng[i], m_vTargetAng[i]); - desired_speed = diff * factor; - m_vAngSpeed[i] += (m_vAngSpeed[i] - desired_speed); - - if (m_vAngSpeed[i] > 180) { - m_vAngSpeed[i] = maxchange; - } - - if (m_vAngSpeed[i] < -180) { - m_vAngSpeed[i] = -maxchange; - } - - anglespeed = m_vAngSpeed[i]; - - if (anglespeed > maxchange) { - anglespeed = maxchange; - } - - if (anglespeed < -maxchange) { - anglespeed = -maxchange; - } - - m_vCurrentAng[i] += anglespeed; - m_vCurrentAng[i] = AngleMod(m_vCurrentAng[i]); - - //demping - m_vAngSpeed[i] *= 0.45 * (1 - factor); - } - - if (m_vCurrentAng[PITCH] > 180) { - m_vCurrentAng[PITCH] -= 360; - } - - m_botEyes.angles[0] = m_vCurrentAng[0]; - m_botEyes.angles[1] = m_vCurrentAng[1]; - m_botCmd.angles[0] = ANGLE2SHORT(m_vCurrentAng[0]) - client->ps.delta_angles[0]; - m_botCmd.angles[1] = ANGLE2SHORT(m_vCurrentAng[1]) - client->ps.delta_angles[1]; - m_botCmd.angles[2] = ANGLE2SHORT(m_vCurrentAng[2]) - client->ps.delta_angles[2]; -} - -void PlayerBot::CheckAttractiveNodes(void) -{ - for (int i = m_attractList.NumObjects(); i > 0; i--) { - nodeAttract_t *a = m_attractList.ObjectAt(i); - - if (a->m_pNode == NULL || !a->m_pNode->CheckTeam(this) || level.time > a->m_fRespawnTime) { - delete a; - m_attractList.RemoveObjectAt(i); - } - } -} - -void PlayerBot::MoveThink(void) -{ - Vector vDir; - Vector vAngles; - Vector vWishDir; - - m_botCmd.forwardmove = 0; - m_botCmd.rightmove = 0; - - CheckAttractiveNodes(); - - if (!IsMoving()) { - return; - } - - if (m_bTempAway && level.inttime >= m_iTempAwayTime) { - m_bTempAway = false; - m_Path.FindPath(origin, m_vTargetPos, this, 0, NULL, 0); - } - - if (m_Path.CurrentNode()) { - m_Path.UpdatePos(origin, 8); - - m_vCurrentGoal = origin; - VectorAdd2D(m_vCurrentGoal, m_Path.CurrentDelta(), m_vCurrentGoal); - - if (m_Path.Complete(origin)) { - // Clear the path - m_Path.Clear(); - } - } else if (!m_bTempAway) { - m_vCurrentGoal = origin; - } - - if (ai_debugpath->integer) { - G_DebugLine(centroid, m_vCurrentGoal + Vector(0, 0, 36), 1, 1, 0, 1); - } - - // Check if we're blocked - if (level.inttime >= m_iCheckPathTime) { - Vector end; - - m_bDeltaMove = false; - - m_iCheckPathTime = level.inttime + 2000; - - if (m_Path.CurrentNode() && m_Path.CurrentNode() != m_Path.LastNode()) { - end = m_Path.NextNode()->point; - } else { - end = m_vCurrentGoal; - } - - if (GetMoveResult() >= MOVERESULT_BLOCKED || velocity.lengthSquared() <= 8 * 8) { - gi.DPrintf2("Updating path for bot client %i\n", edict - g_entities); - - m_bTempAway = true; - m_bDeltaMove = false; - m_iTempAwayTime = level.inttime + 750; - - // Try to backward a little - //vDir = end - origin; - //VectorNormalizeFast( vDir ); - //m_Path.FindPathAway( origin, origin + vDir * 16, vDir, this, 256, NULL, 0 ); - //m_Path.FindPathAway( origin, origin + m_vLastValidDir * 16, -m_vLastValidDir, this, 256, NULL, 0 ); - m_Path.Clear(); - m_vCurrentGoal = m_vLastValidGoal - m_vLastValidDir * 256; - return; - } - } - - if (ai_debugpath->integer) { - PathInfo *pos = m_Path.CurrentNode(); - - if (pos != NULL) { - while (pos != m_Path.LastNode()) { - Vector vStart = pos->point + Vector(0, 0, 32); - - pos--; - - Vector vEnd = pos->point + Vector(0, 0, 32); - - G_DebugLine(vStart, vEnd, 1, 0, 0, 1); - } - } - } - - if ((m_vTargetPos - origin).lengthSquared() <= 16 * 16) { - ClearMove(); - } - - //vDir = m_vCurrentGoal - centroid; - - // Rotate the dir - vDir[0] = m_Path.CurrentDelta()[0]; - vDir[1] = m_Path.CurrentDelta()[1]; - vDir[2] = 0; - VectorNormalize(vDir); - vAngles = vDir.toAngles() - angles; - vAngles.AngleVectorsLeft(&vWishDir); - - m_vLastValidDir = vWishDir; - m_vLastValidGoal = m_vCurrentGoal; - - // Forward to the specified direction - float x = vWishDir.x * 255.0f; - float y = -vWishDir.y * 255.0f; - - m_botCmd.forwardmove = (signed char)(x > 127 ? 127 : x < -127 ? -127 : x); - m_botCmd.rightmove = (signed char)(y > 127 ? 127 : y < -127 ? -127 : y); - CheckJump(); - - Weapon *pWeap = GetActiveWeapon(WEAPON_MAIN); - - if (pWeap && !pWeap->ShouldReload()) { - m_RunLabel.Execute(this); - } -} - -void PlayerBot::CheckJump(void) -{ - Vector start; - Vector end; - Vector dir; - trace_t trace; - - if (!m_Path.CurrentNode()) { - return; - } - - dir = m_Path.CurrentDelta(); - VectorNormalizeFast(dir); - - if (ai_debugpath->integer) { - G_DebugLine(origin + Vector(0, 0, STEPSIZE), origin + Vector(0, 0, STEPSIZE) + dir * 32, 1, 0, 1, 1); - G_DebugLine(origin + Vector(0, 0, 56), origin + Vector(0, 0, 56) + dir * 32, 1, 0, 1, 1); - } - - Vector vStart = origin + Vector(0, 0, STEPSIZE); - Vector vEnd = origin + Vector(0, 0, STEPSIZE) + dir * 4; - - // Check if the bot needs to jump - trace = G_Trace(vStart, mins, maxs, vEnd, this, MASK_PLAYERSOLID, false, "PlayerBot::CheckJump"); - - // No need to jump - if (trace.fraction >= 0.95f) { - m_botCmd.upmove = 0; - return; - } - - start = origin + Vector(0, 0, 56); - end = origin + Vector(0, 0, 56) + dir * 4; - - // Check if the bot can jump - trace = G_Trace(start, mins, maxs, end, this, MASK_PLAYERSOLID, true, "PlayerBot::CheckJump"); - - // Make the bot climb walls - if (trace.fraction >= 0.95f) { - if (!m_botCmd.upmove) { - m_botCmd.upmove = 127; - } else { - m_botCmd.upmove = 0; - } - } else { - m_botCmd.upmove = 0; - } -} - -void PlayerBot::CheckEndPos(void) -{ - Vector start; - Vector end; - trace_t trace; - - if (!m_Path.LastNode()) { - return; - } - - start = m_Path.LastNode()->point; - end = m_vTargetPos; - - trace = G_Trace(start, mins, maxs, end, this, MASK_TARGETPATH, true, "PlayerBot::CheckEndPos"); - - if (trace.fraction < 0.95f) { - m_vTargetPos = trace.endpos; - } -} - -void PlayerBot::CheckUse(void) -{ - Vector dir; - Vector start; - Vector end; - trace_t trace; - - m_botCmd.buttons &= ~BUTTON_USE; - - angles.AngleVectorsLeft(&dir); - - start = origin + Vector(0, 0, viewheight); - end = origin + Vector(0, 0, viewheight) + dir * 32; - - trace = G_Trace(start, vec_zero, vec_zero, end, this, MASK_USABLE, false, "PlayerBot::CheckUse"); - - // It may be a door - if ((trace.allsolid || trace.startsolid || trace.fraction != 1.0f) && trace.entityNum) { - m_botCmd.buttons |= BUTTON_USE; - } -} - -void PlayerBot::GetUsercmd(usercmd_t *ucmd) +void BotController::GetUsercmd(usercmd_t *ucmd) { *ucmd = m_botCmd; } -void PlayerBot::GetEyeInfo(usereyes_t *eyeinfo) +void BotController::GetEyeInfo(usereyes_t *eyeinfo) { *eyeinfo = m_botEyes; } -void PlayerBot::UpdateBotStates(void) +void BotController::UpdateBotStates(void) { if (bot_manualmove->integer) { memset(&m_botCmd, 0, sizeof(usercmd_t)); return; } - if (IsDead()) { + if (!controlledEnt->client->pers.dm_primary[0]) { + Event *event; + + // + // Primary weapon + // + event = new Event(EV_Player_PrimaryDMWeapon); + event->AddString("auto"); + + controlledEnt->ProcessEvent(event); + } + + if (controlledEnt->GetTeam() == TEAM_NONE || controlledEnt->GetTeam() == TEAM_SPECTATOR) { + float time; + + // Add some delay to avoid telefragging + time = controlledEnt->entnum / 20.0; + + if (controlledEnt->EventPending(EV_Player_AutoJoinDMTeam)) { + return; + } + + // + // Team + // + controlledEnt->PostEvent(EV_Player_AutoJoinDMTeam, time); + return; + } + + if (controlledEnt->IsDead() || controlledEnt->IsSpectator()) { // The bot should respawn m_botCmd.buttons ^= BUTTON_ATTACKLEFT; return; } m_botCmd.buttons |= BUTTON_RUN; + m_botCmd.serverTime = level.svsTime; m_botEyes.ofs[0] = 0; m_botEyes.ofs[1] = 0; - m_botEyes.ofs[2] = viewheight; + m_botEyes.ofs[2] = controlledEnt->viewheight; m_botEyes.angles[0] = 0; m_botEyes.angles[1] = 0; - SetTargetAngles(Vector(0, 90, 0)); - CheckStates(); - MoveThink(); - TurnThink(); + movement.MoveThink(m_botCmd); + rotation.TurnThink(m_botCmd, m_botEyes); CheckUse(); + + CheckValidWeapon(); } -void PlayerBot::SendCommand(const char *text) +void BotController::CheckUse(void) +{ + Vector dir; + Vector start; + Vector end; + trace_t trace; + + controlledEnt->angles.AngleVectorsLeft(&dir); + + start = controlledEnt->origin + Vector(0, 0, controlledEnt->viewheight); + end = controlledEnt->origin + Vector(0, 0, controlledEnt->viewheight) + dir * 32; + + trace = G_Trace(start, vec_zero, vec_zero, end, controlledEnt, MASK_USABLE, false, "BotController::CheckUse"); + + // It may be a door + if ((trace.allsolid || trace.startsolid || trace.fraction != 1.0f) && trace.ent) { + if (trace.ent->entity->IsSubclassOfDoor()) { + Door *door = static_cast(trace.ent->entity); + if (door->isOpen()) { + m_botCmd.buttons &= ~BUTTON_USE; + return; + } + } + + // + // Toggle the use button + // + m_botCmd.buttons ^= BUTTON_USE; + } else { + m_botCmd.buttons &= ~BUTTON_USE; + } +} + +void BotController::CheckValidWeapon() { + Weapon* weapon = controlledEnt->GetActiveWeapon(WEAPON_MAIN); + if (!weapon) { + // If holstered, use the best weapon available + UseWeaponWithAmmo(); + } else if (!weapon->HasAmmo(FIRE_PRIMARY) && !controlledEnt->GetNewActiveWeapon()) { + // In case the current weapon has no ammo, use the best available weapon + UseWeaponWithAmmo(); + } +} + +void BotController::SendCommand(const char *text) { char *buffer; char *data; @@ -461,7 +239,7 @@ void PlayerBot::SendCommand(const char *text) return; } - m_lastcommand = com_token; + controlledEnt->m_lastcommand = com_token; if (!Event::GetEvent(com_token)) { return; @@ -474,7 +252,7 @@ void PlayerBot::SendCommand(const char *text) return; } - ev.SetConsoleEdict(edict); + ev.SetConsoleEdict(controlledEnt->edict); while (1) { com_token = COM_Parse(&data); @@ -489,62 +267,12 @@ void PlayerBot::SendCommand(const char *text) gi.Free(buffer); try { - ProcessEvent(ev); + controlledEnt->ProcessEvent(ev); } catch (ScriptException& exc) { gi.DPrintf("*** Bot Command Exception *** %s\n", exc.string.c_str()); } } -void PlayerBot::setAngles(Vector ang) -{ - Entity::setAngles(ang); - SetTargetAngles(angles); -} - -void PlayerBot::updateOrigin(void) -{ - Entity::updateOrigin(); - - if (origin == client->ps.origin) { - // no change because of Pmove - return; - } - - m_pPrimaryAttract = NULL; - - if (m_Path.CurrentNode()) { - // recalculate paths because of a new origin - m_Path.ReFindPath(origin, this); - } -} - -/* -==================== -SetTargetAngles - -Set the bot's angle -==================== -*/ -void PlayerBot::SetTargetAngles(Vector vAngles) -{ - m_vTargetAng = vAngles; -} - -/* -==================== -AimAt - -Make the bot face to the specified direction -==================== -*/ -void PlayerBot::AimAt(Vector vPos) -{ - Vector vDelta = vPos - centroid; - - VectorNormalize(vDelta); - vectoangles(vDelta, m_vTargetAng); -} - /* ==================== AimAtAimNode @@ -552,15 +280,22 @@ AimAtAimNode Make the bot face toward the current path ==================== */ -void PlayerBot::AimAtAimNode(void) +void BotController::AimAtAimNode(void) { - if (m_Path.CurrentDelta()) { - AimAt(origin + m_Path.CurrentDelta()); - } else { - AimAt(m_vCurrentGoal); + Vector goal; + + if (!movement.IsMoving()) { + return; } - m_vTargetAng[PITCH] = 0; + goal = movement.GetCurrentGoal(); + if (goal != controlledEnt->origin) { + rotation.AimAt(goal); + } + + Vector targetAngles = rotation.GetTargetAngles(); + targetAngles.x = 0; + rotation.SetTargetAngles(targetAngles); } /* @@ -570,236 +305,15 @@ CheckReload Make the bot reload if necessary ==================== */ -void PlayerBot::CheckReload(void) +void BotController::CheckReload(void) { - Weapon *weap = GetActiveWeapon(WEAPON_MAIN); + Weapon *weap = controlledEnt->GetActiveWeapon(WEAPON_MAIN); if (weap && weap->CheckReload(FIRE_PRIMARY)) { SendCommand("reload"); } } -/* -==================== -MoveTo - -Move to the specified position -==================== -*/ -void PlayerBot::MoveTo(Vector vPos, float *vLeashHome, float fLeashRadius) -{ - m_bPathing = true; - m_vTargetPos = vPos; - m_Path.FindPath(origin, vPos, this, 0, vLeashHome, fLeashRadius * fLeashRadius); - - if (!m_Path.CurrentNode()) { - m_bPathing = false; - return; - } - - CheckEndPos(); -} - -/* -==================== -MoveTo - -Move to the nearest attractive point with a minimum priority -Returns true if no attractive point was found -==================== -*/ -bool PlayerBot::MoveToBestAttractivePoint(int iMinPriority) -{ - Container list; - AttractiveNode *bestNode; - float bestDistanceSquared; - int bestPriority; - - if (m_pPrimaryAttract) { - MoveTo(m_pPrimaryAttract->origin); - - if (!IsMoving()) { - m_pPrimaryAttract = NULL; - } else { - if (MoveDone()) { - if (!m_fAttractTime) { - m_fAttractTime = level.time + m_pPrimaryAttract->m_fMaxStayTime; - } - if (level.time > m_fAttractTime) { - nodeAttract_t *a = new nodeAttract_t; - a->m_fRespawnTime = level.time + m_pPrimaryAttract->m_fRespawnTime; - a->m_pNode = m_pPrimaryAttract; - - m_pPrimaryAttract = NULL; - } - } - - return true; - } - } - - if (!attractiveNodes.NumObjects()) { - return false; - } - - bestNode = NULL; - bestDistanceSquared = 99999999.0f; - bestPriority = iMinPriority; - - for (int i = attractiveNodes.NumObjects(); i > 0; i--) { - AttractiveNode *node = attractiveNodes.ObjectAt(i); - float distSquared; - bool m_bRespawning = false; - - for (int j = m_attractList.NumObjects(); j > 0; j--) { - AttractiveNode *node2 = m_attractList.ObjectAt(j)->m_pNode; - - if (node2 == node) { - m_bRespawning = true; - break; - } - } - - if (m_bRespawning) { - continue; - } - - if (node->m_iPriority < bestPriority) { - continue; - } - - if (!node->CheckTeam(this)) { - continue; - } - - distSquared = VectorLengthSquared(origin - node->origin); - - if (node->m_fMaxDistanceSquared >= 0 && distSquared > node->m_fMaxDistanceSquared) { - continue; - } - - if (!CanMoveTo(node->origin)) { - continue; - } - - if (distSquared < bestDistanceSquared) { - bestDistanceSquared = distSquared; - bestNode = node; - bestPriority = node->m_iPriority; - } - } - - if (bestNode) { - m_pPrimaryAttract = bestNode; - m_fAttractTime = 0; - MoveTo(bestNode->origin); - return true; - } else { - // No attractive point found - return false; - } -} - -/* -==================== -CanMoveTo - -Returns true if the bot has done moving -==================== -*/ -bool PlayerBot::CanMoveTo(Vector vPos) -{ - return m_Path.DoesTheoreticPathExist(origin, vPos, NULL, 0, NULL, 0); -} - -/* -==================== -MoveDone - -Returns true if the bot has done moving -==================== -*/ -bool PlayerBot::MoveDone(void) -{ - return !m_Path.LastNode() || m_Path.Complete(origin); -} - -/* -==================== -IsMoving - -Returns true if the bot has a current path -==================== -*/ -bool PlayerBot::IsMoving(void) -{ - return m_bPathing; -} - -/* -==================== -ClearMove - -Stop the bot from moving -==================== -*/ -void PlayerBot::ClearMove(void) -{ - m_Path.Clear(); - m_bPathing = false; -} - -/* -==================== -MoveNear - -Move near the specified position within the radius -==================== -*/ -void PlayerBot::MoveNear(Vector vNear, float fRadius, float *vLeashHome, float fLeashRadius) -{ - m_bPathing = true; - m_Path.FindPathNear(origin, vNear, this, 0, fRadius * fRadius, vLeashHome, fLeashRadius * fLeashRadius); - - if (!m_Path.CurrentNode()) { - m_bPathing = false; - return; - } - - m_vTargetPos = m_Path.LastNode()->point; -} - -/* -==================== -AvoidPath - -Avoid the specified position within the radius and start from a direction -==================== -*/ -void PlayerBot::AvoidPath( - Vector vAvoid, float fAvoidRadius, Vector vPreferredDir, float *vLeashHome, float fLeashRadius -) -{ - Vector vDir; - - if (vPreferredDir == vec_zero) { - vDir = origin - vAvoid; - VectorNormalizeFast(vDir); - } else { - vDir = vPreferredDir; - } - - m_bPathing = true; - m_Path.FindPathAway(origin, vAvoid, vDir, this, fAvoidRadius, vLeashHome, fLeashRadius * fLeashRadius); - - if (!m_Path.CurrentNode()) { - m_bPathing = false; - return; - } - - m_vTargetPos = m_Path.LastNode()->point; -} - /* ==================== NoticeEvent @@ -807,22 +321,47 @@ NoticeEvent Warn the bot of an event ==================== */ -void PlayerBot::NoticeEvent(Vector vPos, int iType, Entity *pEnt, float fDistanceSquared, float fRadiusSquared) +void BotController::NoticeEvent(Vector vPos, int iType, Entity *pEnt, float fDistanceSquared, float fRadiusSquared) { - // Ignore teammates - if (pEnt->IsSubclassOfPlayer()) { - Player *p = (Player *)pEnt; + Sentient *pSentOwner; + float fRangeFactor; - if (p->GetTeam() == GetTeam()) { + fRangeFactor = 1.0 - (fDistanceSquared / fRadiusSquared); + + if (fRangeFactor < random()) { + return; + } + + if (pEnt->IsSubclassOfSentient()) { + pSentOwner = static_cast(pEnt); + } else if (pEnt->IsSubclassOfVehicleTurretGun()) { + VehicleTurretGun *pVTG = static_cast(pEnt); + pSentOwner = pVTG->GetSentientOwner(); + } else if (pEnt->IsSubclassOfItem()) { + Item *pItem = static_cast(pEnt); + pSentOwner = pItem->GetOwner(); + } else if (pEnt->IsSubclassOfProjectile()) { + Projectile *pProj = static_cast(pEnt); + pSentOwner = pProj->GetOwner(); + } else { + pSentOwner = NULL; + } + + if (pSentOwner) { + if (pSentOwner == controlledEnt) { + // Ignore self return; } - } else if (pEnt->IsSubclassOfWeapon()) { - Weapon *pWeap = (Weapon *)pEnt; - if (pWeap->GetOwner()) { - Player *p = (Player *)pWeap->GetOwner(); + if ((pSentOwner->flags & FL_NOTARGET) || pSentOwner->getSolidType() == SOLID_NOT) { + return; + } - if (p->IsSubclassOfPlayer() && p->GetTeam() == GetTeam()) { + // Ignore teammates + if (pSentOwner->IsSubclassOfPlayer()) { + Player *p = static_cast(pSentOwner); + + if (g_gametype->integer >= GT_TEAM && p->GetTeam() == controlledEnt->GetTeam()) { return; } } @@ -842,8 +381,8 @@ void PlayerBot::NoticeEvent(Vector vPos, int iType, Entity *pEnt, float fDistanc case AI_EVENT_FOOTSTEP: case AI_EVENT_GRENADE: default: - m_iCuriousTime = level.inttime + 20000; - m_vLastCuriousPos = vPos; + m_iCuriousTime = level.inttime + 20000; + m_vNewCuriousPos = vPos; break; } } @@ -855,10 +394,12 @@ ClearEnemy Clear the bot's enemy ==================== */ -void PlayerBot::ClearEnemy(void) +void BotController::ClearEnemy(void) { m_iAttackTime = 0; + m_iConfirmTime = 0; m_pEnemy = NULL; + m_iEnemyEyesTag = -1; m_vOldEnemyPos = vec_zero; m_vLastEnemyPos = vec_zero; } @@ -877,7 +418,7 @@ ____________________ ==================== */ -void PlayerBot::CheckStates(void) +void BotController::CheckStates(void) { m_StateCount = 0; @@ -917,7 +458,7 @@ void PlayerBot::CheckStates(void) assert(m_StateCount); if (!m_StateCount) { - gi.DPrintf("*** WARNING *** %s was stuck with no states !!!", client->pers.netname); + gi.DPrintf("*** WARNING *** %s was stuck with no states !!!", controlledEnt->client->pers.netname); State_Reset(); } } @@ -929,14 +470,14 @@ Default state ==================== */ -void PlayerBot::State_DefaultBegin(void) +void BotController::State_DefaultBegin(void) { - ClearMove(); + movement.ClearMove(); } -void PlayerBot::State_DefaultEnd(void) {} +void BotController::State_DefaultEnd(void) {} -void PlayerBot::State_Reset(void) +void BotController::State_Reset(void) { m_iCuriousTime = 0; m_iAttackTime = 0; @@ -945,6 +486,7 @@ void PlayerBot::State_Reset(void) m_vLastEnemyPos = vec_zero; m_vLastDeathPos = vec_zero; m_pEnemy = NULL; + m_iEnemyEyesTag = -1; } /* @@ -954,13 +496,13 @@ Idle state Make the bot move to random directions ==================== */ -void PlayerBot::InitState_Idle(botfunc_t *func) +void BotController::InitState_Idle(botfunc_t *func) { - func->CheckCondition = &PlayerBot::CheckCondition_Idle; - func->ThinkState = &PlayerBot::State_Idle; + func->CheckCondition = &BotController::CheckCondition_Idle; + func->ThinkState = &BotController::State_Idle; } -bool PlayerBot::CheckCondition_Idle(void) +bool BotController::CheckCondition_Idle(void) { if (m_iCuriousTime) { return false; @@ -973,20 +515,24 @@ bool PlayerBot::CheckCondition_Idle(void) return true; } -void PlayerBot::State_Idle(void) +void BotController::State_Idle(void) { AimAtAimNode(); CheckReload(); - if (!MoveToBestAttractivePoint() && !IsMoving()) { + if (!movement.MoveToBestAttractivePoint() && !movement.IsMoving()) { if (m_vLastDeathPos != vec_zero) { - MoveTo(m_vLastDeathPos); + movement.MoveTo(m_vLastDeathPos); - if (MoveDone()) { + if (movement.MoveDone()) { m_vLastDeathPos = vec_zero; } } else { - AvoidPath(origin - Vector(orientation[0]) * 128.0f, 1024); + Vector randomDir(G_CRandom(16), G_CRandom(16), G_CRandom(16)); + Vector preferredDir = Vector(controlledEnt->orientation[0]) * (rand() % 5 ? 1024 : -1024); + float radius = 512 + G_Random(2048); + + movement.AvoidPath(controlledEnt->origin + randomDir, radius, preferredDir); } } } @@ -998,13 +544,13 @@ Curious state Forward to the last event position ==================== */ -void PlayerBot::InitState_Curious(botfunc_t *func) +void BotController::InitState_Curious(botfunc_t *func) { - func->CheckCondition = &PlayerBot::CheckCondition_Curious; - func->ThinkState = &PlayerBot::State_Curious; + func->CheckCondition = &BotController::CheckCondition_Curious; + func->ThinkState = &BotController::State_Curious; } -bool PlayerBot::CheckCondition_Curious(void) +bool BotController::CheckCondition_Curious(void) { if (m_iAttackTime) { m_iCuriousTime = 0; @@ -1013,7 +559,7 @@ bool PlayerBot::CheckCondition_Curious(void) if (level.inttime > m_iCuriousTime) { if (m_iCuriousTime) { - ClearMove(); + movement.ClearMove(); m_iCuriousTime = 0; } @@ -1023,16 +569,16 @@ bool PlayerBot::CheckCondition_Curious(void) return true; } -void PlayerBot::State_Curious(void) +void BotController::State_Curious(void) { - //AimAt( m_vLastCuriousPos ); AimAtAimNode(); - if (!MoveToBestAttractivePoint(3) && !IsMoving()) { - MoveTo(m_vLastCuriousPos); + if (!movement.MoveToBestAttractivePoint(3) && (!movement.IsMoving() || m_vLastCuriousPos != m_vNewCuriousPos)) { + movement.MoveTo(m_vNewCuriousPos); + m_vLastCuriousPos = m_vNewCuriousPos; } - if (MoveDone()) { + if (movement.MoveDone()) { m_iCuriousTime = 0; } } @@ -1044,11 +590,11 @@ Attack state Attack the enemy ==================== */ -void PlayerBot::InitState_Attack(botfunc_t *func) +void BotController::InitState_Attack(botfunc_t *func) { - func->CheckCondition = &PlayerBot::CheckCondition_Attack; - func->EndState = &PlayerBot::State_EndAttack; - func->ThinkState = &PlayerBot::State_Attack; + func->CheckCondition = &BotController::CheckCondition_Attack; + func->EndState = &BotController::State_EndAttack; + func->ThinkState = &BotController::State_Attack; } static Vector bot_origin; @@ -1075,49 +621,86 @@ static int sentients_compare(const void *elem1, const void *elem2) } } -bool PlayerBot::CheckCondition_Attack(void) +bool BotController::IsValidEnemy(Sentient *sent) const { - Container sents = SentientList; + if (sent == controlledEnt) { + return false; + } - bot_origin = origin; + if (sent->hidden() || (sent->flags & FL_NOTARGET)) { + // Ignore hidden / non-target enemies + return false; + } + + if (sent->IsDead()) { + // Ignore dead enemies + return false; + } + + if (sent->getSolidType() == SOLID_NOT) { + // Ignore non-solid, like spectators + return false; + } + + if (sent->IsSubclassOfPlayer()) { + Player *player = static_cast(sent); + + if (g_gametype->integer >= GT_TEAM && player->GetTeam() == controlledEnt->GetTeam()) { + return false; + } + } else { + if (sent->m_Team == controlledEnt->m_Team) { + return false; + } + } + + return true; +} + +bool BotController::CheckCondition_Attack(void) +{ + Container sents = SentientList; + float maxDistance = 0; + + bot_origin = controlledEnt->origin; sents.Sort(sentients_compare); for (int i = 1; i <= sents.NumObjects(); i++) { - Sentient *sent = sents.ObjectAt(i); - Player *player = (Player *)sent; + Sentient *sent = sents.ObjectAt(i); - if (sent == this) { + if (!IsValidEnemy(sent)) { continue; } - if (sent->hidden()) { - continue; - } + maxDistance = Q_min(world->m_fAIVisionDistance, world->farplane_distance * 0.828); - if (sent->IsDead()) { - continue; - } - - if (sent->IsSubclassOfPlayer()) { - if (g_gametype->integer >= GT_TEAM && player->GetTeam() == GetTeam()) { - continue; + if (controlledEnt->CanSee(sent, 80, maxDistance, false)) { + if (m_pEnemy != sent) { + m_iEnemyEyesTag = -1; } - } else { - if (sent->m_Team == m_Team) { - continue; + + if (!m_pEnemy) { + // Slight reaction time + m_iConfirmTime = level.inttime + (200 + G_Random(200)); + m_iAttackTime = 0; + } + + m_pEnemy = sent; + m_vLastEnemyPos = m_pEnemy->origin; + if (level.inttime < m_iConfirmTime) { + return false; } } - if (CanSee(sent, 80, world->m_fAIVisionDistance, false)) { - m_pEnemy = sent; - m_iAttackTime = level.inttime + 10000; + if (m_pEnemy && level.inttime >= m_iConfirmTime) { + m_iAttackTime = level.inttime + 1000; return true; } } if (level.inttime > m_iAttackTime) { if (m_iAttackTime) { - ClearMove(); + movement.ClearMove(); m_iAttackTime = 0; } @@ -1127,29 +710,34 @@ bool PlayerBot::CheckCondition_Attack(void) return true; } -void PlayerBot::State_EndAttack(void) +void BotController::State_EndAttack(void) { m_botCmd.buttons &= ~(BUTTON_ATTACKLEFT | BUTTON_ATTACKRIGHT); + controlledEnt->ZoomOff(); } -void PlayerBot::State_Attack(void) +void BotController::State_Attack(void) { - Player *p = (Player *)m_pEnemy.Pointer(); bool bMelee = false; + bool bCanSee = false; float fMinDistance = 128; float fMinDistanceSquared = fMinDistance * fMinDistance; + float fEnemyDistanceSquared; + Weapon *pWeap = controlledEnt->GetActiveWeapon(WEAPON_MAIN); + bool bNoMove = false; - if (!m_pEnemy || m_pEnemy->IsDead() || (!p->IsSubclassOfPlayer() && m_pEnemy->m_Team == m_Team) - || (g_gametype->integer >= GT_TEAM && p->GetTeam() == GetTeam())) { + if (!m_pEnemy || !IsValidEnemy(m_pEnemy)) { + // Ignore dead enemies m_iAttackTime = 0; return; } + float fDistanceSquared = (m_pEnemy->origin - controlledEnt->origin).lengthSquared(); - float fDistanceSquared = (m_pEnemy->origin - origin).lengthSquared(); - - if (CanSee(m_pEnemy, 20, world->m_fAIVisionDistance, false)) { - Weapon *pWeap = GetActiveWeapon(WEAPON_MAIN); + m_vOldEnemyPos = m_vLastEnemyPos; + bCanSee = + controlledEnt->CanSee(m_pEnemy, 20, Q_min(world->m_fAIVisionDistance, world->farplane_distance * 0.828), false); + if (bCanSee) { if (!pWeap) { return; } @@ -1158,6 +746,20 @@ void PlayerBot::State_Attack(void) float fPrimaryBulletRangeSquared = fPrimaryBulletRange * fPrimaryBulletRange; float fSecondaryBulletRange = pWeap->GetBulletRange(FIRE_SECONDARY); float fSecondaryBulletRangeSquared = fSecondaryBulletRange * fSecondaryBulletRange; + float fSpreadFactor = pWeap->GetSpreadFactor(FIRE_PRIMARY); + + // + // check the fire movement speed if the weapon has a max fire movement + // + if (pWeap->GetMaxFireMovement() < 1 && pWeap->HasAmmoInClip(FIRE_PRIMARY)) { + float length; + + length = controlledEnt->velocity.length(); + if ((length / sv_runspeed->value) > (pWeap->GetMaxFireMovementMult())) { + bNoMove = true; + movement.ClearMove(); + } + } fMinDistance = fPrimaryBulletRange; @@ -1167,51 +769,125 @@ void PlayerBot::State_Attack(void) fMinDistanceSquared = fMinDistance * fMinDistance; - if (client->ps.stats[STAT_AMMO] > 0 || client->ps.stats[STAT_CLIPAMMO] > 0) { + if (controlledEnt->client->ps.stats[STAT_AMMO] > 0 || controlledEnt->client->ps.stats[STAT_CLIPAMMO] > 0) { if (fDistanceSquared <= fPrimaryBulletRangeSquared) { if (pWeap->IsSemiAuto()) { - m_botCmd.buttons ^= BUTTON_ATTACKLEFT; + if (controlledEnt->client->ps.iViewModelAnim == VM_ANIM_IDLE + || controlledEnt->client->ps.iViewModelAnim >= VM_ANIM_IDLE_0 + && controlledEnt->client->ps.iViewModelAnim <= VM_ANIM_IDLE_2) { + if (fSpreadFactor < 0.25) { + m_botCmd.buttons ^= BUTTON_ATTACKLEFT; + if (pWeap->GetZoom()) { + if (!controlledEnt->IsZoomed()) { + m_botCmd.buttons |= BUTTON_ATTACKRIGHT; + } else { + m_botCmd.buttons &= ~BUTTON_ATTACKRIGHT; + } + } + } else { + bNoMove = true; + movement.ClearMove(); + } + } else { + m_botCmd.buttons &= ~(BUTTON_ATTACKLEFT | BUTTON_ATTACKRIGHT); + controlledEnt->ZoomOff(); + } } else { m_botCmd.buttons |= BUTTON_ATTACKLEFT; } } else { - m_botCmd.buttons &= ~BUTTON_ATTACKLEFT; + m_botCmd.buttons &= ~(BUTTON_ATTACKLEFT | BUTTON_ATTACKRIGHT); + controlledEnt->ZoomOff(); } - } else if (pWeap->GetFireType(FIRE_SECONDARY) == FT_MELEE) { - bMelee = true; + } else { + m_botCmd.buttons &= ~(BUTTON_ATTACKLEFT | BUTTON_ATTACKRIGHT); + controlledEnt->ZoomOff(); + } + + if (pWeap->GetFireType(FIRE_SECONDARY) == FT_MELEE) { + if (controlledEnt->client->ps.stats[STAT_AMMO] <= 0 && controlledEnt->client->ps.stats[STAT_CLIPAMMO] <= 0) { + bMelee = true; + } else if (fDistanceSquared <= fSecondaryBulletRangeSquared) { + bMelee = true; + } + } + + if (bMelee) { + m_botCmd.buttons &= ~BUTTON_ATTACKLEFT; if (fDistanceSquared <= fSecondaryBulletRangeSquared) { m_botCmd.buttons ^= BUTTON_ATTACKRIGHT; } else { m_botCmd.buttons &= ~BUTTON_ATTACKRIGHT; } - } else { - m_botCmd.buttons &= ~(BUTTON_ATTACKLEFT | BUTTON_ATTACKRIGHT); } + + m_iAttackTime = level.inttime + 1000; + m_iAttackStopAimTime = level.inttime + 3000; + m_vLastEnemyPos = m_pEnemy->centroid; } else { m_botCmd.buttons &= ~(BUTTON_ATTACKLEFT | BUTTON_ATTACKRIGHT); fMinDistanceSquared = 0; } - AimAt(m_vLastEnemyPos); + if (bCanSee || level.inttime < m_iAttackStopAimTime) { + Vector vRandomOffset; + Vector vTarget; + orientation_t eyes_or; - m_vOldEnemyPos = m_vLastEnemyPos; - m_vLastEnemyPos = m_pEnemy->centroid; + if (m_iEnemyEyesTag == -1) { + // Cache the tag + m_iEnemyEyesTag = gi.Tag_NumForName(m_pEnemy->edict->tiki, "eyes bone"); + } - if ((!MoveToBestAttractivePoint(5) && !IsMoving()) || (m_vOldEnemyPos != m_vLastEnemyPos && !MoveDone())) { - if (!bMelee) { - if ((origin - m_vLastEnemyPos).lengthSquared() < fMinDistanceSquared) { - Vector vDir = origin - m_vLastEnemyPos; + if (m_iEnemyEyesTag != -1) { + // Use the enemy's eyes bone + m_pEnemy->GetTag(m_iEnemyEyesTag, &eyes_or); + + vRandomOffset = Vector(G_CRandom(8), G_CRandom(8), -G_Random(32)); + vTarget = eyes_or.origin + vRandomOffset; + rotation.AimAt(eyes_or.origin + vRandomOffset); + } else { + vRandomOffset = Vector(G_CRandom(8), G_CRandom(8), 16 + G_Random(m_pEnemy->viewheight - 16)); + vTarget = m_pEnemy->origin + vRandomOffset; + } + + rotation.AimAt(vTarget); + } else { + AimAtAimNode(); + } + + if (bNoMove) { + return; + } + + fEnemyDistanceSquared = (controlledEnt->origin - m_vLastEnemyPos).lengthSquared(); + + if ((!movement.MoveToBestAttractivePoint(5) && !movement.IsMoving()) + || (m_vOldEnemyPos != m_vLastEnemyPos && !movement.MoveDone()) || fEnemyDistanceSquared < fMinDistanceSquared) { + if (!bMelee || !bCanSee) { + if (fEnemyDistanceSquared < fMinDistanceSquared) { + Vector vDir = controlledEnt->origin - m_vLastEnemyPos; VectorNormalizeFast(vDir); - AvoidPath(m_vLastEnemyPos, fMinDistance, vDir); + movement.AvoidPath(m_vLastEnemyPos, fMinDistance, Vector(controlledEnt->orientation[1]) * 512); } else { - MoveNear(m_vLastEnemyPos, fMinDistance); + movement.MoveTo(m_vLastEnemyPos); + } + + if (!bCanSee && movement.MoveDone()) { + // Lost track of the enemy + ClearEnemy(); + return; } } else { - MoveTo(m_vLastEnemyPos); + movement.MoveTo(m_vLastEnemyPos); } } + + if (movement.IsMoving()) { + m_iAttackTime = level.inttime + 1000; + } } /* @@ -1221,19 +897,19 @@ Grenade state Avoid any grenades ==================== */ -void PlayerBot::InitState_Grenade(botfunc_t *func) +void BotController::InitState_Grenade(botfunc_t *func) { - func->CheckCondition = &PlayerBot::CheckCondition_Grenade; - func->ThinkState = &PlayerBot::State_Grenade; + func->CheckCondition = &BotController::CheckCondition_Grenade; + func->ThinkState = &BotController::State_Grenade; } -bool PlayerBot::CheckCondition_Grenade(void) +bool BotController::CheckCondition_Grenade(void) { // FIXME: TODO return false; } -void PlayerBot::State_Grenade(void) +void BotController::State_Grenade(void) { // FIXME: TODO } @@ -1245,20 +921,21 @@ Weapon state Change weapon when necessary ==================== */ -void PlayerBot::InitState_Weapon(botfunc_t *func) +void BotController::InitState_Weapon(botfunc_t *func) { - func->CheckCondition = &PlayerBot::CheckCondition_Weapon; - func->BeginState = &PlayerBot::State_BeginWeapon; + func->CheckCondition = &BotController::CheckCondition_Weapon; + func->BeginState = &BotController::State_BeginWeapon; } -bool PlayerBot::CheckCondition_Weapon(void) +bool BotController::CheckCondition_Weapon(void) { - return GetActiveWeapon(WEAPON_MAIN) != BestWeapon(NULL, false, WEAPON_CLASS_THROWABLE); + return controlledEnt->GetActiveWeapon(WEAPON_MAIN) + != controlledEnt->BestWeapon(NULL, false, WEAPON_CLASS_THROWABLE); } -void PlayerBot::State_BeginWeapon(void) +void BotController::State_BeginWeapon(void) { - Weapon *weap = BestWeapon(NULL, false, WEAPON_CLASS_THROWABLE); + Weapon *weap = controlledEnt->BestWeapon(NULL, false, WEAPON_CLASS_THROWABLE); if (weap == NULL) { SendCommand("safeholster 1"); @@ -1268,17 +945,124 @@ void PlayerBot::State_BeginWeapon(void) SendCommand(va("use \"%s\"", weap->model.c_str())); } -void PlayerBot::Spawned(void) -{ - ClearEnemy(); - m_iCuriousTime = 0; +Weapon* BotController::FindWeaponWithAmmo() { + + Weapon *next; + int n; + int j; + int bestrank; + Weapon *bestweapon; + const Container& inventory = controlledEnt->getInventory(); - Player::Spawned(); + n = inventory.NumObjects(); + + // Search until we find the best weapon with ammo + bestweapon = NULL; + bestrank = -999999; + + for (j = 1; j <= n; j++) { + next = (Weapon *)G_GetEntity(inventory.ObjectAt(j)); + + assert(next); + if (!next->IsSubclassOfWeapon() || next->IsSubclassOfInventoryItem()) { + continue; + } + + if (next->GetWeaponClass() & WEAPON_CLASS_THROWABLE) { + continue; + } + + if (next->GetRank() < bestrank) { + continue; + } + + if (!next->HasAmmo(FIRE_PRIMARY)) { + continue; + } + + bestweapon = (Weapon*)next; + bestrank = bestweapon->GetRank(); + } + + return bestweapon; } -void PlayerBot::Killed(Event *ev) +Weapon* BotController::FindMeleeWeapon() { + + Weapon *next; + int n; + int j; + int bestrank; + Weapon *bestweapon; + const Container& inventory = controlledEnt->getInventory(); + + n = inventory.NumObjects(); + + // Search until we find the best weapon with ammo + bestweapon = NULL; + bestrank = -999999; + + for (j = 1; j <= n; j++) { + next = (Weapon *)G_GetEntity(inventory.ObjectAt(j)); + + assert(next); + if (!next->IsSubclassOfWeapon() || next->IsSubclassOfInventoryItem()) { + continue; + } + + if (next->GetRank() < bestrank) { + continue; + } + + if (next->GetFireType(FIRE_SECONDARY) != FT_MELEE) { + continue; + } + + bestweapon = (Weapon*)next; + bestrank = bestweapon->GetRank(); + } + + return bestweapon; +} + +void BotController::UseWeaponWithAmmo() { + Weapon* bestWeapon = FindWeaponWithAmmo(); + if (!bestWeapon) { + // + // If there is no weapon with ammo, fallback to a weapon that can melee + // + bestWeapon = FindMeleeWeapon(); + } + + if (!bestWeapon || bestWeapon == controlledEnt->GetActiveWeapon(WEAPON_MAIN)) { + return; + } + + controlledEnt->useWeapon(bestWeapon, WEAPON_MAIN); +} + +void BotController::Spawned(void) { - Player::Killed(ev); + ClearEnemy(); + m_iCuriousTime = 0; + m_botCmd.buttons = 0; +} + +void BotController::Think() +{ + usercmd_t ucmd; + usereyes_t eyeinfo; + + UpdateBotStates(); + GetUsercmd(&ucmd); + GetEyeInfo(&eyeinfo); + + G_ClientThink(controlledEnt->edict, &ucmd, &eyeinfo); +} + +void BotController::Killed(const Event& ev) +{ + Entity *attacker; // send the respawn buttons if (!(m_botCmd.buttons & BUTTON_ATTACKLEFT)) { @@ -1293,18 +1077,155 @@ void PlayerBot::Killed(Event *ev) m_botEyes.angles[0] = 0; m_botEyes.angles[1] = 0; - m_vLastDeathPos = origin; + attacker = ev.GetEntity(1); + + if (attacker && rand() % 5 == 0) { + // 1/5 chance to go back to the attacker position + m_vLastDeathPos = attacker->origin; + } else { + m_vLastDeathPos = vec_zero; + } + + // Choose a new random primary weapon + Event event(EV_Player_PrimaryDMWeapon); + event.AddString("auto"); + + controlledEnt->ProcessEvent(event); + + // + // This is useful to change nationality in Spearhead and Breakthrough + // this allows the AI to use more weapons + // + Info_SetValueForKey(controlledEnt->client->pers.userinfo, "dm_playermodel", G_GetRandomAlliedPlayerModel()); + Info_SetValueForKey(controlledEnt->client->pers.userinfo, "dm_playergermanmodel", G_GetRandomGermanPlayerModel()); + + G_ClientUserinfoChanged(controlledEnt->edict, controlledEnt->client->pers.userinfo); } -void PlayerBot::GotKill(Event *ev) +void BotController::GotKill(const Event& ev) { - Player::GotKill(ev); - ClearEnemy(); m_iCuriousTime = 0; + + if (level.inttime >= m_iNextTauntTime && (rand() % 5) == 0) { + // + // Randomly play a taunt + // + Event event("dmmessage"); + + event.AddInteger(0); + + if (g_protocol >= protocol_e::PROTOCOL_MOHTA_MIN) { + event.AddString("*5" + str(1 + (rand() % 8))); + } else { + event.AddString("*4" + str(1 + (rand() % 9))); + } + + controlledEnt->ProcessEvent(event); + + m_iNextTauntTime = level.inttime + 5000; + } } -void PlayerBot::EventStuffText(Event *ev) +void BotController::EventStuffText(const str& text) { - SendCommand(ev->GetString(1)); + SendCommand(text); +} + +void BotController::setControlledEntity(Player *player) +{ + controlledEnt = player; + movement.SetControlledEntity(player); + rotation.SetControlledEntity(player); + + delegateHandle_gotKill = player->delegate_gotKill.Add(std::bind(&BotController::GotKill, this, std::placeholders::_1)); + delegateHandle_killed = player->delegate_killed.Add(std::bind(&BotController::Killed, this, std::placeholders::_1)); + delegateHandle_stufftext = player->delegate_stufftext.Add(std::bind(&BotController::EventStuffText, this, std::placeholders::_1)); +} + +Player *BotController::getControlledEntity() const +{ + return controlledEnt; +} + +BotController *BotControllerManager::createController(Player *player) +{ + BotController *controller = new BotController(); + controller->setControlledEntity(player); + + controllers.AddObject(controller); + + return controller; +} + +void BotControllerManager::removeController(BotController *controller) +{ + controllers.RemoveObject(controller); + delete controller; +} + +BotController *BotControllerManager::findController(Entity *ent) +{ + int i; + + for (i = 1; i <= controllers.NumObjects(); i++) { + BotController *controller = controllers.ObjectAt(i); + if (controller->getControlledEntity() == ent) { + return controller; + } + } + + return nullptr; +} + +const Container& BotControllerManager::getControllers() const +{ + return controllers; +} + +BotControllerManager::~BotControllerManager() +{ + Cleanup(); +} + +void BotControllerManager::Init() +{ + BotController::Init(); +} + +void BotControllerManager::Cleanup() +{ + int i; + + BotController::Init(); + + for (i = 1; i <= controllers.NumObjects(); i++) { + BotController *controller = controllers.ObjectAt(i); + delete controller; + } + + controllers.FreeObjectList(); +} + +void BotControllerManager::ThinkControllers() +{ + int i; + + // Delete controllers that don't have associated player entity + // This cannot happen unless some mods remove them + for (i = controllers.NumObjects(); i > 0; i--) { + BotController* controller = controllers.ObjectAt(i); + if (!controller->getControlledEntity()) { + gi.DPrintf("Bot %d has no associated player entity. This shouldn't happen unless the entity has been removed by a script. The controller will be removed, please fix.\n", i); + + // Remove the controller, it will be recreated later to match `sv_numbots` + delete controller; + controllers.RemoveObjectAt(i); + } + } + + for (i = 1; i <= controllers.NumObjects(); i++) { + BotController *controller = controllers.ObjectAt(i); + controller->Think(); + } } diff --git a/code/fgame/playerbot.h b/code/fgame/playerbot.h index c39954fe..6d67fab3 100644 --- a/code/fgame/playerbot.h +++ b/code/fgame/playerbot.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -21,8 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // playerbot.h: Multiplayer bot system. -#ifndef __PLAYERBOT_H__ -#define __PLAYERBOT_H__ +#pragma once #include "player.h" #include "navigate.h" @@ -35,65 +34,144 @@ typedef struct nodeAttract_s { AttractiveNodePtr m_pNode; } nodeAttract_t; -class PlayerBot : public Player +class BotController; + +class BotMovement { +public: + BotMovement(); + + void SetControlledEntity(Player *newEntity); + + void MoveThink(usercmd_t& botcmd); + + void AvoidPath( + Vector vPos, + float fAvoidRadius, + Vector vPreferredDir = vec_zero, + float *vLeashHome = NULL, + float fLeashRadius = 0.0f + ); + void MoveNear(Vector vNear, float fRadius, float *vLeashHome = NULL, float fLeashRadius = 0.0f); + void MoveTo(Vector vPos, float *vLeashHome = NULL, float fLeashRadius = 0.0f); + bool MoveToBestAttractivePoint(int iMinPriority = 0); + + bool CanMoveTo(Vector vPos); + bool MoveDone(); + bool IsMoving(void); + void ClearMove(void); + + Vector GetCurrentGoal() const; + +private: + void CheckAttractiveNodes(); + void CheckEndPos(Entity *entity); + void CheckJump(usercmd_t& botcmd); + void NewMove(); + +private: + SafePtr controlledEntity; + AttractiveNodePtr m_pPrimaryAttract; + Container m_attractList; + ActorPath m_Path; + + Vector m_vCurrentOrigin; + Vector m_vTargetPos; + Vector m_vCurrentGoal; + Vector m_vLastValidDir; + Vector m_vLastValidGoal; + Vector m_vLastCheckPos[2]; + float m_fAttractTime; + int m_iTempAwayTime; + int m_iNumBlocks; + int m_iCheckPathTime; + bool m_bPathing; + bool m_bTempAway; +}; + +class BotRotation +{ +public: + BotRotation(); + + void SetControlledEntity(Player *newEntity); + + void TurnThink(usercmd_t& botcmd, usereyes_t& eyeinfo); + const Vector& GetTargetAngles() const; + void SetTargetAngles(Vector vAngles); + void AimAt(Vector vPos); + +private: + SafePtr controlledEntity; + + Vector m_vTargetAng; + Vector m_vCurrentAng; + Vector m_vAngSpeed; + float m_fYawSpeedMult; +}; + +class BotState +{ +public: + virtual bool CheckCondition() const = 0; + virtual void Begin() = 0; + virtual void End() = 0; + virtual void Think() = 0; +}; + +class BotController : public Listener +{ +public: struct botfunc_t { - bool (PlayerBot::*CheckCondition)(void); - void (PlayerBot::*BeginState)(void); - void (PlayerBot::*EndState)(void); - void (PlayerBot::*ThinkState)(void); + bool (BotController::*CheckCondition)(void); + void (BotController::*BeginState)(void); + void (BotController::*EndState)(void); + void (BotController::*ThinkState)(void); }; private: static botfunc_t botfuncs[]; - // Paths - ActorPath m_Path; - Vector m_vTargetPos; - Vector m_vCurrentGoal; - Vector m_vLastValidDir; - Vector m_vLastValidGoal; - bool m_bPathing; - bool m_bTempAway; - bool m_bAimPath; - bool m_bDeltaMove; - int m_iTempAwayTime; - int m_iCheckPathTime; - AttractiveNodePtr m_pPrimaryAttract; - float m_fAttractTime; - Container m_attractList; + BotMovement movement; + BotRotation rotation; // States int m_iCuriousTime; int m_iAttackTime; + int m_iConfirmTime; + int m_iAttackStopAimTime; Vector m_vLastCuriousPos; + Vector m_vNewCuriousPos; Vector m_vOldEnemyPos; Vector m_vLastEnemyPos; Vector m_vLastDeathPos; SafePtr m_pEnemy; + int m_iEnemyEyesTag; // Input usercmd_t m_botCmd; usereyes_t m_botEyes; - // Direction - Vector m_vTargetAng; - Vector m_vCurrentAng; - Vector m_vAngSpeed; - float m_fYawSpeedMult; - // States int m_StateCount; unsigned int m_StateFlags; ScriptThreadLabel m_RunLabel; + // Taunts + int m_iNextTauntTime; + private: - void CheckAttractiveNodes(void); - void MoveThink(void); - void TurnThink(void); - void CheckEndPos(void); - void CheckJump(void); + DelegateHandle delegateHandle_gotKill; + DelegateHandle delegateHandle_killed; + DelegateHandle delegateHandle_stufftext; + +private: + Weapon* FindWeaponWithAmmo(void); + Weapon* FindMeleeWeapon(void); + void UseWeaponWithAmmo(void); + void CheckUse(void); + void CheckValidWeapon(void); void State_DefaultBegin(void); void State_DefaultEnd(void); @@ -116,6 +194,7 @@ private: void State_BeginAttack(void); void State_EndAttack(void); void State_Attack(void); + bool IsValidEnemy(Sentient *sent) const; static void InitState_Grenade(botfunc_t *func); bool CheckCondition_Grenade(void); @@ -132,51 +211,80 @@ private: void CheckStates(void); public: - CLASS_PROTOTYPE(PlayerBot); + CLASS_PROTOTYPE(BotController); - PlayerBot(); + BotController(); + ~BotController(); static void Init(void); void GetEyeInfo(usereyes_t *eyeinfo); void GetUsercmd(usercmd_t *ucmd); - void SetTargetAngles(Vector vAngles); void UpdateBotStates(void); void CheckReload(void); - void AimAt(Vector vPos); void AimAtAimNode(void); - void AvoidPath( - Vector vPos, - float fAvoidRadius, - Vector vPreferredDir = vec_zero, - float *vLeashHome = NULL, - float fLeashRadius = 0.0f - ); - void MoveNear(Vector vNear, float fRadius, float *vLeashHome = NULL, float fLeashRadius = 0.0f); - void MoveTo(Vector vPos, float *vLeashHome = NULL, float fLeashRadius = 0.0f); - bool MoveToBestAttractivePoint(int iMinPriority = 0); - - bool CanMoveTo(Vector vPos); - bool MoveDone(void); - bool IsMoving(void); - void ClearMove(void); - void NoticeEvent(Vector vPos, int iType, Entity *pEnt, float fDistanceSquared, float fRadiusSquared); void ClearEnemy(void); void SendCommand(const char *text); - void setAngles(Vector angles) override; - void updateOrigin(void) override; + void Think(); - void Spawned(void) override; + void Spawned(void); - void Killed(Event *ev); - void GotKill(Event *ev); - void EventStuffText(Event *ev); + void Killed(const Event& ev); + void GotKill(const Event& ev); + void EventStuffText(const str& text); + + BotMovement& GetMovement(); + +public: + void setControlledEntity(Player *player); + Player *getControlledEntity() const; + +private: + SafePtr controlledEnt; }; -#endif /* playerbot.h */ +class BotControllerManager : public Listener +{ +public: + CLASS_PROTOTYPE(BotControllerManager); + +public: + ~BotControllerManager(); + + BotController *createController(Player *player); + void removeController(BotController *controller); + BotController *findController(Entity *ent); + const Container& getControllers() const; + + void Init(); + void Cleanup(); + void ThinkControllers(); + +private: + Container controllers; +}; + +class BotManager : public Listener +{ +public: + CLASS_PROTOTYPE(BotManager); + +public: + BotControllerManager& getControllerManager(); + + void Init(); + void Cleanup(); + void Frame(); + void BroadcastEvent(Entity *originator, Vector origin, int iType, float radius); + +private: + BotControllerManager botControllerManager; +}; + +extern BotManager botManager; diff --git a/code/fgame/playerbot_master.cpp b/code/fgame/playerbot_master.cpp new file mode 100644 index 00000000..d4cdcd4e --- /dev/null +++ b/code/fgame/playerbot_master.cpp @@ -0,0 +1,114 @@ +#include "playerbot.h" +/* +=========================================================================== +Copyright (C) 2024 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA source code 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. + +OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// playerbot_master.cpp: Multiplayer bot system. + +#include "g_local.h" +#include "actor.h" +#include "playerbot.h" +#include "consoleevent.h" +#include "debuglines.h" +#include "scriptexception.h" +#include "vehicleturret.h" +#include "weaputils.h" + +BotManager botManager; + +CLASS_DECLARATION(Listener, BotControllerManager, NULL) { + {NULL, NULL} +}; + +CLASS_DECLARATION(Listener, BotManager, NULL) { + {NULL, NULL} +}; + +void BotManager::Init() +{ + botControllerManager.Init(); +} + +void BotManager::Cleanup() +{ + botControllerManager.Cleanup(); +} + +void BotManager::Frame() +{ + botControllerManager.ThinkControllers(); +} + +void BotManager::BroadcastEvent(Entity *originator, Vector origin, int iType, float radius) +{ + Sentient *ent; + Actor *act; + Vector delta; + str name; + float r2; + float dist2; + int i; + int iNumSentients; + int iAreaNum; + BotController *controller; + + if (radius <= 0.0f) { + radius = G_AIEventRadius(iType); + } + + assert(originator); + + r2 = Square(radius); + + const Container& controllers = getControllerManager().getControllers(); + for (i = 1; i <= controllers.NumObjects(); i++) { + controller = controllers.ObjectAt(i); + ent = controller->getControlledEntity(); + if (!ent || ent == originator || ent->deadflag) { + continue; + } + + delta = origin - ent->centroid; + + // dot product returns length squared + dist2 = Square(delta); + + if (originator) { + iAreaNum = originator->edict->r.areanum; + } else { + iAreaNum = gi.AreaForPoint(origin); + } + + if (dist2 > r2) { + continue; + } + + if (iAreaNum != ent->edict->r.areanum && !gi.AreasConnected(iAreaNum, ent->edict->r.areanum)) { + continue; + } + + controller->NoticeEvent(origin, iType, originator, dist2, r2); + } +} + +BotControllerManager& BotManager::getControllerManager() +{ + return botControllerManager; +} diff --git a/code/fgame/playerbot_movement.cpp b/code/fgame/playerbot_movement.cpp new file mode 100644 index 00000000..03e402f0 --- /dev/null +++ b/code/fgame/playerbot_movement.cpp @@ -0,0 +1,635 @@ +/* +=========================================================================== +Copyright (C) 2024 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA source code 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. + +OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// playerbot_movement.cpp: Manages bot movements + +#include "playerbot.h" +#include "debuglines.h" + +BotMovement::BotMovement() +{ + controlledEntity = NULL; + + m_Path.SetFallHeight(400); + m_bPathing = false; + m_bTempAway = false; + m_fAttractTime = 0; + + m_iCheckPathTime = 0; + m_iTempAwayTime = 0; + m_iNumBlocks = 0; +} + +void BotMovement::SetControlledEntity(Player *newEntity) +{ + controlledEntity = newEntity; +} + +void BotMovement::MoveThink(usercmd_t& botcmd) +{ + Vector vDir; + Vector vAngles; + Vector vWishDir; + + botcmd.forwardmove = 0; + botcmd.rightmove = 0; + + CheckAttractiveNodes(); + + if (!IsMoving()) { + return; + } + + if (level.inttime >= m_Path.Time() + 1000 && m_vCurrentOrigin != controlledEntity->origin) { + m_vCurrentOrigin = controlledEntity->origin; + + if (m_Path.CurrentNode()) { + // recalculate paths because of a new origin + m_Path.ReFindPath(controlledEntity->origin, controlledEntity); + } + } + + if (m_bTempAway && level.inttime >= m_iTempAwayTime) { + m_bTempAway = false; + m_Path.FindPath(controlledEntity->origin, m_vTargetPos, controlledEntity, 0, NULL, 0); + } + + if (!m_bTempAway) { + if (m_Path.CurrentNode()) { + m_Path.UpdatePos(controlledEntity->origin, 8); + + m_vCurrentGoal = controlledEntity->origin; + VectorAdd2D(m_vCurrentGoal, m_Path.CurrentDelta(), m_vCurrentGoal); + + if (MoveDone()) { + // Clear the path + m_Path.Clear(); + } + } + } + + if (ai_debugpath->integer) { + G_DebugLine(controlledEntity->centroid, m_vCurrentGoal + Vector(0, 0, 36), 1, 1, 0, 1); + } + + // Check if we're blocked + if (level.inttime >= m_iCheckPathTime) { + m_iCheckPathTime = level.inttime + 1000; + + if (m_iNumBlocks >= 5) { + // Give up + ClearMove(); + } + + m_bTempAway = false; + + if (controlledEntity->groundentity || controlledEntity->client->ps.walking) { + if (controlledEntity->GetMoveResult() >= MOVERESULT_BLOCKED + || controlledEntity->velocity.lengthSquared() <= Square(8)) { + m_bTempAway = true; + } else if ((controlledEntity->origin - m_vLastCheckPos[0]).lengthSquared() <= Square(32) + && (controlledEntity->origin - m_vLastCheckPos[1]).lengthSquared() <= Square(32)) { + m_bTempAway = true; + } + } else { + // falling + if (controlledEntity->GetMoveResult() >= MOVERESULT_BLOCKED) { + // stuck while falling + m_bTempAway = true; + } + } + + if (m_bTempAway) { + Vector nextPos; + Vector dir; + + m_bTempAway = true; + m_iTempAwayTime = level.inttime + 750; + m_iNumBlocks++; + + // Try to backward a little + if (m_Path.CurrentNode()) { + nextPos = m_Path.CurrentNode()->point; + } else { + nextPos = m_vTargetPos; + } + + m_Path.Clear(); + m_Path.ForceShortLookahead(); + + if (rand() % 10 != 0) { + dir = nextPos - controlledEntity->origin; + dir.z = 0; + dir.normalize(); + + if (dir.x < -0.5 || dir.x > 0.5) { + dir.x *= 4; + dir.y /= 4; + } else if (dir.y < -0.5 || dir.y > 0.5) { + dir.x /= 4; + dir.y *= 4; + } else { + dir.x = G_CRandom(2); + dir.y = G_CRandom(2); + } + + m_vCurrentGoal = nextPos + dir * 128; + } else { + m_vCurrentGoal = controlledEntity->origin + Vector(G_CRandom(512), G_CRandom(512), G_CRandom(512)); + } + + } else { + m_iNumBlocks = 0; + + if (!m_Path.CurrentNode()) { + m_vTargetPos = controlledEntity->origin + Vector(G_CRandom(512), G_CRandom(512), G_CRandom(512)); + m_vCurrentGoal = m_vTargetPos; + } + } + + m_vLastCheckPos[1] = m_vLastCheckPos[0]; + m_vLastCheckPos[0] = controlledEntity->origin; + } + + if (ai_debugpath->integer) { + PathInfo *pos = m_Path.CurrentNode(); + + if (pos != NULL) { + while (pos != m_Path.LastNode()) { + Vector vStart = pos->point + Vector(0, 0, 32); + + pos--; + + Vector vEnd = pos->point + Vector(0, 0, 32); + + G_DebugLine(vStart, vEnd, 1, 0, 0, 1); + } + } + } + + if (m_Path.CurrentNode()) { + if ((m_vTargetPos - controlledEntity->origin).lengthSquared() <= Square(16)) { + ClearMove(); + } + } else { + if ((m_vTargetPos - controlledEntity->origin).lengthXYSquared() <= Square(16)) { + ClearMove(); + } + } + + // Rotate the dir + if (m_Path.CurrentNode()) { + vDir[0] = m_Path.CurrentDelta()[0]; + vDir[1] = m_Path.CurrentDelta()[1]; + } else { + vDir = m_vCurrentGoal - controlledEntity->origin; + } + vDir[2] = 0; + + VectorNormalize2D(vDir); + vAngles = vDir.toAngles() - controlledEntity->angles; + vAngles.AngleVectorsLeft(&vWishDir); + + m_vLastValidDir = vDir; + m_vLastValidGoal = m_vCurrentGoal; + + // Forward to the specified direction + float x = vWishDir.x * 127; + float y = -vWishDir.y * 127; + + botcmd.forwardmove = (signed char)Q_clamp(x, -127, 127); + botcmd.rightmove = (signed char)Q_clamp(y, -127, 127); + + CheckJump(botcmd); +} + +void BotMovement::CheckAttractiveNodes() +{ + for (int i = m_attractList.NumObjects(); i > 0; i--) { + nodeAttract_t *a = m_attractList.ObjectAt(i); + + if (a->m_pNode == NULL || !a->m_pNode->CheckTeam(controlledEntity) || level.time > a->m_fRespawnTime) { + delete a; + m_attractList.RemoveObjectAt(i); + } + } +} + +void BotMovement::CheckEndPos(Entity *entity) +{ + Vector start; + Vector end; + trace_t trace; + + if (!m_Path.LastNode()) { + return; + } + + start = m_Path.LastNode()->point; + end = m_vTargetPos; + + trace = + G_Trace(start, entity->mins, entity->maxs, end, entity, MASK_TARGETPATH, true, "BotController::CheckEndPos"); + + if (trace.fraction < 0.95f) { + m_vTargetPos = trace.endpos; + } +} + +void BotMovement::CheckJump(usercmd_t& botcmd) +{ + Vector start; + Vector end; + Vector dir; + trace_t trace; + + if (controlledEntity->GetLadder()) { + if (!botcmd.upmove) { + botcmd.upmove = 127; + } else { + botcmd.upmove = 0; + } + return; + } + + dir = m_vLastValidDir; + + start = controlledEntity->origin + Vector(0, 0, STEPSIZE); + end = + controlledEntity->origin + Vector(0, 0, STEPSIZE) + dir * (controlledEntity->maxs.y - controlledEntity->mins.y); + + if (ai_debugpath->integer) { + G_DebugLine(start, end, 1, 0, 1, 1); + } + + // Check if the bot needs to jump + trace = G_Trace( + start, + controlledEntity->mins, + controlledEntity->maxs, + end, + controlledEntity, + MASK_PLAYERSOLID, + false, + "BotController::CheckJump" + ); + + // No need to jump + if (trace.fraction > 0.5f) { + botcmd.upmove = 0; + return; + } + + start = controlledEntity->origin; + end = controlledEntity->origin + Vector(0, 0, STEPSIZE * 3); + + if (ai_debugpath->integer) { + G_DebugLine(start, end, 1, 0, 1, 1); + } + + // Check if the bot can jump up + trace = G_Trace( + start, + controlledEntity->mins, + controlledEntity->maxs, + end, + controlledEntity, + MASK_PLAYERSOLID, + true, + "BotController::CheckJump" + ); + + start = trace.endpos; + end = trace.endpos + dir * (controlledEntity->maxs.y - controlledEntity->mins.y); + + if (ai_debugpath->integer) { + G_DebugLine(start, end, 1, 0, 1, 1); + } + + Vector bounds[2]; + bounds[0] = Vector(controlledEntity->mins[0], controlledEntity->mins[1], 0); + bounds[1] = Vector( + controlledEntity->maxs[0], + controlledEntity->maxs[1], + (controlledEntity->maxs[0] + controlledEntity->maxs[1]) * 0.5 + ); + + // Check if the bot can jump at the location + trace = G_Trace( + start, bounds[0], bounds[1], end, controlledEntity, MASK_PLAYERSOLID, false, "BotController::CheckJump" + ); + + if (trace.fraction < 1) { + botcmd.upmove = 0; + return; + } + + // Make the bot climb walls + if (!botcmd.upmove) { + botcmd.upmove = 127; + } else { + botcmd.upmove = 0; + } +} + +/* +==================== +AvoidPath + +Avoid the specified position within the radius and start from a direction +==================== +*/ +void BotMovement::AvoidPath( + Vector vAvoid, float fAvoidRadius, Vector vPreferredDir, float *vLeashHome, float fLeashRadius +) +{ + Vector vDir; + + if (vPreferredDir == vec_zero) { + vDir = controlledEntity->origin - vAvoid; + VectorNormalizeFast(vDir); + } else { + vDir = vPreferredDir; + } + + m_Path.FindPathAway( + controlledEntity->origin, vAvoid, vDir, controlledEntity, fAvoidRadius, vLeashHome, fLeashRadius * fLeashRadius + ); + NewMove(); + + if (!m_Path.CurrentNode()) { + // Random movements + m_vTargetPos = controlledEntity->origin + Vector(G_Random(256) - 128, G_Random(256) - 128, G_Random(256) - 128); + m_vCurrentGoal = m_vTargetPos; + return; + } + + m_vTargetPos = m_Path.LastNode()->point; +} + +/* +==================== +MoveNear + +Move near the specified position within the radius +==================== +*/ +void BotMovement::MoveNear(Vector vNear, float fRadius, float *vLeashHome, float fLeashRadius) +{ + m_Path.FindPathNear( + controlledEntity->origin, vNear, controlledEntity, 0, fRadius * fRadius, vLeashHome, fLeashRadius * fLeashRadius + ); + NewMove(); + + if (!m_Path.CurrentNode()) { + m_bPathing = false; + return; + } + + m_vTargetPos = m_Path.LastNode()->point; +} + +/* +==================== +MoveTo + +Move to the specified position +==================== +*/ +void BotMovement::MoveTo(Vector vPos, float *vLeashHome, float fLeashRadius) +{ + m_vTargetPos = vPos; + m_Path.FindPath( + controlledEntity->origin, m_vTargetPos, controlledEntity, 0, vLeashHome, fLeashRadius * fLeashRadius + ); + + NewMove(); + + if (!m_Path.CurrentNode()) { + m_bPathing = false; + return; + } + + CheckEndPos(controlledEntity); +} + +/* +==================== +MoveToBestAttractivePoint + +Move to the nearest attractive point with a minimum priority +Returns true if no attractive point was found +==================== +*/ +bool BotMovement::MoveToBestAttractivePoint(int iMinPriority) +{ + Container list; + AttractiveNode *bestNode; + float bestDistanceSquared; + int bestPriority; + + if (m_pPrimaryAttract) { + MoveTo(m_pPrimaryAttract->origin); + + if (!IsMoving()) { + m_pPrimaryAttract = NULL; + } else { + if (MoveDone()) { + if (!m_fAttractTime) { + m_fAttractTime = level.time + m_pPrimaryAttract->m_fMaxStayTime; + } + if (level.time > m_fAttractTime) { + nodeAttract_t *a = new nodeAttract_t; + a->m_fRespawnTime = level.time + m_pPrimaryAttract->m_fRespawnTime; + a->m_pNode = m_pPrimaryAttract; + + m_pPrimaryAttract = NULL; + } + } + + return true; + } + } + + if (!attractiveNodes.NumObjects()) { + return false; + } + + bestNode = NULL; + bestDistanceSquared = 99999999.0f; + bestPriority = iMinPriority; + + for (int i = attractiveNodes.NumObjects(); i > 0; i--) { + AttractiveNode *node = attractiveNodes.ObjectAt(i); + float distSquared; + bool m_bRespawning = false; + + for (int j = m_attractList.NumObjects(); j > 0; j--) { + AttractiveNode *node2 = m_attractList.ObjectAt(j)->m_pNode; + + if (node2 == node) { + m_bRespawning = true; + break; + } + } + + if (m_bRespawning) { + continue; + } + + if (node->m_iPriority < bestPriority) { + continue; + } + + if (!node->CheckTeam(controlledEntity)) { + continue; + } + + distSquared = VectorLengthSquared(controlledEntity->origin - node->origin); + + if (node->m_fMaxDistanceSquared >= 0 && distSquared > node->m_fMaxDistanceSquared) { + continue; + } + + if (!CanMoveTo(node->origin)) { + continue; + } + + if (distSquared < bestDistanceSquared) { + bestDistanceSquared = distSquared; + bestNode = node; + bestPriority = node->m_iPriority; + } + } + + if (bestNode) { + m_pPrimaryAttract = bestNode; + m_fAttractTime = 0; + MoveTo(bestNode->origin); + return true; + } else { + // No attractive point found + return false; + } +} + +/* +==================== +NewMove + +Called when there is a new move +==================== +*/ +void BotMovement::NewMove() +{ + m_bPathing = true; + m_vLastCheckPos[0] = controlledEntity->origin; + m_vLastCheckPos[1] = controlledEntity->origin; +} + +/* +==================== +CanMoveTo + +Returns true if the bot has done moving +==================== +*/ +bool BotMovement::CanMoveTo(Vector vPos) +{ + return m_Path.DoesTheoreticPathExist(controlledEntity->origin, vPos, NULL, 0, NULL, 0); +} + +/* +==================== +MoveDone + +Returns true if the bot has done moving +==================== +*/ +bool BotMovement::MoveDone() +{ + PathInfo *next; + + if (!m_bPathing) { + return true; + } + + if (m_bTempAway) { + return false; + } + + if (!m_Path.CurrentNode()) { + return true; + } + + Vector delta = Vector(m_Path.CurrentPathGoal()) - controlledEntity->origin; + if (delta.lengthXYSquared() < Square(16) && delta.z < controlledEntity->maxs.z) { + return true; + } + + return false; +} + +/* +==================== +IsMoving + +Returns true if the bot has a current path +==================== +*/ +bool BotMovement::IsMoving(void) +{ + return m_bPathing; +} + +/* +==================== +ClearMove + +Stop the bot from moving +==================== +*/ +void BotMovement::ClearMove(void) +{ + m_Path.Clear(); + m_bPathing = false; + m_iNumBlocks = 0; +} + +/* +==================== +GetCurrentGoal + +Return the current goal, usually the nearest node the player should look at +==================== +*/ +Vector BotMovement::GetCurrentGoal() const +{ + if (!m_Path.CurrentNode()) { + return m_vCurrentGoal; + } + + if (!m_Path.Complete(controlledEntity->origin)) { + return controlledEntity->origin + Vector(m_Path.CurrentDelta()[0], m_Path.CurrentDelta()[1], 0); + } + + return controlledEntity->origin; +} diff --git a/code/fgame/playerbot_rotation.cpp b/code/fgame/playerbot_rotation.cpp new file mode 100644 index 00000000..0228be21 --- /dev/null +++ b/code/fgame/playerbot_rotation.cpp @@ -0,0 +1,139 @@ +/* +=========================================================================== +Copyright (C) 2024 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA source code 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. + +OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// playerbot_rotation.cpp: Manages bot rotation + +#include "playerbot.h" + +BotRotation::BotRotation() +{ + m_vAngSpeed = vec_zero; + m_vTargetAng = vec_zero; + m_vCurrentAng = vec_zero; + m_fYawSpeedMult = 1.0f; +} + +void BotRotation::SetControlledEntity(Player *newEntity) +{ + controlledEntity = newEntity; +} + +float AngleDifference(float ang1, float ang2) +{ + float diff; + + diff = ang1 - ang2; + if (ang1 > ang2) { + if (diff > 180.0) { + diff -= 360.0; + } + } else { + if (diff < -180.0) { + diff += 360.0; + } + } + return diff; +} + +void BotRotation::TurnThink(usercmd_t& botcmd, usereyes_t& eyeinfo) +{ + float diff, factor, maxchange, anglespeed, desired_speed; + int i; + + if (m_vTargetAng[PITCH] > 180) { + m_vTargetAng[PITCH] -= 360; + } + + factor = 0.5f; + maxchange = 360; + + if (maxchange < 240) { + maxchange = 240; + } + + maxchange *= level.frametime; + + for (i = 0; i < 2; i++) { + //over reaction view model + m_vCurrentAng[i] = AngleMod(m_vCurrentAng[i]); + m_vTargetAng[i] = AngleMod(m_vTargetAng[i]); + diff = AngleDifference(m_vCurrentAng[i], m_vTargetAng[i]); + desired_speed = diff * factor; + + m_vAngSpeed[i] = Q_clamp_float(m_vAngSpeed[i] + (m_vAngSpeed[i] - desired_speed), -180, 180); + anglespeed = Q_clamp_float(m_vAngSpeed[i], -maxchange, maxchange); + + m_vCurrentAng[i] += anglespeed; + m_vCurrentAng[i] = AngleMod(m_vCurrentAng[i]); + + //damping + m_vAngSpeed[i] *= 0.2 * (1 - factor); + } + + if (m_vCurrentAng[PITCH] > 180) { + m_vCurrentAng[PITCH] -= 360; + } + + eyeinfo.angles[0] = m_vCurrentAng[0]; + eyeinfo.angles[1] = m_vCurrentAng[1]; + botcmd.angles[0] = ANGLE2SHORT(m_vCurrentAng[0]) - controlledEntity->client->ps.delta_angles[0]; + botcmd.angles[1] = ANGLE2SHORT(m_vCurrentAng[1]) - controlledEntity->client->ps.delta_angles[1]; + botcmd.angles[2] = ANGLE2SHORT(m_vCurrentAng[2]) - controlledEntity->client->ps.delta_angles[2]; +} + +/* +==================== +GetTargetAngles + +Return the target angle +==================== +*/ +const Vector& BotRotation::GetTargetAngles() const +{ + return m_vTargetAng; +} + +/* +==================== +SetTargetAngles + +Set the bot's angle +==================== +*/ +void BotRotation::SetTargetAngles(Vector vAngles) +{ + m_vTargetAng = vAngles; +} + +/* +==================== +AimAt + +Make the bot face to the specified direction +==================== +*/ +void BotRotation::AimAt(Vector vPos) +{ + Vector vDelta = vPos - controlledEntity->EyePosition(); + + VectorNormalize(vDelta); + vectoangles(vDelta, m_vTargetAng); +} diff --git a/code/renderergl2/new/tr_world.c b/code/fgame/playerbot_strategy.cpp similarity index 84% rename from code/renderergl2/new/tr_world.c rename to code/fgame/playerbot_strategy.cpp index 2f55db4f..db8e8b83 100644 --- a/code/renderergl2/new/tr_world.c +++ b/code/fgame/playerbot_strategy.cpp @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2025 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -20,9 +20,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -#include "../tr_local.h" +#include "g_local.h" +#include "playerbot_strategy.h" -void R_GetInlineModelBounds(int iIndex, vec3_t vMins, vec3_t vMaxs) -{ - // FIXME: unimplemented -} \ No newline at end of file +CLASS_DECLARATION(SimpleEntity, NavigationPoint, NULL) { + {NULL, NULL} +}; diff --git a/code/renderergl2/new/tr_bsp.c b/code/fgame/playerbot_strategy.h similarity index 76% rename from code/renderergl2/new/tr_bsp.c rename to code/fgame/playerbot_strategy.h index dacb52d7..8352e1f9 100644 --- a/code/renderergl2/new/tr_bsp.c +++ b/code/fgame/playerbot_strategy.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2025 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -19,16 +19,19 @@ along with OpenMoHAA source code; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ +// playerbot_strategy.h: Bot strategy & navigation points -#include "../tr_local.h" +#pragma once -int RE_MapVersion(void) +#include "simpleentity.h" + +// +// Abstract class for navigation points +// +class NavigationPoint : public SimpleEntity { - // FIXME: unimplemented - return 0; -} +public: + CLASS_PROTOTYPE(NavigationPoint); -void RE_PrintBSPFileSizes(void) -{ - // FIXME: unimplemented -} + // TODO +}; diff --git a/code/fgame/playerstart.h b/code/fgame/playerstart.h index 37beee68..e856a2df 100644 --- a/code/fgame/playerstart.h +++ b/code/fgame/playerstart.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -23,8 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // PlayerStart.h: Player start location entity declarations // -#ifndef __PLAYERSTART_H__ -#define __PLAYERSTART_H__ +#pragma once #include "g_local.h" #include "simpleentity.h" @@ -89,5 +88,3 @@ class PlayerIntermission : public Camera CLASS_PROTOTYPE( PlayerIntermission ); PlayerIntermission(); }; - -#endif /* PlayerStart.h */ diff --git a/code/fgame/portableturret.cpp b/code/fgame/portableturret.cpp index 2ac3bc4a..718d0bd0 100644 --- a/code/fgame/portableturret.cpp +++ b/code/fgame/portableturret.cpp @@ -215,7 +215,7 @@ void CarryableTurret::EventPlaceTurret(Event *ev) if (trace.startsolid || trace.fraction < 1 || trace.ent) { gi.DPrintf( - "~*~*~ Not enough room to auto place protable turret at (%i %i %i)\n", + "~*~*~ Not enough room to auto place portable turret at (%i %i %i)\n", (int)origin[0], (int)origin[1], (int)origin[2] @@ -243,7 +243,7 @@ void CarryableTurret::EventPlaceTurret(Event *ev) if (trace.startsolid || trace.fraction < 1) { gi.DPrintf( - "~*~*~ Not enough room to auto place protable turret at (%i %i %i)\n", + "~*~*~ Not enough room to auto place portable turret at (%i %i %i)\n", (int)origin[0], (int)origin[1], (int)origin[2] diff --git a/code/fgame/portal.h b/code/fgame/portal.h index 1679378c..a7200819 100644 --- a/code/fgame/portal.h +++ b/code/fgame/portal.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -23,8 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // portal.h: // -#ifndef __PORTAL_H__ -#define __PORTAL_H__ +#pragma once #include "g_local.h" #include "entity.h" @@ -45,6 +44,3 @@ class PortalCamera : public Entity PortalCamera(); void Roll( Event *ev ); }; - -#endif // __PORTAL_H__ - diff --git a/code/fgame/scriptdelegate.cpp b/code/fgame/scriptdelegate.cpp new file mode 100644 index 00000000..636aa88c --- /dev/null +++ b/code/fgame/scriptdelegate.cpp @@ -0,0 +1,190 @@ +/* +=========================================================================== +Copyright (C) 2025 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA source code 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. + +OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "scriptdelegate.h" +#include "../script/scriptexception.h" + +ScriptDelegate *ScriptDelegate::root = NULL; + +ScriptRegisteredDelegate_Script::ScriptRegisteredDelegate_Script(const ScriptThreadLabel& inLabel) + : label(inLabel) +{} + +void ScriptRegisteredDelegate_Script::Execute(Listener *object, const Event& ev) +{ + Event newev = ev; + + label.Execute(object, newev); +} + +bool ScriptRegisteredDelegate_Script::operator==(const ScriptRegisteredDelegate_Script& registeredDelegate) const +{ + return label == registeredDelegate.label; +} + +ScriptRegisteredDelegate_CodeMember::ScriptRegisteredDelegate_CodeMember( + Class *inObject, DelegateClassResponse inResponse +) + : object(inObject) + , response(inResponse) +{} + +void ScriptRegisteredDelegate_CodeMember::Execute(Listener *object, const Event& ev) +{ + if (!object) { + return; + } + + (object->*response)(object, ev); +} + +bool ScriptRegisteredDelegate_CodeMember::operator==(const ScriptRegisteredDelegate_CodeMember& registeredDelegate +) const +{ + return object == registeredDelegate.object && response == registeredDelegate.response; +} + +ScriptRegisteredDelegate_Code::ScriptRegisteredDelegate_Code(DelegateResponse inResponse) + : response(inResponse) +{} + +void ScriptRegisteredDelegate_Code::Execute(Listener *object, const Event& ev) +{ + (*response)(object, ev); +} + +bool ScriptRegisteredDelegate_Code::operator==(const ScriptRegisteredDelegate_Code& registeredDelegate) const +{ + return response == registeredDelegate.response; +} + +ScriptDelegate::ScriptDelegate(const char *inName, const char *inDescription) + : name(inName) + , description(inDescription) +{ + LL_SafeAddFirst(root, this, next, prev); +} + +ScriptDelegate::~ScriptDelegate() +{ + LL_SafeRemoveRoot(root, this, next, prev); +} + +const ScriptDelegate *ScriptDelegate::GetRoot() +{ + return root; +} + +const ScriptDelegate *ScriptDelegate::GetNext() const +{ + return next; +} + +void ScriptDelegate::Register(const ScriptThreadLabel& label) +{ + if (!label.IsSet()) { + ScriptError("Invalid label specified for the script delegate"); + } + + list_script.AddUniqueObject(label); +} + +void ScriptDelegate::Unregister(const ScriptThreadLabel& label) +{ + list_script.RemoveObject(label); +} + +void ScriptDelegate::Register(ScriptRegisteredDelegate_Code::DelegateResponse response) +{ + list_code.AddUniqueObject(ScriptRegisteredDelegate_Code(response)); +} + +void ScriptDelegate::Unregister(ScriptRegisteredDelegate_Code::DelegateResponse response) +{ + list_code.RemoveObject(response); +} + +void ScriptDelegate::Register(Class *object, ScriptRegisteredDelegate_CodeMember::DelegateClassResponse response) +{ + list_codeMember.AddUniqueObject(ScriptRegisteredDelegate_CodeMember(object, response)); +} + +void ScriptDelegate::Unregister(Class *object, ScriptRegisteredDelegate_CodeMember::DelegateClassResponse response) +{ + list_codeMember.RemoveObject(ScriptRegisteredDelegate_CodeMember(object, response)); +} + +void ScriptDelegate::Trigger(const Event& ev) const +{ + Trigger(NULL, ev); +} + +void ScriptDelegate::Trigger(Listener *object, const Event& ev) const +{ + size_t i; + + { + const Container tmpList = list_script; + for (i = 1; i <= tmpList.NumObjects(); i++) { + tmpList.ObjectAt(i).Execute(object, ev); + } + } + + { + const Container tmpList = list_code; + for (i = 1; i <= tmpList.NumObjects(); i++) { + tmpList.ObjectAt(i).Execute(object, ev); + } + } + + { + const Container tmpList = list_codeMember; + for (i = 1; i <= tmpList.NumObjects(); i++) { + tmpList.ObjectAt(i).Execute(object, ev); + } + } +} + +ScriptDelegate *ScriptDelegate::GetScriptDelegate(const char *name) +{ + for (ScriptDelegate *delegate = root; delegate; delegate = delegate->next) { + if (!Q_stricmp(delegate->name, name)) { + return delegate; + } + } + + return NULL; +} + +void ScriptDelegate::Reset() +{ + list_script.FreeObjectList(); + list_code.FreeObjectList(); + list_codeMember.FreeObjectList(); +} + +void ScriptDelegate::ResetAllDelegates() +{ + for (ScriptDelegate *delegate = root; delegate; delegate = delegate->next) { + delegate->Reset(); + } +} diff --git a/code/fgame/scriptdelegate.h b/code/fgame/scriptdelegate.h new file mode 100644 index 00000000..0ff04923 --- /dev/null +++ b/code/fgame/scriptdelegate.h @@ -0,0 +1,196 @@ +/* +=========================================================================== +Copyright (C) 2025 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA source code 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. + +OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// scriptdelegate -- manages function delegate + +#include "../qcommon/listener.h" +#include "../qcommon/delegate.h" +#include "gamescript.h" + +class ScriptRegisteredDelegate +{ +public: + void Execute(Listener *object, const Event& ev); +}; + +/** + * Registered delegate, for scripts. + * It contains a ScriptThreadLabel with the game script and the label to execute. + */ +class ScriptRegisteredDelegate_Script : public ScriptRegisteredDelegate +{ +public: + ScriptRegisteredDelegate_Script(const ScriptThreadLabel& inLabel); + + void Execute(Listener *object, const Event& ev); + + bool operator==(const ScriptRegisteredDelegate_Script& registeredDelegate) const; + +private: + ScriptThreadLabel label; +}; + +/** + * Registered delegate, for code use. + * It contains the function to execute. + */ +class ScriptRegisteredDelegate_Code : public ScriptRegisteredDelegate +{ +public: + using DelegateResponse = void (*)(Listener *object, const Event& ev); + +public: + ScriptRegisteredDelegate_Code(DelegateResponse inResponse); + + void Execute(Listener *object, const Event& ev); + + bool operator==(const ScriptRegisteredDelegate_Code& registeredDelegate) const; + +private: + DelegateResponse response; +}; + +/** + * Registered delegate, for code use. + * It contains the object along the member function to execute. + * The function will not be executed if the object is NULL. + */ +class ScriptRegisteredDelegate_CodeMember : public ScriptRegisteredDelegate +{ +public: + using DelegateClassResponse = void (Class::*)(Listener *object, const Event& ev); + +public: + ScriptRegisteredDelegate_CodeMember(Class *inObject, DelegateClassResponse inResponse); + + void Execute(Listener *object, const Event& ev); + + bool operator==(const ScriptRegisteredDelegate_CodeMember& registeredDelegate) const; + +private: + SafePtr object; + DelegateClassResponse response; +}; + +/** + * A script delegate provides a way for code to subscribe for events. + * Scripts and code can register for a delegate and have their function executed + * when the delegate gets triggered. + */ +class ScriptDelegate +{ +public: + ScriptDelegate(const char *name, const char *description); + ~ScriptDelegate(); + + static const ScriptDelegate *GetRoot(); + const ScriptDelegate *GetNext() const; + + /** + * Register a script label. + * + * @param label The label to be executed + */ + void Register(const ScriptThreadLabel& label); + + /** + * Unregistered the label. + * + * @param label The label to unregister + */ + void Unregister(const ScriptThreadLabel& label); + + /** + * Register a function. + * + * @param response The function to be executed + */ + void Register(ScriptRegisteredDelegate_Code::DelegateResponse response); + + /** + * Unregistered the function. + * + * @param response the function to unregister + */ + void Unregister(ScriptRegisteredDelegate_Code::DelegateResponse response); + + /** + * Register with an object and a member function. + * + * @param object The object to notify + * @param response The member function of the object to be executed + */ + void Register(Class *object, ScriptRegisteredDelegate_CodeMember::DelegateClassResponse response); + + /** + * Unregistered the member function. + * + * @param object The object where the member function is + * @param response The member function to unregister + */ + void Unregister(Class *object, ScriptRegisteredDelegate_CodeMember::DelegateClassResponse response); + + /** + * Executes all registered delegates with the specified event. + * + * @param ev Parameter list + */ + void Trigger(const Event& ev = Event()) const; + + /** + * Executes all registered delegates with the specified event. + * + * @param ev Parameter list + */ + void Trigger(Listener *object, const Event& ev = Event()) const; + + /** + * Reset the delegate, unregister callbacks. + */ + void Reset(); + + /** + * Search and return the specified script delegate by name. + * + * @param name The name to search for + */ + static ScriptDelegate *GetScriptDelegate(const char *name); + static void ResetAllDelegates(); + + // non-movable and non-copyable + ScriptDelegate(ScriptDelegate&& other) = delete; + ScriptDelegate& operator=(ScriptDelegate&& other) = delete; + ScriptDelegate(const ScriptDelegate& other) = delete; + ScriptDelegate& operator=(const ScriptDelegate& other) = delete; + +private: + // Linked-list + ScriptDelegate *next; + ScriptDelegate *prev; + static ScriptDelegate *root; + const char *name; + const char *description; + + Container list_script; + Container list_code; + Container list_codeMember; +}; diff --git a/code/fgame/scriptmaster.cpp b/code/fgame/scriptmaster.cpp index 56a1b9d8..6900dc42 100644 --- a/code/fgame/scriptmaster.cpp +++ b/code/fgame/scriptmaster.cpp @@ -230,7 +230,7 @@ const char *ScriptMaster::ConstStrings[] = { "anim/shoot.scr", "anim/mg42_shoot.scr", "anim/mg42_idle.scr", - "anim_mg42_reload.scr", + "anim/mg42_reload.scr", "drive", "global/weapon.scr", "global/moveto.scr", @@ -346,7 +346,7 @@ const char *ScriptMaster::ConstStrings[] = { "anim/fullbody.scr", "salute", "sentry", - "officier", + "officer", "rover", "none", "machinegunner", @@ -399,12 +399,12 @@ const char *ScriptMaster::ConstStrings[] = { "anim/no_anim_killed.scr", "mg42", "mp40", + // Added in 2.0 "auto", "both", + // Added in 2.30 "runandshoot", - // // Added in OPM - // "respawn", "viewmodelanim_done" }; @@ -440,24 +440,27 @@ static int bLoadForMap(char *psMapsBuffer, const char *name) return false; } -void ScriptMaster::RegisterAliasInternal(Event *ev, bool bCache) +void ScriptMaster::RegisterAliasAndCache(Event *ev) { - int i; - char parameters[MAX_STRING_CHARS]; - char *psMapsBuffer; - int subtitle; - bool bAlwaysLoaded = false; + int i; + char parameters[MAX_STRING_CHARS]; + char *psMapsBuffer; + bool bAlwaysLoaded = false; + + if (ev->NumArgs() < 2) { + return; + } // Get the parameters for this alias command parameters[0] = 0; - subtitle = 0; psMapsBuffer = NULL; for (i = 3; i <= ev->NumArgs(); i++) { str s; - // MOHAA doesn't check that + // Added in OPM + // MOHAA doesn't check that if (ev->IsListenerAt(i)) { Listener *l = ev->GetListener(i); @@ -470,44 +473,97 @@ void ScriptMaster::RegisterAliasInternal(Event *ev, bool bCache) s = ev->GetString(i); } - if (subtitle) { + if (!s.icmp("maps")) { + i++; + psMapsBuffer = (char *)ev->GetToken(i).c_str(); + continue; + } + + if (!s.icmp("always")) { + bAlwaysLoaded = true; + continue; + } + + strcat(parameters, s); + strcat(parameters, " "); + } + + if (bAlwaysLoaded) { + gi.GlobalAlias_Add(ev->GetString(1), ev->GetString(2), parameters); + } + + if (bLoadForMap(psMapsBuffer, ev->GetString(1))) { + if (!bAlwaysLoaded) { + gi.GlobalAlias_Add(ev->GetString(1), ev->GetString(2), parameters); + } + + CacheResource(ev->GetString(2)); + } +} + +void ScriptMaster::RegisterAlias(Event *ev) +{ + int i; + char parameters[MAX_STRING_CHARS]; + char *psMapsBuffer; + qboolean subtitle; + bool bAlwaysLoaded = false; + + if (ev->NumArgs() < 2) { + return; + } + + // Get the parameters for this alias command + + parameters[0] = 0; + subtitle = 0; + psMapsBuffer = NULL; + + for (i = 3; i <= ev->NumArgs(); i++) { + str s; + + // Added in OPM + // MOHAA doesn't check that + if (ev->IsListenerAt(i)) { + Listener *l = ev->GetListener(i); + + if (l && l == Director.CurrentThread()) { + s = "local"; + } else { + s = ev->GetString(i); + } + } else { + s = ev->GetString(i); + } + + if (!s.icmp("maps")) { + i++; + psMapsBuffer = (char *)ev->GetToken(i).c_str(); + continue; + } + + if (!s.icmp("always")) { + bAlwaysLoaded = true; + } else if (subtitle) { strcat(parameters, "\""); strcat(parameters, s); strcat(parameters, "\" "); subtitle = 0; - } else if (!s.icmp("maps")) { - i++; - psMapsBuffer = (char *)ev->GetToken(i).c_str(); - } else if (!s.icmp("always")) { - bAlwaysLoaded = true; } else { subtitle = s.icmp("subtitle") == 0; strcat(parameters, s); - strcat(parameters, " "); } + + strcat(parameters, " "); } if (bAlwaysLoaded || bLoadForMap(psMapsBuffer, ev->GetString(1))) { gi.GlobalAlias_Add(ev->GetString(1), ev->GetString(2), parameters); - - if (bCache) { - CacheResource(ev->GetString(2)); - } } } -void ScriptMaster::RegisterAliasAndCache(Event *ev) -{ - RegisterAliasInternal(ev, true); -} - -void ScriptMaster::RegisterAlias(Event *ev) -{ - RegisterAliasInternal(ev); -} - void ScriptMaster::Cache(Event *ev) { #ifdef GAME_DLL @@ -525,11 +581,21 @@ void ScriptMaster::InitConstStrings(void) const_str name; unsigned int eventnum; con_map_enum en; + int i; - for (int i = 0; i < sizeof(ConstStrings) / sizeof(ConstStrings[0]); i++) { + static_assert(ARRAY_LEN(ConstStrings) == (STRING_LENGTH_ - 1), "Constant strings don't match. Make sure the 'const_str' enum match with the 'ConstStrings' string array"); + + for (i = 0; i < ARRAY_LEN(ConstStrings); i++) { AddString(ConstStrings[i]); } + if (!Listener::EventSystemStarted) { + // Added in OPM + // This usually means the game module is getting destroyed + // most often, the event command list has been destroyed earlier + return; + } + Event::normalCommandList.clear(); Event::returnCommandList.clear(); Event::getterCommandList.clear(); @@ -541,7 +607,10 @@ void ScriptMaster::InitConstStrings(void) eventDef = en.CurrentValue(); eventnum = (*en.CurrentKey())->eventnum; str command = eventDef->command.c_str(); - command.tolower(); + + if (eventDef->type == EV_NORMAL || eventDef->type == EV_RETURN) { + command.tolower(); + } name = AddString(command); @@ -665,6 +734,10 @@ ScriptThread *ScriptMaster::CreateScriptThread(ScriptClass *scriptClass, str lab } } +ScriptMaster::ScriptMaster() +{ +} + void ScriptMaster::Reset(qboolean samemap) { ScriptClass_allocator.FreeAll(); @@ -693,6 +766,8 @@ void ScriptMaster::Reset(qboolean samemap) StringDict.clear(); InitConstStrings(); } + + ScriptDelegate::ResetAllDelegates(); } void ScriptMaster::ExecuteRunning(void) @@ -766,7 +841,7 @@ void ScriptMaster::RemoveTiming(ScriptThread *thread) ScriptClass *ScriptMaster::CurrentScriptClass(void) { - return CurrentThread()->GetScriptClass(); + return CurrentScriptThread()->GetScriptClass(); } void ScriptMaster::CloseGameScript(void) @@ -797,16 +872,16 @@ GameScript *ScriptMaster::GetGameScriptInternal(str& filename) gi.Error(ERR_DROP, "Script filename '%s' exceeds maximum length of %d\n", filename.c_str(), MAX_QPATH); } + Q_strncpyz(filepath, filename.c_str(), sizeof(filepath)); + gi.FS_CanonicalFilename(filepath); + filename = filepath; + scr = m_GameScripts[StringDict.findKeyIndex(filename)]; if (scr != NULL) { return scr; } - strcpy(filepath, filename.c_str()); - gi.FS_CanonicalFilename(filepath); - filename = filepath; - scr = new GameScript(filename); m_GameScripts[StringDict.addKeyIndex(filename)] = scr; @@ -1030,7 +1105,6 @@ ScriptThread *ScriptMaster::CurrentThread(void) ScriptThread *ScriptMaster::CurrentScriptThread(void) { - assert(m_CurrentThread); if (!m_CurrentThread) { ScriptError("current thread is NULL"); } @@ -1105,30 +1179,30 @@ void ScriptMaster::PrintStatus(void) ScriptVM *vm; for (vm = scriptClass->m_Threads; vm != NULL; vm = vm->next) { - sprintf(szBuffer, "%.7d", iThreadNum); + Com_sprintf(szBuffer, sizeof(szBuffer), "%.7d", iThreadNum); status += szBuffer + str(" "); switch (vm->ThreadState()) { case THREAD_RUNNING: - sprintf(szBuffer, "%8s", "running"); + Com_sprintf(szBuffer, sizeof(szBuffer), "%8s", "running"); iThreadRunning++; break; case THREAD_WAITING: - sprintf(szBuffer, "%8s", "waiting"); + Com_sprintf(szBuffer, sizeof(szBuffer), "%8s", "waiting"); iThreadWaiting++; break; case THREAD_SUSPENDED: - sprintf(szBuffer, "%8s", "suspended"); + Com_sprintf(szBuffer, sizeof(szBuffer), "%8s", "suspended"); iThreadSuspended++; break; } status += szBuffer; - sprintf(szBuffer, "%15s", vm->Label().c_str()); + Com_sprintf(szBuffer, sizeof(szBuffer), "%15s", vm->Label().c_str()); status += szBuffer + str(" "); - sprintf(szBuffer, "%15s", vm->Filename().c_str()); + Com_sprintf(szBuffer, sizeof(szBuffer), "%15s", vm->Filename().c_str()); status += szBuffer; status += "\n"; diff --git a/code/fgame/scriptmaster.h b/code/fgame/scriptmaster.h index 12a7708b..28faef7f 100644 --- a/code/fgame/scriptmaster.h +++ b/code/fgame/scriptmaster.h @@ -82,11 +82,11 @@ protected: void Cache(Event *ev); void RegisterAliasAndCache(Event *ev); void RegisterAlias(Event *ev); - void RegisterAliasInternal(Event *ev, bool bCache = false); public: CLASS_PROTOTYPE(ScriptMaster); + ScriptMaster(); virtual ~ScriptMaster(); // diff --git a/code/fgame/scriptslave.cpp b/code/fgame/scriptslave.cpp index f2929f18..b357820f 100644 --- a/code/fgame/scriptslave.cpp +++ b/code/fgame/scriptslave.cpp @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2025 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -44,6 +44,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "game.h" #include "debuglines.h" #include "weaputils.h" +#include "parm.h" /*****************************************************************************/ /*QUAKED script_object (0 0.5 1) ? NOT_SOLID @@ -68,6 +69,22 @@ Event EV_ScriptSlave_WaitMove "Move the script slave and wait until finished.", EV_NORMAL ); +Event EV_ScriptSlave_Stop +( + "stop", + EV_DEFAULT, + NULL, + NULL, + "Stop the script slave." +); +Event EV_ScriptSlave_ThreadMove +( + "threadmove", + EV_DEFAULT, + "s", + "label", + "Move the script slave and create thread which waits until finished." +); Event EV_ScriptSlave_Angles ( "angles", @@ -221,6 +238,15 @@ Event EV_ScriptSlave_MoveRight "Move the position right.", EV_NORMAL ); +Event EV_ScriptSlave_MoveOffset +( + "moveOffset", + EV_DEFAULT, + "v", + "dist", + "Move the position by the offset vector.", + EV_NORMAL +); Event EV_ScriptSlave_RotateXDownTo ( "rotateXdownto", @@ -462,7 +488,7 @@ Event EV_ScriptSlave_FollowPath "eSSSSSS", "path arg1 arg2 arg3 arg4 arg5 arg6", "Makes the script slave follow the specified path. The allowable arguments are ignoreangles,\n" - "normalangles, loop, and a number specifying the start time.", + "ignorevelocity, normalangles, loop, and a number specifying the start time.", EV_NORMAL ); Event EV_ScriptSlave_FollowPath_RelativeYaw @@ -608,6 +634,8 @@ CLASS_DECLARATION(Mover, ScriptSlave, "script_object") { {&EV_Unbind, &ScriptSlave::EventUnbind }, {&EV_ScriptSlave_DoMove, &ScriptSlave::DoMove }, {&EV_ScriptSlave_WaitMove, &ScriptSlave::WaitMove }, + {&EV_ScriptSlave_Stop, &ScriptSlave::Stop }, + {&EV_ScriptSlave_ThreadMove, &ScriptSlave::ThreadMove }, {&EV_ScriptSlave_Angles, &ScriptSlave::SetAnglesEvent }, {&EV_SetAngle, &ScriptSlave::SetAngleEvent }, {&EV_Model, &ScriptSlave::SetModelEvent }, @@ -627,6 +655,7 @@ CLASS_DECLARATION(Mover, ScriptSlave, "script_object") { {&EV_ScriptSlave_MoveBackward, &ScriptSlave::MoveBackward }, {&EV_ScriptSlave_MoveLeft, &ScriptSlave::MoveLeft }, {&EV_ScriptSlave_MoveRight, &ScriptSlave::MoveRight }, + {&EV_ScriptSlave_MoveOffset, &ScriptSlave::MoveOffset }, {&EV_ScriptSlave_RotateXDownTo, &ScriptSlave::RotateXdownto }, {&EV_ScriptSlave_RotateYDownTo, &ScriptSlave::RotateYdownto }, {&EV_ScriptSlave_RotateZDownTo, &ScriptSlave::RotateZdownto }, @@ -654,6 +683,10 @@ CLASS_DECLARATION(Mover, ScriptSlave, "script_object") { {&EV_ScriptSlave_FollowPath_RelativeYaw, &ScriptSlave::FollowPathRelativeYaw}, {&EV_ScriptSlave_EndPath, &ScriptSlave::EndPath }, {&EV_ScriptSlave_FollowingPath, &ScriptSlave::FollowingPath }, + {&EV_Touch, &ScriptSlave::TouchFunc }, + {&EV_Blocked, &ScriptSlave::BlockFunc }, + {&EV_Activate, &ScriptSlave::TriggerFunc }, + {&EV_Use, &ScriptSlave::UseFunc }, {&EV_ScriptSlave_MoveDone, &ScriptSlave::MoveEnd }, {&EV_Damage, &ScriptSlave::DamageFunc }, {&EV_ScriptSlave_RotateDownTo, &ScriptSlave::Rotatedownto }, @@ -692,14 +725,23 @@ ScriptSlave::ScriptSlave() // this is a normal entity edict->s.eType = ET_GENERAL; + splineTime = 0; + + ignoreangles = false; + ignorevelocity = false; + moving = false; + speed = 100; takedamage = DAMAGE_YES; waypoint = NULL; - NewAngles = localangles; - NewPos = localorigin; traveltime = 0; commandswaiting = false; + splinePath = NULL; + splineangles = false; + m_fFollowRelativeYaw = 0; + + attack_finished = 0; dmg = 2; dmg_means_of_death = MOD_CRUSH; @@ -709,20 +751,16 @@ ScriptSlave::ScriptSlave() edict->s.renderfx = RF_ALWAYSDRAW; } - splinePath = NULL; - m_pCurPath = NULL; - m_iCurNode = 0; - m_fLookAhead = 0; - m_fCurSpeed = 0; - m_fIdealSpeed = 0; - m_fIdealAccel = 0; - m_fIdealDistance = 100; - splineangles = false; - m_fFollowRelativeYaw = 0; - attack_finished = 0; - setSolidType(SOLID_NOT); + m_pCurPath = NULL; + m_iCurNode = 0; + m_fCurSpeed = 0; + m_fLookAhead = 0; + m_fIdealSpeed = 0; + m_fIdealAccel = 0; + m_fIdealDistance = 100; + if (spawnflags & 1) { PostEvent(EV_BecomeNonSolid, EV_POSTSPAWN); } @@ -762,10 +800,7 @@ void ScriptSlave::NewMove(void) BroadcastEvent(0, ev); } - if (m_pCurPath) { - PostEvent(EV_ScriptSlave_FollowingPath, 0); - } else if (splinePath) { - moving = true; + if (m_pCurPath || splinePath) { PostEvent(EV_ScriptSlave_FollowingPath, 0); } else { float t = traveltime; @@ -773,13 +808,11 @@ void ScriptSlave::NewMove(void) dist = Vector(NewPos - localorigin).length(); t = dist / speed; } - moving = true; LinearInterpolate(NewPos, NewAngles, t, EV_ScriptSlave_MoveDone); } } void ScriptSlave::BindEvent(Event *ev) - { Entity *ent; @@ -794,7 +827,6 @@ void ScriptSlave::BindEvent(Event *ev) } void ScriptSlave::EventUnbind(Event *ev) - { unbind(); @@ -811,7 +843,25 @@ void ScriptSlave::DoMove(Event *ev) void ScriptSlave::WaitMove(Event *ev) { NewMove(); - Register(0, Director.CurrentThread()); + Register(0, Director.CurrentScriptThread()); +} + +void ScriptSlave::Stop(Event *ev) +{ + commandswaiting = false; + if (RegisterSize(0)) { + Event newev(EV_DelayThrow); + newev.AddConstString(STRING_FAIL); + BroadcastEvent(0, newev); + } + + Mover::Stop(); +} + +void ScriptSlave::ThreadMove(Event *ev) +{ + NewMove(); + Register(0, CreateThreadInternal(ev->GetValue(1))); } void ScriptSlave::MoveEnd(Event *ev) @@ -820,15 +870,13 @@ void ScriptSlave::MoveEnd(Event *ev) } void ScriptSlave::SetAnglesEvent(Event *ev) - { - commandswaiting = true; + CheckNewOrders(); SetAngles(ev); NewAngles = localangles; } void ScriptSlave::SetAngleEvent(Event *ev) - { float angle; @@ -880,7 +928,6 @@ void ScriptSlave::SetModelEvent(Event *ev) } void ScriptSlave::TriggerEvent(Event *ev) - { Entity *ent; Event *e; @@ -898,9 +945,8 @@ void ScriptSlave::TriggerEvent(Event *ev) } void ScriptSlave::GotoNextWaypoint(Event *ev) - { - commandswaiting = true; + CheckNewOrders(); if (!waypoint) { ScriptError("%s is currently not at a waypoint", TargetName().c_str()); @@ -956,9 +1002,8 @@ void ScriptSlave::JumpTo(Event *ev) } void ScriptSlave::MoveToEvent(Event *ev) - { - commandswaiting = true; + CheckNewOrders(); // // see if it is a vector @@ -966,22 +1011,29 @@ void ScriptSlave::MoveToEvent(Event *ev) if (ev->IsVectorAt(1)) { NewPos = ev->GetVector(1); } else { - waypoint = (Waypoint *)ev->GetEntity(1); - if (waypoint) { - NewPos = waypoint->origin; + SimpleEntity* ent; + + ent = ev->GetSimpleEntity(1); + if (ent) { + // + // see if it is a waypoint + // + if (ent->IsSubclassOfWaypoint()) { + waypoint = static_cast(ent); + } + // use the entity's origin + NewPos = ent->origin; } } } void ScriptSlave::SetSpeed(Event *ev) - { speed = ev->GetFloat(1); traveltime = 0; } void ScriptSlave::SetTime(Event *ev) - { traveltime = ev->GetFloat(1); } @@ -1076,6 +1128,12 @@ void ScriptSlave::MoveRight(Event *ev) NewPos -= v * ev->GetFloat(1); } +void ScriptSlave::MoveOffset(Event *ev) +{ + CheckNewOrders(); + NewPos += ev->GetVector(1); +} + // exact rotate commands void ScriptSlave::RotateXdownto(Event *ev) @@ -1276,25 +1334,21 @@ void ScriptSlave::RotateAxisup(Event *ev) } void ScriptSlave::RotateX(Event *ev) - { avelocity[0] = ev->GetFloat(1); } void ScriptSlave::RotateY(Event *ev) - { avelocity[1] = ev->GetFloat(1); } void ScriptSlave::RotateZ(Event *ev) - { avelocity[2] = ev->GetFloat(1); } void ScriptSlave::RotateAxis(Event *ev) - { int axis; @@ -1302,25 +1356,60 @@ void ScriptSlave::RotateAxis(Event *ev) avelocity[axis] = ev->GetFloat(2); } +void ScriptSlave::TouchFunc(Event* ev) +{ + parm.other = ev->GetEntity(1); + parm.owner = parm.other; + Unregister(STRING_TOUCH); +} + +void ScriptSlave::BlockFunc(Event* ev) +{ + Entity* other; + + other = ev->GetEntity(1); + if (level.time >= attack_finished) { + attack_finished = level.time + 0.5; + if (dmg) { + other->Damage(this, this, dmg, origin, vec_zero, vec_zero, 0, 0, dmg_means_of_death); + } + } + + parm.other = ev->GetEntity(1); + parm.owner = parm.other; + Unregister(STRING_BLOCK); +} + +void ScriptSlave::TriggerFunc(Event* ev) +{ + parm.other = ev->GetEntity(1); + parm.owner = parm.other; + Unregister(STRING_TRIGGER); +} + +void ScriptSlave::UseFunc(Event* ev) +{ + parm.other = ev->GetEntity(1); + parm.owner = parm.other; + Unregister(STRING_USE); +} + void ScriptSlave::DamageFunc(Event *ev) { Unregister(STRING_DAMAGE); } void ScriptSlave::SetDamage(Event *ev) - { dmg = ev->GetInteger(1); } void ScriptSlave::SetMeansOfDeath(Event *ev) - { dmg_means_of_death = MOD_string_to_int(ev->GetString(1)); } void ScriptSlave::CreatePath(SplinePath *path, splinetype_t type) - { SplinePath *node; @@ -1344,36 +1433,50 @@ void ScriptSlave::CreatePath(SplinePath *path, splinetype_t type) void ScriptSlave::FollowPath(Event *ev) { - int i, argnum; - Entity *ent; - str token; - SplinePath *path; - qboolean clamp; - float starttime; + int i, argnum; + SimpleEntity *ent; + str token; + SplinePath *path; + qboolean clamp; + float starttime; - ent = ev->GetEntity(1); - argnum = 2; - starttime = -2; - clamp = true; - ignoreangles = false; - splineangles = true; + ent = ev->GetSimpleEntity(1); + argnum = 2; + starttime = -2; + clamp = true; + ignoreangles = false; + ignorevelocity = false; + splineangles = true; for (i = argnum; i <= ev->NumArgs(); i++) { token = ev->GetString(i); if (!Q_stricmp(token, "ignoreangles")) { ignoreangles = true; + } else if (!Q_stricmp(token, "ignorevelocity")) { + ignorevelocity = true; } else if (!Q_stricmp(token, "normalangles")) { splineangles = false; } else if (!Q_stricmp(token, "loop")) { clamp = false; } else if (IsNumeric(token)) { starttime = atof(token); + // Fixed in OPM + // HACKHACK + // + // There is a bug in mohaa where the token's raw pointer is directly used + // but then the token can be freed before comparison, which cause + // starttime to be always 0. + // OPM is correct here but for compatibility purpose the bug have to be reproduced. + // Otherwise, for example the final bomber plane in t3l2 will not fly. + if (!ev->IsStringAt(i)) { + starttime = 0; + } } else { ScriptError("Unknown followpath command %s.", token.c_str()); } } + if (ent && ent->IsSubclassOfSplinePath()) { - commandswaiting = true; - path = (SplinePath *)ent; + path = (SplinePath *)ent; if (clamp) { CreatePath(path, SPLINE_CLAMP); } else { @@ -1384,7 +1487,9 @@ void ScriptSlave::FollowPath(Event *ev) if (!ignoreangles) { avelocity = vec_zero; } - velocity = vec_zero; + if (!ignorevelocity) { + velocity = vec_zero; + } } } @@ -1401,7 +1506,9 @@ void ScriptSlave::EndPath(Event *ev) delete splinePath; splinePath = NULL; - velocity = vec_zero; + if (!ignorevelocity) { + velocity = vec_zero; + } if (!ignoreangles) { avelocity = vec_zero; } @@ -1431,22 +1538,57 @@ void ScriptSlave::FollowingPath(Event *ev) if (g_showflypath && g_showflypath->integer) { for (int i = 0; i < m_pCurPath->m_iPoints; i++) { vTmp = m_pCurPath->GetByNode(i, NULL); - G_DebugBBox((vTmp + 1), Vector(-32, -32, -32), Vector(32, 32, 32), 0.0f, 1.0f, 1.0f, 1.0f); + VectorCopy((vTmp + 1), vCur); + + G_DebugBBox(vCur, Vector(-32, -32, -32), Vector(32, 32, 32), 0, 1, 1, 1); for (int ii = 0; ii <= 8; ii++) { - G_DebugLine( - (m_pCurPath->GetByNode((ii / 10.0f + (i + 1)), NULL) + 1), - (m_pCurPath->GetByNode(m_fLookAhead + (ii / 10.0f + (i + 1)), NULL) + 1), - 0.0f, - 1.0f, - 1.0f, - 1.0f - ); + vTmp = m_pCurPath->GetByNode(i + ii / 10.0, NULL); + VectorCopy((vTmp + 1), vPrev); + vTmp = m_pCurPath->GetByNode(i + ii / 10.0 + m_fLookAhead, NULL); + VectorCopy((vTmp + 1), vCur); + + G_DebugLine(vPrev, vCur, 0, 1, 0, 1); } } } - if (m_iCurNode <= 0) { + if (m_iCurNode > 0) { + // Get previous node + vTmp = m_pCurPath->GetByNode(m_iCurNode - 1, NULL); + vPrev = (vTmp + 1); + // Get current node + vTmp = m_pCurPath->GetByNode(m_iCurNode, NULL); + vCur = (vTmp + 1); + + vDelta = vCur - vPrev; + m_vIdealDir = vDelta; + VectorNormalize(m_vIdealDir); + angles.AngleVectorsLeft(&vWishAngles); + + fCoef = ProjectLineOnPlane(vWishAngles, DotProduct(origin, vWishAngles), vPrev, vCur, NULL); + + vTmp = m_pCurPath->GetByNode(m_iCurNode - (1.0 - fCoef), NULL); + vTmp = m_pCurPath->Get(vTmp[0] + m_fLookAhead, NULL); + vWishPosition = (vTmp + 1); + + if (fCoef > 1.0f) { + m_iCurNode++; + + if (m_iCurNode >= m_pCurPath->m_iPoints) { + velocity = vec_zero; + avelocity = vec_zero; + + delete m_pCurPath; + m_pCurPath = NULL; + m_iCurNode = 0; + moving = false; + + ProcessEvent(EV_ScriptSlave_MoveDone); + return; + } + } + } else { vTmp = m_pCurPath->GetByNode(m_iCurNode, NULL); vWishPosition = (vTmp + 1); vDelta = vWishPosition - origin; @@ -1454,37 +1596,6 @@ void ScriptSlave::FollowingPath(Event *ev) if (vDelta.length() <= 32.0f) { m_iCurNode++; - if (m_iCurNode >= m_pCurPath->m_iPoints) { - velocity = vec_zero; - avelocity = vec_zero; - - delete m_pCurPath; - m_pCurPath = NULL; - m_iCurNode = 0; - moving = false; - ProcessEvent(EV_ScriptSlave_MoveDone); - return; - } - } - } else { - vTmp = m_pCurPath->GetByNode(m_iCurNode - 1, NULL); - vPrev = (vTmp + 1); - vTmp = m_pCurPath->GetByNode(m_iCurNode, NULL); - vCur = (vTmp + 1); - - m_vIdealDir = vCur - vPrev; - VectorNormalize(m_vIdealDir); - angles.AngleVectorsLeft(&vWishAngles); - - fCoef = ProjectLineOnPlane(vWishAngles, DotProduct(origin, vWishAngles), vPrev, vCur, NULL); - - vTmp = m_pCurPath->GetByNode((m_iCurNode - (1.0f - fCoef)), NULL); - vTmp = m_pCurPath->Get(vTmp[0] + m_fLookAhead, NULL); - vWishPosition = (vTmp + 1); - - if (fCoef > 1.0f) { - m_iCurNode++; - if (m_iCurNode >= m_pCurPath->m_iPoints) { velocity = vec_zero; avelocity = vec_zero; @@ -1499,39 +1610,47 @@ void ScriptSlave::FollowingPath(Event *ev) } } - vWishAngles = vWishPosition - origin; + vDelta = vWishPosition - origin; - if (vWishAngles.length() > 0.0f) { - VectorNormalize(vWishAngles); - VectorToAngles(vWishAngles, vNextWishAngles); + if (vDelta.length() > 0.0f) { + vDelta.normalize(); + VectorToAngles(vDelta, vNextWishAngles); + + // + // Added in 2.0 + // Relative yaw + vNextWishAngles[1] += m_fFollowRelativeYaw; + if (m_fFollowRelativeYaw == 180) { + vNextWishAngles[0] *= -1; + } } else { - AngleVectorsLeft(angles, vWishAngles, NULL, NULL); vNextWishAngles = angles; + AngleVectorsLeft(angles, vDelta, NULL, NULL); } vAngles = angles; for (int i = 0; i < 3; i++) { + float change, error; + n_angles[i] = vNextWishAngles[i] - angles[i]; - if (n_angles[i] <= 180.0f) { - if (n_angles[i] < -180.0f) { - n_angles[i] += 360.0f; - } - } else { - n_angles[i] -= 360.0f; + if (n_angles[i] > 180) { + n_angles[i] -= 360; + } else if (n_angles[i] < -180) { + n_angles[i] += 360; } - float change = level.frametime * 360.0f; - float error = 0.33f * n_angles[i]; + change = level.frametime * 360.0f; + error = 0.33f * n_angles[i]; - if (-change > error) { + if (error < -change) { error = -change; - } else if (error <= change) { - change = error; + } else if (error > change) { + error = change; } - primal_angles[i] = change + angles[i]; + primal_angles[i] = angles[i] + error; } setAngles(primal_angles); @@ -1563,15 +1682,15 @@ void ScriptSlave::FollowingPath(Event *ev) } avelocity = vDeltaAngles; - velocity = vWishAngles * m_fCurSpeed; + velocity = vDelta * m_fCurSpeed; - if (m_fCurSpeed < m_fIdealSpeed) { + if (m_fIdealSpeed > m_fCurSpeed) { m_fCurSpeed += m_fIdealAccel * level.frametime; if (m_fCurSpeed > m_fIdealSpeed) { m_fCurSpeed = m_fIdealSpeed; } - } else if (m_fCurSpeed > m_fIdealSpeed) { + } else if (m_fIdealSpeed < m_fCurSpeed) { m_fCurSpeed -= m_fIdealAccel * level.frametime; if (m_fCurSpeed < m_fIdealSpeed) { @@ -1586,7 +1705,9 @@ void ScriptSlave::FollowingPath(Event *ev) if ((splinePath->GetType() == SPLINE_CLAMP) && (splineTime > (splinePath->EndPoint() - 2))) { delete splinePath; splinePath = NULL; - velocity = vec_zero; + if (!ignorevelocity) { + velocity = vec_zero; + } if (!ignoreangles) { avelocity = vec_zero; } @@ -1628,7 +1749,6 @@ void ScriptSlave::FollowingPath(Event *ev) } void ScriptSlave::Explode(Event *ev) - { float damage; @@ -1758,15 +1878,11 @@ void ScriptSlave::EventNormalAngles(Event *ev) void ScriptSlave::SetupPath(cSpline<4, 512> *pPath, SimpleEntity *se) { str name; - //int iObjNum; + int iObjNum = 0; Vector vLastOrigin; SimpleEntity *ent; - int i; - static cSpline<4, 512> *pTmpPath = NULL; - - if (!pTmpPath) { - pTmpPath = new cSpline<4, 512>; - } + int i = 1; + static cSpline<4, 512> *pTmpPath = new cSpline<4, 512>; if (!pPath) { return; @@ -1779,25 +1895,22 @@ void ScriptSlave::SetupPath(cSpline<4, 512> *pPath, SimpleEntity *se) name = se->Target(); - if (name.c_str()) { - Vector vDelta; - vec4_t origin; - float fCurLength; + if (name.length()) { + for(ent = se; ent; ent = ent->Next()) { + Vector vDelta; + vec4_t vTmp; - i = 0; - fCurLength = 0; - ent = se; - while (ent) { - if (vLastOrigin.length() == 0.0f && i > 1) { + vDelta = vLastOrigin - ent->origin; + + if (vDelta.length() == 0 && i > 1) { Com_Printf("^~^~^Warning: ScriptSlave Flying with a Path that contains 2 equal points\n"); } else { - origin[0] = fCurLength; - origin[1] = ent->origin[0]; - origin[2] = ent->origin[1]; - origin[3] = ent->origin[2]; - pTmpPath->Add(origin, 0); + vTmp[0] = iObjNum++; + vTmp[1] = ent->origin[0]; + vTmp[2] = ent->origin[1]; + vTmp[3] = ent->origin[2]; + pTmpPath->Add(vTmp, 0); vLastOrigin = ent->origin; - fCurLength++; } if (ent == se && i > 1) { @@ -1805,35 +1918,38 @@ void ScriptSlave::SetupPath(cSpline<4, 512> *pPath, SimpleEntity *se) } i++; - ent = ent->Next(); } + } - if (pTmpPath->m_iPoints > 2) { - float *vTmp; + if (pTmpPath->m_iPoints > 2) { + float* vTmp; + float fCurLength = 0; + vec3_t vLastOrigin; + vec3_t origin; + vec3_t vDelta; - pPath->Reset(); - vTmp = pTmpPath->GetByNode(0.0f, 0); + pPath->Reset(); - vLastOrigin[0] = vTmp[1]; - vLastOrigin[1] = vTmp[2]; - vLastOrigin[2] = vTmp[3]; + vTmp = pTmpPath->GetByNode(0, NULL); + VectorCopy((vTmp + 1), vLastOrigin); + VectorCopy((vTmp + 1), origin); - fCurLength = 0; + for (i = 0; i < pTmpPath->m_iPoints; i++) { + vec4_t vTmp2; - for (i = 0; i < pTmpPath->m_iPoints; i++) { - vTmp = pTmpPath->GetByNode(i, 0); + vTmp = pTmpPath->GetByNode(i, NULL); - vDelta = (vTmp + 1) - vLastOrigin; + VectorCopy((vTmp + 1), vLastOrigin); + VectorSubtract(vLastOrigin, origin, vDelta); - fCurLength += vDelta.length(); - origin[0] = fCurLength; - origin[1] = vTmp[1]; - origin[2] = vTmp[2]; - origin[3] = vTmp[3]; + fCurLength += VectorLength(vDelta); + vTmp2[0] = fCurLength; + vTmp2[1] = vLastOrigin[0]; + vTmp2[2] = vLastOrigin[1]; + vTmp2[3] = vLastOrigin[2]; - pPath->Add(origin, 0); - vLastOrigin = (vTmp + 1); - } + pPath->Add(vTmp2, 0); + VectorCopy(vLastOrigin, origin); } } } @@ -1917,7 +2033,8 @@ void ScriptModel::SetAnimEvent(Event *ev) animnum = gi.Anim_NumForName(edict->tiki, animname); if (animnum >= 0) { - NewAnim(animnum); + NewAnim(animnum, EV_ScriptModel_AnimDone); + RestartAnimSlot(0); } } } @@ -2040,9 +2157,40 @@ Used as an alternate origin for objects. Bind the object to the script_origin in order to simulate changing that object's origin. ******************************************************************************/ +// Added in 2.30 +Event EV_ScriptOrigin_SetAngle +( + "angle", + EV_DEFAULT, + "f", + "newAngle", + "set the angles of the entity using just one value.\n" + "Sets the yaw of the entity or an up and down\n" + "direction if newAngle is [0-359] or -1 or -2" +); + +// Added in 2.30 +Event EV_ScriptOrigin_GetAngle +( + "angle", + EV_DEFAULT, + NULL, + NULL, + "get the angles of the entity using just one value.\n" + "Gets the yaw of the entity or an up and down\n" + "direction if newAngle is [0-359] or -1 or -2", + EV_GETTER +); + CLASS_DECLARATION(ScriptSlave, ScriptOrigin, "script_origin") { {&EV_Model, &ScriptOrigin::SetModelEvent}, - {NULL, NULL } + + // + // Added in 2.30 + // + {&EV_ScriptOrigin_SetAngle, &ScriptOrigin::SetAngleEvent}, + {&EV_ScriptOrigin_GetAngle, &ScriptOrigin::GetAngleEvent}, + {NULL, NULL } }; ScriptOrigin::ScriptOrigin() @@ -2051,6 +2199,39 @@ ScriptOrigin::ScriptOrigin() setSolidType(SOLID_NOT); } +void ScriptOrigin::SetAngleEvent(Event* ev) +{ + float angle; + + if (g_target_game < target_game_e::TG_MOHTT) { + // Restore the old behavior on previous versions (below 2.30). + // For example, higgins rangers in m3l1a would not face forward + return ScriptSlave::SetAngleEvent(ev); + } + + angle = ev->GetFloat(1); + if (angle == -1) { + ForwardDir = Vector(0, 0, 90); + localangles = Vector(-90, 0, 0); + } else if (angle == -2) { + ForwardDir = Vector(0, 0, -90); + localangles = Vector(90, 0, 0); + } else { + ForwardDir = Vector(0, angle, 0); + localangles = Vector(0, angle, 0); + } + + setAngles(localangles); +} + +void ScriptOrigin::GetAngleEvent(Event* ev) +{ + Vector forward; + + angles.AngleVectorsLeft(&forward); + ev->AddFloat(G_GetAngle(forward)); +} + /*****************************************************************************/ /*QUAKED script_skyorigin (1.0 0 0) ? @@ -2064,6 +2245,7 @@ CLASS_DECLARATION(ScriptSlave, ScriptSkyOrigin, "script_skyorigin") { ScriptSkyOrigin::ScriptSkyOrigin() { edict->s.renderfx |= RF_SKYORIGIN; + edict->r.svFlags &= ~SVF_NOCLIENT; setContents(0); setSolidType(SOLID_NOT); } @@ -2211,8 +2393,9 @@ Event EV_ScriptAimedStrafingGunfire_AimTarget ); CLASS_DECLARATION(ScriptSimpleStrafingGunfire, ScriptAimedStrafingGunfire, "script_aimedstrafinggunfire") { - {&EV_ScriptSimpleStrafingGunfire_Fire, &ScriptAimedStrafingGunfire::GunFire}, - {NULL, NULL } + {&EV_ScriptAimedStrafingGunfire_AimTarget, &ScriptAimedStrafingGunfire::SetAimTarget}, + {&EV_ScriptSimpleStrafingGunfire_Fire, &ScriptAimedStrafingGunfire::GunFire }, + {NULL, NULL } }; ScriptAimedStrafingGunfire::ScriptAimedStrafingGunfire() @@ -2230,8 +2413,8 @@ void ScriptAimedStrafingGunfire::GunFire(Event *ev) Vector dir, right, up; Vector horzAngles; - AngleVectors(angles, NULL, NULL, up); - dir = -1 * up; + dir = aimTarget->origin - origin; + dir.normalize(); VectorToAngles(dir, horzAngles); AngleVectors(horzAngles, NULL, right, up); diff --git a/code/fgame/scriptslave.h b/code/fgame/scriptslave.h index 9e1a6cfe..b3bbae74 100644 --- a/code/fgame/scriptslave.h +++ b/code/fgame/scriptslave.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2025 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -93,6 +93,8 @@ protected: void EventUnbind(Event *ev); void DoMove(Event *ev); void WaitMove(Event *ev); + void Stop(Event *ev); + void ThreadMove(Event *ev); void MoveEnd(Event *ev); void SetAnglesEvent(Event *ev); void SetAngleEvent(Event *ev); @@ -113,6 +115,7 @@ protected: void MoveBackward(Event *ev); void MoveLeft(Event *ev); void MoveRight(Event *ev); + void MoveOffset(Event *ev); void RotateXdownto(Event *ev); void RotateYdownto(Event *ev); void RotateZdownto(Event *ev); @@ -136,6 +139,11 @@ protected: void RotateY(Event *ev); void RotateZ(Event *ev); void RotateAxis(Event *ev); + void TouchFunc(Event *ev); + void BlockFunc(Event *ev); + void TriggerFunc(Event *ev); + void UseFunc(Event *ev); + void DamageFunc(Event *ev); void SetDamage(Event *ev); void SetMeansOfDeath(Event *ev); void FollowPath(Event *ev); @@ -150,7 +158,6 @@ protected: void PhysicsOn(Event *ev); void PhysicsOff(Event *ev); void PhysicsVelocity(Event *ev); - void DamageFunc(Event *ev); void EventFlyPath(Event *ev); void EventModifyFlyPath(Event *ev); void EventNormalAngles(Event *ev); // Added in 2.0 @@ -201,6 +208,7 @@ inline void ScriptSlave::Archive(Archiver& arc) arc.ArchiveFloat(&splineTime); arc.ArchiveBoolean(&splineangles); arc.ArchiveBoolean(&ignoreangles); + arc.ArchiveBoolean(&ignorevelocity); arc.ArchiveBoolean(&moving); if (arc.Saving()) { @@ -280,6 +288,9 @@ class ScriptOrigin : public ScriptSlave public: CLASS_PROTOTYPE(ScriptOrigin); ScriptOrigin(); + + void SetAngleEvent(Event *ev); // Added in 2.30 + void GetAngleEvent(Event *ev); // Added in 2.30 }; class ScriptSkyOrigin : public ScriptSlave diff --git a/code/fgame/scriptthread.cpp b/code/fgame/scriptthread.cpp index 7146f58b..f5a91873 100644 --- a/code/fgame/scriptthread.cpp +++ b/code/fgame/scriptthread.cpp @@ -430,7 +430,8 @@ Event EV_ScriptThread_KillEnt ); Event EV_ScriptThread_IsAlive ( - "IsAlive", EV_DEFAULT, + "IsAlive", + EV_DEFAULT, "e", "ent", "Returns true if the specified entity exists and has health > 0.", @@ -707,7 +708,8 @@ Event EV_ScriptThread_Vector_Normalize ); Event EV_ScriptThread_Vector_Add ( - "vector_add", EV_DEFAULT, + "vector_add", + EV_DEFAULT, "vv", "vector1 vector2", "Returns vector1 + vector2.", @@ -724,7 +726,8 @@ Event EV_ScriptThread_Vector_Subtract ); Event EV_ScriptThread_Vector_Scale ( - "vector_scale", EV_DEFAULT, + "vector_scale", + EV_DEFAULT, "vf", "vector1 scale_factor", "Returns vector1 * scale_factor.", @@ -732,7 +735,8 @@ Event EV_ScriptThread_Vector_Scale ); Event EV_ScriptThread_Vector_DotProduct ( - "vector_dot", EV_DEFAULT, + "vector_dot", + EV_DEFAULT, "vv", "vector1 vector2", "Returns vector1 * vector2.", @@ -953,7 +957,7 @@ Event EV_ScriptThread_HudDraw_VirtualSize EV_DEFAULT, "ii", "index virtual", - "Sets if the huddraw element for given player should use virutal screen resolution for positioning and size", + "Sets if the huddraw element for given player should use virtual screen resolution for positioning and size", EV_NORMAL ); Event EV_ScriptThread_HudDraw_Color @@ -1039,10 +1043,9 @@ Event EV_ScriptThread_BspTransition ( "bsptransition", EV_DEFAULT, - "s", - "next_map", - "Transitions to the next BSP. Keeps player data," - "and game data." + "sB", + "next_map skipFade", // Added in 2.30: skipFade + "Transitions to the next BSP. Keeps player data, and game data." ); Event EV_ScriptThread_LevelTransition ( @@ -1365,7 +1368,7 @@ Event EV_ScriptThread_iHudDrawVirtualSize EV_DEFAULT, "eii", "player index virtual", - "Sets if the huddraw element for given player should use virutal screen resolution for positioning and size", + "Sets if the huddraw element for given player should use virtual screen resolution for positioning and size", EV_NORMAL ); Event EV_ScriptThread_IsArray @@ -1432,6 +1435,15 @@ Event EV_ScriptThread_FileRead EV_NORMAL ); Event EV_ScriptThread_FileClose +( + "fclose", + EV_DEFAULT, + "i", + "filehandle", + "Closes file of given file handle", + EV_NORMAL +); +Event EV_ScriptThread_FileClose2 ( "fclose", EV_DEFAULT, @@ -1664,6 +1676,24 @@ Event EV_ScriptThread_UnregisterEv "Unregisters script callback handler for specified event", EV_RETURN ); +Event EV_ScriptThread_Event_Subscribe +( + "event_subscribe", + EV_DEFAULT, + "ss", + "eventname script", + "Subscribe to the specified event. The specified script will be executed when the event gets triggered.", + EV_NORMAL +); +Event EV_ScriptThread_Event_Unsubscribe +( + "event_unsubscribe", + EV_DEFAULT, + "ss", + "eventname script", + "Unsubscribe the script from the specified event.", + EV_NORMAL +); Event EV_ScriptThread_Conprintf ( "conprintf", @@ -1969,6 +1999,15 @@ Event EV_ScriptThread_Md5String "generates MD5 hash of given text", EV_RETURN ); +Event EV_ScriptThread_GetEntity +( + "getentity", + EV_CHEAT, + "i", + "ent_num", + "Gets the specified entity", + EV_RETURN +); Event EV_ScriptThread_SetTimer ( "settimer", @@ -2015,6 +2054,15 @@ Event EV_ScriptThread_VisionSetNaked "empty string, it will be set to the current map's name.", EV_NORMAL ); +Event EV_ScriptThread_IsBot +( + "isBot", + EV_DEFAULT, + "e", + "entity", + "Returns 1 if the client is a bot, 0 otherwise. Will return 0 if the entity is not a client.", + EV_RETURN +); CLASS_DECLARATION(Listener, ScriptThread, NULL) { {&EV_ScriptThread_GetCvar, &ScriptThread::Getcvar }, @@ -2109,7 +2157,7 @@ CLASS_DECLARATION(Listener, ScriptThread, NULL) { {&EV_ScriptThread_MissionFailed, &ScriptThread::MissionFailed }, {&EV_ScriptThread_IsAlive, &ScriptThread::EventIsAlive }, {&EV_ScriptThread_Popmenu, &ScriptThread::EventPopmenu }, - {&EV_ScriptThread_Showmenu, &ScriptThread::EventPopmenu }, + {&EV_ScriptThread_Showmenu, &ScriptThread::EventShowmenu }, {&EV_ScriptThread_Hidemenu, &ScriptThread::EventHidemenu }, {&EV_ScriptThread_PlayMovie, &ScriptThread::EventPlayMovie }, {&EV_ScriptThread_Pushmenu, &ScriptThread::EventPushmenu }, @@ -2168,9 +2216,12 @@ CLASS_DECLARATION(Listener, ScriptThread, NULL) { {&EV_ScriptThread_GetTanH, &ScriptThread::EventTanH }, {&EV_ScriptThread_strncpy, &ScriptThread::StringBytesCopy }, {&EV_ScriptThread_Md5String, &ScriptThread::Md5String }, + {&EV_ScriptThread_GetEntity, &ScriptThread::GetEntByEntnum }, {&EV_ScriptThread_TypeOf, &ScriptThread::TypeOfVariable }, {&EV_ScriptThread_RegisterEv, &ScriptThread::RegisterEvent }, {&EV_ScriptThread_UnregisterEv, &ScriptThread::UnregisterEvent }, + {&EV_ScriptThread_Event_Subscribe, &ScriptThread::SubscribeEvent }, + {&EV_ScriptThread_Event_Unsubscribe, &ScriptThread::UnsubscribeEvent }, {&EV_ScriptThread_CancelWaiting, &ScriptThread::CancelWaiting }, {&EV_ScriptThread_GetTime, &ScriptThread::GetTime }, {&EV_ScriptThread_GetTimeZone, &ScriptThread::GetTimeZone }, @@ -2188,6 +2239,7 @@ CLASS_DECLARATION(Listener, ScriptThread, NULL) { {&EV_ScriptThread_Earthquake2, &ScriptThread::Earthquake }, {&EV_ScriptThread_FadeSound, &ScriptThread::FadeSound }, {&EV_ScriptThread_FileClose, &ScriptThread::FileClose }, + {&EV_ScriptThread_FileClose2, &ScriptThread::FileClose }, {&EV_ScriptThread_FileCopy, &ScriptThread::FileCopy }, {&EV_ScriptThread_FileEof, &ScriptThread::FileEof }, {&EV_ScriptThread_FileError, &ScriptThread::FileError }, @@ -2240,6 +2292,7 @@ CLASS_DECLARATION(Listener, ScriptThread, NULL) { {&EV_ScriptThread_TraceDetails, &ScriptThread::TraceDetails }, {&EV_ScriptThread_VisionGetNaked, &ScriptThread::VisionGetNaked }, {&EV_ScriptThread_VisionSetNaked, &ScriptThread::VisionSetNaked }, + {&EV_ScriptThread_IsBot, &ScriptThread::IsPlayerBot }, {NULL, NULL } }; @@ -2273,7 +2326,7 @@ ScriptThread::ScriptThread(ScriptClass *scriptClass, unsigned char *pCodePos) ScriptThread::~ScriptThread() { - ScriptVM* vm; + ScriptVM *vm; if (g_scripttrace->integer && CanScriptTracePrint()) { gi.DPrintf2("---Destructor THREAD: %p\n", this); @@ -2282,10 +2335,11 @@ ScriptThread::~ScriptThread() assert(m_ScriptVM); if (!m_ScriptVM) { // should never happen - throw ScriptException("Attempting to delete a dead thread."); + //throw ScriptException("Attempting to delete a dead thread."); + gi.Error(ERR_DROP, "Attempting to delete a dead thread."); } - vm = m_ScriptVM; + vm = m_ScriptVM; m_ScriptVM = NULL; if (vm->ThreadState() == THREAD_WAITING) { vm->m_ThreadState = THREAD_RUNNING; @@ -2366,7 +2420,7 @@ void ScriptThread::ScriptExecuteInternal(ScriptVariable *data, int dataSize) SafePtr currentThread; SafePtr previousThread; - currentThread = Director.CurrentThread(); + currentThread = Director.CurrentThread(); previousThread = this; Director.m_PreviousThread = Director.CurrentThread(); @@ -2474,7 +2528,7 @@ void ScriptThread::Stop(void) } } -void ScriptThread::Wait(float time) +void ScriptThread::Wait(int time) { StartTiming(level.inttime + time); m_ScriptVM->Suspend(); @@ -2489,10 +2543,10 @@ void ScriptThread::Pause() void ScriptThread::Getcvar(Event *ev) { str varName = ev->GetString(1); - str s = gi.Cvar_Get(varName.c_str(), "", 0)->string; + str s = gi.Cvar_Get(varName.c_str(), "", 0)->string; if (strstr(s.c_str(), ".")) { - for (int i = s.length() - 1; i >= 0; i--) { + for (size_t i = s.length() - 1; i >= 0; i--) { if (s[i] == '0') { s[i] = 0; } else { @@ -2707,12 +2761,17 @@ void ScriptThread::EventDelayThrow(Event *ev) void ScriptThread::EventWait(Event *ev) { - Wait((int)(ev->GetFloat(1) * 1000.0f + 0.5f)); + float timeSeconds; + + // Fixed in OPM + // Clamp to make sure to not overflow when converting to integer + timeSeconds = Q_clamp_float(ev->GetFloat(1), 0, 2000000); + Wait((int)roundf(timeSeconds * 1000)); } void ScriptThread::EventWaitFrame(Event *ev) { - Wait((int)(level.frametime * 1000.0f + 0.5f)); + Wait((int)roundf(level.frametime * 1000)); } void ScriptThread::EventResume(Event *ev) @@ -2788,7 +2847,7 @@ void ScriptThread::IPrintln(Event *ev) sString += ev->GetString(i); } - G_PrintToAllClients(gi.LV_ConvertString(sString), false); + gi.SendServerCommand(-1, "print \"" HUD_MESSAGE_YELLOW "%s\n\"", gi.LV_ConvertString(sString.c_str())); } void ScriptThread::IPrintlnBold(Event *ev) @@ -2801,7 +2860,7 @@ void ScriptThread::IPrintlnBold(Event *ev) sString += ev->GetString(i); } - G_PrintToAllClients(gi.LV_ConvertString(sString), true); + gi.SendServerCommand(-1, "print \"" HUD_MESSAGE_WHITE "%s\n\"", gi.LV_ConvertString(sString.c_str())); } void ScriptThread::IPrintln_NoLoc(Event *ev) @@ -2814,7 +2873,7 @@ void ScriptThread::IPrintln_NoLoc(Event *ev) sString += ev->GetString(i); } - G_PrintToAllClients(sString, false); + gi.SendServerCommand(-1, "print \"" HUD_MESSAGE_YELLOW "%s\n\"", sString.c_str()); } void ScriptThread::IPrintlnBold_NoLoc(Event *ev) @@ -2827,7 +2886,7 @@ void ScriptThread::IPrintlnBold_NoLoc(Event *ev) sString += ev->GetString(i); } - G_PrintToAllClients(sString, true); + gi.SendServerCommand(-1, "print \"" HUD_MESSAGE_WHITE "%s\n\"", sString.c_str()); } void ScriptThread::MPrint(Event *ev) @@ -2906,7 +2965,8 @@ void ScriptThread::TriggerEvent(Event *ev) void ScriptThread::RegisterAliasAndCache(Event *ev) { //assert(!"ScriptThread::RegisterAliasAndCache needs to be implemented like ClientGameCommandManager::AliasCache"); - gi.DPrintf("ScriptThread::RegisterAliasAndCache needs to be implemented like ClientGameCommandManager::AliasCache\n"); + gi.DPrintf("ScriptThread::RegisterAliasAndCache needs to be implemented like ClientGameCommandManager::AliasCache\n" + ); } void ScriptThread::CacheResourceEvent(Event *ev) @@ -3022,6 +3082,16 @@ Listener *ScriptThread::SpawnInternal(Event *ev) throw ScriptException("Usage: spawn entityname [keyname] [value]..."); } + // Fixed in OPM + // The original game uses a raw char* pointer to get the classname rather than storing it in an str. + // This causes an issue when the argument is none (NIL), stringValue() will allocate and return a new str() with "NIL". + // As the returned str() is not stored anywhere, it gets destroyed immediately, meaning that the char* pointer gets empty. + // This has the effect of using empty class ID, which is "Explosion" in original game. + // + // For example, t2l2 has an incorrect "mg42_spawner_gunner" of class PathNode, but PathNode has no model variable. + // global/spawner.scr::spawner_activate: + // - In OG, it will successfully spawn an instance of "Explosion" due to the NIL argument behavior stated above. + // - In OPM, it will not spawn anything and will cause script errors, it's the expected behavior by design classname = ev->GetString(1); if (getClassForID(classname) || getClass(classname)) { @@ -3463,7 +3533,15 @@ void ScriptThread::CameraCommand(Event *ev) void ScriptThread::MissionFailed(Event *ev) { - G_MissionFailed(); + bool bNoFade; + + if (level.intermissiontime) { + return; + } + + bNoFade = ev->NumArgs() && ev->GetInteger(1); + + G_BeginIntermission(level.current_map, TRANS_MISSION_FAILED, bNoFade); } void ScriptThread::Archive(Archiver& arc) {} @@ -3523,31 +3601,46 @@ void ScriptThread::Vector_CrossProduct(Event *ev) void ScriptThread::Vector_ToAngles(Event *ev) { - ev->AddVector(ev->GetVector(1).toAngles()); + Vector v1; + Vector v3; + + v1 = ev->GetVector(1); + vectoangles(v1, v3); + + ev->AddVector(v3); } void ScriptThread::Angles_ToForward(Event *ev) { - Vector fwd; + Vector v1; + Vector v3; - ev->GetVector(1).AngleVectors(&fwd); - ev->AddVector(fwd); + v1 = ev->GetVector(1); + + AngleVectors(v1, v3, NULL, NULL); + ev->AddVector(v3); } void ScriptThread::Angles_ToLeft(Event *ev) { - Vector left; + Vector v1; + Vector v3; - ev->GetVector(1).AngleVectors(NULL, &left); - ev->AddVector(left); + v1 = ev->GetVector(1); + + AngleVectors(v1, NULL, v3, NULL); + ev->AddVector(v3); } void ScriptThread::Angles_ToUp(Event *ev) { - Vector up; + Vector v1; + Vector v3; - ev->GetVector(1).AngleVectors(NULL, NULL, &up); - ev->AddVector(up); + v1 = ev->GetVector(1); + + AngleVectors(v1, NULL, NULL, v3); + ev->AddVector(v3); } void ScriptThread::Angles_PointAt(Event *ev) @@ -3576,7 +3669,7 @@ void ScriptThread::Angles_PointAt(Event *ev) void ScriptThread::EventIsAlive(Event *ev) { - Entity* ent; + Entity *ent; if (!ev->IsEntityAt(1)) { ev->AddInteger(false); @@ -3705,13 +3798,6 @@ void ScriptThread::EventHideMouse(Event *ev) { gentity_t *ent; int i; - str name; - - if (game.maxclients <= 0) { - return; - } - - name = ev->GetString(1); for (i = 0, ent = g_entities; i < game.maxclients; i++, ent++) { if (!ent->inuse || !ent->client) { @@ -3746,7 +3832,7 @@ void ScriptThread::EventTrace(Event *ev) mins = ev->GetVector(4); case 3: if (ev->GetInteger(3)) { - content_mask = MASK_SOLID; + content_mask &= ~MASK_SCRIPT_SLAVE; } case 2: end = ev->GetVector(2); @@ -3765,7 +3851,7 @@ void ScriptThread::EventTrace(Event *ev) void ScriptThread::EventSightTrace(Event *ev) { - int content_mask = MASK_LINE; + int content_mask = MASK_SOLID; Vector start; Vector mins; Vector maxs; @@ -3781,7 +3867,7 @@ void ScriptThread::EventSightTrace(Event *ev) mins = ev->GetVector(4); case 3: if (ev->GetInteger(3)) { - content_mask = MASK_SOLID; + content_mask &= ~MASK_IGNORE_ENTS; } case 2: end = ev->GetVector(2); @@ -3868,7 +3954,7 @@ void ScriptThread::EventHudDrawAlign(Event *ev) } else if (h_align == "right") { h_alignement = 2; } else { - throw ScriptException("Wrong alignement h_align string for huddraw_align!\n"); + throw ScriptException("Wrong alignment h_align string for huddraw_align!\n"); } if (v_align == "top") { @@ -3878,7 +3964,7 @@ void ScriptThread::EventHudDrawAlign(Event *ev) } else if (v_align == "bottom") { v_alignement = 2; } else { - throw ScriptException("Wrong alignement v_align string for huddraw_align!\n"); + throw ScriptException("Wrong alignment v_align string for huddraw_align!\n"); } HudDrawAlign(index, h_alignement, v_alignement); @@ -4022,7 +4108,7 @@ void ScriptThread::EventDebugInt3(Event *ev) void ScriptThread::EventTimeout(Event *ev) { - Director.maxTime = ev->GetFloat(1) * 1000.0f + 0.5f; + Director.maxTime = roundf(ev->GetFloat(1) * 1000.0f); } void ScriptThread::EventLandmineDamage(Event *ev) @@ -4067,10 +4153,16 @@ void ScriptThread::EventRadiusDamage(Event *ev) void ScriptThread::EventBspTransition(Event *ev) { - str map = ev->GetString(1); + str map = ev->GetString(1); + bool skipFade = false; + + if (ev->NumArgs() >= 2) { + // Added in 2.30 + skipFade = ev->GetBoolean(2); + } if (level.intermissiontime == 0.0f) { - G_BeginIntermission(map, TRANS_BSP); + G_BeginIntermission(map, TRANS_BSP, skipFade); } } @@ -4139,7 +4231,7 @@ void ScriptThread::EventEarthquake(Event *ev) { earthquake_t e; - e.duration = (int)(ev->GetFloat(1) * 1000.0f + 0.5f); + e.duration = (int)roundf(ev->GetFloat(1) * 1000.0f); if (e.duration <= 0) { return; } @@ -4170,12 +4262,16 @@ void ScriptThread::EventAIsCloserThanBToC(Event *ev) void ScriptThread::EventPointsWithinDist(Event *ev) { Vector delta; - float dist = ev->GetFloat(3); + Vector v1, v2; + float fDistance; - delta = ev->GetVector(1) - ev->GetVector(2); + v1 = ev->GetVector(1); + v2 = ev->GetVector(2); + fDistance = ev->GetFloat(3); + delta = v1 - v2; // check squared distance - ev->AddInteger(((delta * delta) < (dist * dist))); + ev->AddInteger(delta.lengthSquared() < Square(fDistance)); } bool ScriptThread::CanScriptTracePrint(void) @@ -4274,27 +4370,20 @@ void ScriptThread::SetCurrentObjective(int iObjective, int iTeam) gi.setConfigstring(CS_CURRENT_OBJECTIVE, va("%i", iObjective)); if (iObjective == -1) { - level.m_vObjectiveLocation = vec_zero; + level.m_vObjectiveLocation = vec_zero; level.m_vAlliedObjectiveLocation = vec_zero; - level.m_vAxisObjectiveLocation = vec_zero; + level.m_vAxisObjectiveLocation = vec_zero; } else { const char *s = gi.getConfigstring(CS_OBJECTIVES + iObjective); const char *loc = Info_ValueForKey(s, "loc"); - Vector v; + Vector v; - sscanf( - loc, - "%f %f %f", - &v[0], - &v[1], - &v[2] - ); + sscanf(loc, "%f %f %f", &v[0], &v[1], &v[2]); // // Since 2.0, allow objective location per team // - switch (iTeam) - { + switch (iTeam) { case TEAM_NONE: default: level.m_vObjectiveLocation = v; @@ -4375,14 +4464,13 @@ void ScriptThread::EventSetScoreboardToggle(Event *ev) void ScriptThread::EventSetCurrentObjective(Event *ev) { int iObjective = ev->GetInteger(1); - int iTeam = 0; + int iTeam = 0; if (iObjective > MAX_OBJECTIVES) { ScriptError("Index Out Of Range"); } - if (ev->NumArgs() >= 2) - { + if (ev->NumArgs() >= 2) { const_str teamStr = ev->GetConstString(2); if (teamStr == STRING_ALLIES) { iTeam = TEAM_ALLIES; @@ -4622,7 +4710,7 @@ void ScriptThread::RestoreSound(Event *ev) time = delaytime * 1000.0f; - gi.SendServerCommand(player != NULL ? player->edict - g_entities : NULL, "restoresound %0.2f %f", time, max_vol); + gi.SendServerCommand(player != NULL ? player->edict - g_entities : 0, "restoresound %0.2f %f", time, max_vol); } void ScriptThread::EventHudDraw3d(Event *ev) @@ -4716,7 +4804,7 @@ void ScriptThread::GetPlayerIP(Event *ev) ip = ent->client->pers.ip; - sprintf(ip_buff, "%s:%i", ip, ent->client->pers.port); + Com_sprintf(ip_buff, sizeof(ip_buff), "%s:%i", ip, ent->client->pers.port); ev->AddString(ip_buff); } @@ -5022,7 +5110,7 @@ void ScriptThread::EventIHudDrawAlign(Event *ev) } else if (h_align == "right") { h_alignement = 2; } else { - throw ScriptException("Wrong alignement h_align string for ihuddraw_align!\n"); + throw ScriptException("Wrong alignment h_align string for ihuddraw_align!\n"); } if (v_align == "top") { @@ -5032,7 +5120,7 @@ void ScriptThread::EventIHudDrawAlign(Event *ev) } else if (v_align == "bottom") { v_alignement = 2; } else { - throw ScriptException("Wrong alignement v_align string for ihuddraw_align!\n"); + throw ScriptException("Wrong alignment v_align string for ihuddraw_align!\n"); } iHudDrawAlign(player->edict - g_entities, index, h_alignement, v_alignement); @@ -5283,13 +5371,13 @@ void ScriptThread::TeamSetScore(Event *ev) if (bAdd) { team->m_iKills += score; - if (g_gametype->integer < 3) { + if (g_gametype->integer < GT_TEAM_ROUNDS) { team->m_teamwins += score; } } else { team->m_iKills = score; - if (g_gametype->integer < 3) { + if (g_gametype->integer < GT_TEAM_ROUNDS) { team->m_teamwins = score; } } @@ -5333,15 +5421,15 @@ void ScriptThread::FileOpen(Event *ev) f = fopen(filename, accesstype); - if (f == NULL) { - ev->AddInteger(0); - return; - } else { - ev->AddInteger((int)(size_t)f); - sprintf(buf, "%i", scriptfiles->integer + 1); - gi.cvar_set("sv_scriptfiles", buf); + if (!f) { + ev->AddNil(); return; } + + ev->AddListener(new OSFile(f)); + + Com_sprintf(buf, sizeof(buf), "%i", scriptfiles->integer + 1); + gi.cvar_set("sv_scriptfiles", buf); } void ScriptThread::FileWrite(Event *ev) {} @@ -5350,11 +5438,10 @@ void ScriptThread::FileRead(Event *ev) {} void ScriptThread::FileClose(Event *ev) { - int id = 0; - int numArgs = 0; - int ret = 0; - FILE *f = NULL; - char buf[16] = {0}; + OSFile *osFile = NULL; + int numArgs = 0; + FILE *f = NULL; + char buf[16] = {0}; numArgs = ev->NumArgs(); @@ -5362,57 +5449,30 @@ void ScriptThread::FileClose(Event *ev) throw ScriptException("Wrong arguments count for fclose!\n"); } - id = ev->GetInteger(1); - - /*if( (int)scriptFiles[0].f != id && (int)scriptFiles[1].f != id ) - { - gi.Printf("Wrong file handle for fclose!\n"); - return; + osFile = (OSFile *)ev->GetListener(1); + if (!osFile || !osFile->isSubclassOf(OSFile)) { + throw ScriptException("Not a file!\n"); } - if( (int)scriptFiles[0].f == id ) - { - scriptFiles[0].inUse = 0; - fclose( scriptFiles[0].f ); - return; - } - else if( (int)scriptFiles[1].f == id ) - { - scriptFiles[1].inUse = 0; - fclose( scriptFiles[1].f ); - return; - } - else - { - gi.Printf("Unknown error while closing file - fclose!\n"); - return; - }*/ - - f = (FILE *)id; + f = (FILE *)osFile->getOSFile(); if (f == NULL) { throw ScriptException("File handle is NULL for fclose!\n"); } - ret = fclose(f); + // delete the file object + delete osFile; - if (ret == 0) { - ev->AddInteger(0); - sprintf(buf, "%i", scriptfiles->integer - 1); - gi.cvar_set("sv_scriptfiles", buf); - return; - } else { - ev->AddInteger(ret); - return; - } + Com_sprintf(buf, sizeof(buf), "%i", scriptfiles->integer - 1); + gi.cvar_set("sv_scriptfiles", buf); } void ScriptThread::FileEof(Event *ev) { - int id = 0; - int numArgs = 0; - int ret = 0; - FILE *f = NULL; + OSFile *osFile = NULL; + int numArgs = 0; + int ret = 0; + FILE *f = NULL; numArgs = ev->NumArgs(); @@ -5420,9 +5480,12 @@ void ScriptThread::FileEof(Event *ev) throw ScriptException("Wrong arguments count for feof!\n"); } - id = ev->GetInteger(1); + osFile = (OSFile *)ev->GetListener(1); + if (!osFile || !osFile->isSubclassOf(OSFile)) { + throw ScriptException("Not a file!\n"); + } - f = (FILE *)id; + f = (FILE *)osFile->getOSFile(); ret = feof(f); @@ -5431,7 +5494,7 @@ void ScriptThread::FileEof(Event *ev) void ScriptThread::FileSeek(Event *ev) { - int id = 0; + OSFile *osFile = NULL; int numArgs = 0; int pos = 0; long int offset = 0; @@ -5444,9 +5507,12 @@ void ScriptThread::FileSeek(Event *ev) throw ScriptException("Wrong arguments count for fseek!\n"); } - id = ev->GetInteger(1); + osFile = (OSFile *)ev->GetListener(1); + if (!osFile || !osFile->isSubclassOf(OSFile)) { + throw ScriptException("Not a file!\n"); + } - f = (FILE *)id; + f = (FILE *)osFile->getOSFile(); offset = ev->GetInteger(2); @@ -5467,7 +5533,7 @@ void ScriptThread::FileSeek(Event *ev) void ScriptThread::FileTell(Event *ev) { - int id = 0; + OSFile *osFile = NULL; int numArgs = 0; long int ret = 0; FILE *f = NULL; @@ -5478,9 +5544,12 @@ void ScriptThread::FileTell(Event *ev) throw ScriptException("Wrong arguments count for ftell!\n"); } - id = ev->GetInteger(1); + osFile = (OSFile *)ev->GetListener(1); + if (!osFile || !osFile->isSubclassOf(OSFile)) { + throw ScriptException("Not a file!\n"); + } - f = (FILE *)id; + f = (FILE *)osFile->getOSFile(); ret = ftell(f); @@ -5489,7 +5558,7 @@ void ScriptThread::FileTell(Event *ev) void ScriptThread::FileRewind(Event *ev) { - int id = 0; + OSFile *osFile = NULL; int numArgs = 0; long int ret = 0; FILE *f = NULL; @@ -5500,20 +5569,23 @@ void ScriptThread::FileRewind(Event *ev) throw ScriptException("Wrong arguments count for frewind!\n"); } - id = ev->GetInteger(1); + osFile = (OSFile *)ev->GetListener(1); + if (!osFile || !osFile->isSubclassOf(OSFile)) { + throw ScriptException("Not a file!\n"); + } - f = (FILE *)id; + f = (FILE *)osFile->getOSFile(); rewind(f); } void ScriptThread::FilePutc(Event *ev) { - int id = 0; - int numArgs = 0; - int ret = 0; - FILE *f = NULL; - int c = 0; + OSFile *osFile = NULL; + int numArgs = 0; + int ret = 0; + FILE *f = NULL; + int c = 0; numArgs = ev->NumArgs(); @@ -5521,9 +5593,12 @@ void ScriptThread::FilePutc(Event *ev) throw ScriptException("Wrong arguments count for fputc!\n"); } - id = ev->GetInteger(1); + osFile = (OSFile *)ev->GetListener(1); + if (!osFile || !osFile->isSubclassOf(OSFile)) { + throw ScriptException("Not a file!\n"); + } - f = (FILE *)id; + f = (FILE *)osFile->getOSFile(); c = ev->GetInteger(2); @@ -5534,11 +5609,11 @@ void ScriptThread::FilePutc(Event *ev) void ScriptThread::FilePuts(Event *ev) { - int id = 0; - int numArgs = 0; - int ret = 0; - FILE *f = NULL; - str c; + OSFile *osFile = NULL; + int numArgs = 0; + int ret = 0; + FILE *f = NULL; + str c; numArgs = ev->NumArgs(); @@ -5546,9 +5621,12 @@ void ScriptThread::FilePuts(Event *ev) throw ScriptException("Wrong arguments count for fputs!\n"); } - id = ev->GetInteger(1); + osFile = (OSFile *)ev->GetListener(1); + if (!osFile || !osFile->isSubclassOf(OSFile)) { + throw ScriptException("Not a file!\n"); + } - f = (FILE *)id; + f = (FILE *)osFile->getOSFile(); c = ev->GetString(2); //gi.Printf("Putting line into a file\n"); @@ -5559,10 +5637,10 @@ void ScriptThread::FilePuts(Event *ev) void ScriptThread::FileGetc(Event *ev) { - int id = 0; - int numArgs = 0; - int ret = 0; - FILE *f = NULL; + OSFile *osFile = NULL; + int numArgs = 0; + int ret = 0; + FILE *f = NULL; numArgs = ev->NumArgs(); @@ -5570,9 +5648,12 @@ void ScriptThread::FileGetc(Event *ev) throw ScriptException("Wrong arguments count for fgetc!\n"); } - id = ev->GetInteger(1); + osFile = (OSFile *)ev->GetListener(1); + if (!osFile || !osFile->isSubclassOf(OSFile)) { + throw ScriptException("Not a file!\n"); + } - f = (FILE *)id; + f = (FILE *)osFile->getOSFile(); ret = fgetc(f); @@ -5581,12 +5662,12 @@ void ScriptThread::FileGetc(Event *ev) void ScriptThread::FileGets(Event *ev) { - int id = 0; - int numArgs = 0; - int maxCount = 0; - FILE *f = NULL; - char *c = NULL; - char *buff = NULL; + OSFile *osFile = NULL; + int numArgs = 0; + int maxCount = 0; + FILE *f = NULL; + char *c = NULL; + char *buff = NULL; numArgs = ev->NumArgs(); @@ -5594,9 +5675,12 @@ void ScriptThread::FileGets(Event *ev) throw ScriptException("Wrong arguments count for fgets!\n"); } - id = ev->GetInteger(1); + osFile = (OSFile *)ev->GetListener(1); + if (!osFile || !osFile->isSubclassOf(OSFile)) { + throw ScriptException("Not a file!\n"); + } - f = (FILE *)id; + f = (FILE *)osFile->getOSFile(); maxCount = ev->GetInteger(2); @@ -5629,10 +5713,10 @@ void ScriptThread::FileGets(Event *ev) void ScriptThread::FileError(Event *ev) { - int id = 0; - int numArgs = 0; - int ret = 0; - FILE *f = NULL; + OSFile *osFile = NULL; + int numArgs = 0; + int ret = 0; + FILE *f = NULL; numArgs = ev->NumArgs(); @@ -5640,9 +5724,12 @@ void ScriptThread::FileError(Event *ev) throw ScriptException("Wrong arguments count for ferror!\n"); } - id = ev->GetInteger(1); + osFile = (OSFile *)ev->GetListener(1); + if (!osFile || !osFile->isSubclassOf(OSFile)) { + throw ScriptException("Not a file!\n"); + } - f = (FILE *)id; + f = (FILE *)osFile->getOSFile(); ret = ferror(f); @@ -5651,10 +5738,10 @@ void ScriptThread::FileError(Event *ev) void ScriptThread::FileFlush(Event *ev) { - int id = 0; - int numArgs = 0; - int ret = 0; - FILE *f = NULL; + OSFile *osFile = NULL; + int numArgs = 0; + int ret = 0; + FILE *f = NULL; numArgs = ev->NumArgs(); @@ -5662,9 +5749,12 @@ void ScriptThread::FileFlush(Event *ev) throw ScriptException("Wrong arguments count for fflush!\n"); } - id = ev->GetInteger(1); + osFile = (OSFile *)ev->GetListener(1); + if (!osFile || !osFile->isSubclassOf(OSFile)) { + throw ScriptException("Not a file!\n"); + } - f = (FILE *)id; + f = (FILE *)osFile->getOSFile(); ret = fflush(f); @@ -5673,7 +5763,6 @@ void ScriptThread::FileFlush(Event *ev) void ScriptThread::FileExists(Event *ev) { - int id = 0; int numArgs = 0; FILE *f = 0; str filename; @@ -5686,7 +5775,7 @@ void ScriptThread::FileExists(Event *ev) filename = ev->GetString(1); - if (filename == NULL) { + if (!filename.length()) { throw ScriptException("Empty file name passed to fexists!\n"); } @@ -5701,13 +5790,13 @@ void ScriptThread::FileExists(Event *ev) void ScriptThread::FileReadAll(Event *ev) { - int id = 0; - int numArgs = 0; - FILE *f = NULL; - char *ret = NULL; - long currentPos = 0; - size_t size = 0; - size_t sizeRead = 0; + OSFile *osFile = NULL; + int numArgs = 0; + FILE *f = NULL; + char *ret = NULL; + long currentPos = 0; + size_t size = 0; + size_t sizeRead = 0; numArgs = ev->NumArgs(); @@ -5715,9 +5804,12 @@ void ScriptThread::FileReadAll(Event *ev) throw ScriptException("Wrong arguments count for freadall!\n"); } - id = ev->GetInteger(1); + osFile = (OSFile *)ev->GetListener(1); + if (!osFile || !osFile->isSubclassOf(OSFile)) { + throw ScriptException("Not a file!\n"); + } - f = (FILE *)id; + f = (FILE *)osFile->getOSFile(); currentPos = ftell(f); fseek(f, 0, SEEK_END); @@ -5741,11 +5833,11 @@ void ScriptThread::FileReadAll(Event *ev) void ScriptThread::FileSaveAll(Event *ev) { - int id = 0; - int numArgs = 0; - FILE *f = NULL; - size_t sizeWrite = 0; - str text; + OSFile *osFile = NULL; + int numArgs = 0; + FILE *f = NULL; + size_t sizeWrite = 0; + str text; numArgs = ev->NumArgs(); @@ -5753,12 +5845,16 @@ void ScriptThread::FileSaveAll(Event *ev) throw ScriptException("Wrong arguments count for fsaveall!\n"); } - id = ev->GetInteger(1); - f = (FILE *)id; + osFile = (OSFile *)ev->GetListener(1); + if (!osFile || !osFile->isSubclassOf(OSFile)) { + throw ScriptException("Not a file!\n"); + } + + f = (FILE *)osFile->getOSFile(); text = ev->GetString(2); - if (text == NULL) { + if (text.length()) { ev->AddInteger(-1); throw ScriptException("Text to be written is NULL - fsaveall!\n"); } @@ -5770,7 +5866,6 @@ void ScriptThread::FileSaveAll(Event *ev) void ScriptThread::FileRemove(Event *ev) { - int id = 0; int numArgs = 0; int ret = 0; str filename; @@ -5783,7 +5878,7 @@ void ScriptThread::FileRemove(Event *ev) filename = ev->GetString(1); - if (filename == NULL) { + if (!filename.length()) { throw ScriptException("Empty file name passed to fremove!\n"); } @@ -5794,7 +5889,6 @@ void ScriptThread::FileRemove(Event *ev) void ScriptThread::FileRename(Event *ev) { - int id = 0; int numArgs = 0; int ret = 0; str oldfilename, newfilename; @@ -5894,7 +5988,7 @@ void ScriptThread::FileReadPak(Event *ev) filename = ev->GetString(1); - if (filename == NULL) { + if (!filename.length()) { throw ScriptException("Filename is NULL - freadpak!\n"); } @@ -5969,7 +6063,7 @@ void ScriptThread::FileNewDirectory(Event *ev) path = ev->GetString(1); - if (path == NULL) { + if (!path.length()) { throw ScriptException("Path is NULL - fnewdir!\n"); } @@ -5997,7 +6091,7 @@ void ScriptThread::FileRemoveDirectory(Event *ev) path = ev->GetString(1); - if (path == NULL) { + if (!path.length()) { throw ScriptException("Path is NULL - fremovedir!\n"); } @@ -6242,7 +6336,7 @@ void ScriptThread::FlagInit(Event *ev) flag = new Flag; flag->bSignaled = false; - strcpy(flag->flagName, name); + Q_strncpyz(flag->flagName, name, sizeof(flag->flagName)); } void ScriptThread::FlagSet(Event *ev) @@ -6593,7 +6687,7 @@ void ScriptThread::EventFmod(Event *ev) ev->AddFloat((float)res); } -int checkMD5(const char *filepath, char *md5Hash) +int checkMD5(const char *filepath, char *md5Hash, size_t destSize) { md5_state_t state; md5_byte_t digest[16]; @@ -6642,7 +6736,7 @@ int checkMD5(const char *filepath, char *md5Hash) md5_finish(&state, digest); for (di = 0; di < 16; ++di) { - sprintf(md5Hash + di * 2, "%02x", digest[di]); + Com_sprintf(md5Hash + di * 2, destSize - di * 2, "%02x", digest[di]); } gi.Free(buff); @@ -6650,7 +6744,7 @@ int checkMD5(const char *filepath, char *md5Hash) return 0; } -int checkMD5String(const char *string, char *md5Hash) +int checkMD5String(const char *string, char *md5Hash, size_t destSize) { md5_state_t state; md5_byte_t digest[16]; @@ -6675,7 +6769,7 @@ int checkMD5String(const char *string, char *md5Hash) md5_finish(&state, digest); for (di = 0; di < 16; ++di) { - sprintf(md5Hash + di * 2, "%02x", digest[di]); + Com_sprintf(md5Hash + di * 2, destSize - di * 2, "%02x", digest[di]); } gi.Free(buff); @@ -6695,7 +6789,7 @@ void ScriptThread::Md5File(Event *ev) filename = ev->GetString(1); - ret = checkMD5(filename, hash); + ret = checkMD5(filename, hash, sizeof(hash)); if (ret != 0) { ev->AddInteger(-1); throw ScriptException("Error while generating MD5 checksum for file - md5file!\n"); @@ -6732,7 +6826,7 @@ void ScriptThread::Md5String(Event *ev) text = ev->GetString(1); - ret = checkMD5String(text, hash); + ret = checkMD5String(text, hash, sizeof(hash)); if (ret != 0) { ev->AddInteger(-1); throw ScriptException("Error while generating MD5 checksum for strin!\n"); @@ -6791,6 +6885,8 @@ void ScriptThread::RegisterEvent(Event *ev) char eventname_full[64]; scriptedEvType_t evType; + ScriptDeprecatedAltMethod("event_subscribe"); + eventname = ev->GetString(1); evType = EventNameToType(eventname, eventname_full); @@ -6822,6 +6918,8 @@ void ScriptThread::UnregisterEvent(Event *ev) int numArgs = 0; scriptedEvType_t evType; + ScriptDeprecatedAltMethod("event_unsubscribe"); + eventname = ev->GetString(1); evType = EventNameToType(eventname, NULL); @@ -6855,6 +6953,42 @@ void ScriptThread::UnregisterEvent(Event *ev) ev->AddInteger(0); } +void ScriptThread::SubscribeEvent(Event *ev) +{ + str eventName; + ScriptDelegate *delegate; + ScriptThreadLabel label; + + eventName = ev->GetString(1); + + delegate = ScriptDelegate::GetScriptDelegate(eventName); + if (!delegate) { + throw ScriptException("Invalid event '%s'", eventName.c_str()); + } + + label.SetThread(ev->GetValue(2)); + + delegate->Register(label); +} + +void ScriptThread::UnsubscribeEvent(Event *ev) +{ + str eventName; + ScriptDelegate *delegate; + ScriptThreadLabel label; + + eventName = ev->GetString(1); + + delegate = ScriptDelegate::GetScriptDelegate(eventName); + if (!delegate) { + throw ScriptException("Invalid event '%s'", eventName.c_str()); + } + + label.SetThread(ev->GetValue(2)); + + delegate->Unregister(label); +} + void ScriptThread::TypeOfVariable(Event *ev) { int numArgs = 0; @@ -6927,7 +7061,7 @@ void ScriptThread::GetTime(Event *ev) timediff = timearray[0] - gmttime; - sprintf(buff, "%02i:%02i:%02i", (int)timearray[0], (int)timearray[1], (int)timearray[2]); + Com_sprintf(buff, sizeof(buff), "%02i:%02i:%02i", (int)timearray[0], (int)timearray[1], (int)timearray[2]); ev->AddString(buff); } @@ -7021,4 +7155,47 @@ void ScriptThread::TraceDetails(Event *ev) array.setArrayAtRef(entityIndex, entityValue); ev->AddValue(array); -} \ No newline at end of file +} + +void ScriptThread::IsPlayerBot(Event *ev) +{ + Entity *e = ev->GetEntity(1); + + if (!e || !e->client) { + // Invalid entity or not a client + ev->AddInteger(0); + return; + } + + if (!(e->edict->r.svFlags & SVF_BOT)) { + ev->AddInteger(0); + return; + } + + // has SVF_BOT server flag + ev->AddInteger(1); +} + +CLASS_DECLARATION(Listener, OSFile, NULL) { + {NULL, NULL} +}; + +OSFile::OSFile() + : file(NULL) +{} + +OSFile::OSFile(void *inFile) + : file(inFile) +{} + +OSFile::~OSFile() +{ + if (file) { + fclose((FILE *)file); + } +} + +void *OSFile::getOSFile() const +{ + return file; +} diff --git a/code/fgame/scriptthread.h b/code/fgame/scriptthread.h index d46f3b1c..89536853 100644 --- a/code/fgame/scriptthread.h +++ b/code/fgame/scriptthread.h @@ -131,14 +131,14 @@ protected: void GetRandomFloat(Event *ev); void GetRandomInt(Event *ev); - void GetAbs(Event* ev); + void GetAbs(Event *ev); ////////// // Added in 2.30 - void EventCos(Event* ev); - void EventSin(Event* ev); - void EventTan(Event* ev); - void EventATan(Event* ev); - void EventSqrt(Event* ev); + void EventCos(Event *ev); + void EventSin(Event *ev); + void EventTan(Event *ev); + void EventATan(Event *ev); + void EventSqrt(Event *ev); ////////// void GetSelf(Event *ev); void Vector_Length(Event *ev); @@ -192,13 +192,13 @@ public: ScriptThread(ScriptClass *scriptClass, unsigned char *pCodePos); virtual ~ScriptThread(); - void Execute(Event &ev); + void Execute(Event& ev); void Execute(Event *ev); void Execute(); void Execute(ScriptVariable *data, int dataSize); - void Wait(float time); + void Wait(int time); void Pause(void); - void ScriptExecute(ScriptVariable *data, int dataSize, ScriptVariable &returnValue); + void ScriptExecute(ScriptVariable *data, int dataSize, ScriptVariable& returnValue); void ScriptExecuteInternal(ScriptVariable *data = NULL, int dataSize = 0); void EventThrow(Event *ev); void StartWaiting(); @@ -225,22 +225,22 @@ public: // static void AddObjective(int index, int status, str text, Vector location); static void SetCurrentObjective(int iObjective, int iTeam); - void SendObjective(); - void SendObjectives(); - void ClearObjectives(); - void EventAddObjective(Event *ev); - void EventSetScoreboardToggle(Event *ev); // Added in 2.30 - void EventSetCurrentObjective(Event *ev); - void EventClearObjectives(Event *ev); - void SetObjectiveLocation(Vector vLocation); - void SetObjectiveLocation(Event *ev); - void ClearObjectiveLocation(void); - void ClearObjectiveLocation(Event *ev); + void SendObjective(); + void SendObjectives(); + void ClearObjectives(); + void EventAddObjective(Event *ev); + void EventSetScoreboardToggle(Event *ev); // Added in 2.30 + void EventSetCurrentObjective(Event *ev); + void EventClearObjectives(Event *ev); + void SetObjectiveLocation(Vector vLocation); + void SetObjectiveLocation(Event *ev); + void ClearObjectiveLocation(void); + void ClearObjectiveLocation(Event *ev); void EventDrawHud(Event *ev); virtual void Archive(Archiver& arc) override; - void ArchiveInternal(Archiver &arc); + void ArchiveInternal(Archiver& arc); // // Openmohaa addition @@ -345,4 +345,23 @@ public: void UnregisterEvent(Event *ev); void VisionGetNaked(Event *ev); void VisionSetNaked(Event *ev); -}; \ No newline at end of file + void IsPlayerBot(Event *ev); + + void SubscribeEvent(Event *ev); + void UnsubscribeEvent(Event *ev); +}; + +class OSFile : public Listener +{ + CLASS_PROTOTYPE(OSFile); + +public: + OSFile(); + OSFile(void *inFile); + ~OSFile(); + + void *getOSFile() const; + +private: + void *file; +}; diff --git a/code/fgame/scripttimer.h b/code/fgame/scripttimer.h index 96fff34a..9fcfd46d 100644 --- a/code/fgame/scripttimer.h +++ b/code/fgame/scripttimer.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -23,8 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // ScriptTimer.cpp: Scripted Timer & Fader // -#ifndef __SCRIPTTIMER_H__ -#define __SCRIPTTIMER_H__ +#pragma once #include "listener.h" @@ -81,5 +80,3 @@ public: bool isEnabled(); void setType( timertype_e type ); }; - -#endif /* __SCRIPTTIMER_H__ */ diff --git a/code/fgame/sentient.cpp b/code/fgame/sentient.cpp index 46535362..1551a715 100644 --- a/code/fgame/sentient.cpp +++ b/code/fgame/sentient.cpp @@ -146,8 +146,8 @@ Event EV_Sentient_GiveAmmo ( "ammo", EV_DEFAULT, - "si", - "type amount", + "siI", + "type amount max_amount", "Gives the sentient some ammo.", EV_NORMAL ); @@ -193,7 +193,7 @@ Event EV_Sentient_UseItem EV_CONSOLE, "si", "name weapon_hand", - "Use the specified weapon or item in the hand choosen (optional).", + "Use the specified weapon or item in the hand chosen (optional).", EV_NORMAL ); Event EV_Sentient_SetBloodModel @@ -391,7 +391,7 @@ Event EV_Sentient_UseWeaponClass EV_CONSOLE, "sI", "name weapon_hand", - "Use the weapon of the specified class in the hand choosen (optional).", + "Use the weapon of the specified class in the hand chosen (optional).", EV_NORMAL ); Event EV_Sentient_German @@ -531,7 +531,7 @@ Event EV_Sentient_ForceDropWeapon2 ); Event EV_Sentient_ForceDropHealth ( - "forcedropweapon", + "forcedrophealth", EV_DEFAULT, NULL, NULL, @@ -540,7 +540,7 @@ Event EV_Sentient_ForceDropHealth ); Event EV_Sentient_ForceDropHealth2 ( - "forcedropweapon", + "forcedrophealth", EV_DEFAULT, NULL, NULL, @@ -578,6 +578,24 @@ Event EV_Sentient_GetNewActiveWeap "gets new active weapon", EV_RETURN ); +Event EV_Sentient_GetNewActiveWeapon +( + "newActiveWeapon", + EV_DEFAULT, + NULL, + NULL, + "gets new active weapon", + EV_GETTER +); +Event EV_Sentient_GetNewActiveWeaponHand +( + "newActiveWeaponHand", + EV_DEFAULT, + NULL, + NULL, + "gets the hand of the new active weapon", + EV_GETTER +); Event EV_Sentient_GetActiveWeap ( "getactiveweap", @@ -656,10 +674,12 @@ CLASS_DECLARATION(Animate, Sentient, NULL) { {&EV_Sentient_ForceDropWeapon2, &Sentient::EventForceDropWeapon }, {&EV_Sentient_GetForceDropWeapon, &Sentient::EventGetForceDropWeapon }, - {&EV_Sentient_GetActiveWeap, &Sentient::GetActiveWeap }, - {&EV_Sentient_GetNewActiveWeap, &Sentient::GetNewActiveWeapon }, - {&EV_Sentient_Client_Landing, &Sentient::EventClientLanding }, - {NULL, NULL } + {&EV_Sentient_GetActiveWeap, &Sentient::GetActiveWeap }, + {&EV_Sentient_GetNewActiveWeap, &Sentient::GetNewActiveWeaponOld }, + {&EV_Sentient_GetNewActiveWeapon, &Sentient::GetNewActiveWeapon }, + {&EV_Sentient_GetNewActiveWeaponHand, &Sentient::GetNewActiveWeaponHand }, + {&EV_Sentient_Client_Landing, &Sentient::EventClientLanding }, + {NULL, NULL } }; Container SentientList; @@ -690,7 +710,8 @@ void Sentient::EventGiveDynItem(Event *ev) } Sentient::Sentient() - : m_bIsAnimal(false) + : mAccuracy(0.2f) + , m_bIsAnimal(false) { SentientList.AddObject((Sentient *)this); entflags |= ECF_SENTIENT; @@ -1031,7 +1052,7 @@ void Sentient::FreeInventory(void) num = inventory.NumObjects(); for (i = num; i > 0; i--) { item = (Item *)G_GetEntity(inventory.ObjectAt(i)); - delete item; + item->Delete(); } inventory.ClearObjectList(); @@ -1120,30 +1141,19 @@ qboolean Sentient::HasSecondaryWeapon(void) void Sentient::EventGiveTargetname(Event *ev) { - int i; - ConSimple *tlist; - str name; - const char *ptr; - qboolean found; + int i; + str name; + qboolean found; + ScriptVariable var; + SimpleEntity *ent; - name = ev->GetString(1); + var = ev->GetValue(1); + var.CastConstArrayValue(); - ptr = name.c_str(); - - // skip over the $ - ptr++; - - found = qfalse; - - str sName = ptr; - tlist = world->GetTargetList(sName); - for (i = 1; i <= tlist->NumObjects(); i++) { - Entity *ent; - - ent = (Entity *)tlist->ObjectAt(i).Pointer(); - assert(ent); - - if (ent->isSubclassOf(Item)) { + for (i = var.arraysize(); i > 0; i--) { + const ScriptVariable *variable = var[i]; + ent = variable->simpleEntityValue(); + if (ent && ent->IsSubclassOfItem()) { Item *item; item = (Item *)ent; @@ -1212,13 +1222,13 @@ Item *Sentient::giveItem(str itemname, int amount) AddItem(item); - if (item->isSubclassOf(Weapon)) { + if (item->IsSubclassOfWeapon()) { // Post an event to give the ammo to the sentient Event *ev1; ev1 = new Event(EV_Weapon_GiveStartingAmmo); ev1->AddEntity(this); - item->PostEvent(ev1, 0); + item->PostEvent(ev1, level.frametime); } return item; @@ -1353,24 +1363,22 @@ void Sentient::ArmorDamage(Event *ev) { Entity *inflictor; Sentient *attacker; - float damage; - Vector momentum; - Vector position; - Vector normal; - Vector direction; - Event *event; - int dflags; - int meansofdeath; - int knockback; - int location; + float damage; + Vector momentum; + Vector position; + Vector normal; + Vector direction; + Event event; + int dflags; + int meansofdeath; + int knockback; + int location; - /* - qboolean blocked; + //qboolean blocked; float damage_red; float damage_green; float damage_time; - qboolean set_means_of_death; -*/ + //qboolean set_means_of_death; static bool tmp = false; static cvar_t *AIDamageMult = NULL; @@ -1395,7 +1403,7 @@ void Sentient::ArmorDamage(Event *ev) meansofdeath = ev->GetInteger(9); location = CheckHitLocation(ev->GetInteger(10)); - if (location == -2) { + if (location == HITLOC_MISS) { return; } @@ -1403,12 +1411,10 @@ void Sentient::ArmorDamage(Event *ev) return; } - if ((client && !g_gametype->integer) || (location < 0 || location > 18)) { - if (attacker && attacker->IsSubclassOfActor()) { - damage *= AIDamageMult->value; - } - } else { + if ((!isClient() || g_gametype->integer != GT_SINGLE_PLAYER) && (location > HITLOC_GENERAL && location < NUMBODYLOCATIONS)) { damage *= m_fDamageMultipliers[location]; + } else if (isClient() && attacker && attacker->IsSubclassOfActor() && g_gametype->integer == GT_SINGLE_PLAYER) { + damage *= AIDamageMult->value; } // See if sentient is immune to this type of damage @@ -1470,34 +1476,6 @@ void Sentient::ArmorDamage(Event *ev) } */ - /* -if( meansofdeath == MOD_SLIME ) -{ - damage_green = damage / 50; - if( damage_green > 1.0f ) - damage_green = 1.0f; - if( ( damage_green < 0.2 ) && ( damage_green > 0 ) ) - damage_green = 0.2f; - damage_red = 0; -} -else -{ - damage_red = damage / 50; - if( damage_red > 1.0f ) - damage_red = 1.0f; - if( ( damage_red < 0.2 ) && ( damage_red > 0 ) ) - damage_red = 0.2f; - damage_green = 0; -} - -damage_time = damage / 50; - -if( damage_time > 2 ) - damage_time = 2; - -SetOffsetColor( damage_red, damage_green, 0, damage_time ); -*/ - // Do the kick if (!(dflags & DAMAGE_NO_KNOCKBACK)) { if ((knockback) && (movetype != MOVETYPE_NONE) && (movetype != MOVETYPE_STATIONARY) @@ -1505,14 +1483,14 @@ SetOffsetColor( damage_red, damage_green, 0, damage_time ); float m; Event *immunity_event; - if (mass < 50) { - m = 50; + if (mass < 20) { + m = 20; } else { m = mass; } direction.normalize(); - if (isClient() && (attacker == this) && g_gametype->integer) { + if (isClient() && (attacker == this) && deathmatch->integer) { momentum = direction * (1700.0f * (float)knockback / m); // the rocket jump hack... } else { momentum = direction * (500.0f * (float)knockback / m); @@ -1541,8 +1519,8 @@ SetOffsetColor( damage_red, damage_green, 0, damage_time ); } if (!(flags & FL_GODMODE) - && ((g_gametype->integer) || !(attacker) || (attacker) == this || !(attacker->IsSubclassOfPlayer()) - || !(attacker->IsTeamMate(this)))) { + && ((g_gametype->integer != GT_SINGLE_PLAYER) || !(attacker) || (attacker) == this || !(attacker->IsSubclassOfSentient()) + || (attacker->m_Team != m_Team))) { health -= damage; } @@ -1572,44 +1550,88 @@ SetOffsetColor( damage_red, damage_green, 0, damage_time ); } } - if (health > 0) { - // Send pain event - event = new Event(EV_Pain, 10); - event->AddEntity(attacker); - event->AddFloat(damage); - event->AddEntity(inflictor); - event->AddVector(position); - event->AddVector(direction); - event->AddVector(normal); - event->AddInteger(knockback); - event->AddInteger(dflags); - event->AddInteger(meansofdeath); - event->AddInteger(location); - - ProcessEvent(event); + if (meansofdeath == MOD_SLIME) + { + damage_green = damage / 50; + if (damage_green > 1.0f) + damage_green = 1.0f; + if ((damage_green < 0.2) && (damage_green > 0)) + damage_green = 0.2f; + damage_red = 0; } + else + { + damage_red = damage / 50; + if (damage_red > 1.0f) + damage_red = 1.0f; + if ((damage_red < 0.2) && (damage_red > 0)) + damage_red = 0.2f; + damage_green = 0; + } + + damage_time = damage / 50; + + if (damage_time > 2) + damage_time = 2; + + //SetOffsetColor(damage_red, damage_green, 0, damage_time); if (health < 0.1) { // Make sure health is now 0 health = 0; - event = new Event(EV_Killed, 10); - event->AddEntity(attacker); - event->AddFloat(damage); - event->AddEntity(inflictor); - event->AddVector(position); - event->AddVector(direction); - event->AddVector(normal); - event->AddInteger(knockback); - event->AddInteger(dflags); - event->AddInteger(meansofdeath); - event->AddInteger(location); + if (attacker) { + const EntityPtr attackerPtr = attacker; + + // Added in OPM + event = Event(EV_GotKill); + event.AddEntity(this); + event.AddInteger(damage); + event.AddEntity(inflictor); + event.AddInteger(meansofdeath); + event.AddInteger(0); + + attackerPtr->ProcessEvent(event); + if (attackerPtr) { + attackerPtr->delegate_gotKill.Execute(event); + } + } + + event = Event(EV_Killed, 10); + event.AddEntity(attacker); + event.AddFloat(damage); + event.AddEntity(inflictor); + event.AddVector(position); + event.AddVector(direction); + event.AddVector(normal); + event.AddInteger(knockback); + event.AddInteger(dflags); + event.AddInteger(meansofdeath); + event.AddInteger(location); + + ProcessEvent(event); + delegate_killed.Execute(event); + } + + if (health > 0) { + // Send pain event + event = Event(EV_Pain, 10); + event.AddEntity(attacker); + event.AddFloat(damage); + event.AddEntity(inflictor); + event.AddVector(position); + event.AddVector(direction); + event.AddVector(normal); + event.AddInteger(knockback); + event.AddInteger(dflags); + event.AddInteger(meansofdeath); + event.AddInteger(location); ProcessEvent(event); } - return; + delegate_damage.Execute(*ev); } qboolean Sentient::CanBlock(int meansofdeath, qboolean full_block) @@ -1962,17 +1984,49 @@ void Sentient::DropInventoryItems(void) int i; Item *item; + if (m_bForceDropHealth) { + giveItem("ITEMS/item_25_healthbox.tik", 25); + } else if (skill->integer != 2 && !level.mbNoDropHealth) { + static cvar_t *ai_health_kar = gi.Cvar_Get("ai_health_kar", "6", CVAR_CHEAT); + static cvar_t *ai_health_mp40 = gi.Cvar_Get("ai_health_mp40points", "2", CVAR_CHEAT); + + Weapon *weapon = GetActiveWeapon(WEAPON_MAIN); + if (weapon) { + if (!Q_stricmp("rifle", Director.GetString(weapon->GetWeaponGroup()))) { + level.mHealthPopCount++; + } else { + level.mHealthPopCount += ai_health_mp40->integer; + } + + if (level.mHealthPopCount >= ai_health_kar->integer) { + giveItem("ITEMS/item_25_healthbox.tik", 25); + level.mHealthPopCount -= ai_health_kar->integer; + } + } + } + // Drop any inventory items num = inventory.NumObjects(); for (i = num; i >= 1; i--) { item = (Item *)G_GetEntity(inventory.ObjectAt(i)); - if (item->isSubclassOf(InventoryItem)) { - if (m_bDontDropWeapons && item->IsSubclassOfWeapon()) { - item->Delete(); - } else { - item->Drop(); - } + // Added in 2.30 + // Force drop the item when specified + if (m_bForceDropWeapon && item->IsSubclassOfWeapon()) { + item->Drop(); + continue; } + + if (!m_bDontDropWeapons && !level.mbNoDropWeapons) { + item->Drop(); + continue; + } + + if (!item->IsSubclassOfWeapon()) { + item->Drop(); + continue; + } + + item->Delete(); } } @@ -2152,11 +2206,27 @@ static bool IsItemName(const char *name) void Sentient::ArchivePersistantData(Archiver& arc) { - int i; - int num; + int i; + int num; + str name; + int amount; + Item *item; + Entity *ent; // archive the inventory if (arc.Saving()) { + // remove all special items before persistence + for (i = inventory.NumObjects(); i > 0; i--) { + int index; + + index = inventory.ObjectAt(i); + ent = G_GetEntity(index); + name = ent->model; + + if (IsItemName(name)) { + ent->Delete(); + } + } // count up the total number num = inventory.NumObjects(); } else { @@ -2166,10 +2236,6 @@ void Sentient::ArchivePersistantData(Archiver& arc) arc.ArchiveInteger(&num); // archive each item for (i = 1; i <= num; i++) { - str name; - int amount; - Item *item; - if (arc.Saving()) { Entity *ent; @@ -2182,11 +2248,26 @@ void Sentient::ArchivePersistantData(Archiver& arc) error("ArchivePersistantData", "Non Item in inventory\n"); } } + arc.ArchiveString(&name); arc.ArchiveInteger(&amount); + if (arc.Loading()) { item = giveItem(name, amount); + } + + if (item && item->IsSubclassOfWeapon()) { + Weapon *pWeap = static_cast(item); + item->CancelEventsOfType(EV_Weapon_GiveStartingAmmo); + if (arc.Saving()) { + amount = pWeap->ClipAmmo(FIRE_PRIMARY); + } + arc.ArchiveInteger(&amount); + + if (arc.Loading()) { + pWeap->SetAmmoAmount(amount, FIRE_PRIMARY); + } } } @@ -2212,16 +2293,17 @@ void Sentient::ArchivePersistantData(Archiver& arc) amount = ptr->getAmount(); maxamount = ptr->getMaxAmount(); } + arc.ArchiveString(&name); arc.ArchiveInteger(&amount); arc.ArchiveInteger(&maxamount); + if (arc.Loading()) { GiveAmmo(name, amount, maxamount); } } for (i = 0; i < MAX_ACTIVE_WEAPONS; i++) { - str name; if (arc.Saving()) { if (activeWeaponList[i]) { name = activeWeaponList[i]->getName(); @@ -2229,18 +2311,25 @@ void Sentient::ArchivePersistantData(Archiver& arc) name = "none"; } } + arc.ArchiveString(&name); - if (arc.Loading()) { - if (name != "none") { - Weapon *weapon; - weapon = (Weapon *)FindItem(name); - if (weapon) { - ChangeWeapon(weapon, (weaponhand_t)i); - } + + if (arc.Loading() && name != "none") { + Weapon *weapon; + + weapon = (Weapon *)FindItem(name); + if (weapon) { + ChangeWeapon(weapon, (weaponhand_t)i); } } } + if (GetActiveWeapon(WEAPON_MAIN)) { + edict->s.eFlags &= ~EF_UNARMED; + } else { + edict->s.eFlags |= EF_UNARMED; + } + arc.ArchiveFloat(&health); arc.ArchiveFloat(&max_health); } @@ -2515,6 +2604,11 @@ void Sentient::EventGerman(Event *ev) if (bRejoinSquads) { JoinNearbySquads(1024.0f); } + + // Added in 2.0 + // Tell clients about sentient team + edict->s.eFlags &= ~EF_ALLIES; + edict->s.eFlags |= EF_AXIS; } void Sentient::EventAmerican(Event *ev) @@ -2532,7 +2626,6 @@ void Sentient::EventAmerican(Event *ev) DisbandSquadMate(this); } - Unlink(); m_Team = TEAM_AMERICAN; Link(); @@ -2546,6 +2639,11 @@ void Sentient::EventAmerican(Event *ev) pActor->m_csMood = STRING_NERVOUS; pActor->m_csIdleMood = STRING_NERVOUS; } + + // Added in 2.0 + // Tell clients about sentient team + edict->s.eFlags &= ~EF_AXIS; + edict->s.eFlags |= EF_ALLIES; } void Sentient::EventGetTeam(Event *ev) @@ -2721,7 +2819,10 @@ void Sentient::RemovedItem(Item *item) {} void Sentient::AssertValidSquad() { - for (Sentient *pSquadMate = this; pSquadMate != this; pSquadMate = pSquadMate->m_pNextSquadMate) {} + for (Sentient *pSquadMate = this; pSquadMate != this; pSquadMate = pSquadMate->m_pNextSquadMate) { + assert(pSquadMate->m_pNextSquadMate); + assert(pSquadMate->m_pPrevSquadMate); + } } bool Sentient::IsTeamMate(Sentient *pOther) @@ -2845,7 +2946,7 @@ void Sentient::UpdateFootsteps(void) iTagNum = gi.Tag_NumForName(edict->tiki, "Bip01 R Foot"); if (iTagNum >= 0) { if (G_TIKI_IsOnGround(edict, iTagNum, 13.461539f)) { - BroadcastAIEvent(10, G_AIEventRadius(10)); + BroadcastAIEvent(AI_EVENT_FOOTSTEP, G_AIEventRadius(AI_EVENT_FOOTSTEP)); // simulate footstep sounds Footstep("Bip01 L Foot", (iAnimFlags & TAF_AUTOSTEPS_RUNNING), (iAnimFlags & TAF_AUTOSTEPS_EQUIPMENT)); m_bFootOnGround_Right = true; @@ -2866,7 +2967,7 @@ void Sentient::UpdateFootsteps(void) iTagNum = gi.Tag_NumForName(edict->tiki, "Bip01 L Foot"); if (iTagNum >= 0) { if (G_TIKI_IsOnGround(edict, iTagNum, 13.461539f)) { - BroadcastAIEvent(10, G_AIEventRadius(10)); + BroadcastAIEvent(AI_EVENT_FOOTSTEP, G_AIEventRadius(AI_EVENT_FOOTSTEP)); // simulate footstep sounds Footstep("Bip01 R Foot", (iAnimFlags & TAF_AUTOSTEPS_RUNNING), (iAnimFlags & TAF_AUTOSTEPS_EQUIPMENT)); m_bFootOnGround_Left = true; @@ -2945,42 +3046,47 @@ void Sentient::SetMinViewVariation(const Vector& vVariation) m_vViewVariation.z = Q_min(m_vViewVariation.z, vVariation.z); } -void Sentient::SetHolsteredByCode(bool holstered) { +void Sentient::SetHolsteredByCode(bool holstered) +{ weapons_holstered_by_code = holstered; } -Vehicle* Sentient::GetVehicle() const +Vehicle *Sentient::GetVehicle() const { return m_pVehicle; } -void Sentient::SetVehicle(Vehicle* pVehicle) +void Sentient::SetVehicle(Vehicle *pVehicle) { m_pVehicle = NULL; } -TurretGun* Sentient::GetTurret() const +TurretGun *Sentient::GetTurret() const { return m_pTurret; } -void Sentient::SetTurret(TurretGun* pTurret) +void Sentient::SetTurret(TurretGun *pTurret) { m_pTurret = pTurret; } +Entity* Sentient::GetLadder() const { + return m_pLadder; +} + #define GROUND_DISTANCE 8 #define WATER_NO_SPLASH_HEIGHT 16 -void Sentient::EventClientLanding(Event* ev) +void Sentient::EventClientLanding(Event *ev) { - float fVolume = ev->NumArgs() >= 1 ? ev->GetFloat(1) : 1; - int iEquipment = ev->NumArgs() >= 2 ? ev->GetInteger(2) : 1; + float fVolume = ev->NumArgs() >= 1 ? ev->GetFloat(1) : 1; + int iEquipment = ev->NumArgs() >= 2 ? ev->GetInteger(2) : 1; LandingSound(fVolume, iEquipment); } -void Sentient::FootstepMain(trace_t* trace, int iRunning, int iEquipment) +void Sentient::FootstepMain(trace_t *trace, int iRunning, int iEquipment) { int contents; int surftype; @@ -3000,12 +3106,10 @@ void Sentient::FootstepMain(trace_t* trace, int iRunning, int iEquipment) contents = gi.pointcontents(midlegs, -1); if (contents & MASK_WATER) { sSoundName += "wade"; - } - else { + } else { sSoundName += "puddle"; } - } - else { + } else { surftype = trace->surfaceFlags & MASK_SURF_TYPE; switch (surftype) { case SURF_FOLIAGE: @@ -3065,8 +3169,7 @@ void Sentient::FootstepMain(trace_t* trace, int iRunning, int iEquipment) } else { fVolume = 1.0; } - } - else { + } else { fVolume = 0.25; } @@ -3082,7 +3185,7 @@ void Sentient::FootstepMain(trace_t* trace, int iRunning, int iEquipment) } } -void Sentient::Footstep(const char* szTagName, int iRunning, int iEquipment) +void Sentient::Footstep(const char *szTagName, int iRunning, int iEquipment) { int i; int iTagNum; @@ -3115,8 +3218,7 @@ void Sentient::Footstep(const char* szTagName, int iRunning, int iEquipment) VectorSet(vMins, -2, -2, -8); VectorSet(vMaxs, 2, 2, 8); - } - else { + } else { VectorSet(vMins, -4, -4, 0); VectorSet(vMaxs, 4, 4, 2); @@ -3127,28 +3229,9 @@ void Sentient::Footstep(const char* szTagName, int iRunning, int iEquipment) } if (IsSubclassOfPlayer()) { - trace = G_Trace( - vStart, - vMins, - vMaxs, - vEnd, - edict, - MASK_PLAYERSOLID, - qtrue, - "Player Footsteps" - ); - } - else { - trace = G_Trace( - vStart, - vMins, - vMaxs, - vEnd, - edict, - MASK_MONSTERSOLID, - qfalse, - "Monster Footsteps" - ); + trace = G_Trace(vStart, vMins, vMaxs, vEnd, edict, MASK_PLAYERSOLID, qtrue, "Player Footsteps"); + } else { + trace = G_Trace(vStart, vMins, vMaxs, vEnd, edict, MASK_MONSTERSOLID, qfalse, "Monster Footsteps"); } if (trace.fraction == 1.0f) { @@ -3160,14 +3243,14 @@ void Sentient::Footstep(const char* szTagName, int iRunning, int iEquipment) void Sentient::LandingSound(float volume, int iEquipment) { - int contents; - int surftype; - vec3_t vStart, vEnd; - vec3_t midlegs; - str sSoundName; - trace_t trace; - static vec3_t g_vFootstepMins = { -4, -4, 0 }; - static vec3_t g_vFootstepMaxs = { 4, 4, 2 }; + int contents; + int surftype; + vec3_t vStart, vEnd; + vec3_t midlegs; + str sSoundName; + trace_t trace; + static vec3_t g_vFootstepMins = {-4, -4, 0}; + static vec3_t g_vFootstepMaxs = {4, 4, 2}; if (this->iNextLandTime > level.inttime) { this->iNextLandTime = level.inttime + 200; @@ -3182,26 +3265,11 @@ void Sentient::LandingSound(float volume, int iEquipment) vEnd[2] -= 64.0; if (IsSubclassOfPlayer()) { - trace = G_Trace( - vStart, - g_vFootstepMins, - g_vFootstepMaxs, - vEnd, - edict, - MASK_PLAYERSOLID, - qtrue, - "Player Footsteps" - ); + trace = + G_Trace(vStart, g_vFootstepMins, g_vFootstepMaxs, vEnd, edict, MASK_PLAYERSOLID, qtrue, "Player Footsteps"); } else { trace = G_Trace( - vStart, - g_vFootstepMins, - g_vFootstepMaxs, - vEnd, - edict, - MASK_MONSTERSOLID, - qfalse, - "Monster Footsteps" + vStart, g_vFootstepMins, g_vFootstepMaxs, vEnd, edict, MASK_MONSTERSOLID, qfalse, "Monster Footsteps" ); } diff --git a/code/fgame/sentient.h b/code/fgame/sentient.h index 184629e9..c148db26 100644 --- a/code/fgame/sentient.h +++ b/code/fgame/sentient.h @@ -321,6 +321,7 @@ public: Weapon *GetNewActiveWeapon(void); weaponhand_t GetNewActiveWeaponHand(void); void ClearNewActiveWeapon(void); + void SetNewActiveWeapon(Weapon* weapon, weaponhand_t hand); void Holster(qboolean putaway); void SafeHolster(qboolean putaway); void ActivateNewWeapon(void); @@ -349,16 +350,23 @@ public: TurretGun* GetTurret() const; void SetTurret(TurretGun* pTurret); + Entity* GetLadder() const; // Added in OPM + // // Custom openmohaa stuff // void GetActiveWeap(Event *ev); + void GetNewActiveWeaponOld(Event *ev); void GetNewActiveWeapon(Event *ev); + void GetNewActiveWeaponHand(Event *ev); void EventClientLanding(Event *ev); void FootstepMain(trace_t *trace, int iRunning, int iEquipment); void Footstep(const char *szTagName, int iRunning, int iEquipment); void LandingSound(float volume, int iEquipment); + + const Container& getInventory() const; + const Container& getAmmoInventory() const; }; typedef SafePtr SentientPtr; diff --git a/code/fgame/sentient_combat.cpp b/code/fgame/sentient_combat.cpp index 6ebe3279..e095d49d 100644 --- a/code/fgame/sentient_combat.cpp +++ b/code/fgame/sentient_combat.cpp @@ -33,7 +33,7 @@ ActiveWeapon::ActiveWeapon() void ActiveWeapon::Archive(Archiver& arc) { - arc.ArchiveObjectPointer((Class **)&weapon); + arc.ArchiveSafePointer(&weapon); ArchiveEnum(hand, weaponhand_t); } @@ -54,8 +54,13 @@ Weapon *Sentient::GetNewActiveWeapon(void) void Sentient::ClearNewActiveWeapon(void) { - newActiveWeapon.weapon.Clear(); - newActiveWeapon.hand = WEAPON_ERROR; + SetNewActiveWeapon(NULL, WEAPON_ERROR); +} + +void Sentient::SetNewActiveWeapon(Weapon* weapon, weaponhand_t hand) +{ + newActiveWeapon.weapon = weapon; + newActiveWeapon.hand = hand; } void Sentient::EventGiveAmmo(Event *ev) @@ -74,7 +79,6 @@ void Sentient::EventGiveAmmo(Event *ev) } int Sentient::AmmoIndex(str type) - { Ammo *ammo; @@ -146,7 +150,6 @@ void Sentient::GiveAmmo(str type, int amount, int maxamount) } int Sentient::UseAmmo(str type, int amount) - { int count, i; @@ -154,7 +157,7 @@ int Sentient::UseAmmo(str type, int amount) for (i = 1; i <= count; i++) { Ammo *ammo = ammo_inventory.ObjectAt(i); - if (type == ammo->getName()) { + if (!str::icmp(type, ammo->getName())) { int ammo_amount = ammo->getAmount(); // Less ammo than what we specified to use @@ -180,7 +183,9 @@ void Sentient::AmmoAmountInClipChanged(str type, int amount_in_clip) for (i = 1; i <= count; i++) { Ammo *ammo = ammo_inventory.ObjectAt(i); - if (type == ammo->getName()) { + // Fixed in OPM + // Original uses strcmp + if (!str::icmp(type, ammo->getName())) { AmmoAmountChanged(ammo, amount_in_clip); } } @@ -446,7 +451,7 @@ void Sentient::FireWeapon(int number, firemode_t mode) { Weapon *activeWeapon = activeWeaponList[number]; - if (activeWeapon) { + if (activeWeapon && activeWeapon->ReadyToFire(mode)) { if (mode == FIRE_SECONDARY && activeWeapon->GetZoom() && !activeWeapon->GetAutoZoom() && IsSubclassOfPlayer()) { Player *p = (Player *)this; p->ToggleZoom(activeWeapon->GetZoom()); @@ -863,15 +868,32 @@ Weapon *Sentient::BestWeapon(Weapon *ignore, qboolean bGetItem, int iIgnoreClass next = (Weapon *)G_GetEntity(inventory.ObjectAt(j)); assert(next); - - if ((next != ignore) - && ((next->IsSubclassOfWeapon() && !(next->GetWeaponClass() & iIgnoreClass)) - || (next->IsSubclassOfItem() && bGetItem)) - && (next->GetRank() > bestrank) - && (next->HasAmmo(FIRE_PRIMARY) || next->GetFireType(FIRE_SECONDARY) == FT_MELEE)) { - bestweapon = (Weapon *)next; - bestrank = bestweapon->GetRank(); + if (next == ignore) { + continue; } + + if (!next->IsSubclassOfWeapon() && (!bGetItem || !next->IsSubclassOfInventoryItem())) { + continue; + } + + if (!bGetItem && next->IsSubclassOfInventoryItem()) { + continue; + } + + if (next->GetWeaponClass() & iIgnoreClass) { + continue; + } + + if (next->GetRank() < bestrank) { + continue; + } + + if (!next->HasAmmo(FIRE_PRIMARY) && !next->GetUseNoAmmo()) { + continue; + } + + bestweapon = (Weapon*)next; + bestrank = bestweapon->GetRank(); } return bestweapon; @@ -895,14 +917,32 @@ Weapon *Sentient::WorstWeapon(Weapon *ignore, qboolean bGetItem, int iIgnoreClas assert(next); - if ((next != ignore) - && ((next->IsSubclassOfWeapon() && !(next->GetWeaponClass() & iIgnoreClass)) - || (next->IsSubclassOfWeapon() && bGetItem)) - && (next->GetRank() < iWorstRank) - && (next->HasAmmo(FIRE_PRIMARY) || next->GetFireType(FIRE_SECONDARY) == FT_MELEE)) { - worstweapon = (Weapon *)next; - iWorstRank = worstweapon->GetRank(); + if (next == ignore) { + continue; } + + if (!next->IsSubclassOfWeapon()) { + continue; + } + + if (!bGetItem && next->IsSubclassOfInventoryItem()) { + continue; + } + + if (next->GetWeaponClass() & iIgnoreClass) { + continue; + } + + if (next->GetRank() >= iWorstRank) { + continue; + } + + if (!next->HasAmmo(FIRE_PRIMARY) && !next->GetUseNoAmmo()) { + continue; + } + + worstweapon = (Weapon*)next; + iWorstRank = worstweapon->GetRank(); } return worstweapon; @@ -1035,7 +1075,6 @@ Weapon *Sentient::GetActiveWeapon(weaponhand_t hand) const } qboolean Sentient::IsActiveWeapon(Weapon *weapon) - { int i; @@ -1063,6 +1102,9 @@ void Sentient::useWeapon(const char *weaponname, weaponhand_t hand) // Find the item in the sentient's inventory weapon = (Weapon *)FindItem(weaponname); + if (!weapon) { + weapon = (Weapon *)FindItemByExternalName(weaponname); + } // If it exists, then make the change to the slot number specified if (weapon) { @@ -1080,8 +1122,7 @@ void Sentient::useWeapon(Weapon *weapon, weaponhand_t hand) } if (newActiveWeapon.weapon) { - newActiveWeapon.weapon = weapon; - newActiveWeapon.hand = hand; + SetNewActiveWeapon(weapon, hand); return; } @@ -1093,14 +1134,15 @@ void Sentient::useWeapon(Weapon *weapon, weaponhand_t hand) activeWeaponList[WEAPON_OFFHAND]->PutAway(); } - if (activeWeaponList[WEAPON_MAIN] && activeWeaponList[WEAPON_MAIN] != weapon) { + if (activeWeaponList[WEAPON_MAIN] == weapon) { + return; + } + + if (activeWeaponList[WEAPON_MAIN]) { activeWeaponList[WEAPON_MAIN]->PutAway(); } - newActiveWeapon.weapon = weapon; - newActiveWeapon.hand = hand; - - //ChangeWeapon( weapon, hand ); + SetNewActiveWeapon(weapon, hand); } void Sentient::EventUseWeaponClass(Event *ev) @@ -1246,18 +1288,30 @@ Ammo *Sentient::FindAmmoByName(str name) for (i = 1; i <= count; i++) { Ammo *ammo = ammo_inventory.ObjectAt(i); - if (name == ammo->getName()) { + if (!str::icmp(name, ammo->getName())) { return ammo; } } return NULL; } -void Sentient::GetNewActiveWeapon(Event *ev) +void Sentient::GetNewActiveWeaponOld(Event *ev) +{ + ScriptDeprecatedAltVariable("newActiveWeapon"); + + ev->AddEntity(GetNewActiveWeapon()); +} + +void Sentient::GetNewActiveWeapon(Event* ev) { ev->AddEntity(GetNewActiveWeapon()); } +void Sentient::GetNewActiveWeaponHand(Event* ev) +{ + ev->AddInteger(GetNewActiveWeaponHand()); +} + void Sentient::GetActiveWeap(Event *ev) { weaponhand_t weaponhand; @@ -1274,3 +1328,11 @@ void Sentient::GetActiveWeap(Event *ev) ev->AddEntity(weapon); } + +const Container& Sentient::getInventory() const { + return inventory; +} + +const Container& Sentient::getAmmoInventory() const { + return ammo_inventory; +} diff --git a/code/fgame/simpleactor.cpp b/code/fgame/simpleactor.cpp index 7c4aecf6..d4d407db 100644 --- a/code/fgame/simpleactor.cpp +++ b/code/fgame/simpleactor.cpp @@ -85,7 +85,7 @@ SimpleActor::SimpleActor() m_csNextAnimString = STRING_NULL; for (int i = 0; i < MAX_FRAMEINFOS; i++) { - m_weightType[i] = 0.0f; + m_weightType[i] = ANIM_WEIGHT_NONE; } m_ChangeActionAnimIndex = -1; @@ -187,30 +187,42 @@ void SimpleActor::SetPath( m_Path.FindPath(origin, vDestPos, this, 0.0, vLeashHome, fLeashDistSquared); if (!PathExists()) { - if (g_patherror->integer && description - && (g_patherror->integer - || g_patherror->integer == 2 - && (static_cast(this)->m_ThinkState == THINKSTATE_IDLE - || static_cast(this)->m_ThinkState == THINKSTATE_CURIOUS) - && m_bPathErrorTime + 5000 < level.inttime)) { - m_bPathErrorTime = level.inttime; - - Com_Printf( - "^~^~^ Path not found in '%s' for (entnum %d, radnum %d, targetname '%s') from (%f %f " - "%f) to (%f %f %f)\n", - description, - entnum, - radnum, - targetname.c_str(), - origin.x, - origin.y, - origin.z, - vDestPos.x, - vDestPos.y, - vDestPos.z - ); - Com_Printf("Reason: %s\n", PathSearch::last_error); + if (!g_patherror->integer || !description) { + return; } + + if (g_patherror->integer != 1 && g_patherror->integer != 2) { + return; + } + + if (g_patherror->integer == 2) { + int thinkState = static_cast(this)->m_ThinkState; + if (thinkState != THINKSTATE_IDLE && thinkState != THINKSTATE_CURIOUS) { + return; + } + } + + if (m_bPathErrorTime + 5000 >= level.inttime) { + return; + } + + m_bPathErrorTime = level.inttime; + + Com_Printf( + "^~^~^ Path not found in '%s' for (entnum %d, radnum %d, targetname '%s') from (%f %f " + "%f) to (%f %f %f)\n", + description, + entnum, + radnum, + targetname.c_str(), + origin.x, + origin.y, + origin.z, + vDestPos.x, + vDestPos.y, + vDestPos.z + ); + Com_Printf("Reason: %s\n", PathSearch::last_error); } } @@ -653,7 +665,7 @@ void SimpleActor::StopAnimating(int slot) { int index = 0; - m_weightType[slot] = 0; + m_weightType[slot] = ANIM_WEIGHT_NONE; DoExitCommands(slot); if (edict->s.frameInfo[slot].index || gi.TIKI_NumAnims(edict->tiki) <= 1) { @@ -802,7 +814,6 @@ void SimpleActor::StartAimAnimSlot(int slot, int anim) m_weightType[slot] = ANIM_WEIGHT_AIM; m_weightCrossBlend[slot] = 0.0; - m_weightBase[slot] = 1.0; NewAnim(anim, slot, 1.0); RestartAnimSlot(slot); @@ -853,9 +864,9 @@ void SimpleActor::UpdateCrossBlendAnimSlot(int slot) void SimpleActor::UpdateCrossBlendDialogAnimSlot(int slot) { if (m_iSaySlot >= 0) { - m_weightCrossBlend[m_iSaySlot] -= level.frametime / 0.1f; + m_weightCrossBlend[slot] -= level.frametime / 0.1f; } else { - m_weightCrossBlend[m_iSaySlot] -= level.frametime / 0.5f; + m_weightCrossBlend[slot] -= level.frametime / 0.5f; } if (m_weightCrossBlend[slot] > 0.0) { @@ -869,9 +880,9 @@ void SimpleActor::UpdateCrossBlendDialogAnimSlot(int slot) void SimpleActor::UpdateSayAnimSlot(int slot) { if (m_iSaySlot >= 0) { - m_weightCrossBlend[m_iSaySlot] += level.frametime / 0.1f; + m_weightCrossBlend[slot] += level.frametime / 0.1f; } else { - m_weightCrossBlend[m_iSaySlot] += level.frametime / 0.5f; + m_weightCrossBlend[slot] += level.frametime / 0.5f; } SetBlendedWeight(slot); @@ -1066,7 +1077,7 @@ int SimpleActor::GetEmotionAnim(void) default: char assertStr[16317] = {0}; - strcpy(assertStr, "\"Unknown value for m_EmotionMode in SimpleActor::GetEmotionAnim\"\n\tMessage: "); + Q_strncpyz(assertStr, "\"Unknown value for m_EmotionMode in SimpleActor::GetEmotionAnim\"\n\tMessage: ", sizeof(assertStr)); Q_strcat(assertStr, sizeof(assertStr), DumpCallTrace("")); assert(!assertStr); return -1; @@ -1089,7 +1100,7 @@ int SimpleActor::GetEmotionAnim(void) default: char assertStr[16317] = {0}; - strcpy(assertStr, "\"Unknown value for m_csMood in SimpleActor::GetEmotionAnim\"\n\tMessage: "); + Q_strncpyz(assertStr, "\"Unknown value for m_csMood in SimpleActor::GetEmotionAnim\"\n\tMessage: ", sizeof(assertStr)); Q_strcat(assertStr, sizeof(assertStr), DumpCallTrace("")); assert(!assertStr); return -1; diff --git a/code/fgame/simpleactor.h b/code/fgame/simpleactor.h index 873a8885..4aea2112 100644 --- a/code/fgame/simpleactor.h +++ b/code/fgame/simpleactor.h @@ -469,7 +469,7 @@ inline void SimpleActor::SetDesiredYawDest(const vec3_t vec) vec2_t facedir; VectorSub2D(vec, origin, facedir); - if (!facedir[0] || !facedir[1]) { + if (facedir[0] || facedir[1]) { SetDesiredYawDir(facedir); } } diff --git a/code/fgame/simpleentity.cpp b/code/fgame/simpleentity.cpp index a4120e92..6b582500 100644 --- a/code/fgame/simpleentity.cpp +++ b/code/fgame/simpleentity.cpp @@ -356,11 +356,6 @@ int SimpleEntity::IsSubclassOfCrateObject(void) const return (entflags & ECF_CRATEOBJECT); } -int SimpleEntity::IsSubclassOfBot(void) const -{ - return (entflags & ECF_BOT); -} - void SimpleEntity::SetTargetName(str targetname) { if (!world) { @@ -411,7 +406,7 @@ void SimpleEntity::GetCentroid(Event *ev) ev->AddVector(centroid); } -str& SimpleEntity::Target() +const str& SimpleEntity::Target() { return target; } @@ -491,7 +486,10 @@ void SimpleEntity::SetAngleEvent(Event *ev) void SimpleEntity::GetAngleEvent(Event *ev) { - ev->AddFloat(angles[1]); + Vector forward; + + angles.AngleVectorsLeft(&forward); + ev->AddFloat(G_GetAngle(forward)); } void SimpleEntity::setAngles(Vector angles) @@ -533,12 +531,18 @@ void SimpleEntity::GetUpVector(Event *ev) SimpleEntity *SimpleEntity::Next(void) { - SimpleEntity *ent = world->GetTarget(target, true); + Listener* ent; + + if (!target.length()) { + return NULL; + } + + ent = world->GetTarget(target, true); if (!ent || !ent->isSubclassOf(SimpleEntity)) { return NULL; } else { - return ent; + return static_cast(ent); } } diff --git a/code/fgame/simpleentity.h b/code/fgame/simpleentity.h index 235a4b6c..d9f2aa18 100644 --- a/code/fgame/simpleentity.h +++ b/code/fgame/simpleentity.h @@ -64,7 +64,7 @@ public: virtual void setOrigin(Vector origin); virtual void setOriginEvent(Vector origin); virtual void setAngles(Vector angles); - str & Target(); + const str & Target(); qboolean Targeted(void); str & TargetName(); virtual void SetTargetName(str targetname); @@ -91,7 +91,6 @@ public: int IsSubclassOfVehiclePoint(void) const; int IsSubclassOfSplinePath(void) const; int IsSubclassOfCrateObject(void) const; - int IsSubclassOfBot(void) const; void GetOrigin(Event *ev); void SetOrigin(Event *ev); diff --git a/code/fgame/smokegrenade.cpp b/code/fgame/smokegrenade.cpp index 93e39a1c..0ec353c8 100644 --- a/code/fgame/smokegrenade.cpp +++ b/code/fgame/smokegrenade.cpp @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -122,106 +122,107 @@ Event EV_SmokeGrenade_SetMaxAlpha "sets maximum opacity of an individual smoke particle, in 0-1 range" ); -CLASS_DECLARATION(EffectEntity, SmokeGrenade, "smokegrenade") -{ - { &EV_SmokeGrenade_SetSpawnRate, &SmokeGrenade::EventSetSpawnrate }, - { &EV_SmokeGrenade_SetBouncefactor, &SmokeGrenade::EventSetBouncefactor }, - { &EV_SmokeGrenade_SetLife, &SmokeGrenade::EventSetLife }, - { &EV_SmokeGrenade_SetSpawnLife, &SmokeGrenade::EventSetSpawnLife }, - { &EV_SmokeGrenade_SetScalerate, &SmokeGrenade::EventSetScalerate }, - { &EV_SmokeGrenade_SetVelocity, &SmokeGrenade::EventSetVelocity }, - { &EV_SmokeGrenade_SetSpin, &SmokeGrenade::EventSetSpin }, - { &EV_SmokeGrenade_SetOffset, &SmokeGrenade::EventSetOffset }, - { &EV_SmokeGrenade_SetScale, &SmokeGrenade::EventSetScale }, - { &EV_SmokeGrenade_SetFadein, &SmokeGrenade::EventSetFadein }, - { &EV_SmokeGrenade_SetFadedelay, &SmokeGrenade::EventSetFadedelay }, - { &EV_SmokeGrenade_SetMaxAlpha, &SmokeGrenade::EventSetMaxAlpha }, - { NULL, NULL } +CLASS_DECLARATION(EffectEntity, SmokeGrenade, "smokegrenade") { + {&EV_SmokeGrenade_SetSpawnRate, &SmokeGrenade::EventSetSpawnrate }, + {&EV_SmokeGrenade_SetBouncefactor, &SmokeGrenade::EventSetBouncefactor}, + {&EV_SmokeGrenade_SetLife, &SmokeGrenade::EventSetLife }, + {&EV_SmokeGrenade_SetSpawnLife, &SmokeGrenade::EventSetSpawnLife }, + {&EV_SmokeGrenade_SetScalerate, &SmokeGrenade::EventSetScalerate }, + {&EV_SmokeGrenade_SetVelocity, &SmokeGrenade::EventSetVelocity }, + {&EV_SmokeGrenade_SetSpin, &SmokeGrenade::EventSetSpin }, + {&EV_SmokeGrenade_SetOffset, &SmokeGrenade::EventSetOffset }, + {&EV_SmokeGrenade_SetScale, &SmokeGrenade::EventSetScale }, + {&EV_SmokeGrenade_SetFadein, &SmokeGrenade::EventSetFadein }, + {&EV_SmokeGrenade_SetFadedelay, &SmokeGrenade::EventSetFadedelay }, + {&EV_SmokeGrenade_SetMaxAlpha, &SmokeGrenade::EventSetMaxAlpha }, + {NULL, NULL } }; -void SmokeGrenade::EventSetSpawnrate(Event* ev) +void SmokeGrenade::EventSetSpawnrate(Event *ev) { float rate = ev->GetFloat(1); - if (rate < 0.001f) rate = 0.001f; + if (rate < 0.001f) { + rate = 0.001f; + } spawnRate = 1000.0f / rate; } -void SmokeGrenade::EventSetBouncefactor(Event* ev) +void SmokeGrenade::EventSetBouncefactor(Event *ev) { bounceFactor = ev->GetFloat(1); } -void SmokeGrenade::EventSetLife(Event* ev) +void SmokeGrenade::EventSetLife(Event *ev) { nextRemoveTime = level.time + ev->GetFloat(1); } -void SmokeGrenade::EventSetSpawnLife(Event* ev) +void SmokeGrenade::EventSetSpawnLife(Event *ev) { spawnLife = ev->GetFloat(1); } -void SmokeGrenade::EventSetScalerate(Event* ev) +void SmokeGrenade::EventSetScalerate(Event *ev) { scaleRate = ev->GetFloat(1); } -void SmokeGrenade::EventSetVelocity(Event* ev) +void SmokeGrenade::EventSetVelocity(Event *ev) { velocity[0] = ev->GetFloat(1); velocity[1] = ev->GetFloat(2); velocity[2] = ev->GetFloat(3); } -void SmokeGrenade::EventSetSpin(Event* ev) +void SmokeGrenade::EventSetSpin(Event *ev) { spinRate = ev->GetFloat(1); } -void SmokeGrenade::EventSetOffset(Event* ev) +void SmokeGrenade::EventSetOffset(Event *ev) { offset[0] = ev->GetFloat(1); offset[1] = ev->GetFloat(2); offset[2] = ev->GetFloat(3); } -void SmokeGrenade::EventSetScale(Event* ev) +void SmokeGrenade::EventSetScale(Event *ev) { scale = ev->GetFloat(1) * 0.5; } -void SmokeGrenade::EventSetFadein(Event* ev) +void SmokeGrenade::EventSetFadein(Event *ev) { fadeIn = ev->GetFloat(1); } -void SmokeGrenade::EventSetFadedelay(Event* ev) +void SmokeGrenade::EventSetFadedelay(Event *ev) { fadeDelay = ev->GetFloat(1); } -void SmokeGrenade::EventSetMaxAlpha(Event* ev) +void SmokeGrenade::EventSetMaxAlpha(Event *ev) { maxAlpha = ev->GetFloat(1); } SmokeGrenade::SmokeGrenade() { - flags |= FL_THINK; - nextRemoveTime = level.time + 1.0; - spawnRate = 1000; - bounceFactor = 0.0; - spawnLife = 1.0; - scaleRate = 1.0; - velocity = vec_zero; - offset = vec_zero; - spinRate = 0.0; - scale = 1.0; - fadeIn = 0.0; - fadeDelay = spawnLife; - maxAlpha = 1.0; - lastSpawnTime = level.inttime + 150; + flags |= FL_THINK; + nextRemoveTime = level.time + 1.0; + spawnRate = 1000; + bounceFactor = 0.0; + spawnLife = 1.0; + scaleRate = 1.0; + velocity = vec_zero; + offset = vec_zero; + spinRate = 0.0; + scale = 1.0; + fadeIn = 0.0; + fadeDelay = spawnLife; + maxAlpha = 1.0; + lastSpawnTime = level.inttime + 150; } void SmokeGrenade::Think() @@ -233,42 +234,57 @@ void SmokeGrenade::Think() if (level.inttime >= lastSpawnTime + spawnRate) { SmokeSprite sp; - float degrees; + float degrees; lastSpawnTime += spawnRate; - sp.origin = origin; + sp.origin = origin; sp.spawnTime = level.time; - sp.scale = scale; + sp.scale = scale; degrees = angles.y + (((level.inttime / 1000.0 - 176.0) * spinRate) * -0.36); - - RotatePointAroundAxis( - sp.velocity, - 2, - velocity, - degrees - ); - sp.spawnLife = spawnLife; + RotatePointAroundAxis(sp.velocity, 2, velocity, degrees); + + sp.spawnLife = spawnLife; sp.bounceFactor = bounceFactor; - sp.scaleStart = scale; - sp.scaleRate = scaleRate; - sp.fadeIn = fadeIn; - sp.fadeDelay = fadeDelay; - sp.maxAlpha = maxAlpha; - sp.owner = owner; + sp.scaleStart = scale; + sp.scaleRate = scaleRate; + sp.fadeIn = fadeIn; + sp.fadeDelay = fadeDelay; + sp.maxAlpha = maxAlpha; + sp.owner = owner; G_AddSmokeSprite(&sp); } } -void SmokeGrenade::setOwner(Sentient* other) +void SmokeGrenade::Archive(Archiver& arc) +{ + EffectEntity::Archive(arc); + + arc.ArchiveFloat(&nextRemoveTime); + arc.ArchiveInteger(&spawnRate); + arc.ArchiveFloat(&bounceFactor); + arc.ArchiveFloat(&spawnLife); + arc.ArchiveFloat(&scaleRate); + arc.ArchiveVector(&velocity); + arc.ArchiveFloat(&spinRate); + arc.ArchiveVector(&offset); + arc.ArchiveFloat(&scale); + arc.ArchiveFloat(&fadeIn); + arc.ArchiveFloat(&fadeDelay); + arc.ArchiveFloat(&maxAlpha); + arc.ArchiveInteger(&lastSpawnTime); + arc.ArchiveSafePointer(&owner); +} + +void SmokeGrenade::setOwner(Sentient *other) { owner = other; } -Sentient* SmokeGrenade::getOwner() const +Sentient *SmokeGrenade::getOwner() const { return owner; } diff --git a/code/fgame/smokegrenade.h b/code/fgame/smokegrenade.h index d77754d6..15b6f710 100644 --- a/code/fgame/smokegrenade.h +++ b/code/fgame/smokegrenade.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -26,43 +26,46 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA class Sentient; -class SmokeGrenade : public EffectEntity { +class SmokeGrenade : public EffectEntity +{ CLASS_PROTOTYPE(SmokeGrenade); public: SmokeGrenade(); - void EventSetSpawnrate(Event* ev); - void EventSetBouncefactor(Event* ev); - void EventSetLife(Event* ev); - void EventSetSpawnLife(Event* ev); - void EventSetScalerate(Event* ev); - void EventSetVelocity(Event* ev); - void EventSetSpin(Event* ev); - void EventSetOffset(Event* ev); - void EventSetScale(Event* ev); - void EventSetFadein(Event* ev); - void EventSetFadedelay(Event* ev); - void EventSetMaxAlpha(Event* ev); + void EventSetSpawnrate(Event *ev); + void EventSetBouncefactor(Event *ev); + void EventSetLife(Event *ev); + void EventSetSpawnLife(Event *ev); + void EventSetScalerate(Event *ev); + void EventSetVelocity(Event *ev); + void EventSetSpin(Event *ev); + void EventSetOffset(Event *ev); + void EventSetScale(Event *ev); + void EventSetFadein(Event *ev); + void EventSetFadedelay(Event *ev); + void EventSetMaxAlpha(Event *ev); void Think() override; - void setOwner(Sentient* other); - Sentient* getOwner() const; + void Archive(Archiver& arc) override; + + void setOwner(Sentient *other); + Sentient *getOwner() const; private: - float nextRemoveTime; - int spawnRate; - float bounceFactor; - float spawnLife; - float scaleRate; - Vector velocity; - float spinRate; - Vector offset; - float scale; - float fadeIn; - float fadeDelay; - float maxAlpha; - int lastSpawnTime; + float nextRemoveTime; + int spawnRate; + float bounceFactor; + float spawnLife; + float scaleRate; + Vector velocity; + float spinRate; + Vector offset; + float scale; + float fadeIn; + float fadeDelay; + float maxAlpha; + int lastSpawnTime; SafePtr owner; }; diff --git a/code/fgame/smokesprite.cpp b/code/fgame/smokesprite.cpp index 1fe6c5d0..f848a8cb 100644 --- a/code/fgame/smokesprite.cpp +++ b/code/fgame/smokesprite.cpp @@ -113,8 +113,56 @@ void G_AddSmokeSprite(const SmokeSprite* sprite) } float G_ObfuscationForSmokeSprites(float visibilityAlpha, const Vector& start, const Vector& end) { - // FIXME: unimplemented - return 0; + Vector vDelta = end - start; + float fLength = vDelta.length(); + Vector vDir = vDelta * (1.0 / fLength); + float fObfuscation = visibilityAlpha; + int i; + + for (i = 1; i <= g_Sprites.NumObjects(); i++) { + const SmokeSprite& sprite = g_Sprites.ObjectAt(i); + Vector vSpriteDelta = sprite.origin - start; + float fDot = vSpriteDelta * vDir; + float fTimeAlive; + + if (fDot < -sprite.scale || fDot > fLength + sprite.scale) { + continue; + } + + if (fDot <= 0) { + if (Square(sprite.scale) <= vSpriteDelta.lengthSquared()) { + continue; + } + } else if (fDot >= fLength) { + Vector vSpriteEndDelta = sprite.origin - end; + + if (Square(sprite.scale) <= vSpriteEndDelta.lengthSquared()) { + continue; + } + } else { + Vector vSpriteEndDelta = vSpriteDelta - (vDir * fDot); + + if (Square(sprite.scale) <= vSpriteEndDelta.lengthSquared()) { + continue; + } + } + + fTimeAlive = level.time - sprite.spawnTime; + if (fTimeAlive < sprite.fadeIn) { + fObfuscation += sprite.maxAlpha * fTimeAlive / sprite.fadeIn; + } else if (sprite.spawnTime + sprite.fadeDelay >= level.svsTime) { + fObfuscation += sprite.maxAlpha; + } else if (sprite.spawnLife - fTimeAlive > 0) { + fObfuscation = (sprite.spawnLife - fTimeAlive) * sprite.maxAlpha / (sprite.spawnLife - sprite.fadeDelay); + } + + if(fObfuscation >= 1.0) { + // Completely obfuscated + return 1.0; + } + } + + return fObfuscation; } SmokeSprite* G_GetRandomSmokeSprite() { diff --git a/code/fgame/soundman.h b/code/fgame/soundman.h index 3ac6e758..2f0943ad 100644 --- a/code/fgame/soundman.h +++ b/code/fgame/soundman.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -23,8 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // soundman.h: Sound Manager // -#ifndef __SOUND_MANAGER_H__ -#define __SOUND_MANAGER_H__ +#pragma once #include "g_local.h" #include "entity.h" @@ -110,5 +109,3 @@ inline void SoundManager::Archive } extern SoundManager SoundMan; - -#endif /* camera.h */ diff --git a/code/fgame/specialfx.h b/code/fgame/specialfx.h index 2e52e41a..fc2138a0 100644 --- a/code/fgame/specialfx.h +++ b/code/fgame/specialfx.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -23,8 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // specialfx.h: special effects // -#ifndef __SPECIAL_FX_H__ -#define __SPECIAL_FX_H__ +#pragma once #include "g_local.h" #include "scriptslave.h" @@ -174,5 +173,3 @@ inline void SinkObject::Archive arc.ArchiveBoolean( &active ); arc.ArchiveVector( &startpos ); } - -#endif /* specialfx.h */ diff --git a/code/fgame/spline.h b/code/fgame/spline.h index aa6ab59b..a32dc460 100644 --- a/code/fgame/spline.h +++ b/code/fgame/spline.h @@ -85,7 +85,7 @@ int cSpline::Add(float *fAdd, int flags) int ii; int insertIndex; - if (m_iPoints + 1 > 512) { + if (m_iPoints + 1 > cPoints) { return -1; } @@ -115,8 +115,8 @@ void cSpline::UniformAdd(float *pos) int i; int ii; - for (i = m_iPoints; i > 0; i--) { - for (ii = 0; ii <= cGrids; ii++) { + for (i = 0; i < m_iPoints; i++) { + for (ii = 0; ii < cGrids; ii++) { m_vPoints[i][ii] += pos[ii]; } } @@ -197,7 +197,7 @@ float *cSpline::GetByNode(float x, int *flags) static float r[cGrids]; double delta[cGrids]; - rp = (int)(floor(x) + 1.0f); + rp = (int)(floor(x) + 1.0); if (rp <= 0) { if (flags) { @@ -221,11 +221,11 @@ float *cSpline::GetByNode(float x, int *flags) } } else { if (flags) { - *flags = m_iPointFlags[rp - 1]; + *flags = m_iPointFlags[m_iPoints - 1]; } for (i = 0; i < cGrids; i++) { - r[i] = m_vPoints[rp - 1][i]; + r[i] = m_vPoints[m_iPoints - 1][i]; } } @@ -240,13 +240,16 @@ int cSpline::Append(cSpline *pNew) float fIndexAdd; int i; int ii; - int iFlags; + int iFlags = 0; if (!pNew || pNew->m_iPoints == 0) { return -1; } if (m_iPoints) { + int points; + + points = m_iPoints; fIndexAdd = *GetByNode(m_iPoints, NULL); for (i = 0; i < pNew->m_iPoints; i++) { @@ -260,7 +263,7 @@ int cSpline::Append(cSpline *pNew) Add(o_fTmp, iFlags); } - return m_iPoints; + return points; } else { for (i = 0; i < pNew->m_iPoints; i++) { i_fTmp = pNew->GetByNode(i, &iFlags); diff --git a/code/fgame/stack.h b/code/fgame/stack.h index 86d4807b..e67df81e 100644 --- a/code/fgame/stack.h +++ b/code/fgame/stack.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -23,8 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // stack.h: Generic Stack object. // -#ifndef __STACK_H__ -#define __STACK_H__ +#pragma once #include "g_local.h" #include "class.h" @@ -142,5 +141,3 @@ inline Type Stack::Pop return ret; } - -#endif /* stack.h */ diff --git a/code/fgame/trigger.cpp b/code/fgame/trigger.cpp index a62fde94..0cc77ade 100644 --- a/code/fgame/trigger.cpp +++ b/code/fgame/trigger.cpp @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -77,7 +77,7 @@ Event EV_Trigger_SetCount EV_DEFAULT, "i", "count", - "Set the amount of times this trigger can be triggered", + "Set the number of times this trigger can be triggered", EV_NORMAL ); Event EV_Trigger_SetMessage @@ -322,7 +322,6 @@ Trigger::Trigger() Trigger::~Trigger() {} void Trigger::SetTriggerDir(float angle) - { triggerDirYaw = angle; triggerDir = G_GetMovedir(angle); @@ -330,13 +329,11 @@ void Trigger::SetTriggerDir(float angle) } Vector Trigger::GetTriggerDir(void) - { return triggerDir; } void Trigger::SetTriggerCone(Event *ev) - { triggerCone = cos(DEG2RAD(ev->GetFloat(1))); } @@ -347,7 +344,6 @@ qboolean Trigger::UsingTriggerDir(void) } void Trigger::SetTriggerDir(Event *ev) - { SetTriggerDir(ev->GetFloat(1)); } @@ -389,7 +385,6 @@ void Trigger::StartThread(Event *ev) } qboolean Trigger::respondTo(Entity *other) - { return ( ((respondto & TRIGGER_PLAYERS) && other->isClient()) @@ -399,7 +394,6 @@ qboolean Trigger::respondTo(Entity *other) } Entity *Trigger::getActivator(Entity *other) - { return other; } @@ -446,6 +440,12 @@ void Trigger::TriggerStuff(Event *ev) ScriptError("trigger '%s' triggered by self", TargetName().c_str()); } + // Fixed in OPM + // Safety check + if (other == NULL) { + ScriptError("trigger '%s' triggered by NULL entity", TargetName().c_str()); + } + // Always respond to activate messages from the world since they're probably from // the "trigger" command if (!respondTo(other) && (other != world || *ev != EV_Activate) @@ -457,7 +457,7 @@ void Trigger::TriggerStuff(Event *ev) // if we setup an angle for this trigger, only trigger if other is within ~60 degrees of the triggers origin // only test for this case if we were touched, activating or killed should never go through this code // - if (useTriggerDir && (*ev == EV_Touch)) { + if (useTriggerDir && (*ev == EV_Touch || (*ev == EV_Use && isSubclassOf(TriggerSidedUse)))) { Vector norm; float dot; @@ -528,10 +528,10 @@ void Trigger::TriggerStuff(Event *ev) event = new Event(EV_Trigger_StartThread); if (activator) { event->AddEntity(activator); - } - if (activator->IsSubclassOfProjectile()) { - Projectile *proj = static_cast(activator); - event->AddEntity(G_GetEntity(proj->owner)); + if (activator->IsSubclassOfProjectile()) { + Projectile* proj = static_cast(activator); + event->AddEntity(G_GetEntity(proj->owner)); + } } PostEvent(event, delay); } @@ -570,7 +570,6 @@ void Trigger::TriggerStuff(Event *ev) //============================== // void Trigger::ActivateTargets(Event *ev) - { Entity *other; Entity *ent; @@ -647,13 +646,11 @@ void Trigger::ActivateTargets(Event *ev) } void Trigger::EventSetWait(Event *ev) - { wait = ev->GetFloat(1); } void Trigger::EventSetDelay(Event *ev) - { delay = ev->GetFloat(1); } @@ -668,19 +665,16 @@ void Trigger::EventSetThread(Event *ev) } void Trigger::EventSetCount(Event *ev) - { count = ev->GetInteger(1); } void Trigger::EventSetMessage(Event *ev) - { SetMessage(ev->GetString(1)); } void Trigger::SetMessage(const char *text) - { if (text) { message = Director.AddString(text); @@ -690,19 +684,16 @@ void Trigger::SetMessage(const char *text) } str& Trigger::Message(void) - { return Director.GetString(message); } void Trigger::EventSetNoise(Event *ev) - { SetNoise(ev->GetString(1)); } void Trigger::SetNoise(const char *text) - { if (text) { noise = Director.AddString(text); @@ -714,7 +705,6 @@ void Trigger::SetNoise(const char *text) } str& Trigger::Noise(void) - { return Director.GetString(noise); } @@ -766,6 +756,10 @@ void Trigger::DamageEvent(Event *ev) Vector dir; Vector momentum; + if (!takedamage) { + return; + } + if (Immune(ev->GetInteger(9))) { // trigger is immune return; @@ -788,6 +782,10 @@ void Trigger::DamageEvent(Event *ev) if (health <= 0) { Event *event; + if (max_health) { + deadflag = DEAD_DEAD; + } + event = new Event(EV_Activate, 1); event->AddEntity(attacker); ProcessEvent(event); @@ -839,7 +837,7 @@ CLASS_DECLARATION(Trigger, TriggerVehicle, "trigger_vehicle") { qboolean TriggerVehicle::respondTo(Entity *other) { - if ((other->IsSubclassOfVehicle()) || isSubclassOf(VehicleCollisionEntity)) { + if ((other->IsSubclassOfVehicle()) || other->isSubclassOf(VehicleCollisionEntity)) { return qtrue; } else { return qfalse; @@ -873,6 +871,7 @@ If DAMAGE is set, the trigger will only respond to bullets set "message" to text string ******************************************************************************/ + CLASS_DECLARATION(Trigger, TriggerAll, "trigger_multipleall") { {&EV_Touch, &TriggerAll::TriggerStuff}, {&EV_Activate, &TriggerAll::TriggerStuff}, @@ -901,6 +900,12 @@ void TriggerAll::TriggerStuff(Event *ev) ScriptError("trigger '%s' triggered by self", TargetName().c_str()); } + // Fixed in OPM + // Safety check + if (other == NULL) { + ScriptError("trigger '%s' triggered by NULL entity", TargetName().c_str()); + } + // Always respond to activate messages from the world since they're probably from // the "trigger" command if (!respondTo(other) && !((other == world) && (*ev == EV_Activate)) @@ -987,10 +992,14 @@ void TriggerAll::TriggerStuff(Event *ev) PostEvent(event, delay); // don't trigger the thread if we were triggered by the world touching us - if ((activator != world) || (ev->eventnum != EV_Touch.eventnum)) { + if ((activator != world) || (*ev != EV_Touch)) { event = new Event(EV_Trigger_StartThread); if (activator) { event->AddEntity(activator); + if (activator->IsSubclassOfProjectile()) { + Projectile* proj = static_cast(activator); + event->AddEntity(G_GetEntity(proj->owner)); + } } PostEvent(event, delay); } @@ -1067,7 +1076,6 @@ TouchField::TouchField() } void TouchField::Setup(Entity *ownerentity, Event& touchevent, Vector min, Vector max, int respondto) - { assert(ownerentity); if (!ownerentity) { @@ -1090,7 +1098,6 @@ void TouchField::Setup(Entity *ownerentity, Event& touchevent, Vector min, Vecto } void TouchField::SendEvent(Event *ev) - { Event *event; @@ -1199,7 +1206,8 @@ set "message" to text string ******************************************************************************/ -Event EV_TriggerSave_SaveName( +Event EV_TriggerSave_SaveName +( "savename", EV_DEFAULT, "s", @@ -1225,7 +1233,7 @@ void TriggerSave::SaveGame(Event *ev) void TriggerSave::EventSaveName(Event *ev) { - m_sSaveName = ev->GetConstString(1); + m_sSaveName = ev->GetString(1); } void TriggerSave::Archive(Archiver& arc) @@ -1301,7 +1309,6 @@ TriggerSecret::TriggerSecret() } void TriggerSecret::FoundSecret(Event *ev) - { // // anything that causes the trigger to fire increments the number @@ -1387,7 +1394,6 @@ void TriggerPush::SetPushDir(Event *ev) } void TriggerPush::SetPushSpeed(Event *ev) - { speed = ev->GetFloat(1); } @@ -1522,7 +1528,6 @@ CLASS_DECLARATION(Trigger, TriggerPlaySound, "play_sound_triggered") { }; void TriggerPlaySound::ToggleSound(Event *ev) - { if (!state) { // noise should already be initialized @@ -1548,7 +1553,6 @@ void TriggerPlaySound::ToggleSound(Event *ev) } void TriggerPlaySound::StartSound(void) - { // turn the current one off state = 1; @@ -1560,31 +1564,26 @@ void TriggerPlaySound::StartSound(void) } void TriggerPlaySound::SetVolume(float vol) - { volume = vol; } void TriggerPlaySound::SetVolume(Event *ev) - { volume = ev->GetFloat(1); } void TriggerPlaySound::SetMinDist(float dist) - { min_dist = dist; } void TriggerPlaySound::SetMinDist(Event *ev) - { min_dist = ev->GetFloat(1); } void TriggerPlaySound::SetChannel(Event *ev) - { channel = ev->GetInteger(1); } @@ -1718,7 +1717,6 @@ CLASS_DECLARATION(TriggerSpeaker, RandomSpeaker, "sound_randomspeaker") { }; void RandomSpeaker::TriggerSound(Event *ev) - { ScheduleSound(); if (G_Random(1) <= chance) { @@ -1727,44 +1725,37 @@ void RandomSpeaker::TriggerSound(Event *ev) } void RandomSpeaker::ScheduleSound(void) - { CancelEventsOfType(EV_Trigger_Effect); PostEvent(EV_Trigger_Effect, mindelay + G_Random(maxdelay - mindelay)); } void RandomSpeaker::SetMinDelay(Event *ev) - { mindelay = ev->GetFloat(1); } void RandomSpeaker::SetMaxDelay(Event *ev) - { maxdelay = ev->GetFloat(1); } void RandomSpeaker::SetChance(Event *ev) - { chance = ev->GetFloat(1); } void RandomSpeaker::SetMinDelay(float newMinDelay) - { mindelay = newMinDelay; } void RandomSpeaker::SetMaxDelay(float newMaxDelay) - { maxdelay = newMaxDelay; } void RandomSpeaker::SetChance(float newChance) - { chance = newChance; } @@ -1842,7 +1833,6 @@ TriggerChangeLevel::TriggerChangeLevel() } void TriggerChangeLevel::SetMap(Event *ev) - { map = ev->GetConstString(1); } @@ -1886,7 +1876,7 @@ void TriggerChangeLevel::ChangeLevel(Event *ev) // m_Thread.Execute(); - if (g_gametype->integer) { + if (g_gametype->integer != GT_SINGLE_PLAYER) { G_BeginIntermission2(); return; } @@ -1947,6 +1937,27 @@ CLASS_DECLARATION(Trigger, TriggerUse, "trigger_use") { TriggerUse::TriggerUse() {} +/*****************************************************************************/ +/*QUAKED trigger_sideduse (1 0 0) ? x x NOT_PLAYERS MONSTERS + +Activates targets when 'used' by an entity. It is usable only within specific degrees. +"setthread" name of thread to trigger. This can be in a different script file as well\ +by using the '::' notation. + +"triggerable" turn trigger on +"nottriggerable" turn trigger off + +If NOT_PLAYERS is set, the trigger does not respond to players +If MONSTERS is set, the trigger will respond to monsters + +******************************************************************************/ + +CLASS_DECLARATION(TriggerUse, TriggerSidedUse, "trigger_sideduse") { + {NULL, NULL} +}; + +TriggerSidedUse::TriggerSidedUse() {} + /*****************************************************************************/ /*QUAKED trigger_useonce (1 0 0) ? x x NOT_PLAYERS MONSTERS @@ -2108,13 +2119,11 @@ TriggerDamageTargets::TriggerDamageTargets() } void TriggerDamageTargets::SetDamage(Event *ev) - { damage = ev->GetInteger(1); } void TriggerDamageTargets::PassDamage(Event *ev) - { Entity *attacker; int dmg; @@ -2150,7 +2159,6 @@ void TriggerDamageTargets::PassDamage(Event *ev) // void TriggerDamageTargets::DamageTargets(Event *ev) - { Entity *other; Entity *ent; @@ -2304,13 +2312,11 @@ TriggerExit::TriggerExit() } void TriggerExit::TurnExitSignOff(Event *ev) - { level.near_exit = false; } void TriggerExit::DisplayExitSign(Event *ev) - { level.near_exit = qtrue; @@ -2827,7 +2833,6 @@ void TriggerByPushObject::setTriggerName(Event *event) } qboolean TriggerByPushObject::respondTo(Entity *other) - { if (other->isSubclassOf(PushObject)) { if (triggername != STRING_EMPTY) { @@ -2841,7 +2846,6 @@ qboolean TriggerByPushObject::respondTo(Entity *other) } Entity *TriggerByPushObject::getActivator(Entity *other) - { Entity *owner; @@ -2863,10 +2867,30 @@ void TriggerByPushObject::Archive(Archiver& arc) Director.ArchiveString(arc, triggername); } -Event EV_TriggerGivePowerup_OneShot("oneshot", EV_DEFAULT, NULL, NULL, "Make this a one time trigger."); +/*****************************************************************************/ +/*QUAKED trigger_givepowerup (1 0 0) ? x x NOT_PLAYERS MONSTERS x x x DAMAGE +Special trigger that can be triggered to give special items to sentients. -Event EV_TriggerGivePowerup_PowerupName( - "powerupname", EV_DEFAULT, "s", "powerup_name", "Specifies the powerup to give to the sentient." +"cnt" how many times it can be triggered (default 1, use -1 for infinite) +"powerupname" the name of the powerup to give to sentients +******************************************************************************/ + +Event EV_TriggerGivePowerup_OneShot +( + "oneshot", + EV_DEFAULT, + NULL, + NULL, + "Make this a one time trigger." +); + +Event EV_TriggerGivePowerup_PowerupName +( + "powerupname", + EV_DEFAULT, + "s", + "powerup_name", + "Specifies the powerup to give to the sentient." ); CLASS_DECLARATION(Trigger, TriggerGivePowerup, "trigger_givepowerup") { @@ -3008,6 +3032,27 @@ void TriggerClickItem::SetClickItemModelEvent(Event *ev) link(); } +//=============== +// +// Added in 2.0 +// +//=============== + +/*****************************************************************************/ +/*QUAKED trigger_nodamage (1 0 0) ? x x NOT_PLAYERS MONSTERS + +Activates targets when 'used' by an entity. It cannot take damage. +"setthread" name of thread to trigger. This can be in a different script file as well\ +by using the '::' notation. + +"triggerable" turn trigger on +"nottriggerable" turn trigger off + +If NOT_PLAYERS is set, the trigger does not respond to players +If MONSTERS is set, the trigger will respond to monsters + +******************************************************************************/ + CLASS_DECLARATION(TriggerUse, TriggerNoDamage, "trigger_nodamage") { {&EV_Touch, &TriggerNoDamage::TakeNoDamage}, {&EV_Trigger_Effect, &TriggerNoDamage::TakeNoDamage}, @@ -3028,10 +3073,59 @@ void TriggerNoDamage::TakeNoDamage(Event *ev) ent->PostEvent(newev, level.frametime * 3); } +//=============== +// +// Added in 2.30 +// +//=============== + +/*****************************************************************************/ +/*QUAKED trigger_entity (1 0 0) ? + +Variable sized repeatable trigger that respond to entities. Must be targeted at one or more entities. + +If "health" is set, the trigger must be killed to activate each time. +If "delay" is set, the trigger waits some time after activating before firing. + +"setthread" name of thread to trigger. This can be in a different script file as well\ +by using the '::' notation. + +if "angle" is set, the trigger will only fire when someone is facing the +direction of the angle. +"cone" the cone in which a directed trigger can be triggered (default 60 degrees) + +"wait" : Seconds between triggerings. (.2 default) +"cnt" how many times it can be triggered (infinite default) + +"triggerable" turn trigger on +"nottriggerable" turn trigger off + +set "message" to text string + +******************************************************************************/ + CLASS_DECLARATION(Trigger, TriggerEntity, "trigger_entity") { {NULL, NULL} }; +qboolean TriggerEntity::respondTo(Entity* other) +{ + return other != NULL && other->IsSubclassOfEntity() != false; +} + +/*****************************************************************************/ +/*QUAKED trigger_landmine (1 0 0) ? + +Variable sized repeatable trigger for landmine. Must be handled by scripts. + +"setthread" name of thread to trigger. This can be in a different script file as well\ +by using the '::' notation. + +"triggerable" turn trigger on +"nottriggerable" turn trigger off + +******************************************************************************/ + Event EV_Trigger_IsAbandoned ( "isabandoned", diff --git a/code/fgame/trigger.h b/code/fgame/trigger.h index d8adabe4..1a4e56e9 100644 --- a/code/fgame/trigger.h +++ b/code/fgame/trigger.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -172,7 +172,7 @@ public: TouchField(); virtual void Setup(Entity *ownerentity, Event& ontouch, Vector min, Vector max, int respondto); void SendEvent(Event *ev); - void Archive(Archiver &arc) override; + void Archive(Archiver& arc) override; }; inline void TouchField::Archive(Archiver& arc) @@ -380,7 +380,7 @@ public: void ChangeLevel(Event *ev); const char *Map(void); const char *SpawnSpot(void); - void Archive(Archiver &arc) override; + void Archive(Archiver& arc) override; }; class TriggerExit : public Trigger @@ -401,6 +401,17 @@ public: TriggerUse(); }; +// +// Added in 2.30 +// Can only be triggered if within specific degrees +class TriggerSidedUse : public TriggerUse +{ +public: + CLASS_PROTOTYPE(TriggerSidedUse); + + TriggerSidedUse(); +}; + class TriggerUseOnce : public TriggerUse { public: @@ -593,6 +604,10 @@ inline void TriggerClickItem::Archive(Archiver& arc) Trigger::Archive(arc); } +// +// Added in 2.0 +// + class TriggerNoDamage : public TriggerUse { public: @@ -602,10 +617,17 @@ public: void TakeNoDamage(Event *ev); }; +// +// Added in 2.30 +// + class TriggerEntity : public Trigger { public: CLASS_PROTOTYPE(TriggerEntity); + +public: + qboolean respondTo(Entity *other) override; }; class TriggerLandmine : public TriggerEntity diff --git a/code/fgame/umap.h b/code/fgame/umap.h index e3cdfdae..2a44a341 100644 --- a/code/fgame/umap.h +++ b/code/fgame/umap.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -24,8 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // stored data. // -#ifndef __UMAP_H__ -#define __UMAP_H__ +#pragma once #include "str.h" #include @@ -335,5 +334,3 @@ inline unsigned UMap::getNumEntries { return m_numentries; } - -#endif /* !__UMAP_H__ */ diff --git a/code/fgame/vehicle.cpp b/code/fgame/vehicle.cpp index 1c20db88..6f8ca73b 100644 --- a/code/fgame/vehicle.cpp +++ b/code/fgame/vehicle.cpp @@ -1096,6 +1096,7 @@ Vehicle::Vehicle() m_bAutoPilot = qfalse; m_fIdealSpeed = 0; + m_fMaxSpeed = 0; m_fIdealAccel = 0; m_fIdealDistance = 100; m_bBounceBackwards = false; @@ -1173,6 +1174,7 @@ Vehicle::Vehicle() m_sAnimationSet = ""; m_sSoundSet = ""; + m_iLastTiresUpdate = -1; for (i = 0; i < NUM_VEHICLE_TIRES; i++) { m_vTireEnd[i] = origin; m_bTireHit[i] = false; @@ -1194,11 +1196,7 @@ Vehicle::~Vehicle */ Vehicle::~Vehicle() { - for (int i = 0; i < MAX_CORNERS; i++) { - if (m_pVehicleSoundEntities[i]) { - m_pVehicleSoundEntities[i]->PostEvent(EV_Remove, EV_LINKDOORS); - } - } + RemoveVehicleSoundEntities(); if (m_pCollisionEntity) { m_pCollisionEntity->ProcessEvent(EV_Remove); @@ -1217,7 +1215,7 @@ void Vehicle::ResetSlots(void) driver.ent = NULL; driver.boneindex = -1; driver.enter_boneindex = -1; - driver.flags = SLOT_UNUSED; + driver.flags = 0; lastdriver.ent = NULL; lastdriver.boneindex = -1; lastdriver.enter_boneindex = -1; @@ -1506,6 +1504,9 @@ void Vehicle::QueryTurretSlotPosition(int slot, float *pos) if (Turrets[slot].enter_boneindex >= 0) { GetTagPositionAndOrientation(Turrets[slot].enter_boneindex, &orient); VectorCopy(orient.origin, pos); + } else if (Turrets[slot].boneindex >= 0) { + GetTagPositionAndOrientation(Turrets[slot].boneindex, &orient); + VectorCopy(orient.origin, pos); } else { VectorCopy(origin, pos); } @@ -2037,7 +2038,7 @@ bool Vehicle::FindExitPosition(Entity *pEnt, const Vector& vOrigin, const Vector return false; } - if (!pEnt->IsSubclassOfPlayer() && vOrigin != vec_zero) { + if ((g_target_game < target_game_e::TG_MOHTA || !pEnt->IsSubclassOfPlayer()) && vOrigin != vec_zero) { if (vAngles) { pEnt->setAngles(*vAngles); } @@ -3137,19 +3138,26 @@ void Vehicle::AutoPilot(void) fCoef = ProjectLineOnPlane(vDelta, DotProduct(origin, vDelta), vPrev, vCur, NULL); if (g_showvehiclemovedebug->integer) { - Vector vColor; - G_DebugBBox(vColor, Vector(-32, -32, -32), Vector(32, 32, 32), 0, 1, 1, 1); - G_DebugBBox(vColor, Vector(-32, -32, -32), Vector(32, 32, 32), 1, 1, 0, 1); - G_DebugArrow(vColor, m_vIdealDir * -1, (1 - fCoef) * fTotal, 0, 1, 0, 1); - G_DebugArrow(vColor, m_vIdealDir * 1, fCoef * fTotal, 0, 0, 1, 1); + G_DebugBBox(vPrev, Vector(-32, -32, -32), Vector(32, 32, 32), 0, 1, 1, 1); + G_DebugBBox(vCur, Vector(-32, -32, -32), Vector(32, 32, 32), 1, 1, 0, 1); + G_DebugArrow(vCur, m_vIdealDir * -1, (1 - fCoef) * fTotal, 0, 1, 0, 1); + G_DebugArrow(vPrev, m_vIdealDir * 1, fCoef * fTotal, 0, 0, 1, 1); } vTmp = m_pCurPath->GetByNode(m_iCurNode - (1.0 - fCoef), NULL); fCurPathPosition = vTmp[0]; - vTmp = m_pCurPath->Get(fCurPathPosition + m_fLookAhead, NULL); - vWishPosition = vTmp + 1; - fDistToCurPos = Vector(origin[0] - vWishPosition[0], origin[1] - vWishPosition[1], 0).length(); + // Added in 2.30 + // Check if vehicle bounces backwards + if (m_bBounceBackwards) { + vTmp = m_pCurPath->Get(fCurPathPosition - m_fLookAhead, NULL); + } else { + vTmp = m_pCurPath->Get(fCurPathPosition + m_fLookAhead, NULL); + } + vWishPosition = vTmp + 1; + fDistToCurPos = Vector(origin[0] - vWishPosition[0], origin[1] - vWishPosition[1], 0).length(); + // Added in 2.30 + // Check if vehicle bounces backwards if (fCoef > 1 && !m_bBounceBackwards) { m_iCurNode++; if (m_iCurNode >= m_pCurPath->m_iPoints) { @@ -3257,7 +3265,8 @@ void Vehicle::AutoPilot(void) vDeltaSave[2] = 0; if (fDistToCurPos > 1) { - if (moveimpulse >= 0 && !m_bBounceBackwards) { // 2.30: checks if it doesn't bounce backwards + // Added 2.30: checks if it doesn't bounce backwards + if (moveimpulse >= 0 && !m_bBounceBackwards) { vectoangles(vDelta, vDeltaAngles); turnimpulse = angledist(vDeltaAngles.y - angles.y); } else { @@ -3296,12 +3305,12 @@ void Vehicle::AutoPilot(void) moveimpulse = -m_fIdealSpeed; } } - } else if (m_fIdealSpeed > moveimpulse) { + } else if (moveimpulse < m_fIdealSpeed) { moveimpulse += m_fIdealAccel * level.frametime; if (moveimpulse > m_fIdealSpeed) { moveimpulse = m_fIdealSpeed; } - } else if (m_fIdealSpeed < moveimpulse) { + } else if (moveimpulse > m_fIdealSpeed) { moveimpulse -= m_fIdealAccel * level.frametime; if (moveimpulse < m_fIdealSpeed) { moveimpulse = m_fIdealSpeed; @@ -3310,13 +3319,19 @@ void Vehicle::AutoPilot(void) if (m_iNextPathStartNode >= 0 && m_pNextPath && m_pNextPath->m_iPoints && m_iCurNode > m_iNextPathStartNode + 2) { - cVehicleSpline *spline = m_pCurPath; - m_pCurPath = m_pNextPath; - m_pNextPath = spline; - m_iCurNode = 2; + cVehicleSpline *spline; + + spline = m_pCurPath; + m_pCurPath = m_pNextPath; + m_pNextPath = spline; + + m_iCurNode = 2; m_pNextPath->Reset(); m_iNextPathStartNode = -1; + + // notify scripts that the drive has finished Unregister(STRING_DRIVE); + m_bStopEnabled = false; m_bEnableSkidding = false; } @@ -3379,7 +3394,7 @@ void Vehicle::EventDriveInternal(Event *ev, bool wait) m_fLookAhead = 256; m_fIdealAccel = 35; m_fIdealSpeed = 250; - m_fMaxSpeed = 250; + m_fMaxSpeed = 250; // Added in 2.30 switch (ev->NumArgs()) { case 6: @@ -3392,6 +3407,7 @@ void Vehicle::EventDriveInternal(Event *ev, bool wait) m_fIdealAccel = ev->GetFloat(3); case 2: m_fIdealSpeed = ev->GetFloat(2); + m_fMaxSpeed = m_fIdealSpeed; // Added in 2.30 case 1: path = ev->GetSimpleEntity(1); if (!path) { @@ -3449,11 +3465,11 @@ void Vehicle::SetupPath(cVehicleSpline *pPath, SimpleEntity *se) vLastOrigin = se->origin; - for (ent = se; ent != NULL; ent = ent->Next(), i++) { + for (ent = se; ent; ent = ent->Next(), i++) { Vector vDelta = vLastOrigin - ent->origin; float vTmp[4]; - if (vDelta.length() == 0.0f && i > 1) { + if (vDelta.length() == 0 && i > 1) { Com_Printf("^~^~^Warning: Vehicle Driving with a Path that contains 2 equal points\n"); } else { fCurLength += vDelta.length(); @@ -3462,7 +3478,7 @@ void Vehicle::SetupPath(cVehicleSpline *pPath, SimpleEntity *se) VectorCopy(ent->origin, vTmp + 1); if (ent->IsSubclassOfVehiclePoint()) { - pPath->Add(vTmp, static_cast(ent)->spawnflags); + pPath->Add(vTmp, static_cast(ent)->spawnflags); } else { pPath->Add(vTmp, 0); } @@ -3665,6 +3681,23 @@ void Vehicle::DriverUse(Event *ev) return; } + // Added in 2.30 + // Check use angle + if (!driver.ent && m_fMaxUseAngle && ent && Turrets[0].ent) { + Vector vForward; + Vector vDir; + + AngleVectors(Turrets[0].ent->angles, vForward, NULL, NULL); + + vDir = Turrets[0].ent->origin - ent->origin; + VectorNormalize(vDir); + + if (fabs(GetAngleBetweenVectors2D(vForward, vDir)) > m_fMaxUseAngle) { + // Not usable + return; + } + } + if (ev->NumArgs() == 2) { if (ev->IsVectorAt(2)) { vExitPosition = ev->GetVector(2); @@ -3722,14 +3755,12 @@ void Vehicle::DriverUse(Event *ev) slot = FindTurretSlotByEntity(sent->GetTurret()); if (slot >= 0) { - if (bHasExitPosition) { - if (bHasExitAngles) { - AttachTurretSlot(slot, sentTurret, vExitPosition, &vExitAngles); - } else { - AttachTurretSlot(slot, sentTurret, vExitPosition, NULL); - } + if (!bHasExitPosition) { + AttachTurretSlot(slot, sent, vec_zero, NULL); + } else if (!bHasExitAngles) { + AttachTurretSlot(slot, sent, vExitPosition, NULL); } else { - AttachTurretSlot(slot, sentTurret, vec_zero, NULL); + AttachTurretSlot(slot, sent, vExitPosition, &vExitAngles); } sent->SetVehicle(NULL); @@ -3740,7 +3771,7 @@ void Vehicle::DriverUse(Event *ev) // Check for passengers slots for (slot = 0; slot < MAX_PASSENGERS; slot++) { - if (!(Passengers[0].flags & SLOT_FREE)) { + if (!(Passengers[slot].flags & SLOT_FREE)) { continue; } @@ -3758,7 +3789,7 @@ void Vehicle::DriverUse(Event *ev) // Check for turrets slots if (ent->IsSubclassOfWeapon()) { for (slot = 0; slot < MAX_TURRETS; slot++) { - if (!(Turrets[0].flags & SLOT_FREE)) { + if (!(Turrets[slot].flags & SLOT_FREE)) { continue; } @@ -3774,7 +3805,7 @@ void Vehicle::DriverUse(Event *ev) } } else { for (slot = 0; slot < MAX_TURRETS; slot++) { - if (!(Turrets[0].flags & SLOT_BUSY)) { + if (!(Turrets[slot].flags & SLOT_BUSY)) { continue; } @@ -3836,15 +3867,15 @@ void Vehicle::SetMoveInfo(vmove_t *vm) { memset(vm, 0, sizeof(vmove_t)); - VectorCopy(origin, vs.origin); + origin.copyTo(vs.origin); vs.useGravity = false; vs.entityNum = entnum; vm->vs = &vs; vm->frametime = level.frametime; vm->tracemask = edict->clipmask; - VectorCopy(mins, vm->mins); - VectorCopy(maxs, vm->maxs); + mins.copyTo(vm->mins); + maxs.copyTo(vm->maxs); vs.entityNum = edict->s.number; vs.desired_dir[0] = velocity[0]; @@ -3881,14 +3912,17 @@ Vehicle::SetCEMoveInfo */ void Vehicle::SetCEMoveInfo(vmove_t *vm) { + Vector mins, maxs; + SetMoveInfo(vm); - vm->mins[0] = m_pCollisionEntity->mins[0] - 24.0f; - vm->mins[1] = m_pCollisionEntity->mins[1] - 24.0f; - vm->mins[2] = m_pCollisionEntity->mins[2]; - vm->maxs[0] = m_pCollisionEntity->maxs[0] + 24.0f; - vm->maxs[1] = m_pCollisionEntity->maxs[1] + 24.0f; - vm->maxs[2] = m_pCollisionEntity->maxs[2]; + mins = m_pCollisionEntity->mins; + maxs = m_pCollisionEntity->maxs; + mins -= Vector(24, 24, 0); + maxs += Vector(24, 24, 0); + + mins.copyTo(vm->mins); + maxs.copyTo(vm->maxs); } /* @@ -4092,12 +4126,12 @@ void Vehicle::SlidePush(Vector vPush) if (j == i && other->entity) { other->entity->CheckGround(); - if (other->entity->groundentity - && (other->entity->groundentity == edict || other->entity == m_pCollisionEntity)) { + if (other->entity->groundentity && (other->entity->groundentity == edict + || m_pCollisionEntity && other->entity->groundentity->entity == m_pCollisionEntity)) { // save the entity - pSkippedEntities[iNumSkipped] = other->entity; + pSkippedEntities[iNumSkipped] = other->entity; iContentsEntities[iNumSkipped] = other->r.contents; - solidEntities[iNumSkipped] = other->solid; + solidEntities[iNumSkipped] = other->solid; iNumSkipped++; if (iNumSkipped >= MAX_SKIPPED_ENTITIES) { @@ -4198,6 +4232,9 @@ void Vehicle::MoveVehicle(void) int iNumSkippedEntities = 0; Event *event = nullptr; Entity *chain; + Entity *driverEnt = NULL; + solid_t solidDriver = SOLID_NOT; + int contentsDriver = 0; if (m_bMovementLocked) { return; @@ -4217,6 +4254,19 @@ void Vehicle::MoveVehicle(void) if (velocity.length() > 0.5f) { Vector vVel; + if (driver.ent && driver.ent->edict->solid != SOLID_NOT) { + // + // Added in OPM + // Make the driver nonsolid while moving. + // Scripts usually set the player to nonsolid. + // However some scripts still rely on the old 1.11 behavior + // where the player is set to nonsolid when driving some type of vehicles + solidDriver = driver.ent->edict->solid; + contentsDriver = driver.ent->getContents(); + + driver.ent->setSolidType(SOLID_NOT); + } + fSpeed = orientation[0] * velocity; vecDelta = velocity * level.frametime; @@ -4255,8 +4305,8 @@ void Vehicle::MoveVehicle(void) tr.ent->entity->CheckGround(); if (!tr.ent->entity->groundentity - || (tr.ent->entity->groundentity == edict - && (!m_pCollisionEntity || tr.ent->entity != m_pCollisionEntity))) { + || (tr.ent->entity->groundentity != edict + && (!m_pCollisionEntity || tr.ent->entity->groundentity->entity != m_pCollisionEntity))) { Event *event = new Event(EV_Touch); event->AddEntity(this); tr.ent->entity->ProcessEvent(event); @@ -4277,7 +4327,15 @@ void Vehicle::MoveVehicle(void) ); } - break; + // Added in OPM + // Skip the entity if the sentient is dead. + // This is a workaround against sentients getting in path of vehicles + // and thus blocking them temporarily while dying. + // For example in e1l1, the first tank would get stuck, because sometimes + // there are too many actors moving in the path of the vehicle + if (!bHitPerson || !tr.ent->entity->IsDead()) { + break; + } } pSkippedEntities[iNumSkippedEntities] = tr.ent->entity; @@ -4337,8 +4395,8 @@ void Vehicle::MoveVehicle(void) tr.ent->entity->CheckGround(); if (!tr.ent->entity->groundentity - || (tr.ent->entity->groundentity == edict - && (!m_pCollisionEntity || tr.ent->entity != m_pCollisionEntity))) { + || (tr.ent->entity->groundentity != edict + && (!m_pCollisionEntity || tr.ent->entity->groundentity->entity != m_pCollisionEntity))) { Event *event = new Event(EV_Touch); event->AddEntity(this); tr.ent->entity->ProcessEvent(event); @@ -4359,7 +4417,11 @@ void Vehicle::MoveVehicle(void) ); } - break; + // Added in OPM + // (see the comment above) + if (!bHitPerson || !tr.ent->entity->IsDead()) { + break; + } } pSkippedEntities[iNumSkippedEntities] = tr.ent->entity; @@ -4411,14 +4473,10 @@ void Vehicle::MoveVehicle(void) "Vehicle::MoveVehicle" ); - if (tr.fraction != 1.0f || tr.plane.normal[2] < 0.7f || tr.allsolid) { + if ((tr.fraction != 1.0f && tr.plane.normal[2] < 0.7f) || tr.allsolid) { flMoveFrac = 0.0f; } - if (tr.fraction == 1.0f && !tr.allsolid && !tr.startsolid) { - break; - } - if (!tr.ent || !tr.ent->entity || tr.ent->entity == world) { break; } @@ -4426,8 +4484,8 @@ void Vehicle::MoveVehicle(void) tr.ent->entity->CheckGround(); if (!tr.ent->entity->groundentity - || (tr.ent->entity->groundentity == edict - && (!m_pCollisionEntity || tr.ent->entity != m_pCollisionEntity))) { + || (tr.ent->entity->groundentity != edict + && (!m_pCollisionEntity || tr.ent->entity->groundentity->entity != m_pCollisionEntity))) { Event *event = new Event(EV_Touch); event->AddEntity(this); tr.ent->entity->ProcessEvent(event); @@ -4448,7 +4506,11 @@ void Vehicle::MoveVehicle(void) ); } - break; + // Added in OPM + // (see the comment above) + if (!bHitPerson || !tr.ent->entity->IsDead()) { + break; + } } pSkippedEntities[iNumSkippedEntities] = tr.ent->entity; @@ -4513,9 +4575,16 @@ void Vehicle::MoveVehicle(void) } else if (!bHitPerson) { velocity *= 0.5; } + + if (solidDriver != SOLID_NOT) { + driver.ent->setSolidType(solidDriver); + driver.ent->setContents(contentsDriver); + } } if (bDoGravity) { + velocity[2] -= sv_gravity->value * level.frametime; + tr = G_Trace( origin, mins, @@ -4675,8 +4744,8 @@ void Vehicle::Postthink(void) velocity.z = drivespeed * jumpimpulse; avelocity *= 0.05f; - if (steerinplace && drivespeed < 350.0f) { - drivespeed = 350.0f; + if (steerinplace && drivespeed < 350) { + drivespeed = 350; } avelocity.y += turn * drivespeed; @@ -4882,10 +4951,6 @@ void Vehicle::VehicleTouched(Event *ev) return; } - if (drivable && !driver.ent) { - return; - } - delta = other->origin - last_origin; delta.normalize(); @@ -5856,15 +5921,20 @@ void Vehicle::UpdateNormals(void) } if (m_iNumNormals > 1) { + float x, z; + temp = m_vNormalSum / m_iNumNormals; i = temp.CrossProduct(temp, j); - pitch = i; - angles[0] = pitch.toPitch(); + pitch = i; + x = pitch.toPitch(); - temp = m_vNormalSum / m_iNumNormals; - pitch = temp.CrossProduct(temp, i); - angles[2] = pitch.toPitch(); + temp = m_vNormalSum / m_iNumNormals; + pitch = temp.CrossProduct(temp, i); + z = pitch.toPitch(); + + angles[0] = x; + angles[2] = z; } } @@ -5964,7 +6034,7 @@ void Vehicle::UpdatePassengerSlot(int iSlot) Passengers[iSlot].ent->avelocity = avelocity; Passengers[iSlot].ent->velocity = velocity; - if (!Passengers[iSlot].ent->IsSubclassOfActor() || ((Actor *)Passengers[iSlot].ent.Pointer())->m_Enemy) { + if (!Passengers[iSlot].ent->IsSubclassOfActor() || !((Actor *)Passengers[iSlot].ent.Pointer())->m_Enemy) { Vector newAngles; MatrixToEulerAngles(orient.axis, newAngles); @@ -6438,12 +6508,16 @@ void Vehicle::EventCanUse(Event *ev) VectorNormalize(vDir); if (fabs(GetAngleBetweenVectors2D(vForward, vDir)) > m_fMaxUseAngle) { - ev->AddInteger(1); + ev->AddInteger(false); } else { - ev->AddInteger(0); + ev->AddInteger(true); } } +int Vehicle::GetProjectileHitsRemaining() const { + return m_iProjectileHitsRemaining; +} + /* ==================== Vehicle::Archive @@ -6463,6 +6537,7 @@ void Vehicle::Archive(Archiver& arc) arc.ArchiveFloat(&conesize); arc.ArchiveFloat(&maxtracedist); arc.ArchiveString(&weaponName); + arc.ArchiveString(&vehicleName); arc.ArchiveVector(&last_origin); arc.ArchiveVector(&seatangles); arc.ArchiveVector(&seatoffset); @@ -6474,6 +6549,7 @@ void Vehicle::Archive(Archiver& arc) arc.ArchiveVector(&Corners[3]); arc.ArchiveBoolean(&drivable); + arc.ArchiveBoolean(&pathDrivable); // Added in 2.30 arc.ArchiveBoolean(&locked); arc.ArchiveBoolean(&hasweapon); arc.ArchiveBoolean(&showweapon); @@ -6481,14 +6557,19 @@ void Vehicle::Archive(Archiver& arc) arc.ArchiveBoolean(&jumpable); arc.ArchiveBoolean(&m_bMovementLocked); + arc.ArchiveBoolean(&m_bAnimMove); // Added in 2.0 + arc.ArchiveBoolean(&m_bDamageSounds); // Added in 2.0 + arc.ArchiveBoolean(&m_bRunSounds); // Added in 2.0 + arc.ArchiveInteger(&m_iProjectileHitsRemaining); // Added in 2.30 + driver.Archive(arc); lastdriver.Archive(arc); - for (int i = MAX_PASSENGERS - 1; i >= 0; i--) { + for (int i = 0; i < MAX_PASSENGERS; i++) { Passengers[i].Archive(arc); } - for (int i = MAX_TURRETS - 1; i >= 0; i--) { + for (int i = 0; i < MAX_TURRETS; i++) { Turrets[i].Archive(arc); } @@ -6708,7 +6789,19 @@ void Vehicle::Archive(Archiver& arc) arc.ArchiveBoolean(&m_bRemoveOnDeath); arc.ArchiveBoolean(&m_bStopEnabled); arc.ArchiveBoolean(&m_bEnableSkidding); - arc.ArchiveRaw(&vs, sizeof(vehicleState_t)); + + arc.ArchiveVec3(vs.origin); + arc.ArchiveVec3(vs.velocity); + arc.ArchiveInteger(&vs.groundEntityNum); + arc.ArchiveBoolean(&vs.walking); + arc.ArchiveBoolean(&vs.groundPlane); + G_ArchiveTrace(arc, &vs.groundTrace); + arc.ArchiveInteger(&vs.entityNum); + arc.ArchiveVec2(vs.desired_dir); + arc.ArchiveBoolean(&vs.hit_obstacle); + arc.ArchiveVec3(vs.hit_origin); + arc.ArchiveVec3(vs.obstacle_normal); + arc.ArchiveBoolean(&vs.useGravity); if (!arc.Saving()) { m_sMoveGrid = new cMoveGrid(3, 3, 1); @@ -6717,6 +6810,8 @@ void Vehicle::Archive(Archiver& arc) m_sMoveGrid->Archive(arc); arc.ArchiveFloat(&m_fIdealSpeed); + arc.ArchiveFloat(&m_fMaxSpeed); // Added in 2.30 + arc.ArchiveBool(&m_bBounceBackwards); // Added in 2.30 arc.ArchiveVector(&m_vIdealPosition); arc.ArchiveVector(&m_vIdealDir); arc.ArchiveFloat(&m_fIdealAccel); @@ -6730,6 +6825,10 @@ void Vehicle::Archive(Archiver& arc) arc.ArchiveSafePointer(&m_pVehicleSoundEntities[1]); arc.ArchiveSafePointer(&m_pVehicleSoundEntities[2]); arc.ArchiveSafePointer(&m_pVehicleSoundEntities[3]); + + // Added in 2.30 + arc.ArchiveFloat(&m_fMaxUseAngle); + arc.ArchiveBool(&m_bBounceStayFullSpeed); } /* @@ -6805,11 +6904,6 @@ DrivableVehicle::DrivableVehicle */ DrivableVehicle::DrivableVehicle() { - if (LoadingSavegame) { - // Archive function will setup all necessary data - return; - } - AddWaitTill(STRING_DEATH); drivable = true; @@ -6929,7 +7023,7 @@ void DrivableVehicle::Killed(Event *ev) if (name && strcmp(name, "")) { for (ent = G_FindTarget(NULL, name); ent; ent = G_FindTarget(ent, name)) { event = new Event(EV_Activate); - event->AddEntity(ent); + event->AddEntity(attacker); ent->ProcessEvent(event); } } diff --git a/code/fgame/vehicle.h b/code/fgame/vehicle.h index d27ea5f5..b8709df2 100644 --- a/code/fgame/vehicle.h +++ b/code/fgame/vehicle.h @@ -326,11 +326,6 @@ protected: virtual void VehicleStart(Event *ev); virtual void VehicleTouched(Event *ev); virtual void VehicleBlocked(Event *ev); - // Added in 2.30 - //==== - void SetProjectileVulnerable(Event *ev); - void DoProjectileVulnerability(Entity *pProjectile, Entity *pOwner, meansOfDeath_t meansOfDeath); - //==== void Think(void) override; void Postthink(void) override; virtual void Drivable(Event *ev); @@ -485,7 +480,7 @@ public: virtual qboolean ShowWeapon(void); Entity *Driver(void); virtual qboolean IsDrivable(void); - void Archive(Archiver &arc) override; + void Archive(Archiver& arc) override; str GetSoundSet(void); virtual float QuerySpeed(void); virtual int QueryFreePassengerSlot(void); @@ -503,7 +498,7 @@ public: virtual Entity *QueryPassengerSlotEntity(int slot); virtual Entity *QueryDriverSlotEntity(int slot); virtual Entity *QueryTurretSlotEntity(int slot); - bool FindExitPosition(Entity *pEnt, const Vector &vOrigin, const Vector *vAngles); // added in 2.0 + bool FindExitPosition(Entity *pEnt, const Vector& vOrigin, const Vector *vAngles); // added in 2.0 virtual void AttachPassengerSlot(int slot, Entity *ent, Vector vExitPosition); virtual void AttachDriverSlot(int slot, Entity *ent, Vector vExitPosition); virtual void AttachTurretSlot(int slot, Entity *ent, Vector vExitPosition, Vector *vExitAngles); @@ -519,12 +514,15 @@ public: qboolean isLocked(void); void Lock(void); void UnLock(void); - const str & getName() const; // added in 2.0 + const str& getName() const; // added in 2.0 VehicleCollisionEntity *GetCollisionEntity(void); // Added in 2.30 //==== void EventSetMaxUseAngle(Event *ev); void EventCanUse(Event *ev); + int GetProjectileHitsRemaining() const; + void SetProjectileVulnerable(Event* ev); + void DoProjectileVulnerability(Entity* pProjectile, Entity* pOwner, meansOfDeath_t meansOfDeath); //==== }; @@ -535,7 +533,7 @@ public: DrivableVehicle(void); - virtual void Killed(Event *ev); + virtual void Killed(Event *ev) override; }; class VehicleWheelsX4 : public DrivableVehicle @@ -592,7 +590,7 @@ public: virtual void CalculateOriginOffset() override; void UpdateSound() override; //void AttachDriverSlot(Event* ev) override; - void AttachDriverSlot(int slot, Entity* ent, Vector vExitPosition) override; + void AttachDriverSlot(int slot, Entity *ent, Vector vExitPosition) override; }; class VehicleHalfTrack : public DrivableVehicle diff --git a/code/fgame/vehicleturret.cpp b/code/fgame/vehicleturret.cpp index 7ed211fd..6bd57faa 100644 --- a/code/fgame/vehicleturret.cpp +++ b/code/fgame/vehicleturret.cpp @@ -340,7 +340,6 @@ void VehicleTurretGun::Think(void) UpdateSound(); UpdateFireControl(); - sentOwner = GetSentientOwner(); if (sentOwner) { G_TouchTriggers(sentOwner); UpdateOwner(sentOwner); @@ -371,6 +370,11 @@ void VehicleTurretGun::P_UserAim(usercmd_t *ucmd) return; } + if (!m_pVehicleOwner) { + // Added in OPM + return; + } + if (!m_pVehicleOwner->IsSubclassOfVehicle()) { return; } @@ -386,7 +390,9 @@ void VehicleTurretGun::P_UserAim(usercmd_t *ucmd) Entity *slotEnt; slotEnt = pVehicle->QueryTurretSlotEntity(newSlot); - if (slotEnt->IsSubclassOfVehicleTurretGun()) { + // slotEnt check: + // Added in OPM + if (slotEnt && slotEnt->IsSubclassOfVehicleTurretGun()) { VehicleTurretGun *existing; Vector newAng; bool wasThisLocked, wasExistingLocked; @@ -754,7 +760,7 @@ void VehicleTurretGun::EventDamage(Event *ev) break; } - DamageEvent(ev); + Entity::DamageEvent(ev); return; } @@ -809,7 +815,8 @@ void VehicleTurretGun::UpdateSound(void) case STT_OFF_TRANS_MOVING: m_fNextSoundState = level.time; - m_eSoundState = STT_OFF; + m_eSoundState = STT_MOVING; + Sound(m_sSoundSet + "snd_move_start"); break; case STT_MOVING: @@ -823,6 +830,7 @@ void VehicleTurretGun::UpdateSound(void) case STT_MOVING_TRANS_OFF: m_fNextSoundState = level.time; m_eSoundState = STT_OFF; + StopLoopSound(); Sound(m_sSoundSet + "snd_move_stop"); break; @@ -949,7 +957,7 @@ void VehicleTurretGun::UpdateOwner(Sentient *pOwner) void VehicleTurretGun::TurretHasBeenMounted() { - m_fLastFireTime = level.time + m_fWarmupDelay + fire_delay[FIRE_PRIMARY]; + m_fLastFireTime = (level.time + m_fWarmupDelay) - fire_delay[FIRE_PRIMARY]; if (m_fWarmupDelay > 0.25) { Sound(m_sSoundSet + "snd_warmup"); } @@ -1029,6 +1037,18 @@ void VehicleTurretGun::AdjustReloadStatus() m_iAmmo = m_iReloadShots; m_fReloadTimeRemaining = m_fReloadDelay; + if (g_target_game <= target_game_e::TG_MOHTA) { + // + // Below 2.30 (Spearhead), the sound is played immediately. + // 2.30 has it wrong with the Nebelwerfer. + // + ProcessEvent(EV_VehicleTurretGun_PlayReloadSound); + return; + } + + // + // Changed in 2.30 + // Play the reload sound once finished reloading PostEvent(EV_VehicleTurretGun_PlayReloadSound, m_fReloadDelay * 0.5); } } @@ -1102,7 +1122,7 @@ void VehicleTurretGun::GetMuzzlePosition(vec3_t position, vec3_t vBarrelPos, vec VectorCopy(position, vBarrelPos); } - delta = viewer->GunTarget(position) - position; + delta = viewer->GunTarget(false, position) - position; aim_angles = delta.toAngles(); if (IsSubclassOfVehicleTurretGun()) { @@ -1137,6 +1157,14 @@ void VehicleTurretGun::ApplyFireKickback(const Vector& org, float kickback) return; } + if (g_target_game <= target_game_e::TG_MOH) { + // Don't apply fire kickback in older version + // this could cause issues as models weren't made for this feature + return; + } + + // Added in 2.0 + pVehicle = static_cast(m_pVehicleOwner.Pointer()); pVehicle->m_fForwardForce += org.x * kickback; pVehicle->m_fLeftForce += org.y * kickback; @@ -1502,7 +1530,7 @@ void VehicleTurretGun::UpdateCollisionEntity() vec3_t axis[3]; vec3_t mat[3]; - AnglesToAxis(m_vLocalAngles, mat); + AnglesToAxis(m_vLocalAngles, axis); MatrixMultiply(axis, m_mBaseOrientation, mat); MatrixToEulerAngles(mat, newAngles); } else { @@ -1666,6 +1694,10 @@ void VehicleTurretGun::EndRemoteControl() m_iFiring = 0; m_vTargetAngles = m_vLocalAngles; + // Added in OPM + // Clear the camera shake/jitter + m_fCurrViewJitter = 0; + // // Added in OPM. // The camera must be removed after ending the remote control. @@ -1765,6 +1797,8 @@ Event EV_VTGP_LinkTurret "Sets the next turret in the link.", EV_NORMAL ); + +// Added in 2.30 Event EV_VTGP_SetSwitchThread ( "setswitchthread", @@ -1777,6 +1811,8 @@ Event EV_VTGP_SetSwitchThread CLASS_DECLARATION(VehicleTurretGun, VehicleTurretGunTandem, "VehicleTurretGunTandem") { {&EV_VTGP_LinkTurret, &VehicleTurretGunTandem::EventLinkTurret }, + + // Added in 2.30 {&EV_VTGP_SetSwitchThread, &VehicleTurretGunTandem::EventSetSwitchThread}, {NULL, NULL } }; @@ -2039,7 +2075,7 @@ void VehicleTurretGunTandem::RemoteControl(usercmd_t *ucmd, Sentient *owner) vNewCmdAng = Vector(SHORT2ANGLE(ucmd->angles[0]), SHORT2ANGLE(ucmd->angles[1]), SHORT2ANGLE(ucmd->angles[2])); - if (vNewCmdAng[0] || vNewCmdAng[1] || vNewCmdAng[2]) { + if (m_vUserLastCmdAng[0] || m_vUserLastCmdAng[1] || m_vUserLastCmdAng[2]) { m_vUserViewAng[0] += AngleSubtract(vNewCmdAng[0], m_vUserLastCmdAng[0]); m_vUserViewAng[1] += AngleSubtract(vNewCmdAng[1], m_vUserLastCmdAng[1]); m_vUserViewAng[2] += AngleSubtract(vNewCmdAng[2], m_vUserLastCmdAng[2]); @@ -2060,7 +2096,7 @@ void VehicleTurretGunTandem::RemoteControlSecondary(usercmd_t *ucmd, Sentient *o vNewCmdAng = Vector(SHORT2ANGLE(ucmd->angles[0]), SHORT2ANGLE(ucmd->angles[1]), SHORT2ANGLE(ucmd->angles[2])); - if (vNewCmdAng[0] || vNewCmdAng[1] || vNewCmdAng[2]) { + if (m_vUserLastCmdAng[0] || m_vUserLastCmdAng[1] || m_vUserLastCmdAng[2]) { m_vUserViewAng[0] += AngleSubtract(vNewCmdAng[0], m_vUserLastCmdAng[0]); m_vUserViewAng[1] += AngleSubtract(vNewCmdAng[1], m_vUserLastCmdAng[1]); m_vUserViewAng[2] += AngleSubtract(vNewCmdAng[2], m_vUserLastCmdAng[2]); @@ -2106,10 +2142,16 @@ void VehicleTurretGunTandem::SwitchToLinkedTurret() if (m_Slot.ent) { pTurret = static_cast(m_Slot.ent.Pointer()); - m_SwitchLabel.Execute(pTurret, NULL); + // Added in 2.30 + m_SwitchLabel.Execute(this, pTurret, NULL); } else { pTurret = m_PrimaryTurret; - m_PrimaryTurret->m_SwitchLabel.Execute(pTurret, NULL); + // Added in 2.30 + if (m_PrimaryTurret) { + // Fixed in OPM + // Check for primary turret before setting the switch label + m_PrimaryTurret->m_SwitchLabel.Execute(this, pTurret, NULL); + } } SetActiveTurret(pTurret); @@ -2146,6 +2188,8 @@ void VehicleTurretGunTandem::Archive(Archiver& arc) arc.ArchiveSafePointer(&m_ActiveTurret); arc.ArchiveFloat(&m_fSwitchTimeRemaining); arc.ArchiveFloat(&m_fSwitchDelay); + // Added in 2.30 + m_SwitchLabel.Archive(arc); } VehicleTurretGunTandem *VehicleTurretGunTandem::GetPrimaryTurret() diff --git a/code/fgame/vehicleturret.h b/code/fgame/vehicleturret.h index 617cbb65..97244137 100644 --- a/code/fgame/vehicleturret.h +++ b/code/fgame/vehicleturret.h @@ -160,6 +160,9 @@ public: void Archive(Archiver& arc) override; }; +// +// Added in 2.0 +// class VehicleTurretGunTandem : public VehicleTurretGun { private: @@ -179,7 +182,7 @@ public: ~VehicleTurretGunTandem(); virtual void EventLinkTurret(Event *ev); - virtual void EventSetSwitchThread(Event *ev); + virtual void EventSetSwitchThread(Event *ev); // Added in 2.30 virtual void AttachLinkedTurret(Entity *ent); virtual void UpdateLinkedTurret(); virtual void OpenSlotsByModel(); diff --git a/code/fgame/viewthing.h b/code/fgame/viewthing.h index 29763439..fc466257 100644 --- a/code/fgame/viewthing.h +++ b/code/fgame/viewthing.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -23,8 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // viewthing.h: Actor code for the viewthing. // -#ifndef __VIEWTHING_H__ -#define __VIEWTHING_H__ +#pragma once #include "animate.h" @@ -113,5 +112,3 @@ inline void Viewthing::Archive arc.ArchiveVector( &baseorigin ); arc.ArchiveRaw( origSurfaces, sizeof( origSurfaces ) ); } - -#endif /* viewthing.h */ diff --git a/code/fgame/weapon.cpp b/code/fgame/weapon.cpp index f6921757..2d7de504 100644 --- a/code/fgame/weapon.cpp +++ b/code/fgame/weapon.cpp @@ -195,7 +195,14 @@ Event EV_Weapon_DMSetFireDelay "Set the minimum time between shots from the weapon", EV_NORMAL ); -Event EV_Weapon_NotDroppable("notdroppable", EV_DEFAULT, NULL, NULL, "Makes a weapon not droppable"); +Event EV_Weapon_NotDroppable +( + "notdroppable", + EV_DEFAULT, + NULL, + NULL, + "Makes a weapon not droppable" +); Event EV_Weapon_SetAimAnim ( "setaimanim", @@ -205,8 +212,14 @@ Event EV_Weapon_SetAimAnim "Set the aim animation and frame for when a weapon fires", EV_NORMAL ); -Event - EV_Weapon_SetRank("rank", EV_DEFAULT, "ii", "iOrder iRank", "Set the order value and power ranking for the weapon"); +Event EV_Weapon_SetRank +( + "rank", + EV_DEFAULT, + "ii", + "iOrder iRank", + "Set the order value and power ranking for the weapon" +); Event EV_Weapon_SetFireType ( "firetype", @@ -216,7 +229,8 @@ Event EV_Weapon_SetFireType "Set the firing type of the weapon (projectile or bullet)", EV_NORMAL ); -Event EV_Weapon_SetAIRange( +Event EV_Weapon_SetAIRange +( "airange", EV_DEFAULT, "s", @@ -350,7 +364,8 @@ Event EV_Weapon_SetDMBulletRange "Set the range of the bullets", EV_NORMAL ); -Event EV_Weapon_SetBulletSpread( +Event EV_Weapon_SetBulletSpread +( "bulletspread", EV_DEFAULT, "ffFF", @@ -358,7 +373,8 @@ Event EV_Weapon_SetBulletSpread( "Set the min & optional max spread of the bullet in the x and y axis", EV_NORMAL ); -Event EV_Weapon_SetDMBulletSpread( +Event EV_Weapon_SetDMBulletSpread +( "dmbulletspread", EV_DEFAULT, "ffFF", @@ -654,7 +670,8 @@ Event EV_Weapon_SetMeansOfDeath "Set the meansOfDeath of the weapon.", EV_NORMAL ); -Event EV_Weapon_SetWorldHitSpawn( +Event EV_Weapon_SetWorldHitSpawn +( "worldhitspawn", EV_DEFAULT, "s", @@ -870,6 +887,30 @@ Event EV_OverCooked_Warning EV_NORMAL ); +// +// Added in OPM +// + +Event EV_Weapon_DoneAnimating +( + "doneanimating", + EV_DEFAULT, + NULL, + NULL, + "Signals the end of animation", + EV_NORMAL +); + +Event EV_Weapon_GetPutaway +( + "putaway", + EV_DEFAULT, + NULL, + NULL, + "Returns whether or not the given weapon is being put away", + EV_GETTER +); + CLASS_DECLARATION(Item, Weapon, NULL) { {&EV_SetAnim, &Weapon::SetWeaponAnimEvent }, {&EV_Item_Pickup, &Weapon::PickupWeapon }, @@ -966,6 +1007,11 @@ CLASS_DECLARATION(Item, Weapon, NULL) { {&EV_OverCooked_Warning, &Weapon::OnOverCookedWarning }, {&EV_Weapon_SetCurrentFireAnim, &Weapon::SetCurrentFireAnim }, {&EV_Weapon_SetSecondaryAmmoInHud, &Weapon::SetSecondaryAmmoInHud }, + // + // Added in OPM + // + {&EV_Weapon_DoneAnimating, &Weapon::DoneAnimating }, + {&EV_Weapon_GetPutaway, &Weapon::EventGetPutaway }, {NULL, NULL } }; @@ -1133,6 +1179,7 @@ Weapon::Weapon() INITIALIZE_WEAPONMODE_VAR(meansofdeath, MOD_NONE); // Set the stats + m_iNumShotsFired = 0; m_iNumHits = 0; m_iNumGroinShots = 0; m_iNumHeadShots = 0; @@ -1202,15 +1249,9 @@ void Weapon::Delete(void) { if (g_iInThinks) { DetachGun(); - - if (owner) { - RemoveFromOwner(); - } - - PostEvent(EV_Remove, 0); - } else { - delete this; } + + Item::Delete(); } //====================== @@ -1282,7 +1323,7 @@ void Weapon::SetUseNoAmmo(Event *ev) //====================== void Weapon::SetStartAmmo(Event *ev) { - if (g_protocol <= protocol_e::PROTOCOL_MOH && g_gametype->integer) { + if (g_protocol <= protocol_e::PROTOCOL_MOH && g_gametype->integer != GT_SINGLE_PLAYER) { return; } @@ -1295,7 +1336,7 @@ void Weapon::SetStartAmmo(Event *ev) //====================== void Weapon::SetDMStartAmmo(Event *ev) { - if (!g_gametype->integer) { + if (g_gametype->integer == GT_SINGLE_PLAYER) { return; } @@ -1344,7 +1385,7 @@ float Weapon::GetMaxChargeTime(firemode_t mode) //====================== void Weapon::SetAmmoRequired(Event *ev) { - if (g_protocol <= protocol_e::PROTOCOL_MOH && g_gametype->integer) { + if (g_protocol <= protocol_e::PROTOCOL_MOH && g_gametype->integer != GT_SINGLE_PLAYER) { return; } @@ -1357,7 +1398,7 @@ void Weapon::SetAmmoRequired(Event *ev) //====================== void Weapon::SetDMAmmoRequired(Event *ev) { - if (!g_gametype->integer) { + if (g_gametype->integer == GT_SINGLE_PLAYER) { return; } @@ -1604,7 +1645,6 @@ void Weapon::GetMuzzlePosition(vec3_t position, vec3_t vBarrelPos, vec3_t forwar int i; owner = (Player *)this->owner.Pointer(); - assert(owner); // We should always have an owner if (!owner) { @@ -1815,7 +1855,7 @@ void Weapon::Shoot(Event *ev) switch (firetype[mode]) { case FT_PROJECTILE: - ProjectileAttack(pos, forward, owner, projectileModel[mode], charge_fraction); + ProjectileAttack(pos, forward, owner, projectileModel[mode], charge_fraction, 0, this); break; case FT_LANDMINE: PlaceLandmine(pos, owner, projectileModel[mode], this); @@ -1834,11 +1874,7 @@ void Weapon::Shoot(Event *ev) if (owner->client) { Player *player = (Player *)owner.Pointer(); - fSpreadFactor = player->velocity.length() / sv_runspeed->integer; - - if (fSpreadFactor > 1.0f) { - fSpreadFactor = 1.0f; - } + fSpreadFactor = GetSpreadFactor(mode); vSpread = bulletspreadmax[mode] * fSpreadFactor; fSpreadFactor = 1.0f - fSpreadFactor; @@ -1855,7 +1891,9 @@ void Weapon::Shoot(Event *ev) vSpread = (bulletspreadmax[mode] + bulletspread[mode]) * 0.5f; } - if (!g_gametype->integer && owner && owner->IsSubclassOfPlayer()) { + // Don't display tracers if the owner is a player for non-turret weapons + // It would have some artifacts for the first person model, as the tracer is created from the world model + if ((g_target_game == TG_MOH || g_gametype->integer == GT_SINGLE_PLAYER) && owner && owner->IsSubclassOfPlayer()) { if (IsSubclassOfTurretGun()) { tracerFrequency = 3; } else { @@ -2003,11 +2041,17 @@ void Weapon::Shoot(Event *ev) break; } - if (!quiet[firemodeindex]) { - if (next_noise_time <= level.time) { - BroadcastAIEvent(AI_EVENT_WEAPON_FIRE); - next_noise_time = level.time + 1; + if (!quiet[mode] && next_noise_time <= level.time) { + if (g_gametype->integer == GT_SINGLE_PLAYER) { + BroadcastAIEvent(AI_EVENT_WEAPON_FIRE, 1500); + } else { + // + // Added in OPM + // Weapon firing sounds can be heard 8000 units away + // (from ubersound.scr) + BroadcastAIEvent(AI_EVENT_WEAPON_FIRE, 8000); } + next_noise_time = level.time + 1; } if (owner && owner->client) { @@ -2334,23 +2378,27 @@ qboolean Weapon::Drop(void) int ammo; if (ammo_clip_size[FIRE_PRIMARY]) { - startammo[FIRE_PRIMARY] = g_dropclips->integer * ammo_in_clip[FIRE_PRIMARY]; + // Fixed in OPM + // Always drop at least 1 because of grenades + startammo[FIRE_PRIMARY] = g_dropclips->integer * Q_max(ammo_in_clip[FIRE_PRIMARY], 1); } else { startammo[FIRE_PRIMARY] = g_dropclips->integer; } - ammo = AmmoAvailable(FIRE_PRIMARY); + // Fixed in OPM + // Use the max between the available ammo and the ammo in clip + ammo = Q_max(AmmoAvailable(FIRE_PRIMARY), ammo_in_clip[FIRE_PRIMARY]); if (startammo[FIRE_PRIMARY] > ammo) { startammo[FIRE_PRIMARY] = ammo; } if (ammo_clip_size[FIRE_SECONDARY]) { - startammo[FIRE_SECONDARY] = g_dropclips->integer * ammo_in_clip[FIRE_SECONDARY]; + startammo[FIRE_SECONDARY] = g_dropclips->integer * Q_max(ammo_in_clip[FIRE_SECONDARY], 1); } else { startammo[FIRE_SECONDARY] = g_dropclips->integer; } - ammo = AmmoAvailable(FIRE_SECONDARY); + ammo = Q_max(AmmoAvailable(FIRE_SECONDARY), ammo_in_clip[FIRE_SECONDARY]); if (startammo[FIRE_SECONDARY] > ammo) { startammo[FIRE_SECONDARY] = ammo; } @@ -2393,7 +2441,10 @@ qboolean Weapon::Drop(void) // Remove this from the owner's item list RemoveFromOwner(); - PostEvent(EV_Remove, g_droppeditemlife->value); + if (g_droppeditemlife->value > 0) { + PostEvent(EV_Remove, g_droppeditemlife->value); + } + PostEvent(EV_Weapon_FallingAngleAdjust, level.frametime); return true; } @@ -2728,7 +2779,7 @@ void Weapon::AttachToHand(Event *ev) //====================== void Weapon::SetCantPartialReload(Event *ev) { - if (g_protocol <= protocol_e::PROTOCOL_MOH && g_gametype->integer) { + if (g_protocol <= protocol_e::PROTOCOL_MOH && g_gametype->integer != GT_SINGLE_PLAYER) { return; } @@ -2740,7 +2791,7 @@ void Weapon::SetCantPartialReload(Event *ev) //====================== void Weapon::SetDMCantPartialReload(Event *ev) { - if (!g_gametype->integer) { + if (g_gametype->integer == GT_SINGLE_PLAYER) { return; } @@ -2773,10 +2824,7 @@ void Weapon::GiveStartingAmmoToOwner(Event *ev) int mode; int i; - assert(owner); - if (!owner) { - warning("Weapon::GiveStartingAmmoToOwner", "Owner not found\n"); return; } @@ -2888,83 +2936,108 @@ void Weapon::PickupWeapon(Event *ev) "print \"" HUD_MESSAGE_YELLOW "%s\n\"", gi.LV_ConvertString(va("Picked Up %s", item_name.c_str())) ); - - if (!(spawnflags & DROPPED_PLAYER_ITEM) && !(spawnflags & DROPPED_ITEM)) { - ItemPickup(other); - return; - } - - if (Pickupable(other)) { - setMoveType(MOVETYPE_NONE); - setSolidType(SOLID_NOT); - - hideModel(); - - velocity = vec_zero; - avelocity = vec_zero; - - CancelEventsOfType(EV_Remove); - CancelEventsOfType(EV_Weapon_FallingAngleAdjust); - - DetachFromOwner(); - current_attachToTag = ""; - lastValid = qfalse; - edict->s.tag_num = -1; - edict->s.attach_use_angles = qfalse; - VectorClear(edict->s.attach_offset); - - setOrigin(vec_zero); - setAngles(vec_zero); - SetOwner(sen); - - sen->AddItem(this); - sen->ReceivedItem(this); - - Sound(sPickupSound); - } } + + if (!(spawnflags & DROPPED_PLAYER_ITEM) && !(spawnflags & DROPPED_ITEM)) { + ItemPickup(other); + return; + } + + if (!Pickupable(other)) { + return; + } + + setMoveType(MOVETYPE_NONE); + setSolidType(SOLID_NOT); + + hideModel(); + + velocity = vec_zero; + avelocity = vec_zero; + + CancelEventsOfType(EV_Remove); + CancelEventsOfType(EV_Weapon_FallingAngleAdjust); + + DetachFromOwner(); + current_attachToTag = ""; + lastValid = qfalse; + edict->s.tag_num = -1; + edict->s.attach_use_angles = qfalse; + VectorClear(edict->s.attach_offset); + + setOrigin(vec_zero); + setAngles(vec_zero); + SetOwner(sen); + + sen->AddItem(this); + sen->ReceivedItem(this); + + iGiveAmmo = startammo[FIRE_PRIMARY]; + + Sound(sPickupSound); } else { - str sAmmoName = ammo_type[FIRE_PRIMARY]; + bool bSameAmmo[MAX_FIREMODES] = { false }; - if (sen->AmmoCount(sAmmoName) != sen->MaxAmmoCount(sAmmoName)) { - setSolidType(SOLID_NOT); - hideModel(); - - CancelEventsOfType(EV_Item_DropToFloor); - CancelEventsOfType(EV_Item_Respawn); - CancelEventsOfType(EV_FadeOut); - CancelEventsOfType(EV_Remove); - CancelEventsOfType(EV_Weapon_FallingAngleAdjust); - - if (Respawnable()) { - PostEvent(EV_Item_Respawn, 0); - } else { - PostEvent(EV_Remove, 0); + if (sen->AmmoCount(ammo_type[FIRE_PRIMARY]) == sen->MaxAmmoCount(ammo_type[FIRE_PRIMARY])) { + bSameAmmo[FIRE_PRIMARY] = true; + if (ammo_type[0] == ammo_type[1]) { + bSameAmmo[FIRE_SECONDARY] = true; } - - Sound(m_sAmmoPickupSound); } + + if (!bSameAmmo[FIRE_SECONDARY]) { + if (sen->AmmoCount(ammo_type[FIRE_SECONDARY]) == sen->MaxAmmoCount(ammo_type[FIRE_SECONDARY])) { + bSameAmmo[FIRE_SECONDARY] = true; + } + } + + if (bSameAmmo[FIRE_PRIMARY] && bSameAmmo[FIRE_SECONDARY]) { + return; + } + + if (bSameAmmo[FIRE_PRIMARY]) { + startammo[FIRE_PRIMARY] = 0; + } + + if (bSameAmmo[FIRE_SECONDARY]) { + startammo[FIRE_SECONDARY] = 0; + } + + iGiveAmmo = ammo_in_clip[FIRE_PRIMARY] + startammo[FIRE_PRIMARY]; + + if (!iGiveAmmo && !startammo[FIRE_SECONDARY]) { + // Fixed in OPM + // Don't let the sentient pick the ammo up if it already has the weapon in inventory + // and the player would get no ammo. + // This can only be picked up as a new weapon. + return; + } + + setSolidType(SOLID_NOT); + hideModel(); + + CancelEventsOfType(EV_Item_DropToFloor); + CancelEventsOfType(EV_Item_Respawn); + CancelEventsOfType(EV_FadeOut); + CancelEventsOfType(EV_Remove); + CancelEventsOfType(EV_Weapon_FallingAngleAdjust); + + if (Respawnable()) { + PostEvent(EV_Item_Respawn, 0); + } else { + PostEvent(EV_Remove, 0); + } + + Sound(m_sAmmoPickupSound); } if (startammo[FIRE_PRIMARY] && ammo_type[FIRE_PRIMARY].length() && other->isClient()) { str sMessage; const str& sAmmoType = ammo_type[FIRE_PRIMARY]; - iGiveAmmo = startammo[FIRE_PRIMARY]; - sen->GiveAmmo(sAmmoType, iGiveAmmo); - if (!g_gametype->integer && other->IsSubclassOfPlayer()) { - if (!sAmmoType.icmp("agrenade")) { - if (iGiveAmmo == 1) { - sMessage = gi.LV_ConvertString("Got 1 Grenade"); - } else { - sMessage = gi.LV_ConvertString(va("Got %i Grenades", iGiveAmmo)); - } - } - } - - if (!sAmmoType.icmp("grenade")) { + if (!sAmmoType.icmp("grenade") || !sAmmoType.icmp("agrenade")) { if (iGiveAmmo == 1) { sMessage = gi.LV_ConvertString("Got 1 Grenade"); } else { @@ -2977,26 +3050,16 @@ void Weapon::PickupWeapon(Event *ev) gi.SendServerCommand(other->edict - g_entities, "print \"" HUD_MESSAGE_YELLOW "%s\n\"", sMessage.c_str()); } - if (ammo_type[FIRE_SECONDARY] != ammo_type[FIRE_PRIMARY]) { + if (ammo_type[FIRE_SECONDARY] != ammo_type[FIRE_PRIMARY] && str::icmp(ammo_type[FIRE_SECONDARY], "none")) { if (startammo[FIRE_SECONDARY] && ammo_type[FIRE_SECONDARY].length() && other->isClient()) { str sMessage; - const str& sAmmoType = ammo_type[FIRE_PRIMARY]; + const str& sAmmoType = ammo_type[FIRE_SECONDARY]; iGiveAmmo = startammo[FIRE_SECONDARY]; sen->GiveAmmo(sAmmoType, iGiveAmmo); - if (!g_gametype->integer && other->IsSubclassOfPlayer()) { - if (!sAmmoType.icmp("agrenade")) { - if (iGiveAmmo == 1) { - sMessage = gi.LV_ConvertString("Got 1 Grenade"); - } else { - sMessage = gi.LV_ConvertString(va("Got %i Grenades", iGiveAmmo)); - } - } - } - - if (!sAmmoType.icmp("grenade")) { + if (!sAmmoType.icmp("grenade") || !sAmmoType.icmp("agrenade")) { if (iGiveAmmo == 1) { sMessage = gi.LV_ConvertString("Got 1 Grenade"); } else { @@ -3028,6 +3091,12 @@ void Weapon::ForceIdle(void) // Force the weapon to the idle animation weaponstate = WEAPON_READY; + + // Fixed in OPM + // Stop the weapon from charging/cooking + CancelEventsOfType(EV_OverCooked); + CancelEventsOfType(EV_OverCooked_Warning); + charge_fraction = 0; } //====================== @@ -3067,7 +3136,8 @@ void Weapon::SetWeaponIdleAnimEvent(Event *ev) //====================== void Weapon::SetWeaponAnimEvent(Event *ev) { - SetWeaponAnim(ev->GetString(1)); + //SetWeaponAnim(ev->GetString(1)); + SetWeaponAnim(ev->GetString(1), EV_Weapon_DoneAnimating); } //====================== @@ -3091,7 +3161,7 @@ qboolean Weapon::SetWeaponAnim(const char *anim, Event *ev) int idleanim = gi.Anim_NumForName(edict->tiki, "idle"); edict->s.frameInfo[m_iAnimSlot].index = idleanim; - m_iAnimSlot = (m_iAnimSlot + 1) & 3; + m_iAnimSlot = (m_iAnimSlot + 1) % MAX_WEAPON_ANIM_SLOTS; edict->s.frameInfo[m_iAnimSlot].index = idleanim; if (ev) { @@ -3129,7 +3199,7 @@ void Weapon::StopWeaponAnim(void) animnum = gi.Anim_NumForName(edict->tiki, "idle"); StartAnimSlot(m_iAnimSlot, animnum, 1.f); - m_iAnimSlot = (m_iAnimSlot + 1) & 3; + m_iAnimSlot = (m_iAnimSlot + 1) % MAX_WEAPON_ANIM_SLOTS; } //====================== @@ -3305,6 +3375,10 @@ void Weapon::DoneReloading(Event *ev) { SetShouldReload(qfalse); weaponstate = WEAPON_READY; + + // Added in OPM + // Set to idle when done reloading + SetWeaponIdleAnim(); } //====================== @@ -3524,7 +3598,7 @@ int Weapon::ClipAmmo(firemode_t mode) //====================== void Weapon::SetFireDelay(Event *ev) { - if (g_protocol <= protocol_e::PROTOCOL_MOH && g_gametype->integer) { + if (g_protocol <= protocol_e::PROTOCOL_MOH && g_gametype->integer != GT_SINGLE_PLAYER) { return; } @@ -3536,7 +3610,7 @@ void Weapon::SetFireDelay(Event *ev) //====================== void Weapon::SetDMFireDelay(Event *ev) { - if (!g_gametype->integer) { + if (g_gametype->integer == GT_SINGLE_PLAYER) { return; } @@ -3617,7 +3691,7 @@ firemode_t Weapon::GetFireMode() //====================== void Weapon::SetProjectile(Event *ev) { - if (g_protocol <= protocol_e::PROTOCOL_MOH && g_gametype->integer) { + if (g_protocol <= protocol_e::PROTOCOL_MOH && g_gametype->integer != GT_SINGLE_PLAYER) { return; } @@ -3631,7 +3705,7 @@ void Weapon::SetProjectile(Event *ev) //====================== void Weapon::SetDMProjectile(Event *ev) { - if (!g_gametype->integer) { + if (g_gametype->integer == GT_SINGLE_PLAYER) { return; } @@ -3670,7 +3744,7 @@ void Weapon::SetTracerSpeed(Event *ev) //====================== void Weapon::SetDMBulletDamage(Event *ev) { - if (!g_gametype->integer) { + if (g_gametype->integer == GT_SINGLE_PLAYER) { return; } @@ -3692,7 +3766,7 @@ void Weapon::SetBulletKnockback(Event *ev) //====================== void Weapon::SetDMBulletKnockback(Event *ev) { - if (!g_gametype->integer) { + if (g_gametype->integer == GT_SINGLE_PLAYER) { return; } @@ -3721,7 +3795,7 @@ void Weapon::SetBulletThroughMetal(Event *ev) //====================== void Weapon::SetBulletRange(Event *ev) { - if (g_protocol <= protocol_e::PROTOCOL_MOH && g_gametype->integer) { + if (g_protocol <= protocol_e::PROTOCOL_MOH && g_gametype->integer != GT_SINGLE_PLAYER) { return; } @@ -3734,7 +3808,7 @@ void Weapon::SetBulletRange(Event *ev) //====================== void Weapon::SetDMBulletRange(Event *ev) { - if (!g_gametype->integer) { + if (g_gametype->integer == GT_SINGLE_PLAYER) { return; } @@ -3755,7 +3829,7 @@ void Weapon::SetRange(Event *ev) //====================== void Weapon::SetBulletCount(Event *ev) { - if (g_protocol <= protocol_e::PROTOCOL_MOH && g_gametype->integer) { + if (g_protocol <= protocol_e::PROTOCOL_MOH && g_gametype->integer != GT_SINGLE_PLAYER) { return; } @@ -3768,7 +3842,7 @@ void Weapon::SetBulletCount(Event *ev) //====================== void Weapon::SetDMBulletCount(Event *ev) { - if (!g_gametype->integer) { + if (g_gametype->integer == GT_SINGLE_PLAYER) { return; } @@ -3781,7 +3855,7 @@ void Weapon::SetDMBulletCount(Event *ev) //====================== void Weapon::SetBulletSpread(Event *ev) { - if (g_protocol <= protocol_e::PROTOCOL_MOH && g_gametype->integer) { + if (g_protocol <= protocol_e::PROTOCOL_MOH && g_gametype->integer != GT_SINGLE_PLAYER) { return; } @@ -3800,7 +3874,7 @@ void Weapon::SetBulletSpread(Event *ev) //====================== void Weapon::SetDMBulletSpread(Event *ev) { - if (!g_gametype->integer) { + if (g_gametype->integer == GT_SINGLE_PLAYER) { return; } @@ -3819,7 +3893,7 @@ void Weapon::SetDMBulletSpread(Event *ev) //====================== void Weapon::SetZoomSpreadMult(Event *ev) { - if (g_protocol <= protocol_e::PROTOCOL_MOH && g_gametype->integer) { + if (g_protocol <= protocol_e::PROTOCOL_MOH && g_gametype->integer != GT_SINGLE_PLAYER) { return; } @@ -3831,7 +3905,7 @@ void Weapon::SetZoomSpreadMult(Event *ev) //====================== void Weapon::SetDMZoomSpreadMult(Event *ev) { - if (!g_gametype->integer) { + if (g_gametype->integer == GT_SINGLE_PLAYER) { return; } @@ -3844,7 +3918,7 @@ void Weapon::SetDMZoomSpreadMult(Event *ev) //====================== void Weapon::SetFireSpreadMult(Event *ev) { - if (g_protocol <= protocol_e::PROTOCOL_MOH && g_gametype->integer) { + if (g_protocol <= protocol_e::PROTOCOL_MOH && g_gametype->integer != GT_SINGLE_PLAYER) { return; } @@ -3860,7 +3934,7 @@ void Weapon::SetFireSpreadMult(Event *ev) //====================== void Weapon::SetDMFireSpreadMult(Event *ev) { - if (!g_gametype->integer) { + if (g_gametype->integer == GT_SINGLE_PLAYER) { return; } @@ -3920,7 +3994,7 @@ void Weapon::Crosshair(Event *ev) //==================== void Weapon::DMCrosshair(Event *ev) { - if (!g_gametype->integer) { + if (g_gametype->integer == GT_SINGLE_PLAYER) { return; } @@ -4149,6 +4223,11 @@ void Weapon::FallingAngleAdjust(Event *ev) //====================== qboolean Weapon::GetUseCrosshair() const { + if (g_protocol < protocol_e::PROTOCOL_MOHTA_MIN) { + // Always show the crosshair in 1.11 and below + return qtrue; + } + if (m_fMaxFireMovement >= 1.f) { return crosshair; } @@ -4220,7 +4299,7 @@ void Weapon::SetViewKick(Event *ev) //====================== void Weapon::SetMovementSpeed(Event *ev) { - if (g_protocol <= protocol_e::PROTOCOL_MOH && g_gametype->integer) { + if (g_protocol <= protocol_e::PROTOCOL_MOH && g_gametype->integer != GT_SINGLE_PLAYER) { return; } @@ -4232,7 +4311,7 @@ void Weapon::SetMovementSpeed(Event *ev) //====================== void Weapon::SetDMMovementSpeed(Event *ev) { - if (!g_gametype->integer) { + if (g_gametype->integer == GT_SINGLE_PLAYER) { return; } @@ -4516,6 +4595,36 @@ float Weapon::GetBulletRange(firemode_t mode) return bulletrange[mode]; } +//====================== +//Weapon::GetSpreadFactor +//====================== +float Weapon::GetSpreadFactor(firemode_t mode) +{ + float fSpreadFactor; + + if (owner && owner->client) { + Player* player = (Player*)owner.Pointer(); + + fSpreadFactor = player->velocity.length() / sv_runspeed->integer; + + if (fSpreadFactor > 1.0f) { + fSpreadFactor = 1.0f; + } + } else { + fSpreadFactor = 0.5f; + } + + return fSpreadFactor; +} + +//====================== +//Weapon::GetChargeFraction +//====================== +float Weapon::GetChargeFraction(void) const +{ + return charge_fraction; +} + //====================== //Weapon::GetScriptOwner //====================== @@ -4523,3 +4632,42 @@ Listener *Weapon::GetScriptOwner(void) { return owner; } + +//====================== +//Weapon::DoneAnimating +//====================== +void Weapon::DoneAnimating(Event* ev) { + // Added in OPM + // Set to idle when done reloading + SetWeaponIdleAnim(); +} + +//====================== +//Weapon::GetMaxFireMovementMult +//====================== +void Weapon::EventGetPutaway(Event* ev) { + // Added in OPM + // Set to idle when done reloading + ev->AddInteger(GetPutaway()); +} + +//====================== +//Weapon::GetMaxFireMovementMult +//====================== +float Weapon::GetMaxFireMovementMult() const { + return m_fMaxFireMovement * m_fMovementSpeed; +} + +//====================== +//Weapon::GetMaxFireMovementMult +//====================== +float Weapon::GetZoomMovement() const { + return m_fZoomMovement * m_fMovementSpeed; +} + +//====================== +//Weapon::GetMaxFireMovement +//====================== +float Weapon::GetMaxFireMovement() const { + return m_fMaxFireMovement; +} diff --git a/code/fgame/weapon.h b/code/fgame/weapon.h index e5f223b9..18e9bf8f 100644 --- a/code/fgame/weapon.h +++ b/code/fgame/weapon.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -25,8 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // class will be usable by any Sentient (players and monsters) as a weapon. // -#ifndef __WEAPON_H__ -#define __WEAPON_H__ +#pragma once #include "g_local.h" #include "item.h" @@ -92,6 +91,8 @@ typedef enum { } \ } +static const unsigned int MAX_WEAPON_ANIM_SLOTS = 4; + class Player; class Weapon : public Item @@ -399,12 +400,12 @@ public: virtual void GetMuzzlePosition( vec3_t position, vec3_t vBarrelPos = NULL, vec3_t forward = NULL, vec3_t right = NULL, vec3_t up = NULL ); - qboolean AutoChange(void); - int ClipAmmo(firemode_t mode); - qboolean IsDroppable(void); - float FireDelay(firemode_t mode); - void SetFireDelay(Event *ev); - void SetDMFireDelay(Event *ev); + qboolean AutoChange(void); + int ClipAmmo(firemode_t mode); + qboolean IsDroppable(void); + virtual float FireDelay(firemode_t mode); + virtual void SetFireDelay(Event *ev); + void SetDMFireDelay(Event *ev); weaponstate_t GetState(void); void ForceState(weaponstate_t state); @@ -454,8 +455,16 @@ public: // Listener *GetScriptOwner(void) override; float GetBulletRange(firemode_t firemode); + float GetSpreadFactor(firemode_t firemode); + float GetChargeFraction(void) const; firemode_t GetFireMode(void); qboolean IsSemiAuto(void); + void DoneAnimating(Event *ev); + void EventGetPutaway(Event *ev); + + float GetMaxFireMovementMult() const; + float GetZoomMovement() const; + float GetMaxFireMovement() const; }; inline void Weapon::Archive(Archiver& arc) @@ -529,8 +538,8 @@ inline void Weapon::Archive(Archiver& arc) arc.ArchiveFloat(&bulletknockback[0]); arc.ArchiveFloat(&bulletknockback[1]); arc.ArchiveFloat(&bulletthroughwood[0]); - arc.ArchiveFloat(&bulletthroughwood[0]); - arc.ArchiveFloat(&bulletthroughmetal[1]); + arc.ArchiveFloat(&bulletthroughwood[1]); + arc.ArchiveFloat(&bulletthroughmetal[0]); arc.ArchiveFloat(&bulletthroughmetal[1]); arc.ArchiveFloat(&projectilespeed[0]); arc.ArchiveFloat(&projectilespeed[1]); @@ -620,5 +629,3 @@ inline void Weapon::Archive(Archiver& arc) } typedef SafePtr WeaponPtr; - -#endif /* weapon.h */ diff --git a/code/fgame/weapturret.cpp b/code/fgame/weapturret.cpp index 9b8a7229..9857ac24 100644 --- a/code/fgame/weapturret.cpp +++ b/code/fgame/weapturret.cpp @@ -73,7 +73,7 @@ Event EV_Turret_P_SetPlayerUsable EV_DEFAULT, "i", "state", - "Sets wether the turret can be used by players. 0 means no, 1 means yes.", + "Sets whether the turret can be used by players. 0 means no, 1 means yes.", EV_NORMAL ); Event EV_Turret_AI_SetAimTarget @@ -309,7 +309,7 @@ Event EV_Turret_SetUsable EV_DEFAULT, "i", "state", - "Sets wether the turret can be used as a weapon. 0 means no, 1 means yes.", + "Sets whether the turret can be used as a weapon. 0 means no, 1 means yes.", EV_NORMAL ); Event EV_Turret_AI_SetBulletSpread @@ -573,7 +573,12 @@ void TurretGun::ThinkIdle(void) m_fIdlePitchSpeed -= level.frametime * 300.0f; - vNewAngles = Vector(angles[0] + level.frametime * m_fIdlePitchSpeed, angles[1], angles[2]); + vNewAngles = Vector( + Q_max(angles[0] + level.frametime * m_fIdlePitchSpeed, m_fMaxIdlePitch), + angles[1], + angles[2] + ); + vNewAngles.AngleVectorsLeft(&vDir); vEnd = origin + vDir * m_vIdleCheckOffset[0]; @@ -643,14 +648,12 @@ void TurretGun::AI_SetTargetAngles(vec3_t vTargAngles, float speed) vTargAngles[1] = m_fStartYaw + m_fMaxYawOffset; } else if (fDiff < -m_fMaxYawOffset) { vTargAngles[1] = m_fStartYaw - m_fMaxYawOffset; - } else { - vTargAngles[1] = m_fStartYaw + fDiff; } fYawDiff = AngleSubtract(vTargAngles[1], angles[1]); fPitchDiff = AngleSubtract(vTargAngles[0], angles[0]); - if (fabs(fPitchDiff) == 0) { + if (speed == 0) { fTurnYawSpeed = m_fTurnSpeed * level.frametime; fTurnPitchSpeed = m_fAIPitchSpeed * level.frametime; } else { @@ -681,10 +684,10 @@ void TurretGun::AI_SetTargetAngles(vec3_t vTargAngles, float speed) if (fabs(fYawDiff) < fTurnYawSpeed) { angles[1] = vTargAngles[1]; - } else if (fPitchDiff > 0) { - angles[1] += fYawDiff; + } else if (fYawDiff > 0) { + angles[1] += fTurnYawSpeed; } else { - angles[1] -= fYawDiff; + angles[1] -= fTurnYawSpeed; } setAngles(angles); @@ -775,7 +778,7 @@ bool TurretGun::AI_CanTarget(const vec3_t pos) yawCap = AngleSubtract(vAngles[1], m_fStartYaw); if (yawCap > m_fMaxYawOffset) { return false; - } else if (yawCap < m_fMaxYawOffset) { + } else if (yawCap < -m_fMaxYawOffset) { return false; } @@ -885,7 +888,7 @@ void TurretGun::P_ThinkActive(void) m_pUserCamera->setAngles(vAngles); m_pUserCamera->SetPositionOffset(m_vViewOffset); - owner->client->ps.camera_flags |= CF_CAMERA_ANGLES_ALLOWOFFSET; + owner->client->ps.camera_flags |= CF_CAMERA_ANGLES_TURRETMODE; Player *player = (Player *)owner.Pointer(); @@ -1238,6 +1241,37 @@ void TurretGun::AI_DoAiming() void TurretGun::AI_DoFiring() { + float minBurstTime, maxBurstTime; + float minBurstDelay, maxBurstDelay; + + if (g_target_game == target_game_e::TG_MOH) { + // + // Removed in 2.0 + // The fire delay is always constant on 1.11 and below + // + if (m_iFiring == 1) { + m_iFiring = 4; + } + + if (IsFiring() && ReadyToFire(FIRE_PRIMARY)) { + Fire(FIRE_PRIMARY); + } + + return; + } + + minBurstTime = m_fMinBurstTime; + maxBurstTime = m_fMaxBurstTime; + minBurstDelay = m_fMinBurstDelay; + maxBurstDelay = m_fMaxBurstDelay; + + if (!maxBurstTime) { + // Added in OPM + // default values if not set + maxBurstTime = minBurstTime = 0.001f; + maxBurstDelay = minBurstDelay = fire_delay[FIRE_PRIMARY] / 10.f; + } + if (m_iFiring == 1) { if (m_fMaxBurstTime > 0) { if (m_fFireToggleTime < level.time) { @@ -1261,16 +1295,22 @@ void TurretGun::AI_DoFiring() void TurretGun::AI_ThinkActive() { + if (!g_ai->integer) { + return; + } + AI_DoAiming(); AI_DoFiring(); } void TurretGun::Think(void) { - if (owner || (!m_bHadOwner && aim_target)) { + if (!owner && (m_bHadOwner || !aim_target)) { + ThinkIdle(); + } else if (owner && owner->IsSubclassOfPlayer()) { P_ThinkActive(); } else { - ThinkIdle(); + AI_ThinkActive(); } } @@ -1280,7 +1320,7 @@ void TurretGun::P_UserAim(usercmd_t *ucmd) vNewCmdAng = Vector(SHORT2ANGLE(ucmd->angles[0]), SHORT2ANGLE(ucmd->angles[1]), SHORT2ANGLE(ucmd->angles[2])); - if (vNewCmdAng[0] || vNewCmdAng[1] || vNewCmdAng[2]) { + if (m_vUserLastCmdAng[0] || m_vUserLastCmdAng[1] || m_vUserLastCmdAng[2]) { m_vUserViewAng[0] += AngleSubtract(vNewCmdAng[0], m_vUserLastCmdAng[0]); m_vUserViewAng[1] += AngleSubtract(vNewCmdAng[1], m_vUserLastCmdAng[1]); m_vUserViewAng[2] += AngleSubtract(vNewCmdAng[2], m_vUserLastCmdAng[2]); @@ -1288,7 +1328,7 @@ void TurretGun::P_UserAim(usercmd_t *ucmd) m_vUserLastCmdAng = vNewCmdAng; - if ((ucmd->buttons & BUTTON_ATTACKLEFT) || (ucmd->buttons & BUTTON_ATTACKRIGHT)) { + if (ucmd->buttons & BUTTON_ATTACKLEFT) { if (m_iFiring == 0) { m_iFiring = 1; } @@ -1460,6 +1500,10 @@ void TurretGun::P_TurretUsed(Player *player) m_vUserViewAng = player->GetViewAngles(); if (fabs(AngleSubtract(m_vUserViewAng[1], angles[1])) <= m_fMaxUseAngle) { + if (player->charge_start_time) { + return; + } + P_TurretBeginUsed(player); flags &= ~FL_THINK; @@ -1607,7 +1651,7 @@ void TurretGun::P_EventDoJitter(Event *ev) void TurretGun::AI_EventBurstFireSettings(Event *ev) { - if (ev->NumArgs() <= 3) { + if (ev->NumArgs() < 4) { return; } @@ -1835,6 +1879,14 @@ void TurretGun::Archive(Archiver& arc) arc.ArchiveFloat(&m_fAISuppressHeight); arc.ArchiveVec3(m_vMuzzlePosition); arc.ArchiveFloat(&m_fMaxUseAngle); + + // + // Added in 2.30 + // Clear the last command angles when loading + // otherwise it would cause the player to face (0,0,0) when loading + if (arc.Loading()) { + m_vUserLastCmdAng = vec_zero; + } } qboolean TurretGun::AI_SetWeaponAnim(const char *anim, Event *ev) @@ -1910,11 +1962,18 @@ void TurretGun::StopWeaponAnim(void) float TurretGun::FireDelay(firemode_t mode) { - if (owner && owner->IsSubclassOfPlayer()) { - return 0.06f; - } else { - return Weapon::FireDelay(mode); + if (g_target_game == target_game_e::TG_MOH) { + // + // Removed in 2.0 + // + // On 1.11 and below, the firedelay for players is always 0.06. + // Some maps like m1l1 sets the turret firedelay higher for AI + if (owner && owner->IsSubclassOfPlayer()) { + return 0.06f; + } } + + return fire_delay[mode]; } void TurretGun::SetFireDelay(Event *ev) @@ -2089,7 +2148,7 @@ void TurretGun::GetMuzzlePosition(vec3_t position, vec3_t vBarrelPos, vec3_t for VectorCopy(position, vBarrelPos); } - delta = viewer->GunTarget(position) - position; + delta = viewer->GunTarget(false, position) - position; aim_angles = delta.toAngles(); if (IsSubclassOfVehicleTurretGun()) { diff --git a/code/fgame/weapturret.h b/code/fgame/weapturret.h index 1b200081..6646dbf9 100644 --- a/code/fgame/weapturret.h +++ b/code/fgame/weapturret.h @@ -200,8 +200,8 @@ public: void StopWeaponAnim() override; bool AI_CanTarget(const vec3_t org); - virtual float FireDelay(firemode_t mode); - virtual void SetFireDelay(Event *ev); // added in 2.0 + virtual float FireDelay(firemode_t mode) override; + virtual void SetFireDelay(Event *ev) override; // added in 2.0 void ShowInfo(float fDot, float fDist) override; // added in 2.0 diff --git a/code/fgame/weaputils.cpp b/code/fgame/weaputils.cpp index 166e74d9..62acae3e 100644 --- a/code/fgame/weaputils.cpp +++ b/code/fgame/weaputils.cpp @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -168,7 +168,7 @@ qboolean MeleeAttack( victim->Damage(attacker, attacker, damage, pos, dir, vec_zero, knockback, 0, means_of_death); - if (victim->edict->r.contents & CONTENTS_SOLID) { + if (!(victim->edict->r.contents & CONTENTS_CLAYPIDGEON)) { victim->Sound("pistol_hit"); } } @@ -602,6 +602,7 @@ Projectile::Projectile() return; } + minlife = 0; m_beam = NULL; speed = 0; minspeed = 0; @@ -621,19 +622,22 @@ Projectile::Projectile() impactmarkradius = 10; charge_fraction = 1.0; target = NULL; + addownervelocity = false; fDrunk = 0; fDrunkRate = 0; - m_iSmashThroughGlass = 0; - addownervelocity = qtrue; can_hit_owner = false; remove_when_stopped = false; m_bExplodeOnTouch = false; m_bHurtOwnerOnly = false; + m_iSmashThroughGlass = 0; takedamage = DAMAGE_NO; owner = ENTITYNUM_NONE; edict->r.ownerNum = ENTITYNUM_NONE; - m_bArcToTarget = false; - m_bDieInWater = false; + + // Added in 2.0 + m_bArcToTarget = false; + // Added in 2.30 + m_bDieInWater = false; // make this shootable but non-solid on the client setContents(CONTENTS_SHOOTONLY); @@ -643,7 +647,9 @@ Projectile::Projectile() // flags |= FL_TOUCH_TRIGGERS; - m_iTeam = 0; + m_iTeam = 0; + + // Added in OPM m_bHadPlayerOwner = false; } @@ -892,11 +898,13 @@ void Projectile::Explode(Event *ev) // Move the projectile back off the surface a bit so we can see // explosion effects. Vector dir, v; - v = velocity; - v.normalize(); - dir = v; - v = origin - v * 36; - setOrigin(v); + dir = velocity; + if (dir.normalize() == 0) { + vec3_t forward; + AngleVectors(angles, forward, NULL, NULL); + dir = forward; + } + v = origin; ExplosionAttack(v, owner, explosionmodel, dir, ignoreEnt, 1.0f, weap, m_bHurtOwnerOnly); } @@ -932,6 +940,13 @@ void Projectile::SetSmashThroughGlass(Event *ev) } void Projectile::SmashThroughGlassThink(Event *ev) +{ + SmashThroughGlassThink(); + + PostEvent(EV_Projectile_SmashThroughGlass, level.frametime); +} + +void Projectile::SmashThroughGlassThink() { if (velocity.length() > m_iSmashThroughGlass) { Vector vEnd; @@ -953,8 +968,6 @@ void Projectile::SmashThroughGlassThink(Event *ev) } } } - - PostEvent(EV_Projectile_SmashThroughGlass, level.frametime); } void Projectile::BeamCommand(Event *ev) @@ -1008,7 +1021,13 @@ void Projectile::SetBounceSoundWater(Event *ev) void Projectile::SetChargeLife(Event *ev) { - projFlags |= P_CHARGE_LIFE; + if (ev->NumArgs() <= 0 || ev->GetInteger(1)) { + projFlags |= P_CHARGE_LIFE; + } else { + // Added in 2.0 + // Allow disabling the charge life when set to 0 + projFlags &= ~P_CHARGE_LIFE; + } } void Projectile::SetFuse(Event *ev) @@ -1023,7 +1042,13 @@ void Projectile::SetFuse(Event *ev) void Projectile::SetMinLife(Event *ev) { minlife = ev->GetFloat(1); - projFlags |= P_CHARGE_LIFE; + if (minlife > 0) { + projFlags |= P_CHARGE_LIFE; + } else { + // Added in 2.0 + // Allow disabling the charge life when set to 0 + projFlags &= ~P_CHARGE_LIFE; + } } void Projectile::SetLife(Event *ev) @@ -1144,6 +1169,7 @@ void Projectile::Touch(Event *ev) // Bouncy Projectile if ((projFlags & P_BOUNCE_TOUCH)) { str snd; + int flags; if (level.time - fLastBounceTime < 0.1f) { fLastBounceTime = level.time; @@ -1155,49 +1181,60 @@ void Projectile::Touch(Event *ev) if (bouncesound_water.length()) { this->Sound(bouncesound_water, CHAN_BODY); } - } else { - if (bouncesound_metal.length()) { - snd = bouncesound_metal; - } else if (bouncesound_hard.length()) { - snd = bouncesound_hard; - } else { - snd = bouncesound; + + // + // Added in 2.30 + // + if (m_bDieInWater) { + PostEvent(EV_Remove, 0.5f); } - int flags = level.impact_trace.surfaceFlags; + return; + } - if (flags & SURF_MUD) { - if (bouncesound.length()) { - Sound(bouncesound, CHAN_BODY); - } - } else if (flags & SURF_ROCK) { - if (bouncesound_hard.length()) { - Sound(bouncesound_hard, CHAN_BODY); - } - } else if (flags & SURF_GRILL) { - if (bouncesound_metal.length()) { - Sound(bouncesound_metal, CHAN_BODY); - } - } else if (flags & SURF_WOOD) { - if (bouncesound_hard.length()) { - Sound(bouncesound_hard, CHAN_BODY); - } - } else if (flags & SURF_METAL) { - if (bouncesound_metal.length()) { - Sound(bouncesound_metal, CHAN_BODY); - } - } else if (flags & SURF_GLASS) { - if (bouncesound_hard.length()) { - Sound(bouncesound_hard, CHAN_BODY); - } - } else { - if (bouncesound.length()) { - Sound(bouncesound, CHAN_BODY); - } + if (bouncesound_metal.length()) { + snd = bouncesound_metal; + } else if (bouncesound_hard.length()) { + snd = bouncesound_hard; + } else { + snd = bouncesound; + } + + flags = level.impact_trace.surfaceFlags; + + if (flags & SURF_MUD) { + if (bouncesound.length()) { + Sound(bouncesound, CHAN_BODY); + } + } else if (flags & SURF_ROCK) { + if (bouncesound_hard.length()) { + Sound(bouncesound_hard, CHAN_BODY); + } + } else if (flags & SURF_GRILL) { + if (bouncesound_metal.length()) { + Sound(bouncesound_metal, CHAN_BODY); + } + } else if (flags & SURF_WOOD) { + if (bouncesound_hard.length()) { + Sound(bouncesound_hard, CHAN_BODY); + } + } else if (flags & SURF_METAL) { + if (bouncesound_metal.length()) { + Sound(bouncesound_metal, CHAN_BODY); + } + } else if (flags & SURF_GLASS) { + if (bouncesound_hard.length()) { + Sound(bouncesound_hard, CHAN_BODY); + } + } else { + if (bouncesound.length()) { + Sound(bouncesound, CHAN_BODY); } } BroadcastAIEvent(AI_EVENT_WEAPON_IMPACT); + fLastBounceTime = level.time; + return; } @@ -1222,21 +1259,21 @@ void Projectile::Touch(Event *ev) other->Damage( this, owner, damage, origin, velocity, level.impact_trace.plane.normal, knockback, 0, meansofdeath ); - } - if (!g_gametype->integer && weap) { - if (other->IsSubclassOfPlayer() || other->IsSubclassOfVehicle() || other->IsSubclassOfVehicleTank() - || other->isSubclassOf(VehicleCollisionEntity)) { - weap->m_iNumHits++; - weap->m_iNumTorsoShots++; + if (g_gametype->integer == GT_SINGLE_PLAYER && weap) { + if (other->IsSubclassOfSentient() || other->IsSubclassOfVehicle() || other->IsSubclassOfVehicleTank() + || other->isSubclassOf(VehicleCollisionEntity)) { + weap->m_iNumHits++; + weap->m_iNumTorsoShots++; - if (weap->IsSubclassOfVehicleTurretGun()) { - VehicleTurretGun *t = (VehicleTurretGun *)weap.Pointer(); - Player *p = (Player *)t->GetRemoteOwner().Pointer(); + if (weap->IsSubclassOfVehicleTurretGun()) { + VehicleTurretGun *t = (VehicleTurretGun *)weap.Pointer(); + Player *p = (Player *)t->GetRemoteOwner().Pointer(); - if (p && p->IsSubclassOfPlayer()) { - p->m_iNumHits++; - p->m_iNumTorsoShots++; + if (p && p->IsSubclassOfPlayer()) { + p->m_iNumHits++; + p->m_iNumTorsoShots++; + } } } } @@ -1264,6 +1301,33 @@ void Projectile::Touch(Event *ev) explEv = new Event(EV_Projectile_Explode); explEv->AddEntity(other); ProcessEvent(explEv); + + // + // Added in 2.30 + // Check for projectile vulnerability + // + + Vehicle *pVehicle = NULL; + + if (other->IsSubclassOfVehicle()) { + pVehicle = static_cast(other); + } else if (other->IsSubclassOfVehicleTurretGun()) { + VehicleTurretGun *pTurret = static_cast(other); + Entity *pEnt = pTurret->GetVehicle(); + if (pEnt && pEnt->IsSubclassOfVehicle()) { + pVehicle = static_cast(pEnt); + } + } else if (other->isSubclassOf(VehicleCollisionEntity)) { + VehicleCollisionEntity *pCollision = static_cast(other); + + if (pCollision && pCollision->GetOwner()->IsSubclassOfVehicle()) { + pVehicle = static_cast(pCollision->GetOwner()); + } + } + + if (pVehicle && pVehicle->GetProjectileHitsRemaining() > 0) { + pVehicle->DoProjectileVulnerability(this, owner, meansofdeath); + } } void Projectile::SetCanHitOwner(Event *ev) @@ -1306,7 +1370,7 @@ void Projectile::SetOwner(Entity *owner) if (owner->IsSubclassOfPlayer()) { Player *p = (Player *)owner; m_iTeam = p->GetTeam(); - // Added in OPM + // Added in OPM // this was added to prevent glitches, like when the player // disconnects or when the player spectates m_bHadPlayerOwner = true; @@ -1493,6 +1557,11 @@ Explosion::Explosion() return; } + flash_r = 0; + flash_g = 0; + flash_b = 0; + flash_a = 0; + flash_radius = 0; radius = 0; constant_damage = false; damage_every_frame = false; @@ -1804,7 +1873,7 @@ void PlaceLandmine(const Vector& origin, Entity *owner, const str& model, Weapon weap->m_iNumShotsFired++; if (owner && owner->IsSubclassOfPlayer() && weap->IsSubclassOfTurretGun()) { - Player* p = static_cast(owner); + Player *p = static_cast(owner); p->m_iNumShotsFired++; } } @@ -1828,6 +1897,11 @@ Projectile *ProjectileAttack( } args.setArg("model", projectileModel); + // Added in 2.0 + // Set the projectile targetname + // so they can be managed from scripts + args.setArg("targetname", "projectile"); + obj = (Entity *)args.Spawn(); if (!obj) { @@ -1849,9 +1923,9 @@ Projectile *ProjectileAttack( proj->setMoveType(MOVETYPE_BOUNCE); proj->ProcessInitCommands(); proj->SetOwner(owner); - proj->edict->r.ownerNum = owner->entnum; proj->angles = dir.toAngles(); proj->charge_fraction = fraction; + proj->weap = weap; if (!real_speed) { if (proj->projFlags & P_CHARGE_SPEED) { @@ -2072,6 +2146,7 @@ float BulletAttack( { Vector vDir; Vector vTmpEnd; + Vector vOldTmpEnd; Vector vTraceStart; Vector vTraceEnd; int i; @@ -2085,7 +2160,7 @@ float BulletAttack( qboolean bBulletDone; qboolean bThroughThing; int iContinueCount; - float vEndArray[64][3]; + vec3_t vEndArray[64]; int iTracerCount = 0; int iNumHit; int lastSurfaceFlags; @@ -2133,12 +2208,15 @@ float BulletAttack( iTravelDist += MAX_TRAVEL_DIST; vTraceStart = start; vTraceEnd = start + vDir * iTravelDist; + vOldTmpEnd = vTraceStart; memset(&trace, 0, sizeof(trace_t)); oldfrac = -1; while (trace.fraction < 1.0f) { + Vector vDeltaTrace; + trace = G_Trace( vTraceStart, vec_zero, vec_zero, vTraceEnd, newowner, MASK_SHOT_TRIG, false, "BulletAttack", true ); @@ -2194,6 +2272,11 @@ float BulletAttack( } newdamage -= damage * bulletdist * throughThingFrac; + + if (g_showbullettrace->integer) { + gi.Printf("%.2f\n", newdamage); + } + if (newdamage < 1.f) { vTmpEnd = vTraceStart + vDir * -4; trace.fraction = 1.f; @@ -2239,10 +2322,10 @@ float BulletAttack( ent = NULL; } - if (ent && ent != world && ent != newowner) { + if (ent && ent != world && ent != owner) { if (ent->takedamage) { if (g_gametype->integer == GT_SINGLE_PLAYER && !iNumHit) { - BulletAttack_Stat(newowner, ent, &trace, weap); + BulletAttack_Stat(owner, ent, &trace, weap); } iNumHit++; @@ -2253,7 +2336,7 @@ float BulletAttack( ent->Damage( world, - newowner, + owner, newdamage, trace.endpos, dir, @@ -2272,16 +2355,16 @@ float BulletAttack( if (ent->edict->solid == SOLID_BBOX && !(trace.contents & CONTENTS_CLAYPIDGEON)) { if (trace.surfaceFlags & MASK_SURF_TYPE) { gi.SetBroadcastVisible(vTmpEnd, NULL); - gi.MSG_StartCGM(CGM_BULLET_6); + gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_BULLET_6)); gi.MSG_WriteCoord(vTmpEnd[0]); gi.MSG_WriteCoord(vTmpEnd[1]); gi.MSG_WriteCoord(vTmpEnd[2]); gi.MSG_WriteDir(trace.plane.normal); gi.MSG_WriteBits(bulletlarge, bulletbits); gi.MSG_EndCGM(); - } else if (trace.location >= 0 && ent->IsSubclassOfPlayer()) { + } else if (trace.location >= 0 && ent->IsSubclassOfSentient()) { gi.SetBroadcastVisible(vTmpEnd, NULL); - gi.MSG_StartCGM(CGM_BULLET_8); + gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_BULLET_8)); gi.MSG_WriteCoord(vTmpEnd[0]); gi.MSG_WriteCoord(vTmpEnd[1]); gi.MSG_WriteCoord(vTmpEnd[2]); @@ -2290,7 +2373,7 @@ float BulletAttack( gi.MSG_EndCGM(); } else if (ent->edict->r.contents & CONTENTS_SOLID) { gi.SetBroadcastVisible(vTmpEnd, NULL); - gi.MSG_StartCGM(CGM_BULLET_7); + gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_BULLET_7)); gi.MSG_WriteCoord(vTmpEnd[0]); gi.MSG_WriteCoord(vTmpEnd[1]); gi.MSG_WriteCoord(vTmpEnd[2]); @@ -2300,7 +2383,7 @@ float BulletAttack( } } else if (ent->edict->solid == SOLID_BSP && !(trace.contents & CONTENTS_CLAYPIDGEON)) { gi.SetBroadcastVisible(vTmpEnd, NULL); - gi.MSG_StartCGM(CGM_BULLET_6); + gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_BULLET_6)); gi.MSG_WriteCoord(vTmpEnd[0]); gi.MSG_WriteCoord(vTmpEnd[1]); gi.MSG_WriteCoord(vTmpEnd[2]); @@ -2313,11 +2396,13 @@ float BulletAttack( if (trace.fraction < 1.0f) { if (trace.surfaceFlags & (SURF_FOLIAGE | SURF_GLASS | SURF_PUDDLE | SURF_PAPER) || trace.contents & (CONTENTS_CLAYPIDGEON | CONTENTS_WATER) - || (bulletlarge && trace.ent && trace.ent->r.contents & CONTENTS_BBOX && !trace.ent->r.bmodel - && trace.ent->entity->takedamage) + || (g_protocol < protocol_e::PROTOCOL_MOHTA && trace.startsolid) + || (bulletlarge && trace.ent + && (g_protocol < protocol_e::PROTOCOL_MOHTA || (trace.ent->r.contents & CONTENTS_BBOX)) + && !trace.ent->r.bmodel && trace.ent->entity->takedamage) || ((trace.surfaceFlags & SURF_WOOD) && bulletthroughwood) - || ((trace.surfaceFlags & (SURF_GRILL | SURF_METAL)) && bulletthroughmetal) - && iContinueCount < 5) { + || ((trace.surfaceFlags & (SURF_GRILL | SURF_METAL)) && bulletthroughmetal && iContinueCount < 5 + )) { if (((trace.surfaceFlags & SURF_WOOD) && bulletthroughwood) || ((trace.surfaceFlags & (SURF_GRILL | SURF_METAL)) && bulletthroughmetal)) { if (trace.contents & CONTENTS_FENCE) { @@ -2341,7 +2426,7 @@ float BulletAttack( VectorAdd(tracethrough.endpos, vTmpEnd, tracethrough.endpos); } } else { - trace.fraction = 1.f; + trace.fraction = 1; bBulletDone = qtrue; if (g_showbullettrace->integer) { @@ -2374,16 +2459,27 @@ float BulletAttack( iContinueCount++; } } else { - trace.fraction = 1.f; + trace.fraction = 1; bBulletDone = qtrue; } - - if (oldfrac != trace.fraction) { - oldfrac = trace.fraction; - } else { - trace.fraction = 1.f; - } } + + if (oldfrac != trace.fraction) { + oldfrac = trace.fraction; + } else { + trace.fraction = 1; + } + + vDeltaTrace = vTmpEnd - vOldTmpEnd; + if (!bBulletDone && DotProduct(vDeltaTrace, vDir) < 0) { + // Fixed in OPM + // Make sure the new trace doesn't start behind the last one + // This can happen in rare circumstances if the trace is out of the world limit + // Or if entities being shot are almost at the same origin + break; + } + + vOldTmpEnd = vTmpEnd; } } @@ -2399,7 +2495,7 @@ float BulletAttack( ); } - VectorCopy(vTraceEnd, vEndArray[i]); + VectorCopy(vTmpEnd, vEndArray[i]); if (iTracerFrequency && piTracerCount) { (*piTracerCount)++; @@ -2428,25 +2524,25 @@ float BulletAttack( } } - gi.SetBroadcastVisible(start, trace.endpos); + gi.SetBroadcastVisible(start, vEndArray[0]); if (count == 1) { if (iTracerCount) { - gi.MSG_StartCGM(CGM_BULLET_1); + gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_BULLET_1)); gi.MSG_WriteCoord(vBarrel[0]); gi.MSG_WriteCoord(vBarrel[1]); gi.MSG_WriteCoord(vBarrel[2]); } else { - gi.MSG_StartCGM(CGM_BULLET_2); + gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_BULLET_2)); } gi.MSG_WriteCoord(start[0]); gi.MSG_WriteCoord(start[1]); gi.MSG_WriteCoord(start[2]); - gi.MSG_WriteCoord(trace.endpos[0]); - gi.MSG_WriteCoord(trace.endpos[1]); - gi.MSG_WriteCoord(trace.endpos[2]); + gi.MSG_WriteCoord(vEndArray[0][0]); + gi.MSG_WriteCoord(vEndArray[0][1]); + gi.MSG_WriteCoord(vEndArray[0][2]); gi.MSG_WriteBits(bulletlarge, bulletbits); if (g_protocol >= protocol_e::PROTOCOL_MOHTA_MIN) { @@ -2463,7 +2559,7 @@ float BulletAttack( } } else { if (iTracerCount) { - gi.MSG_StartCGM(CGM_BULLET_3); + gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_BULLET_3)); gi.MSG_WriteCoord(vBarrel[0]); gi.MSG_WriteCoord(vBarrel[1]); @@ -2475,7 +2571,7 @@ float BulletAttack( gi.MSG_WriteBits(Q_min(iTracerCount, 63), 6); } else { - gi.MSG_StartCGM(CGM_BULLET_4); + gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_BULLET_4)); } gi.MSG_WriteCoord(start[0]); @@ -2487,8 +2583,12 @@ float BulletAttack( if (tracerspeed == 1.f) { gi.MSG_WriteBits(0, 1); } else { + int speed; + + speed = tracerspeed * (1 << 9); + gi.MSG_WriteBits(1, 1); - gi.MSG_WriteBits(Q_clamp(tracerspeed, 1, 1023), 10); + gi.MSG_WriteBits(Q_clamp(speed, 1, 1023), 10); } } @@ -2574,8 +2674,12 @@ void FakeBulletAttack( if (tracerspeed == 1.f) { gi.MSG_WriteBits(0, 1); } else { + int speed; + + speed = tracerspeed * (1 << 9); + gi.MSG_WriteBits(1, 1); - gi.MSG_WriteBits(Q_clamp(tracerspeed, 1, 1023), 10); + gi.MSG_WriteBits(Q_clamp(speed, 1, 1023), 10); } } @@ -2585,30 +2689,37 @@ void FakeBulletAttack( void ClickItemAttack(Vector vStart, Vector vForward, float fRange, Entity *pOwner) { + Event *ev; Vector vEnd; trace_t trace; vEnd = vStart + vForward * fRange; - trace = G_Trace(vStart, vec_zero, vec_zero, vEnd, pOwner, MASK_ALL, qfalse, "ClickItemAttack"); + trace = G_Trace(vStart, vec_zero, vec_zero, vEnd, pOwner, MASK_CLICKITEM, qfalse, "ClickItemAttack"); if (g_showbullettrace->integer) { - G_DebugLine(vStart, vEnd, 1, 1, 1, 1); + //G_DebugLine(vStart, vEnd, 1, 1, 1, 1); + // Added in OPM + // White line between start and end trace position + G_DebugLine(vStart, trace.endpos, 1, 1, 1, 1); + G_DebugLine(trace.endpos, vEnd, 1, 0, 0, 1); } - if (trace.entityNum != ENTITYNUM_NONE && trace.ent && trace.ent->entity - && trace.ent->entity->isSubclassOf(TriggerClickItem)) { - Event *ev = new Event(EV_Activate); - ev->AddEntity(pOwner); - trace.ent->entity->PostEvent(ev, 0); - } else { + if (trace.entityNum == ENTITYNUM_WORLD || !trace.ent || !trace.ent->entity + || !trace.ent->entity->isSubclassOf(TriggerClickItem)) { ScriptThreadLabel failThread; // Try to execute a fail thread if (failThread.TrySet("clickitem_fail")) { failThread.Execute(); } + + return; } + + ev = new Event(EV_Activate); + ev->AddEntity(pOwner); + trace.ent->entity->PostEvent(ev, 0); } Projectile *HeavyAttack(Vector start, Vector dir, str projectileModel, float real_speed, Entity *owner, Weapon *weap) @@ -2692,7 +2803,7 @@ Projectile *HeavyAttack(Vector start, Vector dir, str projectileModel, float rea // Calc the life of the projectile if (proj->projFlags & P_CHARGE_LIFE) { - if (g_gametype->integer && proj->dmlife) { + if (g_gametype->integer != GT_SINGLE_PLAYER && proj->dmlife) { newlife = proj->dmlife; } else { newlife = proj->life; @@ -2702,7 +2813,7 @@ Projectile *HeavyAttack(Vector start, Vector dir, str projectileModel, float rea newlife = proj->minlife; } } else { - if (g_gametype->integer && proj->dmlife) { + if (g_gametype->integer != GT_SINGLE_PLAYER && proj->dmlife) { newlife = proj->dmlife; } else { newlife = proj->life; @@ -2715,7 +2826,7 @@ Projectile *HeavyAttack(Vector start, Vector dir, str projectileModel, float rea proj->NewAnim("idle"); - if (!g_gametype->integer) { + if (g_gametype->integer == GT_SINGLE_PLAYER) { if (weap) { weap->m_iNumShotsFired++; if (owner->IsSubclassOfPlayer() && weap->IsSubclassOfTurretGun()) { @@ -2845,10 +2956,10 @@ void ExplosionAttack( } // Remove explosion after the life has expired - if (explosion->life || (g_gametype->integer && explosion->dmlife)) { + if (explosion->life || (g_gametype->integer != GT_SINGLE_PLAYER && explosion->dmlife)) { ev = new Event(EV_Remove); - if (g_gametype->integer && explosion->dmlife) { + if (g_gametype->integer != GT_SINGLE_PLAYER && explosion->dmlife) { explosion->PostEvent(ev, explosion->dmlife); } else { explosion->PostEvent(ev, explosion->life); diff --git a/code/fgame/weaputils.h b/code/fgame/weaputils.h index f854c412..2cff35ed 100644 --- a/code/fgame/weaputils.h +++ b/code/fgame/weaputils.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2015 the OpenMoHAA team +Copyright (C) 2024 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -23,8 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // weaputils.h: // -#ifndef __WEAPUTILS_H__ -#define __WEAPUTILS_H__ +#pragma once #include "g_local.h" #include "animate.h" @@ -82,11 +81,18 @@ public: bool m_bExplodeOnTouch; bool m_bHurtOwnerOnly; int m_iSmashThroughGlass; + // Added in 2.0 bool m_bArcToTarget; + // Added in 2.30 bool m_bDieInWater; + // Added in 2.0 int m_iTeam; + + // + // Added in OPM + // bool m_bHadPlayerOwner; - SafePtr m_pOwnerPtr; + SafePtr m_pOwnerPtr; Projectile(); void Archive( Archiver &arc ) override; @@ -125,6 +131,7 @@ public: void HeatSeek( Event *ev ); void Drunk( Event *ev ); void SmashThroughGlassThink( Event *ev ); + void SmashThroughGlassThink(); // Added in OPM void AddOwnerVelocity( Event *ev ); void Prethink( Event *ev ); float ResolveMinimumDistance( Entity *potential_target, float currmin ); @@ -144,7 +151,7 @@ public: // // Added in OPM // - bool CheckTeams( void ); + bool CheckTeams(void); }; inline void Projectile::SetMartyr(int entnum) @@ -361,5 +368,3 @@ Entity* FindDefusableObject(const Vector& dir, Entity* owner, float maxdist); void DefuseObject(const Vector& dir, Entity* owner, float maxdist); qboolean CanPlaceLandmine(const Vector& origin, Entity* owner); void PlaceLandmine(const Vector& origin, Entity* owner, const str& model, Weapon* weap); - -#endif // __WEAPUTILS_H__ diff --git a/code/fgame/windows.cpp b/code/fgame/windows.cpp index c0ce66e0..b485987c 100644 --- a/code/fgame/windows.cpp +++ b/code/fgame/windows.cpp @@ -55,6 +55,16 @@ CLASS_DECLARATION(Entity, WindowObject, "func_window") { WindowObject::WindowObject() { + if (LoadingSavegame) { + return; + } + + edict->s.eType = ET_GENERAL; + health = 250; + max_health = health; + deadflag = 0; + takedamage = DAMAGE_YES; + m_iDebrisType = WINDOW_GLASS; PostEvent(EV_Window_Setup, EV_POSTSPAWN); @@ -72,24 +82,22 @@ void WindowObject::WindowSetup(Event *ev) { Entity *pEnt; + setMoveType(MOVETYPE_NONE); setSolidType(SOLID_BSP); + setContents(CONTENTS_TRIGGER); if (Target().length()) { + // If a target is defined, + // find it and set the model from it pEnt = (Entity *)G_FindTarget(NULL, Target()); if (pEnt) { - // set the broken model to the target model m_sBrokenModel = pEnt->model; + // Don't keep the original entity pEnt->PostEvent(EV_Remove, 0); } } - - takedamage = DAMAGE_YES; - - if (health <= 0.1f) { - health = 100.0f; - } } void WindowObject::WindowDebrisType(Event *ev) @@ -118,7 +126,7 @@ void WindowObject::WindowDamaged(Event *ev) iDamage *= 2; } else if (iMeansOfDeath == MOD_EXPLOSION) { // instant break - iDamage = health; + iDamage *= 10; } health -= iDamage; @@ -143,7 +151,8 @@ void WindowObject::WindowKilled(Event *ev) hideModel(); takedamage = DAMAGE_NO; - vCenter = origin + mins + maxs; + vCenter = (mins + maxs) * 0.5; + vCenter += origin; gi.SetBroadcastVisible(vCenter, vCenter); gi.MSG_StartCGM(BG_MapCGMToProtocol(g_protocol, CGM_MAKE_WINDOW_DEBRIS)); diff --git a/code/fgame/worldspawn.cpp b/code/fgame/worldspawn.cpp index cd677728..cbe476fc 100644 --- a/code/fgame/worldspawn.cpp +++ b/code/fgame/worldspawn.cpp @@ -627,6 +627,12 @@ World::World() m_fNorth = 0; } +World::~World() +{ + world_dying = false; + FreeTargetList(); +} + void World::UpdateConfigStrings(void) { // @@ -920,16 +926,17 @@ void World::GetRenderTerrain(Event *ev) void World::SetRenderTerrain(Event *ev) { render_terrain = ev->GetInteger(1); + UpdateFog(); } void World::GetSkyboxSpeed(Event *ev) { - ev->AddInteger(skybox_speed); + ev->AddFloat(skybox_speed); } void World::SetSkyboxSpeed(Event *ev) { - skybox_speed = ev->GetInteger(1); + skybox_speed = ev->GetFloat(1); } void World::SetSkyAlpha(Event *ev) @@ -993,24 +1000,23 @@ void World::SetNorthYaw(Event *ev) m_fNorth = anglemod(ev->GetFloat(1)); } -SimpleEntity *World::GetTarget(str targetname, bool quiet) +Listener *World::GetTarget(str targetname, bool quiet) { - return GetTarget(Director.AddString(targetname), quiet); -} + TargetList *targetList = GetTargetList(targetname); -SimpleEntity *World::GetTarget(const_str targetname, bool quiet) -{ - ConSimple *list = GetTargetList(targetname); + if (!targetList) { + return NULL; + } - if (list->NumObjects() == 1) { - return list->ObjectAt(1); - } else if (list->NumObjects() > 1) { + if (targetList->list.NumObjects() == 1) { + return targetList->list.ObjectAt(1); + } else if (targetList->list.NumObjects() > 1) { if (!quiet) { warning( "World::GetTarget", "There are %d entities with targetname '%s'. You are using a command that requires exactly one.", - list->NumObjects(), - Director.GetString(targetname).c_str() + targetList->list.NumObjects(), + targetname.c_str() ); } } @@ -1018,79 +1024,101 @@ SimpleEntity *World::GetTarget(const_str targetname, bool quiet) return NULL; } -SimpleEntity *World::GetScriptTarget(str targetname) +Listener *World::GetScriptTarget(str targetname) { - return GetScriptTarget(Director.AddString(targetname)); -} + TargetList *targetList = GetTargetList(targetname); -SimpleEntity *World::GetScriptTarget(const_str targetname) -{ - ConSimple *list = GetTargetList(targetname); + if (!targetList) { + return NULL; + } - if (list->NumObjects() == 1) { - return list->ObjectAt(1); - } else if (list->NumObjects() > 1) { + if (targetList->list.NumObjects() == 1) { + return targetList->list.ObjectAt(1); + } else if (targetList->list.NumObjects() > 1) { ScriptError( "There are %d entities with targetname '%s'. You are using a command that requires exactly one.", - list->NumObjects(), - Director.GetString(targetname).c_str() + targetList->list.NumObjects(), + targetname.c_str() ); } return NULL; } -ConSimple *World::GetExistingTargetList(const str& targetname) +TargetList *World::GetExistingTargetList(const str& targetname) { - return GetExistingTargetList(Director.AddString(targetname)); + TargetList *targetList; + int i; + + if (!targetname.length()) { + return NULL; + } + + for (i = m_targetListContainer.NumObjects(); i > 0; i--) { + targetList = m_targetListContainer.ObjectAt(i); + if (targetname == targetList->targetname) { + return targetList; + } + } + + return NULL; } -ConSimple *World::GetExistingTargetList(const_str targetname) +TargetList *World::GetTargetList(str& targetname) { - return m_targetList.findKeyValue(targetname); -} + TargetList *targetList; + int i; -ConSimple *World::GetTargetList(str& targetname) -{ - return GetTargetList(Director.AddString(targetname)); -} + if (!targetname.length()) { + // Fixed in OPM + // Don't create a targetlist for the empty target name + return NULL; + } -ConSimple *World::GetTargetList(const_str targetname) -{ - return &m_targetList.addKeyValue(targetname); + for (i = m_targetListContainer.NumObjects(); i > 0; i--) { + targetList = m_targetListContainer.ObjectAt(i); + if (targetname == targetList->targetname) { + return targetList; + } + } + + targetList = new TargetList(targetname); + m_targetListContainer.AddObject(targetList); + + return targetList; } void World::AddTargetEntity(SimpleEntity *ent) { - str targetname = ent->TargetName(); + TargetList *targetList = GetTargetList(ent->TargetName()); - if (!targetname.length()) { + if (!targetList) { return; } - ConSimple *list = GetTargetList(targetname); - - list->AddObject(ent); + targetList->AddEntity(ent); } void World::AddTargetEntityAt(SimpleEntity *ent, int index) { - str targetname = ent->TargetName(); + TargetList *targetList = GetTargetList(ent->TargetName()); - if (!targetname.length()) { + if (!targetList || !index) { return; } - ConSimple *list = GetTargetList(targetname); - - list->AddObjectAt(index, ent); + targetList->AddEntityAt(ent, index); } int World::GetTargetnameIndex(SimpleEntity *ent) { - ConSimple *list = GetTargetList(ent->TargetName()); + TargetList *targetList = GetTargetList(ent->TargetName()); - return list->IndexOfObject(ent); + if (!targetList) { + return 0; + } + + return targetList->GetEntityIndex(ent); } void World::RemoveTargetEntity(SimpleEntity *ent) @@ -1099,53 +1127,72 @@ void World::RemoveTargetEntity(SimpleEntity *ent) return; } - const str targetname = ent->TargetName(); - - if (!targetname.length()) { + TargetList *targetList = GetExistingTargetList(ent->TargetName()); + if (!targetList) { return; } - ConSimple *list = GetExistingTargetList(targetname); - - if (list) { - list->RemoveObject(ent); - - if (list->NumObjects() <= 0) { - m_targetList.remove(Director.AddString(targetname)); - } - } + targetList->RemoveEntity(ent); } SimpleEntity *World::GetNextEntity(str targetname, SimpleEntity *ent) { - return GetNextEntity(Director.AddString(targetname), ent); -} - -SimpleEntity *World::GetNextEntity(const_str targetname, SimpleEntity *ent) -{ - ConSimple *list = GetTargetList(targetname); - int index; - - if (ent) { - index = list->IndexOfObject(ent) + 1; - } else { - index = 1; - } - - if (list->NumObjects() >= index) { - return list->ObjectAt(index); - } else { + TargetList *targetList = GetExistingTargetList(targetname); + if (!targetList) { return NULL; } + + return targetList->GetNextEntity(ent); } void World::FreeTargetList() { - m_targetList.clear(); + int i; + + for (i = 1; i <= m_targetListContainer.NumObjects(); i++) { + delete m_targetListContainer.ObjectAt(i); + } + + m_targetListContainer.FreeObjectList(); } void World::Archive(Archiver& arc) { + int num; + int num2; + int i; + TargetList *targetList; + + if (arc.Loading()) { + str targetname; + + arc.ArchiveInteger(&num); + for (i = 1; i <= num; i++) { + arc.ArchiveString(&targetname); + + targetList = new TargetList(targetname); + m_targetListContainer.AddObject(targetList); + + arc.ArchiveObjectPosition((LightClass *)&targetList->list); + arc.ArchiveInteger(&num2); + + targetList->list.Resize(num2); + } + } else { + num = m_targetListContainer.NumObjects(); + arc.ArchiveInteger(&num); + + for (i = 1; i <= num; i++) { + targetList = m_targetListContainer.ObjectAt(i); + + arc.ArchiveString(&targetList->targetname); + arc.ArchiveObjectPosition((LightClass *)&targetList->list); + + num2 = targetList->list.NumObjects(); + arc.ArchiveInteger(&num2); + } + } + Entity::Archive(arc); arc.ArchiveFloat(&farplane_distance); @@ -1197,3 +1244,57 @@ bool WithinFarplaneDistance(const Vector& org) return org.lengthSquared() < (Square(distance) * Square(0.828f)); } + +CLASS_DECLARATION(Class, TargetList, NULL) { + {NULL, NULL} +}; + +TargetList::TargetList() {} + +TargetList::TargetList(const str& tname) + : targetname(tname) +{} + +void TargetList::AddEntity(Listener *ent) +{ + list.AddObject(static_cast(ent)); +} + +void TargetList::AddEntityAt(Listener *ent, int i) +{ + list.AddObjectAt(i, static_cast(ent)); +} + +int TargetList::GetEntityIndex(Listener *ent) +{ + return list.IndexOfObject(static_cast(ent)); +} + +void TargetList::RemoveEntity(Listener *ent) +{ + list.RemoveObject(static_cast(ent)); +} + +SimpleEntity *TargetList::GetNextEntity(SimpleEntity *ent) +{ + int index; + + if (ent) { + index = list.IndexOfObject(ent); + } else { + index = 0; + } + + index++; + + for (; index <= list.NumObjects(); index++) { + Listener *objptr; + + objptr = list.ObjectAt(index); + if (objptr->isSubclassOf(SimpleEntity)) { + return static_cast(objptr); + } + } + + return NULL; +} diff --git a/code/fgame/worldspawn.h b/code/fgame/worldspawn.h index 3e1a05f9..b7ced3c8 100644 --- a/code/fgame/worldspawn.h +++ b/code/fgame/worldspawn.h @@ -39,10 +39,66 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA typedef Container> ConSimple; +class TargetList : public Class { +public: + CLASS_PROTOTYPE(TargetList); + +public: + ConSimple list; + str targetname; + +public: + TargetList(); + TargetList(const str& tname); + + void AddEntity(Listener* ent); + void AddEntityAt(Listener* ent, int i); + int GetEntityIndex(Listener* ent); + void RemoveEntity(Listener* ent); + SimpleEntity* GetNextEntity(SimpleEntity* ent); +}; + +template<> +class con_set_Entry +{ + friend con_set; + friend con_set_enum; + +private: + con_set_Entry *next; + +public: + const_str key; + ConSimple value; + +public: + void *operator new(size_t size) { return con_set::NewEntry(size); } + + void operator delete(void *ptr) { con_set::DeleteEntry(ptr); } + + void Archive(Archiver& arc) { + int num; + + arc.ArchiveUnsigned(&key); + arc.ArchiveObjectPosition((LightClass*)&value); + + if (arc.Loading()) { + arc.ArchiveInteger(&num); + value.Resize(num); + } else { + num = value.NumObjects(); + arc.ArchiveInteger(&num); + } + } + const_str& GetKey() { return key; } + + void SetKey(const const_str& newKey) { key = newKey; } +}; + class World : public Entity { - con_set m_targetList; // moh could have used con_set instead of TargetList - qboolean world_dying; + Container m_targetListContainer; + qboolean world_dying; public: // farplane variables @@ -80,6 +136,7 @@ public: CLASS_PROTOTYPE(World); World(); + ~World(); void AddTargetEntity(SimpleEntity *ent); void AddTargetEntityAt(SimpleEntity *ent, int index); @@ -88,17 +145,12 @@ public: void FreeTargetList(); SimpleEntity *GetNextEntity(str targetname, SimpleEntity *ent); - SimpleEntity *GetNextEntity(const_str targetname, SimpleEntity *ent); - SimpleEntity *GetScriptTarget(str targetname); - SimpleEntity *GetScriptTarget(const_str targetname); - SimpleEntity *GetTarget(str targetname, bool quiet); - SimpleEntity *GetTarget(const_str targetname, bool quiet); + Listener *GetScriptTarget(str targetname); + Listener *GetTarget(str targetname, bool quiet); int GetTargetnameIndex(SimpleEntity *ent); - ConSimple *GetExistingTargetList(const str& targetname); - ConSimple *GetExistingTargetList(const_str targetname); - ConSimple *GetTargetList(str& targetname); - ConSimple *GetTargetList(const_str targetname); + TargetList *GetExistingTargetList(const str& targetname); + TargetList *GetTargetList(str& targetname); void SetFarClipOverride(Event *ev); void SetFarPlaneColorOverride(Event *ev); diff --git a/code/gamespy/CMakeLists.txt b/code/gamespy/CMakeLists.txt index fedbf2b8..db690703 100644 --- a/code/gamespy/CMakeLists.txt +++ b/code/gamespy/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) include_directories("./common") include_directories("./gcdkey") @@ -11,6 +11,7 @@ file(GLOB SRCS_common "./hashtable.c" "./md5c.c" "./gutil.c" + "./gcrypt.c" ) file(GLOB SRCS_gcdkey @@ -101,4 +102,5 @@ foreach(LIB ${DEPENDENT_LIBS}) target_link_libraries(${LIB} PUBLIC gcd_common) endforeach() +target_link_libraries(gcd_key PRIVATE gcd_qr2) target_link_libraries(gcd_qr2 PRIVATE gcd_natneg) diff --git a/code/renderer/tr_swipe.cpp b/code/gamespy/cl_gamespy.c similarity index 66% rename from code/renderer/tr_swipe.cpp rename to code/gamespy/cl_gamespy.c index 08cdbc32..203497ed 100644 --- a/code/renderer/tr_swipe.cpp +++ b/code/gamespy/cl_gamespy.c @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2025 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -20,30 +20,30 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -// tr_swipe.cpp -- swipe rendering +#pragma once -#include "tr_local.h" +#include "cl_gamespy.h" +#include "q_gamespy.h" -void RB_DrawSwipeSurface(surfaceType_t* pswipe) { - // FIXME: unimplemented -} - -void RE_SwipeBegin(float thistime, float life, qhandle_t shader) +unsigned int ServerListGetNumMasters() { - // FIXME: unimplemented + return Com_GetNumMasterEntries(); } -void RE_SwipePoint(vec3_t point1, vec3_t point2, float time) +const char *ServerListGetHost(int index) { - // FIXME: unimplemented + master_entry_t entry; + Com_GetMasterEntry(index, &entry); + + return entry.host; } -void RE_SwipeEnd() +int ServerListGetMsPort(int index) { - // FIXME: unimplemented + master_entry_t entry; + Com_GetMasterEntry(index, &entry); + + return entry.queryport; } -void R_AddSwipeSurfaces() -{ - // FIXME: unimplemented -} +void CL_RestartGamespy_f() {} diff --git a/code/renderer/tr_ghost.h b/code/gamespy/cl_gamespy.h similarity index 88% rename from code/renderer/tr_ghost.h rename to code/gamespy/cl_gamespy.h index 64b139d4..45e38ee4 100644 --- a/code/renderer/tr_ghost.h +++ b/code/gamespy/cl_gamespy.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2025 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -20,4 +20,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ +// cl_gamespy.h -- Game-specific client GameSpy code + #pragma once + +void CL_RestartGamespy_f(); diff --git a/code/gamespy/common/gsAssert.c b/code/gamespy/common/gsAssert.c index c4c56861..d8a9b658 100644 --- a/code/gamespy/common/gsAssert.c +++ b/code/gamespy/common/gsAssert.c @@ -96,7 +96,7 @@ void gsDebugAssert (const char *szError,const char *szText, const char *szFi // continues rendering void _gsDebugAssert (const char *string) { - printf(string); + printf("%s", string); while(1) { @@ -118,7 +118,7 @@ void gsDebugAssert (const char *szError,const char *szText, const char *szFi void _gsDebugAssert (const char *string) { - scePrintf(string); + scePrintf("%s", string); while(1);; } @@ -127,7 +127,7 @@ void gsDebugAssert (const char *szError,const char *szText, const char *szFi #elif defined _MACOSX void _gsDebugAssert (const char *string) { - printf(string); + printf("%s", string); while(1) { @@ -139,7 +139,7 @@ void gsDebugAssert (const char *szError,const char *szText, const char *szFi #elif defined _LINUX void _gsDebugAssert (const char *string) { - printf(string); + printf("%s", string); while(1) { @@ -170,7 +170,7 @@ void gsDebugAssert (const char *szError,const char *szText, const char *szFi void _gsDebugAssert (const char *string) { - printf(string); + printf("%s", string); while(1);; } diff --git a/code/gamespy/common/gsPlatform.h b/code/gamespy/common/gsPlatform.h index a4daf16e..10916417 100644 --- a/code/gamespy/common/gsPlatform.h +++ b/code/gamespy/common/gsPlatform.h @@ -8,7 +8,7 @@ // Windows: _WIN32 // Xbox: _WIN32 + _XBOX // Xbox360: _WIN32 + _XBOX + _X360 -// MacOSX: _MACOSX + _UNIX +// MacOSX: _MACOSX + _UNIX + __APPLE__ // Linux: _LINUX + _UNIX // Nintendo DS: _NITRO // PSP: _PSP @@ -23,7 +23,9 @@ /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// // Set the platform define -#ifdef __mips64 +#if defined (__linux__) || defined(_LINUX) || defined(_MACOSX) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) + #define _UNIX +#elif __mips64 #ifndef _PS2 #define _PS2 #endif @@ -34,10 +36,6 @@ #endif #endif -#if defined(_LINUX) || defined(_MACOSX) - #define _UNIX -#endif - #if defined(_XBOX) || defined (_X360) #if _XBOX_VER >= 200 #define _X360 diff --git a/code/gamespy/common/gsPlatformThread.h b/code/gamespy/common/gsPlatformThread.h index 85421ea8..7b5cf779 100644 --- a/code/gamespy/common/gsPlatformThread.h +++ b/code/gamespy/common/gsPlatformThread.h @@ -89,7 +89,11 @@ extern "C" { } GSICriticalSection; typedef void (*GSThreadFunc)(void *arg); -#elif defined(_UNIX) //_LINUX || _MACOSX +#elif defined(_UNIX) // Linux, Mac OS X, openbsd, etc. + #if defined(__OpenBSD__) + #include + #endif + typedef pthread_mutex_t GSICriticalSection; typedef struct { diff --git a/code/gamespy/common/gsPlatformUtil.c b/code/gamespy/common/gsPlatformUtil.c index c341e94a..69c81e0c 100644 --- a/code/gamespy/common/gsPlatformUtil.c +++ b/code/gamespy/common/gsPlatformUtil.c @@ -439,7 +439,7 @@ void SocketStartUp() void SocketShutDown() { #if defined(_WIN32) -// WSACleanup(); + WSACleanup(); #if defined(_X360) XNetCleanup(); #endif diff --git a/code/gamespy/darray.c b/code/gamespy/darray.c index 3db363e2..688729fb 100644 --- a/code/gamespy/darray.c +++ b/code/gamespy/darray.c @@ -20,30 +20,30 @@ #define DEF_GROWBY 8 #ifdef _NO_NOPORT_H_ - #define gsimalloc malloc - #define gsifree free - #define gsirealloc realloc - #include "common/gsAssert.h" + #define gsimalloc malloc + #define gsifree free + #define gsirealloc realloc + #include "common/gsAssert.h" #else - #include "nonport.h" //for gsimalloc/realloc/free/GS_ASSERT + #include "nonport.h" //for gsimalloc/realloc/free/GS_ASSERT #endif // STRUCTURES struct DArrayImplementation { - int count, capacity; - int elemsize; - int growby; - ArrayElementFreeFn elemfreefn; - void *list; //array of elements + int count, capacity; + int elemsize; + int growby; + ArrayElementFreeFn elemfreefn; + void *list; //array of elements }; // PROTOTYPES static void *mylsearch(const void *key, void *base, int count, int size, - ArrayCompareFn comparator); + ArrayCompareFn comparator); static void *mybsearch(const void *elem, void *base, int num, int elemsize, - ArrayCompareFn comparator, int *found); + ArrayCompareFn comparator, int *found); // FUNCTIONS /* FreeElement @@ -51,8 +51,8 @@ static void *mybsearch(const void *elem, void *base, int num, int elemsize, */ static void FreeElement(DArray array, int n) { - if (array->elemfreefn != NULL) - array->elemfreefn(ArrayNth(array,n)); + if (array->elemfreefn != NULL) + array->elemfreefn(ArrayNth(array,n)); } /* ArrayGrow @@ -60,10 +60,10 @@ static void FreeElement(DArray array, int n) */ static void ArrayGrow(DArray array) { - GS_ASSERT(array->elemsize) // sanity check -mj Oct 31st - array->capacity += array->growby; - array->list = gsirealloc(array->list, (size_t) array->capacity * array->elemsize); - GS_ASSERT(array->list); + GS_ASSERT(array->elemsize) // sanity check -mj Oct 31st + array->capacity += array->growby; + array->list = gsirealloc(array->list, (size_t) array->capacity * array->elemsize); + GS_ASSERT(array->list); } /* SetElement @@ -71,94 +71,94 @@ static void ArrayGrow(DArray array) */ static void SetElement(DArray array, const void *elem, int pos) { - GS_ASSERT(array) // safety check -mj Oct 31st - GS_ASSERT(elem) - GS_ASSERT(array->elemsize) + GS_ASSERT(array) // safety check -mj Oct 31st + GS_ASSERT(elem) + GS_ASSERT(array->elemsize) - memcpy(ArrayNth(array,pos), elem, (size_t)array->elemsize); + memcpy(ArrayNth(array,pos), elem, (size_t)array->elemsize); } DArray ArrayNew(int elemSize, int numElemsToAllocate, ArrayElementFreeFn elemFreeFn) { - DArray array; + DArray array; - array = (DArray) gsimalloc(sizeof(struct DArrayImplementation)); - GS_ASSERT(array); - GS_ASSERT(elemSize); - if (numElemsToAllocate == 0) - numElemsToAllocate = DEF_GROWBY; - array->count = 0; - array->capacity = numElemsToAllocate;; - array->elemsize = elemSize; - array->growby = numElemsToAllocate; - array->elemfreefn = elemFreeFn; - if (array->capacity != 0) - { - array->list = gsimalloc((size_t)array->capacity * array->elemsize); - GS_ASSERT(array->list); - } else - array->list = NULL; + array = (DArray) gsimalloc(sizeof(struct DArrayImplementation)); + GS_ASSERT(array); + GS_ASSERT(elemSize); + if (numElemsToAllocate == 0) + numElemsToAllocate = DEF_GROWBY; + array->count = 0; + array->capacity = numElemsToAllocate;; + array->elemsize = elemSize; + array->growby = numElemsToAllocate; + array->elemfreefn = elemFreeFn; + if (array->capacity != 0) + { + array->list = gsimalloc((size_t)array->capacity * array->elemsize); + GS_ASSERT(array->list); + } else + array->list = NULL; - return array; + return array; } void ArrayFree(DArray array) { - int i; - - GS_ASSERT(array); - for (i = 0; i < array->count; i++) - { - FreeElement(array, i); - } - // mj to do: move these asserts into gsi_free. maybe, depends on whether user overloads them - GS_ASSERT(array->list) - GS_ASSERT(array) - gsifree(array->list); - gsifree(array); + int i; + + GS_ASSERT(array); + for (i = 0; i < array->count; i++) + { + FreeElement(array, i); + } + // mj to do: move these asserts into gsi_free. maybe, depends on whether user overloads them + GS_ASSERT(array->list) + GS_ASSERT(array) + gsifree(array->list); + gsifree(array); } void *ArrayGetDataPtr(DArray array) { - GS_ASSERT(array); - return array->list; + GS_ASSERT(array); + return array->list; } void ArraySetDataPtr(DArray array, void *ptr, int count, int capacity) { - int i; - - GS_ASSERT(array); - if (array->list != NULL) - { - for (i = 0; i < array->count; i++) - { - FreeElement(array, i); - } - gsifree(array->list); - } - array->list = ptr; - array->count = count; - array->capacity = capacity; + int i; + + GS_ASSERT(array); + if (array->list != NULL) + { + for (i = 0; i < array->count; i++) + { + FreeElement(array, i); + } + gsifree(array->list); + } + array->list = ptr; + array->count = count; + array->capacity = capacity; } int ArrayLength(const DArray array) { - GS_ASSERT(array) - return array->count; + GS_ASSERT(array) + return array->count; } void *ArrayNth(DArray array, int n) { - // 2004.Nov.16.JED - modified GS_ASSERT to include "if" to add robustness - GS_ASSERT( (n >= 0) && (n < array->count)); - if( ! ((n >= 0) && (n < array->count)) ) - return NULL; - - return (char *)array->list + array->elemsize*n; + // 2004.Nov.16.JED - modified GS_ASSERT to include "if" to add robustness + GS_ASSERT( (n >= 0) && (n < array->count)); + if( ! ((n >= 0) && (n < array->count)) ) + return NULL; + + return (char *)array->list + array->elemsize*n; } /* ArrayAppend @@ -166,166 +166,166 @@ void *ArrayNth(DArray array, int n) */ void ArrayAppend(DArray array, const void *newElem) { - GS_ASSERT(array); - if(array) - ArrayInsertAt(array, newElem, array->count); + GS_ASSERT(array); + if(array) + ArrayInsertAt(array, newElem, array->count); } void ArrayInsertAt(DArray array, const void *newElem, int n) { - GS_ASSERT (array) - GS_ASSERT ( (n >= 0) && (n <= array->count)); + GS_ASSERT (array) + GS_ASSERT ( (n >= 0) && (n <= array->count)); - if (array->count == array->capacity) - ArrayGrow(array); - array->count++; - if (n < array->count - 1) //if we aren't appending - memmove(ArrayNth(array, n+1), ArrayNth(array,n), - (size_t)(array->count - 1 - n) * array->elemsize); - SetElement(array, newElem, n); + if (array->count == array->capacity) + ArrayGrow(array); + array->count++; + if (n < array->count - 1) //if we aren't appending + memmove(ArrayNth(array, n+1), ArrayNth(array,n), + (size_t)(array->count - 1 - n) * array->elemsize); + SetElement(array, newElem, n); } void ArrayInsertSorted(DArray array, const void *newElem, ArrayCompareFn comparator) { - int n; - void *res; - int found; + int n; + void *res; + int found; - GS_ASSERT (array) - GS_ASSERT (comparator); + GS_ASSERT (array) + GS_ASSERT (comparator); - res=mybsearch(newElem, array->list, array->count, array->elemsize, comparator, &found); - n = (((char *)res - (char *)array->list) / array->elemsize); - ArrayInsertAt(array, newElem, n); + res=mybsearch(newElem, array->list, array->count, array->elemsize, comparator, &found); + n = (((char *)res - (char *)array->list) / array->elemsize); + ArrayInsertAt(array, newElem, n); } void ArrayRemoveAt(DArray array, int n) { - GS_ASSERT (array) - GS_ASSERT( (n >= 0) && (n < array->count)); + GS_ASSERT (array) + GS_ASSERT( (n >= 0) && (n < array->count)); - if (n < array->count - 1) //if not last element - memmove(ArrayNth(array,n),ArrayNth(array,n+1), - (size_t)(array->count - 1 - n) * array->elemsize); - array->count--; + if (n < array->count - 1) //if not last element + memmove(ArrayNth(array,n),ArrayNth(array,n+1), + (size_t)(array->count - 1 - n) * array->elemsize); + array->count--; } void ArrayDeleteAt(DArray array, int n) { - GS_ASSERT (array) - GS_ASSERT ( (n >= 0) && (n < array->count)); + GS_ASSERT (array) + GS_ASSERT ( (n >= 0) && (n < array->count)); - FreeElement(array,n); - ArrayRemoveAt(array, n); + FreeElement(array,n); + ArrayRemoveAt(array, n); } void ArrayReplaceAt(DArray array, const void *newElem, int n) { - GS_ASSERT (array) - GS_ASSERT ( (n >= 0) && (n < array->count)); + GS_ASSERT (array) + GS_ASSERT ( (n >= 0) && (n < array->count)); - FreeElement(array, n); - SetElement(array, newElem,n); + FreeElement(array, n); + SetElement(array, newElem,n); } void ArraySort(DArray array, ArrayCompareFn comparator) { - GS_ASSERT (array) - qsort(array->list, (size_t)array->count, (size_t)array->elemsize, comparator); + GS_ASSERT (array) + qsort(array->list, (size_t)array->count, (size_t)array->elemsize, comparator); } //GS_ASSERT will be raised by ArrayNth if fromindex out of range int ArraySearch(DArray array, const void *key, ArrayCompareFn comparator, int fromIndex, int isSorted) { - void *res; - int found = 1; - if (!array || array->count == 0) - return NOT_FOUND; + void *res; + int found = 1; + if (!array || array->count == 0) + return NOT_FOUND; - if (isSorted) - res=mybsearch(key, ArrayNth(array,fromIndex), - array->count - fromIndex, array->elemsize, comparator, &found); - else - res=mylsearch(key, ArrayNth(array, fromIndex), - array->count - fromIndex, array->elemsize, comparator); - if (res != NULL && found) - return (((char *)res - (char *)array->list) / array->elemsize); - else - return NOT_FOUND; + if (isSorted) + res=mybsearch(key, ArrayNth(array,fromIndex), + array->count - fromIndex, array->elemsize, comparator, &found); + else + res=mylsearch(key, ArrayNth(array, fromIndex), + array->count - fromIndex, array->elemsize, comparator); + if (res != NULL && found) + return (((char *)res - (char *)array->list) / array->elemsize); + else + return NOT_FOUND; } void ArrayMap(DArray array, ArrayMapFn fn, void *clientData) { - int i; + int i; - GS_ASSERT (array) - GS_ASSERT(fn); + GS_ASSERT (array) + GS_ASSERT(fn); - for (i = 0; i < array->count; i++) - fn(ArrayNth(array,i), clientData); - + for (i = 0; i < array->count; i++) + fn(ArrayNth(array,i), clientData); + } void ArrayMapBackwards(DArray array, ArrayMapFn fn, void *clientData) { - int i; + int i; - GS_ASSERT(fn); + GS_ASSERT(fn); - for (i = (array->count - 1) ; i >= 0 ; i--) - fn(ArrayNth(array,i), clientData); - + for (i = (array->count - 1) ; i >= 0 ; i--) + fn(ArrayNth(array,i), clientData); + } void * ArrayMap2(DArray array, ArrayMapFn2 fn, void *clientData) { - int i; - void * pcurr; + int i; + void * pcurr; - GS_ASSERT(fn); - GS_ASSERT(clientData); + GS_ASSERT(fn); + GS_ASSERT(clientData); - for (i = 0; i < array->count; i++) - { - pcurr = ArrayNth(array,i); - if(!fn(pcurr, clientData)) - return pcurr; - } + for (i = 0; i < array->count; i++) + { + pcurr = ArrayNth(array,i); + if(!fn(pcurr, clientData)) + return pcurr; + } - return NULL; + return NULL; } void * ArrayMapBackwards2(DArray array, ArrayMapFn2 fn, void *clientData) { - int i; - void * pcurr; + int i; + void * pcurr; - GS_ASSERT(fn); - GS_ASSERT(clientData); + GS_ASSERT(fn); + GS_ASSERT(clientData); - for (i = (array->count - 1) ; i >= 0 ; i--) - { - pcurr = ArrayNth(array,i); - if(!fn(pcurr, clientData)) - return pcurr; - } + for (i = (array->count - 1) ; i >= 0 ; i--) + { + pcurr = ArrayNth(array,i); + if(!fn(pcurr, clientData)) + return pcurr; + } - return NULL; + return NULL; } void ArrayClear(DArray array) { - int i; + int i; - // This could be more optimal! - ////////////////////////////// - for(i = (ArrayLength(array) - 1) ; i >= 0 ; i--) - ArrayDeleteAt(array, i); + // This could be more optimal! + ////////////////////////////// + for(i = (ArrayLength(array) - 1) ; i >= 0 ; i--) + ArrayDeleteAt(array, i); } /* mylsearch @@ -333,17 +333,17 @@ void ArrayClear(DArray array) * couldn't use lfind */ static void *mylsearch(const void *key, void *base, int count, int size, - ArrayCompareFn comparator) + ArrayCompareFn comparator) { - int i; - GS_ASSERT(key); - GS_ASSERT(base); - for (i = 0; i < count; i++) - { - if (comparator(key, (char *)base + size*i) == 0) - return (char *)base + size*i; - } - return NULL; + int i; + GS_ASSERT(key); + GS_ASSERT(base); + for (i = 0; i < count; i++) + { + if (comparator(key, (char *)base + size*i) == 0) + return (char *)base + size*i; + } + return NULL; } /* mybsearch @@ -351,27 +351,27 @@ static void *mylsearch(const void *key, void *base, int count, int size, */ static void *mybsearch(const void *elem, void *base, int num, int elemsize, ArrayCompareFn comparator, int *found) { - int L, H, I, C; - - GS_ASSERT(elem); - GS_ASSERT(base); - GS_ASSERT(found); + int L, H, I, C; + + GS_ASSERT(elem); + GS_ASSERT(base); + GS_ASSERT(found); - L = 0; - H = num - 1; - *found = 0; - while (L <= H) - { - I = (L + H) >> 1; - C = comparator(((char *)base) + I * elemsize,elem); - if (C == 0) - *found = 1; - if (C < 0) - L = I + 1; - else - { - H = I - 1; - } - } - return ((char *)base) + L * elemsize; + L = 0; + H = num - 1; + *found = 0; + while (L <= H) + { + I = (L + H) >> 1; + C = comparator(((char *)base) + I * elemsize,elem); + if (C == 0) + *found = 1; + if (C < 0) + L = I + 1; + else + { + H = I - 1; + } + } + return ((char *)base) + L * elemsize; } diff --git a/code/gamespy/darray.h b/code/gamespy/darray.h index ad84b13f..29ed76cc 100644 --- a/code/gamespy/darray.h +++ b/code/gamespy/darray.h @@ -43,9 +43,9 @@ typedef struct DArrayImplementation *DArray; * If the two elements are "equal", return 0. */ #if defined(WIN32) - typedef int (__cdecl *ArrayCompareFn)(const void *elem1, const void *elem2); + typedef int (__cdecl *ArrayCompareFn)(const void *elem1, const void *elem2); #else - typedef int (*ArrayCompareFn)(const void *elem1, const void *elem2); + typedef int (*ArrayCompareFn)(const void *elem1, const void *elem2); #endif diff --git a/code/gamespy/gcrypt.c b/code/gamespy/gcrypt.c new file mode 100644 index 00000000..372e239d --- /dev/null +++ b/code/gamespy/gcrypt.c @@ -0,0 +1,223 @@ +/* +=========================================================================== +Copyright (C) 2025 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA source code 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. + +OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "gcrypt.h" +#include "../qcommon/q_platform.h" +#include "../qcommon/q_shared.h" + +static unsigned int rotl32(unsigned int value, unsigned int count) +{ + return (value << count) | (value >> (-count & 31)); +} + +static unsigned int crypt_seek(GCryptInfo *info, unsigned int n1, unsigned int n2) +{ + int part; + int i; + int keyIndex; + int xorKey; + int current; + + current = 0x8000; + xorKey = n1; + keyIndex = 0; + i = 1; + + info->offset = 0; + + while (current > 0) { + xorKey += i; + keyIndex += xorKey; + xorKey += keyIndex; + + if (n2 & current) { + part = rotl32(~xorKey, 24); + xorKey = rotl32(info->key[part & 0xff] ^ part, 24); + part = rotl32(info->key[keyIndex & 0xff] ^ keyIndex, 8); + xorKey ^= info->key[xorKey & 0xff]; + keyIndex = rotl32(info->key[part & 0xff] ^ part, 8); + + i += 1 + i; + } else { + info->msg[info->offset] = xorKey; + info->msg[info->offset + 16] = keyIndex; + info->msg[info->offset + 32] = i; + info->offset++; + + part = rotl32(keyIndex, 24); + keyIndex = rotl32(info->key[part & 0xff] ^ part, 24); + part = rotl32(info->key[xorKey & 0xff] ^ xorKey, 8); + keyIndex ^= info->key[keyIndex & 0xff]; + xorKey = rotl32(info->key[part & 0xff] ^ part, 8); + + i *= 2; + } + + current >>= 1; + } + + info->xorKey = xorKey; + info->keyIndex = keyIndex; + info->i = i; + info->start = n1; + + return keyIndex ^ xorKey; +} + +static void crypt_encrypt(GCryptInfo *info, unsigned int *words, int len) +{ + int part; + unsigned int i; + unsigned int w; + int keyIndex; + int xorKey; + int offset; + + offset = info->offset; + xorKey = info->xorKey; + keyIndex = info->keyIndex; + i = info->i; + + for (w = 0; w < len; w++) { + while (i < 0x10000) { + xorKey += i; + keyIndex += xorKey; + xorKey += keyIndex; + + info->msg[offset] = xorKey; + info->msg[offset + 16] = keyIndex; + info->msg[offset + 32] = i; + offset++; + + part = rotl32(keyIndex, 24); + keyIndex = rotl32(info->key[part & 0xff] ^ part, 24); + part = rotl32(info->key[xorKey & 0xff] ^ xorKey, 8); + keyIndex ^= info->key[keyIndex & 0xff]; + xorKey = rotl32(info->key[part & 0xff] ^ part, 8); + + i *= 2; + } + + words[w] = LittleLong(keyIndex ^ xorKey); + offset--; + if (offset < 0) { + offset = 0; + } + + part = rotl32(~info->msg[offset], 24); + xorKey = rotl32(info->key[part & 0xff] ^ part, 24); + part = rotl32(info->key[info->msg[offset + 16] & 0xff] ^ info->msg[offset + 16], 8); + xorKey ^= info->key[xorKey & 0xff]; + keyIndex = rotl32(info->key[part & 0xff] ^ part, 8); + + i = info->msg[offset + 32] + 1 + info->msg[offset + 32]; + } + + info->offset = offset; + info->xorKey = xorKey; + info->keyIndex = keyIndex; + info->i = i; +} + +void init_crypt_key(unsigned char *src, unsigned int len, GCryptInfo *info) +{ + int index; + int i, j, k; + int tmp; + + info->wordPtr = NULL; + for (k = 0; k < 256; k++) { + info->key[k] = 0; + } + + for (i = 0; i < 4; i++) { + for (k = 0; k < 256; k++) { + info->key[k] = (info->key[k] << 8) + k; + } + + index = i; + + for (j = 0; j < 2; j++) { + for (k = 0; k < 256; k++) { + index = ((info->key[k] & 0xff) + src[k % len] + index) & 0xff; + + tmp = info->key[k]; + info->key[k] = info->key[index]; + info->key[index] = tmp; + } + } + } + + for (k = 0; k < 256; k++) { + info->key[k] ^= k; + } + + crypt_seek(info, 0, 0); +} + +void crypt_docrypt(GCryptInfo *info, unsigned char *out, int len) +{ + int i; + + for (i = 0; i < len; i++) { + if (!info->wordPtr || ((char *)info->wordPtr - (char *)info->words) >= (sizeof(info->words) - 1)) { + info->wordPtr = (unsigned char *)info->words; + crypt_encrypt(info, info->words, ARRAY_LEN(info->words)); + } + + out[i] ^= *info->wordPtr; + info->wordPtr++; + } +} + +int enctype2_encoder(unsigned char *secKey, unsigned char *data, int size) +{ + GCryptInfo info = {0}; + int i; + int header_size = 8; + + // move the data and put it after the header + for (i = size - 1; i >= 0; i--) { + data[1 + header_size + i] = data[i]; + } + + // initialize the header + for (i = 0; i < header_size; i++) { + data[i + 1] = 0; + } + + // initialize the crypt key + init_crypt_key(data + 1, header_size, &info); + + for (i = 0; i < 6; i++) { + data[1 + header_size + size + i] = 0; + } + crypt_docrypt(&info, data + 1 + header_size, size + 6); + + for (i = 0; secKey[i]; i++) { + data[i + 1] ^= secKey[i]; + } + + size += 1 + header_size + 6; + *data = header_size ^ 0xec; + return size; +} diff --git a/code/gamespy/gcrypt.h b/code/gamespy/gcrypt.h new file mode 100644 index 00000000..dfe6993c --- /dev/null +++ b/code/gamespy/gcrypt.h @@ -0,0 +1,40 @@ +/* +=========================================================================== +Copyright (C) 2025 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA source code 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. + +OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#pragma once + +typedef struct { + int key[256]; + int msg[48]; + + int offset; + int xorKey; + int keyIndex; + int i; + int start; + + unsigned int words[16]; + unsigned char *wordPtr; +} GCryptInfo; + +void init_crypt_key(unsigned char *src, unsigned int len, GCryptInfo *info); +void crypt_docrypt(GCryptInfo *info, unsigned char *out, int len); diff --git a/code/gamespy/goaceng.h b/code/gamespy/goaceng.h index 298f8338..b278af78 100644 --- a/code/gamespy/goaceng.h +++ b/code/gamespy/goaceng.h @@ -74,7 +74,9 @@ idle - no processing or querying underway, ready to being updates listreq - a server list request has been or is being sent listxfer - we are transfering the server list lanlist - we are waiting for replies from servers on the LAN -querying - the servers on the list are being queried */ +querying - the servers on the list are being queried +connecting (added in OPM) - socket is currently connecting to the master server +*/ typedef enum {sl_idle, sl_listxfer, sl_lanlist, sl_querying} GServerListState; /* Comparision types for the ServerListSort function @@ -85,7 +87,7 @@ stricase - assume the values are strings and do a case insensitive compare */ typedef enum {cm_int, cm_float, cm_strcase, cm_stricase} GCompareMode; -typedef enum {qt_basic, qt_info, qt_rules, qt_players, qt_info_rules, qt_status} GQueryType; +typedef enum {qt_basic, qt_info, qt_rules, qt_players, qt_info_rules, qt_status, qt_grouprooms, qt_masterinfo} GQueryType; /* Messages that are passed to the ListCallBackFn */ #define LIST_STATECHANGED 1 // ServerListState changed, no parameters diff --git a/code/gamespy/gserver.c b/code/gamespy/gserver.c index 7a300558..13571064 100644 --- a/code/gamespy/gserver.c +++ b/code/gamespy/gserver.c @@ -13,17 +13,17 @@ Fax(714)549-0757 ****** Updated 10-15-99 (BGW) - Modified ServerParseKeyVals to actually parse and store empty - values for keys (i.e. "\delete\\" adds key="delete" and value="") + Modified ServerParseKeyVals to actually parse and store empty + values for keys (i.e. "\delete\\" adds key="delete" and value="") Updated 6-17-99 (DDW) - Added new tokenize function to handle empty values for keys + Added new tokenize function to handle empty values for keys - + *******/ #if defined(applec) || defined(THINK_C) || defined(__MWERKS__) && !defined(__KATANA__) - #include "::nonport.h" + #include "::nonport.h" #else - #include "../nonport.h" + #include "../nonport.h" #endif #include "goaceng.h" #include "gserver.h" @@ -36,121 +36,177 @@ Updated 6-17-99 (DDW) static int KeyValHashKeyP(const void *elem, int numbuckets); static int KeyValCompareKeyP(const void *entry1, const void *entry2); +static char *mytok(char *instr, char delim); +static char *LookupKey(GServer server, char *k); void ServerFree(void *elem) { - //free a server! - GServer server = *(GServer *)elem; - - TableFree(server->keyvals); - free(server); + //free a server! + GServer server = *(GServer *)elem; + + TableFree(server->keyvals); + free(server); +} + +static void ServerSetAddressFromString (GServer server, char *address) +{ + char *cpos; + + cpos = strchr(address, ':'); + if (!cpos) { + return; + } + + *cpos = 0; + server->ip = inet_addr(address); + server->port = atoi(cpos + 1); +} + +GServer ServerNewData(char **fieldlist, int fieldcount, char *serverdata, GQueryType qtype, HashTable keylist) +{ + GServer server; + char *k; + char *v; + int curfield; + GKeyValuePair kvpair; + + curfield = 0; + server = (GServer)ServerNew(0, 0, qtype, keylist); + v = mytok(serverdata + 1, '\\'); + + while (curfield < fieldcount) { + k = fieldlist[curfield]; + if (!v) { + v = ""; + } + + if (!strcmp(k, "ip")) { + ServerSetAddressFromString(server, v); + } else if (qtype == qt_grouprooms && !strcmp(k, "other")) { + for (char *p = v; *p; ++p) { + if (*p == 1) { + *p = '\\'; + } + } + ServerParseKeyVals(server, v); + } else { + kvpair.key = (char *)LookupKey(server, k); + kvpair.value = (char *)LookupKey(server, v); + TableEnter(server->keyvals, &kvpair); + } + if (++curfield < fieldcount) { + v = mytok(0, '\\'); + } + } + + return server; } GServer ServerNew(unsigned long ip, unsigned short port, GQueryType qtype, HashTable keylist) { - GServer server; - int nBuckets, nChains; + GServer server; + int nBuckets, nChains; - server = malloc(sizeof(struct GServerImplementation)); - server->ip = ip; - server->port = port; - server->ping = 9999; - server->querytype = qtype; - /* optimize the number of buckets / chains based on query type */ - switch (qtype) - { - case qt_basic: - nBuckets = 4; - nChains = 2; - break; - case qt_info: - nBuckets = 6; - nChains = 2; - break; - case qt_players: - case qt_rules: - nBuckets = 8; - nChains = 2; - break; - case qt_info_rules: - case qt_status: - default: - nBuckets = 8; - nChains= 4; - break; - } - server->keyvals = TableNew2(sizeof(GKeyValuePair),nBuckets,nChains, KeyValHashKeyP, KeyValCompareKeyP, NULL); - server->keylist = keylist; - return server; + server = malloc(sizeof(struct GServerImplementation)); + server->ip = ip; + server->port = port; + server->ping = 9999; + server->querytype = qtype; + /* optimize the number of buckets / chains based on query type */ + switch (qtype) + { + case qt_basic: + nBuckets = 4; + nChains = 2; + break; + case qt_info: + nBuckets = 6; + nChains = 2; + break; + case qt_players: + case qt_rules: + nBuckets = 8; + nChains = 2; + break; + case qt_info_rules: + case qt_status: + default: + nBuckets = 8; + nChains= 4; + break; + } + server->keyvals = TableNew2(sizeof(GKeyValuePair),nBuckets,nChains, KeyValHashKeyP, KeyValCompareKeyP, NULL); + server->keylist = keylist; + return server; } static char *mytok(char *instr, char delim) { - char *result; - static char *thestr; + char *result; + static char *thestr; - if (instr) - thestr = instr; - result=thestr; - while (*thestr && *thestr != delim) - { - thestr++; - } - if (thestr == result) - result = NULL; - if (*thestr) //not the null term - *thestr++ = '\0'; - return result; + if (instr) + thestr = instr; + result=thestr; + while (*thestr && *thestr != delim) + { + thestr++; + } + if (thestr == result) + result = NULL; + if (*thestr) //not the null term + *thestr++ = '\0'; + return result; } static int CheckValidKey(char *key) { - const char *InvalidKeys[]={"queryid","final"}; - int i; - for (i = 0; i < sizeof(InvalidKeys)/sizeof(InvalidKeys[0]); i++) - { - if (strcmp(key,InvalidKeys[i]) == 0) - return 0; - } - return 1; + const char *InvalidKeys[]={"queryid","final"}; + int i; + for (i = 0; i < sizeof(InvalidKeys)/sizeof(InvalidKeys[0]); i++) + { + if (strcmp(key,InvalidKeys[i]) == 0) + return 0; + } + return 1; } static char *LookupKey(GServer server, char *k) { - char **keyindex; + char **keyindex; - keyindex = (char **)TableLookup(server->keylist,&k); - if (keyindex != NULL) - return *keyindex; - k = strdup(k); - TableEnter(server->keylist,&k); - return k; + keyindex = (char **)TableLookup(server->keylist,&k); + if (keyindex != NULL) + return *keyindex; + k = strdup(k); + TableEnter(server->keylist,&k); + return k; } void ServerParseKeyVals(GServer server, char *keyvals) { - char *k, *v; - GKeyValuePair kvpair; + char *k, *v; + GKeyValuePair kvpair; - k = mytok(++keyvals,'\\'); //skip over starting backslash - while (k != NULL) - { - v = mytok(NULL,'\\'); - if (v == NULL) - v = ""; - if (CheckValidKey(k)) - { - kvpair.key = LookupKey(server, k); - kvpair.value = LookupKey(server, v); - TableEnter(server->keyvals, &kvpair); - } - k = mytok(NULL,'\\'); + k = mytok(++keyvals,'\\'); //skip over starting backslash + while (k != NULL) + { + v = mytok(NULL,'\\'); + if (v == NULL) + v = ""; + if (CheckValidKey(k)) + { + kvpair.key = LookupKey(server, k); + kvpair.value = LookupKey(server, v); + TableEnter(server->keyvals, &kvpair); + } + k = mytok(NULL,'\\'); - } + } } @@ -159,7 +215,7 @@ void ServerParseKeyVals(GServer server, char *keyvals) Returns the ping for the specified server. */ int ServerGetPing(GServer server) { - return server->ping; + return server->ping; } /* ServerGetAddress @@ -167,7 +223,7 @@ int ServerGetPing(GServer server) Returns the string, dotted IP address for the specified server */ char *ServerGetAddress(GServer server) { - return (char *)inet_ntoa(*(struct in_addr*)&server->ip); + return (char *)inet_ntoa(*(struct in_addr*)&server->ip); } /* ServerGetInetAddress @@ -175,7 +231,7 @@ char *ServerGetAddress(GServer server) Returns the IP address for the specified server */ unsigned int ServerGetInetAddress(GServer server) { - return server->ip; + return server->ip; } @@ -184,18 +240,18 @@ unsigned int ServerGetInetAddress(GServer server) Returns the "query" port for the specified server. */ int ServerGetQueryPort(GServer server) { - return server->port; + return server->port; } static GKeyValuePair *ServerRuleLookup(GServer server, char *key) { - GKeyValuePair kvp; - char **keyindex; - keyindex = (char **)TableLookup(server->keylist, &key); - if (keyindex == NULL) - return NULL; //otherwise, the keyindex->keyindex is valid, so use it to lookup - kvp.key = *keyindex; - return (GKeyValuePair *)TableLookup(server->keyvals, &kvp); + GKeyValuePair kvp; + char **keyindex; + keyindex = (char **)TableLookup(server->keylist, &key); + if (keyindex == NULL) + return NULL; //otherwise, the keyindex->keyindex is valid, so use it to lookup + kvp.key = *keyindex; + return (GKeyValuePair *)TableLookup(server->keyvals, &kvp); } /* ServerGet[]Value @@ -203,60 +259,60 @@ static GKeyValuePair *ServerRuleLookup(GServer server, char *key) Returns the value for the specified key. */ char *ServerGetStringValue(GServer server, char *key, char *sdefault) { - GKeyValuePair *kv; + GKeyValuePair *kv; - if (strcmp(key,"hostaddr") == 0) //ooh! they want the hostaddr! - return ServerGetAddress(server); - kv = ServerRuleLookup(server,key); - if (!kv) - return sdefault; - return kv->value; + if (strcmp(key,"hostaddr") == 0) //ooh! they want the hostaddr! + return ServerGetAddress(server); + kv = ServerRuleLookup(server,key); + if (!kv) + return sdefault; + return kv->value; } int ServerGetIntValue(GServer server, char *key, int idefault) { - GKeyValuePair *kv; + GKeyValuePair *kv; - if (strcmp(key,"ping") == 0) //ooh! they want the ping! - return ServerGetPing(server); - kv = ServerRuleLookup(server,key); - if (!kv) - return idefault; - return atoi(kv->value); + if (strcmp(key,"ping") == 0) //ooh! they want the ping! + return ServerGetPing(server); + kv = ServerRuleLookup(server,key); + if (!kv) + return idefault; + return atoi(kv->value); } double ServerGetFloatValue(GServer server, char *key, double fdefault) { - GKeyValuePair *kv; + GKeyValuePair *kv; - kv = ServerRuleLookup(server,key); - if (!kv) - return fdefault; - return atof(kv->value); + kv = ServerRuleLookup(server,key); + if (!kv) + return fdefault; + return atof(kv->value); } char *ServerGetPlayerStringValue(GServer server, int playernum, char *key, char *sdefault) { - char newkey[32]; - - sprintf(newkey,"%s_%d",key,playernum); - return ServerGetStringValue(server, newkey, sdefault); + char newkey[32]; + + sprintf(newkey,"%s_%d",key,playernum); + return ServerGetStringValue(server, newkey, sdefault); } int ServerGetPlayerIntValue(GServer server, int playernum, char *key, int idefault) { - char newkey[32]; - - sprintf(newkey,"%s_%d",key,playernum); - return ServerGetIntValue(server, newkey, idefault); + char newkey[32]; + + sprintf(newkey,"%s_%d",key,playernum); + return ServerGetIntValue(server, newkey, idefault); } double ServerGetPlayerFloatValue(GServer server, int playernum, char *key, double fdefault) { - char newkey[32]; - - sprintf(newkey,"%s_%d",key,playernum); - return ServerGetFloatValue(server, newkey, fdefault); + char newkey[32]; + + sprintf(newkey,"%s_%d",key,playernum); + return ServerGetFloatValue(server, newkey, fdefault); } @@ -268,20 +324,20 @@ key/value. The user-defined instance data will be passed to the KeyFn callback * static void KeyMapF(void *elem, void *clientData) { - GKeyValuePair *kv = (GKeyValuePair *)elem; - GEnumData *ped = (GEnumData *)clientData; - ped->EnumFn(kv->key, kv->value, ped->instance); + GKeyValuePair *kv = (GKeyValuePair *)elem; + GEnumData *ped = (GEnumData *)clientData; + ped->EnumFn(kv->key, kv->value, ped->instance); } void ServerEnumKeys(GServer server, KeyEnumFn KeyFn, void *instance) { - GEnumData ed; + GEnumData ed; - ed.EnumFn = KeyFn; - ed.instance = instance; - ed.keylist = server->keylist; - TableMap(server->keyvals, KeyMapF, &ed); + ed.EnumFn = KeyFn; + ed.instance = instance; + ed.keylist = server->keylist; + TableMap(server->keyvals, KeyMapF, &ed); } @@ -293,21 +349,21 @@ void ServerEnumKeys(GServer server, KeyEnumFn KeyFn, void *instance) #define MULTIPLIER -1664117991 static int StringHash(char *s, int numbuckets) { - unsigned long hashcode = 0; - while (*s != 0) - hashcode = hashcode * MULTIPLIER + tolower(*s++); + unsigned long hashcode = 0; + while (*s != 0) + hashcode = hashcode * MULTIPLIER + tolower(*s++); return (hashcode % numbuckets); } int GStringHash(const void *elem, int numbuckets) { - return StringHash(*(char **)elem, numbuckets); + return StringHash(*(char **)elem, numbuckets); } static int KeyValHashKeyP(const void *elem, int numbuckets) { - return StringHash(((GKeyValuePair *)elem)->key, numbuckets); + return StringHash(((GKeyValuePair *)elem)->key, numbuckets); } @@ -328,12 +384,12 @@ int GCaseInsensitiveCompare(const void *entry1, const void *entry2) */ static int KeyValCompareKeyP(const void *entry1, const void *entry2) { - return ((GKeyValuePair *)entry1)->key - ((GKeyValuePair *)entry2)->key; + return ((GKeyValuePair *)entry1)->key - ((GKeyValuePair *)entry2)->key; } void GStringFree(void *elem) { - free(*(char **)elem); + free(*(char **)elem); } /* keyval @@ -341,8 +397,8 @@ void GStringFree(void *elem) * static int KeyValCompareKeyA(const void *entry1, const void *entry2) { - return CaseInsensitiveCompare(&((GKeyValuePair *)entry1)->key, - &((GKeyValuePair *)entry2)->key); + return CaseInsensitiveCompare(&((GKeyValuePair *)entry1)->key, + &((GKeyValuePair *)entry2)->key); } */ \ No newline at end of file diff --git a/code/gamespy/gserver.h b/code/gamespy/gserver.h index a62822fd..b7b9dcf6 100644 --- a/code/gamespy/gserver.h +++ b/code/gamespy/gserver.h @@ -27,41 +27,42 @@ extern "C" { #endif #if defined(applec) || defined(THINK_C) || defined(__MWERKS__) && !defined(__KATANA__) - #include "::hashtable.h" + #include "::hashtable.h" #else - #include "../hashtable.h" + #include "../hashtable.h" #endif struct GServerImplementation { - unsigned long ip; - unsigned short port; - short ping; - GQueryType querytype; - HashTable keyvals; - HashTable keylist; + unsigned long ip; + unsigned short port; + short ping; + GQueryType querytype; + HashTable keyvals; + HashTable keylist; }; typedef struct { - char *key; - char *value; + char *key; + char *value; } GKeyValuePair; /* typedef struct { - char *key, *value; + char *key, *value; } GKeyValuePair; */ typedef struct { - KeyEnumFn EnumFn; - void *instance; - HashTable keylist; + KeyEnumFn EnumFn; + void *instance; + HashTable keylist; } GEnumData; void ServerFree(void *elem); +GServer ServerNewData(char **fieldlist, int fieldcount, char *serverdata, GQueryType qtype, HashTable keylist); GServer ServerNew(unsigned long ip, unsigned short port, GQueryType qtype, HashTable keylist); void ServerParseKeyVals(GServer server, char *keyvals); int GStringHash(const void *elem, int numbuckets); diff --git a/code/gamespy/gserverlist.c b/code/gamespy/gserverlist.c index 378c3eac..fefd9f31 100644 --- a/code/gamespy/gserverlist.c +++ b/code/gamespy/gserverlist.c @@ -19,19 +19,37 @@ Fax(714)549-0757 for this SDK. It also has a change history for the SDK. ******/ + +/** + * The following modifications were made: + * + * 1) Non-blocking server list sockets. List requests are asynchronous and won't block the game. The only blocking request could be due to DNS resolution. + * 2) Server list sockets will timeout after 10 seconds of no reply. + * 3) Parallel server list requests. + * 3.1) A pool of sockets is initially created + * 3.2) The server list connects idling sockets to available masters, afterwards the server list state is set to `sl_listxfer`. + * 3.3) The server list sends the list request to connected masters, and receives the data for each. + * 3.4) When finished fetching 1 master (got `\final`), the server list state transitions to `sl_querying`. + * 3.5) The server list queries all fetched servers. It can still continue fetching list from currently connected masters + * but it will not connect to other masters while servers are being queried. It won't be sending more queries if remaining masters replied in under 500 ms. + * 3.6) When finished querying all fetched servers, the server list restarts from 3.2 and queries next masters. + * + * The idea here is to ensure the redundancy of the server list between multiple masters even if the results are combined. + * Optionally for best results, the game should return a list of masters from the same community. + */ #include "goaceng.h" #include "gserver.h" #if defined(applec) || defined(THINK_C) || defined(__MWERKS__) && !defined(__KATANA__) - #include "::nonport.h" + #include "::nonport.h" #else - #include "../nonport.h" + #include "../nonport.h" #endif #ifdef _MACOS - #include "::darray.h" - #include "::hashtable.h" + #include "::darray.h" + #include "::hashtable.h" #else - #include "../darray.h" - #include "../hashtable.h" + #include "../darray.h" + #include "../hashtable.h" #endif #include "common/gsPlatformSocket.h" #include "gutil.h" @@ -45,10 +63,24 @@ Fax(714)549-0757 #include #include -#define MSHOST MASTER_SERVER_HOST -#define MSPORT 28900 +// Added in 2.0 +#include "gcrypt.h" + +/** + * @brief Custom function used to return the master host, based on game settings + * + * @return const char* The master host + */ +extern unsigned int ServerListGetNumMasters(); +extern const char *ServerListGetHost(int index); +extern int ServerListGetMsPort(int index); + +//#define MSHOST ServerListGetHost(0) +//#define MSPORT ServerListGetMsPort(0) #define SERVER_GROWBY 64 #define LAN_SEARCH_TIME 3000 //3 sec +#define SERVER_QUERY_MAX_PAUSE 500 +#define INTERNET_SEARCH_TIME 10000 //10 sec #define LIST_NUMKEYBUCKETS 500 #define LIST_NUMKEYCHAINS 4 @@ -60,33 +92,58 @@ extern "C" { //todo: check state changes on error typedef struct { - SOCKET s; - GServer currentserver; - unsigned long starttime; - struct sockaddr_in saddr; + SOCKET s; + GServer currentserver; + unsigned long starttime; + struct sockaddr_in saddr; } UpdateInfo; +typedef enum { pi_fieldcount, pi_fields, pi_servers } GParseInfoState; +typedef enum { ls_none, ls_connecting, ls_connected } GListSocketState; +typedef struct GServerListSocketImplementation +{ + SOCKET s; + GListSocketState socketstate; + char data[2048]; + int oldlen; + gsi_time lastreplytime; + GCryptInfo cryptinfo; +} *GServerListSocket; struct GServerListImplementation { - GServerListState state; - DArray servers; - UpdateInfo *updatelist; //dynamic array of updateinfos - char gamename[32]; - char seckey[32]; - char enginename[32]; - int maxupdates; - int nextupdate; - int abortupdate; - ListCallBackFn CallBackFn; - void *instance; - char *sortkey; - gbool sortascending; - SOCKET slsocket; - unsigned long lanstarttime; - GQueryType querytype; - HashTable keylist; + GServerListState state; + DArray servers; + UpdateInfo *updatelist; //dynamic array of updateinfos + char gamename[32]; + char seckey[32]; + char enginename[32]; + char filter[256]; + int maxupdates; + int nextupdate; + int abortupdate; + ListCallBackFn CallBackFn; + void *instance; + char *sortkey; + gbool sortascending; + GServerListSocket slsockets; + int numslsockets; + int startslindex; + gsi_time lastsltime; + unsigned long lanstarttime; + GQueryType querytype; + HashTable keylist; + + // Added in 2.0 + int numservers; + // Added in 2.0 + //GCryptInfo cryptinfo; + // Added in OPM + int encryptdata; + gbool async; + + GParseInfoState pistate; }; GServerList g_sortserverlist; //global serverlist for sorting info!! @@ -94,39 +151,57 @@ GServerList g_sortserverlist; //global serverlist for sorting info!! /* these correspond to the qt_ constants */ #define NUM_QUERYTYPES 6 const char *querystrings[NUM_QUERYTYPES] = {"\\basic\\","\\info\\","\\rules\\", - "\\players\\","\\info\\\\rules\\","\\status\\"}; + "\\players\\","\\info\\\\rules\\","\\status\\"}; const int querylengths[NUM_QUERYTYPES] = {7,6,7,9,13,8}; static void KeyValFree(void *elem); static int KeyValCompareKeyA(const void *entry1, const void *entry2); static int KeyValHashKeyA(const void *elem, int numbuckets); - +static gbool ServerListHasFinishedFetchingList(GServerList serverlist); /* ServerListNew ---------------- Creates and returns a new (empty) GServerList. */ GServerList ServerListNew(const char *gamename, const char *enginename, const char *seckey, int maxconcupdates, void *CallBackFn, int CallBackFnType, void *instance) { - GServerList list; + GServerList list; - list = (GServerList) malloc(sizeof(struct GServerListImplementation)); - assert(list != NULL); - list->state = sl_idle; - list->servers = ArrayNew(sizeof(GServer), SERVER_GROWBY, ServerFree); - list->keylist = TableNew2(sizeof(char *),LIST_NUMKEYBUCKETS,LIST_NUMKEYCHAINS,GStringHash, GCaseInsensitiveCompare, GStringFree); - list->maxupdates = maxconcupdates; - list->updatelist = malloc(maxconcupdates * sizeof(UpdateInfo)); - memset(list->updatelist, 0, maxconcupdates * sizeof(UpdateInfo)); - assert(list->updatelist != NULL); - strcpy(list->gamename, gamename); - strcpy(list->seckey, seckey); - strcpy(list->enginename, enginename); - list->CallBackFn = CallBackFn; - assert(CallBackFn != NULL); - list->instance = instance; - list->sortkey = ""; - SocketStartUp(); - return list; + list = (GServerList) malloc(sizeof(struct GServerListImplementation)); + assert(list != NULL); + list->state = sl_idle; + list->servers = ArrayNew(sizeof(GServer), SERVER_GROWBY, ServerFree); + list->keylist = TableNew2(sizeof(char *),LIST_NUMKEYBUCKETS,LIST_NUMKEYCHAINS,GStringHash, GCaseInsensitiveCompare, GStringFree); + list->maxupdates = maxconcupdates; + list->updatelist = malloc(maxconcupdates * sizeof(UpdateInfo)); + memset(list->updatelist, 0, maxconcupdates * sizeof(UpdateInfo)); + assert(list->updatelist != NULL); + strcpy(list->gamename, gamename); + strcpy(list->seckey, seckey); + strcpy(list->enginename, enginename); + list->CallBackFn = CallBackFn; + assert(CallBackFn != NULL); + list->instance = instance; + list->sortkey = ""; + // Added in 2.0 + list->numservers = 0; + // Added in OPM + list->encryptdata = 1; + list->async = 0; + + list->numslsockets = maxconcupdates / 4; + if (list->numslsockets < 1) { + list->numslsockets = 1; + } else if (list->numslsockets > 4) { + // Above 4 seems too much + list->numslsockets = 4; + } + list->slsockets = (GServerListSocket)malloc(sizeof(struct GServerListSocketImplementation) * list->numslsockets); + memset(list->slsockets, 0, sizeof(struct GServerListSocketImplementation) * list->numslsockets); + list->startslindex = 0; + list->lastsltime = current_time(); + + SocketStartUp(); + return list; } /* ServerListFree @@ -134,33 +209,34 @@ GServerList ServerListNew(const char *gamename, const char *enginename, const ch Free a GServerList and all internal sturctures and servers */ void ServerListFree(GServerList serverlist) { - ArrayFree(serverlist->servers); - TableFree(serverlist->keylist); - free(serverlist->updatelist); + ArrayFree(serverlist->servers); + TableFree(serverlist->keylist); + free(serverlist->updatelist); + free(serverlist->slsockets); - free(serverlist); - SocketShutDown(); + free(serverlist); + SocketShutDown(); } //create update sockets and init structures static GError InitUpdateList(GServerList serverlist) { - int i; + int i; - for (i = 0 ; i < serverlist->maxupdates ; i++) - { - serverlist->updatelist[i].s = socket(AF_INET, SOCK_DGRAM,IPPROTO_UDP); - if (serverlist->updatelist[i].s == INVALID_SOCKET) - { //ran out of sockets, just cap maxupdates here, unless we don't have any - if (i == 0) - return GE_NOSOCKET; - serverlist->maxupdates = i; - return 0; - } - serverlist->updatelist[i].currentserver = NULL; - serverlist->updatelist[i].starttime = 0; - } - return 0; + for (i = 0 ; i < serverlist->maxupdates ; i++) + { + serverlist->updatelist[i].s = socket(AF_INET, SOCK_DGRAM,IPPROTO_UDP); + if (serverlist->updatelist[i].s == INVALID_SOCKET) + { //ran out of sockets, just cap maxupdates here, unless we don't have any + if (i == 0) + return GE_NOSOCKET; + serverlist->maxupdates = i; + return 0; + } + serverlist->updatelist[i].currentserver = NULL; + serverlist->updatelist[i].starttime = 0; + } + return 0; } @@ -168,61 +244,105 @@ static GError InitUpdateList(GServerList serverlist) //free update sockets static GError FreeUpdateList(GServerList serverlist) { - int i; - for (i = 0 ; i < serverlist->maxupdates ; i++) - { - closesocket(serverlist->updatelist[i].s); - } - return 0; + int i; + for (i = 0 ; i < serverlist->maxupdates ; i++) + { + closesocket(serverlist->updatelist[i].s); + } + return 0; } //create and connect a server list socket -static GError CreateServerListSocket(GServerList serverlist) +static GError CreateServerListSocket(GServerList serverlist, GServerListSocket slsocket, gbool async) { - struct sockaddr_in saddr; - struct hostent *hent; + struct sockaddr_in saddr; + struct hostent *hent; + int lasterr; + int i; + int port; + const char *host; - saddr.sin_family = AF_INET; - saddr.sin_port = htons(MSPORT); - saddr.sin_addr.s_addr = inet_addr(MSHOST); - if (saddr.sin_addr.s_addr == INADDR_NONE) - { - hent = gethostbyname(MSHOST); - if (!hent) - return GE_NODNS; - saddr.sin_addr.s_addr = *(u_long *)hent->h_addr_list[0]; - } - serverlist->slsocket = socket ( AF_INET, SOCK_STREAM, IPPROTO_TCP ); - if (serverlist->slsocket == INVALID_SOCKET) - return GE_NOSOCKET; - if (connect ( serverlist->slsocket, (struct sockaddr *) &saddr, sizeof saddr ) != 0) - { - closesocket(serverlist->slsocket); - return GE_NOCONNECT; - } + if (serverlist->startslindex >= ServerListGetNumMasters()) { + return GE_NODNS; + } - //else we are connected - return 0; + if (slsocket->socketstate != ls_none) { + closesocket(slsocket->s); + slsocket->s = INVALID_SOCKET; + } + + port = ServerListGetMsPort(serverlist->startslindex); + host = ServerListGetHost(serverlist->startslindex); + + saddr.sin_family = AF_INET; + saddr.sin_port = htons(port); + saddr.sin_addr.s_addr = inet_addr(host); + if (saddr.sin_addr.s_addr == INADDR_NONE) + { + hent = gethostbyname(host); + if (!hent) + return GE_NODNS; + saddr.sin_addr.s_addr = *(u_long *)hent->h_addr_list[0]; + } + slsocket->s = socket ( AF_INET, SOCK_STREAM, IPPROTO_TCP ); + if (slsocket->s == INVALID_SOCKET) + return GE_NOSOCKET; + + if (async) { + SetSockBlocking(slsocket->s, 0); + } + + if (connect ( slsocket->s, (struct sockaddr *) &saddr, sizeof saddr ) != 0 + && (lasterr = GOAGetLastError(slsocket->slsocket), lasterr != WSAEWOULDBLOCK && lasterr != WSAEINPROGRESS)) + { + closesocket(slsocket->s); + slsocket->s = INVALID_SOCKET; + return GE_NOCONNECT; + } + + slsocket->socketstate = ls_connecting; + slsocket->oldlen = 0; + slsocket->cryptinfo.offset = -1; + slsocket->lastreplytime = current_time(); + serverlist->startslindex++; + + //else we are connected + return 0; } +//create and connect a server list sockets +static GError CreateServerListForAvailableSockets(GServerList serverlist, gbool async) +{ + int i; + + for(i = 0; i < serverlist->numslsockets; i++) { + if (serverlist->slsockets[i].socketstate == ls_none) { + CreateServerListSocket(serverlist, &serverlist->slsockets[i], async); + } + } + + return 0; +} + //create and connect a server list socket static GError CreateServerListLANSocket(GServerList serverlist) { - int optval = 1; + int optval = 1; + GServerListSocket slsocket = &serverlist->slsockets[0]; - serverlist->slsocket = socket ( AF_INET, SOCK_DGRAM, IPPROTO_UDP ); - if (serverlist->slsocket == INVALID_SOCKET) - return GE_NOSOCKET; - if (setsockopt(serverlist->slsocket, SOL_SOCKET, SO_BROADCAST, (char *)&optval, sizeof(optval)) != 0) - return GE_NOSOCKET; + slsocket->s = socket ( AF_INET, SOCK_DGRAM, IPPROTO_UDP ); + if (slsocket->s == INVALID_SOCKET) + return GE_NOSOCKET; + if (setsockopt(slsocket->s, SOL_SOCKET, SO_BROADCAST, (char *)&optval, sizeof(optval)) != 0) + return GE_NOSOCKET; - //else we are ready to broadcast - return 0; + //else we are ready to broadcast + return 0; } @@ -230,69 +350,99 @@ static GError CreateServerListLANSocket(GServerList serverlist) //trigger the callback and set the new mode static void ServerListModeChange(GServerList serverlist, GServerListState newstate) { - serverlist->state = newstate; - serverlist->CallBackFn(serverlist, LIST_STATECHANGED, serverlist->instance, NULL, NULL); + serverlist->state = newstate; + serverlist->CallBackFn(serverlist, LIST_STATECHANGED, serverlist->instance, NULL, NULL); } // validate us to the master and send a list request #define SECURE "\\secure\\" -static GError SendListRequest(GServerList serverlist, char *filter) +static GError SendListRequest(GServerList serverlist, GServerListSocket slsocket, char *filter) { - char data[256], *ptr, result[64]; - int len; + char data[256], *ptr, result[64]; + int len; + int i; + char *modifier; + + len = recv(slsocket->s, data, sizeof(data) - 1, 0); + if (gsiSocketIsError(len)) { + return GE_NOCONNECT; + } + data[len] = '\0'; //null terminate it + + ptr = strstr ( data, SECURE ); + if (!ptr) + return GE_DATAERROR; + ptr = ptr + strlen(SECURE); + gs_encrypt ( (uchar *) serverlist->seckey, 6, (uchar *)ptr, 6 ); + if (serverlist->encryptdata) { + // Added in 2.0 + for(i = 0; i < 6; i++) { + ptr[i] ^= serverlist->seckey[i]; + } + } + gs_encode ( (uchar *)ptr, 6, (uchar *) result ); - - len = recv(serverlist->slsocket, data, sizeof(data) - 1, 0); - if (gsiSocketIsError(len)) - return GE_NOCONNECT; - data[len] = '\0'; //null terminate it - - ptr = strstr ( data, SECURE ); - if (!ptr) - return GE_DATAERROR; - ptr = ptr + strlen(SECURE); - gs_encrypt ( (uchar *) serverlist->seckey, 6, (uchar *)ptr, 6 ); - gs_encode ( (uchar *)ptr, 6, (uchar *) result ); + if (serverlist->encryptdata) { + // Added in 2.0 + // Encrypt data + //validate to the master + sprintf(data, "\\gamename\\%s\\gamever\\%s\\location\\0\\validate\\%s\\enctype\\2\\final\\\\queryid\\1.1\\", + serverlist->enginename, "2", result); //validate us + } else { + //validate to the master + sprintf(data, "\\gamename\\%s\\gamever\\%s\\location\\0\\validate\\%s\\final\\\\queryid\\1.1\\", + serverlist->enginename, ENGINE_VERSION, result); //validate us + } + + len = send ( slsocket->s, data, strlen(data), 0 ); + if (gsiSocketIsError(len) || len == 0) + return GE_NOCONNECT; - //validate to the master - sprintf(data, "\\gamename\\%s\\gamever\\%s\\location\\0\\validate\\%s\\final\\\\queryid\\1.1\\", - serverlist->enginename, ENGINE_VERSION, result); //validate us - - len = send ( serverlist->slsocket, data, strlen(data), 0 ); - if (gsiSocketIsError(len) || len == 0) - return GE_NOCONNECT; + if (serverlist->querytype == qt_grouprooms) { + modifier = "groups"; - //send the list request - if (filter) - sprintf(data, "\\list\\cmp\\gamename\\%s\\where\\%s\\final\\", serverlist->gamename, filter); - else - sprintf(data, "\\list\\cmp\\gamename\\%s\\final\\", serverlist->gamename); - len = send ( serverlist->slsocket, data, strlen(data), 0 ); - if (gsiSocketIsError(len) || len == 0) - return GE_NOCONNECT; + serverlist->pistate = pi_fieldcount; + } else if (serverlist->querytype == qt_masterinfo) { + modifier = "info2"; - ServerListModeChange(serverlist, sl_listxfer); - return 0; + serverlist->pistate = pi_fieldcount; + } else { + modifier = "cmp"; + } + + //send the list request + if (filter) + sprintf(data, "\\list\\%s\\gamename\\%s\\where\\%s\\final\\", modifier, serverlist->gamename, filter); + else + sprintf(data, "\\list\\%s\\gamename\\%s\\final\\", modifier, serverlist->gamename); + len = send ( slsocket->s, data, strlen(data), 0 ); + if (gsiSocketIsError(len) || len == 0) + return GE_NOCONNECT; + + if (serverlist->state == sl_idle) { + ServerListModeChange(serverlist, sl_listxfer); + } + return 0; } static GError SendBroadcastRequest(GServerList serverlist, int startport, int endport, int delta) { - struct sockaddr_in saddr; - short i; + struct sockaddr_in saddr; + short i; - saddr.sin_family = AF_INET; - saddr.sin_addr.s_addr = 0xFFFFFFFF; //broadcast - for (i = startport ; i <= endport ; i += delta) - { - saddr.sin_port = htons(i); - sendto(serverlist->slsocket, "\\status\\",8,0,(struct sockaddr *)&saddr,sizeof(saddr)); - } - ServerListModeChange(serverlist, sl_lanlist); - serverlist->lanstarttime = current_time(); - return 0; + saddr.sin_family = AF_INET; + saddr.sin_addr.s_addr = 0xFFFFFFFF; //broadcast + for (i = startport ; i <= endport ; i += delta) + { + saddr.sin_port = htons(i); + sendto(serverlist->slsockets[0].s, "\\status\\",8,0,(struct sockaddr *)&saddr,sizeof(saddr)); + } + ServerListModeChange(serverlist, sl_lanlist); + serverlist->lanstarttime = current_time(); + return 0; @@ -301,13 +451,13 @@ static GError SendBroadcastRequest(GServerList serverlist, int startport, int en //just wait for the server list to become idle static void DoSyncLoop(GServerList serverlist) { - while (serverlist->state != sl_idle) - { - ServerListThink(serverlist); - msleep(10); - - } - + while (serverlist->state != sl_idle) + { + ServerListThink(serverlist); + msleep(10); + + } + } /* ServerListUpdate @@ -315,7 +465,71 @@ static void DoSyncLoop(GServerList serverlist) Start updating a GServerList without filters */ GError ServerListUpdate(GServerList serverlist, gbool async) { - return ServerListUpdate2(serverlist, async, NULL, qt_status); + return ServerListUpdate2(serverlist, async, NULL, qt_status); +} + +/* ServerListCheckSocketError +------------------------- +Verify if the server list socket has an error or has timed out, and abort. */ +GError ServerListCheckSocketError(GServerList serverlist, GServerListSocket slsocket) +{ + int so_error; + int len = sizeof(so_error); + getsockopt(slsocket->s, SOL_SOCKET, SO_ERROR, &so_error, &len); + + // Abort if the socket has an error or if it connect/recv has timed out + if (so_error || current_time() >= slsocket->lastreplytime + INTERNET_SEARCH_TIME) { + closesocket(slsocket->s); + slsocket->s = INVALID_SOCKET; + slsocket->socketstate = ls_none; + return GE_NOCONNECT; + } + + return 0; +} + +/* ServerListStartQuery +------------------------- +Start querying a GServerList. */ +GError ServerListStartQuery(GServerList serverlist, GServerListSocket slsocket, gbool async) +{ + GError error; + int i; + + if (slsocket->socketstate != ls_connecting) { + return GE_BUSY; + } + + if (serverlist->abortupdate) { + for(i = 0; i < serverlist->numslsockets; i++) { + closesocket(serverlist->slsockets[i].s); + serverlist->slsockets[i].s = INVALID_SOCKET; + } + ServerListModeChange(serverlist, sl_idle); + return GE_NOCONNECT; + } + + if (async) { + // Check for pending data + char buf; + if (recv(slsocket->s, &buf, 1, MSG_PEEK) == -1) { + return GE_BUSY; + } + } + + slsocket->socketstate = ls_connected; + + error = SendListRequest(serverlist, slsocket, serverlist->filter); + if (error) return error; + if (serverlist->querytype != qt_grouprooms && serverlist->querytype != qt_masterinfo) { + error = InitUpdateList(serverlist); + if (error) return error; + } + + if (!async) + DoSyncLoop(serverlist); + + return 0; } /* ServerListUpdate2 @@ -323,24 +537,41 @@ GError ServerListUpdate(GServerList serverlist, gbool async) Start updating a GServerList. */ GError ServerListUpdate2(GServerList serverlist, gbool async, char *filter, GQueryType querytype) { - GError error; + GError error; + int i; - if (serverlist->state != sl_idle) - return GE_BUSY; + if (serverlist->state != sl_idle) + return GE_BUSY; - serverlist->querytype = querytype; - error = CreateServerListSocket(serverlist); - if (error) return error; - error = SendListRequest(serverlist, filter); - if (error) return error; - error = InitUpdateList(serverlist); - if (error) return error; - serverlist->nextupdate = 0; - serverlist->abortupdate = 0; - if (!async) - DoSyncLoop(serverlist); + serverlist->querytype = querytype; + error = CreateServerListForAvailableSockets(serverlist, async); + //if (error) return error; - return 0; + serverlist->nextupdate = 0; + serverlist->abortupdate = 0; + // Added in 2.0 + serverlist->numservers = ServerListCount(serverlist); + // Added in 2.0 + //serverlist->cryptinfo.offset = -1; + if (filter) { + strncpy(serverlist->filter, filter, sizeof(serverlist->filter)); + } else { + serverlist->filter[0] = 0; + } + + serverlist->async = async; + + if (async) { + // As it's asynchronous, set the state to transfering + ServerListModeChange(serverlist, sl_listxfer); + return 0; + } + + for(i = 0; i < serverlist->numslsockets; i++) { + ServerListStartQuery(serverlist, &serverlist->slsockets[i], async); + } + + return 0; } /* ServerListLANUpdate @@ -348,75 +579,90 @@ GError ServerListUpdate2(GServerList serverlist, gbool async, char *filter, GQue Start updating a GServerList from servers on the LAN. */ GError ServerListLANUpdate(GServerList serverlist, gbool async, int startsearchport, int endsearchport, int searchdelta) { - GError error; + GError error; - assert(searchdelta > 0); + assert(searchdelta > 0); - if (serverlist->state != sl_idle) - return GE_BUSY; + if (serverlist->state != sl_idle) + return GE_BUSY; - error = InitUpdateList(serverlist); - if (error) return error; - error = CreateServerListLANSocket(serverlist); - if (error) return error; - error = SendBroadcastRequest(serverlist, startsearchport, endsearchport, searchdelta); - if (error) return error; - serverlist->nextupdate = 0; - serverlist->abortupdate = 0; - if (!async) - DoSyncLoop(serverlist); + error = InitUpdateList(serverlist); + if (error) return error; + error = CreateServerListLANSocket(serverlist); + if (error) return error; + error = SendBroadcastRequest(serverlist, startsearchport, endsearchport, searchdelta); + if (error) return error; + serverlist->nextupdate = 0; + serverlist->abortupdate = 0; + if (!async) + DoSyncLoop(serverlist); - return 0; + return 0; } +//add a new server based on the data +static GServer ServerListAddServerData(GServerList serverlist, char **fieldlist, int fieldcount, char *serverdata, GQueryType qtype) +{ + GServer server; + + server = ServerNewData(fieldlist, fieldcount, serverdata, qtype, serverlist->keylist); + ArrayAppend(serverlist->servers, &server); + return server; +} //add the server to the list with the given ip, port static void ServerListAddServer(GServerList serverlist, unsigned long ip, unsigned short port, GQueryType qtype) { - GServer server; - server = ServerNew(ip, port, qtype, serverlist->keylist); - ArrayAppend(serverlist->servers,&server); + GServer server; + server = ServerNew(ip, port, qtype, serverlist->keylist); + ArrayAppend(serverlist->servers,&server); //printf("%d %s:%d\n",++count, ip,port); } //add the server to the list with the given ip, port static void ServerListInsertServer(GServerList serverlist, unsigned long ip, unsigned short port, int pos, GQueryType qtype) { - GServer server; - server = ServerNew(ip, port, qtype, serverlist->keylist); - ArrayInsertAt(serverlist->servers,&server,pos); + GServer server; + server = ServerNew(ip, port, qtype, serverlist->keylist); + ArrayInsertAt(serverlist->servers,&server,pos); //printf("%d %s:%d\n",++count, ip,port); } +//find the server in the list, returns -1 if it does not exist +static int ServerListFindServerMax(GServerList serverlist, unsigned int ip, int port, int count) +{ + int i; + GServer server; + + for (i = 0; i < count ; i++) + { + server = *(GServer *)ArrayNth(serverlist->servers,i); + if (port == ServerGetQueryPort(server) && ServerGetInetAddress(server)==ip) + { + return i; + } + } + return -1; +} + //find the server in the list, returns -1 if it does not exist static int ServerListFindServer(GServerList serverlist, unsigned int ip, int port) { - int i; - GServer server; - - for (i = 0; i < ArrayLength(serverlist->servers) ; i++) - { - server = *(GServer *)ArrayNth(serverlist->servers,i); - if (port == ServerGetQueryPort(server) && ServerGetInetAddress(server)==ip) - { - return i; - } - } - return -1; + return ServerListFindServerMax(serverlist, ip, port, ArrayLength(serverlist->servers)); } //finds the server in the list of servers currently being queried // returns -1 if it does not exist static int ServerListFindServerInUpdateList(GServerList serverlist, GServer server) { - int i; + int i; - for (i = 0 ; i < serverlist->maxupdates ; i++) - { - if (serverlist->updatelist[i].currentserver == server) - return i; - } - return -1; + for (i = 0 ; i < serverlist->maxupdates ; i++) + { + if (serverlist->updatelist[i].currentserver == server) + return i; + } + return -1; } /* ServerListRemoveServer @@ -424,22 +670,22 @@ static int ServerListFindServerInUpdateList(GServerList serverlist, GServer serv Removes a single server from the list. Frees the memory associated with the GServer */ void ServerListRemoveServer(GServerList serverlist, char *ip, int port) { - int currentindex = ServerListFindServer(serverlist, inet_addr(ip), port); - int updateindex; + int currentindex = ServerListFindServer(serverlist, inet_addr(ip), port); + int updateindex; - if (currentindex == -1) - return; //can't do anything, it doesn't exist + if (currentindex == -1) + return; //can't do anything, it doesn't exist - //check to see whether we need to change the updatelist or move the nextupdate - if (serverlist->state != sl_idle && serverlist->nextupdate > currentindex) - { - GServer holdserver = *(GServer *)ArrayNth(serverlist->servers,currentindex); - updateindex = ServerListFindServerInUpdateList(serverlist, holdserver); - if (updateindex != -1) //is currently being queried, stop it - serverlist->updatelist[updateindex].currentserver = NULL; - serverlist->nextupdate--; //decrement the next update, since we are removing a server - } - ArrayDeleteAt(serverlist->servers, currentindex); + //check to see whether we need to change the updatelist or move the nextupdate + if (serverlist->state != sl_idle && serverlist->nextupdate > currentindex) + { + GServer holdserver = *(GServer *)ArrayNth(serverlist->servers,currentindex); + updateindex = ServerListFindServerInUpdateList(serverlist, holdserver); + if (updateindex != -1) //is currently being queried, stop it + serverlist->updatelist[updateindex].currentserver = NULL; + serverlist->nextupdate--; //decrement the next update, since we are removing a server + } + ArrayDeleteAt(serverlist->servers, currentindex); } /* ServerListUpdate @@ -448,159 +694,297 @@ Adds an auxilliary (non-fetched) server to the update list. If the engine is idle, the server is added and the engine started. */ GError ServerListAuxUpdate(GServerList serverlist, const char *ip, int port, gbool async, GQueryType querytype) { - GError error; - int currentindex; - int updateindex; - unsigned int real_ip = inet_addr(ip); - //first, see if the server already exists - currentindex = ServerListFindServer(serverlist,real_ip,port); + GError error; + int currentindex; + int updateindex; + unsigned int real_ip = inet_addr(ip); + //first, see if the server already exists + currentindex = ServerListFindServer(serverlist,real_ip,port); - //if we're idle, start things up - if (serverlist->state == sl_idle) - { - //prepare as if we're going to do a normal list fetch, - //but skip the call to SendListRequest(). + //if we're idle, start things up + if (serverlist->state == sl_idle) + { + //prepare as if we're going to do a normal list fetch, + //but skip the call to SendListRequest(). - - error = InitUpdateList(serverlist); - if (error) return error; - if (currentindex != -1) //we need to "move" this server to the end of the list - { //move the server to the end of the array - GServer holdserver = *(GServer *)ArrayNth(serverlist->servers,currentindex); - holdserver->ping = 9999;//clear the ping so it gets recalculated - ArrayRemoveAt(serverlist->servers,currentindex); - ArrayAppend(serverlist->servers,&holdserver); - } else - { //add the aux server - ServerListAddServer(serverlist, real_ip, (unsigned short)port, querytype); - } - - serverlist->nextupdate = ArrayLength(serverlist->servers) - 1; - serverlist->abortupdate = 0; + + error = InitUpdateList(serverlist); + if (error) return error; + if (currentindex != -1) //we need to "move" this server to the end of the list + { //move the server to the end of the array + GServer holdserver = *(GServer *)ArrayNth(serverlist->servers,currentindex); + holdserver->ping = 9999;//clear the ping so it gets recalculated + ArrayRemoveAt(serverlist->servers,currentindex); + ArrayAppend(serverlist->servers,&holdserver); + } else + { //add the aux server + ServerListAddServer(serverlist, real_ip, (unsigned short)port, querytype); + } + + serverlist->nextupdate = ArrayLength(serverlist->servers) - 1; + serverlist->abortupdate = 0; - //chane the mode straight to querying - ServerListModeChange(serverlist, sl_querying); - //is it's a sync call, do it until done - if (!async) - DoSyncLoop(serverlist); + //chane the mode straight to querying + ServerListModeChange(serverlist, sl_querying); + //is it's a sync call, do it until done + if (!async) + DoSyncLoop(serverlist); - } - else - { - //if we're in the middle of an update, we should - //be able to just slip the aux server in for querying - //ServerListAddServer(serverlist, ip, port); - //crt -- make it the next server to be queried - //note: this should NEVER be called in a different thread from think!! - if (currentindex == -1) //it doesn't exist yet - ServerListInsertServer(serverlist, real_ip, (unsigned short)port, serverlist->nextupdate, querytype); - else - { //it exists, find out whats happening to it - GServer holdserver = *(GServer *)ArrayNth(serverlist->servers,currentindex); - if (currentindex >= serverlist->nextupdate) //hasn't been queried yet! - return 0; //it will be queried soon anyway - holdserver->ping = 9999;//clear the ping so it gets recalculated - updateindex = ServerListFindServerInUpdateList(serverlist, holdserver); - if (updateindex != -1) //is currently being queried, stop it - serverlist->updatelist[updateindex].currentserver = NULL; - ArrayInsertAt(serverlist->servers,&holdserver, serverlist->nextupdate); //insert at new place - ArrayRemoveAt(serverlist->servers,currentindex); //remove the old one - serverlist->nextupdate--; //decrement the next update, since we are removing a server - } - } - return 0; + } + else + { + //if we're in the middle of an update, we should + //be able to just slip the aux server in for querying + //ServerListAddServer(serverlist, ip, port); + //crt -- make it the next server to be queried + //note: this should NEVER be called in a different thread from think!! + if (currentindex == -1) //it doesn't exist yet + ServerListInsertServer(serverlist, real_ip, (unsigned short)port, serverlist->nextupdate, querytype); + else + { //it exists, find out whats happening to it + GServer holdserver = *(GServer *)ArrayNth(serverlist->servers,currentindex); + if (currentindex >= serverlist->nextupdate) //hasn't been queried yet! + return 0; //it will be queried soon anyway + holdserver->ping = 9999;//clear the ping so it gets recalculated + updateindex = ServerListFindServerInUpdateList(serverlist, holdserver); + if (updateindex != -1) //is currently being queried, stop it + serverlist->updatelist[updateindex].currentserver = NULL; + ArrayInsertAt(serverlist->servers,&holdserver, serverlist->nextupdate); //insert at new place + ArrayRemoveAt(serverlist->servers,currentindex); //remove the old one + serverlist->nextupdate--; //decrement the next update, since we are removing a server + } + } + return 0; } -static GError ServerListLANList(GServerList serverlist) +static GError ServerListLANList(GServerList serverlist, GServerListSocket slsocket) { - struct timeval timeout = {0,0}; - fd_set set; - char indata[1500]; - struct sockaddr_in saddr; - int saddrlen = sizeof(saddr); - int error; - - while (1) //we break if the select fails - { - FD_ZERO(&set); - FD_SET( serverlist->slsocket, &set); - error = select(FD_SETSIZE, &set, NULL, NULL, &timeout); - if (gsiSocketIsError(error) || 0 == error) //no data - break; - error = recvfrom(serverlist->slsocket, indata, sizeof(indata) - 1, 0, (struct sockaddr *)&saddr, &saddrlen ); - if (gsiSocketIsError(error)) - continue; - //we got data, add the server to the list to update - if (strstr(indata,"\\final\\") != NULL) - ServerListAddServer(serverlist,saddr.sin_addr.s_addr, ntohs(saddr.sin_port), qt_status); - } - if (current_time() - serverlist->lanstarttime > LAN_SEARCH_TIME) //done waiting for replies - { - closesocket(serverlist->slsocket); - serverlist->slsocket = INVALID_SOCKET; - ServerListModeChange(serverlist, sl_querying); - } - return 0; + struct timeval timeout = {0,0}; + fd_set set; + char indata[1500]; + struct sockaddr_in saddr; + int saddrlen = sizeof(saddr); + int error; + while (1) //we break if the select fails + { + FD_ZERO(&set); + FD_SET( slsocket->s, &set); + error = select(FD_SETSIZE, &set, NULL, NULL, &timeout); + if (gsiSocketIsError(error) || 0 == error) //no data + break; + error = recvfrom(slsocket->s, indata, sizeof(indata) - 1, 0, (struct sockaddr *)&saddr, &saddrlen ); + if (gsiSocketIsError(error)) + continue; + //we got data, add the server to the list to update + if (strstr(indata,"\\final\\") != NULL) + ServerListAddServer(serverlist,saddr.sin_addr.s_addr, ntohs(saddr.sin_port), qt_status); + } + if (current_time() - serverlist->lanstarttime > LAN_SEARCH_TIME) //done waiting for replies + { + closesocket(slsocket->s); + slsocket->s = INVALID_SOCKET; + ServerListModeChange(serverlist, sl_querying); + } + return 0; } - + +static int CountSlashOffset(char *data, int len, int slashcount) +{ + char *p; + + for (p = data; slashcount && p != data + len; ++p) { + if (*p == '\\') { + slashcount--; + } + } + + if (slashcount) { + return -1; + } + + return p - data; +} + +//parses and retrieve servers based on fields +static int ServerListParseInfoList(GServerList serverlist, char *data, int len) +{ + char *fieldlist[20]; + char tempfield[64]; + char *tempptr; + static int fieldcount; + int offset; + int i; + GServer server; + + switch (serverlist->pistate) { + case pi_fieldcount: + offset = CountSlashOffset(data, len, 3); + if (offset == -1) { + return 0; + } + if (offset < 12) { + return 0; + } + + strncpy(tempfield, data + 12, offset - 12); + tempfield[offset - 13] = 0; + + fieldcount = atoi(tempfield); + if (fieldcount > 20) { + return -1; + } + + serverlist->pistate = pi_fields; + + for (i = 0; i < fieldcount; ++i) { + fieldlist[i] = 0; + } + + return offset - 1; + case pi_fields: + offset = CountSlashOffset(data, len, 2); + if (offset == -1) { + return 0; + } + + strncpy(tempfield, data + 1, offset - 2); + tempfield[offset - 2] = 0; + tempptr = goastrdup(tempfield); + + for (i = 0; i < fieldcount; ++i) { + if (!fieldlist[i]) { + fieldlist[i] = tempptr; + if (i == fieldcount - 1) { + serverlist->pistate = pi_servers; + } + return offset - 1; + } + } + + return -1; + case pi_servers: + offset = CountSlashOffset(data, len, fieldcount + 1); + if (offset == -1) { + return 0; + } + + server = ServerListAddServerData(serverlist, (char **)fieldlist, fieldcount, data, serverlist->querytype); + data[offset - 1] = '\\'; + serverlist->CallBackFn(serverlist, 2, serverlist->instance, server, 0); + return offset - 1; + default: + return -1; + } +} + //reads the server list from the socket and parses it -static GError ServerListReadList(GServerList serverlist) +static GError ServerListReadList(GServerList serverlist, GServerListSocket slsocket) { - static char data[2048]; //static input buffer - static int oldlen = 0; - fd_set set; - struct timeval timeout = {0,0}; - int len, i; - char *p; - unsigned long ip; - unsigned short port; + //static char data[2048]; //static input buffer + //static int oldlen = 0; + fd_set set; + struct timeval timeout = {0,0}; + int len, i; + char *p; + unsigned long ip; + unsigned short port; - FD_ZERO(&set); - FD_SET(serverlist->slsocket, &set); + FD_ZERO(&set); + FD_SET(slsocket->s, &set); #ifndef KGTRN_ACCESS - i = select( FD_SETSIZE, &set, NULL, NULL, &timeout ); - if (i <= 0) - return GE_NOERROR; + i = select( FD_SETSIZE, &set, NULL, NULL, &timeout ); + if (i <= 0) + return GE_NOERROR; #endif //append to data - len = recv(serverlist->slsocket, data + oldlen, sizeof(data) - oldlen - 1, 0); - if (gsiSocketIsError(len) || len == 0) - { - closesocket(serverlist->slsocket); - serverlist->slsocket = INVALID_SOCKET; - oldlen = 0; //clear data so it can be used again - ServerListHalt(serverlist); - ServerListModeChange(serverlist, sl_querying); - return GE_NOCONNECT; + len = recv(slsocket->s, slsocket->data + slsocket->oldlen, sizeof(slsocket->data) - slsocket->oldlen - 1, 0); + if (gsiSocketIsError(len) || len == 0) + { + closesocket(slsocket->s); + slsocket->s = INVALID_SOCKET; + slsocket->socketstate = ls_none; + slsocket->oldlen = 0; //clear data so it can be used again + //ServerListHalt(serverlist); + ServerListModeChange(serverlist, sl_querying); + return GE_NOCONNECT; - } - oldlen += len; + } - p = data; - while (p - data <= oldlen - 6) - { - if (strncmp(p,"\\final\\",7) == 0 || serverlist->abortupdate) - { - closesocket(serverlist->slsocket); - serverlist->slsocket = INVALID_SOCKET; - oldlen = 0; //clear data so it can be used again - ServerListModeChange(serverlist, sl_querying); - return 0; //get out!! - } - if (oldlen < 6) //no way it could be a full IP, quit - break; - memcpy(&ip,p,4); - p += 4; - memcpy(&port,p,2); - p += 2; - ServerListAddServer(serverlist,ip, ntohs(port), serverlist->querytype ); - } - oldlen = oldlen - (p - data); - memmove(data,p,oldlen); //shift it over - return 0; + slsocket->lastreplytime = current_time(); + serverlist->lastsltime = slsocket->lastreplytime; + + if (serverlist->encryptdata && slsocket->cryptinfo.offset != -1) { + // Added in 2.0 + crypt_docrypt(&slsocket->cryptinfo, slsocket->data + slsocket->oldlen, len); + } + + slsocket->oldlen += len; + + p = slsocket->data; + + if (!serverlist->encryptdata) { + slsocket->cryptinfo.offset = 0; + } else if (slsocket->cryptinfo.offset == -1) { + // Added in 2.0 + if (slsocket->oldlen > (*p ^ 0xEC)) { + *p ^= 0xEC; + len = strlen(serverlist->seckey); + for (i = 0; i < len; i++) { + p[i + 1] ^= serverlist->seckey[i]; + } + init_crypt_key((unsigned char *)p + 1, *p, &slsocket->cryptinfo); + p += *p + 1; + crypt_docrypt(&slsocket->cryptinfo, (unsigned char *)p, slsocket->oldlen - (p - slsocket->data)); + } + } + + if (slsocket->cryptinfo.offset != -1) + { + while (p - slsocket->data <= slsocket->oldlen - 6) + { + if (strncmp(p,"\\final\\",7) == 0 || serverlist->abortupdate) + { + closesocket(slsocket->s); + slsocket->s = INVALID_SOCKET; + slsocket->socketstate = ls_none; + slsocket->oldlen = 0; //clear data so it can be used again + if (serverlist->querytype == qt_grouprooms || serverlist->querytype == qt_masterinfo) { + ServerListModeChange(serverlist, sl_idle); + } else { + ServerListModeChange(serverlist, sl_querying); + } + return 0; //get out!! + } + if (slsocket->oldlen < 6) //no way it could be a full IP, quit + break; + + if (serverlist->querytype == qt_grouprooms || serverlist->querytype == qt_masterinfo) { + i = ServerListParseInfoList(serverlist, p, slsocket->oldlen - (p - slsocket->data)); + if (i < 0) { + serverlist->abortupdate = 1; + } else if (!i) { + // finished + break; + } + } else { + memcpy(&ip, p, 4); + p += 4; + memcpy(&port, p, 2); + p += 2; + // Added in 2.0 + // Skip adding the server if already exists + if (ServerListFindServer(serverlist, ip, ntohs(port)) == -1) { + ServerListAddServer(serverlist, ip, ntohs(port), serverlist->querytype); + } + } + } + } + slsocket->oldlen = slsocket->oldlen - (p - slsocket->data); + memmove(slsocket->data,p,slsocket->oldlen); //shift it over + return 0; } @@ -608,96 +992,172 @@ static GError ServerListReadList(GServerList serverlist) static GError ServerListQueryLoop(GServerList serverlist) { - int i, scount = 0, error, final; - fd_set set; - struct timeval timeout = {0,0}; - char indata[1500]; - struct sockaddr_in saddr; - int saddrlen = sizeof(saddr); - GServer server; + int i, scount = 0, error, final; + fd_set set; + struct timeval timeout = {0,0}; + char indata[1500]; + struct sockaddr_in saddr; + int saddrlen = sizeof(saddr); + GServer server; //first, check for available data - FD_ZERO(&set); - for (i = 0 ; i < serverlist->maxupdates ; i++) - if (serverlist->updatelist[i].currentserver != NULL) //there is a server waiting - { - scount++; - FD_SET( serverlist->updatelist[i].s, &set); + FD_ZERO(&set); + for (i = 0 ; i < serverlist->maxupdates ; i++) + if (serverlist->updatelist[i].currentserver != NULL) //there is a server waiting + { + scount++; + FD_SET( serverlist->updatelist[i].s, &set); - } - if (scount > 0) //there are sockets to check for data - { + } + if (scount > 0) //there are sockets to check for data + { - error = select(FD_SETSIZE, &set, NULL, NULL, &timeout); - if (!gsiSocketIsError(error) && 0 != error) - for (i = 0 ; i < serverlist->maxupdates ; i++) - if (serverlist->updatelist[i].currentserver != NULL && FD_ISSET(serverlist->updatelist[i].s, &set) ) //there is a server waiting - { //we can read data!! - saddrlen = sizeof(saddr); - error = recvfrom(serverlist->updatelist[i].s, indata, sizeof(indata) - 1, 0,(struct sockaddr *)&saddr, &saddrlen); + error = select(FD_SETSIZE, &set, NULL, NULL, &timeout); + if (!gsiSocketIsError(error) && 0 != error) + for (i = 0 ; i < serverlist->maxupdates ; i++) + if (serverlist->updatelist[i].currentserver != NULL && FD_ISSET(serverlist->updatelist[i].s, &set) ) //there is a server waiting + { //we can read data!! + saddrlen = sizeof(saddr); + error = recvfrom(serverlist->updatelist[i].s, indata, sizeof(indata) - 1, 0,(struct sockaddr *)&saddr, &saddrlen); - if (saddr.sin_addr.s_addr != serverlist->updatelist[i].saddr.sin_addr.s_addr || - saddr.sin_port != serverlist->updatelist[i].saddr.sin_port) - continue; //it wasn't from this server + if (saddr.sin_addr.s_addr != serverlist->updatelist[i].saddr.sin_addr.s_addr || + saddr.sin_port != serverlist->updatelist[i].saddr.sin_port) + continue; //it wasn't from this server + + if (!gsiSocketIsError(error)) //we got data + { + indata[error] = 0; //truncate and parse it + final = (strstr(indata,"\\final\\") != NULL); + server = serverlist->updatelist[i].currentserver; + if (server->ping == 9999) //set the ping + server->ping = (short)(current_time() - serverlist->updatelist[i].starttime); + ServerParseKeyVals(server, indata); + if (final) //it's all done + { + serverlist->CallBackFn(serverlist, + LIST_PROGRESS, + serverlist->instance, + server, + (void *)((serverlist->nextupdate * 100) / ArrayLength(serverlist->servers))); //percent done + serverlist->updatelist[i].currentserver = NULL; //reuse the updatelist + } + } else + serverlist->updatelist[i].currentserver = NULL; //reuse the updatelist + + } + } + //kill expired ones + for (i = 0 ; i < serverlist->maxupdates ; i++) + if (serverlist->updatelist[i].currentserver != NULL && current_time() - serverlist->updatelist[i].starttime > SERVER_TIMEOUT ) + { + /* serverlist->CallBackFn(serverlist, //do we want to notify of dead servers? if so, uncomment! + LIST_PROGRESS, + serverlist->instance, + *(GServer *)serverlist->updatelist[i].currentserver, + (void *)((serverlist->nextupdate * 100) / ArrayLength(serverlist->servers))); //percent done + */ + serverlist->updatelist[i].currentserver = NULL; //reuse the updatelist + } + + if (serverlist->abortupdate || (serverlist->nextupdate >= ArrayLength(serverlist->servers) && scount == 0)) + { //we are done!! + FreeUpdateList(serverlist); + if (serverlist->abortupdate) { + ServerListModeChange(serverlist, sl_idle); + return 0; + } + + if (serverlist->startslindex < ServerListGetNumMasters() || !ServerListHasFinishedFetchingList(serverlist)) { + ServerListModeChange(serverlist, sl_listxfer); + } else { + // No more masters + ServerListModeChange(serverlist, sl_idle); + } + return 0; + } + + if (!ServerListHasFinishedFetchingList(serverlist) && current_time() < serverlist->lastsltime + SERVER_QUERY_MAX_PAUSE) { + // Make sure to not send out other queries if currently fetching from other lists + // to avoid overloading the network + return GE_BUSY; + } - if (!gsiSocketIsError(error)) //we got data - { - indata[error] = 0; //truncate and parse it - final = (strstr(indata,"\\final\\") != NULL); - server = serverlist->updatelist[i].currentserver; - if (server->ping == 9999) //set the ping - server->ping = (short)(current_time() - serverlist->updatelist[i].starttime); - ServerParseKeyVals(server, indata); - if (final) //it's all done - { - serverlist->CallBackFn(serverlist, - LIST_PROGRESS, - serverlist->instance, - server, - (void *)((serverlist->nextupdate * 100) / ArrayLength(serverlist->servers))); //percent done - serverlist->updatelist[i].currentserver = NULL; //reuse the updatelist - } - } else - serverlist->updatelist[i].currentserver = NULL; //reuse the updatelist - - } - } - //kill expired ones - for (i = 0 ; i < serverlist->maxupdates ; i++) - if (serverlist->updatelist[i].currentserver != NULL && current_time() - serverlist->updatelist[i].starttime > SERVER_TIMEOUT ) - { - /* serverlist->CallBackFn(serverlist, //do we want to notify of dead servers? if so, uncomment! - LIST_PROGRESS, - serverlist->instance, - *(GServer *)serverlist->updatelist[i].currentserver, - (void *)((serverlist->nextupdate * 100) / ArrayLength(serverlist->servers))); //percent done - */ - serverlist->updatelist[i].currentserver = NULL; //reuse the updatelist - } - - if (serverlist->abortupdate || (serverlist->nextupdate >= ArrayLength(serverlist->servers) && scount == 0)) - { //we are done!! - FreeUpdateList(serverlist); - ServerListModeChange(serverlist, sl_idle); - return 0; - } - //now, send out queries on available sockets - for (i = 0 ; i < serverlist->maxupdates && serverlist->nextupdate < ArrayLength(serverlist->servers) ; i++) - if (serverlist->updatelist[i].currentserver == NULL) //it's availalbe - { - server = *(GServer *)ArrayNth(serverlist->servers,serverlist->nextupdate); - serverlist->nextupdate++; - serverlist->updatelist[i].currentserver = server; - serverlist->updatelist[i].saddr.sin_family = AF_INET; - serverlist->updatelist[i].saddr.sin_addr.s_addr = inet_addr(ServerGetAddress(server)); - serverlist->updatelist[i].saddr.sin_port = htons((short)ServerGetQueryPort(server)); - sendto(serverlist->updatelist[i].s,querystrings[server->querytype] ,querylengths[server->querytype],0,(struct sockaddr *)&serverlist->updatelist[i].saddr,sizeof(struct sockaddr_in)); - serverlist->updatelist[i].starttime = current_time(); - } + for (i = 0 ; i < serverlist->maxupdates && serverlist->nextupdate < ArrayLength(serverlist->servers) ; i++) + if (serverlist->updatelist[i].currentserver == NULL) //it's availalbe + { + server = *(GServer *)ArrayNth(serverlist->servers,serverlist->nextupdate); + serverlist->nextupdate++; + serverlist->updatelist[i].currentserver = server; + serverlist->updatelist[i].saddr.sin_family = AF_INET; + serverlist->updatelist[i].saddr.sin_addr.s_addr = inet_addr(ServerGetAddress(server)); + serverlist->updatelist[i].saddr.sin_port = htons((short)ServerGetQueryPort(server)); + sendto(serverlist->updatelist[i].s,querystrings[server->querytype] ,querylengths[server->querytype],0,(struct sockaddr *)&serverlist->updatelist[i].saddr,sizeof(struct sockaddr_in)); + serverlist->updatelist[i].starttime = current_time(); + } - return 0; + return 0; +} + +/* ServerListThinkSocket +------------------ +For use with Async Updates. This needs to be called every ~10ms for list processing and +updating to occur during async server list updates */ +GError ServerListThinkSocket(GServerList serverlist, GServerListSocket slsocket) +{ + GError socketerror; + + if (slsocket->s == INVALID_SOCKET) { + return GE_NOSOCKET; + } + + socketerror = ServerListCheckSocketError(serverlist, slsocket); + if (socketerror) { + return socketerror; + } + + switch(slsocket->socketstate) + { + case ls_connecting: + ServerListStartQuery(serverlist, slsocket, 1); + break; + case ls_connected: + //read the data + return ServerListReadList(serverlist, slsocket); + break; + default: + break; + } + + switch (serverlist->state) + { + case sl_idle: return 0; + case sl_listxfer: + //read the data + //return ServerListReadList(serverlist, slsocket); + break; + case sl_lanlist: + return ServerListLANList(serverlist, slsocket); + } + + return 0; +} + +/* ServerListHasFinishedFetchingList +------------------ +Whether or not the list has finished fetching */ +static gbool ServerListHasFinishedFetchingList(GServerList serverlist) +{ + int i; + + for(i = 0; i < serverlist->numslsockets; i++) { + if (serverlist->slsockets[i].s != INVALID_SOCKET) { + return 0; + } + } + + return 1; } /* ServerListThink @@ -706,24 +1166,32 @@ For use with Async Updates. This needs to be called every ~10ms for list process updating to occur during async server list updates */ GError ServerListThink(GServerList serverlist) { + int i; - switch (serverlist->state) - { - case sl_idle: return 0; - case sl_listxfer: - //read the data - return ServerListReadList(serverlist); - break; - case sl_lanlist: - return ServerListLANList(serverlist); - case sl_querying: - //do some queries - return ServerListQueryLoop(serverlist); - break; - } + for(i = 0; i < serverlist->numslsockets; i++) { + ServerListThinkSocket(serverlist, &serverlist->slsockets[i]); + } + switch(serverlist->state) + { + case sl_idle: + case sl_listxfer: + if (!serverlist->abortupdate) { + if (serverlist->startslindex < ServerListGetNumMasters()) { + CreateServerListForAvailableSockets(serverlist, serverlist->async); + } else if (serverlist->state == sl_listxfer && ServerListHasFinishedFetchingList(serverlist)) { + ServerListModeChange(serverlist, sl_idle); + } + } + break; + case sl_querying: + //do some queries + return ServerListQueryLoop(serverlist); + break; + default: break; + } - return 0; + return 0; } /* ServerListHalt @@ -731,10 +1199,10 @@ GError ServerListThink(GServerList serverlist) Halts the current update batch */ GError ServerListHalt(GServerList serverlist) { - if (serverlist->state != sl_idle) - serverlist->abortupdate = 1; + if (serverlist->state != sl_idle) + serverlist->abortupdate = 1; - return 0; + return 0; } /* ServerListClear @@ -743,13 +1211,13 @@ Clear and free all of the servers from the server list. List must be in the sl_idle state */ GError ServerListClear(GServerList serverlist) { - - if (serverlist->state != sl_idle) - return GE_BUSY; - //fastest way to clear is kill and recreate - ArrayFree(serverlist->servers); - serverlist->servers = ArrayNew(sizeof(GServer), SERVER_GROWBY, ServerFree); - return 0; + + if (serverlist->state != sl_idle) + return GE_BUSY; + //fastest way to clear is kill and recreate + ArrayFree(serverlist->servers); + serverlist->servers = ArrayNew(sizeof(GServer), SERVER_GROWBY, ServerFree); + return 0; } /* ServerListState @@ -757,7 +1225,7 @@ GError ServerListClear(GServerList serverlist) Returns the current state of the server list */ GServerListState ServerListState(GServerList serverlist) { - return serverlist->state; + return serverlist->state; } /* ServerListErrorDesc @@ -765,16 +1233,16 @@ GServerListState ServerListState(GServerList serverlist) Returns a static string description of the specified error */ char *ServerListErrorDesc(GServerList serverlist, GError error) { - switch (error) - { - case GE_NOERROR: return ""; - case GE_NOSOCKET: return "Unable to create socket"; - case GE_NODNS: return "Unable to resolve master"; - case GE_NOCONNECT: return "Connection to master reset"; - case GE_BUSY: return "Server List is busy"; - case GE_DATAERROR: return "Unexpected data in server list"; - } - return "UNKNOWN ERROR CODE"; + switch (error) + { + case GE_NOERROR: return ""; + case GE_NOSOCKET: return "Unable to create socket"; + case GE_NODNS: return "Unable to resolve master"; + case GE_NOCONNECT: return "Connection to master reset"; + case GE_BUSY: return "Server List is busy"; + case GE_DATAERROR: return "Unexpected data in server list"; + } + return "UNKNOWN ERROR CODE"; } @@ -783,9 +1251,9 @@ char *ServerListErrorDesc(GServerList serverlist, GError error) Returns the server at the specified index, or NULL if the index is out of bounds */ GServer ServerListGetServer(GServerList serverlist, int index) { - if (index < 0 || index >= ArrayLength(serverlist->servers)) - return NULL; - return *(GServer *)ArrayNth(serverlist->servers,index); + if (index < 0 || index >= ArrayLength(serverlist->servers)) + return NULL; + return *(GServer *)ArrayNth(serverlist->servers,index); } /* ServerListCount @@ -794,7 +1262,7 @@ Returns the number of servers on the specified list. Indexing is 0 based, so the actual server indexes are 0 <= valid index < Count */ int ServerListCount(GServerList serverlist) { - return ArrayLength(serverlist->servers); + return ArrayLength(serverlist->servers); } /**** @@ -802,50 +1270,50 @@ Comparision Functions ***/ static int IntKeyCompare(const void *entry1, const void *entry2) { - GServer server1 = *(GServer *)entry1, server2 = *(GServer *)entry2; - int diff; - diff = ServerGetIntValue(server1, g_sortserverlist->sortkey, 0) - - ServerGetIntValue(server2, g_sortserverlist->sortkey, 0); - if (!g_sortserverlist->sortascending) - diff = -diff; - return diff; - + GServer server1 = *(GServer *)entry1, server2 = *(GServer *)entry2; + int diff; + diff = ServerGetIntValue(server1, g_sortserverlist->sortkey, 0) - + ServerGetIntValue(server2, g_sortserverlist->sortkey, 0); + if (!g_sortserverlist->sortascending) + diff = -diff; + return diff; + } static int FloatKeyCompare(const void *entry1, const void *entry2) { GServer server1 = *(GServer *)entry1, server2 = *(GServer *)entry2; - double f = ServerGetFloatValue(server1, g_sortserverlist->sortkey, 0) - - ServerGetFloatValue(server2, g_sortserverlist->sortkey, 0); - if (!g_sortserverlist->sortascending) - f = -f; - if ((float)f > (float)0.0) - return 1; - else if ((float)f < (float)0.0) - return -1; - else - return 0; + double f = ServerGetFloatValue(server1, g_sortserverlist->sortkey, 0) - + ServerGetFloatValue(server2, g_sortserverlist->sortkey, 0); + if (!g_sortserverlist->sortascending) + f = -f; + if ((float)f > (float)0.0) + return 1; + else if ((float)f < (float)0.0) + return -1; + else + return 0; } static int StrCaseKeyCompare(const void *entry1, const void *entry2) { - + GServer server1 = *(GServer *)entry1, server2 = *(GServer *)entry2; int diff = strcmp(ServerGetStringValue(server1, g_sortserverlist->sortkey, ""), - ServerGetStringValue(server2, g_sortserverlist->sortkey, "")); - if (!g_sortserverlist->sortascending) - diff = -diff; - return diff; + ServerGetStringValue(server2, g_sortserverlist->sortkey, "")); + if (!g_sortserverlist->sortascending) + diff = -diff; + return diff; } static int StrNoCaseKeyCompare(const void *entry1, const void *entry2) { - GServer server1 = *(GServer *)entry1, server2 = *(GServer *)entry2; - int diff = strcasecmp(ServerGetStringValue(server1, g_sortserverlist->sortkey, ""), - ServerGetStringValue(server2, g_sortserverlist->sortkey, "")); - if (!g_sortserverlist->sortascending) - diff = -diff; - return diff; + GServer server1 = *(GServer *)entry1, server2 = *(GServer *)entry2; + int diff = strcasecmp(ServerGetStringValue(server1, g_sortserverlist->sortkey, ""), + ServerGetStringValue(server2, g_sortserverlist->sortkey, "")); + if (!g_sortserverlist->sortascending) + diff = -diff; + return diff; } /* ServerListSort @@ -855,22 +1323,22 @@ specified comparemode. sortkey can be a normal server key, or "ping" or "hostaddr" */ void ServerListSort(GServerList serverlist, gbool ascending, char *sortkey, GCompareMode comparemode) { - ArrayCompareFn comparator; - switch (comparemode) - { - case cm_int: comparator = IntKeyCompare; - break; - case cm_float: comparator = FloatKeyCompare; - break; - case cm_strcase: comparator = StrCaseKeyCompare; - break; - case cm_stricase: comparator = StrNoCaseKeyCompare; - break; - } - serverlist->sortkey = sortkey; - serverlist->sortascending = ascending; - g_sortserverlist = serverlist; - ArraySort(serverlist->servers,comparator); + ArrayCompareFn comparator; + switch (comparemode) + { + case cm_int: comparator = IntKeyCompare; + break; + case cm_float: comparator = FloatKeyCompare; + break; + case cm_strcase: comparator = StrCaseKeyCompare; + break; + case cm_stricase: comparator = StrNoCaseKeyCompare; + break; + } + serverlist->sortkey = sortkey; + serverlist->sortascending = ascending; + g_sortserverlist = serverlist; + ArraySort(serverlist->servers,comparator); } diff --git a/code/gamespy/gstats/gp_stats/gp_stats.rc b/code/gamespy/gstats/gp_stats/gp_stats.rc index dee94b35..d0b03cff 100644 --- a/code/gamespy/gstats/gp_stats/gp_stats.rc +++ b/code/gamespy/gstats/gp_stats/gp_stats.rc @@ -90,7 +90,7 @@ BEGIN EDITTEXT IDC_PASSWORD,65,50,110,12,ES_PASSWORD | ES_AUTOHSCROLL EDITTEXT IDC_PROFILE_ID,65,65,110,12,ES_AUTOHSCROLL | ES_READONLY PUSHBUTTON "Authenticate",IDC_AUTHENTICATE,35,85,50,14 - GROUPBOX "Persistant Data",IDC_STATIC,10,115,175,140 + GROUPBOX "Persistent Data",IDC_STATIC,10,115,175,140 CONTROL "Private Read/Write",IDC_PRIVATE_RW,"Button", BS_AUTORADIOBUTTON | WS_GROUP,20,130,77,10 CONTROL "Private Read-Only",IDC_PRIVATE_RO,"Button", diff --git a/code/gamespy/gutil.c b/code/gamespy/gutil.c index 698aa946..136c2c77 100644 --- a/code/gamespy/gutil.c +++ b/code/gamespy/gutil.c @@ -18,68 +18,68 @@ typedef unsigned char uchar; static void swap_byte(uchar* a, uchar* b) { - uchar swapByte; + uchar swapByte; - swapByte = *a; - *a = *b; - *b = swapByte; + swapByte = *a; + *a = *b; + *b = swapByte; } static uchar encode_ct(uchar c) { - if (c < 26) return (uchar)('A' + c); - if (c < 52) return (uchar)('a' + c - 26); - if (c < 62) return (uchar)('0' + c - 52); - if (c == 62) return (uchar)('+'); - if (c == 63) return (uchar)('/'); + if (c < 26) return (uchar)('A' + c); + if (c < 52) return (uchar)('a' + c - 26); + if (c < 62) return (uchar)('0' + c - 52); + if (c == 62) return (uchar)('+'); + if (c == 63) return (uchar)('/'); - return 0; + return 0; } void gs_encode(uchar* ins, int size, uchar* result) { - int i, pos; - uchar trip[3]; - uchar kwart[4]; + int i, pos; + uchar trip[3]; + uchar kwart[4]; - i = 0; - while (i < size) - { - for (pos = 0; pos <= 2; pos++, i++) - if (i < size) trip[pos] = *ins++; - else trip[pos] = '\0'; - kwart[0] = (unsigned char)((trip[0]) >> 2); - kwart[1] = (unsigned char)((((trip[0]) & 3) << 4) + ((trip[1]) >> 4)); - kwart[2] = (unsigned char)((((trip[1]) & 15) << 2) + ((trip[2]) >> 6)); - kwart[3] = (unsigned char)((trip[2]) & 63); - for (pos = 0; pos <= 3; pos++) *result++ = encode_ct(kwart[pos]); - } - *result = '\0'; + i = 0; + while (i < size) + { + for (pos = 0; pos <= 2; pos++, i++) + if (i < size) trip[pos] = *ins++; + else trip[pos] = '\0'; + kwart[0] = (unsigned char)((trip[0]) >> 2); + kwart[1] = (unsigned char)((((trip[0]) & 3) << 4) + ((trip[1]) >> 4)); + kwart[2] = (unsigned char)((((trip[1]) & 15) << 2) + ((trip[2]) >> 6)); + kwart[3] = (unsigned char)((trip[2]) & 63); + for (pos = 0; pos <= 3; pos++) *result++ = encode_ct(kwart[pos]); + } + *result = '\0'; } void gs_encrypt(uchar* key, int key_len, uchar* buffer_ptr, int buffer_len) { - int counter; - uchar x, y, xorIndex; - uchar state[256]; + int counter; + uchar x, y, xorIndex; + uchar state[256]; - for (counter = 0; counter < 256; counter++) state[counter] = (uchar)counter; + for (counter = 0; counter < 256; counter++) state[counter] = (uchar)counter; - x = 0; y = 0; - for (counter = 0; counter < 256; counter++) - { - y = (uchar)((key[x] + state[counter] + y) % 256); - x = (uchar)((x + 1) % key_len); - swap_byte(&state[counter], &state[y]); - } + x = 0; y = 0; + for (counter = 0; counter < 256; counter++) + { + y = (uchar)((key[x] + state[counter] + y) % 256); + x = (uchar)((x + 1) % key_len); + swap_byte(&state[counter], &state[y]); + } - x = 0; y = 0; - for (counter = 0; counter < buffer_len; counter++) - { - x = (uchar)((x + buffer_ptr[counter] + 1) % 256); - y = (uchar)((state[x] + y) % 256); - swap_byte(&state[x], &state[y]); - xorIndex = (uchar)((state[x] + state[y]) % 256); - buffer_ptr[counter] ^= state[xorIndex]; - } + x = 0; y = 0; + for (counter = 0; counter < buffer_len; counter++) + { + x = (uchar)((x + buffer_ptr[counter] + 1) % 256); + y = (uchar)((state[x] + y) % 256); + swap_byte(&state[x], &state[y]); + xorIndex = (uchar)((state[x] + state[y]) % 256); + buffer_ptr[counter] ^= state[xorIndex]; + } } diff --git a/code/gamespy/gutil.h b/code/gamespy/gutil.h index b35d0f6c..f1889513 100644 --- a/code/gamespy/gutil.h +++ b/code/gamespy/gutil.h @@ -27,7 +27,7 @@ size: size of the buffer OUT --- result: pointer to buffer to store result. Size should be (4 * size) / 3 + 1 - result will be null terminated. + result will be null terminated. **********/ void gs_encode(uchar* ins, int size, uchar* result); diff --git a/code/gamespy/hashtable.c b/code/gamespy/hashtable.c index 9313e503..84ad6275 100644 --- a/code/gamespy/hashtable.c +++ b/code/gamespy/hashtable.c @@ -22,208 +22,208 @@ #ifdef _NO_NOPORT_H_ - #define gsimalloc malloc - #define gsifree free - #define gsirealloc realloc - #include + #define gsimalloc malloc + #define gsifree free + #define gsirealloc realloc + #include #else - #include "nonport.h" //for gsimalloc/realloc/free/assert + #include "nonport.h" //for gsimalloc/realloc/free/assert #endif struct HashImplementation { - DArray *buckets; - int nbuckets; - TableElementFreeFn freefn; - TableHashFn hashfn; - TableCompareFn compfn; + DArray *buckets; + int nbuckets; + TableElementFreeFn freefn; + TableHashFn hashfn; + TableCompareFn compfn; }; HashTable TableNew(int elemSize, int nBuckets, TableHashFn hashFn, TableCompareFn compFn, - TableElementFreeFn freeFn) + TableElementFreeFn freeFn) { - return TableNew2(elemSize, nBuckets, 4, hashFn, compFn, freeFn); + return TableNew2(elemSize, nBuckets, 4, hashFn, compFn, freeFn); } HashTable TableNew2(int elemSize, int nBuckets, int nChains, TableHashFn hashFn, TableCompareFn compFn, - TableElementFreeFn freeFn) + TableElementFreeFn freeFn) { - HashTable table; - int i; + HashTable table; + int i; - assert(hashFn); - assert(compFn); - assert(elemSize); - assert(nBuckets); + assert(hashFn); + assert(compFn); + assert(elemSize); + assert(nBuckets); - table = (HashTable)gsimalloc(sizeof(struct HashImplementation)); - assert(table); - - table->buckets = (DArray *)gsimalloc(nBuckets * sizeof(DArray)); - assert(table->buckets); - for (i = 0; i < nBuckets; i++) //ArrayNew will assert if allocation fails - table->buckets[i] = ArrayNew(elemSize, nChains, freeFn); - table->nbuckets = nBuckets; - table->freefn = freeFn; - table->compfn = compFn; - table->hashfn = hashFn; + table = (HashTable)gsimalloc(sizeof(struct HashImplementation)); + assert(table); + + table->buckets = (DArray *)gsimalloc(nBuckets * sizeof(DArray)); + assert(table->buckets); + for (i = 0; i < nBuckets; i++) //ArrayNew will assert if allocation fails + table->buckets[i] = ArrayNew(elemSize, nChains, freeFn); + table->nbuckets = nBuckets; + table->freefn = freeFn; + table->compfn = compFn; + table->hashfn = hashFn; - return table; + return table; } void TableFree(HashTable table) { - int i; - - assert(table); + int i; + + assert(table); - if (NULL == table ) - return; - - for (i = 0 ; i < table->nbuckets ; i++) - ArrayFree(table->buckets[i]); - gsifree(table->buckets); - gsifree(table); + if (NULL == table ) + return; + + for (i = 0 ; i < table->nbuckets ; i++) + ArrayFree(table->buckets[i]); + gsifree(table->buckets); + gsifree(table); } int TableCount(HashTable table) { - int i, count = 0; - - assert(table); + int i, count = 0; + + assert(table); - if (NULL == table ) - return count; + if (NULL == table ) + return count; - for (i = 0 ; i < table->nbuckets ; i++) - count += ArrayLength(table->buckets[i]); - - return count; + for (i = 0 ; i < table->nbuckets ; i++) + count += ArrayLength(table->buckets[i]); + + return count; } void TableEnter(HashTable table, const void *newElem) { - int hash, itempos; - - assert(table); + int hash, itempos; + + assert(table); - if (NULL == table ) - return; + if (NULL == table ) + return; - hash = table->hashfn(newElem, table->nbuckets); - itempos = ArraySearch(table->buckets[hash], newElem, table->compfn, 0,0); - if (itempos == NOT_FOUND) - ArrayAppend(table->buckets[hash], newElem); - else - ArrayReplaceAt(table->buckets[hash], newElem, itempos); + hash = table->hashfn(newElem, table->nbuckets); + itempos = ArraySearch(table->buckets[hash], newElem, table->compfn, 0,0); + if (itempos == NOT_FOUND) + ArrayAppend(table->buckets[hash], newElem); + else + ArrayReplaceAt(table->buckets[hash], newElem, itempos); } int TableRemove(HashTable table, const void *delElem) { - int hash, itempos; - - assert(table); + int hash, itempos; + + assert(table); - if (NULL == table ) - return 0; + if (NULL == table ) + return 0; - hash = table->hashfn(delElem, table->nbuckets); - itempos = ArraySearch(table->buckets[hash], delElem, table->compfn, 0,0); - if (itempos == NOT_FOUND) - return 0; - else - ArrayDeleteAt(table->buckets[hash], itempos); - return 1; + hash = table->hashfn(delElem, table->nbuckets); + itempos = ArraySearch(table->buckets[hash], delElem, table->compfn, 0,0); + if (itempos == NOT_FOUND) + return 0; + else + ArrayDeleteAt(table->buckets[hash], itempos); + return 1; } void *TableLookup(HashTable table, const void *elemKey) { - int hash, itempos; - - assert(table); + int hash, itempos; + + assert(table); - if (NULL == table ) - return NULL; + if (NULL == table ) + return NULL; - hash = table->hashfn(elemKey, table->nbuckets); - itempos = ArraySearch(table->buckets[hash], elemKey, table->compfn, 0, - 0); - if (itempos == NOT_FOUND) - return NULL; - else - return ArrayNth(table->buckets[hash], itempos); + hash = table->hashfn(elemKey, table->nbuckets); + itempos = ArraySearch(table->buckets[hash], elemKey, table->compfn, 0, + 0); + if (itempos == NOT_FOUND) + return NULL; + else + return ArrayNth(table->buckets[hash], itempos); } void TableMap(HashTable table, TableMapFn fn, void *clientData) { - int i; - - assert(table); - assert(fn); + int i; + + assert(table); + assert(fn); - if (NULL == table || NULL == fn) - return; - - for (i = 0 ; i < table->nbuckets ; i++) - ArrayMap(table->buckets[i], fn, clientData); - + if (NULL == table || NULL == fn) + return; + + for (i = 0 ; i < table->nbuckets ; i++) + ArrayMap(table->buckets[i], fn, clientData); + } void TableMapSafe(HashTable table, TableMapFn fn, void *clientData) { - int i; - - assert(fn); - - for (i = 0 ; i < table->nbuckets ; i++) - ArrayMapBackwards(table->buckets[i], fn, clientData); - + int i; + + assert(fn); + + for (i = 0 ; i < table->nbuckets ; i++) + ArrayMapBackwards(table->buckets[i], fn, clientData); + } void * TableMap2(HashTable table, TableMapFn2 fn, void *clientData) { - int i; - void * pcurr; - - assert(fn); - - for (i = 0 ; i < table->nbuckets ; i++) - { - pcurr = ArrayMap2(table->buckets[i], fn, clientData); - if(pcurr) - return pcurr; - } + int i; + void * pcurr; + + assert(fn); + + for (i = 0 ; i < table->nbuckets ; i++) + { + pcurr = ArrayMap2(table->buckets[i], fn, clientData); + if(pcurr) + return pcurr; + } - return NULL; + return NULL; } void * TableMapSafe2(HashTable table, TableMapFn2 fn, void *clientData) { - int i; - void * pcurr; - - assert(fn); - - for (i = 0 ; i < table->nbuckets ; i++) - { - pcurr = ArrayMapBackwards2(table->buckets[i], fn, clientData); - if(pcurr) - return pcurr; - } + int i; + void * pcurr; + + assert(fn); + + for (i = 0 ; i < table->nbuckets ; i++) + { + pcurr = ArrayMapBackwards2(table->buckets[i], fn, clientData); + if(pcurr) + return pcurr; + } - return NULL; + return NULL; } void TableClear(HashTable table) { - int i; + int i; - for (i = 0 ; i < table->nbuckets ; i++) - ArrayClear(table->buckets[i]); + for (i = 0 ; i < table->nbuckets ; i++) + ArrayClear(table->buckets[i]); } diff --git a/code/gamespy/hashtable.h b/code/gamespy/hashtable.h index d6c8a4a3..fa00c2ec 100644 --- a/code/gamespy/hashtable.h +++ b/code/gamespy/hashtable.h @@ -126,11 +126,11 @@ extern "C" { HashTable TableNew(int elemSize, int nBuckets, TableHashFn hashFn, TableCompareFn compFn, - TableElementFreeFn freeFn); + TableElementFreeFn freeFn); HashTable TableNew2(int elemSize, int nBuckets, int nChains, TableHashFn hashFn, TableCompareFn compFn, - TableElementFreeFn freeFn); + TableElementFreeFn freeFn); /* TableFree diff --git a/code/gamespy/md5.h b/code/gamespy/md5.h index 0fccee0c..0d324291 100644 --- a/code/gamespy/md5.h +++ b/code/gamespy/md5.h @@ -38,7 +38,7 @@ The following makes PROTOTYPES default to 0 if it has not already #ifdef __cplusplus extern "C" { #endif - + #ifndef PROTOTYPES #define PROTOTYPES 1 #endif diff --git a/code/gamespy/md5c.c b/code/gamespy/md5c.c index de31fc6a..8383e62f 100644 --- a/code/gamespy/md5c.c +++ b/code/gamespy/md5c.c @@ -305,7 +305,7 @@ static void Decode (UINT4 *output, unsigned char *input, unsigned int len) */ static void MD5_memcpy (POINTER output, POINTER input, unsigned int len) { - memcpy(output, input, len); + memcpy(output, input, len); /* unsigned int i; for (i = 0; i < len; i++) @@ -316,7 +316,7 @@ static void MD5_memcpy (POINTER output, POINTER input, unsigned int len) */ static void MD5_memset (POINTER output, int value, unsigned int len) { - memset(output, value, len); + memset(output, value, len); /* unsigned int i; for (i = 0; i < len; i++) @@ -327,26 +327,26 @@ static void MD5_memset (POINTER output, int value, unsigned int len) void MD5Print (unsigned char digest[16], char output[33]) { - static const char hex_digits[] = "0123456789abcdef"; - unsigned int i; + static const char hex_digits[] = "0123456789abcdef"; + unsigned int i; - for (i = 0; i < 16; i++) - { - output[i*2 ] = hex_digits[digest[i] / 16]; - output[i*2+1] = hex_digits[digest[i] % 16]; - } - output[32] = '\0'; + for (i = 0; i < 16; i++) + { + output[i*2 ] = hex_digits[digest[i] / 16]; + output[i*2+1] = hex_digits[digest[i] % 16]; + } + output[32] = '\0'; } void MD5Digest (unsigned char *input, unsigned int len, char output[33]) { - MD5_CTX ctx; - unsigned char digest[16]; + MD5_CTX ctx; + unsigned char digest[16]; - MD5Init(&ctx); - MD5Update(&ctx, input, len); - MD5Final(digest, &ctx); - MD5Print(digest, output); + MD5Init(&ctx); + MD5Update(&ctx, input, len); + MD5Final(digest, &ctx); + MD5Print(digest, output); } #ifdef __cplusplus diff --git a/code/gamespy/q_gamespy.c b/code/gamespy/q_gamespy.c new file mode 100644 index 00000000..69d98981 --- /dev/null +++ b/code/gamespy/q_gamespy.c @@ -0,0 +1,170 @@ +/* +=========================================================================== +Copyright (C) 2025 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA source code 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. + +OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#pragma once + +#include "q_gamespy.h" +#include "../qcommon/qcommon.h" +#include "cl_gamespy.h" +#include "sv_gamespy.h" + +#define MAX_MASTERS 8 +#define MASTER_DEFAULT_MSPORT 28900 +#define MASTER_DEFAULT_HBPORT 27900 + +cvar_t *com_master_host[MAX_MASTERS]; +cvar_t *com_master_msport[MAX_MASTERS]; +cvar_t *com_master_hbport[MAX_MASTERS]; + +master_entry_t entries[MAX_MASTERS]; +int num_entries = 0; + +static void Com_RestartGameSpy_f(void); + +static qboolean ShouldRefreshMasters() +{ + int i; + + for (i = 0; i < MAX_MASTERS; i++) { + if (com_master_host[i] && com_master_host[i]->latchedString) { + return qtrue; + } + if (com_master_msport[i] && com_master_msport[i]->latchedString) { + return qtrue; + } + if (com_master_hbport[i] && com_master_hbport[i]->latchedString) { + return qtrue; + } + } + + return qfalse; +} + +static void CreateMasterVar(int index, const char *host, int msport, int hbport) +{ + assert(index < MAX_MASTERS); + + // + // These variables should be modified for testing purposes only. + // So prevent them to be saved in the configuration file. + // + com_master_host[index] = Cvar_Get(va("com_master%d_host", index), host, CVAR_LATCH | CVAR_TEMP); + com_master_msport[index] = Cvar_Get(va("com_master%d_msport", index), va("%d", msport), CVAR_LATCH | CVAR_TEMP); + com_master_hbport[index] = Cvar_Get(va("com_master%d_hbport", index), va("%d", hbport), CVAR_LATCH | CVAR_TEMP); + + com_master_host[index]->flags &= ~CVAR_ARCHIVE; + com_master_msport[index]->flags &= ~CVAR_ARCHIVE; + com_master_hbport[index]->flags &= ~CVAR_ARCHIVE; +} + +qboolean Com_RefreshGameSpyMasters() +{ + int msIndex = 0; + int i; + qboolean shouldRestart; + + shouldRestart = ShouldRefreshMasters(); + + // + // These masters come from the 333networks community and use the same software + // that emulate the GameSpy protocol -- see https://333networks.com/ + // They are managed by different entities, are independent and sync with eachother. + // + CreateMasterVar(msIndex++, "master.333networks.com", MASTER_DEFAULT_MSPORT, MASTER_DEFAULT_HBPORT); + CreateMasterVar(msIndex++, "master.errorist.eu", MASTER_DEFAULT_MSPORT, MASTER_DEFAULT_HBPORT); + CreateMasterVar(msIndex++, "master.noccer.de", MASTER_DEFAULT_MSPORT, MASTER_DEFAULT_HBPORT); + CreateMasterVar(msIndex++, "master-au.unrealarchive.org", MASTER_DEFAULT_MSPORT, MASTER_DEFAULT_HBPORT); + CreateMasterVar(msIndex++, "master.frag-net.com", MASTER_DEFAULT_MSPORT, MASTER_DEFAULT_HBPORT); + + for (; msIndex < MAX_MASTERS; msIndex++) { + CreateMasterVar(msIndex, "", MASTER_DEFAULT_MSPORT, MASTER_DEFAULT_HBPORT); + } + + num_entries = 0; + + // + // Find and insert valid entries + // + for (i = 0; i < MAX_MASTER_SERVERS; i++) { + master_entry_t *entry = &entries[num_entries]; + + if (com_master_host[i]->string && com_master_host[i]->string[0]) { + entry->host = com_master_host[i]->string; + entry->queryport = com_master_msport[i]->integer; + entry->hbport = com_master_hbport[i]->integer; + num_entries++; + } + } + + return shouldRestart; +} + +void Com_InitGameSpy() +{ + Com_RefreshGameSpyMasters(); + + Cmd_AddCommand("net_gamespy_restart", Com_RestartGameSpy_f); +} + +static void Com_RestartGameSpy_f(void) +{ + Com_RefreshGameSpyMasters(); + +#ifndef DEDICATED + CL_RestartGamespy_f(); +#endif + SV_RestartGamespy_f(); +} + +unsigned int Com_GetNumMasterEntries() +{ + return num_entries; +} + +void Com_GetMasterEntry(int index, master_entry_t *entry) +{ + if (index >= num_entries) { + entry->host = NULL; + entry->hbport = 0; + entry->queryport = 0; + return; + } + + entry->host = com_master_host[index]->string; + entry->queryport = com_master_msport[index]->integer; + entry->hbport = com_master_hbport[index]->integer; +} + +const char *Com_GetMasterHost() +{ + return com_master_host[0]->string; +} + +int Com_GetMasterQueryPort() +{ + return com_master_msport[0]->integer; +} + +int Com_GetMasterHeartbeatPort() +{ + return com_master_hbport[0]->integer; +} diff --git a/code/gamespy/q_gamespy.h b/code/gamespy/q_gamespy.h new file mode 100644 index 00000000..a60baa3e --- /dev/null +++ b/code/gamespy/q_gamespy.h @@ -0,0 +1,42 @@ +/* +=========================================================================== +Copyright (C) 2025 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA source code 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. + +OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// q_gamespy.h -- Common game-specific GameSpy code shared between client and server + +#pragma once + +#include "../qcommon/q_shared.h" + +typedef struct { + const char *host; + int queryport; + int hbport; +} master_entry_t; + +void Com_InitGameSpy(); +qboolean Com_RefreshGameSpyMasters(); + +unsigned int Com_GetNumMasterEntries(); +void Com_GetMasterEntry(int index, master_entry_t* entry); +const char *Com_GetMasterHost(); +int Com_GetMasterQueryPort(); +int Com_GetMasterHeartbeatPort(); diff --git a/code/gamespy/sc/sciInterface.c b/code/gamespy/sc/sciInterface.c index 1bf05252..f572337c 100644 --- a/code/gamespy/sc/sciInterface.c +++ b/code/gamespy/sc/sciInterface.c @@ -9,7 +9,7 @@ /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -// This is declared as an extern so it can be overriden when testing +// This is declared as an extern so it can be overridden when testing #define SC_SERVICE_URL_FORMAT "http://%s.comp.pubsvs." GSI_DOMAIN_NAME "/CompetitionService/CompetitionService.asmx" char scServiceURL[SC_SERVICE_MAX_URL_LEN] = ""; diff --git a/code/gamespy/sv_gamespy.c b/code/gamespy/sv_gamespy.c index 58a245a5..6f2cc451 100644 --- a/code/gamespy/sv_gamespy.c +++ b/code/gamespy/sv_gamespy.c @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2025 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -22,18 +22,24 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "../qcommon/q_shared.h" #include "../server/server.h" +#include "../qcommon/q_version.h" #include "sv_gqueryreporting.h" #include "sv_gamespy.h" +#include "q_gamespy.h" #include "gcdkey/gcdkeys.h" #include "common/gsCommon.h" #include "common/gsAvailable.h" -static char gamemode[128]; -static qboolean gcdInitialized = qfalse; -static qboolean gcdValid = qfalse; +static char gamemode[128]; +static qboolean gcdInitialized = qfalse; +static qboolean gcdValid = qfalse; +static qboolean gsRunning = qfalse; extern GSIACResult __GSIACResult; +cvar_t *net_ip = NULL; +cvar_t *net_gamespy_port = NULL; + static const char *SECRET_GS_KEYS[] = { "M5Fdwc", @@ -55,25 +61,35 @@ static const char *GS_GAME_NAME[] = "mohaab" }; +static const char *GS_GAME_NAME_DEMO[] = +{ + "mohaa", + "mohaas", + "mohaabd" +}; + static const char *GS_GAME_VERSION[] = { - TARGET_GAME_VERSION_MOH, - TARGET_GAME_VERSION_MOHTA, - TARGET_GAME_VERSION_MOHTT, + TARGET_GAME_VERSION_MOH "+" PRODUCT_VERSION, + TARGET_GAME_VERSION_MOHTA "+" PRODUCT_VERSION, + TARGET_GAME_VERSION_MOHTT "+" PRODUCT_VERSION, +}; + +static const char* GS_GAME_VERSION_DEMO[] = +{ + TARGET_GAME_VERSION_MOH "+" PRODUCT_VERSION, + "d" TARGET_GAME_VERSION_MOHTA "+" PRODUCT_VERSION, + "d" TARGET_GAME_VERSION_MOHTT_DEMO "+" PRODUCT_VERSION, }; static const unsigned int GAMESPY_DEFAULT_PORT = 12300; -void qr_send_statechanged(qr_t qrec); -void qr_shutdown(qr_t qrec); -void qr_process_queries(qr_t qrec); - int qr_init( qr_t *qrec, - const char *ip, + const char *ip, int baseport, - const char *gamename, - const char *secret_key, + const char *gamename, + const char *secret_key, qr_querycallback_t qr_basic_callback, qr_querycallback_t qr_info_callback, qr_querycallback_t qr_rules_callback, @@ -81,35 +97,51 @@ int qr_init( void *userdata ); -const char* GS_GetGameKey(unsigned int index) { +const char *GS_GetGameKey(unsigned int index) +{ return SECRET_GS_KEYS[index]; } -const char* GS_GetCurrentGameKey() { +const char *GS_GetCurrentGameKey() +{ return GS_GetGameKey(com_target_game->integer); } -unsigned int GS_GetGameID(unsigned int index) { +unsigned int GS_GetGameID(unsigned int index) +{ return GCD_GAME_IDS[index]; } -unsigned int GS_GetCurrentGameID() { +unsigned int GS_GetCurrentGameID() +{ return GS_GetGameID(com_target_game->integer); } -const char* GS_GetGameName(unsigned int index) { - return GS_GAME_NAME[index]; +const char *GS_GetGameName(unsigned int index) +{ + if (!com_target_demo->integer) { + return GS_GAME_NAME[index]; + } else { + return GS_GAME_NAME_DEMO[index]; + } } -const char* GS_GetCurrentGameName() { +const char *GS_GetCurrentGameName() +{ return GS_GetGameName(com_target_game->integer); } -const char* GS_GetGameVersion(unsigned int index) { - return GS_GAME_VERSION[index]; +const char *GS_GetGameVersion(unsigned int index) +{ + if (!com_target_demo->integer) { + return GS_GAME_VERSION[index]; + } else { + return GS_GAME_VERSION_DEMO[index]; + } } -const char* GS_GetCurrentGameVersion() { +const char *GS_GetCurrentGameVersion() +{ return GS_GetGameVersion(com_target_game->integer); } @@ -130,7 +162,6 @@ static void basic_callback(char *outbuf, int maxlen, void *userdata) { Info_SetValueForKey(outbuf, "gamename", GS_GetCurrentGameName()); Info_SetValueForKey(outbuf, "gamever", GS_GetCurrentGameVersion()); - Info_SetValueForKey(outbuf, "location", va("%i", sv_location->integer)); if (sv_debug_gamespy->integer) { @@ -191,42 +222,54 @@ static void rules_callback(char *outbuf, int maxlen, void *userdata) static void players_callback(char *outbuf, int maxlen, void *userdata) { - int i; - char infostring[128]; - size_t infolen; - size_t currlen = 0; + client_t *cl; + playerState_t *ps; + size_t infolen; + size_t currlen = 0; + int i; + int index; + char infostring[128]; + + outbuf[0] = 0; if (!svs.clients) { return; } - for (i = 0; i < svs.iNumClients; i++) { - if (svs.clients[i].state == CS_FREE) { + for (i = 0, index = 0; i < svs.iNumClients; i++) { + cl = &svs.clients[i]; + + if (cl->state == CS_FREE) { // ignore inactive clients continue; } - playerState_t *ps = SV_GameClientNum(i); + ps = SV_GameClientNum(i); - Com_sprintf( + infolen = Com_sprintf( infostring, - 128, + sizeof(infostring), "\\player_%d\\%s\\frags_%d\\%d\\deaths_%d\\%d\\ping_%d\\%d", - i, - svs.clients[i].name, - i, + index, + cl->name, + index, ps->stats[STAT_KILLS], - i, + index, ps->stats[STAT_DEATHS], - i, - svs.clients[i].ping + index, + cl->ping ); - infolen = strlen(infostring); if (currlen + infolen < maxlen) { strcat(outbuf, infostring); currlen += infolen; } + + // + // Fixed in OPM + // Some programs enumerate by testing indexes, and stop iterating if the index doesn't exist + // + index++; } } @@ -263,6 +306,12 @@ void SV_ShutdownGamespy() return; } + if (!gsRunning) { + // Added in OPM + // Gamespy is not running + return; + } + strcpy(gamemode, "exiting"); if (gcdInitialized) { @@ -272,12 +321,12 @@ void SV_ShutdownGamespy() qr_send_statechanged(NULL); qr_shutdown(NULL); + + gsRunning = qfalse; } qboolean SV_InitGamespy() { - cvar_t *net_ip; - cvar_t *net_gamespy_port; char secret_key[9]; const char *secret_gs_key; const char *gs_game_name; @@ -339,10 +388,12 @@ qboolean SV_InitGamespy() gcdInitialized = qtrue; } + gsRunning = qtrue; + return qtrue; } -void SV_CreateGamespyChallenge(char* challenge) +void SV_CreateGamespyChallenge(char *challenge) { int i; @@ -352,10 +403,10 @@ void SV_CreateGamespyChallenge(char* challenge) challenge[i] = 0; } -challenge_t* FindChallengeById(int gameid) +challenge_t *FindChallengeById(int gameid) { - challenge_t* challenge; - int i; + challenge_t *challenge; + int i; for (i = 0; i < MAX_CHALLENGES; i++) { challenge = &svs.challenges[i]; @@ -367,61 +418,63 @@ challenge_t* FindChallengeById(int gameid) return NULL; } -void AuthenticateCallback(int gameid, int localid, int authenticated, char* errmsg, void* instance) +void AuthenticateCallback(int gameid, int localid, int authenticated, char *errmsg, void *instance) { - challenge_t* challenge; - qboolean valid = qfalse; + challenge_t *challenge; + qboolean valid = qfalse; if (localid || !Q_stricmp(errmsg, "CD Key in use")) { valid = qtrue; } challenge = FindChallengeById(gameid); - if (valid) - { + if (valid) { challenge->cdkeyState = 2; - challenge->pingTime = svs.time; + challenge->pingTime = svs.time; - NET_OutOfBandPrint(NS_SERVER, challenge->adr, "challengeResponse %i", challenge->challenge); - } - else - { + SV_NET_OutOfBandPrint(&svs.netprofile, challenge->adr, "challengeResponse %i", challenge->challenge); + } else { char buf[32]; if (!challenge) { return; } - Com_sprintf(buf, sizeof(buf), "%d.%d.%d.%d", challenge->adr.ip[0], challenge->adr.ip[1], challenge->adr.ip[2], challenge->adr.ip[3]); + Com_sprintf( + buf, + sizeof(buf), + "%d.%d.%d.%d", + challenge->adr.ip[0], + challenge->adr.ip[1], + challenge->adr.ip[2], + challenge->adr.ip[3] + ); Com_Printf("%s failed cdkey authorization\n", buf); challenge->cdkeyState = 3; // tell the client about the reason - NET_OutOfBandPrint(NS_SERVER, challenge->adr, "droperror\nServer rejected connection:\n%s", errmsg); + SV_NET_OutOfBandPrint(&svs.netprofile, challenge->adr, "droperror\nServer rejected connection:\n%s", errmsg); } } -void RefreshAuthCallback(int gameid, int localid, int hint, char* challenge, void* instance) -{ -} +void RefreshAuthCallback(int gameid, int localid, int hint, char *challenge, void *instance) {} -void SV_GamespyAuthorize(netadr_t from, const char* response) +void SV_GamespyAuthorize(netadr_t from, const char *response) { - char buf[64]; - challenge_t* challenge = FindChallenge(from, qtrue); + char buf[64]; + challenge_t *challenge = FindChallenge(from, qtrue); if (!challenge) { return; } - switch (challenge->cdkeyState) - { + switch (challenge->cdkeyState) { case CDKS_NONE: challenge->cdkeyState = CDKS_AUTHENTICATING; - challenge->firstTime = svs.time; + challenge->firstTime = svs.time; gcd_authenticate_user( GS_GetCurrentGameID(), challenge->gamespyId, - LittleLong(*(unsigned int*)from.ip), + LittleLong(*(unsigned int *)from.ip), challenge->gsChallenge, response, AuthenticateCallback, @@ -432,25 +485,87 @@ void SV_GamespyAuthorize(netadr_t from, const char* response) case CDKS_AUTHENTICATING: // the server can't reach the authentication server // let the client connect - if (svs.time - challenge->firstTime > 5000) - { + if (svs.time - challenge->firstTime > 5000) { Com_DPrintf("authorize server timed out\n"); challenge->cdkeyState = CDKS_AUTHENTICATED; - challenge->pingTime = svs.time; - NET_OutOfBandPrint(NS_SERVER, from, "challengeResponse %i", challenge->challenge); + challenge->pingTime = svs.time; + SV_NET_OutOfBandPrint(&svs.netprofile, from, "challengeResponse %i", challenge->challenge); } break; case CDKS_AUTHENTICATED: - NET_OutOfBandPrint(NS_SERVER, from, "challengeResponse %i", challenge->challenge); + SV_NET_OutOfBandPrint(&svs.netprofile, from, "challengeResponse %i", challenge->challenge); break; case CDKS_FAILED: // authentication server told the cdkey was invalid - Com_sprintf(buf, sizeof(buf), "%d.%d.%d.%d", challenge->adr.ip[0], challenge->adr.ip[1], challenge->adr.ip[2], challenge->adr.ip[3]); + Com_sprintf( + buf, + sizeof(buf), + "%d.%d.%d.%d", + challenge->adr.ip[0], + challenge->adr.ip[1], + challenge->adr.ip[2], + challenge->adr.ip[3] + ); Com_Printf("%s failed cdkey authorization\n", buf); // reject the client - NET_OutOfBandPrint(NS_SERVER, from, "droperror\nServer rejected connection:\nInvalid CD Key"); + SV_NET_OutOfBandPrint(&svs.netprofile, from, "droperror\nServer rejected connection:\nInvalid CD Key"); break; default: break; } } + +void SV_RestartGamespy() +{ + if (gsRunning) { + // + // Reinitialize Gamespy + // + SV_ShutdownGamespy(); + SV_InitGamespy(); + } +} + +void SV_RestartGamespy_f() +{ + SV_RestartGamespy(); +} + +void SV_TryRestartGamespy() +{ + if (Com_RefreshGameSpyMasters()) { + SV_RestartGamespy(); + return; + } + + if (net_gamespy_port && net_gamespy_port->latchedString) { + SV_RestartGamespy(); + return; + } + + if (sv_gamespy && sv_gamespy->latchedString) { + SV_RestartGamespy(); + return; + } +} + +unsigned int qr_get_num_masters() +{ + return Com_GetNumMasterEntries(); +} + +const char *qr_get_master_host(int index) +{ + master_entry_t entry; + Com_GetMasterEntry(index, &entry); + + return entry.host; +} + +int qr_get_master_port(int index) +{ + master_entry_t entry; + Com_GetMasterEntry(index, &entry); + + return entry.hbport; +} diff --git a/code/gamespy/sv_gamespy.h b/code/gamespy/sv_gamespy.h index 3ceb293a..769a8afe 100644 --- a/code/gamespy/sv_gamespy.h +++ b/code/gamespy/sv_gamespy.h @@ -1,5 +1,31 @@ +/* +=========================================================================== +Copyright (C) 2025 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA source code 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. + +OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// sv_gamespy.h -- Game-specific server GameSpy code + #pragma once +#include "q_gamespy.h" + #ifdef __cplusplus extern "C" { #endif @@ -13,6 +39,13 @@ extern const char* GS_GetCurrentGameName(); void SV_CreateGamespyChallenge(char* challenge); void SV_GamespyAuthorize(netadr_t from, const char* response); +void SV_GamespyHeartbeat(); +void SV_ProcessGamespyQueries(); +qboolean SV_InitGamespy(); +void SV_ShutdownGamespy(); +void SV_RestartGamespy(); +void SV_RestartGamespy_f(); +void SV_TryRestartGamespy(); #ifdef __cplusplus } diff --git a/code/gamespy/sv_gqueryreporting.c b/code/gamespy/sv_gqueryreporting.c index 2e464d4b..0196a538 100644 --- a/code/gamespy/sv_gqueryreporting.c +++ b/code/gamespy/sv_gqueryreporting.c @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2025 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -20,335 +20,776 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -#include "../qcommon/q_shared.h" +/****** +.c +GameSpy Query & Reporting SDK + +Copyright 2000 GameSpy Industries, Inc + +18002 Skypark Circle +Irvine, CA 92614 +(949)798-4200 +Fax(949)798-4299 +****** + + + Please see the GameSpy Query & Reporting SDK documentation for more + information + + Updated 6/9/99 - DDW + Added get_sockaddrin function, and use for resolving + Made portable with additions from CEngine code + Double check that we don't bind to localhost (instead use INADDR_ANY) + + Updated 9/1/99 - DDW + Add the ability to pass in 0 as the queryport, to allocate it + automatically. + + Updated 10/11/99 - DDW + TCP Heartbeat support (#define TCP_HEARTBEATS) + + Updated 11/20/99 - BGW + Split goa_process_queries into two functions: goa_check_queries() and + goa_check_send_heartbeat(). + + Updated 3/19/00 - DDW + Added Dreamcast CE Support + + Updated 4/5/00 - DDW + Added Dreamcast Shinobi Support (use sendto/recvfrom for UDP sockets to work + around connect bug) + + Updated 4/17/00 - DDW + Use a single socket for heartbeats/queries (conserve sockets on DC) + + Updated 5/23/00 - DDW + Developer SDK renamed "Query & Reporting SDK" + Encapsulate global data in a structure so multiple simultaneous instances + can run in the same process. Most developers can just pass NULL for the extra + parameter. + qr_init now scans for an open port, starting from a base port. + heartbeats are sent every 30 seconds now until the first query is received, + then they are sent every 5 minutes as recommened by the developer spec + this helps remove the problem of dropped heartbeats causing a server to not + show up for 5 minutes. + + Updated 10/2/00 - DDW + Added qr_process_queries_no_heartbeat, so you can advertise a server on the + LAN only. + Updated 11/9/00 - DDW + Use common alloc/re-alloc functions +******/ + +/******** +INCLUDES +********/ +#if defined(applec) || defined(THINK_C) || defined(__MWERKS__) && !defined(__KATANA__) && !defined(__mips64) +#include "::nonport.h" +#else +#include "nonport.h" +#endif #include "sv_gqueryreporting.h" +#include +#include -#include "common/gsPlatformSocket.h" -#include "common/gsPlatformUtil.h" -#include "gutil.h" +#include +#if !defined(UNDER_CE) && !defined(__KATANA__) +#include +#else +#define assert(a) +#endif -static char *queries[] = {"basic", "info", "rules", "players", "status", "packets", "echo", "secure"}; +#ifdef __cplusplus +extern "C" { +#endif -static qr_implementation_t static_rec; -static qr_implementation_t *current_rec = &static_rec; -struct sockaddr_in hbaddr; -char qr_hostname[64]; +/***** +TCP_HEARTBEATS +Define this to use reliable heartbeats. Only needed for certain +classes of peer-to-peer games, please contact us if you are unsure +whether you need this or not. +******/ +//#define TCP_HEARTBEATS -void qr_check_queries(qr_t qrec); -void qr_check_send_heartbeat(qr_t qrec); -static void parse_query(qr_t qrec, char *query, struct sockaddr *sender); -static void send_heartbeat(qr_t qrec, int statechanged); +/******** +TYPEDEFS +********/ +typedef unsigned char uchar; +#if defined(_LINUX) || defined(__linux__) +typedef unsigned int qrsocklen_t; +#else +typedef int qrsocklen_t; +#endif -void qr_process_queries(qr_t qrec) +typedef enum { - if (!qrec) { - qrec = current_rec; + qtunknown, + qtbasic, + qtinfo, + qtrules, + qtplayers, + qtstatus, + qtpackets, + qtecho, + qtsecure +} query_t; + +typedef struct qr_implementation_s +{ + SOCKET querysock; + SOCKET hbsock; + char gamename[64]; + char secret_key[128]; + qr_querycallback_t qr_basic_callback; + qr_querycallback_t qr_info_callback; + qr_querycallback_t qr_rules_callback; + qr_querycallback_t qr_players_callback; + unsigned long lastheartbeat; + int queryid; + int packetnumber; + int qport; + char no_query; + struct sockaddr_in hbaddr; + qr_cdkey_process_t cdkeyprocess; + void* udata; +}* qr_t; + +/******** +VARS +********/ +static const char* queries[] = {"", "basic", "info", "rules", "players", "status", "packets", "echo", "secure"}; +static struct sockaddr_in hbaddr; +struct qr_implementation_s static_rec = {INVALID_SOCKET, INVALID_SOCKET}; +static qr_t current_rec = &static_rec; +//char qr_hostname[64] = MASTER_ADDR; + +//static struct sockaddr_in MasterList[8]; +static struct sockaddr_in *MasterList = NULL; +static char keyvalue[8192]; +static int MasterCount; +static int MasterMaxCount; + +/******** +PROTOTYPES +********/ +static void send_heartbeat(qr_t qrec, int statechanged); +static void qr_parse_query(qr_t qrec, char* query, int len, struct sockaddr* sender); +static int do_connect(SOCKET sock, char* addr, int port, struct sockaddr_in* hbaddr); +static int do_connect_multi(); +void qr_check_queries(qr_t qrec); +void qr_check_send_heartbeat(qr_t qrec); + +static void init_qrec(qr_t* qrec, + int baseport, + SOCKET hbsock, + SOCKET querysock, + const char* gamename, + const char* secret_key, + qr_querycallback_t qr_basic_callback, + qr_querycallback_t qr_info_callback, + qr_querycallback_t qr_rules_callback, + qr_querycallback_t qr_players_callback, + void* userdata); + +/****************************************************************************/ +/* PUBLIC FUNCTIONS */ +/****************************************************************************/ + +/* qr_init: Initializes the sockets, etc. Returns an error value +if an error occured, or 0 otherwise */ +int qr_init(qr_t* qrec, + const char* ip, + int baseport, + const char* gamename, + const char* secret_key, + qr_querycallback_t qr_basic_callback, + qr_querycallback_t qr_info_callback, + qr_querycallback_t qr_rules_callback, + qr_querycallback_t qr_players_callback, + void* userdata) +{ + int lasterror; + struct sockaddr_in saddr; + qrsocklen_t saddrlen; + int maxport; + SOCKET querysock; + SOCKET hbsock; + + if (qrec != NULL) //init it to empty + *qrec = NULL; + //create our sockets + SocketStartUp(); + + querysock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); +#ifdef TCP_HEARTBEATS + hbsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); +#else + hbsock = querysock; //share the socket +#endif + if (INVALID_SOCKET == querysock || INVALID_SOCKET == hbsock) { + return E_GOA_WSOCKERROR; } + lasterror = 0; + maxport = baseport + NUM_PORTS_TO_TRY; + while (baseport < maxport) { + get_sockaddrin(ip, baseport, &saddr, NULL); + if (saddr.sin_addr.s_addr == htonl(0x7F000001)) //localhost -- we don't want that! + saddr.sin_addr.s_addr = INADDR_ANY; + + lasterror = bind(querysock, (struct sockaddr*)&saddr, sizeof(saddr)); + if (lasterror == 0) + break; //we found a port + baseport++; + } + + if (lasterror != 0) //we weren't able to find a port + { + return E_GOA_BINDERROR; + } + + if (baseport == 0) //we bound it dynamically + { + saddrlen = sizeof(saddr); + lasterror = getsockname(querysock, (struct sockaddr*)&saddr, &saddrlen); + if (lasterror) + return E_GOA_BINDERROR; + baseport = ntohs(saddr.sin_port); + } + + init_qrec(qrec, + baseport, + hbsock, + querysock, + gamename, + secret_key, + qr_basic_callback, + qr_info_callback, + qr_rules_callback, + qr_players_callback, + userdata); + + if (!qrec) { + qrec = ¤t_rec; + } + + return do_connect_multi(); +} + +void init_qrec(qr_t* qrec, + int qport, + SOCKET hbsock, + SOCKET querysock, + const char* gamename, + const char* secret_key, + qr_querycallback_t qr_basic_callback, + qr_querycallback_t qr_info_callback, + qr_querycallback_t qr_rules_callback, + qr_querycallback_t qr_players_callback, + void* userdata) +{ + qr_t cr; + + if (qrec == NULL) { + cr = &static_rec; + } else { + *qrec = (qr_t)malloc(sizeof(struct qr_implementation_s)); + cr = *qrec; + } + + strcpy(cr->gamename, gamename); + strcpy(cr->secret_key, secret_key); + + cr->qport = qport; + cr->lastheartbeat = 0; + cr->hbsock = hbsock; + cr->querysock = querysock; + cr->packetnumber = 0; + cr->queryid = 1; + cr->no_query = 1; + cr->udata = userdata; + cr->qr_basic_callback = qr_basic_callback; + cr->qr_info_callback = qr_info_callback; + cr->qr_players_callback = qr_players_callback; + cr->qr_rules_callback = qr_rules_callback; + cr->cdkeyprocess = NULL; +} + +int qr_init_socket(qr_t* qrec, + unsigned int s, + const char* gamename, + const char* secret_key, + qr_querycallback_t qr_basic_callback, + qr_querycallback_t qr_info_callback, + qr_querycallback_t qr_rules_callback, + qr_querycallback_t qr_players_callback, + void* userdata) +{ + if (qrec) { + *qrec = NULL; + } + + SocketStartUp(); + init_qrec(qrec, + 0, + s, + s, + gamename, + secret_key, + qr_basic_callback, + qr_info_callback, + qr_rules_callback, + qr_players_callback, + userdata); + + return do_connect_multi(); +} + +/* qr_process_queries: Processes any waiting queries, and sends a +heartbeat if 5 minutes have elapsed */ +void qr_process_queries(qr_t qrec) +{ + if (qrec == NULL) + qrec = current_rec; qr_check_send_heartbeat(qrec); qr_check_queries(qrec); } +/* qr_process_queries_no_heartbeat: Processes any waiting queries, but +never sends heartbeats */ void qr_process_queries_no_heartbeat(qr_t qrec) { - if (!qrec) { + if (qrec == NULL) qrec = current_rec; - } - qr_check_queries(qrec); } +/* qr_check_queries: Processes any waiting queries */ void qr_check_queries(qr_t qrec) { -#define INBUF_LEN 256 - static char indata[INBUF_LEN]; //256 byte input buffer + static char indata[INBUF_LEN]; //256 byte input buffer struct sockaddr_in saddr; - int error; + qrsocklen_t saddrlen = sizeof(struct sockaddr_in); + fd_set set; + struct timeval timeout = {0, 0}; + int error; -#if defined(_LINUX) - unsigned int saddrlen = sizeof(struct sockaddr_in); -#else - int saddrlen = sizeof(struct sockaddr_in); -#endif + if (0 == qrec->qport) + return; - while (CanReceiveOnSocket((SOCKET)qrec->hbsock)) { + FD_ZERO(&set); + FD_SET(qrec->querysock, &set); + + while (1) { + error = select(FD_SETSIZE, &set, NULL, NULL, &timeout); + if (gsiSocketIsError(error) || error == 0) + return; //else we have data - error = (int)recvfrom((SOCKET)qrec->hbsock, indata, (INBUF_LEN - 1), 0, (struct sockaddr *)&saddr, &saddrlen); - + error = recvfrom(qrec->querysock, indata, INBUF_LEN - 1, 0, (struct sockaddr*)&saddr, &saddrlen); if (gsiSocketIsNotError(error)) { indata[error] = '\0'; - parse_query(qrec, indata, (struct sockaddr *)&saddr); + qr_parse_query(qrec, indata, error, (struct sockaddr*)&saddr); } } } +/* check_send_heartbeat: Perform any scheduled outgoing +heartbeats, (every 5 minutes) */ void qr_check_send_heartbeat(qr_t qrec) { - unsigned long tc; + unsigned long tc = current_time(); - tc = current_time(); + if (INVALID_SOCKET == qrec->hbsock) + return; //no sockets to work with! - if ((SOCKET)qrec->hbsock != INVALID_SOCKET) { - if (tc - qrec->lastheartbeat > MAX_HEARTBEAT_TIME || tc < qrec->lastheartbeat) { - send_heartbeat(qrec, 0); - } else if (qrec->no_query > 0 && tc - qrec->lastheartbeat > MIN_HEARTBEAT_TIME) { - send_heartbeat(qrec, 0); - - qrec->no_query++; - if (qrec->no_query > 10) { - qrec->no_query = 0; - } - } + //check if we need to send a heartbet + if (tc - qrec->lastheartbeat > HB_TIME || qrec->lastheartbeat == 0 || tc < qrec->lastheartbeat) + send_heartbeat(qrec, 0); + else if (qrec->no_query > 0 + && tc - qrec->lastheartbeat > FIRST_HB_TIME) { //check to see if we haven't gotten a query yet + send_heartbeat(qrec, 0); + qrec->no_query++; + if (qrec->no_query > MAX_FIRST_COUNT) + qrec->no_query = 0; //stop trying to get first query } } +/* qr_send_statechanged: Sends a statechanged heartbeat, call when +your gamemode changes */ void qr_send_statechanged(qr_t qrec) { - if (!qrec) { + if (qrec == NULL) qrec = current_rec; - } send_heartbeat(qrec, 1); } +void qr_send_exiting(qr_t qrec) +{ + if (qrec == NULL) + qrec = current_rec; + send_heartbeat(qrec, 2); +} + +/* qr_shutdown: Cleans up the sockets and shuts down */ void qr_shutdown(qr_t qrec) { - if (qrec == NULL) { + if (qrec == NULL) qrec = current_rec; + if (INVALID_SOCKET != qrec->querysock && qrec->qport != 0) { + closesocket(qrec->querysock); } - if (INVALID_SOCKET != (SOCKET)qrec->hbsock && (SOCKET)qrec->querysock) //if we own the socket - { - closesocket((SOCKET)qrec->hbsock); + if (INVALID_SOCKET != qrec->hbsock && qrec->hbsock != qrec->querysock) { + closesocket(qrec->hbsock); } - qrec->hbsock = (void *)INVALID_SOCKET; + qrec->hbsock = INVALID_SOCKET; + qrec->querysock = INVALID_SOCKET; qrec->lastheartbeat = 0; - if (qrec->querysock) //if we own the socket + if (qrec != &static_rec) //need to gsifree it, it was dynamically allocated { - SocketShutDown(); + gsifree(qrec); } - if (qrec != &static_rec) //need to free it, it was dynamically allocated - { - free(qrec); + + if (MasterList) { + gsifree(MasterList); + MasterList = NULL; } + + MasterCount = 0; + + SocketShutDown(); +} + +/****************************************************************************/ + +static int do_connect(SOCKET sock, char* addr, int port, struct sockaddr_in* hbaddr) +{ +#ifdef TCP_HEARTBEATS + struct sockaddr_in saddr; + + get_sockaddrin(addr, port, &saddr, NULL); + + if (connect(sock, (struct sockaddr*)&saddr, sizeof(saddr)) == SOCKET_ERROR) { + return E_GOA_CONNERROR; + } + + add_master(&saddr); +#else + get_sockaddrin(addr, port, hbaddr, NULL); + add_master(hbaddr); +#endif + return 0; +} + +static int do_connect_multi() +{ + int i; + + MasterMaxCount = qr_get_num_masters(); + if (MasterList) { + gsifree(MasterList); + MasterList = NULL; + } + + MasterList = gsimalloc(sizeof(struct sockaddr_in) * MasterMaxCount); + MasterCount = 0; + + for(i = 0; i < MasterMaxCount; i++) { + struct sockaddr_in hbaddr; + if (get_sockaddrin(qr_get_master_host(i), qr_get_master_port(i), &hbaddr, NULL)) { + // Valid, add it + add_master(&hbaddr); + } + } + + return 0; } /* Return a sockaddrin for the given host (numeric or DNS) and port) Returns the hostent in savehent if it is not NULL */ -static int get_sockaddrin(const char *host, int port, struct sockaddr_in *saddr, struct hostent **savehent) +int get_sockaddrin(const char* host, int port, struct sockaddr_in* saddr, struct hostent** savehent) { - struct hostent *hent = NULL; + struct hostent* hent; + char broadcast_t[] = { + '2', '5', '5', '.', '2', '5', '5', '.', '2', '5', '5', '.', '2', '5', '5', '\0'}; //255.255.255.255 + hent = 0; + memset(saddr, 0, sizeof(struct sockaddr_in)); saddr->sin_family = AF_INET; - saddr->sin_port = htons((unsigned short)port); - if (host == NULL) { + saddr->sin_port = htons((unsigned short)port); + if (host == NULL) saddr->sin_addr.s_addr = INADDR_ANY; - } else { + else saddr->sin_addr.s_addr = inet_addr(host); - } - if (saddr->sin_addr.s_addr == INADDR_NONE && strcmp(host, "255.255.255.255") != 0) { + if (saddr->sin_addr.s_addr == INADDR_NONE && strcmp(host, broadcast_t) != 0) { hent = gethostbyname(host); - if (!hent) { + if (!hent) return 0; - } - saddr->sin_addr.s_addr = *(unsigned int *)hent->h_addr_list[0]; + saddr->sin_addr.s_addr = *(u_long*)hent->h_addr_list[0]; } - if (savehent != NULL) { + if (savehent != NULL) *savehent = hent; - } return 1; } /* value_for_key: this returns a value for a certain key in s, where s is a string -containing key\value pairs. If the key does not exist, it returns NULL. +containing key\value pairs. If the key does not exist, it returns NULL. Note: the value is stored in a common buffer. If you want to keep it, make a copy! */ -static char *value_for_key(const char *s, const char *key) +static char* value_for_key(const char* s, const char* key) { - static int valueindex; - char *pos, *pos2; - char keyspec[256] = "\\"; + static int valueindex; + char *pos, *pos2; + char keyspec[256] = "\\"; static char value[2][256]; valueindex ^= 1; strcat(keyspec, key); strcat(keyspec, "\\"); pos = strstr(s, keyspec); - if (!pos) { + if (!pos) return NULL; - } pos += strlen(keyspec); pos2 = value[valueindex]; - while (*pos && *pos != '\\') { + while (*pos && *pos != '\\') *pos2++ = *pos++; - } *pos2 = '\0'; return value[valueindex]; } -static void packet_send(qr_t qrec, struct sockaddr *addr, char *buffer) +/*****************************************************************************/ +/* Various encryption / encoding routines */ + +#ifndef _GUTIL +#define _GUTIL +static void swap_byte(uchar* a, uchar* b) +{ + uchar swapByte; + + swapByte = *a; + *a = *b; + *b = swapByte; +} + +static uchar encode_ct(uchar c) +{ + if (c < 26) + return ('A' + c); + if (c < 52) + return ('a' + c - 26); + if (c < 62) + return ('0' + c - 52); + if (c == 62) + return ('+'); + if (c == 63) + return ('/'); + + return 0; +} + +void gs_encode(uchar* ins, int size, uchar* result) +{ + int i, pos; + uchar trip[3]; + uchar kwart[4]; + + i = 0; + while (i < size) { + for (pos = 0; pos <= 2; pos++, i++) + if (i < size) + trip[pos] = *ins++; + else + trip[pos] = '\0'; + kwart[0] = (trip[0]) >> 2; + kwart[1] = (((trip[0]) & 3) << 4) + ((trip[1]) >> 4); + kwart[2] = (((trip[1]) & 15) << 2) + ((trip[2]) >> 6); + kwart[3] = (trip[2]) & 63; + for (pos = 0; pos <= 3; pos++) + *result++ = encode_ct(kwart[pos]); + } + *result = '\0'; +} + +void gs_encrypt(uchar* key, int key_len, uchar* buffer_ptr, int buffer_len) +{ + short counter; + uchar x, y, xorIndex; + uchar state[256]; + + for (counter = 0; counter < 256; counter++) + state[counter] = (uchar)counter; + + x = 0; + y = 0; + for (counter = 0; counter < 256; counter++) { + y = (key[x] + state[counter] + y) % 256; + x = (x + 1) % key_len; + swap_byte(&state[counter], &state[y]); + } + + x = 0; + y = 0; + for (counter = 0; counter < buffer_len; counter++) { + x = (x + buffer_ptr[counter] + 1) % 256; + y = (state[x] + y) % 256; + swap_byte(&state[x], &state[y]); + xorIndex = (state[x] + state[y]) % 256; + buffer_ptr[counter] ^= state[xorIndex]; + } +} +/*****************************************************************************/ +#endif + +/* packet_send: sends a key\value packet. Appends the queryid +key\value pair. Clears the buffer */ +static void packet_send(qr_t qrec, struct sockaddr* addr, char* buffer) { char keyvalue[80]; - if (!strlen(buffer)) { - return; - } - - Com_sprintf(keyvalue, sizeof(keyvalue), "\\queryid\\%d.%d", qrec->queryid, qrec->packetnumber); + if (strlen(buffer) == 0) + return; //dont need to send an empty one! + qrec->packetnumber++; //packet numbers start at 1 + snprintf(keyvalue, sizeof(keyvalue), "\\queryid\\%d.%d", qrec->queryid, qrec->packetnumber); strcat(buffer, keyvalue); - - qrec->packetnumber++; - - sendto((SOCKET)qrec->querysock, buffer, (int)strlen(buffer), 0, addr, sizeof(*addr)); - *buffer = 0; + sendto(qrec->querysock, buffer, (int)strlen(buffer), 0, addr, sizeof(struct sockaddr_in)); + buffer[0] = '\0'; } -static void buffer_send(qr_t qrec, struct sockaddr *sender, char *buffer, char *newdata) +/* buffer_send: appends buffer with newdata. If the combined +size would be too large, it flushes buffer first. Space is reserved +on the total size to allow for the queryid key\value */ +static void buffer_send(qr_t qrec, struct sockaddr* sender, char* buffer, char* newdata) { - int bcount; - int i; - char *lastkey; - char *pos; + char *pos, *lastkey; + int bcount = 0; - bcount = 0; - if (strlen(newdata) + strlen(buffer) < MAX_INFO_STRING) { + if (strlen(buffer) + strlen(newdata) < MAX_DATA_SIZE - 50) { strcat(buffer, newdata); - return; - } - - pos = newdata; - while (strlen(pos) > MAX_INFO_STRING) { - lastkey = pos; - - for (i = 0; i < MAX_INFO_STRING; ++i) { - if (pos[i] == '\\') { - if (!(bcount % 2)) { - lastkey = pos + i; + } else { + if (strlen(newdata) > MAX_DATA_SIZE - 50) //incoming data is too big already! + { + lastkey = pos = newdata; + while (pos - newdata < MAX_DATA_SIZE - 50) { + if ('\\' == *pos) { + if (bcount % 2 == 0) + lastkey = pos; + bcount++; } - - ++bcount; + pos++; } - } - - if (lastkey == pos) { - return; - } - - *lastkey = 0; - buffer_send(qrec, sender, buffer, pos); - *lastkey = '\\'; - pos = lastkey; - bcount = 0; - - if (strlen(buffer) + strlen(lastkey) < MAX_INFO_STRING) { - strcat(buffer, pos); - return; + if (lastkey == newdata) + return; //endless loop - single key was too big! + *lastkey = '\0'; + buffer_send(qrec, sender, buffer, newdata); + *lastkey = '\\'; + buffer_send(qrec, sender, buffer, lastkey); //send the rest! + } else { + packet_send(qrec, sender, buffer); + strcpy(buffer, newdata); } } - - packet_send(qrec, sender, buffer); - strcpy(buffer, pos); } -static void send_basic(qr_t qrec, struct sockaddr *sender, char *outbuf) +/* send_basic: sends a response to the basic query */ +static void send_basic(qr_t qrec, struct sockaddr* sender, char* outbuf) { - char keyvalue[MAX_KEYVALUES_LENGTH] = {0}; + char keyvalue[BUF_SIZE] = ""; - qrec->qr_basic_callback(keyvalue, MAX_KEYVALUES_LENGTH, qrec->udata); + assert(qrec->qr_basic_callback); + qrec->qr_basic_callback(keyvalue, sizeof(keyvalue), qrec->udata); buffer_send(qrec, sender, outbuf, keyvalue); } -static void send_info(qr_t qrec, struct sockaddr *sender, char *outbuf) +/* send_info: sends a response to the info query */ +static void send_info(qr_t qrec, struct sockaddr* sender, char* outbuf) { - char keyvalue[MAX_KEYVALUES_LENGTH] = {0}; + char keyvalue[BUF_SIZE] = ""; - qrec->qr_info_callback(keyvalue, MAX_KEYVALUES_LENGTH, qrec->udata); + assert(qrec->qr_info_callback); + qrec->qr_info_callback(keyvalue, sizeof(keyvalue), qrec->udata); buffer_send(qrec, sender, outbuf, keyvalue); } -static void send_rules(qr_t qrec, struct sockaddr *sender, char *outbuf) +/* send_rules: sends a response to the rules query. */ +static void send_rules(qr_t qrec, struct sockaddr* sender, char* outbuf) { - char keyvalue[MAX_KEYVALUES_LENGTH] = {0}; + char keyvalue[BUF_SIZE] = ""; - qrec->qr_rules_callback(keyvalue, MAX_KEYVALUES_LENGTH, qrec->udata); + assert(qrec->qr_rules_callback); + qrec->qr_rules_callback(keyvalue, sizeof(keyvalue), qrec->udata); buffer_send(qrec, sender, outbuf, keyvalue); } -static void send_players(qr_t qrec, struct sockaddr *sender, char *outbuf) +/* send_players: sends the players and their information.*/ +static void send_players(qr_t qrec, struct sockaddr* sender, char* outbuf) { - char keyvalue[MAX_KEYVALUES_LENGTH] = {0}; - - qrec->qr_players_callback(keyvalue, MAX_KEYVALUES_LENGTH, qrec->udata); + assert(qrec->qr_players_callback); + qrec->qr_players_callback(keyvalue, sizeof(keyvalue), qrec->udata); buffer_send(qrec, sender, outbuf, keyvalue); } -static void send_echo(qr_t qrec, struct sockaddr *sender, char *outbuf, const char *echostr) +/* send_echo: bounces the echostr back to sender +Note: you should always make sure that your echostr doesn't exceed the MAX_DATA_SIZE*/ +static void send_echo(qr_t qrec, struct sockaddr* sender, char* outbuf, char* echostr) { - char keyvalue[MAX_KEYVALUES_LENGTH] = {0}; + char keyvalue[MAX_DATA_SIZE]; - if (strlen(echostr) > 50) { + if (strlen(echostr) > MAX_DATA_SIZE - 50) return; - } - - Com_sprintf(keyvalue, sizeof(keyvalue), "\\echoresponse\\%s", echostr); + snprintf(keyvalue, sizeof(keyvalue), "\\echo\\%s", echostr); buffer_send(qrec, sender, outbuf, keyvalue); } -static void send_final(qr_t qrec, struct sockaddr *sender, char *outbuf, char *validation) +/* send_final: sends the remaining data in outbuf. Appends the final +key\value to the end. Also adds validation if required. */ +static void send_final(qr_t qrec, struct sockaddr* sender, char* outbuf, char* validation) { char keyvalue[256]; - char encrypted_val[128]; + char encrypted_val[128]; //don't need to null terminate char encoded_val[200]; - int keylen; + int keylen; - if (*validation) { + if (validation[0]) { keylen = (int)strlen(validation); - - if (keylen >= ARRAY_LEN(encrypted_val)) { + if (keylen > 128) return; - } - strcpy(encrypted_val, validation); - - gs_encrypt((uchar *)qrec->secret_key, (int)strlen(qrec->secret_key), encrypted_val, keylen); - gs_encode(encrypted_val, keylen, encoded_val); - - Com_sprintf(keyvalue, sizeof(keyvalue), "\\validate\\%s", encoded_val); + gs_encrypt((uchar*)qrec->secret_key, (int)strlen(qrec->secret_key), (uchar*)encrypted_val, keylen); + gs_encode((uchar*)encrypted_val, keylen, (uchar*)encoded_val); + snprintf(keyvalue, sizeof(keyvalue), "\\validate\\%s", encoded_val); buffer_send(qrec, sender, outbuf, keyvalue); } - Com_sprintf(keyvalue, sizeof(keyvalue), "\\final\\"); + snprintf(keyvalue, sizeof(keyvalue), "\\final\\"); buffer_send(qrec, sender, outbuf, keyvalue); packet_send(qrec, sender, outbuf); } -static void parse_query(qr_t qrec, char *query, struct sockaddr *sender) +/* parse_query: parse an incoming query (which may contain 1 or more +individual queries) and reply to each query */ +static void qr_parse_query(qr_t qrec, char* query, int len, struct sockaddr* sender) { - query_t querytype = qtunknown; - char buffer[MAX_KEYVALUES_LENGTH] = {0}; - const char *value; - char validation[256] = {0}; + int querytype; + char buffer[MAX_DATA_SIZE] = ""; + char* value; + char validation[256] = ""; - if (!qrec) { + if (qrec == NULL) qrec = current_rec; - } - - if (*query == ';') { - // custom handler - if (qrec->qr_custom_handler) { - qrec->qr_custom_handler(query, sender); + if (query[0] == 0x3B) /* a cdkey query */ + { + if (qrec->cdkeyprocess != NULL) { + qrec->cdkeyprocess(query, len, sender); } return; } - qrec->packetnumber = 0; qrec->queryid++; - - if (qrec->no_query > 0) { + qrec->packetnumber = 0; + if (qrec->no_query > 0) qrec->no_query = 0; - } - for (querytype = qtbasic; querytype <= qtsecure; ++querytype) { - value = value_for_key(query, queries[querytype - 1]); - if (value) { + for (querytype = qtbasic; querytype <= qtsecure; querytype++) { + if ((value = value_for_key(query, queries[querytype]))) switch (querytype) { case qtbasic: send_basic(qrec, sender, buffer); @@ -369,6 +810,7 @@ static void parse_query(qr_t qrec, char *query, struct sockaddr *sender) send_players(qrec, sender, buffer); break; case qtpackets: + /*note: "packets" is NOT a real query type. It is simply here to illustrate how a large query would look if broken into packets */ send_basic(qrec, sender, buffer); packet_send(qrec, sender, buffer); send_info(qrec, sender, buffer); @@ -378,160 +820,65 @@ static void parse_query(qr_t qrec, char *query, struct sockaddr *sender) send_players(qrec, sender, buffer); break; case qtecho: + //note: \echo\value is the syntax here send_echo(qrec, sender, buffer, value); break; case qtsecure: strcpy(validation, value); break; - default: - continue; + case qtunknown: + break; } - } } - send_final(qrec, sender, buffer, validation); } +int get_master_count() +{ + return MasterCount; +} + +void clear_master_list() +{ + memset(MasterList, 0, sizeof(MasterList)); + MasterCount = 0; +} + +void add_master(struct sockaddr_in* addr) +{ + int i; + for (i = 0; i < MasterCount; i++) { + if (memcmp(addr, &MasterList[i], sizeof(MasterList[i])) == 0) { + return; + } + } + if (i == MasterMaxCount) { + return; + } else { + MasterList[i] = *addr; + MasterCount++; + } +} + +/* send_heartbeat: Sends a heartbeat to the gamemaster, +adds \statechanged\ if statechanged != 0 */ static void send_heartbeat(qr_t qrec, int statechanged) { char buf[256]; + int ret; + int i; - sprintf(buf, "\\heartbeat\\%d\\gamename\\%s", qrec->qport, qrec->gamename); + snprintf(buf, sizeof(buf), "\\heartbeat\\%d\\gamename\\%s", qrec->qport, qrec->gamename); + if (statechanged) + snprintf(&buf[strlen(buf)], sizeof(buf) - strlen(buf), "\\statechanged\\"); - if (statechanged) { - sprintf(buf + strlen(buf), "\\statechanged\\%d", statechanged); + for (i = 0; i < MasterCount; i++) { + ret = sendto(qrec->hbsock, buf, (int)strlen(buf), 0, (struct sockaddr*)&MasterList[i], sizeof(MasterList[i])); } - sendto((SOCKET)qrec->hbsock, buf, (int)strlen(buf), 0, (const struct sockaddr *)&qrec->master_saddr, sizeof(qrec->master_saddr)); qrec->lastheartbeat = current_time(); } -static int do_connect(void *sock, char *addr, int port, struct sockaddr_in *master_saddr) -{ - get_sockaddrin(addr, port, master_saddr, NULL); - return 0; +#ifdef __cplusplus } - -void init_qrec( - qr_t *qrec, - int baseport, - SOCKET hbsock, - SOCKET querysock, - const char *gamename, - const char *secret_key, - qr_querycallback_t qr_basic_callback, - qr_querycallback_t qr_info_callback, - qr_querycallback_t qr_rules_callback, - qr_querycallback_t qr_players_callback, - void *userdata -) -{ - qr_t qr; - - if (qrec) { - qr = (qr_t)malloc(sizeof(qr_implementation_t)); - *qrec = qr; - } else { - qr = &static_rec; - } - - strcpy(qr->gamename, gamename); - strcpy(qr->secret_key, secret_key); - - qr->qport = baseport; - qr->hbsock = (void *)hbsock; - qr->querysock = (void *)querysock; - qr->queryid = 1; - qr->no_query = 1; - qr->udata = userdata; - qr->qr_basic_callback = qr_basic_callback; - qr->qr_info_callback = qr_info_callback; - qr->lastheartbeat = 0; - qr->packetnumber = 0; - qr->qr_players_callback = qr_players_callback; - qr->qr_rules_callback = qr_rules_callback; - qr->qr_custom_handler = NULL; -} - -#define NUM_PORTS_TO_TRY 100 - -int qr_init( - qr_t *qrec, - const char *ip, - int baseport, - const char *gamename, - const char *secret_key, - qr_querycallback_t qr_basic_callback, - qr_querycallback_t qr_info_callback, - qr_querycallback_t qr_rules_callback, - qr_querycallback_t qr_players_callback, - void *userdata -) -{ - struct sockaddr_in saddr; - SOCKET hbsock; - int maxport; - int lasterror = 0; - -#if defined(_LINUX) - unsigned int saddrlen; -#else - int saddrlen; #endif - - hbsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - if (hbsock == INVALID_SOCKET) { - return 1; - } - - maxport = baseport + NUM_PORTS_TO_TRY; - while (baseport < maxport) { - get_sockaddrin(ip, baseport, &saddr, NULL); - if (saddr.sin_addr.s_addr == htonl(0x7F000001)) { //localhost -- we don't want that! - saddr.sin_addr.s_addr = INADDR_ANY; - } - - lasterror = bind(hbsock, (struct sockaddr *)&saddr, sizeof(saddr)); - if (lasterror == 0) { - break; //we found a port - } - baseport++; - } - - if (lasterror != 0) //we weren't able to find a port - { - return 2; - } - - if (baseport == 0) //we bound it dynamically - { - saddrlen = sizeof(saddr); - - lasterror = getsockname(hbsock, (struct sockaddr *)&saddr, &saddrlen); - - if (lasterror) { - return 2; - } - baseport = ntohs(saddr.sin_port); - } - - init_qrec( - qrec, - baseport, - hbsock, - hbsock, - gamename, - secret_key, - qr_basic_callback, - qr_info_callback, - qr_rules_callback, - qr_players_callback, - userdata - ); - - if (!qrec) { - qrec = ¤t_rec; - } - - return do_connect((void *)hbsock, MASTER_SERVER_HOST, 27900, &(*qrec)->master_saddr); -} diff --git a/code/gamespy/sv_gqueryreporting.h b/code/gamespy/sv_gqueryreporting.h index 95f1a3f7..23823568 100644 --- a/code/gamespy/sv_gqueryreporting.h +++ b/code/gamespy/sv_gqueryreporting.h @@ -1,6 +1,6 @@ /* =========================================================================== -Copyright (C) 2023 the OpenMoHAA team +Copyright (C) 2025 the OpenMoHAA team This file is part of OpenMoHAA source code. @@ -20,50 +20,200 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ +/****** +gqueryreporting.h +GameSpy Query & Reporting SDK + +Copyright 2000 GameSpy Industries, Inc + +18002 Skypark Circle +Irvine, CA 92614 +(949)798-4200 +Fax(949)798-4299 +****** + + Please see the GameSpy Query & Reporting SDK documentation for more + information + +******/ + #pragma once -#include "common/gsPlatformSocket.h" +#ifdef __cplusplus +extern "C" { +#endif -#define MAX_KEYVALUES_LENGTH 1400 +/******** +ERROR CONSTANTS +--------------- +These constants are returned from qr_init to signal an error condition +***************/ -static const unsigned int MIN_HEARTBEAT_TIME = 30000; // wait at least 30 seconds before new heartbeat can be sent -static const unsigned int MAX_HEARTBEAT_TIME = 300000; // 5 minutes +#define E_GOA_WSOCKERROR 1 +#define E_GOA_BINDERROR 2 +#define E_GOA_DNSERROR 3 +#define E_GOA_CONNERROR 4 +/********* +NUM_PORTS_TO_TRY +---------------- +This value is the maximum number of ports that will be scanned to +find an open query port, starting from the value passed to qr_init +as the base port. Generally there is no reason to modify this value. +***********/ +#define NUM_PORTS_TO_TRY 100 -typedef void (*qr_querycallback_t)(char *outbuf, int maxlen, void *userdata); -typedef void (*qr_custom_handler_t)(const char *query, struct sockaddr *sender); +/******** +DEFINES +********/ +#define MASTER_PORT qr_get_master_port(0) +//#define MASTER_ADDR "master." GSI_DOMAIN_NAME +#define MASTER_ADDR qr_get_master_host(0) +#define FIRST_HB_TIME 30000 /* 30 sec */ +#define HB_TIME 300000 /* 5 minutes */ +#define MAX_FIRST_COUNT 10 /* 10 tries = 5 minutes */ +#define MAX_DATA_SIZE 1400 +#define INBUF_LEN 256 +#define BUF_SIZE 1400 -typedef enum query_e { - qtunknown, - qtbasic, - qtinfo, - qtrules, - qtplayers, - qtstatus, - qtpackets, - qtecho, - qtsecure -} query_t; +/* The hostname of the master server. +If the app resolves the hostname, an +IP can be stored here before calling +qr_init */ +extern char qr_hostname[64]; -typedef struct qr_implementation_s { - void *querysock; - void *hbsock; - char gamename[64]; - char secret_key[128]; - qr_querycallback_t qr_basic_callback; - qr_querycallback_t qr_info_callback; - qr_querycallback_t qr_rules_callback; - qr_querycallback_t qr_players_callback; - long unsigned int lastheartbeat; - int queryid; - int packetnumber; - int qport; - char no_query; - struct sockaddr_in master_saddr; - int unk2; - int unk3; - int unk4; - qr_custom_handler_t qr_custom_handler; - void *udata; -} qr_implementation_t, *qr_t; +/** + * @brief Custom function used to return the master host, based on game settings + * + * @return const char* The full master server address + */ +extern unsigned int qr_get_num_masters(); +extern const char *qr_get_master_host(int index); +extern int qr_get_master_port(int index); -#define MASTER_SERVER_HOST "master.x-null.net" +/******** +qr_querycallback_t +------------------- +This is the prototype for the callback functions your game needs to +implement for each of the four basic query types. The callback works the +same for each query type. + +[outbuf] is a pre-allocated buffer for you to place the query reply. It's size is +[maxlen] (default is 1400). If you need larger, you can adjust the + defines in gqueryreporting.c +[userdata] is the pointer that was passed into qr_init. You can use this for an + object or structure pointer if needed. + +Simply fill outbuf with the correct data for the query type (consult the sample +apps and the GameSpy Developer Spec). +outbuf should be a NULL terminated ANSI string. +********/ +typedef void (*qr_querycallback_t)(char* outbuf, int maxlen, void* userdata); + +typedef void (*qr_cdkey_process_t)(char* buf, int len, struct sockaddr* fromaddr); + +/*********** +qr_t +---- +This abstract type is used to instantiate multiple instances of the +Query & Reporting SDK (for example, if you are running multiple servers +in the same process). +For most games, you can ignore this value and pass NULL in to all functions +that require it. A single global instance will be used, similar to how the +original Developer SDK worked +************/ +typedef struct qr_implementation_s *qr_t; +/************ +QR_INIT +-------- +This creates/binds the sockets needed for heartbeats and queries/replies. +[qrec] if not null, will be filled with the qr_t instance for this server. + If you are not using more than one instance of the Query & Reporting SDK you + can pass in NULL for this value. +[ip] is an optional parameter that determines which dotted IP address to bind to on + a multi-homed machine. You can pass NULL to bind to all IP addresses. +[baseport] is the port to accept queries on. If baseport is not available, the + Query and Reporting SDK will scan for an available port in the range of + baseport -> baseport + NUM_PORTS_TO_TRY + Optionally, you can pass in 0 to have a port chosen automatically + (makes it harder for debugging/testing). +[gamename] is the unique gamename that you were given +[secretkey] is your unique secret key +[qr_*_callback] are your data callback functions, this cannot be NULL +[userdata] is an optional, implementation specific parameter that will be + passed to all callback functions. Use it to store an object or structure + pointer if needed. + +Returns +0 is successful, otherwise one of the E_GOA constants above. +************/ +int qr_init(/*[out]*/ qr_t* qrec, + const char* ip, + int baseport, + const char* gamename, + const char* secret_key, + qr_querycallback_t qr_basic_callback, + qr_querycallback_t qr_info_callback, + qr_querycallback_t qr_rules_callback, + qr_querycallback_t qr_players_callback, + void* userdata); + +/******************* +QR_PROCESS_QUERIES +------------------- +This function should be called somewhere in your main program loop to +process any pending server queries and send a heartbeat if 5 minutes has +elapsed. + +Query replies are very latency sensative, so you should make sure this +function is called at least every 100ms while your game is in progress. +The function has very low overhead and should not cause any performance +problems. +Unless you are using multiple instances of the SDK, you should pass NULl +for qrec. +The no_heartbeat version will not send any heartbeats to the master - use +this if you only want to advertise your server on the LAN. +********************/ +void qr_process_queries(qr_t qrec); +void qr_process_queries_no_heartbeat(qr_t qrec); + +/***************** +QR_SEND_STATECHANGED +-------------------- +This function forces a \statechanged\ heartbeat to be sent immediately. +Use it any time you have changed the gamestate of your game to signal the +master to update your status. +Also use it before your game exits by changing the gamestate to "exiting" +and sending a statechanged heartbeat. This will insure that your game +is removed from the list promptly. +Unless you are using multiple instances of the SDK, you should pass NULl +for qrec. +*******************/ +void qr_send_statechanged(qr_t qrec); + +/***************** +QR_SHUTDOWN +------------ +This function closes the sockets created in qr_init and takes care of +any misc. cleanup. You should try to call it when before exiting the server +if qr_init was called. +If you pass in a qrec that was returned from qr_init, all resources associated +with that qrec will be freed. If you passed NULL into qr_int, you can pass +NULL in here as well. +******************/ +void qr_shutdown(qr_t qrec); + +void qr_check_queries(qr_t qrec); + +void qr_send_exiting(qr_t qrec); + +int get_master_count(); + +void clear_master_list(); + +int get_sockaddrin(const char *host, int port, struct sockaddr_in *saddr, struct hostent **savehent); + +void add_master(struct sockaddr_in *addr); + +#ifdef __cplusplus +} +#endif diff --git a/code/gamespy/webservices/AuthService.c b/code/gamespy/webservices/AuthService.c index 0ad0ac51..11ecd459 100644 --- a/code/gamespy/webservices/AuthService.c +++ b/code/gamespy/webservices/AuthService.c @@ -51,7 +51,7 @@ const char WS_AUTHSERVICE_SIGNATURE_KEY[] = const char WS_AUTHSERVICE_SIGNATURE_EXP[] = "010001"; -// This is declared as an extern so it can be overriden when testing +// This is declared as an extern so it can be overridden when testing #define WS_LOGIN_SERVICE_URL_FORMAT "https://%s.auth.pubsvs." GSI_DOMAIN_NAME "/AuthService/AuthService.asmx" char wsAuthServiceURL[WS_LOGIN_MAX_URL_LEN] = ""; diff --git a/code/libmad-0.15.1b/CMakeLists.txt b/code/libmad-0.15.1b/CMakeLists.txt deleted file mode 100644 index 01fde5e0..00000000 --- a/code/libmad-0.15.1b/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -cmake_minimum_required(VERSION 3.5) -project(libmad) - -set(SRCS - "./bit.c" - "./decoder.c" - "./fixed.c" - "./frame.c" - "./huffman.c" - "./layer3.c" - "./layer12.c" - "./stream.c" - "./synth.c" - "./timer.c" - "./version.c" -) - -add_library(libmad STATIC ${SRCS}) -target_compile_definitions(libmad PUBLIC FPM_64BIT) -target_compile_definitions(libmad PUBLIC NDEBUG) # otherwise assert() will call abort() and it fails to compile on clang-16 (call to undeclared library function 'abort') diff --git a/code/libmad-0.15.1b/INSTALL b/code/libmad-0.15.1b/INSTALL deleted file mode 100644 index 50dbe439..00000000 --- a/code/libmad-0.15.1b/INSTALL +++ /dev/null @@ -1,183 +0,0 @@ -Basic Installation -================== - - These are generic installation instructions. - - The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that -you can run in the future to recreate the current configuration, a file -`config.cache' that saves the results of its tests to speed up -reconfiguring, and a file `config.log' containing compiler output -(useful mainly for debugging `configure'). - - If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can -be considered for the next release. If at some point `config.cache' -contains results you don't want to keep, you may remove or edit it. - - The file `configure.in' is used to create `configure' by a program -called `autoconf'. You only need `configure.in' if you want to change -it or regenerate `configure' using a newer version of `autoconf'. - -The simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. If you're - using `csh' on an old version of System V, you might need to type - `sh ./configure' instead to prevent `csh' from trying to execute - `configure' itself. - - Running `configure' takes awhile. While running, it prints some - messages telling which features it is checking for. - - 2. Type `make' to compile the package. - - 3. Optionally, type `make check' to run any self-tests that come with - the package. - - 4. Type `make install' to install the programs and any data files and - documentation. - - 5. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly - for the package's developers. If you use it, you may have to get - all sorts of other programs in order to regenerate files that came - with the distribution. - -Compilers and Options -===================== - - Some systems require unusual options for compilation or linking that -the `configure' script does not know about. You can give `configure' -initial values for variables by setting them in the environment. Using -a Bourne-compatible shell, you can do that on the command line like -this: - CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure - -Or on systems that have the `env' program, you can do it like this: - env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure - -Compiling For Multiple Architectures -==================================== - - You can compile the package for more than one kind of computer at the -same time, by placing the object files for each architecture in their -own directory. To do this, you must use a version of `make' that -supports the `VPATH' variable, such as GNU `make'. `cd' to the -directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. - - If you have to use a `make' that does not supports the `VPATH' -variable, you have to compile the package for one architecture at a time -in the source code directory. After you have installed the package for -one architecture, use `make distclean' before reconfiguring for another -architecture. - -Installation Names -================== - - By default, `make install' will install the package's files in -`/usr/local/bin', `/usr/local/man', etc. You can specify an -installation prefix other than `/usr/local' by giving `configure' the -option `--prefix=PATH'. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -give `configure' the option `--exec-prefix=PATH', the package will use -PATH as the prefix for installing programs and libraries. -Documentation and other data files will still use the regular prefix. - - In addition, if you use an unusual directory layout you can give -options like `--bindir=PATH' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - -Optional Features -================= - - Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. - - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. - -Specifying the System Type -========================== - - There may be some features `configure' can not figure out -automatically, but needs to determine by the type of host the package -will run on. Usually `configure' can figure that out, but if it prints -a message saying it can not guess the host type, give it the -`--host=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name with three fields: - CPU-COMPANY-SYSTEM - -See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the host type. - - If you are building compiler tools for cross-compiling, you can also -use the `--target=TYPE' option to select the type of system they will -produce code for and the `--build=TYPE' option to select the type of -system on which you are compiling the package. - -Sharing Defaults -================ - - If you want to set default values for `configure' scripts to share, -you can create a site shell script called `config.site' that gives -default values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. - -Operation Controls -================== - - `configure' recognizes the following options to control how it -operates. - -`--cache-file=FILE' - Use and save the results of the tests in FILE instead of - `./config.cache'. Set FILE to `/dev/null' to disable caching, for - debugging `configure'. - -`--help' - Print a summary of the options to `configure', and exit. - -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to `/dev/null' (any error - messages will still be shown). - -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. - -`--version' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`configure' also accepts some other, not widely useful, options. - diff --git a/code/libmad-0.15.1b/Makefile.am b/code/libmad-0.15.1b/Makefile.am deleted file mode 100644 index ad5c596d..00000000 --- a/code/libmad-0.15.1b/Makefile.am +++ /dev/null @@ -1,140 +0,0 @@ -## -## 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 -## -## $Id: Makefile.am,v 1.23 2004/02/17 02:02:03 rob Exp $ -## - -## Process this file with automake to produce Makefile.in - -SUBDIRS = -DIST_SUBDIRS = msvc++ - -lib_LTLIBRARIES = libmad.la -include_HEADERS = mad.h - -EXTRA_PROGRAMS = minimad - -minimad_SOURCES = minimad.c -minimad_INCLUDES = -minimad_LDADD = libmad.la - -EXTRA_DIST = mad.h.sed \ - CHANGES COPYRIGHT CREDITS README TODO VERSION - -exported_headers = version.h fixed.h bit.h timer.h stream.h frame.h \ - synth.h decoder.h - -headers = $(exported_headers) \ - global.h layer12.h layer3.h huffman.h - -data_includes = D.dat imdct_s.dat qc_table.dat rq_table.dat \ - sf_table.dat - -libmad_la_SOURCES = version.c fixed.c bit.c timer.c stream.c frame.c \ - synth.c decoder.c layer12.c layer3.c huffman.c \ - $(headers) $(data_includes) - -EXTRA_libmad_la_SOURCES = imdct_l_arm.S #synth_mmx.S - -libmad_la_DEPENDENCIES = @ASO_OBJS@ -libmad_la_LIBADD = @ASO_OBJS@ - -INCLUDES = $(FPM) $(ASO) - -BUILT_SOURCES = mad.h -CLEANFILES = mad.h - -## From the libtool documentation on library versioning: -## -## CURRENT -## The most recent interface number that this library implements. -## -## REVISION -## The implementation number of the CURRENT interface. -## -## AGE -## The difference between the newest and oldest interfaces that this -## library implements. In other words, the library implements all the -## interface numbers in the range from number `CURRENT - AGE' to -## `CURRENT'. -## -## If two libraries have identical CURRENT and AGE numbers, then the -## dynamic linker chooses the library with the greater REVISION number. -## -## 1. Start with version information of `0:0:0' for each libtool library. -## -## 2. Update the version information only immediately before a public -## release of your software. More frequent updates are unnecessary, -## and only guarantee that the current interface number gets larger -## faster. -## -## 3. If the library source code has changed at all since the last -## update, then increment REVISION (`C:R:A' becomes `C:r+1:A'). -## -## 4. If any interfaces have been added, removed, or changed since the -## last update, increment CURRENT, and set REVISION to 0. -## -## 5. If any interfaces have been added since the last public release, -## then increment AGE. -## -## 6. If any interfaces have been removed since the last public release, -## then set AGE to 0. - -version_current = 2 -version_revision = 1 -version_age = 2 - -version_info = $(version_current):$(version_revision):$(version_age) - -libmad_la_LDFLAGS = -version-info $(version_info) - -mad.h: config.status config.h Makefile.am \ - $(srcdir)/COPYRIGHT $(srcdir)/mad.h.sed $(exported_headers) - (sed -e '1s|.*|/*|' -e '1b' -e '$$s|.*| */|' -e '$$b' \ - -e 's/^.*/ *&/' $(srcdir)/COPYRIGHT; echo; \ - echo "# ifdef __cplusplus"; \ - echo 'extern "C" {'; \ - echo "# endif"; echo; \ - if [ ".$(FPM)" != "." ]; then \ - echo ".$(FPM)" | sed -e 's|^\.-D|# define |'; echo; \ - fi; \ - sed -ne 's/^# *define *\(HAVE_.*_ASM\).*/# define \1/p' \ - config.h; echo; \ - sed -ne 's/^# *define *OPT_\(SPEED\|ACCURACY\).*/# define OPT_\1/p' \ - config.h; echo; \ - sed -ne 's/^# *define *\(SIZEOF_.*\)/# define \1/p' \ - config.h; echo; \ - for header in $(exported_headers); do \ - echo; \ - sed -n -f $(srcdir)/mad.h.sed $(srcdir)/$$header; \ - done; echo; \ - echo "# ifdef __cplusplus"; \ - echo '}'; \ - echo "# endif") >$@ - -libtool: $(LIBTOOL_DEPS) - $(SHELL) ./config.status --recheck - -.c.s: - $(COMPILE) -S $< - -again: - $(MAKE) clean - $(MAKE) - -.PHONY: again diff --git a/code/libmad-0.15.1b/Makefile.in b/code/libmad-0.15.1b/Makefile.in deleted file mode 100644 index 723070ad..00000000 --- a/code/libmad-0.15.1b/Makefile.in +++ /dev/null @@ -1,821 +0,0 @@ -# Makefile.in generated by automake 1.8.2 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004 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. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - - -SOURCES = $(libmad_la_SOURCES) $(EXTRA_libmad_la_SOURCES) $(minimad_SOURCES) - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -top_builddir = . -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -INSTALL = @INSTALL@ -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -host_triplet = @host@ -EXTRA_PROGRAMS = minimad$(EXEEXT) -DIST_COMMON = README $(am__configure_deps) $(include_HEADERS) \ - $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ - $(srcdir)/config.h.in $(srcdir)/libmad.list.in \ - $(top_srcdir)/configure COPYING INSTALL TODO config.guess \ - config.sub depcomp install-sh ltmain.sh missing mkinstalldirs -subdir = . -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ - configure.lineno configure.status.lineno -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs -CONFIG_HEADER = config.h -CONFIG_CLEAN_FILES = libmad.list -am__installdirs = $(DESTDIR)$(libdir) $(DESTDIR)$(includedir) -libLTLIBRARIES_INSTALL = $(INSTALL) -LTLIBRARIES = $(lib_LTLIBRARIES) -am__objects_1 = -am__objects_2 = $(am__objects_1) -am_libmad_la_OBJECTS = version.lo fixed.lo bit.lo timer.lo stream.lo \ - frame.lo synth.lo decoder.lo layer12.lo layer3.lo huffman.lo \ - $(am__objects_2) $(am__objects_1) -libmad_la_OBJECTS = $(am_libmad_la_OBJECTS) -am_minimad_OBJECTS = minimad.$(OBJEXT) -minimad_OBJECTS = $(am_minimad_OBJECTS) -minimad_DEPENDENCIES = libmad.la -DEFAULT_INCLUDES = -I. -I$(srcdir) -I. -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles -@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/bit.Plo ./$(DEPDIR)/decoder.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/fixed.Plo ./$(DEPDIR)/frame.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/huffman.Plo ./$(DEPDIR)/layer12.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/layer3.Plo ./$(DEPDIR)/minimad.Po \ -@AMDEP_TRUE@ ./$(DEPDIR)/stream.Plo ./$(DEPDIR)/synth.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/timer.Plo ./$(DEPDIR)/version.Plo -CCASCOMPILE = $(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS) -LTCCASCOMPILE = $(LIBTOOL) --mode=compile $(CCAS) $(AM_CCASFLAGS) \ - $(CCASFLAGS) -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -SOURCES = $(libmad_la_SOURCES) $(EXTRA_libmad_la_SOURCES) \ - $(minimad_SOURCES) -DIST_SOURCES = $(libmad_la_SOURCES) $(EXTRA_libmad_la_SOURCES) \ - $(minimad_SOURCES) -RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ - html-recursive info-recursive install-data-recursive \ - install-exec-recursive install-info-recursive \ - install-recursive installcheck-recursive installdirs-recursive \ - pdf-recursive ps-recursive uninstall-info-recursive \ - uninstall-recursive -includeHEADERS_INSTALL = $(INSTALL_HEADER) -HEADERS = $(include_HEADERS) -ETAGS = etags -CTAGS = ctags -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 -GZIP_ENV = --best -distuninstallcheck_listfiles = find . -type f -print -distcleancheck_listfiles = find . -type f -print -ACLOCAL = @ACLOCAL@ -AMDEP_FALSE = @AMDEP_FALSE@ -AMDEP_TRUE = @AMDEP_TRUE@ -AMTAR = @AMTAR@ -AR = @AR@ -ASO = @ASO@ -ASO_OBJS = @ASO_OBJS@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCAS = @CCAS@ -CCASFLAGS = @CCASFLAGS@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -ECHO = @ECHO@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -F77 = @F77@ -FFLAGS = @FFLAGS@ -FPM = @FPM@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LIBTOOL_DEPS = @LIBTOOL_DEPS@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -RANLIB = @RANLIB@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_F77 = @ac_ct_F77@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -ac_ct_STRIP = @ac_ct_STRIP@ -am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ -am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ -am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ -am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -datadir = @datadir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -SUBDIRS = -DIST_SUBDIRS = msvc++ -lib_LTLIBRARIES = libmad.la -include_HEADERS = mad.h -minimad_SOURCES = minimad.c -minimad_INCLUDES = -minimad_LDADD = libmad.la -EXTRA_DIST = mad.h.sed \ - CHANGES COPYRIGHT CREDITS README TODO VERSION - -exported_headers = version.h fixed.h bit.h timer.h stream.h frame.h \ - synth.h decoder.h - -headers = $(exported_headers) \ - global.h layer12.h layer3.h huffman.h - -data_includes = D.dat imdct_s.dat qc_table.dat rq_table.dat \ - sf_table.dat - -libmad_la_SOURCES = version.c fixed.c bit.c timer.c stream.c frame.c \ - synth.c decoder.c layer12.c layer3.c huffman.c \ - $(headers) $(data_includes) - -EXTRA_libmad_la_SOURCES = imdct_l_arm.S #synth_mmx.S -libmad_la_DEPENDENCIES = @ASO_OBJS@ -libmad_la_LIBADD = @ASO_OBJS@ -INCLUDES = $(FPM) $(ASO) -BUILT_SOURCES = mad.h -CLEANFILES = mad.h -version_current = 2 -version_revision = 1 -version_age = 2 -version_info = $(version_current):$(version_revision):$(version_age) -libmad_la_LDFLAGS = -version-info $(version_info) -all: $(BUILT_SOURCES) config.h - $(MAKE) $(AM_MAKEFLAGS) all-recursive - -.SUFFIXES: -.SUFFIXES: .S .c .lo .o .obj .s -am--refresh: - @: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \ - cd $(srcdir) && $(AUTOMAKE) --foreign \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ - 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);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - $(SHELL) ./config.status --recheck - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(srcdir) && $(AUTOCONF) -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) - -config.h: stamp-h1 - @if test ! -f $@; then \ - rm -f stamp-h1; \ - $(MAKE) stamp-h1; \ - else :; fi - -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: $(am__configure_deps) - cd $(top_srcdir) && $(AUTOHEADER) - rm -f stamp-h1 - touch $@ - -distclean-hdr: - -rm -f config.h stamp-h1 -libmad.list: $(top_builddir)/config.status $(srcdir)/libmad.list.in - cd $(top_builddir) && $(SHELL) ./config.status $@ -install-libLTLIBRARIES: $(lib_LTLIBRARIES) - @$(NORMAL_INSTALL) - $(mkdir_p) $(DESTDIR)$(libdir) - @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ - if test -f $$p; then \ - f="`echo $$p | sed -e 's|^.*/||'`"; \ - echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$f"; \ - $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$f; \ - else :; fi; \ - done - -uninstall-libLTLIBRARIES: - @$(NORMAL_UNINSTALL) - @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ - p="`echo $$p | sed -e 's|^.*/||'`"; \ - echo " $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p"; \ - $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \ - done - -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 -libmad.la: $(libmad_la_OBJECTS) $(libmad_la_DEPENDENCIES) - $(LINK) -rpath $(libdir) $(libmad_la_LDFLAGS) $(libmad_la_OBJECTS) $(libmad_la_LIBADD) $(LIBS) -minimad$(EXEEXT): $(minimad_OBJECTS) $(minimad_DEPENDENCIES) - @rm -f minimad$(EXEEXT) - $(LINK) $(minimad_LDFLAGS) $(minimad_OBJECTS) $(minimad_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bit.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/decoder.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fixed.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/frame.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/huffman.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/layer12.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/layer3.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/minimad.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stream.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/synth.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timer.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/version.Plo@am__quote@ - -.S.o: - $(CCASCOMPILE) -c $< - -.S.obj: - $(CCASCOMPILE) -c `$(CYGPATH_W) '$<'` - -.S.lo: - $(LTCCASCOMPILE) -c -o $@ $< - -.c.o: -@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c $< - -.c.obj: -@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -distclean-libtool: - -rm -f libtool -uninstall-info-am: -install-includeHEADERS: $(include_HEADERS) - @$(NORMAL_INSTALL) - $(mkdir_p) $(DESTDIR)$(includedir) - @list='$(include_HEADERS)'; for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - f="`echo $$p | sed -e 's|^.*/||'`"; \ - echo " $(includeHEADERS_INSTALL) $$d$$p $(DESTDIR)$(includedir)/$$f"; \ - $(includeHEADERS_INSTALL) $$d$$p $(DESTDIR)$(includedir)/$$f; \ - done - -uninstall-includeHEADERS: - @$(NORMAL_UNINSTALL) - @list='$(include_HEADERS)'; for p in $$list; do \ - f="`echo $$p | sed -e 's|^.*/||'`"; \ - echo " rm -f $(DESTDIR)$(includedir)/$$f"; \ - rm -f $(DESTDIR)$(includedir)/$$f; \ - done - -# This directory's subdirectories are mostly independent; you can cd -# into them and run `make' without going through this Makefile. -# To change the values of `make' variables: instead of editing Makefiles, -# (1) if the variable is set in `config.status', edit `config.status' -# (which will cause the Makefiles to be regenerated when you run `make'); -# (2) otherwise, pass the desired values on the `make' command line. -$(RECURSIVE_TARGETS): - @set fnord $$MAKEFLAGS; amf=$$2; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -mostlyclean-recursive clean-recursive distclean-recursive \ -maintainer-clean-recursive: - @set fnord $$MAKEFLAGS; amf=$$2; \ - dot_seen=no; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - rev=''; for subdir in $$list; do \ - if test "$$subdir" = "."; then :; else \ - rev="$$subdir $$rev"; \ - fi; \ - done; \ - rev="$$rev ."; \ - target=`echo $@ | sed s/-recursive//`; \ - for subdir in $$rev; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ - done && test -z "$$fail" -tags-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ - done -ctags-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ - done - -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; } \ - END { for (i in files) print i; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - if (etags --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - else \ - include_option=--include; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test -f $$subdir/TAGS && \ - tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - 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; } \ - END { for (i in files) print i; }'`; \ - test -z "$(ETAGS_ARGS)$$tags$$unique" \ - || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$tags $$unique -ctags: CTAGS -CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - 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; } \ - END { for (i in files) print i; }'`; \ - test -z "$(CTAGS_ARGS)$$tags$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$tags $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && cd $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) $$here - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - $(am__remove_distdir) - mkdir $(distdir) - $(mkdir_p) $(distdir)/. - @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ - list='$(DISTFILES)'; for file in $$list; do \ - case $$file in \ - $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ - $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ - esac; \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test "$$dir" != "$$file" && test "$$dir" != "."; then \ - dir="/$$dir"; \ - $(mkdir_p) "$(distdir)$$dir"; \ - else \ - dir=''; \ - fi; \ - if test -d $$d/$$file; then \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done - list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test -d "$(distdir)/$$subdir" \ - || mkdir "$(distdir)/$$subdir" \ - || exit 1; \ - (cd $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="../$(top_distdir)" \ - distdir="../$(distdir)/$$subdir" \ - distdir) \ - || exit 1; \ - fi; \ - done - -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -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 $(SHELL) $(install_sh) -c -m a+r {} {} \; \ - || chmod -R a+r $(distdir) -dist-gzip: distdir - $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz - $(am__remove_distdir) - -dist-bzip2: distdir - $(AMTAR) chof - $(distdir) | bzip2 -9 -c >$(distdir).tar.bz2 - $(am__remove_distdir) - -dist-tarZ: distdir - $(AMTAR) chof - $(distdir) | compress -c >$(distdir).tar.Z - $(am__remove_distdir) - -dist-shar: distdir - shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz - $(am__remove_distdir) - -dist-zip: distdir - -rm -f $(distdir).zip - zip -rq $(distdir).zip $(distdir) - $(am__remove_distdir) - -dist dist-all: distdir - $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz - $(am__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 -# tarfile. -distcheck: dist - case '$(DIST_ARCHIVES)' in \ - *.tar.gz*) \ - GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(AMTAR) xf - ;;\ - *.tar.bz2*) \ - bunzip2 -c $(distdir).tar.bz2 | $(AMTAR) xf - ;;\ - *.tar.Z*) \ - uncompress -c $(distdir).tar.Z | $(AMTAR) xf - ;;\ - *.shar.gz*) \ - GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | unshar ;;\ - *.zip*) \ - unzip $(distdir).zip ;;\ - esac - chmod -R a-w $(distdir); chmod a+w $(distdir) - mkdir $(distdir)/_build - mkdir $(distdir)/_inst - chmod a-w $(distdir) - dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ - && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ - && cd $(distdir)/_build \ - && ../configure --srcdir=.. --prefix="$$dc_install_base" \ - $(DISTCHECK_CONFIGURE_FLAGS) \ - && $(MAKE) $(AM_MAKEFLAGS) \ - && $(MAKE) $(AM_MAKEFLAGS) dvi \ - && $(MAKE) $(AM_MAKEFLAGS) check \ - && $(MAKE) $(AM_MAKEFLAGS) install \ - && $(MAKE) $(AM_MAKEFLAGS) installcheck \ - && $(MAKE) $(AM_MAKEFLAGS) uninstall \ - && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ - distuninstallcheck \ - && chmod -R a-w "$$dc_install_base" \ - && ({ \ - (cd ../.. && $(mkdir_p) "$$dc_destdir") \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ - distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ - } || { rm -rf "$$dc_destdir"; exit 1; }) \ - && rm -rf "$$dc_destdir" \ - && $(MAKE) $(AM_MAKEFLAGS) dist \ - && rm -rf $(DIST_ARCHIVES) \ - && $(MAKE) $(AM_MAKEFLAGS) distcleancheck - $(am__remove_distdir) - @(echo "$(distdir) archives ready for distribution: "; \ - list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ - sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}' -distuninstallcheck: - @cd $(distuninstallcheck_dir) \ - && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ - || { echo "ERROR: files left after uninstall:" ; \ - if test -n "$(DESTDIR)"; then \ - echo " (check DESTDIR support)"; \ - fi ; \ - $(distuninstallcheck_listfiles) ; \ - exit 1; } >&2 -distcleancheck: distclean - @if test '$(srcdir)' = . ; then \ - echo "ERROR: distcleancheck can only run from a VPATH build" ; \ - exit 1 ; \ - fi - @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ - || { echo "ERROR: files left in build directory after distclean:" ; \ - $(distcleancheck_listfiles) ; \ - exit 1; } >&2 -check-am: all-am -check: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) check-recursive -all-am: Makefile $(LTLIBRARIES) $(HEADERS) config.h -installdirs: installdirs-recursive -installdirs-am: - $(mkdir_p) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir) -install: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -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 -mostlyclean-generic: - -clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) - -distclean-generic: - -rm -f $(CONFIG_CLEAN_FILES) - -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) -clean: clean-recursive - -clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ - mostlyclean-am - -distclean: distclean-recursive - -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-hdr distclean-libtool distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -info: info-recursive - -info-am: - -install-data-am: install-includeHEADERS - -install-exec-am: install-libLTLIBRARIES - -install-info: install-info-recursive - -install-man: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf $(top_srcdir)/autom4te.cache - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: uninstall-includeHEADERS uninstall-info-am \ - uninstall-libLTLIBRARIES - -uninstall-info: uninstall-info-recursive - -.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am am--refresh check \ - check-am clean clean-generic clean-libLTLIBRARIES \ - clean-libtool clean-recursive ctags ctags-recursive dist \ - dist-all dist-bzip2 dist-gzip dist-shar dist-tarZ dist-zip \ - distcheck distclean distclean-compile distclean-generic \ - distclean-hdr distclean-libtool distclean-recursive \ - distclean-tags distcleancheck distdir distuninstallcheck dvi \ - dvi-am html html-am info info-am install install-am \ - install-data install-data-am install-exec install-exec-am \ - install-includeHEADERS install-info install-info-am \ - install-libLTLIBRARIES install-man install-strip installcheck \ - installcheck-am installdirs installdirs-am maintainer-clean \ - maintainer-clean-generic maintainer-clean-recursive \ - mostlyclean mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool mostlyclean-recursive pdf pdf-am ps ps-am \ - tags tags-recursive uninstall uninstall-am \ - uninstall-includeHEADERS uninstall-info-am \ - uninstall-libLTLIBRARIES - - -mad.h: config.status config.h Makefile.am \ - $(srcdir)/COPYRIGHT $(srcdir)/mad.h.sed $(exported_headers) - (sed -e '1s|.*|/*|' -e '1b' -e '$$s|.*| */|' -e '$$b' \ - -e 's/^.*/ *&/' $(srcdir)/COPYRIGHT; echo; \ - echo "# ifdef __cplusplus"; \ - echo 'extern "C" {'; \ - echo "# endif"; echo; \ - if [ ".$(FPM)" != "." ]; then \ - echo ".$(FPM)" | sed -e 's|^\.-D|# define |'; echo; \ - fi; \ - sed -ne 's/^# *define *\(HAVE_.*_ASM\).*/# define \1/p' \ - config.h; echo; \ - sed -ne 's/^# *define *OPT_\(SPEED\|ACCURACY\).*/# define OPT_\1/p' \ - config.h; echo; \ - sed -ne 's/^# *define *\(SIZEOF_.*\)/# define \1/p' \ - config.h; echo; \ - for header in $(exported_headers); do \ - echo; \ - sed -n -f $(srcdir)/mad.h.sed $(srcdir)/$$header; \ - done; echo; \ - echo "# ifdef __cplusplus"; \ - echo '}'; \ - echo "# endif") >$@ - -libtool: $(LIBTOOL_DEPS) - $(SHELL) ./config.status --recheck - -.c.s: - $(COMPILE) -S $< - -again: - $(MAKE) clean - $(MAKE) - -.PHONY: again -# 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. -.NOEXPORT: diff --git a/code/libmad-0.15.1b/README b/code/libmad-0.15.1b/README deleted file mode 100644 index b3f15ea4..00000000 --- a/code/libmad-0.15.1b/README +++ /dev/null @@ -1,241 +0,0 @@ - - libmad - MPEG audio decoder library - Copyright (C) 2000-2004 Underbit Technologies, Inc. - - $Id: README,v 1.4 2004/01/23 09:41:32 rob Exp $ - -=============================================================================== - -INTRODUCTION - - MAD (libmad) is a high-quality MPEG audio decoder. It currently supports - MPEG-1 and the MPEG-2 extension to Lower Sampling Frequencies, as well as - the so-called MPEG 2.5 format. All three audio layers (Layer I, Layer II, - and Layer III a.k.a. MP3) are fully implemented. - - MAD does not yet support MPEG-2 multichannel audio (although it should be - backward compatible with such streams) nor does it currently support AAC. - - MAD has the following special features: - - - 24-bit PCM output - - 100% fixed-point (integer) computation - - completely new implementation based on the ISO/IEC standards - - distributed under the terms of the GNU General Public License (GPL) - - Because MAD provides full 24-bit PCM output, applications using MAD are - able to produce high quality audio. Even when the output device supports - only 16-bit PCM, applications can use the extra resolution to increase the - audible dynamic range through the use of dithering or noise shaping. - - Because MAD uses integer computation rather than floating point, it is - well suited for architectures without a floating point unit. All - calculations are performed with a 32-bit fixed-point integer - representation. - - Because MAD is a new implementation of the ISO/IEC standards, it is - unencumbered by the errors of other implementations. MAD is NOT a - derivation of the ISO reference source or any other code. Considerable - effort has been expended to ensure a correct implementation, even in cases - where the standards are ambiguous or misleading. - - Because MAD is distributed under the terms of the GPL, its redistribution - is not generally restricted, so long as the terms of the GPL are followed. - This means MAD can be incorporated into other software as long as that - software is also distributed under the GPL. (Should this be undesirable, - alternate arrangements may be possible by contacting Underbit.) - -=============================================================================== - -ABOUT THE CODE - - The code is optimized and performs very well, although specific - improvements can still be made. The output from the decoder library - consists of 32-bit signed linear fixed-point values that can be easily - scaled for any size PCM output, up to 24 bits per sample. - - The API for libmad can be found in the `mad.h' header file. Note that this - file is automatically generated, and will not exist until after you have - built the library. - - There are two APIs available, one high-level, and the other low-level. - With the low-level API, each step of the decoding process must be handled - explicitly, offering the greatest amount of control. With the high-level - API, after callbacks are configured, a single routine will decode an - entire bitstream. - - The high-level API may either be used synchronously or asynchronously. If - used asynchronously, decoding will occur in a separate process. - Communication is possible with the decoding process by passing control - messages. - - The file `minimad.c' contains an example usage of the libmad API that - shows only the bare minimum required to implement a useful decoder. It - expects a regular file to be redirected to standard input, and it sends - decoded 16-bit signed little-endian PCM samples to standard output. If a - decoding error occurs, it is reported to standard error and decoding - continues. Note that the scale() routine in this code is only provided as - an example; it rounds MAD's high-resolution samples down to 16 bits, but - does not perform any dithering or noise shaping. It is therefore not - recommended to use this routine as-is in your own code if sound quality is - important. - -Integer Performance - - To get the best possible performance, it is recommended that an assembly - version of the fixed-point multiply and related routines be selected. - Several such assembly routines have been written for various CPUs. - - If an assembly version is not available, a fast approximation version will - be used. This will result in reduced accuracy of the decoder. - - Alternatively, if 64-bit integers are supported as a datatype by the - compiler, another version can be used that is much more accurate. - However, using an assembly version is generally much faster and just as - accurate. - - More information can be gathered from the `fixed.h' header file. - - MAD's CPU-intensive subband synthesis routine can be further optimized at - the expense of a slight loss in output accuracy due to a modified method - for fixed-point multiplication with a small windowing constant. While this - is helpful for performance and the output accuracy loss is generally - undetectable, it is disabled by default and must be explicitly enabled. - - Under some architectures, other special optimizations may also be - available. - -Audio Quality - - The output from MAD has been found to satisfy the ISO/IEC 11172-4 - computational accuracy requirements for compliance. In most - configurations, MAD is a Full Layer III ISO/IEC 11172-3 audio decoder as - defined by the standard. - - When the approximation version of the fixed-point multiply is used, MAD is - a limited accuracy ISO/IEC 11172-3 audio decoder as defined by the - standard. - - MAD can alternatively be configured to produce output with less or more - accuracy than the default, as a tradeoff with performance. - - MAD produces output samples with a precision greater than 24 bits. Because - most output formats use fewer bits, typically 16, it is recommended that a - dithering algorithm be used (rather than rounding or truncating) to obtain - the highest quality audio. However, dithering may unfavorably affect an - analytic examination of the output (such as compliance testing); you may - therefore wish to use rounding in this case instead. - -Portability Issues - - GCC is preferred to compile the code, but other compilers may also work. - The assembly code in `fixed.h' depends on the inline assembly features of - your compiler. If you're not using GCC or MSVC++, you can either write - your own assembly macros or use the default (low quality output) version. - - The union initialization of `huffman.c' may not be portable to all - platforms when GCC is not used. - - The code should not be sensitive to word sizes or byte ordering, however - it does assume A % B has the same sign as A. - -=============================================================================== - -BUILDING AND INSTALLING - -Windows Platforms - - MAD can be built under Windows using either MSVC++ or Cygwin. A MSVC++ - project file can be found under the `msvc++' subdirectory. - - To build libmad using Cygwin, you will first need to install the Cygwin - tools: - - http://www.cygwin.com/ - - You may then proceed with the following POSIX instructions within the - Cygwin shell. - - Note that by default Cygwin will build a library that depends on the - Cygwin DLL. You can use MinGW to build a library that does not depend on - the Cygwin DLL. To do so, give the option --host=mingw32 to `configure'. - -POSIX Platforms (including Cygwin) - - The code is distributed with a `configure' script that will generate for - you a `Makefile' and a `config.h' for your platform. See the file - `INSTALL' for generic instructions. - - The specific options you may want to give `configure' are: - - --enable-speed optimize for speed over accuracy - - --enable-accuracy optimize for accuracy over speed - - --disable-debugging do not compile with debugging support, and - use more optimizations - - --disable-shared do not build a shared library - - Note that you need not specify one of --enable-speed or --enable-accuracy; - in its default configuration, MAD is optimized for both. You should only - use one of these options if you wish to compromise speed or accuracy for - the other. - - By default the package will build a shared library if possible for your - platform. If you want only a static library, use --disable-shared. - - It is not normally necessary to use the following options, but you may - fine-tune the configuration with them if desired: - - --enable-fpm=ARCH use the ARCH-specific version of the - fixed-point math assembly routines - (current options are: intel, arm, mips, - sparc, ppc; also allowed are: 64bit, approx) - - --enable-sso use the subband synthesis optimization, - with reduced accuracy - - --disable-aso do not use certain architecture-specific - optimizations - - By default an appropriate fixed-point assembly routine will be selected - for the configured host type, if it can be determined. Thus if you are - cross-compiling for another architecture, you should be sure either to - give `configure' a host type argument (--host) or to use an explicit - --enable-fpm option. - - If an appropriate assembly routine cannot be determined, the default - approximation version will be used. In this case, use of an alternate - --enable-fpm is highly recommended. - -Experimenting and Developing - - Further options for `configure' that may be useful to developers and - experimenters are: - - --enable-debugging enable diagnostic debugging support and - debugging symbols - - --enable-profiling generate `gprof' profiling code - - --enable-experimental enable code using the EXPERIMENTAL - preprocessor define - -=============================================================================== - -COPYRIGHT - - Please read the `COPYRIGHT' file for copyright and warranty information. - Also, the file `COPYING' contains the full text of the GNU GPL. - - Send inquiries, comments, bug reports, suggestions, patches, etc. to: - - Underbit Technologies, Inc. - - See also the MAD home page on the Web: - - http://www.underbit.com/products/mad/ - -=============================================================================== - diff --git a/code/libmad-0.15.1b/VERSION b/code/libmad-0.15.1b/VERSION deleted file mode 100644 index d4e8f64a..00000000 --- a/code/libmad-0.15.1b/VERSION +++ /dev/null @@ -1,7 +0,0 @@ -0.15.1b -configure.ac:24 -version.h:25-28 -msvc++/config.h:99,105,120 -msvc++/mad.h:41-44 - -Makefile.am:98-100 diff --git a/code/libmad-0.15.1b/aclocal.m4 b/code/libmad-0.15.1b/aclocal.m4 deleted file mode 100644 index 1d15e0b9..00000000 --- a/code/libmad-0.15.1b/aclocal.m4 +++ /dev/null @@ -1,6849 +0,0 @@ -# generated automatically by aclocal 1.8.2 -*- Autoconf -*- - -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 -# 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. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- - -# serial 47 AC_PROG_LIBTOOL -# Debian $Rev: 192 $ - - -# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED) -# ----------------------------------------------------------- -# If this macro is not defined by Autoconf, define it here. -m4_ifdef([AC_PROVIDE_IFELSE], - [], - [m4_define([AC_PROVIDE_IFELSE], - [m4_ifdef([AC_PROVIDE_$1], - [$2], [$3])])]) - - -# AC_PROG_LIBTOOL -# --------------- -AC_DEFUN([AC_PROG_LIBTOOL], -[AC_REQUIRE([_AC_PROG_LIBTOOL])dnl -dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX -dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX. - AC_PROVIDE_IFELSE([AC_PROG_CXX], - [AC_LIBTOOL_CXX], - [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX - ])]) -dnl And a similar setup for Fortran 77 support - AC_PROVIDE_IFELSE([AC_PROG_F77], - [AC_LIBTOOL_F77], - [define([AC_PROG_F77], defn([AC_PROG_F77])[AC_LIBTOOL_F77 -])]) - -dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly. -dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run -dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both. - AC_PROVIDE_IFELSE([AC_PROG_GCJ], - [AC_LIBTOOL_GCJ], - [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], - [AC_LIBTOOL_GCJ], - [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ], - [AC_LIBTOOL_GCJ], - [ifdef([AC_PROG_GCJ], - [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ])]) - ifdef([A][M_PROG_GCJ], - [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ])]) - ifdef([LT_AC_PROG_GCJ], - [define([LT_AC_PROG_GCJ], - defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])])]) -])])# AC_PROG_LIBTOOL - - -# _AC_PROG_LIBTOOL -# ---------------- -AC_DEFUN([_AC_PROG_LIBTOOL], -[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl -AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl -AC_BEFORE([$0],[AC_LIBTOOL_F77])dnl -AC_BEFORE([$0],[AC_LIBTOOL_GCJ])dnl - -# This can be used to rebuild libtool when needed -LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" - -# Always use our own libtool. -LIBTOOL='$(SHELL) $(top_builddir)/libtool' -AC_SUBST(LIBTOOL)dnl - -# Prevent multiple expansion -define([AC_PROG_LIBTOOL], []) -])# _AC_PROG_LIBTOOL - - -# AC_LIBTOOL_SETUP -# ---------------- -AC_DEFUN([AC_LIBTOOL_SETUP], -[AC_PREREQ(2.50)dnl -AC_REQUIRE([AC_ENABLE_SHARED])dnl -AC_REQUIRE([AC_ENABLE_STATIC])dnl -AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl -AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_CANONICAL_BUILD])dnl -AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([AC_PROG_LD])dnl -AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl -AC_REQUIRE([AC_PROG_NM])dnl - -AC_REQUIRE([AC_PROG_LN_S])dnl -AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl -# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers! -AC_REQUIRE([AC_OBJEXT])dnl -AC_REQUIRE([AC_EXEEXT])dnl -dnl - -AC_LIBTOOL_SYS_MAX_CMD_LEN -AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE -AC_LIBTOOL_OBJDIR - -AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl -_LT_AC_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. -Xsed='sed -e s/^X//' -[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 avoid accidental globbing in evaled expressions -no_glob_subst='s/\*/\\\*/g' - -# Constants: -rm="rm -f" - -# Global variables: -default_ofile=libtool -can_build_shared=yes - -# All known linkers require a `.a' archive for static linking (except M$VC, -# which needs '.lib'). -libext=a -ltmain="$ac_aux_dir/ltmain.sh" -ofile="$default_ofile" -with_gnu_ld="$lt_cv_prog_gnu_ld" - -AC_CHECK_TOOL(AR, ar, false) -AC_CHECK_TOOL(RANLIB, ranlib, :) -AC_CHECK_TOOL(STRIP, strip, :) - -old_CC="$CC" -old_CFLAGS="$CFLAGS" - -# Set sane defaults for various variables -test -z "$AR" && AR=ar -test -z "$AR_FLAGS" && AR_FLAGS=cru -test -z "$AS" && AS=as -test -z "$CC" && CC=cc -test -z "$LTCC" && LTCC=$CC -test -z "$DLLTOOL" && DLLTOOL=dlltool -test -z "$LD" && LD=ld -test -z "$LN_S" && LN_S="ln -s" -test -z "$MAGIC_CMD" && MAGIC_CMD=file -test -z "$NM" && NM=nm -test -z "$SED" && SED=sed -test -z "$OBJDUMP" && OBJDUMP=objdump -test -z "$RANLIB" && RANLIB=: -test -z "$STRIP" && STRIP=: -test -z "$ac_objext" && ac_objext=o - -# Determine commands to create old-style static archives. -old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs' -old_postinstall_cmds='chmod 644 $oldlib' -old_postuninstall_cmds= - -if test -n "$RANLIB"; then - case $host_os in - openbsd*) - old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds" - ;; - *) - old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds" - ;; - esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" -fi - -# Only perform the check for file, if the check method requires it -case $deplibs_check_method in -file_magic*) - if test "$file_magic_cmd" = '$MAGIC_CMD'; then - AC_PATH_MAGIC - fi - ;; -esac - -AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no) -AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL], -enable_win32_dll=yes, enable_win32_dll=no) - -AC_ARG_ENABLE([libtool-lock], - [AC_HELP_STRING([--disable-libtool-lock], - [avoid locking (might break parallel builds)])]) -test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes - -AC_ARG_WITH([pic], - [AC_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=default - -# Use C for the default configuration in the libtool script -tagname= -AC_LIBTOOL_LANG_C_CONFIG -_LT_AC_TAGCONFIG -])# AC_LIBTOOL_SETUP - - -# _LT_AC_SYS_COMPILER -# ------------------- -AC_DEFUN([_LT_AC_SYS_COMPILER], -[AC_REQUIRE([AC_PROG_CC])dnl - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# Allow CC to be a program name with arguments. -compiler=$CC -])# _LT_AC_SYS_COMPILER - - -# _LT_AC_SYS_LIBPATH_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. -AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX], -[AC_LINK_IFELSE(AC_LANG_PROGRAM,[ -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'` -# 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 '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'`; fi],[]) -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi -])# _LT_AC_SYS_LIBPATH_AIX - - -# _LT_AC_SHELL_INIT(ARG) -# ---------------------- -AC_DEFUN([_LT_AC_SHELL_INIT], -[ifdef([AC_DIVERSION_NOTICE], - [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], - [AC_DIVERT_PUSH(NOTICE)]) -$1 -AC_DIVERT_POP -])# _LT_AC_SHELL_INIT - - -# _LT_AC_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. -AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH], -[_LT_AC_SHELL_INIT([ -# Check that we are running under the correct shell. -SHELL=${CONFIG_SHELL-/bin/sh} - -case X$ECHO in -X*--fallback-echo) - # Remove one level of quotation (which was required for Make). - ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` - ;; -esac - -echo=${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 </dev/null && - echo_test_string="`eval $cmd`" && - (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. -ECHO=$echo -if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then - ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" -fi - -AC_SUBST(ECHO) -])])# _LT_AC_PROG_ECHO_BACKSLASH - - -# _LT_AC_LOCK -# ----------- -AC_DEFUN([_LT_AC_LOCK], -[AC_ARG_ENABLE([libtool-lock], - [AC_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-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|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-*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-*linux*) - LD="${LD-ld} -m elf_x86_64" - ;; - ppc*-*linux*|powerpc*-*linux*) - LD="${LD-ld} -m elf64ppc" - ;; - s390*-*linux*) - 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_TRY_LINK([],[],[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 - ;; -AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL], -[*-*-cygwin* | *-*-mingw* | *-*-pw32*) - AC_CHECK_TOOL(DLLTOOL, dlltool, false) - AC_CHECK_TOOL(AS, as, false) - AC_CHECK_TOOL(OBJDUMP, objdump, false) - ;; - ]) -esac - -need_locks="$enable_libtool_lock" - -])# _LT_AC_LOCK - - -# AC_LIBTOOL_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, -# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) -# ---------------------------------------------------------------- -# Check whether the given compiler option works -AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], -[AC_REQUIRE([LT_AC_PROG_SED]) -AC_CACHE_CHECK([$1], [$2], - [$2=no - ifelse([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) - printf "$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}? :&$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 - if test ! -s conftest.err; then - $2=yes - fi - fi - $rm conftest* -]) - -if test x"[$]$2" = xyes; then - ifelse([$5], , :, [$5]) -else - ifelse([$6], , :, [$6]) -fi -])# AC_LIBTOOL_COMPILER_OPTION - - -# AC_LIBTOOL_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, -# [ACTION-SUCCESS], [ACTION-FAILURE]) -# ------------------------------------------------------------ -# Check whether the given compiler option works -AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], -[AC_CACHE_CHECK([$1], [$2], - [$2=no - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS $3" - printf "$lt_simple_link_test_code" > conftest.$ac_ext - if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then - # The compiler 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 - else - $2=yes - fi - fi - $rm conftest* - LDFLAGS="$save_LDFLAGS" -]) - -if test x"[$]$2" = xyes; then - ifelse([$4], , :, [$4]) -else - ifelse([$5], , :, [$5]) -fi -])# AC_LIBTOOL_LINKER_OPTION - - -# AC_LIBTOOL_SYS_MAX_CMD_LEN -# -------------------------- -AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], -[# 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 - testring="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*) - # 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; - ;; - - *) - # 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"`$CONFIG_SHELL [$]0 --fallback-echo "X$testring" 2>/dev/null` \ - = "XX$testring") >/dev/null 2>&1 && - new_result=`expr "X$testring" : ".*" 2>&1` && - lt_cv_sys_max_cmd_len=$new_result && - test $i != 17 # 1/2 MB should be enough - do - i=`expr $i + 1` - testring=$testring$testring - done - testring= - # 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` - ;; - 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 -])# AC_LIBTOOL_SYS_MAX_CMD_LEN - - -# _LT_AC_CHECK_DLFCN -# -------------------- -AC_DEFUN([_LT_AC_CHECK_DLFCN], -[AC_CHECK_HEADERS(dlfcn.h)dnl -])# _LT_AC_CHECK_DLFCN - - -# _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, -# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) -# ------------------------------------------------------------------ -AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF], -[AC_REQUIRE([_LT_AC_CHECK_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 < -#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 - -#ifdef __cplusplus -extern "C" void exit (int); -#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); */ - } - - exit (status); -}] -EOF - if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) 2>/dev/null - lt_status=$? - case x$lt_status in - x$lt_dlno_uscore) $1 ;; - x$lt_dlneed_uscore) $2 ;; - x$lt_unknown|x*) $3 ;; - esac - else : - # compilation failed - $3 - fi -fi -rm -fr conftest* -])# _LT_AC_TRY_DLOPEN_SELF - - -# AC_LIBTOOL_DLOPEN_SELF -# ------------------- -AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], -[AC_REQUIRE([_LT_AC_CHECK_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*) - 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="-dld"], - [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="-dld"]) - ]) - ]) - ]) - ]) - ]) - ;; - 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" - 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_AC_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 - LDFLAGS="$LDFLAGS $link_static_flag" - AC_CACHE_CHECK([whether a statically linked program can dlopen itself], - lt_cv_dlopen_self_static, [dnl - _LT_AC_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 -])# AC_LIBTOOL_DLOPEN_SELF - - -# AC_LIBTOOL_PROG_CC_C_O([TAGNAME]) -# --------------------------------- -# Check to see if options -c and -o are simultaneously supported by compiler -AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O], -[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl -AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], - [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)], - [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no - $rm -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - printf "$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}? :&$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 - if test ! -s out/conftest.err; then - _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes - fi - fi - chmod u+w . - $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 .. - rmdir conftest - $rm conftest* -]) -])# AC_LIBTOOL_PROG_CC_C_O - - -# AC_LIBTOOL_SYS_HARD_LINK_LOCKS([TAGNAME]) -# ----------------------------------------- -# Check to see if we can do hard links to lock some files if needed -AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], -[AC_REQUIRE([_LT_AC_LOCK])dnl - -hard_links="nottested" -if test "$_LT_AC_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 -])# AC_LIBTOOL_SYS_HARD_LINK_LOCKS - - -# AC_LIBTOOL_OBJDIR -# ----------------- -AC_DEFUN([AC_LIBTOOL_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 -])# AC_LIBTOOL_OBJDIR - - -# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH([TAGNAME]) -# ---------------------------------------------- -# Check hardcoding attributes. -AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], -[AC_MSG_CHECKING([how to hardcode library paths into programs]) -_LT_AC_TAGVAR(hardcode_action, $1)= -if test -n "$_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)" || \ - test -n "$_LT_AC_TAGVAR(runpath_var $1)" || \ - test "X$_LT_AC_TAGVAR(hardcode_automatic, $1)"="Xyes" ; then - - # We can hardcode non-existant directories. - if test "$_LT_AC_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_AC_TAGVAR(hardcode_shlibpath_var, $1)" != no && - test "$_LT_AC_TAGVAR(hardcode_minus_L, $1)" != no; then - # Linking always hardcodes the temporary library directory. - _LT_AC_TAGVAR(hardcode_action, $1)=relink - else - # We can link without hardcoding, and we can hardcode nonexisting dirs. - _LT_AC_TAGVAR(hardcode_action, $1)=immediate - fi -else - # We cannot hardcode anything, or else we can only hardcode existing - # directories. - _LT_AC_TAGVAR(hardcode_action, $1)=unsupported -fi -AC_MSG_RESULT([$_LT_AC_TAGVAR(hardcode_action, $1)]) - -if test "$_LT_AC_TAGVAR(hardcode_action, $1)" = relink; 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 -])# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH - - -# AC_LIBTOOL_SYS_LIB_STRIP -# ------------------------ -AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP], -[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" - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) -fi - ;; - *) - AC_MSG_RESULT([no]) - ;; - esac -fi -])# AC_LIBTOOL_SYS_LIB_STRIP - - -# AC_LIBTOOL_SYS_DYNAMIC_LINKER -# ----------------------------- -# PORTME Fill in your ld.so characteristics -AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER], -[AC_MSG_CHECKING([dynamic linker characteristics]) -library_names_spec= -libname_spec='lib$name' -soname_spec= -shrext=".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" -if test "$GCC" = yes; then - 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 ';' >/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. - 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 -else - sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" -fi -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' - ;; - -aix4* | aix5*) - 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*) - 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' - ;; - -beos*) - library_names_spec='${libname}${shared_ext}' - dynamic_linker="$host_os ld.so" - shlibpath_var=LIBRARY_PATH - ;; - -bsdi4*) - 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*) - version_type=windows - shrext=".dll" - need_version=no - need_lib_prefix=no - - case $GCC,$host_os in - yes,cygwin* | yes,mingw* | yes,pw32*) - 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' - 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*) - # 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}${versuffix}$shared_ext ${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='$(test .$module = .yes && echo .so || echo .dylib)' - # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. - if test "$GCC" = yes; then - sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` - else - sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' - fi - 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 - ;; - -kfreebsd*-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 - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='GNU ld.so' - ;; - -freebsd*) - objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` - 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 - ;; - *) # from 3.2 on - shlibpath_overrides_runpath=no - 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='.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='.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='.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' - ;; - -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*) - 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 - # 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 - ld_extra=`$SED -e 's/[:,\t]/ /g;s/=[^=]*$//;s/=[^= ]* / /g' /etc/ld.so.conf` - sys_lib_dlsearch_path_spec="/lib /usr/lib $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' - ;; - -knetbsd*-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 - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='GNU 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=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 - ;; - -openbsd*) - version_type=sunos - need_lib_prefix=no - need_version=yes - 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=".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" - ;; - -sco3.2v5*) - version_type=osf - 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 - ;; - -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.2uw2* | sysv4.3* | sysv5*) - 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 - export_dynamic_flag_spec='${wl}-Blargedynsym' - 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 - ;; - -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 -])# AC_LIBTOOL_SYS_DYNAMIC_LINKER - - -# _LT_AC_TAGCONFIG -# ---------------- -AC_DEFUN([_LT_AC_TAGCONFIG], -[AC_ARG_WITH([tags], - [AC_HELP_STRING([--with-tags@<:@=TAGS@:>@], - [include additional configurations @<:@automatic@:>@])], - [tagnames="$withval"]) - -if test -f "$ltmain" && test -n "$tagnames"; then - if test ! -f "${ofile}"; then - AC_MSG_WARN([output file `$ofile' does not exist]) - fi - - if test -z "$LTCC"; then - eval "`$SHELL ${ofile} --config | grep '^LTCC='`" - if test -z "$LTCC"; then - AC_MSG_WARN([output file `$ofile' does not look like a libtool script]) - else - AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$ofile']) - fi - fi - - # Extract list of available tagged configurations in $ofile. - # Note that this assumes the entire list is on one line. - available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'` - - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for tagname in $tagnames; do - IFS="$lt_save_ifs" - # Check whether tagname contains only valid characters - case `$echo "X$tagname" | $Xsed -e 's:[[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]]::g'` in - "") ;; - *) AC_MSG_ERROR([invalid tag name: $tagname]) - ;; - esac - - if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null - then - AC_MSG_ERROR([tag name \"$tagname\" already exists]) - fi - - # Update the list of available tags. - if test -n "$tagname"; then - echo appending configuration tag \"$tagname\" to $ofile - - case $tagname in - CXX) - if test -n "$CXX" && test "X$CXX" != "Xno"; then - AC_LIBTOOL_LANG_CXX_CONFIG - else - tagname="" - fi - ;; - - F77) - if test -n "$F77" && test "X$F77" != "Xno"; then - AC_LIBTOOL_LANG_F77_CONFIG - else - tagname="" - fi - ;; - - GCJ) - if test -n "$GCJ" && test "X$GCJ" != "Xno"; then - AC_LIBTOOL_LANG_GCJ_CONFIG - else - tagname="" - fi - ;; - - RC) - AC_LIBTOOL_LANG_RC_CONFIG - ;; - - *) - AC_MSG_ERROR([Unsupported tag name: $tagname]) - ;; - esac - - # Append the new tag name to the list of available tags. - if test -n "$tagname" ; then - available_tags="$available_tags $tagname" - fi - fi - done - IFS="$lt_save_ifs" - - # Now substitute the updated list of available tags. - if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then - mv "${ofile}T" "$ofile" - chmod +x "$ofile" - else - rm -f "${ofile}T" - AC_MSG_ERROR([unable to update list of available tagged configurations.]) - fi -fi -])# _LT_AC_TAGCONFIG - - -# AC_LIBTOOL_DLOPEN -# ----------------- -# enable checks for dlopen support -AC_DEFUN([AC_LIBTOOL_DLOPEN], - [AC_BEFORE([$0],[AC_LIBTOOL_SETUP]) -])# AC_LIBTOOL_DLOPEN - - -# AC_LIBTOOL_WIN32_DLL -# -------------------- -# declare package support for building win32 dll's -AC_DEFUN([AC_LIBTOOL_WIN32_DLL], -[AC_BEFORE([$0], [AC_LIBTOOL_SETUP]) -])# AC_LIBTOOL_WIN32_DLL - - -# AC_ENABLE_SHARED([DEFAULT]) -# --------------------------- -# implement the --enable-shared flag -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -AC_DEFUN([AC_ENABLE_SHARED], -[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl -AC_ARG_ENABLE([shared], - [AC_HELP_STRING([--enable-shared@<:@=PKGS@:>@], - [build shared libraries @<:@default=]AC_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=]AC_ENABLE_SHARED_DEFAULT) -])# AC_ENABLE_SHARED - - -# AC_DISABLE_SHARED -# ----------------- -#- set the default shared flag to --disable-shared -AC_DEFUN([AC_DISABLE_SHARED], -[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl -AC_ENABLE_SHARED(no) -])# AC_DISABLE_SHARED - - -# AC_ENABLE_STATIC([DEFAULT]) -# --------------------------- -# implement the --enable-static flag -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -AC_DEFUN([AC_ENABLE_STATIC], -[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl -AC_ARG_ENABLE([static], - [AC_HELP_STRING([--enable-static@<:@=PKGS@:>@], - [build static libraries @<:@default=]AC_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=]AC_ENABLE_STATIC_DEFAULT) -])# AC_ENABLE_STATIC - - -# AC_DISABLE_STATIC -# ----------------- -# set the default static flag to --disable-static -AC_DEFUN([AC_DISABLE_STATIC], -[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl -AC_ENABLE_STATIC(no) -])# AC_DISABLE_STATIC - - -# AC_ENABLE_FAST_INSTALL([DEFAULT]) -# --------------------------------- -# implement the --enable-fast-install flag -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -AC_DEFUN([AC_ENABLE_FAST_INSTALL], -[define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl -AC_ARG_ENABLE([fast-install], - [AC_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], - [optimize for fast installation @<:@default=]AC_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=]AC_ENABLE_FAST_INSTALL_DEFAULT) -])# AC_ENABLE_FAST_INSTALL - - -# AC_DISABLE_FAST_INSTALL -# ----------------------- -# set the default to --disable-fast-install -AC_DEFUN([AC_DISABLE_FAST_INSTALL], -[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl -AC_ENABLE_FAST_INSTALL(no) -])# AC_DISABLE_FAST_INSTALL - - -# AC_LIBTOOL_PICMODE([MODE]) -# -------------------------- -# implement the --with-pic flag -# MODE is either `yes' or `no'. If omitted, it defaults to `both'. -AC_DEFUN([AC_LIBTOOL_PICMODE], -[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl -pic_mode=ifelse($#,1,$1,default) -])# AC_LIBTOOL_PICMODE - - -# AC_PROG_EGREP -# ------------- -# This is predefined starting with Autoconf 2.54, so this conditional -# definition can be removed once we require Autoconf 2.54 or later. -m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP], -[AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep], - [if echo a | (grep -E '(a|b)') >/dev/null 2>&1 - then ac_cv_prog_egrep='grep -E' - else ac_cv_prog_egrep='egrep' - fi]) - EGREP=$ac_cv_prog_egrep - AC_SUBST([EGREP]) -])]) - - -# AC_PATH_TOOL_PREFIX -# ------------------- -# find a file program which can recognise shared library -AC_DEFUN([AC_PATH_TOOL_PREFIX], -[AC_REQUIRE([AC_PROG_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="ifelse([$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 <&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 - -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 -])# AC_PATH_TOOL_PREFIX - - -# AC_PATH_MAGIC -# ------------- -# find a file program which can recognise a shared library -AC_DEFUN([AC_PATH_MAGIC], -[AC_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 - AC_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) - else - MAGIC_CMD=: - fi -fi -])# AC_PATH_MAGIC - - -# AC_PROG_LD -# ---------- -# find the pathname to the GNU or non-GNU linker -AC_DEFUN([AC_PROG_LD], -[AC_ARG_WITH([gnu-ld], - [AC_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]) -AC_REQUIRE([LT_AC_PROG_SED])dnl -AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_CANONICAL_BUILD])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 GNU ld's 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; 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)/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 - ;; - -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*) - lt_cv_deplibs_check_method=pass_all - ;; - -netbsd* | knetbsd*-gnu) - 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=unknown - ;; - -openbsd*) - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB shared object' - else - lt_cv_deplibs_check_method='file_magic OpenBSD.* shared library' - fi - ;; - -osf3* | osf4* | osf5*) - lt_cv_deplibs_check_method=pass_all - ;; - -sco3.2v5*) - lt_cv_deplibs_check_method=pass_all - ;; - -solaris*) - lt_cv_deplibs_check_method=pass_all - ;; - -sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - 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 - ;; - esac - ;; - -sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[[78]]* | unixware7* | sysv4*uw2*) - 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 -])# AC_DEPLIBS_CHECK_METHOD - - -# AC_PROG_NM -# ---------- -# find the pathname to a BSD-compatible name lister -AC_DEFUN([AC_PROG_NM], -[AC_CACHE_CHECK([for BSD-compatible nm], lt_cv_path_NM, -[if test -n "$NM"; then - # Let the user override the test. - lt_cv_path_NM="$NM" -else - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - tmp_nm="$ac_dir/${ac_tool_prefix}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" - test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm -fi]) -NM="$lt_cv_path_NM" -])# AC_PROG_NM - - -# AC_CHECK_LIBM -# ------------- -# check for math library -AC_DEFUN([AC_CHECK_LIBM], -[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_CHECK_LIBM - - -# AC_LIBLTDL_CONVENIENCE([DIRECTORY]) -# ----------------------------------- -# sets LIBLTDL to the link flags for the libltdl convenience library and -# LTDLINCL to the include flags for the libltdl header and adds -# --enable-ltdl-convenience to the configure arguments. Note that LIBLTDL -# and LTDLINCL are not AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If -# DIRECTORY is not provided, it is assumed to be `libltdl'. LIBLTDL will -# be prefixed with '${top_builddir}/' and LTDLINCL will be prefixed with -# '${top_srcdir}/' (note the single quotes!). If your package is not -# flat and you're not using automake, define top_builddir and -# top_srcdir appropriately in the Makefiles. -AC_DEFUN([AC_LIBLTDL_CONVENIENCE], -[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl - case $enable_ltdl_convenience in - no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;; - "") enable_ltdl_convenience=yes - ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; - esac - LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la - LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) - # For backwards non-gettext consistent compatibility... - INCLTDL="$LTDLINCL" -])# AC_LIBLTDL_CONVENIENCE - - -# AC_LIBLTDL_INSTALLABLE([DIRECTORY]) -# ----------------------------------- -# sets LIBLTDL to the link flags for the libltdl installable library and -# LTDLINCL to the include flags for the libltdl header and adds -# --enable-ltdl-install to the configure arguments. Note that LIBLTDL -# and LTDLINCL are not AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If -# DIRECTORY is not provided and an installed libltdl is not found, it is -# assumed to be `libltdl'. LIBLTDL will be prefixed with '${top_builddir}/' -# and LTDLINCL will be prefixed with '${top_srcdir}/' (note the single -# quotes!). If your package is not flat and you're not using automake, -# define top_builddir and top_srcdir appropriately in the Makefiles. -# In the future, this macro may have to be called after AC_PROG_LIBTOOL. -AC_DEFUN([AC_LIBLTDL_INSTALLABLE], -[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl - AC_CHECK_LIB(ltdl, lt_dlinit, - [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no], - [if test x"$enable_ltdl_install" = xno; then - AC_MSG_WARN([libltdl not installed, but installation disabled]) - else - enable_ltdl_install=yes - fi - ]) - if test x"$enable_ltdl_install" = x"yes"; then - ac_configure_args="$ac_configure_args --enable-ltdl-install" - LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la - LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) - else - ac_configure_args="$ac_configure_args --enable-ltdl-install=no" - LIBLTDL="-lltdl" - LTDLINCL= - fi - # For backwards non-gettext consistent compatibility... - INCLTDL="$LTDLINCL" -])# AC_LIBLTDL_INSTALLABLE - - -# AC_LIBTOOL_CXX -# -------------- -# enable support for C++ libraries -AC_DEFUN([AC_LIBTOOL_CXX], -[AC_REQUIRE([_LT_AC_LANG_CXX]) -])# AC_LIBTOOL_CXX - - -# _LT_AC_LANG_CXX -# --------------- -AC_DEFUN([_LT_AC_LANG_CXX], -[AC_REQUIRE([AC_PROG_CXX]) -AC_REQUIRE([AC_PROG_CXXCPP]) -_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}CXX]) -])# _LT_AC_LANG_CXX - - -# AC_LIBTOOL_F77 -# -------------- -# enable support for Fortran 77 libraries -AC_DEFUN([AC_LIBTOOL_F77], -[AC_REQUIRE([_LT_AC_LANG_F77]) -])# AC_LIBTOOL_F77 - - -# _LT_AC_LANG_F77 -# --------------- -AC_DEFUN([_LT_AC_LANG_F77], -[AC_REQUIRE([AC_PROG_F77]) -_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}F77]) -])# _LT_AC_LANG_F77 - - -# AC_LIBTOOL_GCJ -# -------------- -# enable support for GCJ libraries -AC_DEFUN([AC_LIBTOOL_GCJ], -[AC_REQUIRE([_LT_AC_LANG_GCJ]) -])# AC_LIBTOOL_GCJ - - -# _LT_AC_LANG_GCJ -# --------------- -AC_DEFUN([_LT_AC_LANG_GCJ], -[AC_PROVIDE_IFELSE([AC_PROG_GCJ],[], - [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],[], - [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],[], - [ifdef([AC_PROG_GCJ],[AC_REQUIRE([AC_PROG_GCJ])], - [ifdef([A][M_PROG_GCJ],[AC_REQUIRE([A][M_PROG_GCJ])], - [AC_REQUIRE([A][C_PROG_GCJ_OR_A][M_PROG_GCJ])])])])])]) -_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}GCJ]) -])# _LT_AC_LANG_GCJ - - -# AC_LIBTOOL_RC -# -------------- -# enable support for Windows resource files -AC_DEFUN([AC_LIBTOOL_RC], -[AC_REQUIRE([LT_AC_PROG_RC]) -_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}RC]) -])# AC_LIBTOOL_RC - - -# AC_LIBTOOL_LANG_C_CONFIG -# ------------------------ -# Ensure that the configuration vars for the C compiler are -# suitably defined. Those variables are subsequently used by -# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'. -AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG], [_LT_AC_LANG_C_CONFIG]) -AC_DEFUN([_LT_AC_LANG_C_CONFIG], -[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_AC_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="int some_variable = 0;\n" - -# Code to be used in simple link tests -lt_simple_link_test_code='int main(){return(0);}\n' - -_LT_AC_SYS_COMPILER - -# -# Check for any special shared library compilation flags. -# -_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)= -if test "$GCC" = no; then - case $host_os in - sco3.2v5*) - _LT_AC_TAGVAR(lt_prog_cc_shlib, $1)='-belf' - ;; - esac -fi -if test -n "$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)"; then - AC_MSG_WARN([`$CC' requires `$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)' to build shared libraries]) - if echo "$old_CC $old_CFLAGS " | grep "[[ ]]$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)[[ ]]" >/dev/null; then : - else - AC_MSG_WARN([add `$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)' to the CC or CFLAGS env variable and reconfigure]) - _LT_AC_TAGVAR(lt_cv_prog_cc_can_build_shared, $1)=no - fi -fi - - -# -# Check to make sure the static flag actually works. -# -AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $_LT_AC_TAGVAR(lt_prog_compiler_static, $1) works], - _LT_AC_TAGVAR(lt_prog_compiler_static_works, $1), - $_LT_AC_TAGVAR(lt_prog_compiler_static, $1), - [], - [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=]) - - -AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1) -AC_LIBTOOL_PROG_COMPILER_PIC($1) -AC_LIBTOOL_PROG_CC_C_O($1) -AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1) -AC_LIBTOOL_PROG_LD_SHLIBS($1) -AC_LIBTOOL_SYS_DYNAMIC_LINKER($1) -AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1) -AC_LIBTOOL_SYS_LIB_STRIP -AC_LIBTOOL_DLOPEN_SELF($1) - -# Report which librarie types wil 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 - ;; - -aix4*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no - fi - ;; - darwin* | rhapsody*) - if test "$GCC" = yes; then - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no - case "$host_os" in - rhapsody* | darwin1.[[012]]) - _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined suppress' - ;; - *) # Darwin 1.3 on - if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then - _LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress' - else - case ${MACOSX_DEPLOYMENT_TARGET} in - 10.[[012]]) - _LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress' - ;; - 10.*) - _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined dynamic_lookup' - ;; - esac - fi - ;; - esac - output_verbose_link_cmd='echo' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs$compiler_flags -install_name $rpath/$soname $verstring' - _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' - # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs$compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - _LT_AC_TAGVAR(hardcode_direct, $1)=no - _LT_AC_TAGVAR(hardcode_automatic, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-all_load $convenience' - _LT_AC_TAGVAR(link_all_deplibs, $1)=yes - else - _LT_AC_TAGVAR(ld_shlibs, $1)=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]) - -AC_LIBTOOL_CONFIG($1) - -AC_LANG_POP -CC="$lt_save_CC" -])# AC_LIBTOOL_LANG_C_CONFIG - - -# AC_LIBTOOL_LANG_CXX_CONFIG -# -------------------------- -# Ensure that the configuration vars for the C compiler are -# suitably defined. Those variables are subsequently used by -# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'. -AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG], [_LT_AC_LANG_CXX_CONFIG(CXX)]) -AC_DEFUN([_LT_AC_LANG_CXX_CONFIG], -[AC_LANG_PUSH(C++) -AC_REQUIRE([AC_PROG_CXX]) -AC_REQUIRE([AC_PROG_CXXCPP]) - -_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no -_LT_AC_TAGVAR(allow_undefined_flag, $1)= -_LT_AC_TAGVAR(always_export_symbols, $1)=no -_LT_AC_TAGVAR(archive_expsym_cmds, $1)= -_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)= -_LT_AC_TAGVAR(hardcode_direct, $1)=no -_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= -_LT_AC_TAGVAR(hardcode_libdir_separator, $1)= -_LT_AC_TAGVAR(hardcode_minus_L, $1)=no -_LT_AC_TAGVAR(hardcode_automatic, $1)=no -_LT_AC_TAGVAR(module_cmds, $1)= -_LT_AC_TAGVAR(module_expsym_cmds, $1)= -_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown -_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_AC_TAGVAR(no_undefined_flag, $1)= -_LT_AC_TAGVAR(whole_archive_flag_spec, $1)= -_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no - -# Dependencies to place before and after the object being linked: -_LT_AC_TAGVAR(predep_objects, $1)= -_LT_AC_TAGVAR(postdep_objects, $1)= -_LT_AC_TAGVAR(predeps, $1)= -_LT_AC_TAGVAR(postdeps, $1)= -_LT_AC_TAGVAR(compiler_lib_search_path, $1)= - -# Source file extension for C++ test sources. -ac_ext=cc - -# Object file extension for compiled C++ test sources. -objext=o -_LT_AC_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="int some_variable = 0;\n" - -# Code to be used in simple link tests -lt_simple_link_test_code='int main(int, char *[]) { return(0); }\n' - -# ltmain only uses $CC for tagged configurations so make sure $CC is set. -_LT_AC_SYS_COMPILER - -# 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 - 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 - unset lt_cv_path_LD -fi -test -z "${LDCXX+set}" || LD=$LDCXX -CC=${CXX-"c++"} -compiler=$CC -_LT_AC_TAGVAR(compiler, $1)=$CC -cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'` - -# We don't want -fno-exception wen compiling C++ code, so set the -# no_builtin_flag separately -if test "$GXX" = yes; then - _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' -else - _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= -fi - -if test "$GXX" = yes; then - # Set up default GNU C++ configuration - - AC_PROG_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_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_AC_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_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' - _LT_AC_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_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - _LT_AC_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_AC_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_AC_TAGVAR(ld_shlibs, $1)=yes -case $host_os in - aix3*) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - aix4* | aix5*) - 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]].*|aix5*) - 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_AC_TAGVAR(archive_cmds, $1)='' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_AC_TAGVAR(link_all_deplibs, $1)=yes - - 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 - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - else - # We have old collect2 - _LT_AC_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_AC_TAGVAR(hardcode_minus_L, $1)=yes - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= - fi - esac - shared_flag='-shared' - 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 - - # It seems that -bexpall does not export symbols beginning with - # underscore (_), so it is better to generate a list of symbols to export. - _LT_AC_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_AC_TAGVAR(allow_undefined_flag, $1)='-berok' - # Determine the default libpath from the value encoded in an empty executable. - _LT_AC_SYS_LIBPATH_AIX - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - - _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' - _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs" - _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an empty executable. - _LT_AC_SYS_LIBPATH_AIX - _LT_AC_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_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' - _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' - # -bexpall does not export symbols beginning with underscore (_) - _LT_AC_TAGVAR(always_export_symbols, $1)=yes - # Exported symbols can be pulled into shared objects from archives - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=' ' - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes - # This is similar to how AIX traditionally builds it's shared libraries. - _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - chorus*) - case $cc_basename in - *) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - cygwin* | mingw* | pw32*) - # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, - # as there is no search path for DLLs. - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_AC_TAGVAR(always_export_symbols, $1)=no - _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - - if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - _LT_AC_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}--image-base=0x10000000 ${wl}--out-implib,$lib' - else - _LT_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - darwin* | rhapsody*) - if test "$GXX" = yes; then - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no - case "$host_os" in - rhapsody* | darwin1.[[012]]) - _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined suppress' - ;; - *) # Darwin 1.3 on - if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then - _LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress' - else - case ${MACOSX_DEPLOYMENT_TARGET} in - 10.[[012]]) - _LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress' - ;; - 10.*) - _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined dynamic_lookup' - ;; - esac - fi - ;; - esac - lt_int_apple_cc_single_mod=no - output_verbose_link_cmd='echo' - if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then - lt_int_apple_cc_single_mod=yes - fi - if test "X$lt_int_apple_cc_single_mod" = Xyes ; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' - else - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r ${wl}-bind_at_load -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' - fi - _LT_AC_TAGVAR(module_cmds, $1)='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' - - # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's - if test "X$lt_int_apple_cc_single_mod" = Xyes ; then - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - else - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -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~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - fi - _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - _LT_AC_TAGVAR(hardcode_direct, $1)=no - _LT_AC_TAGVAR(hardcode_automatic, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-all_load $convenience' - _LT_AC_TAGVAR(link_all_deplibs, $1)=yes - else - _LT_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - dgux*) - case $cc_basename in - ec++) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - ghcx) - # Green Hills C++ Compiler - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - freebsd[12]*) - # C++ shared libraries reported to be fairly broken before switch to ELF - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - freebsd-elf*) - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no - ;; - freebsd* | kfreebsd*-gnu) - # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF - # conventions - _LT_AC_TAGVAR(ld_shlibs, $1)=yes - ;; - gnu*) - ;; - hpux9*) - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_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_AC_TAGVAR(ld_shlibs, $1)=no - ;; - aCC) - _LT_AC_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 $list' - ;; - *) - if test "$GXX" = yes; then - _LT_AC_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_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - hpux10*|hpux11*) - if test $with_gnu_ld = no; then - case "$host_cpu" in - hppa*64*) - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - ;; - ia64*) - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - ;; - *) - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - ;; - esac - fi - case "$host_cpu" in - hppa*64*) - _LT_AC_TAGVAR(hardcode_direct, $1)=no - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - ia64*) - _LT_AC_TAGVAR(hardcode_direct, $1)=no - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, - # but as the default - # location of the library. - ;; - *) - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_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_AC_TAGVAR(ld_shlibs, $1)=no - ;; - aCC) - case "$host_cpu" in - hppa*64*|ia64*) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs' - ;; - *) - _LT_AC_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 $list' - ;; - *) - if test "$GXX" = yes; then - if test $with_gnu_ld = no; then - case "$host_cpu" in - ia64*|hppa*64*) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs' - ;; - *) - _LT_AC_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_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - irix5* | irix6*) - case $cc_basename in - CC) - # SGI C++ - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${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_AC_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_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' - else - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib' - fi - fi - _LT_AC_TAGVAR(link_all_deplibs, $1)=yes - ;; - esac - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - ;; - linux*) - 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_AC_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_AC_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 $list' - - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath,$libdir' - _LT_AC_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_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' - ;; - icpc) - # Intel C++ - with_gnu_ld=yes - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_AC_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' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' - ;; - cxx) - # Compaq C++ - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_AC_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_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' - _LT_AC_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 $templist | $SED "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 $list' - ;; - esac - ;; - lynxos*) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - m88k*) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - mvs*) - case $cc_basename in - cxx) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - netbsd* | knetbsd*-gnu) - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' - wlarc= - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_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::"' - ;; - osf3*) - 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_AC_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_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - - # Archives containing C++ object files must be created using - # "CC -Bstatic", where "CC" is the KAI C++ compiler. - _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' - - ;; - RCC) - # Rational C++ 2.4.1 - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - cxx) - _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' - - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_AC_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 $templist | $SED "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 $list' - ;; - *) - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_AC_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 ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' - - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_AC_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_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - 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_AC_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_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - - # Archives containing C++ object files must be created using - # the KAI C++ compiler. - _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' - ;; - RCC) - # Rational C++ 2.4.1 - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - cxx) - _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' - _LT_AC_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 -set_version $verstring` -update_registry $objdir/so_locations -o $lib~ - $rm $lib.exp' - - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' - _LT_AC_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 $templist | $SED "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 $list' - ;; - *) - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_AC_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` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' - - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_AC_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_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - psos*) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - sco*) - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no - case $cc_basename in - CC) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - sunos4*) - case $cc_basename in - CC) - # Sun C++ 4.x - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - lcc) - # Lucid - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - solaris*) - case $cc_basename in - CC) - # Sun C++ 4.2, 5.x and Centerline C++ - _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -nolib -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - _LT_AC_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} -nolib ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' - - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - case $host_os in - solaris2.[0-5] | solaris2.[0-5].*) ;; - *) - # The C++ compiler is used as linker so we must use $wl - # flag to pass the commands to the underlying system - # linker. - # Supported since Solaris 2.6 (maybe 2.5.1?) - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' - ;; - esac - _LT_AC_TAGVAR(link_all_deplibs, $1)=yes - - # 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 -G $CFLAGS -v conftest.$objext 2>&1 | grep "\-[[LR]]"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' - - # 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_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' - ;; - gcx) - # Green Hills C++ Compiler - _LT_AC_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_AC_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_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' - if $CC --version | grep -v '^2\.7' > /dev/null; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - _LT_AC_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_AC_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - _LT_AC_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_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' - fi - ;; - esac - ;; - sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[[78]]* | unixware7*) - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no - ;; - tandem*) - case $cc_basename in - NCC) - # NonStop-UX NCC 3.20 - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - vxworks*) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; -esac -AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)]) -test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no - -_LT_AC_TAGVAR(GCC, $1)="$GXX" -_LT_AC_TAGVAR(LD, $1)="$LD" - -AC_LIBTOOL_POSTDEP_PREDEP($1) -AC_LIBTOOL_PROG_COMPILER_PIC($1) -AC_LIBTOOL_PROG_CC_C_O($1) -AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1) -AC_LIBTOOL_PROG_LD_SHLIBS($1) -AC_LIBTOOL_SYS_DYNAMIC_LINKER($1) -AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1) -AC_LIBTOOL_SYS_LIB_STRIP -AC_LIBTOOL_DLOPEN_SELF($1) - -AC_LIBTOOL_CONFIG($1) - -AC_LANG_POP -CC=$lt_save_CC -LDCXX=$LD -LD=$lt_save_LD -GCC=$lt_save_GCC -with_gnu_ldcxx=$with_gnu_ld -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 -])# AC_LIBTOOL_LANG_CXX_CONFIG - -# AC_LIBTOOL_POSTDEP_PREDEP([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. -AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP],[ -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... -ifelse([$1],[],[cat > conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext <> "$cfgfile" -ifelse([$1], [], -[#! $SHELL - -# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services. -# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) -# NOTE: Changes made to this file will be lost: look at ltmain.sh. -# -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 -# Free Software Foundation, Inc. -# -# This file is part of GNU Libtool: -# Originally by Gordon Matzigkeit , 1996 -# -# 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. -# -# 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. - -# A sed program that does not truncate output. -SED=$lt_SED - -# Sed that helps us avoid accidentally triggering echo(1) options like -n. -Xsed="$SED -e s/^X//" - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi - -# The names of the tagged configurations supported by this script. -available_tags= - -# ### BEGIN LIBTOOL CONFIG], -[# ### BEGIN LIBTOOL TAG CONFIG: $tagname]) - -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: - -# Shell to use when invoking shell scripts. -SHELL=$lt_SHELL - -# Whether or not to build shared libraries. -build_libtool_libs=$enable_shared - -# Whether or not to build static libraries. -build_old_libs=$enable_static - -# Whether or not to add -lc for building shared libraries. -build_libtool_need_lc=$_LT_AC_TAGVAR(archive_cmds_need_lc, $1) - -# Whether or not to disallow shared libs when runtime libs are static -allow_libtool_libs_with_static_runtimes=$_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1) - -# Whether or not to optimize for fast installation. -fast_install=$enable_fast_install - -# The host system. -host_alias=$host_alias -host=$host - -# An echo program that does not interpret backslashes. -echo=$lt_echo - -# The archiver. -AR=$lt_AR -AR_FLAGS=$lt_AR_FLAGS - -# A C compiler. -LTCC=$lt_LTCC - -# A language-specific compiler. -CC=$lt_[]_LT_AC_TAGVAR(compiler, $1) - -# Is the compiler the GNU C compiler? -with_gcc=$_LT_AC_TAGVAR(GCC, $1) - -# An ERE matcher. -EGREP=$lt_EGREP - -# The linker used to build libraries. -LD=$lt_[]_LT_AC_TAGVAR(LD, $1) - -# Whether we need hard or soft links. -LN_S=$lt_LN_S - -# A BSD-compatible nm program. -NM=$lt_NM - -# A symbol stripping program -STRIP=$lt_STRIP - -# Used to examine libraries when file_magic_cmd begins "file" -MAGIC_CMD=$MAGIC_CMD - -# Used on cygwin: DLL creation program. -DLLTOOL="$DLLTOOL" - -# Used on cygwin: object dumper. -OBJDUMP="$OBJDUMP" - -# Used on cygwin: assembler. -AS="$AS" - -# The name of the directory that contains temporary libtool files. -objdir=$objdir - -# How to create reloadable object files. -reload_flag=$lt_reload_flag -reload_cmds=$lt_reload_cmds - -# How to pass a linker flag through the compiler. -wl=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) - -# Object file suffix (normally "o"). -objext="$ac_objext" - -# Old archive suffix (normally "a"). -libext="$libext" - -# Shared library suffix (normally ".so"). -shrext='$shrext' - -# Executable file suffix (normally ""). -exeext="$exeext" - -# Additional compiler flags for building library objects. -pic_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) -pic_mode=$pic_mode - -# What is the maximum length of a command? -max_cmd_len=$lt_cv_sys_max_cmd_len - -# Does compiler simultaneously support -c and -o options? -compiler_c_o=$lt_[]_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1) - -# Must we lock files when doing compilation ? -need_locks=$lt_need_locks - -# Do we need the lib prefix for modules? -need_lib_prefix=$need_lib_prefix - -# Do we need a version for libraries? -need_version=$need_version - -# Whether dlopen is supported. -dlopen_support=$enable_dlopen - -# Whether dlopen of programs is supported. -dlopen_self=$enable_dlopen_self - -# Whether dlopen of statically linked programs is supported. -dlopen_self_static=$enable_dlopen_self_static - -# Compiler flag to prevent dynamic linking. -link_static_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_static, $1) - -# Compiler flag to turn off builtin functions. -no_builtin_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) - -# Compiler flag to allow reflexive dlopens. -export_dynamic_flag_spec=$lt_[]_LT_AC_TAGVAR(export_dynamic_flag_spec, $1) - -# Compiler flag to generate shared objects directly from archives. -whole_archive_flag_spec=$lt_[]_LT_AC_TAGVAR(whole_archive_flag_spec, $1) - -# Compiler flag to generate thread-safe objects. -thread_safe_flag_spec=$lt_[]_LT_AC_TAGVAR(thread_safe_flag_spec, $1) - -# Library versioning type. -version_type=$version_type - -# Format of library name prefix. -libname_spec=$lt_libname_spec - -# 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. -library_names_spec=$lt_library_names_spec - -# The coded name of the library, if different from the real name. -soname_spec=$lt_soname_spec - -# Commands used to build and install an old-style archive. -RANLIB=$lt_RANLIB -old_archive_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_cmds, $1) -old_postinstall_cmds=$lt_old_postinstall_cmds -old_postuninstall_cmds=$lt_old_postuninstall_cmds - -# Create an old-style archive from a shared archive. -old_archive_from_new_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_new_cmds, $1) - -# Create a temporary old-style archive to link instead of a shared archive. -old_archive_from_expsyms_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) - -# Commands used to build and install a shared archive. -archive_cmds=$lt_[]_LT_AC_TAGVAR(archive_cmds, $1) -archive_expsym_cmds=$lt_[]_LT_AC_TAGVAR(archive_expsym_cmds, $1) -postinstall_cmds=$lt_postinstall_cmds -postuninstall_cmds=$lt_postuninstall_cmds - -# Commands used to build a loadable module (assumed same as above if empty) -module_cmds=$lt_[]_LT_AC_TAGVAR(module_cmds, $1) -module_expsym_cmds=$lt_[]_LT_AC_TAGVAR(module_expsym_cmds, $1) - -# Commands to strip libraries. -old_striplib=$lt_old_striplib -striplib=$lt_striplib - -# Dependencies to place before the objects being linked to create a -# shared library. -predep_objects=$lt_[]_LT_AC_TAGVAR(predep_objects, $1) - -# Dependencies to place after the objects being linked to create a -# shared library. -postdep_objects=$lt_[]_LT_AC_TAGVAR(postdep_objects, $1) - -# Dependencies to place before the objects being linked to create a -# shared library. -predeps=$lt_[]_LT_AC_TAGVAR(predeps, $1) - -# Dependencies to place after the objects being linked to create a -# shared library. -postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1) - -# The library search path used internally by the compiler when linking -# a shared library. -compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1) - -# 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. -file_magic_cmd=$lt_file_magic_cmd - -# Flag that allows shared libraries with undefined symbols to be built. -allow_undefined_flag=$lt_[]_LT_AC_TAGVAR(allow_undefined_flag, $1) - -# Flag that forces no undefined symbols. -no_undefined_flag=$lt_[]_LT_AC_TAGVAR(no_undefined_flag, $1) - -# Commands used to finish a libtool library installation in a directory. -finish_cmds=$lt_finish_cmds - -# Same as above, but a single script fragment to be evaled but not shown. -finish_eval=$lt_finish_eval - -# Take the output of nm and produce a listing of raw symbols and C names. -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 in a C name address pair -global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address - -# This is the shared library runtime path variable. -runpath_var=$runpath_var - -# This is the shared library path variable. -shlibpath_var=$shlibpath_var - -# Is shlibpath searched before the hard-coded library search path? -shlibpath_overrides_runpath=$shlibpath_overrides_runpath - -# How to hardcode a shared library path into an executable. -hardcode_action=$_LT_AC_TAGVAR(hardcode_action, $1) - -# Whether we should hardcode library paths into libraries. -hardcode_into_libs=$hardcode_into_libs - -# Flag to hardcode \$libdir into a binary during linking. -# This must work even if \$libdir does not exist. -hardcode_libdir_flag_spec=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $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. -hardcode_libdir_flag_spec_ld=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1) - -# Whether we need a single -rpath flag with a separated argument. -hardcode_libdir_separator=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_separator, $1) - -# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the -# resulting binary. -hardcode_direct=$_LT_AC_TAGVAR(hardcode_direct, $1) - -# Set to yes if using the -LDIR flag during linking hardcodes DIR into the -# resulting binary. -hardcode_minus_L=$_LT_AC_TAGVAR(hardcode_minus_L, $1) - -# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into -# the resulting binary. -hardcode_shlibpath_var=$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1) - -# Set to yes if building a shared library automatically hardcodes DIR into the library -# and all subsequent libraries and executables linked against it. -hardcode_automatic=$_LT_AC_TAGVAR(hardcode_automatic, $1) - -# Variables whose values should be saved in libtool wrapper scripts and -# restored at relink time. -variables_saved_for_relink="$variables_saved_for_relink" - -# Whether libtool must link a program against all its dependency libraries. -link_all_deplibs=$_LT_AC_TAGVAR(link_all_deplibs, $1) - -# 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 - -# Fix the shell variable \$srcfile for the compiler. -fix_srcfile_path="$_LT_AC_TAGVAR(fix_srcfile_path, $1)" - -# Set to yes if exported symbols are required. -always_export_symbols=$_LT_AC_TAGVAR(always_export_symbols, $1) - -# The commands to list exported symbols. -export_symbols_cmds=$lt_[]_LT_AC_TAGVAR(export_symbols_cmds, $1) - -# The commands to extract the exported symbol list from a shared archive. -extract_expsyms_cmds=$lt_extract_expsyms_cmds - -# Symbols that should not be listed in the preloaded symbols. -exclude_expsyms=$lt_[]_LT_AC_TAGVAR(exclude_expsyms, $1) - -# Symbols that must always be exported. -include_expsyms=$lt_[]_LT_AC_TAGVAR(include_expsyms, $1) - -ifelse([$1],[], -[# ### END LIBTOOL CONFIG], -[# ### END LIBTOOL TAG CONFIG: $tagname]) - -__EOF__ - -ifelse([$1],[], [ - case $host_os in - aix3*) - cat <<\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 -EOF - ;; - esac - - # 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 '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1) - - mv -f "$cfgfile" "$ofile" || \ - (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") - chmod +x "$ofile" -]) -else - # If there is no Makefile yet, we rely on a make rule to execute - # `config.status --recheck' to rerun these tests and create the - # libtool script then. - ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` - if test -f "$ltmain_in"; then - test -f Makefile && make "$ltmain" - fi -fi -])# AC_LIBTOOL_CONFIG - - -# AC_LIBTOOL_PROG_COMPILER_NO_RTTI([TAGNAME]) -# ------------------------------------------- -AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], -[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl - -_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= - -if test "$GCC" = yes; then - _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' - - AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], - lt_cv_prog_compiler_rtti_exceptions, - [-fno-rtti -fno-exceptions], [], - [_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) -fi -])# AC_LIBTOOL_PROG_COMPILER_NO_RTTI - - -# AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE -# --------------------------------- -AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], -[AC_REQUIRE([AC_CANONICAL_HOST]) -AC_REQUIRE([AC_PROG_NM]) -AC_REQUIRE([AC_OBJEXT]) -# 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]]*\)' - -# Transform the above into a raw symbol and a C symbol. -symxfrm='\1 \2\3 \3' - -# Transform an extracted symbol line into a proper C declaration -lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \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\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" - -# Define system-specific variables. -case $host_os in -aix*) - symcode='[[BCDT]]' - ;; -cygwin* | mingw* | pw32*) - symcode='[[ABCDGISTW]]' - ;; -hpux*) # Its linker distinguishes data from code symbols - if test "$host_cpu" = ia64; then - symcode='[[ABCDEGRST]]' - fi - 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_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" - ;; -irix* | nonstopux*) - symcode='[[BCDEGRST]]' - ;; -osf*) - symcode='[[BCDEGQRST]]' - ;; -solaris* | sysv5*) - symcode='[[BDRT]]' - ;; -sysv4) - symcode='[[DFNSTU]]' - ;; -esac - -# 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 - -# If we're using GNU nm, then use its standard symbol codes. -case `$NM -V 2>&1` in -*GNU* | *'with BFD'*) - symcode='[[ABCDGIRSTW]]' ;; -esac - -# Try without a prefix undercore, then with it. -for ac_symprfx in "" "_"; do - - # Write the raw and C identifiers. - lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*\($ac_symprfx\)$sympat$opt_cr$/$symxfrm/p'" - - # Check to see that the pipe works correctly. - pipe_works=no - - rm -f conftest* - cat > conftest.$ac_ext < $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 < conftest.$ac_ext -#ifdef __cplusplus -extern "C" { -#endif - -EOF - # Now generate the symbol file. - eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext' - - cat <> conftest.$ac_ext -#if defined (__STDC__) && __STDC__ -# define lt_ptr_t void * -#else -# define lt_ptr_t char * -# define const -#endif - -/* The mapping between symbol names and symbols. */ -const struct { - const char *name; - lt_ptr_t address; -} -lt_preloaded_symbols[[]] = -{ -EOF - $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext - cat <<\EOF >> conftest.$ac_ext - {0, (lt_ptr_t) 0} -}; - -#ifdef __cplusplus -} -#endif -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_AC_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 -f 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 -]) # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE - - -# AC_LIBTOOL_PROG_COMPILER_PIC([TAGNAME]) -# --------------------------------------- -AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC], -[_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)= -_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= -_LT_AC_TAGVAR(lt_prog_compiler_static, $1)= - -AC_MSG_CHECKING([for $compiler option to produce PIC]) - ifelse([$1],[CXX],[ - # C++ specific cases for pic, static, wl, etc. - if test "$GXX" = yes; then - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_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_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - fi - ;; - amigaos*) - # 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_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' - ;; - beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - mingw* | os2* | pw32*) - # 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_AC_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_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' - ;; - *djgpp*) - # DJGPP does not support shared libraries at all - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= - ;; - sysv4*MP*) - if test -d /usr/nec; then - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic - fi - ;; - hpux*) - # 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*) - ;; - *) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - ;; - *) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - else - case $host_os in - aix4* | aix5*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - else - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' - fi - ;; - chorus*) - case $cc_basename in - cxch68) - # Green Hills C++ Compiler - # _LT_AC_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_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - ;; - ghcx) - # Green Hills C++ Compiler - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - ;; - *) - ;; - esac - ;; - freebsd* | kfreebsd*-gnu) - # FreeBSD uses GNU C++ - ;; - hpux9* | hpux10* | hpux11*) - case $cc_basename in - CC) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive" - if test "$host_cpu" != ia64; then - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' - fi - ;; - aCC) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive" - case "$host_cpu" in - hppa*64*|ia64*) - # +Z the default - ;; - *) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' - ;; - esac - ;; - *) - ;; - esac - ;; - irix5* | irix6* | nonstopux*) - case $cc_basename in - CC) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - # CC pic flag -KPIC is the default. - ;; - *) - ;; - esac - ;; - linux*) - case $cc_basename in - KCC) - # KAI C++ Compiler - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - icpc) - # Intel C++ - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - cxx) - # Compaq C++ - # Make sure the PIC flag is empty. It appears that all Alpha - # Linux and Compaq Tru64 Unix objects are PIC. - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - *) - ;; - esac - ;; - lynxos*) - ;; - m88k*) - ;; - mvs*) - case $cc_basename in - cxx) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' - ;; - *) - ;; - esac - ;; - netbsd* | knetbsd*-gnu) - ;; - osf3* | osf4* | osf5*) - case $cc_basename in - KCC) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' - ;; - RCC) - # Rational C++ 2.4.1 - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - ;; - cxx) - # Digital/Compaq C++ - _LT_AC_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_AC_TAGVAR(lt_prog_compiler_pic, $1)= - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - *) - ;; - esac - ;; - psos*) - ;; - sco*) - case $cc_basename in - CC) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - *) - ;; - esac - ;; - solaris*) - case $cc_basename in - CC) - # Sun C++ 4.2, 5.x and Centerline C++ - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' - ;; - gcx) - # Green Hills C++ Compiler - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' - ;; - *) - ;; - esac - ;; - sunos4*) - case $cc_basename in - CC) - # Sun C++ 4.x - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - lcc) - # Lucid - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - ;; - *) - ;; - esac - ;; - tandem*) - case $cc_basename in - NCC) - # NonStop-UX NCC 3.20 - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - ;; - *) - ;; - esac - ;; - unixware*) - ;; - vxworks*) - ;; - *) - _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - ;; - esac - fi -], -[ - if test "$GCC" = yes; then - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_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_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - fi - ;; - - amigaos*) - # 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_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' - ;; - - beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - - mingw* | pw32* | os2*) - # 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_AC_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_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' - ;; - - msdosdjgpp*) - # Just because we use GCC doesn't mean we suddenly get shared libraries - # on systems that don't support them. - _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - enable_shared=no - ;; - - sysv4*MP*) - if test -d /usr/nec; then - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic - fi - ;; - - hpux*) - # 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_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - ;; - - *) - _LT_AC_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_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - else - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' - fi - ;; - - mingw* | pw32* | os2*) - # 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_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT' - ;; - - hpux9* | hpux10* | hpux11*) - _LT_AC_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_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' - ;; - esac - # Is there a better lt_prog_compiler_static that works with the bundled CC? - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' - ;; - - irix5* | irix6* | nonstopux*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # PIC (with -KPIC) is the default. - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - - newsos6) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - linux*) - case $CC in - icc* | ecc*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - ccc*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # All Alpha code is PIC. - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - esac - ;; - - osf3* | osf4* | osf5*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # All OSF/1 code is PIC. - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - - sco3.2v5*) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kpic' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-dn' - ;; - - solaris*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - sunos4*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - sysv4*MP*) - if test -d /usr/nec ;then - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - fi - ;; - - uts4*) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - *) - _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - ;; - esac - fi -]) -AC_MSG_RESULT([$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)]) - -# -# Check to make sure the PIC flag actually works. -# -if test -n "$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)"; then - AC_LIBTOOL_COMPILER_OPTION([if $compiler PIC flag $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) works], - _LT_AC_TAGVAR(lt_prog_compiler_pic_works, $1), - [$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])], [], - [case $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) in - "" | " "*) ;; - *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)" ;; - esac], - [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= - _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) -fi -case "$host_os" in - # For platforms which do not support PIC, -DPIC is meaningless: - *djgpp*) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= - ;; - *) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])" - ;; -esac -]) - - -# AC_LIBTOOL_PROG_LD_SHLIBS([TAGNAME]) -# ------------------------------------ -# See if the linker supports building shared libraries. -AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS], -[AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) -ifelse([$1],[CXX],[ - _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - case $host_os in - aix4* | aix5*) - # 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_AC_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_AC_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_AC_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" - ;; - cygwin* | mingw*) - _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols' - ;; - *) - _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - ;; - esac -],[ - runpath_var= - _LT_AC_TAGVAR(allow_undefined_flag, $1)= - _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no - _LT_AC_TAGVAR(archive_cmds, $1)= - _LT_AC_TAGVAR(archive_expsym_cmds, $1)= - _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)= - _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)= - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)= - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= - _LT_AC_TAGVAR(thread_safe_flag_spec, $1)= - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= - _LT_AC_TAGVAR(hardcode_direct, $1)=no - _LT_AC_TAGVAR(hardcode_minus_L, $1)=no - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported - _LT_AC_TAGVAR(link_all_deplibs, $1)=unknown - _LT_AC_TAGVAR(hardcode_automatic, $1)=no - _LT_AC_TAGVAR(module_cmds, $1)= - _LT_AC_TAGVAR(module_expsym_cmds, $1)= - _LT_AC_TAGVAR(always_export_symbols, $1)=no - _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - # include_expsyms should be a list of space-separated symbols to be *always* - # included in the symbol list - _LT_AC_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_AC_TAGVAR(exclude_expsyms, $1)="_GLOBAL_OFFSET_TABLE_" - # 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. - extract_expsyms_cmds= - - case $host_os in - cygwin* | mingw* | pw32*) - # 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 - ;; - openbsd*) - with_gnu_ld=no - ;; - esac - - _LT_AC_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}' - - # See if GNU ld supports shared libraries. - case $host_os in - aix3* | aix4* | aix5*) - # On AIX/PPC, the GNU linker is very broken - if test "$host_cpu" != ia64; then - _LT_AC_TAGVAR(ld_shlibs, $1)=no - cat <&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. - -EOF - fi - ;; - - amigaos*) - _LT_AC_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_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes - - # Samuel A. Falvo II reports - # that the semantics of dynamic libraries on AmigaOS, at least up - # to version 4, is to share data among multiple programs linked - # with the same dynamic library. Since this doesn't match the - # behavior of shared libraries on other platforms, we can't use - # them. - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - - beos*) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - _LT_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - cygwin* | mingw* | pw32*) - # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, - # as there is no search path for DLLs. - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_AC_TAGVAR(always_export_symbols, $1)=no - _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols' - - if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - _LT_AC_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}--image-base=0x10000000 ${wl}--out-implib,$lib' - else - ld_shlibs=no - fi - ;; - - netbsd* | knetbsd*-gnu) - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' - wlarc= - else - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_AC_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* | sysv5*) - if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then - _LT_AC_TAGVAR(ld_shlibs, $1)=no - cat <&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. - -EOF - elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_AC_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_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - sunos4*) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' - wlarc= - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - linux*) - if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then - tmp_archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_AC_TAGVAR(archive_cmds, $1)="$tmp_archive_cmds" - supports_anon_versioning=no - case `$LD -v 2>/dev/null` 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 - if test $supports_anon_versioning = yes; then - _LT_AC_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 -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' - else - _LT_AC_TAGVAR(archive_expsym_cmds, $1)="$tmp_archive_cmds" - fi - else - _LT_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - *) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_AC_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_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - - if test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = yes; then - runpath_var=LD_RUN_PATH - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' - _LT_AC_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_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= - fi - fi - else - # PORTME fill in a description of your system's linker (not GNU ld) - case $host_os in - aix3*) - _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_AC_TAGVAR(always_export_symbols, $1)=yes - _LT_AC_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_AC_TAGVAR(hardcode_minus_L, $1)=yes - if test "$GCC" = yes && test -z "$link_static_flag"; then - # Neither direct hardcoding nor static linking is supported with a - # broken collect2. - _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported - fi - ;; - - aix4* | aix5*) - 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_AC_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_AC_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]].*|aix5*) - 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_AC_TAGVAR(archive_cmds, $1)='' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_AC_TAGVAR(link_all_deplibs, $1)=yes - - 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 - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - else - # We have old collect2 - _LT_AC_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_AC_TAGVAR(hardcode_minus_L, $1)=yes - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= - fi - esac - shared_flag='-shared' - 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 - - # It seems that -bexpall does not export symbols beginning with - # underscore (_), so it is better to generate a list of symbols to export. - _LT_AC_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_AC_TAGVAR(allow_undefined_flag, $1)='-berok' - # Determine the default libpath from the value encoded in an empty executable. - _LT_AC_SYS_LIBPATH_AIX - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' - _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs" - _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an empty executable. - _LT_AC_SYS_LIBPATH_AIX - _LT_AC_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_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' - _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' - # -bexpall does not export symbols beginning with underscore (_) - _LT_AC_TAGVAR(always_export_symbols, $1)=yes - # Exported symbols can be pulled into shared objects from archives - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=' ' - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes - # This is similar to how AIX traditionally builds it's shared libraries. - _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - - amigaos*) - _LT_AC_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_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes - # see comment about different semantics on the GNU ld section - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - - bsdi4*) - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic - ;; - - cygwin* | mingw* | pw32*) - # 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_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' - _LT_AC_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=".dll" - # FIXME: Setting linknames here is a bad hack. - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' - # The linker will automatically build a .lib file if we build a DLL. - _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='true' - # FIXME: Should let the user specify the lib program. - _LT_AC_TAGVAR(old_archive_cmds, $1)='lib /OUT:$oldlib$oldobjs$old_deplibs' - fix_srcfile_path='`cygpath -w "$srcfile"`' - _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - ;; - - darwin* | rhapsody*) - if test "$GXX" = yes ; then - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no - case "$host_os" in - rhapsody* | darwin1.[[012]]) - _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined suppress' - ;; - *) # Darwin 1.3 on - if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then - _LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress' - else - case ${MACOSX_DEPLOYMENT_TARGET} in - 10.[[012]]) - _LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress' - ;; - 10.*) - _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined dynamic_lookup' - ;; - esac - fi - ;; - esac - lt_int_apple_cc_single_mod=no - output_verbose_link_cmd='echo' - if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then - lt_int_apple_cc_single_mod=yes - fi - if test "X$lt_int_apple_cc_single_mod" = Xyes ; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' - else - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r ${wl}-bind_at_load -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' - fi - _LT_AC_TAGVAR(module_cmds, $1)='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' - # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's - if test "X$lt_int_apple_cc_single_mod" = Xyes ; then - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - else - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -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~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - fi - _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - _LT_AC_TAGVAR(hardcode_direct, $1)=no - _LT_AC_TAGVAR(hardcode_automatic, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-all_load $convenience' - _LT_AC_TAGVAR(link_all_deplibs, $1)=yes - else - _LT_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - dgux*) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - freebsd1*) - _LT_AC_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_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2*) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - # FreeBSD 3 and greater uses gcc -shared to do shared libraries. - freebsd* | kfreebsd*-gnu) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - hpux9*) - if test "$GCC" = yes; then - _LT_AC_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_AC_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_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - ;; - - hpux10* | hpux11*) - if test "$GCC" = yes -a "$with_gnu_ld" = no; then - case "$host_cpu" in - hppa*64*|ia64*) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_AC_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*|ia64*) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags' - ;; - *) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' - ;; - esac - fi - if test "$with_gnu_ld" = no; then - case "$host_cpu" in - hppa*64*) - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_AC_TAGVAR(hardcode_direct, $1)=no - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - ia64*) - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(hardcode_direct, $1)=no - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes - ;; - *) - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_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_AC_TAGVAR(hardcode_minus_L, $1)=yes - ;; - esac - fi - ;; - - irix5* | irix6* | nonstopux*) - if test "$GCC" = yes; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' - fi - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_AC_TAGVAR(link_all_deplibs, $1)=yes - ;; - - netbsd* | knetbsd*-gnu) - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out - else - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF - fi - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - newsos6) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - openbsd*) - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - else - case $host_os in - openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - ;; - *) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - ;; - esac - fi - ;; - - os2*) - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes - _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_AC_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_AC_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' - ;; - - osf3*) - if test "$GCC" = yes; then - _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - fi - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - ;; - - osf4* | osf5*) # as osf3* with the addition of -msym flag - if test "$GCC" = yes; then - _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - else - _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_AC_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~ - $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp' - - # Both c and cxx compiler support -rpath directly - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' - fi - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - ;; - - sco3.2v5*) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' - runpath_var=LD_RUN_PATH - hardcode_runpath_var=yes - ;; - - solaris*) - _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text' - if test "$GCC" = yes; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_AC_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}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' - else - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_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' - fi - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - case $host_os in - solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; - *) # Supported since Solaris 2.6 (maybe 2.5.1?) - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;; - esac - _LT_AC_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_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' - fi - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - sysv4) - case $host_vendor in - sni) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes # is this really true??? - ;; - siemens) - ## LD is ld it makes a PLAMLIB - ## CC just makes a GrossModule. - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' - _LT_AC_TAGVAR(hardcode_direct, $1)=no - ;; - motorola) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie - ;; - esac - runpath_var='LD_RUN_PATH' - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - sysv4.3*) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - runpath_var=LD_RUN_PATH - hardcode_runpath_var=yes - _LT_AC_TAGVAR(ld_shlibs, $1)=yes - fi - ;; - - sysv4.2uw2*) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_minus_L, $1)=no - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - hardcode_runpath_var=yes - runpath_var=LD_RUN_PATH - ;; - - sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[[78]]* | unixware7*) - _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z ${wl}text' - if test "$GCC" = yes; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - runpath_var='LD_RUN_PATH' - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - sysv5*) - _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text' - # $CC -shared without GNU ld will not create a library from C++ - # object files and a static libstdc++, better avoid it by now - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_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' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - runpath_var='LD_RUN_PATH' - ;; - - uts4*) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - *) - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - esac - fi -]) -AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)]) -test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = 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 - -# -# Do we need to explicitly link libc? -# -case "x$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)" in -x|xyes) - # Assume -lc should be added - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes - - if test "$enable_shared" = yes && test "$GCC" = yes; then - case $_LT_AC_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* - printf "$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_AC_TAGVAR(lt_prog_compiler_wl, $1) - compiler_flags=-v - linker_flags=-v - verstring= - output_objdir=. - libname=conftest - lt_save_allow_undefined_flag=$_LT_AC_TAGVAR(allow_undefined_flag, $1) - _LT_AC_TAGVAR(allow_undefined_flag, $1)= - if AC_TRY_EVAL(_LT_AC_TAGVAR(archive_cmds, $1) 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) - then - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no - else - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes - fi - _LT_AC_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag - else - cat conftest.err 1>&5 - fi - $rm conftest* - AC_MSG_RESULT([$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)]) - ;; - esac - fi - ;; -esac -])# AC_LIBTOOL_PROG_LD_SHLIBS - - -# _LT_AC_FILE_LTDLL_C -# ------------------- -# Be careful that the start marker always follows a newline. -AC_DEFUN([_LT_AC_FILE_LTDLL_C], [ -# /* ltdll.c starts here */ -# #define WIN32_LEAN_AND_MEAN -# #include -# #undef WIN32_LEAN_AND_MEAN -# #include -# -# #ifndef __CYGWIN__ -# # ifdef __CYGWIN32__ -# # define __CYGWIN__ __CYGWIN32__ -# # endif -# #endif -# -# #ifdef __cplusplus -# extern "C" { -# #endif -# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved); -# #ifdef __cplusplus -# } -# #endif -# -# #ifdef __CYGWIN__ -# #include -# DECLARE_CYGWIN_DLL( DllMain ); -# #endif -# HINSTANCE __hDllInstance_base; -# -# BOOL APIENTRY -# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved) -# { -# __hDllInstance_base = hInst; -# return TRUE; -# } -# /* ltdll.c ends here */ -])# _LT_AC_FILE_LTDLL_C - - -# _LT_AC_TAGVAR(VARNAME, [TAGNAME]) -# --------------------------------- -AC_DEFUN([_LT_AC_TAGVAR], [ifelse([$2], [], [$1], [$1_$2])]) - - -# old names -AC_DEFUN([AM_PROG_LIBTOOL], [AC_PROG_LIBTOOL]) -AC_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) -AC_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) -AC_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) -AC_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) -AC_DEFUN([AM_PROG_LD], [AC_PROG_LD]) -AC_DEFUN([AM_PROG_NM], [AC_PROG_NM]) - -# This is just to silence aclocal about the macro not being used -ifelse([AC_DISABLE_FAST_INSTALL]) - -AC_DEFUN([LT_AC_PROG_GCJ], -[AC_CHECK_TOOL(GCJ, gcj, no) - test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" - AC_SUBST(GCJFLAGS) -]) - -AC_DEFUN([LT_AC_PROG_RC], -[AC_CHECK_TOOL(RC, windres, no) -]) - -# 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. # -# LT_AC_PROG_SED -# -------------- -# Check for a fully-functional sed program, that truncates -# as few characters as possible. Prefer GNU sed if found. -AC_DEFUN([LT_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 -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 && break - 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_MSG_RESULT([$SED]) -]) - -# -*- Autoconf -*- -# Copyright (C) 2002, 2003 Free Software Foundation, Inc. -# Generated from amversion.in; do not edit by hand. - -# 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, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - -# AM_AUTOMAKE_VERSION(VERSION) -# ---------------------------- -# Automake X.Y traces this macro to ensure aclocal.m4 has been -# generated from the m4 files accompanying Automake X.Y. -AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.8"]) - -# AM_SET_CURRENT_AUTOMAKE_VERSION -# ------------------------------- -# Call AM_AUTOMAKE_VERSION so it can be traced. -# This function is AC_REQUIREd by AC_INIT_AUTOMAKE. -AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], - [AM_AUTOMAKE_VERSION([1.8.2])]) - -# Figure out how to run the assembler. -*- Autoconf -*- - -# serial 3 - -# Copyright (C) 2001, 2003, 2004 Free Software Foundation, 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, 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. - -# 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_AUX_DIR_EXPAND - -# Copyright (C) 2001, 2003 Free Software Foundation, 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, 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. - -# 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/../..'. -# -# Of course, Automake must honor this variable whenever it calls a -# tool from the auxiliary directory. The problem is that $srcdir (and -# therefore $ac_aux_dir as well) can be either absolute or relative, -# depending on how configure is run. This is pretty annoying, since -# it makes $ac_aux_dir quite unusable in subdirectories: in the top -# source directory, any form will work fine, but in subdirectories a -# relative path needs to be adjusted first. -# -# $ac_aux_dir/missing -# fails when called from a subdirectory if $ac_aux_dir is relative -# $top_srcdir/$ac_aux_dir/missing -# fails if $ac_aux_dir is absolute, -# fails when called from a subdirectory in a VPATH build with -# a relative $ac_aux_dir -# -# 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 -# start a VPATH build or use an absolute $srcdir. -# -# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, -# iff we strip the leading $srcdir from $ac_aux_dir. That would be: -# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` -# and then we would define $MISSING as -# MISSING="\${SHELL} $am_aux_dir/missing" -# This will work as long as MISSING is not called from configure, because -# unfortunately $(top_srcdir) has no meaning in configure. -# However there are other variables, like CC, which are often used in -# configure, and could therefore not use this "fixed" $ac_aux_dir. -# -# Another solution, used here, is to always expand $ac_aux_dir to an -# absolute PATH. The drawback is that using absolute paths prevent a -# 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` -]) - -# AM_CONDITIONAL -*- Autoconf -*- - -# Copyright (C) 1997, 2000, 2001, 2003 Free Software Foundation, 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, 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. - -# serial 6 - -# 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_SUBST([$1_TRUE]) -AC_SUBST([$1_FALSE]) -if $2; then - $1_TRUE= - $1_FALSE='#' -else - $1_TRUE='#' - $1_FALSE= -fi -AC_CONFIG_COMMANDS_PRE( -[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then - AC_MSG_ERROR([conditional "$1" was never defined. -Usually this means the macro was only invoked conditionally.]) -fi])]) - -# serial 6 -*- Autoconf -*- - -# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 -# Free Software Foundation, 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, 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. - - -# 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 -# CC etc. in the Makefile, will ask for an AC_PROG_CC use... - - - -# _AM_DEPENDENCIES(NAME) -# ---------------------- -# See how the compiler implements dependency checking. -# NAME is "CC", "CXX", "GCJ", or "OBJC". -# 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 -# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular -# dependency, and given that the user is not expected to run this macro, -# just rely on AC_PROG_CC. -AC_DEFUN([_AM_DEPENDENCIES], -[AC_REQUIRE([AM_SET_DEPDIR])dnl -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], 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], -[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'. - 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_$1_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` - fi - 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 - : > sub/conftst$i.h - done - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - - case $depmode in - 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 - ;; - none) break ;; - esac - # 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. - if depmode=$depmode \ - source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ - $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ - >/dev/null 2>conftest.err && - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftest.${OBJEXT-o} 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 - # (even with -Werror). So we grep stderr for any message - # that says an option was ignored. - if grep 'ignoring option' conftest.err >/dev/null 2>&1; then :; else - am_cv_$1_dependencies_compiler_type=$depmode - break - fi - fi - done - - cd .. - rm -rf conftest.dir -else - am_cv_$1_dependencies_compiler_type=none -fi -]) -AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) -AM_CONDITIONAL([am__fastdep$1], [ - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) -]) - - -# AM_SET_DEPDIR -# ------------- -# Choose a directory name for dependency files. -# 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 -]) - - -# 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]) -if test "x$enable_dependency_tracking" != xno; then - am_depcomp="$ac_aux_dir/depcomp" - AMDEPBACKSLASH='\' -fi -AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) -AC_SUBST([AMDEPBACKSLASH]) -]) - -# Generate code to set up dependency tracking. -*- Autoconf -*- - -# Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, 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, 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. - -#serial 2 - -# _AM_OUTPUT_DEPENDENCY_COMMANDS -# ------------------------------ -AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], -[for mf in $CONFIG_FILES; 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. - # So let's grep whole file. - if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then - dirpart=`AS_DIRNAME("$mf")` - else - continue - fi - grep '^DEP_FILES *= *[[^ @%:@]]' < "$mf" > /dev/null || continue - # Extract the definition of DEP_FILES from the Makefile without - # running `make'. - DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"` - test -z "$DEPDIR" && continue - # When using ansi2knr, U may be empty or an underscore; expand it - U=`sed -n -e '/^U = / s///p' < "$mf"` - test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR" - # 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 -e ' - /^DEP_FILES = .*\\\\$/ { - s/^DEP_FILES = // - :loop - s/\\\\$// - p - n - /\\\\$/ b loop - p - } - /^DEP_FILES = / s/^DEP_FILES = //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 -done -])# _AM_OUTPUT_DEPENDENCY_COMMANDS - - -# 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. -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"]) -]) - -# Like AC_CONFIG_HEADER, but automatically create stamp file. -*- Autoconf -*- - -# Copyright (C) 1996, 1997, 2000, 2001, 2003 Free Software Foundation, 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, 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. - -# serial 7 - -# AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS. -AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)]) - -# Do all the work for Automake. -*- Autoconf -*- - -# 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. - -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 -# Free Software Foundation, 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, 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. - -# serial 11 - -# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) -# AM_INIT_AUTOMAKE([OPTIONS]) -# ----------------------------------------------- -# The call with PACKAGE and VERSION arguments is the old style -# call (pre autoconf-2.50), which is being phased out. PACKAGE -# and VERSION should now be passed to AC_INIT and removed from -# the call to AM_INIT_AUTOMAKE. -# We support both call styles for the transition. After -# the next Automake release, Autoconf can make the AC_INIT -# 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.58])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 -AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl -AC_REQUIRE([AC_PROG_INSTALL])dnl -# test to see if srcdir already configured -if test "`cd $srcdir && pwd`" != "`pwd`" && - test -f $srcdir/config.status; then - AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) -fi - -# test whether we have cygpath -if test -z "$CYGPATH_W"; then - if (cygpath --version) >/dev/null 2>/dev/null; then - CYGPATH_W='cygpath -w' - else - CYGPATH_W=echo - fi -fi -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_SUBST([PACKAGE], [$1])dnl - AC_SUBST([VERSION], [$2])], -[_AM_SET_OPTIONS([$1])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 - -# 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(AMTAR, tar) -AM_PROG_INSTALL_SH -AM_PROG_INSTALL_STRIP -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_AWK])dnl -AC_REQUIRE([AC_PROG_MAKE_SET])dnl -AC_REQUIRE([AM_SET_LEADING_DOT])dnl - -_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 -AC_PROVIDE_IFELSE([AC_PROG_CXX], - [_AM_DEPENDENCIES(CXX)], - [define([AC_PROG_CXX], - defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl -]) -]) - - -# 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. - -# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the -# loop where config.status creates the headers, so we can generate -# our stamp files there. -AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], -[# Compute $1's index in $config_headers. -_am_stamp_count=1 -for _am_header in $config_headers :; do - case $_am_header in - $1 | $1:* ) - break ;; - * ) - _am_stamp_count=`expr $_am_stamp_count + 1` ;; - esac -done -echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count]) - -# AM_PROG_INSTALL_SH -# ------------------ -# Define $install_sh. - -# Copyright (C) 2001, 2003 Free Software Foundation, 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, 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. - -AC_DEFUN([AM_PROG_INSTALL_SH], -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -install_sh=${install_sh-"$am_aux_dir/install-sh"} -AC_SUBST(install_sh)]) - -# -*- Autoconf -*- -# Copyright (C) 2003 Free Software Foundation, 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, 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. - -# serial 1 - -# Check whether the underlying file-system supports filenames -# with a leading dot. For instance MS-DOS doesn't. -AC_DEFUN([AM_SET_LEADING_DOT], -[rm -rf .tst 2>/dev/null -mkdir .tst 2>/dev/null -if test -d .tst; then - am__leading_dot=. -else - am__leading_dot=_ -fi -rmdir .tst 2>/dev/null -AC_SUBST([am__leading_dot])]) - -# Check to see how 'make' treats includes. -*- Autoconf -*- - -# Copyright (C) 2001, 2002, 2003 Free Software Foundation, 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, 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. - -# serial 2 - -# AM_MAKE_INCLUDE() -# ----------------- -# Check to see how make treats includes. -AC_DEFUN([AM_MAKE_INCLUDE], -[am_make=${MAKE-make} -cat > confinc << 'END' -am__doit: - @echo done -.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 -# We grep out `Entering directory' and `Leaving directory' -# messages which can occur if `w' ends up in MAKEFLAGS. -# In particular we don't look at `^make:' because GNU make might -# be invoked under some other name (usually "gmake"), in which -# case it prints its new name instead of `make'. -if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then - am__include=include - am__quote= - _am_result=GNU -fi -# Now try BSD make style include. -if test "$am__include" = "#"; then - echo '.include "confinc"' > confmf - if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then - am__include=.include - am__quote="\"" - _am_result=BSD - fi -fi -AC_SUBST([am__include]) -AC_SUBST([am__quote]) -AC_MSG_RESULT([$_am_result]) -rm -f confinc confmf -]) - -# -*- Autoconf -*- - - -# Copyright (C) 1997, 1999, 2000, 2001, 2003 Free Software Foundation, 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, 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. - -# serial 3 - -# AM_MISSING_PROG(NAME, PROGRAM) -# ------------------------------ -AC_DEFUN([AM_MISSING_PROG], -[AC_REQUIRE([AM_MISSING_HAS_RUN]) -$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. -AC_DEFUN([AM_MISSING_HAS_RUN], -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" -# Use eval to expand $SHELL -if eval "$MISSING --run true"; then - am_missing_run="$MISSING --run " -else - am_missing_run= - AC_MSG_WARN([`missing' script is too old or missing]) -fi -]) - -# AM_PROG_MKDIR_P -# --------------- -# Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise. - -# Copyright (C) 2003, 2004 Free Software Foundation, 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, 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. - -# Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories -# created by `make install' are always world readable, even if the -# installer happens to have an overly restrictive umask (e.g. 077). -# This was a mistake. There are at least two reasons why we must not -# use `-m 0755': -# - it causes special bits like SGID to be ignored, -# - it may be too restrictive (some setups expect 775 directories). -# -# Do not use -m 0755 and let people choose whatever they expect by -# setting umask. -AC_DEFUN([AM_PROG_MKDIR_P], -[if mkdir -p -- . 2>/dev/null; then - # Keeping the `.' argument allows $(mkdir_p) to be used without - # argument. Indeed, we sometimes output rules like - # $(mkdir_p) $(somedir) - # where $(somedir) is conditionally defined. - # (`test -n '$(somedir)' && $(mkdir_p) $(somedir)' is a more - # expensive solution, as it forces Make to start a sub-shell.) - mkdir_p='mkdir -p -- .' -else - # On NextStep and OpenStep, the `mkdir' command does not - # recognize any option. It will interpret all options as - # directories to create, and then abort because `.' already - # exists. - for d in ./-p ./--; - do - test -d $d && rmdir $d - done - # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. - if test -f "$ac_aux_dir/mkinstalldirs"; then - mkdir_p='$(mkinstalldirs)' - else - mkdir_p='$(install_sh) -d' - fi -fi -AC_SUBST([mkdir_p])]) - -# Helper functions for option handling. -*- Autoconf -*- - -# Copyright (C) 2001, 2002, 2003 Free Software Foundation, 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, 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. - -# serial 2 - -# _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)]) - -# _AM_SET_OPTIONS(OPTIONS) -# ---------------------------------- -# OPTIONS is a space-separated list of Automake options. -AC_DEFUN([_AM_SET_OPTIONS], -[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) - -# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) -# ------------------------------------------- -# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. -AC_DEFUN([_AM_IF_OPTION], -[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) - -# -# Check to make sure that the build environment is sane. -# - -# Copyright (C) 1996, 1997, 2000, 2001, 2003 Free Software Foundation, 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, 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. - -# serial 3 - -# 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 -# 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 - - test "$[2]" = conftest.file - ) -then - # Ok. - : -else - AC_MSG_ERROR([newly created file is older than distributed files! -Check your system clock]) -fi -AC_MSG_RESULT(yes)]) - -# AM_PROG_INSTALL_STRIP - -# Copyright (C) 2001, 2003 Free Software Foundation, 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, 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. - -# 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 -# 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 -# 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'. -if test "$cross_compiling" != no; then - AC_CHECK_TOOL([STRIP], [strip], :) -fi -INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" -AC_SUBST([INSTALL_STRIP_PROGRAM])]) - diff --git a/code/libmad-0.15.1b/bit.h b/code/libmad-0.15.1b/bit.h deleted file mode 100644 index 5a51570b..00000000 --- a/code/libmad-0.15.1b/bit.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 - * - * $Id: bit.h,v 1.12 2004/01/23 09:41:32 rob Exp $ - */ - -# ifndef LIBMAD_BIT_H -# define LIBMAD_BIT_H - -struct mad_bitptr { - unsigned char const *byte; - unsigned short cache; - unsigned short left; -}; - -void mad_bit_init(struct mad_bitptr *, unsigned char const *); - -# define mad_bit_finish(bitptr) /* nothing */ - -unsigned int mad_bit_length(struct mad_bitptr const *, - struct mad_bitptr const *); - -# define mad_bit_bitsleft(bitptr) ((bitptr)->left) -unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *); - -void mad_bit_skip(struct mad_bitptr *, unsigned int); -unsigned long mad_bit_read(struct mad_bitptr *, unsigned int); -void mad_bit_write(struct mad_bitptr *, unsigned int, unsigned long); - -unsigned short mad_bit_crc(struct mad_bitptr, unsigned int, unsigned short); - -# endif diff --git a/code/libmad-0.15.1b/config.guess b/code/libmad-0.15.1b/config.guess deleted file mode 100644 index e8c6fc0c..00000000 --- a/code/libmad-0.15.1b/config.guess +++ /dev/null @@ -1,1432 +0,0 @@ -#! /bin/sh -# Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003 Free Software Foundation, Inc. - -timestamp='2004-01-05' - -# 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 -# (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. -# -# 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. -# -# 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. -# -# The plan is that this can be called by configure scripts if you -# don't specify an explicit build system type. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] - -Output the configuration name of the system \`$me' is run on. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.guess ($timestamp) - -Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -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." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit 0 ;; - --version | -v ) - echo "$version" ; exit 0 ;; - --help | --h* | -h ) - echo "$usage"; exit 0 ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" >&2 - exit 1 ;; - * ) - break ;; - esac -done - -if test $# != 0; then - echo "$me: too many arguments$help" >&2 - exit 1 -fi - -trap 'exit 1' 1 2 15 - -# CC_FOR_BUILD -- compiler used by this script. Note that the use of a -# compiler to aid in system detection is discouraged as it requires -# temporary files to be created and, as you can see below, it is a -# headache to deal with in a portable fashion. - -# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still -# use `HOST_CC' if defined, but it is deprecated. - -# Portable tmp directory creation inspired by the Autoconf team. - -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -: ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -dummy=$tmp/dummy ; -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) 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 - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ;' - -# This is needed to find uname on a Pyramid OSx when run in the BSD universe. -# (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then - PATH=$PATH:/.attbin ; export PATH -fi - -UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown -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 - -# Note: order is significant - the case branches are not exclusive. - -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*, - # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently - # switched to ELF, *-*-netbsd* would select the old - # object file format. This provides both forward - # compatibility and a consistent mechanism for selecting the - # object file format. - # - # 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 - armeb) machine=armeb-unknown ;; - arm*) machine=arm-unknown ;; - sh3el) machine=shl-unknown ;; - sh3eb) machine=sh-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 - arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build - if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep __ELF__ >/dev/null - then - # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). - # Return netbsd for either. FIX? - os=netbsd - else - os=netbsdelf - fi - ;; - *) - os=netbsd - ;; - esac - # The OS release - # Debian GNU/NetBSD machines have a different userland, and - # 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 - Debian*) - release='-gnu' - ;; - *) - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - ;; - 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}" - exit 0 ;; - amiga:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - arc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - hp300:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mac68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - macppc:OpenBSD:*:*) - echo powerpc-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme88k:OpenBSD:*:*) - echo m88k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvmeppc:OpenBSD:*:*) - echo powerpc-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - pegasos:OpenBSD:*:*) - echo powerpc-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - pmax:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sgi:OpenBSD:*:*) - echo mipseb-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sun3:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - wgrisc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - *:OpenBSD:*:*) - echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - alpha:OSF1:*:*) - if test $UNAME_RELEASE = "V4.0"; then - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - fi - # According to Compaq, /usr/sbin/psrinfo has been available on - # OSF/1 and Tru64 systems produced since 1995. I hope that - # covers most systems running today. This code pipes the CPU - # types through head -n 1, so we only detect the type of CPU 0. - 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" ;; - "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; - "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; - "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; - "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; - "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; - "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; - "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; - "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; - "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; - "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; - "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; - "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; - esac - # 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/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - exit 0 ;; - Alpha*:OpenVMS:*:*) - echo alpha-hp-vms - exit 0 ;; - 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 0 ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit 0 ;; - Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 - exit 0;; - *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos - exit 0 ;; - *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos - exit 0 ;; - *:OS/390:*:*) - echo i370-ibm-openedition - exit 0 ;; - *:OS400:*:*) - echo powerpc-ibm-os400 - exit 0 ;; - arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit 0;; - SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit 0;; - Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) - # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit 0 ;; - NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit 0 ;; - DRS?6000:unix:4.0:6*) - echo sparc-icl-nx6 - exit 0 ;; - DRS?6000:UNIX_SV:4.2*:7*) - case `/usr/bin/uname -p` in - sparc) echo sparc-icl-nx7 && exit 0 ;; - esac ;; - sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - i86pc:SunOS:5.*:*) - echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - 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/[^.]*//'` - exit 0 ;; - sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in - Series*|S4*) - UNAME_RELEASE=`uname -v` - ;; - esac - # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit 0 ;; - sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit 0 ;; - 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 - case "`/bin/arch`" in - sun3) - echo m68k-sun-sunos${UNAME_RELEASE} - ;; - sun4) - echo sparc-sun-sunos${UNAME_RELEASE} - ;; - esac - exit 0 ;; - aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit 0 ;; - # The situation for MiNT is a little confusing. The machine name - # can be virtually everything (everything which is not - # "atarist" or "atariste" at least should have a processor - # > m68000). The system name ranges from "MiNT" over "FreeMiNT" - # to the lowercase version "mint" (or "freemint"). Finally - # the system name "TOS" denotes a system which is actually not - # 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} - exit 0 ;; - atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; - *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; - milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit 0 ;; - hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit 0 ;; - *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit 0 ;; - powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit 0 ;; - RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit 0 ;; - RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit 0 ;; - VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit 0 ;; - 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit 0 ;; - mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c -#ifdef __cplusplus -#include /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif - #if defined (host_mips) && defined (MIPSEB) - #if defined (SYSTYPE_SYSV) - 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); - #endif - #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); - #endif - #endif - exit (-1); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c \ - && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ - && exit 0 - echo mips-mips-riscos${UNAME_RELEASE} - exit 0 ;; - Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax - exit 0 ;; - Motorola:*:4.3:PL8-*) - echo powerpc-harris-powermax - exit 0 ;; - Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) - echo powerpc-harris-powermax - exit 0 ;; - Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit 0 ;; - m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit 0 ;; - m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit 0 ;; - m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit 0 ;; - AViiON:dgux:*:*) - # 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 ] - then - echo m88k-dg-dgux${UNAME_RELEASE} - else - echo m88k-dg-dguxbcs${UNAME_RELEASE} - fi - else - echo i586-dg-dgux${UNAME_RELEASE} - fi - exit 0 ;; - M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit 0 ;; - M88*:*:R3*:*) - # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit 0 ;; - XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit 0 ;; - Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit 0 ;; - *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit 0 ;; - ????????: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 - exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' - i*86:AIX:*:*) - echo i386-ibm-aix - exit 0 ;; - ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit 0 ;; - *: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 - #include - - main() - { - if (!__power_pc()) - exit(1); - puts("powerpc-ibm-aix3.2.5"); - exit(0); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 - echo rs6000-ibm-aix3.2.5 - elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 - else - echo rs6000-ibm-aix3.2 - fi - exit 0 ;; - *:AIX:*:[45]) - 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 - IBM_ARCH=rs6000 - else - IBM_ARCH=powerpc - fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit 0 ;; - *:AIX:*:*) - echo rs6000-ibm-aix - exit 0 ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 - exit 0 ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit 0 ;; # report: romp-ibm BSD 4.3 - *:BOSX:*:*) - echo rs6000-bull-bosx - exit 0 ;; - DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit 0 ;; - 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit 0 ;; - hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit 0 ;; - 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 ;; - 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 - fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - - #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); - - 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` - test -z "$HP_ARCH" && HP_ARCH=hppa - fi ;; - esac - if [ ${HP_ARCH} = "hppa2.0w" ] - then - # avoid double evaluation of $set_cc_for_build - test -n "$CC_FOR_BUILD" || eval $set_cc_for_build - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null - then - HP_ARCH="hppa2.0w" - else - HP_ARCH="hppa64" - fi - fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit 0 ;; - ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} - exit 0 ;; - 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - int - main () - { - long cpu = sysconf (_SC_CPU_VERSION); - /* The order matters, because CPU_IS_HP_MC68K erroneously returns - true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct - results, however. */ - if (CPU_IS_PA_RISC (cpu)) - { - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; - case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; - default: puts ("hppa-hitachi-hiuxwe2"); break; - } - } - else if (CPU_IS_HP_MC68K (cpu)) - puts ("m68k-hitachi-hiuxwe2"); - else puts ("unknown-hitachi-hiuxwe2"); - exit (0); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 - echo unknown-hitachi-hiuxwe2 - exit 0 ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd - exit 0 ;; - 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit 0 ;; - *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit 0 ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf - exit 0 ;; - hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit 0 ;; - i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk - else - echo ${UNAME_MACHINE}-unknown-osf1 - fi - exit 0 ;; - parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit 0 ;; - C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit 0 ;; - C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit 0 ;; - C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit 0 ;; - C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit 0 ;; - C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit 0 ;; - CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ - | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ - -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - *:UNICOS/mp:*:*) - echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - 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 0 ;; - 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}" - exit 0 ;; - i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit 0 ;; - sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; - *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; - *:FreeBSD:*:*) - # Determine whether the default compiler uses glibc. - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - #if __GLIBC__ >= 2 - LIBC=gnu - #else - LIBC= - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` - # GNU/KFreeBSD systems have a "k" prefix to indicate we are using - # FreeBSD's kernel, but not the complete OS. - case ${LIBC} in gnu) kernel_only='k' ;; esac - echo ${UNAME_MACHINE}-unknown-${kernel_only}freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC} - exit 0 ;; - i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit 0 ;; - i*:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit 0 ;; - i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 - exit 0 ;; - x86:Interix*:[34]*) - echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' - exit 0 ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit 0 ;; - 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 0 ;; - i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin - exit 0 ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit 0 ;; - prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - *:GNU:*:*) - # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit 0 ;; - *: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 - exit 0 ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix - exit 0 ;; - arm*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - cris:Linux:*:*) - echo cris-axis-linux-gnu - exit 0 ;; - ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - 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 | grep ^CPU=` - test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 - ;; - 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 | grep ^CPU=` - test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 - ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-gnu - exit 0 ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-gnu - exit 0 ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - EV5) UNAME_MACHINE=alphaev5 ;; - EV56) UNAME_MACHINE=alphaev56 ;; - PCA56) UNAME_MACHINE=alphapca56 ;; - PCA57) UNAME_MACHINE=alphapca56 ;; - 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} - exit 0 ;; - 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 ;; - esac - exit 0 ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-gnu - exit 0 ;; - s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux - exit 0 ;; - sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - x86_64:Linux:*:*) - echo x86_64-unknown-linux-gnu - exit 0 ;; - 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 0 ;; - coff-i386) - echo "${UNAME_MACHINE}-pc-linux-gnucoff" - exit 0 ;; - "") - # 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 0 ;; - 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 - #ifdef __INTEL_COMPILER - LIBC=gnu - #else - LIBC=gnuaout - #endif - #endif - #ifdef __dietlibc__ - LIBC=dietlibc - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` - test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0 - test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 - ;; - 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 - # sysname and nodename. - echo i386-sequent-sysv4 - exit 0 ;; - 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, - # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit 0 ;; - i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility - # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit 0 ;; - i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop - exit 0 ;; - i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos - exit 0 ;; - i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable - exit 0 ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit 0 ;; - i*86:*:4.*:* | i*86:SYSTEM_V: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} - else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} - fi - exit 0 ;; - i*86:*:5:[78]*) - 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} - exit 0 ;; - 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 - (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ - && UNAME_MACHINE=i586 - (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ - && UNAME_MACHINE=i686 - (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ - && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL - else - echo ${UNAME_MACHINE}-pc-sysv32 - fi - exit 0 ;; - 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 i386. - echo i386-pc-msdosdjgpp - exit 0 ;; - Intel:Mach:3*:*) - echo i386-pc-mach3 - exit 0 ;; - paragon:*:*:*) - echo i860-intel-osf1 - exit 0 ;; - 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 - else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 - fi - exit 0 ;; - mini*:CTIX:SYS*5:*) - # "miniframe" - echo m68010-convergent-sysv - exit 0 ;; - mc68k:UNIX:SYSTEM5:3.51m) - echo m68k-convergent-sysv - exit 0 ;; - M680?0:D-NIX:5.3:*) - echo m68k-diab-dnix - exit 0 ;; - M68*:*:R3V[567]*:*) - test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; - 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0) - OS_REL='' - 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 0 - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; - 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4 && exit 0 ;; - m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit 0 ;; - TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit 0 ;; - RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit 0 ;; - RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit 0 ;; - *:SINIX-*:*:*) - if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 - else - echo ns32k-sni-sysv - fi - exit 0 ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit 0 ;; - *:UNIX_System_V:4*:FTX*) - # From Gerald Hewes . - # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit 0 ;; - *:*:*:FTX*) - # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit 0 ;; - *:VOS:*:*) - # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit 0 ;; - mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit 0 ;; - news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit 0 ;; - R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} - else - echo mips-unknown-sysv${UNAME_RELEASE} - fi - exit 0 ;; - BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit 0 ;; - BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit 0 ;; - BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit 0 ;; - SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} - exit 0 ;; - SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} - exit 0 ;; - SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} - exit 0 ;; - Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit 0 ;; - *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit 0 ;; - *:Darwin:*:*) - case `uname -p` in - *86) UNAME_PROCESSOR=i686 ;; - powerpc) UNAME_PROCESSOR=powerpc ;; - esac - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} - exit 0 ;; - *:procnto*:*:* | *:QNX:[0123456789]*:*) - UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then - UNAME_PROCESSOR=i386 - UNAME_MACHINE=pc - fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} - exit 0 ;; - *:QNX:*:4*) - echo i386-pc-qnx - exit 0 ;; - NSR-?:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} - exit 0 ;; - *:NonStop-UX:*:*) - echo mips-compaq-nonstopux - exit 0 ;; - BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv - exit 0 ;; - DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit 0 ;; - *: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 - UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" - fi - echo ${UNAME_MACHINE}-unknown-plan9 - exit 0 ;; - *:TOPS-10:*:*) - echo pdp10-unknown-tops10 - exit 0 ;; - *:TENEX:*:*) - echo pdp10-unknown-tenex - exit 0 ;; - KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 - exit 0 ;; - XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 - exit 0 ;; - *:TOPS-20:*:*) - echo pdp10-unknown-tops20 - exit 0 ;; - *:ITS:*:*) - echo pdp10-unknown-its - exit 0 ;; - SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} - exit 0 ;; - *:DRAGONFLY:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly${UNAME_RELEASE} - exit 0 ;; -esac - -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&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 - -#if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix"); exit (0); -#endif - -#if defined (hp300) && !defined (hpux) - printf ("m68k-hp-bsd\n"); exit (0); -#endif - -#if defined (NeXT) -#if !defined (__ARCHITECTURE__) -#define __ARCHITECTURE__ "m68k" -#endif - int version; - version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 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); -} -EOF - -$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0 - -# Apollos put the system type in the environment. - -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } - -# 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 0 ;; - c2*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit 0 ;; - c34*) - echo c34-convex-bsd - exit 0 ;; - c38*) - echo c38-convex-bsd - exit 0 ;; - c4*) - echo c4-convex-bsd - exit 0 ;; - esac -fi - -cat >&2 < in order to provide the needed -information to handle your system. - -config.guess timestamp = $timestamp - -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null` - -hostinfo = `(hostinfo) 2>/dev/null` -/bin/universe = `(/bin/universe) 2>/dev/null` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` -/bin/arch = `(/bin/arch) 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} -EOF - -exit 1 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/code/libmad-0.15.1b/config.h.in b/code/libmad-0.15.1b/config.h.in deleted file mode 100644 index a29b5820..00000000 --- a/code/libmad-0.15.1b/config.h.in +++ /dev/null @@ -1,135 +0,0 @@ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define to enable diagnostic debugging support. */ -#undef DEBUG - -/* Define to enable experimental code. */ -#undef EXPERIMENTAL - -/* Define to 1 if you have the header file. */ -#undef HAVE_ASSERT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_DLFCN_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_ERRNO_H - -/* Define to 1 if you have the `fcntl' function. */ -#undef HAVE_FCNTL - -/* Define to 1 if you have the header file. */ -#undef HAVE_FCNTL_H - -/* Define to 1 if you have the `fork' function. */ -#undef HAVE_FORK - -/* Define to 1 if you have the header file. */ -#undef HAVE_INTTYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_LIMITS_H - -/* Define if your MIPS CPU supports a 2-operand MADD16 instruction. */ -#undef HAVE_MADD16_ASM - -/* Define if your MIPS CPU supports a 2-operand MADD instruction. */ -#undef HAVE_MADD_ASM - -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - -/* Define to 1 if you have the `pipe' function. */ -#undef HAVE_PIPE - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have that is POSIX.1 compatible. */ -#undef HAVE_SYS_WAIT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Define to 1 if you have the `waitpid' function. */ -#undef HAVE_WAITPID - -/* Define to disable debugging assertions. */ -#undef NDEBUG - -/* Define to optimize for accuracy over speed. */ -#undef OPT_ACCURACY - -/* Define to optimize for speed over accuracy. */ -#undef OPT_SPEED - -/* Define to enable a fast subband synthesis approximation optimization. */ -#undef OPT_SSO - -/* Define to influence a strict interpretation of the ISO/IEC standards, even - if this is in opposition with best accepted practices. */ -#undef OPT_STRICT - -/* Name of package */ -#undef PACKAGE - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* The size of a `int', as computed by sizeof. */ -#undef SIZEOF_INT - -/* The size of a `long', as computed by sizeof. */ -#undef SIZEOF_LONG - -/* The size of a `long long', as computed by sizeof. */ -#undef SIZEOF_LONG_LONG - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* Version number of package */ -#undef VERSION - -/* Define to 1 if your processor stores words with the most significant byte - first (like Motorola and SPARC, unlike Intel and VAX). */ -#undef WORDS_BIGENDIAN - -/* Define to empty if `const' does not conform to ANSI C. */ -#undef const - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus -#undef inline -#endif - -/* Define to `int' if does not define. */ -#undef pid_t diff --git a/code/libmad-0.15.1b/config.sub b/code/libmad-0.15.1b/config.sub deleted file mode 100644 index 463186db..00000000 --- a/code/libmad-0.15.1b/config.sub +++ /dev/null @@ -1,1537 +0,0 @@ -#! /bin/sh -# Configuration validation subroutine script. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003 Free Software Foundation, Inc. - -timestamp='2004-01-05' - -# 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 -# (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. - -# 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. - -# Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. -# -# 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. - -# 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. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration. - -# The goal of this file is to map all the various variations of a given -# machine specification into a single specification in the form: -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or in some cases, the newer four-part form: -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# It is wrong to echo any other type of specification. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS - -Canonicalize a configuration name. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.sub ($timestamp) - -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -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." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit 0 ;; - --version | -v ) - echo "$version" ; exit 0 ;; - --help | --h* | -h ) - echo "$usage"; exit 0 ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" - exit 1 ;; - - *local*) - # First pass through any local machine types. - echo $1 - exit 0;; - - * ) - break ;; - esac -done - -case $# in - 0) echo "$me: missing argument$help" >&2 - exit 1;; - 1) ;; - *) echo "$me: too many arguments$help" >&2 - exit 1;; -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/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \ - kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac - -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -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) - os= - basic_machine=$1 - ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 - ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - 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/'` - ;; - -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/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - 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/'` - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; -esac - -# Decode aliases for certain CPU-COMPANY combinations. -case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | 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 \ - | c4x | clipper \ - | d10v | d30v | dlx | dsp16xx \ - | fr30 | frv \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | i370 | i860 | i960 | ia64 \ - | ip2k | iq2000 \ - | m32r | m68000 | m68k | m88k | mcore \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64vr | mips64vrel \ - | mips64orion | mips64orionel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | msp430 \ - | ns16k | ns32k \ - | openrisc | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ - | pyramid \ - | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \ - | strongarm \ - | tahoe | thumb | tic4x | tic80 | tron \ - | v850 | v850e \ - | we32k \ - | x86 | xscale | xstormy16 | xtensa \ - | z8k) - basic_machine=$basic_machine-unknown - ;; - m6811 | m68hc11 | m6812 | m68hc12) - # Motorola 68HC11/12. - basic_machine=$basic_machine-unknown - os=-none - ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) - ;; - - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* \ - | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ - | clipper-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | elxsi-* \ - | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | i*86-* | i860-* | i960-* | ia64-* \ - | ip2k-* | iq2000-* \ - | m32r-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | mcore-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipstx39-* | mipstx39el-* \ - | msp430-* \ - | none-* | np1-* | nv1-* | ns16k-* | ns32k-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ - | pyramid-* \ - | romp-* | rs6000-* \ - | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ - | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ - | tahoe-* | thumb-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tron-* \ - | v850-* | v850e-* | vax-* \ - | we32k-* \ - | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \ - | xtensa-* \ - | ymp-* \ - | z8k-*) - ;; - # 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 - os=-bsd - ;; - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amd64) - basic_machine=x86_64-pc - ;; - amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - crds | unos) - basic_machine=m68k-crds - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 - ;; - decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp - ;; - hp9k78[0-9] | hp78[0-9]) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp - ;; - 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 - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - 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/'` - os=-sysv32 - ;; - i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach - ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - mingw32) - basic_machine=i386-pc - os=-mingw32 - ;; - miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - mmix*) - basic_machine=mmix-knuth - os=-mmixware - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; - np1) - basic_machine=np1-gould - ;; - nv1) - basic_machine=nv1-cray - os=-unicosmp - ;; - nsr-tandem) - basic_machine=nsr-tandem - ;; - op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - or32 | or32-*) - basic_machine=or32-unknown - os=-coff - ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc - ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc - ;; - pentium4) - basic_machine=i786-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc) basic_machine=powerpc-unknown - ;; - ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390 | s390-*) - basic_machine=s390-ibm - ;; - s390x | s390x-*) - basic_machine=s390x-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sb1) - basic_machine=mipsisa64sb1-unknown - ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown - ;; - sei) - basic_machine=mips-sei - os=-seiux - ;; - sequent) - basic_machine=i386-sequent - ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sh64) - basic_machine=sh64-unknown - ;; - sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - st2000) - basic_machine=m68k-tandem - ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - sv1) - basic_machine=sv1-cray - os=-unicos - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - t3e) - basic_machine=alphaev5-cray - os=-unicos - ;; - t90) - 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 - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - toad1) - basic_machine=pdp10-xkl - os=-tops20 - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - tpf) - basic_machine=s390x-ibm - os=-tpf - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - v810 | necv810) - basic_machine=v810-nec - os=-none - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - w65*) - basic_machine=w65-wdc - os=-none - ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=-proelf - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - ymp) - basic_machine=ymp-cray - os=-unicos - ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - none) - basic_machine=none-none - os=-none - ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond - ;; - op50n) - basic_machine=hppa1.1-oki - ;; - op60c) - basic_machine=hppa1.1-oki - ;; - romp) - basic_machine=romp-ibm - ;; - rs6000) - basic_machine=rs6000-ibm - ;; - 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 - ;; - we32k) - basic_machine=we32k-att - ;; - sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele) - basic_machine=sh-unknown - ;; - sh64) - basic_machine=sh64-unknown - ;; - sparc | sparcv9 | sparcv9b) - basic_machine=sparc-sun - ;; - cydra) - basic_machine=cydra-cydrome - ;; - orion) - basic_machine=orion-highlevel - ;; - orion105) - basic_machine=clipper-highlevel - ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple - ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple - ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. - ;; - *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; -esac - -# Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` - ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` - ;; - *) - ;; -esac - -# Decode manufacturer-specific aliases for certain operating systems. - -if [ x"$os" != x"" ] -then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -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. - # The portable systems comes first. - # 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* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -netbsd* | -openbsd* | -kfreebsd* | -freebsd* | -riscix* \ - | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* \ - | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -qnx*) - case $basic_machine in - x86-* | i*86-*) - ;; - *) - os=-nto$os - ;; - esac - ;; - -nto-qnx*) - ;; - -nto*) - os=`echo $os | sed -e 's|nto|nto-qnx|'` - ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) - ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` - ;; - -linux-dietlibc) - os=-linux-dietlibc - ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` - ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` - ;; - -opened*) - os=-openedition - ;; - -os400*) - os=-os400 - ;; - -wince*) - os=-wince - ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; - -utek*) - os=-bsd - ;; - -dynix*) - os=-bsd - ;; - -acis*) - os=-aos - ;; - -atheos*) - os=-atheos - ;; - -syllable*) - os=-syllable - ;; - -386bsd) - os=-bsd - ;; - -ctix* | -uts*) - os=-sysv - ;; - -nova*) - os=-rtmk-nova - ;; - -ns2 ) - os=-nextstep2 - ;; - -nsk*) - os=-nsk - ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` - ;; - -sinix*) - os=-sysv4 - ;; - -tpf*) - os=-tpf - ;; - -triton*) - os=-sysv3 - ;; - -oss*) - os=-sysv3 - ;; - -svr4) - os=-sysv4 - ;; - -svr3) - os=-sysv3 - ;; - -sysvr4) - os=-sysv4 - ;; - # This must come after -sysvr4. - -sysv*) - ;; - -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 - ;; - -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 - exit 1 - ;; -esac -else - -# Here we handle the default operating systems that come with various machines. -# The value should be what the vendor currently ships out the door with their -# machine or put another way, the most popular os provided with the machine. - -# Note that if you're going to try to match "-MANUFACTURER" here (say, -# "-sun"), then you have to tell the case statement up towards the top -# that MANUFACTURER isn't an operating system. Otherwise, code above -# will signal an error saying that MANUFACTURER isn't an operating -# system, and we'll never get to this point. - -case $basic_machine in - *-acorn) - os=-riscix1.2 - ;; - arm*-rebel) - os=-linux - ;; - arm*-semi) - os=-aout - ;; - c4x-* | tic4x-*) - os=-coff - ;; - # This must come before the *-dec entry. - pdp10-*) - os=-tops20 - ;; - pdp11-*) - os=-none - ;; - *-dec | vax-*) - os=-ultrix4.2 - ;; - m68*-apollo) - os=-domain - ;; - i386-sun) - os=-sunos4.0.2 - ;; - m68000-sun) - os=-sunos3 - # This also exists in the configure program, but was not the - # default. - # os=-sunos4 - ;; - m68*-cisco) - os=-aout - ;; - mips*-cisco) - os=-elf - ;; - mips*-*) - os=-elf - ;; - or32-*) - os=-coff - ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 - ;; - sparc-* | *-sun) - os=-sunos4.1.1 - ;; - *-be) - os=-beos - ;; - *-ibm) - os=-aix - ;; - *-wec) - os=-proelf - ;; - *-winbond) - os=-proelf - ;; - *-oki) - os=-proelf - ;; - *-hp) - os=-hpux - ;; - *-hitachi) - os=-hiux - ;; - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv - ;; - *-cbm) - os=-amigaos - ;; - *-dg) - os=-dgux - ;; - *-dolphin) - os=-sysv3 - ;; - m68k-ccur) - os=-rtu - ;; - m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 - ;; - *-gould) - os=-sysv - ;; - *-highlevel) - os=-bsd - ;; - *-encore) - os=-bsd - ;; - *-sgi) - os=-irix - ;; - *-siemens) - os=-sysv4 - ;; - *-masscomp) - os=-rtu - ;; - f30[01]-fujitsu | f700-fujitsu) - os=-uxpv - ;; - *-rom68k) - os=-coff - ;; - *-*bug) - os=-coff - ;; - *-apple) - os=-macos - ;; - *-atari*) - os=-mint - ;; - *) - os=-none - ;; -esac -fi - -# Here we handle the case where we know the os, and the CPU type, but not the -# manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) - vendor=acorn - ;; - -sunos*) - vendor=sun - ;; - -aix*) - vendor=ibm - ;; - -beos*) - vendor=be - ;; - -hpux*) - vendor=hp - ;; - -mpeix*) - vendor=hp - ;; - -hiux*) - vendor=hitachi - ;; - -unos*) - vendor=crds - ;; - -dgux*) - vendor=dg - ;; - -luna*) - vendor=omron - ;; - -genix*) - vendor=ns - ;; - -mvs* | -opened*) - vendor=ibm - ;; - -os400*) - vendor=ibm - ;; - -ptx*) - vendor=sequent - ;; - -tpf*) - vendor=ibm - ;; - -vxsim* | -vxworks* | -windiss*) - vendor=wrs - ;; - -aux*) - vendor=apple - ;; - -hms*) - vendor=hitachi - ;; - -mpw* | -macos*) - vendor=apple - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - vendor=atari - ;; - -vos*) - vendor=stratus - ;; - esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` - ;; -esac - -echo $basic_machine$os -exit 0 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/code/libmad-0.15.1b/configure b/code/libmad-0.15.1b/configure deleted file mode 100644 index ee421cc3..00000000 --- a/code/libmad-0.15.1b/configure +++ /dev/null @@ -1,23106 +0,0 @@ -#! /bin/sh -# From configure.ac Id: configure.ac,v 1.9 2004/01/23 09:41:32 rob Exp . -# Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.59 for MPEG Audio Decoder 0.15.1b. -# -# Report bugs to . -# -# Copyright (C) 2003 Free Software Foundation, Inc. -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## - -# Be Bourne compatible -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' -elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then - set -o posix -fi -DUALCASE=1; export DUALCASE # for MKS sh - -# Support unset when possible. -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset -else - as_unset=false -fi - - -# Work around bugs in pre-3.0 UWIN ksh. -$as_unset ENV MAIL MAILPATH -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -for as_var in \ - LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ - LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ - LC_TELEPHONE LC_TIME -do - if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then - eval $as_var=C; export $as_var - else - $as_unset $as_var - fi -done - -# Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1; then - as_expr=expr -else - as_expr=false -fi - -if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - - -# Name of the executable. -as_me=`$as_basename "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)$' \| \ - . : '\(.\)' 2>/dev/null || -echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } - /^X\/\(\/\/\)$/{ s//\1/; q; } - /^X\/\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - - -# PATH needs CR, and LINENO needs CR and PATH. -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi - - - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" || { - # Find who we are. Look in the path if we contain no path at all - # relative or not. - case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done - - ;; - esac - # We did not find ourselves, most probably we were run as `sh COMMAND' - # in which case we are not to be found in the path. - if test "x$as_myself" = x; then - as_myself=$0 - fi - if test ! -f "$as_myself"; then - { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 - { (exit 1); exit 1; }; } - fi - case $CONFIG_SHELL in - '') - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for as_base in sh bash ksh sh5; do - case $as_dir in - /*) - if ("$as_dir/$as_base" -c ' - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then - $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } - $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } - CONFIG_SHELL=$as_dir/$as_base - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$0" ${1+"$@"} - fi;; - esac - done -done -;; - esac - - # Create $as_me.lineno as a copy of $as_myself, but with $LINENO - # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line before each line; the second 'sed' does the real - # work. The second script uses 'N' to pair each line-number line - # with the numbered line, and appends trailing '-' during - # substitution so that $LINENO is not a special case at line end. - # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) - sed '=' <$as_myself | - sed ' - N - s,$,-, - : loop - s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, - t loop - s,-$,, - s,^['$as_cr_digits']*\n,, - ' >$as_me.lineno && - chmod +x $as_me.lineno || - { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 - { (exit 1); exit 1; }; } - - # 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 sensible to this). - . ./$as_me.lineno - # Exit status is that of the last command. - exit -} - - -case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in - *c*,-n*) ECHO_N= ECHO_C=' -' ECHO_T=' ' ;; - *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; - *) ECHO_N= ECHO_C='\c' ECHO_T= ;; -esac - -if expr a : '\(a\)' >/dev/null 2>&1; then - as_expr=expr -else - as_expr=false -fi - -rm -f conf$$ conf$$.exe conf$$.file -echo >conf$$.file -if ln -s conf$$.file conf$$ 2>/dev/null; then - # We could just check for DJGPP; but this test a) works b) is more generic - # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). - if test -f conf$$.exe; then - # Don't use ln at all; we don't have any links - as_ln_s='cp -p' - else - as_ln_s='ln -s' - fi -elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln -else - as_ln_s='cp -p' -fi -rm -f conf$$ conf$$.exe conf$$.file - -if mkdir -p . 2>/dev/null; then - as_mkdir_p=: -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -as_executable_p="test -f" - -# 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'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -# IFS -# We need space, tab and new line, in precisely that order. -as_nl=' -' -IFS=" $as_nl" - -# CDPATH. -$as_unset CDPATH - - - -# Check that we are running under the correct shell. -SHELL=${CONFIG_SHELL-/bin/sh} - -case X$ECHO in -X*--fallback-echo) - # Remove one level of quotation (which was required for Make). - ECHO=`echo "$ECHO" | sed 's,\\\\\$\\$0,'$0','` - ;; -esac - -echo=${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 </dev/null && - echo_test_string="`eval $cmd`" && - (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. -ECHO=$echo -if test "X$ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then - ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo" -fi - - - - -tagnames=${tagnames+${tagnames},}CXX - -tagnames=${tagnames+${tagnames},}F77 - -# Name of the host. -# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, -# so uname gets run too. -ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` - -exec 6>&1 - -# -# Initializations. -# -ac_default_prefix=/usr/local -ac_config_libobj_dir=. -cross_compiling=no -subdirs= -MFLAGS= -MAKEFLAGS= -SHELL=${CONFIG_SHELL-/bin/sh} - -# Maximum number of lines to put in a shell here document. -# This variable seems obsolete. It should probably be removed, and -# only ac_max_sed_lines should be used. -: ${ac_max_here_lines=38} - -# Identity of this package. -PACKAGE_NAME='MPEG Audio Decoder' -PACKAGE_TARNAME='libmad' -PACKAGE_VERSION='0.15.1b' -PACKAGE_STRING='MPEG Audio Decoder 0.15.1b' -PACKAGE_BUGREPORT='support@underbit.com' - -ac_unique_file="decoder.h" -# Factoring default headers for most tests. -ac_includes_default="\ -#include -#if HAVE_SYS_TYPES_H -# include -#endif -#if HAVE_SYS_STAT_H -# include -#endif -#if STDC_HEADERS -# include -# include -#else -# if HAVE_STDLIB_H -# include -# endif -#endif -#if HAVE_STRING_H -# if !STDC_HEADERS && HAVE_MEMORY_H -# include -# endif -# include -#endif -#if HAVE_STRINGS_H -# include -#endif -#if HAVE_INTTYPES_H -# include -#else -# if HAVE_STDINT_H -# include -# endif -#endif -#if HAVE_UNISTD_H -# include -#endif" - -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO AMTAR install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CCAS CCASFLAGS EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CPP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL LIBTOOL_DEPS FPM ASO ASO_OBJS LIBOBJS LTLIBOBJS' -ac_subst_files='' - -# Initialize some variables set by options. -ac_init_help= -ac_init_version=false -# The variables have the same names as the options, with -# dashes changed to underlines. -cache_file=/dev/null -exec_prefix=NONE -no_create= -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -verbose= -x_includes=NONE -x_libraries=NONE - -# Installation directory options. -# These are left unexpanded so users can "make install exec_prefix=/foo" -# and all the variables that are supposed to be based on exec_prefix -# by default will actually change. -# Use braces instead of parens because sh, perl, etc. also accept them. -bindir='${exec_prefix}/bin' -sbindir='${exec_prefix}/sbin' -libexecdir='${exec_prefix}/libexec' -datadir='${prefix}/share' -sysconfdir='${prefix}/etc' -sharedstatedir='${prefix}/com' -localstatedir='${prefix}/var' -libdir='${exec_prefix}/lib' -includedir='${prefix}/include' -oldincludedir='/usr/include' -infodir='${prefix}/info' -mandir='${prefix}/man' - -ac_prev= -for ac_option -do - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval "$ac_prev=\$ac_option" - ac_prev= - continue - fi - - ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case $ac_option in - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir=$ac_optarg ;; - - -build | --build | --buil | --bui | --bu) - ac_prev=build_alias ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build_alias=$ac_optarg ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file=$ac_optarg ;; - - --config-cache | -C) - cache_file=config.cache ;; - - -datadir | --datadir | --datadi | --datad | --data | --dat | --da) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ - | --da=*) - datadir=$ac_optarg ;; - - -disable-* | --disable-*) - ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid feature name: $ac_feature" >&2 - { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/-/_/g'` - eval "enable_$ac_feature=no" ;; - - -enable-* | --enable-*) - ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid feature name: $ac_feature" >&2 - { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/-/_/g'` - case $ac_option in - *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; - *) ac_optarg=yes ;; - esac - eval "enable_$ac_feature='$ac_optarg'" ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix=$ac_optarg ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he | -h) - ac_init_help=long ;; - -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) - ac_init_help=recursive ;; - -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) - ac_init_help=short ;; - - -host | --host | --hos | --ho) - ac_prev=host_alias ;; - -host=* | --host=* | --hos=* | --ho=*) - host_alias=$ac_optarg ;; - - -includedir | --includedir | --includedi | --included | --include \ - | --includ | --inclu | --incl | --inc) - ac_prev=includedir ;; - -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ - | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir=$ac_optarg ;; - - -infodir | --infodir | --infodi | --infod | --info | --inf) - ac_prev=infodir ;; - -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir=$ac_optarg ;; - - -libdir | --libdir | --libdi | --libd) - ac_prev=libdir ;; - -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir=$ac_optarg ;; - - -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ - | --libexe | --libex | --libe) - ac_prev=libexecdir ;; - -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ - | --libexe=* | --libex=* | --libe=*) - libexecdir=$ac_optarg ;; - - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst \ - | --locals | --local | --loca | --loc | --lo) - ac_prev=localstatedir ;; - -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* \ - | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) - localstatedir=$ac_optarg ;; - - -mandir | --mandir | --mandi | --mand | --man | --ma | --m) - ac_prev=mandir ;; - -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir=$ac_optarg ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c | -n) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ - | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ - | --oldin | --oldi | --old | --ol | --o) - ac_prev=oldincludedir ;; - -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ - | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ - | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir=$ac_optarg ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix=$ac_optarg ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix=$ac_optarg ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix=$ac_optarg ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name=$ac_optarg ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ - | --sbi=* | --sb=*) - sbindir=$ac_optarg ;; - - -sharedstatedir | --sharedstatedir | --sharedstatedi \ - | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ - | --sharedst | --shareds | --shared | --share | --shar \ - | --sha | --sh) - ac_prev=sharedstatedir ;; - -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ - | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ - | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ - | --sha=* | --sh=*) - sharedstatedir=$ac_optarg ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site=$ac_optarg ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir=$ac_optarg ;; - - -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ - | --syscon | --sysco | --sysc | --sys | --sy) - ac_prev=sysconfdir ;; - -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir=$ac_optarg ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target_alias ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target_alias=$ac_optarg ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers | -V) - ac_init_version=: ;; - - -with-* | --with-*) - ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid package name: $ac_package" >&2 - { (exit 1); exit 1; }; } - ac_package=`echo $ac_package| sed 's/-/_/g'` - case $ac_option in - *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; - *) ac_optarg=yes ;; - esac - eval "with_$ac_package='$ac_optarg'" ;; - - -without-* | --without-*) - ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid package name: $ac_package" >&2 - { (exit 1); exit 1; }; } - ac_package=`echo $ac_package | sed 's/-/_/g'` - eval "with_$ac_package=no" ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes=$ac_optarg ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries=$ac_optarg ;; - - -*) { echo "$as_me: error: unrecognized option: $ac_option -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; } - ;; - - *=*) - ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` - # Reject names that are not valid shell variable names. - expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 - { (exit 1); exit 1; }; } - ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` - eval "$ac_envvar='$ac_optarg'" - export $ac_envvar ;; - - *) - # FIXME: should be removed in autoconf 3.0. - echo "$as_me: WARNING: you should use --build, --host, --target" >&2 - expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && - echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} - ;; - - esac -done - -if test -n "$ac_prev"; then - ac_option=--`echo $ac_prev | sed 's/_/-/g'` - { echo "$as_me: error: missing argument to $ac_option" >&2 - { (exit 1); exit 1; }; } -fi - -# Be sure to have absolute paths. -for ac_var in exec_prefix prefix -do - eval ac_val=$`echo $ac_var` - case $ac_val in - [\\/$]* | ?:[\\/]* | NONE | '' ) ;; - *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; };; - esac -done - -# Be sure to have absolute paths. -for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ - localstatedir libdir includedir oldincludedir infodir mandir -do - eval ac_val=$`echo $ac_var` - case $ac_val in - [\\/$]* | ?:[\\/]* ) ;; - *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; };; - esac -done - -# There might be people who depend on the old broken behavior: `$host' -# used to hold the argument of --host etc. -# FIXME: To remove some day. -build=$build_alias -host=$host_alias -target=$target_alias - -# FIXME: To remove some day. -if test "x$host_alias" != x; then - if test "x$build_alias" = x; then - cross_compiling=maybe - 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 -fi - -ac_tool_prefix= -test -n "$host_alias" && ac_tool_prefix=$host_alias- - -test "$silent" = yes && exec 6>/dev/null - - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then its parent. - ac_confdir=`(dirname "$0") 2>/dev/null || -$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$0" : 'X\(//\)[^/]' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$0" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - srcdir=$ac_confdir - if test ! -r $srcdir/$ac_unique_file; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r $srcdir/$ac_unique_file; then - if test "$ac_srcdir_defaulted" = yes; then - { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 - { (exit 1); exit 1; }; } - else - { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 - { (exit 1); exit 1; }; } - fi -fi -(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || - { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 - { (exit 1); exit 1; }; } -srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` -ac_env_build_alias_set=${build_alias+set} -ac_env_build_alias_value=$build_alias -ac_cv_env_build_alias_set=${build_alias+set} -ac_cv_env_build_alias_value=$build_alias -ac_env_host_alias_set=${host_alias+set} -ac_env_host_alias_value=$host_alias -ac_cv_env_host_alias_set=${host_alias+set} -ac_cv_env_host_alias_value=$host_alias -ac_env_target_alias_set=${target_alias+set} -ac_env_target_alias_value=$target_alias -ac_cv_env_target_alias_set=${target_alias+set} -ac_cv_env_target_alias_value=$target_alias -ac_env_CC_set=${CC+set} -ac_env_CC_value=$CC -ac_cv_env_CC_set=${CC+set} -ac_cv_env_CC_value=$CC -ac_env_CFLAGS_set=${CFLAGS+set} -ac_env_CFLAGS_value=$CFLAGS -ac_cv_env_CFLAGS_set=${CFLAGS+set} -ac_cv_env_CFLAGS_value=$CFLAGS -ac_env_LDFLAGS_set=${LDFLAGS+set} -ac_env_LDFLAGS_value=$LDFLAGS -ac_cv_env_LDFLAGS_set=${LDFLAGS+set} -ac_cv_env_LDFLAGS_value=$LDFLAGS -ac_env_CPPFLAGS_set=${CPPFLAGS+set} -ac_env_CPPFLAGS_value=$CPPFLAGS -ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} -ac_cv_env_CPPFLAGS_value=$CPPFLAGS -ac_env_CCAS_set=${CCAS+set} -ac_env_CCAS_value=$CCAS -ac_cv_env_CCAS_set=${CCAS+set} -ac_cv_env_CCAS_value=$CCAS -ac_env_CCASFLAGS_set=${CCASFLAGS+set} -ac_env_CCASFLAGS_value=$CCASFLAGS -ac_cv_env_CCASFLAGS_set=${CCASFLAGS+set} -ac_cv_env_CCASFLAGS_value=$CCASFLAGS -ac_env_CPP_set=${CPP+set} -ac_env_CPP_value=$CPP -ac_cv_env_CPP_set=${CPP+set} -ac_cv_env_CPP_value=$CPP -ac_env_CXX_set=${CXX+set} -ac_env_CXX_value=$CXX -ac_cv_env_CXX_set=${CXX+set} -ac_cv_env_CXX_value=$CXX -ac_env_CXXFLAGS_set=${CXXFLAGS+set} -ac_env_CXXFLAGS_value=$CXXFLAGS -ac_cv_env_CXXFLAGS_set=${CXXFLAGS+set} -ac_cv_env_CXXFLAGS_value=$CXXFLAGS -ac_env_CXXCPP_set=${CXXCPP+set} -ac_env_CXXCPP_value=$CXXCPP -ac_cv_env_CXXCPP_set=${CXXCPP+set} -ac_cv_env_CXXCPP_value=$CXXCPP -ac_env_F77_set=${F77+set} -ac_env_F77_value=$F77 -ac_cv_env_F77_set=${F77+set} -ac_cv_env_F77_value=$F77 -ac_env_FFLAGS_set=${FFLAGS+set} -ac_env_FFLAGS_value=$FFLAGS -ac_cv_env_FFLAGS_set=${FFLAGS+set} -ac_cv_env_FFLAGS_value=$FFLAGS - -# -# Report the --help message. -# -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 MPEG Audio Decoder 0.15.1b to adapt to many kinds of systems. - -Usage: $0 [OPTION]... [VAR=VALUE]... - -To assign environment variables (e.g., CC, CFLAGS...), specify them as -VAR=VALUE. See below for descriptions of some of the useful variables. - -Defaults for the options are specified in brackets. - -Configuration: - -h, --help display this help and exit - --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 - --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 - --srcdir=DIR find the sources in DIR [configure dir or \`..'] - -_ACEOF - - cat <<_ACEOF -Installation directories: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [PREFIX] - -By default, \`make install' will install all the files in -\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify -an installation prefix other than \`$ac_default_prefix' using \`--prefix', -for instance \`--prefix=\$HOME'. - -For better control, use the options below. - -Fine tuning of the installation directories: - --bindir=DIR user executables [EPREFIX/bin] - --sbindir=DIR system admin executables [EPREFIX/sbin] - --libexecdir=DIR program executables [EPREFIX/libexec] - --datadir=DIR read-only architecture-independent data [PREFIX/share] - --sysconfdir=DIR read-only single-machine data [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] - --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --libdir=DIR object code libraries [EPREFIX/lib] - --includedir=DIR C header files [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc [/usr/include] - --infodir=DIR info documentation [PREFIX/info] - --mandir=DIR man documentation [PREFIX/man] -_ACEOF - - cat <<\_ACEOF - -Program names: - --program-prefix=PREFIX prepend PREFIX to installed program names - --program-suffix=SUFFIX append SUFFIX to installed program names - --program-transform-name=PROGRAM run sed PROGRAM on installed program names - -System types: - --build=BUILD configure for building on BUILD [guessed] - --host=HOST cross-compile to build programs to run on HOST [BUILD] -_ACEOF -fi - -if test -n "$ac_init_help"; then - case $ac_init_help in - short | recursive ) echo "Configuration of MPEG Audio Decoder 0.15.1b:";; - esac - cat <<\_ACEOF - -Optional Features: - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --disable-dependency-tracking speeds up one-time build - --enable-dependency-tracking do not reject slow dependency extractors - --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-speed optimize for speed over accuracy - --enable-accuracy optimize for accuracy over speed - --enable-fpm=ARCH use ARCH-specific fixed-point math routines (one of: - intel, arm, mips, sparc, ppc, 64bit, default) - --enable-sso use subband synthesis optimization - --disable-aso disable architecture-specific optimizations - --enable-strict-iso use strict ISO/IEC interpretations - --enable-profiling generate profiling code - --enable-debugging enable diagnostic debugging support - --disable-debugging do not enable debugging and use more optimization - --enable-experimental enable experimental code - -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 - both] - --with-tags[=TAGS] - include additional configurations [automatic] - -Some influential environment variables: - CC C compiler command - CFLAGS C compiler flags - LDFLAGS linker flags, e.g. -L if you have libraries in a - nonstandard directory - CPPFLAGS 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 - CXX C++ compiler command - CXXFLAGS C++ compiler flags - CXXCPP C++ preprocessor - F77 Fortran 77 compiler command - FFLAGS Fortran 77 compiler flags - -Use these variables to override the choices made by `configure' or to help -it to find libraries and programs with nonstandard names/locations. - -Report bugs to . -_ACEOF -fi - -if test "$ac_init_help" = "recursive"; then - # If there are subdirs, report their specific --help. - ac_popdir=`pwd` - for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d $ac_dir || continue - ac_builddir=. - -if test "$ac_dir" != .; then - ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A "../" for each directory in $ac_dir_suffix. - ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` -else - ac_dir_suffix= ac_top_builddir= -fi - -case $srcdir in - .) # No --srcdir option. We are building in place. - ac_srcdir=. - if test -z "$ac_top_builddir"; then - ac_top_srcdir=. - else - ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` - fi ;; - [\\/]* | ?:[\\/]* ) # Absolute path. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir ;; - *) # Relative path. - ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_builddir$srcdir ;; -esac - -# Do not use `cd foo && pwd` to compute absolute paths, because -# the directories may not exist. -case `pwd` in -.) ac_abs_builddir="$ac_dir";; -*) - case "$ac_dir" in - .) ac_abs_builddir=`pwd`;; - [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; - *) ac_abs_builddir=`pwd`/"$ac_dir";; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_builddir=${ac_top_builddir}.;; -*) - case ${ac_top_builddir}. in - .) ac_abs_top_builddir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; - *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_srcdir=$ac_srcdir;; -*) - case $ac_srcdir in - .) ac_abs_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; - *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_srcdir=$ac_top_srcdir;; -*) - case $ac_top_srcdir in - .) ac_abs_top_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; - *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; - esac;; -esac - - cd $ac_dir - # Check for guested configure; otherwise get Cygnus style configure. - if test -f $ac_srcdir/configure.gnu; then - echo - $SHELL $ac_srcdir/configure.gnu --help=recursive - elif test -f $ac_srcdir/configure; then - echo - $SHELL $ac_srcdir/configure --help=recursive - elif test -f $ac_srcdir/configure.ac || - test -f $ac_srcdir/configure.in; then - echo - $ac_configure --help - else - echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 - fi - cd "$ac_popdir" - done -fi - -test -n "$ac_init_help" && exit 0 -if $ac_init_version; then - cat <<\_ACEOF -MPEG Audio Decoder configure 0.15.1b -generated by GNU Autoconf 2.59 - -Copyright (C) 2003 Free Software Foundation, Inc. -This configure script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it. -_ACEOF - exit 0 -fi -exec 5>config.log -cat >&5 <<_ACEOF -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. - -It was created by MPEG Audio Decoder $as_me 0.15.1b, which was -generated by GNU Autoconf 2.59. Invocation command line was - - $ $0 $@ - -_ACEOF -{ -cat <<_ASUNAME -## --------- ## -## Platform. ## -## --------- ## - -hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` - -/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` -hostinfo = `(hostinfo) 2>/dev/null || echo unknown` -/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` -/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` - -_ASUNAME - -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - echo "PATH: $as_dir" -done - -} >&5 - -cat >&5 <<_ACEOF - - -## ----------- ## -## Core tests. ## -## ----------- ## - -_ACEOF - - -# Keep a trace of the command line. -# Strip out --no-create and --no-recursion so they do not pile up. -# Strip out --silent because we don't want to record it for future runs. -# Also quote any args containing shell meta-characters. -# Make two passes to allow for proper duplicate-argument suppression. -ac_configure_args= -ac_configure_args0= -ac_configure_args1= -ac_sep= -ac_must_keep_next=false -for ac_pass in 1 2 -do - for ac_arg - do - case $ac_arg in - -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - continue ;; - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) - ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - case $ac_pass in - 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; - 2) - ac_configure_args1="$ac_configure_args1 '$ac_arg'" - if test $ac_must_keep_next = true; then - ac_must_keep_next=false # Got value, back to normal. - else - case $ac_arg in - *=* | --config-cache | -C | -disable-* | --disable-* \ - | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ - | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ - | -with-* | --with-* | -without-* | --without-* | --x) - case "$ac_configure_args0 " in - "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; - esac - ;; - -* ) ac_must_keep_next=true ;; - esac - fi - ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" - # Get rid of the leading space. - ac_sep=" " - ;; - esac - done -done -$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } -$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } - -# When interrupted or exit'd, cleanup temporary files, and complete -# config.log. We remove comments because anyway the quotes in there -# would cause problems or look ugly. -# WARNING: Be sure not to use single quotes in there, as some shells, -# such as our DU 5.0 friend, will then `close' the trap. -trap 'exit_status=$? - # Save into config.log some information that might help in debugging. - { - echo - - cat <<\_ASBOX -## ---------------- ## -## Cache variables. ## -## ---------------- ## -_ASBOX - echo - # The following way of writing the cache mishandles newlines in values, -{ - (set) 2>&1 | - case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in - *ac_space=\ *) - sed -n \ - "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" - ;; - *) - sed -n \ - "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" - ;; - esac; -} - echo - - cat <<\_ASBOX -## ----------------- ## -## Output variables. ## -## ----------------- ## -_ASBOX - echo - for ac_var in $ac_subst_vars - do - eval ac_val=$`echo $ac_var` - echo "$ac_var='"'"'$ac_val'"'"'" - done | sort - echo - - if test -n "$ac_subst_files"; then - cat <<\_ASBOX -## ------------- ## -## Output files. ## -## ------------- ## -_ASBOX - echo - for ac_var in $ac_subst_files - do - eval ac_val=$`echo $ac_var` - echo "$ac_var='"'"'$ac_val'"'"'" - done | sort - echo - fi - - if test -s confdefs.h; then - cat <<\_ASBOX -## ----------- ## -## confdefs.h. ## -## ----------- ## -_ASBOX - echo - sed "/^$/d" confdefs.h | sort - echo - fi - test "$ac_signal" != 0 && - echo "$as_me: caught signal $ac_signal" - echo "$as_me: exit $exit_status" - } >&5 - rm -f core *.core && - rm -rf conftest* confdefs* conf$$* $ac_clean_files && - exit $exit_status - ' 0 -for ac_signal in 1 2 13 15; do - trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal -done -ac_signal=0 - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -rf conftest* confdefs.h -# AIX cpp loses on an empty file, so make sure it contains at least a newline. -echo >confdefs.h - -# Predefined preprocessor variables. - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_NAME "$PACKAGE_NAME" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_TARNAME "$PACKAGE_TARNAME" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_VERSION "$PACKAGE_VERSION" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_STRING "$PACKAGE_STRING" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" -_ACEOF - - -# Let the site file select an alternate cache file if it wants to. -# Prefer explicitly selected file to automatically selected ones. -if test -z "$CONFIG_SITE"; then - if test "x$prefix" != xNONE; then - CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" - else - CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" - fi -fi -for ac_site_file in $CONFIG_SITE; do - if test -r "$ac_site_file"; then - { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 -echo "$as_me: loading site script $ac_site_file" >&6;} - sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" - fi -done - -if test -r "$cache_file"; then - # Some versions of bash will fail to source /dev/null (special - # files actually), so we avoid doing that. - if test -f "$cache_file"; then - { echo "$as_me:$LINENO: loading cache $cache_file" >&5 -echo "$as_me: loading cache $cache_file" >&6;} - case $cache_file in - [\\/]* | ?:[\\/]* ) . $cache_file;; - *) . ./$cache_file;; - esac - fi -else - { echo "$as_me:$LINENO: creating cache $cache_file" >&5 -echo "$as_me: creating cache $cache_file" >&6;} - >$cache_file -fi - -# Check that the precious variables saved in the cache have kept the same -# value. -ac_cache_corrupted=false -for ac_var in `(set) 2>&1 | - sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do - eval ac_old_set=\$ac_cv_env_${ac_var}_set - eval ac_new_set=\$ac_env_${ac_var}_set - eval ac_old_val="\$ac_cv_env_${ac_var}_value" - eval ac_new_val="\$ac_env_${ac_var}_value" - case $ac_old_set,$ac_new_set in - set,) - { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 -echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,set) - { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 -echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,);; - *) - if test "x$ac_old_val" != "x$ac_new_val"; then - { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 -echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} - { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 -echo "$as_me: former value: $ac_old_val" >&2;} - { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 -echo "$as_me: current value: $ac_new_val" >&2;} - ac_cache_corrupted=: - fi;; - esac - # Pass precious variables to config.status. - if test "$ac_new_set" = set; then - case $ac_new_val in - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) - ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; - *) ac_arg=$ac_var=$ac_new_val ;; - esac - case " $ac_configure_args " in - *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. - *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; - esac - fi -done -if $ac_cache_corrupted; then - { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 -echo "$as_me: error: changes in the environment can compromise the build" >&2;} - { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 -echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} - { (exit 1); exit 1; }; } -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 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -am__api_version="1.8" -ac_aux_dir= -for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do - 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 - { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 -echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} - { (exit 1); exit 1; }; } -fi -ac_config_guess="$SHELL $ac_aux_dir/config.guess" -ac_config_sub="$SHELL $ac_aux_dir/config.sub" -ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. - -# Find a good install program. We prefer a C program (faster), -# so one script is as good as another. But avoid the broken or -# incompatible versions: -# SysV /etc/install, /usr/sbin/install -# SunOS /usr/etc/install -# IRIX /sbin/install -# AIX /bin/install -# AmigaOS /C/install, which installs bootblocks on floppy discs -# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag -# AFS /usr/afsws/bin/install, which mishandles nonexistent args -# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" -# OS/2's system install, which has a completely different semantic -# ./install, which can be erroneously created by make from ./install.sh. -echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 -echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 -if test -z "$INSTALL"; then -if test "${ac_cv_path_install+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - # Account for people who put trailing slashes in PATH elements. -case $as_dir/ in - ./ | .// | /cC/* | \ - /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ - ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ - /usr/ucb/* ) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - # Don't use installbsd from OSF since it installs stuff as root - # by default. - for ac_prog in ginstall scoinst install; do - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_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. - : - elif test $ac_prog = install && - grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # program-specific install script used by HP pwplus--don't use. - : - else - ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" - break 3 - fi - fi - done - done - ;; -esac -done - - -fi - if test "${ac_cv_path_install+set}" = set; then - INSTALL=$ac_cv_path_install - else - # As a last resort, use the slow shell script. We don't cache a - # path for INSTALL within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the path is relative. - INSTALL=$ac_install_sh - fi -fi -echo "$as_me:$LINENO: result: $INSTALL" >&5 -echo "${ECHO_T}$INSTALL" >&6 - -# Use test -z because SunOS4 sh mishandles braces in ${var-val}. -# It thinks the first close brace ends the variable substitution. -test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' - -test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' - -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' - -echo "$as_me:$LINENO: checking whether build environment is sane" >&5 -echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6 -# Just in case -sleep 1 -echo timestamp > conftest.file -# 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". - { { echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken -alias in your environment" >&5 -echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken -alias in your environment" >&2;} - { (exit 1); exit 1; }; } - fi - - test "$2" = conftest.file - ) -then - # Ok. - : -else - { { echo "$as_me:$LINENO: error: newly created file is older than distributed files! -Check your system clock" >&5 -echo "$as_me: error: newly created file is older than distributed files! -Check your system clock" >&2;} - { (exit 1); exit 1; }; } -fi -echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 -test "$program_prefix" != NONE && - program_transform_name="s,^,$program_prefix,;$program_transform_name" -# Use a double $ so make ignores it. -test "$program_suffix" != NONE && - program_transform_name="s,\$,$program_suffix,;$program_transform_name" -# Double any \ or $. echo might interpret backslashes. -# By default was `s,x,x', remove it if useless. -cat <<\_ACEOF >conftest.sed -s/[\\$]/&&/g;s/;s,x,x,$// -_ACEOF -program_transform_name=`echo $program_transform_name | sed -f conftest.sed` -rm conftest.sed - -# expand $ac_aux_dir to an absolute path -am_aux_dir=`cd $ac_aux_dir && pwd` - -test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" -# Use eval to expand $SHELL -if eval "$MISSING --run true"; then - am_missing_run="$MISSING --run " -else - am_missing_run= - { echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5 -echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} -fi - -if mkdir -p -- . 2>/dev/null; then - # Keeping the `.' argument allows $(mkdir_p) to be used without - # argument. Indeed, we sometimes output rules like - # $(mkdir_p) $(somedir) - # where $(somedir) is conditionally defined. - # (`test -n '$(somedir)' && $(mkdir_p) $(somedir)' is a more - # expensive solution, as it forces Make to start a sub-shell.) - mkdir_p='mkdir -p -- .' -else - # On NextStep and OpenStep, the `mkdir' command does not - # recognize any option. It will interpret all options as - # directories to create, and then abort because `.' already - # exists. - for d in ./-p ./--; - do - test -d $d && rmdir $d - done - # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. - if test -f "$ac_aux_dir/mkinstalldirs"; then - mkdir_p='$(mkinstalldirs)' - else - mkdir_p='$(install_sh) -d' - fi -fi - -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 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_AWK+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - 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 -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_AWK="$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -AWK=$ac_cv_prog_AWK -if test -n "$AWK"; then - echo "$as_me:$LINENO: result: $AWK" >&5 -echo "${ECHO_T}$AWK" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - test -n "$AWK" && break -done - -echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 -echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6 -set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'` -if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.make <<\_ACEOF -all: - @echo 'ac_maketemp="$(MAKE)"' -_ACEOF -# GNU make sometimes prints "make[1]: Entering...", which would confuse us. -eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=` -if test -n "$ac_maketemp"; then - eval ac_cv_prog_make_${ac_make}_set=yes -else - eval ac_cv_prog_make_${ac_make}_set=no -fi -rm -f conftest.make -fi -if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 - SET_MAKE= -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 - SET_MAKE="MAKE=${MAKE-make}" -fi - -rm -rf .tst 2>/dev/null -mkdir .tst 2>/dev/null -if test -d .tst; then - am__leading_dot=. -else - am__leading_dot=_ -fi -rmdir .tst 2>/dev/null - -# test to see if srcdir already configured -if test "`cd $srcdir && pwd`" != "`pwd`" && - test -f $srcdir/config.status; then - { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 -echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} - { (exit 1); exit 1; }; } -fi - -# test whether we have cygpath -if test -z "$CYGPATH_W"; then - if (cygpath --version) >/dev/null 2>/dev/null; then - CYGPATH_W='cygpath -w' - else - CYGPATH_W=echo - fi -fi - - -# Define the identity of the package. - PACKAGE='libmad' - VERSION='0.15.1b' - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE "$PACKAGE" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define VERSION "$VERSION" -_ACEOF - -# Some tools Automake needs. - -ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} - - -AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} - - -AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} - - -AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} - - -MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} - - -AMTAR=${AMTAR-"${am_missing_run}tar"} - -install_sh=${install_sh-"$am_aux_dir/install-sh"} - -# 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. -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 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_STRIP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$STRIP"; then - ac_cv_prog_STRIP="$STRIP" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_STRIP="${ac_tool_prefix}strip" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -STRIP=$ac_cv_prog_STRIP -if test -n "$STRIP"; then - echo "$as_me:$LINENO: result: $STRIP" >&5 -echo "${ECHO_T}$STRIP" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -fi -if test -z "$ac_cv_prog_STRIP"; then - ac_ct_STRIP=$STRIP - # Extract the first word of "strip", so it can be a program name with args. -set dummy strip; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_STRIP"; then - ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_STRIP="strip" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - - test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":" -fi -fi -ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP -if test -n "$ac_ct_STRIP"; then - echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 -echo "${ECHO_T}$ac_ct_STRIP" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - STRIP=$ac_ct_STRIP -else - STRIP="$ac_cv_prog_STRIP" -fi - -fi -INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" - -# We need awk for the "check" target. The system "awk" is bad on -# some platforms. - - - - - ac_config_headers="$ac_config_headers config.h" - - - -# Make sure we can run config.sub. -$ac_config_sub sun4 >/dev/null 2>&1 || - { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5 -echo "$as_me: error: cannot run $ac_config_sub" >&2;} - { (exit 1); exit 1; }; } - -echo "$as_me:$LINENO: checking build system type" >&5 -echo $ECHO_N "checking build system type... $ECHO_C" >&6 -if test "${ac_cv_build+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_cv_build_alias=$build_alias -test -z "$ac_cv_build_alias" && - ac_cv_build_alias=`$ac_config_guess` -test -z "$ac_cv_build_alias" && - { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 -echo "$as_me: error: cannot guess build type; you must specify one" >&2;} - { (exit 1); exit 1; }; } -ac_cv_build=`$ac_config_sub $ac_cv_build_alias` || - { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5 -echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;} - { (exit 1); exit 1; }; } - -fi -echo "$as_me:$LINENO: result: $ac_cv_build" >&5 -echo "${ECHO_T}$ac_cv_build" >&6 -build=$ac_cv_build -build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` - - -echo "$as_me:$LINENO: checking host system type" >&5 -echo $ECHO_N "checking host system type... $ECHO_C" >&6 -if test "${ac_cv_host+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_cv_host_alias=$host_alias -test -z "$ac_cv_host_alias" && - ac_cv_host_alias=$ac_cv_build_alias -ac_cv_host=`$ac_config_sub $ac_cv_host_alias` || - { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5 -echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;} - { (exit 1); exit 1; }; } - -fi -echo "$as_me:$LINENO: result: $ac_cv_host" >&5 -echo "${ECHO_T}$ac_cv_host" >&6 -host=$ac_cv_host -host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` - - - - -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 -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="gcc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - CC=$ac_ct_CC -else - CC="$ac_cv_prog_CC" -fi - -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="cc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - CC=$ac_ct_CC -else - CC="$ac_cv_prog_CC" -fi - -fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - ac_prog_rejected=no -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_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 - fi - ac_cv_prog_CC="cc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# != 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" - fi -fi -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - for ac_prog in cl - 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 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - test -n "$CC" && break - done -fi -if test -z "$CC"; then - ac_ct_CC=$CC - for ac_prog in cl -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - test -n "$ac_ct_CC" && break -done - - CC=$ac_ct_CC -fi - -fi - - -test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&5 -echo "$as_me: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } - -# Provide some information about the compiler. -echo "$as_me:$LINENO:" \ - "checking for C compiler version" >&5 -ac_compiler=`set X $ac_compile; echo $2` -{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 - (eval $ac_compiler --version &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 - (eval $ac_compiler -v &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 - (eval $ac_compiler -V &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } - -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.exe b.out" -# Try to create an executable without -o first, disregard a.out. -# It will help us diagnose broken compilers, and finding out an intuition -# of exeext. -echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 -echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6 -ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` -if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 - (eval $ac_link_default) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - # Find the output, starting from the most likely. This scheme is -# not robust to junk in `.', hence go to wildcards (a.*) only as a last -# resort. - -# Be careful to initialize this variable, since it used to be cached. -# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. -ac_cv_exeext= -# b.out is created by i960 compilers. -for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out -do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) - ;; - conftest.$ac_ext ) - # This is the source file. - ;; - [ab].out ) - # We found the default executable, but exeext='' is most - # certainly right. - break;; - *.* ) - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - # FIXME: I believe we export ac_cv_exeext for Libtool, - # but it would be cool to find out if it's true. Does anybody - # maintain Libtool? --akim. - export ac_cv_exeext - break;; - * ) - break;; - esac -done -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { echo "$as_me:$LINENO: error: C compiler cannot create executables -See \`config.log' for more details." >&5 -echo "$as_me: error: C compiler cannot create executables -See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } -fi - -ac_exeext=$ac_cv_exeext -echo "$as_me:$LINENO: result: $ac_file" >&5 -echo "${ECHO_T}$ac_file" >&6 - -# Check the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -echo "$as_me:$LINENO: checking whether the C compiler works" >&5 -echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 -# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 -# If not cross compiling, check that we can run a simple program. -if test "$cross_compiling" != yes; then - if { ac_try='./$ac_file' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { echo "$as_me:$LINENO: error: cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } - fi - fi -fi -echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 - -rm -f a.out a.exe conftest$ac_cv_exeext b.out -ac_clean_files=$ac_clean_files_save -# Check the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 -echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 -echo "$as_me:$LINENO: result: $cross_compiling" >&5 -echo "${ECHO_T}$cross_compiling" >&6 - -echo "$as_me:$LINENO: checking for suffix of executables" >&5 -echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - # If both `conftest.exe' and `conftest' are `present' (well, observable) -# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will -# work properly (i.e., refer to `conftest.exe'), while it won't with -# `rm'. -for ac_file in conftest.exe conftest conftest.*; do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; - *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - export ac_cv_exeext - break;; - * ) break;; - esac -done -else - { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi - -rm -f conftest$ac_cv_exeext -echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 -echo "${ECHO_T}$ac_cv_exeext" >&6 - -rm -f conftest.$ac_ext -EXEEXT=$ac_cv_exeext -ac_exeext=$EXEEXT -echo "$as_me:$LINENO: checking for suffix of object files" >&5 -echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 -if test "${ac_cv_objext+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.o conftest.obj -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; - *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` - break;; - esac -done -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi - -rm -f conftest.$ac_cv_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 -echo "${ECHO_T}$ac_cv_objext" >&6 -OBJEXT=$ac_cv_objext -ac_objext=$OBJEXT -echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 -echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 -if test "${ac_cv_c_compiler_gnu+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_compiler_gnu=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_compiler_gnu=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_c_compiler_gnu=$ac_compiler_gnu - -fi -echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 -echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 -GCC=`test $ac_compiler_gnu = yes && echo yes` -ac_test_CFLAGS=${CFLAGS+set} -ac_save_CFLAGS=$CFLAGS -CFLAGS="-g" -echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 -echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 -if test "${ac_cv_prog_cc_g+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_prog_cc_g=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_prog_cc_g=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 -echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 -if test "$ac_test_CFLAGS" = set; then - CFLAGS=$ac_save_CFLAGS -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi -echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 -echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 -if test "${ac_cv_prog_cc_stdc+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_cv_prog_cc_stdc=no -ac_save_CC=$CC -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include -#include -#include -/* 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); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} - -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not '\xHH' hex character constants. - These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std1 is added to get - proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an - array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std1. */ -int osf4_cc_array ['\x00' == 0 ? 1 : -1]; - -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} -_ACEOF -# Don't try gcc -ansi; that turns off useful extensions and -# breaks some systems' header files. -# AIX -qlanglvl=ansi -# Ultrix and OSF/1 -std1 -# HP-UX 10.20 and later -Ae -# HP-UX older versions -Aa -D_HPUX_SOURCE -# SVR4 -Xc -D__EXTENSIONS__ -for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_prog_cc_stdc=$ac_arg -break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext -done -rm -f conftest.$ac_ext conftest.$ac_objext -CC=$ac_save_CC - -fi - -case "x$ac_cv_prog_cc_stdc" in - x|xno) - echo "$as_me:$LINENO: result: none needed" >&5 -echo "${ECHO_T}none needed" >&6 ;; - *) - echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 -echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 - CC="$CC $ac_cv_prog_cc_stdc" ;; -esac - -# Some people use a C++ compiler to compile C. Since we use `exit', -# in C++ we need to declare it. In case someone uses the same compiler -# for both compiling C and C++ we need to have the C++ compiler decide -# the declaration of exit, since it's the most demanding environment. -cat >conftest.$ac_ext <<_ACEOF -#ifndef __cplusplus - choke me -#endif -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - for ac_declaration in \ - '' \ - 'extern "C" void std::exit (int) throw (); using std::exit;' \ - 'extern "C" void std::exit (int); using std::exit;' \ - 'extern "C" void exit (int) throw ();' \ - 'extern "C" void exit (int);' \ - 'void exit (int);' -do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_declaration -#include -int -main () -{ -exit (42); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -continue -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_declaration -int -main () -{ -exit (42); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -done -rm -f conftest* -if test -n "$ac_declaration"; then - echo '#ifdef __cplusplus' >>confdefs.h - echo $ac_declaration >>confdefs.h - echo '#endif' >>confdefs.h -fi - -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -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' -am__doit: - @echo done -.PHONY: am__doit -END -# If we don't find an include directive, just comment out the code. -echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5 -echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6 -am__include="#" -am__quote= -_am_result=none -# First try GNU make style include. -echo "include confinc" > confmf -# We grep out `Entering directory' and `Leaving directory' -# messages which can occur if `w' ends up in MAKEFLAGS. -# In particular we don't look at `^make:' because GNU make might -# be invoked under some other name (usually "gmake"), in which -# case it prints its new name instead of `make'. -if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then - am__include=include - am__quote= - _am_result=GNU -fi -# Now try BSD make style include. -if test "$am__include" = "#"; then - echo '.include "confinc"' > confmf - if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then - am__include=.include - am__quote="\"" - _am_result=BSD - fi -fi - - -echo "$as_me:$LINENO: result: $_am_result" >&5 -echo "${ECHO_T}$_am_result" >&6 -rm -f confinc confmf - -# Check whether --enable-dependency-tracking or --disable-dependency-tracking was given. -if test "${enable_dependency_tracking+set}" = set; then - enableval="$enable_dependency_tracking" - -fi; -if test "x$enable_dependency_tracking" != xno; then - am_depcomp="$ac_aux_dir/depcomp" - AMDEPBACKSLASH='\' -fi - - -if test "x$enable_dependency_tracking" != xno; then - AMDEP_TRUE= - AMDEP_FALSE='#' -else - AMDEP_TRUE='#' - AMDEP_FALSE= -fi - - - - -depcc="$CC" am_compiler_list= - -echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 -echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6 -if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&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'. - 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_CC_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` - fi - 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 - : > sub/conftst$i.h - done - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - - case $depmode in - 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 - ;; - none) break ;; - esac - # 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. - if depmode=$depmode \ - source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ - $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ - >/dev/null 2>conftest.err && - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftest.${OBJEXT-o} 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 - # (even with -Werror). So we grep stderr for any message - # that says an option was ignored. - if grep 'ignoring option' conftest.err >/dev/null 2>&1; then :; else - am_cv_CC_dependencies_compiler_type=$depmode - break - fi - fi - done - - cd .. - rm -rf conftest.dir -else - am_cv_CC_dependencies_compiler_type=none -fi - -fi -echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 -echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6 -CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type - - - -if - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then - am__fastdepCC_TRUE= - am__fastdepCC_FALSE='#' -else - am__fastdepCC_TRUE='#' - am__fastdepCC_FALSE= -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 - - - - -if test "$GCC" = yes -then - case "$host" in - *-*-mingw*) - case "$build" in - *-*-cygwin*) - CPPFLAGS="$CPPFLAGS -mno-cygwin" - LDFLAGS="$LDFLAGS -mno-cygwin" - ;; - esac - esac - -fi - - -# Check whether --enable-shared or --disable-shared was given. -if test "${enable_shared+set}" = set; then - enableval="$enable_shared" - 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 -else - enable_shared=yes -fi; - -# Check whether --enable-static or --disable-static was given. -if test "${enable_static+set}" = set; then - enableval="$enable_static" - 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 -else - enable_static=yes -fi; - -# Check whether --enable-fast-install or --disable-fast-install was given. -if test "${enable_fast_install+set}" = set; then - enableval="$enable_fast_install" - 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 -else - enable_fast_install=yes -fi; - -echo "$as_me:$LINENO: checking for a sed that does not truncate output" >&5 -echo $ECHO_N "checking for a sed that does not truncate output... $ECHO_C" >&6 -if test "${lt_cv_path_SED+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - # 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 -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 && break - 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 - -fi - -echo "$as_me:$LINENO: result: $SED" >&5 -echo "${ECHO_T}$SED" >&6 - -echo "$as_me:$LINENO: checking for egrep" >&5 -echo $ECHO_N "checking for egrep... $ECHO_C" >&6 -if test "${ac_cv_prog_egrep+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if echo a | (grep -E '(a|b)') >/dev/null 2>&1 - then ac_cv_prog_egrep='grep -E' - else ac_cv_prog_egrep='egrep' - fi -fi -echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5 -echo "${ECHO_T}$ac_cv_prog_egrep" >&6 - EGREP=$ac_cv_prog_egrep - - - -# Check whether --with-gnu-ld or --without-gnu-ld was given. -if test "${with_gnu_ld+set}" = set; then - withval="$with_gnu_ld" - test "$withval" = no || with_gnu_ld=yes -else - with_gnu_ld=no -fi; -ac_prog=ld -if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - echo "$as_me:$LINENO: checking for ld used by $CC" >&5 -echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6 - 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 - echo "$as_me:$LINENO: checking for GNU ld" >&5 -echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6 -else - echo "$as_me:$LINENO: checking for non-GNU ld" >&5 -echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6 -fi -if test "${lt_cv_path_LD+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - 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 GNU ld's 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 -echo "${ECHO_T}$LD" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi -test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5 -echo "$as_me: error: no acceptable ld found in \$PATH" >&2;} - { (exit 1); exit 1; }; } -echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5 -echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6 -if test "${lt_cv_prog_gnu_ld+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - # I'd rather use --version here, but apparently some GNU ld's only accept -v. -case `$LD -v 2>&1 &5 -echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6 -with_gnu_ld=$lt_cv_prog_gnu_ld - - -echo "$as_me:$LINENO: checking for $LD option to reload object files" >&5 -echo $ECHO_N "checking for $LD option to reload object files... $ECHO_C" >&6 -if test "${lt_cv_ld_reload_flag+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - lt_cv_ld_reload_flag='-r' -fi -echo "$as_me:$LINENO: result: $lt_cv_ld_reload_flag" >&5 -echo "${ECHO_T}$lt_cv_ld_reload_flag" >&6 -reload_flag=$lt_cv_ld_reload_flag -case $reload_flag in -"" | " "*) ;; -*) reload_flag=" $reload_flag" ;; -esac -reload_cmds='$LD$reload_flag -o $output$reload_objs' - -echo "$as_me:$LINENO: checking for BSD-compatible nm" >&5 -echo $ECHO_N "checking for BSD-compatible nm... $ECHO_C" >&6 -if test "${lt_cv_path_NM+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$NM"; then - # Let the user override the test. - lt_cv_path_NM="$NM" -else - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - tmp_nm="$ac_dir/${ac_tool_prefix}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" - test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm -fi -fi -echo "$as_me:$LINENO: result: $lt_cv_path_NM" >&5 -echo "${ECHO_T}$lt_cv_path_NM" >&6 -NM="$lt_cv_path_NM" - -echo "$as_me:$LINENO: checking whether ln -s works" >&5 -echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6 -LN_S=$as_ln_s -if test "$LN_S" = "ln -s"; then - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 -else - echo "$as_me:$LINENO: result: no, using $LN_S" >&5 -echo "${ECHO_T}no, using $LN_S" >&6 -fi - -echo "$as_me:$LINENO: checking how to recognise dependent libraries" >&5 -echo $ECHO_N "checking how to recognise dependent libraries... $ECHO_C" >&6 -if test "${lt_cv_deplibs_check_method+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - lt_cv_file_magic_cmd='$MAGIC_CMD' -lt_cv_file_magic_test_file= -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. -# '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. - -case $host_os in -aix4* | aix5*) - lt_cv_deplibs_check_method=pass_all - ;; - -beos*) - lt_cv_deplibs_check_method=pass_all - ;; - -bsdi4*) - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' - lt_cv_file_magic_cmd='/usr/bin/file -L' - lt_cv_file_magic_test_file=/shlib/libc.so - ;; - -cygwin*) - # win32_libid is a shell function defined in ltmain.sh - lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' - lt_cv_file_magic_cmd='win32_libid' - ;; - -mingw* | pw32*) - # Base MSYS/MinGW do not provide the 'file' command needed by - # win32_libid shell function, so use a weaker test based on 'objdump'. - lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' - lt_cv_file_magic_cmd='$OBJDUMP -f' - ;; - -darwin* | rhapsody*) - lt_cv_deplibs_check_method=pass_all - ;; - -freebsd* | kfreebsd*-gnu) - 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)/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 - ;; - -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*) - lt_cv_deplibs_check_method=pass_all - ;; - -netbsd* | knetbsd*-gnu) - 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=unknown - ;; - -openbsd*) - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB shared object' - else - lt_cv_deplibs_check_method='file_magic OpenBSD.* shared library' - fi - ;; - -osf3* | osf4* | osf5*) - lt_cv_deplibs_check_method=pass_all - ;; - -sco3.2v5*) - lt_cv_deplibs_check_method=pass_all - ;; - -solaris*) - lt_cv_deplibs_check_method=pass_all - ;; - -sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - 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 - ;; - esac - ;; - -sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7* | sysv4*uw2*) - lt_cv_deplibs_check_method=pass_all - ;; -esac - -fi -echo "$as_me:$LINENO: result: $lt_cv_deplibs_check_method" >&5 -echo "${ECHO_T}$lt_cv_deplibs_check_method" >&6 -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 - - - - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# Allow CC to be a program name with arguments. -compiler=$CC - - -# Check whether --enable-libtool-lock or --disable-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 - -# 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 { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; 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 3683 "configure"' > conftest.$ac_ext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; 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-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - case "`/usr/bin/file conftest.o`" in - *32-bit*) - case $host in - 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-*linux*) - LD="${LD-ld} -m elf_x86_64" - ;; - ppc*-*linux*|powerpc*-*linux*) - LD="${LD-ld} -m elf64ppc" - ;; - s390*-*linux*) - 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" - echo "$as_me:$LINENO: checking whether the C compiler needs -belf" >&5 -echo $ECHO_N "checking whether the C compiler needs -belf... $ECHO_C" >&6 -if test "${lt_cv_cc_needs_belf+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - 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 - - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - lt_cv_cc_needs_belf=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -lt_cv_cc_needs_belf=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - 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 - -fi -echo "$as_me:$LINENO: result: $lt_cv_cc_needs_belf" >&5 -echo "${ECHO_T}$lt_cv_cc_needs_belf" >&6 - 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 - ;; - -esac - -need_locks="$enable_libtool_lock" - - -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 -echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 -echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if test "${ac_cv_prog_CPP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.$ac_ext - - # OK, works on sane cases. Now check whether non-existent headers - # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - # Broken: success on invalid input. -continue -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then - break -fi - - done - ac_cv_prog_CPP=$CPP - -fi - CPP=$ac_cv_prog_CPP -else - ac_cv_prog_CPP=$CPP -fi -echo "$as_me:$LINENO: result: $CPP" >&5 -echo "${ECHO_T}$CPP" >&6 -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.$ac_ext - - # OK, works on sane cases. Now check whether non-existent headers - # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - # Broken: success on invalid input. -continue -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then - : -else - { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." >&5 -echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -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 - - -echo "$as_me:$LINENO: checking for ANSI C header files" >&5 -echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 -if test "${ac_cv_header_stdc+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include -#include -#include - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_header_stdc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_header_stdc=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then - : -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then - : -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then - : -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - exit(2); - exit (0); -} -_ACEOF -rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -ac_cv_header_stdc=no -fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi -fi -fi -echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 -echo "${ECHO_T}$ac_cv_header_stdc" >&6 -if test $ac_cv_header_stdc = yes; then - -cat >>confdefs.h <<\_ACEOF -#define STDC_HEADERS 1 -_ACEOF - -fi - -# On IRIX 5.3, sys/types and inttypes.h are conflicting. - - - - - - - - - -for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - inttypes.h stdint.h unistd.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default - -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - eval "$as_ac_Header=yes" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -eval "$as_ac_Header=no" -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - - -for ac_header in dlfcn.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -else - # Is the header compilable? -echo "$as_me:$LINENO: checking $ac_header usability" >&5 -echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_header_compiler=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_header_compiler=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6 - -# Is the header present? -echo "$as_me:$LINENO: checking $ac_header presence" >&5 -echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - ac_header_preproc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi -rm -f conftest.err conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6 - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - ( - cat <<\_ASBOX -## ----------------------------------- ## -## Report this to support@underbit.com ## -## ----------------------------------- ## -_ASBOX - ) | - sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 - -fi -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - -ac_ext=cc -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -if test -n "$ac_tool_prefix"; then - for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC - 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 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_CXX+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CXX"; then - ac_cv_prog_CXX="$CXX" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -CXX=$ac_cv_prog_CXX -if test -n "$CXX"; then - echo "$as_me:$LINENO: result: $CXX" >&5 -echo "${ECHO_T}$CXX" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - test -n "$CXX" && break - done -fi -if test -z "$CXX"; then - ac_ct_CXX=$CXX - for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_CXX"; then - ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CXX="$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -ac_ct_CXX=$ac_cv_prog_ac_ct_CXX -if test -n "$ac_ct_CXX"; then - echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 -echo "${ECHO_T}$ac_ct_CXX" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - test -n "$ac_ct_CXX" && break -done -test -n "$ac_ct_CXX" || ac_ct_CXX="g++" - - CXX=$ac_ct_CXX -fi - - -# Provide some information about the compiler. -echo "$as_me:$LINENO:" \ - "checking for C++ compiler version" >&5 -ac_compiler=`set X $ac_compile; echo $2` -{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 - (eval $ac_compiler --version &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 - (eval $ac_compiler -v &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 - (eval $ac_compiler -V &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } - -echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5 -echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6 -if test "${ac_cv_cxx_compiler_gnu+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_compiler_gnu=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_compiler_gnu=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_cxx_compiler_gnu=$ac_compiler_gnu - -fi -echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5 -echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6 -GXX=`test $ac_compiler_gnu = yes && echo yes` -ac_test_CXXFLAGS=${CXXFLAGS+set} -ac_save_CXXFLAGS=$CXXFLAGS -CXXFLAGS="-g" -echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5 -echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6 -if test "${ac_cv_prog_cxx_g+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_prog_cxx_g=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_prog_cxx_g=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5 -echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6 -if test "$ac_test_CXXFLAGS" = set; then - CXXFLAGS=$ac_save_CXXFLAGS -elif test $ac_cv_prog_cxx_g = yes; then - if test "$GXX" = yes; then - CXXFLAGS="-g -O2" - else - CXXFLAGS="-g" - fi -else - if test "$GXX" = yes; then - CXXFLAGS="-O2" - else - CXXFLAGS= - fi -fi -for ac_declaration in \ - '' \ - 'extern "C" void std::exit (int) throw (); using std::exit;' \ - 'extern "C" void std::exit (int); using std::exit;' \ - 'extern "C" void exit (int) throw ();' \ - 'extern "C" void exit (int);' \ - 'void exit (int);' -do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_declaration -#include -int -main () -{ -exit (42); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -continue -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_declaration -int -main () -{ -exit (42); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -done -rm -f conftest* -if test -n "$ac_declaration"; then - echo '#ifdef __cplusplus' >>confdefs.h - echo $ac_declaration >>confdefs.h - echo '#endif' >>confdefs.h -fi - -ac_ext=cc -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - -depcc="$CXX" am_compiler_list= - -echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 -echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6 -if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&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'. - 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_CXX_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` - fi - 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 - : > sub/conftst$i.h - done - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - - case $depmode in - 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 - ;; - none) break ;; - esac - # 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. - if depmode=$depmode \ - source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ - $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ - >/dev/null 2>conftest.err && - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftest.${OBJEXT-o} 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 - # (even with -Werror). So we grep stderr for any message - # that says an option was ignored. - if grep 'ignoring option' conftest.err >/dev/null 2>&1; then :; else - am_cv_CXX_dependencies_compiler_type=$depmode - break - fi - fi - done - - cd .. - rm -rf conftest.dir -else - am_cv_CXX_dependencies_compiler_type=none -fi - -fi -echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5 -echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6 -CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type - - - -if - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then - am__fastdepCXX_TRUE= - am__fastdepCXX_FALSE='#' -else - am__fastdepCXX_TRUE='#' - am__fastdepCXX_FALSE= -fi - - -ac_ext=cc -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -echo "$as_me:$LINENO: checking how to run the C++ preprocessor" >&5 -echo $ECHO_N "checking how to run the C++ preprocessor... $ECHO_C" >&6 -if test -z "$CXXCPP"; then - if test "${ac_cv_prog_CXXCPP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - # Double quotes because CXXCPP needs to be expanded - for CXXCPP in "$CXX -E" "/lib/cpp" - do - ac_preproc_ok=false -for ac_cxx_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_cxx_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.$ac_ext - - # OK, works on sane cases. Now check whether non-existent headers - # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_cxx_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - # Broken: success on invalid input. -continue -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then - break -fi - - done - ac_cv_prog_CXXCPP=$CXXCPP - -fi - CXXCPP=$ac_cv_prog_CXXCPP -else - ac_cv_prog_CXXCPP=$CXXCPP -fi -echo "$as_me:$LINENO: result: $CXXCPP" >&5 -echo "${ECHO_T}$CXXCPP" >&6 -ac_preproc_ok=false -for ac_cxx_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_cxx_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.$ac_ext - - # OK, works on sane cases. Now check whether non-existent headers - # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_cxx_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - # Broken: success on invalid input. -continue -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then - : -else - { { echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity check -See \`config.log' for more details." >&5 -echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi - -ac_ext=cc -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - - -ac_ext=f -ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5' -ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_f77_compiler_gnu -if test -n "$ac_tool_prefix"; then - for ac_prog in g77 f77 xlf frt pgf77 fort77 fl32 af77 f90 xlf90 pgf90 epcf90 f95 fort xlf95 ifc efc pgf95 lf95 gfortran - 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 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_F77+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$F77"; then - ac_cv_prog_F77="$F77" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_F77="$ac_tool_prefix$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -F77=$ac_cv_prog_F77 -if test -n "$F77"; then - echo "$as_me:$LINENO: result: $F77" >&5 -echo "${ECHO_T}$F77" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - test -n "$F77" && break - done -fi -if test -z "$F77"; then - ac_ct_F77=$F77 - for ac_prog in g77 f77 xlf frt pgf77 fort77 fl32 af77 f90 xlf90 pgf90 epcf90 f95 fort xlf95 ifc efc pgf95 lf95 gfortran -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_F77+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_F77"; then - ac_cv_prog_ac_ct_F77="$ac_ct_F77" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_F77="$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -ac_ct_F77=$ac_cv_prog_ac_ct_F77 -if test -n "$ac_ct_F77"; then - echo "$as_me:$LINENO: result: $ac_ct_F77" >&5 -echo "${ECHO_T}$ac_ct_F77" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - test -n "$ac_ct_F77" && break -done - - F77=$ac_ct_F77 -fi - - -# Provide some information about the compiler. -echo "$as_me:5240:" \ - "checking for Fortran 77 compiler version" >&5 -ac_compiler=`set X $ac_compile; echo $2` -{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 - (eval $ac_compiler --version &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 - (eval $ac_compiler -v &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 - (eval $ac_compiler -V &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -rm -f a.out - -# If we don't use `.F' as extension, the preprocessor is not run on the -# input file. (Note that this only needs to work for GNU compilers.) -ac_save_ext=$ac_ext -ac_ext=F -echo "$as_me:$LINENO: checking whether we are using the GNU Fortran 77 compiler" >&5 -echo $ECHO_N "checking whether we are using the GNU Fortran 77 compiler... $ECHO_C" >&6 -if test "${ac_cv_f77_compiler_gnu+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF - program main -#ifndef __GNUC__ - choke me -#endif - - end -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_compiler_gnu=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_compiler_gnu=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_f77_compiler_gnu=$ac_compiler_gnu - -fi -echo "$as_me:$LINENO: result: $ac_cv_f77_compiler_gnu" >&5 -echo "${ECHO_T}$ac_cv_f77_compiler_gnu" >&6 -ac_ext=$ac_save_ext -ac_test_FFLAGS=${FFLAGS+set} -ac_save_FFLAGS=$FFLAGS -FFLAGS= -echo "$as_me:$LINENO: checking whether $F77 accepts -g" >&5 -echo $ECHO_N "checking whether $F77 accepts -g... $ECHO_C" >&6 -if test "${ac_cv_prog_f77_g+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - FFLAGS=-g -cat >conftest.$ac_ext <<_ACEOF - program main - - end -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_prog_f77_g=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_prog_f77_g=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - -fi -echo "$as_me:$LINENO: result: $ac_cv_prog_f77_g" >&5 -echo "${ECHO_T}$ac_cv_prog_f77_g" >&6 -if test "$ac_test_FFLAGS" = set; then - FFLAGS=$ac_save_FFLAGS -elif test $ac_cv_prog_f77_g = yes; then - if test "x$ac_cv_f77_compiler_gnu" = xyes; then - FFLAGS="-g -O2" - else - FFLAGS="-g" - fi -else - if test "x$ac_cv_f77_compiler_gnu" = xyes; then - FFLAGS="-O2" - else - FFLAGS= - fi -fi - -G77=`test $ac_compiler_gnu = yes && echo yes` -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 - - - -# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers! - -# find the maximum length of command line arguments -echo "$as_me:$LINENO: checking the maximum length of command line arguments" >&5 -echo $ECHO_N "checking the maximum length of command line arguments... $ECHO_C" >&6 -if test "${lt_cv_sys_max_cmd_len+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - i=0 - testring="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*) - # 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; - ;; - - *) - # 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"`$CONFIG_SHELL $0 --fallback-echo "X$testring" 2>/dev/null` \ - = "XX$testring") >/dev/null 2>&1 && - new_result=`expr "X$testring" : ".*" 2>&1` && - lt_cv_sys_max_cmd_len=$new_result && - test $i != 17 # 1/2 MB should be enough - do - i=`expr $i + 1` - testring=$testring$testring - done - testring= - # 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` - ;; - esac - -fi - -if test -n $lt_cv_sys_max_cmd_len ; then - echo "$as_me:$LINENO: result: $lt_cv_sys_max_cmd_len" >&5 -echo "${ECHO_T}$lt_cv_sys_max_cmd_len" >&6 -else - echo "$as_me:$LINENO: result: none" >&5 -echo "${ECHO_T}none" >&6 -fi - - - - -# Check for command to grab the raw symbol name followed by C symbol from nm. -echo "$as_me:$LINENO: checking command to parse $NM output from $compiler object" >&5 -echo $ECHO_N "checking command to parse $NM output from $compiler object... $ECHO_C" >&6 -if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - -# 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]*\)' - -# Transform the above into a raw symbol and a C symbol. -symxfrm='\1 \2\3 \3' - -# Transform an extracted symbol line into a proper C declaration -lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \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\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" - -# Define system-specific variables. -case $host_os in -aix*) - symcode='[BCDT]' - ;; -cygwin* | mingw* | pw32*) - symcode='[ABCDGISTW]' - ;; -hpux*) # Its linker distinguishes data from code symbols - if test "$host_cpu" = ia64; then - symcode='[ABCDEGRST]' - fi - 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_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" - ;; -irix* | nonstopux*) - symcode='[BCDEGRST]' - ;; -osf*) - symcode='[BCDEGQRST]' - ;; -solaris* | sysv5*) - symcode='[BDRT]' - ;; -sysv4) - symcode='[DFNSTU]' - ;; -esac - -# 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 - -# If we're using GNU nm, then use its standard symbol codes. -case `$NM -V 2>&1` in -*GNU* | *'with BFD'*) - symcode='[ABCDGIRSTW]' ;; -esac - -# Try without a prefix undercore, then with it. -for ac_symprfx in "" "_"; do - - # Write the raw and C identifiers. - lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*\($ac_symprfx\)$sympat$opt_cr$/$symxfrm/p'" - - # Check to see that the pipe works correctly. - pipe_works=no - - rm -f conftest* - cat > conftest.$ac_ext <&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - # Now try to grab the symbols. - nlist=conftest.nm - if { (eval echo "$as_me:$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=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && 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 < conftest.$ac_ext -#ifdef __cplusplus -extern "C" { -#endif - -EOF - # Now generate the symbol file. - eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext' - - cat <> conftest.$ac_ext -#if defined (__STDC__) && __STDC__ -# define lt_ptr_t void * -#else -# define lt_ptr_t char * -# define const -#endif - -/* The mapping between symbol names and symbols. */ -const struct { - const char *name; - lt_ptr_t address; -} -lt_preloaded_symbols[] = -{ -EOF - $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext - cat <<\EOF >> conftest.$ac_ext - {0, (lt_ptr_t) 0} -}; - -#ifdef __cplusplus -} -#endif -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_prog_compiler_no_builtin_flag" - if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && 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" >&5 - fi - else - echo "cannot find nm_test_var in $nlist" >&5 - fi - else - echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 - fi - else - echo "$progname: failed program was:" >&5 - cat conftest.$ac_ext >&5 - fi - rm -f 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 - -fi - -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 - echo "$as_me:$LINENO: result: failed" >&5 -echo "${ECHO_T}failed" >&6 -else - echo "$as_me:$LINENO: result: ok" >&5 -echo "${ECHO_T}ok" >&6 -fi - -echo "$as_me:$LINENO: checking for objdir" >&5 -echo $ECHO_N "checking for objdir... $ECHO_C" >&6 -if test "${lt_cv_objdir+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - 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 -fi -echo "$as_me:$LINENO: result: $lt_cv_objdir" >&5 -echo "${ECHO_T}$lt_cv_objdir" >&6 -objdir=$lt_cv_objdir - - - - - -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. -Xsed='sed -e s/^X//' -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 avoid accidental globbing in evaled expressions -no_glob_subst='s/\*/\\\*/g' - -# Constants: -rm="rm -f" - -# Global variables: -default_ofile=libtool -can_build_shared=yes - -# All known linkers require a `.a' archive for static linking (except M$VC, -# which needs '.lib'). -libext=a -ltmain="$ac_aux_dir/ltmain.sh" -ofile="$default_ofile" -with_gnu_ld="$lt_cv_prog_gnu_ld" - -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 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_AR+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$AR"; then - ac_cv_prog_AR="$AR" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_AR="${ac_tool_prefix}ar" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -AR=$ac_cv_prog_AR -if test -n "$AR"; then - echo "$as_me:$LINENO: result: $AR" >&5 -echo "${ECHO_T}$AR" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -fi -if test -z "$ac_cv_prog_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 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_AR+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_AR"; then - ac_cv_prog_ac_ct_AR="$ac_ct_AR" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_AR="ar" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - - test -z "$ac_cv_prog_ac_ct_AR" && ac_cv_prog_ac_ct_AR="false" -fi -fi -ac_ct_AR=$ac_cv_prog_ac_ct_AR -if test -n "$ac_ct_AR"; then - echo "$as_me:$LINENO: result: $ac_ct_AR" >&5 -echo "${ECHO_T}$ac_ct_AR" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - AR=$ac_ct_AR -else - AR="$ac_cv_prog_AR" -fi - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. -set dummy ${ac_tool_prefix}ranlib; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_RANLIB+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$RANLIB"; then - ac_cv_prog_RANLIB="$RANLIB" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -RANLIB=$ac_cv_prog_RANLIB -if test -n "$RANLIB"; then - echo "$as_me:$LINENO: result: $RANLIB" >&5 -echo "${ECHO_T}$RANLIB" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -fi -if test -z "$ac_cv_prog_RANLIB"; then - ac_ct_RANLIB=$RANLIB - # Extract the first word of "ranlib", so it can be a program name with args. -set dummy ranlib; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_RANLIB"; then - ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_RANLIB="ranlib" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - - test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":" -fi -fi -ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB -if test -n "$ac_ct_RANLIB"; then - echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 -echo "${ECHO_T}$ac_ct_RANLIB" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - RANLIB=$ac_ct_RANLIB -else - RANLIB="$ac_cv_prog_RANLIB" -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 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_STRIP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$STRIP"; then - ac_cv_prog_STRIP="$STRIP" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_STRIP="${ac_tool_prefix}strip" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -STRIP=$ac_cv_prog_STRIP -if test -n "$STRIP"; then - echo "$as_me:$LINENO: result: $STRIP" >&5 -echo "${ECHO_T}$STRIP" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -fi -if test -z "$ac_cv_prog_STRIP"; then - ac_ct_STRIP=$STRIP - # Extract the first word of "strip", so it can be a program name with args. -set dummy strip; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_STRIP"; then - ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_STRIP="strip" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - - test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":" -fi -fi -ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP -if test -n "$ac_ct_STRIP"; then - echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 -echo "${ECHO_T}$ac_ct_STRIP" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - STRIP=$ac_ct_STRIP -else - STRIP="$ac_cv_prog_STRIP" -fi - - -old_CC="$CC" -old_CFLAGS="$CFLAGS" - -# Set sane defaults for various variables -test -z "$AR" && AR=ar -test -z "$AR_FLAGS" && AR_FLAGS=cru -test -z "$AS" && AS=as -test -z "$CC" && CC=cc -test -z "$LTCC" && LTCC=$CC -test -z "$DLLTOOL" && DLLTOOL=dlltool -test -z "$LD" && LD=ld -test -z "$LN_S" && LN_S="ln -s" -test -z "$MAGIC_CMD" && MAGIC_CMD=file -test -z "$NM" && NM=nm -test -z "$SED" && SED=sed -test -z "$OBJDUMP" && OBJDUMP=objdump -test -z "$RANLIB" && RANLIB=: -test -z "$STRIP" && STRIP=: -test -z "$ac_objext" && ac_objext=o - -# Determine commands to create old-style static archives. -old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs' -old_postinstall_cmds='chmod 644 $oldlib' -old_postuninstall_cmds= - -if test -n "$RANLIB"; then - case $host_os in - openbsd*) - old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds" - ;; - *) - old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds" - ;; - esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" -fi - -# Only perform the check for file, if the check method requires it -case $deplibs_check_method in -file_magic*) - if test "$file_magic_cmd" = '$MAGIC_CMD'; then - echo "$as_me:$LINENO: checking for ${ac_tool_prefix}file" >&5 -echo $ECHO_N "checking for ${ac_tool_prefix}file... $ECHO_C" >&6 -if test "${lt_cv_path_MAGIC_CMD+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - 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 - ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" - for ac_dir in $ac_dummy; do - 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 -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 <&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 - -EOF - fi ;; - esac - fi - break - fi - done - IFS="$lt_save_ifs" - MAGIC_CMD="$lt_save_MAGIC_CMD" - ;; -esac -fi - -MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -if test -n "$MAGIC_CMD"; then - echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5 -echo "${ECHO_T}$MAGIC_CMD" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -if test -z "$lt_cv_path_MAGIC_CMD"; then - if test -n "$ac_tool_prefix"; then - echo "$as_me:$LINENO: checking for file" >&5 -echo $ECHO_N "checking for file... $ECHO_C" >&6 -if test "${lt_cv_path_MAGIC_CMD+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - 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 - ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" - for ac_dir in $ac_dummy; do - 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 -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 <&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 - -EOF - fi ;; - esac - fi - break - fi - done - IFS="$lt_save_ifs" - MAGIC_CMD="$lt_save_MAGIC_CMD" - ;; -esac -fi - -MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -if test -n "$MAGIC_CMD"; then - echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5 -echo "${ECHO_T}$MAGIC_CMD" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - else - MAGIC_CMD=: - fi -fi - - fi - ;; -esac - -enable_dlopen=no -enable_win32_dll=no - -# Check whether --enable-libtool-lock or --disable-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 - - -# Check whether --with-pic or --without-pic was given. -if test "${with_pic+set}" = set; then - withval="$with_pic" - pic_mode="$withval" -else - pic_mode=default -fi; -test -z "$pic_mode" && pic_mode=default - -# Use C for the default configuration in the libtool script -tagname= -lt_save_CC="$CC" -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 - - -# Source file extension for C test sources. -ac_ext=c - -# Object file extension for compiled C test sources. -objext=o -objext=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="int some_variable = 0;\n" - -# Code to be used in simple link tests -lt_simple_link_test_code='int main(){return(0);}\n' - - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# Allow CC to be a program name with arguments. -compiler=$CC - - -# -# Check for any special shared library compilation flags. -# -lt_prog_cc_shlib= -if test "$GCC" = no; then - case $host_os in - sco3.2v5*) - lt_prog_cc_shlib='-belf' - ;; - esac -fi -if test -n "$lt_prog_cc_shlib"; then - { echo "$as_me:$LINENO: WARNING: \`$CC' requires \`$lt_prog_cc_shlib' to build shared libraries" >&5 -echo "$as_me: WARNING: \`$CC' requires \`$lt_prog_cc_shlib' to build shared libraries" >&2;} - if echo "$old_CC $old_CFLAGS " | grep "[ ]$lt_prog_cc_shlib[ ]" >/dev/null; then : - else - { echo "$as_me:$LINENO: WARNING: add \`$lt_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" >&5 -echo "$as_me: WARNING: add \`$lt_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" >&2;} - lt_cv_prog_cc_can_build_shared=no - fi -fi - - -# -# Check to make sure the static flag actually works. -# -echo "$as_me:$LINENO: checking if $compiler static flag $lt_prog_compiler_static works" >&5 -echo $ECHO_N "checking if $compiler static flag $lt_prog_compiler_static works... $ECHO_C" >&6 -if test "${lt_prog_compiler_static_works+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - lt_prog_compiler_static_works=no - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS $lt_prog_compiler_static" - printf "$lt_simple_link_test_code" > conftest.$ac_ext - if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then - # The compiler 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 - else - lt_prog_compiler_static_works=yes - fi - fi - $rm conftest* - LDFLAGS="$save_LDFLAGS" - -fi -echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works" >&5 -echo "${ECHO_T}$lt_prog_compiler_static_works" >&6 - -if test x"$lt_prog_compiler_static_works" = xyes; then - : -else - lt_prog_compiler_static= -fi - - - - -lt_prog_compiler_no_builtin_flag= - -if test "$GCC" = yes; then - lt_prog_compiler_no_builtin_flag=' -fno-builtin' - - -echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 -echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6 -if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - lt_cv_prog_compiler_rtti_exceptions=no - ac_outfile=conftest.$ac_objext - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="-fno-rtti -fno-exceptions" - # 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}? :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6272: $lt_compile\"" >&5) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&5 - echo "$as_me:6276: \$? = $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 - if test ! -s conftest.err; then - lt_cv_prog_compiler_rtti_exceptions=yes - fi - fi - $rm conftest* - -fi -echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 -echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6 - -if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then - lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" -else - : -fi - -fi - -lt_prog_compiler_wl= -lt_prog_compiler_pic= -lt_prog_compiler_static= - -echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 -echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 - - if test "$GCC" = yes; 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 - # AIX 5 now supports IA64 processor - lt_prog_compiler_static='-Bstatic' - fi - ;; - - amigaos*) - # 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_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' - ;; - - beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - - mingw* | pw32* | os2*) - # 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' - ;; - - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - lt_prog_compiler_pic='-fno-common' - ;; - - msdosdjgpp*) - # Just because we use GCC doesn't mean we suddenly get shared libraries - # on systems that don't support them. - lt_prog_compiler_can_build_shared=no - enable_shared=no - ;; - - sysv4*MP*) - if test -d /usr/nec; then - lt_prog_compiler_pic=-Kconform_pic - fi - ;; - - hpux*) - # 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_prog_compiler_pic='-fPIC' - ;; - esac - ;; - - *) - lt_prog_compiler_pic='-fPIC' - ;; - 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 - # AIX 5 now supports IA64 processor - lt_prog_compiler_static='-Bstatic' - else - lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' - fi - ;; - - mingw* | pw32* | os2*) - # 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' - ;; - - hpux9* | hpux10* | hpux11*) - lt_prog_compiler_wl='-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_prog_compiler_pic='+Z' - ;; - esac - # Is there a better lt_prog_compiler_static that works with the bundled CC? - lt_prog_compiler_static='${wl}-a ${wl}archive' - ;; - - irix5* | irix6* | nonstopux*) - lt_prog_compiler_wl='-Wl,' - # PIC (with -KPIC) is the default. - lt_prog_compiler_static='-non_shared' - ;; - - newsos6) - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - ;; - - linux*) - case $CC in - icc* | ecc*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-static' - ;; - ccc*) - lt_prog_compiler_wl='-Wl,' - # All Alpha code is PIC. - lt_prog_compiler_static='-non_shared' - ;; - esac - ;; - - osf3* | osf4* | osf5*) - lt_prog_compiler_wl='-Wl,' - # All OSF/1 code is PIC. - lt_prog_compiler_static='-non_shared' - ;; - - sco3.2v5*) - lt_prog_compiler_pic='-Kpic' - lt_prog_compiler_static='-dn' - ;; - - solaris*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - ;; - - sunos4*) - lt_prog_compiler_wl='-Qoption ld ' - lt_prog_compiler_pic='-PIC' - lt_prog_compiler_static='-Bstatic' - ;; - - sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - ;; - - sysv4*MP*) - if test -d /usr/nec ;then - lt_prog_compiler_pic='-Kconform_pic' - lt_prog_compiler_static='-Bstatic' - fi - ;; - - uts4*) - lt_prog_compiler_pic='-pic' - lt_prog_compiler_static='-Bstatic' - ;; - - *) - lt_prog_compiler_can_build_shared=no - ;; - esac - fi - -echo "$as_me:$LINENO: result: $lt_prog_compiler_pic" >&5 -echo "${ECHO_T}$lt_prog_compiler_pic" >&6 - -# -# Check to make sure the PIC flag actually works. -# -if test -n "$lt_prog_compiler_pic"; then - -echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 -echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic works... $ECHO_C" >&6 -if test "${lt_prog_compiler_pic_works+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - lt_prog_compiler_pic_works=no - ac_outfile=conftest.$ac_objext - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="$lt_prog_compiler_pic -DPIC" - # 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}? :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6505: $lt_compile\"" >&5) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&5 - echo "$as_me:6509: \$? = $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 - if test ! -s conftest.err; then - lt_prog_compiler_pic_works=yes - fi - fi - $rm conftest* - -fi -echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works" >&5 -echo "${ECHO_T}$lt_prog_compiler_pic_works" >&6 - -if test x"$lt_prog_compiler_pic_works" = xyes; then - case $lt_prog_compiler_pic in - "" | " "*) ;; - *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; - esac -else - lt_prog_compiler_pic= - lt_prog_compiler_can_build_shared=no -fi - -fi -case "$host_os" in - # For platforms which do not support PIC, -DPIC is meaningless: - *djgpp*) - lt_prog_compiler_pic= - ;; - *) - lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" - ;; -esac - -echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 -echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 -if test "${lt_cv_prog_compiler_c_o+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - lt_cv_prog_compiler_c_o=no - $rm -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - printf "$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}? :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6565: $lt_compile\"" >&5) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&5 - echo "$as_me:6569: \$? = $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 - if test ! -s out/conftest.err; then - lt_cv_prog_compiler_c_o=yes - fi - fi - chmod u+w . - $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 .. - rmdir conftest - $rm conftest* - -fi -echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o" >&5 -echo "${ECHO_T}$lt_cv_prog_compiler_c_o" >&6 - - -hard_links="nottested" -if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then - # do not overwrite the value of need_locks provided by the user - echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 -echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 - 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 - echo "$as_me:$LINENO: result: $hard_links" >&5 -echo "${ECHO_T}$hard_links" >&6 - if test "$hard_links" = no; then - { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 -echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} - need_locks=warn - fi -else - need_locks=no -fi - -echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 -echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 - - runpath_var= - allow_undefined_flag= - enable_shared_with_static_runtimes=no - archive_cmds= - archive_expsym_cmds= - old_archive_From_new_cmds= - old_archive_from_expsyms_cmds= - export_dynamic_flag_spec= - whole_archive_flag_spec= - thread_safe_flag_spec= - hardcode_libdir_flag_spec= - hardcode_libdir_flag_spec_ld= - hardcode_libdir_separator= - hardcode_direct=no - hardcode_minus_L=no - hardcode_shlibpath_var=unsupported - link_all_deplibs=unknown - hardcode_automatic=no - module_cmds= - module_expsym_cmds= - always_export_symbols=no - export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - # include_expsyms should be a list of space-separated symbols to be *always* - # 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'. - exclude_expsyms="_GLOBAL_OFFSET_TABLE_" - # 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. - extract_expsyms_cmds= - - case $host_os in - cygwin* | mingw* | pw32*) - # 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 - ;; - openbsd*) - with_gnu_ld=no - ;; - esac - - ld_shlibs=yes - if test "$with_gnu_ld" = yes; then - # If archive_cmds runs LD, not CC, wlarc should be empty - wlarc='${wl}' - - # See if GNU ld supports shared libraries. - case $host_os in - aix3* | aix4* | aix5*) - # On AIX/PPC, the GNU linker is very broken - if test "$host_cpu" != ia64; then - ld_shlibs=no - cat <&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. - -EOF - fi - ;; - - amigaos*) - archive_cmds='$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)' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - - # Samuel A. Falvo II reports - # that the semantics of dynamic libraries on AmigaOS, at least up - # to version 4, is to share data among multiple programs linked - # with the same dynamic library. Since this doesn't match the - # behavior of shared libraries on other platforms, we can't use - # them. - ld_shlibs=no - ;; - - beos*) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - 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' - else - ld_shlibs=no - fi - ;; - - cygwin* | mingw* | pw32*) - # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, - # as there is no search path for DLLs. - hardcode_libdir_flag_spec='-L$libdir' - 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 '\''/^[BCDGS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' - - if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$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}--image-base=0x10000000 ${wl}--out-implib,$lib' - else - ld_shlibs=no - fi - ;; - - netbsd* | knetbsd*-gnu) - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - 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' - fi - ;; - - solaris* | sysv5*) - if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then - ld_shlibs=no - cat <&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. - -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' - else - ld_shlibs=no - fi - ;; - - sunos4*) - archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' - wlarc= - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - linux*) - if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then - tmp_archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_cmds="$tmp_archive_cmds" - supports_anon_versioning=no - case `$LD -v 2>/dev/null` 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 - if test $supports_anon_versioning = yes; 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 -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' - else - archive_expsym_cmds="$tmp_archive_cmds" - fi - else - ld_shlibs=no - fi - ;; - - *) - 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' - else - ld_shlibs=no - fi - ;; - esac - - if test "$ld_shlibs" = yes; then - runpath_var=LD_RUN_PATH - 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' - else - whole_archive_flag_spec= - fi - fi - else - # PORTME fill in a description of your system's linker (not GNU ld) - case $host_os in - aix3*) - allow_undefined_flag=unsupported - always_export_symbols=yes - archive_expsym_cmds='$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. - hardcode_minus_L=yes - if test "$GCC" = yes && test -z "$link_static_flag"; then - # Neither direct hardcoding nor static linking is supported with a - # broken collect2. - hardcode_direct=unsupported - fi - ;; - - aix4* | aix5*) - 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 - 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' - 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' - 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].*|aix5*) - 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. - - archive_cmds='' - hardcode_direct=yes - hardcode_libdir_separator=':' - link_all_deplibs=yes - - 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 - hardcode_direct=yes - else - # We have old collect2 - hardcode_direct=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 - hardcode_minus_L=yes - hardcode_libdir_flag_spec='-L$libdir' - hardcode_libdir_separator= - fi - esac - shared_flag='-shared' - 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 - - # 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 - # 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 >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'` -# 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 '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'`; fi -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -if test -z "$aix_libpath"; then 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 $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${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' - allow_undefined_flag="-z nodefs" - archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an empty executable. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'` -# 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 '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'`; fi -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; 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' - # -bexpall does not export symbols beginning with underscore (_) - always_export_symbols=yes - # Exported symbols can be pulled into shared objects from archives - whole_archive_flag_spec=' ' - archive_cmds_need_lc=yes - # This is similar to how AIX traditionally builds it's shared libraries. - archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - - amigaos*) - archive_cmds='$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)' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - # see comment about different semantics on the GNU ld section - ld_shlibs=no - ;; - - bsdi4*) - export_dynamic_flag_spec=-rdynamic - ;; - - cygwin* | mingw* | pw32*) - # 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. - 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=".dll" - # FIXME: Setting linknames here is a bad hack. - archive_cmds='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -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 - ;; - - darwin* | rhapsody*) - if test "$GXX" = yes ; then - archive_cmds_need_lc=no - case "$host_os" in - rhapsody* | darwin1.[012]) - allow_undefined_flag='-undefined suppress' - ;; - *) # Darwin 1.3 on - if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then - allow_undefined_flag='-flat_namespace -undefined suppress' - else - case ${MACOSX_DEPLOYMENT_TARGET} in - 10.[012]) - allow_undefined_flag='-flat_namespace -undefined suppress' - ;; - 10.*) - allow_undefined_flag='-undefined dynamic_lookup' - ;; - esac - fi - ;; - esac - lt_int_apple_cc_single_mod=no - output_verbose_link_cmd='echo' - if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then - lt_int_apple_cc_single_mod=yes - fi - if test "X$lt_int_apple_cc_single_mod" = Xyes ; then - archive_cmds='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' - else - archive_cmds='$CC -r ${wl}-bind_at_load -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' - fi - module_cmds='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' - # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's - if test "X$lt_int_apple_cc_single_mod" = Xyes ; then - archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - else - archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -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~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - fi - module_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - hardcode_direct=no - hardcode_automatic=yes - hardcode_shlibpath_var=unsupported - whole_archive_flag_spec='-all_load $convenience' - link_all_deplibs=yes - else - ld_shlibs=no - fi - ;; - - dgux*) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='-L$libdir' - 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 - # extra space). - freebsd2.2*) - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2*) - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=yes - hardcode_minus_L=yes - hardcode_shlibpath_var=no - ;; - - # FreeBSD 3 and greater uses gcc -shared to do shared libraries. - freebsd* | kfreebsd*-gnu) - archive_cmds='$CC -shared -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' - 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' - fi - 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' - ;; - - hpux10* | hpux11*) - if test "$GCC" = yes -a "$with_gnu_ld" = no; then - case "$host_cpu" in - hppa*64*|ia64*) - archive_cmds='$CC -shared ${wl}+h ${wl}$soname -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' - ;; - esac - else - case "$host_cpu" in - hppa*64*|ia64*) - archive_cmds='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags' - ;; - *) - archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' - ;; - esac - fi - if test "$with_gnu_ld" = no; then - case "$host_cpu" in - hppa*64*) - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_flag_spec_ld='+b $libdir' - hardcode_libdir_separator=: - hardcode_direct=no - hardcode_shlibpath_var=no - ;; - ia64*) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_direct=no - hardcode_shlibpath_var=no - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L=yes - ;; - *) - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_separator=: - hardcode_direct=yes - 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 - ;; - esac - 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 ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - hardcode_libdir_flag_spec_ld='-rpath $libdir' - fi - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - link_all_deplibs=yes - ;; - - netbsd* | knetbsd*-gnu) - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out - else - archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF - fi - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - 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_separator=: - hardcode_shlibpath_var=no - ;; - - openbsd*) - hardcode_direct=yes - hardcode_shlibpath_var=no - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - 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 - fi - ;; - - os2*) - 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' - ;; - - 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 ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - allow_undefined_flag=' -expect_unresolved \*' - archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - fi - 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 ${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='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -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; echo "-hidden">> $lib.exp~ - $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp' - - # Both c and cxx compiler support -rpath directly - hardcode_libdir_flag_spec='-rpath $libdir' - fi - hardcode_libdir_separator=: - ;; - - sco3.2v5*) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_shlibpath_var=no - export_dynamic_flag_spec='${wl}-Bexport' - runpath_var=LD_RUN_PATH - hardcode_runpath_var=yes - ;; - - solaris*) - no_undefined_flag=' -z text' - if test "$GCC" = yes; then - archive_cmds='$CC -shared ${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}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' - else - 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' - fi - hardcode_libdir_flag_spec='-R$libdir' - hardcode_shlibpath_var=no - case $host_os in - solaris2.[0-5] | solaris2.[0-5].*) ;; - *) # Supported since Solaris 2.6 (maybe 2.5.1?) - whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;; - esac - link_all_deplibs=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. - 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 - hardcode_libdir_flag_spec='-L$libdir' - hardcode_direct=yes - hardcode_minus_L=yes - hardcode_shlibpath_var=no - ;; - - sysv4) - case $host_vendor in - sni) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=yes # is this really true??? - ;; - siemens) - ## LD is ld it makes a PLAMLIB - ## CC just makes a GrossModule. - archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' - reload_cmds='$CC -r -o $output$reload_objs' - hardcode_direct=no - ;; - motorola) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=no #Motorola manual says yes, but my tests say they lie - ;; - esac - runpath_var='LD_RUN_PATH' - hardcode_shlibpath_var=no - ;; - - sysv4.3*) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_shlibpath_var=no - export_dynamic_flag_spec='-Bexport' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_shlibpath_var=no - runpath_var=LD_RUN_PATH - hardcode_runpath_var=yes - ld_shlibs=yes - fi - ;; - - sysv4.2uw2*) - archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=yes - hardcode_minus_L=no - hardcode_shlibpath_var=no - hardcode_runpath_var=yes - runpath_var=LD_RUN_PATH - ;; - - sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*) - no_undefined_flag='${wl}-z ${wl}text' - if test "$GCC" = yes; then - archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - runpath_var='LD_RUN_PATH' - hardcode_shlibpath_var=no - ;; - - sysv5*) - no_undefined_flag=' -z text' - # $CC -shared without GNU ld will not create a library from C++ - # object files and a static libstdc++, better avoid it by now - 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' - hardcode_libdir_flag_spec= - hardcode_shlibpath_var=no - runpath_var='LD_RUN_PATH' - ;; - - uts4*) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_shlibpath_var=no - ;; - - *) - ld_shlibs=no - ;; - esac - fi - -echo "$as_me:$LINENO: result: $ld_shlibs" >&5 -echo "${ECHO_T}$ld_shlibs" >&6 -test "$ld_shlibs" = 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 - -# -# Do we need to explicitly link libc? -# -case "x$archive_cmds_need_lc" in -x|xyes) - # Assume -lc should be added - archive_cmds_need_lc=yes - - if test "$enable_shared" = yes && test "$GCC" = yes; then - case $archive_cmds 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. - echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 -echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 - $rm conftest* - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } 2>conftest.err; then - soname=conftest - lib=conftest - libobjs=conftest.$ac_objext - deplibs= - wl=$lt_prog_compiler_wl - 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:$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=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } - 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* - echo "$as_me:$LINENO: result: $archive_cmds_need_lc" >&5 -echo "${ECHO_T}$archive_cmds_need_lc" >&6 - ;; - esac - fi - ;; -esac - -echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 -echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 -library_names_spec= -libname_spec='lib$name' -soname_spec= -shrext=".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" -if test "$GCC" = yes; then - 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 ';' >/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. - 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 -else - sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" -fi -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' - ;; - -aix4* | aix5*) - 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*) - 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' - ;; - -beos*) - library_names_spec='${libname}${shared_ext}' - dynamic_linker="$host_os ld.so" - shlibpath_var=LIBRARY_PATH - ;; - -bsdi4*) - 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*) - version_type=windows - shrext=".dll" - need_version=no - need_lib_prefix=no - - case $GCC,$host_os in - yes,cygwin* | yes,mingw* | yes,pw32*) - 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' - 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*) - # 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}${versuffix}$shared_ext ${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='$(test .$module = .yes && echo .so || echo .dylib)' - # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. - if test "$GCC" = yes; then - sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` - else - sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' - fi - 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 - ;; - -kfreebsd*-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 - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='GNU ld.so' - ;; - -freebsd*) - objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` - 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 - ;; - *) # from 3.2 on - shlibpath_overrides_runpath=no - 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='.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='.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='.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' - ;; - -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*) - 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 - # 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 - ld_extra=`$SED -e 's/:,\t/ /g;s/=^=*$//;s/=^= * / /g' /etc/ld.so.conf` - sys_lib_dlsearch_path_spec="/lib /usr/lib $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' - ;; - -knetbsd*-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 - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='GNU 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=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 - ;; - -openbsd*) - version_type=sunos - need_lib_prefix=no - need_version=yes - 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=".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" - ;; - -sco3.2v5*) - version_type=osf - 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 - ;; - -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.2uw2* | sysv4.3* | sysv5*) - 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 - export_dynamic_flag_spec='${wl}-Blargedynsym' - 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 - ;; - -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 -echo "$as_me:$LINENO: result: $dynamic_linker" >&5 -echo "${ECHO_T}$dynamic_linker" >&6 -test "$dynamic_linker" = no && can_build_shared=no - -echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 -echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 -hardcode_action= -if test -n "$hardcode_libdir_flag_spec" || \ - test -n "$runpath_var " || \ - test "X$hardcode_automatic"="Xyes" ; then - - # We can hardcode non-existant directories. - if test "$hardcode_direct" != 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_AC_TAGVAR(hardcode_shlibpath_var, )" != no && - test "$hardcode_minus_L" != no; then - # Linking always hardcodes the temporary library directory. - hardcode_action=relink - else - # We can link without hardcoding, and we can hardcode nonexisting dirs. - hardcode_action=immediate - fi -else - # We cannot hardcode anything, or else we can only hardcode existing - # directories. - hardcode_action=unsupported -fi -echo "$as_me:$LINENO: result: $hardcode_action" >&5 -echo "${ECHO_T}$hardcode_action" >&6 - -if test "$hardcode_action" = relink; 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 - -striplib= -old_striplib= -echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5 -echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6 -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" - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 -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" - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 - else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - ;; - *) - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 - ;; - esac -fi - -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*) - 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 - echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 -echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 -if test "${ac_cv_lib_dl_dlopen+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldl $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char dlopen (); -int -main () -{ -dlopen (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_lib_dl_dlopen=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_lib_dl_dlopen=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 -echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 -if test $ac_cv_lib_dl_dlopen = yes; then - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" -else - - lt_cv_dlopen="dyld" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - -fi - - ;; - - *) - echo "$as_me:$LINENO: checking for shl_load" >&5 -echo $ECHO_N "checking for shl_load... $ECHO_C" >&6 -if test "${ac_cv_func_shl_load+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define shl_load to an innocuous variant, in case declares shl_load. - For example, HP-UX 11i declares gettimeofday. */ -#define shl_load innocuous_shl_load - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char shl_load (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef shl_load - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -{ -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char shl_load (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_shl_load) || defined (__stub___shl_load) -choke me -#else -char (*f) () = shl_load; -#endif -#ifdef __cplusplus -} -#endif - -int -main () -{ -return f != shl_load; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_func_shl_load=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_func_shl_load=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5 -echo "${ECHO_T}$ac_cv_func_shl_load" >&6 -if test $ac_cv_func_shl_load = yes; then - lt_cv_dlopen="shl_load" -else - echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5 -echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6 -if test "${ac_cv_lib_dld_shl_load+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldld $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char shl_load (); -int -main () -{ -shl_load (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_lib_dld_shl_load=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_lib_dld_shl_load=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5 -echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6 -if test $ac_cv_lib_dld_shl_load = yes; then - lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld" -else - echo "$as_me:$LINENO: checking for dlopen" >&5 -echo $ECHO_N "checking for dlopen... $ECHO_C" >&6 -if test "${ac_cv_func_dlopen+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define dlopen to an innocuous variant, in case declares dlopen. - For example, HP-UX 11i declares gettimeofday. */ -#define dlopen innocuous_dlopen - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char dlopen (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef dlopen - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -{ -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char dlopen (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_dlopen) || defined (__stub___dlopen) -choke me -#else -char (*f) () = dlopen; -#endif -#ifdef __cplusplus -} -#endif - -int -main () -{ -return f != dlopen; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_func_dlopen=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_func_dlopen=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5 -echo "${ECHO_T}$ac_cv_func_dlopen" >&6 -if test $ac_cv_func_dlopen = yes; then - lt_cv_dlopen="dlopen" -else - echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 -echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 -if test "${ac_cv_lib_dl_dlopen+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldl $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char dlopen (); -int -main () -{ -dlopen (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_lib_dl_dlopen=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_lib_dl_dlopen=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 -echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 -if test $ac_cv_lib_dl_dlopen = yes; then - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" -else - echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5 -echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6 -if test "${ac_cv_lib_svld_dlopen+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lsvld $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char dlopen (); -int -main () -{ -dlopen (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_lib_svld_dlopen=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_lib_svld_dlopen=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5 -echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6 -if test $ac_cv_lib_svld_dlopen = yes; then - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" -else - echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5 -echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6 -if test "${ac_cv_lib_dld_dld_link+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldld $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char dld_link (); -int -main () -{ -dld_link (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_lib_dld_dld_link=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_lib_dld_dld_link=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5 -echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6 -if test $ac_cv_lib_dld_dld_link = yes; then - lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld" -fi - - -fi - - -fi - - -fi - - -fi - - -fi - - ;; - 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" - eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" - - save_LIBS="$LIBS" - LIBS="$lt_cv_dlopen_libs $LIBS" - - echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5 -echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6 -if test "${lt_cv_dlopen_self+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test "$cross_compiling" = yes; 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 < -#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 - -#ifdef __cplusplus -extern "C" void exit (int); -#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); */ - } - - exit (status); -} -EOF - if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) 2>/dev/null - lt_status=$? - case x$lt_status in - x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; - x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; - x$lt_unknown|x*) lt_cv_dlopen_self=no ;; - esac - else : - # compilation failed - lt_cv_dlopen_self=no - fi -fi -rm -fr conftest* - - -fi -echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5 -echo "${ECHO_T}$lt_cv_dlopen_self" >&6 - - if test "x$lt_cv_dlopen_self" = xyes; then - LDFLAGS="$LDFLAGS $link_static_flag" - echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5 -echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6 -if test "${lt_cv_dlopen_self_static+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test "$cross_compiling" = yes; 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 < -#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 - -#ifdef __cplusplus -extern "C" void exit (int); -#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); */ - } - - exit (status); -} -EOF - if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) 2>/dev/null - lt_status=$? - case x$lt_status in - x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; - x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; - x$lt_unknown|x*) lt_cv_dlopen_self_static=no ;; - esac - else : - # compilation failed - lt_cv_dlopen_self_static=no - fi -fi -rm -fr conftest* - - -fi -echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5 -echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6 - 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 - - -# Report which librarie types wil actually be built -echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5 -echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6 -echo "$as_me:$LINENO: result: $can_build_shared" >&5 -echo "${ECHO_T}$can_build_shared" >&6 - -echo "$as_me:$LINENO: checking whether to build shared libraries" >&5 -echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6 -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 - ;; - -aix4*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no - fi - ;; - darwin* | rhapsody*) - if test "$GCC" = yes; then - archive_cmds_need_lc=no - case "$host_os" in - rhapsody* | darwin1.[012]) - allow_undefined_flag='-undefined suppress' - ;; - *) # Darwin 1.3 on - if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then - allow_undefined_flag='-flat_namespace -undefined suppress' - else - case ${MACOSX_DEPLOYMENT_TARGET} in - 10.[012]) - allow_undefined_flag='-flat_namespace -undefined suppress' - ;; - 10.*) - allow_undefined_flag='-undefined dynamic_lookup' - ;; - esac - fi - ;; - esac - output_verbose_link_cmd='echo' - archive_cmds='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs$compiler_flags -install_name $rpath/$soname $verstring' - module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' - # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's - archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs$compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - module_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - hardcode_direct=no - hardcode_automatic=yes - hardcode_shlibpath_var=unsupported - whole_archive_flag_spec='-all_load $convenience' - link_all_deplibs=yes - else - ld_shlibs=no - fi - ;; -esac -echo "$as_me:$LINENO: result: $enable_shared" >&5 -echo "${ECHO_T}$enable_shared" >&6 - -echo "$as_me:$LINENO: checking whether to build static libraries" >&5 -echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6 -# Make sure either enable_shared or enable_static is yes. -test "$enable_shared" = yes || enable_static=yes -echo "$as_me:$LINENO: result: $enable_static" >&5 -echo "${ECHO_T}$enable_static" >&6 - -# The else clause should only fire when bootstrapping the -# libtool distribution, otherwise you forgot to ship ltmain.sh -# with your package, and you will get complaints that there are -# no rules to generate ltmain.sh. -if test -f "$ltmain"; then - # 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 - # Now quote all the things that may contain metacharacters while being - # careful not to overquote the AC_SUBSTed values. We take copies of the - # variables and quote the copies for generation of the libtool script. - for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \ - SED SHELL STRIP \ - libname_spec library_names_spec soname_spec extract_expsyms_cmds \ - old_striplib striplib file_magic_cmd finish_cmds finish_eval \ - deplibs_check_method reload_flag reload_cmds need_locks \ - lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ - lt_cv_sys_global_symbol_to_c_name_address \ - sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ - old_postinstall_cmds old_postuninstall_cmds \ - compiler \ - CC \ - LD \ - lt_prog_compiler_wl \ - lt_prog_compiler_pic \ - lt_prog_compiler_static \ - lt_prog_compiler_no_builtin_flag \ - export_dynamic_flag_spec \ - thread_safe_flag_spec \ - whole_archive_flag_spec \ - enable_shared_with_static_runtimes \ - old_archive_cmds \ - old_archive_from_new_cmds \ - predep_objects \ - postdep_objects \ - predeps \ - postdeps \ - compiler_lib_search_path \ - archive_cmds \ - archive_expsym_cmds \ - postinstall_cmds \ - postuninstall_cmds \ - old_archive_from_expsyms_cmds \ - allow_undefined_flag \ - no_undefined_flag \ - export_symbols_cmds \ - hardcode_libdir_flag_spec \ - hardcode_libdir_flag_spec_ld \ - hardcode_libdir_separator \ - hardcode_automatic \ - module_cmds \ - module_expsym_cmds \ - lt_cv_prog_compiler_c_o \ - exclude_expsyms \ - include_expsyms; do - - case $var in - old_archive_cmds | \ - old_archive_from_new_cmds | \ - archive_cmds | \ - archive_expsym_cmds | \ - module_cmds | \ - module_expsym_cmds | \ - old_archive_from_expsyms_cmds | \ - export_symbols_cmds | \ - extract_expsyms_cmds | reload_cmds | finish_cmds | \ - postinstall_cmds | postuninstall_cmds | \ - old_postinstall_cmds | old_postuninstall_cmds | \ - sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) - # Double-quote double-evaled strings. - eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" - ;; - *) - eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" - ;; - esac - done - - case $lt_echo in - *'\$0 --fallback-echo"') - lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` - ;; - esac - -cfgfile="${ofile}T" - trap "$rm \"$cfgfile\"; exit 1" 1 2 15 - $rm -f "$cfgfile" - { echo "$as_me:$LINENO: creating $ofile" >&5 -echo "$as_me: creating $ofile" >&6;} - - cat <<__EOF__ >> "$cfgfile" -#! $SHELL - -# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services. -# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) -# NOTE: Changes made to this file will be lost: look at ltmain.sh. -# -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 -# Free Software Foundation, Inc. -# -# This file is part of GNU Libtool: -# Originally by Gordon Matzigkeit , 1996 -# -# 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. -# -# 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. - -# A sed program that does not truncate output. -SED=$lt_SED - -# Sed that helps us avoid accidentally triggering echo(1) options like -n. -Xsed="$SED -e s/^X//" - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi - -# The names of the tagged configurations supported by this script. -available_tags= - -# ### BEGIN LIBTOOL CONFIG - -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: - -# Shell to use when invoking shell scripts. -SHELL=$lt_SHELL - -# Whether or not to build shared libraries. -build_libtool_libs=$enable_shared - -# Whether or not to build static libraries. -build_old_libs=$enable_static - -# Whether or not to add -lc for building shared libraries. -build_libtool_need_lc=$archive_cmds_need_lc - -# Whether or not to disallow shared libs when runtime libs are static -allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes - -# Whether or not to optimize for fast installation. -fast_install=$enable_fast_install - -# The host system. -host_alias=$host_alias -host=$host - -# An echo program that does not interpret backslashes. -echo=$lt_echo - -# The archiver. -AR=$lt_AR -AR_FLAGS=$lt_AR_FLAGS - -# A C compiler. -LTCC=$lt_LTCC - -# A language-specific compiler. -CC=$lt_compiler - -# Is the compiler the GNU C compiler? -with_gcc=$GCC - -# An ERE matcher. -EGREP=$lt_EGREP - -# The linker used to build libraries. -LD=$lt_LD - -# Whether we need hard or soft links. -LN_S=$lt_LN_S - -# A BSD-compatible nm program. -NM=$lt_NM - -# A symbol stripping program -STRIP=$lt_STRIP - -# Used to examine libraries when file_magic_cmd begins "file" -MAGIC_CMD=$MAGIC_CMD - -# Used on cygwin: DLL creation program. -DLLTOOL="$DLLTOOL" - -# Used on cygwin: object dumper. -OBJDUMP="$OBJDUMP" - -# Used on cygwin: assembler. -AS="$AS" - -# The name of the directory that contains temporary libtool files. -objdir=$objdir - -# How to create reloadable object files. -reload_flag=$lt_reload_flag -reload_cmds=$lt_reload_cmds - -# How to pass a linker flag through the compiler. -wl=$lt_lt_prog_compiler_wl - -# Object file suffix (normally "o"). -objext="$ac_objext" - -# Old archive suffix (normally "a"). -libext="$libext" - -# Shared library suffix (normally ".so"). -shrext='$shrext' - -# Executable file suffix (normally ""). -exeext="$exeext" - -# Additional compiler flags for building library objects. -pic_flag=$lt_lt_prog_compiler_pic -pic_mode=$pic_mode - -# What is the maximum length of a command? -max_cmd_len=$lt_cv_sys_max_cmd_len - -# Does compiler simultaneously support -c and -o options? -compiler_c_o=$lt_lt_cv_prog_compiler_c_o - -# Must we lock files when doing compilation ? -need_locks=$lt_need_locks - -# Do we need the lib prefix for modules? -need_lib_prefix=$need_lib_prefix - -# Do we need a version for libraries? -need_version=$need_version - -# Whether dlopen is supported. -dlopen_support=$enable_dlopen - -# Whether dlopen of programs is supported. -dlopen_self=$enable_dlopen_self - -# Whether dlopen of statically linked programs is supported. -dlopen_self_static=$enable_dlopen_self_static - -# Compiler flag to prevent dynamic linking. -link_static_flag=$lt_lt_prog_compiler_static - -# Compiler flag to turn off builtin functions. -no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag - -# Compiler flag to allow reflexive dlopens. -export_dynamic_flag_spec=$lt_export_dynamic_flag_spec - -# Compiler flag to generate shared objects directly from archives. -whole_archive_flag_spec=$lt_whole_archive_flag_spec - -# Compiler flag to generate thread-safe objects. -thread_safe_flag_spec=$lt_thread_safe_flag_spec - -# Library versioning type. -version_type=$version_type - -# Format of library name prefix. -libname_spec=$lt_libname_spec - -# 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. -library_names_spec=$lt_library_names_spec - -# The coded name of the library, if different from the real name. -soname_spec=$lt_soname_spec - -# Commands used to build and install an old-style archive. -RANLIB=$lt_RANLIB -old_archive_cmds=$lt_old_archive_cmds -old_postinstall_cmds=$lt_old_postinstall_cmds -old_postuninstall_cmds=$lt_old_postuninstall_cmds - -# Create an old-style archive from a shared archive. -old_archive_from_new_cmds=$lt_old_archive_from_new_cmds - -# Create a temporary old-style archive to link instead of a shared archive. -old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds - -# Commands used to build and install a shared archive. -archive_cmds=$lt_archive_cmds -archive_expsym_cmds=$lt_archive_expsym_cmds -postinstall_cmds=$lt_postinstall_cmds -postuninstall_cmds=$lt_postuninstall_cmds - -# Commands used to build a loadable module (assumed same as above if empty) -module_cmds=$lt_module_cmds -module_expsym_cmds=$lt_module_expsym_cmds - -# Commands to strip libraries. -old_striplib=$lt_old_striplib -striplib=$lt_striplib - -# Dependencies to place before the objects being linked to create a -# shared library. -predep_objects=$lt_predep_objects - -# Dependencies to place after the objects being linked to create a -# shared library. -postdep_objects=$lt_postdep_objects - -# Dependencies to place before the objects being linked to create a -# shared library. -predeps=$lt_predeps - -# Dependencies to place after the objects being linked to create a -# shared library. -postdeps=$lt_postdeps - -# The library search path used internally by the compiler when linking -# a shared library. -compiler_lib_search_path=$lt_compiler_lib_search_path - -# 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. -file_magic_cmd=$lt_file_magic_cmd - -# Flag that allows shared libraries with undefined symbols to be built. -allow_undefined_flag=$lt_allow_undefined_flag - -# Flag that forces no undefined symbols. -no_undefined_flag=$lt_no_undefined_flag - -# Commands used to finish a libtool library installation in a directory. -finish_cmds=$lt_finish_cmds - -# Same as above, but a single script fragment to be evaled but not shown. -finish_eval=$lt_finish_eval - -# Take the output of nm and produce a listing of raw symbols and C names. -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 in a C name address pair -global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address - -# This is the shared library runtime path variable. -runpath_var=$runpath_var - -# This is the shared library path variable. -shlibpath_var=$shlibpath_var - -# Is shlibpath searched before the hard-coded library search path? -shlibpath_overrides_runpath=$shlibpath_overrides_runpath - -# How to hardcode a shared library path into an executable. -hardcode_action=$hardcode_action - -# Whether we should hardcode library paths into libraries. -hardcode_into_libs=$hardcode_into_libs - -# Flag to hardcode \$libdir into a binary during linking. -# 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 DIR into the -# resulting binary. -hardcode_direct=$hardcode_direct - -# Set to yes if using the -LDIR flag during linking hardcodes DIR into the -# resulting binary. -hardcode_minus_L=$hardcode_minus_L - -# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into -# the resulting binary. -hardcode_shlibpath_var=$hardcode_shlibpath_var - -# Set to yes if building a shared library automatically hardcodes DIR into the library -# and all subsequent libraries and executables linked against it. -hardcode_automatic=$hardcode_automatic - -# Variables whose values should be saved in libtool wrapper scripts and -# restored at relink time. -variables_saved_for_relink="$variables_saved_for_relink" - -# Whether libtool must link a program against all its dependency libraries. -link_all_deplibs=$link_all_deplibs - -# 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 - -# Fix the shell variable \$srcfile for the compiler. -fix_srcfile_path="$fix_srcfile_path" - -# Set to yes if exported symbols are required. -always_export_symbols=$always_export_symbols - -# The commands to list exported symbols. -export_symbols_cmds=$lt_export_symbols_cmds - -# The commands to extract the exported symbol list from a shared archive. -extract_expsyms_cmds=$lt_extract_expsyms_cmds - -# Symbols that should not be listed in the preloaded symbols. -exclude_expsyms=$lt_exclude_expsyms - -# Symbols that must always be exported. -include_expsyms=$lt_include_expsyms - -# ### END LIBTOOL CONFIG - -__EOF__ - - - case $host_os in - aix3*) - cat <<\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 -EOF - ;; - esac - - # 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 '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1) - - mv -f "$cfgfile" "$ofile" || \ - (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") - chmod +x "$ofile" - -else - # If there is no Makefile yet, we rely on a make rule to execute - # `config.status --recheck' to rerun these tests and create the - # libtool script then. - ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` - if test -f "$ltmain_in"; then - test -f Makefile && make "$ltmain" - fi -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 - -CC="$lt_save_CC" - - -# Check whether --with-tags or --without-tags was given. -if test "${with_tags+set}" = set; then - withval="$with_tags" - tagnames="$withval" -fi; - -if test -f "$ltmain" && test -n "$tagnames"; then - if test ! -f "${ofile}"; then - { echo "$as_me:$LINENO: WARNING: output file \`$ofile' does not exist" >&5 -echo "$as_me: WARNING: output file \`$ofile' does not exist" >&2;} - fi - - if test -z "$LTCC"; then - eval "`$SHELL ${ofile} --config | grep '^LTCC='`" - if test -z "$LTCC"; then - { echo "$as_me:$LINENO: WARNING: output file \`$ofile' does not look like a libtool script" >&5 -echo "$as_me: WARNING: output file \`$ofile' does not look like a libtool script" >&2;} - else - { echo "$as_me:$LINENO: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&5 -echo "$as_me: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&2;} - fi - fi - - # Extract list of available tagged configurations in $ofile. - # Note that this assumes the entire list is on one line. - available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'` - - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for tagname in $tagnames; do - IFS="$lt_save_ifs" - # Check whether tagname contains only valid characters - case `$echo "X$tagname" | $Xsed -e 's:[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]::g'` in - "") ;; - *) { { echo "$as_me:$LINENO: error: invalid tag name: $tagname" >&5 -echo "$as_me: error: invalid tag name: $tagname" >&2;} - { (exit 1); exit 1; }; } - ;; - esac - - if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null - then - { { echo "$as_me:$LINENO: error: tag name \"$tagname\" already exists" >&5 -echo "$as_me: error: tag name \"$tagname\" already exists" >&2;} - { (exit 1); exit 1; }; } - fi - - # Update the list of available tags. - if test -n "$tagname"; then - echo appending configuration tag \"$tagname\" to $ofile - - case $tagname in - CXX) - if test -n "$CXX" && test "X$CXX" != "Xno"; then - ac_ext=cc -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - - - - -archive_cmds_need_lc_CXX=no -allow_undefined_flag_CXX= -always_export_symbols_CXX=no -archive_expsym_cmds_CXX= -export_dynamic_flag_spec_CXX= -hardcode_direct_CXX=no -hardcode_libdir_flag_spec_CXX= -hardcode_libdir_flag_spec_ld_CXX= -hardcode_libdir_separator_CXX= -hardcode_minus_L_CXX=no -hardcode_automatic_CXX=no -module_cmds_CXX= -module_expsym_cmds_CXX= -link_all_deplibs_CXX=unknown -old_archive_cmds_CXX=$old_archive_cmds -no_undefined_flag_CXX= -whole_archive_flag_spec_CXX= -enable_shared_with_static_runtimes_CXX=no - -# Dependencies to place before and after the object being linked: -predep_objects_CXX= -postdep_objects_CXX= -predeps_CXX= -postdeps_CXX= -compiler_lib_search_path_CXX= - -# Source file extension for C++ test sources. -ac_ext=cc - -# Object file extension for compiled C++ test sources. -objext=o -objext_CXX=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="int some_variable = 0;\n" - -# Code to be used in simple link tests -lt_simple_link_test_code='int main(int, char *) { return(0); }\n' - -# ltmain only uses $CC for tagged configurations so make sure $CC is set. - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# Allow CC to be a program name with arguments. -compiler=$CC - - -# 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 - 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 - unset lt_cv_path_LD -fi -test -z "${LDCXX+set}" || LD=$LDCXX -CC=${CXX-"c++"} -compiler=$CC -compiler_CXX=$CC -cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'` - -# We don't want -fno-exception wen compiling C++ code, so set the -# no_builtin_flag separately -if test "$GXX" = yes; then - lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin' -else - lt_prog_compiler_no_builtin_flag_CXX= -fi - -if test "$GXX" = yes; then - # Set up default GNU C++ configuration - - -# Check whether --with-gnu-ld or --without-gnu-ld was given. -if test "${with_gnu_ld+set}" = set; then - withval="$with_gnu_ld" - test "$withval" = no || with_gnu_ld=yes -else - with_gnu_ld=no -fi; -ac_prog=ld -if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - echo "$as_me:$LINENO: checking for ld used by $CC" >&5 -echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6 - 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 - echo "$as_me:$LINENO: checking for GNU ld" >&5 -echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6 -else - echo "$as_me:$LINENO: checking for non-GNU ld" >&5 -echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6 -fi -if test "${lt_cv_path_LD+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - 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 GNU ld's 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 -echo "${ECHO_T}$LD" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi -test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5 -echo "$as_me: error: no acceptable ld found in \$PATH" >&2;} - { (exit 1); exit 1; }; } -echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5 -echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6 -if test "${lt_cv_prog_gnu_ld+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - # I'd rather use --version here, but apparently some GNU ld's only accept -v. -case `$LD -v 2>&1 &5 -echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6 -with_gnu_ld=$lt_cv_prog_gnu_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 - archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - - hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir' - export_dynamic_flag_spec_CXX='${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 - whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - whole_archive_flag_spec_CXX= - 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. - archive_cmds_CXX='$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 -echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 -echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 -ld_shlibs_CXX=yes -case $host_os in - aix3*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - aix4* | aix5*) - 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].*|aix5*) - 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. - - archive_cmds_CXX='' - hardcode_direct_CXX=yes - hardcode_libdir_separator_CXX=':' - link_all_deplibs_CXX=yes - - 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 - hardcode_direct_CXX=yes - else - # We have old collect2 - hardcode_direct_CXX=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 - hardcode_minus_L_CXX=yes - hardcode_libdir_flag_spec_CXX='-L$libdir' - hardcode_libdir_separator_CXX= - fi - esac - shared_flag='-shared' - 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 - - # 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_CXX=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. - allow_undefined_flag_CXX='-berok' - # Determine the default libpath from the value encoded in an empty executable. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'` -# 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 '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'`; fi -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi - - hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" - - archive_expsym_cmds_CXX="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib' - allow_undefined_flag_CXX="-z nodefs" - archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an empty executable. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'` -# 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 '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'`; fi -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi - - hardcode_libdir_flag_spec_CXX='${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_CXX=' ${wl}-bernotok' - allow_undefined_flag_CXX=' ${wl}-berok' - # -bexpall does not export symbols beginning with underscore (_) - always_export_symbols_CXX=yes - # Exported symbols can be pulled into shared objects from archives - whole_archive_flag_spec_CXX=' ' - archive_cmds_need_lc_CXX=yes - # This is similar to how AIX traditionally builds it's shared libraries. - archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - chorus*) - case $cc_basename in - *) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - esac - ;; - - cygwin* | mingw* | pw32*) - # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless, - # as there is no search path for DLLs. - hardcode_libdir_flag_spec_CXX='-L$libdir' - allow_undefined_flag_CXX=unsupported - always_export_symbols_CXX=no - enable_shared_with_static_runtimes_CXX=yes - - if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then - archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - archive_expsym_cmds_CXX='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}--image-base=0x10000000 ${wl}--out-implib,$lib' - else - ld_shlibs_CXX=no - fi - ;; - - darwin* | rhapsody*) - if test "$GXX" = yes; then - archive_cmds_need_lc_CXX=no - case "$host_os" in - rhapsody* | darwin1.[012]) - allow_undefined_flag_CXX='-undefined suppress' - ;; - *) # Darwin 1.3 on - if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then - allow_undefined_flag_CXX='-flat_namespace -undefined suppress' - else - case ${MACOSX_DEPLOYMENT_TARGET} in - 10.[012]) - allow_undefined_flag_CXX='-flat_namespace -undefined suppress' - ;; - 10.*) - allow_undefined_flag_CXX='-undefined dynamic_lookup' - ;; - esac - fi - ;; - esac - lt_int_apple_cc_single_mod=no - output_verbose_link_cmd='echo' - if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then - lt_int_apple_cc_single_mod=yes - fi - if test "X$lt_int_apple_cc_single_mod" = Xyes ; then - archive_cmds_CXX='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' - else - archive_cmds_CXX='$CC -r ${wl}-bind_at_load -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' - fi - module_cmds_CXX='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' - - # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's - if test "X$lt_int_apple_cc_single_mod" = Xyes ; then - archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - else - archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -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~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - fi - module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - hardcode_direct_CXX=no - hardcode_automatic_CXX=yes - hardcode_shlibpath_var_CXX=unsupported - whole_archive_flag_spec_CXX='-all_load $convenience' - link_all_deplibs_CXX=yes - else - ld_shlibs_CXX=no - fi - ;; - - dgux*) - case $cc_basename in - ec++) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - ghcx) - # Green Hills C++ Compiler - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - *) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - esac - ;; - freebsd12*) - # C++ shared libraries reported to be fairly broken before switch to ELF - ld_shlibs_CXX=no - ;; - freebsd-elf*) - archive_cmds_need_lc_CXX=no - ;; - freebsd* | kfreebsd*-gnu) - # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF - # conventions - ld_shlibs_CXX=yes - ;; - gnu*) - ;; - hpux9*) - hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' - hardcode_libdir_separator_CXX=: - export_dynamic_flag_spec_CXX='${wl}-E' - hardcode_direct_CXX=yes - hardcode_minus_L_CXX=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 - ld_shlibs_CXX=no - ;; - aCC) - archive_cmds_CXX='$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 $list' - ;; - *) - if test "$GXX" = yes; then - archive_cmds_CXX='$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 - ld_shlibs_CXX=no - fi - ;; - esac - ;; - hpux10*|hpux11*) - if test $with_gnu_ld = no; then - case "$host_cpu" in - hppa*64*) - hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' - hardcode_libdir_flag_spec_ld_CXX='+b $libdir' - hardcode_libdir_separator_CXX=: - ;; - ia64*) - hardcode_libdir_flag_spec_CXX='-L$libdir' - ;; - *) - hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' - hardcode_libdir_separator_CXX=: - export_dynamic_flag_spec_CXX='${wl}-E' - ;; - esac - fi - case "$host_cpu" in - hppa*64*) - hardcode_direct_CXX=no - hardcode_shlibpath_var_CXX=no - ;; - ia64*) - hardcode_direct_CXX=no - hardcode_shlibpath_var_CXX=no - hardcode_minus_L_CXX=yes # Not in the search PATH, - # but as the default - # location of the library. - ;; - *) - hardcode_direct_CXX=yes - hardcode_minus_L_CXX=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 - ld_shlibs_CXX=no - ;; - aCC) - case "$host_cpu" in - hppa*64*|ia64*) - archive_cmds_CXX='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs' - ;; - *) - archive_cmds_CXX='$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 $list' - ;; - *) - if test "$GXX" = yes; then - if test $with_gnu_ld = no; then - case "$host_cpu" in - ia64*|hppa*64*) - archive_cmds_CXX='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs' - ;; - *) - archive_cmds_CXX='$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 - ld_shlibs_CXX=no - fi - ;; - esac - ;; - irix5* | irix6*) - case $cc_basename in - CC) - # SGI C++ - archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${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. - old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs' - ;; - *) - if test "$GXX" = yes; then - if test "$with_gnu_ld" = no; then - archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' - else - archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib' - fi - fi - link_all_deplibs_CXX=yes - ;; - esac - hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator_CXX=: - ;; - linux*) - 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. - archive_cmds_CXX='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' - archive_expsym_cmds_CXX='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 $list' - - hardcode_libdir_flag_spec_CXX='${wl}--rpath,$libdir' - export_dynamic_flag_spec_CXX='${wl}--export-dynamic' - - # Archives containing C++ object files must be created using - # "CC -Bstatic", where "CC" is the KAI C++ compiler. - old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' - ;; - icpc) - # Intel C++ - with_gnu_ld=yes - archive_cmds_need_lc_CXX=no - archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' - export_dynamic_flag_spec_CXX='${wl}--export-dynamic' - whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive' - ;; - cxx) - # Compaq C++ - archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds_CXX='$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 - hardcode_libdir_flag_spec_CXX='-rpath $libdir' - hardcode_libdir_separator_CXX=: - - # 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 $templist | $SED "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 $list' - ;; - esac - ;; - lynxos*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - m88k*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - mvs*) - case $cc_basename in - cxx) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - *) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - esac - ;; - netbsd* | knetbsd*-gnu) - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - archive_cmds_CXX='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' - wlarc= - hardcode_libdir_flag_spec_CXX='-R$libdir' - hardcode_direct_CXX=yes - hardcode_shlibpath_var_CXX=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::"' - ;; - osf3*) - 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. - archive_cmds_CXX='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' - - hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' - hardcode_libdir_separator_CXX=: - - # Archives containing C++ object files must be created using - # "CC -Bstatic", where "CC" is the KAI C++ compiler. - old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' - - ;; - RCC) - # Rational C++ 2.4.1 - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - cxx) - allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' - - hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator_CXX=: - - # 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 $templist | $SED "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 $list' - ;; - *) - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' - - hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator_CXX=: - - # 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 - ld_shlibs_CXX=no - fi - ;; - esac - ;; - 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. - archive_cmds_CXX='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' - - hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' - hardcode_libdir_separator_CXX=: - - # Archives containing C++ object files must be created using - # the KAI C++ compiler. - old_archive_cmds_CXX='$CC -o $oldlib $oldobjs' - ;; - RCC) - # Rational C++ 2.4.1 - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - cxx) - allow_undefined_flag_CXX=' -expect_unresolved \*' - archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' - archive_expsym_cmds_CXX='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 -set_version $verstring` -update_registry $objdir/so_locations -o $lib~ - $rm $lib.exp' - - hardcode_libdir_flag_spec_CXX='-rpath $libdir' - hardcode_libdir_separator_CXX=: - - # 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 $templist | $SED "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 $list' - ;; - *) - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds_CXX='$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` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' - - hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator_CXX=: - - # 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 - ld_shlibs_CXX=no - fi - ;; - esac - ;; - psos*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - sco*) - archive_cmds_need_lc_CXX=no - case $cc_basename in - CC) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - *) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - esac - ;; - sunos4*) - case $cc_basename in - CC) - # Sun C++ 4.x - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - lcc) - # Lucid - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - *) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - esac - ;; - solaris*) - case $cc_basename in - CC) - # Sun C++ 4.2, 5.x and Centerline C++ - no_undefined_flag_CXX=' -zdefs' - archive_cmds_CXX='$CC -G${allow_undefined_flag} -nolib -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ - $CC -G${allow_undefined_flag} -nolib ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' - - hardcode_libdir_flag_spec_CXX='-R$libdir' - hardcode_shlibpath_var_CXX=no - case $host_os in - solaris2.0-5 | solaris2.0-5.*) ;; - *) - # The C++ compiler is used as linker so we must use $wl - # flag to pass the commands to the underlying system - # linker. - # Supported since Solaris 2.6 (maybe 2.5.1?) - whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' - ;; - esac - link_all_deplibs_CXX=yes - - # 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 -G $CFLAGS -v conftest.$objext 2>&1 | grep "\-[LR]"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' - - # 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. - old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' - ;; - gcx) - # Green Hills C++ Compiler - archive_cmds_CXX='$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. - old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs' - ;; - *) - # GNU C++ compiler with Solaris linker - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - no_undefined_flag_CXX=' ${wl}-z ${wl}defs' - if $CC --version | grep -v '^2\.7' > /dev/null; then - archive_cmds_CXX='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - archive_expsym_cmds_CXX='$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. - archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - archive_expsym_cmds_CXX='$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 - - hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir' - fi - ;; - esac - ;; - sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*) - archive_cmds_need_lc_CXX=no - ;; - tandem*) - case $cc_basename in - NCC) - # NonStop-UX NCC 3.20 - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - *) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - esac - ;; - vxworks*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - *) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; -esac -echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5 -echo "${ECHO_T}$ld_shlibs_CXX" >&6 -test "$ld_shlibs_CXX" = no && can_build_shared=no - -GCC_CXX="$GXX" -LD_CXX="$LD" - - -cat > conftest.$ac_ext <&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; 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 - - # The `*' in the case matches for architectures that use `case' in - # $output_verbose_cmd can trigger glob expansion during the loop - # eval without this substitution. - output_verbose_link_cmd="`$echo \"X$output_verbose_link_cmd\" | $Xsed -e \"$no_glob_subst\"`" - - 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 "$compiler_lib_search_path_CXX"; then - compiler_lib_search_path_CXX="${prev}${p}" - else - compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${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 "$postdeps_CXX"; then - postdeps_CXX="${prev}${p}" - else - postdeps_CXX="${postdeps_CXX} ${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 "$predep_objects_CXX"; then - predep_objects_CXX="$p" - else - predep_objects_CXX="$predep_objects_CXX $p" - fi - else - if test -z "$postdep_objects_CXX"; then - postdep_objects_CXX="$p" - else - postdep_objects_CXX="$postdep_objects_CXX $p" - fi - fi - ;; - - *) ;; # Ignore the rest. - - esac - done - - # Clean up. - rm -f a.out a.exe -else - echo "libtool.m4: error: problem compiling CXX test program" -fi - -$rm -f confest.$objext - -case " $postdeps_CXX " in -*" -lc "*) archive_cmds_need_lc_CXX=no ;; -esac - -lt_prog_compiler_wl_CXX= -lt_prog_compiler_pic_CXX= -lt_prog_compiler_static_CXX= - -echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 -echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 - - # C++ specific cases for pic, static, wl, etc. - if test "$GXX" = yes; then - lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_static_CXX='-static' - - case $host_os in - aix*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - lt_prog_compiler_static_CXX='-Bstatic' - fi - ;; - amigaos*) - # 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_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4' - ;; - beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - mingw* | os2* | pw32*) - # 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_CXX='-DDLL_EXPORT' - ;; - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - lt_prog_compiler_pic_CXX='-fno-common' - ;; - *djgpp*) - # DJGPP does not support shared libraries at all - lt_prog_compiler_pic_CXX= - ;; - sysv4*MP*) - if test -d /usr/nec; then - lt_prog_compiler_pic_CXX=-Kconform_pic - fi - ;; - hpux*) - # 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*) - ;; - *) - lt_prog_compiler_pic_CXX='-fPIC' - ;; - esac - ;; - *) - lt_prog_compiler_pic_CXX='-fPIC' - ;; - esac - else - case $host_os in - aix4* | aix5*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - lt_prog_compiler_static_CXX='-Bstatic' - else - lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp' - fi - ;; - chorus*) - case $cc_basename in - cxch68) - # Green Hills C++ Compiler - # _LT_AC_TAGVAR(lt_prog_compiler_static, CXX)="--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_prog_compiler_pic_CXX='-KPIC' - ;; - ghcx) - # Green Hills C++ Compiler - lt_prog_compiler_pic_CXX='-pic' - ;; - *) - ;; - esac - ;; - freebsd* | kfreebsd*-gnu) - # FreeBSD uses GNU C++ - ;; - hpux9* | hpux10* | hpux11*) - case $cc_basename in - CC) - lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_static_CXX="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive" - if test "$host_cpu" != ia64; then - lt_prog_compiler_pic_CXX='+Z' - fi - ;; - aCC) - lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_static_CXX="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive" - case "$host_cpu" in - hppa*64*|ia64*) - # +Z the default - ;; - *) - lt_prog_compiler_pic_CXX='+Z' - ;; - esac - ;; - *) - ;; - esac - ;; - irix5* | irix6* | nonstopux*) - case $cc_basename in - CC) - lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_static_CXX='-non_shared' - # CC pic flag -KPIC is the default. - ;; - *) - ;; - esac - ;; - linux*) - case $cc_basename in - KCC) - # KAI C++ Compiler - lt_prog_compiler_wl_CXX='--backend -Wl,' - lt_prog_compiler_pic_CXX='-fPIC' - ;; - icpc) - # Intel C++ - lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_pic_CXX='-KPIC' - lt_prog_compiler_static_CXX='-static' - ;; - cxx) - # Compaq C++ - # Make sure the PIC flag is empty. It appears that all Alpha - # Linux and Compaq Tru64 Unix objects are PIC. - lt_prog_compiler_pic_CXX= - lt_prog_compiler_static_CXX='-non_shared' - ;; - *) - ;; - esac - ;; - lynxos*) - ;; - m88k*) - ;; - mvs*) - case $cc_basename in - cxx) - lt_prog_compiler_pic_CXX='-W c,exportall' - ;; - *) - ;; - esac - ;; - netbsd* | knetbsd*-gnu) - ;; - osf3* | osf4* | osf5*) - case $cc_basename in - KCC) - lt_prog_compiler_wl_CXX='--backend -Wl,' - ;; - RCC) - # Rational C++ 2.4.1 - lt_prog_compiler_pic_CXX='-pic' - ;; - cxx) - # Digital/Compaq C++ - lt_prog_compiler_wl_CXX='-Wl,' - # Make sure the PIC flag is empty. It appears that all Alpha - # Linux and Compaq Tru64 Unix objects are PIC. - lt_prog_compiler_pic_CXX= - lt_prog_compiler_static_CXX='-non_shared' - ;; - *) - ;; - esac - ;; - psos*) - ;; - sco*) - case $cc_basename in - CC) - lt_prog_compiler_pic_CXX='-fPIC' - ;; - *) - ;; - esac - ;; - solaris*) - case $cc_basename in - CC) - # Sun C++ 4.2, 5.x and Centerline C++ - lt_prog_compiler_pic_CXX='-KPIC' - lt_prog_compiler_static_CXX='-Bstatic' - lt_prog_compiler_wl_CXX='-Qoption ld ' - ;; - gcx) - # Green Hills C++ Compiler - lt_prog_compiler_pic_CXX='-PIC' - ;; - *) - ;; - esac - ;; - sunos4*) - case $cc_basename in - CC) - # Sun C++ 4.x - lt_prog_compiler_pic_CXX='-pic' - lt_prog_compiler_static_CXX='-Bstatic' - ;; - lcc) - # Lucid - lt_prog_compiler_pic_CXX='-pic' - ;; - *) - ;; - esac - ;; - tandem*) - case $cc_basename in - NCC) - # NonStop-UX NCC 3.20 - lt_prog_compiler_pic_CXX='-KPIC' - ;; - *) - ;; - esac - ;; - unixware*) - ;; - vxworks*) - ;; - *) - lt_prog_compiler_can_build_shared_CXX=no - ;; - esac - fi - -echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_CXX" >&5 -echo "${ECHO_T}$lt_prog_compiler_pic_CXX" >&6 - -# -# Check to make sure the PIC flag actually works. -# -if test -n "$lt_prog_compiler_pic_CXX"; then - -echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5 -echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... $ECHO_C" >&6 -if test "${lt_prog_compiler_pic_works_CXX+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - lt_prog_compiler_pic_works_CXX=no - ac_outfile=conftest.$ac_objext - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC" - # 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}? :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:11015: $lt_compile\"" >&5) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&5 - echo "$as_me:11019: \$? = $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 - if test ! -s conftest.err; then - lt_prog_compiler_pic_works_CXX=yes - fi - fi - $rm conftest* - -fi -echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_CXX" >&5 -echo "${ECHO_T}$lt_prog_compiler_pic_works_CXX" >&6 - -if test x"$lt_prog_compiler_pic_works_CXX" = xyes; then - case $lt_prog_compiler_pic_CXX in - "" | " "*) ;; - *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;; - esac -else - lt_prog_compiler_pic_CXX= - lt_prog_compiler_can_build_shared_CXX=no -fi - -fi -case "$host_os" in - # For platforms which do not support PIC, -DPIC is meaningless: - *djgpp*) - lt_prog_compiler_pic_CXX= - ;; - *) - lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC" - ;; -esac - -echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 -echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 -if test "${lt_cv_prog_compiler_c_o_CXX+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - lt_cv_prog_compiler_c_o_CXX=no - $rm -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - printf "$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}? :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:11075: $lt_compile\"" >&5) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&5 - echo "$as_me:11079: \$? = $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 - if test ! -s out/conftest.err; then - lt_cv_prog_compiler_c_o_CXX=yes - fi - fi - chmod u+w . - $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 .. - rmdir conftest - $rm conftest* - -fi -echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_CXX" >&5 -echo "${ECHO_T}$lt_cv_prog_compiler_c_o_CXX" >&6 - - -hard_links="nottested" -if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then - # do not overwrite the value of need_locks provided by the user - echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 -echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 - 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 - echo "$as_me:$LINENO: result: $hard_links" >&5 -echo "${ECHO_T}$hard_links" >&6 - if test "$hard_links" = no; then - { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 -echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} - need_locks=warn - fi -else - need_locks=no -fi - -echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 -echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 - - export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - case $host_os in - aix4* | aix5*) - # 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 - export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' - else - export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' - fi - ;; - pw32*) - export_symbols_cmds_CXX="$ltdll_cmds" - ;; - cygwin* | mingw*) - export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' - ;; - *) - export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - ;; - esac - -echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5 -echo "${ECHO_T}$ld_shlibs_CXX" >&6 -test "$ld_shlibs_CXX" = 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 - -# -# Do we need to explicitly link libc? -# -case "x$archive_cmds_need_lc_CXX" in -x|xyes) - # Assume -lc should be added - archive_cmds_need_lc_CXX=yes - - if test "$enable_shared" = yes && test "$GCC" = yes; then - case $archive_cmds_CXX 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. - echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 -echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 - $rm conftest* - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } 2>conftest.err; then - soname=conftest - lib=conftest - libobjs=conftest.$ac_objext - deplibs= - wl=$lt_prog_compiler_wl_CXX - compiler_flags=-v - linker_flags=-v - verstring= - output_objdir=. - libname=conftest - lt_save_allow_undefined_flag=$allow_undefined_flag_CXX - allow_undefined_flag_CXX= - if { (eval echo "$as_me:$LINENO: \"$archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 - (eval $archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } - then - archive_cmds_need_lc_CXX=no - else - archive_cmds_need_lc_CXX=yes - fi - allow_undefined_flag_CXX=$lt_save_allow_undefined_flag - else - cat conftest.err 1>&5 - fi - $rm conftest* - echo "$as_me:$LINENO: result: $archive_cmds_need_lc_CXX" >&5 -echo "${ECHO_T}$archive_cmds_need_lc_CXX" >&6 - ;; - esac - fi - ;; -esac - -echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 -echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 -library_names_spec= -libname_spec='lib$name' -soname_spec= -shrext=".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" -if test "$GCC" = yes; then - 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 ';' >/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. - 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 -else - sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" -fi -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' - ;; - -aix4* | aix5*) - 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*) - 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' - ;; - -beos*) - library_names_spec='${libname}${shared_ext}' - dynamic_linker="$host_os ld.so" - shlibpath_var=LIBRARY_PATH - ;; - -bsdi4*) - 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*) - version_type=windows - shrext=".dll" - need_version=no - need_lib_prefix=no - - case $GCC,$host_os in - yes,cygwin* | yes,mingw* | yes,pw32*) - 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' - 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*) - # 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}${versuffix}$shared_ext ${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='$(test .$module = .yes && echo .so || echo .dylib)' - # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. - if test "$GCC" = yes; then - sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` - else - sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' - fi - 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 - ;; - -kfreebsd*-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 - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='GNU ld.so' - ;; - -freebsd*) - objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` - 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 - ;; - *) # from 3.2 on - shlibpath_overrides_runpath=no - 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='.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='.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='.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' - ;; - -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*) - 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 - # 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 - ld_extra=`$SED -e 's/:,\t/ /g;s/=^=*$//;s/=^= * / /g' /etc/ld.so.conf` - sys_lib_dlsearch_path_spec="/lib /usr/lib $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' - ;; - -knetbsd*-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 - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='GNU 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=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 - ;; - -openbsd*) - version_type=sunos - need_lib_prefix=no - need_version=yes - 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=".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" - ;; - -sco3.2v5*) - version_type=osf - 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 - ;; - -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.2uw2* | sysv4.3* | sysv5*) - 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 - export_dynamic_flag_spec='${wl}-Blargedynsym' - 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 - ;; - -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 -echo "$as_me:$LINENO: result: $dynamic_linker" >&5 -echo "${ECHO_T}$dynamic_linker" >&6 -test "$dynamic_linker" = no && can_build_shared=no - -echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 -echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 -hardcode_action_CXX= -if test -n "$hardcode_libdir_flag_spec_CXX" || \ - test -n "$runpath_var CXX" || \ - test "X$hardcode_automatic_CXX"="Xyes" ; then - - # We can hardcode non-existant directories. - if test "$hardcode_direct_CXX" != 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_AC_TAGVAR(hardcode_shlibpath_var, CXX)" != no && - test "$hardcode_minus_L_CXX" != no; then - # Linking always hardcodes the temporary library directory. - hardcode_action_CXX=relink - else - # We can link without hardcoding, and we can hardcode nonexisting dirs. - hardcode_action_CXX=immediate - fi -else - # We cannot hardcode anything, or else we can only hardcode existing - # directories. - hardcode_action_CXX=unsupported -fi -echo "$as_me:$LINENO: result: $hardcode_action_CXX" >&5 -echo "${ECHO_T}$hardcode_action_CXX" >&6 - -if test "$hardcode_action_CXX" = relink; 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 - -striplib= -old_striplib= -echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5 -echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6 -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" - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 -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" - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 - else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - ;; - *) - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 - ;; - esac -fi - -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*) - 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 - echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 -echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 -if test "${ac_cv_lib_dl_dlopen+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldl $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char dlopen (); -int -main () -{ -dlopen (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_lib_dl_dlopen=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_lib_dl_dlopen=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 -echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 -if test $ac_cv_lib_dl_dlopen = yes; then - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" -else - - lt_cv_dlopen="dyld" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - -fi - - ;; - - *) - echo "$as_me:$LINENO: checking for shl_load" >&5 -echo $ECHO_N "checking for shl_load... $ECHO_C" >&6 -if test "${ac_cv_func_shl_load+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define shl_load to an innocuous variant, in case declares shl_load. - For example, HP-UX 11i declares gettimeofday. */ -#define shl_load innocuous_shl_load - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char shl_load (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef shl_load - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -{ -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char shl_load (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_shl_load) || defined (__stub___shl_load) -choke me -#else -char (*f) () = shl_load; -#endif -#ifdef __cplusplus -} -#endif - -int -main () -{ -return f != shl_load; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_func_shl_load=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_func_shl_load=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5 -echo "${ECHO_T}$ac_cv_func_shl_load" >&6 -if test $ac_cv_func_shl_load = yes; then - lt_cv_dlopen="shl_load" -else - echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5 -echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6 -if test "${ac_cv_lib_dld_shl_load+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldld $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char shl_load (); -int -main () -{ -shl_load (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_lib_dld_shl_load=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_lib_dld_shl_load=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5 -echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6 -if test $ac_cv_lib_dld_shl_load = yes; then - lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld" -else - echo "$as_me:$LINENO: checking for dlopen" >&5 -echo $ECHO_N "checking for dlopen... $ECHO_C" >&6 -if test "${ac_cv_func_dlopen+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define dlopen to an innocuous variant, in case declares dlopen. - For example, HP-UX 11i declares gettimeofday. */ -#define dlopen innocuous_dlopen - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char dlopen (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef dlopen - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -{ -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char dlopen (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_dlopen) || defined (__stub___dlopen) -choke me -#else -char (*f) () = dlopen; -#endif -#ifdef __cplusplus -} -#endif - -int -main () -{ -return f != dlopen; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_func_dlopen=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_func_dlopen=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5 -echo "${ECHO_T}$ac_cv_func_dlopen" >&6 -if test $ac_cv_func_dlopen = yes; then - lt_cv_dlopen="dlopen" -else - echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 -echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 -if test "${ac_cv_lib_dl_dlopen+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldl $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char dlopen (); -int -main () -{ -dlopen (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_lib_dl_dlopen=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_lib_dl_dlopen=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 -echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 -if test $ac_cv_lib_dl_dlopen = yes; then - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" -else - echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5 -echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6 -if test "${ac_cv_lib_svld_dlopen+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lsvld $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char dlopen (); -int -main () -{ -dlopen (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_lib_svld_dlopen=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_lib_svld_dlopen=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5 -echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6 -if test $ac_cv_lib_svld_dlopen = yes; then - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" -else - echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5 -echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6 -if test "${ac_cv_lib_dld_dld_link+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldld $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char dld_link (); -int -main () -{ -dld_link (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_lib_dld_dld_link=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_lib_dld_dld_link=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5 -echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6 -if test $ac_cv_lib_dld_dld_link = yes; then - lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld" -fi - - -fi - - -fi - - -fi - - -fi - - -fi - - ;; - 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" - eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" - - save_LIBS="$LIBS" - LIBS="$lt_cv_dlopen_libs $LIBS" - - echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5 -echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6 -if test "${lt_cv_dlopen_self+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test "$cross_compiling" = yes; 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 < -#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 - -#ifdef __cplusplus -extern "C" void exit (int); -#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); */ - } - - exit (status); -} -EOF - if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) 2>/dev/null - lt_status=$? - case x$lt_status in - x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; - x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; - x$lt_unknown|x*) lt_cv_dlopen_self=no ;; - esac - else : - # compilation failed - lt_cv_dlopen_self=no - fi -fi -rm -fr conftest* - - -fi -echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5 -echo "${ECHO_T}$lt_cv_dlopen_self" >&6 - - if test "x$lt_cv_dlopen_self" = xyes; then - LDFLAGS="$LDFLAGS $link_static_flag" - echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5 -echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6 -if test "${lt_cv_dlopen_self_static+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test "$cross_compiling" = yes; 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 < -#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 - -#ifdef __cplusplus -extern "C" void exit (int); -#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); */ - } - - exit (status); -} -EOF - if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) 2>/dev/null - lt_status=$? - case x$lt_status in - x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; - x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; - x$lt_unknown|x*) lt_cv_dlopen_self_static=no ;; - esac - else : - # compilation failed - lt_cv_dlopen_self_static=no - fi -fi -rm -fr conftest* - - -fi -echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5 -echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6 - 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 - - -# The else clause should only fire when bootstrapping the -# libtool distribution, otherwise you forgot to ship ltmain.sh -# with your package, and you will get complaints that there are -# no rules to generate ltmain.sh. -if test -f "$ltmain"; then - # 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 - # Now quote all the things that may contain metacharacters while being - # careful not to overquote the AC_SUBSTed values. We take copies of the - # variables and quote the copies for generation of the libtool script. - for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \ - SED SHELL STRIP \ - libname_spec library_names_spec soname_spec extract_expsyms_cmds \ - old_striplib striplib file_magic_cmd finish_cmds finish_eval \ - deplibs_check_method reload_flag reload_cmds need_locks \ - lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ - lt_cv_sys_global_symbol_to_c_name_address \ - sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ - old_postinstall_cmds old_postuninstall_cmds \ - compiler_CXX \ - CC_CXX \ - LD_CXX \ - lt_prog_compiler_wl_CXX \ - lt_prog_compiler_pic_CXX \ - lt_prog_compiler_static_CXX \ - lt_prog_compiler_no_builtin_flag_CXX \ - export_dynamic_flag_spec_CXX \ - thread_safe_flag_spec_CXX \ - whole_archive_flag_spec_CXX \ - enable_shared_with_static_runtimes_CXX \ - old_archive_cmds_CXX \ - old_archive_from_new_cmds_CXX \ - predep_objects_CXX \ - postdep_objects_CXX \ - predeps_CXX \ - postdeps_CXX \ - compiler_lib_search_path_CXX \ - archive_cmds_CXX \ - archive_expsym_cmds_CXX \ - postinstall_cmds_CXX \ - postuninstall_cmds_CXX \ - old_archive_from_expsyms_cmds_CXX \ - allow_undefined_flag_CXX \ - no_undefined_flag_CXX \ - export_symbols_cmds_CXX \ - hardcode_libdir_flag_spec_CXX \ - hardcode_libdir_flag_spec_ld_CXX \ - hardcode_libdir_separator_CXX \ - hardcode_automatic_CXX \ - module_cmds_CXX \ - module_expsym_cmds_CXX \ - lt_cv_prog_compiler_c_o_CXX \ - exclude_expsyms_CXX \ - include_expsyms_CXX; do - - case $var in - old_archive_cmds_CXX | \ - old_archive_from_new_cmds_CXX | \ - archive_cmds_CXX | \ - archive_expsym_cmds_CXX | \ - module_cmds_CXX | \ - module_expsym_cmds_CXX | \ - old_archive_from_expsyms_cmds_CXX | \ - export_symbols_cmds_CXX | \ - extract_expsyms_cmds | reload_cmds | finish_cmds | \ - postinstall_cmds | postuninstall_cmds | \ - old_postinstall_cmds | old_postuninstall_cmds | \ - sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) - # Double-quote double-evaled strings. - eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" - ;; - *) - eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" - ;; - esac - done - - case $lt_echo in - *'\$0 --fallback-echo"') - lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` - ;; - esac - -cfgfile="$ofile" - - cat <<__EOF__ >> "$cfgfile" -# ### BEGIN LIBTOOL TAG CONFIG: $tagname - -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: - -# Shell to use when invoking shell scripts. -SHELL=$lt_SHELL - -# Whether or not to build shared libraries. -build_libtool_libs=$enable_shared - -# Whether or not to build static libraries. -build_old_libs=$enable_static - -# Whether or not to add -lc for building shared libraries. -build_libtool_need_lc=$archive_cmds_need_lc_CXX - -# Whether or not to disallow shared libs when runtime libs are static -allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX - -# Whether or not to optimize for fast installation. -fast_install=$enable_fast_install - -# The host system. -host_alias=$host_alias -host=$host - -# An echo program that does not interpret backslashes. -echo=$lt_echo - -# The archiver. -AR=$lt_AR -AR_FLAGS=$lt_AR_FLAGS - -# A C compiler. -LTCC=$lt_LTCC - -# A language-specific compiler. -CC=$lt_compiler_CXX - -# Is the compiler the GNU C compiler? -with_gcc=$GCC_CXX - -# An ERE matcher. -EGREP=$lt_EGREP - -# The linker used to build libraries. -LD=$lt_LD_CXX - -# Whether we need hard or soft links. -LN_S=$lt_LN_S - -# A BSD-compatible nm program. -NM=$lt_NM - -# A symbol stripping program -STRIP=$lt_STRIP - -# Used to examine libraries when file_magic_cmd begins "file" -MAGIC_CMD=$MAGIC_CMD - -# Used on cygwin: DLL creation program. -DLLTOOL="$DLLTOOL" - -# Used on cygwin: object dumper. -OBJDUMP="$OBJDUMP" - -# Used on cygwin: assembler. -AS="$AS" - -# The name of the directory that contains temporary libtool files. -objdir=$objdir - -# How to create reloadable object files. -reload_flag=$lt_reload_flag -reload_cmds=$lt_reload_cmds - -# How to pass a linker flag through the compiler. -wl=$lt_lt_prog_compiler_wl_CXX - -# Object file suffix (normally "o"). -objext="$ac_objext" - -# Old archive suffix (normally "a"). -libext="$libext" - -# Shared library suffix (normally ".so"). -shrext='$shrext' - -# Executable file suffix (normally ""). -exeext="$exeext" - -# Additional compiler flags for building library objects. -pic_flag=$lt_lt_prog_compiler_pic_CXX -pic_mode=$pic_mode - -# What is the maximum length of a command? -max_cmd_len=$lt_cv_sys_max_cmd_len - -# Does compiler simultaneously support -c and -o options? -compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX - -# Must we lock files when doing compilation ? -need_locks=$lt_need_locks - -# Do we need the lib prefix for modules? -need_lib_prefix=$need_lib_prefix - -# Do we need a version for libraries? -need_version=$need_version - -# Whether dlopen is supported. -dlopen_support=$enable_dlopen - -# Whether dlopen of programs is supported. -dlopen_self=$enable_dlopen_self - -# Whether dlopen of statically linked programs is supported. -dlopen_self_static=$enable_dlopen_self_static - -# Compiler flag to prevent dynamic linking. -link_static_flag=$lt_lt_prog_compiler_static_CXX - -# Compiler flag to turn off builtin functions. -no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX - -# Compiler flag to allow reflexive dlopens. -export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX - -# Compiler flag to generate shared objects directly from archives. -whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX - -# Compiler flag to generate thread-safe objects. -thread_safe_flag_spec=$lt_thread_safe_flag_spec_CXX - -# Library versioning type. -version_type=$version_type - -# Format of library name prefix. -libname_spec=$lt_libname_spec - -# 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. -library_names_spec=$lt_library_names_spec - -# The coded name of the library, if different from the real name. -soname_spec=$lt_soname_spec - -# Commands used to build and install an old-style archive. -RANLIB=$lt_RANLIB -old_archive_cmds=$lt_old_archive_cmds_CXX -old_postinstall_cmds=$lt_old_postinstall_cmds -old_postuninstall_cmds=$lt_old_postuninstall_cmds - -# Create an old-style archive from a shared archive. -old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX - -# Create a temporary old-style archive to link instead of a shared archive. -old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX - -# Commands used to build and install a shared archive. -archive_cmds=$lt_archive_cmds_CXX -archive_expsym_cmds=$lt_archive_expsym_cmds_CXX -postinstall_cmds=$lt_postinstall_cmds -postuninstall_cmds=$lt_postuninstall_cmds - -# Commands used to build a loadable module (assumed same as above if empty) -module_cmds=$lt_module_cmds_CXX -module_expsym_cmds=$lt_module_expsym_cmds_CXX - -# Commands to strip libraries. -old_striplib=$lt_old_striplib -striplib=$lt_striplib - -# Dependencies to place before the objects being linked to create a -# shared library. -predep_objects=$lt_predep_objects_CXX - -# Dependencies to place after the objects being linked to create a -# shared library. -postdep_objects=$lt_postdep_objects_CXX - -# Dependencies to place before the objects being linked to create a -# shared library. -predeps=$lt_predeps_CXX - -# Dependencies to place after the objects being linked to create a -# shared library. -postdeps=$lt_postdeps_CXX - -# The library search path used internally by the compiler when linking -# a shared library. -compiler_lib_search_path=$lt_compiler_lib_search_path_CXX - -# 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. -file_magic_cmd=$lt_file_magic_cmd - -# Flag that allows shared libraries with undefined symbols to be built. -allow_undefined_flag=$lt_allow_undefined_flag_CXX - -# Flag that forces no undefined symbols. -no_undefined_flag=$lt_no_undefined_flag_CXX - -# Commands used to finish a libtool library installation in a directory. -finish_cmds=$lt_finish_cmds - -# Same as above, but a single script fragment to be evaled but not shown. -finish_eval=$lt_finish_eval - -# Take the output of nm and produce a listing of raw symbols and C names. -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 in a C name address pair -global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address - -# This is the shared library runtime path variable. -runpath_var=$runpath_var - -# This is the shared library path variable. -shlibpath_var=$shlibpath_var - -# Is shlibpath searched before the hard-coded library search path? -shlibpath_overrides_runpath=$shlibpath_overrides_runpath - -# How to hardcode a shared library path into an executable. -hardcode_action=$hardcode_action_CXX - -# Whether we should hardcode library paths into libraries. -hardcode_into_libs=$hardcode_into_libs - -# Flag to hardcode \$libdir into a binary during linking. -# This must work even if \$libdir does not exist. -hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX - -# 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_CXX - -# Whether we need a single -rpath flag with a separated argument. -hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX - -# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the -# resulting binary. -hardcode_direct=$hardcode_direct_CXX - -# Set to yes if using the -LDIR flag during linking hardcodes DIR into the -# resulting binary. -hardcode_minus_L=$hardcode_minus_L_CXX - -# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into -# the resulting binary. -hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX - -# Set to yes if building a shared library automatically hardcodes DIR into the library -# and all subsequent libraries and executables linked against it. -hardcode_automatic=$hardcode_automatic_CXX - -# Variables whose values should be saved in libtool wrapper scripts and -# restored at relink time. -variables_saved_for_relink="$variables_saved_for_relink" - -# Whether libtool must link a program against all its dependency libraries. -link_all_deplibs=$link_all_deplibs_CXX - -# 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 - -# Fix the shell variable \$srcfile for the compiler. -fix_srcfile_path="$fix_srcfile_path_CXX" - -# Set to yes if exported symbols are required. -always_export_symbols=$always_export_symbols_CXX - -# The commands to list exported symbols. -export_symbols_cmds=$lt_export_symbols_cmds_CXX - -# The commands to extract the exported symbol list from a shared archive. -extract_expsyms_cmds=$lt_extract_expsyms_cmds - -# Symbols that should not be listed in the preloaded symbols. -exclude_expsyms=$lt_exclude_expsyms_CXX - -# Symbols that must always be exported. -include_expsyms=$lt_include_expsyms_CXX - -# ### END LIBTOOL TAG CONFIG: $tagname - -__EOF__ - - -else - # If there is no Makefile yet, we rely on a make rule to execute - # `config.status --recheck' to rerun these tests and create the - # libtool script then. - ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` - if test -f "$ltmain_in"; then - test -f Makefile && make "$ltmain" - fi -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 - -CC=$lt_save_CC -LDCXX=$LD -LD=$lt_save_LD -GCC=$lt_save_GCC -with_gnu_ldcxx=$with_gnu_ld -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 - - else - tagname="" - fi - ;; - - F77) - if test -n "$F77" && test "X$F77" != "Xno"; then - -ac_ext=f -ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5' -ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_f77_compiler_gnu - - -archive_cmds_need_lc_F77=no -allow_undefined_flag_F77= -always_export_symbols_F77=no -archive_expsym_cmds_F77= -export_dynamic_flag_spec_F77= -hardcode_direct_F77=no -hardcode_libdir_flag_spec_F77= -hardcode_libdir_flag_spec_ld_F77= -hardcode_libdir_separator_F77= -hardcode_minus_L_F77=no -hardcode_automatic_F77=no -module_cmds_F77= -module_expsym_cmds_F77= -link_all_deplibs_F77=unknown -old_archive_cmds_F77=$old_archive_cmds -no_undefined_flag_F77= -whole_archive_flag_spec_F77= -enable_shared_with_static_runtimes_F77=no - -# Source file extension for f77 test sources. -ac_ext=f - -# Object file extension for compiled f77 test sources. -objext=o -objext_F77=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code=" subroutine t\n return\n end\n" - -# Code to be used in simple link tests -lt_simple_link_test_code=" program t\n end\n" - -# ltmain only uses $CC for tagged configurations so make sure $CC is set. - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# Allow CC to be a program name with arguments. -compiler=$CC - - -# Allow CC to be a program name with arguments. -lt_save_CC="$CC" -CC=${F77-"f77"} -compiler=$CC -compiler_F77=$CC -cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'` - -echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5 -echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6 -echo "$as_me:$LINENO: result: $can_build_shared" >&5 -echo "${ECHO_T}$can_build_shared" >&6 - -echo "$as_me:$LINENO: checking whether to build shared libraries" >&5 -echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6 -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 - ;; -aix4*) - test "$enable_shared" = yes && enable_static=no - ;; -esac -echo "$as_me:$LINENO: result: $enable_shared" >&5 -echo "${ECHO_T}$enable_shared" >&6 - -echo "$as_me:$LINENO: checking whether to build static libraries" >&5 -echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6 -# Make sure either enable_shared or enable_static is yes. -test "$enable_shared" = yes || enable_static=yes -echo "$as_me:$LINENO: result: $enable_static" >&5 -echo "${ECHO_T}$enable_static" >&6 - -test "$ld_shlibs_F77" = no && can_build_shared=no - -GCC_F77="$G77" -LD_F77="$LD" - -lt_prog_compiler_wl_F77= -lt_prog_compiler_pic_F77= -lt_prog_compiler_static_F77= - -echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 -echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 - - if test "$GCC" = yes; then - lt_prog_compiler_wl_F77='-Wl,' - lt_prog_compiler_static_F77='-static' - - case $host_os in - aix*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - lt_prog_compiler_static_F77='-Bstatic' - fi - ;; - - amigaos*) - # 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_prog_compiler_pic_F77='-m68020 -resident32 -malways-restore-a4' - ;; - - beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - - mingw* | pw32* | os2*) - # 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_F77='-DDLL_EXPORT' - ;; - - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - lt_prog_compiler_pic_F77='-fno-common' - ;; - - msdosdjgpp*) - # Just because we use GCC doesn't mean we suddenly get shared libraries - # on systems that don't support them. - lt_prog_compiler_can_build_shared_F77=no - enable_shared=no - ;; - - sysv4*MP*) - if test -d /usr/nec; then - lt_prog_compiler_pic_F77=-Kconform_pic - fi - ;; - - hpux*) - # 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_prog_compiler_pic_F77='-fPIC' - ;; - esac - ;; - - *) - lt_prog_compiler_pic_F77='-fPIC' - ;; - esac - else - # PORTME Check for flag to pass linker flags through the system compiler. - case $host_os in - aix*) - lt_prog_compiler_wl_F77='-Wl,' - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - lt_prog_compiler_static_F77='-Bstatic' - else - lt_prog_compiler_static_F77='-bnso -bI:/lib/syscalls.exp' - fi - ;; - - mingw* | pw32* | os2*) - # 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_F77='-DDLL_EXPORT' - ;; - - hpux9* | hpux10* | hpux11*) - lt_prog_compiler_wl_F77='-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_prog_compiler_pic_F77='+Z' - ;; - esac - # Is there a better lt_prog_compiler_static that works with the bundled CC? - lt_prog_compiler_static_F77='${wl}-a ${wl}archive' - ;; - - irix5* | irix6* | nonstopux*) - lt_prog_compiler_wl_F77='-Wl,' - # PIC (with -KPIC) is the default. - lt_prog_compiler_static_F77='-non_shared' - ;; - - newsos6) - lt_prog_compiler_pic_F77='-KPIC' - lt_prog_compiler_static_F77='-Bstatic' - ;; - - linux*) - case $CC in - icc* | ecc*) - lt_prog_compiler_wl_F77='-Wl,' - lt_prog_compiler_pic_F77='-KPIC' - lt_prog_compiler_static_F77='-static' - ;; - ccc*) - lt_prog_compiler_wl_F77='-Wl,' - # All Alpha code is PIC. - lt_prog_compiler_static_F77='-non_shared' - ;; - esac - ;; - - osf3* | osf4* | osf5*) - lt_prog_compiler_wl_F77='-Wl,' - # All OSF/1 code is PIC. - lt_prog_compiler_static_F77='-non_shared' - ;; - - sco3.2v5*) - lt_prog_compiler_pic_F77='-Kpic' - lt_prog_compiler_static_F77='-dn' - ;; - - solaris*) - lt_prog_compiler_wl_F77='-Wl,' - lt_prog_compiler_pic_F77='-KPIC' - lt_prog_compiler_static_F77='-Bstatic' - ;; - - sunos4*) - lt_prog_compiler_wl_F77='-Qoption ld ' - lt_prog_compiler_pic_F77='-PIC' - lt_prog_compiler_static_F77='-Bstatic' - ;; - - sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - lt_prog_compiler_wl_F77='-Wl,' - lt_prog_compiler_pic_F77='-KPIC' - lt_prog_compiler_static_F77='-Bstatic' - ;; - - sysv4*MP*) - if test -d /usr/nec ;then - lt_prog_compiler_pic_F77='-Kconform_pic' - lt_prog_compiler_static_F77='-Bstatic' - fi - ;; - - uts4*) - lt_prog_compiler_pic_F77='-pic' - lt_prog_compiler_static_F77='-Bstatic' - ;; - - *) - lt_prog_compiler_can_build_shared_F77=no - ;; - esac - fi - -echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_F77" >&5 -echo "${ECHO_T}$lt_prog_compiler_pic_F77" >&6 - -# -# Check to make sure the PIC flag actually works. -# -if test -n "$lt_prog_compiler_pic_F77"; then - -echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works" >&5 -echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works... $ECHO_C" >&6 -if test "${lt_prog_compiler_pic_works_F77+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - lt_prog_compiler_pic_works_F77=no - ac_outfile=conftest.$ac_objext - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="$lt_prog_compiler_pic_F77" - # 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}? :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:13354: $lt_compile\"" >&5) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&5 - echo "$as_me:13358: \$? = $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 - if test ! -s conftest.err; then - lt_prog_compiler_pic_works_F77=yes - fi - fi - $rm conftest* - -fi -echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_F77" >&5 -echo "${ECHO_T}$lt_prog_compiler_pic_works_F77" >&6 - -if test x"$lt_prog_compiler_pic_works_F77" = xyes; then - case $lt_prog_compiler_pic_F77 in - "" | " "*) ;; - *) lt_prog_compiler_pic_F77=" $lt_prog_compiler_pic_F77" ;; - esac -else - lt_prog_compiler_pic_F77= - lt_prog_compiler_can_build_shared_F77=no -fi - -fi -case "$host_os" in - # For platforms which do not support PIC, -DPIC is meaningless: - *djgpp*) - lt_prog_compiler_pic_F77= - ;; - *) - lt_prog_compiler_pic_F77="$lt_prog_compiler_pic_F77" - ;; -esac - -echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 -echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 -if test "${lt_cv_prog_compiler_c_o_F77+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - lt_cv_prog_compiler_c_o_F77=no - $rm -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - printf "$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}? :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:13414: $lt_compile\"" >&5) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&5 - echo "$as_me:13418: \$? = $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 - if test ! -s out/conftest.err; then - lt_cv_prog_compiler_c_o_F77=yes - fi - fi - chmod u+w . - $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 .. - rmdir conftest - $rm conftest* - -fi -echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_F77" >&5 -echo "${ECHO_T}$lt_cv_prog_compiler_c_o_F77" >&6 - - -hard_links="nottested" -if test "$lt_cv_prog_compiler_c_o_F77" = no && test "$need_locks" != no; then - # do not overwrite the value of need_locks provided by the user - echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 -echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 - 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 - echo "$as_me:$LINENO: result: $hard_links" >&5 -echo "${ECHO_T}$hard_links" >&6 - if test "$hard_links" = no; then - { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 -echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} - need_locks=warn - fi -else - need_locks=no -fi - -echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 -echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 - - runpath_var= - allow_undefined_flag_F77= - enable_shared_with_static_runtimes_F77=no - archive_cmds_F77= - archive_expsym_cmds_F77= - old_archive_From_new_cmds_F77= - old_archive_from_expsyms_cmds_F77= - export_dynamic_flag_spec_F77= - whole_archive_flag_spec_F77= - thread_safe_flag_spec_F77= - hardcode_libdir_flag_spec_F77= - hardcode_libdir_flag_spec_ld_F77= - hardcode_libdir_separator_F77= - hardcode_direct_F77=no - hardcode_minus_L_F77=no - hardcode_shlibpath_var_F77=unsupported - link_all_deplibs_F77=unknown - hardcode_automatic_F77=no - module_cmds_F77= - module_expsym_cmds_F77= - always_export_symbols_F77=no - export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - # include_expsyms should be a list of space-separated symbols to be *always* - # included in the symbol list - include_expsyms_F77= - # 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'. - exclude_expsyms_F77="_GLOBAL_OFFSET_TABLE_" - # 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. - extract_expsyms_cmds= - - case $host_os in - cygwin* | mingw* | pw32*) - # 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 - ;; - openbsd*) - with_gnu_ld=no - ;; - esac - - ld_shlibs_F77=yes - if test "$with_gnu_ld" = yes; then - # If archive_cmds runs LD, not CC, wlarc should be empty - wlarc='${wl}' - - # See if GNU ld supports shared libraries. - case $host_os in - aix3* | aix4* | aix5*) - # On AIX/PPC, the GNU linker is very broken - if test "$host_cpu" != ia64; then - ld_shlibs_F77=no - cat <&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. - -EOF - fi - ;; - - amigaos*) - archive_cmds_F77='$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)' - hardcode_libdir_flag_spec_F77='-L$libdir' - hardcode_minus_L_F77=yes - - # Samuel A. Falvo II reports - # that the semantics of dynamic libraries on AmigaOS, at least up - # to version 4, is to share data among multiple programs linked - # with the same dynamic library. Since this doesn't match the - # behavior of shared libraries on other platforms, we can't use - # them. - ld_shlibs_F77=no - ;; - - beos*) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - allow_undefined_flag_F77=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - archive_cmds_F77='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - ld_shlibs_F77=no - fi - ;; - - cygwin* | mingw* | pw32*) - # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, F77) is actually meaningless, - # as there is no search path for DLLs. - hardcode_libdir_flag_spec_F77='-L$libdir' - allow_undefined_flag_F77=unsupported - always_export_symbols_F77=no - enable_shared_with_static_runtimes_F77=yes - export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' - - if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then - archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - archive_expsym_cmds_F77='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}--image-base=0x10000000 ${wl}--out-implib,$lib' - else - ld_shlibs=no - fi - ;; - - netbsd* | knetbsd*-gnu) - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - archive_cmds_F77='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' - wlarc= - else - archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - fi - ;; - - solaris* | sysv5*) - if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then - ld_shlibs_F77=no - cat <&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. - -EOF - elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - ld_shlibs_F77=no - fi - ;; - - sunos4*) - archive_cmds_F77='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' - wlarc= - hardcode_direct_F77=yes - hardcode_shlibpath_var_F77=no - ;; - - linux*) - if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then - tmp_archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_cmds_F77="$tmp_archive_cmds" - supports_anon_versioning=no - case `$LD -v 2>/dev/null` 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 - if test $supports_anon_versioning = yes; then - archive_expsym_cmds_F77='$echo "{ global:" > $output_objdir/$libname.ver~ -cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ -$echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' - else - archive_expsym_cmds_F77="$tmp_archive_cmds" - fi - else - ld_shlibs_F77=no - fi - ;; - - *) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - ld_shlibs_F77=no - fi - ;; - esac - - if test "$ld_shlibs_F77" = yes; then - runpath_var=LD_RUN_PATH - hardcode_libdir_flag_spec_F77='${wl}--rpath ${wl}$libdir' - export_dynamic_flag_spec_F77='${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_F77="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - whole_archive_flag_spec_F77= - fi - fi - else - # PORTME fill in a description of your system's linker (not GNU ld) - case $host_os in - aix3*) - allow_undefined_flag_F77=unsupported - always_export_symbols_F77=yes - archive_expsym_cmds_F77='$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. - hardcode_minus_L_F77=yes - if test "$GCC" = yes && test -z "$link_static_flag"; then - # Neither direct hardcoding nor static linking is supported with a - # broken collect2. - hardcode_direct_F77=unsupported - fi - ;; - - aix4* | aix5*) - 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 - export_symbols_cmds_F77='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' - else - export_symbols_cmds_F77='$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].*|aix5*) - 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. - - archive_cmds_F77='' - hardcode_direct_F77=yes - hardcode_libdir_separator_F77=':' - link_all_deplibs_F77=yes - - 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 - hardcode_direct_F77=yes - else - # We have old collect2 - hardcode_direct_F77=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 - hardcode_minus_L_F77=yes - hardcode_libdir_flag_spec_F77='-L$libdir' - hardcode_libdir_separator_F77= - fi - esac - shared_flag='-shared' - 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 - - # 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_F77=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. - allow_undefined_flag_F77='-berok' - # Determine the default libpath from the value encoded in an empty executable. - cat >conftest.$ac_ext <<_ACEOF - program main - - end -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'` -# 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 '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'`; fi -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi - - hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath" - archive_expsym_cmds_F77="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - hardcode_libdir_flag_spec_F77='${wl}-R $libdir:/usr/lib:/lib' - allow_undefined_flag_F77="-z nodefs" - archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an empty executable. - cat >conftest.$ac_ext <<_ACEOF - program main - - end -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'` -# 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 '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'`; fi -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi - - hardcode_libdir_flag_spec_F77='${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_F77=' ${wl}-bernotok' - allow_undefined_flag_F77=' ${wl}-berok' - # -bexpall does not export symbols beginning with underscore (_) - always_export_symbols_F77=yes - # Exported symbols can be pulled into shared objects from archives - whole_archive_flag_spec_F77=' ' - archive_cmds_need_lc_F77=yes - # This is similar to how AIX traditionally builds it's shared libraries. - archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - - amigaos*) - archive_cmds_F77='$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)' - hardcode_libdir_flag_spec_F77='-L$libdir' - hardcode_minus_L_F77=yes - # see comment about different semantics on the GNU ld section - ld_shlibs_F77=no - ;; - - bsdi4*) - export_dynamic_flag_spec_F77=-rdynamic - ;; - - cygwin* | mingw* | pw32*) - # 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. - hardcode_libdir_flag_spec_F77=' ' - allow_undefined_flag_F77=unsupported - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext=".dll" - # FIXME: Setting linknames here is a bad hack. - archive_cmds_F77='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' - # The linker will automatically build a .lib file if we build a DLL. - old_archive_From_new_cmds_F77='true' - # FIXME: Should let the user specify the lib program. - old_archive_cmds_F77='lib /OUT:$oldlib$oldobjs$old_deplibs' - fix_srcfile_path='`cygpath -w "$srcfile"`' - enable_shared_with_static_runtimes_F77=yes - ;; - - darwin* | rhapsody*) - if test "$GXX" = yes ; then - archive_cmds_need_lc_F77=no - case "$host_os" in - rhapsody* | darwin1.[012]) - allow_undefined_flag_F77='-undefined suppress' - ;; - *) # Darwin 1.3 on - if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then - allow_undefined_flag_F77='-flat_namespace -undefined suppress' - else - case ${MACOSX_DEPLOYMENT_TARGET} in - 10.[012]) - allow_undefined_flag_F77='-flat_namespace -undefined suppress' - ;; - 10.*) - allow_undefined_flag_F77='-undefined dynamic_lookup' - ;; - esac - fi - ;; - esac - lt_int_apple_cc_single_mod=no - output_verbose_link_cmd='echo' - if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then - lt_int_apple_cc_single_mod=yes - fi - if test "X$lt_int_apple_cc_single_mod" = Xyes ; then - archive_cmds_F77='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' - else - archive_cmds_F77='$CC -r ${wl}-bind_at_load -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' - fi - module_cmds_F77='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' - # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's - if test "X$lt_int_apple_cc_single_mod" = Xyes ; then - archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - else - archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -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~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - fi - module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - hardcode_direct_F77=no - hardcode_automatic_F77=yes - hardcode_shlibpath_var_F77=unsupported - whole_archive_flag_spec_F77='-all_load $convenience' - link_all_deplibs_F77=yes - else - ld_shlibs_F77=no - fi - ;; - - dgux*) - archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec_F77='-L$libdir' - hardcode_shlibpath_var_F77=no - ;; - - freebsd1*) - ld_shlibs_F77=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*) - archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' - hardcode_libdir_flag_spec_F77='-R$libdir' - hardcode_direct_F77=yes - hardcode_shlibpath_var_F77=no - ;; - - # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2*) - archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct_F77=yes - hardcode_minus_L_F77=yes - hardcode_shlibpath_var_F77=no - ;; - - # FreeBSD 3 and greater uses gcc -shared to do shared libraries. - freebsd* | kfreebsd*-gnu) - archive_cmds_F77='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' - hardcode_libdir_flag_spec_F77='-R$libdir' - hardcode_direct_F77=yes - hardcode_shlibpath_var_F77=no - ;; - - hpux9*) - if test "$GCC" = yes; then - archive_cmds_F77='$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 - archive_cmds_F77='$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 - hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir' - hardcode_libdir_separator_F77=: - hardcode_direct_F77=yes - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L_F77=yes - export_dynamic_flag_spec_F77='${wl}-E' - ;; - - hpux10* | hpux11*) - if test "$GCC" = yes -a "$with_gnu_ld" = no; then - case "$host_cpu" in - hppa*64*|ia64*) - archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - archive_cmds_F77='$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*|ia64*) - archive_cmds_F77='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags' - ;; - *) - archive_cmds_F77='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' - ;; - esac - fi - if test "$with_gnu_ld" = no; then - case "$host_cpu" in - hppa*64*) - hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir' - hardcode_libdir_flag_spec_ld_F77='+b $libdir' - hardcode_libdir_separator_F77=: - hardcode_direct_F77=no - hardcode_shlibpath_var_F77=no - ;; - ia64*) - hardcode_libdir_flag_spec_F77='-L$libdir' - hardcode_direct_F77=no - hardcode_shlibpath_var_F77=no - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L_F77=yes - ;; - *) - hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir' - hardcode_libdir_separator_F77=: - hardcode_direct_F77=yes - export_dynamic_flag_spec_F77='${wl}-E' - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L_F77=yes - ;; - esac - fi - ;; - - irix5* | irix6* | nonstopux*) - if test "$GCC" = yes; then - archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - archive_cmds_F77='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - hardcode_libdir_flag_spec_ld_F77='-rpath $libdir' - fi - hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator_F77=: - link_all_deplibs_F77=yes - ;; - - netbsd* | knetbsd*-gnu) - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out - else - archive_cmds_F77='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF - fi - hardcode_libdir_flag_spec_F77='-R$libdir' - hardcode_direct_F77=yes - hardcode_shlibpath_var_F77=no - ;; - - newsos6) - archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct_F77=yes - hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator_F77=: - hardcode_shlibpath_var_F77=no - ;; - - openbsd*) - hardcode_direct_F77=yes - hardcode_shlibpath_var_F77=no - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir' - export_dynamic_flag_spec_F77='${wl}-E' - else - case $host_os in - openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) - archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec_F77='-R$libdir' - ;; - *) - archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir' - ;; - esac - fi - ;; - - os2*) - hardcode_libdir_flag_spec_F77='-L$libdir' - hardcode_minus_L_F77=yes - allow_undefined_flag_F77=unsupported - archive_cmds_F77='$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_F77='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' - ;; - - osf3*) - if test "$GCC" = yes; then - allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - allow_undefined_flag_F77=' -expect_unresolved \*' - archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - fi - hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator_F77=: - ;; - - osf4* | osf5*) # as osf3* with the addition of -msym flag - if test "$GCC" = yes; then - allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' - else - allow_undefined_flag_F77=' -expect_unresolved \*' - archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - archive_expsym_cmds_F77='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ - $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp' - - # Both c and cxx compiler support -rpath directly - hardcode_libdir_flag_spec_F77='-rpath $libdir' - fi - hardcode_libdir_separator_F77=: - ;; - - sco3.2v5*) - archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_shlibpath_var_F77=no - export_dynamic_flag_spec_F77='${wl}-Bexport' - runpath_var=LD_RUN_PATH - hardcode_runpath_var=yes - ;; - - solaris*) - no_undefined_flag_F77=' -z text' - if test "$GCC" = yes; then - archive_cmds_F77='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ - $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' - else - archive_cmds_F77='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' - archive_expsym_cmds_F77='$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' - fi - hardcode_libdir_flag_spec_F77='-R$libdir' - hardcode_shlibpath_var_F77=no - case $host_os in - solaris2.[0-5] | solaris2.[0-5].*) ;; - *) # Supported since Solaris 2.6 (maybe 2.5.1?) - whole_archive_flag_spec_F77='-z allextract$convenience -z defaultextract' ;; - esac - link_all_deplibs_F77=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. - archive_cmds_F77='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds_F77='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' - fi - hardcode_libdir_flag_spec_F77='-L$libdir' - hardcode_direct_F77=yes - hardcode_minus_L_F77=yes - hardcode_shlibpath_var_F77=no - ;; - - sysv4) - case $host_vendor in - sni) - archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct_F77=yes # is this really true??? - ;; - siemens) - ## LD is ld it makes a PLAMLIB - ## CC just makes a GrossModule. - archive_cmds_F77='$LD -G -o $lib $libobjs $deplibs $linker_flags' - reload_cmds_F77='$CC -r -o $output$reload_objs' - hardcode_direct_F77=no - ;; - motorola) - archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct_F77=no #Motorola manual says yes, but my tests say they lie - ;; - esac - runpath_var='LD_RUN_PATH' - hardcode_shlibpath_var_F77=no - ;; - - sysv4.3*) - archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_shlibpath_var_F77=no - export_dynamic_flag_spec_F77='-Bexport' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_shlibpath_var_F77=no - runpath_var=LD_RUN_PATH - hardcode_runpath_var=yes - ld_shlibs_F77=yes - fi - ;; - - sysv4.2uw2*) - archive_cmds_F77='$LD -G -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct_F77=yes - hardcode_minus_L_F77=no - hardcode_shlibpath_var_F77=no - hardcode_runpath_var=yes - runpath_var=LD_RUN_PATH - ;; - - sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*) - no_undefined_flag_F77='${wl}-z ${wl}text' - if test "$GCC" = yes; then - archive_cmds_F77='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds_F77='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - runpath_var='LD_RUN_PATH' - hardcode_shlibpath_var_F77=no - ;; - - sysv5*) - no_undefined_flag_F77=' -z text' - # $CC -shared without GNU ld will not create a library from C++ - # object files and a static libstdc++, better avoid it by now - archive_cmds_F77='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' - archive_expsym_cmds_F77='$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' - hardcode_libdir_flag_spec_F77= - hardcode_shlibpath_var_F77=no - runpath_var='LD_RUN_PATH' - ;; - - uts4*) - archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec_F77='-L$libdir' - hardcode_shlibpath_var_F77=no - ;; - - *) - ld_shlibs_F77=no - ;; - esac - fi - -echo "$as_me:$LINENO: result: $ld_shlibs_F77" >&5 -echo "${ECHO_T}$ld_shlibs_F77" >&6 -test "$ld_shlibs_F77" = 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 - -# -# Do we need to explicitly link libc? -# -case "x$archive_cmds_need_lc_F77" in -x|xyes) - # Assume -lc should be added - archive_cmds_need_lc_F77=yes - - if test "$enable_shared" = yes && test "$GCC" = yes; then - case $archive_cmds_F77 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. - echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 -echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 - $rm conftest* - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } 2>conftest.err; then - soname=conftest - lib=conftest - libobjs=conftest.$ac_objext - deplibs= - wl=$lt_prog_compiler_wl_F77 - compiler_flags=-v - linker_flags=-v - verstring= - output_objdir=. - libname=conftest - lt_save_allow_undefined_flag=$allow_undefined_flag_F77 - allow_undefined_flag_F77= - if { (eval echo "$as_me:$LINENO: \"$archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 - (eval $archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } - then - archive_cmds_need_lc_F77=no - else - archive_cmds_need_lc_F77=yes - fi - allow_undefined_flag_F77=$lt_save_allow_undefined_flag - else - cat conftest.err 1>&5 - fi - $rm conftest* - echo "$as_me:$LINENO: result: $archive_cmds_need_lc_F77" >&5 -echo "${ECHO_T}$archive_cmds_need_lc_F77" >&6 - ;; - esac - fi - ;; -esac - -echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 -echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 -library_names_spec= -libname_spec='lib$name' -soname_spec= -shrext=".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" -if test "$GCC" = yes; then - 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 ';' >/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. - 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 -else - sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" -fi -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' - ;; - -aix4* | aix5*) - 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*) - 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' - ;; - -beos*) - library_names_spec='${libname}${shared_ext}' - dynamic_linker="$host_os ld.so" - shlibpath_var=LIBRARY_PATH - ;; - -bsdi4*) - 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*) - version_type=windows - shrext=".dll" - need_version=no - need_lib_prefix=no - - case $GCC,$host_os in - yes,cygwin* | yes,mingw* | yes,pw32*) - 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' - 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*) - # 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}${versuffix}$shared_ext ${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='$(test .$module = .yes && echo .so || echo .dylib)' - # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. - if test "$GCC" = yes; then - sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` - else - sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' - fi - 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 - ;; - -kfreebsd*-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 - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='GNU ld.so' - ;; - -freebsd*) - objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` - 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 - ;; - *) # from 3.2 on - shlibpath_overrides_runpath=no - 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='.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='.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='.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' - ;; - -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*) - 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 - # 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 - ld_extra=`$SED -e 's/:,\t/ /g;s/=^=*$//;s/=^= * / /g' /etc/ld.so.conf` - sys_lib_dlsearch_path_spec="/lib /usr/lib $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' - ;; - -knetbsd*-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 - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='GNU 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=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 - ;; - -openbsd*) - version_type=sunos - need_lib_prefix=no - need_version=yes - 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=".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" - ;; - -sco3.2v5*) - version_type=osf - 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 - ;; - -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.2uw2* | sysv4.3* | sysv5*) - 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 - export_dynamic_flag_spec='${wl}-Blargedynsym' - 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 - ;; - -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 -echo "$as_me:$LINENO: result: $dynamic_linker" >&5 -echo "${ECHO_T}$dynamic_linker" >&6 -test "$dynamic_linker" = no && can_build_shared=no - -echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 -echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 -hardcode_action_F77= -if test -n "$hardcode_libdir_flag_spec_F77" || \ - test -n "$runpath_var F77" || \ - test "X$hardcode_automatic_F77"="Xyes" ; then - - # We can hardcode non-existant directories. - if test "$hardcode_direct_F77" != 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_AC_TAGVAR(hardcode_shlibpath_var, F77)" != no && - test "$hardcode_minus_L_F77" != no; then - # Linking always hardcodes the temporary library directory. - hardcode_action_F77=relink - else - # We can link without hardcoding, and we can hardcode nonexisting dirs. - hardcode_action_F77=immediate - fi -else - # We cannot hardcode anything, or else we can only hardcode existing - # directories. - hardcode_action_F77=unsupported -fi -echo "$as_me:$LINENO: result: $hardcode_action_F77" >&5 -echo "${ECHO_T}$hardcode_action_F77" >&6 - -if test "$hardcode_action_F77" = relink; 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 - -striplib= -old_striplib= -echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5 -echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6 -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" - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 -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" - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 - else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - ;; - *) - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 - ;; - esac -fi - - - -# The else clause should only fire when bootstrapping the -# libtool distribution, otherwise you forgot to ship ltmain.sh -# with your package, and you will get complaints that there are -# no rules to generate ltmain.sh. -if test -f "$ltmain"; then - # 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 - # Now quote all the things that may contain metacharacters while being - # careful not to overquote the AC_SUBSTed values. We take copies of the - # variables and quote the copies for generation of the libtool script. - for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \ - SED SHELL STRIP \ - libname_spec library_names_spec soname_spec extract_expsyms_cmds \ - old_striplib striplib file_magic_cmd finish_cmds finish_eval \ - deplibs_check_method reload_flag reload_cmds need_locks \ - lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ - lt_cv_sys_global_symbol_to_c_name_address \ - sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ - old_postinstall_cmds old_postuninstall_cmds \ - compiler_F77 \ - CC_F77 \ - LD_F77 \ - lt_prog_compiler_wl_F77 \ - lt_prog_compiler_pic_F77 \ - lt_prog_compiler_static_F77 \ - lt_prog_compiler_no_builtin_flag_F77 \ - export_dynamic_flag_spec_F77 \ - thread_safe_flag_spec_F77 \ - whole_archive_flag_spec_F77 \ - enable_shared_with_static_runtimes_F77 \ - old_archive_cmds_F77 \ - old_archive_from_new_cmds_F77 \ - predep_objects_F77 \ - postdep_objects_F77 \ - predeps_F77 \ - postdeps_F77 \ - compiler_lib_search_path_F77 \ - archive_cmds_F77 \ - archive_expsym_cmds_F77 \ - postinstall_cmds_F77 \ - postuninstall_cmds_F77 \ - old_archive_from_expsyms_cmds_F77 \ - allow_undefined_flag_F77 \ - no_undefined_flag_F77 \ - export_symbols_cmds_F77 \ - hardcode_libdir_flag_spec_F77 \ - hardcode_libdir_flag_spec_ld_F77 \ - hardcode_libdir_separator_F77 \ - hardcode_automatic_F77 \ - module_cmds_F77 \ - module_expsym_cmds_F77 \ - lt_cv_prog_compiler_c_o_F77 \ - exclude_expsyms_F77 \ - include_expsyms_F77; do - - case $var in - old_archive_cmds_F77 | \ - old_archive_from_new_cmds_F77 | \ - archive_cmds_F77 | \ - archive_expsym_cmds_F77 | \ - module_cmds_F77 | \ - module_expsym_cmds_F77 | \ - old_archive_from_expsyms_cmds_F77 | \ - export_symbols_cmds_F77 | \ - extract_expsyms_cmds | reload_cmds | finish_cmds | \ - postinstall_cmds | postuninstall_cmds | \ - old_postinstall_cmds | old_postuninstall_cmds | \ - sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) - # Double-quote double-evaled strings. - eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" - ;; - *) - eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" - ;; - esac - done - - case $lt_echo in - *'\$0 --fallback-echo"') - lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` - ;; - esac - -cfgfile="$ofile" - - cat <<__EOF__ >> "$cfgfile" -# ### BEGIN LIBTOOL TAG CONFIG: $tagname - -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: - -# Shell to use when invoking shell scripts. -SHELL=$lt_SHELL - -# Whether or not to build shared libraries. -build_libtool_libs=$enable_shared - -# Whether or not to build static libraries. -build_old_libs=$enable_static - -# Whether or not to add -lc for building shared libraries. -build_libtool_need_lc=$archive_cmds_need_lc_F77 - -# Whether or not to disallow shared libs when runtime libs are static -allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_F77 - -# Whether or not to optimize for fast installation. -fast_install=$enable_fast_install - -# The host system. -host_alias=$host_alias -host=$host - -# An echo program that does not interpret backslashes. -echo=$lt_echo - -# The archiver. -AR=$lt_AR -AR_FLAGS=$lt_AR_FLAGS - -# A C compiler. -LTCC=$lt_LTCC - -# A language-specific compiler. -CC=$lt_compiler_F77 - -# Is the compiler the GNU C compiler? -with_gcc=$GCC_F77 - -# An ERE matcher. -EGREP=$lt_EGREP - -# The linker used to build libraries. -LD=$lt_LD_F77 - -# Whether we need hard or soft links. -LN_S=$lt_LN_S - -# A BSD-compatible nm program. -NM=$lt_NM - -# A symbol stripping program -STRIP=$lt_STRIP - -# Used to examine libraries when file_magic_cmd begins "file" -MAGIC_CMD=$MAGIC_CMD - -# Used on cygwin: DLL creation program. -DLLTOOL="$DLLTOOL" - -# Used on cygwin: object dumper. -OBJDUMP="$OBJDUMP" - -# Used on cygwin: assembler. -AS="$AS" - -# The name of the directory that contains temporary libtool files. -objdir=$objdir - -# How to create reloadable object files. -reload_flag=$lt_reload_flag -reload_cmds=$lt_reload_cmds - -# How to pass a linker flag through the compiler. -wl=$lt_lt_prog_compiler_wl_F77 - -# Object file suffix (normally "o"). -objext="$ac_objext" - -# Old archive suffix (normally "a"). -libext="$libext" - -# Shared library suffix (normally ".so"). -shrext='$shrext' - -# Executable file suffix (normally ""). -exeext="$exeext" - -# Additional compiler flags for building library objects. -pic_flag=$lt_lt_prog_compiler_pic_F77 -pic_mode=$pic_mode - -# What is the maximum length of a command? -max_cmd_len=$lt_cv_sys_max_cmd_len - -# Does compiler simultaneously support -c and -o options? -compiler_c_o=$lt_lt_cv_prog_compiler_c_o_F77 - -# Must we lock files when doing compilation ? -need_locks=$lt_need_locks - -# Do we need the lib prefix for modules? -need_lib_prefix=$need_lib_prefix - -# Do we need a version for libraries? -need_version=$need_version - -# Whether dlopen is supported. -dlopen_support=$enable_dlopen - -# Whether dlopen of programs is supported. -dlopen_self=$enable_dlopen_self - -# Whether dlopen of statically linked programs is supported. -dlopen_self_static=$enable_dlopen_self_static - -# Compiler flag to prevent dynamic linking. -link_static_flag=$lt_lt_prog_compiler_static_F77 - -# Compiler flag to turn off builtin functions. -no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_F77 - -# Compiler flag to allow reflexive dlopens. -export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_F77 - -# Compiler flag to generate shared objects directly from archives. -whole_archive_flag_spec=$lt_whole_archive_flag_spec_F77 - -# Compiler flag to generate thread-safe objects. -thread_safe_flag_spec=$lt_thread_safe_flag_spec_F77 - -# Library versioning type. -version_type=$version_type - -# Format of library name prefix. -libname_spec=$lt_libname_spec - -# 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. -library_names_spec=$lt_library_names_spec - -# The coded name of the library, if different from the real name. -soname_spec=$lt_soname_spec - -# Commands used to build and install an old-style archive. -RANLIB=$lt_RANLIB -old_archive_cmds=$lt_old_archive_cmds_F77 -old_postinstall_cmds=$lt_old_postinstall_cmds -old_postuninstall_cmds=$lt_old_postuninstall_cmds - -# Create an old-style archive from a shared archive. -old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_F77 - -# Create a temporary old-style archive to link instead of a shared archive. -old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_F77 - -# Commands used to build and install a shared archive. -archive_cmds=$lt_archive_cmds_F77 -archive_expsym_cmds=$lt_archive_expsym_cmds_F77 -postinstall_cmds=$lt_postinstall_cmds -postuninstall_cmds=$lt_postuninstall_cmds - -# Commands used to build a loadable module (assumed same as above if empty) -module_cmds=$lt_module_cmds_F77 -module_expsym_cmds=$lt_module_expsym_cmds_F77 - -# Commands to strip libraries. -old_striplib=$lt_old_striplib -striplib=$lt_striplib - -# Dependencies to place before the objects being linked to create a -# shared library. -predep_objects=$lt_predep_objects_F77 - -# Dependencies to place after the objects being linked to create a -# shared library. -postdep_objects=$lt_postdep_objects_F77 - -# Dependencies to place before the objects being linked to create a -# shared library. -predeps=$lt_predeps_F77 - -# Dependencies to place after the objects being linked to create a -# shared library. -postdeps=$lt_postdeps_F77 - -# The library search path used internally by the compiler when linking -# a shared library. -compiler_lib_search_path=$lt_compiler_lib_search_path_F77 - -# 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. -file_magic_cmd=$lt_file_magic_cmd - -# Flag that allows shared libraries with undefined symbols to be built. -allow_undefined_flag=$lt_allow_undefined_flag_F77 - -# Flag that forces no undefined symbols. -no_undefined_flag=$lt_no_undefined_flag_F77 - -# Commands used to finish a libtool library installation in a directory. -finish_cmds=$lt_finish_cmds - -# Same as above, but a single script fragment to be evaled but not shown. -finish_eval=$lt_finish_eval - -# Take the output of nm and produce a listing of raw symbols and C names. -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 in a C name address pair -global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address - -# This is the shared library runtime path variable. -runpath_var=$runpath_var - -# This is the shared library path variable. -shlibpath_var=$shlibpath_var - -# Is shlibpath searched before the hard-coded library search path? -shlibpath_overrides_runpath=$shlibpath_overrides_runpath - -# How to hardcode a shared library path into an executable. -hardcode_action=$hardcode_action_F77 - -# Whether we should hardcode library paths into libraries. -hardcode_into_libs=$hardcode_into_libs - -# Flag to hardcode \$libdir into a binary during linking. -# This must work even if \$libdir does not exist. -hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_F77 - -# 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_F77 - -# Whether we need a single -rpath flag with a separated argument. -hardcode_libdir_separator=$lt_hardcode_libdir_separator_F77 - -# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the -# resulting binary. -hardcode_direct=$hardcode_direct_F77 - -# Set to yes if using the -LDIR flag during linking hardcodes DIR into the -# resulting binary. -hardcode_minus_L=$hardcode_minus_L_F77 - -# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into -# the resulting binary. -hardcode_shlibpath_var=$hardcode_shlibpath_var_F77 - -# Set to yes if building a shared library automatically hardcodes DIR into the library -# and all subsequent libraries and executables linked against it. -hardcode_automatic=$hardcode_automatic_F77 - -# Variables whose values should be saved in libtool wrapper scripts and -# restored at relink time. -variables_saved_for_relink="$variables_saved_for_relink" - -# Whether libtool must link a program against all its dependency libraries. -link_all_deplibs=$link_all_deplibs_F77 - -# 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 - -# Fix the shell variable \$srcfile for the compiler. -fix_srcfile_path="$fix_srcfile_path_F77" - -# Set to yes if exported symbols are required. -always_export_symbols=$always_export_symbols_F77 - -# The commands to list exported symbols. -export_symbols_cmds=$lt_export_symbols_cmds_F77 - -# The commands to extract the exported symbol list from a shared archive. -extract_expsyms_cmds=$lt_extract_expsyms_cmds - -# Symbols that should not be listed in the preloaded symbols. -exclude_expsyms=$lt_exclude_expsyms_F77 - -# Symbols that must always be exported. -include_expsyms=$lt_include_expsyms_F77 - -# ### END LIBTOOL TAG CONFIG: $tagname - -__EOF__ - - -else - # If there is no Makefile yet, we rely on a make rule to execute - # `config.status --recheck' to rerun these tests and create the - # libtool script then. - ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` - if test -f "$ltmain_in"; then - test -f Makefile && make "$ltmain" - fi -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 - -CC="$lt_save_CC" - - else - tagname="" - fi - ;; - - GCJ) - if test -n "$GCJ" && test "X$GCJ" != "Xno"; then - - - -# Source file extension for Java test sources. -ac_ext=java - -# Object file extension for compiled Java test sources. -objext=o -objext_GCJ=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="class foo {}\n" - -# Code to be used in simple link tests -lt_simple_link_test_code='public class conftest { public static void main(String argv) {}; }\n' - -# ltmain only uses $CC for tagged configurations so make sure $CC is set. - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# Allow CC to be a program name with arguments. -compiler=$CC - - -# Allow CC to be a program name with arguments. -lt_save_CC="$CC" -CC=${GCJ-"gcj"} -compiler=$CC -compiler_GCJ=$CC - -# GCJ did not exist at the time GCC didn't implicitly link libc in. -archive_cmds_need_lc_GCJ=no - - -lt_prog_compiler_no_builtin_flag_GCJ= - -if test "$GCC" = yes; then - lt_prog_compiler_no_builtin_flag_GCJ=' -fno-builtin' - - -echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 -echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6 -if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - lt_cv_prog_compiler_rtti_exceptions=no - ac_outfile=conftest.$ac_objext - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="-fno-rtti -fno-exceptions" - # 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}? :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15446: $lt_compile\"" >&5) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&5 - echo "$as_me:15450: \$? = $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 - if test ! -s conftest.err; then - lt_cv_prog_compiler_rtti_exceptions=yes - fi - fi - $rm conftest* - -fi -echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 -echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6 - -if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then - lt_prog_compiler_no_builtin_flag_GCJ="$lt_prog_compiler_no_builtin_flag_GCJ -fno-rtti -fno-exceptions" -else - : -fi - -fi - -lt_prog_compiler_wl_GCJ= -lt_prog_compiler_pic_GCJ= -lt_prog_compiler_static_GCJ= - -echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 -echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 - - if test "$GCC" = yes; then - lt_prog_compiler_wl_GCJ='-Wl,' - lt_prog_compiler_static_GCJ='-static' - - case $host_os in - aix*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - lt_prog_compiler_static_GCJ='-Bstatic' - fi - ;; - - amigaos*) - # 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_prog_compiler_pic_GCJ='-m68020 -resident32 -malways-restore-a4' - ;; - - beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - - mingw* | pw32* | os2*) - # 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_GCJ='-DDLL_EXPORT' - ;; - - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - lt_prog_compiler_pic_GCJ='-fno-common' - ;; - - msdosdjgpp*) - # Just because we use GCC doesn't mean we suddenly get shared libraries - # on systems that don't support them. - lt_prog_compiler_can_build_shared_GCJ=no - enable_shared=no - ;; - - sysv4*MP*) - if test -d /usr/nec; then - lt_prog_compiler_pic_GCJ=-Kconform_pic - fi - ;; - - hpux*) - # 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_prog_compiler_pic_GCJ='-fPIC' - ;; - esac - ;; - - *) - lt_prog_compiler_pic_GCJ='-fPIC' - ;; - esac - else - # PORTME Check for flag to pass linker flags through the system compiler. - case $host_os in - aix*) - lt_prog_compiler_wl_GCJ='-Wl,' - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - lt_prog_compiler_static_GCJ='-Bstatic' - else - lt_prog_compiler_static_GCJ='-bnso -bI:/lib/syscalls.exp' - fi - ;; - - mingw* | pw32* | os2*) - # 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_GCJ='-DDLL_EXPORT' - ;; - - hpux9* | hpux10* | hpux11*) - lt_prog_compiler_wl_GCJ='-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_prog_compiler_pic_GCJ='+Z' - ;; - esac - # Is there a better lt_prog_compiler_static that works with the bundled CC? - lt_prog_compiler_static_GCJ='${wl}-a ${wl}archive' - ;; - - irix5* | irix6* | nonstopux*) - lt_prog_compiler_wl_GCJ='-Wl,' - # PIC (with -KPIC) is the default. - lt_prog_compiler_static_GCJ='-non_shared' - ;; - - newsos6) - lt_prog_compiler_pic_GCJ='-KPIC' - lt_prog_compiler_static_GCJ='-Bstatic' - ;; - - linux*) - case $CC in - icc* | ecc*) - lt_prog_compiler_wl_GCJ='-Wl,' - lt_prog_compiler_pic_GCJ='-KPIC' - lt_prog_compiler_static_GCJ='-static' - ;; - ccc*) - lt_prog_compiler_wl_GCJ='-Wl,' - # All Alpha code is PIC. - lt_prog_compiler_static_GCJ='-non_shared' - ;; - esac - ;; - - osf3* | osf4* | osf5*) - lt_prog_compiler_wl_GCJ='-Wl,' - # All OSF/1 code is PIC. - lt_prog_compiler_static_GCJ='-non_shared' - ;; - - sco3.2v5*) - lt_prog_compiler_pic_GCJ='-Kpic' - lt_prog_compiler_static_GCJ='-dn' - ;; - - solaris*) - lt_prog_compiler_wl_GCJ='-Wl,' - lt_prog_compiler_pic_GCJ='-KPIC' - lt_prog_compiler_static_GCJ='-Bstatic' - ;; - - sunos4*) - lt_prog_compiler_wl_GCJ='-Qoption ld ' - lt_prog_compiler_pic_GCJ='-PIC' - lt_prog_compiler_static_GCJ='-Bstatic' - ;; - - sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - lt_prog_compiler_wl_GCJ='-Wl,' - lt_prog_compiler_pic_GCJ='-KPIC' - lt_prog_compiler_static_GCJ='-Bstatic' - ;; - - sysv4*MP*) - if test -d /usr/nec ;then - lt_prog_compiler_pic_GCJ='-Kconform_pic' - lt_prog_compiler_static_GCJ='-Bstatic' - fi - ;; - - uts4*) - lt_prog_compiler_pic_GCJ='-pic' - lt_prog_compiler_static_GCJ='-Bstatic' - ;; - - *) - lt_prog_compiler_can_build_shared_GCJ=no - ;; - esac - fi - -echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_GCJ" >&5 -echo "${ECHO_T}$lt_prog_compiler_pic_GCJ" >&6 - -# -# Check to make sure the PIC flag actually works. -# -if test -n "$lt_prog_compiler_pic_GCJ"; then - -echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works" >&5 -echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works... $ECHO_C" >&6 -if test "${lt_prog_compiler_pic_works_GCJ+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - lt_prog_compiler_pic_works_GCJ=no - ac_outfile=conftest.$ac_objext - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="$lt_prog_compiler_pic_GCJ" - # 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}? :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15679: $lt_compile\"" >&5) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&5 - echo "$as_me:15683: \$? = $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 - if test ! -s conftest.err; then - lt_prog_compiler_pic_works_GCJ=yes - fi - fi - $rm conftest* - -fi -echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_GCJ" >&5 -echo "${ECHO_T}$lt_prog_compiler_pic_works_GCJ" >&6 - -if test x"$lt_prog_compiler_pic_works_GCJ" = xyes; then - case $lt_prog_compiler_pic_GCJ in - "" | " "*) ;; - *) lt_prog_compiler_pic_GCJ=" $lt_prog_compiler_pic_GCJ" ;; - esac -else - lt_prog_compiler_pic_GCJ= - lt_prog_compiler_can_build_shared_GCJ=no -fi - -fi -case "$host_os" in - # For platforms which do not support PIC, -DPIC is meaningless: - *djgpp*) - lt_prog_compiler_pic_GCJ= - ;; - *) - lt_prog_compiler_pic_GCJ="$lt_prog_compiler_pic_GCJ" - ;; -esac - -echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 -echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 -if test "${lt_cv_prog_compiler_c_o_GCJ+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - lt_cv_prog_compiler_c_o_GCJ=no - $rm -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - printf "$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}? :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15739: $lt_compile\"" >&5) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&5 - echo "$as_me:15743: \$? = $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 - if test ! -s out/conftest.err; then - lt_cv_prog_compiler_c_o_GCJ=yes - fi - fi - chmod u+w . - $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 .. - rmdir conftest - $rm conftest* - -fi -echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_GCJ" >&5 -echo "${ECHO_T}$lt_cv_prog_compiler_c_o_GCJ" >&6 - - -hard_links="nottested" -if test "$lt_cv_prog_compiler_c_o_GCJ" = no && test "$need_locks" != no; then - # do not overwrite the value of need_locks provided by the user - echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 -echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 - 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 - echo "$as_me:$LINENO: result: $hard_links" >&5 -echo "${ECHO_T}$hard_links" >&6 - if test "$hard_links" = no; then - { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 -echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} - need_locks=warn - fi -else - need_locks=no -fi - -echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 -echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 - - runpath_var= - allow_undefined_flag_GCJ= - enable_shared_with_static_runtimes_GCJ=no - archive_cmds_GCJ= - archive_expsym_cmds_GCJ= - old_archive_From_new_cmds_GCJ= - old_archive_from_expsyms_cmds_GCJ= - export_dynamic_flag_spec_GCJ= - whole_archive_flag_spec_GCJ= - thread_safe_flag_spec_GCJ= - hardcode_libdir_flag_spec_GCJ= - hardcode_libdir_flag_spec_ld_GCJ= - hardcode_libdir_separator_GCJ= - hardcode_direct_GCJ=no - hardcode_minus_L_GCJ=no - hardcode_shlibpath_var_GCJ=unsupported - link_all_deplibs_GCJ=unknown - hardcode_automatic_GCJ=no - module_cmds_GCJ= - module_expsym_cmds_GCJ= - always_export_symbols_GCJ=no - export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - # include_expsyms should be a list of space-separated symbols to be *always* - # included in the symbol list - include_expsyms_GCJ= - # 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'. - exclude_expsyms_GCJ="_GLOBAL_OFFSET_TABLE_" - # 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. - extract_expsyms_cmds= - - case $host_os in - cygwin* | mingw* | pw32*) - # 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 - ;; - openbsd*) - with_gnu_ld=no - ;; - esac - - ld_shlibs_GCJ=yes - if test "$with_gnu_ld" = yes; then - # If archive_cmds runs LD, not CC, wlarc should be empty - wlarc='${wl}' - - # See if GNU ld supports shared libraries. - case $host_os in - aix3* | aix4* | aix5*) - # On AIX/PPC, the GNU linker is very broken - if test "$host_cpu" != ia64; then - ld_shlibs_GCJ=no - cat <&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. - -EOF - fi - ;; - - amigaos*) - archive_cmds_GCJ='$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)' - hardcode_libdir_flag_spec_GCJ='-L$libdir' - hardcode_minus_L_GCJ=yes - - # Samuel A. Falvo II reports - # that the semantics of dynamic libraries on AmigaOS, at least up - # to version 4, is to share data among multiple programs linked - # with the same dynamic library. Since this doesn't match the - # behavior of shared libraries on other platforms, we can't use - # them. - ld_shlibs_GCJ=no - ;; - - beos*) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - allow_undefined_flag_GCJ=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - archive_cmds_GCJ='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - ld_shlibs_GCJ=no - fi - ;; - - cygwin* | mingw* | pw32*) - # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, GCJ) is actually meaningless, - # as there is no search path for DLLs. - hardcode_libdir_flag_spec_GCJ='-L$libdir' - allow_undefined_flag_GCJ=unsupported - always_export_symbols_GCJ=no - enable_shared_with_static_runtimes_GCJ=yes - export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' - - if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then - archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - archive_expsym_cmds_GCJ='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}--image-base=0x10000000 ${wl}--out-implib,$lib' - else - ld_shlibs=no - fi - ;; - - netbsd* | knetbsd*-gnu) - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - archive_cmds_GCJ='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' - wlarc= - else - archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - fi - ;; - - solaris* | sysv5*) - if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then - ld_shlibs_GCJ=no - cat <&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. - -EOF - elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - ld_shlibs_GCJ=no - fi - ;; - - sunos4*) - archive_cmds_GCJ='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' - wlarc= - hardcode_direct_GCJ=yes - hardcode_shlibpath_var_GCJ=no - ;; - - linux*) - if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then - tmp_archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_cmds_GCJ="$tmp_archive_cmds" - supports_anon_versioning=no - case `$LD -v 2>/dev/null` 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 - if test $supports_anon_versioning = yes; then - archive_expsym_cmds_GCJ='$echo "{ global:" > $output_objdir/$libname.ver~ -cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ -$echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' - else - archive_expsym_cmds_GCJ="$tmp_archive_cmds" - fi - else - ld_shlibs_GCJ=no - fi - ;; - - *) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - ld_shlibs_GCJ=no - fi - ;; - esac - - if test "$ld_shlibs_GCJ" = yes; then - runpath_var=LD_RUN_PATH - hardcode_libdir_flag_spec_GCJ='${wl}--rpath ${wl}$libdir' - export_dynamic_flag_spec_GCJ='${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_GCJ="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - whole_archive_flag_spec_GCJ= - fi - fi - else - # PORTME fill in a description of your system's linker (not GNU ld) - case $host_os in - aix3*) - allow_undefined_flag_GCJ=unsupported - always_export_symbols_GCJ=yes - archive_expsym_cmds_GCJ='$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. - hardcode_minus_L_GCJ=yes - if test "$GCC" = yes && test -z "$link_static_flag"; then - # Neither direct hardcoding nor static linking is supported with a - # broken collect2. - hardcode_direct_GCJ=unsupported - fi - ;; - - aix4* | aix5*) - 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 - export_symbols_cmds_GCJ='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' - else - export_symbols_cmds_GCJ='$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].*|aix5*) - 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. - - archive_cmds_GCJ='' - hardcode_direct_GCJ=yes - hardcode_libdir_separator_GCJ=':' - link_all_deplibs_GCJ=yes - - 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 - hardcode_direct_GCJ=yes - else - # We have old collect2 - hardcode_direct_GCJ=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 - hardcode_minus_L_GCJ=yes - hardcode_libdir_flag_spec_GCJ='-L$libdir' - hardcode_libdir_separator_GCJ= - fi - esac - shared_flag='-shared' - 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 - - # 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_GCJ=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. - allow_undefined_flag_GCJ='-berok' - # Determine the default libpath from the value encoded in an empty executable. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'` -# 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 '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'`; fi -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi - - hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath" - archive_expsym_cmds_GCJ="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - hardcode_libdir_flag_spec_GCJ='${wl}-R $libdir:/usr/lib:/lib' - allow_undefined_flag_GCJ="-z nodefs" - archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an empty executable. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'` -# 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 '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'`; fi -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi - - hardcode_libdir_flag_spec_GCJ='${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_GCJ=' ${wl}-bernotok' - allow_undefined_flag_GCJ=' ${wl}-berok' - # -bexpall does not export symbols beginning with underscore (_) - always_export_symbols_GCJ=yes - # Exported symbols can be pulled into shared objects from archives - whole_archive_flag_spec_GCJ=' ' - archive_cmds_need_lc_GCJ=yes - # This is similar to how AIX traditionally builds it's shared libraries. - archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - - amigaos*) - archive_cmds_GCJ='$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)' - hardcode_libdir_flag_spec_GCJ='-L$libdir' - hardcode_minus_L_GCJ=yes - # see comment about different semantics on the GNU ld section - ld_shlibs_GCJ=no - ;; - - bsdi4*) - export_dynamic_flag_spec_GCJ=-rdynamic - ;; - - cygwin* | mingw* | pw32*) - # 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. - hardcode_libdir_flag_spec_GCJ=' ' - allow_undefined_flag_GCJ=unsupported - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext=".dll" - # FIXME: Setting linknames here is a bad hack. - archive_cmds_GCJ='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' - # The linker will automatically build a .lib file if we build a DLL. - old_archive_From_new_cmds_GCJ='true' - # FIXME: Should let the user specify the lib program. - old_archive_cmds_GCJ='lib /OUT:$oldlib$oldobjs$old_deplibs' - fix_srcfile_path='`cygpath -w "$srcfile"`' - enable_shared_with_static_runtimes_GCJ=yes - ;; - - darwin* | rhapsody*) - if test "$GXX" = yes ; then - archive_cmds_need_lc_GCJ=no - case "$host_os" in - rhapsody* | darwin1.[012]) - allow_undefined_flag_GCJ='-undefined suppress' - ;; - *) # Darwin 1.3 on - if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then - allow_undefined_flag_GCJ='-flat_namespace -undefined suppress' - else - case ${MACOSX_DEPLOYMENT_TARGET} in - 10.[012]) - allow_undefined_flag_GCJ='-flat_namespace -undefined suppress' - ;; - 10.*) - allow_undefined_flag_GCJ='-undefined dynamic_lookup' - ;; - esac - fi - ;; - esac - lt_int_apple_cc_single_mod=no - output_verbose_link_cmd='echo' - if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then - lt_int_apple_cc_single_mod=yes - fi - if test "X$lt_int_apple_cc_single_mod" = Xyes ; then - archive_cmds_GCJ='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' - else - archive_cmds_GCJ='$CC -r ${wl}-bind_at_load -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' - fi - module_cmds_GCJ='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' - # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's - if test "X$lt_int_apple_cc_single_mod" = Xyes ; then - archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - else - archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -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~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - fi - module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - hardcode_direct_GCJ=no - hardcode_automatic_GCJ=yes - hardcode_shlibpath_var_GCJ=unsupported - whole_archive_flag_spec_GCJ='-all_load $convenience' - link_all_deplibs_GCJ=yes - else - ld_shlibs_GCJ=no - fi - ;; - - dgux*) - archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec_GCJ='-L$libdir' - hardcode_shlibpath_var_GCJ=no - ;; - - freebsd1*) - ld_shlibs_GCJ=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*) - archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' - hardcode_libdir_flag_spec_GCJ='-R$libdir' - hardcode_direct_GCJ=yes - hardcode_shlibpath_var_GCJ=no - ;; - - # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2*) - archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct_GCJ=yes - hardcode_minus_L_GCJ=yes - hardcode_shlibpath_var_GCJ=no - ;; - - # FreeBSD 3 and greater uses gcc -shared to do shared libraries. - freebsd* | kfreebsd*-gnu) - archive_cmds_GCJ='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' - hardcode_libdir_flag_spec_GCJ='-R$libdir' - hardcode_direct_GCJ=yes - hardcode_shlibpath_var_GCJ=no - ;; - - hpux9*) - if test "$GCC" = yes; then - archive_cmds_GCJ='$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 - archive_cmds_GCJ='$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 - hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir' - hardcode_libdir_separator_GCJ=: - hardcode_direct_GCJ=yes - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L_GCJ=yes - export_dynamic_flag_spec_GCJ='${wl}-E' - ;; - - hpux10* | hpux11*) - if test "$GCC" = yes -a "$with_gnu_ld" = no; then - case "$host_cpu" in - hppa*64*|ia64*) - archive_cmds_GCJ='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - archive_cmds_GCJ='$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*|ia64*) - archive_cmds_GCJ='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags' - ;; - *) - archive_cmds_GCJ='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' - ;; - esac - fi - if test "$with_gnu_ld" = no; then - case "$host_cpu" in - hppa*64*) - hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir' - hardcode_libdir_flag_spec_ld_GCJ='+b $libdir' - hardcode_libdir_separator_GCJ=: - hardcode_direct_GCJ=no - hardcode_shlibpath_var_GCJ=no - ;; - ia64*) - hardcode_libdir_flag_spec_GCJ='-L$libdir' - hardcode_direct_GCJ=no - hardcode_shlibpath_var_GCJ=no - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L_GCJ=yes - ;; - *) - hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir' - hardcode_libdir_separator_GCJ=: - hardcode_direct_GCJ=yes - export_dynamic_flag_spec_GCJ='${wl}-E' - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L_GCJ=yes - ;; - esac - fi - ;; - - irix5* | irix6* | nonstopux*) - if test "$GCC" = yes; then - archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - archive_cmds_GCJ='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - hardcode_libdir_flag_spec_ld_GCJ='-rpath $libdir' - fi - hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator_GCJ=: - link_all_deplibs_GCJ=yes - ;; - - netbsd* | knetbsd*-gnu) - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out - else - archive_cmds_GCJ='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF - fi - hardcode_libdir_flag_spec_GCJ='-R$libdir' - hardcode_direct_GCJ=yes - hardcode_shlibpath_var_GCJ=no - ;; - - newsos6) - archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct_GCJ=yes - hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator_GCJ=: - hardcode_shlibpath_var_GCJ=no - ;; - - openbsd*) - hardcode_direct_GCJ=yes - hardcode_shlibpath_var_GCJ=no - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir' - export_dynamic_flag_spec_GCJ='${wl}-E' - else - case $host_os in - openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) - archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec_GCJ='-R$libdir' - ;; - *) - archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir' - ;; - esac - fi - ;; - - os2*) - hardcode_libdir_flag_spec_GCJ='-L$libdir' - hardcode_minus_L_GCJ=yes - allow_undefined_flag_GCJ=unsupported - archive_cmds_GCJ='$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_GCJ='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' - ;; - - osf3*) - if test "$GCC" = yes; then - allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - allow_undefined_flag_GCJ=' -expect_unresolved \*' - archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - fi - hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator_GCJ=: - ;; - - osf4* | osf5*) # as osf3* with the addition of -msym flag - if test "$GCC" = yes; then - allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' - else - allow_undefined_flag_GCJ=' -expect_unresolved \*' - archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - archive_expsym_cmds_GCJ='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ - $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp' - - # Both c and cxx compiler support -rpath directly - hardcode_libdir_flag_spec_GCJ='-rpath $libdir' - fi - hardcode_libdir_separator_GCJ=: - ;; - - sco3.2v5*) - archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_shlibpath_var_GCJ=no - export_dynamic_flag_spec_GCJ='${wl}-Bexport' - runpath_var=LD_RUN_PATH - hardcode_runpath_var=yes - ;; - - solaris*) - no_undefined_flag_GCJ=' -z text' - if test "$GCC" = yes; then - archive_cmds_GCJ='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ - $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' - else - archive_cmds_GCJ='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' - archive_expsym_cmds_GCJ='$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' - fi - hardcode_libdir_flag_spec_GCJ='-R$libdir' - hardcode_shlibpath_var_GCJ=no - case $host_os in - solaris2.[0-5] | solaris2.[0-5].*) ;; - *) # Supported since Solaris 2.6 (maybe 2.5.1?) - whole_archive_flag_spec_GCJ='-z allextract$convenience -z defaultextract' ;; - esac - link_all_deplibs_GCJ=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. - archive_cmds_GCJ='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds_GCJ='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' - fi - hardcode_libdir_flag_spec_GCJ='-L$libdir' - hardcode_direct_GCJ=yes - hardcode_minus_L_GCJ=yes - hardcode_shlibpath_var_GCJ=no - ;; - - sysv4) - case $host_vendor in - sni) - archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct_GCJ=yes # is this really true??? - ;; - siemens) - ## LD is ld it makes a PLAMLIB - ## CC just makes a GrossModule. - archive_cmds_GCJ='$LD -G -o $lib $libobjs $deplibs $linker_flags' - reload_cmds_GCJ='$CC -r -o $output$reload_objs' - hardcode_direct_GCJ=no - ;; - motorola) - archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct_GCJ=no #Motorola manual says yes, but my tests say they lie - ;; - esac - runpath_var='LD_RUN_PATH' - hardcode_shlibpath_var_GCJ=no - ;; - - sysv4.3*) - archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_shlibpath_var_GCJ=no - export_dynamic_flag_spec_GCJ='-Bexport' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_shlibpath_var_GCJ=no - runpath_var=LD_RUN_PATH - hardcode_runpath_var=yes - ld_shlibs_GCJ=yes - fi - ;; - - sysv4.2uw2*) - archive_cmds_GCJ='$LD -G -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct_GCJ=yes - hardcode_minus_L_GCJ=no - hardcode_shlibpath_var_GCJ=no - hardcode_runpath_var=yes - runpath_var=LD_RUN_PATH - ;; - - sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*) - no_undefined_flag_GCJ='${wl}-z ${wl}text' - if test "$GCC" = yes; then - archive_cmds_GCJ='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds_GCJ='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - runpath_var='LD_RUN_PATH' - hardcode_shlibpath_var_GCJ=no - ;; - - sysv5*) - no_undefined_flag_GCJ=' -z text' - # $CC -shared without GNU ld will not create a library from C++ - # object files and a static libstdc++, better avoid it by now - archive_cmds_GCJ='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' - archive_expsym_cmds_GCJ='$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' - hardcode_libdir_flag_spec_GCJ= - hardcode_shlibpath_var_GCJ=no - runpath_var='LD_RUN_PATH' - ;; - - uts4*) - archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec_GCJ='-L$libdir' - hardcode_shlibpath_var_GCJ=no - ;; - - *) - ld_shlibs_GCJ=no - ;; - esac - fi - -echo "$as_me:$LINENO: result: $ld_shlibs_GCJ" >&5 -echo "${ECHO_T}$ld_shlibs_GCJ" >&6 -test "$ld_shlibs_GCJ" = 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 - -# -# Do we need to explicitly link libc? -# -case "x$archive_cmds_need_lc_GCJ" in -x|xyes) - # Assume -lc should be added - archive_cmds_need_lc_GCJ=yes - - if test "$enable_shared" = yes && test "$GCC" = yes; then - case $archive_cmds_GCJ 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. - echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 -echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 - $rm conftest* - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } 2>conftest.err; then - soname=conftest - lib=conftest - libobjs=conftest.$ac_objext - deplibs= - wl=$lt_prog_compiler_wl_GCJ - compiler_flags=-v - linker_flags=-v - verstring= - output_objdir=. - libname=conftest - lt_save_allow_undefined_flag=$allow_undefined_flag_GCJ - allow_undefined_flag_GCJ= - if { (eval echo "$as_me:$LINENO: \"$archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 - (eval $archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } - then - archive_cmds_need_lc_GCJ=no - else - archive_cmds_need_lc_GCJ=yes - fi - allow_undefined_flag_GCJ=$lt_save_allow_undefined_flag - else - cat conftest.err 1>&5 - fi - $rm conftest* - echo "$as_me:$LINENO: result: $archive_cmds_need_lc_GCJ" >&5 -echo "${ECHO_T}$archive_cmds_need_lc_GCJ" >&6 - ;; - esac - fi - ;; -esac - -echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 -echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 -library_names_spec= -libname_spec='lib$name' -soname_spec= -shrext=".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" -if test "$GCC" = yes; then - 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 ';' >/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. - 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 -else - sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" -fi -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' - ;; - -aix4* | aix5*) - 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*) - 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' - ;; - -beos*) - library_names_spec='${libname}${shared_ext}' - dynamic_linker="$host_os ld.so" - shlibpath_var=LIBRARY_PATH - ;; - -bsdi4*) - 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*) - version_type=windows - shrext=".dll" - need_version=no - need_lib_prefix=no - - case $GCC,$host_os in - yes,cygwin* | yes,mingw* | yes,pw32*) - 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' - 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*) - # 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}${versuffix}$shared_ext ${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='$(test .$module = .yes && echo .so || echo .dylib)' - # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. - if test "$GCC" = yes; then - sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` - else - sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' - fi - 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 - ;; - -kfreebsd*-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 - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='GNU ld.so' - ;; - -freebsd*) - objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` - 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 - ;; - *) # from 3.2 on - shlibpath_overrides_runpath=no - 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='.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='.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='.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' - ;; - -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*) - 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 - # 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 - ld_extra=`$SED -e 's/:,\t/ /g;s/=^=*$//;s/=^= * / /g' /etc/ld.so.conf` - sys_lib_dlsearch_path_spec="/lib /usr/lib $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' - ;; - -knetbsd*-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 - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='GNU 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=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 - ;; - -openbsd*) - version_type=sunos - need_lib_prefix=no - need_version=yes - 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=".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" - ;; - -sco3.2v5*) - version_type=osf - 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 - ;; - -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.2uw2* | sysv4.3* | sysv5*) - 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 - export_dynamic_flag_spec='${wl}-Blargedynsym' - 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 - ;; - -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 -echo "$as_me:$LINENO: result: $dynamic_linker" >&5 -echo "${ECHO_T}$dynamic_linker" >&6 -test "$dynamic_linker" = no && can_build_shared=no - -echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 -echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 -hardcode_action_GCJ= -if test -n "$hardcode_libdir_flag_spec_GCJ" || \ - test -n "$runpath_var GCJ" || \ - test "X$hardcode_automatic_GCJ"="Xyes" ; then - - # We can hardcode non-existant directories. - if test "$hardcode_direct_GCJ" != 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_AC_TAGVAR(hardcode_shlibpath_var, GCJ)" != no && - test "$hardcode_minus_L_GCJ" != no; then - # Linking always hardcodes the temporary library directory. - hardcode_action_GCJ=relink - else - # We can link without hardcoding, and we can hardcode nonexisting dirs. - hardcode_action_GCJ=immediate - fi -else - # We cannot hardcode anything, or else we can only hardcode existing - # directories. - hardcode_action_GCJ=unsupported -fi -echo "$as_me:$LINENO: result: $hardcode_action_GCJ" >&5 -echo "${ECHO_T}$hardcode_action_GCJ" >&6 - -if test "$hardcode_action_GCJ" = relink; 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 - -striplib= -old_striplib= -echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5 -echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6 -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" - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 -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" - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 - else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - ;; - *) - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 - ;; - esac -fi - -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*) - 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 - echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 -echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 -if test "${ac_cv_lib_dl_dlopen+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldl $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char dlopen (); -int -main () -{ -dlopen (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_lib_dl_dlopen=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_lib_dl_dlopen=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 -echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 -if test $ac_cv_lib_dl_dlopen = yes; then - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" -else - - lt_cv_dlopen="dyld" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - -fi - - ;; - - *) - echo "$as_me:$LINENO: checking for shl_load" >&5 -echo $ECHO_N "checking for shl_load... $ECHO_C" >&6 -if test "${ac_cv_func_shl_load+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define shl_load to an innocuous variant, in case declares shl_load. - For example, HP-UX 11i declares gettimeofday. */ -#define shl_load innocuous_shl_load - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char shl_load (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef shl_load - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -{ -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char shl_load (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_shl_load) || defined (__stub___shl_load) -choke me -#else -char (*f) () = shl_load; -#endif -#ifdef __cplusplus -} -#endif - -int -main () -{ -return f != shl_load; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_func_shl_load=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_func_shl_load=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5 -echo "${ECHO_T}$ac_cv_func_shl_load" >&6 -if test $ac_cv_func_shl_load = yes; then - lt_cv_dlopen="shl_load" -else - echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5 -echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6 -if test "${ac_cv_lib_dld_shl_load+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldld $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char shl_load (); -int -main () -{ -shl_load (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_lib_dld_shl_load=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_lib_dld_shl_load=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5 -echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6 -if test $ac_cv_lib_dld_shl_load = yes; then - lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld" -else - echo "$as_me:$LINENO: checking for dlopen" >&5 -echo $ECHO_N "checking for dlopen... $ECHO_C" >&6 -if test "${ac_cv_func_dlopen+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define dlopen to an innocuous variant, in case declares dlopen. - For example, HP-UX 11i declares gettimeofday. */ -#define dlopen innocuous_dlopen - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char dlopen (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef dlopen - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -{ -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char dlopen (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_dlopen) || defined (__stub___dlopen) -choke me -#else -char (*f) () = dlopen; -#endif -#ifdef __cplusplus -} -#endif - -int -main () -{ -return f != dlopen; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_func_dlopen=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_func_dlopen=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5 -echo "${ECHO_T}$ac_cv_func_dlopen" >&6 -if test $ac_cv_func_dlopen = yes; then - lt_cv_dlopen="dlopen" -else - echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 -echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 -if test "${ac_cv_lib_dl_dlopen+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldl $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char dlopen (); -int -main () -{ -dlopen (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_lib_dl_dlopen=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_lib_dl_dlopen=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 -echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 -if test $ac_cv_lib_dl_dlopen = yes; then - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" -else - echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5 -echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6 -if test "${ac_cv_lib_svld_dlopen+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lsvld $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char dlopen (); -int -main () -{ -dlopen (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_lib_svld_dlopen=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_lib_svld_dlopen=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5 -echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6 -if test $ac_cv_lib_svld_dlopen = yes; then - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" -else - echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5 -echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6 -if test "${ac_cv_lib_dld_dld_link+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldld $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char dld_link (); -int -main () -{ -dld_link (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_lib_dld_dld_link=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_lib_dld_dld_link=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5 -echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6 -if test $ac_cv_lib_dld_dld_link = yes; then - lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld" -fi - - -fi - - -fi - - -fi - - -fi - - -fi - - ;; - 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" - eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" - - save_LIBS="$LIBS" - LIBS="$lt_cv_dlopen_libs $LIBS" - - echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5 -echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6 -if test "${lt_cv_dlopen_self+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test "$cross_compiling" = yes; 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 < -#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 - -#ifdef __cplusplus -extern "C" void exit (int); -#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); */ - } - - exit (status); -} -EOF - if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) 2>/dev/null - lt_status=$? - case x$lt_status in - x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; - x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; - x$lt_unknown|x*) lt_cv_dlopen_self=no ;; - esac - else : - # compilation failed - lt_cv_dlopen_self=no - fi -fi -rm -fr conftest* - - -fi -echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5 -echo "${ECHO_T}$lt_cv_dlopen_self" >&6 - - if test "x$lt_cv_dlopen_self" = xyes; then - LDFLAGS="$LDFLAGS $link_static_flag" - echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5 -echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6 -if test "${lt_cv_dlopen_self_static+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test "$cross_compiling" = yes; 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 < -#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 - -#ifdef __cplusplus -extern "C" void exit (int); -#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); */ - } - - exit (status); -} -EOF - if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) 2>/dev/null - lt_status=$? - case x$lt_status in - x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; - x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; - x$lt_unknown|x*) lt_cv_dlopen_self_static=no ;; - esac - else : - # compilation failed - lt_cv_dlopen_self_static=no - fi -fi -rm -fr conftest* - - -fi -echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5 -echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6 - 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 - - -# The else clause should only fire when bootstrapping the -# libtool distribution, otherwise you forgot to ship ltmain.sh -# with your package, and you will get complaints that there are -# no rules to generate ltmain.sh. -if test -f "$ltmain"; then - # 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 - # Now quote all the things that may contain metacharacters while being - # careful not to overquote the AC_SUBSTed values. We take copies of the - # variables and quote the copies for generation of the libtool script. - for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \ - SED SHELL STRIP \ - libname_spec library_names_spec soname_spec extract_expsyms_cmds \ - old_striplib striplib file_magic_cmd finish_cmds finish_eval \ - deplibs_check_method reload_flag reload_cmds need_locks \ - lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ - lt_cv_sys_global_symbol_to_c_name_address \ - sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ - old_postinstall_cmds old_postuninstall_cmds \ - compiler_GCJ \ - CC_GCJ \ - LD_GCJ \ - lt_prog_compiler_wl_GCJ \ - lt_prog_compiler_pic_GCJ \ - lt_prog_compiler_static_GCJ \ - lt_prog_compiler_no_builtin_flag_GCJ \ - export_dynamic_flag_spec_GCJ \ - thread_safe_flag_spec_GCJ \ - whole_archive_flag_spec_GCJ \ - enable_shared_with_static_runtimes_GCJ \ - old_archive_cmds_GCJ \ - old_archive_from_new_cmds_GCJ \ - predep_objects_GCJ \ - postdep_objects_GCJ \ - predeps_GCJ \ - postdeps_GCJ \ - compiler_lib_search_path_GCJ \ - archive_cmds_GCJ \ - archive_expsym_cmds_GCJ \ - postinstall_cmds_GCJ \ - postuninstall_cmds_GCJ \ - old_archive_from_expsyms_cmds_GCJ \ - allow_undefined_flag_GCJ \ - no_undefined_flag_GCJ \ - export_symbols_cmds_GCJ \ - hardcode_libdir_flag_spec_GCJ \ - hardcode_libdir_flag_spec_ld_GCJ \ - hardcode_libdir_separator_GCJ \ - hardcode_automatic_GCJ \ - module_cmds_GCJ \ - module_expsym_cmds_GCJ \ - lt_cv_prog_compiler_c_o_GCJ \ - exclude_expsyms_GCJ \ - include_expsyms_GCJ; do - - case $var in - old_archive_cmds_GCJ | \ - old_archive_from_new_cmds_GCJ | \ - archive_cmds_GCJ | \ - archive_expsym_cmds_GCJ | \ - module_cmds_GCJ | \ - module_expsym_cmds_GCJ | \ - old_archive_from_expsyms_cmds_GCJ | \ - export_symbols_cmds_GCJ | \ - extract_expsyms_cmds | reload_cmds | finish_cmds | \ - postinstall_cmds | postuninstall_cmds | \ - old_postinstall_cmds | old_postuninstall_cmds | \ - sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) - # Double-quote double-evaled strings. - eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" - ;; - *) - eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" - ;; - esac - done - - case $lt_echo in - *'\$0 --fallback-echo"') - lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` - ;; - esac - -cfgfile="$ofile" - - cat <<__EOF__ >> "$cfgfile" -# ### BEGIN LIBTOOL TAG CONFIG: $tagname - -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: - -# Shell to use when invoking shell scripts. -SHELL=$lt_SHELL - -# Whether or not to build shared libraries. -build_libtool_libs=$enable_shared - -# Whether or not to build static libraries. -build_old_libs=$enable_static - -# Whether or not to add -lc for building shared libraries. -build_libtool_need_lc=$archive_cmds_need_lc_GCJ - -# Whether or not to disallow shared libs when runtime libs are static -allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_GCJ - -# Whether or not to optimize for fast installation. -fast_install=$enable_fast_install - -# The host system. -host_alias=$host_alias -host=$host - -# An echo program that does not interpret backslashes. -echo=$lt_echo - -# The archiver. -AR=$lt_AR -AR_FLAGS=$lt_AR_FLAGS - -# A C compiler. -LTCC=$lt_LTCC - -# A language-specific compiler. -CC=$lt_compiler_GCJ - -# Is the compiler the GNU C compiler? -with_gcc=$GCC_GCJ - -# An ERE matcher. -EGREP=$lt_EGREP - -# The linker used to build libraries. -LD=$lt_LD_GCJ - -# Whether we need hard or soft links. -LN_S=$lt_LN_S - -# A BSD-compatible nm program. -NM=$lt_NM - -# A symbol stripping program -STRIP=$lt_STRIP - -# Used to examine libraries when file_magic_cmd begins "file" -MAGIC_CMD=$MAGIC_CMD - -# Used on cygwin: DLL creation program. -DLLTOOL="$DLLTOOL" - -# Used on cygwin: object dumper. -OBJDUMP="$OBJDUMP" - -# Used on cygwin: assembler. -AS="$AS" - -# The name of the directory that contains temporary libtool files. -objdir=$objdir - -# How to create reloadable object files. -reload_flag=$lt_reload_flag -reload_cmds=$lt_reload_cmds - -# How to pass a linker flag through the compiler. -wl=$lt_lt_prog_compiler_wl_GCJ - -# Object file suffix (normally "o"). -objext="$ac_objext" - -# Old archive suffix (normally "a"). -libext="$libext" - -# Shared library suffix (normally ".so"). -shrext='$shrext' - -# Executable file suffix (normally ""). -exeext="$exeext" - -# Additional compiler flags for building library objects. -pic_flag=$lt_lt_prog_compiler_pic_GCJ -pic_mode=$pic_mode - -# What is the maximum length of a command? -max_cmd_len=$lt_cv_sys_max_cmd_len - -# Does compiler simultaneously support -c and -o options? -compiler_c_o=$lt_lt_cv_prog_compiler_c_o_GCJ - -# Must we lock files when doing compilation ? -need_locks=$lt_need_locks - -# Do we need the lib prefix for modules? -need_lib_prefix=$need_lib_prefix - -# Do we need a version for libraries? -need_version=$need_version - -# Whether dlopen is supported. -dlopen_support=$enable_dlopen - -# Whether dlopen of programs is supported. -dlopen_self=$enable_dlopen_self - -# Whether dlopen of statically linked programs is supported. -dlopen_self_static=$enable_dlopen_self_static - -# Compiler flag to prevent dynamic linking. -link_static_flag=$lt_lt_prog_compiler_static_GCJ - -# Compiler flag to turn off builtin functions. -no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_GCJ - -# Compiler flag to allow reflexive dlopens. -export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_GCJ - -# Compiler flag to generate shared objects directly from archives. -whole_archive_flag_spec=$lt_whole_archive_flag_spec_GCJ - -# Compiler flag to generate thread-safe objects. -thread_safe_flag_spec=$lt_thread_safe_flag_spec_GCJ - -# Library versioning type. -version_type=$version_type - -# Format of library name prefix. -libname_spec=$lt_libname_spec - -# 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. -library_names_spec=$lt_library_names_spec - -# The coded name of the library, if different from the real name. -soname_spec=$lt_soname_spec - -# Commands used to build and install an old-style archive. -RANLIB=$lt_RANLIB -old_archive_cmds=$lt_old_archive_cmds_GCJ -old_postinstall_cmds=$lt_old_postinstall_cmds -old_postuninstall_cmds=$lt_old_postuninstall_cmds - -# Create an old-style archive from a shared archive. -old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_GCJ - -# Create a temporary old-style archive to link instead of a shared archive. -old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_GCJ - -# Commands used to build and install a shared archive. -archive_cmds=$lt_archive_cmds_GCJ -archive_expsym_cmds=$lt_archive_expsym_cmds_GCJ -postinstall_cmds=$lt_postinstall_cmds -postuninstall_cmds=$lt_postuninstall_cmds - -# Commands used to build a loadable module (assumed same as above if empty) -module_cmds=$lt_module_cmds_GCJ -module_expsym_cmds=$lt_module_expsym_cmds_GCJ - -# Commands to strip libraries. -old_striplib=$lt_old_striplib -striplib=$lt_striplib - -# Dependencies to place before the objects being linked to create a -# shared library. -predep_objects=$lt_predep_objects_GCJ - -# Dependencies to place after the objects being linked to create a -# shared library. -postdep_objects=$lt_postdep_objects_GCJ - -# Dependencies to place before the objects being linked to create a -# shared library. -predeps=$lt_predeps_GCJ - -# Dependencies to place after the objects being linked to create a -# shared library. -postdeps=$lt_postdeps_GCJ - -# The library search path used internally by the compiler when linking -# a shared library. -compiler_lib_search_path=$lt_compiler_lib_search_path_GCJ - -# 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. -file_magic_cmd=$lt_file_magic_cmd - -# Flag that allows shared libraries with undefined symbols to be built. -allow_undefined_flag=$lt_allow_undefined_flag_GCJ - -# Flag that forces no undefined symbols. -no_undefined_flag=$lt_no_undefined_flag_GCJ - -# Commands used to finish a libtool library installation in a directory. -finish_cmds=$lt_finish_cmds - -# Same as above, but a single script fragment to be evaled but not shown. -finish_eval=$lt_finish_eval - -# Take the output of nm and produce a listing of raw symbols and C names. -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 in a C name address pair -global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address - -# This is the shared library runtime path variable. -runpath_var=$runpath_var - -# This is the shared library path variable. -shlibpath_var=$shlibpath_var - -# Is shlibpath searched before the hard-coded library search path? -shlibpath_overrides_runpath=$shlibpath_overrides_runpath - -# How to hardcode a shared library path into an executable. -hardcode_action=$hardcode_action_GCJ - -# Whether we should hardcode library paths into libraries. -hardcode_into_libs=$hardcode_into_libs - -# Flag to hardcode \$libdir into a binary during linking. -# This must work even if \$libdir does not exist. -hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_GCJ - -# 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_GCJ - -# Whether we need a single -rpath flag with a separated argument. -hardcode_libdir_separator=$lt_hardcode_libdir_separator_GCJ - -# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the -# resulting binary. -hardcode_direct=$hardcode_direct_GCJ - -# Set to yes if using the -LDIR flag during linking hardcodes DIR into the -# resulting binary. -hardcode_minus_L=$hardcode_minus_L_GCJ - -# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into -# the resulting binary. -hardcode_shlibpath_var=$hardcode_shlibpath_var_GCJ - -# Set to yes if building a shared library automatically hardcodes DIR into the library -# and all subsequent libraries and executables linked against it. -hardcode_automatic=$hardcode_automatic_GCJ - -# Variables whose values should be saved in libtool wrapper scripts and -# restored at relink time. -variables_saved_for_relink="$variables_saved_for_relink" - -# Whether libtool must link a program against all its dependency libraries. -link_all_deplibs=$link_all_deplibs_GCJ - -# 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 - -# Fix the shell variable \$srcfile for the compiler. -fix_srcfile_path="$fix_srcfile_path_GCJ" - -# Set to yes if exported symbols are required. -always_export_symbols=$always_export_symbols_GCJ - -# The commands to list exported symbols. -export_symbols_cmds=$lt_export_symbols_cmds_GCJ - -# The commands to extract the exported symbol list from a shared archive. -extract_expsyms_cmds=$lt_extract_expsyms_cmds - -# Symbols that should not be listed in the preloaded symbols. -exclude_expsyms=$lt_exclude_expsyms_GCJ - -# Symbols that must always be exported. -include_expsyms=$lt_include_expsyms_GCJ - -# ### END LIBTOOL TAG CONFIG: $tagname - -__EOF__ - - -else - # If there is no Makefile yet, we rely on a make rule to execute - # `config.status --recheck' to rerun these tests and create the - # libtool script then. - ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` - if test -f "$ltmain_in"; then - test -f Makefile && make "$ltmain" - fi -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 - -CC="$lt_save_CC" - - else - tagname="" - fi - ;; - - RC) - - - -# Source file extension for RC test sources. -ac_ext=rc - -# Object file extension for compiled RC test sources. -objext=o -objext_RC=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }\n' - -# 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. - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# Allow CC to be a program name with arguments. -compiler=$CC - - -# Allow CC to be a program name with arguments. -lt_save_CC="$CC" -CC=${RC-"windres"} -compiler=$CC -compiler_RC=$CC -lt_cv_prog_compiler_c_o_RC=yes - -# The else clause should only fire when bootstrapping the -# libtool distribution, otherwise you forgot to ship ltmain.sh -# with your package, and you will get complaints that there are -# no rules to generate ltmain.sh. -if test -f "$ltmain"; then - # 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 - # Now quote all the things that may contain metacharacters while being - # careful not to overquote the AC_SUBSTed values. We take copies of the - # variables and quote the copies for generation of the libtool script. - for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \ - SED SHELL STRIP \ - libname_spec library_names_spec soname_spec extract_expsyms_cmds \ - old_striplib striplib file_magic_cmd finish_cmds finish_eval \ - deplibs_check_method reload_flag reload_cmds need_locks \ - lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ - lt_cv_sys_global_symbol_to_c_name_address \ - sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ - old_postinstall_cmds old_postuninstall_cmds \ - compiler_RC \ - CC_RC \ - LD_RC \ - lt_prog_compiler_wl_RC \ - lt_prog_compiler_pic_RC \ - lt_prog_compiler_static_RC \ - lt_prog_compiler_no_builtin_flag_RC \ - export_dynamic_flag_spec_RC \ - thread_safe_flag_spec_RC \ - whole_archive_flag_spec_RC \ - enable_shared_with_static_runtimes_RC \ - old_archive_cmds_RC \ - old_archive_from_new_cmds_RC \ - predep_objects_RC \ - postdep_objects_RC \ - predeps_RC \ - postdeps_RC \ - compiler_lib_search_path_RC \ - archive_cmds_RC \ - archive_expsym_cmds_RC \ - postinstall_cmds_RC \ - postuninstall_cmds_RC \ - old_archive_from_expsyms_cmds_RC \ - allow_undefined_flag_RC \ - no_undefined_flag_RC \ - export_symbols_cmds_RC \ - hardcode_libdir_flag_spec_RC \ - hardcode_libdir_flag_spec_ld_RC \ - hardcode_libdir_separator_RC \ - hardcode_automatic_RC \ - module_cmds_RC \ - module_expsym_cmds_RC \ - lt_cv_prog_compiler_c_o_RC \ - exclude_expsyms_RC \ - include_expsyms_RC; do - - case $var in - old_archive_cmds_RC | \ - old_archive_from_new_cmds_RC | \ - archive_cmds_RC | \ - archive_expsym_cmds_RC | \ - module_cmds_RC | \ - module_expsym_cmds_RC | \ - old_archive_from_expsyms_cmds_RC | \ - export_symbols_cmds_RC | \ - extract_expsyms_cmds | reload_cmds | finish_cmds | \ - postinstall_cmds | postuninstall_cmds | \ - old_postinstall_cmds | old_postuninstall_cmds | \ - sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) - # Double-quote double-evaled strings. - eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" - ;; - *) - eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" - ;; - esac - done - - case $lt_echo in - *'\$0 --fallback-echo"') - lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` - ;; - esac - -cfgfile="$ofile" - - cat <<__EOF__ >> "$cfgfile" -# ### BEGIN LIBTOOL TAG CONFIG: $tagname - -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: - -# Shell to use when invoking shell scripts. -SHELL=$lt_SHELL - -# Whether or not to build shared libraries. -build_libtool_libs=$enable_shared - -# Whether or not to build static libraries. -build_old_libs=$enable_static - -# Whether or not to add -lc for building shared libraries. -build_libtool_need_lc=$archive_cmds_need_lc_RC - -# Whether or not to disallow shared libs when runtime libs are static -allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_RC - -# Whether or not to optimize for fast installation. -fast_install=$enable_fast_install - -# The host system. -host_alias=$host_alias -host=$host - -# An echo program that does not interpret backslashes. -echo=$lt_echo - -# The archiver. -AR=$lt_AR -AR_FLAGS=$lt_AR_FLAGS - -# A C compiler. -LTCC=$lt_LTCC - -# A language-specific compiler. -CC=$lt_compiler_RC - -# Is the compiler the GNU C compiler? -with_gcc=$GCC_RC - -# An ERE matcher. -EGREP=$lt_EGREP - -# The linker used to build libraries. -LD=$lt_LD_RC - -# Whether we need hard or soft links. -LN_S=$lt_LN_S - -# A BSD-compatible nm program. -NM=$lt_NM - -# A symbol stripping program -STRIP=$lt_STRIP - -# Used to examine libraries when file_magic_cmd begins "file" -MAGIC_CMD=$MAGIC_CMD - -# Used on cygwin: DLL creation program. -DLLTOOL="$DLLTOOL" - -# Used on cygwin: object dumper. -OBJDUMP="$OBJDUMP" - -# Used on cygwin: assembler. -AS="$AS" - -# The name of the directory that contains temporary libtool files. -objdir=$objdir - -# How to create reloadable object files. -reload_flag=$lt_reload_flag -reload_cmds=$lt_reload_cmds - -# How to pass a linker flag through the compiler. -wl=$lt_lt_prog_compiler_wl_RC - -# Object file suffix (normally "o"). -objext="$ac_objext" - -# Old archive suffix (normally "a"). -libext="$libext" - -# Shared library suffix (normally ".so"). -shrext='$shrext' - -# Executable file suffix (normally ""). -exeext="$exeext" - -# Additional compiler flags for building library objects. -pic_flag=$lt_lt_prog_compiler_pic_RC -pic_mode=$pic_mode - -# What is the maximum length of a command? -max_cmd_len=$lt_cv_sys_max_cmd_len - -# Does compiler simultaneously support -c and -o options? -compiler_c_o=$lt_lt_cv_prog_compiler_c_o_RC - -# Must we lock files when doing compilation ? -need_locks=$lt_need_locks - -# Do we need the lib prefix for modules? -need_lib_prefix=$need_lib_prefix - -# Do we need a version for libraries? -need_version=$need_version - -# Whether dlopen is supported. -dlopen_support=$enable_dlopen - -# Whether dlopen of programs is supported. -dlopen_self=$enable_dlopen_self - -# Whether dlopen of statically linked programs is supported. -dlopen_self_static=$enable_dlopen_self_static - -# Compiler flag to prevent dynamic linking. -link_static_flag=$lt_lt_prog_compiler_static_RC - -# Compiler flag to turn off builtin functions. -no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_RC - -# Compiler flag to allow reflexive dlopens. -export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_RC - -# Compiler flag to generate shared objects directly from archives. -whole_archive_flag_spec=$lt_whole_archive_flag_spec_RC - -# Compiler flag to generate thread-safe objects. -thread_safe_flag_spec=$lt_thread_safe_flag_spec_RC - -# Library versioning type. -version_type=$version_type - -# Format of library name prefix. -libname_spec=$lt_libname_spec - -# 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. -library_names_spec=$lt_library_names_spec - -# The coded name of the library, if different from the real name. -soname_spec=$lt_soname_spec - -# Commands used to build and install an old-style archive. -RANLIB=$lt_RANLIB -old_archive_cmds=$lt_old_archive_cmds_RC -old_postinstall_cmds=$lt_old_postinstall_cmds -old_postuninstall_cmds=$lt_old_postuninstall_cmds - -# Create an old-style archive from a shared archive. -old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_RC - -# Create a temporary old-style archive to link instead of a shared archive. -old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_RC - -# Commands used to build and install a shared archive. -archive_cmds=$lt_archive_cmds_RC -archive_expsym_cmds=$lt_archive_expsym_cmds_RC -postinstall_cmds=$lt_postinstall_cmds -postuninstall_cmds=$lt_postuninstall_cmds - -# Commands used to build a loadable module (assumed same as above if empty) -module_cmds=$lt_module_cmds_RC -module_expsym_cmds=$lt_module_expsym_cmds_RC - -# Commands to strip libraries. -old_striplib=$lt_old_striplib -striplib=$lt_striplib - -# Dependencies to place before the objects being linked to create a -# shared library. -predep_objects=$lt_predep_objects_RC - -# Dependencies to place after the objects being linked to create a -# shared library. -postdep_objects=$lt_postdep_objects_RC - -# Dependencies to place before the objects being linked to create a -# shared library. -predeps=$lt_predeps_RC - -# Dependencies to place after the objects being linked to create a -# shared library. -postdeps=$lt_postdeps_RC - -# The library search path used internally by the compiler when linking -# a shared library. -compiler_lib_search_path=$lt_compiler_lib_search_path_RC - -# 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. -file_magic_cmd=$lt_file_magic_cmd - -# Flag that allows shared libraries with undefined symbols to be built. -allow_undefined_flag=$lt_allow_undefined_flag_RC - -# Flag that forces no undefined symbols. -no_undefined_flag=$lt_no_undefined_flag_RC - -# Commands used to finish a libtool library installation in a directory. -finish_cmds=$lt_finish_cmds - -# Same as above, but a single script fragment to be evaled but not shown. -finish_eval=$lt_finish_eval - -# Take the output of nm and produce a listing of raw symbols and C names. -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 in a C name address pair -global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address - -# This is the shared library runtime path variable. -runpath_var=$runpath_var - -# This is the shared library path variable. -shlibpath_var=$shlibpath_var - -# Is shlibpath searched before the hard-coded library search path? -shlibpath_overrides_runpath=$shlibpath_overrides_runpath - -# How to hardcode a shared library path into an executable. -hardcode_action=$hardcode_action_RC - -# Whether we should hardcode library paths into libraries. -hardcode_into_libs=$hardcode_into_libs - -# Flag to hardcode \$libdir into a binary during linking. -# This must work even if \$libdir does not exist. -hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_RC - -# 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_RC - -# Whether we need a single -rpath flag with a separated argument. -hardcode_libdir_separator=$lt_hardcode_libdir_separator_RC - -# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the -# resulting binary. -hardcode_direct=$hardcode_direct_RC - -# Set to yes if using the -LDIR flag during linking hardcodes DIR into the -# resulting binary. -hardcode_minus_L=$hardcode_minus_L_RC - -# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into -# the resulting binary. -hardcode_shlibpath_var=$hardcode_shlibpath_var_RC - -# Set to yes if building a shared library automatically hardcodes DIR into the library -# and all subsequent libraries and executables linked against it. -hardcode_automatic=$hardcode_automatic_RC - -# Variables whose values should be saved in libtool wrapper scripts and -# restored at relink time. -variables_saved_for_relink="$variables_saved_for_relink" - -# Whether libtool must link a program against all its dependency libraries. -link_all_deplibs=$link_all_deplibs_RC - -# 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 - -# Fix the shell variable \$srcfile for the compiler. -fix_srcfile_path="$fix_srcfile_path_RC" - -# Set to yes if exported symbols are required. -always_export_symbols=$always_export_symbols_RC - -# The commands to list exported symbols. -export_symbols_cmds=$lt_export_symbols_cmds_RC - -# The commands to extract the exported symbol list from a shared archive. -extract_expsyms_cmds=$lt_extract_expsyms_cmds - -# Symbols that should not be listed in the preloaded symbols. -exclude_expsyms=$lt_exclude_expsyms_RC - -# Symbols that must always be exported. -include_expsyms=$lt_include_expsyms_RC - -# ### END LIBTOOL TAG CONFIG: $tagname - -__EOF__ - - -else - # If there is no Makefile yet, we rely on a make rule to execute - # `config.status --recheck' to rerun these tests and create the - # libtool script then. - ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` - if test -f "$ltmain_in"; then - test -f Makefile && make "$ltmain" - fi -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 - -CC="$lt_save_CC" - - ;; - - *) - { { echo "$as_me:$LINENO: error: Unsupported tag name: $tagname" >&5 -echo "$as_me: error: Unsupported tag name: $tagname" >&2;} - { (exit 1); exit 1; }; } - ;; - esac - - # Append the new tag name to the list of available tags. - if test -n "$tagname" ; then - available_tags="$available_tags $tagname" - fi - fi - done - IFS="$lt_save_ifs" - - # Now substitute the updated list of available tags. - if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then - mv "${ofile}T" "$ofile" - chmod +x "$ofile" - else - rm -f "${ofile}T" - { { echo "$as_me:$LINENO: error: unable to update list of available tagged configurations." >&5 -echo "$as_me: error: unable to update list of available tagged configurations." >&2;} - { (exit 1); exit 1; }; } - fi -fi - - - -# This can be used to rebuild libtool when needed -LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" - -# Always use our own libtool. -LIBTOOL='$(SHELL) $(top_builddir)/libtool' - -# Prevent multiple expansion - - - - - - - - - - - - - - - - - - - - - - - - -arch="" -debug="" -optimize="" -profile="" - -set -- $CFLAGS -CFLAGS="" - -if test "$GCC" = yes -then - CFLAGS="-Wall" -fi - -while test $# -gt 0 -do - case "$1" in - -Wall) - if test "$GCC" = yes - then - : - else - CFLAGS="$CFLAGS $1" - fi - shift - ;; - -g) - debug="-g" - shift - ;; - -mno-cygwin) - shift - ;; - -m*) - arch="$arch $1" - shift - ;; - -O2) - optimize="-O" - shift - ;; - -fomit-frame-pointer) - shift - ;; - -O*|-f*) - optimize="$optimize $1" - shift - ;; - *) - CFLAGS="$CFLAGS $1" - shift - ;; - esac -done - -if test "$GCC" = yes -then - if test -z "$arch" - then - case "$host" in - i386-*) ;; - i?86-*) arch="-march=i486" ;; - arm*-empeg-*) arch="-march=armv4 -mtune=strongarm1100" ;; - armv4*-*) arch="-march=armv4 -mtune=strongarm" ;; - powerpc-*) ;; - mips*-agenda-*) arch="-mcpu=vr4100" ;; - mips*-luxsonor-*) arch="-mips1 -mcpu=r3000 -Wa,-m4010" ;; - esac - fi - - case "$optimize" in - -O|"-O "*) - optimize="-O" - optimize="$optimize -fforce-mem" - optimize="$optimize -fforce-addr" - : #x optimize="$optimize -finline-functions" - : #- optimize="$optimize -fstrength-reduce" - optimize="$optimize -fthread-jumps" - optimize="$optimize -fcse-follow-jumps" - optimize="$optimize -fcse-skip-blocks" - : #x optimize="$optimize -frerun-cse-after-loop" - : #x optimize="$optimize -frerun-loop-opt" - : #x optimize="$optimize -fgcse" - optimize="$optimize -fexpensive-optimizations" - optimize="$optimize -fregmove" - : #* optimize="$optimize -fdelayed-branch" - : #x optimize="$optimize -fschedule-insns" - optimize="$optimize -fschedule-insns2" - : #? optimize="$optimize -ffunction-sections" - : #? optimize="$optimize -fcaller-saves" - : #> optimize="$optimize -funroll-loops" - : #> optimize="$optimize -funroll-all-loops" - : #x optimize="$optimize -fmove-all-movables" - : #x optimize="$optimize -freduce-all-givs" - : #? optimize="$optimize -fstrict-aliasing" - : #* optimize="$optimize -fstructure-noalias" - - case "$host" in - arm*-*) - optimize="$optimize -fstrength-reduce" - ;; - mips*-*) - optimize="$optimize -fstrength-reduce" - optimize="$optimize -finline-functions" - ;; - i?86-*) - optimize="$optimize -fstrength-reduce" - ;; - powerpc-apple-*) - # this triggers an internal compiler error with gcc2 - : #optimize="$optimize -fstrength-reduce" - - # this is really only beneficial with gcc3 - : #optimize="$optimize -finline-functions" - ;; - *) - # this sometimes provokes bugs in gcc 2.95.2 - : #optimize="$optimize -fstrength-reduce" - ;; - esac - ;; - esac -fi - -case "$host" in - mips*-agenda-*) - -cat >>confdefs.h <<\_ACEOF -#define HAVE_MADD16_ASM 1 -_ACEOF - - ;; - mips*-luxsonor-*) - -cat >>confdefs.h <<\_ACEOF -#define HAVE_MADD_ASM 1 -_ACEOF - - ;; -esac - - -echo "$as_me:$LINENO: checking for ANSI C header files" >&5 -echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 -if test "${ac_cv_header_stdc+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include -#include -#include - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_header_stdc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_header_stdc=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then - : -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then - : -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then - : -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - exit(2); - exit (0); -} -_ACEOF -rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -ac_cv_header_stdc=no -fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi -fi -fi -echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 -echo "${ECHO_T}$ac_cv_header_stdc" >&6 -if test $ac_cv_header_stdc = yes; then - -cat >>confdefs.h <<\_ACEOF -#define STDC_HEADERS 1 -_ACEOF - -fi - -echo "$as_me:$LINENO: checking for sys/wait.h that is POSIX.1 compatible" >&5 -echo $ECHO_N "checking for sys/wait.h that is POSIX.1 compatible... $ECHO_C" >&6 -if test "${ac_cv_header_sys_wait_h+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include -#ifndef WEXITSTATUS -# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) -#endif -#ifndef WIFEXITED -# define WIFEXITED(stat_val) (((stat_val) & 255) == 0) -#endif - -int -main () -{ - int s; - wait (&s); - s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_header_sys_wait_h=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_header_sys_wait_h=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_header_sys_wait_h" >&5 -echo "${ECHO_T}$ac_cv_header_sys_wait_h" >&6 -if test $ac_cv_header_sys_wait_h = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_SYS_WAIT_H 1 -_ACEOF - -fi - - - - - - - -for ac_header in assert.h limits.h unistd.h sys/types.h fcntl.h errno.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -else - # Is the header compilable? -echo "$as_me:$LINENO: checking $ac_header usability" >&5 -echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_header_compiler=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_header_compiler=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6 - -# Is the header present? -echo "$as_me:$LINENO: checking $ac_header presence" >&5 -echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - ac_header_preproc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi -rm -f conftest.err conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6 - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - ( - cat <<\_ASBOX -## ----------------------------------- ## -## Report this to support@underbit.com ## -## ----------------------------------- ## -_ASBOX - ) | - sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 - -fi -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - - -echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 -echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6 -if test "${ac_cv_c_const+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ -/* FIXME: Include the comments suggested by Paul. */ -#ifndef __cplusplus - /* Ultrix mips cc rejects this. */ - typedef int charset[2]; - const charset x; - /* SunOS 4.1.1 cc rejects this. */ - char const *const *ccp; - char **p; - /* NEC SVR4.0.2 mips cc rejects this. */ - struct point {int x, y;}; - static struct point const zero = {0,0}; - /* AIX XL C 1.02.0.0 rejects this. - It does not let you subtract one const X* pointer from another in - an arm of an if-expression whose if-part is not a constant - expression */ - const char *g = "string"; - ccp = &g + (g ? g-g : 0); - /* HPUX 7.0 cc rejects these. */ - ++ccp; - p = (char**) ccp; - ccp = (char const *const *) p; - { /* SCO 3.2v4 cc rejects this. */ - char *t; - char const *s = 0 ? (char *) 0 : (char const *) 0; - - *t++ = 0; - } - { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ - int x[] = {25, 17}; - const int *foo = &x[0]; - ++foo; - } - { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ - typedef const int *iptr; - iptr p = 0; - ++p; - } - { /* AIX XL C 1.02.0.0 rejects this 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; - } - { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ - const int foo = 10; - } -#endif - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_c_const=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_c_const=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 -echo "${ECHO_T}$ac_cv_c_const" >&6 -if test $ac_cv_c_const = no; then - -cat >>confdefs.h <<\_ACEOF -#define const -_ACEOF - -fi - -echo "$as_me:$LINENO: checking for inline" >&5 -echo $ECHO_N "checking for inline... $ECHO_C" >&6 -if test "${ac_cv_c_inline+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_cv_c_inline=no -for ac_kw in inline __inline__ __inline; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#ifndef __cplusplus -typedef int foo_t; -static $ac_kw foo_t static_foo () {return 0; } -$ac_kw foo_t foo () {return 0; } -#endif - -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_c_inline=$ac_kw; break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -done - -fi -echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5 -echo "${ECHO_T}$ac_cv_c_inline" >&6 - - -case $ac_cv_c_inline in - inline | yes) ;; - *) - case $ac_cv_c_inline in - no) ac_val=;; - *) ac_val=$ac_cv_c_inline;; - esac - cat >>confdefs.h <<_ACEOF -#ifndef __cplusplus -#define inline $ac_val -#endif -_ACEOF - ;; -esac - -echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 -echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6 -if test "${ac_cv_c_bigendian+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - # See if sys/param.h defines the BYTE_ORDER macro. -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include - -int -main () -{ -#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN - bogus endian macros -#endif - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - # It does; now see whether it defined to BIG_ENDIAN or not. -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include - -int -main () -{ -#if BYTE_ORDER != BIG_ENDIAN - not big endian -#endif - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_c_bigendian=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_c_bigendian=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -# It does not; compile a test program. -if test "$cross_compiling" = yes; then - # try to guess the endianness by grepping values into an object file - ac_cv_c_bigendian=unknown - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; -short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; -void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; } -short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; -short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; -void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; } -int -main () -{ - _ascii (); _ebcdic (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then - ac_cv_c_bigendian=yes -fi -if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then - if test "$ac_cv_c_bigendian" = unknown; then - ac_cv_c_bigendian=no - else - # finding both strings is unlikely to happen, but who knows? - ac_cv_c_bigendian=unknown - fi -fi -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -int -main () -{ - /* Are we little or big endian? From Harbison&Steele. */ - union - { - long l; - char c[sizeof (long)]; - } u; - u.l = 1; - exit (u.c[sizeof (long) - 1] == 1); -} -_ACEOF -rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_c_bigendian=no -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -ac_cv_c_bigendian=yes -fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 -echo "${ECHO_T}$ac_cv_c_bigendian" >&6 -case $ac_cv_c_bigendian in - yes) - -cat >>confdefs.h <<\_ACEOF -#define WORDS_BIGENDIAN 1 -_ACEOF - ;; - no) - ;; - *) - { { echo "$as_me:$LINENO: error: unknown endianness -presetting ac_cv_c_bigendian=no (or yes) will help" >&5 -echo "$as_me: error: unknown endianness -presetting ac_cv_c_bigendian=no (or yes) will help" >&2;} - { (exit 1); exit 1; }; } ;; -esac - -echo "$as_me:$LINENO: checking for pid_t" >&5 -echo $ECHO_N "checking for pid_t... $ECHO_C" >&6 -if test "${ac_cv_type_pid_t+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -if ((pid_t *) 0) - return 0; -if (sizeof (pid_t)) - return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_type_pid_t=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_type_pid_t=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_type_pid_t" >&5 -echo "${ECHO_T}$ac_cv_type_pid_t" >&6 -if test $ac_cv_type_pid_t = yes; then - : -else - -cat >>confdefs.h <<_ACEOF -#define pid_t int -_ACEOF - -fi - - -echo "$as_me:$LINENO: checking for int" >&5 -echo $ECHO_N "checking for int... $ECHO_C" >&6 -if test "${ac_cv_type_int+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -if ((int *) 0) - return 0; -if (sizeof (int)) - return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_type_int=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_type_int=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_type_int" >&5 -echo "${ECHO_T}$ac_cv_type_int" >&6 - -echo "$as_me:$LINENO: checking size of int" >&5 -echo $ECHO_N "checking size of int... $ECHO_C" >&6 -if test "${ac_cv_sizeof_int+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test "$ac_cv_type_int" = yes; then - # The cast to unsigned long works around a bug in the HP C Compiler - # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects - # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. - # This bug is HP SR number 8606223364. - if test "$cross_compiling" = yes; then - # Depending upon the size, compute the lo and hi bounds. -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(((long) (sizeof (int))) >= 0)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_lo=0 ac_mid=0 - while :; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(((long) (sizeof (int))) <= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_hi=$ac_mid; break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_lo=`expr $ac_mid + 1` - if test $ac_lo -le $ac_mid; then - ac_lo= ac_hi= - break - fi - ac_mid=`expr 2 '*' $ac_mid + 1` -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - done -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(((long) (sizeof (int))) < 0)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_hi=-1 ac_mid=-1 - while :; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(((long) (sizeof (int))) >= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_lo=$ac_mid; break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_hi=`expr '(' $ac_mid ')' - 1` - if test $ac_mid -le $ac_hi; then - ac_lo= ac_hi= - break - fi - ac_mid=`expr 2 '*' $ac_mid` -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - done -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_lo= ac_hi= -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -# Binary search between lo and hi bounds. -while test "x$ac_lo" != "x$ac_hi"; do - ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(((long) (sizeof (int))) <= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_hi=$ac_mid -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_lo=`expr '(' $ac_mid ')' + 1` -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -done -case $ac_lo in -?*) ac_cv_sizeof_int=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (int), 77 -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (int), 77 -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } ;; -esac -else - if test "$cross_compiling" = yes; then - { { echo "$as_me:$LINENO: error: internal error: not reached in cross-compile" >&5 -echo "$as_me: error: internal error: not reached in cross-compile" >&2;} - { (exit 1); exit 1; }; } -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -long longval () { return (long) (sizeof (int)); } -unsigned long ulongval () { return (long) (sizeof (int)); } -#include -#include -int -main () -{ - - FILE *f = fopen ("conftest.val", "w"); - if (! f) - exit (1); - if (((long) (sizeof (int))) < 0) - { - long i = longval (); - if (i != ((long) (sizeof (int)))) - exit (1); - fprintf (f, "%ld\n", i); - } - else - { - unsigned long i = ulongval (); - if (i != ((long) (sizeof (int)))) - exit (1); - fprintf (f, "%lu\n", i); - } - exit (ferror (f) || fclose (f) != 0); - - ; - return 0; -} -_ACEOF -rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_sizeof_int=`cat conftest.val` -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (int), 77 -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (int), 77 -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi -fi -rm -f conftest.val -else - ac_cv_sizeof_int=0 -fi -fi -echo "$as_me:$LINENO: result: $ac_cv_sizeof_int" >&5 -echo "${ECHO_T}$ac_cv_sizeof_int" >&6 -cat >>confdefs.h <<_ACEOF -#define SIZEOF_INT $ac_cv_sizeof_int -_ACEOF - - -echo "$as_me:$LINENO: checking for long" >&5 -echo $ECHO_N "checking for long... $ECHO_C" >&6 -if test "${ac_cv_type_long+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -if ((long *) 0) - return 0; -if (sizeof (long)) - return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_type_long=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_type_long=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_type_long" >&5 -echo "${ECHO_T}$ac_cv_type_long" >&6 - -echo "$as_me:$LINENO: checking size of long" >&5 -echo $ECHO_N "checking size of long... $ECHO_C" >&6 -if test "${ac_cv_sizeof_long+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test "$ac_cv_type_long" = yes; then - # The cast to unsigned long works around a bug in the HP C Compiler - # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects - # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. - # This bug is HP SR number 8606223364. - if test "$cross_compiling" = yes; then - # Depending upon the size, compute the lo and hi bounds. -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(((long) (sizeof (long))) >= 0)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_lo=0 ac_mid=0 - while :; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(((long) (sizeof (long))) <= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_hi=$ac_mid; break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_lo=`expr $ac_mid + 1` - if test $ac_lo -le $ac_mid; then - ac_lo= ac_hi= - break - fi - ac_mid=`expr 2 '*' $ac_mid + 1` -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - done -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(((long) (sizeof (long))) < 0)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_hi=-1 ac_mid=-1 - while :; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(((long) (sizeof (long))) >= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_lo=$ac_mid; break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_hi=`expr '(' $ac_mid ')' - 1` - if test $ac_mid -le $ac_hi; then - ac_lo= ac_hi= - break - fi - ac_mid=`expr 2 '*' $ac_mid` -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - done -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_lo= ac_hi= -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -# Binary search between lo and hi bounds. -while test "x$ac_lo" != "x$ac_hi"; do - ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(((long) (sizeof (long))) <= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_hi=$ac_mid -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_lo=`expr '(' $ac_mid ')' + 1` -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -done -case $ac_lo in -?*) ac_cv_sizeof_long=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long), 77 -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (long), 77 -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } ;; -esac -else - if test "$cross_compiling" = yes; then - { { echo "$as_me:$LINENO: error: internal error: not reached in cross-compile" >&5 -echo "$as_me: error: internal error: not reached in cross-compile" >&2;} - { (exit 1); exit 1; }; } -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -long longval () { return (long) (sizeof (long)); } -unsigned long ulongval () { return (long) (sizeof (long)); } -#include -#include -int -main () -{ - - FILE *f = fopen ("conftest.val", "w"); - if (! f) - exit (1); - if (((long) (sizeof (long))) < 0) - { - long i = longval (); - if (i != ((long) (sizeof (long)))) - exit (1); - fprintf (f, "%ld\n", i); - } - else - { - unsigned long i = ulongval (); - if (i != ((long) (sizeof (long)))) - exit (1); - fprintf (f, "%lu\n", i); - } - exit (ferror (f) || fclose (f) != 0); - - ; - return 0; -} -_ACEOF -rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_sizeof_long=`cat conftest.val` -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (long), 77 -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (long), 77 -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi -fi -rm -f conftest.val -else - ac_cv_sizeof_long=0 -fi -fi -echo "$as_me:$LINENO: result: $ac_cv_sizeof_long" >&5 -echo "${ECHO_T}$ac_cv_sizeof_long" >&6 -cat >>confdefs.h <<_ACEOF -#define SIZEOF_LONG $ac_cv_sizeof_long -_ACEOF - - -echo "$as_me:$LINENO: checking for long long" >&5 -echo $ECHO_N "checking for long long... $ECHO_C" >&6 -if test "${ac_cv_type_long_long+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -if ((long long *) 0) - return 0; -if (sizeof (long long)) - return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_type_long_long=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_type_long_long=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_type_long_long" >&5 -echo "${ECHO_T}$ac_cv_type_long_long" >&6 - -echo "$as_me:$LINENO: checking size of long long" >&5 -echo $ECHO_N "checking size of long long... $ECHO_C" >&6 -if test "${ac_cv_sizeof_long_long+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test "$ac_cv_type_long_long" = yes; then - # The cast to unsigned long works around a bug in the HP C Compiler - # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects - # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. - # This bug is HP SR number 8606223364. - if test "$cross_compiling" = yes; then - # Depending upon the size, compute the lo and hi bounds. -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(((long) (sizeof (long long))) >= 0)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_lo=0 ac_mid=0 - while :; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(((long) (sizeof (long long))) <= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_hi=$ac_mid; break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_lo=`expr $ac_mid + 1` - if test $ac_lo -le $ac_mid; then - ac_lo= ac_hi= - break - fi - ac_mid=`expr 2 '*' $ac_mid + 1` -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - done -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(((long) (sizeof (long long))) < 0)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_hi=-1 ac_mid=-1 - while :; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(((long) (sizeof (long long))) >= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_lo=$ac_mid; break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_hi=`expr '(' $ac_mid ')' - 1` - if test $ac_mid -le $ac_hi; then - ac_lo= ac_hi= - break - fi - ac_mid=`expr 2 '*' $ac_mid` -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - done -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_lo= ac_hi= -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -# Binary search between lo and hi bounds. -while test "x$ac_lo" != "x$ac_hi"; do - ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(((long) (sizeof (long long))) <= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_hi=$ac_mid -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_lo=`expr '(' $ac_mid ')' + 1` -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -done -case $ac_lo in -?*) ac_cv_sizeof_long_long=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long long), 77 -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (long long), 77 -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } ;; -esac -else - if test "$cross_compiling" = yes; then - { { echo "$as_me:$LINENO: error: internal error: not reached in cross-compile" >&5 -echo "$as_me: error: internal error: not reached in cross-compile" >&2;} - { (exit 1); exit 1; }; } -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -long longval () { return (long) (sizeof (long long)); } -unsigned long ulongval () { return (long) (sizeof (long long)); } -#include -#include -int -main () -{ - - FILE *f = fopen ("conftest.val", "w"); - if (! f) - exit (1); - if (((long) (sizeof (long long))) < 0) - { - long i = longval (); - if (i != ((long) (sizeof (long long)))) - exit (1); - fprintf (f, "%ld\n", i); - } - else - { - unsigned long i = ulongval (); - if (i != ((long) (sizeof (long long)))) - exit (1); - fprintf (f, "%lu\n", i); - } - exit (ferror (f) || fclose (f) != 0); - - ; - return 0; -} -_ACEOF -rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_sizeof_long_long=`cat conftest.val` -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (long long), 77 -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (long long), 77 -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi -fi -rm -f conftest.val -else - ac_cv_sizeof_long_long=0 -fi -fi -echo "$as_me:$LINENO: result: $ac_cv_sizeof_long_long" >&5 -echo "${ECHO_T}$ac_cv_sizeof_long_long" >&6 -cat >>confdefs.h <<_ACEOF -#define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long -_ACEOF - - - - - - - - -for ac_func in waitpid fcntl pipe fork -do -as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -echo "$as_me:$LINENO: checking for $ac_func" >&5 -echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 -if eval "test \"\${$as_ac_var+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -{ -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -choke me -#else -char (*f) () = $ac_func; -#endif -#ifdef __cplusplus -} -#endif - -int -main () -{ -return f != $ac_func; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - eval "$as_ac_var=yes" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -eval "$as_ac_var=no" -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 -if test `eval echo '${'$as_ac_var'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - - - - - - - - -cat >confcache <<\_ACEOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs, see configure's option --config-cache. -# It is not useful on other systems. If it contains results you don't -# want to keep, you may remove or edit it. -# -# config.status only pays attention to the cache file if you give it -# the --recheck option to rerun configure. -# -# `ac_cv_env_foo' variables (set or unset) will be overridden when -# loading this file, other *unset* `ac_cv_foo' will be assigned the -# following values. - -_ACEOF - -# The following way of writing the cache mishandles newlines in values, -# but we know of no workaround that is simple, portable, and efficient. -# So, don't put newlines in cache variables' values. -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -{ - (set) 2>&1 | - case `(ac_space=' '; set | grep ac_space) 2>&1` in - *ac_space=\ *) - # `set' does not quote correctly, so add quotes (double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \). - sed -n \ - "s/'/'\\\\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n \ - "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" - ;; - esac; -} | - sed ' - t clear - : clear - s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ - t end - /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\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" && echo "updating cache $cache_file" - cat confcache >$cache_file - else - echo "not updating unwritable cache $cache_file" - fi -fi -rm -f confcache - -echo "$as_me:$LINENO: checking whether to optimize for speed or for accuracy" >&5 -echo $ECHO_N "checking whether to optimize for speed or for accuracy... $ECHO_C" >&6 - -# Check whether --enable-speed or --disable-speed was given. -if test "${enable_speed+set}" = set; then - enableval="$enable_speed" - - case "$enableval" in - yes) - optimize_for="speed" - -cat >>confdefs.h <<\_ACEOF -#define OPT_SPEED 1 -_ACEOF - - ;; - esac - -fi; - -# Check whether --enable-accuracy or --disable-accuracy was given. -if test "${enable_accuracy+set}" = set; then - enableval="$enable_accuracy" - - case "$enableval" in - yes) - if test "$optimize_for" = "speed" - then - optimize_for="both" - else - optimize_for="accuracy" - fi - -cat >>confdefs.h <<\_ACEOF -#define OPT_ACCURACY 1 -_ACEOF - - ;; - esac - -fi; - -echo "$as_me:$LINENO: result: ${optimize_for-default}" >&5 -echo "${ECHO_T}${optimize_for-default}" >&6 - -if test "$optimize_for" = "both" -then - { { echo "$as_me:$LINENO: error: cannot optimize for both speed and accuracy" >&5 -echo "$as_me: error: cannot optimize for both speed and accuracy" >&2;} - { (exit 1); exit 1; }; } -fi - -echo "$as_me:$LINENO: checking for architecture-specific fixed-point math routines" >&5 -echo $ECHO_N "checking for architecture-specific fixed-point math routines... $ECHO_C" >&6 -# Check whether --enable-fpm or --disable-fpm was given. -if test "${enable_fpm+set}" = set; then - enableval="$enable_fpm" - - case "$enableval" in - yes) ;; - no|default|approx) FPM="DEFAULT" ;; - intel|i?86) FPM="INTEL" ;; - arm) FPM="ARM" ;; - mips) FPM="MIPS" ;; - sparc) FPM="SPARC" ;; - ppc|powerpc) FPM="PPC" ;; - 64bit) FPM="64BIT" ;; - float) FPM="FLOAT" ;; - *) - echo "$as_me:$LINENO: result: failed" >&5 -echo "${ECHO_T}failed" >&6 - { { echo "$as_me:$LINENO: error: bad --enable-fpm option" >&5 -echo "$as_me: error: bad --enable-fpm option" >&2;} - { (exit 1); exit 1; }; } - ;; - esac - -fi; - -if test -z "$FPM" && test "$GCC" = yes -then - case "$host" in - i?86-*) FPM="INTEL" ;; - arm*-*) FPM="ARM" ;; - mips*-*) FPM="MIPS" ;; - sparc*-*) FPM="SPARC" ;; - powerpc*-*) FPM="PPC" ;; - # FIXME: need to test for 64-bit long long... - esac -fi - -echo "$as_me:$LINENO: result: ${FPM=DEFAULT}" >&5 -echo "${ECHO_T}${FPM=DEFAULT}" >&6 - -if test "$FPM" = "DEFAULT" -then - { echo "$as_me:$LINENO: WARNING: default fixed-point math will yield limited accuracy" >&5 -echo "$as_me: WARNING: default fixed-point math will yield limited accuracy" >&2;} -fi - -FPM="-DFPM_$FPM" - -# Check whether --enable-sso or --disable-sso was given. -if test "${enable_sso+set}" = set; then - enableval="$enable_sso" - - case "$enableval" in - yes) - -cat >>confdefs.h <<\_ACEOF -#define OPT_SSO 1 -_ACEOF - - ;; - esac - -fi; - -# Check whether --enable-aso or --disable-aso was given. -if test "${enable_aso+set}" = set; then - enableval="$enable_aso" - -else - enable_aso=yes -fi; - -if test "$enable_aso" = yes -then - case "$host" in - i?86-*) - : #ASO="$ASO -DASO_INTERLEAVE1" - ASO="$ASO -DASO_ZEROCHECK" - : #not yet #ASO="$ASO -DASO_SYNTH" - : #not yet #ASO_OBJS="synth_mmx.lo" - ;; - arm*-*) - ASO="$ASO -DASO_INTERLEAVE1" - ASO="$ASO -DASO_IMDCT" - ASO_OBJS="imdct_l_arm.lo" - ;; - mips*-*) - ASO="$ASO -DASO_INTERLEAVE2" - ASO="$ASO -DASO_ZEROCHECK" - ;; - esac -fi - -echo "$as_me:$LINENO: checking for ISO/IEC interpretation" >&5 -echo $ECHO_N "checking for ISO/IEC interpretation... $ECHO_C" >&6 -# Check whether --enable-strict-iso or --disable-strict-iso was given. -if test "${enable_strict_iso+set}" = set; then - enableval="$enable_strict_iso" - - case "$enableval" in - yes) - -cat >>confdefs.h <<\_ACEOF -#define OPT_STRICT 1 -_ACEOF - - interpretation="strict" - ;; - esac - -fi; -echo "$as_me:$LINENO: result: ${interpretation-best accepted practices}" >&5 -echo "${ECHO_T}${interpretation-best accepted practices}" >&6 - -echo "$as_me:$LINENO: checking whether to enable profiling" >&5 -echo $ECHO_N "checking whether to enable profiling... $ECHO_C" >&6 -# Check whether --enable-profiling or --disable-profiling was given. -if test "${enable_profiling+set}" = set; then - enableval="$enable_profiling" - - case "$enableval" in - yes) profile="-pg" ;; - esac - -fi; -echo "$as_me:$LINENO: result: ${enable_profiling-no}" >&5 -echo "${ECHO_T}${enable_profiling-no}" >&6 - -echo "$as_me:$LINENO: checking whether to enable debugging" >&5 -echo $ECHO_N "checking whether to enable debugging... $ECHO_C" >&6 -# Check whether --enable-debugging or --disable-debugging was given. -if test "${enable_debugging+set}" = set; then - enableval="$enable_debugging" - - case "$enableval" in - yes) - -cat >>confdefs.h <<\_ACEOF -#define DEBUG 1 -_ACEOF - - optimize="" - ;; - no) - if test -n "$profile" - then - { { echo "$as_me:$LINENO: error: --enable-profiling and --disable-debugging are incompatible" >&5 -echo "$as_me: error: --enable-profiling and --disable-debugging are incompatible" >&2;} - { (exit 1); exit 1; }; } - fi - - -cat >>confdefs.h <<\_ACEOF -#define NDEBUG 1 -_ACEOF - - debug="" - if test "$GCC" = yes - then - optimize="$optimize -fomit-frame-pointer" - fi - ;; - esac - -fi; -echo "$as_me:$LINENO: result: ${enable_debugging-default}" >&5 -echo "${ECHO_T}${enable_debugging-default}" >&6 - -echo "$as_me:$LINENO: checking whether to enable experimental code" >&5 -echo $ECHO_N "checking whether to enable experimental code... $ECHO_C" >&6 -# Check whether --enable-experimental or --disable-experimental was given. -if test "${enable_experimental+set}" = set; then - enableval="$enable_experimental" - - case "$enableval" in - yes) - -cat >>confdefs.h <<\_ACEOF -#define EXPERIMENTAL 1 -_ACEOF - - ;; - esac - -fi; -echo "$as_me:$LINENO: result: ${enable_experimental-no}" >&5 -echo "${ECHO_T}${enable_experimental-no}" >&6 - - -test -n "$arch" && CFLAGS="$CFLAGS $arch" -test -n "$debug" && CFLAGS="$CFLAGS $debug" -test -n "$optimize" && CFLAGS="$CFLAGS $optimize" -test -n "$profile" && CFLAGS="$CFLAGS $profile" LDFLAGS="$LDFLAGS $profile" - - - ac_config_files="$ac_config_files Makefile msvc++/Makefile libmad.list" - -cat >confcache <<\_ACEOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs, see configure's option --config-cache. -# It is not useful on other systems. If it contains results you don't -# want to keep, you may remove or edit it. -# -# config.status only pays attention to the cache file if you give it -# the --recheck option to rerun configure. -# -# `ac_cv_env_foo' variables (set or unset) will be overridden when -# loading this file, other *unset* `ac_cv_foo' will be assigned the -# following values. - -_ACEOF - -# The following way of writing the cache mishandles newlines in values, -# but we know of no workaround that is simple, portable, and efficient. -# So, don't put newlines in cache variables' values. -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -{ - (set) 2>&1 | - case `(ac_space=' '; set | grep ac_space) 2>&1` in - *ac_space=\ *) - # `set' does not quote correctly, so add quotes (double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \). - sed -n \ - "s/'/'\\\\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n \ - "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" - ;; - esac; -} | - sed ' - t clear - : clear - s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ - t end - /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\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" && echo "updating cache $cache_file" - cat confcache >$cache_file - else - echo "not updating unwritable cache $cache_file" - fi -fi -rm -f confcache - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -# VPATH may cause trouble with some makes, so we remove $(srcdir), -# ${srcdir} and @srcdir@ 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/; -s/:*$//; -s/^[^=]*=[ ]*$//; -}' -fi - -DEFS=-DHAVE_CONFIG_H - -ac_libobjs= -ac_ltlibobjs= -for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue - # 1. Remove the extension, and $U if already installed. - ac_i=`echo "$ac_i" | - sed 's/\$U\././;s/\.o$//;s/\.obj$//'` - # 2. Add them. - ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" - ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' -done -LIBOBJS=$ac_libobjs - -LTLIBOBJS=$ac_ltlibobjs - - -if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then - { { echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined. -Usually this means the macro was only invoked conditionally." >&5 -echo "$as_me: error: conditional \"AMDEP\" was never defined. -Usually this means the macro was only invoked conditionally." >&2;} - { (exit 1); exit 1; }; } -fi -if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then - { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined. -Usually this means the macro was only invoked conditionally." >&5 -echo "$as_me: error: conditional \"am__fastdepCC\" was never defined. -Usually this means the macro was only invoked conditionally." >&2;} - { (exit 1); exit 1; }; } -fi -if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then - { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCXX\" was never defined. -Usually this means the macro was only invoked conditionally." >&5 -echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined. -Usually this means the macro was only invoked conditionally." >&2;} - { (exit 1); exit 1; }; } -fi - -: ${CONFIG_STATUS=./config.status} -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 -echo "$as_me: creating $CONFIG_STATUS" >&6;} -cat >$CONFIG_STATUS <<_ACEOF -#! $SHELL -# Generated by $as_me. -# Run this file to recreate the current configuration. -# Compiler output produced by configure, useful for debugging -# configure, is in config.log if it exists. - -debug=false -ac_cs_recheck=false -ac_cs_silent=false -SHELL=\${CONFIG_SHELL-$SHELL} -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## - -# Be Bourne compatible -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' -elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then - set -o posix -fi -DUALCASE=1; export DUALCASE # for MKS sh - -# Support unset when possible. -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset -else - as_unset=false -fi - - -# Work around bugs in pre-3.0 UWIN ksh. -$as_unset ENV MAIL MAILPATH -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -for as_var in \ - LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ - LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ - LC_TELEPHONE LC_TIME -do - if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then - eval $as_var=C; export $as_var - else - $as_unset $as_var - fi -done - -# Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1; then - as_expr=expr -else - as_expr=false -fi - -if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - - -# Name of the executable. -as_me=`$as_basename "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)$' \| \ - . : '\(.\)' 2>/dev/null || -echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } - /^X\/\(\/\/\)$/{ s//\1/; q; } - /^X\/\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - - -# PATH needs CR, and LINENO needs CR and PATH. -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi - - - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" || { - # Find who we are. Look in the path if we contain no path at all - # relative or not. - case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done - - ;; - esac - # We did not find ourselves, most probably we were run as `sh COMMAND' - # in which case we are not to be found in the path. - if test "x$as_myself" = x; then - as_myself=$0 - fi - if test ! -f "$as_myself"; then - { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 -echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} - { (exit 1); exit 1; }; } - fi - case $CONFIG_SHELL in - '') - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for as_base in sh bash ksh sh5; do - case $as_dir in - /*) - if ("$as_dir/$as_base" -c ' - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then - $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } - $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } - CONFIG_SHELL=$as_dir/$as_base - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$0" ${1+"$@"} - fi;; - esac - done -done -;; - esac - - # Create $as_me.lineno as a copy of $as_myself, but with $LINENO - # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line before each line; the second 'sed' does the real - # work. The second script uses 'N' to pair each line-number line - # with the numbered line, and appends trailing '-' during - # substitution so that $LINENO is not a special case at line end. - # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) - sed '=' <$as_myself | - sed ' - N - s,$,-, - : loop - s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, - t loop - s,-$,, - s,^['$as_cr_digits']*\n,, - ' >$as_me.lineno && - chmod +x $as_me.lineno || - { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 -echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} - { (exit 1); exit 1; }; } - - # 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 sensible to this). - . ./$as_me.lineno - # Exit status is that of the last command. - exit -} - - -case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in - *c*,-n*) ECHO_N= ECHO_C=' -' ECHO_T=' ' ;; - *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; - *) ECHO_N= ECHO_C='\c' ECHO_T= ;; -esac - -if expr a : '\(a\)' >/dev/null 2>&1; then - as_expr=expr -else - as_expr=false -fi - -rm -f conf$$ conf$$.exe conf$$.file -echo >conf$$.file -if ln -s conf$$.file conf$$ 2>/dev/null; then - # We could just check for DJGPP; but this test a) works b) is more generic - # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). - if test -f conf$$.exe; then - # Don't use ln at all; we don't have any links - as_ln_s='cp -p' - else - as_ln_s='ln -s' - fi -elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln -else - as_ln_s='cp -p' -fi -rm -f conf$$ conf$$.exe conf$$.file - -if mkdir -p . 2>/dev/null; then - as_mkdir_p=: -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -as_executable_p="test -f" - -# 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'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -# IFS -# We need space, tab and new line, in precisely that order. -as_nl=' -' -IFS=" $as_nl" - -# CDPATH. -$as_unset CDPATH - -exec 6>&1 - -# Open the log real soon, to keep \$[0] and so on meaningful, and to -# report actual input values of CONFIG_FILES etc. instead of their -# values after options handling. Logging --version etc. is OK. -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX -} >&5 -cat >&5 <<_CSEOF - -This file was extended by MPEG Audio Decoder $as_me 0.15.1b, which was -generated by GNU Autoconf 2.59. Invocation command line was - - CONFIG_FILES = $CONFIG_FILES - CONFIG_HEADERS = $CONFIG_HEADERS - CONFIG_LINKS = $CONFIG_LINKS - CONFIG_COMMANDS = $CONFIG_COMMANDS - $ $0 $@ - -_CSEOF -echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 -echo >&5 -_ACEOF - -# Files that config.status was made for. -if test -n "$ac_config_files"; then - echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS -fi - -if test -n "$ac_config_headers"; then - echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS -fi - -if test -n "$ac_config_links"; then - echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS -fi - -if test -n "$ac_config_commands"; then - echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS -fi - -cat >>$CONFIG_STATUS <<\_ACEOF - -ac_cs_usage="\ -\`$as_me' instantiates files from templates according to the -current configuration. - -Usage: $0 [OPTIONS] [FILE]... - - -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 - --recheck update $as_me by reconfiguring in the same conditions - --file=FILE[:TEMPLATE] - instantiate the configuration file FILE - --header=FILE[:TEMPLATE] - instantiate the configuration header FILE - -Configuration files: -$config_files - -Configuration headers: -$config_headers - -Configuration commands: -$config_commands - -Report bugs to ." -_ACEOF - -cat >>$CONFIG_STATUS <<_ACEOF -ac_cs_version="\\ -MPEG Audio Decoder config.status 0.15.1b -configured by $0, generated by GNU Autoconf 2.59, - with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" - -Copyright (C) 2003 Free Software Foundation, Inc. -This config.status script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it." -srcdir=$srcdir -INSTALL="$INSTALL" -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF -# If no file are specified by the user, then we need to provide default -# value. By we need to know if files were specified by the user. -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=$1 - ac_optarg=$2 - ac_shift=shift - ;; - *) # This is not an option, so the user has probably given explicit - # arguments. - ac_option=$1 - ac_need_defaults=false;; - esac - - case $ac_option in - # Handling of the options. -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - ac_cs_recheck=: ;; - --version | --vers* | -V ) - echo "$ac_cs_version"; exit 0 ;; - --he | --h) - # Conflict between --help and --header - { { echo "$as_me:$LINENO: error: ambiguous option: $1 -Try \`$0 --help' for more information." >&5 -echo "$as_me: error: ambiguous option: $1 -Try \`$0 --help' for more information." >&2;} - { (exit 1); exit 1; }; };; - --help | --hel | -h ) - echo "$ac_cs_usage"; exit 0 ;; - --debug | --d* | -d ) - debug=: ;; - --file | --fil | --fi | --f ) - $ac_shift - CONFIG_FILES="$CONFIG_FILES $ac_optarg" - ac_need_defaults=false;; - --header | --heade | --head | --hea ) - $ac_shift - CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" - ac_need_defaults=false;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil | --si | --s) - ac_cs_silent=: ;; - - # This is an error. - -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&5 -echo "$as_me: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&2;} - { (exit 1); exit 1; }; } ;; - - *) ac_config_targets="$ac_config_targets $1" ;; - - esac - shift -done - -ac_configure_extra_args= - -if $ac_cs_silent; then - exec 6>/dev/null - ac_configure_extra_args="$ac_configure_extra_args --silent" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF -if \$ac_cs_recheck; then - echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 - exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion -fi - -_ACEOF - -cat >>$CONFIG_STATUS <<_ACEOF -# -# INIT-COMMANDS section. -# - -AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" - -_ACEOF - - - -cat >>$CONFIG_STATUS <<\_ACEOF -for ac_config_target in $ac_config_targets -do - case "$ac_config_target" in - # Handling of arguments. - "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; - "msvc++/Makefile" ) CONFIG_FILES="$CONFIG_FILES msvc++/Makefile" ;; - "libmad.list" ) CONFIG_FILES="$CONFIG_FILES libmad.list" ;; - "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; - "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; - *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 -echo "$as_me: error: invalid argument: $ac_config_target" >&2;} - { (exit 1); exit 1; }; };; - esac -done - -# If the user did not use the arguments to specify the items to instantiate, -# then the envvar interface is used. Set only those that are not. -# We use the long form for the default assignment because of an extremely -# bizarre bug on SunOS 4.1.3. -if $ac_need_defaults; then - test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files - test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers - test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands -fi - -# Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason to put it here, and in addition, -# creating and moving files from /tmp can sometimes cause problems. -# Create a temporary directory, and hook for its removal unless debugging. -$debug || -{ - trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 - trap '{ (exit 1); exit 1; }' 1 2 13 15 -} - -# Create a (secure) tmp directory for tmp files. - -{ - tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && - test -n "$tmp" && test -d "$tmp" -} || -{ - tmp=./confstat$$-$RANDOM - (umask 077 && mkdir $tmp) -} || -{ - echo "$me: cannot create a temporary directory in ." >&2 - { (exit 1); exit 1; } -} - -_ACEOF - -cat >>$CONFIG_STATUS <<_ACEOF - -# -# CONFIG_FILES section. -# - -# No need to generate the scripts if there are no CONFIG_FILES. -# This happens for instance when ./config.status config.h -if test -n "\$CONFIG_FILES"; then - # Protect against being on the right side of a sed subst in config.status. - sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; - s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF -s,@SHELL@,$SHELL,;t t -s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t -s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t -s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t -s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t -s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t -s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t -s,@exec_prefix@,$exec_prefix,;t t -s,@prefix@,$prefix,;t t -s,@program_transform_name@,$program_transform_name,;t t -s,@bindir@,$bindir,;t t -s,@sbindir@,$sbindir,;t t -s,@libexecdir@,$libexecdir,;t t -s,@datadir@,$datadir,;t t -s,@sysconfdir@,$sysconfdir,;t t -s,@sharedstatedir@,$sharedstatedir,;t t -s,@localstatedir@,$localstatedir,;t t -s,@libdir@,$libdir,;t t -s,@includedir@,$includedir,;t t -s,@oldincludedir@,$oldincludedir,;t t -s,@infodir@,$infodir,;t t -s,@mandir@,$mandir,;t t -s,@build_alias@,$build_alias,;t t -s,@host_alias@,$host_alias,;t t -s,@target_alias@,$target_alias,;t t -s,@DEFS@,$DEFS,;t t -s,@ECHO_C@,$ECHO_C,;t t -s,@ECHO_N@,$ECHO_N,;t t -s,@ECHO_T@,$ECHO_T,;t t -s,@LIBS@,$LIBS,;t t -s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t -s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t -s,@INSTALL_DATA@,$INSTALL_DATA,;t t -s,@CYGPATH_W@,$CYGPATH_W,;t t -s,@PACKAGE@,$PACKAGE,;t t -s,@VERSION@,$VERSION,;t t -s,@ACLOCAL@,$ACLOCAL,;t t -s,@AUTOCONF@,$AUTOCONF,;t t -s,@AUTOMAKE@,$AUTOMAKE,;t t -s,@AUTOHEADER@,$AUTOHEADER,;t t -s,@MAKEINFO@,$MAKEINFO,;t t -s,@AMTAR@,$AMTAR,;t t -s,@install_sh@,$install_sh,;t t -s,@STRIP@,$STRIP,;t t -s,@ac_ct_STRIP@,$ac_ct_STRIP,;t t -s,@INSTALL_STRIP_PROGRAM@,$INSTALL_STRIP_PROGRAM,;t t -s,@mkdir_p@,$mkdir_p,;t t -s,@AWK@,$AWK,;t t -s,@SET_MAKE@,$SET_MAKE,;t t -s,@am__leading_dot@,$am__leading_dot,;t t -s,@build@,$build,;t t -s,@build_cpu@,$build_cpu,;t t -s,@build_vendor@,$build_vendor,;t t -s,@build_os@,$build_os,;t t -s,@host@,$host,;t t -s,@host_cpu@,$host_cpu,;t t -s,@host_vendor@,$host_vendor,;t t -s,@host_os@,$host_os,;t t -s,@CC@,$CC,;t t -s,@CFLAGS@,$CFLAGS,;t t -s,@LDFLAGS@,$LDFLAGS,;t t -s,@CPPFLAGS@,$CPPFLAGS,;t t -s,@ac_ct_CC@,$ac_ct_CC,;t t -s,@EXEEXT@,$EXEEXT,;t t -s,@OBJEXT@,$OBJEXT,;t t -s,@DEPDIR@,$DEPDIR,;t t -s,@am__include@,$am__include,;t t -s,@am__quote@,$am__quote,;t t -s,@AMDEP_TRUE@,$AMDEP_TRUE,;t t -s,@AMDEP_FALSE@,$AMDEP_FALSE,;t t -s,@AMDEPBACKSLASH@,$AMDEPBACKSLASH,;t t -s,@CCDEPMODE@,$CCDEPMODE,;t t -s,@am__fastdepCC_TRUE@,$am__fastdepCC_TRUE,;t t -s,@am__fastdepCC_FALSE@,$am__fastdepCC_FALSE,;t t -s,@CCAS@,$CCAS,;t t -s,@CCASFLAGS@,$CCASFLAGS,;t t -s,@EGREP@,$EGREP,;t t -s,@LN_S@,$LN_S,;t t -s,@ECHO@,$ECHO,;t t -s,@AR@,$AR,;t t -s,@ac_ct_AR@,$ac_ct_AR,;t t -s,@RANLIB@,$RANLIB,;t t -s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t -s,@CPP@,$CPP,;t t -s,@CXX@,$CXX,;t t -s,@CXXFLAGS@,$CXXFLAGS,;t t -s,@ac_ct_CXX@,$ac_ct_CXX,;t t -s,@CXXDEPMODE@,$CXXDEPMODE,;t t -s,@am__fastdepCXX_TRUE@,$am__fastdepCXX_TRUE,;t t -s,@am__fastdepCXX_FALSE@,$am__fastdepCXX_FALSE,;t t -s,@CXXCPP@,$CXXCPP,;t t -s,@F77@,$F77,;t t -s,@FFLAGS@,$FFLAGS,;t t -s,@ac_ct_F77@,$ac_ct_F77,;t t -s,@LIBTOOL@,$LIBTOOL,;t t -s,@LIBTOOL_DEPS@,$LIBTOOL_DEPS,;t t -s,@FPM@,$FPM,;t t -s,@ASO@,$ASO,;t t -s,@ASO_OBJS@,$ASO_OBJS,;t t -s,@LIBOBJS@,$LIBOBJS,;t t -s,@LTLIBOBJS@,$LTLIBOBJS,;t t -CEOF - -_ACEOF - - cat >>$CONFIG_STATUS <<\_ACEOF - # Split the substitutions into bite-sized pieces for seds with - # small command number limits, like on Digital OSF/1 and HP-UX. - ac_max_sed_lines=48 - ac_sed_frag=1 # Number of current file. - ac_beg=1 # First line for current file. - ac_end=$ac_max_sed_lines # Line after last line for current file. - ac_more_lines=: - ac_sed_cmds= - while $ac_more_lines; do - if test $ac_beg -gt 1; then - sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag - else - sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag - fi - if test ! -s $tmp/subs.frag; then - ac_more_lines=false - else - # The purpose of the label and of the branching condition is to - # speed up the sed processing (if there are no `@' at all, there - # is no need to browse any of the substitutions). - # These are the two extra sed commands mentioned above. - (echo ':t - /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed - if test -z "$ac_sed_cmds"; then - ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" - else - ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" - fi - ac_sed_frag=`expr $ac_sed_frag + 1` - ac_beg=$ac_end - ac_end=`expr $ac_end + $ac_max_sed_lines` - fi - done - if test -z "$ac_sed_cmds"; then - ac_sed_cmds=cat - fi -fi # test -n "$CONFIG_FILES" - -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF -for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case $ac_file in - - | *:- | *:-:* ) # input from stdin - cat >$tmp/stdin - ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - * ) ac_file_in=$ac_file.in ;; - esac - - # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. - ac_dir=`(dirname "$ac_file") 2>/dev/null || -$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - { if $as_mkdir_p; then - mkdir -p "$ac_dir" - else - as_dir="$ac_dir" - as_dirs= - while test ! -d "$as_dir"; do - as_dirs="$as_dir $as_dirs" - as_dir=`(dirname "$as_dir") 2>/dev/null || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - done - test ! -n "$as_dirs" || mkdir $as_dirs - fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 -echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} - { (exit 1); exit 1; }; }; } - - ac_builddir=. - -if test "$ac_dir" != .; then - ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A "../" for each directory in $ac_dir_suffix. - ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` -else - ac_dir_suffix= ac_top_builddir= -fi - -case $srcdir in - .) # No --srcdir option. We are building in place. - ac_srcdir=. - if test -z "$ac_top_builddir"; then - ac_top_srcdir=. - else - ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` - fi ;; - [\\/]* | ?:[\\/]* ) # Absolute path. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir ;; - *) # Relative path. - ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_builddir$srcdir ;; -esac - -# Do not use `cd foo && pwd` to compute absolute paths, because -# the directories may not exist. -case `pwd` in -.) ac_abs_builddir="$ac_dir";; -*) - case "$ac_dir" in - .) ac_abs_builddir=`pwd`;; - [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; - *) ac_abs_builddir=`pwd`/"$ac_dir";; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_builddir=${ac_top_builddir}.;; -*) - case ${ac_top_builddir}. in - .) ac_abs_top_builddir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; - *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_srcdir=$ac_srcdir;; -*) - case $ac_srcdir in - .) ac_abs_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; - *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_srcdir=$ac_top_srcdir;; -*) - case $ac_top_srcdir in - .) ac_abs_top_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; - *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; - esac;; -esac - - - case $INSTALL in - [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; - *) ac_INSTALL=$ac_top_builddir$INSTALL ;; - esac - - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - if test x"$ac_file" = x-; then - configure_input= - else - configure_input="$ac_file. " - fi - configure_input=$configure_input"Generated from `echo $ac_file_in | - sed 's,.*/,,'` by configure." - - # First look for the input files in the build tree, otherwise in the - # src tree. - ac_file_inputs=`IFS=: - for f in $ac_file_in; do - case $f in - -) echo $tmp/stdin ;; - [\\/$]*) - # Absolute (can't be DOS-style, as IFS=:) - test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - echo "$f";; - *) # Relative - if test -f "$f"; then - # Build tree - echo "$f" - elif test -f "$srcdir/$f"; then - # Source tree - echo "$srcdir/$f" - else - # /dev/null tree - { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - fi;; - esac - done` || { (exit 1); exit 1; } - - if test x"$ac_file" != x-; then - { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} - rm -f "$ac_file" - fi -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF - sed "$ac_vpsub -$extrasub -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF -:t -/@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s,@configure_input@,$configure_input,;t t -s,@srcdir@,$ac_srcdir,;t t -s,@abs_srcdir@,$ac_abs_srcdir,;t t -s,@top_srcdir@,$ac_top_srcdir,;t t -s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t -s,@builddir@,$ac_builddir,;t t -s,@abs_builddir@,$ac_abs_builddir,;t t -s,@top_builddir@,$ac_top_builddir,;t t -s,@abs_top_builddir@,$ac_abs_top_builddir,;t t -s,@INSTALL@,$ac_INSTALL,;t t -" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out - rm -f $tmp/stdin - if test x"$ac_file" != x-; then - mv $tmp/out $ac_file - else - cat $tmp/out - rm -f $tmp/out - fi - -done -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF - -# -# CONFIG_HEADER section. -# - -# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where -# NAME is the cpp macro being defined and VALUE is the value it is being given. -# -# ac_d sets the value in "#define NAME VALUE" lines. -ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' -ac_dB='[ ].*$,\1#\2' -ac_dC=' ' -ac_dD=',;t' -# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE". -ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' -ac_uB='$,\1#\2define\3' -ac_uC=' ' -ac_uD=',;t' - -for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case $ac_file in - - | *:- | *:-:* ) # input from stdin - cat >$tmp/stdin - ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - * ) ac_file_in=$ac_file.in ;; - esac - - test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} - - # First look for the input files in the build tree, otherwise in the - # src tree. - ac_file_inputs=`IFS=: - for f in $ac_file_in; do - case $f in - -) echo $tmp/stdin ;; - [\\/$]*) - # Absolute (can't be DOS-style, as IFS=:) - test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - # Do quote $f, to prevent DOS paths from being IFS'd. - echo "$f";; - *) # Relative - if test -f "$f"; then - # Build tree - echo "$f" - elif test -f "$srcdir/$f"; then - # Source tree - echo "$srcdir/$f" - else - # /dev/null tree - { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - fi;; - esac - done` || { (exit 1); exit 1; } - # Remove the trailing spaces. - sed 's/[ ]*$//' $ac_file_inputs >$tmp/in - -_ACEOF - -# Transform confdefs.h into two sed scripts, `conftest.defines' and -# `conftest.undefs', that substitutes the proper values into -# config.h.in to produce config.h. The first handles `#define' -# templates, and the second `#undef' templates. -# And first: Protect against being on the right side of a sed subst in -# config.status. Protect against being in an unquoted here document -# in config.status. -rm -f conftest.defines conftest.undefs -# Using a here document instead of a string reduces the quoting nightmare. -# Putting comments in sed scripts is not portable. -# -# `end' is used to avoid that the second main sed command (meant for -# 0-ary CPP macros) applies to n-ary macro definitions. -# See the Autoconf documentation for `clear'. -cat >confdef2sed.sed <<\_ACEOF -s/[\\&,]/\\&/g -s,[\\$`],\\&,g -t clear -: clear -s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp -t end -s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp -: end -_ACEOF -# If some macros were called several times there might be several times -# the same #defines, which is useless. Nevertheless, we may not want to -# sort them, since we want the *last* AC-DEFINE to be honored. -uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines -sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs -rm -f confdef2sed.sed - -# This sed command replaces #undef with comments. This is necessary, for -# example, in the case of _POSIX_SOURCE, which is predefined and required -# on some systems where configure will not decide to define it. -cat >>conftest.undefs <<\_ACEOF -s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */, -_ACEOF - -# Break up conftest.defines because some shells have a limit on the size -# of here documents, and old seds have small limits too (100 cmds). -echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS -echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS -echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS -echo ' :' >>$CONFIG_STATUS -rm -f conftest.tail -while grep . conftest.defines >/dev/null -do - # Write a limited-size here document to $tmp/defines.sed. - echo ' cat >$tmp/defines.sed <>$CONFIG_STATUS - # Speed up: don't consider the non `#define' lines. - echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS - # Work around the forget-to-reset-the-flag bug. - echo 't clr' >>$CONFIG_STATUS - echo ': clr' >>$CONFIG_STATUS - sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS - echo 'CEOF - sed -f $tmp/defines.sed $tmp/in >$tmp/out - rm -f $tmp/in - mv $tmp/out $tmp/in -' >>$CONFIG_STATUS - sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail - rm -f conftest.defines - mv conftest.tail conftest.defines -done -rm -f conftest.defines -echo ' fi # grep' >>$CONFIG_STATUS -echo >>$CONFIG_STATUS - -# Break up conftest.undefs because some shells have a limit on the size -# of here documents, and old seds have small limits too (100 cmds). -echo ' # Handle all the #undef templates' >>$CONFIG_STATUS -rm -f conftest.tail -while grep . conftest.undefs >/dev/null -do - # Write a limited-size here document to $tmp/undefs.sed. - echo ' cat >$tmp/undefs.sed <>$CONFIG_STATUS - # Speed up: don't consider the non `#undef' - echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS - # Work around the forget-to-reset-the-flag bug. - echo 't clr' >>$CONFIG_STATUS - echo ': clr' >>$CONFIG_STATUS - sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS - echo 'CEOF - sed -f $tmp/undefs.sed $tmp/in >$tmp/out - rm -f $tmp/in - mv $tmp/out $tmp/in -' >>$CONFIG_STATUS - sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail - rm -f conftest.undefs - mv conftest.tail conftest.undefs -done -rm -f conftest.undefs - -cat >>$CONFIG_STATUS <<\_ACEOF - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - if test x"$ac_file" = x-; then - echo "/* Generated by configure. */" >$tmp/config.h - else - echo "/* $ac_file. Generated by configure. */" >$tmp/config.h - fi - cat $tmp/in >>$tmp/config.h - rm -f $tmp/in - if test x"$ac_file" != x-; then - if diff $ac_file $tmp/config.h >/dev/null 2>&1; then - { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 -echo "$as_me: $ac_file is unchanged" >&6;} - else - ac_dir=`(dirname "$ac_file") 2>/dev/null || -$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - { if $as_mkdir_p; then - mkdir -p "$ac_dir" - else - as_dir="$ac_dir" - as_dirs= - while test ! -d "$as_dir"; do - as_dirs="$as_dir $as_dirs" - as_dir=`(dirname "$as_dir") 2>/dev/null || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - done - test ! -n "$as_dirs" || mkdir $as_dirs - fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 -echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} - { (exit 1); exit 1; }; }; } - - rm -f $ac_file - mv $tmp/config.h $ac_file - fi - else - cat $tmp/config.h - rm -f $tmp/config.h - fi -# Compute $ac_file's index in $config_headers. -_am_stamp_count=1 -for _am_header in $config_headers :; do - case $_am_header in - $ac_file | $ac_file:* ) - break ;; - * ) - _am_stamp_count=`expr $_am_stamp_count + 1` ;; - esac -done -echo "timestamp for $ac_file" >`(dirname $ac_file) 2>/dev/null || -$as_expr X$ac_file : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X$ac_file : 'X\(//\)[^/]' \| \ - X$ac_file : 'X\(//\)$' \| \ - X$ac_file : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X$ac_file | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'`/stamp-h$_am_stamp_count -done -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF - -# -# CONFIG_COMMANDS section. -# -for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue - ac_dest=`echo "$ac_file" | sed 's,:.*,,'` - ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_dir=`(dirname "$ac_dest") 2>/dev/null || -$as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_dest" : 'X\(//\)[^/]' \| \ - X"$ac_dest" : 'X\(//\)$' \| \ - X"$ac_dest" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$ac_dest" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - { if $as_mkdir_p; then - mkdir -p "$ac_dir" - else - as_dir="$ac_dir" - as_dirs= - while test ! -d "$as_dir"; do - as_dirs="$as_dir $as_dirs" - as_dir=`(dirname "$as_dir") 2>/dev/null || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - done - test ! -n "$as_dirs" || mkdir $as_dirs - fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 -echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} - { (exit 1); exit 1; }; }; } - - ac_builddir=. - -if test "$ac_dir" != .; then - ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A "../" for each directory in $ac_dir_suffix. - ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` -else - ac_dir_suffix= ac_top_builddir= -fi - -case $srcdir in - .) # No --srcdir option. We are building in place. - ac_srcdir=. - if test -z "$ac_top_builddir"; then - ac_top_srcdir=. - else - ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` - fi ;; - [\\/]* | ?:[\\/]* ) # Absolute path. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir ;; - *) # Relative path. - ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_builddir$srcdir ;; -esac - -# Do not use `cd foo && pwd` to compute absolute paths, because -# the directories may not exist. -case `pwd` in -.) ac_abs_builddir="$ac_dir";; -*) - case "$ac_dir" in - .) ac_abs_builddir=`pwd`;; - [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; - *) ac_abs_builddir=`pwd`/"$ac_dir";; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_builddir=${ac_top_builddir}.;; -*) - case ${ac_top_builddir}. in - .) ac_abs_top_builddir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; - *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_srcdir=$ac_srcdir;; -*) - case $ac_srcdir in - .) ac_abs_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; - *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_srcdir=$ac_top_srcdir;; -*) - case $ac_top_srcdir in - .) ac_abs_top_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; - *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; - esac;; -esac - - - { echo "$as_me:$LINENO: executing $ac_dest commands" >&5 -echo "$as_me: executing $ac_dest commands" >&6;} - case $ac_dest in - depfiles ) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; 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. - # So let's grep whole file. - if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then - dirpart=`(dirname "$mf") 2>/dev/null || -$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$mf" : 'X\(//\)[^/]' \| \ - X"$mf" : 'X\(//\)$' \| \ - X"$mf" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$mf" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - else - continue - fi - grep '^DEP_FILES *= *[^ #]' < "$mf" > /dev/null || continue - # Extract the definition of DEP_FILES from the Makefile without - # running `make'. - DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"` - test -z "$DEPDIR" && continue - # When using ansi2knr, U may be empty or an underscore; expand it - U=`sed -n -e '/^U = / s///p' < "$mf"` - test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR" - # 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 -e ' - /^DEP_FILES = .*\\\\$/ { - s/^DEP_FILES = // - :loop - s/\\\\$// - p - n - /\\\\$/ b loop - p - } - /^DEP_FILES = / s/^DEP_FILES = //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=`(dirname "$file") 2>/dev/null || -$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$file" : 'X\(//\)[^/]' \| \ - X"$file" : 'X\(//\)$' \| \ - X"$file" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - { if $as_mkdir_p; then - mkdir -p $dirpart/$fdir - else - as_dir=$dirpart/$fdir - as_dirs= - while test ! -d "$as_dir"; do - as_dirs="$as_dir $as_dirs" - as_dir=`(dirname "$as_dir") 2>/dev/null || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - done - test ! -n "$as_dirs" || mkdir $as_dirs - fi || { { echo "$as_me:$LINENO: error: cannot create directory $dirpart/$fdir" >&5 -echo "$as_me: error: cannot create directory $dirpart/$fdir" >&2;} - { (exit 1); exit 1; }; }; } - - # echo "creating $dirpart/$file" - echo '# dummy' > "$dirpart/$file" - done -done - ;; - esac -done -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF - -{ (exit 0); exit 0; } -_ACEOF -chmod +x $CONFIG_STATUS -ac_clean_files=$ac_clean_files_save - - -# configure is writing to config.log, and then calls config.status. -# config.status does its own redirection, appending to config.log. -# Unfortunately, on DOS this fails, as config.log is still kept open -# by configure, so config.status won't be able to write to it; its -# output is simply discarded. So we exec the FD to /dev/null, -# effectively closing config.log, so it can be properly (re)opened and -# appended to by config.status. When coming back to configure, we -# need to make the FD available again. -if test "$no_create" != yes; then - ac_cs_success=: - ac_config_status_args= - test "$silent" = yes && - ac_config_status_args="$ac_config_status_args --quiet" - exec 5>/dev/null - $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false - 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 || { (exit 1); exit 1; } -fi - diff --git a/code/libmad-0.15.1b/configure.ac b/code/libmad-0.15.1b/configure.ac deleted file mode 100644 index 9b793995..00000000 --- a/code/libmad-0.15.1b/configure.ac +++ /dev/null @@ -1,433 +0,0 @@ -dnl -*- m4 -*- -dnl -dnl libmad - MPEG audio decoder library -dnl Copyright (C) 2000-2004 Underbit Technologies, Inc. -dnl -dnl This program is free software; you can redistribute it and/or modify -dnl it under the terms of the GNU General Public License as published by -dnl the Free Software Foundation; either version 2 of the License, or -dnl (at your option) any later version. -dnl -dnl This program is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -dnl GNU General Public License for more details. -dnl -dnl You should have received a copy of the GNU General Public License -dnl along with this program; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -dnl -AC_REVISION([$Id: configure.ac,v 1.9 2004/01/23 09:41:32 rob Exp $])dnl - -dnl Process this file with autoconf to produce a configure script. - -AC_INIT([MPEG Audio Decoder], [0.15.1b], [support@underbit.com], [libmad]) -AC_PREREQ(2.53) - -AC_CONFIG_SRCDIR([decoder.h]) - -AM_INIT_AUTOMAKE - -AM_CONFIG_HEADER([config.h]) - -dnl System type. - -AC_CANONICAL_HOST - -dnl Checks for programs. - -AC_PROG_CC -AM_PROG_AS - -if test "$GCC" = yes -then - case "$host" in - *-*-mingw*) - case "$build" in - *-*-cygwin*) - CPPFLAGS="$CPPFLAGS -mno-cygwin" - LDFLAGS="$LDFLAGS -mno-cygwin" - ;; - esac - esac - -dnl case "$host" in -dnl *-*-cygwin* | *-*-mingw*) -dnl LDFLAGS="$LDFLAGS -no-undefined -mdll" -dnl ;; -dnl esac -fi - -dnl Support for libtool. - -dnl AC_DISABLE_SHARED -dnl AC_LIBTOOL_WIN32_DLL -AC_PROG_LIBTOOL - -AC_SUBST(LIBTOOL_DEPS) - -dnl Compiler options. - -arch="" -debug="" -optimize="" -profile="" - -set -- $CFLAGS -CFLAGS="" - -if test "$GCC" = yes -then - CFLAGS="-Wall" -fi - -while test $# -gt 0 -do - case "$1" in - -Wall) - if test "$GCC" = yes - then - : - else - CFLAGS="$CFLAGS $1" - fi - shift - ;; - -g) - debug="-g" - shift - ;; - -mno-cygwin) - shift - ;; - -m*) - arch="$arch $1" - shift - ;; - -O2) - optimize="-O" - shift - ;; - -fomit-frame-pointer) - shift - ;; - -O*|-f*) - optimize="$optimize $1" - shift - ;; - *) - CFLAGS="$CFLAGS $1" - shift - ;; - esac -done - -if test "$GCC" = yes -then - if test -z "$arch" - then - case "$host" in - i386-*) ;; - i?86-*) arch="-march=i486" ;; - arm*-empeg-*) arch="-march=armv4 -mtune=strongarm1100" ;; - armv4*-*) arch="-march=armv4 -mtune=strongarm" ;; - powerpc-*) ;; - mips*-agenda-*) arch="-mcpu=vr4100" ;; - mips*-luxsonor-*) arch="-mips1 -mcpu=r3000 -Wa,-m4010" ;; - esac - fi - - case "$optimize" in - -O|"-O "*) - optimize="-O" - optimize="$optimize -fforce-mem" - optimize="$optimize -fforce-addr" - : #x optimize="$optimize -finline-functions" - : #- optimize="$optimize -fstrength-reduce" - optimize="$optimize -fthread-jumps" - optimize="$optimize -fcse-follow-jumps" - optimize="$optimize -fcse-skip-blocks" - : #x optimize="$optimize -frerun-cse-after-loop" - : #x optimize="$optimize -frerun-loop-opt" - : #x optimize="$optimize -fgcse" - optimize="$optimize -fexpensive-optimizations" - optimize="$optimize -fregmove" - : #* optimize="$optimize -fdelayed-branch" - : #x optimize="$optimize -fschedule-insns" - optimize="$optimize -fschedule-insns2" - : #? optimize="$optimize -ffunction-sections" - : #? optimize="$optimize -fcaller-saves" - : #> optimize="$optimize -funroll-loops" - : #> optimize="$optimize -funroll-all-loops" - : #x optimize="$optimize -fmove-all-movables" - : #x optimize="$optimize -freduce-all-givs" - : #? optimize="$optimize -fstrict-aliasing" - : #* optimize="$optimize -fstructure-noalias" - - case "$host" in - arm*-*) - optimize="$optimize -fstrength-reduce" - ;; - mips*-*) - optimize="$optimize -fstrength-reduce" - optimize="$optimize -finline-functions" - ;; - i?86-*) - optimize="$optimize -fstrength-reduce" - ;; - powerpc-apple-*) - # this triggers an internal compiler error with gcc2 - : #optimize="$optimize -fstrength-reduce" - - # this is really only beneficial with gcc3 - : #optimize="$optimize -finline-functions" - ;; - *) - # this sometimes provokes bugs in gcc 2.95.2 - : #optimize="$optimize -fstrength-reduce" - ;; - esac - ;; - esac -fi - -case "$host" in - mips*-agenda-*) - AC_DEFINE(HAVE_MADD16_ASM, 1, - [Define if your MIPS CPU supports a 2-operand MADD16 instruction.]) - ;; - mips*-luxsonor-*) - AC_DEFINE(HAVE_MADD_ASM, 1, - [Define if your MIPS CPU supports a 2-operand MADD instruction.]) - ;; -esac - -dnl Checks for header files. - -AC_HEADER_STDC -AC_HEADER_SYS_WAIT -AC_CHECK_HEADERS(assert.h limits.h unistd.h sys/types.h fcntl.h errno.h) - -dnl Checks for typedefs, structures, and compiler characteristics. - -AC_C_CONST -AC_C_INLINE -AC_C_BIGENDIAN -AC_TYPE_PID_T - -AC_CHECK_SIZEOF(int, 2) -AC_CHECK_SIZEOF(long, 4) -AC_CHECK_SIZEOF(long long, 8) - -dnl Checks for library functions. - -AC_CHECK_FUNCS(waitpid fcntl pipe fork) - -dnl Other options. - -AC_SUBST(FPM) -AC_SUBST(ASO) -AC_SUBST(ASO_OBJS) - -dnl handle --enable and --disable options - -AC_CACHE_SAVE - -AC_MSG_CHECKING(whether to optimize for speed or for accuracy) - -AC_ARG_ENABLE(speed, AC_HELP_STRING([--enable-speed], - [optimize for speed over accuracy]), -[ - case "$enableval" in - yes) - optimize_for="speed" - AC_DEFINE(OPT_SPEED, 1, - [Define to optimize for speed over accuracy.]) - ;; - esac -]) - -AC_ARG_ENABLE(accuracy, AC_HELP_STRING([--enable-accuracy], - [optimize for accuracy over speed]), -[ - case "$enableval" in - yes) - if test "$optimize_for" = "speed" - then - optimize_for="both" - else - optimize_for="accuracy" - fi - AC_DEFINE(OPT_ACCURACY, 1, - [Define to optimize for accuracy over speed.]) - ;; - esac -]) - -AC_MSG_RESULT(${optimize_for-default}) - -if test "$optimize_for" = "both" -then - AC_MSG_ERROR(cannot optimize for both speed and accuracy) -fi - -AC_MSG_CHECKING(for architecture-specific fixed-point math routines) -AC_ARG_ENABLE(fpm, AC_HELP_STRING([--enable-fpm=ARCH], - [use ARCH-specific fixed-point math routines - (one of: intel, arm, mips, sparc, ppc, 64bit, default)]), -[ - case "$enableval" in - yes) ;; - no|default|approx) FPM="DEFAULT" ;; - intel|i?86) FPM="INTEL" ;; - arm) FPM="ARM" ;; - mips) FPM="MIPS" ;; - sparc) FPM="SPARC" ;; - ppc|powerpc) FPM="PPC" ;; - 64bit) FPM="64BIT" ;; - float) FPM="FLOAT" ;; - *) - AC_MSG_RESULT(failed) - AC_MSG_ERROR([bad --enable-fpm option]) - ;; - esac -]) - -if test -z "$FPM" && test "$GCC" = yes -then - case "$host" in - i?86-*) FPM="INTEL" ;; - arm*-*) FPM="ARM" ;; - mips*-*) FPM="MIPS" ;; - sparc*-*) FPM="SPARC" ;; - powerpc*-*) FPM="PPC" ;; - # FIXME: need to test for 64-bit long long... - esac -fi - -AC_MSG_RESULT(${FPM=DEFAULT}) - -if test "$FPM" = "DEFAULT" -then - AC_MSG_WARN([default fixed-point math will yield limited accuracy]) -fi - -FPM="-DFPM_$FPM" - -AC_ARG_ENABLE(sso, AC_HELP_STRING([--enable-sso], - [use subband synthesis optimization]), -[ - case "$enableval" in - yes) - AC_DEFINE(OPT_SSO, 1, - [Define to enable a fast subband synthesis approximation optimization.]) - ;; - esac -]) - -AC_ARG_ENABLE(aso, AC_HELP_STRING([--disable-aso], - [disable architecture-specific optimizations]), - [], [enable_aso=yes]) - -if test "$enable_aso" = yes -then - case "$host" in - i?86-*) - : #ASO="$ASO -DASO_INTERLEAVE1" - ASO="$ASO -DASO_ZEROCHECK" - : #not yet #ASO="$ASO -DASO_SYNTH" - : #not yet #ASO_OBJS="synth_mmx.lo" - ;; - arm*-*) - ASO="$ASO -DASO_INTERLEAVE1" - ASO="$ASO -DASO_IMDCT" - ASO_OBJS="imdct_l_arm.lo" - ;; - mips*-*) - ASO="$ASO -DASO_INTERLEAVE2" - ASO="$ASO -DASO_ZEROCHECK" - ;; - esac -fi - -AC_MSG_CHECKING(for ISO/IEC interpretation) -AC_ARG_ENABLE(strict-iso, AC_HELP_STRING([--enable-strict-iso], - [use strict ISO/IEC interpretations]), -[ - case "$enableval" in - yes) - AC_DEFINE(OPT_STRICT, 1, - [Define to influence a strict interpretation of the ISO/IEC standards, - even if this is in opposition with best accepted practices.]) - interpretation="strict" - ;; - esac -]) -AC_MSG_RESULT(${interpretation-best accepted practices}) - -AC_MSG_CHECKING(whether to enable profiling) -AC_ARG_ENABLE(profiling, AC_HELP_STRING([--enable-profiling], - [generate profiling code]), -[ - case "$enableval" in - yes) profile="-pg" ;; - esac -]) -AC_MSG_RESULT(${enable_profiling-no}) - -AC_MSG_CHECKING(whether to enable debugging) -AC_ARG_ENABLE(debugging, AC_HELP_STRING([--enable-debugging], - [enable diagnostic debugging support]) -AC_HELP_STRING([--disable-debugging], - [do not enable debugging and use more optimization]), -[ - case "$enableval" in - yes) - AC_DEFINE(DEBUG, 1, - [Define to enable diagnostic debugging support.]) - optimize="" - ;; - no) - if test -n "$profile" - then - AC_MSG_ERROR(--enable-profiling and --disable-debugging are incompatible) - fi - - AC_DEFINE(NDEBUG, 1, - [Define to disable debugging assertions.]) - debug="" - if test "$GCC" = yes - then - optimize="$optimize -fomit-frame-pointer" - fi - ;; - esac -]) -AC_MSG_RESULT(${enable_debugging-default}) - -AC_MSG_CHECKING(whether to enable experimental code) -AC_ARG_ENABLE(experimental, AC_HELP_STRING([--enable-experimental], - [enable experimental code]), -[ - case "$enableval" in - yes) - AC_DEFINE(EXPERIMENTAL, 1, - [Define to enable experimental code.]) - ;; - esac -]) -AC_MSG_RESULT(${enable_experimental-no}) - -dnl Create output files. - -test -n "$arch" && CFLAGS="$CFLAGS $arch" -test -n "$debug" && CFLAGS="$CFLAGS $debug" -test -n "$optimize" && CFLAGS="$CFLAGS $optimize" -test -n "$profile" && CFLAGS="$CFLAGS $profile" LDFLAGS="$LDFLAGS $profile" - -dnl LTLIBOBJS=`echo "$LIBOBJS" | sed -e 's/\.o/.lo/g'` -dnl AC_SUBST(LTLIBOBJS) - -AC_CONFIG_FILES([Makefile msvc++/Makefile \ - libmad.list]) -AC_OUTPUT diff --git a/code/libmad-0.15.1b/decoder.h b/code/libmad-0.15.1b/decoder.h deleted file mode 100644 index f0ad758d..00000000 --- a/code/libmad-0.15.1b/decoder.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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 - * - * $Id: decoder.h,v 1.17 2004/01/23 09:41:32 rob Exp $ - */ - -# ifndef LIBMAD_DECODER_H -# define LIBMAD_DECODER_H - -# include "stream.h" -# include "frame.h" -# include "synth.h" - -enum mad_decoder_mode { - MAD_DECODER_MODE_SYNC = 0, - MAD_DECODER_MODE_ASYNC -}; - -enum mad_flow { - MAD_FLOW_CONTINUE = 0x0000, /* continue normally */ - MAD_FLOW_STOP = 0x0010, /* stop decoding normally */ - MAD_FLOW_BREAK = 0x0011, /* stop decoding and signal an error */ - MAD_FLOW_IGNORE = 0x0020 /* ignore the current frame */ -}; - -struct mad_decoder { - enum mad_decoder_mode mode; - - int options; - - struct { - long pid; - int in; - int out; - } async; - - struct { - struct mad_stream stream; - struct mad_frame frame; - struct mad_synth synth; - } *sync; - - void *cb_data; - - enum mad_flow (*input_func)(void *, struct mad_stream *); - enum mad_flow (*header_func)(void *, struct mad_header const *); - enum mad_flow (*filter_func)(void *, - struct mad_stream const *, struct mad_frame *); - enum mad_flow (*output_func)(void *, - struct mad_header const *, struct mad_pcm *); - enum mad_flow (*error_func)(void *, struct mad_stream *, struct mad_frame *); - enum mad_flow (*message_func)(void *, void *, unsigned int *); -}; - -void mad_decoder_init(struct mad_decoder *, void *, - enum mad_flow (*)(void *, struct mad_stream *), - enum mad_flow (*)(void *, struct mad_header const *), - enum mad_flow (*)(void *, - struct mad_stream const *, - struct mad_frame *), - enum mad_flow (*)(void *, - struct mad_header const *, - struct mad_pcm *), - enum mad_flow (*)(void *, - struct mad_stream *, - struct mad_frame *), - enum mad_flow (*)(void *, void *, unsigned int *)); -int mad_decoder_finish(struct mad_decoder *); - -# define mad_decoder_options(decoder, opts) \ - ((void) ((decoder)->options = (opts))) - -int mad_decoder_run(struct mad_decoder *, enum mad_decoder_mode); -int mad_decoder_message(struct mad_decoder *, void *, unsigned int *); - -# endif diff --git a/code/libmad-0.15.1b/depcomp b/code/libmad-0.15.1b/depcomp deleted file mode 100644 index 51606f8c..00000000 --- a/code/libmad-0.15.1b/depcomp +++ /dev/null @@ -1,464 +0,0 @@ -#! /bin/sh - -# depcomp - compile a program generating dependencies as side-effects -# Copyright 1999, 2000 Free Software Foundation, 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, 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. - -# 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 Alexandre Oliva . - -if test -z "$depmode" || test -z "$source" || test -z "$object"; then - echo "depcomp: Variables source, object and depmode must be set" 1>&2 - exit 1 -fi -# `libtool' can also be set to `yes' or `no'. - -if test -z "$depfile"; then - base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'` - dir=`echo "$object" | sed 's,/.*$,/,'` - if test "$dir" = "$object"; then - dir= - fi - # FIXME: should be _deps on DOS. - depfile="$dir.deps/$base" -fi - -tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} - -rm -f "$tmpdepfile" - -# Some modes work just like other modes, but use different flags. We -# parameterize here, but still list the modes in the big case below, -# to make depend.m4 easier to write. Note that we *cannot* use a case -# here, because this file can only contain one case statement. -if test "$depmode" = hp; then - # HP compiler uses -M and no extra arg. - gccflag=-M - depmode=gcc -fi - -if test "$depmode" = dashXmstdout; then - # This is just like dashmstdout with a different argument. - dashmflag=-xM - depmode=dashmstdout -fi - -case "$depmode" in -gcc3) -## gcc 3 implements dependency tracking that does exactly what -## we want. Yay! Note: for some reason libtool 1.4 doesn't like -## it if -MD -MP comes after the -MF stuff. Hmm. - "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - mv "$tmpdepfile" "$depfile" - ;; - -gcc) -## There are various ways to get dependency output from gcc. Here's -## why we pick this rather obscure method: -## - Don't want to use -MD because we'd like the dependencies to end -## up in a subdir. Having to rename by hand is ugly. -## (We might end up doing this anyway to support other compilers.) -## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like -## -MM, not -M (despite what the docs say). -## - Using -M directly means running the compiler twice (even worse -## than renaming). - if test -z "$gccflag"; then - gccflag=-MD, - fi - "$@" -Wp,"$gccflag$tmpdepfile" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - echo "$object : \\" > "$depfile" - alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz -## The second -e expression handles DOS-style file names with drive letters. - sed -e 's/^[^:]*: / /' \ - -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" -## This next piece of magic avoids the `deleted header file' problem. -## The problem is that when a header file which appears in a .P file -## is deleted, the dependency causes make to die (because there is -## typically no way to rebuild the header). We avoid this by adding -## dummy dependencies for each header file. Too bad gcc doesn't do -## this for us directly. - tr ' ' ' -' < "$tmpdepfile" | -## Some versions of gcc put a space before the `:'. On the theory -## that the space means something, we add a space to the output as -## well. -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -hp) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; - -sgi) - if test "$libtool" = yes; then - "$@" "-Wp,-MDupdate,$tmpdepfile" - else - "$@" -MDupdate "$tmpdepfile" - fi - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - - if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files - echo "$object : \\" > "$depfile" - - # Clip off the initial element (the dependent). Don't try to be - # clever and replace this with sed code, as IRIX sed won't handle - # lines with more than a fixed number of characters (4096 in - # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; - # the IRIX cc adds comments like `#:fec' to the end of the - # dependency line. - tr ' ' ' -' < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ - tr ' -' ' ' >> $depfile - echo >> $depfile - - # The second pass generates a dummy entry for each header file. - tr ' ' ' -' < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ - >> $depfile - else - # The sourcefile does not contain any dependencies, so just - # store a dummy comment line, to avoid errors with the Makefile - # "include basename.Plo" scheme. - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -aix) - # The C for AIX Compiler uses -M and outputs the dependencies - # in a .u file. This file always lives in the current directory. - # Also, the AIX compiler puts `$object:' at the start of each line; - # $object doesn't have directory information. - stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'` - tmpdepfile="$stripped.u" - outname="$stripped.o" - if test "$libtool" = yes; then - "$@" -Wc,-M - else - "$@" -M - fi - - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - - if test -f "$tmpdepfile"; then - # Each line is of the form `foo.o: dependent.h'. - # Do two passes, one to just change these to - # `$object: dependent.h' and one to simply `dependent.h:'. - sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" - sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" - else - # The sourcefile does not contain any dependencies, so just - # store a dummy comment line, to avoid errors with the Makefile - # "include basename.Plo" scheme. - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -icc) - # Must come before tru64. - - # Intel's C compiler understands `-MD -MF file'. However - # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c - # will fill foo.d with something like - # foo.o: sub/foo.c - # foo.o: sub/foo.h - # which is wrong. We want: - # sub/foo.o: sub/foo.c - # sub/foo.o: sub/foo.h - # sub/foo.c: - # sub/foo.h: - - "$@" -MD -MF "$tmpdepfile" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - # Each line is of the form `foo.o: dependent.h'. - # Do two passes, one to just change these to - # `$object: dependent.h' and one to simply `dependent.h:'. - sed -e "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" - sed -e "s,^[^:]*: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" - rm -f "$tmpdepfile" - ;; - -tru64) - # The Tru64 compiler uses -MD to generate dependencies as a side - # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. - # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put - # dependencies in `foo.d' instead, so we check for that too. - # Subdirectories are respected. - dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` - test "x$dir" = "x$object" && dir= - base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` - - if test "$libtool" = yes; then - tmpdepfile1="$dir.libs/$base.lo.d" - tmpdepfile2="$dir.libs/$base.d" - "$@" -Wc,-MD - else - tmpdepfile1="$dir$base.o.d" - tmpdepfile2="$dir$base.d" - "$@" -MD - fi - - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile1" "$tmpdepfile2" - exit $stat - fi - - if test -f "$tmpdepfile1"; then - tmpdepfile="$tmpdepfile1" - else - tmpdepfile="$tmpdepfile2" - fi - if test -f "$tmpdepfile"; then - sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" - # That's a space and a tab in the []. - sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" - else - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -#nosideeffect) - # This comment above is used by automake to tell side-effect - # dependency tracking mechanisms from slower ones. - -dashmstdout) - # Important note: in order to support this mode, a compiler *must* - # always write the proprocessed file to stdout, regardless of -o. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test $1 != '--mode=compile'; do - shift - done - shift - fi - - # Remove `-o $object'. - IFS=" " - for arg - do - case $arg in - -o) - shift - ;; - $object) - shift - ;; - *) - set fnord "$@" "$arg" - shift # fnord - shift # $arg - ;; - esac - done - - test -z "$dashmflag" && dashmflag=-M - # Require at least two characters before searching for `:' - # in the target name. This is to cope with DOS-style filenames: - # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. - "$@" $dashmflag | - sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" - rm -f "$depfile" - cat < "$tmpdepfile" > "$depfile" - tr ' ' ' -' < "$tmpdepfile" | \ -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -dashXmstdout) - # This case only exists to satisfy depend.m4. It is never actually - # run, as this mode is specially recognized in the preamble. - exit 1 - ;; - -makedepend) - "$@" || exit $? - # Remove any Libtool call - if test "$libtool" = yes; then - while test $1 != '--mode=compile'; do - shift - done - shift - fi - # X makedepend - shift - cleared=no - for arg in "$@"; do - case $cleared in - no) - set ""; shift - cleared=yes ;; - esac - case "$arg" in - -D*|-I*) - set fnord "$@" "$arg"; shift ;; - # Strip any option that makedepend may not understand. Remove - # the object too, otherwise makedepend will parse it as a source file. - -*|$object) - ;; - *) - set fnord "$@" "$arg"; shift ;; - esac - done - obj_suffix="`echo $object | sed 's/^.*\././'`" - touch "$tmpdepfile" - ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" - rm -f "$depfile" - cat < "$tmpdepfile" > "$depfile" - sed '1,2d' "$tmpdepfile" | tr ' ' ' -' | \ -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" "$tmpdepfile".bak - ;; - -cpp) - # Important note: in order to support this mode, a compiler *must* - # always write the proprocessed file to stdout. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test $1 != '--mode=compile'; do - shift - done - shift - fi - - # Remove `-o $object'. - IFS=" " - for arg - do - case $arg in - -o) - shift - ;; - $object) - shift - ;; - *) - set fnord "$@" "$arg" - shift # fnord - shift # $arg - ;; - esac - done - - "$@" -E | - sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | - sed '$ s: \\$::' > "$tmpdepfile" - rm -f "$depfile" - echo "$object : \\" > "$depfile" - cat < "$tmpdepfile" >> "$depfile" - sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -msvisualcpp) - # Important note: in order to support this mode, a compiler *must* - # always write the proprocessed file to stdout, regardless of -o, - # because we must use -o when running libtool. - "$@" || exit $? - IFS=" " - for arg - do - case "$arg" in - "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") - set fnord "$@" - shift - shift - ;; - *) - set fnord "$@" "$arg" - shift - shift - ;; - esac - done - "$@" -E | - sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" - rm -f "$depfile" - echo "$object : \\" > "$depfile" - . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" - echo " " >> "$depfile" - . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -none) - exec "$@" - ;; - -*) - echo "Unknown depmode $depmode" 1>&2 - exit 1 - ;; -esac - -exit 0 diff --git a/code/libmad-0.15.1b/fixed.h b/code/libmad-0.15.1b/fixed.h deleted file mode 100644 index 4b58abf5..00000000 --- a/code/libmad-0.15.1b/fixed.h +++ /dev/null @@ -1,499 +0,0 @@ -/* - * 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 - * - * $Id: fixed.h,v 1.38 2004/02/17 02:02:03 rob Exp $ - */ - -# ifndef LIBMAD_FIXED_H -# define LIBMAD_FIXED_H - -# if SIZEOF_INT >= 4 -typedef signed int mad_fixed_t; - -typedef signed int mad_fixed64hi_t; -typedef unsigned int mad_fixed64lo_t; -# else -typedef signed long mad_fixed_t; - -typedef signed long mad_fixed64hi_t; -typedef unsigned long mad_fixed64lo_t; -# endif - -# if defined(_MSC_VER) -# define mad_fixed64_t signed __int64 -# elif 1 || defined(__GNUC__) -# define mad_fixed64_t signed long long -# endif - -# if defined(FPM_FLOAT) -typedef double mad_sample_t; -# else -typedef mad_fixed_t mad_sample_t; -# endif - -/* - * Fixed-point format: 0xABBBBBBB - * A == whole part (sign + 3 bits) - * B == fractional part (28 bits) - * - * Values are signed two's complement, so the effective range is: - * 0x80000000 to 0x7fffffff - * -8.0 to +7.9999999962747097015380859375 - * - * The smallest representable value is: - * 0x00000001 == 0.0000000037252902984619140625 (i.e. about 3.725e-9) - * - * 28 bits of fractional accuracy represent about - * 8.6 digits of decimal accuracy. - * - * Fixed-point numbers can be added or subtracted as normal - * integers, but multiplication requires shifting the 64-bit result - * from 56 fractional bits back to 28 (and rounding.) - * - * Changing the definition of MAD_F_FRACBITS is only partially - * supported, and must be done with care. - */ - -# define MAD_F_FRACBITS 28 - -# if MAD_F_FRACBITS == 28 -# define MAD_F(x) ((mad_fixed_t) (x##L)) -# else -# if MAD_F_FRACBITS < 28 -# warning "MAD_F_FRACBITS < 28" -# define MAD_F(x) ((mad_fixed_t) \ - (((x##L) + \ - (1L << (28 - MAD_F_FRACBITS - 1))) >> \ - (28 - MAD_F_FRACBITS))) -# elif MAD_F_FRACBITS > 28 -# error "MAD_F_FRACBITS > 28 not currently supported" -# define MAD_F(x) ((mad_fixed_t) \ - ((x##L) << (MAD_F_FRACBITS - 28))) -# endif -# endif - -# define MAD_F_MIN ((mad_fixed_t) -0x80000000L) -# define MAD_F_MAX ((mad_fixed_t) +0x7fffffffL) - -# define MAD_F_ONE MAD_F(0x10000000) - -# define mad_f_tofixed(x) ((mad_fixed_t) \ - ((x) * (double) (1L << MAD_F_FRACBITS) + 0.5)) -# define mad_f_todouble(x) ((double) \ - ((x) / (double) (1L << MAD_F_FRACBITS))) - -# define mad_f_intpart(x) ((x) >> MAD_F_FRACBITS) -# define mad_f_fracpart(x) ((x) & ((1L << MAD_F_FRACBITS) - 1)) - /* (x should be positive) */ - -# define mad_f_fromint(x) ((x) << MAD_F_FRACBITS) - -# define mad_f_add(x, y) ((x) + (y)) -# define mad_f_sub(x, y) ((x) - (y)) - -# if defined(FPM_FLOAT) -# error "FPM_FLOAT not yet supported" - -# undef MAD_F -# define MAD_F(x) mad_f_todouble(x) - -# define mad_f_mul(x, y) ((x) * (y)) -# define mad_f_scale64 - -# undef ASO_ZEROCHECK - -# elif defined(FPM_64BIT) - -/* - * This version should be the most accurate if 64-bit types are supported by - * the compiler, although it may not be the most efficient. - */ -# if defined(OPT_ACCURACY) -# define mad_f_mul(x, y) \ - ((mad_fixed_t) \ - ((((mad_fixed64_t) (x) * (y)) + \ - (1L << (MAD_F_SCALEBITS - 1))) >> MAD_F_SCALEBITS)) -# else -# define mad_f_mul(x, y) \ - ((mad_fixed_t) (((mad_fixed64_t) (x) * (y)) >> MAD_F_SCALEBITS)) -# endif - -# define MAD_F_SCALEBITS MAD_F_FRACBITS - -/* --- Intel --------------------------------------------------------------- */ - -# elif defined(FPM_INTEL) - -# if defined(_MSC_VER) -# pragma warning(push) -# pragma warning(disable: 4035) /* no return value */ -static __forceinline -mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y) -{ - enum { - fracbits = MAD_F_FRACBITS - }; - - __asm { - mov eax, x - imul y - shrd eax, edx, fracbits - } - - /* implicit return of eax */ -} -# pragma warning(pop) - -# define mad_f_mul mad_f_mul_inline -# define mad_f_scale64 -# else -/* - * This Intel version is fast and accurate; the disposition of the least - * significant bit depends on OPT_ACCURACY via mad_f_scale64(). - */ -# define MAD_F_MLX(hi, lo, x, y) \ - asm ("imull %3" \ - : "=a" (lo), "=d" (hi) \ - : "%a" (x), "rm" (y) \ - : "cc") - -# if defined(OPT_ACCURACY) -/* - * This gives best accuracy but is not very fast. - */ -# define MAD_F_MLA(hi, lo, x, y) \ - ({ mad_fixed64hi_t __hi; \ - mad_fixed64lo_t __lo; \ - MAD_F_MLX(__hi, __lo, (x), (y)); \ - asm ("addl %2,%0\n\t" \ - "adcl %3,%1" \ - : "=rm" (lo), "=rm" (hi) \ - : "r" (__lo), "r" (__hi), "0" (lo), "1" (hi) \ - : "cc"); \ - }) -# endif /* OPT_ACCURACY */ - -# if defined(OPT_ACCURACY) -/* - * Surprisingly, this is faster than SHRD followed by ADC. - */ -# define mad_f_scale64(hi, lo) \ - ({ mad_fixed64hi_t __hi_; \ - mad_fixed64lo_t __lo_; \ - mad_fixed_t __result; \ - asm ("addl %4,%2\n\t" \ - "adcl %5,%3" \ - : "=rm" (__lo_), "=rm" (__hi_) \ - : "0" (lo), "1" (hi), \ - "ir" (1L << (MAD_F_SCALEBITS - 1)), "ir" (0) \ - : "cc"); \ - asm ("shrdl %3,%2,%1" \ - : "=rm" (__result) \ - : "0" (__lo_), "r" (__hi_), "I" (MAD_F_SCALEBITS) \ - : "cc"); \ - __result; \ - }) -# elif defined(OPT_INTEL) -/* - * Alternate Intel scaling that may or may not perform better. - */ -# define mad_f_scale64(hi, lo) \ - ({ mad_fixed_t __result; \ - asm ("shrl %3,%1\n\t" \ - "shll %4,%2\n\t" \ - "orl %2,%1" \ - : "=rm" (__result) \ - : "0" (lo), "r" (hi), \ - "I" (MAD_F_SCALEBITS), "I" (32 - MAD_F_SCALEBITS) \ - : "cc"); \ - __result; \ - }) -# else -# define mad_f_scale64(hi, lo) \ - ({ mad_fixed_t __result; \ - asm ("shrdl %3,%2,%1" \ - : "=rm" (__result) \ - : "0" (lo), "r" (hi), "I" (MAD_F_SCALEBITS) \ - : "cc"); \ - __result; \ - }) -# endif /* OPT_ACCURACY */ - -# define MAD_F_SCALEBITS MAD_F_FRACBITS -# endif - -/* --- ARM ----------------------------------------------------------------- */ - -# elif defined(FPM_ARM) - -/* - * This ARM V4 version is as accurate as FPM_64BIT but much faster. The - * least significant bit is properly rounded at no CPU cycle cost! - */ -# if 1 -/* - * This is faster than the default implementation via MAD_F_MLX() and - * mad_f_scale64(). - */ -# define mad_f_mul(x, y) \ - ({ mad_fixed64hi_t __hi; \ - mad_fixed64lo_t __lo; \ - mad_fixed_t __result; \ - asm ("smull %0, %1, %3, %4\n\t" \ - "movs %0, %0, lsr %5\n\t" \ - "adc %2, %0, %1, lsl %6" \ - : "=&r" (__lo), "=&r" (__hi), "=r" (__result) \ - : "%r" (x), "r" (y), \ - "M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \ - : "cc"); \ - __result; \ - }) -# endif - -# define MAD_F_MLX(hi, lo, x, y) \ - asm ("smull %0, %1, %2, %3" \ - : "=&r" (lo), "=&r" (hi) \ - : "%r" (x), "r" (y)) - -# define MAD_F_MLA(hi, lo, x, y) \ - asm ("smlal %0, %1, %2, %3" \ - : "+r" (lo), "+r" (hi) \ - : "%r" (x), "r" (y)) - -# define MAD_F_MLN(hi, lo) \ - asm ("rsbs %0, %2, #0\n\t" \ - "rsc %1, %3, #0" \ - : "=r" (lo), "=r" (hi) \ - : "0" (lo), "1" (hi) \ - : "cc") - -# define mad_f_scale64(hi, lo) \ - ({ mad_fixed_t __result; \ - asm ("movs %0, %1, lsr %3\n\t" \ - "adc %0, %0, %2, lsl %4" \ - : "=&r" (__result) \ - : "r" (lo), "r" (hi), \ - "M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \ - : "cc"); \ - __result; \ - }) - -# define MAD_F_SCALEBITS MAD_F_FRACBITS - -/* --- MIPS ---------------------------------------------------------------- */ - -# elif defined(FPM_MIPS) - -/* - * This MIPS version is fast and accurate; the disposition of the least - * significant bit depends on OPT_ACCURACY via mad_f_scale64(). - */ -# define MAD_F_MLX(hi, lo, x, y) \ - asm ("mult %2,%3" \ - : "=l" (lo), "=h" (hi) \ - : "%r" (x), "r" (y)) - -# if defined(HAVE_MADD_ASM) -# define MAD_F_MLA(hi, lo, x, y) \ - asm ("madd %2,%3" \ - : "+l" (lo), "+h" (hi) \ - : "%r" (x), "r" (y)) -# elif defined(HAVE_MADD16_ASM) -/* - * This loses significant accuracy due to the 16-bit integer limit in the - * multiply/accumulate instruction. - */ -# define MAD_F_ML0(hi, lo, x, y) \ - asm ("mult %2,%3" \ - : "=l" (lo), "=h" (hi) \ - : "%r" ((x) >> 12), "r" ((y) >> 16)) -# define MAD_F_MLA(hi, lo, x, y) \ - asm ("madd16 %2,%3" \ - : "+l" (lo), "+h" (hi) \ - : "%r" ((x) >> 12), "r" ((y) >> 16)) -# define MAD_F_MLZ(hi, lo) ((mad_fixed_t) (lo)) -# endif - -# if defined(OPT_SPEED) -# define mad_f_scale64(hi, lo) \ - ((mad_fixed_t) ((hi) << (32 - MAD_F_SCALEBITS))) -# define MAD_F_SCALEBITS MAD_F_FRACBITS -# endif - -/* --- SPARC --------------------------------------------------------------- */ - -# elif defined(FPM_SPARC) - -/* - * This SPARC V8 version is fast and accurate; the disposition of the least - * significant bit depends on OPT_ACCURACY via mad_f_scale64(). - */ -# define MAD_F_MLX(hi, lo, x, y) \ - asm ("smul %2, %3, %0\n\t" \ - "rd %%y, %1" \ - : "=r" (lo), "=r" (hi) \ - : "%r" (x), "rI" (y)) - -/* --- PowerPC ------------------------------------------------------------- */ - -# elif defined(FPM_PPC) - -/* - * This PowerPC version is fast and accurate; the disposition of the least - * significant bit depends on OPT_ACCURACY via mad_f_scale64(). - */ -# define MAD_F_MLX(hi, lo, x, y) \ - do { \ - asm ("mullw %0,%1,%2" \ - : "=r" (lo) \ - : "%r" (x), "r" (y)); \ - asm ("mulhw %0,%1,%2" \ - : "=r" (hi) \ - : "%r" (x), "r" (y)); \ - } \ - while (0) - -# if defined(OPT_ACCURACY) -/* - * This gives best accuracy but is not very fast. - */ -# define MAD_F_MLA(hi, lo, x, y) \ - ({ mad_fixed64hi_t __hi; \ - mad_fixed64lo_t __lo; \ - MAD_F_MLX(__hi, __lo, (x), (y)); \ - asm ("addc %0,%2,%3\n\t" \ - "adde %1,%4,%5" \ - : "=r" (lo), "=r" (hi) \ - : "%r" (lo), "r" (__lo), \ - "%r" (hi), "r" (__hi) \ - : "xer"); \ - }) -# endif - -# if defined(OPT_ACCURACY) -/* - * This is slower than the truncating version below it. - */ -# define mad_f_scale64(hi, lo) \ - ({ mad_fixed_t __result, __round; \ - asm ("rotrwi %0,%1,%2" \ - : "=r" (__result) \ - : "r" (lo), "i" (MAD_F_SCALEBITS)); \ - asm ("extrwi %0,%1,1,0" \ - : "=r" (__round) \ - : "r" (__result)); \ - asm ("insrwi %0,%1,%2,0" \ - : "+r" (__result) \ - : "r" (hi), "i" (MAD_F_SCALEBITS)); \ - asm ("add %0,%1,%2" \ - : "=r" (__result) \ - : "%r" (__result), "r" (__round)); \ - __result; \ - }) -# else -# define mad_f_scale64(hi, lo) \ - ({ mad_fixed_t __result; \ - asm ("rotrwi %0,%1,%2" \ - : "=r" (__result) \ - : "r" (lo), "i" (MAD_F_SCALEBITS)); \ - asm ("insrwi %0,%1,%2,0" \ - : "+r" (__result) \ - : "r" (hi), "i" (MAD_F_SCALEBITS)); \ - __result; \ - }) -# endif - -# define MAD_F_SCALEBITS MAD_F_FRACBITS - -/* --- Default ------------------------------------------------------------- */ - -# elif defined(FPM_DEFAULT) - -/* - * This version is the most portable but it loses significant accuracy. - * Furthermore, accuracy is biased against the second argument, so care - * should be taken when ordering operands. - * - * The scale factors are constant as this is not used with SSO. - * - * Pre-rounding is required to stay within the limits of compliance. - */ -# if defined(OPT_SPEED) -# define mad_f_mul(x, y) (((x) >> 12) * ((y) >> 16)) -# else -# define mad_f_mul(x, y) ((((x) + (1L << 11)) >> 12) * \ - (((y) + (1L << 15)) >> 16)) -# endif - -/* ------------------------------------------------------------------------- */ - -# else -# error "no FPM selected" -# endif - -/* default implementations */ - -# if !defined(mad_f_mul) -# define mad_f_mul(x, y) \ - ({ register mad_fixed64hi_t __hi; \ - register mad_fixed64lo_t __lo; \ - MAD_F_MLX(__hi, __lo, (x), (y)); \ - mad_f_scale64(__hi, __lo); \ - }) -# endif - -# if !defined(MAD_F_MLA) -# define MAD_F_ML0(hi, lo, x, y) ((lo) = mad_f_mul((x), (y))) -# define MAD_F_MLA(hi, lo, x, y) ((lo) += mad_f_mul((x), (y))) -# define MAD_F_MLN(hi, lo) ((lo) = -(lo)) -# define MAD_F_MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo)) -# endif - -# if !defined(MAD_F_ML0) -# define MAD_F_ML0(hi, lo, x, y) MAD_F_MLX((hi), (lo), (x), (y)) -# endif - -# if !defined(MAD_F_MLN) -# define MAD_F_MLN(hi, lo) ((hi) = ((lo) = -(lo)) ? ~(hi) : -(hi)) -# endif - -# if !defined(MAD_F_MLZ) -# define MAD_F_MLZ(hi, lo) mad_f_scale64((hi), (lo)) -# endif - -# if !defined(mad_f_scale64) -# if defined(OPT_ACCURACY) -# define mad_f_scale64(hi, lo) \ - ((((mad_fixed_t) \ - (((hi) << (32 - (MAD_F_SCALEBITS - 1))) | \ - ((lo) >> (MAD_F_SCALEBITS - 1)))) + 1) >> 1) -# else -# define mad_f_scale64(hi, lo) \ - ((mad_fixed_t) \ - (((hi) << (32 - MAD_F_SCALEBITS)) | \ - ((lo) >> MAD_F_SCALEBITS))) -# endif -# define MAD_F_SCALEBITS MAD_F_FRACBITS -# endif - -/* C routines */ - -mad_fixed_t mad_f_abs(mad_fixed_t); -mad_fixed_t mad_f_div(mad_fixed_t, mad_fixed_t); - -# endif diff --git a/code/libmad-0.15.1b/frame.h b/code/libmad-0.15.1b/frame.h deleted file mode 100644 index 3f5bf37e..00000000 --- a/code/libmad-0.15.1b/frame.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * 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 - * - * $Id: frame.h,v 1.20 2004/01/23 09:41:32 rob Exp $ - */ - -# ifndef LIBMAD_FRAME_H -# define LIBMAD_FRAME_H - -# include "fixed.h" -# include "timer.h" -# include "stream.h" - -enum mad_layer { - MAD_LAYER_I = 1, /* Layer I */ - MAD_LAYER_II = 2, /* Layer II */ - MAD_LAYER_III = 3 /* Layer III */ -}; - -enum mad_mode { - MAD_MODE_SINGLE_CHANNEL = 0, /* single channel */ - MAD_MODE_DUAL_CHANNEL = 1, /* dual channel */ - MAD_MODE_JOINT_STEREO = 2, /* joint (MS/intensity) stereo */ - MAD_MODE_STEREO = 3 /* normal LR stereo */ -}; - -enum mad_emphasis { - MAD_EMPHASIS_NONE = 0, /* no emphasis */ - MAD_EMPHASIS_50_15_US = 1, /* 50/15 microseconds emphasis */ - MAD_EMPHASIS_CCITT_J_17 = 3, /* CCITT J.17 emphasis */ - MAD_EMPHASIS_RESERVED = 2 /* unknown emphasis */ -}; - -struct mad_header { - enum mad_layer layer; /* audio layer (1, 2, or 3) */ - enum mad_mode mode; /* channel mode (see above) */ - int mode_extension; /* additional mode info */ - enum mad_emphasis emphasis; /* de-emphasis to use (see above) */ - - unsigned long bitrate; /* stream bitrate (bps) */ - unsigned int samplerate; /* sampling frequency (Hz) */ - - unsigned short crc_check; /* frame CRC accumulator */ - unsigned short crc_target; /* final target CRC checksum */ - - int flags; /* flags (see below) */ - int private_bits; /* private bits (see below) */ - - mad_timer_t duration; /* audio playing time of frame */ -}; - -struct mad_frame { - struct mad_header header; /* MPEG audio header */ - - int options; /* decoding options (from stream) */ - - mad_fixed_t sbsample[2][36][32]; /* synthesis subband filter samples */ - mad_fixed_t (*overlap)[2][32][18]; /* Layer III block overlap data */ -}; - -# define MAD_NCHANNELS(header) ((header)->mode ? 2 : 1) -# define MAD_NSBSAMPLES(header) \ - ((header)->layer == MAD_LAYER_I ? 12 : \ - (((header)->layer == MAD_LAYER_III && \ - ((header)->flags & MAD_FLAG_LSF_EXT)) ? 18 : 36)) - -enum { - MAD_FLAG_NPRIVATE_III = 0x0007, /* number of Layer III private bits */ - MAD_FLAG_INCOMPLETE = 0x0008, /* header but not data is decoded */ - - MAD_FLAG_PROTECTION = 0x0010, /* frame has CRC protection */ - MAD_FLAG_COPYRIGHT = 0x0020, /* frame is copyright */ - MAD_FLAG_ORIGINAL = 0x0040, /* frame is original (else copy) */ - MAD_FLAG_PADDING = 0x0080, /* frame has additional slot */ - - MAD_FLAG_I_STEREO = 0x0100, /* uses intensity joint stereo */ - MAD_FLAG_MS_STEREO = 0x0200, /* uses middle/side joint stereo */ - MAD_FLAG_FREEFORMAT = 0x0400, /* uses free format bitrate */ - - MAD_FLAG_LSF_EXT = 0x1000, /* lower sampling freq. extension */ - MAD_FLAG_MC_EXT = 0x2000, /* multichannel audio extension */ - MAD_FLAG_MPEG_2_5_EXT = 0x4000 /* MPEG 2.5 (unofficial) extension */ -}; - -enum { - MAD_PRIVATE_HEADER = 0x0100, /* header private bit */ - MAD_PRIVATE_III = 0x001f /* Layer III private bits (up to 5) */ -}; - -void mad_header_init(struct mad_header *); - -# define mad_header_finish(header) /* nothing */ - -int mad_header_decode(struct mad_header *, struct mad_stream *); - -void mad_frame_init(struct mad_frame *); -void mad_frame_finish(struct mad_frame *); - -int mad_frame_decode(struct mad_frame *, struct mad_stream *); - -void mad_frame_mute(struct mad_frame *); - -# endif diff --git a/code/libmad-0.15.1b/install-sh b/code/libmad-0.15.1b/install-sh deleted file mode 100644 index 36f96f3e..00000000 --- a/code/libmad-0.15.1b/install-sh +++ /dev/null @@ -1,276 +0,0 @@ -#!/bin/sh -# -# install - install a program, script, or datafile -# This comes from X11R5 (mit/util/scripts/install.sh). -# -# Copyright 1991 by the Massachusetts Institute of Technology -# -# Permission to use, copy, modify, distribute, and sell this software and its -# documentation for any purpose is hereby granted without fee, provided that -# the above copyright notice appear in all copies and that both that -# copyright notice and this permission notice appear in supporting -# documentation, and that the name of M.I.T. not be used in advertising or -# publicity pertaining to distribution of the software without specific, -# written prior permission. M.I.T. makes no representations about the -# suitability of this software for any purpose. It is provided "as is" -# without express or implied warranty. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. It can only install one file at a time, a restriction -# shared with many OS's install programs. - - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" - - -# put in absolute paths if you don't have them in your path; or use env. vars. - -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" - -transformbasename="" -transform_arg="" -instcmd="$mvprog" -chmodcmd="$chmodprog 0755" -chowncmd="" -chgrpcmd="" -stripcmd="" -rmcmd="$rmprog -f" -mvcmd="$mvprog" -src="" -dst="" -dir_arg="" - -while [ x"$1" != x ]; do - case $1 in - -c) instcmd=$cpprog - shift - continue;; - - -d) dir_arg=true - shift - continue;; - - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - -s) stripcmd=$stripprog - shift - continue;; - - -t=*) transformarg=`echo $1 | sed 's/-t=//'` - shift - continue;; - - -b=*) transformbasename=`echo $1 | sed 's/-b=//'` - shift - continue;; - - *) if [ x"$src" = x ] - then - src=$1 - else - # this colon is to work around a 386BSD /bin/sh bug - : - dst=$1 - fi - shift - continue;; - esac -done - -if [ x"$src" = x ] -then - echo "$0: no input file specified" >&2 - exit 1 -else - : -fi - -if [ x"$dir_arg" != x ]; then - dst=$src - src="" - - if [ -d "$dst" ]; then - instcmd=: - chmodcmd="" - else - instcmd=$mkdirprog - fi -else - -# Waiting for this to be detected by the "$instcmd $src $dsttmp" command -# might cause directories to be created, which would be especially bad -# if $src (and thus $dsttmp) contains '*'. - - if [ -f "$src" ] || [ -d "$src" ] - then - : - else - echo "$0: $src does not exist" >&2 - exit 1 - fi - - if [ x"$dst" = x ] - then - echo "$0: no destination specified" >&2 - exit 1 - else - : - fi - -# If destination is a directory, append the input filename; if your system -# does not like double slashes in filenames, you may need to add some logic - - if [ -d "$dst" ] - then - dst=$dst/`basename "$src"` - else - : - fi -fi - -## this sed command emulates the dirname command -dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` - -# Make sure that the destination directory exists. -# this part is taken from Noah Friedman's mkinstalldirs script - -# Skip lots of stat calls in the usual case. -if [ ! -d "$dstdir" ]; then -defaultIFS=' - ' -IFS="${IFS-$defaultIFS}" - -oIFS=$IFS -# Some sh's can't handle IFS=/ for some reason. -IFS='%' -set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'` -IFS=$oIFS - -pathcomp='' - -while [ $# -ne 0 ] ; do - pathcomp=$pathcomp$1 - shift - - if [ ! -d "$pathcomp" ] ; - then - $mkdirprog "$pathcomp" - else - : - fi - - pathcomp=$pathcomp/ -done -fi - -if [ x"$dir_arg" != x ] -then - $doit $instcmd "$dst" && - - if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else : ; fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else : ; fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else : ; fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else : ; fi -else - -# If we're going to rename the final executable, determine the name now. - - if [ x"$transformarg" = x ] - then - dstfile=`basename "$dst"` - else - dstfile=`basename "$dst" $transformbasename | - sed $transformarg`$transformbasename - fi - -# don't allow the sed command to completely eliminate the filename - - if [ x"$dstfile" = x ] - then - dstfile=`basename "$dst"` - else - : - fi - -# Make a couple of temp file names in the proper directory. - - dsttmp=$dstdir/#inst.$$# - rmtmp=$dstdir/#rm.$$# - -# Trap to clean up temp files at exit. - - trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0 - trap '(exit $?); exit' 1 2 13 15 - -# Move or copy the file name to the temp name - - $doit $instcmd "$src" "$dsttmp" && - -# and set any options; do chmod last to preserve setuid bits - -# If any of these fail, we abort the whole thing. If we want to -# ignore errors from any of these, just make sure not to ignore -# errors from the above "$doit $instcmd $src $dsttmp" command. - - if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else :;fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else :;fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; else :;fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else :;fi && - -# Now remove or move aside any old file at destination location. We try this -# two ways since rm can't unlink itself on some systems and the destination -# file might be busy for other reasons. In this case, the final cleanup -# might fail but the new file should still install successfully. - -{ - if [ -f "$dstdir/$dstfile" ] - then - $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null || - $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null || - { - echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 - (exit 1); exit - } - else - : - fi -} && - -# Now rename the file to the real destination. - - $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" - -fi && - -# The final little trick to "correctly" pass the exit status to the exit trap. - -{ - (exit 0); exit -} diff --git a/code/libmad-0.15.1b/libmad.list.in b/code/libmad-0.15.1b/libmad.list.in deleted file mode 100644 index 4718fef3..00000000 --- a/code/libmad-0.15.1b/libmad.list.in +++ /dev/null @@ -1,21 +0,0 @@ -# @configure_input@ - -# Directories... -$prefix=@prefix@ -$exec_prefix=@exec_prefix@ -$srcdir=@srcdir@ - -# Product information -%product @PACKAGE@ -%copyright GPL -%vendor Underbit Technologies, Inc. -%license @srcdir@/COPYING -%readme @srcdir@/README -%description libmad is an MPEG audio decoder library. -%version @VERSION@ -%packager Giuseppe "Cowo" Corbelli - -%system all -f 0755 root root @libdir@/libmad.la .libs/libmad.lai -f 0644 root root @libdir@/libmad.a .libs/libmad.a -f 0644 root root @includedir@/mad.h mad.h diff --git a/code/libmad-0.15.1b/ltmain.sh b/code/libmad-0.15.1b/ltmain.sh deleted file mode 100644 index 4b9f9405..00000000 --- a/code/libmad-0.15.1b/ltmain.sh +++ /dev/null @@ -1,6399 +0,0 @@ -# ltmain.sh - Provide generalized library-building support services. -# NOTE: Changing this file will not affect anything until you rerun configure. -# -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003 -# Free Software Foundation, Inc. -# Originally by Gordon Matzigkeit , 1996 -# -# 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. -# -# 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. - -# Check that we have a working $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, and then maybe $echo will work. - exec $SHELL "$0" --no-reexec ${1+"$@"} -fi - -if test "X$1" = X--fallback-echo; then - # used as fallback echo - shift - cat <&2 - $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 - exit 1 -fi - -# Global variables. -mode=$default_mode -nonopt= -prev= -prevopt= -run= -show="$echo" -show_help= -execute_dlfiles= -lo2o="s/\\.lo\$/.${objext}/" -o2lo="s/\\.${objext}\$/.lo/" - -##################################### -# Shell function definitions: -# This seems to be the best place for them - -# Need a lot of goo to handle *both* DLLs and import libs -# Has to be a shell function in order to 'eat' the argument -# that is supplied when $file_magic_command is called. -win32_libid () { - win32_libid_type="unknown" - win32_fileres=`file -L $1 2>/dev/null` - case $win32_fileres in - *ar\ archive\ import\ library*) # definitely import - win32_libid_type="x86 archive import" - ;; - *ar\ archive*) # could be an import, or static - if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \ - grep -E 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then - win32_nmres=`eval $NM -f posix -A $1 | \ - sed -n -e '1,100{/ I /{x;/import/!{s/^/import/;h;p;};x;};}'` - if test "X$win32_nmres" = "Ximport" ; then - win32_libid_type="x86 archive import" - else - win32_libid_type="x86 archive static" - fi - fi - ;; - *DLL*) - win32_libid_type="x86 DLL" - ;; - *executable*) # but shell scripts are "executable" too... - case $win32_fileres in - *MS\ Windows\ PE\ Intel*) - win32_libid_type="x86 DLL" - ;; - esac - ;; - esac - $echo $win32_libid_type -} - -# End of Shell function definitions -##################################### - -# Parse our command line options once, thoroughly. -while test "$#" -gt 0 -do - arg="$1" - shift - - case $arg in - -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;; - *) optarg= ;; - esac - - # If the previous option needs an argument, assign it. - if test -n "$prev"; then - case $prev in - execute_dlfiles) - execute_dlfiles="$execute_dlfiles $arg" - ;; - tag) - tagname="$arg" - preserve_args="${preserve_args}=$arg" - - # Check whether tagname contains only valid characters - case $tagname in - *[!-_A-Za-z0-9,/]*) - $echo "$progname: invalid tag name: $tagname" 1>&2 - exit 1 - ;; - esac - - case $tagname in - CC) - # Don't test for the "default" C tag, as we know, it's there, but - # not specially marked. - ;; - *) - if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$0" > /dev/null; then - taglist="$taglist $tagname" - # Evaluate the configuration. - eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $0`" - else - $echo "$progname: ignoring unknown tag $tagname" 1>&2 - fi - ;; - esac - ;; - *) - eval "$prev=\$arg" - ;; - esac - - prev= - prevopt= - continue - fi - - # Have we seen a non-optional argument yet? - case $arg in - --help) - show_help=yes - ;; - - --version) - $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP" - $echo - $echo "Copyright (C) 2003 Free Software Foundation, Inc." - $echo "This is free software; see the source for copying conditions. There is NO" - $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - exit 0 - ;; - - --config) - ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $0 - # Now print the configurations for the tags. - for tagname in $taglist; do - ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$0" - done - exit 0 - ;; - - --debug) - $echo "$progname: enabling shell trace mode" - set -x - preserve_args="$preserve_args $arg" - ;; - - --dry-run | -n) - run=: - ;; - - --features) - $echo "host: $host" - if test "$build_libtool_libs" = yes; then - $echo "enable shared libraries" - else - $echo "disable shared libraries" - fi - if test "$build_old_libs" = yes; then - $echo "enable static libraries" - else - $echo "disable static libraries" - fi - exit 0 - ;; - - --finish) mode="finish" ;; - - --mode) prevopt="--mode" prev=mode ;; - --mode=*) mode="$optarg" ;; - - --preserve-dup-deps) duplicate_deps="yes" ;; - - --quiet | --silent) - show=: - preserve_args="$preserve_args $arg" - ;; - - --tag) prevopt="--tag" prev=tag ;; - --tag=*) - set tag "$optarg" ${1+"$@"} - shift - prev=tag - preserve_args="$preserve_args --tag" - ;; - - -dlopen) - prevopt="-dlopen" - prev=execute_dlfiles - ;; - - -*) - $echo "$modename: unrecognized option \`$arg'" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; - - *) - nonopt="$arg" - break - ;; - esac -done - -if test -n "$prevopt"; then - $echo "$modename: option \`$prevopt' requires an argument" 1>&2 - $echo "$help" 1>&2 - exit 1 -fi - -# If this variable is set in any of the actions, the command in it -# will be execed at the end. This prevents here-documents from being -# left over by shells. -exec_cmd= - -if test -z "$show_help"; then - - # Infer the operation mode. - if test -z "$mode"; then - $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2 - $echo "*** Future versions of Libtool will require -mode=MODE be specified." 1>&2 - case $nonopt in - *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*) - mode=link - for arg - do - case $arg in - -c) - mode=compile - break - ;; - esac - done - ;; - *db | *dbx | *strace | *truss) - mode=execute - ;; - *install*|cp|mv) - mode=install - ;; - *rm) - mode=uninstall - ;; - *) - # If we have no mode, but dlfiles were specified, then do execute mode. - test -n "$execute_dlfiles" && mode=execute - - # Just use the default operation mode. - if test -z "$mode"; then - if test -n "$nonopt"; then - $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2 - else - $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2 - fi - fi - ;; - esac - fi - - # Only execute mode is allowed to have -dlopen flags. - if test -n "$execute_dlfiles" && test "$mode" != execute; then - $echo "$modename: unrecognized option \`-dlopen'" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - # Change the help message to a mode-specific one. - generic_help="$help" - help="Try \`$modename --help --mode=$mode' for more information." - - # These modes are in order of execution frequency so that they run quickly. - case $mode in - # libtool compile mode - compile) - modename="$modename: compile" - # Get the compilation command and the source file. - base_compile= - srcfile="$nonopt" # always keep a non-empty value in "srcfile" - suppress_opt=yes - suppress_output= - arg_mode=normal - libobj= - later= - - for arg - do - case "$arg_mode" in - arg ) - # do not "continue". Instead, add this to base_compile - lastarg="$arg" - arg_mode=normal - ;; - - target ) - libobj="$arg" - arg_mode=normal - continue - ;; - - normal ) - # Accept any command-line options. - case $arg in - -o) - if test -n "$libobj" ; then - $echo "$modename: you cannot specify \`-o' more than once" 1>&2 - exit 1 - fi - arg_mode=target - continue - ;; - - -static | -prefer-pic | -prefer-non-pic) - later="$later $arg" - continue - ;; - - -no-suppress) - suppress_opt=no - continue - ;; - - -Xcompiler) - arg_mode=arg # the next one goes into the "base_compile" arg list - continue # The current "srcfile" will either be retained or - ;; # replaced later. I would guess that would be a bug. - - -Wc,*) - args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"` - lastarg= - save_ifs="$IFS"; IFS=',' - for arg in $args; do - IFS="$save_ifs" - - # Double-quote args containing other shell metacharacters. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - lastarg="$lastarg $arg" - done - IFS="$save_ifs" - lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"` - - # Add the arguments to base_compile. - base_compile="$base_compile $lastarg" - continue - ;; - - * ) - # Accept the current argument as the source file. - # The previous "srcfile" becomes the current argument. - # - lastarg="$srcfile" - srcfile="$arg" - ;; - esac # case $arg - ;; - esac # case $arg_mode - - # Aesthetically quote the previous argument. - lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"` - - case $lastarg in - # Double-quote args containing other shell metacharacters. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - lastarg="\"$lastarg\"" - ;; - esac - - base_compile="$base_compile $lastarg" - done # for arg - - case $arg_mode in - arg) - $echo "$modename: you must specify an argument for -Xcompile" - exit 1 - ;; - target) - $echo "$modename: you must specify a target with \`-o'" 1>&2 - exit 1 - ;; - *) - # Get the name of the library object. - [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` - ;; - esac - - # Recognize several different file suffixes. - # If the user specifies -o file.o, it is replaced with file.lo - xform='[cCFSifmso]' - case $libobj in - *.ada) xform=ada ;; - *.adb) xform=adb ;; - *.ads) xform=ads ;; - *.asm) xform=asm ;; - *.c++) xform=c++ ;; - *.cc) xform=cc ;; - *.ii) xform=ii ;; - *.class) xform=class ;; - *.cpp) xform=cpp ;; - *.cxx) xform=cxx ;; - *.f90) xform=f90 ;; - *.for) xform=for ;; - *.java) xform=java ;; - esac - - libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"` - - case $libobj in - *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;; - *) - $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2 - exit 1 - ;; - esac - - # Infer tagged configuration to use if any are available and - # if one wasn't chosen via the "--tag" command line option. - # Only attempt this if the compiler in the base compile - # command doesn't match the default compiler. - if test -n "$available_tags" && test -z "$tagname"; then - case $base_compile in - # Blanks in the command may have been stripped by the calling shell, - # but not from the CC environment variable when configure was run. - " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "*) ;; - # Blanks at the start of $base_compile will cause this to fail - # if we don't check for them as well. - *) - for z in $available_tags; do - if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$0" > /dev/null; then - # Evaluate the configuration. - eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $0`" - case "$base_compile " in - "$CC "* | " $CC "* | "`$echo $CC` "* | " `$echo $CC` "*) - # The compiler in the base compile command matches - # the one in the tagged configuration. - # Assume this is the tagged configuration we want. - tagname=$z - break - ;; - esac - fi - done - # If $tagname still isn't set, then no tagged configuration - # was found and let the user know that the "--tag" command - # line option must be used. - if test -z "$tagname"; then - $echo "$modename: unable to infer tagged configuration" - $echo "$modename: specify a tag with \`--tag'" 1>&2 - exit 1 -# else -# $echo "$modename: using $tagname tagged configuration" - fi - ;; - esac - fi - - for arg in $later; do - case $arg in - -static) - build_old_libs=yes - continue - ;; - - -prefer-pic) - pic_mode=yes - continue - ;; - - -prefer-non-pic) - pic_mode=no - continue - ;; - esac - done - - objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` - xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` - if test "X$xdir" = "X$obj"; then - xdir= - else - xdir=$xdir/ - fi - lobj=${xdir}$objdir/$objname - - if test -z "$base_compile"; then - $echo "$modename: you must specify a compilation command" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - # Delete any leftover library objects. - if test "$build_old_libs" = yes; then - removelist="$obj $lobj $libobj ${libobj}T" - else - removelist="$lobj $libobj ${libobj}T" - fi - - $run $rm $removelist - trap "$run $rm $removelist; exit 1" 1 2 15 - - # On Cygwin there's no "real" PIC flag so we must build both object types - case $host_os in - cygwin* | mingw* | pw32* | os2*) - pic_mode=default - ;; - esac - if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then - # non-PIC code in shared libraries is not supported - pic_mode=default - fi - - # Calculate the filename of the output object if compiler does - # not support -o with -c - if test "$compiler_c_o" = no; then - output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext} - lockfile="$output_obj.lock" - removelist="$removelist $output_obj $lockfile" - trap "$run $rm $removelist; exit 1" 1 2 15 - else - output_obj= - need_locks=no - lockfile= - fi - - # Lock this critical section if it is needed - # We use this script file to make the link, it avoids creating a new file - if test "$need_locks" = yes; then - until $run ln "$0" "$lockfile" 2>/dev/null; do - $show "Waiting for $lockfile to be removed" - sleep 2 - done - elif test "$need_locks" = warn; then - if test -f "$lockfile"; then - $echo "\ -*** ERROR, $lockfile exists and contains: -`cat $lockfile 2>/dev/null` - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $run $rm $removelist - exit 1 - fi - $echo $srcfile > "$lockfile" - fi - - if test -n "$fix_srcfile_path"; then - eval srcfile=\"$fix_srcfile_path\" - fi - - $run $rm "$libobj" "${libobj}T" - - # Create a libtool object file (analogous to a ".la" file), - # but don't create it if we're doing a dry run. - test -z "$run" && cat > ${libobj}T </dev/null`" != "X$srcfile"; then - $echo "\ -*** ERROR, $lockfile contains: -`cat $lockfile 2>/dev/null` - -but it should contain: -$srcfile - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $run $rm $removelist - exit 1 - fi - - # Just move the object if needed, then go on to compile the next one - if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then - $show "$mv $output_obj $lobj" - if $run $mv $output_obj $lobj; then : - else - error=$? - $run $rm $removelist - exit $error - fi - fi - - # Append the name of the PIC object to the libtool object file. - test -z "$run" && cat >> ${libobj}T <> ${libobj}T </dev/null`" != "X$srcfile"; then - $echo "\ -*** ERROR, $lockfile contains: -`cat $lockfile 2>/dev/null` - -but it should contain: -$srcfile - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $run $rm $removelist - exit 1 - fi - - # Just move the object if needed - if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then - $show "$mv $output_obj $obj" - if $run $mv $output_obj $obj; then : - else - error=$? - $run $rm $removelist - exit $error - fi - fi - - # Append the name of the non-PIC object the libtool object file. - # Only append if the libtool object file exists. - test -z "$run" && cat >> ${libobj}T <> ${libobj}T < /dev/null; then - # Evaluate the configuration. - eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $0`" - case $base_compile in - "$CC "* | " $CC "* | "`$echo $CC` "* | " `$echo $CC` "*) - # The compiler in $compile_command matches - # the one in the tagged configuration. - # Assume this is the tagged configuration we want. - tagname=$z - break - ;; - esac - fi - done - # If $tagname still isn't set, then no tagged configuration - # was found and let the user know that the "--tag" command - # line option must be used. - if test -z "$tagname"; then - $echo "$modename: unable to infer tagged configuration" - $echo "$modename: specify a tag with \`--tag'" 1>&2 - exit 1 -# else -# $echo "$modename: using $tagname tagged configuration" - fi - ;; - esac - fi - - # We need to know -static, to get the right output filenames. - for arg - do - case $arg in - -all-static | -static) - if test "X$arg" = "X-all-static"; then - if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then - $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2 - fi - if test -n "$link_static_flag"; then - dlopen_self=$dlopen_self_static - fi - else - if test -z "$pic_flag" && test -n "$link_static_flag"; then - dlopen_self=$dlopen_self_static - fi - fi - build_libtool_libs=no - build_old_libs=yes - prefer_static_libs=yes - break - ;; - esac - done - - # See if our shared archives depend on static archives. - test -n "$old_archive_from_new_cmds" && build_old_libs=yes - - # Go through the arguments, transforming them on the way. - while test "$#" -gt 0; do - arg="$1" - shift - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test - ;; - *) qarg=$arg ;; - esac - libtool_args="$libtool_args $qarg" - - # If the previous option needs an argument, assign it. - if test -n "$prev"; then - case $prev in - output) - compile_command="$compile_command @OUTPUT@" - finalize_command="$finalize_command @OUTPUT@" - ;; - esac - - case $prev in - dlfiles|dlprefiles) - if test "$preload" = no; then - # Add the symbol object into the linking commands. - compile_command="$compile_command @SYMFILE@" - finalize_command="$finalize_command @SYMFILE@" - preload=yes - fi - case $arg in - *.la | *.lo) ;; # We handle these cases below. - force) - if test "$dlself" = no; then - dlself=needless - export_dynamic=yes - fi - prev= - continue - ;; - self) - if test "$prev" = dlprefiles; then - dlself=yes - elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then - dlself=yes - else - dlself=needless - export_dynamic=yes - fi - prev= - continue - ;; - *) - if test "$prev" = dlfiles; then - dlfiles="$dlfiles $arg" - else - dlprefiles="$dlprefiles $arg" - fi - prev= - continue - ;; - esac - ;; - expsyms) - export_symbols="$arg" - if test ! -f "$arg"; then - $echo "$modename: symbol file \`$arg' does not exist" - exit 1 - fi - prev= - continue - ;; - expsyms_regex) - export_symbols_regex="$arg" - prev= - continue - ;; - inst_prefix) - inst_prefix_dir="$arg" - prev= - continue - ;; - precious_regex) - precious_files_regex="$arg" - prev= - continue - ;; - release) - release="-$arg" - prev= - continue - ;; - objectlist) - if test -f "$arg"; then - save_arg=$arg - moreargs= - for fil in `cat $save_arg` - do -# moreargs="$moreargs $fil" - arg=$fil - # A libtool-controlled object. - - # Check to see that this really is a libtool object. - if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - pic_object= - non_pic_object= - - # Read the .lo file - # If there is no directory component, then add one. - case $arg in - */* | *\\*) . $arg ;; - *) . ./$arg ;; - esac - - if test -z "$pic_object" || \ - test -z "$non_pic_object" || - test "$pic_object" = none && \ - test "$non_pic_object" = none; then - $echo "$modename: cannot find name of object for \`$arg'" 1>&2 - exit 1 - fi - - # Extract subdirectory from the argument. - xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` - if test "X$xdir" = "X$arg"; then - xdir= - else - xdir="$xdir/" - fi - - if test "$pic_object" != none; then - # Prepend the subdirectory the object is found in. - pic_object="$xdir$pic_object" - - if test "$prev" = dlfiles; then - if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then - dlfiles="$dlfiles $pic_object" - prev= - continue - else - # If libtool objects are unsupported, then we need to preload. - prev=dlprefiles - fi - fi - - # CHECK ME: I think I busted this. -Ossama - if test "$prev" = dlprefiles; then - # Preload the old-style object. - dlprefiles="$dlprefiles $pic_object" - prev= - fi - - # A PIC object. - libobjs="$libobjs $pic_object" - arg="$pic_object" - fi - - # Non-PIC object. - if test "$non_pic_object" != none; then - # Prepend the subdirectory the object is found in. - non_pic_object="$xdir$non_pic_object" - - # A standard non-PIC object - non_pic_objects="$non_pic_objects $non_pic_object" - if test -z "$pic_object" || test "$pic_object" = none ; then - arg="$non_pic_object" - fi - fi - else - # Only an error if not doing a dry-run. - if test -z "$run"; then - $echo "$modename: \`$arg' is not a valid libtool object" 1>&2 - exit 1 - else - # Dry-run case. - - # Extract subdirectory from the argument. - xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` - if test "X$xdir" = "X$arg"; then - xdir= - else - xdir="$xdir/" - fi - - pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` - non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"` - libobjs="$libobjs $pic_object" - non_pic_objects="$non_pic_objects $non_pic_object" - fi - fi - done - else - $echo "$modename: link input file \`$save_arg' does not exist" - exit 1 - fi - arg=$save_arg - prev= - continue - ;; - rpath | xrpath) - # We need an absolute path. - case $arg in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - $echo "$modename: only absolute run-paths are allowed" 1>&2 - exit 1 - ;; - esac - if test "$prev" = rpath; then - case "$rpath " in - *" $arg "*) ;; - *) rpath="$rpath $arg" ;; - esac - else - case "$xrpath " in - *" $arg "*) ;; - *) xrpath="$xrpath $arg" ;; - esac - fi - prev= - continue - ;; - xcompiler) - compiler_flags="$compiler_flags $qarg" - prev= - compile_command="$compile_command $qarg" - finalize_command="$finalize_command $qarg" - continue - ;; - xlinker) - linker_flags="$linker_flags $qarg" - compiler_flags="$compiler_flags $wl$qarg" - prev= - compile_command="$compile_command $wl$qarg" - finalize_command="$finalize_command $wl$qarg" - continue - ;; - xcclinker) - linker_flags="$linker_flags $qarg" - compiler_flags="$compiler_flags $qarg" - prev= - compile_command="$compile_command $qarg" - finalize_command="$finalize_command $qarg" - continue - ;; - *) - eval "$prev=\"\$arg\"" - prev= - continue - ;; - esac - fi # test -n "$prev" - - prevarg="$arg" - - case $arg in - -all-static) - if test -n "$link_static_flag"; then - compile_command="$compile_command $link_static_flag" - finalize_command="$finalize_command $link_static_flag" - fi - continue - ;; - - -allow-undefined) - # FIXME: remove this flag sometime in the future. - $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2 - continue - ;; - - -avoid-version) - avoid_version=yes - continue - ;; - - -dlopen) - prev=dlfiles - continue - ;; - - -dlpreopen) - prev=dlprefiles - continue - ;; - - -export-dynamic) - export_dynamic=yes - continue - ;; - - -export-symbols | -export-symbols-regex) - if test -n "$export_symbols" || test -n "$export_symbols_regex"; then - $echo "$modename: more than one -exported-symbols argument is not allowed" - exit 1 - fi - if test "X$arg" = "X-export-symbols"; then - prev=expsyms - else - prev=expsyms_regex - fi - continue - ;; - - -inst-prefix-dir) - prev=inst_prefix - continue - ;; - - # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* - # so, if we see these flags be careful not to treat them like -L - -L[A-Z][A-Z]*:*) - case $with_gcc/$host in - no/*-*-irix* | /*-*-irix*) - compile_command="$compile_command $arg" - finalize_command="$finalize_command $arg" - ;; - esac - continue - ;; - - -L*) - dir=`$echo "X$arg" | $Xsed -e 's/^-L//'` - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - absdir=`cd "$dir" && pwd` - if test -z "$absdir"; then - $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2 - exit 1 - fi - dir="$absdir" - ;; - esac - case "$deplibs " in - *" -L$dir "*) ;; - *) - deplibs="$deplibs -L$dir" - lib_search_path="$lib_search_path $dir" - ;; - esac - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) - case :$dllsearchpath: in - *":$dir:"*) ;; - *) dllsearchpath="$dllsearchpath:$dir";; - esac - ;; - esac - continue - ;; - - -l*) - if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then - case $host in - *-*-cygwin* | *-*-pw32* | *-*-beos*) - # These systems don't actually have a C or math library (as such) - continue - ;; - *-*-mingw* | *-*-os2*) - # These systems don't actually have a C library (as such) - test "X$arg" = "X-lc" && continue - ;; - *-*-openbsd* | *-*-freebsd*) - # Do not include libc due to us having libc/libc_r. - test "X$arg" = "X-lc" && continue - ;; - *-*-rhapsody* | *-*-darwin1.[012]) - # Rhapsody C and math libraries are in the System framework - deplibs="$deplibs -framework System" - continue - esac - elif test "X$arg" = "X-lc_r"; then - case $host in - *-*-openbsd* | *-*-freebsd*) - # Do not include libc_r directly, use -pthread flag. - continue - ;; - esac - fi - deplibs="$deplibs $arg" - continue - ;; - - -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe) - deplibs="$deplibs $arg" - continue - ;; - - -module) - module=yes - continue - ;; - - # gcc -m* arguments should be passed to the linker via $compiler_flags - # in order to pass architecture information to the linker - # (e.g. 32 vs 64-bit). This may also be accomplished via -Wl,-mfoo - # but this is not reliable with gcc because gcc may use -mfoo to - # select a different linker, different libraries, etc, while - # -Wl,-mfoo simply passes -mfoo to the linker. - -m*) - # Unknown arguments in both finalize_command and compile_command need - # to be aesthetically quoted because they are evaled later. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - compile_command="$compile_command $arg" - finalize_command="$finalize_command $arg" - if test "$with_gcc" = "yes" ; then - compiler_flags="$compiler_flags $arg" - fi - continue - ;; - - -shrext) - prev=shrext - continue - ;; - - -no-fast-install) - fast_install=no - continue - ;; - - -no-install) - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) - # The PATH hackery in wrapper scripts is required on Windows - # in order for the loader to find any dlls it needs. - $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2 - $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2 - fast_install=no - ;; - *) no_install=yes ;; - esac - continue - ;; - - -no-undefined) - allow_undefined=no - continue - ;; - - -objectlist) - prev=objectlist - continue - ;; - - -o) prev=output ;; - - -precious-files-regex) - prev=precious_regex - continue - ;; - - -release) - prev=release - continue - ;; - - -rpath) - prev=rpath - continue - ;; - - -R) - prev=xrpath - continue - ;; - - -R*) - dir=`$echo "X$arg" | $Xsed -e 's/^-R//'` - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - $echo "$modename: only absolute run-paths are allowed" 1>&2 - exit 1 - ;; - esac - case "$xrpath " in - *" $dir "*) ;; - *) xrpath="$xrpath $dir" ;; - esac - continue - ;; - - -static) - # The effects of -static are defined in a previous loop. - # We used to do the same as -all-static on platforms that - # didn't have a PIC flag, but the assumption that the effects - # would be equivalent was wrong. It would break on at least - # Digital Unix and AIX. - continue - ;; - - -thread-safe) - thread_safe=yes - continue - ;; - - -version-info) - prev=vinfo - continue - ;; - -version-number) - prev=vinfo - vinfo_number=yes - continue - ;; - - -Wc,*) - args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'` - arg= - save_ifs="$IFS"; IFS=',' - for flag in $args; do - IFS="$save_ifs" - case $flag in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - flag="\"$flag\"" - ;; - esac - arg="$arg $wl$flag" - compiler_flags="$compiler_flags $flag" - done - IFS="$save_ifs" - arg=`$echo "X$arg" | $Xsed -e "s/^ //"` - ;; - - -Wl,*) - args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'` - arg= - save_ifs="$IFS"; IFS=',' - for flag in $args; do - IFS="$save_ifs" - case $flag in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - flag="\"$flag\"" - ;; - esac - arg="$arg $wl$flag" - compiler_flags="$compiler_flags $wl$flag" - linker_flags="$linker_flags $flag" - done - IFS="$save_ifs" - arg=`$echo "X$arg" | $Xsed -e "s/^ //"` - ;; - - -Xcompiler) - prev=xcompiler - continue - ;; - - -Xlinker) - prev=xlinker - continue - ;; - - -XCClinker) - prev=xcclinker - continue - ;; - - # Some other compiler flag. - -* | +*) - # Unknown arguments in both finalize_command and compile_command need - # to be aesthetically quoted because they are evaled later. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - ;; - - *.$objext) - # A standard object. - objs="$objs $arg" - ;; - - *.lo) - # A libtool-controlled object. - - # Check to see that this really is a libtool object. - if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - pic_object= - non_pic_object= - - # Read the .lo file - # If there is no directory component, then add one. - case $arg in - */* | *\\*) . $arg ;; - *) . ./$arg ;; - esac - - if test -z "$pic_object" || \ - test -z "$non_pic_object" || - test "$pic_object" = none && \ - test "$non_pic_object" = none; then - $echo "$modename: cannot find name of object for \`$arg'" 1>&2 - exit 1 - fi - - # Extract subdirectory from the argument. - xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` - if test "X$xdir" = "X$arg"; then - xdir= - else - xdir="$xdir/" - fi - - if test "$pic_object" != none; then - # Prepend the subdirectory the object is found in. - pic_object="$xdir$pic_object" - - if test "$prev" = dlfiles; then - if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then - dlfiles="$dlfiles $pic_object" - prev= - continue - else - # If libtool objects are unsupported, then we need to preload. - prev=dlprefiles - fi - fi - - # CHECK ME: I think I busted this. -Ossama - if test "$prev" = dlprefiles; then - # Preload the old-style object. - dlprefiles="$dlprefiles $pic_object" - prev= - fi - - # A PIC object. - libobjs="$libobjs $pic_object" - arg="$pic_object" - fi - - # Non-PIC object. - if test "$non_pic_object" != none; then - # Prepend the subdirectory the object is found in. - non_pic_object="$xdir$non_pic_object" - - # A standard non-PIC object - non_pic_objects="$non_pic_objects $non_pic_object" - if test -z "$pic_object" || test "$pic_object" = none ; then - arg="$non_pic_object" - fi - fi - else - # Only an error if not doing a dry-run. - if test -z "$run"; then - $echo "$modename: \`$arg' is not a valid libtool object" 1>&2 - exit 1 - else - # Dry-run case. - - # Extract subdirectory from the argument. - xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` - if test "X$xdir" = "X$arg"; then - xdir= - else - xdir="$xdir/" - fi - - pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` - non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"` - libobjs="$libobjs $pic_object" - non_pic_objects="$non_pic_objects $non_pic_object" - fi - fi - ;; - - *.$libext) - # An archive. - deplibs="$deplibs $arg" - old_deplibs="$old_deplibs $arg" - continue - ;; - - *.la) - # A libtool-controlled library. - - if test "$prev" = dlfiles; then - # This library was specified with -dlopen. - dlfiles="$dlfiles $arg" - prev= - elif test "$prev" = dlprefiles; then - # The library was specified with -dlpreopen. - dlprefiles="$dlprefiles $arg" - prev= - else - deplibs="$deplibs $arg" - fi - continue - ;; - - # Some other compiler argument. - *) - # Unknown arguments in both finalize_command and compile_command need - # to be aesthetically quoted because they are evaled later. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - ;; - esac # arg - - # Now actually substitute the argument into the commands. - if test -n "$arg"; then - compile_command="$compile_command $arg" - finalize_command="$finalize_command $arg" - fi - done # argument parsing loop - - if test -n "$prev"; then - $echo "$modename: the \`$prevarg' option requires an argument" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then - eval arg=\"$export_dynamic_flag_spec\" - compile_command="$compile_command $arg" - finalize_command="$finalize_command $arg" - fi - - oldlibs= - # calculate the name of the file, without its directory - outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'` - libobjs_save="$libobjs" - - if test -n "$shlibpath_var"; then - # get the directories listed in $shlibpath_var - eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\` - else - shlib_search_path= - fi - eval sys_lib_search_path=\"$sys_lib_search_path_spec\" - eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" - - output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'` - if test "X$output_objdir" = "X$output"; then - output_objdir="$objdir" - else - output_objdir="$output_objdir/$objdir" - fi - # Create the object directory. - if test ! -d "$output_objdir"; then - $show "$mkdir $output_objdir" - $run $mkdir $output_objdir - status=$? - if test "$status" -ne 0 && test ! -d "$output_objdir"; then - exit $status - fi - fi - - # Determine the type of output - case $output in - "") - $echo "$modename: you must specify an output file" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; - *.$libext) linkmode=oldlib ;; - *.lo | *.$objext) linkmode=obj ;; - *.la) linkmode=lib ;; - *) linkmode=prog ;; # Anything else should be a program. - esac - - case $host in - *cygwin* | *mingw* | *pw32*) - # don't eliminate duplcations in $postdeps and $predeps - duplicate_compiler_generated_deps=yes - ;; - *) - duplicate_compiler_generated_deps=$duplicate_deps - ;; - esac - specialdeplibs= - - libs= - # Find all interdependent deplibs by searching for libraries - # that are linked more than once (e.g. -la -lb -la) - for deplib in $deplibs; do - if test "X$duplicate_deps" = "Xyes" ; then - case "$libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - fi - libs="$libs $deplib" - done - - if test "$linkmode" = lib; then - libs="$predeps $libs $compiler_lib_search_path $postdeps" - - # Compute libraries that are listed more than once in $predeps - # $postdeps and mark them as special (i.e., whose duplicates are - # not to be eliminated). - pre_post_deps= - if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then - for pre_post_dep in $predeps $postdeps; do - case "$pre_post_deps " in - *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;; - esac - pre_post_deps="$pre_post_deps $pre_post_dep" - done - fi - pre_post_deps= - fi - - deplibs= - newdependency_libs= - newlib_search_path= - need_relink=no # whether we're linking any uninstalled libtool libraries - notinst_deplibs= # not-installed libtool libraries - notinst_path= # paths that contain not-installed libtool libraries - case $linkmode in - lib) - passes="conv link" - for file in $dlfiles $dlprefiles; do - case $file in - *.la) ;; - *) - $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2 - exit 1 - ;; - esac - done - ;; - prog) - compile_deplibs= - finalize_deplibs= - alldeplibs=no - newdlfiles= - newdlprefiles= - passes="conv scan dlopen dlpreopen link" - ;; - *) passes="conv" - ;; - esac - for pass in $passes; do - if test "$linkmode,$pass" = "lib,link" || - test "$linkmode,$pass" = "prog,scan"; then - libs="$deplibs" - deplibs= - fi - if test "$linkmode" = prog; then - case $pass in - dlopen) libs="$dlfiles" ;; - dlpreopen) libs="$dlprefiles" ;; - link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; - esac - fi - if test "$pass" = dlopen; then - # Collect dlpreopened libraries - save_deplibs="$deplibs" - deplibs= - fi - for deplib in $libs; do - lib= - found=no - case $deplib in - -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe) - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - deplibs="$deplib $deplibs" - fi - continue - ;; - -l*) - if test "$linkmode" != lib && test "$linkmode" != prog; then - $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2 - continue - fi - if test "$pass" = conv; then - deplibs="$deplib $deplibs" - continue - fi - name=`$echo "X$deplib" | $Xsed -e 's/^-l//'` - for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do - for search_ext in .la $shrext .so .a; do - # Search the libtool library - lib="$searchdir/lib${name}${search_ext}" - if test -f "$lib"; then - if test "$search_ext" = ".la"; then - found=yes - else - found=no - fi - break 2 - fi - done - done - if test "$found" != yes; then - # deplib doesn't seem to be a libtool library - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - deplibs="$deplib $deplibs" - test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" - fi - continue - else # deplib is a libtool library - # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, - # We need to do some special things here, and not later. - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then - case " $predeps $postdeps " in - *" $deplib "*) - if (${SED} -e '2q' $lib | - grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - library_names= - old_library= - case $lib in - */* | *\\*) . $lib ;; - *) . ./$lib ;; - esac - for l in $old_library $library_names; do - ll="$l" - done - if test "X$ll" = "X$old_library" ; then # only static version available - found=no - ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` - test "X$ladir" = "X$lib" && ladir="." - lib=$ladir/$old_library - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - deplibs="$deplib $deplibs" - test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" - fi - continue - fi - fi - ;; - *) ;; - esac - fi - fi - ;; # -l - -L*) - case $linkmode in - lib) - deplibs="$deplib $deplibs" - test "$pass" = conv && continue - newdependency_libs="$deplib $newdependency_libs" - newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` - ;; - prog) - if test "$pass" = conv; then - deplibs="$deplib $deplibs" - continue - fi - if test "$pass" = scan; then - deplibs="$deplib $deplibs" - newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` - else - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - fi - ;; - *) - $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2 - ;; - esac # linkmode - continue - ;; # -L - -R*) - if test "$pass" = link; then - dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'` - # Make sure the xrpath contains only unique directories. - case "$xrpath " in - *" $dir "*) ;; - *) xrpath="$xrpath $dir" ;; - esac - fi - deplibs="$deplib $deplibs" - continue - ;; - *.la) lib="$deplib" ;; - *.$libext) - if test "$pass" = conv; then - deplibs="$deplib $deplibs" - continue - fi - case $linkmode in - lib) - if test "$deplibs_check_method" != pass_all; then - $echo - $echo "*** Warning: Trying to link with static lib archive $deplib." - $echo "*** I have the capability to make that library automatically link in when" - $echo "*** you link to this library. But I can only do this if you have a" - $echo "*** shared version of the library, which you do not appear to have" - $echo "*** because the file extensions .$libext of this argument makes me believe" - $echo "*** that it is just a static archive that I should not used here." - else - $echo - $echo "*** Warning: Linking the shared library $output against the" - $echo "*** static library $deplib is not portable!" - deplibs="$deplib $deplibs" - fi - continue - ;; - prog) - if test "$pass" != link; then - deplibs="$deplib $deplibs" - else - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - fi - continue - ;; - esac # linkmode - ;; # *.$libext - *.lo | *.$objext) - if test "$pass" = conv; then - deplibs="$deplib $deplibs" - elif test "$linkmode" = prog; then - if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then - # If there is no dlopen support or we're linking statically, - # we need to preload. - newdlprefiles="$newdlprefiles $deplib" - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - newdlfiles="$newdlfiles $deplib" - fi - fi - continue - ;; - %DEPLIBS%) - alldeplibs=yes - continue - ;; - esac # case $deplib - if test "$found" = yes || test -f "$lib"; then : - else - $echo "$modename: cannot find the library \`$lib'" 1>&2 - exit 1 - fi - - # Check to see that this really is a libtool archive. - if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : - else - $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 - exit 1 - fi - - ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` - test "X$ladir" = "X$lib" && ladir="." - - dlname= - dlopen= - dlpreopen= - libdir= - library_names= - old_library= - # If the library was installed with an old release of libtool, - # it will not redefine variables installed, or shouldnotlink - installed=yes - shouldnotlink=no - - # Read the .la file - case $lib in - */* | *\\*) . $lib ;; - *) . ./$lib ;; - esac - - if test "$linkmode,$pass" = "lib,link" || - test "$linkmode,$pass" = "prog,scan" || - { test "$linkmode" != prog && test "$linkmode" != lib; }; then - test -n "$dlopen" && dlfiles="$dlfiles $dlopen" - test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" - fi - - if test "$pass" = conv; then - # Only check for convenience libraries - deplibs="$lib $deplibs" - if test -z "$libdir"; then - if test -z "$old_library"; then - $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 - exit 1 - fi - # It is a libtool convenience library, so add in its objects. - convenience="$convenience $ladir/$objdir/$old_library" - old_convenience="$old_convenience $ladir/$objdir/$old_library" - tmp_libs= - for deplib in $dependency_libs; do - deplibs="$deplib $deplibs" - if test "X$duplicate_deps" = "Xyes" ; then - case "$tmp_libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - fi - tmp_libs="$tmp_libs $deplib" - done - elif test "$linkmode" != prog && test "$linkmode" != lib; then - $echo "$modename: \`$lib' is not a convenience library" 1>&2 - exit 1 - fi - continue - fi # $pass = conv - - - # Get the name of the library we link against. - linklib= - for l in $old_library $library_names; do - linklib="$l" - done - if test -z "$linklib"; then - $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 - exit 1 - fi - - # This library was specified with -dlopen. - if test "$pass" = dlopen; then - if test -z "$libdir"; then - $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2 - exit 1 - fi - if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then - # If there is no dlname, no dlopen support or we're linking - # statically, we need to preload. We also need to preload any - # dependent libraries so libltdl's deplib preloader doesn't - # bomb out in the load deplibs phase. - dlprefiles="$dlprefiles $lib $dependency_libs" - else - newdlfiles="$newdlfiles $lib" - fi - continue - fi # $pass = dlopen - - # We need an absolute path. - case $ladir in - [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; - *) - abs_ladir=`cd "$ladir" && pwd` - if test -z "$abs_ladir"; then - $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2 - $echo "$modename: passing it literally to the linker, although it might fail" 1>&2 - abs_ladir="$ladir" - fi - ;; - esac - laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` - - # Find the relevant object directory and library name. - if test "X$installed" = Xyes; then - if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then - $echo "$modename: warning: library \`$lib' was moved." 1>&2 - dir="$ladir" - absdir="$abs_ladir" - libdir="$abs_ladir" - else - dir="$libdir" - absdir="$libdir" - fi - else - dir="$ladir/$objdir" - absdir="$abs_ladir/$objdir" - # Remove this search path later - notinst_path="$notinst_path $abs_ladir" - fi # $installed = yes - name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` - - # This library was specified with -dlpreopen. - if test "$pass" = dlpreopen; then - if test -z "$libdir"; then - $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2 - exit 1 - fi - # Prefer using a static library (so that no silly _DYNAMIC symbols - # are required to link). - if test -n "$old_library"; then - newdlprefiles="$newdlprefiles $dir/$old_library" - # Otherwise, use the dlname, so that lt_dlopen finds it. - elif test -n "$dlname"; then - newdlprefiles="$newdlprefiles $dir/$dlname" - else - newdlprefiles="$newdlprefiles $dir/$linklib" - fi - fi # $pass = dlpreopen - - if test -z "$libdir"; then - # Link the convenience library - if test "$linkmode" = lib; then - deplibs="$dir/$old_library $deplibs" - elif test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$dir/$old_library $compile_deplibs" - finalize_deplibs="$dir/$old_library $finalize_deplibs" - else - deplibs="$lib $deplibs" # used for prog,scan pass - fi - continue - fi - - - if test "$linkmode" = prog && test "$pass" != link; then - newlib_search_path="$newlib_search_path $ladir" - deplibs="$lib $deplibs" - - linkalldeplibs=no - if test "$link_all_deplibs" != no || test -z "$library_names" || - test "$build_libtool_libs" = no; then - linkalldeplibs=yes - fi - - tmp_libs= - for deplib in $dependency_libs; do - case $deplib in - -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test - esac - # Need to link against all dependency_libs? - if test "$linkalldeplibs" = yes; then - deplibs="$deplib $deplibs" - else - # Need to hardcode shared library paths - # or/and link against static libraries - newdependency_libs="$deplib $newdependency_libs" - fi - if test "X$duplicate_deps" = "Xyes" ; then - case "$tmp_libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - fi - tmp_libs="$tmp_libs $deplib" - done # for deplib - continue - fi # $linkmode = prog... - - if test "$linkmode,$pass" = "prog,link"; then - if test -n "$library_names" && - { test "$prefer_static_libs" = no || test -z "$old_library"; }; then - # We need to hardcode the library path - if test -n "$shlibpath_var"; then - # Make sure the rpath contains only unique directories. - case "$temp_rpath " in - *" $dir "*) ;; - *" $absdir "*) ;; - *) temp_rpath="$temp_rpath $dir" ;; - esac - fi - - # Hardcode the library path. - # Skip directories that are in the system default run-time - # search path. - case " $sys_lib_dlsearch_path " in - *" $absdir "*) ;; - *) - case "$compile_rpath " in - *" $absdir "*) ;; - *) compile_rpath="$compile_rpath $absdir" - esac - ;; - esac - case " $sys_lib_dlsearch_path " in - *" $libdir "*) ;; - *) - case "$finalize_rpath " in - *" $libdir "*) ;; - *) finalize_rpath="$finalize_rpath $libdir" - esac - ;; - esac - fi # $linkmode,$pass = prog,link... - - if test "$alldeplibs" = yes && - { test "$deplibs_check_method" = pass_all || - { test "$build_libtool_libs" = yes && - test -n "$library_names"; }; }; then - # We only need to search for static libraries - continue - fi - fi - - link_static=no # Whether the deplib will be linked statically - if test -n "$library_names" && - { test "$prefer_static_libs" = no || test -z "$old_library"; }; then - if test "$installed" = no; then - notinst_deplibs="$notinst_deplibs $lib" - need_relink=yes - fi - # This is a shared library - - # Warn about portability, can't link against -module's on some systems (darwin) - if test "$shouldnotlink" = yes && test "$pass" = link ; then - $echo - if test "$linkmode" = prog; then - $echo "*** Warning: Linking the executable $output against the loadable module" - else - $echo "*** Warning: Linking the shared library $output against the loadable module" - fi - $echo "*** $linklib is not portable!" - fi - if test "$linkmode" = lib && - test "$hardcode_into_libs" = yes; then - # Hardcode the library path. - # Skip directories that are in the system default run-time - # search path. - case " $sys_lib_dlsearch_path " in - *" $absdir "*) ;; - *) - case "$compile_rpath " in - *" $absdir "*) ;; - *) compile_rpath="$compile_rpath $absdir" - esac - ;; - esac - case " $sys_lib_dlsearch_path " in - *" $libdir "*) ;; - *) - case "$finalize_rpath " in - *" $libdir "*) ;; - *) finalize_rpath="$finalize_rpath $libdir" - esac - ;; - esac - fi - - if test -n "$old_archive_from_expsyms_cmds"; then - # figure out the soname - set dummy $library_names - realname="$2" - shift; shift - libname=`eval \\$echo \"$libname_spec\"` - # use dlname if we got it. it's perfectly good, no? - if test -n "$dlname"; then - soname="$dlname" - elif test -n "$soname_spec"; then - # bleh windows - case $host in - *cygwin* | mingw*) - major=`expr $current - $age` - versuffix="-$major" - ;; - esac - eval soname=\"$soname_spec\" - else - soname="$realname" - fi - - # Make a new name for the extract_expsyms_cmds to use - soroot="$soname" - soname=`$echo $soroot | ${SED} -e 's/^.*\///'` - newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a" - - # If the library has no export list, then create one now - if test -f "$output_objdir/$soname-def"; then : - else - $show "extracting exported symbol list from \`$soname'" - save_ifs="$IFS"; IFS='~' - cmds=$extract_expsyms_cmds - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - fi - - # Create $newlib - if test -f "$output_objdir/$newlib"; then :; else - $show "generating import library for \`$soname'" - save_ifs="$IFS"; IFS='~' - cmds=$old_archive_from_expsyms_cmds - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - fi - # make sure the library variables are pointing to the new library - dir=$output_objdir - linklib=$newlib - fi # test -n "$old_archive_from_expsyms_cmds" - - if test "$linkmode" = prog || test "$mode" != relink; then - add_shlibpath= - add_dir= - add= - lib_linked=yes - case $hardcode_action in - immediate | unsupported) - if test "$hardcode_direct" = no; then - add="$dir/$linklib" - case $host in - *-*-sco3.2v5* ) add_dir="-L$dir" ;; - *-*-darwin* ) - # if the lib is a module then we can not link against it, someone - # is ignoring the new warnings I added - if /usr/bin/file -L $add 2> /dev/null | grep "bundle" >/dev/null ; then - $echo "** Warning, lib $linklib is a module, not a shared library" - if test -z "$old_library" ; then - $echo - $echo "** And there doesn't seem to be a static archive available" - $echo "** The link will probably fail, sorry" - else - add="$dir/$old_library" - fi - fi - esac - elif test "$hardcode_minus_L" = no; then - case $host in - *-*-sunos*) add_shlibpath="$dir" ;; - esac - add_dir="-L$dir" - add="-l$name" - elif test "$hardcode_shlibpath_var" = no; then - add_shlibpath="$dir" - add="-l$name" - else - lib_linked=no - fi - ;; - relink) - if test "$hardcode_direct" = yes; then - add="$dir/$linklib" - elif test "$hardcode_minus_L" = yes; then - add_dir="-L$dir" - # Try looking first in the location we're being installed to. - if test -n "$inst_prefix_dir"; then - case "$libdir" in - [\\/]*) - add_dir="$add_dir -L$inst_prefix_dir$libdir" - ;; - esac - fi - add="-l$name" - elif test "$hardcode_shlibpath_var" = yes; then - add_shlibpath="$dir" - add="-l$name" - else - lib_linked=no - fi - ;; - *) lib_linked=no ;; - esac - - if test "$lib_linked" != yes; then - $echo "$modename: configuration error: unsupported hardcode properties" - exit 1 - fi - - if test -n "$add_shlibpath"; then - case :$compile_shlibpath: in - *":$add_shlibpath:"*) ;; - *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; - esac - fi - if test "$linkmode" = prog; then - test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" - test -n "$add" && compile_deplibs="$add $compile_deplibs" - else - test -n "$add_dir" && deplibs="$add_dir $deplibs" - test -n "$add" && deplibs="$add $deplibs" - if test "$hardcode_direct" != yes && \ - test "$hardcode_minus_L" != yes && \ - test "$hardcode_shlibpath_var" = yes; then - case :$finalize_shlibpath: in - *":$libdir:"*) ;; - *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; - esac - fi - fi - fi - - if test "$linkmode" = prog || test "$mode" = relink; then - add_shlibpath= - add_dir= - add= - # Finalize command for both is simple: just hardcode it. - if test "$hardcode_direct" = yes; then - add="$libdir/$linklib" - elif test "$hardcode_minus_L" = yes; then - add_dir="-L$libdir" - add="-l$name" - elif test "$hardcode_shlibpath_var" = yes; then - case :$finalize_shlibpath: in - *":$libdir:"*) ;; - *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; - esac - add="-l$name" - elif test "$hardcode_automatic" = yes; then - if test -n "$inst_prefix_dir" && test -f "$inst_prefix_dir$libdir/$linklib" ; then - add="$inst_prefix_dir$libdir/$linklib" - else - add="$libdir/$linklib" - fi - else - # We cannot seem to hardcode it, guess we'll fake it. - add_dir="-L$libdir" - # Try looking first in the location we're being installed to. - if test -n "$inst_prefix_dir"; then - case "$libdir" in - [\\/]*) - add_dir="$add_dir -L$inst_prefix_dir$libdir" - ;; - esac - fi - add="-l$name" - fi - - if test "$linkmode" = prog; then - test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" - test -n "$add" && finalize_deplibs="$add $finalize_deplibs" - else - test -n "$add_dir" && deplibs="$add_dir $deplibs" - test -n "$add" && deplibs="$add $deplibs" - fi - fi - elif test "$linkmode" = prog; then - # Here we assume that one of hardcode_direct or hardcode_minus_L - # is not unsupported. This is valid on all known static and - # shared platforms. - if test "$hardcode_direct" != unsupported; then - test -n "$old_library" && linklib="$old_library" - compile_deplibs="$dir/$linklib $compile_deplibs" - finalize_deplibs="$dir/$linklib $finalize_deplibs" - else - compile_deplibs="-l$name -L$dir $compile_deplibs" - finalize_deplibs="-l$name -L$dir $finalize_deplibs" - fi - elif test "$build_libtool_libs" = yes; then - # Not a shared library - if test "$deplibs_check_method" != pass_all; then - # We're trying link a shared library against a static one - # but the system doesn't support it. - - # Just print a warning and add the library to dependency_libs so - # that the program can be linked against the static library. - $echo - $echo "*** Warning: This system can not link to static lib archive $lib." - $echo "*** I have the capability to make that library automatically link in when" - $echo "*** you link to this library. But I can only do this if you have a" - $echo "*** shared version of the library, which you do not appear to have." - if test "$module" = yes; then - $echo "*** But as you try to build a module library, libtool will still create " - $echo "*** a static module, that should work as long as the dlopening application" - $echo "*** is linked with the -dlopen flag to resolve symbols at runtime." - if test -z "$global_symbol_pipe"; then - $echo - $echo "*** However, this would only work if libtool was able to extract symbol" - $echo "*** lists from a program, using \`nm' or equivalent, but libtool could" - $echo "*** not find such a program. So, this module is probably useless." - $echo "*** \`nm' from GNU binutils and a full rebuild may help." - fi - if test "$build_old_libs" = no; then - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - fi - else - convenience="$convenience $dir/$old_library" - old_convenience="$old_convenience $dir/$old_library" - deplibs="$dir/$old_library $deplibs" - link_static=yes - fi - fi # link shared/static library? - - if test "$linkmode" = lib; then - if test -n "$dependency_libs" && - { test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes || - test "$link_static" = yes; }; then - # Extract -R from dependency_libs - temp_deplibs= - for libdir in $dependency_libs; do - case $libdir in - -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'` - case " $xrpath " in - *" $temp_xrpath "*) ;; - *) xrpath="$xrpath $temp_xrpath";; - esac;; - *) temp_deplibs="$temp_deplibs $libdir";; - esac - done - dependency_libs="$temp_deplibs" - fi - - newlib_search_path="$newlib_search_path $absdir" - # Link against this library - test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" - # ... and its dependency_libs - tmp_libs= - for deplib in $dependency_libs; do - newdependency_libs="$deplib $newdependency_libs" - if test "X$duplicate_deps" = "Xyes" ; then - case "$tmp_libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - fi - tmp_libs="$tmp_libs $deplib" - done - - if test "$link_all_deplibs" != no; then - # Add the search paths of all dependency libraries - for deplib in $dependency_libs; do - case $deplib in - -L*) path="$deplib" ;; - *.la) - dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'` - test "X$dir" = "X$deplib" && dir="." - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; - *) - absdir=`cd "$dir" && pwd` - if test -z "$absdir"; then - $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2 - absdir="$dir" - fi - ;; - esac - if grep "^installed=no" $deplib > /dev/null; then - path="$absdir/$objdir" - else - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` - if test -z "$libdir"; then - $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 - exit 1 - fi - if test "$absdir" != "$libdir"; then - $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2 - fi - path="$absdir" - fi - depdepl= - case $host in - *-*-darwin*) - # we do not want to link against static libs, but need to link against shared - eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` - if test -n "$deplibrary_names" ; then - for tmp in $deplibrary_names ; do - depdepl=$tmp - done - if test -f "$path/$depdepl" ; then - depdepl="$path/$depdepl" - fi - # do not add paths which are already there - case " $newlib_search_path " in - *" $path "*) ;; - *) newlib_search_path="$newlib_search_path $path";; - esac - fi - path="" - ;; - *) - path="-L$path" - ;; - esac - - ;; - -l*) - case $host in - *-*-darwin*) - # Again, we only want to link against shared libraries - eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"` - for tmp in $newlib_search_path ; do - if test -f "$tmp/lib$tmp_libs.dylib" ; then - eval depdepl="$tmp/lib$tmp_libs.dylib" - break - fi - done - path="" - ;; - *) continue ;; - esac - ;; - *) continue ;; - esac - case " $deplibs " in - *" $depdepl "*) ;; - *) deplibs="$deplibs $depdepl" ;; - esac - case " $deplibs " in - *" $path "*) ;; - *) deplibs="$deplibs $path" ;; - esac - done - fi # link_all_deplibs != no - fi # linkmode = lib - done # for deplib in $libs - dependency_libs="$newdependency_libs" - if test "$pass" = dlpreopen; then - # Link the dlpreopened libraries before other libraries - for deplib in $save_deplibs; do - deplibs="$deplib $deplibs" - done - fi - if test "$pass" != dlopen; then - if test "$pass" != conv; then - # Make sure lib_search_path contains only unique directories. - lib_search_path= - for dir in $newlib_search_path; do - case "$lib_search_path " in - *" $dir "*) ;; - *) lib_search_path="$lib_search_path $dir" ;; - esac - done - newlib_search_path= - fi - - if test "$linkmode,$pass" != "prog,link"; then - vars="deplibs" - else - vars="compile_deplibs finalize_deplibs" - fi - for var in $vars dependency_libs; do - # Add libraries to $var in reverse order - eval tmp_libs=\"\$$var\" - new_libs= - for deplib in $tmp_libs; do - # FIXME: Pedantically, this is the right thing to do, so - # that some nasty dependency loop isn't accidentally - # broken: - #new_libs="$deplib $new_libs" - # Pragmatically, this seems to cause very few problems in - # practice: - case $deplib in - -L*) new_libs="$deplib $new_libs" ;; - -R*) ;; - *) - # And here is the reason: when a library appears more - # than once as an explicit dependence of a library, or - # is implicitly linked in more than once by the - # compiler, it is considered special, and multiple - # occurrences thereof are not removed. Compare this - # with having the same library being listed as a - # dependency of multiple other libraries: in this case, - # we know (pedantically, we assume) the library does not - # need to be listed more than once, so we keep only the - # last copy. This is not always right, but it is rare - # enough that we require users that really mean to play - # such unportable linking tricks to link the library - # using -Wl,-lname, so that libtool does not consider it - # for duplicate removal. - case " $specialdeplibs " in - *" $deplib "*) new_libs="$deplib $new_libs" ;; - *) - case " $new_libs " in - *" $deplib "*) ;; - *) new_libs="$deplib $new_libs" ;; - esac - ;; - esac - ;; - esac - done - tmp_libs= - for deplib in $new_libs; do - case $deplib in - -L*) - case " $tmp_libs " in - *" $deplib "*) ;; - *) tmp_libs="$tmp_libs $deplib" ;; - esac - ;; - *) tmp_libs="$tmp_libs $deplib" ;; - esac - done - eval $var=\"$tmp_libs\" - done # for var - fi - # Last step: remove runtime libs from dependency_libs (they stay in deplibs) - tmp_libs= - for i in $dependency_libs ; do - case " $predeps $postdeps $compiler_lib_search_path " in - *" $i "*) - i="" - ;; - esac - if test -n "$i" ; then - tmp_libs="$tmp_libs $i" - fi - done - dependency_libs=$tmp_libs - done # for pass - if test "$linkmode" = prog; then - dlfiles="$newdlfiles" - dlprefiles="$newdlprefiles" - fi - - case $linkmode in - oldlib) - if test -n "$deplibs"; then - $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2 - fi - - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2 - fi - - if test -n "$rpath"; then - $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2 - fi - - if test -n "$xrpath"; then - $echo "$modename: warning: \`-R' is ignored for archives" 1>&2 - fi - - if test -n "$vinfo"; then - $echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2 - fi - - if test -n "$release"; then - $echo "$modename: warning: \`-release' is ignored for archives" 1>&2 - fi - - if test -n "$export_symbols" || test -n "$export_symbols_regex"; then - $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2 - fi - - # Now set the variables for building old libraries. - build_libtool_libs=no - oldlibs="$output" - objs="$objs$old_deplibs" - ;; - - lib) - # Make sure we only generate libraries of the form `libNAME.la'. - case $outputname in - lib*) - name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` - eval shared_ext=\"$shrext\" - eval libname=\"$libname_spec\" - ;; - *) - if test "$module" = no; then - $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - if test "$need_lib_prefix" != no; then - # Add the "lib" prefix for modules if required - name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` - eval shared_ext=\"$shrext\" - eval libname=\"$libname_spec\" - else - libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` - fi - ;; - esac - - if test -n "$objs"; then - if test "$deplibs_check_method" != pass_all; then - $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1 - exit 1 - else - $echo - $echo "*** Warning: Linking the shared library $output against the non-libtool" - $echo "*** objects $objs is not portable!" - libobjs="$libobjs $objs" - fi - fi - - if test "$dlself" != no; then - $echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2 - fi - - set dummy $rpath - if test "$#" -gt 2; then - $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2 - fi - install_libdir="$2" - - oldlibs= - if test -z "$rpath"; then - if test "$build_libtool_libs" = yes; then - # Building a libtool convenience library. - # Some compilers have problems with a `.al' extension so - # convenience libraries should have the same extension an - # archive normally would. - oldlibs="$output_objdir/$libname.$libext $oldlibs" - build_libtool_libs=convenience - build_old_libs=yes - fi - - if test -n "$vinfo"; then - $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2 - fi - - if test -n "$release"; then - $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2 - fi - else - - # Parse the version information argument. - save_ifs="$IFS"; IFS=':' - set dummy $vinfo 0 0 0 - IFS="$save_ifs" - - if test -n "$8"; then - $echo "$modename: too many parameters to \`-version-info'" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - # convert absolute version numbers to libtool ages - # this retains compatibility with .la files and attempts - # to make the code below a bit more comprehensible - - case $vinfo_number in - yes) - number_major="$2" - number_minor="$3" - number_revision="$4" - # - # There are really only two kinds -- those that - # use the current revision as the major version - # and those that subtract age and use age as - # a minor version. But, then there is irix - # which has an extra 1 added just for fun - # - case $version_type in - darwin|linux|osf|windows) - current=`expr $number_major + $number_minor` - age="$number_minor" - revision="$number_revision" - ;; - freebsd-aout|freebsd-elf|sunos) - current="$number_major" - revision="$number_minor" - age="0" - ;; - irix|nonstopux) - current=`expr $number_major + $number_minor - 1` - age="$number_minor" - revision="$number_minor" - ;; - esac - ;; - no) - current="$2" - revision="$3" - age="$4" - ;; - esac - - # Check that each of the things are valid numbers. - case $current in - 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;; - *) - $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit 1 - ;; - esac - - case $revision in - 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;; - *) - $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit 1 - ;; - esac - - case $age in - 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;; - *) - $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit 1 - ;; - esac - - if test "$age" -gt "$current"; then - $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit 1 - fi - - # Calculate the version variables. - major= - versuffix= - verstring= - case $version_type in - none) ;; - - darwin) - # Like Linux, but with the current version available in - # verstring for coding it into the library header - major=.`expr $current - $age` - versuffix="$major.$age.$revision" - # Darwin ld doesn't like 0 for these options... - minor_current=`expr $current + 1` - verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" - ;; - - freebsd-aout) - major=".$current" - versuffix=".$current.$revision"; - ;; - - freebsd-elf) - major=".$current" - versuffix=".$current"; - ;; - - irix | nonstopux) - major=`expr $current - $age + 1` - - case $version_type in - nonstopux) verstring_prefix=nonstopux ;; - *) verstring_prefix=sgi ;; - esac - verstring="$verstring_prefix$major.$revision" - - # Add in all the interfaces that we are compatible with. - loop=$revision - while test "$loop" -ne 0; do - iface=`expr $revision - $loop` - loop=`expr $loop - 1` - verstring="$verstring_prefix$major.$iface:$verstring" - done - - # Before this point, $major must not contain `.'. - major=.$major - versuffix="$major.$revision" - ;; - - linux) - major=.`expr $current - $age` - versuffix="$major.$age.$revision" - ;; - - osf) - major=.`expr $current - $age` - versuffix=".$current.$age.$revision" - verstring="$current.$age.$revision" - - # Add in all the interfaces that we are compatible with. - loop=$age - while test "$loop" -ne 0; do - iface=`expr $current - $loop` - loop=`expr $loop - 1` - verstring="$verstring:${iface}.0" - done - - # Make executables depend on our current version. - verstring="$verstring:${current}.0" - ;; - - sunos) - major=".$current" - versuffix=".$current.$revision" - ;; - - windows) - # Use '-' rather than '.', since we only want one - # extension on DOS 8.3 filesystems. - major=`expr $current - $age` - versuffix="-$major" - ;; - - *) - $echo "$modename: unknown library version type \`$version_type'" 1>&2 - $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 - exit 1 - ;; - esac - - # Clear the version info if we defaulted, and they specified a release. - if test -z "$vinfo" && test -n "$release"; then - major= - case $version_type in - darwin) - # we can't check for "0.0" in archive_cmds due to quoting - # problems, so we reset it completely - verstring= - ;; - *) - verstring="0.0" - ;; - esac - if test "$need_version" = no; then - versuffix= - else - versuffix=".0.0" - fi - fi - - # Remove version info from name if versioning should be avoided - if test "$avoid_version" = yes && test "$need_version" = no; then - major= - versuffix= - verstring="" - fi - - # Check to see if the archive will have undefined symbols. - if test "$allow_undefined" = yes; then - if test "$allow_undefined_flag" = unsupported; then - $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2 - build_libtool_libs=no - build_old_libs=yes - fi - else - # Don't allow undefined symbols. - allow_undefined_flag="$no_undefined_flag" - fi - fi - - if test "$mode" != relink; then - # Remove our outputs, but don't remove object files since they - # may have been created when compiling PIC objects. - removelist= - tempremovelist=`$echo "$output_objdir/*"` - for p in $tempremovelist; do - case $p in - *.$objext) - ;; - $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) - if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 - then - continue - fi - removelist="$removelist $p" - ;; - *) ;; - esac - done - if test -n "$removelist"; then - $show "${rm}r $removelist" - $run ${rm}r $removelist - fi - fi - - # Now set the variables for building old libraries. - if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then - oldlibs="$oldlibs $output_objdir/$libname.$libext" - - # Transform .lo files to .o files. - oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` - fi - - # Eliminate all temporary directories. - for path in $notinst_path; do - lib_search_path=`$echo "$lib_search_path " | ${SED} -e 's% $path % %g'` - deplibs=`$echo "$deplibs " | ${SED} -e 's% -L$path % %g'` - dependency_libs=`$echo "$dependency_libs " | ${SED} -e 's% -L$path % %g'` - done - - if test -n "$xrpath"; then - # If the user specified any rpath flags, then add them. - temp_xrpath= - for libdir in $xrpath; do - temp_xrpath="$temp_xrpath -R$libdir" - case "$finalize_rpath " in - *" $libdir "*) ;; - *) finalize_rpath="$finalize_rpath $libdir" ;; - esac - done - if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then - dependency_libs="$temp_xrpath $dependency_libs" - fi - fi - - # Make sure dlfiles contains only unique files that won't be dlpreopened - old_dlfiles="$dlfiles" - dlfiles= - for lib in $old_dlfiles; do - case " $dlprefiles $dlfiles " in - *" $lib "*) ;; - *) dlfiles="$dlfiles $lib" ;; - esac - done - - # Make sure dlprefiles contains only unique files - old_dlprefiles="$dlprefiles" - dlprefiles= - for lib in $old_dlprefiles; do - case "$dlprefiles " in - *" $lib "*) ;; - *) dlprefiles="$dlprefiles $lib" ;; - esac - done - - if test "$build_libtool_libs" = yes; then - if test -n "$rpath"; then - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*) - # these systems don't actually have a c library (as such)! - ;; - *-*-rhapsody* | *-*-darwin1.[012]) - # Rhapsody C library is in the System framework - deplibs="$deplibs -framework System" - ;; - *-*-netbsd*) - # Don't link with libc until the a.out ld.so is fixed. - ;; - *-*-openbsd* | *-*-freebsd*) - # Do not include libc due to us having libc/libc_r. - test "X$arg" = "X-lc" && continue - ;; - *) - # Add libc to deplibs on all other systems if necessary. - if test "$build_libtool_need_lc" = "yes"; then - deplibs="$deplibs -lc" - fi - ;; - esac - fi - - # Transform deplibs into only deplibs that can be linked in shared. - name_save=$name - libname_save=$libname - release_save=$release - versuffix_save=$versuffix - major_save=$major - # I'm not sure if I'm treating the release correctly. I think - # release should show up in the -l (ie -lgmp5) so we don't want to - # add it in twice. Is that correct? - release="" - versuffix="" - major="" - newdeplibs= - droppeddeps=no - case $deplibs_check_method in - pass_all) - # Don't check for shared/static. Everything works. - # This might be a little naive. We might want to check - # whether the library exists or not. But this is on - # osf3 & osf4 and I'm not really sure... Just - # implementing what was already the behavior. - newdeplibs=$deplibs - ;; - test_compile) - # This code stresses the "libraries are programs" paradigm to its - # limits. Maybe even breaks it. We compile a program, linking it - # against the deplibs as a proxy for the library. Then we can check - # whether they linked in statically or dynamically with ldd. - $rm conftest.c - cat > conftest.c </dev/null` - for potent_lib in $potential_libs; do - # Follow soft links. - if ls -lLd "$potent_lib" 2>/dev/null \ - | grep " -> " >/dev/null; then - continue - fi - # The statement above tries to avoid entering an - # endless loop below, in case of cyclic links. - # We might still enter an endless loop, since a link - # loop can be closed while we follow links, - # but so what? - potlib="$potent_lib" - while test -h "$potlib" 2>/dev/null; do - potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` - case $potliblink in - [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; - *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; - esac - done - if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \ - | ${SED} 10q \ - | $EGREP "$file_magic_regex" > /dev/null; then - newdeplibs="$newdeplibs $a_deplib" - a_deplib="" - break 2 - fi - done - done - fi - if test -n "$a_deplib" ; then - droppeddeps=yes - $echo - $echo "*** Warning: linker path does not have real file for library $a_deplib." - $echo "*** I have the capability to make that library automatically link in when" - $echo "*** you link to this library. But I can only do this if you have a" - $echo "*** shared version of the library, which you do not appear to have" - $echo "*** because I did check the linker path looking for a file starting" - if test -z "$potlib" ; then - $echo "*** with $libname but no candidates were found. (...for file magic test)" - else - $echo "*** with $libname and none of the candidates passed a file format test" - $echo "*** using a file magic. Last file checked: $potlib" - fi - fi - else - # Add a -L argument. - newdeplibs="$newdeplibs $a_deplib" - fi - done # Gone through all deplibs. - ;; - match_pattern*) - set dummy $deplibs_check_method - match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` - for a_deplib in $deplibs; do - name="`expr $a_deplib : '-l\(.*\)'`" - # If $name is empty we are operating on a -L argument. - if test -n "$name" && test "$name" != "0"; then - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then - case " $predeps $postdeps " in - *" $a_deplib "*) - newdeplibs="$newdeplibs $a_deplib" - a_deplib="" - ;; - esac - fi - if test -n "$a_deplib" ; then - libname=`eval \\$echo \"$libname_spec\"` - for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do - potential_libs=`ls $i/$libname[.-]* 2>/dev/null` - for potent_lib in $potential_libs; do - potlib="$potent_lib" # see symlink-check above in file_magic test - if eval $echo \"$potent_lib\" 2>/dev/null \ - | ${SED} 10q \ - | $EGREP "$match_pattern_regex" > /dev/null; then - newdeplibs="$newdeplibs $a_deplib" - a_deplib="" - break 2 - fi - done - done - fi - if test -n "$a_deplib" ; then - droppeddeps=yes - $echo - $echo "*** Warning: linker path does not have real file for library $a_deplib." - $echo "*** I have the capability to make that library automatically link in when" - $echo "*** you link to this library. But I can only do this if you have a" - $echo "*** shared version of the library, which you do not appear to have" - $echo "*** because I did check the linker path looking for a file starting" - if test -z "$potlib" ; then - $echo "*** with $libname but no candidates were found. (...for regex pattern test)" - else - $echo "*** with $libname and none of the candidates passed a file format test" - $echo "*** using a regex pattern. Last file checked: $potlib" - fi - fi - else - # Add a -L argument. - newdeplibs="$newdeplibs $a_deplib" - fi - done # Gone through all deplibs. - ;; - none | unknown | *) - newdeplibs="" - tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \ - -e 's/ -[LR][^ ]*//g'` - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then - for i in $predeps $postdeps ; do - # can't use Xsed below, because $i might contain '/' - tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"` - done - fi - if $echo "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' \ - | grep . >/dev/null; then - $echo - if test "X$deplibs_check_method" = "Xnone"; then - $echo "*** Warning: inter-library dependencies are not supported in this platform." - else - $echo "*** Warning: inter-library dependencies are not known to be supported." - fi - $echo "*** All declared inter-library dependencies are being dropped." - droppeddeps=yes - fi - ;; - esac - versuffix=$versuffix_save - major=$major_save - release=$release_save - libname=$libname_save - name=$name_save - - case $host in - *-*-rhapsody* | *-*-darwin1.[012]) - # On Rhapsody replace the C library is the System framework - newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'` - ;; - esac - - if test "$droppeddeps" = yes; then - if test "$module" = yes; then - $echo - $echo "*** Warning: libtool could not satisfy all declared inter-library" - $echo "*** dependencies of module $libname. Therefore, libtool will create" - $echo "*** a static module, that should work as long as the dlopening" - $echo "*** application is linked with the -dlopen flag." - if test -z "$global_symbol_pipe"; then - $echo - $echo "*** However, this would only work if libtool was able to extract symbol" - $echo "*** lists from a program, using \`nm' or equivalent, but libtool could" - $echo "*** not find such a program. So, this module is probably useless." - $echo "*** \`nm' from GNU binutils and a full rebuild may help." - fi - if test "$build_old_libs" = no; then - oldlibs="$output_objdir/$libname.$libext" - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - else - $echo "*** The inter-library dependencies that have been dropped here will be" - $echo "*** automatically added whenever a program is linked with this library" - $echo "*** or is declared to -dlopen it." - - if test "$allow_undefined" = no; then - $echo - $echo "*** Since this library must not contain undefined symbols," - $echo "*** because either the platform does not support them or" - $echo "*** it was explicitly requested with -no-undefined," - $echo "*** libtool will only create a static version of it." - if test "$build_old_libs" = no; then - oldlibs="$output_objdir/$libname.$libext" - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - fi - fi - fi - # Done checking deplibs! - deplibs=$newdeplibs - fi - - # All the library-specific variables (install_libdir is set above). - library_names= - old_library= - dlname= - - # Test again, we may have decided not to build it any more - if test "$build_libtool_libs" = yes; then - if test "$hardcode_into_libs" = yes; then - # Hardcode the library paths - hardcode_libdirs= - dep_rpath= - rpath="$finalize_rpath" - test "$mode" != relink && rpath="$compile_rpath$rpath" - for libdir in $rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - dep_rpath="$dep_rpath $flag" - fi - elif test -n "$runpath_var"; then - case "$perm_rpath " in - *" $libdir "*) ;; - *) perm_rpath="$perm_rpath $libdir" ;; - esac - fi - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - if test -n "$hardcode_libdir_flag_spec_ld"; then - eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" - else - eval dep_rpath=\"$hardcode_libdir_flag_spec\" - fi - fi - if test -n "$runpath_var" && test -n "$perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $perm_rpath; do - rpath="$rpath$dir:" - done - eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" - fi - test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" - fi - - shlibpath="$finalize_shlibpath" - test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" - if test -n "$shlibpath"; then - eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" - fi - - # Get the real and link names of the library. - eval shared_ext=\"$shrext\" - eval library_names=\"$library_names_spec\" - set dummy $library_names - realname="$2" - shift; shift - - if test -n "$soname_spec"; then - eval soname=\"$soname_spec\" - else - soname="$realname" - fi - if test -z "$dlname"; then - dlname=$soname - fi - - lib="$output_objdir/$realname" - for link - do - linknames="$linknames $link" - done - - # Use standard objects if they are pic - test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` - - # Prepare the list of exported symbols - if test -z "$export_symbols"; then - if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then - $show "generating symbol list for \`$libname.la'" - export_symbols="$output_objdir/$libname.exp" - $run $rm $export_symbols - cmds=$export_symbols_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - if len=`expr "X$cmd" : ".*"` && - test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then - $show "$cmd" - $run eval "$cmd" || exit $? - skipped_export=false - else - # The command line is too long to execute in one step. - $show "using reloadable object file for export list..." - skipped_export=: - fi - done - IFS="$save_ifs" - if test -n "$export_symbols_regex"; then - $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\"" - $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' - $show "$mv \"${export_symbols}T\" \"$export_symbols\"" - $run eval '$mv "${export_symbols}T" "$export_symbols"' - fi - fi - fi - - if test -n "$export_symbols" && test -n "$include_expsyms"; then - $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"' - fi - - tmp_deplibs= - for test_deplib in $deplibs; do - case " $convenience " in - *" $test_deplib "*) ;; - *) - tmp_deplibs="$tmp_deplibs $test_deplib" - ;; - esac - done - deplibs="$tmp_deplibs" - - if test -n "$convenience"; then - if test -n "$whole_archive_flag_spec"; then - save_libobjs=$libobjs - eval libobjs=\"\$libobjs $whole_archive_flag_spec\" - else - gentop="$output_objdir/${outputname}x" - $show "${rm}r $gentop" - $run ${rm}r "$gentop" - $show "$mkdir $gentop" - $run $mkdir "$gentop" - status=$? - if test "$status" -ne 0 && test ! -d "$gentop"; then - exit $status - fi - generated="$generated $gentop" - - for xlib in $convenience; do - # Extract the objects. - case $xlib in - [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; - *) xabs=`pwd`"/$xlib" ;; - esac - xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` - xdir="$gentop/$xlib" - - $show "${rm}r $xdir" - $run ${rm}r "$xdir" - $show "$mkdir $xdir" - $run $mkdir "$xdir" - status=$? - if test "$status" -ne 0 && test ! -d "$xdir"; then - exit $status - fi - # We will extract separately just the conflicting names and we will no - # longer touch any unique names. It is faster to leave these extract - # automatically by $AR in one run. - $show "(cd $xdir && $AR x $xabs)" - $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? - if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then - : - else - $echo "$modename: warning: object name conflicts; renaming object files" 1>&2 - $echo "$modename: warning: to ensure that they will not overwrite" 1>&2 - $AR t "$xabs" | sort | uniq -cd | while read -r count name - do - i=1 - while test "$i" -le "$count" - do - # Put our $i before any first dot (extension) - # Never overwrite any file - name_to="$name" - while test "X$name_to" = "X$name" || test -f "$xdir/$name_to" - do - name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"` - done - $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')" - $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $? - i=`expr $i + 1` - done - done - fi - - libobjs="$libobjs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` - done - fi - fi - - if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then - eval flag=\"$thread_safe_flag_spec\" - linker_flags="$linker_flags $flag" - fi - - # Make a backup of the uninstalled library when relinking - if test "$mode" = relink; then - $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $? - fi - - # Do each of the archive commands. - if test "$module" = yes && test -n "$module_cmds" ; then - if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then - eval test_cmds=\"$module_expsym_cmds\" - cmds=$module_expsym_cmds - else - eval test_cmds=\"$module_cmds\" - cmds=$module_cmds - fi - else - if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then - eval test_cmds=\"$archive_expsym_cmds\" - cmds=$archive_expsym_cmds - else - eval test_cmds=\"$archive_cmds\" - cmds=$archive_cmds - fi - fi - - if test "X$skipped_export" != "X:" && len=`expr "X$test_cmds" : ".*"` && - test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then - : - else - # The command line is too long to link in one step, link piecewise. - $echo "creating reloadable object files..." - - # Save the value of $output and $libobjs because we want to - # use them later. If we have whole_archive_flag_spec, we - # want to use save_libobjs as it was before - # whole_archive_flag_spec was expanded, because we can't - # assume the linker understands whole_archive_flag_spec. - # This may have to be revisited, in case too many - # convenience libraries get linked in and end up exceeding - # the spec. - if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then - save_libobjs=$libobjs - fi - save_output=$output - - # Clear the reloadable object creation command queue and - # initialize k to one. - test_cmds= - concat_cmds= - objlist= - delfiles= - last_robj= - k=1 - output=$output_objdir/$save_output-${k}.$objext - # Loop over the list of objects to be linked. - for obj in $save_libobjs - do - eval test_cmds=\"$reload_cmds $objlist $last_robj\" - if test "X$objlist" = X || - { len=`expr "X$test_cmds" : ".*"` && - test "$len" -le "$max_cmd_len"; }; then - objlist="$objlist $obj" - else - # The command $test_cmds is almost too long, add a - # command to the queue. - if test "$k" -eq 1 ; then - # The first file doesn't have a previous command to add. - eval concat_cmds=\"$reload_cmds $objlist $last_robj\" - else - # All subsequent reloadable object files will link in - # the last one created. - eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\" - fi - last_robj=$output_objdir/$save_output-${k}.$objext - k=`expr $k + 1` - output=$output_objdir/$save_output-${k}.$objext - objlist=$obj - len=1 - fi - done - # Handle the remaining objects by creating one last - # reloadable object file. All subsequent reloadable object - # files will link in the last one created. - test -z "$concat_cmds" || concat_cmds=$concat_cmds~ - eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\" - - if ${skipped_export-false}; then - $show "generating symbol list for \`$libname.la'" - export_symbols="$output_objdir/$libname.exp" - $run $rm $export_symbols - libobjs=$output - # Append the command to create the export file. - eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\" - fi - - # Set up a command to remove the reloadale object files - # after they are used. - i=0 - while test "$i" -lt "$k" - do - i=`expr $i + 1` - delfiles="$delfiles $output_objdir/$save_output-${i}.$objext" - done - - $echo "creating a temporary reloadable object file: $output" - - # Loop through the commands generated above and execute them. - save_ifs="$IFS"; IFS='~' - for cmd in $concat_cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - - libobjs=$output - # Restore the value of output. - output=$save_output - - if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then - eval libobjs=\"\$libobjs $whole_archive_flag_spec\" - fi - # Expand the library linking commands again to reset the - # value of $libobjs for piecewise linking. - - # Do each of the archive commands. - if test "$module" = yes && test -n "$module_cmds" ; then - if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then - cmds=$module_expsym_cmds - else - cmds=$module_cmds - fi - else - if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then - cmds=$archive_expsym_cmds - else - cmds=$archive_cmds - fi - fi - - # Append the command to remove the reloadable object files - # to the just-reset $cmds. - eval cmds=\"\$cmds~\$rm $delfiles\" - fi - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - - # Restore the uninstalled library and exit - if test "$mode" = relink; then - $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $? - exit 0 - fi - - # Create links to the real library. - for linkname in $linknames; do - if test "$realname" != "$linkname"; then - $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)" - $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $? - fi - done - - # If -module or -export-dynamic was specified, set the dlname. - if test "$module" = yes || test "$export_dynamic" = yes; then - # On all known operating systems, these are identical. - dlname="$soname" - fi - fi - ;; - - obj) - if test -n "$deplibs"; then - $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2 - fi - - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2 - fi - - if test -n "$rpath"; then - $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2 - fi - - if test -n "$xrpath"; then - $echo "$modename: warning: \`-R' is ignored for objects" 1>&2 - fi - - if test -n "$vinfo"; then - $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2 - fi - - if test -n "$release"; then - $echo "$modename: warning: \`-release' is ignored for objects" 1>&2 - fi - - case $output in - *.lo) - if test -n "$objs$old_deplibs"; then - $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2 - exit 1 - fi - libobj="$output" - obj=`$echo "X$output" | $Xsed -e "$lo2o"` - ;; - *) - libobj= - obj="$output" - ;; - esac - - # Delete the old objects. - $run $rm $obj $libobj - - # Objects from convenience libraries. This assumes - # single-version convenience libraries. Whenever we create - # different ones for PIC/non-PIC, this we'll have to duplicate - # the extraction. - reload_conv_objs= - gentop= - # reload_cmds runs $LD directly, so let us get rid of - # -Wl from whole_archive_flag_spec - wl= - - if test -n "$convenience"; then - if test -n "$whole_archive_flag_spec"; then - eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\" - else - gentop="$output_objdir/${obj}x" - $show "${rm}r $gentop" - $run ${rm}r "$gentop" - $show "$mkdir $gentop" - $run $mkdir "$gentop" - status=$? - if test "$status" -ne 0 && test ! -d "$gentop"; then - exit $status - fi - generated="$generated $gentop" - - for xlib in $convenience; do - # Extract the objects. - case $xlib in - [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; - *) xabs=`pwd`"/$xlib" ;; - esac - xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` - xdir="$gentop/$xlib" - - $show "${rm}r $xdir" - $run ${rm}r "$xdir" - $show "$mkdir $xdir" - $run $mkdir "$xdir" - status=$? - if test "$status" -ne 0 && test ! -d "$xdir"; then - exit $status - fi - # We will extract separately just the conflicting names and we will no - # longer touch any unique names. It is faster to leave these extract - # automatically by $AR in one run. - $show "(cd $xdir && $AR x $xabs)" - $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? - if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then - : - else - $echo "$modename: warning: object name conflicts; renaming object files" 1>&2 - $echo "$modename: warning: to ensure that they will not overwrite" 1>&2 - $AR t "$xabs" | sort | uniq -cd | while read -r count name - do - i=1 - while test "$i" -le "$count" - do - # Put our $i before any first dot (extension) - # Never overwrite any file - name_to="$name" - while test "X$name_to" = "X$name" || test -f "$xdir/$name_to" - do - name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"` - done - $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')" - $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $? - i=`expr $i + 1` - done - done - fi - - reload_conv_objs="$reload_objs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` - done - fi - fi - - # Create the old-style object. - reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test - - output="$obj" - cmds=$reload_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - - # Exit if we aren't doing a library object file. - if test -z "$libobj"; then - if test -n "$gentop"; then - $show "${rm}r $gentop" - $run ${rm}r $gentop - fi - - exit 0 - fi - - if test "$build_libtool_libs" != yes; then - if test -n "$gentop"; then - $show "${rm}r $gentop" - $run ${rm}r $gentop - fi - - # Create an invalid libtool object if no PIC, so that we don't - # accidentally link it into a program. - # $show "echo timestamp > $libobj" - # $run eval "echo timestamp > $libobj" || exit $? - exit 0 - fi - - if test -n "$pic_flag" || test "$pic_mode" != default; then - # Only do commands if we really have different PIC objects. - reload_objs="$libobjs $reload_conv_objs" - output="$libobj" - cmds=$reload_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - fi - - if test -n "$gentop"; then - $show "${rm}r $gentop" - $run ${rm}r $gentop - fi - - exit 0 - ;; - - prog) - case $host in - *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;; - esac - if test -n "$vinfo"; then - $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2 - fi - - if test -n "$release"; then - $echo "$modename: warning: \`-release' is ignored for programs" 1>&2 - fi - - if test "$preload" = yes; then - if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown && - test "$dlopen_self_static" = unknown; then - $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support." - fi - fi - - case $host in - *-*-rhapsody* | *-*-darwin1.[012]) - # On Rhapsody replace the C library is the System framework - compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'` - finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'` - ;; - esac - - case $host in - *darwin*) - # Don't allow lazy linking, it breaks C++ global constructors - if test "$tagname" = CXX ; then - compile_command="$compile_command ${wl}-bind_at_load" - finalize_command="$finalize_command ${wl}-bind_at_load" - fi - ;; - esac - - compile_command="$compile_command $compile_deplibs" - finalize_command="$finalize_command $finalize_deplibs" - - if test -n "$rpath$xrpath"; then - # If the user specified any rpath flags, then add them. - for libdir in $rpath $xrpath; do - # This is the magic to use -rpath. - case "$finalize_rpath " in - *" $libdir "*) ;; - *) finalize_rpath="$finalize_rpath $libdir" ;; - esac - done - fi - - # Now hardcode the library paths - rpath= - hardcode_libdirs= - for libdir in $compile_rpath $finalize_rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - rpath="$rpath $flag" - fi - elif test -n "$runpath_var"; then - case "$perm_rpath " in - *" $libdir "*) ;; - *) perm_rpath="$perm_rpath $libdir" ;; - esac - fi - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) - case :$dllsearchpath: in - *":$libdir:"*) ;; - *) dllsearchpath="$dllsearchpath:$libdir";; - esac - ;; - esac - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - eval rpath=\" $hardcode_libdir_flag_spec\" - fi - compile_rpath="$rpath" - - rpath= - hardcode_libdirs= - for libdir in $finalize_rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - rpath="$rpath $flag" - fi - elif test -n "$runpath_var"; then - case "$finalize_perm_rpath " in - *" $libdir "*) ;; - *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; - esac - fi - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - eval rpath=\" $hardcode_libdir_flag_spec\" - fi - finalize_rpath="$rpath" - - if test -n "$libobjs" && test "$build_old_libs" = yes; then - # Transform all the library objects into standard objects. - compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` - finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` - fi - - dlsyms= - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - if test -n "$NM" && test -n "$global_symbol_pipe"; then - dlsyms="${outputname}S.c" - else - $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2 - fi - fi - - if test -n "$dlsyms"; then - case $dlsyms in - "") ;; - *.c) - # Discover the nlist of each of the dlfiles. - nlist="$output_objdir/${outputname}.nm" - - $show "$rm $nlist ${nlist}S ${nlist}T" - $run $rm "$nlist" "${nlist}S" "${nlist}T" - - # Parse the name list into a source file. - $show "creating $output_objdir/$dlsyms" - - test -z "$run" && $echo > "$output_objdir/$dlsyms" "\ -/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */ -/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */ - -#ifdef __cplusplus -extern \"C\" { -#endif - -/* Prevent the only kind of declaration conflicts we can make. */ -#define lt_preloaded_symbols some_other_symbol - -/* External symbol declarations for the compiler. */\ -" - - if test "$dlself" = yes; then - $show "generating symbol list for \`$output'" - - test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist" - - # Add our own program objects to the symbol list. - progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` - for arg in $progfiles; do - $show "extracting global C symbols from \`$arg'" - $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" - done - - if test -n "$exclude_expsyms"; then - $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' - $run eval '$mv "$nlist"T "$nlist"' - fi - - if test -n "$export_symbols_regex"; then - $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' - $run eval '$mv "$nlist"T "$nlist"' - fi - - # Prepare the list of exported symbols - if test -z "$export_symbols"; then - export_symbols="$output_objdir/$output.exp" - $run $rm $export_symbols - $run eval "${SED} -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' - else - $run eval "${SED} -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"' - $run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T' - $run eval 'mv "$nlist"T "$nlist"' - fi - fi - - for arg in $dlprefiles; do - $show "extracting global C symbols from \`$arg'" - name=`$echo "$arg" | ${SED} -e 's%^.*/%%'` - $run eval '$echo ": $name " >> "$nlist"' - $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" - done - - if test -z "$run"; then - # Make sure we have at least an empty file. - test -f "$nlist" || : > "$nlist" - - if test -n "$exclude_expsyms"; then - $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T - $mv "$nlist"T "$nlist" - fi - - # Try sorting and uniquifying the output. - if grep -v "^: " < "$nlist" | - if sort -k 3 /dev/null 2>&1; then - sort -k 3 - else - sort +2 - fi | - uniq > "$nlist"S; then - : - else - grep -v "^: " < "$nlist" > "$nlist"S - fi - - if test -f "$nlist"S; then - eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"' - else - $echo '/* NONE */' >> "$output_objdir/$dlsyms" - fi - - $echo >> "$output_objdir/$dlsyms" "\ - -#undef lt_preloaded_symbols - -#if defined (__STDC__) && __STDC__ -# define lt_ptr void * -#else -# define lt_ptr char * -# define const -#endif - -/* The mapping between symbol names and symbols. */ -const struct { - const char *name; - lt_ptr address; -} -lt_preloaded_symbols[] = -{\ -" - - eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms" - - $echo >> "$output_objdir/$dlsyms" "\ - {0, (lt_ptr) 0} -}; - -/* This works around a problem in FreeBSD linker */ -#ifdef FREEBSD_WORKAROUND -static const void *lt_preloaded_setup() { - return lt_preloaded_symbols; -} -#endif - -#ifdef __cplusplus -} -#endif\ -" - fi - - pic_flag_for_symtable= - case $host in - # compiling the symbol table file with pic_flag works around - # a FreeBSD bug that causes programs to crash when -lm is - # linked before any other PIC object. But we must not use - # pic_flag when linking with -static. The problem exists in - # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. - *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) - case "$compile_command " in - *" -static "*) ;; - *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";; - esac;; - *-*-hpux*) - case "$compile_command " in - *" -static "*) ;; - *) pic_flag_for_symtable=" $pic_flag";; - esac - esac - - # Now compile the dynamic symbol file. - $show "(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")" - $run eval '(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $? - - # Clean up the generated files. - $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T" - $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T" - - # Transform the symbol file into the correct name. - compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` - finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` - ;; - *) - $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2 - exit 1 - ;; - esac - else - # We keep going just in case the user didn't refer to - # lt_preloaded_symbols. The linker will fail if global_symbol_pipe - # really was required. - - # Nullify the symbol file. - compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` - finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` - fi - - if test "$need_relink" = no || test "$build_libtool_libs" != yes; then - # Replace the output file specification. - compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` - link_command="$compile_command$compile_rpath" - - # We have no uninstalled library dependencies, so finalize right now. - $show "$link_command" - $run eval "$link_command" - status=$? - - # Delete the generated files. - if test -n "$dlsyms"; then - $show "$rm $output_objdir/${outputname}S.${objext}" - $run $rm "$output_objdir/${outputname}S.${objext}" - fi - - exit $status - fi - - if test -n "$shlibpath_var"; then - # We should set the shlibpath_var - rpath= - for dir in $temp_rpath; do - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) - # Absolute path. - rpath="$rpath$dir:" - ;; - *) - # Relative path: add a thisdir entry. - rpath="$rpath\$thisdir/$dir:" - ;; - esac - done - temp_rpath="$rpath" - fi - - if test -n "$compile_shlibpath$finalize_shlibpath"; then - compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" - fi - if test -n "$finalize_shlibpath"; then - finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" - fi - - compile_var= - finalize_var= - if test -n "$runpath_var"; then - if test -n "$perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $perm_rpath; do - rpath="$rpath$dir:" - done - compile_var="$runpath_var=\"$rpath\$$runpath_var\" " - fi - if test -n "$finalize_perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $finalize_perm_rpath; do - rpath="$rpath$dir:" - done - finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " - fi - fi - - if test "$no_install" = yes; then - # We don't need to create a wrapper script. - link_command="$compile_var$compile_command$compile_rpath" - # Replace the output file specification. - link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` - # Delete the old output file. - $run $rm $output - # Link the executable and exit - $show "$link_command" - $run eval "$link_command" || exit $? - exit 0 - fi - - if test "$hardcode_action" = relink; then - # Fast installation is not supported - link_command="$compile_var$compile_command$compile_rpath" - relink_command="$finalize_var$finalize_command$finalize_rpath" - - $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2 - $echo "$modename: \`$output' will be relinked during installation" 1>&2 - else - if test "$fast_install" != no; then - link_command="$finalize_var$compile_command$finalize_rpath" - if test "$fast_install" = yes; then - relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'` - else - # fast_install is set to needless - relink_command= - fi - else - link_command="$compile_var$compile_command$compile_rpath" - relink_command="$finalize_var$finalize_command$finalize_rpath" - fi - fi - - # Replace the output file specification. - link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` - - # Delete the old output files. - $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname - - $show "$link_command" - $run eval "$link_command" || exit $? - - # Now create the wrapper script. - $show "creating $output" - - # Quote the relink command for shipping. - if test -n "$relink_command"; then - # Preserve any variables that may affect compiler behavior - for var in $variables_saved_for_relink; do - if eval test -z \"\${$var+set}\"; then - relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" - elif eval var_value=\$$var; test -z "$var_value"; then - relink_command="$var=; export $var; $relink_command" - else - var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` - relink_command="$var=\"$var_value\"; export $var; $relink_command" - fi - done - relink_command="(cd `pwd`; $relink_command)" - relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` - fi - - # Quote $echo for shipping. - if test "X$echo" = "X$SHELL $0 --fallback-echo"; then - case $0 in - [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $0 --fallback-echo";; - *) qecho="$SHELL `pwd`/$0 --fallback-echo";; - esac - qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"` - else - qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"` - fi - - # Only actually do things if our run command is non-null. - if test -z "$run"; then - # win32 will think the script is a binary if it has - # a .exe suffix, so we strip it off here. - case $output in - *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;; - esac - # test for cygwin because mv fails w/o .exe extensions - case $host in - *cygwin*) - exeext=.exe - outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;; - *) exeext= ;; - esac - case $host in - *cygwin* | *mingw* ) - cwrappersource=`$echo ${objdir}/lt-${output}.c` - cwrapper=`$echo ${output}.exe` - $rm $cwrappersource $cwrapper - trap "$rm $cwrappersource $cwrapper; exit 1" 1 2 15 - - cat > $cwrappersource <> $cwrappersource<<"EOF" -#include -#include -#include -#include -#include -#include - -#if defined(PATH_MAX) -# define LT_PATHMAX PATH_MAX -#elif defined(MAXPATHLEN) -# define LT_PATHMAX MAXPATHLEN -#else -# define LT_PATHMAX 1024 -#endif - -#ifndef DIR_SEPARATOR -#define DIR_SEPARATOR '/' -#endif - -#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ - defined (__OS2__) -#define HAVE_DOS_BASED_FILE_SYSTEM -#ifndef DIR_SEPARATOR_2 -#define DIR_SEPARATOR_2 '\\' -#endif -#endif - -#ifndef DIR_SEPARATOR_2 -# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) -#else /* DIR_SEPARATOR_2 */ -# define IS_DIR_SEPARATOR(ch) \ - (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) -#endif /* DIR_SEPARATOR_2 */ - -#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) -#define XFREE(stale) do { \ - if (stale) { free ((void *) stale); stale = 0; } \ -} while (0) - -const char *program_name = NULL; - -void * xmalloc (size_t num); -char * xstrdup (const char *string); -char * basename (const char *name); -char * fnqualify(const char *path); -char * strendzap(char *str, const char *pat); -void lt_fatal (const char *message, ...); - -int -main (int argc, char *argv[]) -{ - char **newargz; - int i; - - program_name = (char *) xstrdup ((char *) basename (argv[0])); - newargz = XMALLOC(char *, argc+2); -EOF - - cat >> $cwrappersource <> $cwrappersource <<"EOF" - newargz[1] = fnqualify(argv[0]); - /* we know the script has the same name, without the .exe */ - /* so make sure newargz[1] doesn't end in .exe */ - strendzap(newargz[1],".exe"); - for (i = 1; i < argc; i++) - newargz[i+1] = xstrdup(argv[i]); - newargz[argc+1] = NULL; -EOF - - cat >> $cwrappersource <> $cwrappersource <<"EOF" -} - -void * -xmalloc (size_t num) -{ - void * p = (void *) malloc (num); - if (!p) - lt_fatal ("Memory exhausted"); - - return p; -} - -char * -xstrdup (const char *string) -{ - return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL -; -} - -char * -basename (const char *name) -{ - const char *base; - -#if defined (HAVE_DOS_BASED_FILE_SYSTEM) - /* Skip over the disk name in MSDOS pathnames. */ - if (isalpha (name[0]) && name[1] == ':') - name += 2; -#endif - - for (base = name; *name; name++) - if (IS_DIR_SEPARATOR (*name)) - base = name + 1; - return (char *) base; -} - -char * -fnqualify(const char *path) -{ - size_t size; - char *p; - char tmp[LT_PATHMAX + 1]; - - assert(path != NULL); - - /* Is it qualified already? */ -#if defined (HAVE_DOS_BASED_FILE_SYSTEM) - if (isalpha (path[0]) && path[1] == ':') - return xstrdup (path); -#endif - if (IS_DIR_SEPARATOR (path[0])) - return xstrdup (path); - - /* prepend the current directory */ - /* doesn't handle '~' */ - if (getcwd (tmp, LT_PATHMAX) == NULL) - lt_fatal ("getcwd failed"); - size = strlen(tmp) + 1 + strlen(path) + 1; /* +2 for '/' and '\0' */ - p = XMALLOC(char, size); - sprintf(p, "%s%c%s", tmp, DIR_SEPARATOR, path); - return p; -} - -char * -strendzap(char *str, const char *pat) -{ - size_t len, patlen; - - assert(str != NULL); - assert(pat != NULL); - - len = strlen(str); - patlen = strlen(pat); - - if (patlen <= len) - { - str += len - patlen; - if (strcmp(str, pat) == 0) - *str = '\0'; - } - return str; -} - -static void -lt_error_core (int exit_status, const char * mode, - const char * message, va_list ap) -{ - fprintf (stderr, "%s: %s: ", program_name, mode); - vfprintf (stderr, message, ap); - fprintf (stderr, ".\n"); - - if (exit_status >= 0) - exit (exit_status); -} - -void -lt_fatal (const char *message, ...) -{ - va_list ap; - va_start (ap, message); - lt_error_core (EXIT_FAILURE, "FATAL", message, ap); - va_end (ap); -} -EOF - # we should really use a build-platform specific compiler - # here, but OTOH, the wrappers (shell script and this C one) - # are only useful if you want to execute the "real" binary. - # Since the "real" binary is built for $host, then this - # wrapper might as well be built for $host, too. - $run $LTCC -s -o $cwrapper $cwrappersource - ;; - esac - $rm $output - trap "$rm $output; exit 1" 1 2 15 - - $echo > $output "\ -#! $SHELL - -# $output - temporary wrapper script for $objdir/$outputname -# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP -# -# The $output program cannot be directly executed until all the libtool -# libraries that it depends on are installed. -# -# This wrapper script should never be moved out of the build directory. -# If it is, it will not operate correctly. - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -Xsed='${SED} -e 1s/^X//' -sed_quote_subst='$sed_quote_subst' - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -if test \"\${CDPATH+set}\" = set; then CDPATH=:; export CDPATH; fi - -relink_command=\"$relink_command\" - -# This environment variable determines our operation mode. -if test \"\$libtool_install_magic\" = \"$magic\"; then - # install mode needs the following variable: - notinst_deplibs='$notinst_deplibs' -else - # When we are sourced in execute mode, \$file and \$echo are already set. - if test \"\$libtool_execute_magic\" != \"$magic\"; then - echo=\"$qecho\" - file=\"\$0\" - # Make sure echo works. - if test \"X\$1\" = X--no-reexec; then - # Discard the --no-reexec flag, and continue. - shift - elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then - # Yippee, \$echo works! - : - else - # Restart under the correct shell, and then maybe \$echo will work. - exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} - fi - fi\ -" - $echo >> $output "\ - - # Find the directory that this script lives in. - thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` - test \"x\$thisdir\" = \"x\$file\" && thisdir=. - - # Follow symbolic links until we get to the real thisdir. - file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\` - while test -n \"\$file\"; do - destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` - - # If there was a directory component, then change thisdir. - if test \"x\$destdir\" != \"x\$file\"; then - case \"\$destdir\" in - [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; - *) thisdir=\"\$thisdir/\$destdir\" ;; - esac - fi - - file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\` - file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\` - done - - # Try to get the absolute directory name. - absdir=\`cd \"\$thisdir\" && pwd\` - test -n \"\$absdir\" && thisdir=\"\$absdir\" -" - - if test "$fast_install" = yes; then - $echo >> $output "\ - program=lt-'$outputname'$exeext - progdir=\"\$thisdir/$objdir\" - - if test ! -f \"\$progdir/\$program\" || \\ - { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ - test \"X\$file\" != \"X\$progdir/\$program\"; }; then - - file=\"\$\$-\$program\" - - if test ! -d \"\$progdir\"; then - $mkdir \"\$progdir\" - else - $rm \"\$progdir/\$file\" - fi" - - $echo >> $output "\ - - # relink executable if necessary - if test -n \"\$relink_command\"; then - if relink_command_output=\`eval \$relink_command 2>&1\`; then : - else - $echo \"\$relink_command_output\" >&2 - $rm \"\$progdir/\$file\" - exit 1 - fi - fi - - $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || - { $rm \"\$progdir/\$program\"; - $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; } - $rm \"\$progdir/\$file\" - fi" - else - $echo >> $output "\ - program='$outputname' - progdir=\"\$thisdir/$objdir\" -" - fi - - $echo >> $output "\ - - if test -f \"\$progdir/\$program\"; then" - - # Export our shlibpath_var if we have one. - if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then - $echo >> $output "\ - # Add our own library path to $shlibpath_var - $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" - - # Some systems cannot cope with colon-terminated $shlibpath_var - # The second colon is a workaround for a bug in BeOS R4 sed - $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` - - export $shlibpath_var -" - fi - - # fixup the dll searchpath if we need to. - if test -n "$dllsearchpath"; then - $echo >> $output "\ - # Add the dll search path components to the executable PATH - PATH=$dllsearchpath:\$PATH -" - fi - - $echo >> $output "\ - if test \"\$libtool_execute_magic\" != \"$magic\"; then - # Run the actual program with our arguments. -" - case $host in - # Backslashes separate directories on plain windows - *-*-mingw | *-*-os2*) - $echo >> $output "\ - exec \$progdir\\\\\$program \${1+\"\$@\"} -" - ;; - - *) - $echo >> $output "\ - exec \$progdir/\$program \${1+\"\$@\"} -" - ;; - esac - $echo >> $output "\ - \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\" - exit 1 - fi - else - # The program doesn't exist. - \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2 - \$echo \"This script is just a wrapper for \$program.\" 1>&2 - $echo \"See the $PACKAGE documentation for more information.\" 1>&2 - exit 1 - fi -fi\ -" - chmod +x $output - fi - exit 0 - ;; - esac - - # See if we need to build an old-fashioned archive. - for oldlib in $oldlibs; do - - if test "$build_libtool_libs" = convenience; then - oldobjs="$libobjs_save" - addlibs="$convenience" - build_libtool_libs=no - else - if test "$build_libtool_libs" = module; then - oldobjs="$libobjs_save" - build_libtool_libs=no - else - oldobjs="$old_deplibs $non_pic_objects" - fi - addlibs="$old_convenience" - fi - - if test -n "$addlibs"; then - gentop="$output_objdir/${outputname}x" - $show "${rm}r $gentop" - $run ${rm}r "$gentop" - $show "$mkdir $gentop" - $run $mkdir "$gentop" - status=$? - if test "$status" -ne 0 && test ! -d "$gentop"; then - exit $status - fi - generated="$generated $gentop" - - # Add in members from convenience archives. - for xlib in $addlibs; do - # Extract the objects. - case $xlib in - [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; - *) xabs=`pwd`"/$xlib" ;; - esac - xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` - xdir="$gentop/$xlib" - - $show "${rm}r $xdir" - $run ${rm}r "$xdir" - $show "$mkdir $xdir" - $run $mkdir "$xdir" - status=$? - if test "$status" -ne 0 && test ! -d "$xdir"; then - exit $status - fi - # We will extract separately just the conflicting names and we will no - # longer touch any unique names. It is faster to leave these extract - # automatically by $AR in one run. - $show "(cd $xdir && $AR x $xabs)" - $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? - if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then - : - else - $echo "$modename: warning: object name conflicts; renaming object files" 1>&2 - $echo "$modename: warning: to ensure that they will not overwrite" 1>&2 - $AR t "$xabs" | sort | uniq -cd | while read -r count name - do - i=1 - while test "$i" -le "$count" - do - # Put our $i before any first dot (extension) - # Never overwrite any file - name_to="$name" - while test "X$name_to" = "X$name" || test -f "$xdir/$name_to" - do - name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"` - done - $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')" - $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $? - i=`expr $i + 1` - done - done - fi - - oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP` - done - fi - - # Do each command in the archive commands. - if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then - cmds=$old_archive_from_new_cmds - else - eval cmds=\"$old_archive_cmds\" - - if len=`expr "X$cmds" : ".*"` && - test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then - cmds=$old_archive_cmds - else - # the command line is too long to link in one step, link in parts - $echo "using piecewise archive linking..." - save_RANLIB=$RANLIB - RANLIB=: - objlist= - concat_cmds= - save_oldobjs=$oldobjs - # GNU ar 2.10+ was changed to match POSIX; thus no paths are - # encoded into archives. This makes 'ar r' malfunction in - # this piecewise linking case whenever conflicting object - # names appear in distinct ar calls; check, warn and compensate. - if (for obj in $save_oldobjs - do - $echo "X$obj" | $Xsed -e 's%^.*/%%' - done | sort | sort -uc >/dev/null 2>&1); then - : - else - $echo "$modename: warning: object name conflicts; overriding AR_FLAGS to 'cq'" 1>&2 - $echo "$modename: warning: to ensure that POSIX-compatible ar will work" 1>&2 - AR_FLAGS=cq - fi - # Is there a better way of finding the last object in the list? - for obj in $save_oldobjs - do - last_oldobj=$obj - done - for obj in $save_oldobjs - do - oldobjs="$objlist $obj" - objlist="$objlist $obj" - eval test_cmds=\"$old_archive_cmds\" - if len=`expr "X$test_cmds" : ".*"` && - test "$len" -le "$max_cmd_len"; then - : - else - # the above command should be used before it gets too long - oldobjs=$objlist - if test "$obj" = "$last_oldobj" ; then - RANLIB=$save_RANLIB - fi - test -z "$concat_cmds" || concat_cmds=$concat_cmds~ - eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" - objlist= - fi - done - RANLIB=$save_RANLIB - oldobjs=$objlist - if test "X$oldobjs" = "X" ; then - eval cmds=\"\$concat_cmds\" - else - eval cmds=\"\$concat_cmds~\$old_archive_cmds\" - fi - fi - fi - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - eval cmd=\"$cmd\" - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - done - - if test -n "$generated"; then - $show "${rm}r$generated" - $run ${rm}r$generated - fi - - # Now create the libtool archive. - case $output in - *.la) - old_library= - test "$build_old_libs" = yes && old_library="$libname.$libext" - $show "creating $output" - - # Preserve any variables that may affect compiler behavior - for var in $variables_saved_for_relink; do - if eval test -z \"\${$var+set}\"; then - relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" - elif eval var_value=\$$var; test -z "$var_value"; then - relink_command="$var=; export $var; $relink_command" - else - var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` - relink_command="$var=\"$var_value\"; export $var; $relink_command" - fi - done - # Quote the link command for shipping. - relink_command="(cd `pwd`; $SHELL $0 $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" - relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` - if test "$hardcode_automatic" = yes ; then - relink_command= - fi - # Only create the output if not a dry run. - if test -z "$run"; then - for installed in no yes; do - if test "$installed" = yes; then - if test -z "$install_libdir"; then - break - fi - output="$output_objdir/$outputname"i - # Replace all uninstalled libtool libraries with the installed ones - newdependency_libs= - for deplib in $dependency_libs; do - case $deplib in - *.la) - name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'` - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` - if test -z "$libdir"; then - $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 - exit 1 - fi - newdependency_libs="$newdependency_libs $libdir/$name" - ;; - *) newdependency_libs="$newdependency_libs $deplib" ;; - esac - done - dependency_libs="$newdependency_libs" - newdlfiles= - for lib in $dlfiles; do - name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` - if test -z "$libdir"; then - $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 - exit 1 - fi - newdlfiles="$newdlfiles $libdir/$name" - done - dlfiles="$newdlfiles" - newdlprefiles= - for lib in $dlprefiles; do - name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` - if test -z "$libdir"; then - $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 - exit 1 - fi - newdlprefiles="$newdlprefiles $libdir/$name" - done - dlprefiles="$newdlprefiles" - else - newdlfiles= - for lib in $dlfiles; do - case $lib in - [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; - *) abs=`pwd`"/$lib" ;; - esac - newdlfiles="$newdlfiles $abs" - done - dlfiles="$newdlfiles" - newdlprefiles= - for lib in $dlprefiles; do - case $lib in - [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; - *) abs=`pwd`"/$lib" ;; - esac - newdlprefiles="$newdlprefiles $abs" - done - dlprefiles="$newdlprefiles" - fi - $rm $output - # place dlname in correct position for cygwin - tdlname=$dlname - case $host,$output,$installed,$module,$dlname in - *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; - esac - $echo > $output "\ -# $outputname - a libtool library file -# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP -# -# Please DO NOT delete this file! -# It is necessary for linking the library. - -# The name that we can dlopen(3). -dlname='$tdlname' - -# Names of this library. -library_names='$library_names' - -# The name of the static archive. -old_library='$old_library' - -# Libraries that this one depends upon. -dependency_libs='$dependency_libs' - -# Version information for $libname. -current=$current -age=$age -revision=$revision - -# Is this an already installed library? -installed=$installed - -# Should we warn about portability when linking against -modules? -shouldnotlink=$module - -# Files to dlopen/dlpreopen -dlopen='$dlfiles' -dlpreopen='$dlprefiles' - -# Directory that this library needs to be installed in: -libdir='$install_libdir'" - if test "$installed" = no && test "$need_relink" = yes; then - $echo >> $output "\ -relink_command=\"$relink_command\"" - fi - done - fi - - # Do a symbolic link so that the libtool archive can be found in - # LD_LIBRARY_PATH before the program is installed. - $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" - $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $? - ;; - esac - exit 0 - ;; - - # libtool install mode - install) - modename="$modename: install" - - # There may be an optional sh(1) argument at the beginning of - # install_prog (especially on Windows NT). - if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || - # Allow the use of GNU shtool's install command. - $echo "X$nonopt" | $Xsed | grep shtool > /dev/null; then - # Aesthetically quote it. - arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) - arg="\"$arg\"" - ;; - esac - install_prog="$arg " - arg="$1" - shift - else - install_prog= - arg="$nonopt" - fi - - # The real first argument should be the name of the installation program. - # Aesthetically quote it. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) - arg="\"$arg\"" - ;; - esac - install_prog="$install_prog$arg" - - # We need to accept at least all the BSD install flags. - dest= - files= - opts= - prev= - install_type= - isdir=no - stripme= - for arg - do - if test -n "$dest"; then - files="$files $dest" - dest="$arg" - continue - fi - - case $arg in - -d) isdir=yes ;; - -f) prev="-f" ;; - -g) prev="-g" ;; - -m) prev="-m" ;; - -o) prev="-o" ;; - -s) - stripme=" -s" - continue - ;; - -*) ;; - - *) - # If the previous option needed an argument, then skip it. - if test -n "$prev"; then - prev= - else - dest="$arg" - continue - fi - ;; - esac - - # Aesthetically quote the argument. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) - arg="\"$arg\"" - ;; - esac - install_prog="$install_prog $arg" - done - - if test -z "$install_prog"; then - $echo "$modename: you must specify an install program" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - if test -n "$prev"; then - $echo "$modename: the \`$prev' option requires an argument" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - if test -z "$files"; then - if test -z "$dest"; then - $echo "$modename: no file or destination specified" 1>&2 - else - $echo "$modename: you must specify a destination" 1>&2 - fi - $echo "$help" 1>&2 - exit 1 - fi - - # Strip any trailing slash from the destination. - dest=`$echo "X$dest" | $Xsed -e 's%/$%%'` - - # Check to see that the destination is a directory. - test -d "$dest" && isdir=yes - if test "$isdir" = yes; then - destdir="$dest" - destname= - else - destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'` - test "X$destdir" = "X$dest" && destdir=. - destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'` - - # Not a directory, so check to see that there is only one file specified. - set dummy $files - if test "$#" -gt 2; then - $echo "$modename: \`$dest' is not a directory" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - fi - case $destdir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - for file in $files; do - case $file in - *.lo) ;; - *) - $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; - esac - done - ;; - esac - - # This variable tells wrapper scripts just to set variables rather - # than running their programs. - libtool_install_magic="$magic" - - staticlibs= - future_libdirs= - current_libdirs= - for file in $files; do - - # Do each installation. - case $file in - *.$libext) - # Do the static libraries later. - staticlibs="$staticlibs $file" - ;; - - *.la) - # Check to see that this really is a libtool archive. - if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : - else - $echo "$modename: \`$file' is not a valid libtool archive" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - library_names= - old_library= - relink_command= - # If there is no directory component, then add one. - case $file in - */* | *\\*) . $file ;; - *) . ./$file ;; - esac - - # Add the libdir to current_libdirs if it is the destination. - if test "X$destdir" = "X$libdir"; then - case "$current_libdirs " in - *" $libdir "*) ;; - *) current_libdirs="$current_libdirs $libdir" ;; - esac - else - # Note the libdir as a future libdir. - case "$future_libdirs " in - *" $libdir "*) ;; - *) future_libdirs="$future_libdirs $libdir" ;; - esac - fi - - dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/ - test "X$dir" = "X$file/" && dir= - dir="$dir$objdir" - - if test -n "$relink_command"; then - # Determine the prefix the user has applied to our future dir. - inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"` - - # Don't allow the user to place us outside of our expected - # location b/c this prevents finding dependent libraries that - # are installed to the same prefix. - # At present, this check doesn't affect windows .dll's that - # are installed into $libdir/../bin (currently, that works fine) - # but it's something to keep an eye on. - if test "$inst_prefix_dir" = "$destdir"; then - $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2 - exit 1 - fi - - if test -n "$inst_prefix_dir"; then - # Stick the inst_prefix_dir data into the link command. - relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` - else - relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%%"` - fi - - $echo "$modename: warning: relinking \`$file'" 1>&2 - $show "$relink_command" - if $run eval "$relink_command"; then : - else - $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 - exit 1 - fi - fi - - # See the names of the shared library. - set dummy $library_names - if test -n "$2"; then - realname="$2" - shift - shift - - srcname="$realname" - test -n "$relink_command" && srcname="$realname"T - - # Install the shared library and build the symlinks. - $show "$install_prog $dir/$srcname $destdir/$realname" - $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $? - if test -n "$stripme" && test -n "$striplib"; then - $show "$striplib $destdir/$realname" - $run eval "$striplib $destdir/$realname" || exit $? - fi - - if test "$#" -gt 0; then - # Delete the old symlinks, and create new ones. - for linkname - do - if test "$linkname" != "$realname"; then - $show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" - $run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" - fi - done - fi - - # Do each command in the postinstall commands. - lib="$destdir/$realname" - cmds=$postinstall_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - fi - - # Install the pseudo-library for information purposes. - name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - instname="$dir/$name"i - $show "$install_prog $instname $destdir/$name" - $run eval "$install_prog $instname $destdir/$name" || exit $? - - # Maybe install the static library, too. - test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" - ;; - - *.lo) - # Install (i.e. copy) a libtool object. - - # Figure out destination file name, if it wasn't already specified. - if test -n "$destname"; then - destfile="$destdir/$destname" - else - destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - destfile="$destdir/$destfile" - fi - - # Deduce the name of the destination old-style object file. - case $destfile in - *.lo) - staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"` - ;; - *.$objext) - staticdest="$destfile" - destfile= - ;; - *) - $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; - esac - - # Install the libtool object if requested. - if test -n "$destfile"; then - $show "$install_prog $file $destfile" - $run eval "$install_prog $file $destfile" || exit $? - fi - - # Install the old object if enabled. - if test "$build_old_libs" = yes; then - # Deduce the name of the old-style object file. - staticobj=`$echo "X$file" | $Xsed -e "$lo2o"` - - $show "$install_prog $staticobj $staticdest" - $run eval "$install_prog \$staticobj \$staticdest" || exit $? - fi - exit 0 - ;; - - *) - # Figure out destination file name, if it wasn't already specified. - if test -n "$destname"; then - destfile="$destdir/$destname" - else - destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - destfile="$destdir/$destfile" - fi - - # If the file is missing, and there is a .exe on the end, strip it - # because it is most likely a libtool script we actually want to - # install - stripped_ext="" - case $file in - *.exe) - if test ! -f "$file"; then - file=`$echo $file|${SED} 's,.exe$,,'` - stripped_ext=".exe" - fi - ;; - esac - - # Do a test to see if this is really a libtool program. - case $host in - *cygwin*|*mingw*) - wrapper=`$echo $file | ${SED} -e 's,.exe$,,'` - ;; - *) - wrapper=$file - ;; - esac - if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then - notinst_deplibs= - relink_command= - - # To insure that "foo" is sourced, and not "foo.exe", - # finese the cygwin/MSYS system by explicitly sourcing "foo." - # which disallows the automatic-append-.exe behavior. - case $build in - *cygwin* | *mingw*) wrapperdot=${wrapper}. ;; - *) wrapperdot=${wrapper} ;; - esac - # If there is no directory component, then add one. - case $file in - */* | *\\*) . ${wrapperdot} ;; - *) . ./${wrapperdot} ;; - esac - - # Check the variables that should have been set. - if test -z "$notinst_deplibs"; then - $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2 - exit 1 - fi - - finalize=yes - for lib in $notinst_deplibs; do - # Check to see that each library is installed. - libdir= - if test -f "$lib"; then - # If there is no directory component, then add one. - case $lib in - */* | *\\*) . $lib ;; - *) . ./$lib ;; - esac - fi - libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test - if test -n "$libdir" && test ! -f "$libfile"; then - $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2 - finalize=no - fi - done - - relink_command= - # To insure that "foo" is sourced, and not "foo.exe", - # finese the cygwin/MSYS system by explicitly sourcing "foo." - # which disallows the automatic-append-.exe behavior. - case $build in - *cygwin* | *mingw*) wrapperdot=${wrapper}. ;; - *) wrapperdot=${wrapper} ;; - esac - # If there is no directory component, then add one. - case $file in - */* | *\\*) . ${wrapperdot} ;; - *) . ./${wrapperdot} ;; - esac - - outputname= - if test "$fast_install" = no && test -n "$relink_command"; then - if test "$finalize" = yes && test -z "$run"; then - tmpdir="/tmp" - test -n "$TMPDIR" && tmpdir="$TMPDIR" - tmpdir="$tmpdir/libtool-$$" - if $mkdir "$tmpdir" && chmod 700 "$tmpdir"; then : - else - $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2 - continue - fi - file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'` - outputname="$tmpdir/$file" - # Replace the output file specification. - relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` - - $show "$relink_command" - if $run eval "$relink_command"; then : - else - $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 - ${rm}r "$tmpdir" - continue - fi - file="$outputname" - else - $echo "$modename: warning: cannot relink \`$file'" 1>&2 - fi - else - # Install the binary that we compiled earlier. - file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` - fi - fi - - # remove .exe since cygwin /usr/bin/install will append another - # one anyways - case $install_prog,$host in - */usr/bin/install*,*cygwin*) - case $file:$destfile in - *.exe:*.exe) - # this is ok - ;; - *.exe:*) - destfile=$destfile.exe - ;; - *:*.exe) - destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'` - ;; - esac - ;; - esac - $show "$install_prog$stripme $file $destfile" - $run eval "$install_prog\$stripme \$file \$destfile" || exit $? - test -n "$outputname" && ${rm}r "$tmpdir" - ;; - esac - done - - for file in $staticlibs; do - name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - - # Set up the ranlib parameters. - oldlib="$destdir/$name" - - $show "$install_prog $file $oldlib" - $run eval "$install_prog \$file \$oldlib" || exit $? - - if test -n "$stripme" && test -n "$old_striplib"; then - $show "$old_striplib $oldlib" - $run eval "$old_striplib $oldlib" || exit $? - fi - - # Do each command in the postinstall commands. - cmds=$old_postinstall_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - done - - if test -n "$future_libdirs"; then - $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2 - fi - - if test -n "$current_libdirs"; then - # Maybe just do a dry run. - test -n "$run" && current_libdirs=" -n$current_libdirs" - exec_cmd='$SHELL $0 $preserve_args --finish$current_libdirs' - else - exit 0 - fi - ;; - - # libtool finish mode - finish) - modename="$modename: finish" - libdirs="$nonopt" - admincmds= - - if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then - for dir - do - libdirs="$libdirs $dir" - done - - for libdir in $libdirs; do - if test -n "$finish_cmds"; then - # Do each command in the finish commands. - cmds=$finish_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" || admincmds="$admincmds - $cmd" - done - IFS="$save_ifs" - fi - if test -n "$finish_eval"; then - # Do the single finish_eval. - eval cmds=\"$finish_eval\" - $run eval "$cmds" || admincmds="$admincmds - $cmds" - fi - done - fi - - # Exit here if they wanted silent mode. - test "$show" = : && exit 0 - - $echo "----------------------------------------------------------------------" - $echo "Libraries have been installed in:" - for libdir in $libdirs; do - $echo " $libdir" - done - $echo - $echo "If you ever happen to want to link against installed libraries" - $echo "in a given directory, LIBDIR, you must either use libtool, and" - $echo "specify the full pathname of the library, or use the \`-LLIBDIR'" - $echo "flag during linking and do at least one of the following:" - if test -n "$shlibpath_var"; then - $echo " - add LIBDIR to the \`$shlibpath_var' environment variable" - $echo " during execution" - fi - if test -n "$runpath_var"; then - $echo " - add LIBDIR to the \`$runpath_var' environment variable" - $echo " during linking" - fi - if test -n "$hardcode_libdir_flag_spec"; then - libdir=LIBDIR - eval flag=\"$hardcode_libdir_flag_spec\" - - $echo " - use the \`$flag' linker flag" - fi - if test -n "$admincmds"; then - $echo " - have your system administrator run these commands:$admincmds" - fi - if test -f /etc/ld.so.conf; then - $echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" - fi - $echo - $echo "See any operating system documentation about shared libraries for" - $echo "more information, such as the ld(1) and ld.so(8) manual pages." - $echo "----------------------------------------------------------------------" - exit 0 - ;; - - # libtool execute mode - execute) - modename="$modename: execute" - - # The first argument is the command name. - cmd="$nonopt" - if test -z "$cmd"; then - $echo "$modename: you must specify a COMMAND" 1>&2 - $echo "$help" - exit 1 - fi - - # Handle -dlopen flags immediately. - for file in $execute_dlfiles; do - if test ! -f "$file"; then - $echo "$modename: \`$file' is not a file" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - dir= - case $file in - *.la) - # Check to see that this really is a libtool archive. - if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : - else - $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - # Read the libtool library. - dlname= - library_names= - - # If there is no directory component, then add one. - case $file in - */* | *\\*) . $file ;; - *) . ./$file ;; - esac - - # Skip this library if it cannot be dlopened. - if test -z "$dlname"; then - # Warn if it was a shared library. - test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'" - continue - fi - - dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` - test "X$dir" = "X$file" && dir=. - - if test -f "$dir/$objdir/$dlname"; then - dir="$dir/$objdir" - else - $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2 - exit 1 - fi - ;; - - *.lo) - # Just add the directory containing the .lo file. - dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` - test "X$dir" = "X$file" && dir=. - ;; - - *) - $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2 - continue - ;; - esac - - # Get the absolute pathname. - absdir=`cd "$dir" && pwd` - test -n "$absdir" && dir="$absdir" - - # Now add the directory to shlibpath_var. - if eval "test -z \"\$$shlibpath_var\""; then - eval "$shlibpath_var=\"\$dir\"" - else - eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" - fi - done - - # This variable tells wrapper scripts just to set shlibpath_var - # rather than running their programs. - libtool_execute_magic="$magic" - - # Check if any of the arguments is a wrapper script. - args= - for file - do - case $file in - -*) ;; - *) - # Do a test to see if this is really a libtool program. - if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - # If there is no directory component, then add one. - case $file in - */* | *\\*) . $file ;; - *) . ./$file ;; - esac - - # Transform arg to wrapped name. - file="$progdir/$program" - fi - ;; - esac - # Quote arguments (to preserve shell metacharacters). - file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"` - args="$args \"$file\"" - done - - if test -z "$run"; then - if test -n "$shlibpath_var"; then - # Export the shlibpath_var. - eval "export $shlibpath_var" - fi - - # Restore saved environment variables - if test "${save_LC_ALL+set}" = set; then - LC_ALL="$save_LC_ALL"; export LC_ALL - fi - if test "${save_LANG+set}" = set; then - LANG="$save_LANG"; export LANG - fi - - # Now prepare to actually exec the command. - exec_cmd="\$cmd$args" - else - # Display what would be done. - if test -n "$shlibpath_var"; then - eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\"" - $echo "export $shlibpath_var" - fi - $echo "$cmd$args" - exit 0 - fi - ;; - - # libtool clean and uninstall mode - clean | uninstall) - modename="$modename: $mode" - rm="$nonopt" - files= - rmforce= - exit_status=0 - - # This variable tells wrapper scripts just to set variables rather - # than running their programs. - libtool_install_magic="$magic" - - for arg - do - case $arg in - -f) rm="$rm $arg"; rmforce=yes ;; - -*) rm="$rm $arg" ;; - *) files="$files $arg" ;; - esac - done - - if test -z "$rm"; then - $echo "$modename: you must specify an RM program" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - rmdirs= - - origobjdir="$objdir" - for file in $files; do - dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` - if test "X$dir" = "X$file"; then - dir=. - objdir="$origobjdir" - else - objdir="$dir/$origobjdir" - fi - name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - test "$mode" = uninstall && objdir="$dir" - - # Remember objdir for removal later, being careful to avoid duplicates - if test "$mode" = clean; then - case " $rmdirs " in - *" $objdir "*) ;; - *) rmdirs="$rmdirs $objdir" ;; - esac - fi - - # Don't error if the file doesn't exist and rm -f was used. - if (test -L "$file") >/dev/null 2>&1 \ - || (test -h "$file") >/dev/null 2>&1 \ - || test -f "$file"; then - : - elif test -d "$file"; then - exit_status=1 - continue - elif test "$rmforce" = yes; then - continue - fi - - rmfiles="$file" - - case $name in - *.la) - # Possibly a libtool archive, so verify it. - if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - . $dir/$name - - # Delete the libtool libraries and symlinks. - for n in $library_names; do - rmfiles="$rmfiles $objdir/$n" - done - test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" - test "$mode" = clean && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" - - if test "$mode" = uninstall; then - if test -n "$library_names"; then - # Do each command in the postuninstall commands. - cmds=$postuninstall_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" - if test "$?" -ne 0 && test "$rmforce" != yes; then - exit_status=1 - fi - done - IFS="$save_ifs" - fi - - if test -n "$old_library"; then - # Do each command in the old_postuninstall commands. - cmds=$old_postuninstall_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" - if test "$?" -ne 0 && test "$rmforce" != yes; then - exit_status=1 - fi - done - IFS="$save_ifs" - fi - # FIXME: should reinstall the best remaining shared library. - fi - fi - ;; - - *.lo) - # Possibly a libtool object, so verify it. - if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - - # Read the .lo file - . $dir/$name - - # Add PIC object to the list of files to remove. - if test -n "$pic_object" \ - && test "$pic_object" != none; then - rmfiles="$rmfiles $dir/$pic_object" - fi - - # Add non-PIC object to the list of files to remove. - if test -n "$non_pic_object" \ - && test "$non_pic_object" != none; then - rmfiles="$rmfiles $dir/$non_pic_object" - fi - fi - ;; - - *) - if test "$mode" = clean ; then - noexename=$name - case $file in - *.exe) - file=`$echo $file|${SED} 's,.exe$,,'` - noexename=`$echo $name|${SED} 's,.exe$,,'` - # $file with .exe has already been added to rmfiles, - # add $file without .exe - rmfiles="$rmfiles $file" - ;; - esac - # Do a test to see if this is a libtool program. - if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - relink_command= - . $dir/$noexename - - # note $name still contains .exe if it was in $file originally - # as does the version of $file that was added into $rmfiles - rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" - if test "$fast_install" = yes && test -n "$relink_command"; then - rmfiles="$rmfiles $objdir/lt-$name" - fi - if test "X$noexename" != "X$name" ; then - rmfiles="$rmfiles $objdir/lt-${noexename}.c" - fi - fi - fi - ;; - esac - $show "$rm $rmfiles" - $run $rm $rmfiles || exit_status=1 - done - objdir="$origobjdir" - - # Try to remove the ${objdir}s in the directories where we deleted files - for dir in $rmdirs; do - if test -d "$dir"; then - $show "rmdir $dir" - $run rmdir $dir >/dev/null 2>&1 - fi - done - - exit $exit_status - ;; - - "") - $echo "$modename: you must specify a MODE" 1>&2 - $echo "$generic_help" 1>&2 - exit 1 - ;; - esac - - if test -z "$exec_cmd"; then - $echo "$modename: invalid operation mode \`$mode'" 1>&2 - $echo "$generic_help" 1>&2 - exit 1 - fi -fi # test -z "$show_help" - -if test -n "$exec_cmd"; then - eval exec $exec_cmd - exit 1 -fi - -# We need to display help for each of the modes. -case $mode in -"") $echo \ -"Usage: $modename [OPTION]... [MODE-ARG]... - -Provide generalized library-building support services. - - --config show all configuration variables - --debug enable verbose shell tracing --n, --dry-run display commands without modifying any files - --features display basic configuration information and exit - --finish same as \`--mode=finish' - --help display this help message and exit - --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS] - --quiet same as \`--silent' - --silent don't print informational messages - --tag=TAG use configuration variables from tag TAG - --version print version information - -MODE must be one of the following: - - clean remove files from the build directory - compile compile a source file into a libtool object - execute automatically set library path, then run a program - finish complete the installation of libtool libraries - install install libraries or executables - link create a library or an executable - uninstall remove libraries from an installed directory - -MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for -a more detailed description of MODE. - -Report bugs to ." - exit 0 - ;; - -clean) - $echo \ -"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE... - -Remove files from the build directory. - -RM is the name of the program to use to delete files associated with each FILE -(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed -to RM. - -If FILE is a libtool library, object or program, all the files associated -with it are deleted. Otherwise, only FILE itself is deleted using RM." - ;; - -compile) - $echo \ -"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE - -Compile a source file into a libtool library object. - -This mode accepts the following additional options: - - -o OUTPUT-FILE set the output file name to OUTPUT-FILE - -prefer-pic try to building PIC objects only - -prefer-non-pic try to building non-PIC objects only - -static always build a \`.o' file suitable for static linking - -COMPILE-COMMAND is a command to be used in creating a \`standard' object file -from the given SOURCEFILE. - -The output file name is determined by removing the directory component from -SOURCEFILE, then substituting the C source code suffix \`.c' with the -library object suffix, \`.lo'." - ;; - -execute) - $echo \ -"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]... - -Automatically set library path, then run a program. - -This mode accepts the following additional options: - - -dlopen FILE add the directory containing FILE to the library path - -This mode sets the library path environment variable according to \`-dlopen' -flags. - -If any of the ARGS are libtool executable wrappers, then they are translated -into their corresponding uninstalled binary, and any of their required library -directories are added to the library path. - -Then, COMMAND is executed, with ARGS as arguments." - ;; - -finish) - $echo \ -"Usage: $modename [OPTION]... --mode=finish [LIBDIR]... - -Complete the installation of libtool libraries. - -Each LIBDIR is a directory that contains libtool libraries. - -The commands that this mode executes may require superuser privileges. Use -the \`--dry-run' option if you just want to see what would be executed." - ;; - -install) - $echo \ -"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND... - -Install executables or libraries. - -INSTALL-COMMAND is the installation command. The first component should be -either the \`install' or \`cp' program. - -The rest of the components are interpreted as arguments to that command (only -BSD-compatible install options are recognized)." - ;; - -link) - $echo \ -"Usage: $modename [OPTION]... --mode=link LINK-COMMAND... - -Link object files or libraries together to form another library, or to -create an executable program. - -LINK-COMMAND is a command using the C compiler that you would use to create -a program from several object files. - -The following components of LINK-COMMAND are treated specially: - - -all-static do not do any dynamic linking at all - -avoid-version do not add a version suffix if possible - -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime - -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols - -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) - -export-symbols SYMFILE - try to export only the symbols listed in SYMFILE - -export-symbols-regex REGEX - try to export only the symbols matching REGEX - -LLIBDIR search LIBDIR for required installed libraries - -lNAME OUTPUT-FILE requires the installed library libNAME - -module build a library that can dlopened - -no-fast-install disable the fast-install mode - -no-install link a not-installable executable - -no-undefined declare that a library does not refer to external symbols - -o OUTPUT-FILE create OUTPUT-FILE from the specified objects - -objectlist FILE Use a list of object files found in FILE to specify objects - -precious-files-regex REGEX - don't remove output files matching REGEX - -release RELEASE specify package release information - -rpath LIBDIR the created library will eventually be installed in LIBDIR - -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries - -static do not do any dynamic linking of libtool libraries - -version-info CURRENT[:REVISION[:AGE]] - specify library version info [each variable defaults to 0] - -All other options (arguments beginning with \`-') are ignored. - -Every other argument is treated as a filename. Files ending in \`.la' are -treated as uninstalled libtool libraries, other files are standard or library -object files. - -If the OUTPUT-FILE ends in \`.la', then a libtool library is created, -only library objects (\`.lo' files) may be specified, and \`-rpath' is -required, except when creating a convenience library. - -If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created -using \`ar' and \`ranlib', or on Windows using \`lib'. - -If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file -is created, otherwise an executable program is created." - ;; - -uninstall) - $echo \ -"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... - -Remove libraries from an installation directory. - -RM is the name of the program to use to delete files associated with each FILE -(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed -to RM. - -If FILE is a libtool library, all the files associated with it are deleted. -Otherwise, only FILE itself is deleted using RM." - ;; - -*) - $echo "$modename: invalid operation mode \`$mode'" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; -esac - -$echo -$echo "Try \`$modename --help' for more information about other modes." - -exit 0 - -# The TAGs below are defined such that we never get into a situation -# in which we disable both kinds of libraries. Given conflicting -# choices, we go for a static library, that is the most portable, -# since we can't tell whether shared libraries were disabled because -# the user asked for that or because the platform doesn't support -# them. This is particularly important on AIX, because we don't -# support having both static and shared libraries enabled at the same -# time on that platform, so we default to a shared-only configuration. -# If a disable-shared tag is given, we'll fallback to a static-only -# configuration. But we'll never go from static-only to shared-only. - -# ### BEGIN LIBTOOL TAG CONFIG: disable-shared -build_libtool_libs=no -build_old_libs=yes -# ### END LIBTOOL TAG CONFIG: disable-shared - -# ### BEGIN LIBTOOL TAG CONFIG: disable-static -build_old_libs=`case $build_libtool_libs in yes) $echo no;; *) $echo yes;; esac` -# ### END LIBTOOL TAG CONFIG: disable-static - -# Local Variables: -# mode:shell-script -# sh-indentation:2 -# End: diff --git a/code/libmad-0.15.1b/mad.h.sed b/code/libmad-0.15.1b/mad.h.sed deleted file mode 100644 index 70287854..00000000 --- a/code/libmad-0.15.1b/mad.h.sed +++ /dev/null @@ -1,36 +0,0 @@ -# -# 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 -# -# $Id: mad.h.sed,v 1.9 2004/01/23 09:41:32 rob Exp $ -# - -/^\/\*$/{ -N -s/ \* libmad - /&/ -t copy -b next -: copy -g -n -s|^ \* \$\(Id: .*\) \$$|/* \1 */|p -/^ \*\/$/d -b copy -} -/^# *include "/d -: next -p diff --git a/code/libmad-0.15.1b/missing b/code/libmad-0.15.1b/missing deleted file mode 100644 index 6a37006e..00000000 --- a/code/libmad-0.15.1b/missing +++ /dev/null @@ -1,336 +0,0 @@ -#! /bin/sh -# Common stub for a few missing GNU programs while installing. -# Copyright (C) 1996, 1997, 1999, 2000, 2002 Free Software Foundation, Inc. -# Originally by Fran,cois Pinard , 1996. - -# 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, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. - -# 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. - -if test $# -eq 0; then - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 -fi - -run=: - -# In the cases where this matters, `missing' is being run in the -# srcdir already. -if test -f configure.ac; then - configure_ac=configure.ac -else - configure_ac=configure.in -fi - -case "$1" in ---run) - # Try to run requested program, and just exit if it succeeds. - run= - shift - "$@" && exit 0 - ;; -esac - -# If it does not exist, or fails to run (possibly an outdated version), -# try to emulate it. -case "$1" in - - -h|--h|--he|--hel|--help) - echo "\ -$0 [OPTION]... PROGRAM [ARGUMENT]... - -Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an -error status if there is no known handling for PROGRAM. - -Options: - -h, --help display this help and exit - -v, --version output version information and exit - --run try to run the given command, and emulate it if it fails - -Supported PROGRAM values: - aclocal touch file \`aclocal.m4' - autoconf touch file \`configure' - autoheader touch file \`config.h.in' - automake touch all \`Makefile.in' files - bison create \`y.tab.[ch]', if possible, from existing .[ch] - flex create \`lex.yy.c', if possible, from existing .c - help2man touch the output file - lex create \`lex.yy.c', if possible, from existing .c - makeinfo touch the output file - tar try tar, gnutar, gtar, then tar without non-portable flags - yacc create \`y.tab.[ch]', if possible, from existing .[ch]" - ;; - - -v|--v|--ve|--ver|--vers|--versi|--versio|--version) - echo "missing 0.4 - GNU automake" - ;; - - -*) - echo 1>&2 "$0: Unknown \`$1' option" - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 - ;; - - aclocal*) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - fi - - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`acinclude.m4' or \`${configure_ac}'. You might want - to install the \`Automake' and \`Perl' packages. Grab them from - any GNU archive site." - touch aclocal.m4 - ;; - - autoconf) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - fi - - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`${configure_ac}'. You might want to install the - \`Autoconf' and \`GNU m4' packages. Grab them from any GNU - archive site." - touch configure - ;; - - autoheader) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - fi - - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`acconfig.h' or \`${configure_ac}'. You might want - to install the \`Autoconf' and \`GNU m4' packages. Grab them - from any GNU archive site." - files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` - test -z "$files" && files="config.h" - touch_files= - for f in $files; do - case "$f" in - *:*) touch_files="$touch_files "`echo "$f" | - sed -e 's/^[^:]*://' -e 's/:.*//'`;; - *) touch_files="$touch_files $f.in";; - esac - done - touch $touch_files - ;; - - automake*) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - fi - - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. - You might want to install the \`Automake' and \`Perl' packages. - Grab them from any GNU archive site." - find . -type f -name Makefile.am -print | - sed 's/\.am$/.in/' | - while read f; do touch "$f"; done - ;; - - autom4te) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - fi - - echo 1>&2 "\ -WARNING: \`$1' is needed, and you do not seem to have it handy on your - system. You might have modified some files without having the - proper tools for further handling them. - You can get \`$1Help2man' as part of \`Autoconf' from any GNU - archive site." - - file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'` - test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'` - if test -f "$file"; then - touch $file - else - test -z "$file" || exec >$file - echo "#! /bin/sh" - echo "# Created by GNU Automake missing as a replacement of" - echo "# $ $@" - echo "exit 0" - chmod +x $file - exit 1 - fi - ;; - - bison|yacc) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a \`.y' file. You may need the \`Bison' package - in order for those modifications to take effect. You can get - \`Bison' from any GNU archive site." - rm -f y.tab.c y.tab.h - if [ $# -ne 1 ]; then - eval LASTARG="\${$#}" - case "$LASTARG" in - *.y) - SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" y.tab.c - fi - SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" y.tab.h - fi - ;; - esac - fi - if [ ! -f y.tab.h ]; then - echo >y.tab.h - fi - if [ ! -f y.tab.c ]; then - echo 'main() { return 0; }' >y.tab.c - fi - ;; - - lex|flex) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a \`.l' file. You may need the \`Flex' package - in order for those modifications to take effect. You can get - \`Flex' from any GNU archive site." - rm -f lex.yy.c - if [ $# -ne 1 ]; then - eval LASTARG="\${$#}" - case "$LASTARG" in - *.l) - SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" lex.yy.c - fi - ;; - esac - fi - if [ ! -f lex.yy.c ]; then - echo 'main() { return 0; }' >lex.yy.c - fi - ;; - - help2man) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - fi - - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a dependency of a manual page. You may need the - \`Help2man' package in order for those modifications to take - effect. You can get \`Help2man' from any GNU archive site." - - file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` - if test -z "$file"; then - file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` - fi - if [ -f "$file" ]; then - touch $file - else - test -z "$file" || exec >$file - echo ".ab help2man is required to generate this page" - exit 1 - fi - ;; - - makeinfo) - if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then - # We have makeinfo, but it failed. - exit 1 - fi - - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a \`.texi' or \`.texinfo' file, or any other file - indirectly affecting the aspect of the manual. The spurious - call might also be the consequence of using a buggy \`make' (AIX, - DU, IRIX). You might want to install the \`Texinfo' package or - the \`GNU make' package. Grab either from any GNU archive site." - file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` - if test -z "$file"; then - file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` - file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` - fi - touch $file - ;; - - tar) - shift - if test -n "$run"; then - echo 1>&2 "ERROR: \`tar' requires --run" - exit 1 - fi - - # We have already tried tar in the generic part. - # Look for gnutar/gtar before invocation to avoid ugly error - # messages. - if (gnutar --version > /dev/null 2>&1); then - gnutar "$@" && exit 0 - fi - if (gtar --version > /dev/null 2>&1); then - gtar "$@" && exit 0 - fi - firstarg="$1" - if shift; then - case "$firstarg" in - *o*) - firstarg=`echo "$firstarg" | sed s/o//` - tar "$firstarg" "$@" && exit 0 - ;; - esac - case "$firstarg" in - *h*) - firstarg=`echo "$firstarg" | sed s/h//` - tar "$firstarg" "$@" && exit 0 - ;; - esac - fi - - echo 1>&2 "\ -WARNING: I can't seem to be able to run \`tar' with the given arguments. - You may want to install GNU tar or Free paxutils, or check the - command line arguments." - exit 1 - ;; - - *) - echo 1>&2 "\ -WARNING: \`$1' is needed, and you do not seem to have it handy on your - system. You might have modified some files without having the - proper tools for further handling them. Check the \`README' file, - it often tells you about the needed prerequirements for installing - this package. You may also peek at any GNU archive site, in case - some other package would contain this missing \`$1' program." - exit 1 - ;; -esac - -exit 0 diff --git a/code/libmad-0.15.1b/mkinstalldirs b/code/libmad-0.15.1b/mkinstalldirs deleted file mode 100644 index d2d5f21b..00000000 --- a/code/libmad-0.15.1b/mkinstalldirs +++ /dev/null @@ -1,111 +0,0 @@ -#! /bin/sh -# mkinstalldirs --- make directory hierarchy -# Author: Noah Friedman -# Created: 1993-05-16 -# Public domain - -errstatus=0 -dirmode="" - -usage="\ -Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..." - -# process command line arguments -while test $# -gt 0 ; do - case $1 in - -h | --help | --h*) # -h for help - echo "$usage" 1>&2 - exit 0 - ;; - -m) # -m PERM arg - shift - test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } - dirmode=$1 - shift - ;; - --) # stop option processing - shift - break - ;; - -*) # unknown option - echo "$usage" 1>&2 - exit 1 - ;; - *) # first non-opt arg - break - ;; - esac -done - -for file -do - if test -d "$file"; then - shift - else - break - fi -done - -case $# in - 0) exit 0 ;; -esac - -case $dirmode in - '') - if mkdir -p -- . 2>/dev/null; then - echo "mkdir -p -- $*" - exec mkdir -p -- "$@" - fi - ;; - *) - if mkdir -m "$dirmode" -p -- . 2>/dev/null; then - echo "mkdir -m $dirmode -p -- $*" - exec mkdir -m "$dirmode" -p -- "$@" - fi - ;; -esac - -for file -do - set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` - shift - - pathcomp= - for d - do - pathcomp="$pathcomp$d" - case $pathcomp in - -*) pathcomp=./$pathcomp ;; - esac - - if test ! -d "$pathcomp"; then - echo "mkdir $pathcomp" - - mkdir "$pathcomp" || lasterr=$? - - if test ! -d "$pathcomp"; then - errstatus=$lasterr - else - if test ! -z "$dirmode"; then - echo "chmod $dirmode $pathcomp" - lasterr="" - chmod "$dirmode" "$pathcomp" || lasterr=$? - - if test ! -z "$lasterr"; then - errstatus=$lasterr - fi - fi - fi - fi - - pathcomp="$pathcomp/" - done -done - -exit $errstatus - -# Local Variables: -# mode: shell-script -# sh-indentation: 2 -# End: -# mkinstalldirs ends here diff --git a/code/libmad-0.15.1b/msvc++/Makefile.am b/code/libmad-0.15.1b/msvc++/Makefile.am deleted file mode 100644 index 96865c7f..00000000 --- a/code/libmad-0.15.1b/msvc++/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -## -## 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 -## -## $Id: Makefile.am,v 1.3 2004/01/23 09:41:33 rob Exp $ -## - -## Process this file with automake to produce Makefile.in - -EXTRA_DIST = mad.h config.h libmad.dsp diff --git a/code/libmad-0.15.1b/msvc++/Makefile.in b/code/libmad-0.15.1b/msvc++/Makefile.in deleted file mode 100644 index eaeb8634..00000000 --- a/code/libmad-0.15.1b/msvc++/Makefile.in +++ /dev/null @@ -1,312 +0,0 @@ -# Makefile.in generated by automake 1.8.2 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004 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. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -top_builddir = .. -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -INSTALL = @INSTALL@ -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -host_triplet = @host@ -subdir = msvc++ -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -SOURCES = -DIST_SOURCES = -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AMDEP_FALSE = @AMDEP_FALSE@ -AMDEP_TRUE = @AMDEP_TRUE@ -AMTAR = @AMTAR@ -AR = @AR@ -ASO = @ASO@ -ASO_OBJS = @ASO_OBJS@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCAS = @CCAS@ -CCASFLAGS = @CCASFLAGS@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -ECHO = @ECHO@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -F77 = @F77@ -FFLAGS = @FFLAGS@ -FPM = @FPM@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LIBTOOL_DEPS = @LIBTOOL_DEPS@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -RANLIB = @RANLIB@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_F77 = @ac_ct_F77@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -ac_ct_STRIP = @ac_ct_STRIP@ -am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ -am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ -am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ -am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -datadir = @datadir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -EXTRA_DIST = mad.h config.h libmad.dsp -all: all-am - -.SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign msvc++/Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --foreign msvc++/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -distclean-libtool: - -rm -f libtool -uninstall-info-am: -tags: TAGS -TAGS: - -ctags: CTAGS -CTAGS: - - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ - list='$(DISTFILES)'; for file in $$list; do \ - case $$file in \ - $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ - $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ - esac; \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test "$$dir" != "$$file" && test "$$dir" != "."; then \ - dir="/$$dir"; \ - $(mkdir_p) "$(distdir)$$dir"; \ - else \ - dir=''; \ - fi; \ - if test -d $$d/$$file; then \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-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 -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -rm -f $(CONFIG_CLEAN_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool mostlyclean-am - -distclean: distclean-am - -rm -f Makefile -distclean-am: clean-am distclean-generic distclean-libtool - -dvi: dvi-am - -dvi-am: - -html: html-am - -info: info-am - -info-am: - -install-data-am: - -install-exec-am: - -install-info: install-info-am - -install-man: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-generic mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-info-am - -.PHONY: all all-am check check-am clean clean-generic clean-libtool \ - distclean distclean-generic distclean-libtool distdir dvi \ - dvi-am html html-am info info-am install install-am \ - install-data install-data-am install-exec install-exec-am \ - install-info install-info-am install-man install-strip \ - installcheck installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am \ - uninstall-info-am - -# 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. -.NOEXPORT: diff --git a/code/libmad-0.15.1b/msvc++/config.h b/code/libmad-0.15.1b/msvc++/config.h deleted file mode 100644 index 02683a5f..00000000 --- a/code/libmad-0.15.1b/msvc++/config.h +++ /dev/null @@ -1,130 +0,0 @@ -/* config.h. Generated by configure. */ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define to enable diagnostic debugging support. */ -/* #undef DEBUG */ - -/* Define to enable experimental code. */ -/* #undef EXPERIMENTAL */ - -/* Define to 1 if you have the header file. */ -#define HAVE_ASSERT_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_DLFCN_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_ERRNO_H 1 - -/* Define to 1 if you have the `fcntl' function. */ -/* #undef HAVE_FCNTL */ - -/* Define to 1 if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define to 1 if you have the `fork' function. */ -/* #undef HAVE_FORK */ - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_LIMITS_H 1 - -/* Define if your MIPS CPU supports a 2-operand MADD16 instruction. */ -/* #undef HAVE_MADD16_ASM */ - -/* Define if your MIPS CPU supports a 2-operand MADD instruction. */ -/* #undef HAVE_MADD_ASM */ - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have the `pipe' function. */ -/* #undef HAVE_PIPE */ - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have that is POSIX.1 compatible. */ -/* #undef HAVE_SYS_WAIT_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_UNISTD_H */ - -/* Define to 1 if you have the `waitpid' function. */ -/* #undef HAVE_WAITPID */ - -/* Define to disable debugging assertions. */ -/* #undef NDEBUG */ - -/* Define to optimize for accuracy over speed. */ -/* #undef OPT_ACCURACY */ - -/* Define to optimize for speed over accuracy. */ -/* #undef OPT_SPEED */ - -/* Define to enable a fast subband synthesis approximation optimization. */ -/* #undef OPT_SSO */ - -/* Define to influence a strict interpretation of the ISO/IEC standards, even - if this is in opposition with best accepted practices. */ -/* #undef OPT_STRICT */ - -/* Name of package */ -#define PACKAGE "libmad" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "support@underbit.com" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "MPEG Audio Decoder" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "MPEG Audio Decoder 0.15.1b" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "libmad" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "0.15.1b" - -/* The size of a `int', as computed by sizeof. */ -#define SIZEOF_INT 4 - -/* The size of a `long', as computed by sizeof. */ -#define SIZEOF_LONG 4 - -/* The size of a `long long', as computed by sizeof. */ -#define SIZEOF_LONG_LONG 8 - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Version number of package */ -#define VERSION "0.15.1b" - -/* Define to empty if `const' does not conform to ANSI C. */ -/* #undef const */ - -/* Define as `__inline' if that's what the C compiler calls it, or to nothing - if it is not supported. */ -#define inline __inline - -/* Define to `int' if does not define. */ -/* #undef pid_t */ diff --git a/code/libmad-0.15.1b/msvc++/libmad.dsp b/code/libmad-0.15.1b/msvc++/libmad.dsp deleted file mode 100644 index faf83132..00000000 --- a/code/libmad-0.15.1b/msvc++/libmad.dsp +++ /dev/null @@ -1,214 +0,0 @@ -# Microsoft Developer Studio Project File - Name="libmad" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=libmad - 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 "libmad.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 "libmad.mak" CFG="libmad - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "libmad - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "libmad - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "libmad - 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 "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /GX /O2 /I "." /D "NDEBUG" /D "FPM_INTEL" /D "WIN32" /D "_MBCS" /D "_LIB" /D "HAVE_CONFIG_H" /D "ASO_ZEROCHECK" /FD /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ELSEIF "$(CFG)" == "libmad - 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 "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /Gm /GX /ZI /Od /I "." /D "FPM_DEFAULT" /D "_LIB" /D "HAVE_CONFIG_H" /D "ASO_ZEROCHECK" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "DEBUG" /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ENDIF - -# Begin Target - -# Name "libmad - Win32 Release" -# Name "libmad - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "c" -# Begin Source File - -SOURCE=..\bit.c -# End Source File -# Begin Source File - -SOURCE=..\decoder.c -# End Source File -# Begin Source File - -SOURCE=..\fixed.c -# End Source File -# Begin Source File - -SOURCE=..\frame.c -# End Source File -# Begin Source File - -SOURCE=..\huffman.c -# End Source File -# Begin Source File - -SOURCE=..\layer12.c -# End Source File -# Begin Source File - -SOURCE=..\layer3.c -# End Source File -# Begin Source File - -SOURCE=..\stream.c -# End Source File -# Begin Source File - -SOURCE=..\synth.c -# End Source File -# Begin Source File - -SOURCE=..\timer.c -# End Source File -# Begin Source File - -SOURCE=..\version.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h" -# Begin Source File - -SOURCE=..\bit.h -# End Source File -# Begin Source File - -SOURCE=.\config.h -# End Source File -# Begin Source File - -SOURCE=..\decoder.h -# End Source File -# Begin Source File - -SOURCE=..\fixed.h -# End Source File -# Begin Source File - -SOURCE=..\frame.h -# End Source File -# Begin Source File - -SOURCE=..\global.h -# End Source File -# Begin Source File - -SOURCE=..\huffman.h -# End Source File -# Begin Source File - -SOURCE=..\layer12.h -# End Source File -# Begin Source File - -SOURCE=..\layer3.h -# End Source File -# Begin Source File - -SOURCE=..\stream.h -# End Source File -# Begin Source File - -SOURCE=..\synth.h -# End Source File -# Begin Source File - -SOURCE=..\timer.h -# End Source File -# Begin Source File - -SOURCE=..\version.h -# End Source File -# End Group -# Begin Group "Data Files" - -# PROP Default_Filter "dat" -# Begin Source File - -SOURCE=..\D.dat -# End Source File -# Begin Source File - -SOURCE=..\imdct_s.dat -# End Source File -# Begin Source File - -SOURCE=..\qc_table.dat -# End Source File -# Begin Source File - -SOURCE=..\rq_table.dat -# End Source File -# Begin Source File - -SOURCE=..\sf_table.dat -# End Source File -# End Group -# End Target -# End Project diff --git a/code/libmad-0.15.1b/msvc++/mad.h b/code/libmad-0.15.1b/msvc++/mad.h deleted file mode 100644 index d4834785..00000000 --- a/code/libmad-0.15.1b/msvc++/mad.h +++ /dev/null @@ -1,948 +0,0 @@ -/* - * 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. - */ - -# ifdef __cplusplus -extern "C" { -# endif - -# define FPM_INTEL - - - -# define SIZEOF_INT 4 -# define SIZEOF_LONG 4 -# define SIZEOF_LONG_LONG 8 - - -/* Id: version.h,v 1.24 2003/05/27 22:40:37 rob Exp */ - -# ifndef LIBMAD_VERSION_H -# define LIBMAD_VERSION_H - -# define MAD_VERSION_MAJOR 0 -# define MAD_VERSION_MINOR 15 -# define MAD_VERSION_PATCH 1 -# define MAD_VERSION_EXTRA " (beta)" - -# define MAD_VERSION_STRINGIZE(str) #str -# define MAD_VERSION_STRING(num) MAD_VERSION_STRINGIZE(num) - -# define MAD_VERSION MAD_VERSION_STRING(MAD_VERSION_MAJOR) "." \ - MAD_VERSION_STRING(MAD_VERSION_MINOR) "." \ - MAD_VERSION_STRING(MAD_VERSION_PATCH) \ - MAD_VERSION_EXTRA - -# define MAD_PUBLISHYEAR "2000-2003" -# define MAD_AUTHOR "Underbit Technologies, Inc." -# define MAD_EMAIL "info@underbit.com" - -extern char const mad_version[]; -extern char const mad_copyright[]; -extern char const mad_author[]; -extern char const mad_build[]; - -# endif - -/* Id: fixed.h,v 1.36 2003/05/28 04:36:00 rob Exp */ - -# ifndef LIBMAD_FIXED_H -# define LIBMAD_FIXED_H - -# if SIZEOF_INT >= 4 -typedef signed int mad_fixed_t; - -typedef signed int mad_fixed64hi_t; -typedef unsigned int mad_fixed64lo_t; -# else -typedef signed long mad_fixed_t; - -typedef signed long mad_fixed64hi_t; -typedef unsigned long mad_fixed64lo_t; -# endif - -# if defined(_MSC_VER) -# define mad_fixed64_t signed __int64 -# elif 1 || defined(__GNUC__) -# define mad_fixed64_t signed long long -# endif - -# if defined(FPM_FLOAT) -typedef double mad_sample_t; -# else -typedef mad_fixed_t mad_sample_t; -# endif - -/* - * Fixed-point format: 0xABBBBBBB - * A == whole part (sign + 3 bits) - * B == fractional part (28 bits) - * - * Values are signed two's complement, so the effective range is: - * 0x80000000 to 0x7fffffff - * -8.0 to +7.9999999962747097015380859375 - * - * The smallest representable value is: - * 0x00000001 == 0.0000000037252902984619140625 (i.e. about 3.725e-9) - * - * 28 bits of fractional accuracy represent about - * 8.6 digits of decimal accuracy. - * - * Fixed-point numbers can be added or subtracted as normal - * integers, but multiplication requires shifting the 64-bit result - * from 56 fractional bits back to 28 (and rounding.) - * - * Changing the definition of MAD_F_FRACBITS is only partially - * supported, and must be done with care. - */ - -# define MAD_F_FRACBITS 28 - -# if MAD_F_FRACBITS == 28 -# define MAD_F(x) ((mad_fixed_t) (x##L)) -# else -# if MAD_F_FRACBITS < 28 -# warning "MAD_F_FRACBITS < 28" -# define MAD_F(x) ((mad_fixed_t) \ - (((x##L) + \ - (1L << (28 - MAD_F_FRACBITS - 1))) >> \ - (28 - MAD_F_FRACBITS))) -# elif MAD_F_FRACBITS > 28 -# error "MAD_F_FRACBITS > 28 not currently supported" -# define MAD_F(x) ((mad_fixed_t) \ - ((x##L) << (MAD_F_FRACBITS - 28))) -# endif -# endif - -# define MAD_F_MIN ((mad_fixed_t) -0x80000000L) -# define MAD_F_MAX ((mad_fixed_t) +0x7fffffffL) - -# define MAD_F_ONE MAD_F(0x10000000) - -# define mad_f_tofixed(x) ((mad_fixed_t) \ - ((x) * (double) (1L << MAD_F_FRACBITS) + 0.5)) -# define mad_f_todouble(x) ((double) \ - ((x) / (double) (1L << MAD_F_FRACBITS))) - -# define mad_f_intpart(x) ((x) >> MAD_F_FRACBITS) -# define mad_f_fracpart(x) ((x) & ((1L << MAD_F_FRACBITS) - 1)) - /* (x should be positive) */ - -# define mad_f_fromint(x) ((x) << MAD_F_FRACBITS) - -# define mad_f_add(x, y) ((x) + (y)) -# define mad_f_sub(x, y) ((x) - (y)) - -# if defined(FPM_FLOAT) -# error "FPM_FLOAT not yet supported" - -# undef MAD_F -# define MAD_F(x) mad_f_todouble(x) - -# define mad_f_mul(x, y) ((x) * (y)) -# define mad_f_scale64 - -# undef ASO_ZEROCHECK - -# elif defined(FPM_64BIT) - -/* - * This version should be the most accurate if 64-bit types are supported by - * the compiler, although it may not be the most efficient. - */ -# if defined(OPT_ACCURACY) -# define mad_f_mul(x, y) \ - ((mad_fixed_t) \ - ((((mad_fixed64_t) (x) * (y)) + \ - (1L << (MAD_F_SCALEBITS - 1))) >> MAD_F_SCALEBITS)) -# else -# define mad_f_mul(x, y) \ - ((mad_fixed_t) (((mad_fixed64_t) (x) * (y)) >> MAD_F_SCALEBITS)) -# endif - -# define MAD_F_SCALEBITS MAD_F_FRACBITS - -/* --- Intel --------------------------------------------------------------- */ - -# elif defined(FPM_INTEL) - -# if defined(_MSC_VER) -# pragma warning(push) -# pragma warning(disable: 4035) /* no return value */ -static __forceinline -mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y) -{ - enum { - fracbits = MAD_F_FRACBITS - }; - - __asm { - mov eax, x - imul y - shrd eax, edx, fracbits - } - - /* implicit return of eax */ -} -# pragma warning(pop) - -# define mad_f_mul mad_f_mul_inline -# define mad_f_scale64 -# else -/* - * This Intel version is fast and accurate; the disposition of the least - * significant bit depends on OPT_ACCURACY via mad_f_scale64(). - */ -# define MAD_F_MLX(hi, lo, x, y) \ - asm ("imull %3" \ - : "=a" (lo), "=d" (hi) \ - : "%a" (x), "rm" (y) \ - : "cc") - -# if defined(OPT_ACCURACY) -/* - * This gives best accuracy but is not very fast. - */ -# define MAD_F_MLA(hi, lo, x, y) \ - ({ mad_fixed64hi_t __hi; \ - mad_fixed64lo_t __lo; \ - MAD_F_MLX(__hi, __lo, (x), (y)); \ - asm ("addl %2,%0\n\t" \ - "adcl %3,%1" \ - : "=rm" (lo), "=rm" (hi) \ - : "r" (__lo), "r" (__hi), "0" (lo), "1" (hi) \ - : "cc"); \ - }) -# endif /* OPT_ACCURACY */ - -# if defined(OPT_ACCURACY) -/* - * Surprisingly, this is faster than SHRD followed by ADC. - */ -# define mad_f_scale64(hi, lo) \ - ({ mad_fixed64hi_t __hi_; \ - mad_fixed64lo_t __lo_; \ - mad_fixed_t __result; \ - asm ("addl %4,%2\n\t" \ - "adcl %5,%3" \ - : "=rm" (__lo_), "=rm" (__hi_) \ - : "0" (lo), "1" (hi), \ - "ir" (1L << (MAD_F_SCALEBITS - 1)), "ir" (0) \ - : "cc"); \ - asm ("shrdl %3,%2,%1" \ - : "=rm" (__result) \ - : "0" (__lo_), "r" (__hi_), "I" (MAD_F_SCALEBITS) \ - : "cc"); \ - __result; \ - }) -# else -# define mad_f_scale64(hi, lo) \ - ({ mad_fixed_t __result; \ - asm ("shrdl %3,%2,%1" \ - : "=rm" (__result) \ - : "0" (lo), "r" (hi), "I" (MAD_F_SCALEBITS) \ - : "cc"); \ - __result; \ - }) -# endif /* OPT_ACCURACY */ - -# define MAD_F_SCALEBITS MAD_F_FRACBITS -# endif - -/* --- ARM ----------------------------------------------------------------- */ - -# elif defined(FPM_ARM) - -/* - * This ARM V4 version is as accurate as FPM_64BIT but much faster. The - * least significant bit is properly rounded at no CPU cycle cost! - */ -# if 1 -/* - * This is faster than the default implementation via MAD_F_MLX() and - * mad_f_scale64(). - */ -# define mad_f_mul(x, y) \ - ({ mad_fixed64hi_t __hi; \ - mad_fixed64lo_t __lo; \ - mad_fixed_t __result; \ - asm ("smull %0, %1, %3, %4\n\t" \ - "movs %0, %0, lsr %5\n\t" \ - "adc %2, %0, %1, lsl %6" \ - : "=&r" (__lo), "=&r" (__hi), "=r" (__result) \ - : "%r" (x), "r" (y), \ - "M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \ - : "cc"); \ - __result; \ - }) -# endif - -# define MAD_F_MLX(hi, lo, x, y) \ - asm ("smull %0, %1, %2, %3" \ - : "=&r" (lo), "=&r" (hi) \ - : "%r" (x), "r" (y)) - -# define MAD_F_MLA(hi, lo, x, y) \ - asm ("smlal %0, %1, %2, %3" \ - : "+r" (lo), "+r" (hi) \ - : "%r" (x), "r" (y)) - -# define MAD_F_MLN(hi, lo) \ - asm ("rsbs %0, %2, #0\n\t" \ - "rsc %1, %3, #0" \ - : "=r" (lo), "=r" (hi) \ - : "0" (lo), "1" (hi) \ - : "cc") - -# define mad_f_scale64(hi, lo) \ - ({ mad_fixed_t __result; \ - asm ("movs %0, %1, lsr %3\n\t" \ - "adc %0, %0, %2, lsl %4" \ - : "=&r" (__result) \ - : "r" (lo), "r" (hi), \ - "M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \ - : "cc"); \ - __result; \ - }) - -# define MAD_F_SCALEBITS MAD_F_FRACBITS - -/* --- MIPS ---------------------------------------------------------------- */ - -# elif defined(FPM_MIPS) - -/* - * This MIPS version is fast and accurate; the disposition of the least - * significant bit depends on OPT_ACCURACY via mad_f_scale64(). - */ -# define MAD_F_MLX(hi, lo, x, y) \ - asm ("mult %2,%3" \ - : "=l" (lo), "=h" (hi) \ - : "%r" (x), "r" (y)) - -# if defined(HAVE_MADD_ASM) -# define MAD_F_MLA(hi, lo, x, y) \ - asm ("madd %2,%3" \ - : "+l" (lo), "+h" (hi) \ - : "%r" (x), "r" (y)) -# elif defined(HAVE_MADD16_ASM) -/* - * This loses significant accuracy due to the 16-bit integer limit in the - * multiply/accumulate instruction. - */ -# define MAD_F_ML0(hi, lo, x, y) \ - asm ("mult %2,%3" \ - : "=l" (lo), "=h" (hi) \ - : "%r" ((x) >> 12), "r" ((y) >> 16)) -# define MAD_F_MLA(hi, lo, x, y) \ - asm ("madd16 %2,%3" \ - : "+l" (lo), "+h" (hi) \ - : "%r" ((x) >> 12), "r" ((y) >> 16)) -# define MAD_F_MLZ(hi, lo) ((mad_fixed_t) (lo)) -# endif - -# if defined(OPT_SPEED) -# define mad_f_scale64(hi, lo) \ - ((mad_fixed_t) ((hi) << (32 - MAD_F_SCALEBITS))) -# define MAD_F_SCALEBITS MAD_F_FRACBITS -# endif - -/* --- SPARC --------------------------------------------------------------- */ - -# elif defined(FPM_SPARC) - -/* - * This SPARC V8 version is fast and accurate; the disposition of the least - * significant bit depends on OPT_ACCURACY via mad_f_scale64(). - */ -# define MAD_F_MLX(hi, lo, x, y) \ - asm ("smul %2, %3, %0\n\t" \ - "rd %%y, %1" \ - : "=r" (lo), "=r" (hi) \ - : "%r" (x), "rI" (y)) - -/* --- PowerPC ------------------------------------------------------------- */ - -# elif defined(FPM_PPC) - -/* - * This PowerPC version is fast and accurate; the disposition of the least - * significant bit depends on OPT_ACCURACY via mad_f_scale64(). - */ -# define MAD_F_MLX(hi, lo, x, y) \ - do { \ - asm ("mullw %0,%1,%2" \ - : "=r" (lo) \ - : "%r" (x), "r" (y)); \ - asm ("mulhw %0,%1,%2" \ - : "=r" (hi) \ - : "%r" (x), "r" (y)); \ - } \ - while (0) - -# if defined(OPT_ACCURACY) -/* - * This gives best accuracy but is not very fast. - */ -# define MAD_F_MLA(hi, lo, x, y) \ - ({ mad_fixed64hi_t __hi; \ - mad_fixed64lo_t __lo; \ - MAD_F_MLX(__hi, __lo, (x), (y)); \ - asm ("addc %0,%2,%3\n\t" \ - "adde %1,%4,%5" \ - : "=r" (lo), "=r" (hi) \ - : "%r" (lo), "r" (__lo), \ - "%r" (hi), "r" (__hi) \ - : "xer"); \ - }) -# endif - -# if defined(OPT_ACCURACY) -/* - * This is slower than the truncating version below it. - */ -# define mad_f_scale64(hi, lo) \ - ({ mad_fixed_t __result, __round; \ - asm ("rotrwi %0,%1,%2" \ - : "=r" (__result) \ - : "r" (lo), "i" (MAD_F_SCALEBITS)); \ - asm ("extrwi %0,%1,1,0" \ - : "=r" (__round) \ - : "r" (__result)); \ - asm ("insrwi %0,%1,%2,0" \ - : "+r" (__result) \ - : "r" (hi), "i" (MAD_F_SCALEBITS)); \ - asm ("add %0,%1,%2" \ - : "=r" (__result) \ - : "%r" (__result), "r" (__round)); \ - __result; \ - }) -# else -# define mad_f_scale64(hi, lo) \ - ({ mad_fixed_t __result; \ - asm ("rotrwi %0,%1,%2" \ - : "=r" (__result) \ - : "r" (lo), "i" (MAD_F_SCALEBITS)); \ - asm ("insrwi %0,%1,%2,0" \ - : "+r" (__result) \ - : "r" (hi), "i" (MAD_F_SCALEBITS)); \ - __result; \ - }) -# endif - -# define MAD_F_SCALEBITS MAD_F_FRACBITS - -/* --- Default ------------------------------------------------------------- */ - -# elif defined(FPM_DEFAULT) - -/* - * This version is the most portable but it loses significant accuracy. - * Furthermore, accuracy is biased against the second argument, so care - * should be taken when ordering operands. - * - * The scale factors are constant as this is not used with SSO. - * - * Pre-rounding is required to stay within the limits of compliance. - */ -# if defined(OPT_SPEED) -# define mad_f_mul(x, y) (((x) >> 12) * ((y) >> 16)) -# else -# define mad_f_mul(x, y) ((((x) + (1L << 11)) >> 12) * \ - (((y) + (1L << 15)) >> 16)) -# endif - -/* ------------------------------------------------------------------------- */ - -# else -# error "no FPM selected" -# endif - -/* default implementations */ - -# if !defined(mad_f_mul) -# define mad_f_mul(x, y) \ - ({ register mad_fixed64hi_t __hi; \ - register mad_fixed64lo_t __lo; \ - MAD_F_MLX(__hi, __lo, (x), (y)); \ - mad_f_scale64(__hi, __lo); \ - }) -# endif - -# if !defined(MAD_F_MLA) -# define MAD_F_ML0(hi, lo, x, y) ((lo) = mad_f_mul((x), (y))) -# define MAD_F_MLA(hi, lo, x, y) ((lo) += mad_f_mul((x), (y))) -# define MAD_F_MLN(hi, lo) ((lo) = -(lo)) -# define MAD_F_MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo)) -# endif - -# if !defined(MAD_F_ML0) -# define MAD_F_ML0(hi, lo, x, y) MAD_F_MLX((hi), (lo), (x), (y)) -# endif - -# if !defined(MAD_F_MLN) -# define MAD_F_MLN(hi, lo) ((hi) = ((lo) = -(lo)) ? ~(hi) : -(hi)) -# endif - -# if !defined(MAD_F_MLZ) -# define MAD_F_MLZ(hi, lo) mad_f_scale64((hi), (lo)) -# endif - -# if !defined(mad_f_scale64) -# if defined(OPT_ACCURACY) -# define mad_f_scale64(hi, lo) \ - ((((mad_fixed_t) \ - (((hi) << (32 - (MAD_F_SCALEBITS - 1))) | \ - ((lo) >> (MAD_F_SCALEBITS - 1)))) + 1) >> 1) -# else -# define mad_f_scale64(hi, lo) \ - ((mad_fixed_t) \ - (((hi) << (32 - MAD_F_SCALEBITS)) | \ - ((lo) >> MAD_F_SCALEBITS))) -# endif -# define MAD_F_SCALEBITS MAD_F_FRACBITS -# endif - -/* C routines */ - -mad_fixed_t mad_f_abs(mad_fixed_t); -mad_fixed_t mad_f_div(mad_fixed_t, mad_fixed_t); - -# endif - -/* Id: bit.h,v 1.11 2003/05/27 22:40:36 rob Exp */ - -# ifndef LIBMAD_BIT_H -# define LIBMAD_BIT_H - -struct mad_bitptr { - unsigned char const *byte; - unsigned short cache; - unsigned short left; -}; - -void mad_bit_init(struct mad_bitptr *, unsigned char const *); - -# define mad_bit_finish(bitptr) /* nothing */ - -unsigned int mad_bit_length(struct mad_bitptr const *, - struct mad_bitptr const *); - -# define mad_bit_bitsleft(bitptr) ((bitptr)->left) -unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *); - -void mad_bit_skip(struct mad_bitptr *, unsigned int); -unsigned long mad_bit_read(struct mad_bitptr *, unsigned int); -void mad_bit_write(struct mad_bitptr *, unsigned int, unsigned long); - -unsigned short mad_bit_crc(struct mad_bitptr, unsigned int, unsigned short); - -# endif - -/* Id: timer.h,v 1.15 2003/05/27 22:40:37 rob Exp */ - -# ifndef LIBMAD_TIMER_H -# define LIBMAD_TIMER_H - -typedef struct { - signed long seconds; /* whole seconds */ - unsigned long fraction; /* 1/MAD_TIMER_RESOLUTION seconds */ -} mad_timer_t; - -extern mad_timer_t const mad_timer_zero; - -# define MAD_TIMER_RESOLUTION 352800000UL - -enum mad_units { - MAD_UNITS_HOURS = -2, - MAD_UNITS_MINUTES = -1, - MAD_UNITS_SECONDS = 0, - - /* metric units */ - - MAD_UNITS_DECISECONDS = 10, - MAD_UNITS_CENTISECONDS = 100, - MAD_UNITS_MILLISECONDS = 1000, - - /* audio sample units */ - - MAD_UNITS_8000_HZ = 8000, - MAD_UNITS_11025_HZ = 11025, - MAD_UNITS_12000_HZ = 12000, - - MAD_UNITS_16000_HZ = 16000, - MAD_UNITS_22050_HZ = 22050, - MAD_UNITS_24000_HZ = 24000, - - MAD_UNITS_32000_HZ = 32000, - MAD_UNITS_44100_HZ = 44100, - MAD_UNITS_48000_HZ = 48000, - - /* video frame/field units */ - - MAD_UNITS_24_FPS = 24, - MAD_UNITS_25_FPS = 25, - MAD_UNITS_30_FPS = 30, - MAD_UNITS_48_FPS = 48, - MAD_UNITS_50_FPS = 50, - MAD_UNITS_60_FPS = 60, - - /* CD audio frames */ - - MAD_UNITS_75_FPS = 75, - - /* video drop-frame units */ - - MAD_UNITS_23_976_FPS = -24, - MAD_UNITS_24_975_FPS = -25, - MAD_UNITS_29_97_FPS = -30, - MAD_UNITS_47_952_FPS = -48, - MAD_UNITS_49_95_FPS = -50, - MAD_UNITS_59_94_FPS = -60 -}; - -# define mad_timer_reset(timer) ((void) (*(timer) = mad_timer_zero)) - -int mad_timer_compare(mad_timer_t, mad_timer_t); - -# define mad_timer_sign(timer) mad_timer_compare((timer), mad_timer_zero) - -void mad_timer_negate(mad_timer_t *); -mad_timer_t mad_timer_abs(mad_timer_t); - -void mad_timer_set(mad_timer_t *, unsigned long, unsigned long, unsigned long); -void mad_timer_add(mad_timer_t *, mad_timer_t); -void mad_timer_multiply(mad_timer_t *, signed long); - -signed long mad_timer_count(mad_timer_t, enum mad_units); -unsigned long mad_timer_fraction(mad_timer_t, unsigned long); -void mad_timer_string(mad_timer_t, char *, char const *, - enum mad_units, enum mad_units, unsigned long); - -# endif - -/* Id: stream.h,v 1.18 2003/05/27 22:40:37 rob Exp */ - -# ifndef LIBMAD_STREAM_H -# define LIBMAD_STREAM_H - - -# define MAD_BUFFER_GUARD 8 -# define MAD_BUFFER_MDLEN (511 + 2048 + MAD_BUFFER_GUARD) - -enum mad_error { - MAD_ERROR_NONE = 0x0000, /* no error */ - - MAD_ERROR_BUFLEN = 0x0001, /* input buffer too small (or EOF) */ - MAD_ERROR_BUFPTR = 0x0002, /* invalid (null) buffer pointer */ - - MAD_ERROR_NOMEM = 0x0031, /* not enough memory */ - - MAD_ERROR_LOSTSYNC = 0x0101, /* lost synchronization */ - MAD_ERROR_BADLAYER = 0x0102, /* reserved header layer value */ - MAD_ERROR_BADBITRATE = 0x0103, /* forbidden bitrate value */ - MAD_ERROR_BADSAMPLERATE = 0x0104, /* reserved sample frequency value */ - MAD_ERROR_BADEMPHASIS = 0x0105, /* reserved emphasis value */ - - MAD_ERROR_BADCRC = 0x0201, /* CRC check failed */ - MAD_ERROR_BADBITALLOC = 0x0211, /* forbidden bit allocation value */ - MAD_ERROR_BADSCALEFACTOR = 0x0221, /* bad scalefactor index */ - MAD_ERROR_BADFRAMELEN = 0x0231, /* bad frame length */ - MAD_ERROR_BADBIGVALUES = 0x0232, /* bad big_values count */ - MAD_ERROR_BADBLOCKTYPE = 0x0233, /* reserved block_type */ - MAD_ERROR_BADSCFSI = 0x0234, /* bad scalefactor selection info */ - MAD_ERROR_BADDATAPTR = 0x0235, /* bad main_data_begin pointer */ - MAD_ERROR_BADPART3LEN = 0x0236, /* bad audio data length */ - MAD_ERROR_BADHUFFTABLE = 0x0237, /* bad Huffman table select */ - MAD_ERROR_BADHUFFDATA = 0x0238, /* Huffman data overrun */ - MAD_ERROR_BADSTEREO = 0x0239 /* incompatible block_type for JS */ -}; - -# define MAD_RECOVERABLE(error) ((error) & 0xff00) - -struct mad_stream { - unsigned char const *buffer; /* input bitstream buffer */ - unsigned char const *bufend; /* end of buffer */ - unsigned long skiplen; /* bytes to skip before next frame */ - - int sync; /* stream sync found */ - unsigned long freerate; /* free bitrate (fixed) */ - - unsigned char const *this_frame; /* start of current frame */ - unsigned char const *next_frame; /* start of next frame */ - struct mad_bitptr ptr; /* current processing bit pointer */ - - struct mad_bitptr anc_ptr; /* ancillary bits pointer */ - unsigned int anc_bitlen; /* number of ancillary bits */ - - unsigned char (*main_data)[MAD_BUFFER_MDLEN]; - /* Layer III main_data() */ - unsigned int md_len; /* bytes in main_data */ - - int options; /* decoding options (see below) */ - enum mad_error error; /* error code (see above) */ -}; - -enum { - MAD_OPTION_IGNORECRC = 0x0001, /* ignore CRC errors */ - MAD_OPTION_HALFSAMPLERATE = 0x0002 /* generate PCM at 1/2 sample rate */ -# if 0 /* not yet implemented */ - MAD_OPTION_LEFTCHANNEL = 0x0010, /* decode left channel only */ - MAD_OPTION_RIGHTCHANNEL = 0x0020, /* decode right channel only */ - MAD_OPTION_SINGLECHANNEL = 0x0030 /* combine channels */ -# endif -}; - -void mad_stream_init(struct mad_stream *); -void mad_stream_finish(struct mad_stream *); - -# define mad_stream_options(stream, opts) \ - ((void) ((stream)->options = (opts))) - -void mad_stream_buffer(struct mad_stream *, - unsigned char const *, unsigned long); -void mad_stream_skip(struct mad_stream *, unsigned long); - -int mad_stream_sync(struct mad_stream *); - -char const *mad_stream_errorstr(struct mad_stream const *); - -# endif - -/* Id: frame.h,v 1.19 2003/05/27 22:40:36 rob Exp */ - -# ifndef LIBMAD_FRAME_H -# define LIBMAD_FRAME_H - - -enum mad_layer { - MAD_LAYER_I = 1, /* Layer I */ - MAD_LAYER_II = 2, /* Layer II */ - MAD_LAYER_III = 3 /* Layer III */ -}; - -enum mad_mode { - MAD_MODE_SINGLE_CHANNEL = 0, /* single channel */ - MAD_MODE_DUAL_CHANNEL = 1, /* dual channel */ - MAD_MODE_JOINT_STEREO = 2, /* joint (MS/intensity) stereo */ - MAD_MODE_STEREO = 3 /* normal LR stereo */ -}; - -enum mad_emphasis { - MAD_EMPHASIS_NONE = 0, /* no emphasis */ - MAD_EMPHASIS_50_15_US = 1, /* 50/15 microseconds emphasis */ - MAD_EMPHASIS_CCITT_J_17 = 3, /* CCITT J.17 emphasis */ - MAD_EMPHASIS_RESERVED = 2 /* unknown emphasis */ -}; - -struct mad_header { - enum mad_layer layer; /* audio layer (1, 2, or 3) */ - enum mad_mode mode; /* channel mode (see above) */ - int mode_extension; /* additional mode info */ - enum mad_emphasis emphasis; /* de-emphasis to use (see above) */ - - unsigned long bitrate; /* stream bitrate (bps) */ - unsigned int samplerate; /* sampling frequency (Hz) */ - - unsigned short crc_check; /* frame CRC accumulator */ - unsigned short crc_target; /* final target CRC checksum */ - - int flags; /* flags (see below) */ - int private_bits; /* private bits (see below) */ - - mad_timer_t duration; /* audio playing time of frame */ -}; - -struct mad_frame { - struct mad_header header; /* MPEG audio header */ - - int options; /* decoding options (from stream) */ - - mad_fixed_t sbsample[2][36][32]; /* synthesis subband filter samples */ - mad_fixed_t (*overlap)[2][32][18]; /* Layer III block overlap data */ -}; - -# define MAD_NCHANNELS(header) ((header)->mode ? 2 : 1) -# define MAD_NSBSAMPLES(header) \ - ((header)->layer == MAD_LAYER_I ? 12 : \ - (((header)->layer == MAD_LAYER_III && \ - ((header)->flags & MAD_FLAG_LSF_EXT)) ? 18 : 36)) - -enum { - MAD_FLAG_NPRIVATE_III = 0x0007, /* number of Layer III private bits */ - MAD_FLAG_INCOMPLETE = 0x0008, /* header but not data is decoded */ - - MAD_FLAG_PROTECTION = 0x0010, /* frame has CRC protection */ - MAD_FLAG_COPYRIGHT = 0x0020, /* frame is copyright */ - MAD_FLAG_ORIGINAL = 0x0040, /* frame is original (else copy) */ - MAD_FLAG_PADDING = 0x0080, /* frame has additional slot */ - - MAD_FLAG_I_STEREO = 0x0100, /* uses intensity joint stereo */ - MAD_FLAG_MS_STEREO = 0x0200, /* uses middle/side joint stereo */ - MAD_FLAG_FREEFORMAT = 0x0400, /* uses free format bitrate */ - - MAD_FLAG_LSF_EXT = 0x1000, /* lower sampling freq. extension */ - MAD_FLAG_MC_EXT = 0x2000, /* multichannel audio extension */ - MAD_FLAG_MPEG_2_5_EXT = 0x4000 /* MPEG 2.5 (unofficial) extension */ -}; - -enum { - MAD_PRIVATE_HEADER = 0x0100, /* header private bit */ - MAD_PRIVATE_III = 0x001f /* Layer III private bits (up to 5) */ -}; - -void mad_header_init(struct mad_header *); - -# define mad_header_finish(header) /* nothing */ - -int mad_header_decode(struct mad_header *, struct mad_stream *); - -void mad_frame_init(struct mad_frame *); -void mad_frame_finish(struct mad_frame *); - -int mad_frame_decode(struct mad_frame *, struct mad_stream *); - -void mad_frame_mute(struct mad_frame *); - -# endif - -/* Id: synth.h,v 1.14 2003/05/27 22:40:37 rob Exp */ - -# ifndef LIBMAD_SYNTH_H -# define LIBMAD_SYNTH_H - - -struct mad_pcm { - unsigned int samplerate; /* sampling frequency (Hz) */ - unsigned short channels; /* number of channels */ - unsigned short length; /* number of samples per channel */ - mad_fixed_t samples[2][1152]; /* PCM output samples [ch][sample] */ -}; - -struct mad_synth { - mad_fixed_t filter[2][2][2][16][8]; /* polyphase filterbank outputs */ - /* [ch][eo][peo][s][v] */ - - unsigned int phase; /* current processing phase */ - - struct mad_pcm pcm; /* PCM output */ -}; - -/* single channel PCM selector */ -enum { - MAD_PCM_CHANNEL_SINGLE = 0 -}; - -/* dual channel PCM selector */ -enum { - MAD_PCM_CHANNEL_DUAL_1 = 0, - MAD_PCM_CHANNEL_DUAL_2 = 1 -}; - -/* stereo PCM selector */ -enum { - MAD_PCM_CHANNEL_STEREO_LEFT = 0, - MAD_PCM_CHANNEL_STEREO_RIGHT = 1 -}; - -void mad_synth_init(struct mad_synth *); - -# define mad_synth_finish(synth) /* nothing */ - -void mad_synth_mute(struct mad_synth *); - -void mad_synth_frame(struct mad_synth *, struct mad_frame const *); - -# endif - -/* Id: decoder.h,v 1.16 2003/05/27 22:40:36 rob Exp */ - -# ifndef LIBMAD_DECODER_H -# define LIBMAD_DECODER_H - - -enum mad_decoder_mode { - MAD_DECODER_MODE_SYNC = 0, - MAD_DECODER_MODE_ASYNC -}; - -enum mad_flow { - MAD_FLOW_CONTINUE = 0x0000, /* continue normally */ - MAD_FLOW_STOP = 0x0010, /* stop decoding normally */ - MAD_FLOW_BREAK = 0x0011, /* stop decoding and signal an error */ - MAD_FLOW_IGNORE = 0x0020 /* ignore the current frame */ -}; - -struct mad_decoder { - enum mad_decoder_mode mode; - - int options; - - struct { - long pid; - int in; - int out; - } async; - - struct { - struct mad_stream stream; - struct mad_frame frame; - struct mad_synth synth; - } *sync; - - void *cb_data; - - enum mad_flow (*input_func)(void *, struct mad_stream *); - enum mad_flow (*header_func)(void *, struct mad_header const *); - enum mad_flow (*filter_func)(void *, - struct mad_stream const *, struct mad_frame *); - enum mad_flow (*output_func)(void *, - struct mad_header const *, struct mad_pcm *); - enum mad_flow (*error_func)(void *, struct mad_stream *, struct mad_frame *); - enum mad_flow (*message_func)(void *, void *, unsigned int *); -}; - -void mad_decoder_init(struct mad_decoder *, void *, - enum mad_flow (*)(void *, struct mad_stream *), - enum mad_flow (*)(void *, struct mad_header const *), - enum mad_flow (*)(void *, - struct mad_stream const *, - struct mad_frame *), - enum mad_flow (*)(void *, - struct mad_header const *, - struct mad_pcm *), - enum mad_flow (*)(void *, - struct mad_stream *, - struct mad_frame *), - enum mad_flow (*)(void *, void *, unsigned int *)); -int mad_decoder_finish(struct mad_decoder *); - -# define mad_decoder_options(decoder, opts) \ - ((void) ((decoder)->options = (opts))) - -int mad_decoder_run(struct mad_decoder *, enum mad_decoder_mode); -int mad_decoder_message(struct mad_decoder *, void *, unsigned int *); - -# endif - -# ifdef __cplusplus -} -# endif diff --git a/code/libmad-0.15.1b/stream.h b/code/libmad-0.15.1b/stream.h deleted file mode 100644 index 8bff8b49..00000000 --- a/code/libmad-0.15.1b/stream.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * 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 - * - * $Id: stream.h,v 1.20 2004/02/05 09:02:39 rob Exp $ - */ - -# ifndef LIBMAD_STREAM_H -# define LIBMAD_STREAM_H - -# include "bit.h" - -# define MAD_BUFFER_GUARD 8 -# define MAD_BUFFER_MDLEN (511 + 2048 + MAD_BUFFER_GUARD) - -enum mad_error { - MAD_ERROR_NONE = 0x0000, /* no error */ - - MAD_ERROR_BUFLEN = 0x0001, /* input buffer too small (or EOF) */ - MAD_ERROR_BUFPTR = 0x0002, /* invalid (null) buffer pointer */ - - MAD_ERROR_NOMEM = 0x0031, /* not enough memory */ - - MAD_ERROR_LOSTSYNC = 0x0101, /* lost synchronization */ - MAD_ERROR_BADLAYER = 0x0102, /* reserved header layer value */ - MAD_ERROR_BADBITRATE = 0x0103, /* forbidden bitrate value */ - MAD_ERROR_BADSAMPLERATE = 0x0104, /* reserved sample frequency value */ - MAD_ERROR_BADEMPHASIS = 0x0105, /* reserved emphasis value */ - - MAD_ERROR_BADCRC = 0x0201, /* CRC check failed */ - MAD_ERROR_BADBITALLOC = 0x0211, /* forbidden bit allocation value */ - MAD_ERROR_BADSCALEFACTOR = 0x0221, /* bad scalefactor index */ - MAD_ERROR_BADMODE = 0x0222, /* bad bitrate/mode combination */ - MAD_ERROR_BADFRAMELEN = 0x0231, /* bad frame length */ - MAD_ERROR_BADBIGVALUES = 0x0232, /* bad big_values count */ - MAD_ERROR_BADBLOCKTYPE = 0x0233, /* reserved block_type */ - MAD_ERROR_BADSCFSI = 0x0234, /* bad scalefactor selection info */ - MAD_ERROR_BADDATAPTR = 0x0235, /* bad main_data_begin pointer */ - MAD_ERROR_BADPART3LEN = 0x0236, /* bad audio data length */ - MAD_ERROR_BADHUFFTABLE = 0x0237, /* bad Huffman table select */ - MAD_ERROR_BADHUFFDATA = 0x0238, /* Huffman data overrun */ - MAD_ERROR_BADSTEREO = 0x0239 /* incompatible block_type for JS */ -}; - -# define MAD_RECOVERABLE(error) ((error) & 0xff00) - -struct mad_stream { - unsigned char const *buffer; /* input bitstream buffer */ - unsigned char const *bufend; /* end of buffer */ - unsigned long skiplen; /* bytes to skip before next frame */ - - int sync; /* stream sync found */ - unsigned long freerate; /* free bitrate (fixed) */ - - unsigned char const *this_frame; /* start of current frame */ - unsigned char const *next_frame; /* start of next frame */ - struct mad_bitptr ptr; /* current processing bit pointer */ - - struct mad_bitptr anc_ptr; /* ancillary bits pointer */ - unsigned int anc_bitlen; /* number of ancillary bits */ - - unsigned char (*main_data)[MAD_BUFFER_MDLEN]; - /* Layer III main_data() */ - unsigned int md_len; /* bytes in main_data */ - - int options; /* decoding options (see below) */ - enum mad_error error; /* error code (see above) */ -}; - -enum { - MAD_OPTION_IGNORECRC = 0x0001, /* ignore CRC errors */ - MAD_OPTION_HALFSAMPLERATE = 0x0002 /* generate PCM at 1/2 sample rate */ -# if 0 /* not yet implemented */ - MAD_OPTION_LEFTCHANNEL = 0x0010, /* decode left channel only */ - MAD_OPTION_RIGHTCHANNEL = 0x0020, /* decode right channel only */ - MAD_OPTION_SINGLECHANNEL = 0x0030 /* combine channels */ -# endif -}; - -void mad_stream_init(struct mad_stream *); -void mad_stream_finish(struct mad_stream *); - -# define mad_stream_options(stream, opts) \ - ((void) ((stream)->options = (opts))) - -void mad_stream_buffer(struct mad_stream *, - unsigned char const *, unsigned long); -void mad_stream_skip(struct mad_stream *, unsigned long); - -int mad_stream_sync(struct mad_stream *); - -char const *mad_stream_errorstr(struct mad_stream const *); - -# endif diff --git a/code/libmad-0.15.1b/synth.h b/code/libmad-0.15.1b/synth.h deleted file mode 100644 index 8ae4bc95..00000000 --- a/code/libmad-0.15.1b/synth.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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 - * - * $Id: synth.h,v 1.15 2004/01/23 09:41:33 rob Exp $ - */ - -# ifndef LIBMAD_SYNTH_H -# define LIBMAD_SYNTH_H - -# include "fixed.h" -# include "frame.h" - -struct mad_pcm { - unsigned int samplerate; /* sampling frequency (Hz) */ - unsigned short channels; /* number of channels */ - unsigned short length; /* number of samples per channel */ - mad_fixed_t samples[2][1152]; /* PCM output samples [ch][sample] */ -}; - -struct mad_synth { - mad_fixed_t filter[2][2][2][16][8]; /* polyphase filterbank outputs */ - /* [ch][eo][peo][s][v] */ - - unsigned int phase; /* current processing phase */ - - struct mad_pcm pcm; /* PCM output */ -}; - -/* single channel PCM selector */ -enum { - MAD_PCM_CHANNEL_SINGLE = 0 -}; - -/* dual channel PCM selector */ -enum { - MAD_PCM_CHANNEL_DUAL_1 = 0, - MAD_PCM_CHANNEL_DUAL_2 = 1 -}; - -/* stereo PCM selector */ -enum { - MAD_PCM_CHANNEL_STEREO_LEFT = 0, - MAD_PCM_CHANNEL_STEREO_RIGHT = 1 -}; - -void mad_synth_init(struct mad_synth *); - -# define mad_synth_finish(synth) /* nothing */ - -void mad_synth_mute(struct mad_synth *); - -void mad_synth_frame(struct mad_synth *, struct mad_frame const *); - -# endif diff --git a/code/libmad-0.15.1b/timer.h b/code/libmad-0.15.1b/timer.h deleted file mode 100644 index eb4542bb..00000000 --- a/code/libmad-0.15.1b/timer.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * 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 - * - * $Id: timer.h,v 1.16 2004/01/23 09:41:33 rob Exp $ - */ - -# ifndef LIBMAD_TIMER_H -# define LIBMAD_TIMER_H - -typedef struct { - signed long seconds; /* whole seconds */ - unsigned long fraction; /* 1/MAD_TIMER_RESOLUTION seconds */ -} mad_timer_t; - -extern mad_timer_t const mad_timer_zero; - -# define MAD_TIMER_RESOLUTION 352800000UL - -enum mad_units { - MAD_UNITS_HOURS = -2, - MAD_UNITS_MINUTES = -1, - MAD_UNITS_SECONDS = 0, - - /* metric units */ - - MAD_UNITS_DECISECONDS = 10, - MAD_UNITS_CENTISECONDS = 100, - MAD_UNITS_MILLISECONDS = 1000, - - /* audio sample units */ - - MAD_UNITS_8000_HZ = 8000, - MAD_UNITS_11025_HZ = 11025, - MAD_UNITS_12000_HZ = 12000, - - MAD_UNITS_16000_HZ = 16000, - MAD_UNITS_22050_HZ = 22050, - MAD_UNITS_24000_HZ = 24000, - - MAD_UNITS_32000_HZ = 32000, - MAD_UNITS_44100_HZ = 44100, - MAD_UNITS_48000_HZ = 48000, - - /* video frame/field units */ - - MAD_UNITS_24_FPS = 24, - MAD_UNITS_25_FPS = 25, - MAD_UNITS_30_FPS = 30, - MAD_UNITS_48_FPS = 48, - MAD_UNITS_50_FPS = 50, - MAD_UNITS_60_FPS = 60, - - /* CD audio frames */ - - MAD_UNITS_75_FPS = 75, - - /* video drop-frame units */ - - MAD_UNITS_23_976_FPS = -24, - MAD_UNITS_24_975_FPS = -25, - MAD_UNITS_29_97_FPS = -30, - MAD_UNITS_47_952_FPS = -48, - MAD_UNITS_49_95_FPS = -50, - MAD_UNITS_59_94_FPS = -60 -}; - -# define mad_timer_reset(timer) ((void) (*(timer) = mad_timer_zero)) - -int mad_timer_compare(mad_timer_t, mad_timer_t); - -# define mad_timer_sign(timer) mad_timer_compare((timer), mad_timer_zero) - -void mad_timer_negate(mad_timer_t *); -mad_timer_t mad_timer_abs(mad_timer_t); - -void mad_timer_set(mad_timer_t *, unsigned long, unsigned long, unsigned long); -void mad_timer_add(mad_timer_t *, mad_timer_t); -void mad_timer_multiply(mad_timer_t *, signed long); - -signed long mad_timer_count(mad_timer_t, enum mad_units); -unsigned long mad_timer_fraction(mad_timer_t, unsigned long); -void mad_timer_string(mad_timer_t, char *, char const *, - enum mad_units, enum mad_units, unsigned long); - -# endif diff --git a/code/libmad-0.15.1b/version.h b/code/libmad-0.15.1b/version.h deleted file mode 100644 index d215d4c1..00000000 --- a/code/libmad-0.15.1b/version.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 - * - * $Id: version.h,v 1.26 2004/01/23 09:41:33 rob Exp $ - */ - -# ifndef LIBMAD_VERSION_H -# define LIBMAD_VERSION_H - -# define MAD_VERSION_MAJOR 0 -# define MAD_VERSION_MINOR 15 -# define MAD_VERSION_PATCH 1 -# define MAD_VERSION_EXTRA " (beta)" - -# define MAD_VERSION_STRINGIZE(str) #str -# define MAD_VERSION_STRING(num) MAD_VERSION_STRINGIZE(num) - -# define MAD_VERSION MAD_VERSION_STRING(MAD_VERSION_MAJOR) "." \ - MAD_VERSION_STRING(MAD_VERSION_MINOR) "." \ - MAD_VERSION_STRING(MAD_VERSION_PATCH) \ - MAD_VERSION_EXTRA - -# define MAD_PUBLISHYEAR "2000-2004" -# define MAD_AUTHOR "Underbit Technologies, Inc." -# define MAD_EMAIL "info@underbit.com" - -extern char const mad_version[]; -extern char const mad_copyright[]; -extern char const mad_author[]; -extern char const mad_build[]; - -# endif diff --git a/code/libmad/.github/workflows/build.yml b/code/libmad/.github/workflows/build.yml new file mode 100644 index 00000000..ba50e409 --- /dev/null +++ b/code/libmad/.github/workflows/build.yml @@ -0,0 +1,44 @@ +name: build + +on: + push: + pull_request: + +jobs: + build: + strategy: + fail-fast: false + matrix: + include: + - name: Ubuntu + os: ubuntu-latest + install_dir: ~/libmad + cmake_extras: -DCMAKE_BUILD_TYPE=RelWithDebInfo + - name: macOS + os: macos-latest + install_dir: ~/libmad + cmake_extras: -DCMAKE_BUILD_TYPE=RelWithDebInfo + - name: Windows + os: windows-latest + install_dir: C:\libmad + cmake_config: --config RelWithDebInfo + + name: ${{ matrix.name }} + runs-on: ${{ matrix.os }} + steps: + - name: Check out Git repository + uses: actions/checkout@v2 + - name: Configure + run: cmake -DCMAKE_INSTALL_PREFIX=${{ matrix.install_dir }} ${{ matrix.cmake_extras }} -S . -B build + - name: Build + run: cmake --build build ${{ matrix.cmake_config }} + env: + CMAKE_BUILD_PARALLEL_LEVEL: 2 + - name: Install + run: cmake --install . ${{ matrix.cmake_config }} + working-directory: build + - name: Upload Build Artifact + uses: actions/upload-artifact@v2 + with: + name: ${{ matrix.name }} libmad build + path: ${{ matrix.install_dir }} diff --git a/code/libmad/.gitignore b/code/libmad/.gitignore new file mode 100644 index 00000000..378eac25 --- /dev/null +++ b/code/libmad/.gitignore @@ -0,0 +1 @@ +build diff --git a/code/libmad-0.15.1b/CHANGES b/code/libmad/CHANGES similarity index 94% rename from code/libmad-0.15.1b/CHANGES rename to code/libmad/CHANGES index 9291760b..45a94436 100644 --- a/code/libmad-0.15.1b/CHANGES +++ b/code/libmad/CHANGES @@ -6,6 +6,28 @@ =============================================================================== +Verison 0.16.4 + * Fix compatibility with libmad 0.15.1b + +Version 0.16.3 + * Disable assembly optimizations for all 64 bit CPU architectures; they are + only for 32 and 16 bit architectures + * Fix CPU architecture detection for PowerPC + +Version 0.16.2 + * Fix building assembly file on ARM + * Fix pkgconfig file when CMAKE_INSTALL_{INCLUDE,LIB}DIR are absolute paths + +Version 0.16.1 + * Fix generation of mad.h broken by move to CMake + * Add CMake options for CPU architecture-specific optimizations + +Version 0.16.0 + * Add CMake build system + * Remove autotools build system + * Add pkgconfig and CMake config files + * Apply patches from Debian and Fedora + Version 0.15.1 (beta) * Updated to autoconf 2.59, automake 1.8.2, libtool 1.5.2. diff --git a/code/libmad/CMakeLists.txt b/code/libmad/CMakeLists.txt new file mode 100644 index 00000000..3d3e16db --- /dev/null +++ b/code/libmad/CMakeLists.txt @@ -0,0 +1,240 @@ +cmake_minimum_required(VERSION 3.5) +project(mad VERSION 0.16.4) + +option(BUILD_SHARED_LIBS "Build dynamic library" ON) + +# The library SOVERSION. This is set to 0 for backward compatibility. +# The general policy is that minor versions of the library (e.g., 0.16.1, +# 0.16.2) don't constitute a major ABI breakage. Major versions (e.g., 0.17, +# 0.18) do. +set(LIBRARY_SOVERSION 0) + +include(GNUInstallDirs) +include(CheckTypeSize) + +# +# Build +# + +add_library(mad + bit.c + decoder.c + fixed.c + frame.c + huffman.c + layer12.c + layer3.c + stream.c + synth.c + timer.c + version.c +) +target_include_directories(mad PUBLIC + $ + $ + $ +) + +if(WIN32 AND BUILD_SHARED_LIBS) + set_target_properties(mad PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) +endif() + +set_target_properties(mad PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION ${LIBRARY_SOVERSION} +) + +# +# Compile definitions +# + +option(OPTIMIZE "Optimize for SPEED (default) or ACCURACY" SPEED) +if(OPTIMIZE STREQUAL "SPEED") + message(STATUS "Optimizing for speed over accuracy.") + target_compile_definitions(mad PRIVATE OPT_SPEED) +else() + message(STATUS "Optimizing for accuracy over speed.") + target_compile_definitions(mad PRIVATE OPT_ACCURACY) +endif() + +option(ASO "Enable CPU Architecture Specific Optimizations (x86, ARM, and MIPS only)" ON) +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + message(STATUS "Using 64 bit fixed point math") + option(FPM_64BIT "64 bit fixed point math" ON) +elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86" OR "i386") + message(STATUS "Using x86 fixed point math") + option (FPM_INTEL "x86 fixed point math" ON) + if(ASO) + target_compile_definitions(mad PRIVATE ASO_ZEROCHECK) + endif() +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES ".*(arm|ARM).*") + message(STATUS "Using ARM fixed point math") + option (FPM_ARM "ARM fixed point math" ON) + if(ASO) + enable_language(ASM) + target_compile_definitions(mad PRIVATE ASO_INTERLEAVE1 ASO_IMDCT) + target_sources(mad PRIVATE imdct_l_arm.S) + endif() +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES ".*(mips|MIPS).*") + message(STATUS "Using MIPS fixed point math") + option(FPM_MIPS "MIPS fixed point math" ON) + if(ASO) + target_compile_definitions(mad PRIVATE ASO_INTERLEAVE2 ASO_ZEROCHECK) + endif() +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES ".*(sparc|SPARC).*") + message(STATUS "Using SPARC fixed point math") + option(FPM_SPARC "SPARC fixed point math" ON) +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES ".(ppc|PPC|powerpc).*") + message(STATUS "Using PowerPC fixed point math") + option(FPM_PPC "PowerPC fixed point math" ON) +else() + message(WARNING "Target CPU architecture not detected. Fixed-point math will yield limited accuracy.") + option(FPM_DEFAULT "Generic fixed-point math" ON) +endif() + + +check_type_size(int SIZEOF_INT BUILTIN_TYPES_ONLY LANGUAGE C) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/mad.h.in ${CMAKE_CURRENT_BINARY_DIR}/mad.h @ONLY) + +include(CheckIncludeFile) +check_include_file(sys/types.h HAVE_SYS_TYPES_H) +if(HAVE_SYS_TYPES_H) + target_compile_definitions(mad PRIVATE HAVE_SYS_TYPES_H) +endif() + +check_include_file(sys/wait.h HAVE_SYS_WAIT_H) +if(HAVE_SYS_WAIT_H) + target_compile_definitions(mad PRIVATE HAVE_SYS_WAIT_H) +endif() + +check_include_file(sys/mman.h HAVE_SYS_MMAN_H) +if(HAVE_SYS_MMAN_H) + target_compile_definitions(mad PRIVATE HAVE_SYS_MMAN_H) +endif() + +check_include_file(sys/stat.h HAVE_SYS_STAT_H) +if(HAVE_SYS_STAT_H) + target_compile_definitions(mad PRIVATE HAVE_SYS_STAT_H) +endif() + +check_include_file(unistd.h HAVE_UNISTD_H) +if(HAVE_UNISTD_H) + target_compile_definitions(mad PRIVATE HAVE_UNISTD_H) +endif() + +check_include_file(assert.h HAVE_ASSERT_H) +if(HAVE_ASSERT_H) + target_compile_definitions(mad PRIVATE HAVE_ASSERT_H) +endif() + +check_include_file(fcntl.h HAVE_FCNTL_H) +if(HAVE_FCNTL_H) + target_compile_definitions(mad PRIVATE HAVE_FCNTL_H) +endif() + +check_include_file(limits.h HAVE_LIMITS_H) +if(HAVE_LIMITS_H) + target_compile_definitions(mad PRIVATE HAVE_LIMITS_H) +endif() + +include(CheckFunctionExists) +check_function_exists(ftruncate HAVE_FTRUNCATE) +if(HAVE_FTRUNCATE) + target_compile_definitions(mad PRIVATE HAVE_FTRUNCATE) +endif() + +check_function_exists(pipe HAVE_PIPE) +if(HAVE_PIPE) + target_compile_definitions(mad PRIVATE HAVE_PIPE) +endif() + +check_function_exists(fork HAVE_FORK) +if(HAVE_FORK) + target_compile_definitions(mad PRIVATE HAVE_FORK) +endif() + +check_function_exists(waitpid HAVE_WAITPID) +if(HAVE_WAITPID) + target_compile_definitions(mad PRIVATE HAVE_WAITPID) +endif() + +option(MADD_ASM "Enable if your MIPS CPU supports a 2-operand MADD instruction." OFF) +if(MADD_ASM) + target_compile_definitions(mad PRIVATE HAVE_MADD_ASM) +endif() + +option(MADD16_ASM "Enable if your MIPS CPU supports a 2-operand MADD16 instruction." OFF) +if(MADD16_ASM) + target_compile_definitions(mad PRIVATE HAVE_MADD_ASM) +endif() + +# +# Example application +# + +include(CMakeDependentOption) +cmake_dependent_option(EXAMPLE "Build example executable" ON "HAVE_UNISTD_H;HAVE_SYS_STAT_H;HAVE_SYS_MMAN_H" OFF) +if(EXAMPLE) + add_executable(mad_example minimad.c) + target_link_libraries(mad_example PRIVATE mad) +endif() + +# +# Installation +# + +include(CMakePackageConfigHelpers) + +# Library files +install(TARGETS mad + EXPORT madTargets + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" +) + +# Header files +install( + FILES "${CMAKE_CURRENT_BINARY_DIR}/mad.h" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" +) + +# pkgconfig +if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}") + set(PKGCONFIG_LIBDIR "${CMAKE_INSTALL_LIBDIR}") +else() + set(PKGCONFIG_LIBDIR "\${prefix}/${CMAKE_INSTALL_LIBDIR}") +endif() +if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}") + set(PKGCONFIG_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}") +else() + set(PKGCONFIG_INCLUDEDIR "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") +endif() +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/packaging/mad.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/packaging/mad.pc @ONLY) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/packaging/mad.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") + +# CMake config +set(MAD_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/mad") +install( + EXPORT madTargets + FILE madTargets.cmake + NAMESPACE mad:: + DESTINATION "${MAD_INSTALL_CMAKEDIR}" +) +configure_package_config_file(packaging/madConfig.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/packaging/madConfig.cmake" + INSTALL_DESTINATION "${MAD_INSTALL_CMAKEDIR}" +) +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/packaging/madConfigVersion.cmake" + VERSION "${PROJECT_VERSION}" + COMPATIBILITY SameMajorVersion +) +install( + FILES + "${CMAKE_CURRENT_BINARY_DIR}/packaging/madConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/packaging/madConfigVersion.cmake" + DESTINATION "${MAD_INSTALL_CMAKEDIR}" +) diff --git a/code/libmad-0.15.1b/COPYING b/code/libmad/COPYING similarity index 100% rename from code/libmad-0.15.1b/COPYING rename to code/libmad/COPYING diff --git a/code/libmad-0.15.1b/COPYRIGHT b/code/libmad/COPYRIGHT similarity index 100% rename from code/libmad-0.15.1b/COPYRIGHT rename to code/libmad/COPYRIGHT diff --git a/code/libmad-0.15.1b/CREDITS b/code/libmad/CREDITS similarity index 100% rename from code/libmad-0.15.1b/CREDITS rename to code/libmad/CREDITS diff --git a/code/libmad-0.15.1b/D.dat b/code/libmad/D.dat similarity index 100% rename from code/libmad-0.15.1b/D.dat rename to code/libmad/D.dat diff --git a/code/libmad/README.md b/code/libmad/README.md new file mode 100644 index 00000000..fa8a2db6 --- /dev/null +++ b/code/libmad/README.md @@ -0,0 +1,178 @@ +# libmad - MPEG audio decoder library +Copyright (C) 2000-2004 Underbit Technologies, Inc. +Copyright (C) 2021-2023 Tenacity Team and Contributors + +`$Id: README,v 1.4 2004/01/23 09:41:32 rob Exp $` + +--- + +# Introduction + +MAD (libmad) is a high-quality MPEG audio decoder. It currently supports +MPEG-1 and the MPEG-2 extension to Lower Sampling Frequencies, as well as +the so-called MPEG 2.5 format. All three audio layers (Layer I, Layer II, +and Layer III a.k.a. MP3) are fully implemented. + +MAD does not yet support MPEG-2 multichannel audio (although it should be +backward compatible with such streams) nor does it currently support AAC. + +MAD has the following special features: + + - 24-bit PCM output + - 100% fixed-point (integer) computation + - completely new implementation based on the ISO/IEC standards + - distributed under the terms of the GNU General Public License (GPL) + +Because MAD provides full 24-bit PCM output, applications using MAD are +able to produce high quality audio. Even when the output device supports +only 16-bit PCM, applications can use the extra resolution to increase the +audible dynamic range through the use of dithering or noise shaping. + +Because MAD uses integer computation rather than floating point, it is +well suited for architectures without a floating point unit. All +calculations are performed with a 32-bit fixed-point integer +representation. + +Because MAD is a new implementation of the ISO/IEC standards, it is +unencumbered by the errors of other implementations. MAD is NOT a +derivation of the ISO reference source or any other code. Considerable +effort has been expended to ensure a correct implementation, even in cases +where the standards are ambiguous or misleading. + +Because MAD is distributed under the terms of the GPL, its redistribution +is not generally restricted, so long as the terms of the GPL are followed. +This means MAD can be incorporated into other software as long as that +software is also distributed under the GPL. (Should this be undesirable, +alternate arrangements may be possible by contacting Underbit.) + +# About The Code + +The code is optimized and performs very well, although specific +improvements can still be made. The output from the decoder library +consists of 32-bit signed linear fixed-point values that can be easily +scaled for any size PCM output, up to 24 bits per sample. + +The API for libmad can be found in the `mad.h' header file. Note that this +file is automatically generated, and will not exist until after you have +built the library. + +There are two APIs available, one high-level, and the other low-level. +With the low-level API, each step of the decoding process must be handled +explicitly, offering the greatest amount of control. With the high-level +API, after callbacks are configured, a single routine will decode an +entire bitstream. + +The high-level API may either be used synchronously or asynchronously. If +used asynchronously, decoding will occur in a separate process. +Communication is possible with the decoding process by passing control +messages. + +The file `minimad.c' contains an example usage of the libmad API that +shows only the bare minimum required to implement a useful decoder. It +expects a regular file to be redirected to standard input, and it sends +decoded 16-bit signed little-endian PCM samples to standard output. If a +decoding error occurs, it is reported to standard error and decoding +continues. Note that the scale() routine in this code is only provided as +an example; it rounds MAD's high-resolution samples down to 16 bits, but +does not perform any dithering or noise shaping. It is therefore not +recommended to use this routine as-is in your own code if sound quality is +important. + +## Integer Performance + +To get the best possible performance, it is recommended that an assembly +version of the fixed-point multiply and related routines be selected. +Several such assembly routines have been written for various CPUs. + +If an assembly version is not available, a fast approximation version will +be used. This will result in reduced accuracy of the decoder. + +Alternatively, if 64-bit integers are supported as a datatype by the +compiler, another version can be used that is much more accurate. +However, using an assembly version is generally much faster and just as +accurate. + +More information can be gathered from the `fixed.h' header file. + +MAD's CPU-intensive subband synthesis routine can be further optimized at +the expense of a slight loss in output accuracy due to a modified method +for fixed-point multiplication with a small windowing constant. While this +is helpful for performance and the output accuracy loss is generally +undetectable, it is disabled by default and must be explicitly enabled. + +Under some architectures, other special optimizations may also be +available. + +## Audio Quality + +The output from MAD has been found to satisfy the ISO/IEC 11172-4 +computational accuracy requirements for compliance. In most +configurations, MAD is a Full Layer III ISO/IEC 11172-3 audio decoder as +defined by the standard. + +When the approximation version of the fixed-point multiply is used, MAD is +a limited accuracy ISO/IEC 11172-3 audio decoder as defined by the +standard. + +MAD can alternatively be configured to produce output with less or more +accuracy than the default, as a tradeoff with performance. + +MAD produces output samples with a precision greater than 24 bits. Because +most output formats use fewer bits, typically 16, it is recommended that a +dithering algorithm be used (rather than rounding or truncating) to obtain +the highest quality audio. However, dithering may unfavorably affect an +analytic examination of the output (such as compliance testing); you may +therefore wish to use rounding in this case instead. + +## Portability Issues + +GCC is preferred to compile the code, but other compilers may also work. +The assembly code in `fixed.h' depends on the inline assembly features of +your compiler. If you're not using GCC or MSVC++, you can either write +your own assembly macros or use the default (low quality output) version. + +The union initialization of `huffman.c' may not be portable to all +platforms when GCC is not used. + +The code should not be sensitive to word sizes or byte ordering, however +it does assume A % B has the same sign as A. + +# Building and Installing + +libmad uses the CMake build system and has no dependencies. To build it, run: + +``` bash +cmake -D CMAKE_INSTALL_PREFIX=/where/you/want/to/install/to -S . -B build +cmake --build build --parallel number-of-cpu-cores +cmake --install build +``` + +The following CMake options are available which can be toggled by passing +'-D OPTION=VALUE' to the CMake configure step (the first call to cmake above): + + * ASO (ON|OFF): Enable CPU Architecture Specific Optimizations + (x86, ARM, and MIPS only). ON by default. + * EXAMPLE (ON|OFF): Build the example application. Only works on POSIX + operating systems. ON by default on POSIX operating systems. The example + application is not installed. + +## Supported Platforms + +libmad relies on a POSIX environment. On Windows, you should use Cygwin to +build libmad. + +It is planned that in a future release + +# Copyright + +Please read the `COPYRIGHT` file for copyright and warranty information. +Also, the file `COPYING` contains the full text of the GNU GPL. + +Send inquiries, comments, bug reports, suggestions, patches, etc. to: + + Underbit Technologies, Inc. + +See also the MAD home page on the Web: + + http://www.underbit.com/products/mad/ + diff --git a/code/libmad-0.15.1b/TODO b/code/libmad/TODO similarity index 100% rename from code/libmad-0.15.1b/TODO rename to code/libmad/TODO diff --git a/code/libmad-0.15.1b/bit.c b/code/libmad/bit.c similarity index 98% rename from code/libmad-0.15.1b/bit.c rename to code/libmad/bit.c index c2bfb243..72a094ca 100644 --- a/code/libmad-0.15.1b/bit.c +++ b/code/libmad/bit.c @@ -19,10 +19,6 @@ * $Id: bit.c,v 1.12 2004/01/23 09:41:32 rob Exp $ */ -# ifdef HAVE_CONFIG_H -# include "config.h" -# endif - # include "global.h" # ifdef HAVE_LIMITS_H @@ -31,7 +27,7 @@ # define CHAR_BIT 8 # endif -# include "bit.h" +# include "mad.h" /* * This is the lookup table for computing the CRC-check word. @@ -138,6 +134,9 @@ unsigned long mad_bit_read(struct mad_bitptr *bitptr, unsigned int len) { register unsigned long value; + if (len == 0) + return 0; + if (bitptr->left == CHAR_BIT) bitptr->cache = *bitptr->byte; diff --git a/code/libmad-0.15.1b/decoder.c b/code/libmad/decoder.c similarity index 78% rename from code/libmad-0.15.1b/decoder.c rename to code/libmad/decoder.c index 6d6df0db..b631a686 100644 --- a/code/libmad-0.15.1b/decoder.c +++ b/code/libmad/decoder.c @@ -19,10 +19,6 @@ * $Id: decoder.c,v 1.22 2004/01/23 09:41:32 rob Exp $ */ -# ifdef HAVE_CONFIG_H -# include "config.h" -# endif - # include "global.h" # ifdef HAVE_SYS_TYPES_H @@ -47,10 +43,7 @@ # include # endif -# include "stream.h" -# include "frame.h" -# include "synth.h" -# include "decoder.h" +# include "mad.h" /* * NAME: decoder->init() @@ -236,9 +229,9 @@ enum mad_flow receive(int fd, void **message, unsigned int *size) if (*size > 0) { if (*message == 0) { - *message = malloc(*size); - if (*message == 0) - return MAD_FLOW_BREAK; + *message = malloc(*size); + if (*message == 0) + return MAD_FLOW_BREAK; } result = receive_io_blocking(fd, *message, *size); @@ -277,8 +270,8 @@ enum mad_flow check_message(struct mad_decoder *decoder) result = decoder->message_func(decoder->cb_data, message, &size); if (result == MAD_FLOW_IGNORE || - result == MAD_FLOW_BREAK) - size = 0; + result == MAD_FLOW_BREAK) + size = 0; } if (send(decoder->async.out, message, size) != MAD_FLOW_CONTINUE) @@ -347,114 +340,128 @@ int run_sync(struct mad_decoder *decoder) do { switch (decoder->input_func(decoder->cb_data, stream)) { - case MAD_FLOW_STOP: - goto done; - case MAD_FLOW_BREAK: - goto fail; - case MAD_FLOW_IGNORE: - continue; - case MAD_FLOW_CONTINUE: - break; + case MAD_FLOW_STOP: + goto done; + case MAD_FLOW_BREAK: + goto fail; + case MAD_FLOW_IGNORE: + continue; + case MAD_FLOW_CONTINUE: + break; } - while (1) { -# if defined(USE_ASYNC) + while (1) + { + #if defined(USE_ASYNC) if (decoder->mode == MAD_DECODER_MODE_ASYNC) { - switch (check_message(decoder)) { - case MAD_FLOW_IGNORE: - case MAD_FLOW_CONTINUE: - break; - case MAD_FLOW_BREAK: - goto fail; - case MAD_FLOW_STOP: - goto done; - } + switch (check_message(decoder)) { + case MAD_FLOW_IGNORE: + case MAD_FLOW_CONTINUE: + break; + case MAD_FLOW_BREAK: + goto fail; + case MAD_FLOW_STOP: + goto done; + } } -# endif + #endif - if (decoder->header_func) { - if (mad_header_decode(&frame->header, stream) == -1) { - if (!MAD_RECOVERABLE(stream->error)) - break; + if (decoder->header_func) + { + if (mad_header_decode(&frame->header, stream) == -1) + { + if (!MAD_RECOVERABLE(stream->error)) + { + break; + } - switch (error_func(error_data, stream, frame)) { - case MAD_FLOW_STOP: - goto done; - case MAD_FLOW_BREAK: - goto fail; - case MAD_FLOW_IGNORE: - case MAD_FLOW_CONTINUE: - default: - continue; - } - } + switch (error_func(error_data, stream, frame)) + { + case MAD_FLOW_STOP: + goto done; + case MAD_FLOW_BREAK: + goto fail; + case MAD_FLOW_IGNORE: + case MAD_FLOW_CONTINUE: + default: + continue; + } + } - switch (decoder->header_func(decoder->cb_data, &frame->header)) { - case MAD_FLOW_STOP: - goto done; - case MAD_FLOW_BREAK: - goto fail; - case MAD_FLOW_IGNORE: - continue; - case MAD_FLOW_CONTINUE: - break; - } + switch (decoder->header_func(decoder->cb_data, &frame->header)) + { + case MAD_FLOW_STOP: + goto done; + case MAD_FLOW_BREAK: + goto fail; + case MAD_FLOW_IGNORE: + continue; + case MAD_FLOW_CONTINUE: + break; + } } - if (mad_frame_decode(frame, stream) == -1) { - if (!MAD_RECOVERABLE(stream->error)) - break; + if (mad_frame_decode(frame, stream) == -1) + { + if (!MAD_RECOVERABLE(stream->error)) + break; - switch (error_func(error_data, stream, frame)) { - case MAD_FLOW_STOP: - goto done; - case MAD_FLOW_BREAK: - goto fail; - case MAD_FLOW_IGNORE: - break; - case MAD_FLOW_CONTINUE: - default: - continue; - } + switch (error_func(error_data, stream, frame)) + { + case MAD_FLOW_STOP: + goto done; + case MAD_FLOW_BREAK: + goto fail; + case MAD_FLOW_IGNORE: + break; + case MAD_FLOW_CONTINUE: + default: + continue; + } + } else + { + bad_last_frame = 0; } - else - bad_last_frame = 0; - if (decoder->filter_func) { - switch (decoder->filter_func(decoder->cb_data, stream, frame)) { - case MAD_FLOW_STOP: - goto done; - case MAD_FLOW_BREAK: - goto fail; - case MAD_FLOW_IGNORE: - continue; - case MAD_FLOW_CONTINUE: - break; - } + if (decoder->filter_func) + { + switch (decoder->filter_func(decoder->cb_data, stream, frame)) + { + case MAD_FLOW_STOP: + goto done; + case MAD_FLOW_BREAK: + goto fail; + case MAD_FLOW_IGNORE: + continue; + case MAD_FLOW_CONTINUE: + break; + } } mad_synth_frame(synth, frame); - if (decoder->output_func) { - switch (decoder->output_func(decoder->cb_data, - &frame->header, &synth->pcm)) { - case MAD_FLOW_STOP: - goto done; - case MAD_FLOW_BREAK: - goto fail; - case MAD_FLOW_IGNORE: - case MAD_FLOW_CONTINUE: - break; - } + if (decoder->output_func) + { + switch (decoder->output_func(decoder->cb_data, + &frame->header, &synth->pcm)) + { + case MAD_FLOW_STOP: + goto done; + case MAD_FLOW_BREAK: + goto fail; + case MAD_FLOW_IGNORE: + case MAD_FLOW_CONTINUE: + break; + } } } } while (stream->error == MAD_ERROR_BUFLEN); - fail: +fail: result = -1; - done: +done: mad_synth_finish(synth); mad_frame_finish(frame); mad_stream_finish(stream); diff --git a/code/libmad-0.15.1b/fixed.c b/code/libmad/fixed.c similarity index 95% rename from code/libmad-0.15.1b/fixed.c rename to code/libmad/fixed.c index 9785466f..3e4055f8 100644 --- a/code/libmad-0.15.1b/fixed.c +++ b/code/libmad/fixed.c @@ -19,13 +19,9 @@ * $Id: fixed.c,v 1.13 2004/01/23 09:41:32 rob Exp $ */ -# ifdef HAVE_CONFIG_H -# include "config.h" -# endif - # include "global.h" -# include "fixed.h" +# include "mad.h" /* * NAME: fixed->abs() diff --git a/code/libmad-0.15.1b/frame.c b/code/libmad/frame.c similarity index 95% rename from code/libmad-0.15.1b/frame.c rename to code/libmad/frame.c index 0cb3d0f3..03c94bfe 100644 --- a/code/libmad-0.15.1b/frame.c +++ b/code/libmad/frame.c @@ -19,18 +19,11 @@ * $Id: frame.c,v 1.29 2004/02/04 22:59:19 rob Exp $ */ -# ifdef HAVE_CONFIG_H -# include "config.h" -# endif - # include "global.h" # include -# include "bit.h" -# include "stream.h" -# include "frame.h" -# include "timer.h" +# include "mad.h" # include "layer12.h" # include "layer3.h" @@ -120,11 +113,18 @@ static int decode_header(struct mad_header *header, struct mad_stream *stream) { unsigned int index; + struct mad_bitptr bufend_ptr; header->flags = 0; header->private_bits = 0; + mad_bit_init(&bufend_ptr, stream->bufend); + /* header() */ + if (mad_bit_length(&stream->ptr, &bufend_ptr) < 32) { + stream->error = MAD_ERROR_BUFLEN; + return -1; + } /* syncword */ mad_bit_skip(&stream->ptr, 11); @@ -225,8 +225,13 @@ int decode_header(struct mad_header *header, struct mad_stream *stream) /* error_check() */ /* crc_check */ - if (header->flags & MAD_FLAG_PROTECTION) + if (header->flags & MAD_FLAG_PROTECTION) { + if (mad_bit_length(&stream->ptr, &bufend_ptr) < 16) { + stream->error = MAD_ERROR_BUFLEN; + return -1; + } header->crc_target = mad_bit_read(&stream->ptr, 16); + } return 0; } @@ -338,7 +343,7 @@ int mad_header_decode(struct mad_header *header, struct mad_stream *stream) stream->error = MAD_ERROR_BUFLEN; goto fail; } - else if (!(ptr[0] == 0xff && (ptr[1] & 0xe0) == 0xe0)) { + else if ((end - ptr >= 2) && !(ptr[0] == 0xff && (ptr[1] & 0xe0) == 0xe0)) { /* mark point where frame sync word was expected */ stream->this_frame = ptr; stream->next_frame = ptr + 1; @@ -361,6 +366,8 @@ int mad_header_decode(struct mad_header *header, struct mad_stream *stream) ptr = mad_bit_nextbyte(&stream->ptr); } + stream->error = MAD_ERROR_NONE; + /* begin processing */ stream->this_frame = ptr; stream->next_frame = ptr + 1; /* possibly bogus sync word */ @@ -413,7 +420,7 @@ int mad_header_decode(struct mad_header *header, struct mad_stream *stream) /* check that a valid frame header follows this frame */ ptr = stream->next_frame; - if (!(ptr[0] == 0xff && (ptr[1] & 0xe0) == 0xe0)) { + if ((end - ptr >= 2) && !(ptr[0] == 0xff && (ptr[1] & 0xe0) == 0xe0)) { ptr = stream->next_frame = stream->this_frame + 1; goto sync; } diff --git a/code/libmad-0.15.1b/global.h b/code/libmad/global.h similarity index 100% rename from code/libmad-0.15.1b/global.h rename to code/libmad/global.h diff --git a/code/libmad-0.15.1b/huffman.c b/code/libmad/huffman.c similarity index 99% rename from code/libmad-0.15.1b/huffman.c rename to code/libmad/huffman.c index a230a9c1..9050c700 100644 --- a/code/libmad-0.15.1b/huffman.c +++ b/code/libmad/huffman.c @@ -19,10 +19,6 @@ * $Id: huffman.c,v 1.10 2004/01/23 09:41:32 rob Exp $ */ -# ifdef HAVE_CONFIG_H -# include "config.h" -# endif - # include "global.h" # include "huffman.h" diff --git a/code/libmad-0.15.1b/huffman.h b/code/libmad/huffman.h similarity index 100% rename from code/libmad-0.15.1b/huffman.h rename to code/libmad/huffman.h diff --git a/code/libmad-0.15.1b/imdct_l_arm.S b/code/libmad/imdct_l_arm.S similarity index 99% rename from code/libmad-0.15.1b/imdct_l_arm.S rename to code/libmad/imdct_l_arm.S index badec5bc..92d67e1a 100644 --- a/code/libmad-0.15.1b/imdct_l_arm.S +++ b/code/libmad/imdct_l_arm.S @@ -468,7 +468,7 @@ _III_imdct_l: @---- - add r2, pc, #(imdct36_long_karray-.-8) @ r2 = base address of Knn array (PIC safe ?) + adr r2, imdct36_long_karray loop: diff --git a/code/libmad-0.15.1b/imdct_s.dat b/code/libmad/imdct_s.dat similarity index 100% rename from code/libmad-0.15.1b/imdct_s.dat rename to code/libmad/imdct_s.dat diff --git a/code/libmad-0.15.1b/layer12.c b/code/libmad/layer12.c similarity index 81% rename from code/libmad-0.15.1b/layer12.c rename to code/libmad/layer12.c index 6981f9ce..a334a27e 100644 --- a/code/libmad-0.15.1b/layer12.c +++ b/code/libmad/layer12.c @@ -19,10 +19,6 @@ * $Id: layer12.c,v 1.17 2004/02/05 09:02:39 rob Exp $ */ -# ifdef HAVE_CONFIG_H -# include "config.h" -# endif - # include "global.h" # ifdef HAVE_LIMITS_H @@ -31,10 +27,7 @@ # define CHAR_BIT 8 # endif -# include "fixed.h" -# include "bit.h" -# include "stream.h" -# include "frame.h" +# include "mad.h" # include "layer12.h" /* @@ -72,10 +65,18 @@ mad_fixed_t const linear_table[14] = { * DESCRIPTION: decode one requantized Layer I sample from a bitstream */ static -mad_fixed_t I_sample(struct mad_bitptr *ptr, unsigned int nb) +mad_fixed_t I_sample(struct mad_bitptr *ptr, unsigned int nb, struct mad_stream *stream) { mad_fixed_t sample; + struct mad_bitptr frameend_ptr; + mad_bit_init(&frameend_ptr, stream->next_frame); + + if (mad_bit_length(ptr, &frameend_ptr) < nb) { + stream->error = MAD_ERROR_LOSTSYNC; + stream->sync = 0; + return 0; + } sample = mad_bit_read(ptr, nb); /* invert most significant bit, extend sign, then scale to fixed format */ @@ -106,6 +107,10 @@ int mad_layer_I(struct mad_stream *stream, struct mad_frame *frame) struct mad_header *header = &frame->header; unsigned int nch, bound, ch, s, sb, nb; unsigned char allocation[2][32], scalefactor[2][32]; + struct mad_bitptr bufend_ptr, frameend_ptr; + + mad_bit_init(&bufend_ptr, stream->bufend); + mad_bit_init(&frameend_ptr, stream->next_frame); nch = MAD_NCHANNELS(header); @@ -118,6 +123,11 @@ int mad_layer_I(struct mad_stream *stream, struct mad_frame *frame) /* check CRC word */ if (header->flags & MAD_FLAG_PROTECTION) { + if (mad_bit_length(&stream->ptr, &bufend_ptr) + < 4 * (bound * nch + (32 - bound))) { + stream->error = MAD_ERROR_BADCRC; + return -1; + } header->crc_check = mad_bit_crc(stream->ptr, 4 * (bound * nch + (32 - bound)), header->crc_check); @@ -133,6 +143,11 @@ int mad_layer_I(struct mad_stream *stream, struct mad_frame *frame) for (sb = 0; sb < bound; ++sb) { for (ch = 0; ch < nch; ++ch) { + if (mad_bit_length(&stream->ptr, &frameend_ptr) < 4) { + stream->error = MAD_ERROR_LOSTSYNC; + stream->sync = 0; + return -1; + } nb = mad_bit_read(&stream->ptr, 4); if (nb == 15) { @@ -145,6 +160,11 @@ int mad_layer_I(struct mad_stream *stream, struct mad_frame *frame) } for (sb = bound; sb < 32; ++sb) { + if (mad_bit_length(&stream->ptr, &frameend_ptr) < 4) { + stream->error = MAD_ERROR_LOSTSYNC; + stream->sync = 0; + return -1; + } nb = mad_bit_read(&stream->ptr, 4); if (nb == 15) { @@ -161,6 +181,11 @@ int mad_layer_I(struct mad_stream *stream, struct mad_frame *frame) for (sb = 0; sb < 32; ++sb) { for (ch = 0; ch < nch; ++ch) { if (allocation[ch][sb]) { + if (mad_bit_length(&stream->ptr, &frameend_ptr) < 6) { + stream->error = MAD_ERROR_LOSTSYNC; + stream->sync = 0; + return -1; + } scalefactor[ch][sb] = mad_bit_read(&stream->ptr, 6); # if defined(OPT_STRICT) @@ -185,8 +210,10 @@ int mad_layer_I(struct mad_stream *stream, struct mad_frame *frame) for (ch = 0; ch < nch; ++ch) { nb = allocation[ch][sb]; frame->sbsample[ch][s][sb] = nb ? - mad_f_mul(I_sample(&stream->ptr, nb), + mad_f_mul(I_sample(&stream->ptr, nb, stream), sf_table[scalefactor[ch][sb]]) : 0; + if (stream->error != 0) + return -1; } } @@ -194,7 +221,14 @@ int mad_layer_I(struct mad_stream *stream, struct mad_frame *frame) if ((nb = allocation[0][sb])) { mad_fixed_t sample; - sample = I_sample(&stream->ptr, nb); + if (mad_bit_length(&stream->ptr, &frameend_ptr) < nb) { + stream->error = MAD_ERROR_LOSTSYNC; + stream->sync = 0; + return -1; + } + sample = I_sample(&stream->ptr, nb, stream); + if (stream->error != 0) + return -1; for (ch = 0; ch < nch; ++ch) { frame->sbsample[ch][s][sb] = @@ -280,13 +314,21 @@ struct quantclass { static void II_samples(struct mad_bitptr *ptr, struct quantclass const *quantclass, - mad_fixed_t output[3]) + mad_fixed_t output[3], struct mad_stream *stream) { unsigned int nb, s, sample[3]; + struct mad_bitptr frameend_ptr; + + mad_bit_init(&frameend_ptr, stream->next_frame); if ((nb = quantclass->group)) { unsigned int c, nlevels; + if (mad_bit_length(ptr, &frameend_ptr) < quantclass->bits) { + stream->error = MAD_ERROR_LOSTSYNC; + stream->sync = 0; + return; + } /* degrouping */ c = mad_bit_read(ptr, quantclass->bits); nlevels = quantclass->nlevels; @@ -299,8 +341,14 @@ void II_samples(struct mad_bitptr *ptr, else { nb = quantclass->bits; - for (s = 0; s < 3; ++s) + for (s = 0; s < 3; ++s) { + if (mad_bit_length(ptr, &frameend_ptr) < nb) { + stream->error = MAD_ERROR_LOSTSYNC; + stream->sync = 0; + return; + } sample[s] = mad_bit_read(ptr, nb); + } } for (s = 0; s < 3; ++s) { @@ -336,6 +384,9 @@ int mad_layer_II(struct mad_stream *stream, struct mad_frame *frame) unsigned char const *offsets; unsigned char allocation[2][32], scfsi[2][32], scalefactor[2][32][3]; mad_fixed_t samples[3]; + struct mad_bitptr frameend_ptr; + + mad_bit_init(&frameend_ptr, stream->next_frame); nch = MAD_NCHANNELS(header); @@ -402,13 +453,24 @@ int mad_layer_II(struct mad_stream *stream, struct mad_frame *frame) for (sb = 0; sb < bound; ++sb) { nbal = bitalloc_table[offsets[sb]].nbal; - for (ch = 0; ch < nch; ++ch) + for (ch = 0; ch < nch; ++ch) { + if (mad_bit_length(&stream->ptr, &frameend_ptr) < nbal) { + stream->error = MAD_ERROR_LOSTSYNC; + stream->sync = 0; + return -1; + } allocation[ch][sb] = mad_bit_read(&stream->ptr, nbal); + } } for (sb = bound; sb < sblimit; ++sb) { nbal = bitalloc_table[offsets[sb]].nbal; + if (mad_bit_length(&stream->ptr, &frameend_ptr) < nbal) { + stream->error = MAD_ERROR_LOSTSYNC; + stream->sync = 0; + return -1; + } allocation[0][sb] = allocation[1][sb] = mad_bit_read(&stream->ptr, nbal); } @@ -417,8 +479,14 @@ int mad_layer_II(struct mad_stream *stream, struct mad_frame *frame) for (sb = 0; sb < sblimit; ++sb) { for (ch = 0; ch < nch; ++ch) { - if (allocation[ch][sb]) + if (allocation[ch][sb]) { + if (mad_bit_length(&stream->ptr, &frameend_ptr) < 2) { + stream->error = MAD_ERROR_LOSTSYNC; + stream->sync = 0; + return -1; + } scfsi[ch][sb] = mad_bit_read(&stream->ptr, 2); + } } } @@ -441,6 +509,11 @@ int mad_layer_II(struct mad_stream *stream, struct mad_frame *frame) for (sb = 0; sb < sblimit; ++sb) { for (ch = 0; ch < nch; ++ch) { if (allocation[ch][sb]) { + if (mad_bit_length(&stream->ptr, &frameend_ptr) < 6) { + stream->error = MAD_ERROR_LOSTSYNC; + stream->sync = 0; + return -1; + } scalefactor[ch][sb][0] = mad_bit_read(&stream->ptr, 6); switch (scfsi[ch][sb]) { @@ -451,11 +524,21 @@ int mad_layer_II(struct mad_stream *stream, struct mad_frame *frame) break; case 0: + if (mad_bit_length(&stream->ptr, &frameend_ptr) < 6) { + stream->error = MAD_ERROR_LOSTSYNC; + stream->sync = 0; + return -1; + } scalefactor[ch][sb][1] = mad_bit_read(&stream->ptr, 6); /* fall through */ case 1: case 3: + if (mad_bit_length(&stream->ptr, &frameend_ptr) < 6) { + stream->error = MAD_ERROR_LOSTSYNC; + stream->sync = 0; + return -1; + } scalefactor[ch][sb][2] = mad_bit_read(&stream->ptr, 6); } @@ -487,7 +570,9 @@ int mad_layer_II(struct mad_stream *stream, struct mad_frame *frame) if ((index = allocation[ch][sb])) { index = offset_table[bitalloc_table[offsets[sb]].offset][index - 1]; - II_samples(&stream->ptr, &qc_table[index], samples); + II_samples(&stream->ptr, &qc_table[index], samples, stream); + if (stream->error != 0) + return -1; for (s = 0; s < 3; ++s) { frame->sbsample[ch][3 * gr + s][sb] = @@ -505,7 +590,9 @@ int mad_layer_II(struct mad_stream *stream, struct mad_frame *frame) if ((index = allocation[0][sb])) { index = offset_table[bitalloc_table[offsets[sb]].offset][index - 1]; - II_samples(&stream->ptr, &qc_table[index], samples); + II_samples(&stream->ptr, &qc_table[index], samples, stream); + if (stream->error != 0) + return -1; for (ch = 0; ch < nch; ++ch) { for (s = 0; s < 3; ++s) { diff --git a/code/libmad-0.15.1b/layer12.h b/code/libmad/layer12.h similarity index 96% rename from code/libmad-0.15.1b/layer12.h rename to code/libmad/layer12.h index e1c49969..8caa3f75 100644 --- a/code/libmad-0.15.1b/layer12.h +++ b/code/libmad/layer12.h @@ -22,8 +22,7 @@ # ifndef LIBMAD_LAYER12_H # define LIBMAD_LAYER12_H -# include "stream.h" -# include "frame.h" +# include "mad.h" int mad_layer_I(struct mad_stream *, struct mad_frame *); int mad_layer_II(struct mad_stream *, struct mad_frame *); diff --git a/code/libmad-0.15.1b/layer3.c b/code/libmad/layer3.c similarity index 93% rename from code/libmad-0.15.1b/layer3.c rename to code/libmad/layer3.c index 4e5d3fa0..7f18fd72 100644 --- a/code/libmad-0.15.1b/layer3.c +++ b/code/libmad/layer3.c @@ -19,10 +19,6 @@ * $Id: layer3.c,v 1.43 2004/01/23 09:41:32 rob Exp $ */ -# ifdef HAVE_CONFIG_H -# include "config.h" -# endif - # include "global.h" # include @@ -38,10 +34,7 @@ # define CHAR_BIT 8 # endif -# include "fixed.h" -# include "bit.h" -# include "stream.h" -# include "frame.h" +# include "mad.h" # include "huffman.h" # include "layer3.h" @@ -598,7 +591,8 @@ enum mad_error III_sideinfo(struct mad_bitptr *ptr, unsigned int nch, static unsigned int III_scalefactors_lsf(struct mad_bitptr *ptr, struct channel *channel, - struct channel *gr1ch, int mode_extension) + struct channel *gr1ch, int mode_extension, + unsigned int bits_left, unsigned int *part2_length) { struct mad_bitptr start; unsigned int scalefac_compress, index, slen[4], part, n, i; @@ -644,8 +638,12 @@ unsigned int III_scalefactors_lsf(struct mad_bitptr *ptr, n = 0; for (part = 0; part < 4; ++part) { - for (i = 0; i < nsfb[part]; ++i) + for (i = 0; i < nsfb[part]; ++i) { + if (bits_left < slen[part]) + return MAD_ERROR_BADSCFSI; channel->scalefac[n++] = mad_bit_read(ptr, slen[part]); + bits_left -= slen[part]; + } } while (n < 39) @@ -690,7 +688,10 @@ unsigned int III_scalefactors_lsf(struct mad_bitptr *ptr, max = (1 << slen[part]) - 1; for (i = 0; i < nsfb[part]; ++i) { + if (bits_left < slen[part]) + return MAD_ERROR_BADSCFSI; is_pos = mad_bit_read(ptr, slen[part]); + bits_left -= slen[part]; channel->scalefac[n] = is_pos; gr1ch->scalefac[n++] = (is_pos == max); @@ -703,7 +704,8 @@ unsigned int III_scalefactors_lsf(struct mad_bitptr *ptr, } } - return mad_bit_length(&start, ptr); + *part2_length = mad_bit_length(&start, ptr); + return MAD_ERROR_NONE; } /* @@ -712,7 +714,8 @@ unsigned int III_scalefactors_lsf(struct mad_bitptr *ptr, */ static unsigned int III_scalefactors(struct mad_bitptr *ptr, struct channel *channel, - struct channel const *gr0ch, unsigned int scfsi) + struct channel const *gr0ch, unsigned int scfsi, + unsigned int bits_left, unsigned int *part2_length) { struct mad_bitptr start; unsigned int slen1, slen2, sfbi; @@ -728,12 +731,20 @@ unsigned int III_scalefactors(struct mad_bitptr *ptr, struct channel *channel, sfbi = 0; nsfb = (channel->flags & mixed_block_flag) ? 8 + 3 * 3 : 6 * 3; - while (nsfb--) + while (nsfb--) { + if (bits_left < slen1) + return MAD_ERROR_BADSCFSI; channel->scalefac[sfbi++] = mad_bit_read(ptr, slen1); + bits_left -= slen1; + } nsfb = 6 * 3; - while (nsfb--) + while (nsfb--) { + if (bits_left < slen2) + return MAD_ERROR_BADSCFSI; channel->scalefac[sfbi++] = mad_bit_read(ptr, slen2); + bits_left -= slen2; + } nsfb = 1 * 3; while (nsfb--) @@ -745,8 +756,12 @@ unsigned int III_scalefactors(struct mad_bitptr *ptr, struct channel *channel, channel->scalefac[sfbi] = gr0ch->scalefac[sfbi]; } else { - for (sfbi = 0; sfbi < 6; ++sfbi) + for (sfbi = 0; sfbi < 6; ++sfbi) { + if (bits_left < slen1) + return MAD_ERROR_BADSCFSI; channel->scalefac[sfbi] = mad_bit_read(ptr, slen1); + bits_left -= slen1; + } } if (scfsi & 0x4) { @@ -754,8 +769,12 @@ unsigned int III_scalefactors(struct mad_bitptr *ptr, struct channel *channel, channel->scalefac[sfbi] = gr0ch->scalefac[sfbi]; } else { - for (sfbi = 6; sfbi < 11; ++sfbi) + for (sfbi = 6; sfbi < 11; ++sfbi) { + if (bits_left < slen1) + return MAD_ERROR_BADSCFSI; channel->scalefac[sfbi] = mad_bit_read(ptr, slen1); + bits_left -= slen1; + } } if (scfsi & 0x2) { @@ -763,8 +782,12 @@ unsigned int III_scalefactors(struct mad_bitptr *ptr, struct channel *channel, channel->scalefac[sfbi] = gr0ch->scalefac[sfbi]; } else { - for (sfbi = 11; sfbi < 16; ++sfbi) + for (sfbi = 11; sfbi < 16; ++sfbi) { + if (bits_left < slen2) + return MAD_ERROR_BADSCFSI; channel->scalefac[sfbi] = mad_bit_read(ptr, slen2); + bits_left -= slen2; + } } if (scfsi & 0x1) { @@ -772,14 +795,19 @@ unsigned int III_scalefactors(struct mad_bitptr *ptr, struct channel *channel, channel->scalefac[sfbi] = gr0ch->scalefac[sfbi]; } else { - for (sfbi = 16; sfbi < 21; ++sfbi) + for (sfbi = 16; sfbi < 21; ++sfbi) { + if (bits_left < slen2) + return MAD_ERROR_BADSCFSI; channel->scalefac[sfbi] = mad_bit_read(ptr, slen2); + bits_left -= slen2; + } } channel->scalefac[21] = 0; } - return mad_bit_length(&start, ptr); + *part2_length = mad_bit_length(&start, ptr); + return MAD_ERROR_NONE; } /* @@ -933,19 +961,17 @@ static enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xr[576], struct channel *channel, unsigned char const *sfbwidth, - unsigned int part2_length) + signed int part3_length) { signed int exponents[39], exp; signed int const *expptr; struct mad_bitptr peek; - signed int bits_left, cachesz; + signed int bits_left, cachesz, fakebits; register mad_fixed_t *xrptr; mad_fixed_t const *sfbound; register unsigned long bitcache; - bits_left = (signed) channel->part2_3_length - (signed) part2_length; - if (bits_left < 0) - return MAD_ERROR_BADPART3LEN; + bits_left = part3_length; III_exponents(channel, sfbwidth, exponents); @@ -956,8 +982,12 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xr[576], cachesz = mad_bit_bitsleft(&peek); cachesz += ((32 - 1 - 24) + (24 - cachesz)) & ~7; + if (bits_left < cachesz) { + cachesz = bits_left; + } bitcache = mad_bit_read(&peek, cachesz); bits_left -= cachesz; + fakebits = 0; xrptr = &xr[0]; @@ -986,7 +1016,7 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xr[576], big_values = channel->big_values; - while (big_values-- && cachesz + bits_left > 0) { + while (big_values-- && cachesz + bits_left - fakebits > 0) { union huffpair const *pair; unsigned int clumpsz, value; register mad_fixed_t requantized; @@ -1023,10 +1053,19 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xr[576], unsigned int bits; bits = ((32 - 1 - 21) + (21 - cachesz)) & ~7; + if (bits_left < bits) { + bits = bits_left; + } bitcache = (bitcache << bits) | mad_bit_read(&peek, bits); cachesz += bits; bits_left -= bits; } + if (cachesz < 21) { + unsigned int bits = 21 - cachesz; + bitcache <<= bits; + cachesz += bits; + fakebits += bits; + } /* hcod (0..19) */ @@ -1041,6 +1080,8 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xr[576], } cachesz -= pair->value.hlen; + if (cachesz < fakebits) + return MAD_ERROR_BADHUFFDATA; if (linbits) { /* x (0..14) */ @@ -1054,10 +1095,15 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xr[576], case 15: if (cachesz < linbits + 2) { - bitcache = (bitcache << 16) | mad_bit_read(&peek, 16); - cachesz += 16; - bits_left -= 16; + unsigned int bits = 16; + if (bits_left < 16) + bits = bits_left; + bitcache = (bitcache << bits) | mad_bit_read(&peek, bits); + cachesz += bits; + bits_left -= bits; } + if (cachesz - fakebits < linbits) + return MAD_ERROR_BADHUFFDATA; value += MASK(bitcache, cachesz, linbits); cachesz -= linbits; @@ -1074,6 +1120,8 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xr[576], } x_final: + if (cachesz - fakebits < 1) + return MAD_ERROR_BADHUFFDATA; xrptr[0] = MASK1BIT(bitcache, cachesz--) ? -requantized : requantized; } @@ -1089,10 +1137,15 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xr[576], case 15: if (cachesz < linbits + 1) { - bitcache = (bitcache << 16) | mad_bit_read(&peek, 16); - cachesz += 16; - bits_left -= 16; + unsigned int bits = 16; + if (bits_left < 16) + bits = bits_left; + bitcache = (bitcache << bits) | mad_bit_read(&peek, bits); + cachesz += bits; + bits_left -= bits; } + if (cachesz - fakebits < linbits) + return MAD_ERROR_BADHUFFDATA; value += MASK(bitcache, cachesz, linbits); cachesz -= linbits; @@ -1109,6 +1162,8 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xr[576], } y_final: + if (cachesz - fakebits < 1) + return MAD_ERROR_BADHUFFDATA; xrptr[1] = MASK1BIT(bitcache, cachesz--) ? -requantized : requantized; } @@ -1128,6 +1183,8 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xr[576], requantized = reqcache[value] = III_requantize(value, exp); } + if (cachesz - fakebits < 1) + return MAD_ERROR_BADHUFFDATA; xrptr[0] = MASK1BIT(bitcache, cachesz--) ? -requantized : requantized; } @@ -1146,6 +1203,8 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xr[576], requantized = reqcache[value] = III_requantize(value, exp); } + if (cachesz - fakebits < 1) + return MAD_ERROR_BADHUFFDATA; xrptr[1] = MASK1BIT(bitcache, cachesz--) ? -requantized : requantized; } @@ -1155,9 +1214,6 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xr[576], } } - if (cachesz + bits_left < 0) - return MAD_ERROR_BADHUFFDATA; /* big_values overrun */ - /* count1 */ { union huffquad const *table; @@ -1167,15 +1223,24 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xr[576], requantized = III_requantize(1, exp); - while (cachesz + bits_left > 0 && xrptr <= &xr[572]) { + while (cachesz + bits_left - fakebits > 0 && xrptr <= &xr[572]) { union huffquad const *quad; /* hcod (1..6) */ if (cachesz < 10) { - bitcache = (bitcache << 16) | mad_bit_read(&peek, 16); - cachesz += 16; - bits_left -= 16; + unsigned int bits = 16; + if (bits_left < 16) + bits = bits_left; + bitcache = (bitcache << bits) | mad_bit_read(&peek, bits); + cachesz += bits; + bits_left -= bits; + } + if (cachesz < 10) { + unsigned int bits = 10 - cachesz; + bitcache <<= bits; + cachesz += bits; + fakebits += bits; } quad = &table[MASK(bitcache, cachesz, 4)]; @@ -1188,6 +1253,11 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xr[576], MASK(bitcache, cachesz, quad->ptr.bits)]; } + if (cachesz - fakebits < quad->value.hlen + quad->value.v + + quad->value.w + quad->value.x + quad->value.y) + /* We don't have enough bits to read one more entry, consider them + * stuffing bits. */ + break; cachesz -= quad->value.hlen; if (xrptr == sfbound) { @@ -1236,22 +1306,8 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xr[576], xrptr += 2; } - - if (cachesz + bits_left < 0) { -# if 0 && defined(DEBUG) - fprintf(stderr, "huffman count1 overrun (%d bits)\n", - -(cachesz + bits_left)); -# endif - - /* technically the bitstream is misformatted, but apparently - some encoders are just a bit sloppy with stuffing bits */ - - xrptr -= 4; - } } - assert(-bits_left <= MAD_BUFFER_GUARD * CHAR_BIT); - # if 0 && defined(DEBUG) if (bits_left < 0) fprintf(stderr, "read %d bits too many\n", -bits_left); @@ -2348,10 +2404,11 @@ void III_freqinver(mad_fixed_t sample[18][32], unsigned int sb) */ static enum mad_error III_decode(struct mad_bitptr *ptr, struct mad_frame *frame, - struct sideinfo *si, unsigned int nch) + struct sideinfo *si, unsigned int nch, unsigned int md_len) { struct mad_header *header = &frame->header; unsigned int sfreqi, ngr, gr; + int bits_left = md_len * CHAR_BIT; { unsigned int sfreq; @@ -2383,6 +2440,7 @@ enum mad_error III_decode(struct mad_bitptr *ptr, struct mad_frame *frame, for (ch = 0; ch < nch; ++ch) { struct channel *channel = &granule->ch[ch]; unsigned int part2_length; + unsigned int part3_length; sfbwidth[ch] = sfbwidth_table[sfreqi].l; if (channel->block_type == 2) { @@ -2391,18 +2449,30 @@ enum mad_error III_decode(struct mad_bitptr *ptr, struct mad_frame *frame, } if (header->flags & MAD_FLAG_LSF_EXT) { - part2_length = III_scalefactors_lsf(ptr, channel, + error = III_scalefactors_lsf(ptr, channel, ch == 0 ? 0 : &si->gr[1].ch[1], - header->mode_extension); + header->mode_extension, bits_left, &part2_length); } else { - part2_length = III_scalefactors(ptr, channel, &si->gr[0].ch[ch], - gr == 0 ? 0 : si->scfsi[ch]); + error = III_scalefactors(ptr, channel, &si->gr[0].ch[ch], + gr == 0 ? 0 : si->scfsi[ch], bits_left, &part2_length); } + if (error) + return error; - error = III_huffdecode(ptr, xr[ch], channel, sfbwidth[ch], part2_length); + bits_left -= part2_length; + + if (part2_length > channel->part2_3_length) + return MAD_ERROR_BADPART3LEN; + + part3_length = channel->part2_3_length - part2_length; + if (part3_length > bits_left) + return MAD_ERROR_BADPART3LEN; + + error = III_huffdecode(ptr, xr[ch], channel, sfbwidth[ch], part3_length); if (error) return error; + bits_left -= part3_length; } /* joint stereo processing */ @@ -2519,11 +2589,13 @@ int mad_layer_III(struct mad_stream *stream, struct mad_frame *frame) unsigned int nch, priv_bitlen, next_md_begin = 0; unsigned int si_len, data_bitlen, md_len; unsigned int frame_space, frame_used, frame_free; - struct mad_bitptr ptr; + struct mad_bitptr ptr, bufend_ptr; struct sideinfo si; enum mad_error error; int result = 0; + mad_bit_init(&bufend_ptr, stream->bufend); + /* allocate Layer III dynamic structures */ if (stream->main_data == 0) { @@ -2587,14 +2659,15 @@ int mad_layer_III(struct mad_stream *stream, struct mad_frame *frame) unsigned long header; mad_bit_init(&peek, stream->next_frame); + if (mad_bit_length(&peek, &bufend_ptr) >= 57) { + header = mad_bit_read(&peek, 32); + if ((header & 0xffe60000L) /* syncword | layer */ == 0xffe20000L) { + if (!(header & 0x00010000L)) /* protection_bit */ + mad_bit_skip(&peek, 16); /* crc_check */ - header = mad_bit_read(&peek, 32); - if ((header & 0xffe60000L) /* syncword | layer */ == 0xffe20000L) { - if (!(header & 0x00010000L)) /* protection_bit */ - mad_bit_skip(&peek, 16); /* crc_check */ - - next_md_begin = - mad_bit_read(&peek, (header & 0x00080000L) /* ID */ ? 9 : 8); + next_md_begin = + mad_bit_read(&peek, (header & 0x00080000L) /* ID */ ? 9 : 8); + } } mad_bit_finish(&peek); @@ -2608,6 +2681,11 @@ int mad_layer_III(struct mad_stream *stream, struct mad_frame *frame) next_md_begin = 0; md_len = si.main_data_begin + frame_space - next_md_begin; + if (md_len + MAD_BUFFER_GUARD > MAD_BUFFER_MDLEN) { + stream->error = MAD_ERROR_LOSTSYNC; + stream->sync = 0; + return -1; + } frame_used = 0; @@ -2625,8 +2703,11 @@ int mad_layer_III(struct mad_stream *stream, struct mad_frame *frame) } } else { - mad_bit_init(&ptr, - *stream->main_data + stream->md_len - si.main_data_begin); + memmove(stream->main_data, + *stream->main_data + stream->md_len - si.main_data_begin, + si.main_data_begin); + stream->md_len = si.main_data_begin; + mad_bit_init(&ptr, *stream->main_data); if (md_len > si.main_data_begin) { assert(stream->md_len + md_len - @@ -2645,7 +2726,7 @@ int mad_layer_III(struct mad_stream *stream, struct mad_frame *frame) /* decode main_data */ if (result == 0) { - error = III_decode(&ptr, frame, &si, nch); + error = III_decode(&ptr, frame, &si, nch, md_len); if (error) { stream->error = error; result = -1; diff --git a/code/libmad-0.15.1b/layer3.h b/code/libmad/layer3.h similarity index 96% rename from code/libmad-0.15.1b/layer3.h rename to code/libmad/layer3.h index 2504d461..618951b0 100644 --- a/code/libmad-0.15.1b/layer3.h +++ b/code/libmad/layer3.h @@ -22,8 +22,7 @@ # ifndef LIBMAD_LAYER3_H # define LIBMAD_LAYER3_H -# include "stream.h" -# include "frame.h" +# include "mad.h" int mad_layer_III(struct mad_stream *, struct mad_frame *); diff --git a/code/libmad-0.15.1b/mad.h b/code/libmad/mad.h.in similarity index 95% rename from code/libmad-0.15.1b/mad.h rename to code/libmad/mad.h.in index 9ef6cc8f..0e790d3e 100644 --- a/code/libmad-0.15.1b/mad.h +++ b/code/libmad/mad.h.in @@ -24,24 +24,25 @@ extern "C" { # endif -# define FPM_INTEL - - - -# define SIZEOF_INT 4 -# define SIZEOF_LONG 4 -# define SIZEOF_LONG_LONG 8 +#cmakedefine FPM_INTEL +#cmakedefine FPM_ARM +#cmakedefine FPM_MIPS +#cmakedefine FPM_SPARC +#cmakedefine FPM_PPC +#cmakedefine FPM_64BIT +#cmakedefine FPM_DEFAULT +# define SIZEOF_INT @SIZEOF_INT@ /* Id: version.h,v 1.26 2004/01/23 09:41:33 rob Exp */ # ifndef LIBMAD_VERSION_H # define LIBMAD_VERSION_H -# define MAD_VERSION_MAJOR 0 -# define MAD_VERSION_MINOR 15 -# define MAD_VERSION_PATCH 1 -# define MAD_VERSION_EXTRA " (beta)" +# define MAD_VERSION_MAJOR @CMAKE_PROJECT_VERSION_MAJOR@ +# define MAD_VERSION_MINOR @CMAKE_PROJECT_VERSION_MINOR@ +# define MAD_VERSION_PATCH @CMAKE_PROJECT_VERSION_PATCH@ +# define MAD_VERSION_EXTRA "" # define MAD_VERSION_STRINGIZE(str) #str # define MAD_VERSION_STRING(num) MAD_VERSION_STRINGIZE(num) @@ -67,23 +68,19 @@ extern char const mad_build[]; # ifndef LIBMAD_FIXED_H # define LIBMAD_FIXED_H +# include + # if SIZEOF_INT >= 4 typedef signed int mad_fixed_t; - typedef signed int mad_fixed64hi_t; typedef unsigned int mad_fixed64lo_t; # else typedef signed long mad_fixed_t; - typedef signed long mad_fixed64hi_t; typedef unsigned long mad_fixed64lo_t; # endif -# if defined(_MSC_VER) -# define mad_fixed64_t signed __int64 -# elif 1 || defined(__GNUC__) -# define mad_fixed64_t signed long long -# endif +typedef int64_t mad_fixed64_t; # if defined(FPM_FLOAT) typedef double mad_sample_t; @@ -320,12 +317,25 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y) : "+r" (lo), "+r" (hi) \ : "%r" (x), "r" (y)) +#ifdef __thumb__ +/* In Thumb-2, the RSB-immediate instruction is only allowed with a zero + operand. If needed this code can also support Thumb-1 + (simply append "s" to the end of the second two instructions). */ +# define MAD_F_MLN(hi, lo) \ + asm ("rsbs %0, %0, #0\n\t" \ + "sbc %1, %1, %1\n\t" \ + "sub %1, %1, %2" \ + : "+&r" (lo), "=&r" (hi) \ + : "r" (hi) \ + : "cc") +#else /* ! __thumb__ */ # define MAD_F_MLN(hi, lo) \ asm ("rsbs %0, %2, #0\n\t" \ "rsc %1, %3, #0" \ - : "=r" (lo), "=r" (hi) \ + : "=&r" (lo), "=r" (hi) \ : "0" (lo), "1" (hi) \ : "cc") +#endif /* __thumb__ */ # define mad_f_scale64(hi, lo) \ ({ mad_fixed_t __result; \ @@ -348,31 +358,13 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y) * This MIPS version is fast and accurate; the disposition of the least * significant bit depends on OPT_ACCURACY via mad_f_scale64(). */ -# define MAD_F_MLX(hi, lo, x, y) \ - asm ("mult %2,%3" \ - : "=l" (lo), "=h" (hi) \ - : "%r" (x), "r" (y)) - -# if defined(HAVE_MADD_ASM) -# define MAD_F_MLA(hi, lo, x, y) \ - asm ("madd %2,%3" \ - : "+l" (lo), "+h" (hi) \ - : "%r" (x), "r" (y)) -# elif defined(HAVE_MADD16_ASM) -/* - * This loses significant accuracy due to the 16-bit integer limit in the - * multiply/accumulate instruction. - */ -# define MAD_F_ML0(hi, lo, x, y) \ - asm ("mult %2,%3" \ - : "=l" (lo), "=h" (hi) \ - : "%r" ((x) >> 12), "r" ((y) >> 16)) -# define MAD_F_MLA(hi, lo, x, y) \ - asm ("madd16 %2,%3" \ - : "+l" (lo), "+h" (hi) \ - : "%r" ((x) >> 12), "r" ((y) >> 16)) -# define MAD_F_MLZ(hi, lo) ((mad_fixed_t) (lo)) -# endif + typedef unsigned int u64_di_t __attribute__ ((mode (DI))); +# define MAD_F_MLX(hi, lo, x, y) \ + do { \ + u64_di_t __ll = (u64_di_t) (x) * (y); \ + hi = __ll >> 32; \ + lo = __ll; \ + } while (0) # if defined(OPT_SPEED) # define mad_f_scale64(hi, lo) \ @@ -424,8 +416,8 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y) asm ("addc %0,%2,%3\n\t" \ "adde %1,%4,%5" \ : "=r" (lo), "=r" (hi) \ - : "%r" (lo), "r" (__lo), \ - "%r" (hi), "r" (__hi) \ + : "0" (lo), "r" (__lo), \ + "1" (hi), "r" (__hi) \ : "xer"); \ }) # endif diff --git a/code/libmad-0.15.1b/minimad.c b/code/libmad/minimad.c similarity index 100% rename from code/libmad-0.15.1b/minimad.c rename to code/libmad/minimad.c diff --git a/code/libmad/packaging/mad.pc.in b/code/libmad/packaging/mad.pc.in new file mode 100644 index 00000000..7cb5dbb1 --- /dev/null +++ b/code/libmad/packaging/mad.pc.in @@ -0,0 +1,10 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +includedir=@PKGCONFIG_INCLUDEDIR@ +libdir=@PKGCONFIG_LIBDIR@ + +Name: MAD +Description: MPEG audio decoder library +Version: @CMAKE_PROJECT_VERSION@ +URL: https://codeberg.org/tenacityteam/libmad +Libs: -L${libdir} -lmad +Cflags: -I${includedir} diff --git a/code/libmad/packaging/madConfig.cmake.in b/code/libmad/packaging/madConfig.cmake.in new file mode 100644 index 00000000..2b2e2ce0 --- /dev/null +++ b/code/libmad/packaging/madConfig.cmake.in @@ -0,0 +1,5 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/madTargets.cmake") + +check_required_components(mad) diff --git a/code/libmad-0.15.1b/qc_table.dat b/code/libmad/qc_table.dat similarity index 100% rename from code/libmad-0.15.1b/qc_table.dat rename to code/libmad/qc_table.dat diff --git a/code/libmad-0.15.1b/rq_table.dat b/code/libmad/rq_table.dat similarity index 100% rename from code/libmad-0.15.1b/rq_table.dat rename to code/libmad/rq_table.dat diff --git a/code/libmad-0.15.1b/sf_table.dat b/code/libmad/sf_table.dat similarity index 100% rename from code/libmad-0.15.1b/sf_table.dat rename to code/libmad/sf_table.dat diff --git a/code/libmad-0.15.1b/stream.c b/code/libmad/stream.c similarity index 97% rename from code/libmad-0.15.1b/stream.c rename to code/libmad/stream.c index 8bb4d6a4..18ce95ae 100644 --- a/code/libmad-0.15.1b/stream.c +++ b/code/libmad/stream.c @@ -19,16 +19,11 @@ * $Id: stream.c,v 1.12 2004/02/05 09:02:39 rob Exp $ */ -# ifdef HAVE_CONFIG_H -# include "config.h" -# endif - # include "global.h" # include -# include "bit.h" -# include "stream.h" +# include "mad.h" /* * NAME: stream->init() diff --git a/code/libmad-0.15.1b/synth.c b/code/libmad/synth.c similarity index 99% rename from code/libmad-0.15.1b/synth.c rename to code/libmad/synth.c index 1d28d438..110c9b28 100644 --- a/code/libmad-0.15.1b/synth.c +++ b/code/libmad/synth.c @@ -19,15 +19,9 @@ * $Id: synth.c,v 1.25 2004/01/23 09:41:33 rob Exp $ */ -# ifdef HAVE_CONFIG_H -# include "config.h" -# endif - # include "global.h" -# include "fixed.h" -# include "frame.h" -# include "synth.h" +# include "mad.h" /* * NAME: synth->init() diff --git a/code/libmad-0.15.1b/timer.c b/code/libmad/timer.c similarity index 99% rename from code/libmad-0.15.1b/timer.c rename to code/libmad/timer.c index 4b909aba..df11316c 100644 --- a/code/libmad-0.15.1b/timer.c +++ b/code/libmad/timer.c @@ -19,10 +19,6 @@ * $Id: timer.c,v 1.18 2004/01/23 09:41:33 rob Exp $ */ -# ifdef HAVE_CONFIG_H -# include "config.h" -# endif - # include "global.h" # include @@ -31,7 +27,7 @@ # include # endif -# include "timer.h" +# include "mad.h" mad_timer_t const mad_timer_zero = { 0, 0 }; diff --git a/code/libmad-0.15.1b/version.c b/code/libmad/version.c similarity index 96% rename from code/libmad-0.15.1b/version.c rename to code/libmad/version.c index e643fa71..f3747567 100644 --- a/code/libmad-0.15.1b/version.c +++ b/code/libmad/version.c @@ -19,13 +19,9 @@ * $Id: version.c,v 1.15 2004/01/23 09:41:33 rob Exp $ */ -# ifdef HAVE_CONFIG_H -# include "config.h" -# endif - # include "global.h" -# include "version.h" +# include "mad.h" char const mad_version[] = "MPEG Audio Decoder " MAD_VERSION; char const mad_copyright[] = "Copyright (C) " MAD_PUBLISHYEAR " " MAD_AUTHOR; diff --git a/code/null/null_client.c b/code/null/null_client.c index 4027e404..3c70de34 100644 --- a/code/null/null_client.c +++ b/code/null/null_client.c @@ -62,6 +62,9 @@ void CL_CharEvent( int key ) { void CL_Disconnect() { } +void CL_AbnormalDisconnect() { +} + void CL_MapLoading( qboolean flush, const char *pszMapName ) { } @@ -125,3 +128,11 @@ void SCR_DebugGraph( float value ) { qboolean CL_FinishedIntro( void ) { return qtrue; } + +int R_CountTextureMemory() { + return 0; +} + +qboolean CL_UseLargeLightmap(const char* mapName) { + return qtrue; +} diff --git a/code/null/null_snddma.c b/code/null/null_snddma.c index 28cfb1ec..9b782fa7 100644 --- a/code/null/null_snddma.c +++ b/code/null/null_snddma.c @@ -47,15 +47,30 @@ void SNDDMA_Submit(void) { } -void SNDDMA_Activate(void) { +#ifdef USE_VOIP +void SNDDMA_StartCapture(void) +{ } -sfxHandle_t S_RegisterSound( const char *sample, qboolean compressed ) +int SNDDMA_AvailableCaptureSamples(void) { return 0; } -void S_StartLocalSound( sfxHandle_t sfx, int channelNum ) { +void SNDDMA_Capture(int samples, byte *data) +{ +} + +void SNDDMA_StopCapture(void) +{ +} + +void SNDDMA_MasterGain( float val ) +{ +} +#endif + +void SNDDMA_Activate(void) { } void S_ClearSoundBuffer( void ) { @@ -64,3 +79,17 @@ void S_ClearSoundBuffer( void ) { int S_IsSoundPlaying( int channel_number, const char *sfxName ){ return 0; } + +#if defined(NO_MODERN_DMA) && NO_MODERN_DMA +void S_StartLocalSound(sfxHandle_t sfx, int channelNum) { +} +sfxHandle_t S_RegisterSound(const char* sample, qboolean compressed) { + return 0; +} +#else +void S_StartLocalSound(const char* sound_name, qboolean force_load) { +} +sfxHandle_t S_RegisterSound(const char* name, int streamed, qboolean force_load) { + return 0; +} +#endif diff --git a/code/parser/bison_source.txt b/code/parser/bison_source.txt index e5d393ef..b3ba1d42 100644 --- a/code/parser/bison_source.txt +++ b/code/parser/bison_source.txt @@ -1,7 +1,7 @@ %{ /* * =========================================================================== -* Copyright (C) 2015 the OpenMoHAA team +* Copyright (C) 2025 the OpenMoHAA team * * This file is part of OpenMoHAA source code. * @@ -57,7 +57,7 @@ int success_pos; %precedence TOKEN_EOL %union { - stype_t s; + stype_t s; } %left TOKEN_COMMA @@ -71,11 +71,11 @@ int success_pos; %left TOKEN_LEFT_BRACKET TOKEN_RIGHT_BRACKET %token TOKEN_LEFT_SQUARE_BRACKET TOKEN_RIGHT_SQUARE_BRACKET -%right TOKEN_ASSIGNMENT - TOKEN_PLUS_EQUALS TOKEN_MINUS_EQUALS TOKEN_MULTIPLY_EQUALS TOKEN_DIVIDE_EQUALS TOKEN_MODULUS_EQUALS - TOKEN_AND_EQUALS TOKEN_EXCL_OR_EQUALS TOKEN_OR_EQUALS - TOKEN_SHIFT_LEFT_EQUALS TOKEN_SHIFT_RIGHT_EQUALS - TOKEN_TERNARY TOKEN_COLON +%right TOKEN_ASSIGNMENT + TOKEN_PLUS_EQUALS TOKEN_MINUS_EQUALS TOKEN_MULTIPLY_EQUALS TOKEN_DIVIDE_EQUALS TOKEN_MODULUS_EQUALS + TOKEN_AND_EQUALS TOKEN_EXCL_OR_EQUALS TOKEN_OR_EQUALS + TOKEN_SHIFT_LEFT_EQUALS TOKEN_SHIFT_RIGHT_EQUALS + TOKEN_TERNARY TOKEN_COLON %left TOKEN_LOGICAL_OR %left TOKEN_LOGICAL_AND @@ -103,19 +103,18 @@ int success_pos; %left TOKEN_DOUBLE_COLON %left TOKEN_SEMICOLON %right TOKEN_DOLLAR -%left TOKEN_NUMBER %token TOKEN_INCREMENT TOKEN_DECREMENT TOKEN_PERIOD %right TOKEN_INCREMENT TOKEN_DECREMENT TOKEN_NEG TOKEN_NOT TOKEN_COMPLEMENT %left TOKEN_LEFT_SQUARE_BRACKET TOKEN_RIGHT_SQUARE_BRACKET TOKEN_PERIOD -%precedence TOKEN_CATCH TOKEN_TRY - TOKEN_SWITCH TOKEN_CASE - TOKEN_BREAK TOKEN_CONTINUE - TOKEN_SIZE - TOKEN_END TOKEN_RETURN - TOKEN_MAKEARRAY TOKEN_ENDARRAY +%precedence TOKEN_CATCH TOKEN_TRY + TOKEN_SWITCH TOKEN_CASE + TOKEN_BREAK TOKEN_CONTINUE + TOKEN_SIZE + TOKEN_END TOKEN_RETURN + TOKEN_MAKEARRAY TOKEN_ENDARRAY %type event_parameter_list event_parameter_list_need event_parameter %type statement_list statement statement_declaration makearray_statement_list makearray_statement statement_for_condition @@ -125,6 +124,7 @@ int success_pos; %type prim_expr %type listener_identifier %type nonident_prim_expr +%type nonident_prim_expr_base %type const_array_list %type const_array %type identifier_prim @@ -135,203 +135,207 @@ int success_pos; %% program - : statement_list[list] { parsedata.val = node1(ENUM_statement_list, $list); } - | line_opt { parsedata.val = node0(ENUM_NOP); } - ; + : statement_list[list] { parsedata.val = node1(ENUM_statement_list, $list); } + | line_opt { parsedata.val = node0(ENUM_NOP); } + ; statement_list - : statement { $$ = linked_list_end($1); } - | statement_list statement[stmt] { $$ = append_node($1, $stmt); } - ; + : statement { $$ = linked_list_end($1); } + | statement_list statement[stmt] { $$ = append_node($1, $stmt); } + ; statement - : line_opt statement_declaration[stmt_decl] line_opt { $$ = $stmt_decl; } - ; + : line_opt statement_declaration[stmt_decl] line_opt { $$ = $stmt_decl; } + ; statement_declaration - : TOKEN_IDENTIFIER event_parameter_list TOKEN_COLON { $$ = node3(ENUM_labeled_statement, $1, $2, TOKPOS(@1)); } - | TOKEN_CASE prim_expr event_parameter_list TOKEN_COLON { $$ = node3(ENUM_int_labeled_statement, $2, $3, TOKPOS(@1)); } - | compound_statement - | selection_statement - | iteration_statement - | TOKEN_TRY compound_statement[C1] TOKEN_CATCH compound_statement[C2] { $$ = node3(ENUM_try, $C1, $C2, TOKPOS(@1)); } - | TOKEN_BREAK { $$ = node1(ENUM_break, TOKPOS(@1)); } - | TOKEN_CONTINUE { $$ = node1(ENUM_continue, TOKPOS(@1)); } - | TOKEN_IDENTIFIER event_parameter_list { $$ = node3(ENUM_cmd_event_statement, $1, $2, TOKPOS(@1)); } - | nonident_prim_expr TOKEN_IDENTIFIER event_parameter_list { $$ = node4(ENUM_method_event_statement, $1, $2, $3, TOKPOS(@2)); } - | nonident_prim_expr TOKEN_ASSIGNMENT expr { $$ = node3(ENUM_assignment_statement, $1, $3, TOKPOS(@2)); } - | nonident_prim_expr TOKEN_PLUS_EQUALS expr { $$ = node3(ENUM_assignment_statement, $1, node4(ENUM_func2_expr, node1b(OP_BIN_PLUS), $1, $3, TOKPOS(@2)), TOKPOS(@2)); } - | nonident_prim_expr TOKEN_MINUS_EQUALS expr { $$ = node3(ENUM_assignment_statement, $1, node4(ENUM_func2_expr, node1b(OP_BIN_MINUS), $1, $3, TOKPOS(@2)), TOKPOS(@2)); } - | nonident_prim_expr TOKEN_MULTIPLY_EQUALS expr { $$ = node3(ENUM_assignment_statement, $1, node4(ENUM_func2_expr, node1b(OP_BIN_MULTIPLY), $1, $3, TOKPOS(@2)), TOKPOS(@2)); } - | nonident_prim_expr TOKEN_DIVIDE_EQUALS expr { $$ = node3(ENUM_assignment_statement, $1, node4(ENUM_func2_expr, node1b(OP_BIN_DIVIDE), $1, $3, TOKPOS(@2)), TOKPOS(@2)); } - | nonident_prim_expr TOKEN_MODULUS_EQUALS expr { $$ = node3(ENUM_assignment_statement, $1, node4(ENUM_func2_expr, node1b(OP_BIN_PERCENTAGE), $1, $3, TOKPOS(@2)), TOKPOS(@2)); } - | nonident_prim_expr TOKEN_AND_EQUALS expr { $$ = node3(ENUM_assignment_statement, $1, node4(ENUM_func2_expr, node1b(OP_BIN_BITWISE_AND), $1, $3, TOKPOS(@2)), TOKPOS(@2)); } - | nonident_prim_expr TOKEN_EXCL_OR_EQUALS expr { $$ = node3(ENUM_assignment_statement, $1, node4(ENUM_func2_expr, node1b(OP_BIN_BITWISE_EXCL_OR), $1, $3, TOKPOS(@2)), TOKPOS(@2)); } - | nonident_prim_expr TOKEN_OR_EQUALS expr { $$ = node3(ENUM_assignment_statement, $1, node4(ENUM_func2_expr, node1b(OP_BIN_BITWISE_OR), $1, $3, TOKPOS(@2)), TOKPOS(@2)); } - | nonident_prim_expr TOKEN_SHIFT_LEFT_EQUALS expr { $$ = node3(ENUM_assignment_statement, $1, node4(ENUM_func2_expr, node1b(OP_BIN_SHIFT_LEFT), $1, $3, TOKPOS(@2)), TOKPOS(@2)); } - | nonident_prim_expr TOKEN_SHIFT_RIGHT_EQUALS expr { $$ = node3(ENUM_assignment_statement, $1, node4(ENUM_func2_expr, node1b(OP_BIN_SHIFT_RIGHT), $1, $3, TOKPOS(@2)), TOKPOS(@2)); } - | nonident_prim_expr TOKEN_INCREMENT { $$ = node3(ENUM_assignment_statement, $1, node3(ENUM_func1_expr, node1b(OP_UN_INC), $1, TOKPOS(@2)), TOKPOS(@2)); } - | nonident_prim_expr TOKEN_DECREMENT { $$ = node3(ENUM_assignment_statement, $1, node3(ENUM_func1_expr, node1b(OP_UN_DEC), $1, TOKPOS(@2)), TOKPOS(@2)); } - | TOKEN_SEMICOLON { $$ = node0(ENUM_NOP); } - //| TOKEN_IDENTIFIER TOKEN_DOUBLE_COLON TOKEN_IDENTIFIER event_parameter_list { $$ = node3( ENUM_method_event_statement, node_string( parsetree_string( str( $1.stringValue ) + "::" + $3.stringValue ) ), node1( ENUM_NOP, $4 ), TOKPOS(@1) ); } - //| nonident_prim_expr TOKEN_IDENTIFIER TOKEN_DOUBLE_COLON TOKEN_IDENTIFIER event_parameter_list { $$ = node4( ENUM_method_event_statement, $1, node_string( parsetree_string( str( $2.stringValue ) + "::" + $4.stringValue ) ), node1( ENUM_NOP, $5 ), TOKPOS(@2) ); } - ; - + : TOKEN_IDENTIFIER event_parameter_list TOKEN_COLON { $$ = node3(ENUM_labeled_statement, $1, $2, TOKPOS(@1)); } + | TOKEN_CASE prim_expr event_parameter_list TOKEN_COLON { $$ = node3(ENUM_int_labeled_statement, $2, $3, TOKPOS(@1)); } + | compound_statement + | selection_statement + | iteration_statement + | TOKEN_TRY compound_statement[C1] TOKEN_CATCH compound_statement[C2] { $$ = node3(ENUM_try, $C1, $C2, TOKPOS(@1)); } + | TOKEN_BREAK { $$ = node1(ENUM_break, TOKPOS(@1)); } + | TOKEN_CONTINUE { $$ = node1(ENUM_continue, TOKPOS(@1)); } + | TOKEN_IDENTIFIER event_parameter_list { $$ = node3(ENUM_cmd_event_statement, $1, $2, TOKPOS(@1)); } + | nonident_prim_expr TOKEN_IDENTIFIER event_parameter_list { $$ = node4(ENUM_method_event_statement, $1, $2, $3, TOKPOS(@2)); } + | nonident_prim_expr TOKEN_ASSIGNMENT expr { $$ = node3(ENUM_assignment_statement, $1, $3, TOKPOS(@2)); } + | nonident_prim_expr TOKEN_PLUS_EQUALS expr { $$ = node3(ENUM_assignment_statement, $1, node4(ENUM_func2_expr, node1b(OP_BIN_PLUS), $1, $3, TOKPOS(@2)), TOKPOS(@2)); } + | nonident_prim_expr TOKEN_MINUS_EQUALS expr { $$ = node3(ENUM_assignment_statement, $1, node4(ENUM_func2_expr, node1b(OP_BIN_MINUS), $1, $3, TOKPOS(@2)), TOKPOS(@2)); } + | nonident_prim_expr TOKEN_MULTIPLY_EQUALS expr { $$ = node3(ENUM_assignment_statement, $1, node4(ENUM_func2_expr, node1b(OP_BIN_MULTIPLY), $1, $3, TOKPOS(@2)), TOKPOS(@2)); } + | nonident_prim_expr TOKEN_DIVIDE_EQUALS expr { $$ = node3(ENUM_assignment_statement, $1, node4(ENUM_func2_expr, node1b(OP_BIN_DIVIDE), $1, $3, TOKPOS(@2)), TOKPOS(@2)); } + | nonident_prim_expr TOKEN_MODULUS_EQUALS expr { $$ = node3(ENUM_assignment_statement, $1, node4(ENUM_func2_expr, node1b(OP_BIN_PERCENTAGE), $1, $3, TOKPOS(@2)), TOKPOS(@2)); } + | nonident_prim_expr TOKEN_AND_EQUALS expr { $$ = node3(ENUM_assignment_statement, $1, node4(ENUM_func2_expr, node1b(OP_BIN_BITWISE_AND), $1, $3, TOKPOS(@2)), TOKPOS(@2)); } + | nonident_prim_expr TOKEN_EXCL_OR_EQUALS expr { $$ = node3(ENUM_assignment_statement, $1, node4(ENUM_func2_expr, node1b(OP_BIN_BITWISE_EXCL_OR), $1, $3, TOKPOS(@2)), TOKPOS(@2)); } + | nonident_prim_expr TOKEN_OR_EQUALS expr { $$ = node3(ENUM_assignment_statement, $1, node4(ENUM_func2_expr, node1b(OP_BIN_BITWISE_OR), $1, $3, TOKPOS(@2)), TOKPOS(@2)); } + | nonident_prim_expr TOKEN_SHIFT_LEFT_EQUALS expr { $$ = node3(ENUM_assignment_statement, $1, node4(ENUM_func2_expr, node1b(OP_BIN_SHIFT_LEFT), $1, $3, TOKPOS(@2)), TOKPOS(@2)); } + | nonident_prim_expr TOKEN_SHIFT_RIGHT_EQUALS expr { $$ = node3(ENUM_assignment_statement, $1, node4(ENUM_func2_expr, node1b(OP_BIN_SHIFT_RIGHT), $1, $3, TOKPOS(@2)), TOKPOS(@2)); } + | nonident_prim_expr TOKEN_INCREMENT { $$ = node3(ENUM_assignment_statement, $1, node3(ENUM_func1_expr, node1b(OP_UN_INC), $1, TOKPOS(@2)), TOKPOS(@2)); } + | nonident_prim_expr TOKEN_DECREMENT { $$ = node3(ENUM_assignment_statement, $1, node3(ENUM_func1_expr, node1b(OP_UN_DEC), $1, TOKPOS(@2)), TOKPOS(@2)); } + | TOKEN_SEMICOLON { $$ = node0(ENUM_NOP); } + //| TOKEN_IDENTIFIER TOKEN_DOUBLE_COLON TOKEN_IDENTIFIER event_parameter_list { $$ = node3( ENUM_method_event_statement, node_string( parsetree_string( str( $1.stringValue ) + "::" + $3.stringValue ) ), node1( ENUM_NOP, $4 ), TOKPOS(@1) ); } + //| nonident_prim_expr TOKEN_IDENTIFIER TOKEN_DOUBLE_COLON TOKEN_IDENTIFIER event_parameter_list { $$ = node4( ENUM_method_event_statement, $1, node_string( parsetree_string( str( $2.stringValue ) + "::" + $4.stringValue ) ), node1( ENUM_NOP, $5 ), TOKPOS(@2) ); } + ; + statement_for_condition - : line_opt statement_declaration[stmt_decl] line_opt { $$ = $stmt_decl; } - | line_opt statement_declaration[stmt_decl] TOKEN_SEMICOLON line_opt { $$ = $stmt_decl; } - ; + : line_opt statement_declaration[stmt_decl] line_opt { $$ = $stmt_decl; } + | line_opt statement_declaration[stmt_decl] TOKEN_SEMICOLON line_opt { $$ = $stmt_decl; } + ; compound_statement - : TOKEN_LEFT_BRACES statement_list TOKEN_RIGHT_BRACES { $$ = node1(ENUM_statement_list, $2); } - | TOKEN_LEFT_BRACES line_opt TOKEN_RIGHT_BRACES { $$ = node0(ENUM_NOP); } - | line_opt compound_statement[comp_stmt] line_opt { $$ = $comp_stmt; } - ; + : TOKEN_LEFT_BRACES statement_list TOKEN_RIGHT_BRACES { $$ = node1(ENUM_statement_list, $2); } + | TOKEN_LEFT_BRACES line_opt TOKEN_RIGHT_BRACES { $$ = node0(ENUM_NOP); } + | line_opt compound_statement[comp_stmt] line_opt { $$ = $comp_stmt; } + ; selection_statement - : TOKEN_IF prim_expr[exp] statement_for_condition[stmt] %prec THEN { $$ = node3(ENUM_if_statement, $exp, $stmt, TOKPOS(@1)); } - | TOKEN_IF prim_expr[exp] statement_for_condition[if_stmt] TOKEN_ELSE statement_for_condition[else_stmt] { $$ = node4(ENUM_if_else_statement, $exp, $if_stmt, $else_stmt, TOKPOS(@1)); } - | TOKEN_SWITCH prim_expr[exp] compound_statement[comp_stmt] { $$ = node3(ENUM_switch, $exp, $comp_stmt, TOKPOS(@1)); } - ; + : TOKEN_IF prim_expr[exp] statement_for_condition[stmt] %prec THEN { $$ = node3(ENUM_if_statement, $exp, $stmt, TOKPOS(@1)); } + | TOKEN_IF prim_expr[exp] statement_for_condition[if_stmt] TOKEN_ELSE statement_for_condition[else_stmt] { $$ = node4(ENUM_if_else_statement, $exp, $if_stmt, $else_stmt, TOKPOS(@1)); } + | TOKEN_SWITCH prim_expr[exp] compound_statement[comp_stmt] { $$ = node3(ENUM_switch, $exp, $comp_stmt, TOKPOS(@1)); } + ; iteration_statement - : TOKEN_WHILE prim_expr[exp] statement_for_condition[stmt]{ $$ = node4(ENUM_while_statement, $exp, $stmt, node0(ENUM_NOP), TOKPOS(@1)); } - | TOKEN_FOR TOKEN_LEFT_BRACKET statement[init_stmt] TOKEN_SEMICOLON expr[exp] TOKEN_SEMICOLON statement_list[inc_stmt] TOKEN_RIGHT_BRACKET statement_for_condition[stmt] - { - sval_t while_stmt = node4(ENUM_while_statement, $exp, $stmt, node1(ENUM_statement_list, $inc_stmt), TOKPOS(@1)); - $$ = node1(ENUM_statement_list, append_node(linked_list_end($init_stmt), while_stmt)); - } - | TOKEN_FOR TOKEN_LEFT_BRACKET TOKEN_SEMICOLON expr[exp] TOKEN_SEMICOLON statement_list[inc_stmt] TOKEN_RIGHT_BRACKET statement_for_condition[stmt] - { - $$ = node4(ENUM_while_statement, $exp, $stmt, node1(ENUM_statement_list, $inc_stmt), TOKPOS(@1)); - } - | TOKEN_DO statement_for_condition[stmt] TOKEN_WHILE prim_expr[exp]{ $$ = node3(ENUM_do, $stmt, $exp, TOKPOS(@1)); } - ; + : TOKEN_WHILE prim_expr[exp] statement_for_condition[stmt]{ $$ = node4(ENUM_while_statement, $exp, $stmt, node0(ENUM_NOP), TOKPOS(@1)); } + | TOKEN_FOR TOKEN_LEFT_BRACKET statement[init_stmt] TOKEN_SEMICOLON expr[exp] TOKEN_SEMICOLON statement_list[inc_stmt] TOKEN_RIGHT_BRACKET statement_for_condition[stmt] + { + sval_t while_stmt = node4(ENUM_while_statement, $exp, $stmt, node1(ENUM_statement_list, $inc_stmt), TOKPOS(@1)); + $$ = node1(ENUM_statement_list, append_node(linked_list_end($init_stmt), while_stmt)); + } + | TOKEN_FOR TOKEN_LEFT_BRACKET TOKEN_SEMICOLON expr[exp] TOKEN_SEMICOLON statement_list[inc_stmt] TOKEN_RIGHT_BRACKET statement_for_condition[stmt] + { + $$ = node4(ENUM_while_statement, $exp, $stmt, node1(ENUM_statement_list, $inc_stmt), TOKPOS(@1)); + } + | TOKEN_DO statement_for_condition[stmt] TOKEN_WHILE prim_expr[exp]{ $$ = node3(ENUM_do, $stmt, $exp, TOKPOS(@1)); } + ; expr: - expr TOKEN_LOGICAL_AND expr { $$ = node3( ENUM_logical_and, $1, $3, TOKPOS(@2) ); } - | expr TOKEN_LOGICAL_OR expr { $$ = node3( ENUM_logical_or, $1, $3, TOKPOS(@2) ); } - | expr TOKEN_BITWISE_AND expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_BITWISE_AND ), $1, $3, TOKPOS(@2) ); } - | expr TOKEN_BITWISE_OR expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_BITWISE_OR ), $1, $3, TOKPOS(@2) ); } - | expr TOKEN_BITWISE_EXCL_OR expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_BITWISE_EXCL_OR ), $1, $3, TOKPOS(@2) ); } - | expr TOKEN_EQUALITY expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_EQUALITY ), $1, $3, TOKPOS(@2) ); } - | expr TOKEN_INEQUALITY expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_INEQUALITY ), $1, $3, TOKPOS(@2) ); } - | expr TOKEN_LESS_THAN expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_LESS_THAN ), $1, $3, TOKPOS(@2) ); } - | expr TOKEN_GREATER_THAN expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_GREATER_THAN ), $1, $3, TOKPOS(@2) ); } - | expr TOKEN_LESS_THAN_OR_EQUAL expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_LESS_THAN_OR_EQUAL ), $1, $3, TOKPOS(@2) ); } - | expr TOKEN_GREATER_THAN_OR_EQUAL expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_GREATER_THAN_OR_EQUAL ), $1, $3, TOKPOS(@2) ); } - | expr TOKEN_PLUS expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_PLUS ), $1, $3, TOKPOS(@2) ); } - | expr TOKEN_MINUS expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_MINUS ), $1, $3, TOKPOS(@2) ); } - | expr TOKEN_MULTIPLY expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_MULTIPLY ), $1, $3, TOKPOS(@2) ); } - | expr TOKEN_DIVIDE expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_DIVIDE ), $1, $3, TOKPOS(@2) ); } - | expr TOKEN_MODULUS expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_PERCENTAGE ), $1, $3, TOKPOS(@2) ); } - | expr TOKEN_SHIFT_LEFT expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_SHIFT_LEFT ), $1, $3, TOKPOS(@2) ); } - | expr TOKEN_SHIFT_RIGHT expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_SHIFT_RIGHT ), $1, $3, TOKPOS(@2) ); } - | expr TOKEN_TERNARY expr TOKEN_COLON expr { $$ = node4( ENUM_if_else_statement, $1, $3, $5, TOKPOS(@2) ); } - | TOKEN_EOL expr[exp] { $$ = $exp; } - | nonident_prim_expr - | func_prim_expr - | TOKEN_IDENTIFIER { $$ = node2(ENUM_string, $1, TOKPOS(@1)); } - ; + expr TOKEN_LOGICAL_AND expr { $$ = node3( ENUM_logical_and, $1, $3, TOKPOS(@2) ); } + | expr TOKEN_LOGICAL_OR expr { $$ = node3( ENUM_logical_or, $1, $3, TOKPOS(@2) ); } + | expr TOKEN_BITWISE_AND expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_BITWISE_AND ), $1, $3, TOKPOS(@2) ); } + | expr TOKEN_BITWISE_OR expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_BITWISE_OR ), $1, $3, TOKPOS(@2) ); } + | expr TOKEN_BITWISE_EXCL_OR expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_BITWISE_EXCL_OR ), $1, $3, TOKPOS(@2) ); } + | expr TOKEN_EQUALITY expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_EQUALITY ), $1, $3, TOKPOS(@2) ); } + | expr TOKEN_INEQUALITY expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_INEQUALITY ), $1, $3, TOKPOS(@2) ); } + | expr TOKEN_LESS_THAN expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_LESS_THAN ), $1, $3, TOKPOS(@2) ); } + | expr TOKEN_GREATER_THAN expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_GREATER_THAN ), $1, $3, TOKPOS(@2) ); } + | expr TOKEN_LESS_THAN_OR_EQUAL expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_LESS_THAN_OR_EQUAL ), $1, $3, TOKPOS(@2) ); } + | expr TOKEN_GREATER_THAN_OR_EQUAL expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_GREATER_THAN_OR_EQUAL ), $1, $3, TOKPOS(@2) ); } + | expr TOKEN_PLUS expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_PLUS ), $1, $3, TOKPOS(@2) ); } + | expr TOKEN_MINUS expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_MINUS ), $1, $3, TOKPOS(@2) ); } + | expr TOKEN_MULTIPLY expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_MULTIPLY ), $1, $3, TOKPOS(@2) ); } + | expr TOKEN_DIVIDE expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_DIVIDE ), $1, $3, TOKPOS(@2) ); } + | expr TOKEN_MODULUS expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_PERCENTAGE ), $1, $3, TOKPOS(@2) ); } + | expr TOKEN_SHIFT_LEFT expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_SHIFT_LEFT ), $1, $3, TOKPOS(@2) ); } + | expr TOKEN_SHIFT_RIGHT expr { $$ = node4( ENUM_func2_expr, node1b( OP_BIN_SHIFT_RIGHT ), $1, $3, TOKPOS(@2) ); } + | expr TOKEN_TERNARY expr TOKEN_COLON expr { $$ = node4( ENUM_if_else_statement, $1, $3, $5, TOKPOS(@2) ); } + | TOKEN_EOL expr[exp] { $$ = $exp; } + | nonident_prim_expr + | func_prim_expr + | TOKEN_IDENTIFIER { $$ = node2(ENUM_string, $1, TOKPOS(@1)); } + ; func_prim_expr: - TOKEN_IDENTIFIER event_parameter_list_need { $$ = node3(ENUM_cmd_event_expr, $1, $2, TOKPOS(@1)); } - | nonident_prim_expr TOKEN_IDENTIFIER event_parameter_list { $$ = node4(ENUM_method_event_expr, $1, $2, $3, TOKPOS(@2)); } - | TOKEN_NEG func_prim_expr { $$ = node3(ENUM_func1_expr, node1b(OP_UN_MINUS), $2, TOKPOS(@1)); } - | TOKEN_COMPLEMENT func_prim_expr { $$ = node3(ENUM_func1_expr, node1b(OP_UN_COMPLEMENT), $2, TOKPOS(@1)); } - | TOKEN_NOT func_prim_expr { $$ = node2(ENUM_bool_not, $2, TOKPOS(@1)); } - | TOKEN_IDENTIFIER TOKEN_DOUBLE_COLON const_array_list - { - $$ = node3(ENUM_const_array_expr, node2(ENUM_string, $1, TOKPOS(@1)), $3, TOKPOS(@2)); - } - | nonident_prim_expr TOKEN_DOUBLE_COLON const_array_list - { - $$ = node3(ENUM_const_array_expr, $1, $3, TOKPOS(@2)); - } - | TOKEN_MAKEARRAY makearray_statement_list[stmt] TOKEN_ENDARRAY - { - $$ = node2(ENUM_makearray, $stmt, TOKPOS(@1)); - } - ; + TOKEN_IDENTIFIER event_parameter_list_need { $$ = node3(ENUM_cmd_event_expr, $1, $2, TOKPOS(@1)); } + | nonident_prim_expr_base TOKEN_IDENTIFIER event_parameter_list { $$ = node4(ENUM_method_event_expr, $1, $2, $3, TOKPOS(@2)); } + | TOKEN_NEG func_prim_expr { $$ = node3(ENUM_func1_expr, node1b(OP_UN_MINUS), $2, TOKPOS(@1)); } + | TOKEN_COMPLEMENT func_prim_expr { $$ = node3(ENUM_func1_expr, node1b(OP_UN_COMPLEMENT), $2, TOKPOS(@1)); } + | TOKEN_NOT func_prim_expr { $$ = node2(ENUM_bool_not, $2, TOKPOS(@1)); } + | TOKEN_IDENTIFIER TOKEN_DOUBLE_COLON const_array_list + { + $$ = node3(ENUM_const_array_expr, node2(ENUM_string, $1, TOKPOS(@1)), $3, TOKPOS(@2)); + } + | nonident_prim_expr TOKEN_DOUBLE_COLON const_array_list + { + $$ = node3(ENUM_const_array_expr, $1, $3, TOKPOS(@2)); + } + | TOKEN_MAKEARRAY makearray_statement_list[stmt] TOKEN_ENDARRAY + { + $$ = node2(ENUM_makearray, $stmt, TOKPOS(@1)); + } + ; event_parameter_list - : { $$ = sval_u{}; $$.node = NULL; } - | event_parameter { $$ = $1; } - ; + : { $$ = sval_u{}; $$.node = NULL; } + | event_parameter { $$ = $1; } + ; event_parameter_list_need - : event_parameter { $$ = $1; } - ; + : event_parameter { $$ = $1; } + ; event_parameter - : prim_expr { $$ = linked_list_end($1); } - | event_parameter prim_expr { $$ = append_node($1, $2); } - ; + : prim_expr { $$ = linked_list_end($1); } + | event_parameter prim_expr { $$ = append_node($1, $2); } + ; const_array_list - : const_array { $$ = linked_list_end($1); } - | const_array_list TOKEN_DOUBLE_COLON const_array { $$ = append_node($1, $3); } - ; + : const_array { $$ = linked_list_end($1); } + | const_array_list TOKEN_DOUBLE_COLON const_array { $$ = append_node($1, $3); } + ; const_array - : nonident_prim_expr - | identifier_prim { $$ = node2(ENUM_string, $1, TOKPOS(@1)); } - ; + : nonident_prim_expr + | identifier_prim { $$ = node2(ENUM_string, $1, TOKPOS(@1)); } + ; prim_expr - : nonident_prim_expr - | identifier_prim { $$ = node2(ENUM_string, $1, TOKPOS(@1)); } - | prim_expr TOKEN_DOUBLE_COLON const_array_list { $$ = node3(ENUM_const_array_expr, $1, $3, TOKPOS(@2)); } - ; + : nonident_prim_expr + | identifier_prim { $$ = node2(ENUM_string, $1, TOKPOS(@1)); } + | const_array TOKEN_DOUBLE_COLON const_array_list { $$ = node3(ENUM_const_array_expr, $1, $3, TOKPOS(@2)); } + ; identifier_prim: - TOKEN_IDENTIFIER { $$ = $1; @$ = @1; } - ; + TOKEN_IDENTIFIER { $$ = $1; @$ = @1; } + ; identifier - : TOKEN_IDENTIFIER { $$ = $1; @$ = @1; } - | TOKEN_STRING { $$ = $1; @$ = @1; } - ; + : TOKEN_IDENTIFIER { $$ = $1; @$ = @1; } + | TOKEN_STRING { $$ = $1; @$ = @1; } + ; listener_identifier - : identifier_prim { $$ = node2(ENUM_string, $1, TOKPOS(@1)); } - | TOKEN_LEFT_BRACKET expr TOKEN_RIGHT_BRACKET { $$ = $2; } - ; + : identifier { $$ = node_listener($1, TOKPOS(@1)); } + | TOKEN_LEFT_BRACKET expr TOKEN_RIGHT_BRACKET { $$ = $2; } + ; nonident_prim_expr - : TOKEN_DOLLAR listener_identifier { $$ = node3(ENUM_func1_expr, node1b(OP_UN_TARGETNAME), $2, TOKPOS(@1)); } - | nonident_prim_expr TOKEN_PERIOD identifier { $$ = node3(ENUM_field, $1, $3, TOKPOS(@3)); } - | nonident_prim_expr TOKEN_PERIOD TOKEN_SIZE { $$ = node3(ENUM_func1_expr, node1b(OP_UN_SIZE), $1, TOKPOS(@3)); } - | nonident_prim_expr TOKEN_LEFT_SQUARE_BRACKET expr TOKEN_RIGHT_SQUARE_BRACKET { $$ = node3(ENUM_array_expr, $1, $3, TOKPOS(@2)); } - | TOKEN_STRING { $$ = node2(ENUM_string, $1, TOKPOS(@1)); } - | TOKEN_INTEGER { $$ = node2(ENUM_integer, $1, TOKPOS(@1)); } - | TOKEN_FLOAT { $$ = node2(ENUM_float, $1, TOKPOS(@1)); } - | TOKEN_LEFT_BRACKET expr[exp1] expr[exp2] expr[exp3] TOKEN_RIGHT_BRACKET { $$ = node4(ENUM_vector, $exp1, $exp2, $exp3, TOKPOS(@1)); } - | TOKEN_LISTENER { $$ = node2(ENUM_listener, $1, TOKPOS(@1)); } - | TOKEN_LEFT_BRACKET expr TOKEN_RIGHT_BRACKET { $$ = $2; } - | TOKEN_LEFT_BRACKET expr TOKEN_EOL TOKEN_RIGHT_BRACKET { $$ = $2; } - | TOKEN_NEG nonident_prim_expr { $$ = node3(ENUM_func1_expr, node1b(OP_UN_MINUS), $2, TOKPOS(@1)); } - | TOKEN_COMPLEMENT nonident_prim_expr { $$ = node3(ENUM_func1_expr, node1b(OP_UN_COMPLEMENT), $2, TOKPOS(@1)); } - | TOKEN_NOT nonident_prim_expr { $$ = node2(ENUM_bool_not, $2, TOKPOS(@1)); } - | TOKEN_NULL { $$ = node1(ENUM_NULL, TOKPOS(@1)); } - | TOKEN_NIL { $$ = node1(ENUM_NIL, TOKPOS(@1)); } - ; + : nonident_prim_expr_base + | TOKEN_NEG nonident_prim_expr { $$ = node3(ENUM_func1_expr, node1b(OP_UN_MINUS), $2, TOKPOS(@1)); } + | TOKEN_COMPLEMENT nonident_prim_expr { $$ = node3(ENUM_func1_expr, node1b(OP_UN_COMPLEMENT), $2, TOKPOS(@1)); } + | TOKEN_NOT nonident_prim_expr { $$ = node2(ENUM_bool_not, $2, TOKPOS(@1)); } + ; + +nonident_prim_expr_base + : TOKEN_DOLLAR listener_identifier { $$ = node3(ENUM_func1_expr, node1b(OP_UN_TARGETNAME), $2, TOKPOS(@1)); } + | nonident_prim_expr TOKEN_PERIOD identifier { $$ = node3(ENUM_field, $1, $3, TOKPOS(@3)); } + | nonident_prim_expr TOKEN_PERIOD TOKEN_SIZE { $$ = node3(ENUM_func1_expr, node1b(OP_UN_SIZE), $1, TOKPOS(@3)); } + | nonident_prim_expr TOKEN_LEFT_SQUARE_BRACKET expr TOKEN_RIGHT_SQUARE_BRACKET { $$ = node3(ENUM_array_expr, $1, $3, TOKPOS(@2)); } + | TOKEN_STRING { $$ = node2(ENUM_string, $1, TOKPOS(@1)); } + | TOKEN_INTEGER { $$ = node2(ENUM_integer, $1, TOKPOS(@1)); } + | TOKEN_FLOAT { $$ = node2(ENUM_float, $1, TOKPOS(@1)); } + | TOKEN_LEFT_BRACKET expr[exp1] expr[exp2] expr[exp3] TOKEN_RIGHT_BRACKET { $$ = node4(ENUM_vector, $exp1, $exp2, $exp3, TOKPOS(@1)); } + | TOKEN_LISTENER { $$ = node2(ENUM_listener, $1, TOKPOS(@1)); } + | TOKEN_LEFT_BRACKET expr TOKEN_RIGHT_BRACKET { $$ = $2; } + | TOKEN_LEFT_BRACKET expr TOKEN_EOL TOKEN_RIGHT_BRACKET { $$ = $2; } + | TOKEN_NULL { $$ = node1(ENUM_NULL, TOKPOS(@1)); } + | TOKEN_NIL { $$ = node1(ENUM_NIL, TOKPOS(@1)); } + ; makearray_statement_list: - { $$ = node0(ENUM_NOP); } - | makearray_statement_list[list] makearray_statement[ma_stmt] TOKEN_EOL { $$ = append_node($list, node2(ENUM_makearray, $ma_stmt, TOKPOS(@ma_stmt))); } - | makearray_statement[ma_stmt] TOKEN_EOL { $$ = linked_list_end(node2(ENUM_makearray, $ma_stmt, TOKPOS(@ma_stmt))); } - | TOKEN_EOL makearray_statement_list { $$ = $2; @$ = @2; } - ; + { $$ = node0(ENUM_NOP); } + | makearray_statement_list[list] makearray_statement[ma_stmt] TOKEN_EOL { $$ = append_node($list, node2(ENUM_makearray, $ma_stmt, TOKPOS(@ma_stmt))); } + | makearray_statement[ma_stmt] TOKEN_EOL { $$ = linked_list_end(node2(ENUM_makearray, $ma_stmt, TOKPOS(@ma_stmt))); } + | TOKEN_EOL makearray_statement_list { $$ = $2; @$ = @2; } + ; makearray_statement: - prim_expr { $$ = linked_list_end( $1 ); } - | makearray_statement prim_expr { $$ = append_node( $1, $2 ); } - ; + prim_expr { $$ = linked_list_end( $1 ); } + | makearray_statement prim_expr { $$ = append_node( $1, $2 ); } + ; line_opt - : {} - | TOKEN_EOL - ; + : {} + | TOKEN_EOL + ; %% diff --git a/code/parser/lex.yy.cpp b/code/parser/lex.yy.cpp index a7175203..225052d9 100644 --- a/code/parser/lex.yy.cpp +++ b/code/parser/lex.yy.cpp @@ -1,3 +1,28 @@ +/* +* =========================================================================== +* Copyright (C) 2025 the OpenMoHAA team +* +* This file is part of OpenMoHAA source code. +* +* OpenMoHAA source code 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. +* +* OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +* =========================================================================== +* +* +* lex.yy.cpp: original lex generated file (unimplemented) +*/ + #include "scriptcompiler.h" #include diff --git a/code/parser/lex_source.txt b/code/parser/lex_source.txt index 6f3bb3d2..d97038b0 100644 --- a/code/parser/lex_source.txt +++ b/code/parser/lex_source.txt @@ -1,7 +1,7 @@ %{ /* * =========================================================================== -* Copyright (C) 2015 the OpenMoHAA team +* Copyright (C) 2025 the OpenMoHAA team * * This file is part of OpenMoHAA source code. * @@ -29,149 +29,144 @@ #include -void fprintf2( FILE *f, const char *format, ... ) +void fprintf2(FILE * f, const char *format, ...) { - va_list va; - static char buffer[ 4200 ]; + va_list va; + static char buffer[4200]; - va_start( va, format ); - vsprintf( buffer, format, va ); - va_end( va ); + va_start(va, format); + vsprintf(buffer, format, va); + va_end(va); - gi.Printf( buffer ); + gi.Printf(buffer); } #define fprintf fprintf2 -const char* start_ptr; -const char* in_ptr; -extern int prev_yylex; -extern int out_pos; -extern int success_pos; +const char *start_ptr; +const char *in_ptr; +extern int prev_yylex; +extern int out_pos; +extern int success_pos; parseStage_e parseStage; extern yyparsedata parsedata; -void yyllocset(YYLTYPE *loc, uint32_t off) +void yyllocset(YYLTYPE * loc, uint32_t off) { - success_pos = out_pos - yyleng + off; - loc->sourcePos = success_pos; - parsedata.pos = success_pos; + success_pos = out_pos - yyleng + off; + loc->sourcePos = success_pos; + parsedata.pos = success_pos; } void yyreducepos(uint32_t off) { - out_pos -= off; + out_pos -= off; } -#define YYLEX(n) { yyllocset(&yylloc, 0); prev_yylex = n; return n; } -#define YYLEXOFF(n, off) { yyllocset(&yylloc, off); prev_yylex = n; return n; } +#define YYLEX(n) \ + { \ + yyllocset(&yylloc, 0); \ + prev_yylex = n; \ + return n; \ + } +#define YYLEXOFF(n, off) \ + { \ + yyllocset(&yylloc, off); \ + prev_yylex = n; \ + return n; \ + } -#define YY_USER_ACTION \ -{ \ - out_pos += yyleng - yy_more_len; \ - yylloc.sourcePos = out_pos; \ - parsedata.pos = out_pos; \ -} +#define YY_USER_ACTION \ + { \ + out_pos += yyleng - yy_more_len; \ + yylloc.sourcePos = out_pos; \ + parsedata.pos = out_pos; \ + } -#define YY_FATAL_ERROR( n ) yylexerror( n ) +#define YY_FATAL_ERROR(n) yylexerror(n) -void yylexerror( const char *msg ) +void yylexerror(const char *msg) { - gi.DPrintf( "%s\n%s", msg, yytext ); - assert( 0 ); + gi.DPrintf("%s\n%s", msg, yytext); + assert(0); } -static void TextEscapeValue( char *str, size_t len ) +static void TextEscapeValue(char *str, size_t len) { - char *to = parsetree_malloc( len + 1 ); + char *to = parsetree_malloc(len + 1); - yylval.s.val.stringValue = to; + yylval.s.val.stringValue = to; - while( len ) - { - if( *str == '\\' ) - { - if( len == 1 ) - break; + while (len) { + if (*str == '\\') { + if (len == 1) { + break; + } - if( str[1] == 'n' ) - { - *to = '\n'; - to++; - } - else if( str[1] == 't' ) - { - *to = '\t'; - to++; - } - else if( str[1] == '"' ) - { - *to = '\"'; - to++; - } - else - { - *to = str[1]; - to++; - } + if (str[1] == 'n') { + *to = '\n'; + to++; + } else if (str[1] == 't') { + *to = '\t'; + to++; + } else if (str[1] == '"') { + *to = '\"'; + to++; + } else { + *to = str[1]; + to++; + } - len -= 2; - str += 2; - } - else - { - *to = *str; - to++; - len--; - str++; - } - } + len -= 2; + str += 2; + } else { + *to = *str; + to++; + len--; + str++; + } + } - *to = 0; + *to = 0; } -static void TextValue( char *str, size_t len ) +static void TextValue(char *str, size_t len) { - char* s = parsetree_malloc(len + 1); - strncpy(s, str, len); - s[len] = 0; - yylval.s.val.stringValue = s; + char *s = parsetree_malloc(len + 1); + strncpy(s, str, len); + s[len] = 0; + yylval.s.val.stringValue = s; } -static bool UseField( void ) +static bool UseField(void) { - return prev_yylex == TOKEN_PERIOD - || prev_yylex == TOKEN_DOLLAR; + return prev_yylex == TOKEN_PERIOD || prev_yylex == TOKEN_DOLLAR; } -#define YY_INPUT(buf,result,max_size) \ -{ \ - char c; \ - int n; \ - \ - c = '*'; \ - for(n = 0; n < max_size; n++) \ - { \ - c = *in_ptr++; \ - if (!c || c == '\n') { \ - break; \ - } \ - \ - buf[n] = c; \ - } \ - \ - if (c == '\n') \ - { \ - buf[n++] = c; \ - } \ - else if (!c) \ - { \ - in_ptr--; \ - } \ - \ - result = n; \ -} +#define YY_INPUT(buf, result, max_size) \ + { \ + char c; \ + int n; \ + \ + c = '*'; \ + for (n = 0; n < max_size; n++) { \ + c = *in_ptr++; \ + if (!c || c == '\n') { \ + break; \ + } \ + \ + buf[n] = c; \ + } \ + \ + if (c == '\n') { \ + buf[n++] = c; \ + } else if (!c) { \ + in_ptr--; \ + } \ + \ + result = n; \ + } %} @@ -188,174 +183,193 @@ static bool UseField( void ) %x VARIABLES %x IDENTIFIER -string ([^\\\"\r\n]|\\.)* -identifier [^\{\}\(\)\[\]\r\n\,:; \t] -alphanum [a-zA-Z0-9_]+ -varname [a-zA-Z0-9_\"]+ +string ([^\\\"\r\n]|\\.)* +identifier [^\{\}\(\)\[\]\r\n\,:; \t] +nonexpr [0-9a-zA-Z_\"'?@#`\.\x80-\xff] +nonnumeric [a-zA-Z_\"'?@#`\x80-\xff] +alphanum [a-zA-Z0-9_]+ +varname [a-zA-Z0-9_\"$\\]+ %% -"/*" { BEGIN( C_COMMENT ); } -"*/" { BEGIN( INITIAL ); } -\n { ; } -. { ; } -"*/" { Compiler.CompileError( parsedata.pos - yyleng, "'*/' found outside of comment" ); } +"/*" { BEGIN(C_COMMENT); } +"*/" { BEGIN(INITIAL); } +\n { ; } +. { ; } +"*/" { Compiler.CompileError( parsedata.pos - yyleng, "'*/' found outside of comment" ); } -\\[\r\n]+ { ; } -"//"[^\r\n]* { if( prev_yylex != TOKEN_EOL ) YYLEX( TOKEN_EOL ); } +\\[\r\n]+ { ; } +"//"[^\r\n]* { if(prev_yylex != TOKEN_EOL) YYLEX(TOKEN_EOL); } -"size" { BEGIN(INITIAL); YYLEX(TOKEN_SIZE); } -"." { YYLEX(TOKEN_PERIOD); } -\"{string}\" { BEGIN(INITIAL); TextEscapeValue(yytext + 1, strlen( yytext ) - 2 ); YYLEX(TOKEN_STRING); } -{varname} { - TextValue(yytext, strlen(yytext)); - YYLEX(TOKEN_IDENTIFIER); - } -[ \t\r\n] { - BEGIN(INITIAL); - unput(yytext[yyleng - 1]); - yyreducepos(1); - } -. { - BEGIN(INITIAL); - unput(yytext[yyleng - 1]); - yyreducepos(1); - } - -\"{string}\" { TextEscapeValue( yytext + 1, yyleng - 2 ); YYLEX( TOKEN_STRING ); } +"size" { BEGIN(INITIAL); YYLEX(TOKEN_SIZE); } +[ \t]*\./([0-9]*[^0-9[:space:]]) { YYLEX(TOKEN_PERIOD); } +\"{string}\" { BEGIN(INITIAL); TextEscapeValue(yytext + 1, strlen( yytext ) - 2 ); YYLEX(TOKEN_STRING); } +{varname} { + TextEscapeValue(yytext, strlen(yytext)); + YYLEX(TOKEN_IDENTIFIER); + } +[ \t\r\n] { + BEGIN(INITIAL); + unput(yytext[yyleng - 1]); + yyreducepos(1); + } +. { + BEGIN(INITIAL); + unput(yytext[yyleng - 1]); + yyreducepos(1); + } +\"{string}\"{nonexpr} { + BEGIN(IDENTIFIER); + yymore(); + } -"?" { YYLEX( TOKEN_TERNARY ); } -"if" { YYLEX( TOKEN_IF ); } -"else" { YYLEX( TOKEN_ELSE ); } -"while" { YYLEX( TOKEN_WHILE ); } -"for" { YYLEX( TOKEN_FOR ); } -"do" { YYLEX( TOKEN_DO ); } +\"{string}\" { TextEscapeValue(yytext + 1, yyleng - 2); YYLEX(TOKEN_STRING); } -"game" { BEGIN( VARIABLES ); yylval.s.val = node1_( method_game ); YYLEX( TOKEN_LISTENER ); } -"group" { BEGIN( VARIABLES ); yylval.s.val = node1_( method_group ); YYLEX( TOKEN_LISTENER ); } -"level" { BEGIN( VARIABLES ); yylval.s.val = node1_( method_level ); YYLEX( TOKEN_LISTENER ); } -"local" { BEGIN( VARIABLES ); yylval.s.val = node1_( method_local ); YYLEX( TOKEN_LISTENER ); } -"parm" { BEGIN( VARIABLES ); yylval.s.val = node1_( method_parm ); YYLEX( TOKEN_LISTENER ); } -"owner" { BEGIN( VARIABLES ); yylval.s.val = node1_( method_owner ); YYLEX( TOKEN_LISTENER ); } -"self" { BEGIN( VARIABLES ); yylval.s.val = node1_( method_self ); YYLEX( TOKEN_LISTENER ); } +"?" { YYLEX(TOKEN_TERNARY); } +"if" { YYLEX(TOKEN_IF); } +"else" { YYLEX(TOKEN_ELSE); } +"while" { YYLEX(TOKEN_WHILE); } +"for" { YYLEX(TOKEN_FOR); } +"do" { YYLEX(TOKEN_DO); } -"{" { parsedata.braces_count++; YYLEX( TOKEN_LEFT_BRACES ); } -"}" { parsedata.braces_count--; YYLEX( TOKEN_RIGHT_BRACES ); } -"(" { YYLEX(TOKEN_LEFT_BRACKET); } -")" { BEGIN(VARIABLES); YYLEX(TOKEN_RIGHT_BRACKET); } -"[" { YYLEX(TOKEN_LEFT_SQUARE_BRACKET); } -"]" { BEGIN(VARIABLES); YYLEX(TOKEN_RIGHT_SQUARE_BRACKET); } +"game" { BEGIN(VARIABLES); yylval.s.val = node1_(method_game); YYLEX(TOKEN_LISTENER); } +"group" { BEGIN(VARIABLES); yylval.s.val = node1_(method_group); YYLEX(TOKEN_LISTENER); } +"level" { BEGIN(VARIABLES); yylval.s.val = node1_(method_level); YYLEX(TOKEN_LISTENER); } +"local" { BEGIN(VARIABLES); yylval.s.val = node1_(method_local); YYLEX(TOKEN_LISTENER); } +"parm" { BEGIN(VARIABLES); yylval.s.val = node1_(method_parm); YYLEX(TOKEN_LISTENER); } +"owner" { BEGIN(VARIABLES); yylval.s.val = node1_(method_owner); YYLEX(TOKEN_LISTENER); } +"self" { BEGIN(VARIABLES); yylval.s.val = node1_(method_self); YYLEX(TOKEN_LISTENER); } -"=" { YYLEX( TOKEN_ASSIGNMENT ); } -":" { YYLEX( TOKEN_COLON ); } -"::" { YYLEX( TOKEN_DOUBLE_COLON ); } -";" { YYLEX( TOKEN_SEMICOLON ); } +"{" { parsedata.braces_count++; YYLEX(TOKEN_LEFT_BRACES); } +"}" { parsedata.braces_count--; YYLEX(TOKEN_RIGHT_BRACES); } +"(" { YYLEX(TOKEN_LEFT_BRACKET); } +")" { BEGIN(VARIABLES); YYLEX(TOKEN_RIGHT_BRACKET); } +"[" { YYLEX(TOKEN_LEFT_SQUARE_BRACKET); } +"]" { BEGIN(VARIABLES); YYLEX(TOKEN_RIGHT_SQUARE_BRACKET); } -"==" { YYLEX( TOKEN_EQUALITY ); } -"||" { YYLEX( TOKEN_LOGICAL_OR ); } -"&&" { YYLEX( TOKEN_LOGICAL_AND ); } +"=" { YYLEX(TOKEN_ASSIGNMENT); } +":" { YYLEX(TOKEN_COLON); } +"::" { YYLEX(TOKEN_DOUBLE_COLON); } +";" { YYLEX(TOKEN_SEMICOLON); } -"|" { YYLEX( TOKEN_BITWISE_OR ); } -"^" { YYLEX( TOKEN_BITWISE_EXCL_OR ); } -"&" { YYLEX( TOKEN_BITWISE_AND ); } -"!=" { YYLEX( TOKEN_INEQUALITY ); } -"<" { YYLEX( TOKEN_LESS_THAN ); } -">" { YYLEX( TOKEN_GREATER_THAN ); } -"<=" { YYLEX( TOKEN_LESS_THAN_OR_EQUAL ); } -">=" { YYLEX( TOKEN_GREATER_THAN_OR_EQUAL ); } -[ ]"-" { YYLEX( TOKEN_NEG ); } +"==" { YYLEX(TOKEN_EQUALITY); } +"ifequal" { YYLEX(TOKEN_EQUALITY); } +"ifstrequal" { YYLEX(TOKEN_EQUALITY); } +"||" { YYLEX(TOKEN_LOGICAL_OR); } +"&&" { YYLEX(TOKEN_LOGICAL_AND); } -"+" { YYLEX( TOKEN_PLUS ); } -"+=" { YYLEX( TOKEN_PLUS_EQUALS ); } -"++"|[ ]"++" { YYLEX( TOKEN_INCREMENT ); } -"-"|"-"[ ]|[ ]"-"[ ] { YYLEX( TOKEN_MINUS ); } -"-=" { YYLEX( TOKEN_MINUS_EQUALS ); } -[ ]"-=" { YYLEX( TOKEN_MINUS_EQUALS ); } -"--"|[ ]"--" { YYLEX( TOKEN_DECREMENT ); } -"*" { YYLEX( TOKEN_MULTIPLY ); } -"*=" { YYLEX( TOKEN_MULTIPLY_EQUALS ); } -"/" { YYLEX( TOKEN_DIVIDE ); } -"/=" { YYLEX( TOKEN_DIVIDE_EQUALS ); } -"%" { YYLEX( TOKEN_MODULUS ); } -"%=" { YYLEX( TOKEN_MODULUS_EQUALS ); } -"<<" { YYLEX( TOKEN_SHIFT_LEFT ); } -"<<=" { YYLEX( TOKEN_SHIFT_LEFT_EQUALS ); } -">>" { YYLEX( TOKEN_SHIFT_RIGHT ); } -">>=" { YYLEX( TOKEN_SHIFT_RIGHT_EQUALS ); } -"&=" { YYLEX( TOKEN_AND_EQUALS ); } -"^=" { YYLEX( TOKEN_EXCL_OR_EQUALS ); } -"|=" { YYLEX( TOKEN_OR_EQUALS ); } -"$" { BEGIN( VARIABLES ); YYLEX( TOKEN_DOLLAR ); } -"!" { YYLEX( TOKEN_NOT ); } -"~" { YYLEX( TOKEN_COMPLEMENT ); } +"|" { YYLEX(TOKEN_BITWISE_OR); } +"^" { YYLEX(TOKEN_BITWISE_EXCL_OR); } +"&" { YYLEX(TOKEN_BITWISE_AND); } +"!=" { YYLEX(TOKEN_INEQUALITY); } +"ifnotequal" { YYLEX(TOKEN_INEQUALITY); } +"ifstrnotequal" { YYLEX(TOKEN_INEQUALITY); } +"<" { YYLEX(TOKEN_LESS_THAN); } +"ifless" { YYLEX(TOKEN_LESS_THAN); } +">" { YYLEX(TOKEN_GREATER_THAN); } +"ifgreater" { YYLEX(TOKEN_GREATER_THAN); } +"<=" { YYLEX(TOKEN_LESS_THAN_OR_EQUAL); } +"iflessequal" { YYLEX(TOKEN_LESS_THAN_OR_EQUAL); } +">=" { YYLEX(TOKEN_GREATER_THAN_OR_EQUAL); } +"ifgreaterequal" { YYLEX(TOKEN_GREATER_THAN_OR_EQUAL); } +[ \t]"-" { YYLEX(TOKEN_NEG); } -"." { YYLEX( TOKEN_PERIOD ); } +"+" { YYLEX(TOKEN_PLUS); } +"+=" { YYLEX(TOKEN_PLUS_EQUALS); } +"++"|[ \t]"++" { YYLEX(TOKEN_INCREMENT); } +"-"|"-"[ \t]|[ \t]"-"[ \t] { YYLEX(TOKEN_MINUS); } +"-=" { YYLEX(TOKEN_MINUS_EQUALS); } +[ \t]"-=" { YYLEX(TOKEN_MINUS_EQUALS); } +"--"|[ \t]"--" { YYLEX(TOKEN_DECREMENT); } +"*" { YYLEX(TOKEN_MULTIPLY); } +"*=" { YYLEX(TOKEN_MULTIPLY_EQUALS); } +"/" { YYLEX(TOKEN_DIVIDE); } +"/=" { YYLEX(TOKEN_DIVIDE_EQUALS); } +"%" { YYLEX(TOKEN_MODULUS); } +"%=" { YYLEX(TOKEN_MODULUS_EQUALS); } +"<<" { YYLEX(TOKEN_SHIFT_LEFT); } +"<<=" { YYLEX(TOKEN_SHIFT_LEFT_EQUALS); } +">>" { YYLEX(TOKEN_SHIFT_RIGHT); } +">>=" { YYLEX(TOKEN_SHIFT_RIGHT_EQUALS); } +"&=" { YYLEX(TOKEN_AND_EQUALS); } +"^=" { YYLEX(TOKEN_EXCL_OR_EQUALS); } +"|=" { YYLEX(TOKEN_OR_EQUALS); } +[$]+ { BEGIN( VARIABLES ); YYLEX(TOKEN_DOLLAR); } +"!" { YYLEX(TOKEN_NOT); } +"~" { YYLEX(TOKEN_COMPLEMENT); } -"," { YYLEX( TOKEN_COMMA ); } -"#" { YYLEX( TOKEN_NUMBER ); } +"." { YYLEX(TOKEN_PERIOD); } -"NULL" { YYLEX( TOKEN_NULL ); } -"NIL" { YYLEX( TOKEN_NIL ); } +"," { YYLEX(TOKEN_COMMA); } -"try" { YYLEX( TOKEN_TRY ); } -"catch" { YYLEX( TOKEN_CATCH ); } -"switch" { YYLEX( TOKEN_SWITCH ); } +"NULL" { YYLEX(TOKEN_NULL); } +"NIL" { YYLEX(TOKEN_NIL); } -"case" { YYLEX( TOKEN_CASE ); } -"break" { YYLEX( TOKEN_BREAK ); } -"continue" { YYLEX( TOKEN_CONTINUE ); } +"try" { YYLEX(TOKEN_TRY); } +"catch" { YYLEX(TOKEN_CATCH); } +"switch" { YYLEX(TOKEN_SWITCH); } -"makearray"|"makeArray" { YYLEX( TOKEN_MAKEARRAY ); } -"endarray"|"endArray" { YYLEX( TOKEN_ENDARRAY ); } +"case" { YYLEX(TOKEN_CASE); } +"break" { YYLEX(TOKEN_BREAK); } +"continue" { YYLEX(TOKEN_CONTINUE); } -[\r\n]+ { if (prev_yylex != TOKEN_EOL) YYLEX(TOKEN_EOL); } -[ \t] { ; } +"makearray"|"makeArray" { YYLEX(TOKEN_MAKEARRAY); } +"endarray"|"endArray" { YYLEX(TOKEN_ENDARRAY); } -[0-9]+ { - char* p = nullptr; - yylval.s.val.intValue = std::strtol(yytext, &p, 10); - YYLEX(TOKEN_INTEGER); - } -[0-9\.]+|[0-9\.]+("e+"|"e-")+[0-9\.] { - char* p = nullptr; - yylval.s.val.floatValue = std::strtof(yytext, &p); - YYLEX(TOKEN_FLOAT); - } +[\r\n]+ { if (prev_yylex != TOKEN_EOL) YYLEX(TOKEN_EOL); } +[ \t] { ; } -{identifier}* { - BEGIN(INITIAL); - TextEscapeValue(yytext, yyleng); - YYLEX(TOKEN_IDENTIFIER); - } -[ \t\r\n] { - BEGIN(INITIAL); - unput(yytext[yyleng - 1]); - yyreducepos(1); - TextEscapeValue(yytext, yyleng - 1); - YYLEXOFF(TOKEN_IDENTIFIER, 1); - } -. { - BEGIN(INITIAL); - unput(yytext[yyleng - 1]); - yyreducepos(1); - TextEscapeValue(yytext, yyleng - 1); - YYLEXOFF(TOKEN_IDENTIFIER, 1); - } +[0-9]+ { + char* p = nullptr; + yylval.s.val.intValue = std::strtol(yytext, &p, 10); + YYLEX(TOKEN_INTEGER); + } -{identifier} { - BEGIN(IDENTIFIER); - yymore(); - } +[0-9\.]+{nonnumeric} { + BEGIN(IDENTIFIER); + yymore(); + } -[a-zA-Z0-9_]+ { - BEGIN(IDENTIFIER); - yymore(); - } +[0-9\.]+|[0-9\.]+("e+"|"e-")+[0-9\.] { + char* p = nullptr; + yylval.s.val.floatValue = std::strtof(yytext, &p); + YYLEX(TOKEN_FLOAT); + } - diff --git a/code/zlib/zlib.h b/code/zlib/zlib.h new file mode 100644 index 00000000..02281792 --- /dev/null +++ b/code/zlib/zlib.h @@ -0,0 +1,1357 @@ +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.2.3, July 18th, 2005 + + Copyright (C) 1995-2005 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 + + + The data format used by the zlib library is described by RFCs (Request for + Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt + (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). +*/ + +#ifndef ZLIB_H +#define ZLIB_H + +#include "zconf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZLIB_VERSION "1.2.3" +#define ZLIB_VERNUM 0x1230 + +/* + The 'zlib' compression library provides in-memory compression and + decompression functions, including integrity checks of the uncompressed + data. This version of the library supports only one compression method + (deflation) but other algorithms will be added later and will have the same + stream interface. + + Compression can be done in a single step if the buffers are large + enough (for example if an input file is mmap'ed), or can be done by + repeated calls of the compression function. In the latter case, the + application must provide more input and/or consume the output + (providing more output space) before each call. + + The compressed data format used by default by the in-memory functions is + the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped + around a deflate stream, which is itself documented in RFC 1951. + + The library also supports reading and writing files in gzip (.gz) format + with an interface similar to that of stdio using the functions that start + with "gz". The gzip format is different from the zlib format. gzip is a + gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. + + This library can optionally read and write gzip streams in memory as well. + + The zlib format was designed to be compact and fast for use in memory + and on communications channels. The gzip format was designed for single- + file compression on file systems, has a larger header than zlib to maintain + directory information, and uses a different, slower check method than zlib. + + The library does not install any signal handler. The decoder checks + the consistency of the compressed data, so the library should never + crash even in case of corrupted input. +*/ + +typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); +typedef void (*free_func) OF((voidpf opaque, voidpf address)); + +struct internal_state; + +typedef struct z_stream_s { + Bytef *next_in; /* next input byte */ + uInt avail_in; /* number of bytes available at next_in */ + uLong total_in; /* total nb of input bytes read so far */ + + Bytef *next_out; /* next output byte should be put there */ + uInt avail_out; /* remaining free space at next_out */ + uLong total_out; /* total nb of bytes output so far */ + + char *msg; /* last error message, NULL if no error */ + struct internal_state FAR *state; /* not visible by applications */ + + alloc_func zalloc; /* used to allocate the internal state */ + free_func zfree; /* used to free the internal state */ + voidpf opaque; /* private data object passed to zalloc and zfree */ + + int data_type; /* best guess about the data type: binary or text */ + uLong adler; /* adler32 value of the uncompressed data */ + uLong reserved; /* reserved for future use */ +} z_stream; + +typedef z_stream FAR *z_streamp; + +/* + gzip header information passed to and from zlib routines. See RFC 1952 + for more details on the meanings of these fields. +*/ +typedef struct gz_header_s { + int text; /* true if compressed data believed to be text */ + uLong time; /* modification time */ + int xflags; /* extra flags (not used when writing a gzip file) */ + int os; /* operating system */ + Bytef *extra; /* pointer to extra field or Z_NULL if none */ + uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ + uInt extra_max; /* space at extra (only when reading header) */ + Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ + uInt name_max; /* space at name (only when reading header) */ + Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ + uInt comm_max; /* space at comment (only when reading header) */ + int hcrc; /* true if there was or will be a header crc */ + int done; /* true when done reading gzip header (not used + when writing a gzip file) */ +} gz_header; + +typedef gz_header FAR *gz_headerp; + +/* + The application must update next_in and avail_in when avail_in has + dropped to zero. It must update next_out and avail_out when avail_out + has dropped to zero. The application must initialize zalloc, zfree and + opaque before calling the init function. All other fields are set by the + compression library and must not be updated by the application. + + The opaque value provided by the application will be passed as the first + parameter for calls of zalloc and zfree. This can be useful for custom + memory management. The compression library attaches no meaning to the + opaque value. + + zalloc must return Z_NULL if there is not enough memory for the object. + If zlib is used in a multi-threaded application, zalloc and zfree must be + thread safe. + + On 16-bit systems, the functions zalloc and zfree must be able to allocate + exactly 65536 bytes, but will not be required to allocate more than this + if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, + pointers returned by zalloc for objects of exactly 65536 bytes *must* + have their offset normalized to zero. The default allocation function + provided by this library ensures this (see zutil.c). To reduce memory + requirements and avoid any allocation of 64K objects, at the expense of + compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). + + The fields total_in and total_out can be used for statistics or + progress reports. After compression, total_in holds the total size of + the uncompressed data and may be saved for use in the decompressor + (particularly if the decompressor wants to decompress everything in + a single step). +*/ + + /* constants */ + +#define Z_NO_FLUSH 0 +#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ +#define Z_SYNC_FLUSH 2 +#define Z_FULL_FLUSH 3 +#define Z_FINISH 4 +#define Z_BLOCK 5 +/* Allowed flush values; see deflate() and inflate() below for details */ + +#define Z_OK 0 +#define Z_STREAM_END 1 +#define Z_NEED_DICT 2 +#define Z_ERRNO (-1) +#define Z_STREAM_ERROR (-2) +#define Z_DATA_ERROR (-3) +#define Z_MEM_ERROR (-4) +#define Z_BUF_ERROR (-5) +#define Z_VERSION_ERROR (-6) +/* Return codes for the compression/decompression functions. Negative + * values are errors, positive values are used for special but normal events. + */ + +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 +#define Z_DEFAULT_COMPRESSION (-1) +/* compression levels */ + +#define Z_FILTERED 1 +#define Z_HUFFMAN_ONLY 2 +#define Z_RLE 3 +#define Z_FIXED 4 +#define Z_DEFAULT_STRATEGY 0 +/* compression strategy; see deflateInit2() below for details */ + +#define Z_BINARY 0 +#define Z_TEXT 1 +#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ +#define Z_UNKNOWN 2 +/* Possible values of the data_type field (though see inflate()) */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported in this version) */ + +#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ + +#define zlib_version zlibVersion() +/* for compatibility with versions < 1.0.2 */ + + /* basic functions */ + +ZEXTERN const char * ZEXPORT zlibVersion OF((void)); +/* The application can compare zlibVersion and ZLIB_VERSION for consistency. + If the first character differs, the library code actually used is + not compatible with the zlib.h header file used by the application. + This check is automatically made by deflateInit and inflateInit. + */ + +/* +ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); + + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. + If zalloc and zfree are set to Z_NULL, deflateInit updates them to + use default allocation functions. + + The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: + 1 gives best speed, 9 gives best compression, 0 gives no compression at + all (the input data is simply copied a block at a time). + Z_DEFAULT_COMPRESSION requests a default compromise between speed and + compression (currently equivalent to level 6). + + deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if level is not a valid compression level, + Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible + with the version assumed by the caller (ZLIB_VERSION). + msg is set to null if there is no error message. deflateInit does not + perform any compression: this will be done by deflate(). +*/ + + +ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); +/* + deflate compresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce some + output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. deflate performs one or both of the + following actions: + + - Compress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in and avail_in are updated and + processing will resume at this point for the next call of deflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. This action is forced if the parameter flush is non zero. + Forcing flush frequently degrades the compression ratio, so this parameter + should be set only when necessary (in interactive applications). + Some output may be provided even if flush is not set. + + Before the call of deflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating avail_in or avail_out accordingly; avail_out + should never be zero before the call. The application can consume the + compressed output when it wants, for example when the output buffer is full + (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK + and with zero avail_out, it must be called again after making room in the + output buffer because there might be more output pending. + + Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to + decide how much data to accumualte before producing output, in order to + maximize compression. + + If the parameter flush is set to Z_SYNC_FLUSH, all pending output is + flushed to the output buffer and the output is aligned on a byte boundary, so + that the decompressor can get all input data available so far. (In particular + avail_in is zero after the call if enough output space has been provided + before the call.) Flushing may degrade compression for some compression + algorithms and so it should be used only when necessary. + + If flush is set to Z_FULL_FLUSH, all output is flushed as with + Z_SYNC_FLUSH, and the compression state is reset so that decompression can + restart from this point if previous compressed data has been damaged or if + random access is desired. Using Z_FULL_FLUSH too often can seriously degrade + compression. + + If deflate returns with avail_out == 0, this function must be called again + with the same value of the flush parameter and more output space (updated + avail_out), until the flush is complete (deflate returns with non-zero + avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that + avail_out is greater than six to avoid repeated flush markers due to + avail_out == 0 on return. + + If the parameter flush is set to Z_FINISH, pending input is processed, + pending output is flushed and deflate returns with Z_STREAM_END if there + was enough output space; if deflate returns with Z_OK, this function must be + called again with Z_FINISH and more output space (updated avail_out) but no + more input data, until it returns with Z_STREAM_END or an error. After + deflate has returned Z_STREAM_END, the only possible operations on the + stream are deflateReset or deflateEnd. + + Z_FINISH can be used immediately after deflateInit if all the compression + is to be done in a single step. In this case, avail_out must be at least + the value returned by deflateBound (see below). If deflate does not return + Z_STREAM_END, then it must be called again as described above. + + deflate() sets strm->adler to the adler32 checksum of all input read + so far (that is, total_in bytes). + + deflate() may update strm->data_type if it can make a good guess about + the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered + binary. This field is only for information purposes and does not affect + the compression algorithm in any manner. + + deflate() returns Z_OK if some progress has been made (more input + processed or more output produced), Z_STREAM_END if all input has been + consumed and all output has been produced (only when flush is set to + Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example + if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible + (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not + fatal, and deflate() can be called again with more input and more output + space to continue compressing. +*/ + + +ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the + stream state was inconsistent, Z_DATA_ERROR if the stream was freed + prematurely (some input or output was discarded). In the error case, + msg may be set but then points to a static string (which must not be + deallocated). +*/ + + +/* +ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); + + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by + the caller. If next_in is not Z_NULL and avail_in is large enough (the exact + value depends on the compression method), inflateInit determines the + compression method from the zlib header and allocates all data structures + accordingly; otherwise the allocation will be deferred to the first call of + inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to + use default allocation functions. + + inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller. msg is set to null if there is no error + message. inflateInit does not perform any decompression apart from reading + the zlib header if present: this will be done by inflate(). (So next_in and + avail_in may be modified, but next_out and avail_out are unchanged.) +*/ + + +ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); +/* + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce + some output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. inflate performs one or both of the + following actions: + + - Decompress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in is updated and processing + will resume at this point for the next call of inflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. inflate() provides as much output as possible, until there + is no more input data or no more space in the output buffer (see below + about the flush parameter). + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating the next_* and avail_* values accordingly. + The application can consume the uncompressed output when it wants, for + example when the output buffer is full (avail_out == 0), or after each + call of inflate(). If inflate returns Z_OK and with zero avail_out, it + must be called again after making room in the output buffer because there + might be more output pending. + + The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, + Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much + output as possible to the output buffer. Z_BLOCK requests that inflate() stop + if and when it gets to the next deflate block boundary. When decoding the + zlib or gzip format, this will cause inflate() to return immediately after + the header and before the first block. When doing a raw inflate, inflate() + will go ahead and process the first block, and will return when it gets to + the end of that block, or when it runs out of data. + + The Z_BLOCK option assists in appending to or combining deflate streams. + Also to assist in this, on return inflate() will set strm->data_type to the + number of unused bits in the last byte taken from strm->next_in, plus 64 + if inflate() is currently decoding the last block in the deflate stream, + plus 128 if inflate() returned immediately after decoding an end-of-block + code or decoding the complete header up to just before the first byte of the + deflate stream. The end-of-block will not be indicated until all of the + uncompressed data from that block has been written to strm->next_out. The + number of unused bits may in general be greater than seven, except when + bit 7 of data_type is set, in which case the number of unused bits will be + less than eight. + + inflate() should normally be called until it returns Z_STREAM_END or an + error. However if all decompression is to be performed in a single step + (a single call of inflate), the parameter flush should be set to + Z_FINISH. In this case all pending input is processed and all pending + output is flushed; avail_out must be large enough to hold all the + uncompressed data. (The size of the uncompressed data may have been saved + by the compressor for this purpose.) The next operation on this stream must + be inflateEnd to deallocate the decompression state. The use of Z_FINISH + is never required, but can be used to inform inflate that a faster approach + may be used for the single inflate() call. + + In this implementation, inflate() always flushes as much output as + possible to the output buffer, and always uses the faster approach on the + first call. So the only effect of the flush parameter in this implementation + is on the return value of inflate(), as noted below, or when it returns early + because Z_BLOCK is used. + + If a preset dictionary is needed after this call (see inflateSetDictionary + below), inflate sets strm->adler to the adler32 checksum of the dictionary + chosen by the compressor and returns Z_NEED_DICT; otherwise it sets + strm->adler to the adler32 checksum of all output produced so far (that is, + total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described + below. At the end of the stream, inflate() checks that its computed adler32 + checksum is equal to that saved by the compressor and returns Z_STREAM_END + only if the checksum is correct. + + inflate() will decompress and check either zlib-wrapped or gzip-wrapped + deflate data. The header type is detected automatically. Any information + contained in the gzip header is not retained, so applications that need that + information should instead use raw inflate, see inflateInit2() below, or + inflateBack() and perform their own processing of the gzip header and + trailer. + + inflate() returns Z_OK if some progress has been made (more input processed + or more output produced), Z_STREAM_END if the end of the compressed data has + been reached and all uncompressed output has been produced, Z_NEED_DICT if a + preset dictionary is needed at this point, Z_DATA_ERROR if the input data was + corrupted (input stream not conforming to the zlib format or incorrect check + value), Z_STREAM_ERROR if the stream structure was inconsistent (for example + if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory, + Z_BUF_ERROR if no progress is possible or if there was not enough room in the + output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and + inflate() can be called again with more input and more output space to + continue decompressing. If Z_DATA_ERROR is returned, the application may then + call inflateSync() to look for a good compression block if a partial recovery + of the data is desired. +*/ + + +ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state + was inconsistent. In the error case, msg may be set but then points to a + static string (which must not be deallocated). +*/ + + /* Advanced functions */ + +/* + The following functions are needed only in some special applications. +*/ + +/* +ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy)); + + This is another version of deflateInit with more compression options. The + fields next_in, zalloc, zfree and opaque must be initialized before by + the caller. + + The method parameter is the compression method. It must be Z_DEFLATED in + this version of the library. + + The windowBits parameter is the base two logarithm of the window size + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if + deflateInit is used instead. + + windowBits can also be -8..-15 for raw deflate. In this case, -windowBits + determines the window size. deflate() will then generate raw deflate data + with no zlib header or trailer, and will not compute an adler32 check value. + + windowBits can also be greater than 15 for optional gzip encoding. Add + 16 to windowBits to write a simple gzip header and trailer around the + compressed data instead of a zlib wrapper. The gzip header will have no + file name, no extra data, no comment, no modification time (set to zero), + no header crc, and the operating system will be set to 255 (unknown). If a + gzip stream is being written, strm->adler is a crc32 instead of an adler32. + + The memLevel parameter specifies how much memory should be allocated + for the internal compression state. memLevel=1 uses minimum memory but + is slow and reduces compression ratio; memLevel=9 uses maximum memory + for optimal speed. The default value is 8. See zconf.h for total memory + usage as a function of windowBits and memLevel. + + The strategy parameter is used to tune the compression algorithm. Use the + value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a + filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no + string match), or Z_RLE to limit match distances to one (run-length + encoding). Filtered data consists mostly of small values with a somewhat + random distribution. In this case, the compression algorithm is tuned to + compress them better. The effect of Z_FILTERED is to force more Huffman + coding and less string matching; it is somewhat intermediate between + Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as + Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy + parameter only affects the compression ratio but not the correctness of the + compressed output even if it is not set appropriately. Z_FIXED prevents the + use of dynamic Huffman codes, allowing for a simpler decoder for special + applications. + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid + method). msg is set to null if there is no error message. deflateInit2 does + not perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the compression dictionary from the given byte sequence + without producing any compressed output. This function must be called + immediately after deflateInit, deflateInit2 or deflateReset, before any + call of deflate. The compressor and decompressor must use exactly the same + dictionary (see inflateSetDictionary). + + The dictionary should consist of strings (byte sequences) that are likely + to be encountered later in the data to be compressed, with the most commonly + used strings preferably put towards the end of the dictionary. Using a + dictionary is most useful when the data to be compressed is short and can be + predicted with good accuracy; the data can then be compressed better than + with the default empty dictionary. + + Depending on the size of the compression data structures selected by + deflateInit or deflateInit2, a part of the dictionary may in effect be + discarded, for example if the dictionary is larger than the window size in + deflate or deflate2. Thus the strings most likely to be useful should be + put at the end of the dictionary, not at the front. In addition, the + current implementation of deflate will use at most the window size minus + 262 bytes of the provided dictionary. + + Upon return of this function, strm->adler is set to the adler32 value + of the dictionary; the decompressor may later use this value to determine + which dictionary has been used by the compressor. (The adler32 value + applies to the whole dictionary even if only a subset of the dictionary is + actually used by the compressor.) If a raw deflate was requested, then the + adler32 value is not computed and strm->adler is not set. + + deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent (for example if deflate has already been called for this stream + or if the compression method is bsort). deflateSetDictionary does not + perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when several compression strategies will be + tried, for example when there are several ways of pre-processing the input + data with a filter. The streams that will be discarded should then be freed + by calling deflateEnd. Note that deflateCopy duplicates the internal + compression state which can be quite large, so this strategy is slow and + can consume lots of memory. + + deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); +/* + This function is equivalent to deflateEnd followed by deflateInit, + but does not free and reallocate all the internal compression state. + The stream will keep the same compression level and any other attributes + that may have been set by deflateInit2. + + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + +ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, + int level, + int strategy)); +/* + Dynamically update the compression level and compression strategy. The + interpretation of level and strategy is as in deflateInit2. This can be + used to switch between compression and straight copy of the input data, or + to switch to a different kind of input data requiring a different + strategy. If the compression level is changed, the input available so far + is compressed with the old level (and may be flushed); the new level will + take effect only at the next call of deflate(). + + Before the call of deflateParams, the stream state must be set as for + a call of deflate(), since the currently available input may have to + be compressed and flushed. In particular, strm->avail_out must be non-zero. + + deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source + stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR + if strm->avail_out was zero. +*/ + +ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, + int good_length, + int max_lazy, + int nice_length, + int max_chain)); +/* + Fine tune deflate's internal compression parameters. This should only be + used by someone who understands the algorithm used by zlib's deflate for + searching for the best matching string, and even then only by the most + fanatic optimizer trying to squeeze out the last compressed bit for their + specific input data. Read the deflate.c source code for the meaning of the + max_lazy, good_length, nice_length, and max_chain parameters. + + deflateTune() can be called after deflateInit() or deflateInit2(), and + returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. + */ + +ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, + uLong sourceLen)); +/* + deflateBound() returns an upper bound on the compressed size after + deflation of sourceLen bytes. It must be called after deflateInit() + or deflateInit2(). This would be used to allocate an output buffer + for deflation in a single pass, and so would be called before deflate(). +*/ + +ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + deflatePrime() inserts bits in the deflate output stream. The intent + is that this function is used to start off the deflate output with the + bits leftover from a previous deflate stream when appending to it. As such, + this function can only be used for raw deflate, and must be used before the + first deflate() call after a deflateInit2() or deflateReset(). bits must be + less than or equal to 16, and that many of the least significant bits of + value will be inserted in the output. + + deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, + gz_headerp head)); +/* + deflateSetHeader() provides gzip header information for when a gzip + stream is requested by deflateInit2(). deflateSetHeader() may be called + after deflateInit2() or deflateReset() and before the first call of + deflate(). The text, time, os, extra field, name, and comment information + in the provided gz_header structure are written to the gzip header (xflag is + ignored -- the extra flags are set according to the compression level). The + caller must assure that, if not Z_NULL, name and comment are terminated with + a zero byte, and that if extra is not Z_NULL, that extra_len bytes are + available there. If hcrc is true, a gzip header crc is included. Note that + the current versions of the command-line version of gzip (up through version + 1.3.x) do not support header crc's, and will report that it is a "multi-part + gzip file" and give up. + + If deflateSetHeader is not used, the default gzip header has text false, + the time set to zero, and os set to 255, with no extra, name, or comment + fields. The gzip header is returned to the default state by deflateReset(). + + deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, + int windowBits)); + + This is another version of inflateInit with an extra parameter. The + fields next_in, avail_in, zalloc, zfree and opaque must be initialized + before by the caller. + + The windowBits parameter is the base two logarithm of the maximum window + size (the size of the history buffer). It should be in the range 8..15 for + this version of the library. The default value is 15 if inflateInit is used + instead. windowBits must be greater than or equal to the windowBits value + provided to deflateInit2() while compressing, or it must be equal to 15 if + deflateInit2() was not used. If a compressed stream with a larger window + size is given as input, inflate() will return with the error code + Z_DATA_ERROR instead of trying to allocate a larger window. + + windowBits can also be -8..-15 for raw inflate. In this case, -windowBits + determines the window size. inflate() will then process raw deflate data, + not looking for a zlib or gzip header, not generating a check value, and not + looking for any check values for comparison at the end of the stream. This + is for use with other formats that use the deflate compressed data format + such as zip. Those formats provide their own check values. If a custom + format is developed using the raw deflate format for compressed data, it is + recommended that a check value such as an adler32 or a crc32 be applied to + the uncompressed data as is done in the zlib, gzip, and zip formats. For + most applications, the zlib format should be used as is. Note that comments + above on the use in deflateInit2() applies to the magnitude of windowBits. + + windowBits can also be greater than 15 for optional gzip decoding. Add + 32 to windowBits to enable zlib and gzip decoding with automatic header + detection, or add 16 to decode only the gzip format (the zlib format will + return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is + a crc32 instead of an adler32. + + inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg + is set to null if there is no error message. inflateInit2 does not perform + any decompression apart from reading the zlib header if present: this will + be done by inflate(). (So next_in and avail_in may be modified, but next_out + and avail_out are unchanged.) +*/ + +ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the decompression dictionary from the given uncompressed byte + sequence. This function must be called immediately after a call of inflate, + if that call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the adler32 value returned by that call of inflate. + The compressor and decompressor must use exactly the same dictionary (see + deflateSetDictionary). For raw inflate, this function can be called + immediately after inflateInit2() or inflateReset() and before any call of + inflate() to set the dictionary. The application must insure that the + dictionary that was used for compression is provided. + + inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the + expected one (incorrect adler32 value). inflateSetDictionary does not + perform any decompression: this will be done by subsequent calls of + inflate(). +*/ + +ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); +/* + Skips invalid compressed data until a full flush point (see above the + description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided. + + inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR + if no more input was provided, Z_DATA_ERROR if no flush point has been found, + or Z_STREAM_ERROR if the stream structure was inconsistent. In the success + case, the application may save the current current value of total_in which + indicates where valid compressed data was found. In the error case, the + application may repeatedly call inflateSync, providing more input each time, + until success or end of the input data. +*/ + +ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when randomly accessing a large stream. The + first pass through the stream can periodically record the inflate state, + allowing restarting inflate at those points when randomly accessing the + stream. + + inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); +/* + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate all the internal decompression state. + The stream will keep attributes that may have been set by inflateInit2. + + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + +ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + This function inserts bits in the inflate input stream. The intent is + that this function is used to start inflating at a bit position in the + middle of a byte. The provided bits will be used before any bytes are used + from next_in. This function should only be used with raw inflate, and + should be used before the first inflate() call after inflateInit2() or + inflateReset(). bits must be less than or equal to 16, and that many of the + least significant bits of value will be inserted in the input. + + inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, + gz_headerp head)); +/* + inflateGetHeader() requests that gzip header information be stored in the + provided gz_header structure. inflateGetHeader() may be called after + inflateInit2() or inflateReset(), and before the first call of inflate(). + As inflate() processes the gzip stream, head->done is zero until the header + is completed, at which time head->done is set to one. If a zlib stream is + being decoded, then head->done is set to -1 to indicate that there will be + no gzip header information forthcoming. Note that Z_BLOCK can be used to + force inflate() to return immediately after header processing is complete + and before any actual data is decompressed. + + The text, time, xflags, and os fields are filled in with the gzip header + contents. hcrc is set to true if there is a header CRC. (The header CRC + was valid if done is set to one.) If extra is not Z_NULL, then extra_max + contains the maximum number of bytes to write to extra. Once done is true, + extra_len contains the actual extra field length, and extra contains the + extra field, or that field truncated if extra_max is less than extra_len. + If name is not Z_NULL, then up to name_max characters are written there, + terminated with a zero unless the length is greater than name_max. If + comment is not Z_NULL, then up to comm_max characters are written there, + terminated with a zero unless the length is greater than comm_max. When + any of extra, name, or comment are not Z_NULL and the respective field is + not present in the header, then that field is set to Z_NULL to signal its + absence. This allows the use of deflateSetHeader() with the returned + structure to duplicate the header. However if those fields are set to + allocated memory, then the application will need to save those pointers + elsewhere so that they can be eventually freed. + + If inflateGetHeader is not used, then the header information is simply + discarded. The header is always checked for validity, including the header + CRC if present. inflateReset() will reset the process to discard the header + information. The application would need to call inflateGetHeader() again to + retrieve the header from the next gzip stream. + + inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, + unsigned char FAR *window)); + + Initialize the internal stream state for decompression using inflateBack() + calls. The fields zalloc, zfree and opaque in strm must be initialized + before the call. If zalloc and zfree are Z_NULL, then the default library- + derived memory allocation routines are used. windowBits is the base two + logarithm of the window size, in the range 8..15. window is a caller + supplied buffer of that size. Except for special applications where it is + assured that deflate was used with small window sizes, windowBits must be 15 + and a 32K byte window must be supplied to be able to decompress general + deflate streams. + + See inflateBack() for the usage of these routines. + + inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of + the paramaters are invalid, Z_MEM_ERROR if the internal state could not + be allocated, or Z_VERSION_ERROR if the version of the library does not + match the version of the header file. +*/ + +typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); +typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); + +ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, + in_func in, void FAR *in_desc, + out_func out, void FAR *out_desc)); +/* + inflateBack() does a raw inflate with a single call using a call-back + interface for input and output. This is more efficient than inflate() for + file i/o applications in that it avoids copying between the output and the + sliding window by simply making the window itself the output buffer. This + function trusts the application to not change the output buffer passed by + the output function, at least until inflateBack() returns. + + inflateBackInit() must be called first to allocate the internal state + and to initialize the state with the user-provided window buffer. + inflateBack() may then be used multiple times to inflate a complete, raw + deflate stream with each call. inflateBackEnd() is then called to free + the allocated state. + + A raw deflate stream is one with no zlib or gzip header or trailer. + This routine would normally be used in a utility that reads zip or gzip + files and writes out uncompressed files. The utility would decode the + header and process the trailer on its own, hence this routine expects + only the raw deflate stream to decompress. This is different from the + normal behavior of inflate(), which expects either a zlib or gzip header and + trailer around the deflate stream. + + inflateBack() uses two subroutines supplied by the caller that are then + called by inflateBack() for input and output. inflateBack() calls those + routines until it reads a complete deflate stream and writes out all of the + uncompressed data, or until it encounters an error. The function's + parameters and return types are defined above in the in_func and out_func + typedefs. inflateBack() will call in(in_desc, &buf) which should return the + number of bytes of provided input, and a pointer to that input in buf. If + there is no input available, in() must return zero--buf is ignored in that + case--and inflateBack() will return a buffer error. inflateBack() will call + out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() + should return zero on success, or non-zero on failure. If out() returns + non-zero, inflateBack() will return with an error. Neither in() nor out() + are permitted to change the contents of the window provided to + inflateBackInit(), which is also the buffer that out() uses to write from. + The length written by out() will be at most the window size. Any non-zero + amount of input may be provided by in(). + + For convenience, inflateBack() can be provided input on the first call by + setting strm->next_in and strm->avail_in. If that input is exhausted, then + in() will be called. Therefore strm->next_in must be initialized before + calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called + immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in + must also be initialized, and then if strm->avail_in is not zero, input will + initially be taken from strm->next_in[0 .. strm->avail_in - 1]. + + The in_desc and out_desc parameters of inflateBack() is passed as the + first parameter of in() and out() respectively when they are called. These + descriptors can be optionally used to pass any information that the caller- + supplied in() and out() functions need to do their job. + + On return, inflateBack() will set strm->next_in and strm->avail_in to + pass back any unused input that was provided by the last in() call. The + return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR + if in() or out() returned an error, Z_DATA_ERROR if there was a format + error in the deflate stream (in which case strm->msg is set to indicate the + nature of the error), or Z_STREAM_ERROR if the stream was not properly + initialized. In the case of Z_BUF_ERROR, an input or output error can be + distinguished using strm->next_in which will be Z_NULL only if in() returned + an error. If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to + out() returning non-zero. (in() will always be called before out(), so + strm->next_in is assured to be defined if out() returns non-zero.) Note + that inflateBack() cannot return Z_OK. +*/ + +ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); +/* + All memory allocated by inflateBackInit() is freed. + + inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream + state was inconsistent. +*/ + +ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); +/* Return flags indicating compile-time options. + + Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: + 1.0: size of uInt + 3.2: size of uLong + 5.4: size of voidpf (pointer) + 7.6: size of z_off_t + + Compiler, assembler, and debug options: + 8: DEBUG + 9: ASMV or ASMINF -- use ASM code + 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention + 11: 0 (reserved) + + One-time table building (smaller code, but not thread-safe if true): + 12: BUILDFIXED -- build static block decoding tables when needed + 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed + 14,15: 0 (reserved) + + Library content (indicates missing functionality): + 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking + deflate code when not needed) + 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect + and decode gzip streams (to avoid linking crc code) + 18-19: 0 (reserved) + + Operation variations (changes in library functionality): + 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate + 21: FASTEST -- deflate algorithm with only one, lowest compression level + 22,23: 0 (reserved) + + The sprintf variant used by gzprintf (zero is best): + 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format + 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! + 26: 0 = returns value, 1 = void -- 1 means inferred string length returned + + Remainder: + 27-31: 0 (reserved) + */ + + + /* utility functions */ + +/* + The following utility functions are implemented on top of the + basic stream-oriented functions. To simplify the interface, some + default options are assumed (compression level and memory usage, + standard memory allocation functions). The source code of these + utility functions can easily be modified if you need special options. +*/ + +ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be at least the value returned + by compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed buffer. + This function can be used to compress a whole file at once if the + input file is mmap'ed. + compress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer. +*/ + +ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level)); +/* + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least the value returned by + compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ + +ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); +/* + compressBound() returns an upper bound on the compressed size after + compress() or compress2() on sourceLen bytes. It would be used before + a compress() or compress2() call to allocate the destination buffer. +*/ + +ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be large enough to hold the + entire uncompressed data. (The size of the uncompressed data must have + been saved previously by the compressor and transmitted to the decompressor + by some mechanism outside the scope of this compression library.) + Upon exit, destLen is the actual size of the compressed buffer. + This function can be used to decompress a whole file at once if the + input file is mmap'ed. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. +*/ + + +typedef voidp gzFile; + +ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); +/* + Opens a gzip (.gz) file for reading or writing. The mode parameter + is as in fopen ("rb" or "wb") but can also include a compression level + ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for + Huffman only compression as in "wb1h", or 'R' for run-length encoding + as in "wb1R". (See the description of deflateInit2 for more information + about the strategy parameter.) + + gzopen can be used to read a file which is not in gzip format; in this + case gzread will directly read from the file without decompression. + + gzopen returns NULL if the file could not be opened or if there was + insufficient memory to allocate the (de)compression state; errno + can be checked to distinguish the two cases (if errno is zero, the + zlib error is Z_MEM_ERROR). */ + +ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +/* + gzdopen() associates a gzFile with the file descriptor fd. File + descriptors are obtained from calls like open, dup, creat, pipe or + fileno (in the file has been previously opened with fopen). + The mode parameter is as in gzopen. + The next call of gzclose on the returned gzFile will also close the + file descriptor fd, just like fclose(fdopen(fd), mode) closes the file + descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). + gzdopen returns NULL if there was insufficient memory to allocate + the (de)compression state. +*/ + +ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); +/* + Dynamically update the compression level or strategy. See the description + of deflateInit2 for the meaning of these parameters. + gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not + opened for writing. +*/ + +ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +/* + Reads the given number of uncompressed bytes from the compressed file. + If the input file was not in gzip format, gzread copies the given number + of bytes into the buffer. + gzread returns the number of uncompressed bytes actually read (0 for + end of file, -1 for error). */ + +ZEXTERN int ZEXPORT gzwrite OF((gzFile file, + voidpc buf, unsigned len)); +/* + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of uncompressed bytes actually written + (0 in case of error). +*/ + +ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); +/* + Converts, formats, and writes the args to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written (0 in case of error). The number of + uncompressed bytes written is limited to 4095. The caller should assure that + this limit is not exceeded. If it is exceeded, then gzprintf() will return + return an error (0) with nothing written. In this case, there may also be a + buffer overflow with unpredictable consequences, which is possible only if + zlib was compiled with the insecure functions sprintf() or vsprintf() + because the secure snprintf() or vsnprintf() functions were not available. +*/ + +ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); +/* + Writes the given null-terminated string to the compressed file, excluding + the terminating null character. + gzputs returns the number of characters written, or -1 in case of error. +*/ + +ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); +/* + Reads bytes from the compressed file until len-1 characters are read, or + a newline character is read and transferred to buf, or an end-of-file + condition is encountered. The string is then terminated with a null + character. + gzgets returns buf, or Z_NULL in case of error. +*/ + +ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +/* + Writes c, converted to an unsigned char, into the compressed file. + gzputc returns the value that was written, or -1 in case of error. +*/ + +ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +/* + Reads one byte from the compressed file. gzgetc returns this byte + or -1 in case of end of file or error. +*/ + +ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); +/* + Push one character back onto the stream to be read again later. + Only one character of push-back is allowed. gzungetc() returns the + character pushed, or -1 on failure. gzungetc() will fail if a + character has been pushed but not read yet, or if c is -1. The pushed + character will be discarded if the stream is repositioned with gzseek() + or gzrewind(). +*/ + +ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +/* + Flushes all pending output into the compressed file. The parameter + flush is as in the deflate() function. The return value is the zlib + error number (see function gzerror below). gzflush returns Z_OK if + the flush parameter is Z_FINISH and all output could be flushed. + gzflush should be called only when strictly necessary because it can + degrade compression. +*/ + +ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, + z_off_t offset, int whence)); +/* + Sets the starting position for the next gzread or gzwrite on the + given compressed file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); + the value SEEK_END is not supported. + If the file is opened for reading, this function is emulated but can be + extremely slow. If the file is opened for writing, only forward seeks are + supported; gzseek then compresses a sequence of zeroes up to the new + starting position. + + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error, in + particular if the file is opened for writing and the new starting position + would be before the current position. +*/ + +ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); +/* + Rewinds the given file. This function is supported only for reading. + + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) +*/ + +ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); +/* + Returns the starting position for the next gzread or gzwrite on the + given compressed file. This position represents a number of bytes in the + uncompressed data stream. + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +*/ + +ZEXTERN int ZEXPORT gzeof OF((gzFile file)); +/* + Returns 1 when EOF has previously been detected reading the given + input stream, otherwise zero. +*/ + +ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); +/* + Returns 1 if file is being read directly without decompression, otherwise + zero. +*/ + +ZEXTERN int ZEXPORT gzclose OF((gzFile file)); +/* + Flushes all pending output if necessary, closes the compressed file + and deallocates all the (de)compression state. The return value is the zlib + error number (see function gzerror below). +*/ + +ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); +/* + Returns the error message for the last error which occurred on the + given compressed file. errnum is set to zlib error number. If an + error occurred in the file system and not in the compression library, + errnum is set to Z_ERRNO and the application may consult errno + to get the exact error code. +*/ + +ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); +/* + Clears the error and end-of-file flags for file. This is analogous to the + clearerr() function in stdio. This is useful for continuing to read a gzip + file that is being written concurrently. +*/ + + /* checksum functions */ + +/* + These functions are not related to compression but are exported + anyway because they might be useful in applications using the + compression library. +*/ + +ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); +/* + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is NULL, this function returns + the required initial value for the checksum. + An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + much faster. Usage example: + + uLong adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); +*/ + +ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, + z_off_t len2)); +/* + Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 + and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for + each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of + seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. +*/ + +ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); +/* + Update a running CRC-32 with the bytes buf[0..len-1] and return the + updated CRC-32. If buf is NULL, this function returns the required initial + value for the for the crc. Pre- and post-conditioning (one's complement) is + performed within this function so it shouldn't be done by the application. + Usage example: + + uLong crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); +*/ + +ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); + +/* + Combine two CRC-32 check values into one. For two sequences of bytes, + seq1 and seq2 with lengths len1 and len2, CRC-32 check values were + calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 + check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and + len2. +*/ + + + /* various hacks, don't look :) */ + +/* deflateInit and inflateInit are macros to allow checking the zlib version + * and the compiler's view of z_stream: + */ +ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size)); +ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, + unsigned char FAR *window, + const char *version, + int stream_size)); +#define deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) +#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) +#define inflateBackInit(strm, windowBits, window) \ + inflateBackInit_((strm), (windowBits), (window), \ + ZLIB_VERSION, sizeof(z_stream)) + + +#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) + struct internal_state {int dummy;}; /* hack for buggy compilers */ +#endif + +ZEXTERN const char * ZEXPORT zError OF((int)); +ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); +ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); + +#ifdef __cplusplus +} +#endif + +#endif /* ZLIB_H */ diff --git a/cross-make-mingw.sh b/cross-make-mingw.sh deleted file mode 100644 index c6dbe377..00000000 --- a/cross-make-mingw.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -export CC=i586-mingw32msvc-gcc -export WINDRES=i586-mingw32msvc-windres -export PLATFORM=mingw32 -exec make $* diff --git a/docker/README.md b/docker/README.md index 30b23b8e..eecfbf4a 100644 --- a/docker/README.md +++ b/docker/README.md @@ -1,9 +1,6 @@ # Docker -Run with -```sh -mkdir .cmake -cd .cmake -cmake -DCMAKE_C_COMPILER=clang-15 -DCMAKE_CXX_COMPILER=clang++-15 -G Ninja ../ -ninja -``` +This contains Docker files for openmohaa development and server. + +- See [Development](dev/README.md) to build dev container images. +- See [Server](server/README.md) to build an OpenMoHAA server container image. diff --git a/docker/build.ps1 b/docker/build.ps1 deleted file mode 100644 index d6165255..00000000 --- a/docker/build.ps1 +++ /dev/null @@ -1,7 +0,0 @@ -docker build -t openmohaa/builder.14_04 x86_64/14.04 && ` -docker build -t openmohaa/builder.16_04 x86_64/16.04 && ` -docker build -t openmohaa/builder.18_04 x86_64/18.04 && ` -docker build -t openmohaa/builder.20_04 x86_64/20.04 && ` -docker build -t openmohaa/builder.22_04 x86_64/22.04 && ` -docker build -t openmohaa/builder.22_10 x86_64/22.10 && ` -docker build -t openmohaa/builder.18_04.i386 i386/18.04 diff --git a/docker/dev/README.md b/docker/dev/README.md new file mode 100644 index 00000000..30b23b8e --- /dev/null +++ b/docker/dev/README.md @@ -0,0 +1,9 @@ +# Docker + +Run with +```sh +mkdir .cmake +cd .cmake +cmake -DCMAKE_C_COMPILER=clang-15 -DCMAKE_CXX_COMPILER=clang++-15 -G Ninja ../ +ninja +``` diff --git a/docker/armhf/Dockerfile b/docker/dev/armhf/Dockerfile similarity index 100% rename from docker/armhf/Dockerfile rename to docker/dev/armhf/Dockerfile diff --git a/docker/dev/build.ps1 b/docker/dev/build.ps1 new file mode 100644 index 00000000..61601a22 --- /dev/null +++ b/docker/dev/build.ps1 @@ -0,0 +1,10 @@ +docker build -t openmohaa/builder.14_04 x86_64/14.04 +docker build -t openmohaa/builder.16_04 x86_64/16.04 +docker build -t openmohaa/builder.18_04 x86_64/18.04 +docker build -t openmohaa/builder.20_04 x86_64/20.04 +docker build -t openmohaa/builder.22_04 x86_64/22.04 +docker build -t openmohaa/builder.22_10 x86_64/22.10 +docker build -t openmohaa/builder.debian-11 x86_64/debian-11 +docker build -t openmohaa/builder.debian-12 x86_64/debian-12 + +docker build -t openmohaa/builder.18_04.i386 i386/18.04 diff --git a/docker/i386/18.04/Dockerfile b/docker/dev/i386/18.04/Dockerfile similarity index 100% rename from docker/i386/18.04/Dockerfile rename to docker/dev/i386/18.04/Dockerfile diff --git a/docker/s390x/Dockerfile b/docker/dev/s390x/Dockerfile similarity index 100% rename from docker/s390x/Dockerfile rename to docker/dev/s390x/Dockerfile diff --git a/docker/x86_64/14.04/Dockerfile b/docker/dev/x86_64/14.04/Dockerfile similarity index 100% rename from docker/x86_64/14.04/Dockerfile rename to docker/dev/x86_64/14.04/Dockerfile diff --git a/docker/x86_64/16.04/Dockerfile b/docker/dev/x86_64/16.04/Dockerfile similarity index 100% rename from docker/x86_64/16.04/Dockerfile rename to docker/dev/x86_64/16.04/Dockerfile diff --git a/docker/x86_64/18.04/Dockerfile b/docker/dev/x86_64/18.04/Dockerfile similarity index 100% rename from docker/x86_64/18.04/Dockerfile rename to docker/dev/x86_64/18.04/Dockerfile diff --git a/docker/x86_64/20.04/Dockerfile b/docker/dev/x86_64/20.04/Dockerfile similarity index 100% rename from docker/x86_64/20.04/Dockerfile rename to docker/dev/x86_64/20.04/Dockerfile diff --git a/docker/x86_64/22.04/Dockerfile b/docker/dev/x86_64/22.04/Dockerfile similarity index 100% rename from docker/x86_64/22.04/Dockerfile rename to docker/dev/x86_64/22.04/Dockerfile diff --git a/docker/x86_64/22.10/Dockerfile b/docker/dev/x86_64/22.10/Dockerfile similarity index 100% rename from docker/x86_64/22.10/Dockerfile rename to docker/dev/x86_64/22.10/Dockerfile diff --git a/docker/dev/x86_64/debian-11/Dockerfile b/docker/dev/x86_64/debian-11/Dockerfile new file mode 100644 index 00000000..cf3a9e6c --- /dev/null +++ b/docker/dev/x86_64/debian-11/Dockerfile @@ -0,0 +1,8 @@ +FROM debian:11 + +# install dev tools +RUN apt update && apt install -y ninja-build cmake make clang-16 lld-16 gcc-10 g++-10 flex bison +# install some important libraries like GL +RUN apt install -y --no-install-recommends ncurses-dev libglu1-mesa-dev freeglut3-dev mesa-common-dev libxxf86vm-dev libxxf86dga-dev libsdl2-dev + +WORKDIR /usr/src/openmohaa/ diff --git a/docker/dev/x86_64/debian-12/Dockerfile b/docker/dev/x86_64/debian-12/Dockerfile new file mode 100644 index 00000000..19f8d33c --- /dev/null +++ b/docker/dev/x86_64/debian-12/Dockerfile @@ -0,0 +1,8 @@ +FROM debian:12 + +# install dev tools +RUN apt update && apt install -y ninja-build cmake make clang-19 lld-19 gcc-12 g++-12 flex bison +# install some important libraries like GL +RUN apt install -y --no-install-recommends ncurses-dev libglu1-mesa-dev freeglut3-dev mesa-common-dev libxxf86vm-dev libxxf86dga-dev libsdl2-dev + +WORKDIR /usr/src/openmohaa/ diff --git a/docker/server/README.md b/docker/server/README.md new file mode 100644 index 00000000..7dfa48f3 --- /dev/null +++ b/docker/server/README.md @@ -0,0 +1,39 @@ +# Server image + +## Introduction + +Contains Dockerfile for building openmohaa-based server on Debian Bookworm. MOHAA data must be stored in `/usr/local/share/mohaa`, the directory structure should look like this: +``` +[/usr/local/share/mohaa] +├── [main] +│   └── Pak*.pk3 +├── [mainta] +│   └── pak*.pk3 +├── [maintt] +│   └── pak*.pk3 +└── [home] + ├── [main] + │   └── Custom PK3s go here + ├── [mainta] + │   └── Custom PK3s go here + └── [maintt] + └── Custom PK3s go here +``` + +`sound` and `video` folders are not needed. + +There are two ways to handle game data: +1) Create a new image based on this image (with a new Dockerfile) and copy the game directory in `/usr/local/share/mohaa`. This is the recommended solution because game data should be immutable. For mods, a base image can be created, or a volume can be mounted to `/usr/local/share/mohaa/home` which contains files (in main, mainta or maintt subdir) that will modify the game. + +or + +2) Mount a volume to the game directory directly in `/usr/local/share/mohaa`. + +## Building + +1) Put the game data (`main`, `mainta` and `maintt`) inside `full/game`, it should match the directory structure above +2) Execute one of the build.* scripts (depending on if you are running Linux or Windows). + +## Starting + +The server can now be executed using `docker run -p 12203:12203 -p 12300:12300 openmohaa/full`, or by using a docker composition file. diff --git a/docker/server/base/Dockerfile b/docker/server/base/Dockerfile new file mode 100644 index 00000000..bf63cff2 --- /dev/null +++ b/docker/server/base/Dockerfile @@ -0,0 +1,46 @@ +FROM debian:bookworm + +RUN apt update && apt install -y git clang cmake flex bison zlib1g-dev ninja-build + +# Compile with clang +ENV CC=clang +ENV CXX=clang++ + +# Clone the repository +RUN mkdir -p /tmp/openmohaa/build \ + && cd /tmp/openmohaa \ + && git clone --depth 1 --single-branch -b main https://github.com/openmoh/openmohaa.git + +# Build the project +RUN cd /tmp/openmohaa/build \ + && cmake -G "Ninja" -DBUILD_NO_CLIENT=1 -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DTARGET_LOCAL_SYSTEM=1 -DCMAKE_INSTALL_PREFIX="/usr/local/games/openmohaa" /tmp/openmohaa/openmohaa \ + && cmake --build . \ + && cmake --install . + +# Reset to the base debian image, will gain space +FROM debian:bookworm + +# Copy the installed directory +COPY --from=0 /usr/local/games/openmohaa /usr/local/games/openmohaa + +# MOHAA data (main, mainta and maintt) goes inside this directory +# mods can go inside a subdirectory called "home" +VOLUME "/usr/local/share/mohaa" + +# Install tools to check for the health +RUN apt update && apt install -y socat +COPY "health_check.sh" "/usr/local/bin/health_check.sh" +HEALTHCHECK --interval=15s --timeout=20s --start-period=10s --retries=3 CMD [ "bash", "/usr/local/bin/health_check.sh" ] + +# Create an user for starting the server +# This improves the overall security of the server instance +RUN useradd -m openmohaa +USER openmohaa + +ENV GAME_PORT=12203 +ENV GAMESPY_PORT=12300 + +COPY "entrypoint.sh" "/usr/local/bin/entrypoint.sh" +WORKDIR "/usr/local/share/mohaa" + +ENTRYPOINT [ "bash", "entrypoint.sh" ] diff --git a/docker/server/base/entrypoint.sh b/docker/server/base/entrypoint.sh new file mode 100644 index 00000000..a5d26623 --- /dev/null +++ b/docker/server/base/entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +# It's amazing that with Docker, one can't put environment variables in the array of the ENTRYPOINT command + +/usr/local/games/openmohaa/lib/openmohaa/omohaaded +set fs_homepath home +set dedicated 2 +set net_port $GAME_PORT:-12203 +set net_gamespy_port $GAMESPY_PORT:-12300 $@ diff --git a/docker/server/base/health_check.sh b/docker/server/base/health_check.sh new file mode 100644 index 00000000..f7f490eb --- /dev/null +++ b/docker/server/base/health_check.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +header=$'\xff\xff\xff\xff\x01disconnect' +# to avoid spamming the log file with getinfo/getstatus +# simply send an unsupported message +# so the server will return the disconnect message +message=$'none' + +query_port=${GAME_PORT:-12203} +data="" + +while [ -z "$data" ] +do + data=$(echo "$message" | socat - UDP:0.0.0.0:$query_port 2>/dev/null) + ret=$? + + if [ $ret != 0 ] + then + echo "Fail (socat returned $ret)" + exit 1 + fi + + if [ -n "$data" ] + then + break + fi +done + +if [ "$data" != "$header" ] +then + echo "Fail (not maching header)" + echo $line + exit 1 +fi + +# Success +exit 0 diff --git a/docker/server/build.ps1 b/docker/server/build.ps1 new file mode 100644 index 00000000..d41125a6 --- /dev/null +++ b/docker/server/build.ps1 @@ -0,0 +1,2 @@ +docker build -t openmohaa/base base +docker build -t openmohaa/full full diff --git a/docker/server/build.sh b/docker/server/build.sh new file mode 100644 index 00000000..d41125a6 --- /dev/null +++ b/docker/server/build.sh @@ -0,0 +1,2 @@ +docker build -t openmohaa/base base +docker build -t openmohaa/full full diff --git a/docker/server/full/.dockerignore b/docker/server/full/.dockerignore new file mode 100644 index 00000000..52417c5b --- /dev/null +++ b/docker/server/full/.dockerignore @@ -0,0 +1,2 @@ +**/.gitignore +**/.gitkeep \ No newline at end of file diff --git a/docker/server/full/Dockerfile b/docker/server/full/Dockerfile new file mode 100644 index 00000000..e2a3d64d --- /dev/null +++ b/docker/server/full/Dockerfile @@ -0,0 +1,6 @@ +FROM openmohaa/base + +USER openmohaa + +COPY --chown=openmohaa:openmohaa "game" "/usr/local/share/mohaa" + diff --git a/docker/server/full/game/.gitkeep b/docker/server/full/game/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/docker/server/full/game/home/.gitkeep b/docker/server/full/game/home/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/docs/compiling.md b/docs/compiling.md index 39faec5f..41b4f445 100644 --- a/docs/compiling.md +++ b/docs/compiling.md @@ -1,43 +1,84 @@ # Compiling -OpenMoHAA supports any architecture, thanks to the CMake build system and cross-platform code/libraries. While the most common little-Endian architectures (arm, aarch64, x86, x86_64) have been tested and confirmed to work, big-Endian architectures should be supported as well; however, they remain untested. +OpenMoHAA supports any architecture, thanks to the CMake build system and cross-platform code/libraries. While the most common little-Endian architectures (arm, aarch64, x86, x86_64, ppc64le) have been tested and confirmed to work, big-Endian architectures should be supported as well; however, they remain untested. The following tools are required for all platforms: -- CMake >= 3.5 +- CMake >= 3.12 - Flex (>= 2.6.4) and Bison (>= 3.5.1) -- A C++11 compiler is also required. +- A C++11 compiler +- [SDL2](https://github.com/libsdl-org/SDL/tree/SDL2) +- [OpenAL SDK](https://github.com/kcat/openal-soft) -The installation directory can be set to the MOHAA directory. +The following tools may be useful: +- [cURL](https://github.com/curl/curl) -By default, the build will produce both the client and dedicated server versions. The client can be omitted from the build by appending `-DBUILD_NO_CLIENT=1` to the CMake command-line arguments. Using this parameter will result in only the server portion being built. +The installation directory can be set to the MOHAA directory with `-DCMAKE_INSTALL_PREFIX=/path/to/mohaa`. + +Compiling debug binaries will result in a `-dbg` suffix appended to the name of the binaries to avoid mixing debug/release code. + +cURL is used to access websites. It is currently used to check for a new release. If the project is compiled without cURL, OpenMoHAA will be unable to check for new updates automatically. ## Compiling for Linux These are the tools required on Linux : -- Clang >= 3.3 or GCC >= 4.8.5 +- Clang >= 7.0.1 or GCC >= 9.4.0 - libsdl2-dev +- libopenal-dev +- libssl-dev +- libcurl4-openssl-dev -**clang-3.5** and **gcc-4.8.5** should work (tested on Ubuntu 16.04), but the latest version should be used. - -Ubuntu 20.04 is the minimum version required to fully compile the project successfully. +**clang-7** and **gcc-9** has been tested to work on Ubuntu 20.04. Although it's best to use the latest versions. 1 line install command with clang: ```sh -sudo apt-get install -y cmake ninja-build clang lld flex bison libsdl2-dev +sudo apt-get install -y cmake ninja-build clang lld flex bison libsdl2-dev libopenal-dev libcurl4-openssl-dev ``` Example with **CMake** and **ninja-build** installed: ```sh mkdir .cmake && cd .cmake -cmake -G Ninja ../ +cmake ../ +cmake --build . +cmake --install . ``` +Usually binaries get installed inside the `/usr/local/lib/openmohaa` directory. + Other compilers can be specified by appending `-DCMAKE_C_COMPILER=/path/to/compiler -DCMAKE_CXX_COMPILER=path/to/compiler` to the CMake command-line. ## Compiling for Windows Visual Studio (2019 or 2022) is generally preferred. -Flex and Bison can be downloaded from here: https://github.com/lexxmark/winflexbison/releases/tag/v2.5.25 +- Get Flex/Bison: https://github.com/lexxmark/winflexbison/releases/latest +- Get OpenAL: https://github.com/kcat/openal-soft/releases/latest rename `soft_oal.dll` to `OpenAL64.dll` on 64-bit and `OpenAL32.dll` on 32-bit +- Get cURL: https://github.com/curl/curl -Append `-DFLEX_EXECUTABLE=...\win_flex.exe -DBISON_EXECUTABLE=...\win_bison.exe` to the CMake command-line to use the package from the link above. +Optionally, The cURL library can be compiled with the following CMake commands: +``` +cmake -DCMAKE_INSTALL_PREFIX="E:\Src\openmoh\openmohaa\thirdparty\curl\build\install" -DCURL_USE_LIBPSL=OFF -DCURL_USE_SCHANNEL=ON -B build +cmake --build build --config Release +cmake --install build --config Release +``` + +Append `-DFLEX_EXECUTABLE=...\win_flex.exe -DBISON_EXECUTABLE=...\win_bison.exe -DOPENAL_INCLUDE_DIR="path/to/oal/include" -DOPENAL_LIBRARY="path/to/oal"` to the CMake command-line to compile the project. + +Example after cloning the repository: +```sh +mkdir .cmake && cd .cmake +cmake -DFLEX_EXECUTABLE=path/to/win_flex.exe -DBISON_EXECUTABLE=path/to/win_bison.exe -DOPENAL_INCLUDE_DIR="path/to/oal/include" -DOPENAL_LIBRARY="path/to/oal" ../ +cmake --build . +cmake --install . +``` + +Usually binaries get installed inside the `Program Files (x86)` folder. + +afterwards you can can append `-DCURL_ROOT=path\to\curl\install` to specify the install path to cURL. + +## Tweaking the build + +- `-DBUILD_NO_CLIENT=1` Don't build client binaries. This will only build the dedicated server binaries. +- `-DCMAKE_LIB_SUFFIX=suffix` Default suffix to use for the default `lib` directory. For example `-DCMAKE_LIB_SUFFIX=64` +- `-DNO_MODERN_DMA=1` Use the basic DMA sound system from quake3. This lacks many features such as soundtracks and movie audio from the modern OpenAL-based DMA sound system. This option is not recommended, unless openal is not available. +- `-DTARGET_LOCAL_SYSTEM=1` for compiling and installing on the local system. This will remove the architecture suffix at the end of each binary. This option can be useful for packaging builds. +- `-DUSE_SYSTEM_LIBS=1` for third-party libraries, this will make use of system libraries instead of libraries that are embedded within the project. diff --git a/docs/configuration.md b/docs/configuration.md new file mode 100644 index 00000000..b110713e --- /dev/null +++ b/docs/configuration.md @@ -0,0 +1,139 @@ +# Configuration and commands + +## General configuration + +This documentation currently only lists new changes that were introduced in OpenMoHAA. + +If you want to use containers, see [Building a server container in Docker](../../docker/server/README.md) to build an image for your dedicated server. + +### Home directory + +In original MOH:AA, the game installation directory is used to store mods and data, it's not the case in OpenMoHAA as it uses the home directory by default to write data in here, and the home directory can be used to store mods. This behavior can be changed: + +- `set fs_homepath Z:\openmohaa_data`: User data will be read and written in the directory located in `Z:\openmohaa_data` +- `set fs_homepath homedata`: The subdirectory `homedata` in the game directory will be used to read and store user data +- `set fs_homepath .`: Not recommended, the game directory will be used for storing user data, just like the original MOH:AA + +The variable defaults to the following value depending on the OS: + +- `%APPDATA%\openmohaa` on Windows +- `~/.openmohaa` on Linux +- `~/Library/Application Support/openmohaa` on macOS + +### Configure the network components + +The network settings can be adjusted to use either IPv4, IPv6, or both. By default, IPv6 is disabled on dedicated servers. The following commands adjust network settings: + +- `set net_enabled 0`: This networking. +- `set net_enabled 1`: This enables IPv4 only (the default setting for dedicated servers). +- `set net_enabled 2`: This enables IPv6 only. +- `set net_enabled 3`: This enables both IPv4 and IPv6 (the default setting when running the standalone game). + +*Note: The master server (using the GameSpy protocol) does not support IPv6. If IPv4 is disabled, the server won't appear in the online server list for internet games, even if IPv6 is enabled.* + +### Flood protection differences with MOH: Spearhead + +Flood protection is turned on by default in all games (`sv_floodProtection 1`). + +- In MOH: Allied Assault and OpenMoHAA, flood protection checks all commands. +- In MOH: Spearhead 2.0 and later, flood protection only checks for text messages. + +While flood protection prevents spam, it can sometimes be annoying in certain situations like reloading and checking scores within a short period of time. If needed, it can be disabled with `set sv_floodProtection 0`. + +For more details on preventing message spamming, check out the [Chat](#chat) section below. + +### Updates + +The game periodically retrieves the latest version number from the GitHub project page at fixed intervals to check for available updates. This process runs in the background and does not interfere with the main thread, meaning it will not cause hangs or stability issues. Updates are not applied automatically, they must be downloaded and installed manually. + +Update checking is enabled by default, but can be disabled under any of the following conditions: +- `net_enabled` is set to 0, disables networking, as mentioned above +- `com_updatechecker_enabled` is set to 0 +- The project is compiled without libcurl support + +If you disable the update checker, remember to regularly check the project page for new versions. Updates can improve security and provide important fixes against exploits. + +## Server configuration + +### Optimization / Antichams + +A new variable, `sv_netoptimize`, enables a feature that optimizes network bandwidth by not sending players information about others they can't see. For each client, the server optimizes by only transmitting data about players within their view. Clients will not receive information about players they can't see. This feature also helps protect against cheaters: + +- `set sv_netoptimize 0`: This disables the optimization - the default +- `set sv_netoptimize 1`: This enables the optimization for entities that are moving +- `set sv_netoptimize 2`: This enables the optimization, always + +This option exists since **Medal of Honor: Allied Assault Breakthrough** 2.30, however it was improved in OpenMoHAA: sounds like footsteps will be sent so players don't get confused. + +### Managing bans + +A new feature was introduced to ban IP addresses, thanks to the [ioquake3](https://ioquake3.org/) project. Bans are saved by default in `serverbans.dat` but it can be modified with the `sv_banFile` variable. Here are commands to manage bans: + +|Name |Parameters |Description +|-----------|------------------------------------------------|----------- +|rehashbans | |Loads saved bans from the banlist file +|listbans | |Lists all banned IP addresses +|banaddr |ip[*/subnet*] \| clientnum [*subnet*] [reason] |Bans an IP through its address or through a client number, a subnet can be specified to ban a network range +|exceptaddr |ip[*/subnet*] \| clientnum [*subnet*] |Adds an IP as an exception, for example IP ranges can be banned but one or more exceptions can be added +|bandel |ip[*/subnet*] \| num |Unbans an IP address or a subnet, the entry number can be specified as an alternative +|exceptdel |ip[*/subnet*] \| num |Removes a ban exception +|flushbans | |Removes all bans + +Examples: + +- `banaddr 192.168.5.2` will ban the IP address **192.168.5.2**. +- `banaddr 192.168.1.0/24` will ban all **192.168.1.x** IP addresses (in the range **192.168.1.0**-**192.168.1.255**). +- `banaddr 2` will ban the IP address of the client **#2**. +- `banaddr 4 24` will ban the subnet of client **#4** - i.e if client .**#4** has IP **192.168.8.4**, then it will ban all IPs ranging from **192.168.8.0**-**192.168.8.255**. +- `exceptaddr 3` will add the IP of client **#3** as an exception. +- `bandel 192.168.8.4` will unban **192.168.8.4**. +- `bandel 192.168.1.0/24` will unban the entire **192.168.1.0** subnet (IP ranging from **192.168.1.0**-**192.168.1.255**). + +To calculate IP subnets, search for `IP subnet calculator` on Internet. + +### Game + +#### Chat + +Chat messages will be logged in the console and in the logfile without requiring to set the `developer` variable. + +The in-game chat can be tweaked: + +- `set g_instamsg_allowed 0`: This disables voice instant messages. +- `set g_instamsg_minDelay x`: x is the delay in milliseconds, the minimum delay between each instant messages to avoid spamming. Defaults to 1000. +- `set g_textmsg_allowed 0`: This disables text messages. All, team and private messages will be disabled. +- `set g_textmsg_minDelay x`: x is the delay in milliseconds, the minimum delay between each text message to avoid spamming. Defaults to 1000. + +Temporarily disabling text messages can be useful in situations where tensions arise in the chat. Otherwise, it's best to keep them enabled under normal circumstances. + +#### Balancing teams + +This setting prevents clients from joining a team if that team already has more players than the others. By default, it's turned off, but it can be switched on with the command `set g_teambalance 1`. + +This feature is passive: it only checks the team sizes when someone tries to join, so it won't automatically balance teams during the game. + +*Note: This check doesn't apply in server scripts; it only works when clients join teams directly.* + +#### Bots + +OpenMoHAA introduced multiplayer bots which can be used for entertainment or for testing purposes. Bots are players controlled by the computer, they appear in the scoreboard with their ping set to **bot**. + +First get the [mp-navigation](https://github.com/openmoh/mp-navigation) pk3, it is needed so bots can navigate through MP maps. Then the following variables are used to configure bots: + +- `set sv_maxbots x`: **Required**, configure the maximum number of bots allowed in the game. Since the game can only handle a total of 64 players (clients), the number of bots will be limited to 64 minus the number of real players (`sv_maxclients`). For example, if you set `sv_maxclients` to 48, the maximum number of bots (sv_maxbots) can be 16. +- `set sv_numbots x`: Set the number of bots to spawn. It will be capped to the value of `sv_maxbots`. +- `set sv_minPlayers x`: Configure the minimum number of players required. If the number of real players in a team is below the specified value, the game will automatically add bots to fill the gap. For example, if `sv_minPlayers` is set to 8 and only 5 real players are connected and in a team, the game will spawn 3 bots to make sure there are always 8 players in the game. + +Example with the requirement of 6 players: +```cpp +set sv_maxbots 16 // Reserve 16 client slots for bots +set sv_minPlayers 6 // When there is 0 player in a team, there will be 6 bots. When there is 1 player in a team, there will be 5 bots, and so on +``` + +Example with 4 bots playing: +```cpp +set sv_maxbots 16 // Reserve 16 client slots for bots +set sv_numbots 4 // Spawn 4 bots +``` + +*Note: Bots will have their ping set to **bot** so that all players in-game know they are bots. This prevents any confusion and eliminates any doubt about a hacker being in the game.* diff --git a/docs/faq.md b/docs/faq.md new file mode 100644 index 00000000..6f54759f --- /dev/null +++ b/docs/faq.md @@ -0,0 +1,126 @@ +# Frequently Asked Questions + +
+My OpenMoHAA client has crashed, leaving the desktop brightened up. How can I fix this without restarting the computer? + +## Try one of the following options: + +### 1. Lock and Unlock Your Screen (Windows+L) +Simply pressing **Win+L** to lock your screen and then logging back in can sometimes reset the brightness to its previous state. + +### 2. Command Line Fix (Windows) +If you have an **NVIDIA** or **AMD** GPU, you can try these commands: + +- **For NVIDIA GPUs:** + Open **Command Prompt (cmd.exe)** or **PowerShell** and run: + + ```powershell + nvidia-settings -a "DPY-0/RedBrightness=0.0" -a "DPY-0/GreenBrightness=0.0" -a "DPY-0/BlueBrightness=0.0" + ``` + + (If you have multiple displays, `DPY-0` may need to be replaced with the correct display identifier.) + +- **For AMD GPUs:** + Open the **AMD Radeon Software** and manually adjust brightness or SDR settings to reset them. + +### 3. Use a Third-Party Tool to Reset Gamma & Brightness +Programs like **Gamma Panel** or **f.lux** can help restore modified brightness and gamma settings quickly. + +### 4. Restart the Graphics Driver (Windows) +Press **Win + Ctrl + Shift + B** to restart the graphics driver without rebooting your PC. Your screen will briefly go black, then reset. + +### 5. Reset Gamma via Xrandr (Linux, Xorg Users) +If you’re using Linux with Xorg, try this command to reset gamma settings: + +```bash +xrandr --output eDP-1 --gamma 1:1:1 +``` + +(Replace `eDP-1` with the correct display name, which you can find by running `xrandr` in the terminal.) + +### 6. Changing Display Mode in Windows (Alternative) +If none of the above solutions work, you can manually reset brightness by changing the display mode: +1. Right-click on your desktop and select **Display settings**. +2. Scroll down to **Display resolution** and change it to a different setting. +3. Revert it back to your original resolution. + +This forces Windows to refresh display settings, which may restore brightness. +
+ +--- + +
+I am using a custom map/mod, and I experience glitches that do not occur in the original game. What should I do? + +### 1. Check game file precedences: +As OpenMoHAA has MultiUser Support (on Windows, user game data is stored in `%APPDATA%\openmohaa`), custom files in this directory override existing files in the game installation folder. + +|Example| +|-| +| A custom `grenzuebergang_KE.pk3` (placed in the user game data folder) contains a `scripts/effects.shader` file and it does not declare `bh_wood_puff_simple`. As a result, bullet impact effect has no texture. +However, if `grenzuebergang_KE.pk3` is placed in the game installation folder (`MOHAA/main` or `/mainta` or `/maintt`, where the base `pak*.pk3` files are located) original files take precedence over custom files as they follow the alphabetical order of file naming. +`Pak1.pk3` contains the original `scripts/effects.shader` where the impact effect is declared; therefore, the player does not experience any issue, as the original file is "loaded" after the custom file. | + +### 2. Create a new issue: +If changing the file precedences has no effect on the glitch you discovered, you have probably found a new bug in the OpenMoHAA engine, so please create a new issue for the developers. +
+ +--- + +
+I cannot set my screen resolution in the Options/Video menu. How can I change it? + +### Edit `omconfig.cfg`: + +If they do not exist, add the following console variables (cvars) to your `omconfig.cfg`[^1] + +``` +seta r_mode "-1" +seta r_customwidth "1920" +seta r_customheight "1080" +``` + +### or (alternatively) run the game with command line parameters: + +Launch your OpenMoHAA client with the following: + +``` ++set r_mode -1 +set r_customwidth 1920 +set r_customheight 1080 +``` + +Change the width and height accordingly. + +
+ +--- + +
+Console does not show up in OpenMoHAA. How can I enable it? + +### 1. Check if console is enabled + +In the Options -> Advanced menu, make sure that the checkbox is checked (red "X") at the Console. +Alternatively, check if the value is equal to 1 for the following cvar in `omconfig.cfg`[^1]: +``` +seta ui_console "1" +``` + +### 2. Check Console keys cvar + +OpenMoHAA introduces a new cvar that stores the keys to open up console. Edit the following cvar in your `omconfig.cfg`[^1]: + +``` +seta cl_consoleKeys "~ ` 0x7e 0x60" +``` + +As you see the default variable above, you can add multiple keys (between the quotation marks, divided by spaces) to display/hide the console. + +> bind ` "toggleconsole" is not to be used anymore. +
+ + +--- + +Footnotes: + +[^1]: omconfig.cfg is the OpenMoHAA configuration file that is located in the user game data folder (on Windows, `%APPDATA%\openmohaa\main` or `mainta` or `maintt` `\configs\omconfig.cfg`) diff --git a/docs/features.md b/docs/features.md index 707af024..2ebf8105 100644 --- a/docs/features.md +++ b/docs/features.md @@ -2,22 +2,47 @@ A lot of bugs and exploits from MOH:AA were fixed in OpenMoHAA (BOF exploit, grenade crash bug, command overflow...). +## Summary + +- SDL2 backend +- OpenAL sound support (better sound quality) +- Full 64-bit support +- Cross-platform support +- Multiuser support on OS (On Windows, user game data is stored in "%APPDATA%\openmohaa") +- Many bug fixes and additions from ioquake3 +- Automatic scaling of UI elements on high resolutions like 4K + +Overall, better compatibility on modern systems and bugfixes. + ## Additions -### Client-side and server-side +### General +- Demo recording - Features from ioquake3 +- Features from MOH: Spearhead 2.15 and MOH: Breakthrough 2.40 - IPv6 support (from ioquake3) -- Features from SH 2.15 and BT 2.40 + +### Client-side + +- Customizable FOV +- OpenAL and SDL are used +- Smoother animations + +#### Stufftext restriction + +Servers can no longer make players run any command. Only a small number of safe commands are now allowed. This change helps prevent abuse, like unbinding player controls, and improves overall security. + +`stufftext` is now limited to trusted, commonly used commands, like those for controlling in-game music. The full list can be found in [cgame/cg_servercmds_filter.c](../code/cgame/cg_servercmds_filter.c). ### Server-side - Bots -- Demo recording - IP ban (from ioquake3) - More script commands for mods - Non-PVS optimization -- Spectate players in first-person +- Packet flood protection +- Ability to enable/disable the text chat and the voice message chat and set a delay between chat/instant messages #### Non-PVS optimization @@ -29,7 +54,8 @@ Enable this feature with `set sv_netoptimize 2`. ### Client-side and server-side -- Fixes from SH 2.15 and BT 2.40 +- Fixed background ambient sounds being muted when restarting +- Fixes from SH 2.15, BT 2.40 and ioquake3 - Buffer overflow fixes - Directory traversal fix @@ -37,13 +63,18 @@ Enable this feature with `set sv_netoptimize 2`. - DM message comment fix - Callvote fix -- Getting weapons from opposite team -- Grenade crash bug -- Grenade spectator charge bug -- `leave_team` bug fix -- Primary DM weapon spectator fix -- Projectile spectator glitch fix (for when firing a projectile then going into spectator to kill anyone) -- `sv_fps` (tickrate) fix, higher values won't cause animation issues anymore +- Fix to prevent getting weapons from opposite team +- Fixed grenade crash bug +- Fixed grenade spectator charge bug +- Fixed `leave_team` bug +- Fixed memory leaks issues in long matches +- Fixed sharking issues with ladders +- Fix to prevent being able to spectate while still in the team with a NULL primary deathmatch weapon +- Fix to prevent throwing a projectile and going into spectator to kill anyone +- Fix for `sv_fps` (tickrate), higher values won't cause animation issues anymore +- Grenades with 1 ammo can now be picked up +- Prevent crashing when the last weapon has no ammo and other weapons are inventory items +- Prevent doors from getting blocked ## Planned features diff --git a/docs/features_g_allclasses.html b/docs/features_g_allclasses.html index 5b4b8471..0c82ecfa 100644 --- a/docs/features_g_allclasses.html +++ b/docs/features_g_allclasses.html @@ -28,14 +28,17 @@

ai_on

    Turns the AI on for this actor.
+

alarmnode( String value )
+

    Sets the name of the alarm node for the actor (must have type set to alarm for effect)
+

alarmnode

    Gets the name of the alarm node for the actor (must have type set to alarm for effect)

alarmnode( String value )

    Sets the name of the alarm node for the actor (must have type set to alarm for effect)
-

alarmnode( String value )
-

    Sets the name of the alarm node for the actor (must have type set to alarm for effect)
+

alarmthread( String value )
+

    Sets the name of the alarm thread for the actor (must have type set to alarm for effect)

alarmthread

    Gets the name of the alarm thread for the actor (must have type set to alarm for effect)
@@ -43,8 +46,8 @@

alarmthread( String value )

    Sets the name of the alarm thread for the actor (must have type set to alarm for effect)
-

alarmthread( String value )
-

    Sets the name of the alarm thread for the actor (must have type set to alarm for effect)
+

ammo_grenade( Integer grenade_count )
+

    Gives the AI some grenades

ammo_grenade

    Returns how many grenades an AI has
@@ -52,9 +55,6 @@

ammo_grenade( Integer grenade_count )

    Gives the AI some grenades
-

ammo_grenade( Integer grenade_count )
-

    Gives the AI some grenades
-

anim( String name )

    Play animation.
@@ -65,10 +65,10 @@
    Loop animation.

animname
-

    Gets the animname.
+
    Sets the animname.

animname
-

    Sets the animname.
+
    Gets the animname.

animscript( String name )

    Play the animation script
@@ -95,43 +95,43 @@
    Used only by grenade return animations to tell the code when to attach the grenade to the actor

attackhandler
-

    Sets the current script that will handle attack events
+
    Gets the current script that will handle attack events

attackhandler
-

    Gets the current script that will handle attack events
+
    Sets the current script that will handle attack events

attackplayer

    Force Actor to attack the player
+

avoidplayer( Integer allowavoid )
+

    set to 0 if this AI shouldn't automatically get out of the way, non-zero if he should.
    +
+ +

avoidplayer( Integer allowavoid )
+

    set to 0 if this AI shouldn't automatically get out of the way, non-zero if he should.
    +
+

avoidplayer

    is 0 if this AI won't automatically get out of the way, non-zero if he will
-

avoidplayer( Integer allowavoid )
-

    set to 0 if this AI shouldn't automatically get out of the way, non-zero if he should.
    -
- -

avoidplayer( Integer allowavoid )
-

    set to 0 if this AI shouldn't automatically get out of the way, non-zero if he should.
    -
- -

balconyheight( Float height )
-

    minimum height a balcony guy must fall to do special balcony death
-

balconyheight( Float height )

    minimum height a balcony guy must fall to do special balcony death

balconyheight

    minimum height a balcony guy must fall to do special balcony death
+

balconyheight( Float height )
+

    minimum height a balcony guy must fall to do special balcony death
+

bedead

    Forces the actor to be instantly and totally dead; no death animation is played

blendtime
-

    Get the crossblend time
+
    Set the crossblend time to something other than the default, in seconds

blendtime
-

    Set the crossblend time to something other than the default, in seconds
+
    Get the crossblend time

breakspecial

    tell ai to break special attack
@@ -175,10 +175,10 @@ Should be called infrequently, and never during the middle of a grenade toss.
preps the dead actor for turning nonsolid gradually over time

deathhandler
-

    Gets the current script that will handle death events
+
    Sets the current script that will handle death events

deathhandler
-

    Sets the current script that will handle death events
+
    Gets the current script that will handle death events

deathsinkstart

    Makes the entity sink into the ground and then get removed (this starts it).
@@ -192,21 +192,21 @@ Should be called infrequently, and never during the middle of a grenade toss.
detachgrenade
    Used only by grenade return animations to tell the code when to throw the grenade
-

disguise_accept_thread( String value )
-

    Sets the name of the thread for the actor to start when accepting papers
- -

disguise_accept_thread( String value )
-

    Sets the name of the thread for the actor to start when accepting papers
-

disguise_accept_thread

    Gets the name of the thread for the actor to start when accepting papers
-

disguise_level
-

    Gets the disguise level of the actor. May be 1 or 2
+

disguise_accept_thread( String value )
+

    Sets the name of the thread for the actor to start when accepting papers
+ +

disguise_accept_thread( String value )
+

    Sets the name of the thread for the actor to start when accepting papers

disguise_level( Integer value )

    Sets the disguise level of the actor. May be 1 or 2
+

disguise_level
+

    Gets the disguise level of the actor. May be 1 or 2
+

disguise_level( Integer value )

    Sets the disguise level of the actor. May be 1 or 2
@@ -219,12 +219,12 @@ Should be called infrequently, and never during the middle of a grenade toss.
disguise_period
    Gets the time between the end of one disguise behavior and start of the next
-

disguise_range
-

    Gets the maximum distance for disguise behavior to get triggered
-

disguise_range( Float range_in_units )

    Sets the maximum distance for disguise behavior to get triggered
+

disguise_range
+

    Gets the maximum distance for disguise behavior to get triggered
+

disguise_range( Float range_in_units )

    Sets the maximum distance for disguise behavior to get triggered
@@ -276,10 +276,10 @@ Should be called infrequently, and never during the middle of a grenade toss.
eyeslookat( Entity entity )
    The actor will look at this entity.
-

fallheight
+

fallheight( Float height )

    Set the fallheight
-

fallheight( Float height )
+

fallheight

    Set the fallheight

favoriteenemy( Entity ai_or_player )
@@ -300,35 +300,38 @@ Should be called infrequently, and never during the middle of a grenade toss.
fixedleash( Float multiplier )

    if non-zero, the leash will never auto-reset; if zero, the leash may auto-reset
-

fixedleash
-

    if non-zero, the leash will never auto-reset; if zero, the leash may auto-reset
-

fixedleash( Float multiplier )

    if non-zero, the leash will never auto-reset; if zero, the leash may auto-reset
-

fov( Float angle )
-

    The fov angle of the actor
- -

fov( Float angle )
-

    The fov angle of the actor
+

fixedleash
+

    if non-zero, the leash will never auto-reset; if zero, the leash may auto-reset

fov

    The fov angle of the actor
+

fov( Float angle )
+

    The fov angle of the actor
+ +

fov( Float angle )
+

    The fov angle of the actor
+

GetRunAnim

    Internal usage

GetWalkAnim

    Internal usage
+

gren_awareness( Float awareness_percent )
+

    sets the awareness of grenades in 0-100 percent chance of responding to a grenadewhen the AI sees it (applied once every 0.4 seconds)
+ +

gren_awareness( Float awareness_percent )
+

    sets the awareness of grenades in 0-100 percent chance of responding to a grenadewhen the AI sees it (applied once every 0.4 seconds)
+

gren_awareness

    gets the awareness of grenades in 0-100 percent chance of responding to a grenadewhen the AI sees it (applied once every 0.4 seconds)
-

gren_awareness( Float awareness_percent )
-

    sets the awareness of grenades in 0-100 percent chance of responding to a grenadewhen the AI sees it (applied once every 0.4 seconds)
- -

gren_awareness( Float awareness_percent )
-

    sets the awareness of grenades in 0-100 percent chance of responding to a grenadewhen the AI sees it (applied once every 0.4 seconds)
+

gun( String s )
+

    specifies the gun to use

gun( String s )

    specifies the gun to use
@@ -336,9 +339,6 @@ Should be called infrequently, and never during the middle of a grenade toss.
gun
    gets the gun to being used
-

gun( String s )
-

    specifies the gun to use
-

hascompletelookahead

    returns true if there are no corners to turn on the rest of the AI's current path
@@ -348,12 +348,12 @@ Should be called infrequently, and never during the middle of a grenade toss.
headmodel( String headmodel )
    sets the head model
-

headskin( String headskin )
-

    sets the head skin
-

headskin

    gets the head skin
+

headskin( String headskin )
+

    sets the head skin
+

hearing( Float radius )

    The hearing radius of the actor
@@ -381,24 +381,24 @@ Should be called infrequently, and never during the middle of a grenade toss.
immediateremove
    Removes this listener immediately.
-

inreload( Integer reloading )
-

    set to non-zero to indicate the AI is in a reload
-

inreload

    returns non-zero if the AI is in a reload
+

inreload( Integer reloading )
+

    set to non-zero to indicate the AI is in a reload
+

interrupt_point

    hint from animation scripts to AI code that now is a good time to switch animations

interval( Float distance )

    Sets the distance AI tries to keep between squadmates while moving.
-

interval
-

    Gets the distance AI tries to keep between squadmates while moving.
-

interval( Float distance )

    Sets the distance AI tries to keep between squadmates while moving.
+

interval
+

    Gets the distance AI tries to keep between squadmates while moving.
+

intervaldir

    the direction the AI would like to move to maintain its interval
@@ -439,32 +439,35 @@ Location values:

leash( Float distance )

    Sets the maximum distance the AI will wander from its leash home
-

leash
-

    Gets the maximum distance the AI will wander from its leash home
-

leash( Float distance )

    Sets the maximum distance the AI will wander from its leash home
-

lookaroundangle
-

    gets the angle in degrees left or right of center that the AI will look around while patrolling
+

leash
+

    Gets the maximum distance the AI will wander from its leash home

lookaroundangle( Float angle )

    gets the angle in degrees left or right of center that the AI will look around while patrolling
+

lookaroundangle
+

    gets the angle in degrees left or right of center that the AI will look around while patrolling
+

lookaroundangle( Float angle )

    gets the angle in degrees left or right of center that the AI will look around while patrolling

lookat( Entity entity )

    The actor will look at this entity.
+

maxdist( Float distance )
+

    Sets the maximum distance the AI tries to allow between itself and the player
+ +

maxdist( Float distance )
+

    Sets the maximum distance the AI tries to allow between itself and the player
+

maxdist

    Gets the maximum distance the AI tries to keep between itself and the player
-

maxdist( Float distance )
-

    Sets the maximum distance the AI tries to allow between itself and the player
- -

maxdist( Float distance )
-

    Sets the maximum distance the AI tries to allow between itself and the player
+

mindist( Float distance )
+

    Sets the minimum distance the AI tries to keep between itself and the player

mindist

    Gets the minimum distance the AI tries to keep between itself and the player
@@ -472,15 +475,12 @@ Location values:

mindist( Float distance )

    Sets the minimum distance the AI tries to keep between itself and the player
-

mindist( Float distance )
-

    Sets the minimum distance the AI tries to keep between itself and the player
+

mood
+

    gets the AI mood: 'bored', 'nervous', 'curious', or 'alert'.

mood( String new_mood )

    sets the AI mood... must be 'bored', 'nervous', 'curious', or 'alert'.
-

mood
-

    gets the AI mood: 'bored', 'nervous', 'curious', or 'alert'.
-

movedir

    Returns a unit vector pointing in the current direction of motion, or zero if not moving.This still has meaning if velocity is zero but the AI is starting to move on a path.
@@ -493,15 +493,15 @@ Location values:

moveto( String anim, String dest )

    Specify the location to move to, with animation anim.
+

mumble( Integer can_mumble )
+

    Set to 1 if this guy is allowed to mumble, or 0 if he is not
+ +

mumble( Integer can_mumble )
+

    Set to 1 if this guy is allowed to mumble, or 0 if he is not
+

mumble

    Returns 1 if this guy is allowed to mumble, or 0 if he is not
-

mumble( Integer can_mumble )
-

    Set to 1 if this guy is allowed to mumble, or 0 if he is not
- -

mumble( Integer can_mumble )
-

    Set to 1 if this guy is allowed to mumble, or 0 if he is not
-

nationality

    Get the nationality of an actor. Return values are ger, it, usa, uk, ussr and unset.
@@ -511,15 +511,15 @@ Location values:

nationality( String nationality )

    Set the nationality of an actor. Valid entries are default, ger, it, usa, uk, and ussr.
+

nolongpain( Integer allow )
+

    Set to 1 if long pain is not allowed, or 0 if long pain is allowed.
+ +

nolongpain( Integer allow )
+

    Set to 1 if long pain is not allowed, or 0 if long pain is allowed.
+

nolongpain

    Returns 1 if long pain is not allowed, or 0 if long pain is allowed.
-

nolongpain( Integer allow )
-

    Set to 1 if long pain is not allowed, or 0 if long pain is allowed.
- -

nolongpain( Integer allow )
-

    Set to 1 if long pain is not allowed, or 0 if long pain is allowed.
-

nonvislevel

    visibility level in range 0-1 below which an enemy is treated as non-visible
@@ -529,6 +529,10 @@ Location values:

nonvislevel

    visibility level in range 0-1 below which an enemy is treated as non-visible
+

nosurprise( Integer nosurprise )
+

    set to 0 to allow this guy to play a surprised animation when first encountering an enemy.
    +
+

nosurprise

    gets whether or not this guy is allowed to play a surprised animation when first encountering an enemy.
@@ -537,46 +541,42 @@ Location values:
    set to 0 to allow this guy to play a surprised animation when first encountering an enemy.
-

nosurprise( Integer nosurprise )
-

    set to 0 to allow this guy to play a surprised animation when first encountering an enemy.
    -
- -

noticescale( Float multiplier )
-

    Set the max multiplier in time to notice an enemy (default 100, half as big notices twice as fast)
-

noticescale( Float multiplier )

    Set the max multiplier in time to notice an enemy (default 100, half as big notices twice as fast)

noticescale

    Get the max multiplier in time to notice an enemy (default 100, half as big notices twice as fast)
-

no_idle
-

    Specifies if the actor will not go into idle after playing an animation
+

noticescale( Float multiplier )
+

    Set the max multiplier in time to notice an enemy (default 100, half as big notices twice as fast)

no_idle

    Gets if the actor will not go into idle after playing an animation
+

no_idle
+

    Specifies if the actor will not go into idle after playing an animation
+

pain( Entity attacker, Integer damage, Entity inflictor, Vector position, Vector direction, Vector normal, Integer knockback, Integer damageflags, Integer meansofdeath, Integer location )

    used to inflict pain to an entity

painhandler
-

    Sets the current script that will handle pain events
+
    Gets the current script that will handle pain events

painhandler
-

    Gets the current script that will handle pain events
+
    Sets the current script that will handle pain events

pathdist

    returns total distance along current path to the path goal
+

patrolpath( String value )
+

    Sets the name of the patrol path for the actor (must have type set to patrol for effect)
+ +

patrolpath( String value )
+

    Sets the name of the patrol path for the actor (must have type set to patrol for effect)
+

patrolpath

    Gets the name of the patrol path for the actor (must have type set to patrol for effect)
-

patrolpath( String value )
-

    Sets the name of the patrol path for the actor (must have type set to patrol for effect)
- -

patrolpath( String value )
-

    Sets the name of the patrol path for the actor (must have type set to patrol for effect)
-

physics_off

    turn physics off.
@@ -614,15 +614,15 @@ default channel, CHAN_BODY.

resetleash

    resets the AI's leash to their current position
-

runanimrate( Float multiplier )
-

    Set the rate at which the run animation plays back
- -

runanimrate( Float multiplier )
-

    Set the rate at which the run animation plays back
-

runanimrate

    Get the rate at which the run animation plays back
+

runanimrate( Float multiplier )
+

    Set the rate at which the run animation plays back
+ +

runanimrate( Float multiplier )
+

    Set the rate at which the run animation plays back
+

runto( String dest )

    Specify the location to run to.
@@ -665,15 +665,19 @@ default channel, CHAN_BODY.

share_grenade

    internal code use only - shares an AI's grenade with his squad mates.
-

sight( Float max_sight_range )
-

    Sets the vision distance of the actor.
-

sight

    Gets the vision distance of the actor.

sight( Float max_sight_range )

    Sets the vision distance of the actor.
+

sight( Float max_sight_range )
+

    Sets the vision distance of the actor.
+ +

silent( Integer silent )
+

    set to 0 to prevent this guy from saying stuff besides pain and death sounds.
    +
+

silent

    gets whether or not this guy is allowed to say stuff besides pain and death sounds
@@ -681,9 +685,8 @@ default channel, CHAN_BODY.
    set to 0 to prevent this guy from saying stuff besides pain and death sounds.
-

silent( Integer silent )
-

    set to 0 to prevent this guy from saying stuff besides pain and death sounds.
    -
+

sound_awareness( Float awareness_percent )
+

    sets the awareness of sounds in 0-100 percent chance of hearing a sound withinhalf of the sound's radius' fades to zero outside sound's radius

sound_awareness

    gets the awareness of sounds in 0-100 percent chance of hearing a sound withinhalf of the sound's radius' fades to zero outside sound's radius
@@ -691,9 +694,6 @@ default channel, CHAN_BODY.

sound_awareness( Float awareness_percent )

    sets the awareness of sounds in 0-100 percent chance of hearing a sound withinhalf of the sound's radius' fades to zero outside sound's radius
-

sound_awareness( Float awareness_percent )
-

    sets the awareness of sounds in 0-100 percent chance of hearing a sound withinhalf of the sound's radius' fades to zero outside sound's radius
-

stopped

    sent when entity has stopped bouncing for MOVETYPE_TOSS.
@@ -736,23 +736,20 @@ default channel, CHAN_BODY.

turret( String turret )

    Sets the turret of the actor.
-

turret
-

    Gets the turret of the actor.
-

turret( String turret )

    Sets the turret of the actor.
-

type_attack( String value )
-

    Sets the attack type of the actor.
- -

type_attack( String value )
-

    Sets the attack type of the actor.
+

turret
+

    Gets the turret of the actor.

type_attack

    Gets the attack type of the actor.
-

type_disguise( String value )
-

    Sets the disguise type of the actor.
+

type_attack( String value )
+

    Sets the attack type of the actor.
+ +

type_attack( String value )
+

    Sets the attack type of the actor.

type_disguise

    Gets the disguise type of the actor.
@@ -760,6 +757,9 @@ default channel, CHAN_BODY.

type_disguise( String value )

    Sets the disguise type of the actor.
+

type_disguise( String value )
+

    Sets the disguise type of the actor.
+

type_grenade( String value )

    Sets the grenade type of the actor.
@@ -769,15 +769,15 @@ default channel, CHAN_BODY.

type_grenade

    Gets the grenade type of the actor.
-

type_idle( String value )
-

    Sets the idle type of the actor.
-

type_idle

    Gets the idle type of the actor.

type_idle( String value )

    Sets the idle type of the actor.
+

type_idle( String value )
+

    Sets the idle type of the actor.
+

unholster( Integer holster )

    If non-zero, affects offhand. Unholster weapon
@@ -787,19 +787,19 @@ default channel, CHAN_BODY.

use( String name, Integer weapon_hand )

    Use the specified weapon or item in the hand choosen (optional).
+

voicetype
+

    Set voicetype to magic letter postfix
+ +

voicetype
+

    Set voicetype to magic letter postfix
+

voicetype

    Gets the voice type
-

voicetype
-

    Set voicetype to magic letter postfix
- -

voicetype
-

    Set voicetype to magic letter postfix
- -

waittrigger( Boolean bool )
+

waittrigger

    If true, patrol guys and running men wait until triggered to move
-

waittrigger
+

waittrigger( Boolean bool )

    If true, patrol guys and running men wait until triggered to move

waittrigger( Boolean bool )
@@ -839,30 +839,30 @@ default channel, CHAN_BODY.

accuracy

    Set percent to hit
-

alarmnode
-

    Gets the name of the alarm node for the actor (must have type set to alarm for effect)
-

alarmnode( String value )

    Sets the name of the alarm node for the actor (must have type set to alarm for effect)
+

alarmnode
+

    Gets the name of the alarm node for the actor (must have type set to alarm for effect)
+

ammo_grenade

    Returns how many grenades an AI has

ammo_grenade( Integer grenade_count )

    Gives the AI some grenades
-

balconyheight( Float height )
-

    minimum height a balcony guy must fall to do special balcony death
-

balconyheight

    minimum height a balcony guy must fall to do special balcony death
-

disguise_level
-

    Gets the disguise level of the actor. May be 1 or 2
+

balconyheight( Float height )
+

    minimum height a balcony guy must fall to do special balcony death

disguise_level( Integer value )

    Sets the disguise level of the actor. May be 1 or 2
+

disguise_level
+

    Gets the disguise level of the actor. May be 1 or 2
+

disguise_period( Float period_in_seconds )

    Sets the time between the end of one disguise behavior and start of the next
@@ -918,29 +918,29 @@ default channel, CHAN_BODY.
    Get if the sentient is forced to drop health no matter what level.nodrophealth is.

forcedropweapon
-

    Get if the sentient is forced to drop health no matter what level.nodrophealth is.
+
    Force the sentient to drop weapons no matter what level.nodropweapon is.

forcedropweapon
-

    Force the sentient to drop health no matter what level.nodrophealth is.
- -

fov( Float angle )
-

    The fov angle of the actor
+
    Get if the sentient is forced to drop health no matter what level.nodrophealth is.

fov

    The fov angle of the actor
-

gren_awareness
-

    gets the awareness of grenades in 0-100 percent chance of responding to a grenadewhen the AI sees it (applied once every 0.4 seconds)
+

fov( Float angle )
+

    The fov angle of the actor

gren_awareness( Float awareness_percent )

    sets the awareness of grenades in 0-100 percent chance of responding to a grenadewhen the AI sees it (applied once every 0.4 seconds)
-

gun
-

    gets the gun to being used
+

gren_awareness
+

    gets the awareness of grenades in 0-100 percent chance of responding to a grenadewhen the AI sees it (applied once every 0.4 seconds)

gun( String s )

    specifies the gun to use
+

gun
+

    gets the gun to being used
+

health( Integer newHealth )

    set the health of the entity to newHealth
@@ -965,24 +965,24 @@ default channel, CHAN_BODY.

leash

    Gets the maximum distance the AI will wander from its leash home
-

maxdist
-

    Gets the maximum distance the AI tries to keep between itself and the player
-

maxdist( Float distance )

    Sets the maximum distance the AI tries to allow between itself and the player
-

mindist
-

    Gets the minimum distance the AI tries to keep between itself and the player
+

maxdist
+

    Gets the maximum distance the AI tries to keep between itself and the player

mindist( Float distance )

    Sets the minimum distance the AI tries to keep between itself and the player
-

model
-

    get the modelName.
+

mindist
+

    Gets the minimum distance the AI tries to keep between itself and the player

model( Entity modelName )

    set the model to modelName.
+

model
+

    get the modelName.
+

nosurprise

    gets whether or not this guy is allowed to play a surprised animation when first encountering an enemy.
@@ -991,48 +991,48 @@ default channel, CHAN_BODY.
    set to 0 to allow this guy to play a surprised animation when first encountering an enemy.
-

noticescale( Float multiplier )
-

    Set the max multiplier in time to notice an enemy (default 100, half as big notices twice as fast)
-

noticescale

    Get the max multiplier in time to notice an enemy (default 100, half as big notices twice as fast)
-

patrolpath
-

    Gets the name of the patrol path for the actor (must have type set to patrol for effect)
+

noticescale( Float multiplier )
+

    Set the max multiplier in time to notice an enemy (default 100, half as big notices twice as fast)

patrolpath( String value )

    Sets the name of the patrol path for the actor (must have type set to patrol for effect)
-

sight( Float max_sight_range )
-

    Sets the vision distance of the actor.
+

patrolpath
+

    Gets the name of the patrol path for the actor (must have type set to patrol for effect)

sight

    Gets the vision distance of the actor.
-

sound_awareness
-

    gets the awareness of sounds in 0-100 percent chance of hearing a sound withinhalf of the sound's radius' fades to zero outside sound's radius
+

sight( Float max_sight_range )
+

    Sets the vision distance of the actor.

sound_awareness( Float awareness_percent )

    sets the awareness of sounds in 0-100 percent chance of hearing a sound withinhalf of the sound's radius' fades to zero outside sound's radius
+

sound_awareness
+

    gets the awareness of sounds in 0-100 percent chance of hearing a sound withinhalf of the sound's radius' fades to zero outside sound's radius
+

target

    entity's target

target( String targetname_to_target )

    target another entity with targetname_to_target.
-

turret
-

    Gets the turret of the actor.
-

turret( String turret )

    Sets the turret of the actor.
-

type_attack( String value )
-

    Sets the attack type of the actor.
+

turret
+

    Gets the turret of the actor.

type_attack

    Gets the attack type of the actor.
+

type_attack( String value )
+

    Sets the attack type of the actor.
+

type_disguise

    Gets the disguise type of the actor.
@@ -1052,10 +1052,10 @@ default channel, CHAN_BODY.
    Sets the idle type of the actor.

voicetype
-

    Gets the voice type
+
    Set voicetype to magic letter postfix

voicetype
-

    Set voicetype to magic letter postfix
+
    Gets the voice type

waittrigger

    If true, patrol guys and running men wait until triggered to move
@@ -1076,6 +1076,9 @@ default channel, CHAN_BODY.

AmmoEntity -> Item -> Trigger -> Animate -> Entity -> SimpleEntity -> Listener -> Class

+ +

ammoentity_postspawn
+

    Ammo Entity Post Spawn

Animate (animate) -> Entity -> SimpleEntity -> Listener -> Class

@@ -1134,18 +1137,18 @@ speed - how fast the effect should travel, in other words, how long before the e

max_dist( Float max_dist )

    Set the max distance for this node to be attracted, -1 for unlimited distance.
-

priority
-

    Get the node priority
-

priority( Integer priority )

    Set the node priority
-

respawn_time
-

    Get the how much time will this node re-attract already attracted AIs
+

priority
+

    Get the node priority

respawn_time( Float respawn_time )

    Set the how much time will this node re-attract already attracted AIs. The minimum required value is 1, otherwise AI will get stuck.
+

respawn_time
+

    Get the how much time will this node re-attract already attracted AIs
+

setuse( Boolean use )

    Set if AI should use or not
@@ -1155,11 +1158,11 @@ speed - how fast the effect should travel, in other words, how long before the e

stay_time( Float stay_time )

    Set the maximum stay time AI will stay on this node
-

team
-

    Get the attractive node team. 'none' for no team.
-

team( String team )

    Set the attractive node team. 'none' for no team.
+ +

team
+

    Get the attractive node team. 'none' for no team.

BarrelObject (func_barrel) -> Entity -> SimpleEntity -> Listener -> Class

@@ -1864,14 +1867,14 @@ offset - vector offset for the model from the specified tag
    used to ban certain contact when in parentmode
-

classname
-

    The entity's classname
-

classname( String nameOfClass )

    Determines what class to use for this entity,
    this is pre-processed from the BSP at the start
    of the level.
+

classname
+

    The entity's classname
+

claypidgeon

    turn the entity into a non-solid shootable thing
@@ -1998,9 +2001,6 @@ god - makes the entity invincible

gettagposition( String tag_name )

    Gets the world position of the tag
-

getzone
-

    Gets the current entity zone. NIL if the entity is not in a zone.
-

ghost

    make non-solid but still send to client regardless of hide status.
@@ -2048,9 +2048,6 @@ entity's current health, it will be killed or destroyed.

isinside( Entity ent )

    returns 1 if the entity is inside,0 if not
-

isinzone( Entity zone )
-

    Returns 1 if the entity is in the specified zone. 0 otherwise
-

istouching( Entity ent )

    returns 1 if the entities are touching,0 if not
@@ -2125,21 +2122,21 @@ which is attached to the current entity.

max_health( Integer newHealth )

    sets max_health without changing health
-

max_health( Integer newHealth )
-

    sets max_health without changing health
-

max_health

    gets the entity's max health
+

max_health( Integer newHealth )
+

    sets max_health without changing health
+ +

model( Entity modelName )
+

    set the model to modelName.
+ +

model( Entity modelName )
+

    set the model to modelName.
+

model

    get the modelName.
-

model( Entity modelName )
-

    set the model to modelName.
- -

model( Entity modelName )
-

    set the model to modelName.
-

movementstealth( Float scale )

    Sets the current movement stealth scalar for the sentient
@@ -2211,12 +2208,12 @@ lightstyledynamiclight - the dynamic light uses a light style, use the

revive( Float health )

    sets the health,even if dead
-

rotatedbbox( Integer on_off )
-

    Sets the entity's bbox to rotate with it.
-

rotatedbbox

    Gets te entity's bbox to rotate with it.
+

rotatedbbox( Integer on_off )
+

    Sets the entity's bbox to rotate with it.
+

safesolid

    make solid but first make sure no one is in my bounds that is thinking.
@@ -2351,20 +2348,17 @@ broadcast - always send this entity to the client

usebbox

    do not perform perfect collision,use bounding box instead.
-

velocity
-

    gets the velocity for this entity.
-

velocity( Vector velocity )

    sets the velocity for this entity.
+

velocity
+

    gets the velocity for this entity.
+

volumedamage( Float damage )

    does damage to any entity within this's volume

yaw

    entity's yaw
- -

zone
-

    Get the current entity zone. NIL if the entity is not in a zone.

Event -> Class

@@ -2517,6 +2511,31 @@ Location values:

FencePost (func_fencepost) -> Entity -> SimpleEntity -> Listener -> Class

+ +

killed( Entity attacker, Integer damage, Entity inflictor, Vector position, Vector direction, Vector normal, Integer knockback, Integer damageflags, Integer meansofdeath, Integer location )
+

    event which is sent to an entity once it as been killed
    +
    +Location values:
    +-1 General
    +0 Pelvis
    +1 Lower Torso
    +2 Mid Torso
    +3 Upper Torso
    +4 Neck
    +5 Head
    +6 RUpperArm
    +7 RForearm
    +8 RHand
    +9 LUpperArm
    +10 LForearm
    +11 LHand
    +12 RThigh
    +13 RCalf
    +14 RFoot
    +15 LThigh
    +16 LCalf
    +17 LFoot
    +

FixedTurret -> VehicleTank -> DrivableVehicle -> Vehicle -> VehicleBase -> Animate -> Entity -> SimpleEntity -> Listener -> Class

@@ -2676,6 +2695,12 @@ direction if newAngle is[ 0 - 359 ] or - 1 or - 2

Game -> Listener -> Class

+ +

detail
+

    game.detail
+ +

skill
+

    game.skill

Gib (gib) -> Mover -> Trigger -> Animate -> Entity -> SimpleEntity -> Listener -> Class

@@ -2776,24 +2801,24 @@ direction if newAngle is[ 0 - 359 ] or - 1 or - 2

Hud -> Listener -> Class

-

alignx( String align )
-

    Sets the horizontal alignment for the HUD. Specified by 'left', 'center', or 'right'
-

alignx

    Gets the horizontal alignment for the HUD. Specified by 'left', 'center', or 'right'
+

alignx( String align )
+

    Sets the horizontal alignment for the HUD. Specified by 'left', 'center', or 'right'
+

aligny( String align )

    Sets the vertical alignment for the HUD. Specified by 'top', 'center', or 'bottom'

aligny

    Gets the vertical alignment for the HUD
-

alpha( Float alpha )
-

    Sets the HUD alpha
-

alpha

    Gets the HUD alpha
+

alpha( Float alpha )
+

    Sets the HUD alpha
+

color

    Gets the HUD colors
@@ -2855,17 +2880,17 @@ Note : you will need to call in HUD functions again as it won't refresh to the p

setvirtualsize( Boolean virtual )

    Sets if the HUD should use virtual screen resolution for positioning and size
-

x( Integer x )
-

    Sets the HUD horizontal position
-

x

    Gets the HUD horizontal position
-

y
-

    Gets the HUD vertical position
+

x( Integer x )
+

    Sets the HUD horizontal position

y( Integer y )

    Sets the HUD vertical position
+ +

y
+

    Gets the HUD vertical position

InfoLandmark (info_landmark) -> Listener -> Class

@@ -2882,7 +2907,7 @@ Note : you will need to call in HUD functions again as it won't refresh to the p
-

InfoNull (info_null) -> Entity -> SimpleEntity -> Listener -> Class

+

InfoNull (info_null) -> Listener -> Class

@@ -3028,51 +3053,60 @@ direction if newAngle is[ 0 - 359 ] or - 1 or - 2

Level -> Listener -> Class

-

alarm( Integer alarm_status )
+

alarm

    zero = global level alarm off,non-zero = alarm on
-

alarm
+

alarm( Integer alarm_status )

    zero = global level alarm off,non-zero = alarm on

badplace( String name, Vector origin, Float radius, [ String [team] ], [ Float [duration] ] )

    Enables a 'bad place' for AI of team 'american', 'german', or (default) 'both' to avoid, and optionally gives it a duration

bombs_planted( Integer num )
-

    the number of bombs that are set
+
    Sets the number of bombs that are set

bombs_planted( Integer num )
-

    Sets the number of bombs that are set
+
    the number of bombs that are set

bombs_planted

    Gets the number of bombs that are set
-

clockside
-

    Gets which side the clock is on... 'axis' or 'allies' win when time is up
+

clockside( String axis_allies_draw_kills )
+

    Sets which side the clock is on... 'axis' or 'allies' win when time is up, 'kills' gives the win to the team with more live members,'draw' no one wins

clockside( String axis_or_allies )

    Sets which side the clock is on... 'axis' or 'allies' win when time is up
-

clockside( String axis_allies_draw_kills )
-

    Sets which side the clock is on... 'axis' or 'allies' win when time is up, 'kills' gives the win to the team with more live members,'draw' no one wins
- -

dmrespawning( Integer allow_respawn )
-

    set to 1 to turn on wave-based DM, to 0 to disable respawns within a round
+

clockside
+

    Gets which side the clock is on... 'axis' or 'allies' win when time is up

dmrespawning

    returns 1 if wave-based DM, 0 if respawns are disabled within a round

dmrespawning( Integer allow_respawn )
-

    set to 1 to turn on wave-based DM,to 0 to disable respawns within a round
+
    set to 1 to turn on wave-based DM, to 0 to disable respawns within a round
-

dmroundlimit( Integer roundlimit )
-

    sets the default roundlimit,in minutes; can be overridden by 'roundlimit' cvar
+

dmrespawning( Integer allow_respawn )
+

    set to 1 to turn on wave-based DM,to 0 to disable respawns within a round

dmroundlimit( Integer roundlimit )

    sets the default roundlimit, in minutes; can be overridden by 'roundlimit' cvar
+

dmroundlimit( Integer roundlimit )
+

    sets the default roundlimit,in minutes; can be overridden by 'roundlimit' cvar
+

dmroundlimit

    gets the actual roundlimit, in minutes; may be 'roundlimit' cvar or the default round limit
+

force_team_objective
+

    Return 1 if each team has a separate objective location
+ +

force_team_objective( Integer force )
+

    Whether or not to force using a separate objective location for each team.
    +1 (forced on TOW/Liberation match): different location for each team
    +0 (default): teams use same location on non-TOW/non-Liberation match
    +
+

found_secrets

    count of found secrets
@@ -3103,12 +3137,12 @@ direction if newAngle is[ 0 - 359 ] or - 1 or - 2

planting_team( String axis_allies_draw_kills )

    which is planting the bomb,'axis' or 'allies'
-

planting_team
-

    Gets which is planting the bomb,'axis' or 'allies'
-

planting_team( String axis_or_allies )

    Sets which is planting the bomb,'axis' or 'allies'
+

planting_team
+

    Gets which is planting the bomb,'axis' or 'allies'
+

rain_density

    Sets the rain density
@@ -3172,21 +3206,21 @@ direction if newAngle is[ 0 - 359 ] or - 1 or - 2

roundstarted

    non-zero if round has started
+

targets_destroyed( Integer num )
+

    Sets the number of bomb targets that have been destroyed
+

targets_destroyed

    Gets the number of bomb targets that have been destroyed
-

targets_destroyed( Integer num )
-

    Sets the number of bomb targets that have been destroyed
-

targets_destroyed( Integer num )

    the number of bomb targets that have been destroyed
-

targets_to_destroy
-

    Gets the number of bomb targets that must be destroyed
-

targets_to_destroy( Integer num )

    Sets the number of bomb targets that must be destroyed
+

targets_to_destroy
+

    Gets the number of bomb targets that must be destroyed
+

targets_to_destroy( Integer num )

    the number of bomb targets that must be destroyed
@@ -3390,6 +3424,15 @@ direction if newAngle is[ 0 - 359 ] or - 1 or - 2

Parm -> Listener -> Class

+

motionfail
+

    motionfail
+ +

movedone
+

    movedone
+ +

movefail
+

    movefail
+

other

    other
@@ -3398,6 +3441,12 @@ direction if newAngle is[ 0 - 359 ] or - 1 or - 2

previousthread

    previousthread
+ +

sayfail
+

    sayfail
+ +

upperfail
+

    upperfail

PathNode (info_pathnode) -> SimpleEntity -> Listener -> Class

@@ -3502,11 +3551,11 @@ Location values:
17 LFoot
-

damage_multiplier
-

damage_multiplier( Float damage_multiplier )

    Sets the current damage multiplier
+

damage_multiplier
+

dead

    Called when the player is dead.
@@ -3604,7 +3653,7 @@ Location values:
    Gives the player the specified thing (weapon, ammo, item, etc.) and optionally the amount.

giveweapon( String weapon_name )
-

    Gives player all weapons.
+
    Gives the player the specified weapon.

gotkill( Entity victim, Integer damage, Entity inflictor, Integer meansofdeath, Boolean gib )

    event sent to attacker when an entity dies
@@ -3612,10 +3661,10 @@ Location values:

gvo

    Retrieves the server's vote options file
-

has_disguise
+

has_disguise( Integer is_disguised )

    zero = does not have a disguise,non - zero = has a disguise
-

has_disguise( Integer is_disguised )
+

has_disguise

    zero = does not have a disguise,non - zero = has a disguise

hideent( Entity entity )
@@ -3798,10 +3847,10 @@ can specify 'stand', 'duck' or 'prone'.

    returns 1 if this player is holding the primary fire, or 0 if not

ready
-

    returns 1 if this player is ready,0 otherwise
+
    makes this player ready for the round to start

ready
-

    makes this player ready for the round to start
+
    returns 1 if this player is ready,0 otherwise

reload

    Reloads the player's weapon
@@ -4544,6 +4593,9 @@ Default=0:

ScriptAimedStrafingGunfire (script_aimedstrafinggunfire) -> ScriptSimpleStrafingGunfire -> ScriptSlave -> Mover -> Trigger -> Animate -> Entity -> SimpleEntity -> Listener -> Class

+

aimtarget
+

    Set the aim target.
+

fire

    Fire.
@@ -4748,6 +4800,18 @@ Location values:

dmg( Integer damage )

    Set the damage.
+

doActivate( Entity activatingEntity )
+

    General trigger event for all entities
+ +

doBlocked( Entity obstacle )
+

    sent to entity when blocked.
+ +

doTouch( Entity touchingEntity )
+

    sent to entity when touched.
+ +

doUse( Entity activatingEntity )
+

    sent to entity when it is used by another entity
+

endpath

    Stop following the path
@@ -4759,7 +4823,7 @@ Location values:

followpath( Entity path, [ String arg1 ], [ String arg2 ], [ String arg3 ], [ String arg4 ], [ String arg5 ], [ String arg6 ] )

    Makes the script slave follow the specified path. The allowable arguments are ignoreangles,
    -normalangles, loop, and a number specifying the start time.
+ignorevelocity, normalangles, loop, and a number specifying the start time.

jumpto( String vector_or_entity )

    Jump to specified vector or entity.
@@ -5683,15 +5747,15 @@ Location values:

forcedrophealth

    Get if the sentient is forced to drop health no matter what level.nodrophealth is.
+

forcedropweapon
+

    Force the sentient to drop health no matter what level.nodrophealth is.
+ +

forcedropweapon
+

    Force the sentient to drop health no matter what level.nodrophealth is.
+

forcedropweapon

    Get if the sentient is forced to drop health no matter what level.nodrophealth is.
-

forcedropweapon
-

    Force the sentient to drop weapons no matter what level.nodropweapon is.
- -

forcedropweapon
-

    Force the sentient to drop weapons no matter what level.nodropweapon is.
-

forcelandminemeasure

    Force a remeasurement to all landmines
@@ -5829,18 +5893,15 @@ Location values:
Sets the yaw of the entity or an up and down
direction if newAngle is[ 0 - 359 ] or - 1 or - 2 -

angle( Float newAngle )
-

    set the angles of the entity using just one value.
    -Sets the yaw of the entity or an up and down
    -direction if newAngle is[ 0 - 359 ] or - 1 or - 2
-

angle

    get the angles of the entity using just one value.
    Gets the yaw of the entity or an up and down
    direction if newAngle is[ 0 - 359 ] or - 1 or - 2
-

angles( Vector newAngles<0.00...360.00><0.00...360.00><0.00...360.00> )
-

    set the angles of the entity to newAngles.
+

angle( Float newAngle )
+

    set the angles of the entity using just one value.
    +Sets the yaw of the entity or an up and down
    +direction if newAngle is[ 0 - 359 ] or - 1 or - 2

angles( Vector newAngles<0.00...360.00><0.00...360.00><0.00...360.00> )

    set the angles of the entity to newAngles.
@@ -5848,6 +5909,9 @@ direction if newAngle is[ 0 - 359 ] or - 1 or - 2

angles

    get the angles of the entity.
+

angles( Vector newAngles<0.00...360.00><0.00...360.00><0.00...360.00> )
+

    set the angles of the entity to newAngles.
+

centroid

    entity's centroid
@@ -5869,24 +5933,24 @@ direction if newAngle is[ 0 - 359 ] or - 1 or - 2

rightvector

    get the right vector of angles
+

target( String targetname_to_target )
+

    target another entity with targetname_to_target.
+

target

    entity's target

target( String targetname_to_target )

    target another entity with targetname_to_target.
-

target( String targetname_to_target )
-

    target another entity with targetname_to_target.
- -

targetname( String targetName )
-

    set the targetname of the entity to targetName.
-

targetname( String targetName )

    set the targetname of the entity to targetName.

targetname

    entity's targetname
+

targetname( String targetName )
+

    set the targetname of the entity to targetName.
+

upvector

    get the up vector of angles
@@ -6120,6 +6184,10 @@ direction if newAngle is[ 0 - 359 ] or - 1 or - 2
    Sets the entity to watch at this node.
+

TargetList -> Class

+
+
+

Teleporter (trigger_teleport) -> Trigger -> Animate -> Entity -> SimpleEntity -> Listener -> Class

@@ -6234,7 +6302,7 @@ Location values:

stickybombwet

-

ThrowObject (func_throwobject) -> Object -> Animate -> Entity -> SimpleEntity -> Listener -> Class

+

ThrowObject (func_throwobject) -> Animate -> Entity -> SimpleEntity -> Listener -> Class

doTouch( Entity touchingEntity )
@@ -6289,12 +6357,12 @@ Location values:

AxisObjNum( Integer AxisObjNum )

    Sets the objective number for the axis team
-

ControlledBy( Integer ControlledBy )
-

    Sets the team controlling the objective
-

ControlledBy

    Objective controller
+

ControlledBy( Integer ControlledBy )
+

    Sets the team controlling the objective
+

initialize

    Initialize object
@@ -6454,30 +6522,8 @@ If facet is 2 than trigger is East/West oriented. If facet is 3 than trigger is

activatetrigger( Entity triggering_entity )

    Activates all of the targets for this trigger.
-

damage( Entity attacker, Integer damage, Entity inflictor, Vector position, Vector direction, Vector normal, Integer knockback, Integer damageflags, Integer meansofdeath, Integer location )
-

    general damage event used by all entities
    -
    -Location values:
    --1 General
    -0 Pelvis
    -1 Lower Torso
    -2 Mid Torso
    -3 Upper Torso
    -4 Neck
    -5 Head
    -6 RUpperArm
    -7 RForearm
    -8 RHand
    -9 LUpperArm
    -10 LForearm
    -11 LHand
    -12 RThigh
    -13 RCalf
    -14 RFoot
    -15 LThigh
    -16 LCalf
    -17 LFoot
    -
+

damage( Integer damage )
+

    Sets the amount of damage to do.

TriggerEntity (trigger_entity) -> Trigger -> Animate -> Entity -> SimpleEntity -> Listener -> Class

@@ -6661,6 +6707,10 @@ as a multi-faceted edge trigger.
    Send event to owner of trigger.
+

TriggerSidedUse (trigger_sideduse) -> TriggerUse -> Trigger -> Animate -> Entity -> SimpleEntity -> Listener -> Class

+
+
+

TriggerSpeaker (sound_speaker) -> TriggerPlaySound -> Trigger -> Animate -> Entity -> SimpleEntity -> Listener -> Class

@@ -6767,14 +6817,14 @@ as a multi-faceted edge trigger.

suppressWidth( Float radius )

    Sets the horizontal radius of suppression fire
-

targettype( String value )
-

    Sets the target type to be none any, or player
+

targettype
+

    Gets the target type

targettype( String value )

    Sets the target type to be none, any, or player
-

targettype
-

    Gets the target type
+

targettype( String value )
+

    Sets the target type to be none any, or player

turnSpeed( Float speed )

    Sets the turret's turn speed
@@ -6947,10 +6997,10 @@ Location values:

canuse( Entity entity )

    Returns 1 if passed entity can 'use' this vehicle.
-

collisionent( Entity entity )
+

collisionent

    Gets the Collision Entity
-

collisionent
+

collisionent( Entity entity )

    Gets the Collision Entity

damage( Entity attacker, Integer damage, Entity inflictor, Vector position, Vector direction, Vector normal, Integer knockback, Integer damageflags, Integer meansofdeath, Integer location )
@@ -7233,6 +7283,9 @@ Location values:
16 LCalf
17 LFoot
+ +

owner
+

    owner

VehicleHalfTrack (VehicleHalfTrack) -> DrivableVehicle -> Vehicle -> VehicleBase -> Animate -> Entity -> SimpleEntity -> Listener -> Class

@@ -7348,12 +7401,12 @@ Location values:

aimtolerance( Vector caps )

    Sets a tolerance for the angles.
-

collisionent( Entity entity )
-

    Sets the Collision Entity
-

collisionent

    Gets the Collision Entity
+

collisionent( Entity entity )
+

    Sets the Collision Entity
+

damage( Entity attacker, Integer damage, Entity inflictor, Vector position, Vector direction, Vector normal, Integer knockback, Integer damageflags, Integer meansofdeath, Integer location )

    general damage event used by all entities

    @@ -8114,12 +8167,12 @@ Location values:

    farclipoverride( Float farclipoverride )

      Override the min config default for the far clip distance
    -

    farplane
    -

      Get the distance of the far clipping plane
    -

    farplane( Float farplaneDistance )

      Set the distance of the far clipping plane
    +

    farplane
    +

      Get the distance of the far clipping plane
    +

    farplane( Float farplaneDistance )

      Set the distance of the far clipping plane
    @@ -8129,21 +8182,21 @@ Location values:

    farplane_bias( Float farplaneDistanceBias )

      Set the distance bias of the far clipping plane
    -

    farplane_bias
    -

      Get the distance bias of the far clipping plane
    -

    farplane_bias( Float farplaneDistanceBias )

      Set the distance bias of the far clipping plane
    +

    farplane_bias
    +

      Get the distance bias of the far clipping plane
    + +

    farplane_color( Vector farplaneColor )
    +

      Set the color of the far clipping plane fog
    + +

    farplane_color( Vector farplaneColor )
    +

      Set the color of the far clipping plane fog
    +

    farplane_color

      Get the color of the far clipping plane fog
    -

    farplane_color( Vector farplaneColor )
    -

      Set the color of the far clipping plane fog
    - -

    farplane_color( Vector farplaneColor )
    -

      Set the color of the far clipping plane fog
    -

    farplane_cull( Integer farplaneCull )

      Whether or not the far clipping plane should cull things out of the world
      0 - no cull
      @@ -8208,7 +8261,7 @@ Location values:
        Set the watercolor screen blend

      -189 Game Module Classes.
      2154 Game Module Events. +191 Game Module Classes.
      2169 Game Module Events.

      diff --git a/docs/features_implementation.md b/docs/features_implementation.md deleted file mode 100644 index f013c171..00000000 --- a/docs/features_implementation.md +++ /dev/null @@ -1,25 +0,0 @@ -# Implementation - -## Server - -The server version can be built successfully, but some features are not functional. For example, the Actor system is almost fully implemented, but it is not yet stable. This means that Actor may not work as expected and could cause crashes. - -Overall, the server and the fgame components are almost fully implemented, but they may not be completely stable. There could be some minor bugs (and rare crashes), but the game should be playable. - -## Client - -The client version of OpenMoHAA has undergone partial implementation, with the cgame module being nearly completed. Credits to the SDK of **Heavy Metal: F.A.K.K. 2** both the cgame and fgame modules. - -The current operational status for each component is as follow: - -| Component | Full | Almost | Half | Early | Bad | Not working | Comment | -|-------------------------|------|--------|------|-------|-----|-------------|-------------------------------------------------------------------| -| Audio | | | | | x | | Very basic implementation from Quake III | -| CG Module | | x | | | | | Missing FX, Marks and decals | -| Client | x | | | | | | | -| Collision | x | | | | | | | -| Model/TIKI/Skeletor | x | | | | | | | -| Renderer | | x | | | | | Missing ghost, marks, sphere lights, sky portal, sun flare, swipe | -| Server | | x | | | | | Probably a few bugs remaining | -| Server module (fgame) | | x | | | | | Actor, and few gameplay bugs | -| UI | | x | | | | | A few bugs to fix | diff --git a/docs/getting_started_installation.md b/docs/getting_started_installation.md index 129353eb..d1edfa69 100644 --- a/docs/getting_started_installation.md +++ b/docs/getting_started_installation.md @@ -1,25 +1,128 @@ # Installation -Ensure that you download the binaries compatible with your platform in the release section. +- Windows users can check this [Quick install guide](getting_started_installation_windows.md). +- Linux users may want to check if an OpenMoHAA package is available with the distribution's package manager. ## Requirements -- A valid MOH:AA installation -- On Windows, Microsoft Visual C++ 2015/2017/2019/2022 Redistributable from https://learn.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist?view=msvc-170 may be required. +- A MOH:AA installation. Common installations include: + - GOG copy (recommended). A fully patched MOH:AA War Chest copy can be acquired [here](https://www.gog.com/en/game/medal_of_honor_allied_assault_war_chest). + - For Linux/macOS, see [Extracting GOG Installer on Linux and macOS](#extracting-gog-setup-file-on-linux-and-macos). + - From a CD. Make sure to [patch your installed copy](#installing-official-patches) + - Demo. See [obtaining a demo version](#obtaining-a-demo-version) +- On Windows, Microsoft Visual C++ 2015/2017/2019/2022 Redistributable from https://learn.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist?view=msvc-170 is required. +- The game should be able to run on any modern hardware. See [System requirements](./getting_started_requirements.md) -## Client +## Installing official patches -a) extract archive to your MOHAA installation directory. +If the **MOH: Warchest** copy is installed, skip directly to the [OpenMoHAA installation](#downloadinginstalling) section. + +Otherwise, install the following patches: + +|Game |Patch to download and install +|---------------|------------------ +|Allied Assault |Depends on the installed language: [English](https://web.archive.org/web/20160229203048/http://largedownloads.ea.com/pub/patches/MOHAA_UKUS_ONLY_patch111v9safedisk.exe), [German](https://web.archive.org/web/20160229203013/http://largedownloads.ea.com/pub/patches/MOHAA_DE_ONLY_patch111v9safedisk.exe), [French](https://web.archive.org/web/20151201080806/http://largedownloads.ea.com/pub/patches/MOHAA_FR_ONLY_patch111v9safedisk.exe) [Italian](https://web.archive.org/web/20141205065317/http://largedownloads.ea.com/pub/patches/MOHAA_IT_ONLY_patch111v9safedisk.exe), [Spanish](https://web.archive.org/web/20151201080738/http://largedownloads.ea.com/pub/patches/MOHAA_ES_ONLY_patch111v9safedisk.exe), or [Dutch](https://web.archive.org/web/20151201080902/http://largedownloads.ea.com/pub/patches/MOHAA_NL_ONLY_patch111v9safedisk.exe) +|Spearhead |[2.0 to 2.11](https://web.archive.org/web/20170130184731/ftp://ftp.ea.com/pub/ea/patches/mohaa_spearhead/mohaas_patch_20_to_211.exe), followed by [2.11 to 2.15](https://web.archive.org/web/20170130184725/ftp://ftp.ea.com/pub/ea/patches/mohaa_spearhead/MOHAAS_Patch_211_to_215.exe) +|Breakthrough |[2.40b](https://web.archive.org/web/20160301122255/http://largedownloads.ea.com/pub/patches/medal_of_honor_allied_assault_breakthrough_patch_2_40.exe) + +These patches are required to connect to multiplayer servers and ensure a smooth, bug-free single-player experience. + +## Downloading/installing OpenMoHAA + +Ensure that you download the binaries compatible with your platform in the [releases](https://github.com/openmoh/openmohaa/releases/latest) section. + +### Which release should be downloaded? + +It depends on the OS that is installed on your device: + +|OS |Kind of hardware (CPU, platform...) |Archive +|---------|-------------------------------------------|----------------------- +|Windows |AMD/Intel |`*-windows-x64.zip` +|Windows |Qualcomm/Snapdragon (ARM-based) |`*-windows-arm64.zip` +|macOS |Apple Silicon (ARM) |`*-macos-arm64.zip` +|macOS |Intel |`*-macos-x86_64.zip` +|Linux |AMD/Intel |`*-linux-amd64` +|Linux |Raspberry Pi 4 or 5 |`*-linux-arm64` + +Once the correct archive was downloaded: + +a) Extract the archive1 to your MOHAA installation directory. -or- -b) extract archive somewhere on your hard drive, create a shortcut to openmohaa (or omohaaded), and set the start directory on the shortcut to your MOHAA installation directory. +b) Extract the archive1 somewhere on your hard drive, create a shortcut to each of the **launch_openmohaa_\*** executables (or omohaaded.exe), and set the shortcut's 'Start in' directory to your MOHAA installation directory. -## Server +Once you're ready, start one of the three launchers based on whether you want to play the base game, Spearhead, or Breakthrough, and then you can start playing. -Extract the archive to your MOHAA server installation directory. Then proceed like you would do with mohaa server: +---- -- `.\omohaaded.exe +exec server.cfg` on Windows -- `./omohaaded +exec server.cfg` on Linux +**Notes:** -Only `omohaaded*` and `game*` binaries are required for the server version, other binaries can be omitted. +1. For servers, only the `omohaaded.*` and `game.*` binaries from the archive are required. + +## Appendix + +### Cleaning up the game installation directory + +If you want to clean up the mohaa installation directory by keeping only what is needed for OpenMoHAA, the following files/directories can be kept: +```cpp +[MOHAA] +├── [main] +| ├── [sound] +| ├── [video] +│   ├── Pak*.pk3 // all pak files +├── [mainta] +| ├── [sound] +| ├── [video] +│   ├── pak*.pk3 // all pak files +├── [maintt] +| ├── [sound] +| ├── [video] +│   ├── pak*.pk3 // all pak files +├── All files from the OpenMoHAA archive +``` + +### Extracting GOG setup file on Linux and macOS + +If your MOH:AA copy was acquired from GOG then this section will be relevant. + +The MOH:AA Warchest installer files on GOG are Windows binaries. To attain the game files, you can quickly extract them using [Innoextract](https://github.com/dscharrer/innoextract). + +- Install Innoextract using your preferred Package Manager (e.g. [Brew](https://brew.sh/)). + +- Once installed run the command `innoextract setup_medal_of_honor_2.0.0.21.exe`. The MoH:AA game files will be extracted into a folder called 'app'. + +Alternatively, you can use [WINE](https://www.winehq.org/) as well, but this process may take longer if you do not already have WINE installed and configured. + +### Obtaining a demo version + +Alternatively, free demo versions are available online. Here are the links to the demos: + +|Game |Type |Link | +|--------------------|-----------------------------------|--------------------------------------------------------------------------------------| +|MOH:AA | Single-player (0.05) |https://www.gamefront.com/games/medal-of-honor/file/single-player-demo | +|MOH:AA | Multiplayer1 (1.00) |https://www.gamefront.com/games/medal-of-honor/file/multiplayer-demo | +|MOH:AA Spearhead | Multiplayer2 (2.11) |https://www.gamefront.com/games/medal-of-honor/file/mohaa-spearhead-demo-eng | +|MOH:AA Breakthrough | Multiplayer2 (0.30) |https://www.gamefront.com/games/medal-of-honor/file/mohaa-breakthrough-demo | + +- MOH:AA singleplayer demo ships with the level: **Mission 3: Level 3**. +- MOH:AA multiplayer demo ships with the level: **Stalingrad**. **The Hunt** can be added with the [MP Demo addon](https://www.gamefront.com/games/medal-of-honor/file/mp-demo-add-on-the-hunt). +- MOH:AA Spearhead multiplayer demo ships with multiplayer maps: **Malta** and **Druckkammern**. +- MOH:AA Breakthrough multiplayer demo ships with multiplayer maps: **Anzio** and **Palermo**. + +-------- + +**Notes:** + +1. Can play on MOH:AA 1.00 servers only. +2. Only compatible with demo servers. These servers can be identified by having the letter `d` at the start of their version number (e.g: `(d2.11)`). + +--- + +## Ports and other systems + +OpenMoHAA is officially supported on Windows, Linux and macOS. Below is a list of unofficial open-source ports that required custom modifications to the OpenMoHAA source code to build and run: + +- https://github.com/Rinnegatamante/openmohaa + +To stay up to date with the latest features and fixes from the official repository, these ports depend on their respective maintainers to synchronize changes with the main OpenMoHAA codebase. diff --git a/docs/getting_started_installation_windows.md b/docs/getting_started_installation_windows.md new file mode 100644 index 00000000..a446adb8 --- /dev/null +++ b/docs/getting_started_installation_windows.md @@ -0,0 +1,38 @@ +# Quick installation + +This guide assumes you installed **Medal of Honor: Allied Assault Warchest** from GOG, but it also works with CD or other versions. + +You can get it from [GOG here](https://www.gog.com/en/game/medal_of_honor_allied_assault_war_chest). + +## 1. Download + +Grab the latest `openmohaa-*-windows-x64.zip` from the [releases page](https://github.com/openmoh/openmohaa/releases). + +## 2. Find your game folder + +1. Right-click your **Medal of Honor - Allied Assault** desktop shortcut → **Properties** +2. Then check the "**Start in**" field, that's your game folder. + +![Shortcut](screenshots/install_guide/windows_installation_shortcut.png) + +Alternatively, try one of these common locations: +- C:\GOG Games\Medal of Honor - Allied Assault War Chest +- C:\Program Files (x86)\EA Games\MOHAA +- C:\Program Files\Origin Games\Medal of Honor Allied Assault Warchest +- C:\Program Files\GOG Galaxy\Games\Medal of Honor - Allied Assault War Chest + +If not there, you'll need to search where you installed it. + +## 3. Install + +1. **Extract the .zip file** you downloaded into the game folder you found earlier. +2. **Create desktop shortcuts** for these 3 files: + * `launch_openmohaa_base.x86_64.exe` - *Allied Assault* + * `launch_openmohaa_spearhead.x86_64.exe` - *Spearhead* + * `launch_openmohaa_breakthrough.x86_64.exe` - *Breakthrough* + +To do that, **right-click each file**, then choose **Send to → Desktop (create shortcut)**. + +![Send To](screenshots/install_guide/windows_installation_sendto.png) + +Now you can launch any version of the game directly from your desktop using OpenMoHAA. diff --git a/docs/getting_started_requirements.md b/docs/getting_started_requirements.md new file mode 100644 index 00000000..ad76075f --- /dev/null +++ b/docs/getting_started_requirements.md @@ -0,0 +1,88 @@ +# System requirements + +This matches the hardware requirements (x86) of the original game. + +## Medal of Honor: Allied Assault + +1.2 GB of free disk space is required for the full game installation + binaries. + +### x86 (AMD and Intel) + +|Hardware |Minimum |Recommended +|---------------|----------------------------------------------------|--------------- +|CPU |450 MHz (Intel Pentium II), or 500 MHz (AMD Athlon) |700 MHz (Intel Pentium III or AMD Athlon) +|Memory |128MB |256MB +|GPU |16MB |32MB + +### ARM + +|Hardware |Minimum |Recommended +|---------------|----------------------------------------------------|--------------- +|CPU |600 MHz ARM Cortex-A8 |800 MHz ARM Cortex-A9 +|Memory |128MB |256MB +|GPU |16MB |32MB + +### PowerPC + +|Hardware |Minimum |Recommended +|---------------|----------------------------------------------------|--------------- +|CPU |G3 450 MHz |G4 1 GHz +|Memory |128MB |256MB +|GPU |16MB |32MB + +## Spearhead expansion + +1.0 GB of free disk space is required to install Spearhead on top of the base game. + +### x86 (AMD and Intel) + +|Hardware |Minimum |Recommended +|---------------|----------------------------------------------------|--------------- +|CPU |450 MHz (Intel Pentium II), or 500 MHz (AMD Athlon) |700 MHz (Intel Pentium III or AMD Athlon) +|Memory |128MB |256MB +|GPU |16MB |32MB + +### ARM + +|Hardware |Minimum |Recommended +|---------------|----------------------------------------------------|--------------- +|CPU |600 MHz ARM Cortex-A8 |800 MHz ARM Cortex-A9 +|Memory |128MB |256MB +|GPU |16MB |32MB + +### PowerPC + +|Hardware |Minimum |Recommended +|---------------|----------------------------------------------------|--------------- +|CPU |G3 500 MHz |G4 1 GHz +|Memory |256MB |256MB +|GPU |16MB |32MB + +## Breakthrough expansion + +800 MB of free disk space is required to install Breakthrough on top of the base game. + +### x86 (AMD and Intel) + +|Hardware |Minimum |Recommended +|---------------|-----------------------------------------------------|--------------- +|CPU |733 MHz (Intel Pentium III), or 700 MHz (AMD Athlon) |1 GHz (Intel Pentium III or AMD Athlon) +|Memory |128MB |256MB +|GPU |16MB |32MB + +### ARM + +|Hardware |Minimum |Recommended +|---------------|----------------------------------------------------|--------------- +|CPU |800 MHz ARM Cortex-A9 |1 GHz ARM Cortex-A15 +|Memory |128MB |256MB +|GPU |16MB |32MB + + +### PowerPC + +|Hardware |Minimum |Recommended +|---------------|----------------------------------------------------|--------------- +|CPU |G3 800 MHz |G4 1 GHz +|Memory |256MB |256MB +|GPU |16MB |32MB diff --git a/docs/getting_started_running.md b/docs/getting_started_running.md index 33c1a070..c89b3288 100644 --- a/docs/getting_started_running.md +++ b/docs/getting_started_running.md @@ -2,33 +2,63 @@ ## Game selection -**Medal of Honor: Allied Assault Spearhead** and **Medal of Honor: Allied Assault Breakthrough** are supported in OpenMoHAA using the `com_target_game` variable. To play an expansion, append the following command-line arguments to the executable: +**Medal of Honor: Allied Assault** is the default game, but expansions are also supported. -- `+set com_target_game 1` for Spearhead (mohaas/mohta) -- `+set com_target_game 2` for Breakthrough (mohaab/mohtt) +### From the launchers -On Windows, you can create a shortcut to OpenMoHAA with these command-line arguments. -The default value of `com_target_game` is 0 for the base game (main). +Base game and expansions can be started from one of the 3 launchers: -With `com_target_game`, OpenMoHAA will support the network protocol accordingly. +- `launch_openmohaa_base`, this starts OpenMoHAA in **Medal of Honor: Allied Assault** mode which is the base game +- `launch_openmohaa_spearhead`, this starts OpenMoHAA in **Medal of Honor: Allied Assault: Spearhead** mode +- `launch_openmohaa_breakthrough`, this starts OpenMoHAA in **Medal of Honor: Allied Assault: Breakthrough** mode + +### From command-line + +**Spearhead** and **Breakthrough** are supported in OpenMoHAA using the `com_target_game` variable. + +To change the target game, append the following command-line arguments to the `openmohaa` and `omohaaded` executable: + +- `+set com_target_game 0` for the default base game (mohaa, uses `main` folder) +- `+set com_target_game 1` for the Spearhead expansion (mohaas, uses `mainta` folder) +- `+set com_target_game 2` for the Breakthrough expansion (mohaab, uses `maintt` folder) + +OpenMoHAA will also use the correct network protocol version accordingly. The default value of `com_target_game` is 0. + +On Windows, a shortcut can be created to the `openmohaa` executable, with the command-line argument appended from above to play an expansion. You can now start a local OpenMOHAA server or play on a server. -## Config file +### Using a demo version -The config file can be found in different locations depending on the platform: +The argument `+set com_target_demo 1` must be appended to command-line to play the game or host a server using demo assets. Allied Assault, Spearhead and Breakthrough demos are supported. -- `%APPDATA%\openmohaa\\configs\omconfig.cfg` on Windows -- `~/.openmohaa//configs/omconfig.cfg` on Linux +## User data location -This has two advantages: +The location of user-writable data, like the console logfile, saves and configuration files can be found in different locations depending on the platform: + +- `%APPDATA%\openmohaa` on Windows +- `~/.openmohaa` on Linux +- `~/Library/Application Support/openmohaa` on macOS + +There will be one or more subdirectories like in the game installation folder, they match the game being used: either base game `main` or expansions `mainta`/`maintt`. + +This is by design since ioquake3 and has two advantages: - On a multi-user system, each user will have their own configuration file - It doesn't overwrite the existing MOHAA configuration in the MOHAA installation directory. +If necessary, the location of user-writable data can be changed manually by setting the `fs_homepath` variable in the command-line argument. This is useful when running a dedicated server that can only use the game directory to store/read data. The value can be a relative path (relative to the current working directory) or an absolute path. Example: +- `+set fs_homepath Z:\openmohaa_data` data will be written inside the fully qualified path `Z:\openmohaa_data` +- `+set fs_homepath homedata` will use the subfolder `homedata` in the process current working directory to write data (will be created automatically) +- `+set fs_homepath .` not recommended, will write data inside the process current working directory + +The game directory is intended to be read-only, which is the reason why the home path exists. This prevents existing files in the game directory from being accidentally overwritten. + Note that the configuration file isn't created nor written automatically on a dedicated server (**omohaaded**). ## Playing with bots OpenMoHAA has a basic bot system that emulates real players. The maximum number of bots is defined by the `sv_maxbots` variable, and the number of initial bots is defined by the `sv_numbots` variable. Bots can also be added or removed using the `addbot` and `removebot` commands. -This feature is a great way to test the gameplay and mods. \ No newline at end of file +This feature is a great way to test the gameplay and mods. + +Note that maps must have path built for bots to move, multiplayer maps don't have path built by default. The [mp-navigation](https://github.com/openmoh/mp-navigation) PK3 file can be downloaded and installed in the `main` directory, it adds navigation for all multiplayer maps, including multiplayer maps from Spearhead and Breakthrough. diff --git a/docs/screenshots/install_guide/windows_installation_sendto.png b/docs/screenshots/install_guide/windows_installation_sendto.png new file mode 100644 index 00000000..069a18d0 Binary files /dev/null and b/docs/screenshots/install_guide/windows_installation_sendto.png differ diff --git a/docs/screenshots/install_guide/windows_installation_shortcut.png b/docs/screenshots/install_guide/windows_installation_shortcut.png new file mode 100644 index 00000000..014206e7 Binary files /dev/null and b/docs/screenshots/install_guide/windows_installation_shortcut.png differ diff --git a/docs/script/events.md b/docs/script/events.md new file mode 100644 index 00000000..74bad85b --- /dev/null +++ b/docs/script/events.md @@ -0,0 +1,93 @@ +# Events + +OpenMoHAA introduces a new way for scripts to monitor for specific events, like players spawning or getting killed. Multiple scripts can subscribe to the same events. + +## Subscribing + +Commands related to events: +```cpp +event_subscribe event_name script_label + Subscribes to an event, script_label will be called when the event is triggered + +event_unsubscribe event_name script_label + Unsubscribe from an event, script_label will not be called anymore +``` + +When an event is not needed anymore, make sure to call `event_unsubscribe` with the same parameters used when subscribing to the event. + +### Example + +```cpp +main: + event_subscribe "player_spawned" event_player_spawned + // Can specify another script: + //event_subscribe "player_spawned" global/test_script::event_player_spawned +end + +event_player_spawned: + iprintlnbold("player entity number " + self.entnum + " just spawned!") +end +``` + +## List of events + +### Player events + +The `self` object is the player object for all triggered player events. + +#### player_connected + +The player entered the game. + +Called when: +- When a client spawns for the first time +- When the map restarts, or when the map changes (for all players) +- On the next round (for all players) + +This is called after the player finished spawning, and before `player_spawned` event. + +#### player_damaged + +The player just got hit. + +The parameters are the same as the `damage` command: +``` +player_damaged local.attacker local.damage local.inflictor local.position local.direction local.normal local.knockback local.damageflags local.meansofdeath local.location +``` + +#### player_disconnecting + +The player is disconnecting. + +#### player_killed + +The player got killed. + +The parameters are the same as the `killed` command: +``` +player_killed local.attacker local.damage local.inflictor local.position local.direction local.normal local.knockback local.damageflags local.meansofdeath local.location +``` + +#### player_spawned + +The player just spawned. + +Called when: +- The player has entered the battle +- The player respawned or spawned with weapons + +This is called after the player finished spawning. + +The event can be called even for spectators (when the spectator gets respawned). + +#### player_textMessage + +The player sent a text message. + +``` +player_textMessage local.text local.is_team +``` + +Parameters: +- local.text: The raw text message the client sent to the server +- local.is_team: `1` if it's a team message. `0` otherwise (everyone) diff --git a/docs/scripting.md b/docs/scripting.md new file mode 100644 index 00000000..d8130122 --- /dev/null +++ b/docs/scripting.md @@ -0,0 +1,6 @@ +# Scripting + +The documentation is currently incomplete. + +- [Event subscription](./script/events.md) +- [Scripting commands](https://htmlpreview.github.io/?https://github.com/openmoh/openmohaa/blob/main/docs/features_g_allclasses.html) (all classes documentation) \ No newline at end of file diff --git a/make-macosx-ub.sh b/make-macosx-ub.sh deleted file mode 100644 index a7833e2d..00000000 --- a/make-macosx-ub.sh +++ /dev/null @@ -1,232 +0,0 @@ -#!/bin/sh -APPBUNDLE=openmohaa.app -BINARY=openmohaa.ub -DEDBIN=omohaaded.ub -PKGINFO=APPLOMOHAA -ICNS=misc/openmohaa.icns -DESTDIR=build/release-darwin-ub -BASEDIR=main -MPACKDIR=missionpack -Q3_VERSION=`grep "\#define Q3_VERSION" code/qcommon/q_shared.h | \ - sed -e 's/.*".* \([^ ]*\)"/\1/'`; - -BIN_OBJ=" - build/release-darwin-ppc/openmohaa-smp.ppc - build/release-darwin-i386/openmohaa-smp.i386 -" -BIN_DEDOBJ=" - build/release-darwin-ub/omohaaded.ppc - build/release-darwin-i386/omohaaded.i386 -" -BASE_OBJ=" - build/release-darwin-ppc/$BASEDIR/cgameppc.dylib - build/release-darwin-i386/$BASEDIR/cgamei386.dylib - build/release-darwin-ppc/$BASEDIR/uippc.dylib - build/release-darwin-i386/$BASEDIR/uii386.dylib - build/release-darwin-ppc/$BASEDIR/qagameppc.dylib - build/release-darwin-i386/$BASEDIR/qagamei386.dylib -" -MPACK_OBJ=" - build/release-darwin-ppc/$MPACKDIR/cgameppc.dylib - build/release-darwin-i386/$MPACKDIR/cgamei386.dylib - build/release-darwin-ppc/$MPACKDIR/uippc.dylib - build/release-darwin-i386/$MPACKDIR/uii386.dylib - build/release-darwin-ppc/$MPACKDIR/qagameppc.dylib - build/release-darwin-i386/$MPACKDIR/qagamei386.dylib -" -if [ ! -f Makefile ]; then - echo "This script must be run from the openmohaa build directory"; -fi - -TIGERHOST=0 -if uname -r | grep ^8. > /dev/null; then - TIGERHOST=1 -fi - -# we want to use the oldest available SDK for max compatiblity -unset PPC_CLIENT_SDK -PPC_CLIENT_CC=gcc -unset PPC_CLIENT_CFLAGS -unset PPC_CLIENT_LDFLAGS -unset PPC_SERVER_SDK -unset PPC_SERVER_CFLAGS -unset PPC_SERVER_LDFLAGS -unset X86_SDK -unset X86_CFLAGS -unset X86_LDFLAGS -if [ -d /Developer/SDKs/MacOSX10.5.sdk ]; then - PPC_CLIENT_SDK=/Developer/SDKs/MacOSX10.5.sdk - PPC_CLIENT_CC=gcc-4.0 - PPC_CLIENT_CFLAGS="-arch ppc -isysroot /Developer/SDKs/MacOSX10.5.sdk \ - -DMAC_OS_X_VERSION_MIN_REQUIRED=1050" - PPC_CLIENT_LDFLAGS="-arch ppc \ - -isysroot /Developer/SDKs/MacOSX10.5.sdk \ - -mmacosx-version-min=10.5" - PPC_SERVER_SDK=/Developer/SDKs/MacOSX10.5.sdk - PPC_SERVER_CFLAGS=$PPC_CLIENT_CFLAGS - PPC_SERVER_LDFLAGS=$PPC_CLIENT_LDFLAGS - - X86_SDK=/Developer/SDKs/MacOSX10.5.sdk - X86_CFLAGS="-arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk \ - -DMAC_OS_X_VERSION_MIN_REQUIRED=1050" - X86_LDFLAGS="-arch i386 \ - -isysroot /Developer/SDKs/MacOSX10.5.sdk \ - -mmacosx-version-min=10.5" - X86_ENV="CFLAGS=$CFLAGS LDFLAGS=$LDFLAGS" -fi - -if [ -d /Developer/SDKs/MacOSX10.4u.sdk ]; then - PPC_CLIENT_SDK=/Developer/SDKs/MacOSX10.4u.sdk - PPC_CLIENT_CC=gcc-4.0 - PPC_CLIENT_CFLAGS="-arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk \ - -DMAC_OS_X_VERSION_MIN_REQUIRED=1040" - PPC_CLIENT_LDFLAGS="-arch ppc \ - -isysroot /Developer/SDKs/MacOSX10.4u.sdk \ - -mmacosx-version-min=10.4" - PPC_SERVER_SDK=/Developer/SDKs/MacOSX10.4u.sdk - PPC_SERVER_CFLAGS=$PPC_CLIENT_CFLAGS - PPC_SERVER_LDFLAGS=$PPC_CLIENT_LDFLAGS - - X86_SDK=/Developer/SDKs/MacOSX10.4u.sdk - X86_CFLAGS="-arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk \ - -DMAC_OS_X_VERSION_MIN_REQUIRED=1040" - X86_LDFLAGS="-arch i386 \ - -isysroot /Developer/SDKs/MacOSX10.4u.sdk \ - -mmacosx-version-min=10.4" - X86_ENV="CFLAGS=$CFLAGS LDFLAGS=$LDFLAGS" -fi - -if [ -d /Developer/SDKs/MacOSX10.3.9.sdk ] && [ $TIGERHOST ]; then - PPC_CLIENT_SDK=/Developer/SDKs/MacOSX10.3.9.sdk - PPC_CLIENT_CC=gcc-4.0 - PPC_CLIENT_CFLAGS="-arch ppc -isysroot /Developer/SDKs/MacOSX10.3.9.sdk \ - -DMAC_OS_X_VERSION_MIN_REQUIRED=1030" - PPC_CLIENT_LDFLAGS="-arch ppc \ - -isysroot /Developer/SDKs/MacOSX10.3.9.sdk \ - -mmacosx-version-min=10.3" - PPC_SERVER_SDK=/Developer/SDKs/MacOSX10.3.9.sdk - PPC_SERVER_CFLAGS=$PPC_CLIENT_CFLAGS - PPC_SERVER_LDFLAGS=$PPC_CLIENT_LDFLAGS -fi - -if [ -d /Developer/SDKs/MacOSX10.2.8.sdk ] && [ -x /usr/bin/gcc-3.3 ] && [ $TIGERHOST ]; then - PPC_CLIENT_SDK=/Developer/SDKs/MacOSX10.2.8.sdk - PPC_CLIENT_CC=gcc-3.3 - PPC_CLIENT_CFLAGS="-arch ppc \ - -nostdinc \ - -F/Developer/SDKs/MacOSX10.2.8.sdk/System/Library/Frameworks \ - -I/Developer/SDKs/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3 \ - -isystem /Developer/SDKs/MacOSX10.2.8.sdk/usr/include \ - -DMAC_OS_X_VERSION_MIN_REQUIRED=1020" - PPC_CLIENT_LDFLAGS="-arch ppc \ - -L/Developer/SDKs/MacOSX10.2.8.sdk/usr/lib/gcc/darwin/3.3 \ - -F/Developer/SDKs/MacOSX10.2.8.sdk/System/Library/Frameworks \ - -Wl,-syslibroot,/Developer/SDKs/MacOSX10.2.8.sdk,-m" -fi - -echo "Building PPC Dedicated Server against \"$PPC_SERVER_SDK\"" -echo "Building PPC Client against \"$PPC_CLIENT_SDK\"" -echo "Building X86 Client/Dedicated Server against \"$X86_SDK\"" -if [ "$PPC_CLIENT_SDK" != "/Developer/SDKs/MacOSX10.2.8.sdk" ] || \ - [ "$PPC_SERVER_SDK" != "/Developer/SDKs/MacOSX10.3.9.sdk" ] || \ - [ "$X86_SDK" != "/Developer/SDKs/MacOSX10.4u.sdk" ]; then - echo "\ -WARNING: in order to build a binary with maximum compatibility you must - build on Mac OS X 10.4 using Xcode 2.3 or 2.5 and have the - MacOSX10.2.8, MacOSX10.3.9, and MacOSX10.4u SDKs installed - from the Xcode install disk Packages folder." -fi - -if [ -z $PPC_CLIENT_SDK ] || [ -z $PPC_SERVER_SDK ] || [ -z $X86_SDK ]; then - echo "\ -ERROR: This script is for building a Universal Binary. You cannot build - for a different architecture unless you have the proper Mac OS X SDKs - installed. If you just want to to compile for your own system run - 'make' instead of this script." - exit 1 -fi -sleep 3 - -if [ ! -d $DESTDIR ]; then - mkdir -p $DESTDIR -fi - -# ppc dedicated server -echo "Building Dedicated Server using $PPC_SERVER_SDK" -sleep 2 -if [ -d build/release-darwin-ppc ]; then - rm -r build/release-darwin-ppc -fi -(ARCH=ppc BUILD_CLIENT_SMP=0 BUILD_CLIENT=0 BUILD_GAME_VM=0 BUILD_GAME_SO=0 \ - CFLAGS=$PPC_SERVER_CFLAGS LDFLAGS=$PPC_SERVER_LDFLAGS make) || exit 1; -cp build/release-darwin-ppc/omohaaded.ppc $DESTDIR - -# ppc client -if [ -d build/release-darwin-ppc ]; then - rm -r build/release-darwin-ppc -fi -(ARCH=ppc USE_OPENAL_DLOPEN=1 BUILD_SERVER=0 CC=$PPC_CLIENT_CC \ - CFLAGS=$PPC_CLIENT_CFLAGS LDFLAGS=$PPC_CLIENT_LDFLAGS make) || exit 1; - -# intel client and server -if [ -d build/release-darwin-i386 ]; then - rm -r build/release-darwin-i386 -fi -(ARCH=i386 CFLAGS=$X86_CFLAGS LDFLAGS=$X86_LDFLAGS make) || exit 1; - -echo "Creating .app bundle $DESTDIR/$APPBUNDLE" -if [ ! -d $DESTDIR/$APPBUNDLE/Contents/MacOS/$BASEDIR ]; then - mkdir -p $DESTDIR/$APPBUNDLE/Contents/MacOS/$BASEDIR || exit 1; -fi -if [ ! -d $DESTDIR/$APPBUNDLE/Contents/MacOS/$MPACKDIR ]; then - mkdir -p $DESTDIR/$APPBUNDLE/Contents/MacOS/$MPACKDIR || exit 1; -fi -if [ ! -d $DESTDIR/$APPBUNDLE/Contents/Resources ]; then - mkdir -p $DESTDIR/$APPBUNDLE/Contents/Resources -fi -cp $ICNS $DESTDIR/$APPBUNDLE/Contents/Resources/openmohaa.icns || exit 1; -echo $PKGINFO > $DESTDIR/$APPBUNDLE/Contents/PkgInfo -echo " - - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - $BINARY - CFBundleGetInfoString - openmohaa $Q3_VERSION - CFBundleIconFile - openmohaa.icns - CFBundleIdentifier - org.icculus.quake3 - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - opemohaa - CFBundlePackageType - APPL - CFBundleShortVersionString - $Q3_VERSION - CFBundleSignature - $PKGINFO - CFBundleVersion - $Q3_VERSION - NSExtensions - - NSPrincipalClass - NSApplication - - - " > $DESTDIR/$APPBUNDLE/Contents/Info.plist - -lipo -create -o $DESTDIR/$APPBUNDLE/Contents/MacOS/$BINARY $BIN_OBJ -lipo -create -o $DESTDIR/$APPBUNDLE/Contents/MacOS/$DEDBIN $BIN_DEDOBJ -rm $DESTDIR/omohaaded.ppc -cp $BASE_OBJ $DESTDIR/$APPBUNDLE/Contents/MacOS/$BASEDIR/ -cp $MPACK_OBJ $DESTDIR/$APPBUNDLE/Contents/MacOS/$MPACKDIR/ -cp code/libs/macosx/*.dylib $DESTDIR/$APPBUNDLE/Contents/MacOS/ - diff --git a/misc/build_increment.bat b/misc/build_increment.bat deleted file mode 100644 index a0c38aaf..00000000 --- a/misc/build_increment.bat +++ /dev/null @@ -1,14 +0,0 @@ -@echo off - -set BUILD= - -IF EXIST %1.txt ( - set /p BUILD=<%1.txt -) ELSE ( - set BUILD=0 -) - -set /a BUILD=%BUILD%+1 -@echo %BUILD% >%1.txt - -echo Successfully wrote build number to %1.txt. \ No newline at end of file diff --git a/TargetArch.cmake b/misc/cmake/TargetArch.cmake similarity index 91% rename from TargetArch.cmake rename to misc/cmake/TargetArch.cmake index fd4ba8d9..c2c42fb0 100644 --- a/TargetArch.cmake +++ b/misc/cmake/TargetArch.cmake @@ -3,8 +3,12 @@ set(archdetect_c_code " # error cmake_ARCH x86 #elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64) # error cmake_ARCH x86_64 -#elif defined(__ppc64__) || defined(__powerpc64__) -# error cmake_ARCH ppc64 +#elif defined(__PPC64__) || defined(__ppc64__) || defined(__powerpc64__) || defined(_ARCH_PPC64) +# if __BIG_ENDIAN__ +# error cmake_ARCH ppc64 +# else +# error cmake_ARCH ppc64el +# endif #elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) # error cmake_ARCH ppc #elif defined __s390__ @@ -19,10 +23,14 @@ set(archdetect_c_code " # error cmake_ARCH alpha #elif defined __sparc__ # error cmake_ARCH sparc -#elif defined __arm__ || defined (_M_ARM) -# error cmake_ARCH arm #elif defined(__aarch64__) || defined(__ARM64__) || defined(_M_ARM64) -# error cmake_ARCH aarch64 +# error cmake_ARCH arm64 +#elif defined __arm__ || defined (_M_ARM) +# if defined(__ARM_PCS_VFP) && (__ARM_PCS_VFP) +# error cmake_ARCH armhf +# else +# error cmake_ARCH armel +# endif #elif defined __cris__ # error cmake_ARCH cris #elif defined __hppa__ @@ -63,12 +71,14 @@ function(target_architecture output_var) foreach(osx_arch ${CMAKE_OSX_ARCHITECTURES}) if("${osx_arch}" STREQUAL "ppc" AND ppc_support) set(osx_arch_ppc TRUE) + elseif("${osx_arch}" STREQUAL "ppc64" AND ppc_support) + set(osx_arch_ppc64 TRUE) elseif("${osx_arch}" STREQUAL "i386") set(osx_arch_i386 TRUE) elseif("${osx_arch}" STREQUAL "x86_64") set(osx_arch_x86_64 TRUE) - elseif("${osx_arch}" STREQUAL "ppc64" AND ppc_support) - set(osx_arch_ppc64 TRUE) + elseif("${osx_arch}" STREQUAL "arm64") + set(osx_arch_arm64 TRUE) else() message(FATAL_ERROR "Invalid OS X arch name: ${osx_arch}") endif() @@ -79,6 +89,10 @@ function(target_architecture output_var) list(APPEND ARCH ppc) endif() + if(osx_arch_ppc64) + list(APPEND ARCH ppc64) + endif() + if(osx_arch_i386) list(APPEND ARCH i386) endif() @@ -87,8 +101,8 @@ function(target_architecture output_var) list(APPEND ARCH x86_64) endif() - if(osx_arch_ppc64) - list(APPEND ARCH ppc64) + if(osx_arch_arm64) + list(APPEND ARCH arm64) endif() else() # figure out extension for the source file diff --git a/misc/linux/org.openmoh.openmohaa.desktop.in b/misc/linux/org.openmoh.openmohaa.desktop.in new file mode 100644 index 00000000..f9657705 --- /dev/null +++ b/misc/linux/org.openmoh.openmohaa.desktop.in @@ -0,0 +1,11 @@ +[Desktop Entry] +Version=1.0 +Type=Application + +Name=OpenMoHAA +Comment=An open-source game engine compatible with Medal of Honor: Allied Assault +Categories=Game;Shooter; + +Icon=org.openmoh.openmohaa +Exec=launch_openmohaa_base@TARGET_ARCH@ +Terminal=false diff --git a/misc/linux/org.openmoh.openmohaa.metainfo.xml b/misc/linux/org.openmoh.openmohaa.metainfo.xml new file mode 100644 index 00000000..b1229586 --- /dev/null +++ b/misc/linux/org.openmoh.openmohaa.metainfo.xml @@ -0,0 +1,38 @@ + + + org.openmoh.openmohaa + + OpenMoHAA + An open-source game engine compatible with Medal of Honor: Allied Assault and its expansions (Spearhead and Breakthrough) + + FSFAP + GPL-2.0-or-later + + +

      + The main goal of OpenMoHAA is to ensure the future and continuity of Medal of Honor: Allied Assault. It has always been a dream in the community to provide patches and security fixes for the game. Thanks to the ioquake3 project, F.A.K.K SDK and other quality tools, OpenMoHAA has already reached more than half of its goal: to create an open-source version of MoH:AA (based on version 2.40) that is fully compatible with the original game (in terms of protocol, assets, and scripts). +

      +
      + + org.openmoh.openmohaa.desktop + + + https://github.com/openmoh/openmohaa/blob/main/docs/images/v0.60.0-x86_64/mohdm1_1.png?raw=true + Shows a smoke being deployed during multiplayer gameplay + + + https://github.com/openmoh/openmohaa/blob/main/docs/images/v0.60.0-x86_64/flughafen_1.png?raw=true + Shows a turret firing during multiplayer gameplay + + + https://github.com/openmoh/openmohaa/blob/main/docs/images/v0.60.0-x86_64/flughafen_3.png?raw=true + Shows a mortar firing during multiplayer gameplay + + + + + moderate + moderate + intense + +
      diff --git a/misc/linux/org.openmoh.openmohaab.desktop.in b/misc/linux/org.openmoh.openmohaab.desktop.in new file mode 100644 index 00000000..5b2ecf3d --- /dev/null +++ b/misc/linux/org.openmoh.openmohaab.desktop.in @@ -0,0 +1,11 @@ +[Desktop Entry] +Version=1.0 +Type=Application + +Name=OpenMoHAA Breakthrough +Comment=An open-source game engine compatible with Medal of Honor: Allied Assault Breakthrough +Categories=Game;Shooter; + +Icon=org.openmoh.openmohaa +Exec=launch_openmohaa_breakthrough@TARGET_ARCH@ +Terminal=false diff --git a/misc/linux/org.openmoh.openmohaas.desktop.in b/misc/linux/org.openmoh.openmohaas.desktop.in new file mode 100644 index 00000000..66633291 --- /dev/null +++ b/misc/linux/org.openmoh.openmohaas.desktop.in @@ -0,0 +1,11 @@ +[Desktop Entry] +Version=1.0 +Type=Application + +Name=OpenMoHAA Spearhead +Comment=An open-source game engine compatible with Medal of Honor: Allied Assault Spearhead +Categories=Game;Shooter; + +Icon=org.openmoh.openmohaa +Exec=launch_openmohaa_spearhead@TARGET_ARCH@ +Terminal=false diff --git a/misc/openmohaa-lowdetail.svg b/misc/openmohaa-lowdetail.svg new file mode 100644 index 00000000..31994e76 --- /dev/null +++ b/misc/openmohaa-lowdetail.svg @@ -0,0 +1,2254 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/misc/openmohaa-text-mono.svg b/misc/openmohaa-text-mono.svg new file mode 100644 index 00000000..ca7dd433 --- /dev/null +++ b/misc/openmohaa-text-mono.svg @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + diff --git a/misc/openmohaa-text-sm.png b/misc/openmohaa-text-sm.png new file mode 100644 index 00000000..e27733be Binary files /dev/null and b/misc/openmohaa-text-sm.png differ diff --git a/misc/openmohaa-text.png b/misc/openmohaa-text.png new file mode 100644 index 00000000..57e1c665 Binary files /dev/null and b/misc/openmohaa-text.png differ diff --git a/misc/openmohaa-text.svg b/misc/openmohaa-text.svg new file mode 100644 index 00000000..8de0f98e --- /dev/null +++ b/misc/openmohaa-text.svg @@ -0,0 +1,8500 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/misc/setup/MacOSX/SLA-dmg.sh b/misc/setup/MacOSX/SLA-dmg.sh deleted file mode 100644 index af268f32..00000000 --- a/misc/setup/MacOSX/SLA-dmg.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash -# -# This script appends the text from Q3A_EULA.txt to a .dmg as a SLA resource -# -# usage is './SLA-dmg.sh /path/to/Q3A_EULA.txt /path/to/ioquake3.dmg' -# - -if [ "x$1" = "x" ] || [ "x$2" = "x" ]; then - echo "usage: ./SLA-dmg.sh /path/to/Q3A_EULA.txt /path/to/ioquake3.dmg" - exit 1; -fi - -if [ ! -r $1 ]; then - echo "$1 is not a readable Q3A_EULA.txt file" - exit 1; -fi -if [ ! -w $2 ]; then - echo "$2 is not writable .dmg file" - exit 1; -fi -touch tmp.r -if [ ! -w tmp.r ]; then - echo "Could not create temporary file tmp.r for writing" - exit 1; -fi - -echo " -data 'LPic' (5000) { - \$\"0002 0011 0003 0001 0000 0000 0002 0000\" - \$\"0008 0003 0000 0001 0004 0000 0004 0005\" - \$\"0000 000E 0006 0001 0005 0007 0000 0007\" - \$\"0008 0000 0047 0009 0000 0034 000A 0001\" - \$\"0035 000B 0001 0020 000C 0000 0011 000D\" - \$\"0000 005B 0004 0000 0033 000F 0001 000C\" - \$\"0010 0000 000B 000E 0000\" -}; - -data 'TEXT' (5002, \"English\") { -" > tmp.r - -sed -e 's/"/\\"/g' -e 's/\(.*\)$/"\1\\n"/g' $1 >> tmp.r - -echo " -}; - -resource 'STR#' (5002, \"English\") { - { - \"English\", - \"Agree\", - \"Disagree\", - \"Print\", - \"Save...\", - \"IMPORTANT - Read this License Agreement carefully before clicking on \" - \"the \\\"Agree\\\" button. By clicking on the \\\"Agree\\\" button, you agree \" - \"to be bound by the terms of the License Agreement.\", - \"Software License Agreement\", - \"This text cannot be saved. This disk may be full or locked, or the \" - \"file may be locked.\", - \"Unable to print. Make sure you have selected a printer.\" - } -}; -" >> tmp.r - -hdiutil convert -format UDCO -o tmp.dmg $2 || exit 1 -hdiutil unflatten tmp.dmg || exit 1 -/Developer/Tools/Rez /Developer/Headers/FlatCarbon/*.r tmp.r -a -o tmp.dmg \ - || exit 1 -hdiutil flatten tmp.dmg || exit 1 -hdiutil internet-enable -yes tmp.dmg || exit 1 -mv tmp.dmg $2 || (echo "Could not copy tmp.dmg to $2" && exit 1) -rm tmp.dmg -rm tmp.r -echo "SLA $1 successfully added to $2" diff --git a/misc/setup/Makefile b/misc/setup/Makefile deleted file mode 100644 index 286831c7..00000000 --- a/misc/setup/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -VERSION=1.34 -RELEASE=svn - -all: - VERSION=$(VERSION) RELEASE=$(RELEASE) ./doit - -sign: - for i in *.run; do \ - gpg -bao $$i.asc $$i; \ - done - -clean: - rm -rf *.run image - -.PHONY: all sign clean diff --git a/misc/setup/Solaris_pkg.sh b/misc/setup/Solaris_pkg.sh deleted file mode 100644 index 6b64201f..00000000 --- a/misc/setup/Solaris_pkg.sh +++ /dev/null @@ -1,135 +0,0 @@ -#!/bin/bash - -# Source directory -MOUNT_DIR="../.." - -# Solaris stuff -PLATFORM=`uname|sed -e s/_.*//|tr '[:upper:]' '[:lower:]'` -if [ "X`uname -m`" = "Xi86pc" ]; then - ARCH=i386 -else - ARCH=sparc -fi - -# Packages -PKG_SOLARIS_NAME=ioquake3 -PKG_DATA_NAME=ioquake3d -BUILD_DATE="`/usr/bin/date '+%Y%m%d%H%M%S'`" -SVNVERSION=/usr/local/bin/svnversion -if [ -x /usr/local/bin/svnversion ]; then - SVN_BANNER=`/usr/local/bin/svnversion ${MOUNT_DIR}|sed -e 's/S$//' -e 's/M$//' ` - BUILD_VERSION="1.34-r${SVN_BANNER}" -else - BUILD_VERSION="1.34-rSVN" -fi -PKG_VERSION="`date '+%Y%m%d%H%M'`" -PKG_MAINT_ID="quake@cojot.name" -SOLARIS_PKGFILE="${PKG_SOLARIS_NAME}-${BUILD_VERSION}-${PKG_VERSION}-${ARCH}.pkg" -DATA_PKGFILE="${PKG_DATA_NAME}-${BUILD_VERSION}-${PKG_VERSION}-${ARCH}.pkg" - -# build directories -BUILD_DIR="${MOUNT_DIR}/build/release-${PLATFORM}-${ARCH}" -PKG_SRC_DIR="${MOUNT_DIR}/misc/setup/pkg/${PKG_SOLARIS_NAME}" -PKG_BUILD_DIR="/tmp/ioquake3-build/${PKG_SOLARIS_NAME}-${BUILD_VERSION}" -PKG_DATA_SRC_DIR="${MOUNT_DIR}/misc/setup/pkg/${PKG_DATA_NAME}" -PKG_DATA_BUILD_DIR="/usr/local/src/quake3-data/quake3" - -# Tools -RM="/usr/bin/rm" -TOUCH="/usr/bin/touch" -SED="/usr/bin/sed" -CAT="/usr/bin/cat" -NAWK="/usr/bin/nawk" -MKDIR="gmkdir -v -p" -INSTALL_BIN="ginstall -D -m 755" -INSTALL_DATA="ginstall -D -m 644" -PKGPROTO="/usr/bin/pkgproto" -PKGMK="/usr/bin/pkgmk" -PKGTRANS="/usr/bin/pkgtrans" - -############################################################################# -# SOLARIS PACKAGE -############################################################################# - -if [ -d ${BUILD_DIR} ]; then - if [ ! -d ${BUILD_DIR}/pkg ]; then - ${MKDIR} ${BUILD_DIR}/pkg - fi - echo "Building ${BUILD_DIR}/pkg/${SOLARIS_PKGFILE}" - ${RM} -f ${BUILD_DIR}/pkg/${SOLARIS_PKGFILE} - ${TOUCH} ${BUILD_DIR}/pkg/${SOLARIS_PKGFILE} - ${SED} -e "/VERSION=/s/.*/VERSION=${BUILD_VERSION}-${PKG_VERSION}/" \ - < ${PKG_SRC_DIR}/pkginfo.template \ - > ${PKG_SRC_DIR}/pkginfo - ${CAT} ${PKG_SRC_DIR}/prototype.template > ${PKG_SRC_DIR}/prototype - - ${INSTALL_DATA} ${MOUNT_DIR}/COPYING.txt ${PKG_SRC_DIR}/copyright - for EXEC_READ in README id-readme.txt - do - if [ -f ${MOUNT_DIR}/${EXEC_READ} ]; then - ${INSTALL_DATA} ${MOUNT_DIR}/${EXEC_READ} ${PKG_BUILD_DIR}/${EXEC_READ} - fi - done - - for EXEC_BIN in ioq3ded ioquake3-smp ioquake3 - do - if [ -f ${BUILD_DIR}/${EXEC_BIN}.${ARCH} ]; then - ${INSTALL_BIN} ${BUILD_DIR}/${EXEC_BIN}.${ARCH} ${PKG_BUILD_DIR}/${EXEC_BIN}.${ARCH} - fi - done - - for EXEC_SH in ioq3ded.sh ioquake3.sh - do - if [ -f ${MOUNT_DIR}/misc/setup/pkg/${EXEC_SH} ]; then - ${INSTALL_BIN} ${MOUNT_DIR}/misc/setup/pkg/${EXEC_SH} ${PKG_BUILD_DIR}/${EXEC_SH} - fi - done - - for EXEC_SO in cgamesparc.so qagamesparc.so uisparc.so - do - if [ -f ${BUILD_DIR}/baseq3/${EXEC_SO} ]; then - ${INSTALL_BIN} ${BUILD_DIR}/baseq3/${EXEC_SO} ${PKG_BUILD_DIR}/baseq3/${EXEC_SO} - fi - if [ -f ${BUILD_DIR}/missionpack/${EXEC_SO} ]; then - ${INSTALL_BIN} ${BUILD_DIR}/missionpack/${EXEC_SO} ${PKG_BUILD_DIR}/missionpack/${EXEC_SO} - fi - done - - ${PKGPROTO} ${PKG_BUILD_DIR}=quake3 | \ - ${NAWK} '{ print $1,$2,$3,$4 }' >> ${PKG_SRC_DIR}/prototype - ${PKGMK} -o -p "${PKG_MAINT_ID}${BUILD_DATE}" \ - -b ${PKG_SRC_DIR} -f ${PKG_SRC_DIR}/prototype \ - -d /tmp -a ${ARCH} owner=root group=bin mode=0755 - ${PKGTRANS} -s /tmp ${BUILD_DIR}/pkg/${SOLARIS_PKGFILE} ${PKG_SOLARIS_NAME} - - echo "Building ${BUILD_DIR}/pkg/${DATA_PKGFILE}" - ${RM} -f ${BUILD_DIR}/pkg/${DATA_PKGFILE} - ${TOUCH} ${BUILD_DIR}/pkg/${DATA_PKGFILE} - ${SED} -e "/VERSION=/s/.*/VERSION=${BUILD_VERSION}.${PKG_VERSION}/" \ - < ${PKG_DATA_SRC_DIR}/pkginfo.template \ - > ${PKG_DATA_SRC_DIR}/pkginfo - ${CAT} ${PKG_DATA_SRC_DIR}/prototype.template > ${PKG_DATA_SRC_DIR}/prototype - - if [ -d ${MOUNT_DIR}/../webspace/include ]; then - EULA_DIR=${MOUNT_DIR}/../webspace/include - else - if [ -d ${MOUNT_DIR}/../../webspace/include ]; then - EULA_DIR=${MOUNT_DIR}/../../webspace/include - fi - fi - if [ -f ${EULA_DIR}/id_patch_pk3s_Q3A_EULA.txt ]; then - ${INSTALL_DATA} ${EULA_DIR}/id_patch_pk3s_Q3A_EULA.txt ${PKG_DATA_SRC_DIR}/copyright - fi - - ${PKGPROTO} ${PKG_DATA_BUILD_DIR}=quake3 | \ - ${NAWK} '{ print $1,$2,$3,$4 }' >> ${PKG_DATA_SRC_DIR}/prototype - ${PKGMK} -o -p "${PKG_MAINT_ID}${BUILD_DATE}" \ - -b ${PKG_DATA_SRC_DIR} -f ${PKG_DATA_SRC_DIR}/prototype \ - -d /tmp -a ${ARCH} owner=root group=bin mode=0755 - ${PKGTRANS} -s /tmp ${BUILD_DIR}/pkg/${DATA_PKGFILE} ${PKG_DATA_NAME} -else - echo "Directory ${BUILD_DIR} not found!" - exit 1 -fi - - diff --git a/misc/setup/doit b/misc/setup/doit deleted file mode 100644 index 834cff90..00000000 --- a/misc/setup/doit +++ /dev/null @@ -1,112 +0,0 @@ -#!/bin/bash - -: ${MAKESELF:=/usr/share/loki-setup/makeself} -: ${SETUPIMAGE:=/usr/share/loki-setup/image} - -: ${VERSION:=0.0_`date +%Y%m%d%H%M`} -: ${RELEASE:=0} - -set -e -set -x - -shopt -s nullglob - -rm -rf image -mkdir image - -### loki-setup files -cp -a $SETUPIMAGE/{setup.data,setup.sh} image/ - -### splash -rm -f image/setup.data/splash.xpm -[ -e splash.xpm ] && cp splash.xpm image/setup.data/splash.xpm -rm -f image/quake3.png -cp ../quake3.png image/quake3.png - -### binaries -topdir="../.." - -echo "changequote(\`[', \`]')dnl" > defines.m4 -echo "define(VERSION,$VERSION)dnl" >> defines.m4 - -copystartscript() -{ - local arch="$1" - mkdir -p image/bin/Linux/$arch - if [ "$arch" = x86_64 ]; then - ln -s x86_64 image/bin/Linux/amd64 - fi - install -m 755 ioquake3.sh image/bin/Linux/$arch/ioquake3 - install -m 755 ioq3demo.sh image/bin/Linux/$arch/ioq3demo -} - -archs=() -for arch in $topdir/build/release-*; do - arch=${arch##*-} - case "$arch" in - i386) echo "define(HAVE_I386,yes)dnl" >> defines.m4 - copystartscript x86 - ;; - x86_64) echo "define(HAVE_X86_64,yes)dnl" >> defines.m4 - copystartscript $arch - ;; - ppc) echo "define(HAVE_PPC,yes)dnl" >> defines.m4 - copystartscript $arch - ;; - *) - echo "architecture $arch unsupported" - continue; - ;; - esac - archs[${#archs[@]}]=$arch -done - -for arch in "${archs[@]}"; do - dst=image/tmp - mkdir $dst - mkdir $dst/baseq3 $dst/demoq3 $dst/missionpack - install -m 755 $topdir/build/release-linux-$arch/ioquake3.$arch $dst/ioquake3.$arch - install -m 755 $topdir/build/release-linux-$arch/ioq3ded.$arch $dst/ioq3ded.$arch - install -m 644 $topdir/build/release-linux-$arch/baseq3/*.so $dst/baseq3 - install -m 644 $topdir/build/release-linux-$arch/missionpack/*.so $dst/missionpack - for i in cgame qagame ui; do - ln -s ../baseq3/$i$arch.so $dst/demoq3 - done - - tar --owner=root --group=root -C $dst -cf ./image/ioquake3.$arch.tar . - rm -rf ./image/tmp -done - -# patch pk3 files -if [ -e ./idpatchpk3s.tar -a -e ./idtapatchpk3s.tar ]; then - install -m 644 ./idpatchpk3s.tar image/idpatchpk3s.tar - install -m 644 ./idtapatchpk3s.tar image/idtapatchpk3s.tar - install -m 644 ./id_patch_pk3s_Q3A_EULA.txt image/id_patch_pk3s_Q3A_EULA.txt - echo "define(HAVE_PATCHPK3,yes)dnl" >> defines.m4 -elif [ -e quake3-latest-pk3s.zip ]; then - unzip quake3-latest-pk3s.zip - chmod 644 quake3-latest-pk3s/*/*.pk3 - tar -C quake3-latest-pk3s/baseq3 -cf image/idpatchpk3s.tar . - tar -C quake3-latest-pk3s/missionpack -cf image/idtapatchpk3s.tar . - rm -r quake3-latest-pk3s - install -m 644 id_patch_pk3s_Q3A_EULA.txt image/id_patch_pk3s_Q3A_EULA.txt - echo "define(HAVE_PATCHPK3,yes)dnl" >> defines.m4 -fi - -### uninstall script -install -m 755 ./preuninstall.sh image/preuninstall.sh - - -### README, COPYING and EULA -install -m 644 $topdir/README image/README -install -m 644 $topdir/COPYING.txt image/COPYING - -# create setup.xml -m4 defines.m4 setup.xml.in > image/setup.data/setup.xml - -### makeself installer -ARCH= -if [ "${#archs[@]}" -eq 1 ]; then - ARCH=.$arch -fi -$MAKESELF/makeself.sh image ioquake3-$VERSION-$RELEASE$ARCH.run "ioquake3 $VERSION-$RELEASE" ./setup.sh diff --git a/misc/setup/ioq3demo.sh b/misc/setup/ioq3demo.sh deleted file mode 100644 index 05df7ff8..00000000 --- a/misc/setup/ioq3demo.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/sh - -readlink() { - local path=$1 ll - - if [ -L "$path" ]; then - ll="$(LC_ALL=C ls -l "$path" 2> /dev/null)" && - echo "${ll/* -> }" - else - return 1 - fi -} - -script=$0 -count=0 -while [ -L "$script" ] -do - script=$(readlink "$script") - count=`expr $count + 1` - if [ $count -gt 100 ] - then - echo "Too many symbolic links" - exit 1 - fi -done -cd "`dirname $script`" - - -lib=lib -test -e lib64 && lib=lib64 - -if test "x$LD_LIBRARY_PATH" = x; then - LD_LIBRARY_PATH="`pwd`/$lib" -else - LD_LIBRARY_PATH="`pwd`/$lib:$LD_LIBRARY_PATH" -fi -export LD_LIBRARY_PATH - -archs=`uname -m` -case "$archs" in - i?86) archs=i386 ;; - x86_64) archs="x86_64 i386" ;; - ppc64) archs="ppc64 ppc" ;; -esac - -for arch in $archs; do - test -x ./ioquake3.$arch || continue - exec ./ioquake3.$arch +set sv_pure 0 +set vm_cgame 0 +set vm_game 0 +set vm_ui 0 +set fs_game demoq3 "$@" -done -echo "could not execute ioquake3" >&2 diff --git a/misc/setup/ioquake3.SlackBuild b/misc/setup/ioquake3.SlackBuild deleted file mode 100644 index af261b72..00000000 --- a/misc/setup/ioquake3.SlackBuild +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/sh - -CWD=`pwd` -BASE=$CWD/../.. -if [ "$TMP" = "" ]; then - TMP=/tmp -fi - -# clean, update -make -C $BASE clean || exit 1 -svn up $BASE || exit 1 - -# extract version info -VERSION=`grep "\#define *PRODUCT_VERSION" $BASE/code/qcommon/q_shared.h | \ - sed -e 's/[^"]*"\(.*\)"/\1/'` - -SVN_REV=`LANG=C svnversion $BASE` -if [ ! "$SVN_REV" = "" ]; then - VERSION=${VERSION}_SVN${SVN_REV} -fi - -PKG_VERSION=$VERSION - -ARCH=${ARCH:-i586} - -BUILD=${BUILD:-1_io} - -APP=ioquake3 - -PKG=$TMP/package-$APP - -rm -rf $PKG -mkdir -p $PKG - -# build -make -C $BASE release copyfiles COPYDIR="$PKG"/usr/games/$APP|| exit 1 - -# copy additional files -cp $BASE/BUGS $BASE/COPYING.txt $BASE/ChangeLog $BASE/README $PKG/usr/games/$APP/ -cat $CWD/$APP.SlackBuild > $PKG/usr/games/$APP/$APP.SlackBuild - -mkdir -p $PKG/usr/share/$APP/icons -cp $BASE/misc/quake3.png $PKG/usr/share/$APP/icons/ioquake3.png - -mkdir -p $PKG/usr/bin -cat >> $PKG/usr/bin/ioquake3 << EOF -#!/bin/sh -cd /usr/games/$APP/ -./ioquake3.i386 \$* -exit \$? -EOF -chmod 754 $PKG/usr/bin/ioquake3 - -mkdir -p $PKG/usr/bin -cat >> $PKG/usr/bin/ioq3ded << EOF -#!/bin/sh -cd /usr/games/$APP/ -./ioq3ded.i386 \$* -exit \$? -EOF -chmod 754 $PKG/usr/bin/ioq3ded - -mkdir -p $PKG/install -cat $CWD/slack-desc > $PKG/install/slack-desc - -cat >> $PKG/install/doinst.sh << EOF -chmod 754 /usr/games/$APP/*.i386 -chmod 754 /usr/bin/ioquake3 /usr/bin/ioq3ded -EOF -chmod +x $PKG/install/doinst.sh - -pushd $PKG -chown -R root:root install/ || exit 1 -chown -R root:games usr/ || exit 1 -/sbin/makepkg -l y -c n $TMP/$APP-$VERSION-$ARCH-$BUILD.tgz -popd - diff --git a/misc/setup/ioquake3.sh b/misc/setup/ioquake3.sh deleted file mode 100644 index fbef5676..00000000 --- a/misc/setup/ioquake3.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/sh - -readlink() { - local path=$1 ll - - if [ -L "$path" ]; then - ll="$(LC_ALL=C ls -l "$path" 2> /dev/null)" && - echo "${ll##* -> }" - else - return 1 - fi -} - -script=$0 -count=0 -while [ -L "$script" ] -do - script=$(readlink "$script") - count=`expr $count + 1` - if [ $count -gt 100 ] - then - echo "Too many symbolic links" - exit 1 - fi -done -cd "`dirname $script`" - - -lib=lib -test -e lib64 && lib=lib64 - -if test "x$LD_LIBRARY_PATH" = x; then - LD_LIBRARY_PATH="`pwd`/$lib" -else - LD_LIBRARY_PATH="`pwd`/$lib:$LD_LIBRARY_PATH" -fi -export LD_LIBRARY_PATH - -archs=`uname -m` -case "$archs" in - i?86) archs=i386 ;; - x86_64) archs="x86_64 i386" ;; - ppc64) archs="ppc64 ppc" ;; -esac - -for arch in $archs; do - test -x ./ioquake3.$arch || continue - exec ./ioquake3.$arch "$@" -done -echo "could not execute ioquake3" >&2 diff --git a/misc/setup/pkg/ioq3ded.sh b/misc/setup/pkg/ioq3ded.sh deleted file mode 100644 index 5f2d7e50..00000000 --- a/misc/setup/pkg/ioq3ded.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -# Rev: $Id: ioq3ded.sh,v 1.9 2006/01/18 13:47:42 raistlin Exp raistlin $ -# Needed to make symlinks/shortcuts work. -# the binaries must run with correct working directory - -IOQ3_DIR=/usr/local/share/games/quake3 - -COMPILE_PLATFORM=`uname|sed -e s/_.*//|tr '[:upper:]' '[:lower:]'` -COMPILE_ARCH=`uname -p | sed -e s/i.86/i386/` - -EXEC_REL=release - -# EXEC_BIN=ioquake3.${COMPILE_ARCH} -# EXEC_BIN=ioquake3-smp.${COMPILE_ARCH} -EXEC_BIN=ioq3ded.${COMPILE_ARCH} - -EXEC_FLAGS="+set fs_basepath ${IOQ3_DIR} +set vm_game 1 +set vm_cgame 1 +set vm_ui 1 +set sv_pure 1 +set com_ansiColor 0" - -EXEC_DIR_LIST="${IOQ3_DIR}" - -for d in ${EXEC_DIR_LIST} -do - if [ -d $d ]; then - EXEC_DIR=${d} - break - fi -done - -if [ "X${EXEC_DIR}" != "X" ]; then - if [ ! -x ${EXEC_DIR}/${EXEC_BIN} ]; then - echo "Executable ${EXEC_DIR}/${EXEC_BIN} not found!" ; exit 1 - fi - cd ${IOQ3_DIR} && \ - ${EXEC_DIR}/${EXEC_BIN} ${EXEC_FLAGS} $* - exit $? -else - echo "No ioq3 binaries found!" - exit 1 -fi - - diff --git a/misc/setup/pkg/ioquake3.sh b/misc/setup/pkg/ioquake3.sh deleted file mode 100644 index b2fe7856..00000000 --- a/misc/setup/pkg/ioquake3.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -# Rev: $Id: ioquake3.sh,v 1.11 2006/01/18 13:47:42 raistlin Exp raistlin $ -# Needed to make symlinks/shortcuts work. -# the binaries must run with correct working directory - -IOQ3_DIR=/usr/local/share/games/quake3 - -COMPILE_PLATFORM=`uname|sed -e s/_.*//|tr '[:upper:]' '[:lower:]'` -COMPILE_ARCH=`uname -p | sed -e s/i.86/i386/` - -EXEC_REL=release - -EXEC_BIN=ioquake3.${COMPILE_ARCH} -# EXEC_BIN=ioquake3-smp.${COMPILE_ARCH} -# EXEC_BIN=ioq3ded.${COMPILE_ARCH} - -EXEC_FLAGS="+set fs_basepath ${IOQ3_DIR} +set vm_game 1 +set vm_cgame 1 +set vm_ui 1 +set sv_pure 1 +set com_ansiColor 0" - -EXEC_DIR_LIST="${IOQ3_DIR}" - -for d in ${EXEC_DIR_LIST} -do - if [ -d $d ]; then - EXEC_DIR=${d} - break - fi -done - -if [ "X${EXEC_DIR}" != "X" ]; then - if [ ! -x ${EXEC_DIR}/${EXEC_BIN} ]; then - echo "Executable ${EXEC_DIR}/${EXEC_BIN} not found!" ; exit 1 - fi - cd ${IOQ3_DIR} && \ - ${EXEC_DIR}/${EXEC_BIN} ${EXEC_FLAGS} $* - exit $? -else - echo "No ioq3 binaries found!" - exit 1 -fi - - diff --git a/misc/setup/pkg/ioquake3/depend b/misc/setup/pkg/ioquake3/depend deleted file mode 100644 index 11170caf..00000000 --- a/misc/setup/pkg/ioquake3/depend +++ /dev/null @@ -1,3 +0,0 @@ -P SUNWxilrl XIL Runtime Environment -P SFWsdl SDL - Simple DirectMedia Layer library -P ioquake3d Icculus.Org Quake3 game data files for Solaris 10 (X11,GLX,SDL) diff --git a/misc/setup/pkg/ioquake3/pkginfo.template b/misc/setup/pkg/ioquake3/pkginfo.template deleted file mode 100644 index 34d5b1ff..00000000 --- a/misc/setup/pkg/ioquake3/pkginfo.template +++ /dev/null @@ -1,12 +0,0 @@ -CLASSES=none -BASEDIR=/usr/local/share/games -TZ=PST -PATH=/sbin:/usr/sbin:/usr/bin:/usr/sadm/install/bin -PKG=ioquake3 -NAME=ioquake3 1.34 for Solaris 10 (X11,GLX,SDL) -VERSION= -CATEGORY=application,graphics,opengl -DESC=Icculus.Org Quake3 1.34 for Solaris 10 (http://www.ioquake3.org/) -VENDOR=http://www.ioquake3.org/ -EMAIL=quake@cojot.name -PKGSAV=/var/sadm/pkg/ioquake3/save diff --git a/misc/setup/pkg/ioquake3/postinstall b/misc/setup/pkg/ioquake3/postinstall deleted file mode 100644 index 2775d5ee..00000000 --- a/misc/setup/pkg/ioquake3/postinstall +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -# -# @(#)postinstall $Id: postinstall,v 1.3 2006/01/21 12:54:52 coyote Exp $ -# -# postinstall script for quake3 - -quake3_dir=$BASEDIR/quake3 -dest_dir=${PKG_INSTALL_ROOT}/usr/local/bin - -if [ -d ${dest_dir} ]; then - for inst_script in ioq3ded.sh ioquake3.sh - do - dest_script=${dest_dir}/${inst_script} - if [ ! -h ${dest_script} ]; then - ln -s ${quake3_dir}/${inst_script} ${dest_script} - fi - done -fi - -exit 0 - diff --git a/misc/setup/pkg/ioquake3/postremove b/misc/setup/pkg/ioquake3/postremove deleted file mode 100644 index 37690f61..00000000 --- a/misc/setup/pkg/ioquake3/postremove +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -# -# @(#)postremove $Id: postremove,v 1.3 2006/01/21 12:54:52 coyote Exp $ -# -# postremove script for quake3 - -quake3_dir=$BASEDIR -dest_dir=${PKG_INSTALL_ROOT}/usr/local/bin - -if [ -d ${dest_dir} ]; then - for inst_script in ioq3ded.sh ioquake3.sh - do - dest_script=${dest_dir}/${inst_script} - if [ -h ${dest_script} ]; then - rm -f ${dest_script} - fi - done -fi - -exit 0 - diff --git a/misc/setup/pkg/ioquake3/preinstall b/misc/setup/pkg/ioquake3/preinstall deleted file mode 100644 index ad126a11..00000000 --- a/misc/setup/pkg/ioquake3/preinstall +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# -# @(#)postinstall $Id: preinstall,v 1.2 2006/01/25 13:22:56 coyote Exp $ -# -# postinstall script for quake3 - -quake3_dir=$BASEDIR - -exit 0 - diff --git a/misc/setup/pkg/ioquake3/preremove b/misc/setup/pkg/ioquake3/preremove deleted file mode 100644 index 3f316f3c..00000000 --- a/misc/setup/pkg/ioquake3/preremove +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# -# @(#)postinstall $Id: preremove,v 1.2 2006/01/25 13:22:56 coyote Exp $ -# -# postinstall script for quake3 - -quake3_dir=$BASEDIR - -exit 0 - diff --git a/misc/setup/pkg/ioquake3/prototype.template b/misc/setup/pkg/ioquake3/prototype.template deleted file mode 100644 index f23af773..00000000 --- a/misc/setup/pkg/ioquake3/prototype.template +++ /dev/null @@ -1,8 +0,0 @@ -!default 0755 root bin -i pkginfo -i copyright -i depend -i postinstall -i postremove -i preinstall -i preremove diff --git a/misc/setup/pkg/ioquake3/space b/misc/setup/pkg/ioquake3/space deleted file mode 100644 index 95b72949..00000000 --- a/misc/setup/pkg/ioquake3/space +++ /dev/null @@ -1 +0,0 @@ -/usr/local/share 20000 15 diff --git a/misc/setup/pkg/ioquake3d/depend b/misc/setup/pkg/ioquake3d/depend deleted file mode 100644 index b55ff884..00000000 --- a/misc/setup/pkg/ioquake3d/depend +++ /dev/null @@ -1,2 +0,0 @@ -P SUNWxilrl XIL Runtime Environment -P SFWsdl SDL - Simple DirectMedia Layer library diff --git a/misc/setup/pkg/ioquake3d/pkginfo.template b/misc/setup/pkg/ioquake3d/pkginfo.template deleted file mode 100644 index a351c4de..00000000 --- a/misc/setup/pkg/ioquake3d/pkginfo.template +++ /dev/null @@ -1,12 +0,0 @@ -CLASSES=none -BASEDIR=/usr/local/share/games -TZ=PST -PATH=/sbin:/usr/sbin:/usr/bin:/usr/sadm/install/bin -PKG=ioquake3d -NAME=ioquake3 game data files for Solaris 10 (X11,GLX,SDL) -VERSION= -CATEGORY=application,graphics,opengl -DESC=ioquake3 game data files for Solaris 10 (http://www.ioquake3.org/) -VENDOR=http://www.ioquake3.org/ -EMAIL=quake@cojot.name -PKGSAV=/var/sadm/pkg/ioquake3d/save diff --git a/misc/setup/pkg/ioquake3d/postinstall b/misc/setup/pkg/ioquake3d/postinstall deleted file mode 100644 index f116fc3d..00000000 --- a/misc/setup/pkg/ioquake3d/postinstall +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# -# @(#)postinstall $Id: postinstall,v 1.2 2006/01/25 13:22:56 coyote Exp $ -# -# postinstall script for quake3 - -quake3_dir=$BASEDIR - -exit 0 - diff --git a/misc/setup/pkg/ioquake3d/postremove b/misc/setup/pkg/ioquake3d/postremove deleted file mode 100644 index 7614348d..00000000 --- a/misc/setup/pkg/ioquake3d/postremove +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# -# @(#)postinstall $Id: postremove,v 1.2 2006/01/25 13:22:56 coyote Exp $ -# -# postinstall script for quake3 - -quake3_dir=$BASEDIR - -exit 0 - diff --git a/misc/setup/pkg/ioquake3d/preinstall b/misc/setup/pkg/ioquake3d/preinstall deleted file mode 100644 index ad126a11..00000000 --- a/misc/setup/pkg/ioquake3d/preinstall +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# -# @(#)postinstall $Id: preinstall,v 1.2 2006/01/25 13:22:56 coyote Exp $ -# -# postinstall script for quake3 - -quake3_dir=$BASEDIR - -exit 0 - diff --git a/misc/setup/pkg/ioquake3d/preremove b/misc/setup/pkg/ioquake3d/preremove deleted file mode 100644 index 3f316f3c..00000000 --- a/misc/setup/pkg/ioquake3d/preremove +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# -# @(#)postinstall $Id: preremove,v 1.2 2006/01/25 13:22:56 coyote Exp $ -# -# postinstall script for quake3 - -quake3_dir=$BASEDIR - -exit 0 - diff --git a/misc/setup/pkg/ioquake3d/prototype.template b/misc/setup/pkg/ioquake3d/prototype.template deleted file mode 100644 index 26bd06a1..00000000 --- a/misc/setup/pkg/ioquake3d/prototype.template +++ /dev/null @@ -1,7 +0,0 @@ -!default 0755 root bin -i pkginfo -i depend -i postinstall -i postremove -i preinstall -i preremove diff --git a/misc/setup/pkg/ioquake3d/space b/misc/setup/pkg/ioquake3d/space deleted file mode 100644 index a8d224c3..00000000 --- a/misc/setup/pkg/ioquake3d/space +++ /dev/null @@ -1 +0,0 @@ -/usr/local/share 50000 100 diff --git a/misc/setup/preuninstall.sh b/misc/setup/preuninstall.sh deleted file mode 100644 index 49e80564..00000000 --- a/misc/setup/preuninstall.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -rmdir --ignore-fail-on-non-empty demoq3 missionpack >& /dev/null diff --git a/misc/setup/setup.xml.in b/misc/setup/setup.xml.in deleted file mode 100644 index 65dd1b9d..00000000 --- a/misc/setup/setup.xml.in +++ /dev/null @@ -1,111 +0,0 @@ - - - - README - - - -ifelse(HAVE_X86_64,yes,dnl - -)dnl -ifelse(HAVE_I386,yes,dnl - -)dnl -ifelse(HAVE_PPC,yes,dnl - -)dnl - - -ifelse(HAVE_PATCHPK3,yes,dnl - - - - id_patch_pk3s_Q3A_EULA.txt - - - - - - - - - - id_patch_pk3s_Q3A_EULA.txt - - - - - - - - Quake3/baseq3/pak0.pk3 - - - Setup/missionpack/pak0.pk3 - -)dnl - - diff --git a/misc/setup/slack-desc b/misc/setup/slack-desc deleted file mode 100644 index c88b4bcb..00000000 --- a/misc/setup/slack-desc +++ /dev/null @@ -1,12 +0,0 @@ - |-----handy-ruler------------------------------------------------------| -ioquake3: ioquake 3 - An open source Quake 3 distribution -ioquake3: -ioquake3: ioquake3 aims to build upon id Software's Quake 3 source code release. -ioquake3: The source code was released on August 20, 2005 under the GPL. Since -ioquake3: then code has been cleaned up, bugs have been fixed and features been -ioquake3: added. -ioquake3: The permanent goal is to create THE open source Quake 3 distribution -ioquake3: upon which people base their games and projects. -ioquake3: -ioquake3: http://ioquake3.org/ -ioquake3: diff --git a/misc/setup/splash.xpm b/misc/setup/splash.xpm deleted file mode 100644 index 27677676..00000000 --- a/misc/setup/splash.xpm +++ /dev/null @@ -1,2289 +0,0 @@ -/* XPM */ -static char * splash_xpm[] = { -"296 296 1990 2", -" c #999999", -". c #989797", -"+ c #999898", -"@ c #938B8B", -"# c #979494", -"$ c #8D7D7D", -"% c #958F8F", -"& c #887070", -"* c #928989", -"= c #846666", -"- c #8F7F7F", -"; c #815C5C", -"> c #8B7676", -", c #7D5353", -"' c #876C6C", -") c #7A4949", -"! c #846262", -"~ c #764040", -"{ c #805959", -"] c #733636", -"^ c #7D4F4F", -"/ c #702C2C", -"( c #794646", -"_ c #6C2323", -": c #763C3C", -"< c #691919", -"[ c #733232", -"} c #979595", -"| c #671313", -"1 c #6F2929", -"2 c #969090", -"3 c #660E0E", -"4 c #6C1F1F", -"5 c #948B8B", -"6 c #650A0A", -"7 c #691616", -"8 c #928686", -"9 c #640505", -"0 c #660C0C", -"a c #918181", -"b c #630101", -"c c #640303", -"d c #8D7878", -"e c #630000", -"f c #969292", -"g c #8A6E6E", -"h c #640000", -"i c #938888", -"j c #876565", -"k c #907F7F", -"l c #845B5B", -"m c #650000", -"n c #8D7575", -"o c #815252", -"p c #8A6B6B", -"q c #7E4848", -"r c #660000", -"s c #876262", -"t c #7B3E3E", -"u c #670000", -"v c #845858", -"w c #783535", -"x c #814F4F", -"y c #762B2B", -"z c #680000", -"A c #7E4545", -"B c #732222", -"C c #7B3B3B", -"D c #989696", -"E c #711A1A", -"F c #690000", -"G c #793232", -"H c #701313", -"I c #6A0000", -"J c #762828", -"K c #979191", -"L c #6E0C0C", -"M c #731F1F", -"N c #968F8F", -"O c #6C0505", -"P c #6B0000", -"Q c #711515", -"R c #948A8A", -"S c #6F0D0D", -"T c #928080", -"U c #6C0000", -"V c #6F0909", -"W c #8F7777", -"X c #6E0707", -"Y c #958A8A", -"Z c #8C6D6D", -"` c #6D0000", -" . c #6E0404", -".. c #938383", -"+. c #8A6464", -"@. c #6E0202", -"#. c #917C7C", -"$. c #875A5A", -"%. c #6E0000", -"&. c #8F7474", -"*. c #855050", -"=. c #6F0000", -"-. c #8C6B6B", -";. c #824646", -">. c #8A6161", -",. c #803D3D", -"'. c #700000", -"). c #875757", -"!. c #7E3333", -"~. c #854D4D", -"{. c #7C2929", -"]. c #710000", -"^. c #834444", -"/. c #792020", -"(. c #803A3A", -"_. c #781616", -":. c #720000", -"<. c #7E3131", -"[. c #760D0D", -"}. c #730000", -"|. c #7D2727", -"1. c #740303", -"2. c #7A1D1D", -"3. c #979292", -"4. c #740000", -"5. c #791616", -"6. c #999797", -"7. c #958989", -"8. c #781111", -"9. c #937F7F", -"0. c #750000", -"a. c #780C0C", -"b. c #968E8E", -"c. c #917676", -"d. c #770707", -"e. c #8F6B6B", -"f. c #760000", -"g. c #770202", -"h. c #948484", -"i. c #8D6262", -"j. c #770000", -"k. c #937D7D", -"l. c #8B5858", -"m. c #917373", -"n. c #894F4F", -"o. c #780000", -"p. c #8F6A6A", -"q. c #874545", -"r. c #8D6060", -"s. c #853B3B", -"t. c #790000", -"u. c #8B5656", -"v. c #843232", -"w. c #7A0000", -"x. c #8A4D4D", -"y. c #822828", -"z. c #884343", -"A. c #811F1F", -"B. c #7B0000", -"C. c #863A3A", -"D. c #7F1515", -"E. c #843030", -"F. c #7E0D0D", -"G. c #7C0000", -"H. c #832626", -"I. c #989191", -"J. c #7E0909", -"K. c #821F1F", -"L. c #968A8A", -"M. c #7E0707", -"N. c #7D0000", -"O. c #811717", -"P. c #989595", -"Q. c #958383", -"R. c #7E0404", -"S. c #801010", -"T. c #989292", -"U. c #947C7C", -"V. c #7E0202", -"W. c #7E0000", -"X. c #7F0808", -"Y. c #979090", -"Z. c #937474", -"`. c #7F0000", -" + c #7F0202", -".+ c #978E8E", -"++ c #916A6A", -"@+ c #968585", -"#+ c #906161", -"$+ c #800000", -"%+ c #8E5757", -"&+ c #937373", -"*+ c #8D4D4D", -"=+ c #810000", -"-+ c #916969", -";+ c #8C4444", -">+ c #905F5F", -",+ c #8B3A3A", -"'+ c #820000", -")+ c #8F5555", -"!+ c #8A3131", -"~+ c #830000", -"{+ c #8E4C4C", -"]+ c #892727", -"^+ c #8D4343", -"/+ c #881D1D", -"(+ c #840000", -"_+ c #8C3838", -":+ c #871616", -"<+ c #8A2F2F", -"[+ c #871111", -"}+ c #850000", -"|+ c #8A2525", -"1+ c #988E8E", -"2+ c #870C0C", -"3+ c #891C1C", -"4+ c #978989", -"5+ c #870707", -"6+ c #860000", -"7+ c #881212", -"8+ c #968383", -"9+ c #870202", -"0+ c #870000", -"a+ c #880808", -"b+ c #967C7C", -"c+ c #870101", -"d+ c #957373", -"e+ c #880000", -"f+ c #946969", -"g+ c #978585", -"h+ c #935F5F", -"i+ c #890000", -"j+ c #967B7B", -"k+ c #925656", -"l+ c #8A0000", -"m+ c #957171", -"n+ c #914C4C", -"o+ c #946868", -"p+ c #9F9191", -"q+ c #AB7E7E", -"r+ c #BD6262", -"s+ c #CF4848", -"t+ c #DB3636", -"u+ c #E72525", -"v+ c #EB1F1F", -"w+ c #E12C2C", -"x+ c #CD4B4B", -"y+ c #B76C6C", -"z+ c #9E9191", -"A+ c #914343", -"B+ c #8B0000", -"C+ c #945E5E", -"D+ c #AA7F7F", -"E+ c #C15C5C", -"F+ c #D83A3A", -"G+ c #E82222", -"H+ c #E91F1F", -"I+ c #E02D2D", -"J+ c #D43F3F", -"K+ c #C55555", -"L+ c #B47070", -"M+ c #A38989", -"N+ c #9B9595", -"O+ c #9D9292", -"P+ c #B17474", -"Q+ c #CB4D4D", -"R+ c #E32828", -"S+ c #F70B0B", -"T+ c #FE0000", -"U+ c #FC0202", -"V+ c #EE1919", -"W+ c #D34141", -"X+ c #B76B6B", -"Y+ c #903939", -"Z+ c #935555", -"`+ c #9D9494", -" @ c #AD7B7B", -".@ c #C45757", -"+@ c #E12B2B", -"@@ c #F60A0A", -"#@ c #FD0000", -"$@ c #FB0202", -"%@ c #ED1919", -"&@ c #D63B3B", -"*@ c #BD6161", -"=@ c #A58686", -"-@ c #B46F6F", -";@ c #D63C3C", -">@ c #F11313", -",@ c #FD0101", -"'@ c #EE1717", -")@ c #CE4949", -"!@ c #AC7C7C", -"~@ c #902F2F", -"{@ c #8C0000", -"]@ c #924B4B", -"^@ c #A28B8B", -"/@ c #BC6363", -"(@ c #DE2E2E", -"_@ c #F80707", -":@ c #FC0000", -"<@ c #F70707", -"[@ c #E32525", -"}@ c #C45656", -"|@ c #A58787", -"1@ c #CB4C4C", -"2@ c #EE1515", -"3@ c #FB0101", -"4@ c #DD2F2F", -"5@ c #B37070", -"6@ c #9C9494", -"7@ c #8F2626", -"8@ c #924141", -"9@ c #C94E4E", -"0@ c #F11010", -"a@ c #FB0000", -"b@ c #B86969", -"c@ c #9A9898", -"d@ c #AB7D7D", -"e@ c #D73838", -"f@ c #F90404", -"g@ c #F80505", -"h@ c #D53B3B", -"i@ c #A78383", -"j@ c #8F1E1E", -"k@ c #8D0000", -"l@ c #913838", -"m@ c #9C9595", -"n@ c #BC6161", -"o@ c #EB1717", -"p@ c #FA0000", -"q@ c #EB1818", -"r@ c #BE5E5E", -"s@ c #A88181", -"t@ c #D83636", -"u@ c #F80303", -"v@ c #F90101", -"w@ c #DB3131", -"x@ c #999595", -"y@ c #8F1717", -"z@ c #912E2E", -"A@ c #9D9393", -"B@ c #C35656", -"C@ c #EF1010", -"D@ c #F90000", -"E@ c #ED1414", -"F@ c #BD5F5F", -"G@ c #9F9090", -"H@ c #CD4646", -"I@ c #F40808", -"J@ c #EE1111", -"K@ c #B96666", -"L@ c #999292", -"M@ c #8F1010", -"N@ c #8E0000", -"O@ c #912525", -"P@ c #D73535", -"Q@ c #F70101", -"R@ c #F80000", -"S@ c #E32222", -"T@ c #B17272", -"U@ c #EA1717", -"V@ c #D93232", -"W@ c #989090", -"X@ c #900808", -"Y@ c #8F0000", -"Z@ c #911B1B", -"`@ c #9A9797", -" # c #BA6464", -".# c #F10A0A", -"+# c #F70000", -"@# c #F40404", -"## c #CE4343", -"$# c #CD4444", -"%# c #F70202", -"&# c #C55252", -"*# c #988D8D", -"=# c #8F0101", -"-# c #901111", -";# c #A78282", -"># c #E61A1A", -",# c #F60000", -"'# c #E91616", -")# c #AC7A7A", -"!# c #A18B8B", -"~# c #DD2929", -"{# c #F40505", -"]# c #BD5E5E", -"^# c #988585", -"/# c #900000", -"(# c #910B0B", -"_# c #999696", -":# c #A28A8A", -"<# c #E02222", -"[# c #F50000", -"}# c #F00909", -"|# c #B96363", -"1# c #A88080", -"2# c #E71818", -"3# c #F40303", -"4# c #BD5D5D", -"5# c #977B7B", -"6# c #988F8F", -"7# c #A18C8C", -"8# c #E31D1D", -"9# c #F40000", -"0# c #F20303", -"a# c #C74C4C", -"b# c #E91414", -"c# c #F50101", -"d# c #C84B4B", -"e# c #977171", -"f# c #910000", -"g# c #910606", -"h# c #988888", -"i# c #A48787", -"j# c #EC0D0D", -"k# c #F30101", -"l# c #A68383", -"m# c #E91313", -"n# c #DB2B2B", -"o# c #9B9696", -"p# c #966868", -"q# c #910404", -"r# c #988080", -"s# c #B26F6F", -"t# c #F10303", -"u# c #F30000", -"v# c #C44F4F", -"w# c #E11F1F", -"x# c #EF0707", -"y# c #A58585", -"z# c #965E5E", -"A# c #920000", -"B# c #920101", -"C# c #987979", -"D# c #CE3E3E", -"E# c #F20000", -"F# c #F10202", -"G# c #B76565", -"H# c #CE3D3D", -"I# c #C64C4C", -"J# c #965555", -"K# c #930000", -"L# c #A28989", -"M# c #EA0D0D", -"N# c #F10000", -"O# c #A87F7F", -"P# c #B66767", -"Q# c #F00202", -"R# c #EA0C0C", -"S# c #A08C8C", -"T# c #964B4B", -"U# c #976767", -"V# c #C74949", -"W# c #F00000", -"X# c #DC2323", -"Y# c #E31717", -"Z# c #CB4141", -"`# c #964141", -" $ c #940000", -".$ c #975D5D", -"+$ c #A48585", -"@$ c #EC0606", -"#$ c #EF0000", -"$$ c #BA5E5E", -"%$ c #C25050", -"&$ c #EE0202", -"*$ c #AC7777", -"=$ c #963838", -"-$ c #975353", -";$ c #D72929", -">$ c #EE0000", -",$ c #E51010", -"'$ c #9E8F8F", -")$ c #E41212", -"!$ c #962E2E", -"~$ c #950000", -"{$ c #974A4A", -"]$ c #BE5555", -"^$ c #ED0000", -"/$ c #B86060", -"($ c #D23131", -"_$ c #962424", -":$ c #974040", -"<$ c #A97B7B", -"[$ c #EC0000", -"}$ c #DF1919", -"|$ c #D62929", -"1$ c #C34C4C", -"2$ c #971A1A", -"3$ c #960000", -"4$ c #973737", -"5$ c #EA0202", -"6$ c #EB0000", -"7$ c #AB7777", -"8$ c #E90404", -"9$ c #B76161", -"0$ c #971111", -"a$ c #970000", -"b$ c #982D2D", -"c$ c #E11111", -"d$ c #EA0000", -"e$ c #C14D4D", -"f$ c #AD7373", -"g$ c #B16B6B", -"h$ c #970707", -"i$ c #972323", -"j$ c #DA1C1C", -"k$ c #E90000", -"l$ c #D42929", -"m$ c #BC5656", -"n$ c #AE7272", -"o$ c #980101", -"p$ c #980000", -"q$ c #981A1A", -"r$ c #D72323", -"s$ c #DF1313", -"t$ c #C64343", -"u$ c #B46666", -"v$ c #998D8D", -"w$ c #981414", -"x$ c #DC1717", -"y$ c #E80000", -"z$ c #E40808", -"A$ c #A18A8A", -"B$ c #CC3636", -"C$ c #C93D3D", -"D$ c #998383", -"E$ c #990000", -"F$ c #990F0F", -"G$ c #999191", -"H$ c #A38585", -"I$ c #E70101", -"J$ c #E70000", -"K$ c #E60202", -"L$ c #A48383", -"M$ c #CE3232", -"N$ c #E20A0A", -"O$ c #997A7A", -"P$ c #9A0000", -"Q$ c #9A0A0A", -"R$ c #998C8C", -"S$ c #C73E3E", -"T$ c #E60000", -"U$ c #A58181", -"V$ c #CB3535", -"W$ c #D12929", -"X$ c #997070", -"Y$ c #9A0505", -"Z$ c #998787", -"`$ c #AF6B6B", -" % c #E30404", -".% c #E50000", -"+% c #E40202", -"@% c #C34444", -"#% c #E30000", -"$% c #B23434", -"%% c #6A6A6A", -"&% c #626262", -"*% c #717171", -"=% c #8F8F8F", -"-% c #9A6767", -";% c #9B0000", -">% c #9B0101", -",% c #998282", -"'% c #AC7171", -")% c #DF0A0A", -"!% c #E40000", -"~% c #E00909", -"{% c #A08B8B", -"]% c #B46262", -"^% c #BF0000", -"/% c #450000", -"(% c #050000", -"_% c #000000", -":% c #0A0A0A", -"<% c #494949", -"[% c #929292", -"}% c #9A5D5D", -"|% c #997979", -"1% c #B75A5A", -"2% c #E00707", -"3% c #D61B1B", -"4% c #9F8C8C", -"5% c #E20303", -"6% c #AF0000", -"7% c #120000", -"8% c #272727", -"9% c #9A5353", -"0% c #9C0000", -"a% c #9A7070", -"b% c #C73A3A", -"c% c #E10101", -"d% c #E20000", -"e% c #C14545", -"f% c #CB3131", -"g% c #D90000", -"h% c #1B0000", -"i% c #3D3D3D", -"j% c #989898", -"k% c #9B4A4A", -"l% c #9A6666", -"m% c #919191", -"n% c #868686", -"o% c #8E8E8E", -"p% c #878585", -"q% c #9F5858", -"r% c #D40E0E", -"s% c #E10000", -"t% c #DF0404", -"u% c #A77C7C", -"v% c #A87979", -"w% c #E10303", -"x% c #040404", -"y% c #858585", -"z% c #9B4040", -"A% c #9D0000", -"B% c #9B5C5C", -"C% c #575757", -"D% c #434343", -"E% c #7A7A7A", -"F% c #373737", -"G% c #0B0B0B", -"H% c #010000", -"I% c #250000", -"J% c #CE0000", -"K% c #E00000", -"L% c #C93232", -"M% c #C43D3D", -"N% c #480000", -"O% c #742F2F", -"P% c #A77A7A", -"Q% c #9C3636", -"R% c #9B5353", -"S% c #949494", -"T% c #454545", -"U% c #030303", -"V% c #170000", -"W% c #DF0000", -"X% c #DB0808", -"Y% c #A38383", -"Z% c #D51919", -"`% c #360000", -" & c #DF0303", -".& c #D02323", -"+& c #B45E5E", -"@& c #9D9191", -"#& c #9D2C2C", -"$& c #9E0000", -"%& c #9C4949", -"&& c #979797", -"*& c #3A3A3A", -"=& c #080000", -"-& c #DE0000", -";& c #DD0101", -">& c #B55B5B", -",& c #A57F7F", -"'& c #D90D0D", -")& c #4A0000", -"!& c #DA0C0C", -"~& c #C53838", -"{& c #AD6D6D", -"]& c #9E2323", -"^& c #9F0000", -"/& c #9D4040", -"(& c #5E5E5E", -"_& c #010101", -":& c #0F0000", -"<& c #C90000", -"[& c #BF4444", -"}& c #AA7474", -"|& c #DB0606", -"1& c #090000", -"2& c #C60000", -"3& c #D80D0D", -"4& c #C33C3C", -"5& c #AE6B6B", -"6& c #9D8F8F", -"7& c #9E1919", -"8& c #9D3636", -"9& c #959595", -"0& c #0F0F0F", -"a& c #5E0000", -"b& c #DD0000", -"c& c #C63434", -"d& c #AB7070", -"e& c #D70D0D", -"f& c #D70000", -"g& c #DC0000", -"h& c #D80B0B", -"i& c #C83030", -"j& c #B35D5D", -"k& c #9A9696", -"l& c #9F1010", -"m& c #A00000", -"n& c #9E2C2C", -"o& c #040000", -"p& c #1C0000", -"q& c #130000", -"r& c #180000", -"s& c #D50000", -"t& c #C33838", -"u& c #9C9393", -"v& c #D41313", -"w& c #B70000", -"x& c #1D0000", -"y& c #D30000", -"z& c #DA0404", -"A& c #D01A1A", -"B& c #C04040", -"C& c #AE6969", -"D& c #A08989", -"E& c #A00A0A", -"F& c #9B9494", -"G& c #A67A7A", -"H& c #B65555", -"I& c #681E1E", -"J& c #A80000", -"K& c #D00000", -"L& c #D60000", -"M& c #CC0000", -"N& c #B80000", -"O& c #DA0101", -"P& c #BD4444", -"Q& c #A18686", -"R& c #CB2626", -"S& c #DB0000", -"T& c #580000", -"U& c #1A0000", -"V& c #D80707", -"W& c #C13D3D", -"X& c #B16161", -"Y& c #A28484", -"Z& c #9A8E8E", -"`& c #A10808", -" * c #A10000", -".* c #A01C1C", -"+* c #9C9292", -"@* c #AA7171", -"#* c #B94F4F", -"$* c #C82B2B", -"%* c #D50D0D", -"&* c #D90202", -"** c #DA0000", -"=* c #610000", -"-* c #A40707", -";* c #B35C5C", -">* c #BB4B4B", -",* c #D80404", -"'* c #D40000", -")* c #AD0000", -"!* c #D40F0F", -"~* c #C53232", -"{* c #A77979", -"]* c #9A8686", -"^* c #A10505", -"/* c #A01414", -"(* c #999494", -"_* c #A08787", -":* c #AE6666", -"<* c #BD4343", -"[* c #CC2020", -"}* c #D80202", -"|* c #5C0000", -"1* c #786969", -"2* c #A97272", -"3* c #CD1C1C", -"4* c #D40B0B", -"5* c #CB2222", -"6* c #BF3E3E", -"7* c #9B7F7F", -"8* c #A20303", -"9* c #A20000", -"0* c #A10D0D", -"a* c #9B9393", -"b* c #AD6A6A", -"c* c #B94C4C", -"d* c #C42F2F", -"e* c #CF1616", -"f* c #D70202", -"g* c #D80000", -"h* c #5F0000", -"i* c #060000", -"j* c #260000", -"k* c #737373", -"l* c #747474", -"m* c #5D5D5D", -"n* c #605656", -"o* c #791A1A", -"p* c #B60000", -"q* c #D80101", -"r* c #D40A0A", -"s* c #C13838", -"t* c #B55656", -"u* c #9F8989", -"v* c #9B7878", -"w* c #A30101", -"x* c #A30000", -"y* c #A30606", -"z* c #9A8F8F", -"A* c #A47E7E", -"B* c #AE6464", -"C* c #BB4646", -"D* c #C62929", -"E* c #D01212", -"F* c #D60404", -"G* c #C70000", -"H* c #BC0000", -"I* c #3B3B3B", -"J* c #C00000", -"K* c #3C0000", -"L* c #200000", -"M* c #100000", -"N* c #240000", -"O* c #4C0000", -"P* c #D10000", -"Q* c #D70101", -"R* c #D40707", -"S* c #CF1313", -"T* c #C52C2C", -"U* c #BB4545", -"V* c #B15E5E", -"W* c #A77777", -"X* c #9C6F6F", -"Y* c #9A8B8B", -"Z* c #A28383", -"`* c #AC6A6A", -" = c #B65151", -".= c #C03838", -"+= c #CA1F1F", -"@= c #D20B0B", -"#= c #D50303", -"$= c #CB0000", -"%= c #620000", -"&= c #070000", -"*= c #D01010", -"== c #BB4343", -"-= c #B25B5B", -";= c #A87474", -">= c #9F8A8A", -",= c #7C7C7C", -"'= c #6E6E6E", -")= c #6D6D6D", -"!= c #767676", -"~= c #888888", -"{= c #969696", -"]= c #707070", -"^= c #757575", -"/= c #9D6565", -"(= c #A40000", -"_= c #6D5D5D", -":= c #909090", -"<= c #A37F7F", -"[= c #AD6767", -"}= c #B54E4E", -"|= c #B13535", -"1= c #970505", -"2= c #A70000", -"3= c #C10000", -"4= c #D00D0D", -"5= c #1D1717", -"6= c #BB0000", -"7= c #2F0000", -"8= c #020000", -"9= c #560000", -"0= c #CD0000", -"a= c #D50101", -"b= c #CF0E0E", -"c= c #9F1F1F", -"d= c #3A2525", -"e= c #020202", -"f= c #1F1F1F", -"g= c #5F5F5F", -"h= c #8D8D8D", -"i= c #727272", -"j= c #1C1C1C", -"k= c #9D5B5B", -"l= c #090909", -"m= c #313131", -"n= c #797979", -"o= c #323232", -"p= c #9A9595", -"q= c #9E8B8B", -"r= c #A37E7E", -"s= c #AC6969", -"t= c #B45353", -"u= c #BC3E3E", -"v= c #C42828", -"w= c #CB1616", -"x= c #D10707", -"y= c #3F0000", -"z= c #0B0000", -"A= c #350000", -"B= c #B74C4C", -"C= c #1B1B1B", -"D= c #3C3C3C", -"E= c #673D3D", -"F= c #C32F2F", -"G= c #D40202", -"H= c #2B0000", -"I= c #4E0000", -"J= c #2B2B2B", -"K= c #8B8B8B", -"L= c #9F5252", -"M= c #A50000", -"N= c #515151", -"O= c #444444", -"P= c #020101", -"Q= c #8B4C4C", -"R= c #B64F4F", -"S= c #BD3B3B", -"T= c #C52626", -"U= c #CC1414", -"V= c #D00A0A", -"W= c #D40101", -"X= c #CF0000", -"Y= c #CC1313", -"Z= c #B45252", -"`= c #9E8C8C", -" - c #5B5B5B", -".- c #A47C7C", -"+- c #BC3D3D", -"@- c #500000", -"#- c #222121", -"$- c #948686", -"%- c #9F4848", -"&- c #A18383", -"*- c #5B4F4F", -"=- c #2C0000", -"-- c #C80000", -";- c #D20000", -">- c #420000", -",- c #C71E1E", -"'- c #AF5F5F", -")- c #9C9191", -"!- c #9D8E8E", -"~- c #B35555", -"{- c #CA1717", -"]- c #D30101", -"^- c #B50000", -"/- c #5B0000", -"(- c #D00505", -"_- c #CB1515", -":- c #C42626", -"<- c #BE3737", -"[- c #B74848", -"}- c #B15959", -"|- c #AB6A6A", -"1- c #A57979", -"2- c #9F8888", -"3- c #9C9090", -"4- c #8F8888", -"5- c #A13E3E", -"6- c #A60000", -"7- c #777777", -"8- c #493030", -"9- c #AE6161", -"0- c #B45050", -"a- c #BB3F3F", -"b- c #C12E2E", -"c- c #C71D1D", -"d- c #CE0C0C", -"e- c #D20101", -"f- c #030000", -"g- c #BE0000", -"h- c #CF0808", -"i- c #BE3535", -"j- c #A67676", -"k- c #A87070", -"l- c #BD3737", -"m- c #550505", -"n- c #BA0000", -"o- c #BB1111", -"p- c #0F0202", -"q- c #A67474", -"r- c #A28181", -"s- c #A23535", -"t- c #0D0000", -"u- c #2F2F2F", -"v- c #A08585", -"w- c #A47A7A", -"x- c #A96D6D", -"y- c #AD6161", -"z- c #B25353", -"A- c #B84343", -"B- c #6B1F1F", -"C- c #0E0000", -"D- c #AB0000", -"E- c #D00202", -"F- c #C61D1D", -"G- c #B25555", -"H- c #141414", -"I- c #161414", -"J- c #440000", -"K- c #CA0000", -"L- c #1E0000", -"M- c #340000", -"N- c #470000", -"O- c #380000", -"P- c #D10101", -"Q- c #CF0707", -"R- c #CC0D0D", -"S- c #CA1414", -"T- c #C12B2B", -"U- c #BD3838", -"V- c #B74545", -"W- c #B35252", -"X- c #AE5F5F", -"Y- c #A96C6C", -"Z- c #A57878", -"`- c #795F5F", -" ; c #A32B2B", -".; c #390000", -"+; c #371818", -"@; c #353535", -"#; c #363131", -"$; c #392828", -"%; c #311515", -"&; c #080202", -"*; c #090505", -"=; c #B32222", -"-; c #C81717", -";; c #CA1010", -">; c #CC0A0A", -",; c #CF0303", -"'; c #5A0000", -"); c #0A0000", -"!; c #C40000", -"~; c #2A0000", -"{; c #BA3E3E", -"]; c #A57777", -"^; c #7D7D7D", -"/; c #050505", -"(; c #7B7B7B", -"_; c #3E3E3E", -":; c #570000", -"<; c #D00101", -"[; c #9A0202", -"}; c #A52222", -"|; c #A23E3E", -"1; c #C41F1F", -"2; c #CC0808", -"3; c #CD0505", -"4; c #9C0101", -"5; c #C30000", -"6; c #B90000", -"7; c #160000", -"8; c #BC3737", -"9; c #505050", -"0; c #404040", -"a; c #0E0E0E", -"b; c #070707", -"c; c #4D0000", -"d; c #B10000", -"e; c #5D0000", -"f; c #A61919", -"g; c #A33535", -"h; c #C41C1C", -"i; c #210000", -"j; c #CE0101", -"k; c #CA0D0D", -"l; c #BC3535", -"m; c #AB6565", -"n; c #8A8A8A", -"o; c #0B0707", -"p; c #AC4F4F", -"q; c #C22323", -"r; c #CC0707", -"s; c #1F0000", -"t; c #430000", -"u; c #9A9494", -"v; c #A71313", -"w; c #A90000", -"x; c #A42B2B", -"y; c #C22020", -"z; c #590000", -"A; c #540000", -"B; c #3A0000", -"C; c #600000", -"D; c #CD0101", -"E; c #C71313", -"F; c #B93B3B", -"G; c #A86C6C", -"H; c #9F8787", -"I; c #AD5F5F", -"J; c #BC3333", -"K; c #C90D0D", -"L; c #AE0000", -"M; c #BD0000", -"N; c #A80E0E", -"O; c #AA0000", -"P; c #A62222", -"Q; c #BF2626", -"R; c #C50000", -"S; c #3B0000", -"T; c #CB0303", -"U; c #C21F1F", -"V; c #B34A4A", -"W; c #A57676", -"X; c #9B9292", -"Y; c #282828", -"Z; c #3F3F3F", -"`; c #A67272", -" > c #B54848", -".> c #C12020", -"+> c #9D0202", -"@> c #9B8B8B", -"#> c #A90A0A", -"$> c #A71818", -"%> c #BC2E2E", -"&> c #4F3232", -"*> c #9F8686", -"=> c #777171", -"-> c #9B8686", -";> c #AB0404", -">> c #A90E0E", -",> c #BA3535", -"'> c #CA0101", -")> c #5C0303", -"!> c #484848", -"~> c #AC0000", -"{> c #9C8080", -"]> c #AB0101", -"^> c #510000", -"/> c #510404", -"(> c #571C1C", -"_> c #150000", -":> c #C60A0A", -"<> c #BE2323", -"[> c #B24A4A", -"}> c #A57272", -"|> c #494040", -"1> c #101010", -"2> c #1A0606", -"3> c #C21A1A", -"4> c #C90303", -"5> c #9D7979", -"6> c #4B0000", -"7> c #0C0000", -"8> c #C50D0D", -"9> c #BC2A2A", -"0> c #B14D4D", -"a> c #A67171", -"b> c #464646", -"c> c #151515", -"d> c #9E8989", -"e> c #A86969", -"f> c #B44444", -"g> c #BF2121", -"h> c #C70404", -"i> c #9C7F7F", -"j> c #BF0E0E", -"k> c #590101", -"l> c #2D0101", -"m> c #260D0D", -"n> c #231919", -"o> c #212020", -"p> c #202020", -"q> c #414141", -"r> c #A47474", -"s> c #AF5252", -"t> c #9C2E2E", -"u> c #410000", -"v> c #9C8585", -"w> c #AC0404", -"x> c #302020", -"y> c #9F8585", -"z> c #5C5B5B", -"A> c #828282", -"B> c #1D0202", -"C> c #C60404", -"D> c #9B8A8A", -"E> c #AC0808", -"F> c #190000", -"G> c #C60101", -"H> c #C30B0B", -"I> c #BD1F1F", -"J> c #812828", -"K> c #2C2C2C", -"L> c #171616", -"M> c #9F8383", -"N> c #A76868", -"O> c #B04B4B", -"P> c #B82E2E", -"Q> c #C01616", -"R> c #C50303", -"S> c #AC0D0D", -"T> c #C20C0C", -"U> c #BB2222", -"V> c #B43D3D", -"W> c #AB5959", -"X> c #A27878", -"Y> c #9D8C8C", -"Z> c #363636", -"`> c #424242", -" , c #171717", -"., c #9D8B8B", -"+, c #A47171", -"@, c #AC5555", -"#, c #B53838", -"$, c #BD1C1C", -"%, c #C40404", -"&, c #AC1313", -"*, c #2E0000", -"=, c #631515", -"-, c #595959", -";, c #613C3C", -">, c #140000", -",, c #C00E0E", -"', c #B82B2B", -"), c #B04747", -"!, c #A86464", -"~, c #A08080", -"{, c #9B9191", -"], c #4A4A4A", -"^, c #A07F7F", -"/, c #683030", -"(, c #400000", -"_, c #B40000", -":, c #AC1717", -"<, c #A92C2C", -"[, c #A56D6D", -"}, c #550000", -"|, c #9C0707", -"1, c #B92323", -"2, c #B23D3D", -"3, c #AB5858", -"4, c #A47272", -"5, c #121212", -"6, c #5C5C5C", -"7, c #3A1616", -"8, c #B53333", -"9, c #BB1D1D", -"0, c #C20404", -"a, c #AB2020", -"b, c #B00000", -"c, c #A83636", -"d, c #A37474", -"e, c #C20000", -"f, c #230000", -"g, c #700101", -"h, c #050101", -"i, c #7F7F7F", -"j, c #7E7E7E", -"k, c #9B9090", -"l, c #9F8484", -"m, c #A47070", -"n, c #AA5959", -"o, c #B04343", -"p, c #B62C2C", -"q, c #BC1818", -"r, c #B10707", -"s, c #AA2A2A", -"t, c #A64040", -"u, c #A17B7B", -"v, c #4B2525", -"w, c #A76565", -"x, c #A07C7C", -"y, c #5A5757", -"z, c #8F8585", -"A, c #0C0B0B", -"B, c #A93434", -"C, c #A64949", -"D, c #9F8181", -"E, c #C00101", -"F, c #B81F1F", -"G, c #B23838", -"H, c #AD4D4D", -"I, c #603535", -"J, c #0C0C0C", -"K, c #898989", -"L, c #585858", -"M, c #656565", -"N, c #A73D3D", -"O, c #A45353", -"P, c #9E8585", -"Q, c #BF0404", -"R, c #9F8080", -"S, c #838383", -"T, c #A64747", -"U, c #B20000", -"V, c #A35D5D", -"W, c #9D8989", -"X, c #BD0707", -"Y, c #939393", -"Z, c #161616", -"`, c #A55050", -" ' c #B30000", -".' c #A26666", -"+' c #9C8C8C", -"@' c #BB0B0B", -"#' c #BA0F0F", -"$' c #2D2D2D", -"%' c #212121", -"&' c #555555", -"*' c #A45A5A", -"=' c #A07070", -"-' c #9B8F8F", -";' c #BA0E0E", -">' c #B81717", -",' c #606060", -"'' c #262626", -")' c #343434", -"!' c #292929", -"~' c #A26464", -"{' c #320000", -"]' c #9F7A7A", -"^' c #9A9393", -"/' c #B81111", -"(' c #B42525", -"_' c #616161", -":' c #080808", -"<' c #1D1D1D", -"[' c #686868", -"}' c #333333", -"|' c #A16E6E", -"1' c #715D5D", -"2' c #6E6B6B", -"3' c #820F0F", -"4' c #B03434", -"5' c #6F6F6F", -"6' c #878787", -"7' c #676767", -"8' c #131313", -"9' c #111111", -"0' c #9F7777", -"a' c #B50101", -"b' c #220000", -"c' c #AC4343", -"d' c #222222", -"e' c #808080", -"f' c #9E7E7E", -"g' c #B40303", -"h' c #3D0000", -"i' c #A85252", -"j' c #646464", -"k' c #565656", -"l' c #666666", -"m' c #4C4C4C", -"n' c #9D8585", -"o' c #B50505", -"p' c #300000", -"q' c #A46161", -"r' c #8C8C8C", -"s' c #0D0D0D", -"t' c #787878", -"u' c #9B8C8C", -"v' c #B50808", -"w' c #280000", -"x' c #A17070", -"y' c #1A1A1A", -"z' c #4D4D4D", -"A' c #4F4F4F", -"B' c #B50A0A", -"C' c #330000", -"D' c #520000", -"E' c #B60202", -"F' c #9E7D7D", -"G' c #060606", -"H' c #818181", -"I' c #2E2E2E", -"J' c #181818", -"K' c #232323", -"L' c #636363", -"M' c #2A2A2A", -"N' c #6B6B6B", -"O' c #4D2020", -"P' c #3E0000", -"Q' c #353030", -"R' c #B50E0E", -"S' c #3B0D0D", -"T' c #B40606", -"U' c #9C8888", -"V' c #696969", -"W' c #525252", -"X' c #A74E4E", -"Y' c #B40404", -"Z' c #B31818", -"`' c #AF2E2E", -" ) c #A94444", -".) c #B30A0A", -"+) c #A35E5E", -"@) c #B20A0A", -"#) c #9A9191", -"$) c #B22222", -"%) c #AD3838", -"&) c #A74B4B", -"*) c #B11414", -"=) c #A16C6C", -"-) c #B00F0F", -";) c #9A9292", -">) c #B12B2B", -",) c #AC4141", -"') c #A55252", -")) c #AD2323", -"!) c #9E7C7C", -"~) c #AF1414", -"{) c #AF3535", -"]) c #AA4B4B", -"^) c #A35959", -"/) c #AA3232", -"() c #B20101", -"_) c #AE1919", -":) c #AD3F3F", -"<) c #A85555", -"[) c #A26060", -"}) c #A74141", -"|) c #AF0A0A", -"1) c #AC1F1F", -"2) c #AB4949", -"3) c #A65E5E", -"4) c #A16767", -"5) c #A45050", -"6) c #AD1414", -"7) c #AB2424", -"8) c #A95252", -"9) c #A46868", -"0) c #9F6E6E", -"a) c #A15F5F", -"b) c #AA2020", -"c) c #A92B2B", -"d) c #A75C5C", -"e) c #A27171", -"f) c #9E7474", -"g) c #A82E2E", -"h) c #A73232", -"i) c #A56565", -"j) c #9D7A7A", -"k) c #AD0202", -"l) c #9D7D7D", -"m) c #A53D3D", -"n) c #A63939", -"o) c #A36F6F", -"p) c #BD0202", -"q) c #9E8383", -"r) c #AC0303", -"s) c #A34C4C", -"t) c #A44040", -"u) c #A17979", -"v) c #BC0707", -"w) c #9D8888", -"x) c #9B8585", -"y) c #AA0505", -"z) c #A05B5B", -"A) c #A34747", -"B) c #9F8282", -"C) c #BC0B0B", -"D) c #9C8D8D", -"E) c #A90707", -"F) c #A81212", -"G) c #9E6B6B", -"H) c #A14E4E", -"I) c #BB1010", -"J) c #A90808", -"K) c #A62121", -"L) c #9C7A7A", -"M) c #A05555", -"N) c #BB1515", -"O) c #A80A0A", -"P) c #A43030", -"Q) c #A80404", -"R) c #9F5C5C", -"S) c #BE0606", -"T) c #B91C1C", -"U) c #A70D0D", -"V) c #A23F3F", -"W) c #9A8C8C", -"X) c #A60B0B", -"Y) c #9E6363", -"Z) c #BD1010", -"`) c #B72626", -" ! c #A51414", -".! c #A04E4E", -"+! c #A51313", -"@! c #9D6A6A", -"#! c #BA1A1A", -"$! c #B43030", -"%! c #A41B1B", -"&! c #9E5E5E", -"*! c #A41D1D", -"=! c #9C7171", -"-! c #B33A3A", -";! c #A22222", -">! c #9C6D6D", -",! c #A22C2C", -"'! c #9C7878", -")! c #B72C2C", -"!! c #B14343", -"~! c #A12929", -"{! c #9B7C7C", -"]! c #A03B3B", -"^! c #B43737", -"/! c #AE4D4D", -"(! c #A03030", -"_! c #9A8A8A", -":! c #9E4B4B", -"~ c #BB3232", -",~ c #998B8B", -"'~ c #971E1E", -")~ c #984848", -"!~ c #BF2525", -"~~ c #B83B3B", -"{~ c #972D2D", -"]~ c #984F4F", -"^~ c #BD2E2E", -"/~ c #B54545", -"(~ c #950101", -"_~ c #973C3C", -":~ c #975656", -"<~ c #B93838", -"[~ c #B24F4F", -"}~ c #940707", -"|~ c #940B0B", -"1~ c #B74141", -"2~ c #AF5858", -"3~ c #940E0E", -"4~ c #975A5A", -"5~ c #941A1A", -"6~ c #976464", -"7~ c #B44B4B", -"8~ c #AC6262", -"9~ c #941515", -"0~ c #976969", -"a~ c #942929", -"b~ c #976B6B", -"c~ c #B15555", -"d~ c #A96B6B", -"e~ c #931C1C", -"f~ c #977777", -"g~ c #943838", -"h~ c #977272", -"i~ c #AD5E5E", -"j~ c #A67575", -"k~ c #932323", -"l~ c #988383", -"m~ c #954747", -"n~ c #910101", -"o~ c #977979", -"p~ c #AA6868", -"q~ c #A27F7F", -"r~ c #922A2A", -"s~ c #955656", -"t~ c #900202", -"u~ c #977D7D", -"v~ c #A77171", -"w~ c #923131", -"x~ c #900E0E", -"y~ c #966565", -"z~ c #8F0404", -"A~ c #A47B7B", -"B~ c #923838", -"C~ c #901C1C", -"D~ c #967474", -"E~ c #8E0606", -"F~ c #D00303", -"G~ c #923F3F", -"H~ c #902B2B", -"I~ c #978484", -"J~ c #8E0808", -"K~ c #924646", -"L~ c #913A3A", -"M~ c #8C0404", -"N~ c #8D0A0A", -"O~ c #9D8D8D", -"P~ c #CE0B0B", -"Q~ c #CA1616", -"R~ c #924D4D", -"S~ c #924949", -"T~ c #8C1010", -"U~ c #8C0B0B", -"V~ c #CD1010", -"W~ c #C72020", -"X~ c #925454", -"Y~ c #935858", -"Z~ c #8D1B1B", -"`~ c #8C1111", -" { c #C32929", -".{ c #925B5B", -"+{ c #946767", -"@{ c #8D2828", -"#{ c #8C1919", -"${ c #C91C1C", -"%{ c #C03434", -"&{ c #936262", -"*{ c #957777", -"={ c #8E3737", -"-{ c #8B1F1F", -";{ c #978686", -">{ c #8F4646", -",{ c #8C2626", -"'{ c #C22F2F", -"){ c #B94747", -"!{ c #947070", -"~{ c #989494", -"{{ c #915555", -"]{ c #8C2D2D", -"^{ c #BF3939", -"/{ c #B55050", -"({ c #870B0B", -"_{ c #926464", -":{ c #8C3434", -"<{ c #B25A5A", -"[{ c #957E7E", -"}{ c #881A1A", -"|{ c #947373", -"1{ c #8D3B3B", -"2{ c #B84C4C", -"3{ c #AF6464", -"4{ c #8A2929", -"5{ c #968181", -"6{ c #840101", -"7{ c #8D4242", -"8{ c #B45656", -"9{ c #AB6D6D", -"0{ c #978C8C", -"a{ c #8B3838", -"b{ c #840808", -"c{ c #8E4949", -"d{ c #B15F5F", -"e{ c #978F8F", -"f{ c #830404", -"g{ c #8D4747", -"h{ c #841010", -"i{ c #8E5050", -"j{ c #A38181", -"k{ c #830A0A", -"l{ c #8F5757", -"m{ c #851818", -"n{ c #8F5858", -"o{ c #A97373", -"p{ c #916666", -"q{ c #862626", -"r{ c #8F5E5E", -"s{ c #A67B7B", -"t{ c #D70505", -"u{ c #821414", -"v{ c #937575", -"w{ c #883535", -"x{ c #906565", -"y{ c #A38282", -"z{ c #D50C0C", -"A{ c #821919", -"B{ c #958484", -"C{ c #8A4444", -"D{ c #916C6C", -"E{ c #D21414", -"F{ c #831F1F", -"G{ c #7F0505", -"H{ c #8C5353", -"I{ c #927373", -"J{ c #D70909", -"K{ c #CF1B1B", -"L{ c #842424", -"M{ c #8F6262", -"N{ c #937A7A", -"O{ c #D70C0C", -"P{ c #CD2222", -"Q{ c #842B2B", -"R{ c #811B1B", -"S{ c #917171", -"T{ c #948181", -"U{ c #D31414", -"V{ c #C92B2B", -"W{ c #853232", -"X{ c #832828", -"Y{ c #947E7E", -"Z{ c #7C0303", -"`{ c #968888", -" ] c #D01D1D", -".] c #C53535", -"+] c #863939", -"@] c #853737", -"#] c #968989", -"$] c #7B0707", -"%] c #CC2727", -"&] c #C13F3F", -"*] c #864040", -"=] c #884646", -"-] c #7B0A0A", -";] c #C83131", -">] c #BD4949", -",] c #874747", -"'] c #8A5555", -")] c #7C1414", -"!] c #790404", -"~] c #C43A3A", -"{] c #B95252", -"]] c #884E4E", -"^] c #8D6464", -"/] c #7F2424", -"(] c #7A0B0B", -"_] c #C04444", -":] c #B55C5C", -"<] c #895555", -"[] c #907373", -"}] c #823333", -"|] c #7A1313", -"1] c #BC4E4E", -"2] c #B16565", -"3] c #8B5C5C", -"4] c #750101", -"5] c #938181", -"6] c #854242", -"7] c #7B1919", -"8] c #B85757", -"9] c #AC6F6F", -"0] c #8C6363", -"a] c #760808", -"b] c #885151", -"c] c #7C2020", -"d] c #B46161", -"e] c #8D6A6A", -"f] c #771010", -"g] c #8B6161", -"h] c #7D2828", -"i] c #E00101", -"j] c #A48282", -"k] c #8F7171", -"l] c #791818", -"m] c #8E7070", -"n] c #7E2E2E", -"o] c #DF0505", -"p] c #A28787", -"q] c #917878", -"r] c #7C2626", -"s] c #927F7F", -"t] c #7F3535", -"u] c #A67E7E", -"v] c #DE0A0A", -"w] c #803C3C", -"x] c #A18888", -"y] c #DC0F0F", -"z] c #938484", -"A] c #710202", -"B] c #824444", -"C] c #710505", -"D] c #824343", -"E] c #DA1414", -"F] c #948787", -"G] c #710606", -"H] c #865353", -"I] c #741313", -"J] c #834A4A", -"K] c #E30202", -"L] c #D71A1A", -"M] c #958B8B", -"N] c #710A0A", -"O] c #8A6262", -"P] c #782222", -"Q] c #855252", -"R] c #DF0B0B", -"S] c #D32323", -"T] c #710D0D", -"U] c #8E7171", -"V] c #7B3131", -"W] c #865858", -"X] c #DB1515", -"Y] c #CF2D2D", -"Z] c #711010", -"`] c #6D0303", -" ^ c #917E7E", -".^ c #7F4141", -"+^ c #885F5F", -"@^ c #D71F1F", -"#^ c #CA3737", -"$^ c #711414", -"%^ c #6D0707", -"&^ c #948989", -"*^ c #835050", -"=^ c #8A6767", -"-^ c #D32828", -";^ c #C64141", -">^ c #711717", -",^ c #6D0B0B", -"'^ c #875F5F", -")^ c #C14A4A", -"!^ c #721E1E", -"~^ c #701515", -"{^ c #8B6E6E", -"]^ c #8E7474", -"^^ c #C93B3B", -"/^ c #BD5454", -"(^ c #742525", -"_^ c #742424", -":^ c #907D7D", -"<^ c #907C7C", -"[^ c #C44646", -"}^ c #B85E5E", -"|^ c #762C2C", -"1^ c #793434", -"2^ c #670101", -"3^ c #928282", -"4^ c #C04F4F", -"5^ c #B36767", -"6^ c #783333", -"7^ c #7D4343", -"8^ c #969191", -"9^ c #690A0A", -"0^ c #BB5959", -"a^ c #AE7171", -"b^ c #793A3A", -"c^ c #6C1616", -"d^ c #660202", -"e^ c #958E8E", -"f^ c #B66262", -"g^ c #E90101", -"h^ c #AA7979", -"i^ c #7B4141", -"j^ c #866161", -"k^ c #702222", -"l^ c #680808", -"m^ c #B16C6C", -"n^ c #A68080", -"o^ c #7D4848", -"p^ c #8B7070", -"q^ c #680D0D", -"r^ c #AC7676", -"s^ c #E80606", -"t^ c #A28888", -"u^ c #7F4F4F", -"v^ c #793F3F", -"w^ c #691212", -"x^ c #979393", -"y^ c #A77F7F", -"z^ c #E70808", -"A^ c #9F8F8F", -"B^ c #815656", -"C^ c #7E4E4E", -"D^ c #6A1717", -"E^ c #E60B0B", -"F^ c #835D5D", -"G^ c #630505", -"H^ c #6C1D1D", -"I^ c #EB0404", -"J^ c #E31212", -"K^ c #856464", -"L^ c #886C6C", -"M^ c #6D2222", -"N^ c #E70B0B", -"O^ c #DE1C1C", -"P^ c #886B6B", -"Q^ c #6C2222", -"R^ c #8E7B7B", -"S^ c #6E2828", -"T^ c #E41313", -"U^ c #D92525", -"V^ c #8A7272", -"W^ c #713232", -"X^ c #723434", -"Y^ c #E01A1A", -"Z^ c #D52F2F", -"`^ c #8C7878", -" / c #774141", -"./ c #774343", -"+/ c #DC2121", -"@/ c #CF3939", -"#/ c #8E7D7D", -"$/ c #7C5151", -"%/ c #D82A2A", -"&/ c #CA4242", -"*/ c #908383", -"=/ c #846464", -"-/ c #836363", -";/ c #D33434", -">/ c #C54C4C", -",/ c #928888", -"'/ c #8A7474", -")/ c #8C7979", -"!/ c #C05656", -"~/ c #948D8D", -"{/ c #918585", -"]/ c #C84747", -"^/ c #BA5F5F", -"// c #C35050", -"(/ c #B56969", -"_/ c #BE5A5A", -":/ c #B07373", -" ", -" , ' ", -" ) ! ", -" ~ { ", -" ] ^ ", -" / ( ", -" _ : ", -" + < [ ", -" } | 1 ", -" 2 3 4 ", -" 5 6 7 ", -" 8 9 0 ", -" a b c + ", -" d e e f ", -" g h h i ", -" j h h k ", -" l m m n ", -" o m m p ", -" q r r s ", -" t u u v ", -" w u u x ", -" y z z A ", -" + B z z C ", -" D E F F G ", -" # H I I J ", -" K L I I M ", -" N O P P Q ", -" R P P P S + ", -" T U U U V K ", -" W U U U X Y ", -" Z ` ` ` ... ", -" +.` ` ` @.#. ", -" $.%.%.%.%.&. ", -" *.=.=.=.=.-. ", -" ;.=.=.=.=.>. ", -" ,.'.'.'.'.). ", -" !.'.'.'.'.~. ", -" {.].].].].^. ", -" /.].].].].(. ", -" _.:.:.:.:.<. ", -" [.}.}.}.}.|. ", -" 1.}.}.}.}.2. ", -" 3.4.4.4.4.4.5.6. ", -" 7.4.4.4.4.4.8.3. ", -" 9.0.0.0.0.0.a.b. ", -" c.0.0.0.0.0.d.7. ", -" e.f.f.f.f.f.g.h. ", -" i.j.j.j.j.j.j.k. ", -" l.j.j.j.j.j.j.m. ", -" n.o.o.o.o.o.o.p. ", -" q.o.o.o.o.o.o.r. ", -" s.t.t.t.t.t.t.u. ", -" v.w.w.w.w.w.w.x. ", -" y.w.w.w.w.w.w.z. ", -" A.B.B.B.B.B.B.C. ", -" D.B.B.B.B.B.B.E. ", -" + F.G.G.G.G.G.G.H. ", -" I.J.G.G.G.G.G.G.K.6. ", -" L.M.N.N.N.N.N.N.O.P. ", -" Q.R.N.N.N.N.N.N.S.T. ", -" U.V.W.W.W.W.W.W.X.Y. ", -" Z.`.`.`.`.`.`.`. +.+ ", -" ++`.`.`.`.`.`.`.`.@+ ", -" #+$+$+$+$+$+$+$+$+U. ", -" %+$+$+$+$+$+$+$+$+&+ ", -" *+=+=+=+=+=+=+=+=+-+ ", -" ;+=+=+=+=+=+=+=+=+>+ ", -" ,+'+'+'+'+'+'+'+'+)+ ", -" !+~+~+~+~+~+~+~+~+{+ ", -" ]+~+~+~+~+~+~+~+~+^+ ", -" /+(+(+(+(+(+(+(+(+_+ ", -" 6.:+(+(+(+(+(+(+(+(+<+ ", -" T.[+}+}+}+}+}+}+}+}+|+ ", -" 1+2+}+}+}+}+}+}+}+}+3+ ", -" 4+5+6+6+6+6+6+6+6+6+7+ ", -" 8+9+0+0+0+0+0+0+0+0+a+ ", -" b+0+0+0+0+0+0+0+0+0+c+6. ", -" d+e+e+e+e+e+e+e+e+e+e+1+ ", -" f+e+e+e+e+e+e+e+e+e+e+g+ ", -" h+i+i+i+i+i+i+i+i+i+i+j+ ", -" k+l+l+l+l+l+l+l+l+l+l+m+ ", -" n+l+l+l+l+l+l+l+l+l+l+o+ ", -" + p+q+r+s+t+u+v+w+x+y+z+ A+B+B+B+B+B+B+B+B+B+B+C+ + D+E+F+G+H+I+J+K+L+M+N+ ", -" O+P+Q+R+S+T+U+V+W+X+M+ Y+B+B+B+B+B+B+B+B+B+B+Z+ `+ @.@+@@@#@$@%@&@*@=@+ ", -" N+-@;@>@,@#@,@'@)@!@N+ ~@{@{@{@{@{@{@{@{@{@{@]@ ^@/@(@_@:@:@<@[@}@|@ ", -" |@1@2@3@:@:@3@4@5@6@ 7@{@{@{@{@{@{@{@{@{@{@8@ + M+9@0@a@a@a@<@4@b@+ ", -" c@d@e@f@a@a@a@g@h@i@ 6.j@k@k@k@k@k@k@k@k@k@k@l@ m@n@o@p@p@p@p@q@r@z+ ", -" s@t@u@p@p@p@v@w@d@ x@y@k@k@k@k@k@k@k@k@k@k@z@ A@B@C@D@D@D@D@E@F@m@ ", -" G@H@I@D@D@D@D@J@K@+ L@M@N@N@N@N@N@N@N@N@N@N@O@ M+P@Q@R@R@R@R@S@T@ ", -" T@U@R@R@R@R@R@V@M+ W@X@Y@Y@Y@Y@Y@Y@Y@Y@Y@Y@Z@ `@ #.#+#+#+#+#@###O+ ", -" 6@$#%#R@R@R@R@%#&#c@ *#=#Y@Y@Y@Y@Y@Y@Y@Y@Y@Y@-# ;#>#,#,#,#,#,#'#)# ", -" !#~#+#+#+#+#+#{#]# ^#/#/#/#/#/#/#/#/#/#/#/#(#_# :#<#[#[#[#[#[#}#|#c@ ", -" 1#2#,#,#,#,#,#3#4#+ 5#/#/#/#/#/#/#/#/#/#/#/#X@6# 7#8#9#9#9#9#9#0#a#c@ ", -" ;#b#[#[#[#[#[#c#d#+ e#f#f#f#f#f#f#f#f#f#f#f#g#h# i#j#9#9#9#9#9#k#a# ", -" l#m#9#9#9#9#9#9#n#o# p#f#f#f#f#f#f#f#f#f#f#f#q#r# s#t#u#u#u#u#u#u#v#+ ", -" O+w#u#u#u#u#u#u#x#y# z#A#A#A#A#A#A#A#A#A#A#A#B#C# + D#E#E#E#E#E#E#F#G# ", -" c@H#E#E#E#E#E#E#E#I# J#K#K#K#K#K#K#K#K#K#K#K#K#e# L#M#N#N#N#N#N#N#M#O# ", -" P#Q#N#N#N#N#N#N#R#S# T#K#K#K#K#K#K#K#K#K#K#K#K#U# V#W#W#W#W#W#W#W#X#N+ ", -" z+Y#W#W#W#W#W#W#W#Z# `# $ $ $ $ $ $ $ $ $ $ $ $.$ +$@$#$#$#$#$#$#$#$$$ ", -" %$#$#$#$#$#$#$#$&$*$ =$ $ $ $ $ $ $ $ $ $ $ $ $-$ ;$>$>$>$>$>$>$>$,$z+ ", -" '$,$>$>$>$>$>$>$>$)$O+ !$~$~$~$~$~$~$~$~$~$~$~$~${$ ]$^$^$^$^$^$^$^$^$]$ ", -" /$^$^$^$^$^$^$^$^$($ _$~$~$~$~$~$~$~$~$~$~$~$~$:$ <$[$[$[$[$[$[$[$[$}$`@ ", -" |$^$^$^$^$^$^$^$^$1$ 2$3$3$3$3$3$3$3$3$3$3$3$3$4$ 6@5$6$6$6$6$6$6$6$5$7$ ", -" O+8$[$[$[$[$[$[$[$[$9$ 0$a$a$a$a$a$a$a$a$a$a$a$a$b$ c$d$d$d$d$d$d$d$d$e$ ", -" f$6$6$6$6$6$6$6$6$6$g$ h$a$a$a$a$a$a$a$a$a$a$a$a$i$ j$k$k$k$k$k$k$k$k$l$ ", -" m$d$d$d$d$d$d$d$d$d$n$ 6.o$p$p$p$p$p$p$p$p$p$p$p$p$q$ r$k$k$k$k$k$k$k$k$s$6@ ", -" t$k$k$k$k$k$k$k$k$k$u$ v$p$p$p$p$p$p$p$p$p$p$p$p$p$w$x@ x$y$y$y$y$y$y$y$y$z$A$ ", -" B$y$y$y$y$y$y$y$y$y$C$ D$E$E$E$E$E$E$E$E$E$E$E$E$E$F$G$ H$I$J$J$J$J$J$J$J$J$K$L$ ", -" M$J$J$J$J$J$J$J$J$J$N$L$ O$P$P$P$P$P$P$P$P$P$P$P$P$P$Q$R$ S$T$T$T$T$T$T$T$T$T$T$U$ ", -" V$T$T$T$T$T$T$T$T$T$T$W$N+ X$P$P$P$P$P$P$P$P$P$P$P$P$P$Y$Z$ `$ %.%.%.%.%.%.%.%.%.%+%L$ ", -" @%.%.%.%.%.%.%.%.%.%.%#%$%%%&%*%=% -%;%;%;%;%;%;%;%;%;%;%;%;%;%>%,% '%)%!%!%!%!%!%!%!%!%!%!%~%{% ", -" ]%!%!%!%!%!%!%!%!%!%^%/%(%_%_%_%:%<%[% }%;%;%;%;%;%;%;%;%;%;%;%;%;%;%|% c@1%2%#%#%#%#%#%#%#%#%#%#%#%3%`@ ", -" 4%5%#%#%#%#%#%#%#%6%7%_%_%_%_%_%_%_%8%=% 9%0%0%0%0%0%0%0%0%0%0%0%0%0%0%a% {%b%c%d%d%d%d%d%d%d%d%d%d%d%d%e% ", -" f%d%d%d%d%d%d%g%h%_%_%_%_%_%_%_%_%_%i%j% k%0%0%0%0%0%0%0%0%0%0%0%0%0%0%l% m%n%n%n%n%n%o% =%n%n%n%n%n%n%n%n%n%p%q%r%s%s%s%s%s%s%s%s%s%s%s%s%s%t%u% ", -" v%w%d%d%d%d%d%~+_%_%_%_%_%_%_%_%_%_%x%y% z%A%A%A%A%A%A%A%A%A%A%A%A%A%A%B% C%_%_%_%_%_%D% j%E%F%G%_%_%_%_%_%_%_%_%_%_%_%_%H%I%}.J%K%K%K%K%K%K%K%K%K%K%L% ", -" + M%s%s%s%s%s%N%_%_%_%_%_%_%_%_%_%_%_%O%P%`@ Q%A%A%A%A%A%A%A%A%A%A%A%A%A%A%R% C%_%_%_%_%_%D% S%T%U%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%V%A%W%W%W%W%W%W%W%W%X%Y% ", -" 4%Z%K%K%K%K%`%_%_%_%_%_%_%_%_%_%_%_%f. &.&+&@& #&$&$&$&$&$&$&$&$&$&$&$&$&$&$&%& C%_%_%_%_%_%D% &&*&_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%=&P$-&-&-&-&-&-&;&>& ", -" ,&'&W%W%W%)&_%_%_%_%_%_%_%_%_%_%_%B+W%W%W%!&~&{&N+ ]&^&^&^&^&^&^&^&^&^&^&^&^&^&^&/& C%_%_%_%_%_%D% (&_&_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%:&<&-&-&-&-&-&[&`@ ", -" }&|&-&-&l+_%_%_%_%_%_%_%_%_%_%1&2&-&-&-&-&-&-&3&4&5&6&+ 7&^&^&^&^&^&^&^&^&^&^&^&^&^&^&8& C%_%_%_%_%_%D% 9&0&_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%a&b&b&b&b&c&N+ ", -" d&e&b&f&I%_%_%_%_%_%_%_%_%_%r g&b&b&b&b&b&b&b&b&b&h&i&j&Y%k& l&m&m&m&m&m&m&m&m&m&m&m&m&m&m&n& C%_%_%_%_%_%D% *%_%_%_%_%_%_%o&V%p&p&p&p&p&p&p&p&p&q&H%_%_%_%_%_%r&s&g&g&t&u& ", -" P%v&g&w&x&_%_%_%_%_%_%H%)&y&g&g&g&g&g&g&g&g&g&g&g&g&g&z&A&B&C&D& x@E&m&m&m&m&m&m&m&m&m&m&m&m&m&m&]&+ C%_%_%_%_%_%D% F&G&H&I&_%_%_%_%_%r&J&K&L&L&L&L&L&L&L&L&s&M&}.H%_%_%_%_%(%N&O&P&k& ", -" Q&R&S&2&T&1&_%_%_%U&'+f&S&S&S&S&S&S&S&S&S&S&S&S&S&S&S&S&S&S&V&A&W&X&Y&+ Z&`& * * * * * * * * * * * * * *.*6. C%_%_%_%_%_%D% +*@*#*$*%*&***=*_%_%_%_%_%z ************************s&q&_%_%_%_%H%-*;*`@ ", -" `@>*,***'*)* *N&g%**************************************************!*~*H&{*@&c@ ]*^* * * * * * * * * * * * * * */*(* C%_%_%_%_%_%D% N+_*:*<*[*}*g%g%g%g%g%g%|*_%_%_%_%_%N.g%g%g%g%g%g%g%g%g%g%g%g%g%I%_%_%_%_%_%1* ", -" 2*3*g%g%g%g%g%g%g%g%g%g%g%g%g%g%g%g%g%g%g%g%g%g%g%g%g%g%g%g%g%g%g%g%g%g%4*5*6*;*{*4%c@ 7*8*9*9*9*9*9*9*9*9*9*9*9*9*9*9*0*L@ C%_%_%_%_%_%D% a*Y&b*c*d*e*f*g*g*g*g*g*g*g*g*g*g*h*i*i*i*i*i*`.g*g*g*g*g*g*g*g*g*g*g*g*g*j*_%_%_%_%_%k* ", -" l*m*n*o*(+(+(+(+(+(+p*g*g*g*g*g*g*g*g*g*g*g*g*g*g*g*g*g*L&y&y&y&y&y&y&y&y&y&y&f&g*q*r*3*s*t*2*u*+ v*w*x*x*x*x*x*x*x*x*x*x*x*x*x*x*y*z* C%_%_%_%_%_%D% a*A*B*C*D*E*F*f&f&f&f&f&f&f&f&f&f&f&f&f&f&f&G*H*H*H*H*H*M&f&f&f&f&f&f&f&f&f&f&f&f&f&j*_%_%_%_%_%k* ", -" I*_%_%_%_%_%_%_%_%_%=+f&f&f&f&f&f&f&f&f&f&f&f&f&J*j.K*L*M*:&:&:&:&:&:&:&:&:&:&q&N*O*B+P*f&f&Q*R*S*T*U*V*W*6& X*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*w*Y* C%_%_%_%_%_%D% `@Z*`* =.=+=@=#=L&L&L&L&L&L&L&L&L&L&L&L&L&L&L&L&L&L&L&L&L&L&L&L&L&L&L&L&L&L&L&L&L&L&L&L&L&L&L&L&I%_%_%_%_%_%k* ", -" I*_%_%_%_%_%_%_%_%_%$+f&f&f&f&f&f&f&f&f&f&f&$=%=&=_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%r&i+'*f&f&f&f&f&f&f&Q**=D*==-=;=>=+*`@j%=%,='=)=)=)=)=)=)=)=)=)=)=!=~={= 9&]=)=)=)=)=)= o%)=)=)=)=)=^= /=(=(=(=(=(=(=(=(=(=(=(=;%w.0.0.0._=)=)=)=)=)=)=)='=,=o%j% C%_%_%_%_%_%D% m%'=)=)=)=)=)=:= N+6&<=[=}=|=.*1=p$p$p$p$p$p$p$p$p$p$2=3=y&s&s&s&s&s&s&s&s&s&s&s&s&s&s&s&s&s&s&s&s&s&s&s&s&s&s&s&s&s&s&s&s&4= =5=_%_%_%_%_%k* ", -" I*_%_%_%_%_%_%_%_%_%$+L&L&L&L&L&L&L&L&L&L&6=7=_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%8=9=0=L&L&L&L&L&L&L&s&s&s&s&s&a=b=c=d=:%_%_%_%_%_%_%_%_%_%_%_%_%_%e=f=g=9& h=G%_%_%_%_%_& i=_%_%_%_%_%j= k=(=(=(=(=(=(=(=(=(=(=$&I%_%_%_%_%_%_%_%_%_%_%_%_%_%_%l=m=n= C%_%_%_%_%_%D% S%o=_%_%_%_%_%_&E% p=q=r=s=t=u=v=w=x='*x*y=z=_%_%_%_%_%_%_%_%_%_%_%_%_%(%A=A#K&'*'*'*'*'*'*'*'*'*'*'*'*'*'*'*'*'*'*'*'*'*'*'*'*'*'*'*'*b=B=q= C=_%_%_%_%_%k* ", -" D=_%_%_%_%_%_%_%_%_%E=F=G=s&s&s&s&s&s&s&2&H=_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%I=K&s&s&s&s&s&s&s&'*'*'*'*'*j.&=_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%J=K= h=G%_%_%_%_%_& i=_%_%_%_%_%j= L=M=M=M=M=M=M=M=M=M=M==+H%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%x%N=&& C%_%_%_%_%_%D% j%O=_&_%_%_%_%_%P=Q=R=S=T=U=V=W='*'*'*'*'*X=u (%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%8=O*<&y&y&y&y&y&y&y&y&y&y&y&y&y&y&y&y&y&y&y&y&y&y&y&y&y&Y=Z=`= C=_%_%_%_%_%k* ", -" D=_%_%_%_%_%_%_%_%_% -+ .-+-x='*'*'*'*'*@-_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%H%4.'*'*'*'*'*'*y&y&y&y&y&`.8=_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%#-$-+ h=G%_%_%_%_%_& i=_%_%_%_%_%j= %-M=M=M=M=M=M=M=M=M=M='._%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_&N= C%_%_%_%_%_%D% F&&-*-_&_%_%_%_%_%_%=---y&y&y&y&y&y&y&y&y&y&;-u H%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%>-P*;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-,-'-)- C=_%_%_%_%_%k* ", -" i%_%_%_%_%_%_%_%_%_% - !-~-{-]-y&2=H%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%z=3=y&y&y&y&y&y&y&y&y&^-1&_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%/-(-_-:-<-[-}-|-1-2-3-4-G%_%_%_%_%_& i=_%_%_%_%_%j= 5-6-6-6-6-6-6-6-6-6-6-t._%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%x%7- C%_%_%_%_%_%8-9-0-a-b-c-d-e-A#f-_%_%_%_%_%_%p&g-;-;-;-;-;-;-;-;-;-;-;-m&8=_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%o.;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-;-h-i-j-+ C=_%_%_%_%_%k* ", -" i%_%_%_%_%_%_%_%_%_% - p=k-l-m-_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%G.;-;-;-;-;-;-;-;-;-T&_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%=&n-;-;-;-;-;-;-;-;-h-o-p-_%_%_%_%_&q-r-2-6&p= i=_%_%_%_%_%j= s-2=2=2=2=2=2=2=2=2=2=a$t-_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%u-j%+ +*q=v-w-x-y-z-A-B-_%_%_%_%_%/-P*P*P*P*P*P*M=C-_%_%_%_%_%_%7%D-P*P*P*P*P*P*P*P*P*P*P*P*K*_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%r&--P*P*P*P*P*P*P*P*P*P*P*P*P*P*P*E-F-G-u* H-_%_%_%_%_%l* ", -" i%_%_%_%_%_%_%_%_%_% - I-_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%J-P*P*P*P*P*P*P*P*K-L-_%_%_%_%_%(%M-N-N%N%N%N%N%N%N%N%O-1&_%_%_%_%_%_%N.P*P*P*P*P*P*P*P*P*J*M*_%_%_%_%H%P*P-Q-R-S-F-T-U-V-W-X-Y-Z-`-_%_%_%_%_%j= ;2=2=2=2=2=2=2=2=2=2=2=B.y=.;.;.;+;@;@;@;@;@;#;$;%;&;_%_%_%_%_%*;=;-;;;>;,;K&K&K&K&K&f._%_%_%_%_%';K&K&K&K&K&^-h%_%_%_%_%_%_%);p$K&K&K&K&K&K&K&K&K&K&K&K&!;(%_%_%_%_%_%H%~;N-N-N-N-N-N-N-N-N-y=q&_%_%_%_%_%H%E$K&K&K&K&K&K&K&K&K&K&K&K&K&;;{;];k& ^;/;_%_%_%_%e=(; ", -" _;_%_%_%_%_%_%_%_%_% - [%:%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%=-K&K&K&K&K&K&K&K&n-);_%_%_%_%_%N@X=K&K&K&K&K&K&K&K&K&X=x*t-_%_%_%_%_%:;K&K&K&K&K&K&K&K&K&J*M*_%_%_%_%H%K&K&K&K&K&K&K&K&K&K&K&K&<;[;_%_%_%_%_%j= };J&J&J&J&J&J&J&J&J&J&J&J&J&J&J&J&|; p=1;2;3;4;o&_%_%_%_%_%(=X=X=X=X=X=X=X=X=X=f._%_%_%_%_%';X=X=X=X=5;H=_%_%_%_%_%_%f-~+X=X=X=X=X=X=X=X=X=X=X=X=X=6-_%_%_%_%_%H%].M&X=X=X=X=X=X=X=X=X=X=6;7;_%_%_%_%_%4.X=X=X=X=X=X=X=X=X=X=2;8;Y-+* n%9;9;9;9;9;9;9;0;a;_%_%_%_%_%l==% ", -" _;_%_%_%_%_%_%_%_%_% - K=b;_%_%_%_%_%_%_%_%i*m %.%.%.%.%.%.%.%.c;_%_%_%_%_%_%_%_%_%x&X=X=X=X=X=X=X=X=d;H%_%_%_%_%M*X=X=X=X=X=X=X=X=X=X=X=X=X=e;_%_%_%_%_%/%X=X=X=X=X=X=X=X=X=^%M*_%_%_%_%H%X=X=X=X=X=X=X=X=X=X=X=X=X=P$_%_%_%_%_%j= + f;J&J&J&J&J&J&J&J&J&J&J&J&J&J&J&J&g; `@h;J%J%$=N*_%_%_%_%_%A#J%J%J%J%J%J%J%J%J%0._%_%_%_%_%';J%J%J%K-K*_%_%_%_%_%_%H%` J%J%J%J%J%J%J%J%J%J%J%J%J%J% $_%_%_%_%_%i;K-J%J%J%J%J%J%J%J%J%J%J%J%@-_%_%_%_%_%%=J%J%J%J%J%J%j;k;l;m;a* *%_%_%_%_%_%_%_%_%_%_%_%_%_%_%m= ", -" _;_%_%_%_%_%_%_%_%_% - n;b;_%_%_%_%_%_%_%_%o;p;q;r;J%J%J%J%J%J%^&_%_%_%_%_%_%_%_%_%p&J%J%J%J%J%J%J%J%6%H%_%_%_%_%s;J%J%J%J%J%J%J%J%J%J%J%J%J%B._%_%_%_%_%t;J%J%J%J%J%J%J%J%J%g-:&_%_%_%_%H%J%J%J%J%J%J%J%J%J%J%J%J%J%E$_%_%_%_%_%j= u;v;w;w;w;w;w;w;w;w;w;w;w;w;w;w;w;w;x; + y;0=0=0=7=_%_%_%_%_%/#0=0=0=0=0=0=0=0=0=0._%_%_%_%_%z;0=0=$=T&_%_%_%_%_%_%_%A;M&0=0=0=0=0=0=0=0=0=0=0=0=0=0=A#_%_%_%_%_%B;0=0=0=0=0=0=0=0=0=0=0=0=0=a&_%_%_%_%_%C;0=0=0=D;E;F;G;)- *%_%_%_%_%_%_%_%_%_%_%_%_%_%e=n= ", -" _;_%_%_%_%_%_%_%_%_% - n;b;_%_%_%_%_%_%_%_%:%S%+ H;I;J;K;0=0=0=$&_%_%_%_%_%_%_%_%_%p&0=0=0=0=0=0=0=0=L;H%_%_%_%_%s;0=0=0=0=0=0=0=0=0=0=0=0=0=B._%_%_%_%_%t;0=0=0=0=0=0=0=0=0=M;:&_%_%_%_%H%0=0=0=0=0=0=0=0=0=0=0=0=0=E$_%_%_%_%_%j= z*N;O;O;O;O;O;O;O;O;O;O;O;O;O;O;O;O;P; Q;M&M&M&7=_%_%_%_%_%Y@M&M&M&M&M&M&M&M&M&4._%_%_%_%_%z;M&M&].8=_%_%_%_%_%_%y=R;M&M&M&M&M&M&M&M&M&M&M&M&M&M&M&A#_%_%_%_%_%S;M&M&M&M&M&M&M&M&M&M&M&M&M&a&_%_%_%_%_%C;T;U;V;W;X; *%_%_%_%_%_%_%_%_%_%_%_%_%_%Y; ", -" Z;_%_%_%_%_%_%_%_%_% - n;b;_%_%_%_%_%_%_%_%:%S% )-`; >.>+>_%_%_%_%_%_%_%_%_%p&M&M&M&M&M&M&M&M&)*H%_%_%_%_%L-M&M&M&M&M&M&M&M&M&M&M&M&M&B._%_%_%_%_%t;M&M&M&M&M&M&M&M&M&H*:&_%_%_%_%H%M&M&M&M&M&M&M&M&M&M&M&M&M&p$_%_%_%_%_%j= @>#>O;O;O;O;O;O;O;O;O;O;O;O;O;O;O;O;$> %>$=$=$=7=_%_%_%_%_%N@$=$=$=$=$=$=$=$=$=4._%_%_%_%_%T&$=l+i*_%_%_%_%_%_%H=M;$=$=$=$=$=$=$=$=$=$=$=$=$=$=$=$=f#_%_%_%_%_%S;$=$=$=$=$=$=$=$=$=$=$=$=$=e;_%_%_%_%_%&>*>`@ *%_%_%_%_%_%_%_%_%_%_%_%_%_%e=n= ", -" 0;_%_%_%_%_%_%_%_%_% - n;b;_%_%_%_%_%_%_%_%:%S% =>_%_%_%_%_%_%_%_%_%p&M&M&M&M&M&$=$=$=)*H%_%_%_%_%L-$=$=$=$=$=$=$=$=$=$=$=$=$=w._%_%_%_%_%t;$=$=$=$=$=$=$=$=$=6=:&_%_%_%_%H%$=$=$=$=$=$=$=$=$=$=$=$=$=a$_%_%_%_%_%j= ->;>D-D-D-D-D-D-D-D-D-D-D-D-D-D-D-D->> ,>$=$=$=7=_%_%_%_%_%N@$=$=$=$=$=$=$=$=$=}._%_%_%_%_%T&$&z=_%_%_%_%_%_%p&^-$=$=$=$=$=$=$=$=$=$=$=$=$=$=$=$=$=/#_%_%_%_%_%S;K-K-K-K-K-K-K-K-K-K-K-K-'>)>_%_%_%_%_%!> *%_%_%_%_%_%_%_%_%_%_%_%_%_%_%u- ", -" 0;_%_%_%_%_%_%_%_%_% - n;b;_%_%_%_%_%_%_%_%:%S% !=_%_%_%_%_%_%_%_%_%p&$=$=$=$=$=K-K-K-~>H%_%_%_%_%L-K-K-K-K-K-K-K-K-K-K-K-K-K-w._%_%_%_%_%>-K-K-K-K-K-K-K-K-K-n-:&_%_%_%_%H%K-K-K-K-K-K-K-K-K-K-K-K-K-a$_%_%_%_%_%j= {>]>D-D-D-D-D-D-D-D-D-D-D-0%4.|*^>^>/>!>!>!>!>!>(>C;=*'.p&_%_%_%_%_%k@K-K-K-K-K-K-K-K-K-:._%_%_%_%_%y=_>_%_%_%_%_%_%:&6-K-K-K-K-K-K-K-K-K-K-K-K-K-K-K-K-K-K-Y@_%_%_%_%_%S;<&<&<&<&<&<&<&<&<&:><>[>}>|>_%_%_%_%_%!> n%N=N=N=N=N=N=9;0;1>_%_%_%_%_%l=o% ", -" 0;_%_%_%_%_%_%_%_%_% - n;b;_%_%_%_%_%_%_%_%:%S% !=_%_%_%_%_%_%_%_%_%2>3>4>K-K-K-K-<&<&D-H%_%_%_%_%L-<&<&<&<&<&<&<&<&<&<&<&<&<&t._%_%_%_%_%>-<&<&<&<&<&<&<&<&<&n-:&_%_%_%_%H%<&<&<&<&<&<&<&<&<&<&<&<&<&3$_%_%_%_%_%j= 5>~>~>~>~>~>~>~>~>~>~>$&6>7>_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%{@<&<&<&<&<&<&<&<&<&:._%_%_%_%_%H%_%_%_%_%_%_%=&A#<&<&<&<&<&<&<&<&<&<&<&<&<&<&<&<&<&<&<&Y@_%_%_%_%_%B;----------8>9>0>a>q= b>_%_%_%_%_%!> ,=/;_%_%_%_%e=,= ", -" 0;_%_%_%_%_%_%_%_%_% - n;b;_%_%_%_%_%_%_%_%:%S% !=_%_%_%_%_%_%_%_%_%c>p=d>e>f>g>h>----O;H%_%_%_%_%L---------------------------t._%_%_%_%_%>-------------------6;:&_%_%_%_%H%--------------------------~$_%_%_%_%_%j= i>~>~>~>~>~>~>~>~>~> $h%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%{@------------------]._%_%_%_%_%_%_%_%_%_%_%f-N.G*--------------------------------------N@_%_%_%_%_%B;G*j>k>l>m>n>o>p>p>p>p>p>p>0&_%_%_%_%_%!> H-_%_%_%_%_%l* ", -" q>_%_%_%_%_%_%_%_%_% - n;b;_%_%_%_%_%_%_%_%:%S% !=_%_%_%_%_%_%_%_%_%c> a*r>s>t>_%_%_%_%_%L---------------------------o._%_%_%_%_%u>------------------N&:&_%_%_%_%H%--------------------------~$_%_%_%_%_%j= v>w>)*)*)*)*)*)*)*^&h%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%B+G*G*G*G*G*G*G*G*G*]._%_%_%_%_%_%_%_%_%_%_%z;G*G*G*G*G*G*G*G*G*G*G*G*G*G*G*G*G*G*G*G*G*k@_%_%_%_%_%x>y>z>_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%!> C=_%_%_%_%_%k* ", -" q>_%_%_%_%_%_%_%_%_% - n;b;_%_%_%_%_%_%_%_%:%S% !=_%_%_%_%_%_%_%_%_%c> A>_&_%_%_%_%B>C>G*G*G*G*G*G*G*G*G*G*G*G*o._%_%_%_%_%u>G*G*G*G*G*G*G*G*G*w&:&_%_%_%_%H%G*G*G*G*G*G*G*G*G*G*G*G*G* $_%_%_%_%_%j= D>E>)*)*)*)*)*)*)*6>_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%l+2&2&2&2&2&2&2&2&2&'._%_%_%_%_%_%_%_%_%_%_%F>x*2&2&2&2&2&2&2&2&2&2&2&2&2&2&2&2&2&G>H>I>J>_%_%_%_%_%K> I*_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%!> C=_%_%_%_%_%k* ", -" q>_%_%_%_%_%_%_%_%_% - n;b;_%_%_%_%_%_%_%_%:%S% !=_%_%_%_%_%_%_%_%_%c> A>_&_%_%_%_%L>M>N>O>P>Q>R>2&2&2&2&2&2&2&j._%_%_%_%_%u>2&2&2&2&2&2&2&2&2&p*:&_%_%_%_%H%2&2&2&2&2&2&2&2&2&2&2&2&2&K#_%_%_%_%_%j= z*S>L;L;L;L;L;L;$&7>_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%l+R;R;R;R;R;R;R;R;R;'._%_%_%_%_%_%_%_%_%_%_%_%V%9*R;R;R;R;R;R;R;R;R;R;R;R;T>U>V>W>X>Y>+ )=_%_%_%_%_%K> Z>_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%!> C=_%_%_%_%_%k* ", -" `>_%_%_%_%_%_%_%_%_% - n;b;_%_%_%_%_%_%_%_%:%S% !=_%_%_%_%_%_%_%_%_%c> A>_&_%_%_%_% , u;.,+,@,#,$,%,R;R;f._%_%_%_%_%u>R;R;R;R;R;R;R;R;R;^-:&_%_%_%_%H%R;R;R;R;R;R;R;R;R;R;R;R;R;K#_%_%_%_%_%j= u;&,6%6%6%6%6%6%o._%_%_%_%_%_%*,|*r =,-,-,-,-,-,;,:.|*7>_%_%_%_%_%_%i+!;!;!;!;!;!;!;!;!;=._%_%_%_%_%_%_%_%_%_%_%_%_%>,x*!;!;!;!;!;!;,,',),!,~,{,+ )=_%_%_%_%_%K> ],_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%!> C=_%_%_%_%_%k* ", -" `>_%_%_%_%_%_%_%_%_% - n;b;_%_%_%_%_%_%_%_%:%S% !=_%_%_%_%_%_%_%_%_%c> A>_&_%_%_%_% , p=^,!,/,_%_%_%_%_%(,!;!;!;!;!;!;!;!;!;_,:&_%_%_%_%H%!;!;!;!;!;!;!;!;!;!;!;!;!;A#_%_%_%_%_%j= + :,6%6%6%6%6%6%C;_%_%_%_%_%~;6%6%6%<, [,5;5;p$o&_%_%_%_%_%i+5;5;5;5;5;5;5;5;5;=._%_%_%_%_%},'.f-_%_%_%_%_%_%q&|,1,2,3,4,Y> )=_%_%_%_%_%K> n%5,U%U%U%U%U%U%U%U%U%U%U%U%U%U%U%U%<% C=_%_%_%_%_%k* ", -" D%_%_%_%_%_%_%_%_%_% - n;b;_%_%_%_%_%_%_%_%:%S% !=_%_%_%_%_%_%_%_%_%c> A>_&_%_%_%_% , 6,_%_%_%_%_%7,8,9,j>0,5;5;5;5;5;_,:&_%_%_%_%H%5;5;5;5;5;5;5;5;5;5;5;5;5;f#_%_%_%_%_%j= a,b,b,b,b,b,b,},_%_%_%_%_%9=b,b,b,c, d,e,e,^%f,_%_%_%_%_%e+e,e,e,e,e,e,e,e,e,%._%_%_%_%_%A;3=g,h,_%_%_%_%_%_%1>n= )=_%_%_%_%_%K> m%i,j,j,j,j,j,j,j,j,j,j,j,j,j,j,j,K= C=_%_%_%_%_%k* ", -" D%_%_%_%_%_%_%_%_%_% - n;b;_%_%_%_%_%_%_%_%:%S% !=_%_%_%_%_%_%_%_%_%c> A>_&_%_%_%_% , 6,_%_%_%_%_%o= + k,l,m,n,o,p,q,r,C-_%_%_%_%H%e,e,e,e,e,e,e,e,e,e,e,e,e,f#_%_%_%_%_%j= s,b,b,b,b,b,b,},_%_%_%_%_%|*b,b,b,t, u,3=3=3==-_%_%_%_%_%0+3=3=3=3=3=3=3=3=3=%._%_%_%_%_%v,w,x,y,U%_%_%_%_%_%_%a;n= )=_%_%_%_%_%K> C=_%_%_%_%_%k* ", -" D%_%_%_%_%_%_%_%_%_% - n;b;_%_%_%_%_%_%_%_%:%S% !=_%_%_%_%_%_%_%_%_%c> A>_&_%_%_%_% , 6,_%_%_%_%_%o= p=z,A,_%_%_%_%H%3=3=3=3=3=3=3=3=3=3=3=3=3=/#_%_%_%_%_%j= B,d;d;d;d;d;d;},_%_%_%_%_%|*d;d;d;C, D,E,J*J*=-_%_%_%_%_%0+J*J*J*J*J*J*F,G,H,I,_%_%_%_%_%D% j% -_&_%_%_%_%_%_%J,E% )=_%_%_%_%_%K> K,&%L,M,=% C=_%_%_%_%_%k* ", -" O=_%_%_%_%_%_%_%_%_% - n;b;_%_%_%_%_%_%_%_%:%S% !=_%_%_%_%_%_%_%_%_%c> A>_&_%_%_%_% , 6,_%_%_%_%_%o= h=G%_%_%_%_%H%J*J*J*J*J*J*J*J*J*J*J*J*J*Y@_%_%_%_%_%j= N,d;d;d;d;d;d;},_%_%_%_%_%e;d;d;d;O, P,Q,J*J*=-_%_%_%_%_%6+J*J*J*J*J*E,R, C%_%_%_%_%_%D% 6,x%_%_%_%_%_%_%G%!= )=_%_%_%_%_%K> l*x%_%_%_%G%S, C=_%_%_%_%_%k* ", -" O=_%_%_%_%_%_%_%_%_% - n;b;_%_%_%_%_%_%_%_%:%S% !=_%_%_%_%_%_%_%_%_%c> A>_&_%_%_%_% , 6,_%_%_%_%_%o= h=G%_%_%_%_%H%^%^%^%^%^%^%^%^%^%^%^%^%^%N@_%_%_%_%_%j= T,U,U,U,U,U,U,9=_%_%_%_%_%e;U,U,U,V, W,X,^%g-=-_%_%_%_%_%}+^%^%^%^%^%X,W, C%_%_%_%_%_%D% j%6,x%_%_%_%_%_%_%J,l* )=_%_%_%_%_%K> T%_%_%_%_%_%6, C=_%_%_%_%_%k* ", -" O=_%_%_%_%_%_%_%_%_%m=Y, K=b;_%_%_%_%_%_%_%_%e=D=b>b>b>b>b>b>b>b>m=_%_%_%_%_%_%_%_%_%Z, A>_&_%_%_%_% , 6,_%_%_%_%_%o= h=G%_%_%_%_%H%g-g-g-g-g-g-g-g-g-g-g-g-g-N@_%_%_%_%_%j= `, ' ' ' ' ' '9=_%_%_%_%_%e; ' ' '.' +'@'g-g-=-_%_%_%_%_%}+g-g-g-g-g-#'k, C%_%_%_%_%_%D% j%(&x%_%_%_%_%_%_%G%k* )=_%_%_%_%_%K> q>_%_%_%_%_%L, C=_%_%_%_%_%k* ", -" T%_%_%_%_%_%_%_%_%_%_%$'Y, S%:%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%%' A>_&_%_%_%_%H- &'_%_%_%_%_%o= h=G%_%_%_%_%H%n-M;M;M;M;M;M;M;M;M;M;M;M;k@_%_%_%_%_%j= *' ' ' ' ' ' '9=_%_%_%_%_%T& ' ' '=' -';'M;6;L*_%_%_%_%_%(+M;M;M;M;M;>'6. C%_%_%_%_%_%D% j%,'e=_%_%_%_%_%_%l=l* )=_%_%_%_%_%Y; q>_%_%_%_%_%&' H-_%_%_%_%_%k* ", -" T%_%_%_%_%_%_%_%_%_%_%_%''=% ,_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%)' n%/;_%_%_%_%e=n; 9&!'_%_%_%_%_%o= m%1>_%_%_%_%_%A#M;M;M;M;M;M;M;M;M;M;M;M;k@_%_%_%_%_%j= ~'_,_,_,_,_,_,C;_%_%_%_%_%{' '_,_,]' ^'/'H*l+8=_%_%_%_%_%N@H*H*H*H*H*(' C%_%_%_%_%_%D% _'x%_%_%_%_%_%_%:']= ^=_%_%_%_%_%1>=% <%_%_%_%_%_%@;j% n=x%_%_%_%_%e=E% ", -" b>_%_%_%_%_%_%_%_%_%_%_%_%_; `>_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%g= =%a;_%_%_%_%_%<'6,)='='='='='='='='=['}'_&_%_%_%_%_%o= j%j=_%_%_%_%_%F>P }+6+6+6+6+6+6+6+6+6+6+h _%_%_%_%_%j= |'_,_,_,_,_,_,f._%_%_%_%_%_%N%t.=+1''='='='='=2'3'm t-_%_%_%_%_%8=x*6=6=6=6=6=4' C%_%_%_%_%_%D% j%_'/;_%_%_%_%_%_%:%5' 6'_%_%_%_%_%_%!'&%'='='='='='='='='='='='='='='='=5'S% 6,_%_%_%_%_%U%_;7''='='='='='='='=)=-,8'_%_%_%_%_%b;K, ", -" k*:'_%_%_%_%_%_%_%_%_%_%_%9'[% n=_&_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%G%o% u-_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%o= T%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%j= 0'a'^-^-^-^-^-^&=&_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%b'p*n-n-n-n-n-c' C%_%_%_%_%_%D% j%&%/;_%_%_%_%_%_%J= ,_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%/;n% n%_&_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%d'j% ", -" %%/;_%_%_%_%_%_%_%_%_%_%9'Y, @;_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%L, '=e=_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%o= e'/;_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%j= f'g'^-^-^-^-^-_,h'_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%%.6;6;6;6;6;6;i' C%_%_%_%_%_%D% j'e=_%_%_%_%_%!' k'_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%/;n% u-_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%j' ", -" l'/;_%_%_%_%_%_%_%_%_%m= o%C=_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_&I*&& j%F%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%o= m'_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%j= n'o'p*p*p*p*p*p*0%M*_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%p'U,N&N&N&N&N&N&q' C%_%_%_%_%_%D% M,/;_%_%_%_%!' Y,%'_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%:'r' A>s'_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%$'j% ", -" ,'U%_%_%_%_%_%_%_%b;t' y%d'_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%e=0;S% [%J=_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%o= &&I*_&_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%j= u'v'w&w&w&w&w&w&w&6+t-_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%w'M=w&w&w&w&w&w&w&x' C%_%_%_%_%_%D% M,b;_%_%_%!' y%y'_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%<'j% 5's'_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%''o% ", -" M,:%_%_%_%_%_%x%,' m%z'G%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%y'7'j% S%A'G%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%o= && -9'_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%j= u;B'w&w&w&w&w&w&w&w&3$C'8=_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%1&D')*p*p*p*p*p*p*p*E'F' C%_%_%_%_%_%D% M,G'_%_%!' r'i%x%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%:%k* i,K>_&_%_%_%_%_%_%_%_%_%_%_%_%_%_%_%l=<%m% ", -" H'I'_&_%_%J'*% K=,'F%K'Z,8'8'8'8'8'8'8'8'8'8'J'''`>'=S% r'L'O=@;)')')')')')')')')')'I*M'_%_%_%_%_%o= :=N'O'>-P'P'P'P'P'P'P'P'P'P'P'P'h'Q')')')'b> R'N&N&N&N&N&N&N&N&N&^-3$e )&P'S')')')')')')')'7,y=I=].x*^-^-^-^-^-^-^-^-^-T'U' )=)')')')')',' V')')'A' j%n%-,q>@;)')')')')')')')')')'F%I*0;m'_'K, &&^;W'i%)')')')')')')')')')'Z>D%g=K= ", -" ~='=,=j% 6,_%_%_%_%_%o= X'^-^-^-^-^-^-^-^-^-^-^-^-^-Y'-' Z'N&N&N&N&N&N&N&N&N&N&N&N&N&N&`' )^-^-^-^-^-^-^-^-^-^-^-^-^-.)u; ", -" 6,_%_%_%_%_%o= +)_,_,_,_,_,_,_,_,_,_,_,_,_,@)#) $)6;6;6;6;6;6;6;6;6;6;6;6;6;6;%) &)_,_,_,_,_,_,_,_,_,_,_,_,_,*) ", -" 6,_%_%_%_%_%o= =) ' ' ' ' ' ' ' ' ' ' ' ' '-);) >)n-n-n-n-n-n-n-n-n-n-n-n-n-n-,) ') ' ' ' ' ' ' ' ' ' ' ' ' ')) ", -" 6,_%_%_%_%_%o= !)U,U,U,U,U,U,U,U,U,U,U,U,U,~)u; {)n-n-n-n-n-n-n-n-n-n-n-n-n-n-]) ^)U,U,U,U,U,U,U,U,U,U,U,U,U,/) ", -" 6,_%_%_%_%_%o= D>()U,U,U,U,U,U,U,U,U,U,U,U,_)_# :)6=6=6=6=6=6=6=6=6=6=6=6=6=6=<) [)d;d;d;d;d;d;d;d;d;d;d;d;d;}) ", -" 6,_%_%_%_%_%o= #)|)d;d;d;d;d;d;d;d;d;d;d;d;1)6. 2)6=6=6=6=6=6=6=6=6=6=6=6=6=6=3) 4)b,b,b,b,b,b,b,b,b,b,b,b,b,5) ", -" 6,_%_%_%_%_%o= u;6)b,b,b,b,b,b,b,b,b,b,b,b,7) 8)H*H*H*H*H*H*H*H*H*H*H*H*H*H*9) 0)6%6%6%6%6%6%6%6%6%6%6%6%6%a) ", -" 6,_%_%_%_%_%o= + b)6%6%6%6%6%6%6%6%6%6%6%6%c) d)H*H*H*H*H*H*H*H*H*H*H*H*H*H*e) f)L;L;L;L;L;L;L;L;L;L;L;L;L;0) ", -" 6,_%_%_%_%_%o= g)L;L;L;L;L;L;L;L;L;L;L;L;h) i)M;M;M;M;M;M;M;M;M;M;M;M;M;M;x, j)k))*)*)*)*)*)*)*)*)*)*)*)*l) ", -" 6,_%_%_%_%_%o= m))*)*)*)*)*)*)*)*)*)*)*)*n) o)M;M;M;M;M;M;M;M;M;M;M;M;M;p)q) {>r)~>~>~>~>~>~>~>~>~>~>~>~>u' ", -" 6,_%_%_%_%_%o= s)~>~>~>~>~>~>~>~>~>~>~>~>t) u)g-g-g-g-g-g-g-g-g-g-g-g-g-v)w) x)y)D-D-D-D-D-D-D-D-D-D-D-;>+ ", -" 6,_%_%_%_%_%o= z)D-D-D-D-D-D-D-D-D-D-D-D-A) B)^%^%^%^%^%^%^%^%^%^%^%^%^%C)D) D>E)O;O;O;O;O;O;O;O;O;O;O;F) ", -" i,L,L,L,L,L,)= G)O;O;O;O;O;O;O;O;O;O;O;O;H) +'^%^%^%^%^%^%^%^%^%^%^%^%^%I)X; z*J)O;O;O;O;O;O;O;O;O;O;O;K) ", -" L)w;w;w;w;w;w;w;w;w;w;w;w;M) p=J*J*J*J*J*J*J*J*J*J*J*J*J*N)`@ x@O)w;w;w;w;w;w;w;w;w;w;w;P) ", -" x)Q)J&J&J&J&J&J&J&J&J&J&J&R) S)J*J*J*J*J*J*J*J*J*J*J*J*T) + U)J&J&J&J&J&J&J&J&J&J&J&V) ", -" W)X)2=2=2=2=2=2=2=2=2=2=2=Y) Z)3=3=3=3=3=3=3=3=3=3=3=3=`) !2=2=2=2=2=2=2=2=2=2=2=.! ", -" (*+!2=2=2=2=2=2=2=2=2=2=2=@! #!3=3=3=3=3=3=3=3=3=3=3=3=$! %!6-6-6-6-6-6-6-6-6-6-6-&! ", -" *!6-6-6-6-6-6-6-6-6-6-6-=! 1,e,e,e,e,e,e,e,e,e,e,e,e,-! ;!M=M=M=M=M=M=M=M=M=M=M=>! ", -" ,!M=M=M=M=M=M=M=M=M=M=M='! )!5;5;5;5;5;5;5;5;5;5;5;5;!! ~!(=(=(=(=(=(=(=(=(=(=(={! ", -" ]!(=(=(=(=(=(=(=(=(=(=(=7* ^!5;5;5;5;5;5;5;5;5;5;5;5;/! (!x*x*x*x*x*x*x*x*x*x*w*_! ", -" :!x*x*x*x*x*x*x*x*x*x*x! y!$&$&$&$&$&$&$&$&$&$&z! ", -" + A!A%A%A%A%A%A%A%A%A%B!+ C!G*G*G*G*G*G*G*G*G*G*G*D!E! F!A%A%A%A%A%A%A%A%A%A%B% ", -" G!0%0%0%0%0%0%0%0%0%H! x!----------------------I!{, J!0%0%0%0%0%0%0%0%0%0%K! ", -" L!0%0%0%0%0%0%0%0%0%M! Y>N!--------------------O!+ P!;%;%;%;%;%;%;%;%;%;%O$ ", -" Q!;%;%;%;%;%;%;%;%;%R! S!T!<&<&<&<&<&<&<&<&<&<&U! V!P$P$P$P$P$P$P$P$P$W!X! ", -" Y!P$P$P$P$P$P$P$P$P$Z! X;`!K-K-K-K-K-K-K-K-K-K- ~ .~E$E$E$E$E$E$E$E$E$+~v$ ", -" @~E$E$E$E$E$E$E$E$E$#~ F&$~K-K-K-K-K-K-K-K-K-K-%~ &~p$p$p$p$p$p$p$p$p$*~(* ", -" =~p$p$p$p$p$p$p$p$p$-~ `@;~$=$=$=$=$=$=$=$=$=$=>~ ,~a$a$a$a$a$a$a$a$a$'~ ", -" V!a$a$a$a$a$a$a$a$a$)~ !~$=$=$=$=$=$=$=$=$=$=~~ L@3$3$3$3$3$3$3$3$3${~ ", -" X!3$3$3$3$3$3$3$3$3$]~ ^~M&M&M&M&M&M&M&M&M&M&/~ + (~~$~$~$~$~$~$~$~$_~ ", -" (*(~~$~$~$~$~$~$~$~$:~ <~M&M&M&M&M&M&M&M&M&M&[~ }~ $ $ $ $ $ $ $ $T# ", -" |~ $ $ $ $ $ $ $ $.$ 1~0=0=0=0=0=0=0=0=0=0=2~ 3~ $ $ $ $ $ $ $ $4~ ", -" 5~K#K#K#K#K#K#K#K#6~ 7~0=0=0=0=0=0=0=0=0=0=8~ 9~K#K#K#K#K#K#K#K#0~ ", -" a~A#A#A#A#A#A#A#A#b~ c~J%J%J%J%J%J%J%J%J%J%d~ e~A#A#A#A#A#A#A#B#f~ ", -" g~f#f#f#f#f#f#f#f#h~ i~X=X=X=X=X=X=X=X=X=X=j~ k~f#f#f#f#f#f#f#q#l~ ", -" m~f#f#f#f#f#f#f#n~o~ p~X=X=X=X=X=X=X=X=X=X=q~ r~/#/#/#/#/#/#/#X@1+ ", -" s~/#/#/#/#/#/#/#t~u~ v~K&K&K&K&K&K&K&K&K&K&u* w~Y@Y@Y@Y@Y@Y@Y@x~+ ", -" y~Y@Y@Y@Y@Y@Y@Y@z~l~ A~K&K&K&K&K&K&K&K&K&K&X; B~N@N@N@N@N@N@N@C~ ", -" D~N@N@N@N@N@N@N@E~h# &-E-P*P*P*P*P*P*P*P*F~ G~k@k@k@k@k@k@k@H~ ", -" I~k@k@k@k@k@k@k@J~1+ 2-Q-P*P*P*P*P*P*P*P*R- K~{@{@{@{@{@{@{@L~ ", -" 6#M~{@{@{@{@{@{@N~T. O~P~;-;-;-;-;-;-;-;-Q~ R~B+B+B+B+B+B+B+S~ ", -" T.T~B+B+B+B+B+B+U~+ +*V~y&y&y&y&y&y&y&y&W~ X~l+l+l+l+l+l+l+Y~ ", -" _#Z~l+l+l+l+l+l+`~ `@_-y&y&y&y&y&y&y&y& { .{i+i+i+i+i+i+i++{ ", -" @{i+i+i+i+i+i+#{ ${'*'*'*'*'*'*'*'*%{ &{i+i+i+i+i+i+i+*{ ", -" ={e+e+e+e+e+e+-{ T='*'*'*'*'*'*'*'*+- f+e+e+e+e+e+e+e+;{ ", -" >{0+0+0+0+0+0+,{ '{s&s&s&s&s&s&s&s&){ !{0+0+0+0+0+0+c+~{ ", -" {{6+6+6+6+6+6+]{ ^{s&s&s&s&s&s&s&s&/{ *{6+6+6+6+6+6+({ ", -" _{6+6+6+6+6+6+:{ ==L&L&L&L&L&L&L&L&<{ [{}+}+}+}+}+}+}{ ", -" |{}+}+}+}+}+}+1{ 2{f&f&f&f&f&f&f&f&3{ @+(+(+(+(+(+(+4{ ", -" 5{6{(+(+(+(+(+7{ 8{f&f&f&f&f&f&f&f&9{ 0{~+~+~+~+~+~+a{ ", -" 4+b{~+~+~+~+~+c{ d{g*g*g*g*g*g*g*g*W* e{f{'+'+'+'+'+g{ ", -" I.h{'+'+'+'+'+i{ b*g*g*g*g*g*g*g*g*j{ I.k{=+=+=+=+=+l{ ", -" + m{=+=+=+=+=+n{ o{g%g%g%g%g%g%g%g%>= T.3'$+$+$+$+$+p{ ", -" q{$+$+$+$+$+r{ s{&*************t{6& ~{u{`.`.`.`.`.v{ ", -" w{`.`.`.`.`.x{ y{,*************z{)- P.A{W.W.W.W.W.B{ ", -" C{W.W.W.W.W.D{ D&V&S&S&S&S&S&S&E{F& 6.F{W.W.W.W.G{e{ ", -" H{N.N.N.N.N.I{ @&J{S&S&S&S&S&S&K{k& L{N.N.N.N.S.T. ", -" M{G.G.G.G.G.N{ `@O{g&g&g&g&g&g&P{+ Q{G.G.G.G.R{D ", -" S{B.B.B.B.B.T{ U{g&g&g&g&g&g&V{ W{B.B.B.B.X{ ", -" Y{Z{B.B.B.B.`{ ]b&b&b&b&b&b&.] +]w.w.w.w.@] ", -" #]$]w.w.w.w.e{ %]b&b&b&b&b&b&&] *]t.t.t.t.=] ", -" ~{-]t.t.t.t.D ;]-&-&-&-&-&-&>] ,]o.o.o.o.'] ", -" )]o.o.o.!] ~]W%W%W%W%W%W%{] ]]j.j.j.j.^] ", -" /]j.j.j.(] _]W%W%W%W%W%W%:] <]f.f.f.f.[] ", -" }]f.f.f.|] 1]K%K%K%K%K%K%2] 3]0.0.0.4]5] ", -" 6]0.0.0.7] 8]K%K%K%K%K%K%9] 0]4.4.4.a]7. ", -" b]4.4.4.c] d]s%s%s%s%s%s%v% e]}.}.}.f]K ", -" g]}.}.}.h] `$s%s%s%s%s%i]j] k]}.}.}.l]+ ", -" m]:.:.:.n] }&d%d%d%d%d%o]p] q]:.:.:.r] ", -" s]].].].t] u]#%#%#%#%#%v]4% s]].].].t] ", -" b.'.'.'.w] x]#%#%#%#%#%y]@& z]A]'.'.B] ", -" + C]'.'.D] @&!%!%!%!%!%E]N+ F]G]=.=.H] ", -" I]=.=.J] + K]!%!%!%!%L] M]N]%.%.O] ", -" P]%.%.Q] R].%.%.%.%S] b.T]` ` U] ", -" V]` ` W] X]T$T$T$T$Y] 3.Z]U `] ^ ", -" .^U U +^ @^T$T$T$T$#^ P.$^P %^&^ ", -" *^P P =^ -^J$J$J$J$;^ + >^I ,^~{ ", -" '^I I Z M$J$J$J$J$)^ !^F ~^ ", -" {^F F ]^ ^^y$y$y$y$/^ (^z _^ ", -" :^z z <^ [^y$y$y$y$}^ |^z 1^ ", -" 5 2^u 3^ 4^k$k$k$k$5^ 6^u 7^ ", -" 8^9^r &^ 0^d$d$d$d$a^ b^r o ", -" # c^d^e^ f^d$d$d$g^h^ i^m j^ ", -" + k^l^2 m^6$6$6$8$n^ o^h p^ ", -" O%q^3. r^6$6$6$s^t^ u^e k ", -" v^w^x^ y^[$[$[$z^A^ B^%=e^ ", -" C^D^} L#[$[$[$E^o# F^G^+ ", -" F^H^. A^I^^$^$J^ K^| ", -" L^M^+ @&N^^$^$O^ P^Q^ ", -" R^S^ 6@T^>$>$U^ V^W^ ", -" 8 X^ o#Y^#$#$Z^ `^ / ", -" e^./ + +/#$#$@/ #/, ", -" } $/ %/W#W#&/ */=/ ", -" -/ ;/W#W#>/ ,/'/ ", -" )/ H#N#N#!/ ~/{/ ", -" % ]/N#N#^/ # } ", -" //E#E#(/ ", -" _/u#u#:/ ", -"