diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..3b5ae35c --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,112 @@ +name: build + +on: [push, pull_request] + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os: ubuntu-latest + cc: gcc + cxx: g++ + - os: ubuntu-latest + cc: clang + cxx: clang++ + - os: windows-2019 + cc: cl + cxx: cl + env: + CC: ${{ matrix.cc }} + CXX: ${{ matrix.cxx }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Checkout steam-runtime + if: startsWith(matrix.os, 'ubuntu') + uses: actions/checkout@v3 + with: + repository: ValveSoftware/steam-runtime + path: steam-runtime + - name: Cache steam-runtime + if: startsWith(matrix.os, 'ubuntu') + id: cache-steam-runtime + uses: actions/cache@v3 + with: + path: com.valvesoftware.SteamRuntime.Sdk-i386-scout-sysroot.tar.gz + key: ${{ runner.os }}-steam-runtime + - name: Download steam-runtime + if: startsWith(matrix.os, 'ubuntu') && steps.cache-steam-runtime.outputs.cache-hit != 'true' + run: wget --no-verbose https://repo.steampowered.com/steamrt-images-scout/snapshots/0.20210610.0/com.valvesoftware.SteamRuntime.Sdk-i386-scout-sysroot.tar.gz + - name: Install steam runtime + if: startsWith(matrix.os, 'ubuntu') + run: | + sudo apt update + ./steam-runtime/setup_chroot.sh --i386 --tarball ./com.valvesoftware.SteamRuntime.Sdk-i386-scout-sysroot.tar.gz + sudo sed -i 's/groups=sudo/groups=adm/g' /etc/schroot/chroot.d/steamrt_scout_i386.conf + + - name: Build on Linux + if: startsWith(matrix.os, 'ubuntu') + run: | + schroot --chroot steamrt_scout_i386 -- cmake -B build -S . -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" -DCMAKE_INSTALL_PREFIX="$PWD/dist" + schroot --chroot steamrt_scout_i386 -- cmake --build build --target all + schroot --chroot steamrt_scout_i386 -- cmake --build build --target install + - name: Build on Linux with vgui + if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.cc, 'gcc') + run: | + schroot --chroot steamrt_scout_i386 -- cmake -B build-vgui -S . -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" -DUSE_VGUI=ON -DCMAKE_INSTALL_PREFIX="$PWD/dist-vgui" + cp vgui_support/vgui-dev/lib/vgui.so build-vgui/cl_dll + schroot --chroot steamrt_scout_i386 -- cmake --build build-vgui --target all + schroot --chroot steamrt_scout_i386 -- cmake --build build-vgui --target install + + - name: Add msbuild to PATH + if: startsWith(matrix.os, 'windows') + uses: microsoft/setup-msbuild@v1.1 + - name: Build on Windows + if: startsWith(matrix.os, 'windows') + run: | + cmake -G "Visual Studio 16 2019" -A Win32 -B build -DCMAKE_INSTALL_PREFIX="dist" + msbuild -verbosity:normal /property:Configuration=Release build/INSTALL.vcxproj + - name: Build on Windows with vgui + if: startsWith(matrix.os, 'windows') + run: | + cmake -G "Visual Studio 16 2019" -A Win32 -B build -DUSE_VGUI=ON -DCMAKE_INSTALL_PREFIX="dist-vgui" + msbuild -verbosity:normal /property:Configuration=Release build/INSTALL.vcxproj + + - name: Extract branch name + shell: bash + run: echo "branch=$(echo ${GITHUB_REF#refs/heads/} | tr '/' '_')" >> $GITHUB_OUTPUT + id: extract_branch + - name: Extract gamedir + shell: bash + run: echo "gamedir=$(grep build/CMakeCache.txt -Ee 'GAMEDIR:STRING=[a-z]+' | cut -d '=' -f 2)" >> $GITHUB_OUTPUT + id: extract_gamedir + - name: Upload linux artifact + if: startsWith(matrix.os, 'ubuntu') && matrix.cc == 'gcc' + uses: actions/upload-artifact@v3 + with: + name: hlsdk-${{ steps.extract_branch.outputs.branch }}-linux + path: dist/${{ steps.extract_gamedir.outputs.gamedir }} + - name: Upload linux artifact with vgui + if: startsWith(matrix.os, 'ubuntu') && matrix.cc == 'gcc' + uses: actions/upload-artifact@v3 + with: + name: hlsdk-${{ steps.extract_branch.outputs.branch }}-linux-vgui + path: dist-vgui/${{ steps.extract_gamedir.outputs.gamedir }} + - name: Upload windows artifact + if: startsWith(matrix.os, 'windows') + uses: actions/upload-artifact@v3 + with: + name: hlsdk-${{ steps.extract_branch.outputs.branch }}-windows + path: dist/${{ steps.extract_gamedir.outputs.gamedir }} + - name: Upload windows artifact with vgui + if: startsWith(matrix.os, 'windows') + uses: actions/upload-artifact@v3 + with: + name: hlsdk-${{ steps.extract_branch.outputs.branch }}-windows-vgui + path: dist-vgui/${{ steps.extract_gamedir.outputs.gamedir }} + diff --git a/.github/workflows/manual.yml b/.github/workflows/manual.yml new file mode 100644 index 00000000..9f03d110 --- /dev/null +++ b/.github/workflows/manual.yml @@ -0,0 +1,113 @@ +name: manual build + +on: + workflow_dispatch: + inputs: + buildtype: + type: choice + description: Build Type + options: + - Release + - Debug + usevgui: + type: choice + description: Use VGUI + options: + - 'OFF' + - 'ON' +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os: ubuntu-latest + cc: gcc + cxx: g++ + - os: windows-2019 + cc: cl + cxx: cl + env: + CC: ${{ matrix.cc }} + CXX: ${{ matrix.cxx }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Checkout steam-runtime + if: startsWith(matrix.os, 'ubuntu') + uses: actions/checkout@v3 + with: + repository: ValveSoftware/steam-runtime + path: steam-runtime + - name: Cache steam-runtime + if: startsWith(matrix.os, 'ubuntu') + id: cache-steam-runtime + uses: actions/cache@v3 + with: + path: com.valvesoftware.SteamRuntime.Sdk-i386-scout-sysroot.tar.gz + key: ${{ runner.os }}-steam-runtime + - name: Download steam-runtime + if: startsWith(matrix.os, 'ubuntu') && steps.cache-steam-runtime.outputs.cache-hit != 'true' + run: wget --no-verbose https://repo.steampowered.com/steamrt-images-scout/snapshots/0.20210610.0/com.valvesoftware.SteamRuntime.Sdk-i386-scout-sysroot.tar.gz + - name: Install steam runtime + if: startsWith(matrix.os, 'ubuntu') + run: | + sudo apt update + ./steam-runtime/setup_chroot.sh --i386 --tarball ./com.valvesoftware.SteamRuntime.Sdk-i386-scout-sysroot.tar.gz + sudo sed -i 's/groups=sudo/groups=adm/g' /etc/schroot/chroot.d/steamrt_scout_i386.conf + + - name: Copy vgui.so + if: ${{ startsWith(matrix.os, 'ubuntu') && github.event.inputs.usevgui == 'ON' }} + run: | + mkdir -p build/cl_dll + cp vgui_support/vgui-dev/lib/vgui.so build/cl_dll + - name: Build on Linux + if: startsWith(matrix.os, 'ubuntu') + run: | + schroot --chroot steamrt_scout_i386 -- cmake -B build -S . -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" -DCMAKE_BUILD_TYPE=${{ github.event.inputs.buildtype }} -DCMAKE_INSTALL_PREFIX="$PWD/dist" -DUSE_VGUI=${{ github.event.inputs.usevgui }} + schroot --chroot steamrt_scout_i386 -- cmake --build build --target all + schroot --chroot steamrt_scout_i386 -- cmake --build build --target install + + - name: Add msbuild to PATH + if: startsWith(matrix.os, 'windows') + uses: microsoft/setup-msbuild@v1.1 + - name: Build on Windows + if: startsWith(matrix.os, 'windows') + run: | + cmake -G "Visual Studio 16 2019" -A Win32 -B build -DCMAKE_INSTALL_PREFIX="dist" -DUSE_VGUI=${{ github.event.inputs.usevgui }} + msbuild -verbosity:normal /property:Configuration=${{ github.event.inputs.buildtype }} build/INSTALL.vcxproj + + - name: Extract branch name + shell: bash + run: echo "branch=$(echo ${GITHUB_REF#refs/heads/} | tr '/' '_')" >> $GITHUB_OUTPUT + id: extract_branch + - name: Extract gamedir + shell: bash + run: echo "gamedir=$(grep build/CMakeCache.txt -Ee 'GAMEDIR:STRING=[a-z]+' | cut -d '=' -f 2)" >> $GITHUB_OUTPUT + id: extract_gamedir + - name: Copy pdbs to dist dir + if: ${{ startsWith(matrix.os, 'windows') && github.event.inputs.buildtype == 'Debug' }} + run: | + copy build/cl_dll/Debug/client.pdb dist/${{ steps.extract_gamedir.outputs.gamedir }}/cl_dlls/ + copy build/dlls/Debug/hl.pdb dist/${{ steps.extract_gamedir.outputs.gamedir }}/dlls/ + - name: Delete .lib files from dist + if: startsWith(matrix.os, 'windows') + run: | + Remove-Item -Force -Path dist/${{ steps.extract_gamedir.outputs.gamedir }}/cl_dlls/client.lib + Remove-Item -Force -Path dist/${{ steps.extract_gamedir.outputs.gamedir }}/dlls/hl.lib + - name: Upload linux artifact + if: startsWith(matrix.os, 'ubuntu') + uses: actions/upload-artifact@v3 + with: + name: hlsdk-${{ steps.extract_branch.outputs.branch }}-linux + path: dist/${{ steps.extract_gamedir.outputs.gamedir }} + - name: Upload windows artifact + if: startsWith(matrix.os, 'windows') + uses: actions/upload-artifact@v3 + with: + name: hlsdk-${{ steps.extract_branch.outputs.branch }}-windows + path: dist/${{ steps.extract_gamedir.outputs.gamedir }} + diff --git a/.gitignore b/.gitignore index adcc4f7b..42594b50 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ *.dll *.pdb build/ -CMakeLists.txt.user +CMakeLists.txt.* cmake_install.cmake *.orig *.cbp @@ -18,5 +18,14 @@ cmake_install.cmake *.vsproj *.sln .waf-* +waf-* +.waf3-* +waf3-* .lock* *.pyc +.vscode/ +.vs/ +CMakeSettings.json +CMakeFiles +CMakeCache.txt +Makefile diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..9510c702 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "vgui_support"] + path = vgui_support + url = https://github.com/FWGS/vgui_support diff --git a/CMakeLists.txt b/CMakeLists.txt index 80c2c5d9..add3771f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,42 +20,76 @@ # SOFTWARE. # -cmake_minimum_required(VERSION 2.6.0) +cmake_minimum_required(VERSION 2.8.12) + +if(NOT ${CMAKE_VERSION} VERSION_LESS "3.15.0") + cmake_policy(SET CMP0091 NEW) +endif() # Install custom module path -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/") +include(CheckIncludeFile) +include(CheckCSourceCompiles) include(VSForceXPToolchain) # Force XP toolchain for Visual Studio -project (HLSDK-XASH3D) +project (HLSDK-PORTABLE) #-------------- # USER DEFINES \ ################\ -option(USE_VGUI "Enable VGUI1. UNDONE" OFF) +option(USE_VGUI "Enable VGUI1." OFF) option(USE_VGUI2 "Enable VGUI2. UNDONE" OFF) +option(USE_NOVGUI_MOTD "Prefer non-VGUI MOTD when USE_VGUI is enabled" OFF) +option(USE_NOVGUI_SCOREBOARD "Prefer non-VGUI Scoreboard when USE_VGUI is enabled" OFF) option(USE_VOICEMGR "Enable VOICE MANAGER." OFF) option(BUILD_CLIENT "Build client dll" ON) option(BUILD_SERVER "Build server dll" ON) -option(GOLDSOURCE_SUPPORT "Build goldsource compatible client library" OFF) -option(64BIT "Disable auto -m32 appending to compiler flags" OFF) + +if (CMAKE_SIZEOF_VOID_P EQUAL 4 OR + ((WIN32 OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + AND (CMAKE_SYSTEM_PROCESSOR STREQUAL "x64" + OR CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" + OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64"))) + option(64BIT "Disable auto -m32 appending to compiler flags" OFF) + option(GOLDSOURCE_SUPPORT "Build goldsource compatible client library" ON) +else() + option(64BIT "Disable auto -m32 appending to compiler flags" ON) + option(GOLDSOURCE_SUPPORT "Build goldsource compatible client library" OFF) +endif() + +option(BARNACLE_FIX_VISIBILITY "Enable barnacle tongue length fix" OFF) +option(CLIENT_WEAPONS "Enable client local weapons prediction" ON) +option(CROWBAR_IDLE_ANIM "Enable crowbar idle animation" OFF) +option(CROWBAR_DELAY_FIX "Enable crowbar attack delay fix" OFF) +option(CROWBAR_FIX_RAPID_CROWBAR "Enable rapid crowbar fix" OFF) +option(GAUSS_OVERCHARGE_FIX "Enable gauss overcharge fix" OFF) +option(TRIPMINE_BEAM_DUPLICATION_FIX "Enable fix of tripmine beam duplication on level transition" OFF) +option(HANDGRENADE_DEPLOY_FIX "Enable handgrenade deploy animation fix after finishing a throw" OFF) +option(WEAPONS_ANIMATION_TIMES_FIX "Enable animation times fix for some weapons" OFF) +option(OEM_BUILD "Enable OEM Build" OFF) +option(HLDEMO_BUILD "Enable Demo Build" OFF) + set(GAMEDIR "valve" CACHE STRING "Gamedir path") set(SERVER_INSTALL_DIR "dlls" CACHE STRING "Where put server dll") set(CLIENT_INSTALL_DIR "cl_dlls" CACHE STRING "Where put client dll") -set(SERVER_LIBRARY_NAME "hl" CACHE STRING "Library name for Linux/MacOS/Windows") +set(SERVER_LIBRARY_NAME "hl" CACHE STRING "Library name for PC platforms") +message(STATUS "Half-Life") #----------------- # MAIN BUILD CODE \ ###################\ -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") +if(HLDEMO_BUILD AND OEM_BUILD) + message(FATAL_ERROR "Don't mix Demo and OEM builds!") +endif() if(CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT 64BIT) if(MSVC) error("UNDONE: set 32 build flags") else() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32") endif() set(CMAKE_SIZEOF_VOID_P 4) @@ -65,12 +99,71 @@ if(64BIT AND CMAKE_SIZEOF_VOID_P EQUAL 4) message(FATAL_ERROR "You enabled XASH_64BIT, but compiler can't create 64 bit code!") endif() -if(64BIT) +# Xash3D FWGS Library Naming Scheme compliance +# see documentation: https://github.com/FWGS/xash3d-fwgs/blob/master/Documentation/extensions/library-naming.md +include(LibraryNaming) + +if(CMAKE_SIZEOF_VOID_P EQUAL 8) message(STATUS "Building for 64 Bit") else() message(STATUS "Building for 32 Bit") endif() +if(CLIENT_WEAPONS) + message(STATUS "Client weapons enabled.") + add_definitions(-DCLIENT_WEAPONS) +endif() + +if(BARNACLE_FIX_VISIBILITY) + message(STATUS "Barnacle tongue fix enabled") + add_definitions(-DBARNACLE_FIX_VISIBILITY) +endif() + +if(CROWBAR_IDLE_ANIM) + message(STATUS "Crowbar idle animation enabled") + add_definitions(-DCROWBAR_IDLE_ANIM) +endif() + +if(CROWBAR_DELAY_FIX) + message(STATUS "Crowbar attack delay fix enabled") + add_definitions(-DCROWBAR_DELAY_FIX) +endif() + +if(CROWBAR_FIX_RAPID_CROWBAR) + message(STATUS "Rapid crowbar fix enabled") + add_definitions(-DCROWBAR_FIX_RAPID_CROWBAR) +endif() + +if(GAUSS_OVERCHARGE_FIX) + message(STATUS "Gauss overcharge fix enabled") + add_definitions(-DGAUSS_OVERCHARGE_FIX) +endif() + +if(TRIPMINE_BEAM_DUPLICATION_FIX) + message(STATUS "Tripmine beam duplication fix enabled") + add_definitions(-DTRIPMINE_BEAM_DUPLICATION_FIX) +endif() + +if(HANDGRENADE_DEPLOY_FIX) + message(STATUS "Handgrenade deploy animation fix enabled") + add_definitions(-DHANDGRENADE_DEPLOY_FIX) +endif() + +if(WEAPONS_ANIMATION_TIMES_FIX) + message(STATUS "Weapons animation times fix enabled") + add_definitions(-DWEAPONS_ANIMATION_TIMES_FIX) +endif() + +if(OEM_BUILD) + message(STATUS "OEM build enabled") + add_definitions(-DOEM_BUILD) +endif() + +if(HLDEMO_BUILD) + message(STATUS "Demo build enabled") + add_definitions(-DHLDEMO_BUILD) +endif() + if (MINGW) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++ -static-libgcc") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--add-stdcall-alias") @@ -86,14 +179,40 @@ if(${CMAKE_VERSION} VERSION_LESS "3.0.2") endmacro() endif() +if(NOT MSVC) + #add_compile_options(-Wempty-body) # GCC/Clang flag + add_compile_options(-Wreturn-type) # GCC/Clang flag +else() + add_definitions(-D_CRT_SILENCE_NONCONFORMING_TGMATH_H) +endif() + +if(VITA) + add_compile_options(-fno-use-cxa-atexit) +endif() + +check_include_file("tgmath.h" HAVE_TGMATH_H) +if(HAVE_TGMATH_H) + if(NOT MSVC) + set(CMAKE_REQUIRED_LIBRARIES "m") + endif() + check_c_source_compiles("#include + const float val = 2, val2 = 3; + int main(){ return (int)(-asin(val) + cos(val2)); }" HAVE_VALID_TGMATH_H ) + if(${HAVE_VALID_TGMATH_H}) + add_definitions(-DHAVE_TGMATH_H) + endif() +endif() + if(BUILD_CLIENT) + message(STATUS "Building client enabled") add_subdirectory(cl_dll) endif() if(BUILD_SERVER) + message(STATUS "Building server enabled") add_subdirectory(dlls) endif() if(NOT BUILD_SERVER AND NOT BUILD_CLIENT) - error("Nothing to build") + message(FATAL_ERROR "Nothing to build") endif() diff --git a/README.md b/README.md index be0a5fa8..e1fbcccf 100644 --- a/README.md +++ b/README.md @@ -1,149 +1,336 @@ -# Half-Life SDK for Xash3D [![Build Status](https://travis-ci.org/FWGS/hlsdk-xash3d.svg)](https://travis-ci.org/FWGS/hlsdk-xash3d) [![Windows Build Status](https://ci.appveyor.com/api/projects/status/github/FWGS/hlsdk-xash3d?svg=true)](https://ci.appveyor.com/project/a1batross/hlsdk-xash3d) +# Half-Life SDK for GoldSource and Xash3D [![Build Status](https://github.com/FWGS/hlsdk-portable/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/FWGS/hlsdk-portable/actions/workflows/build.yml) [![Windows Build Status](https://ci.appveyor.com/api/projects/status/github/FWGS/hlsdk-portable?svg=true)](https://ci.appveyor.com/project/a1batross/hlsdk-portable) -Half-Life SDK for Xash3D & GoldSource with some fixes. +Half-Life SDK for GoldSource & Xash3D with some bugfixes. -## How to build +
Changelog +

-### CMake as most universal way +- Fixed an occasional bug when houndeyes stuck unable to do anything. Technical detail: now monster's `Activity` is set before the call to `SetYawSpeed`. [Patch](https://github.com/FWGS/hlsdk-portable/commit/467899b99aa225a95d90222137f18c141c929c86) +- Monsters now play idle sounds as it's supposed by the code. Technical detail: the problem was a check for a wrong variable. [Patch](https://github.com/FWGS/hlsdk-portable/commit/9fc712da019a1ca646171e912209a993e7c43976) +- Fixed a bug that caused talk monsters (scientists and security guards) to face a wrong direction during scripted sequence sometimes. [Patch](https://github.com/FWGS/hlsdk-portable/commit/3e2808de62e479e83068c075cb88b4f177f9acc7) +- Fixed squad member removal. This bug affected houndeye attacks as their attack depends on percieved number of squad members. [Patch](https://github.com/FWGS/hlsdk-portable/commit/b4502f71336a08f3f2c72b7b061b2838a149a11b) +- Scientists now react to smells. [Patch](https://github.com/FWGS/hlsdk-portable/commit/2de4e7ab003d5b1674d12525f5aefb1e57a49fa3) +- Tau-cannon (gauss) plays idle animations. +- Tau-cannon (gauss) beam color depends on the charge as it was before the prediction code was introduced in Half-Life. [Patch](https://github.com/FWGS/hlsdk-portable/commit/0a29ec49c8183ebb8da22a6d2ef395eae9c3dffe) +- Brought back gluon flare in singleplayer. [Patch](https://github.com/FWGS/hlsdk-portable/commit/9d7ab6acf46a8b71ef119d9c252767865522d21d) +- Hand grenades don't stay primed after holster, preventing detonation after weapon switch. [Patch](https://github.com/FWGS/hlsdk-portable/commit/6e1059026faa90c5bfe5e3b3f4f58fde398d4524) +- Fixed flashlight battery appearing as depleted on restore. +- Fixed a potential overflow when reading sentences.txt. [Patch](https://github.com/FWGS/hlsdk-xash3d/commit/cb51d2aa179f1eb622e08c1c07b053ccd49e40a5) +- Fixed beam attachment invalidated on restore (that led to visual bugs). [Patch](https://github.com/FWGS/hlsdk-xash3d/commit/74b5543c83c5cdcb88e9254bacab08bc63c4c896) +- Fixed alien controllers facing wrong direction in non-combat state. [Patch](https://github.com/FWGS/hlsdk-portable/commit/e51878c45b618f9b3920b46357545cbb47befeda) +- Fixed weapon deploy animations not playing sometimes on fast switching between weapons. [Patch](https://github.com/FWGS/hlsdk-portable/commit/ed676a5413c2d26b2982e5b014e0731f0eda6a0d) [Patch2](https://github.com/FWGS/hlsdk-portable/commit/4053dca7a9cf999391cbd77224144da207e4540b) +- Fixed tripmine sometimes having wrong body on pickup [Patch](https://github.com/FWGS/hlsdk-portable/commit/abf08e4520e3b6cd12a40f269f4a256cf8496227) - mkdir build && cd build - cmake ../ - make +Bugfix-related macros that can be enabled during the compilation: -Crosscompiling using mingw: +- **CROWBAR_DELAY_FIX** fixes a bug when crowbar has a longer delay after the first hit. +- **CROWBAR_FIX_RAPID_CROWBAR** fixes a "rapid crowbar" bug when hitting corpses of killed monsters. +- **GAUSS_OVERCHARGE_FIX** fixes tau-cannon (gauss) charge sound not stopping after the overcharge. +- **CROWBAR_IDLE_ANIM** makes crowbar play idle animations. +- **TRIPMINE_BEAM_DUPLICATION_FIX** fixes tripmine's beam duplication on level transition. +- **HANDGRENADE_DEPLOY_FIX** makes handgrenade play draw animation after finishing a throw. +- **WEAPONS_ANIMATION_TIMES_FIX** fixes deploy and idle animation times of some weapons. - mkdir build-mingw && cd build-mingw - TOOLCHAIN_PREFIX=i686-w64-mingw32 # check up the actual mingw prefix of your mingw installation - cmake ../ -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_C_COMPILER="$TOOLCHAIN_PREFIX-gcc" -DCMAKE_CXX_COMPILER="$TOOLCHAIN_PREFIX-g++" +Bugfix-related server cvars: -You may enable or disable some build options by -Dkey=value. All available build options are defined in CMakeLists.txt at root directory. -See below if you want to build the GoldSource compatible libraries. +- **satchelfix**: if set to 1, doors won't get blocked by satchels. Fixes an infamous exploit on `crossfire` map. +- **explosionfix**: if set to 1, explosion damage won't propagate through thin bruses. +- **selfgauss**: if set to 0, players won't hurt themselves with secondary attack when shooting thick brushes. -See below, if CMake is not suitable for you: +*Note*: the macros and cvars were adjusted in [hlfixed](https://github.com/FWGS/hlsdk-portable/tree/hlfixed) branch (for further information read [this](https://github.com/FWGS/hlsdk-portable/wiki/HL-Fixed)). The bugfix macros are kept turned off in `master` branch to maintain the compatibility with vanilla servers and clients. -### Windows +Other server cvars: -#### Using msvc +- **mp_bhopcap**: if set to 1, enable bunny-hop. +- **chargerfix**: if set to 1, wall-mounted health and battery chargers will play reject sounds if player has the full health or armor. +- **corpsephysics**: if set to 1, corpses of killed monsters will fly a bit from an impact. It's a cut feature from Half-Life. -We use compilers provided with Microsoft Visual Studio 6. There're `compile.bat` scripts in both `cl_dll` and `dlls` directories. -Before running any of those files you must define `MSVCDir` variable which is the path to your msvc installation. +

+
- set MSVCDir=C:\Program Files\Microsoft Visual Studio - compile.bat +
Support for mods +

-These scripts also can be ran via wine: +This repository contains (re-)implementations of some mods as separate branches derived from `master`. The list of supported mods can be found [here](https://github.com/FWGS/hlsdk-portable/wiki/Mods). Note that some branches are unstable and incomplete. - MSVCDir="z:\home\$USER\.wine\drive_c\Program Files\Microsoft Visual Studio" wine cmd /c compile.bat +To get the mod branch locally run the following git command: -The libraries built this way are always GoldSource compatible. +``` +git fetch origin asheep:asheep +``` -There're dsp projects for Visual Studio 6 in `cl_dll` and `dlls` directories, but we don't keep them up-to-date. You're free to adapt them for yourself and try to import into the newer Visual Studio versions. +This is considering that you have set **FWGS/hlsdk-portable** as an `origin` remote and want to fetch `asheep` branch. -#### Using mingw +

+
-TODO +# Obtaining source code -### Linux +Either clone the repository via [git](`https://git-scm.com/downloads`) or just download ZIP via **Code** button on github. The first option is more preferable as it also allows you to search through the repo history, switch between branches and clone the vgui submodule. - (cd dlls && make) - (cd cl_dll && make) +To clone the repository with git type in Git Bash (on Windows) or in terminal (on Unix-like operating systems): -### OS X +``` +git clone --recursive https://github.com/FWGS/hlsdk-portable +``` -Nothing here. +# Build Instructions -### FreeBSD +## Windows x86. - (cd dlls && gmake CXX=clang++ CC=clang) - (cd cl_dll && gmake CXX=clang++ CC=clang) +### Prerequisites -### Android +Install and run [Visual Studio Installer](https://visualstudio.microsoft.com/downloads/). The installer allows you to choose specific components. Select `Desktop development with C++`. You can untick everything you don't need in Installation details, but you must keep `MSVC` ticked. You may also keep `C++ CMake tools for Windows` ticked as you'll need **cmake**. Alternatively you can install **cmake** from the [cmake.org](https://cmake.org/download/) and during installation tick *Add to the PATH...*. -Just typical `ndk-build`. -TODO: describe what it is. +### Opening command prompt -### Building GoldSource-compatible libraries +If **cmake** was installed with Visual Studio Installer, you'll need to run `Developer command prompt for VS` via Windows `Start` menu. If **cmake** was installed with cmake installer, you can run the regular Windows `cmd`. -To enable building the goldsource compatible client library add GOLDSOURCE_SUPPORT flag when calling cmake: +Inside the prompt navigate to the hlsdk directory, using `cd` command, e.g. +``` +cd C:\Users\username\projects\hlsdk-portable +``` - cmake .. -DGOLDSOURCE_SUPPORT=ON +Note: if hlsdk-portable is unpacked on another disk, nagivate there first: +``` +D: +cd projects\hlsdk-portable +``` -or when using make without cmake: +### Building - make GOLDSOURCE_SUPPORT=1 +Сonfigure the project: +``` +cmake -A Win32 -B build +``` +Note that you must repeat the configuration step if you modify `CMakeLists.txt` files or want to reconfigure the project with different parameters. -Unlike original client by Valve the resulting client library will not depend on vgui or SDL2 just like the one that's used in FWGS Xash3d. +The next step is to compile the libraries: +``` +cmake --build build --config Release +``` +`hl.dll` and `client.dll` will appear in the `build/dlls/Release` and `build/cl_dll/Release` directories. -Note for **Windows**: it's not possible to create GoldSource compatible libraries using mingw, only msvc builds will work. +If you have a mod and want to automatically install libraries to the mod directory, set **GAMEDIR** variable to the directory name and **CMAKE_INSTALL_PREFIX** to your Half-Life or Xash3D installation path: +``` +cmake -A Win32 -B build -DGAMEDIR=mod -DCMAKE_INSTALL_PREFIX="C:\Program Files (x86)\Steam\steamapps\common\Half-Life" +``` +Then call `cmake` with `--target install` parameter: +``` +cmake --build build --config Release --target install +``` -Note for **Linux**: GoldSource requires libraries (both client and server) to be compiled with libstdc++ bundled with g++ of major version 4 (versions from 4.6 to 4.9 should work). -If your Linux distribution does not provide compatible g++ version you have several options. +#### Choosing Visual Studio version -#### Method 1: Statically build with c++ library +You can explicitly choose a Visual Studio version on the configuration step by specifying cmake generator: +``` +cmake -G "Visual Studio 16 2019" -A Win32 -B build +``` -This one is the most simple but has a drawback. +### Editing code in Visual Studio - cmake ../ -DGOLDSOURCE_SUPPORT=ON -DCMAKE_C_FLAGS="-static-libstdc++ -static-libgcc" +After the configuration step, `HLSDK-PORTABLE.sln` should appear in the `build` directory. You can open this solution in Visual Studio and continue developing there. -The drawback is that the compiled libraries will be larger in size. +## Windows x86. Using Microsoft Visual Studio 6 -#### Method 2: Build in Steam Runtime chroot +Microsoft Visual Studio 6 is very old, but if you still have it installed, you can use it to build this hlsdk. There are no project files, but two `.bat` files, for server and client libraries. They require variable **MSVCDir** to be set to the installation path of Visual Studio: -This is the official way to build Steam compatible games for Linux. +``` +set MSVCDir=C:\Program Files\Microsoft Visual Studio +cd dlls && compile.bat && cd ../cl_dll && compile.bat +``` -Clone https://github.com/ValveSoftware/steam-runtime and follow instructions https://github.com/ValveSoftware/steam-runtime#building-in-the-runtime +`hl.dll` and `client.dll` will appear in `dlls/` and `cl_dll/` diretories. The libraries built with msvc6 should be compatible with Windows XP. - sudo ./setup_chroot.sh --i386 +## Linux x86. Portable steam-compatible build using Steam Runtime in chroot -Then use cmake and make as usual, but prepend the commands with `schroot --chroot steamrt_scout_i386 --`: +### Prerequisites - mkdir build-in-steamrt && cd build-in-steamrt - schroot --chroot steamrt_scout_i386 -- cmake ../ -DGOLDSOURCE_SUPPORT=ON - schroot --chroot steamrt_scout_i386 -- make +The official way to build Steam compatible games for Linux is through steam-runtime. -#### Method 3: Create your own chroot with older distro that includes g++ 4. +Install schroot. On Ubuntu or Debian: -Use the most suitable way for you to create an old distro 32-bit chroot. E.g. on Debian (and similar) you can use debootstrap. +``` +sudo apt install schroot +``` - sudo debootstrap --arch=i386 jessie /var/chroot/jessie-debian-i386 # On Ubuntu type trusty instead of jessie - sudo chroot /var/chroot/jessie-debian-i386 +Clone https://github.com/ValveSoftware/steam-runtime and follow instructions: [download](https://github.com/ValveSoftware/steam-runtime/blob/e014a74f60b45a861d38a867b1c81efe8484f77a/README.md#downloading-a-steam-runtime) and [setup](https://github.com/ValveSoftware/steam-runtime/blob/e014a74f60b45a861d38a867b1c81efe8484f77a/README.md#using-schroot) the chroot. -Inside chroot install cmake, make, g++ and libsdl2-dev. Then exit the chroot. +``` +sudo ./setup_chroot.sh --i386 --tarball ./com.valvesoftware.SteamRuntime.Sdk-i386-scout-sysroot.tar.gz +``` -On the host system install schroot. Then create and adapt the following config in /etc/schroot/chroot.d/jessie.conf (you can choose a different name): +### Building + +Now you can use cmake and make prepending the commands with `schroot --chroot steamrt_scout_i386 --`: +``` +schroot --chroot steamrt_scout_i386 -- cmake -B build-in-steamrt -S . +schroot --chroot steamrt_scout_i386 -- cmake --build build-in-steamrt +``` + +## Linux x86. Portable steam-compatible build without Steam Runtime + +### Prerequisites + +Install C++ compilers, cmake and x86 development libraries for C, C++ and SDL2. On Ubuntu/Debian: +``` +sudo apt install cmake build-essential gcc-multilib g++-multilib libsdl2-dev:i386 +``` + +### Building + +``` +cmake -B build -S . +cmake --build build +``` + +Note that the libraries built this way might be not compatible with Steam Half-Life. If you have such issue you can configure it to build statically with c++ and gcc libraries: +``` +cmake .. -DCMAKE_C_FLAGS="-static-libstdc++ -static-libgcc" +``` +To ensure portability it's still better to build using Steam Runtime or another chroot of some older distro. + +## Linux x86. Portable steam-compatible build in your own chroot + +### Prerequisites + +Use the most suitable way for you to create an old distro 32-bit chroot. E.g. on Ubuntu/Debian you can use debootstrap. + +``` +sudo apt install debootstrap schroot +sudo mkdir -p /var/choots +sudo debootstrap --arch=i386 jessie /var/chroots/jessie-i386 # On Ubuntu type trusty instead of jessie +sudo chroot /var/chroots/jessie-i386 +``` + +``` +# inside chroot +apt install cmake build-essential gcc-multilib g++-multilib libsdl2-dev +exit +``` + +Create and adapt the following config in /etc/schroot/chroot.d/jessie.conf (you can choose a different name): ``` [jessie] type=directory description=Debian jessie i386 -directory=/var/chroot/debian-jessie-i386/ +directory=/var/chroots/jessie-i386/ users=yourusername -groups=yourusername +groups=adm root-groups=root preserve-environment=true personality=linux32 ``` -Insert your actual user name in place of `yourusername`. Then prepend any make or cmake call with `schroot -c jessie --`: +Insert your actual user name in place of `yourusername`. - mkdir build-in-chroot && cd build-in-chroot - schroot --chroot jessie -- cmake ../ -DGOLDSOURCE_SUPPORT=ON - schroot --chroot jessie -- make +### Building -#### Method 4: Install the needed g++ version yourself - -TODO: describe steps. - -#### Configuring Qt Creator to use toolchain from chroot - -Create a file with the following contents anywhere: - -```sh -#!/bin/sh -schroot --chroot steamrt_scout_i386 -- cmake "$@" +Prepend any make or cmake call with `schroot -c jessie --`: +``` +schroot --chroot jessie -- cmake -B build-in-chroot -S . +schroot --chroot jessie -- cmake --build build-in-chroot ``` -Make it executable. -In Qt Creator go to `Tools` -> `Options` -> `Build & Run` -> `CMake`. Add a new cmake tool and specify the path of previously created file. -Go to `Kits` tab, clone your default configuration and choose your CMake tool there. -Choose the new kit when opening CMakeLists.txt. +## Android + +TODO + +## Nintendo Switch + +### Prerequisites + +1. Set up [`dkp-pacman`](https://devkitpro.org/wiki/devkitPro_pacman). +2. Install dependency packages: +``` +sudo dkp-pacman -S switch-dev dkp-toolchain-vars switch-mesa switch-libdrm_nouveau switch-sdl2 +``` +3. Make sure the `DEVKITPRO` environment variable is set to the devkitPro SDK root: +``` +export DEVKITPRO=/opt/devkitpro +``` +4. Install libsolder: +``` +source $DEVKITPRO/switchvars.sh +git clone https://github.com/fgsfdsfgs/libsolder.git +make -C libsolder install +``` + +### Building using CMake +``` +mkdir build && cd build +aarch64-none-elf-cmake -G"Unix Makefiles" -DCMAKE_PROJECT_HLSDK-PORTABLE_INCLUDE="$DEVKITPRO/portlibs/switch/share/SolderShim.cmake" .. +make -j +``` + +### Building using waf +``` +./waf configure -T release --nswitch +./waf build +``` + +## PlayStation Vita + +### Prerequisites + +1. Set up [VitaSDK](https://vitasdk.org/). +2. Install [vita-rtld](https://github.com/fgsfdsfgs/vita-rtld): + ``` + git clone https://github.com/fgsfdsfgs/vita-rtld.git && cd vita-rtld + mkdir build && cd build + cmake -DCMAKE_BUILD_TYPE=Release .. + make -j2 install + ``` + +### Building with waf: +``` +./waf configure -T release --psvita +./waf build +``` + +### Building with CMake: +``` +mkdir build && cd build +cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="$VITASDK/share/vita.toolchain.cmake" -DCMAKE_PROJECT_HLSDK-PORTABLE_INCLUDE="$VITASDK/share/vrtld_shim.cmake" .. +make -j +``` + +## Other platforms + +Building on other architectures (e.g x86_64 or arm) and POSIX-compliant OSes (e.g. FreeBSD) is supported. + +### Prerequisites + +Install C and C++ compilers (like gcc or clang), cmake and make. + +### Building + +``` +cmake -B build -S . +cmake --build build +``` + +### Building with waf + +To use waf, you need to install python (2.7 minimum) + +``` +(./waf configure -T release) +(./waf) +``` + +## Build options + +Some useful build options that can be set during the cmake step. + +* **GOLDSOURCE_SUPPORT** - allows to turn off/on the support for GoldSource input. Set to **ON** by default on Windows and Linux, **OFF** on other platforms. +* **USE_VGUI** - whether to use VGUI library. **OFF** by default. You need to init `vgui_support` submodule in order to build with VGUI. + +This list is incomplete. Look at `CMakeLists.txt` to see all available options. + +Prepend option names with `-D` when passing to cmake. Boolean options can take values **OFF** and **ON**. Example: + +``` +cmake .. -DUSE_VGUI=ON -DGOLDSOURCE_SUPPORT=ON -DCROWBAR_IDLE_ANIM=ON -DCROWBAR_FIX_RAPID_CROWBAR=ON +``` diff --git a/appveyor.yml b/appveyor.yml index eb39ee2d..044bb512 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,28 +1,28 @@ version: 1.0.{build} -branches: - only: - - master - environment: matrix: - - os: Visual Studio 2013 - GENERATOR_NAME: "Visual Studio 12 2013" - os: Visual Studio 2015 GENERATOR_NAME: "Visual Studio 14 2015" # TODO: Uncomment when AppVeyor will provide XP toolchain for VS2017 # - os: Visual Studio 2017 # GENERATOR_NAME: "Visual Studio 15 2017" -clone_folder: c:\projects\xash\hlsdk-xash3d +clone_folder: c:\projects\xash\hlsdk-portable build: - project: INSTALL.vcxproj + project: build/INSTALL.vcxproj verbosity: normal configuration: - Debug + - Release before_build: - git submodule update --init --recursive - - cmake -G "%GENERATOR_NAME%" + - cmake -G "%GENERATOR_NAME%" -B build -DCMAKE_INSTALL_PREFIX="dist" + +artifacts: + - path: dist + name: hlsdk-msvc + type: zip diff --git a/cl_dll/Android.mk b/cl_dll/Android.mk index df6130ed..9cb79970 100755 --- a/cl_dll/Android.mk +++ b/cl_dll/Android.mk @@ -73,7 +73,6 @@ SRCS+=./input_mouse.cpp #SRCS+=./inputw32.cpp SRCS+=./menu.cpp SRCS+=./message.cpp -SRCS+=./overview.cpp SRCS+=./parsemsg.cpp SRCS_C+=../pm_shared/pm_debug.c SRCS_C+=../pm_shared/pm_math.c diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index 1143eefe..45c24b91 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -20,13 +20,12 @@ # SOFTWARE. # -cmake_minimum_required(VERSION 2.6.0) +cmake_minimum_required(VERSION 2.8.12) project (CLDLL) set (CLDLL_LIBRARY client) - -add_definitions(-DCLIENT_WEAPONS -DCLIENT_DLL) +add_definitions(-DCLIENT_DLL) if(NOT MSVC) add_compile_options(-fno-exceptions) # GCC/Clang flag @@ -45,6 +44,15 @@ if (GOLDSOURCE_SUPPORT) add_definitions(-DGOLDSOURCE_SUPPORT) endif() +if (USE_VGUI) + add_definitions(-DUSE_VGUI) + if (USE_NOVGUI_MOTD) + add_definitions(-DUSE_NOVGUI_MOTD) + endif() + if (USE_NOVGUI_SCOREBOARD) + add_definitions(-DUSE_NOVGUI_SCOREBOARD) + endif() +endif() set (CLDLL_SOURCES ../dlls/crossbow.cpp @@ -93,7 +101,6 @@ set (CLDLL_SOURCES input_xash3d.cpp menu.cpp message.cpp - overview.cpp parsemsg.cpp ../pm_shared/pm_debug.c ../pm_shared/pm_math.c @@ -107,11 +114,52 @@ set (CLDLL_SOURCES train.cpp tri.cpp util.cpp - view.cpp - scoreboard.cpp - MOTD.cpp) + view.cpp) -include_directories (. hl/ ../dlls ../dlls/wpn_shared ../common ../engine ../pm_shared ../game_shared ../public ../utils/false_vgui/include) +if (USE_VGUI) + list(APPEND CLDLL_SOURCES + vgui_int.cpp + vgui_ClassMenu.cpp + vgui_ConsolePanel.cpp + vgui_ControlConfigPanel.cpp + vgui_CustomObjects.cpp + vgui_MOTDWindow.cpp + vgui_SchemeManager.cpp + vgui_ScorePanel.cpp + vgui_TeamFortressViewport.cpp + vgui_SpectatorPanel.cpp + vgui_teammenu.cpp + voice_status.cpp + ../game_shared/vgui_checkbutton2.cpp + ../game_shared/vgui_grid.cpp + ../game_shared/vgui_helpers.cpp + ../game_shared/vgui_listbox.cpp + ../game_shared/vgui_loadtga.cpp + ../game_shared/vgui_scrollbar2.cpp + ../game_shared/vgui_slider2.cpp + ../game_shared/voice_banmgr.cpp + ) + if (USE_NOVGUI_MOTD) + list(APPEND CLDLL_SOURCES MOTD.cpp) + endif() + if (USE_NOVGUI_SCOREBOARD) + list(APPEND CLDLL_SOURCES scoreboard.cpp) + endif() +else() + list(APPEND CLDLL_SOURCES + MOTD.cpp + scoreboard.cpp) +endif() + +include_directories (. hl/ ../dlls ../dlls/wpn_shared ../common ../engine ../pm_shared ../game_shared ../public) + +if (USE_VGUI) + SET(CMAKE_SKIP_RPATH TRUE) + link_directories(${CMAKE_SOURCE_DIR}/vgui_support/vgui-dev/lib) + include_directories(../vgui_support/vgui-dev/include) +else() + include_directories(../utils/fake_vgui/include) +endif() if(USE_VOICEMGR) #set(CLDLL_SOURCES @@ -121,24 +169,45 @@ if(USE_VOICEMGR) endif() add_library (${CLDLL_LIBRARY} SHARED ${CLDLL_SOURCES}) + if (GOLDSOURCE_SUPPORT) target_link_libraries( ${CLDLL_LIBRARY} ${CMAKE_DL_LIBS} ) endif() +if (USE_VGUI) + if (WIN32) + add_library(vgui SHARED IMPORTED) + set_property(TARGET vgui PROPERTY IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/vgui_support/vgui-dev/lib/win32_vc6/vgui.dll") + set_property(TARGET vgui PROPERTY IMPORTED_IMPLIB "${CMAKE_SOURCE_DIR}/vgui_support/vgui-dev/lib/win32_vc6/vgui.lib") + target_link_libraries(${CLDLL_LIBRARY} vgui) + elseif(APPLE) + target_link_libraries(${CLDLL_LIBRARY} "-Wl,--no-undefined -L${CMAKE_SOURCE_DIR}/vgui_support/vgui-dev/lib vgui.dylib") + else() + target_link_libraries(${CLDLL_LIBRARY} :vgui.so) + endif() +endif() + +if(WIN32) + target_link_libraries( ${CLDLL_LIBRARY} user32.lib ) + if (GOLDSOURCE_SUPPORT) + target_link_libraries( ${CLDLL_LIBRARY} winmm.lib ) + endif() +endif() + set_target_properties (${CLDLL_LIBRARY} PROPERTIES POSITION_INDEPENDENT_CODE 1) -if(APPLE OR WIN32 OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") +if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Android") set(CLDLL_NAME "client") - if(64BIT) - set(CLDLL_NAME "client64") - endif() - set_target_properties(${CLDLL_LIBRARY} PROPERTIES OUTPUT_NAME ${CLDLL_NAME} PREFIX "") endif() +if(MSVC) + set_property(TARGET ${CLDLL_LIBRARY} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +endif() + install( TARGETS ${CLDLL_LIBRARY} DESTINATION "${GAMEDIR}/${CLIENT_INSTALL_DIR}/" PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE diff --git a/cl_dll/GameStudioModelRenderer.cpp b/cl_dll/GameStudioModelRenderer.cpp index 570b3375..3a720ff3 100644 --- a/cl_dll/GameStudioModelRenderer.cpp +++ b/cl_dll/GameStudioModelRenderer.cpp @@ -18,8 +18,6 @@ #include #include -#include -#include #include "studio_util.h" #include "r_studioint.h" diff --git a/cl_dll/GameStudioModelRenderer_Sample.cpp b/cl_dll/GameStudioModelRenderer_Sample.cpp index ee8e8f9c..a840f393 100644 --- a/cl_dll/GameStudioModelRenderer_Sample.cpp +++ b/cl_dll/GameStudioModelRenderer_Sample.cpp @@ -18,8 +18,6 @@ #include #include -#include -#include #include "studio_util.h" #include "r_studioint.h" diff --git a/cl_dll/MOTD.cpp b/cl_dll/MOTD.cpp index 439fb9c4..1ca1c0f8 100644 --- a/cl_dll/MOTD.cpp +++ b/cl_dll/MOTD.cpp @@ -26,13 +26,17 @@ #include #include +#if !USE_VGUI || USE_NOVGUI_MOTD DECLARE_MESSAGE( m_MOTD, MOTD ) +#endif int CHudMOTD::Init( void ) { gHUD.AddHudElem( this ); +#if !USE_VGUI || USE_NOVGUI_MOTD HOOK_MESSAGE( MOTD ); +#endif m_bShow = false; @@ -66,7 +70,7 @@ int CHudMOTD::Draw( float fTime ) if( !m_bShow ) return 1; gHUD.m_iNoConsolePrint |= 1 << 1; - bool bScroll; + //bool bScroll; // find the top of where the MOTD should be drawn, so the whole thing is centered in the screen int ypos = ( ScreenHeight - LINE_HEIGHT * m_iLines ) / 2; // shift it up slightly char *ch = m_szMOTD; @@ -80,13 +84,13 @@ int CHudMOTD::Draw( float fTime ) { ypos = ROW_RANGE_MIN + 7 + scroll; if( ypos > ROW_RANGE_MIN + 4 ) - scroll-= ( ypos - ( ROW_RANGE_MIN + 4 ) ) / 3.0; + scroll-= ( ypos - ( ROW_RANGE_MIN + 4 ) ) / 3.0f; if( ypos + height < ROW_RANGE_MAX ) - scroll+= ( ROW_RANGE_MAX - ( ypos + height ) ) / 3.0; + scroll+= ( ROW_RANGE_MAX - ( ypos + height ) ) / 3.0f; ypos_r = ROW_RANGE_MIN; height = ROW_RANGE_MAX; } - int ymax = ypos + height; + // int ymax = ypos + height; if( xmax > ScreenWidth - 30 ) xmax = ScreenWidth - 30; gHUD.DrawDarkRectangle( xpos - 5, ypos_r - 5, xmax - xpos + 10, height + 10 ); while( *ch ) @@ -130,7 +134,8 @@ int CHudMOTD::MsgFunc_MOTD( const char *pszName, int iSize, void *pbuf ) BEGIN_READ( pbuf, iSize ); int is_finished = READ_BYTE(); - strncat( m_szMOTD, READ_STRING(), sizeof(m_szMOTD) - 1 ); + strncat( m_szMOTD, READ_STRING(), sizeof(m_szMOTD) - strlen(m_szMOTD) - 1 ); + m_szMOTD[sizeof(m_szMOTD) - 1] = '\0'; if( is_finished ) { @@ -157,7 +162,7 @@ int CHudMOTD::MsgFunc_MOTD( const char *pszName, int iSize, void *pbuf ) if( length > m_iMaxLength ) { m_iMaxLength = length; - length = 0; + // length = 0; } m_bShow = true; } diff --git a/cl_dll/Makefile b/cl_dll/Makefile deleted file mode 100644 index 0ff4dadf..00000000 --- a/cl_dll/Makefile +++ /dev/null @@ -1,93 +0,0 @@ -CC?=gcc -CXX?=g++ -SRCS+=../dlls/crossbow.cpp -SRCS+=../dlls/crowbar.cpp -SRCS+=../dlls/egon.cpp -SRCS+=./ev_hldm.cpp -SRCS+=../dlls/gauss.cpp -SRCS+=../dlls/handgrenade.cpp -SRCS+=./hl/hl_baseentity.cpp -SRCS+=./hl/hl_events.cpp -SRCS+=./hl/hl_objects.cpp -SRCS+=./hl/hl_weapons.cpp -SRCS+=../dlls/glock.cpp -SRCS+=../dlls/hornetgun.cpp -#SRCS+=../common/interface.cpp -SRCS+=../dlls/mp5.cpp -SRCS+=../dlls/python.cpp -SRCS+=../dlls/rpg.cpp -SRCS+=../dlls/satchel.cpp -SRCS+=../dlls/shotgun.cpp -SRCS+=../dlls/squeakgrenade.cpp -SRCS+=../dlls/tripmine.cpp -#SRCS+=../game_shared/voice_banmgr.cpp -#SRCS+=../game_shared/voice_status.cpp -SRCS+=./ammo.cpp -SRCS+=./ammo_secondary.cpp -SRCS+=./ammohistory.cpp -SRCS+=./battery.cpp -SRCS+=./cdll_int.cpp -SRCS+=./com_weapons.cpp -SRCS+=./death.cpp -SRCS+=./demo.cpp -SRCS+=./entity.cpp -SRCS+=./ev_common.cpp -SRCS+=./events.cpp -SRCS+=./flashlight.cpp -SRCS+=./GameStudioModelRenderer.cpp -SRCS+=./geiger.cpp -SRCS+=./health.cpp -SRCS+=./hud.cpp -SRCS+=./hud_msg.cpp -SRCS+=./hud_redraw.cpp -#SRCS+=./hud_servers.cpp -SRCS+=./hud_spectator.cpp -SRCS+=./hud_update.cpp -SRCS+=./in_camera.cpp -SRCS+=./input.cpp -SRCS+=./input_mouse.cpp -SRCS+=./input_goldsource.cpp -SRCS+=./menu.cpp -SRCS+=./message.cpp -SRCS+=./overview.cpp -SRCS+=./parsemsg.cpp -SRCS_C+=../pm_shared/pm_debug.c -SRCS_C+=../pm_shared/pm_math.c -SRCS_C+=../pm_shared/pm_shared.c -SRCS+=./saytext.cpp -SRCS+=./status_icons.cpp -SRCS+=./statusbar.cpp -SRCS+=./studio_util.cpp -SRCS+=./StudioModelRenderer.cpp -SRCS+=./text_message.cpp -SRCS+=./train.cpp -SRCS+=./tri.cpp -SRCS+=./util.cpp -SRCS+=./view.cpp -SRCS+=./input_xash3d.cpp -SRCS+=./scoreboard.cpp -SRCS+=./MOTD.cpp -INCLUDES = -I../common -I. -I../game_shared -I../pm_shared -I../engine -I../dlls -I../utils/false_vgui/include -DEFINES = -Wno-write-strings -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -CFLAGS = -m32 -OBJS = $(SRCS:.cpp=.o) $(SRCS_C:.c=.o) - -LIBS=-lm -ifeq ($(GOLDSOURCE_SUPPORT),1) - DEFINES += -DGOLDSOURCE_SUPPORT -endif - -ifeq ($(shell uname -s),Linux) - LIBS += -ldl -endif - -%.o : %.c - $(CC) $(CFLAGS) $(INCLUDES) $(DEFINES) -fPIC -c $< -o $@ - -%.o : %.cpp - $(CXX) $(CFLAGS) $(INCLUDES) $(DEFINES) -fPIC -c $< -o $@ -client.so : $(OBJS) - $(CXX) $(CFLAGS) $(OBJS) -o client.so -shared -Wl,--no-undefined -fPIC $(LIBS) - -clean: - $(RM) $(OBJS) diff --git a/cl_dll/StudioModelRenderer.cpp b/cl_dll/StudioModelRenderer.cpp index a9859244..fc168dfa 100644 --- a/cl_dll/StudioModelRenderer.cpp +++ b/cl_dll/StudioModelRenderer.cpp @@ -20,8 +20,6 @@ #include #include -#include -#include #include "studio_util.h" #include "r_studioint.h" @@ -138,27 +136,27 @@ void CStudioModelRenderer::StudioCalcBoneAdj( float dadt, float *adj, const byte int a, b; a = ( pcontroller1[j] + 128 ) % 256; b = ( pcontroller2[j] + 128 ) % 256; - value = ( ( a * dadt ) + ( b * ( 1 - dadt ) ) - 128 ) * ( 360.0 / 256.0 ) + pbonecontroller[j].start; + value = ( ( a * dadt ) + ( b * ( 1.0f - dadt ) ) - 128.0f ) * ( 360.0f / 256.0f ) + pbonecontroller[j].start; } else { - value = ( ( pcontroller1[i] * dadt + ( pcontroller2[i] ) * ( 1.0 - dadt ) ) ) * ( 360.0 / 256.0 ) + pbonecontroller[j].start; + value = ( ( pcontroller1[i] * dadt + ( pcontroller2[i] ) * ( 1.0f - dadt ) ) ) * ( 360.0f / 256.0f ) + pbonecontroller[j].start; } } else { - value = ( pcontroller1[i] * dadt + pcontroller2[i] * ( 1.0 - dadt ) ) / 255.0; - if( value < 0 ) value = 0; - if( value > 1.0 ) value = 1.0; - value = ( 1.0 - value ) * pbonecontroller[j].start + value * pbonecontroller[j].end; + value = ( pcontroller1[i] * dadt + pcontroller2[i] * ( 1.0f - dadt ) ) / 255.0f; + if( value < 0.0f ) value = 0.0f; + if( value > 1.0f ) value = 1.0f; + value = ( 1.0f - value ) * pbonecontroller[j].start + value * pbonecontroller[j].end; } // Con_DPrintf( "%d %d %f : %f\n", m_pCurrentEntity->curstate.controller[j], m_pCurrentEntity->latched.prevcontroller[j], value, dadt ); } else { - value = mouthopen / 64.0; - if( value > 1.0 ) value = 1.0; - value = ( 1.0 - value ) * pbonecontroller[j].start + value * pbonecontroller[j].end; + value = mouthopen / 64.0f; + if( value > 1.0f ) value = 1.0f; + value = ( 1.0f - value ) * pbonecontroller[j].start + value * pbonecontroller[j].end; // Con_DPrintf( "%d %f\n", mouthopen, value ); } switch( pbonecontroller[j].type & STUDIO_TYPES ) @@ -166,7 +164,7 @@ void CStudioModelRenderer::StudioCalcBoneAdj( float dadt, float *adj, const byte case STUDIO_XR: case STUDIO_YR: case STUDIO_ZR: - adj[j] = value * ( M_PI / 180.0 ); + adj[j] = value * ( M_PI_F / 180.0f ); break; case STUDIO_X: case STUDIO_Y: @@ -305,7 +303,7 @@ void CStudioModelRenderer::StudioCalcBonePosition( int frame, float s, mstudiobo // and there's more data in the span if( panimvalue->num.valid > k + 1 ) { - pos[j] += ( panimvalue[k + 1].value * ( 1.0 - s ) + s * panimvalue[k + 2].value ) * pbone->scale[j]; + pos[j] += ( panimvalue[k + 1].value * ( 1.0f - s ) + s * panimvalue[k + 2].value ) * pbone->scale[j]; } else { @@ -317,7 +315,7 @@ void CStudioModelRenderer::StudioCalcBonePosition( int frame, float s, mstudiobo // are we at the end of the repeating values section and there's another section with data? if( panimvalue->num.total <= k + 1 ) { - pos[j] += ( panimvalue[panimvalue->num.valid].value * ( 1.0 - s ) + s * panimvalue[panimvalue->num.valid + 2].value ) * pbone->scale[j]; + pos[j] += ( panimvalue[panimvalue->num.valid].value * ( 1.0f - s ) + s * panimvalue[panimvalue->num.valid + 2].value ) * pbone->scale[j]; } else { @@ -344,12 +342,12 @@ void CStudioModelRenderer::StudioSlerpBones( vec4_t q1[], float pos1[][3], vec4_ vec4_t q3; float s1; - if( s < 0 ) - s = 0; - else if( s > 1.0 ) - s = 1.0; + if( s < 0.0f ) + s = 0.0f; + else if( s > 1.0f ) + s = 1.0f; - s1 = 1.0 - s; + s1 = 1.0f - s; for( i = 0; i < m_pStudioHeader->numbones; i++ ) { @@ -410,17 +408,17 @@ void CStudioModelRenderer::StudioPlayerBlend( mstudioseqdesc_t *pseqdesc, int *p *pBlend = ( *pPitch * 3 ); if( *pBlend < pseqdesc->blendstart[0] ) { - *pPitch -= pseqdesc->blendstart[0] / 3.0; + *pPitch -= pseqdesc->blendstart[0] / 3.0f; *pBlend = 0; } else if( *pBlend > pseqdesc->blendend[0] ) { - *pPitch -= pseqdesc->blendend[0] / 3.0; + *pPitch -= pseqdesc->blendend[0] / 3.0f; *pBlend = 255; } else { - if( pseqdesc->blendend[0] - pseqdesc->blendstart[0] < 0.1 ) // catch qc error + if( pseqdesc->blendend[0] - pseqdesc->blendstart[0] < 0.1f ) // catch qc error *pBlend = 127; else *pBlend = 255 * ( *pBlend - pseqdesc->blendstart[0] ) / ( pseqdesc->blendend[0] - pseqdesc->blendstart[0] ); @@ -475,11 +473,11 @@ void CStudioModelRenderer::StudioSetUpTransform( int trivial_accept ) if( m_fDoInterp ) { // ugly hack to interpolate angle, position. current is reached 0.1 seconds after being set - f = f - 1.0; + f = f - 1.0f; } else { - f = 0; + f = 0.0f; } for( i = 0; i < 3; i++ ) @@ -489,7 +487,7 @@ void CStudioModelRenderer::StudioSetUpTransform( int trivial_accept ) // NOTE: Because multiplayer lag can be relatively large, we don't want to cap // f at 1.5 anymore. - //if( f > -1.0 && f < 1.5 ) {} + //if( f > -1.0f && f < 1.5f ) {} //Con_DPrintf( "%.0f %.0f\n",m_pCurrentEntity->msg_angles[0][YAW], m_pCurrentEntity->msg_angles[1][YAW] ); for( i = 0; i < 3; i++ ) { @@ -499,13 +497,13 @@ void CStudioModelRenderer::StudioSetUpTransform( int trivial_accept ) ang2 = m_pCurrentEntity->latched.prevangles[i]; d = ang1 - ang2; - if( d > 180 ) + if( d > 180.0f ) { - d -= 360; + d -= 360.0f; } - else if( d < -180 ) + else if( d < -180.0f ) { - d += 360; + d += 360.0f; } angles[i] += d * f; @@ -547,9 +545,9 @@ void CStudioModelRenderer::StudioSetUpTransform( int trivial_accept ) { for( i = 0; i < 4; i++ ) { - (*m_paliastransform)[0][i] *= m_fSoftwareXScale * ( 1.0 / ( ZISCALE * 0x10000 ) ); - (*m_paliastransform)[1][i] *= m_fSoftwareYScale * ( 1.0 / ( ZISCALE * 0x10000 ) ); - (*m_paliastransform)[2][i] *= 1.0 / ( ZISCALE * 0x10000 ); + (*m_paliastransform)[0][i] *= m_fSoftwareXScale * ( 1.0f / ( ZISCALE * 0x10000 ) ); + (*m_paliastransform)[1][i] *= m_fSoftwareYScale * ( 1.0f / ( ZISCALE * 0x10000 ) ); + (*m_paliastransform)[2][i] *= 1.0f / ( ZISCALE * 0x10000 ); } } } @@ -567,14 +565,14 @@ StudioEstimateInterpolant */ float CStudioModelRenderer::StudioEstimateInterpolant( void ) { - float dadt = 1.0; + float dadt = 1.0f; - if( m_fDoInterp && ( m_pCurrentEntity->curstate.animtime >= m_pCurrentEntity->latched.prevanimtime + 0.01 ) ) + if( m_fDoInterp && ( m_pCurrentEntity->curstate.animtime >= m_pCurrentEntity->latched.prevanimtime + 0.01f ) ) { - dadt = ( m_clTime - m_pCurrentEntity->curstate.animtime ) / 0.1; - if( dadt > 2.0 ) + dadt = ( m_clTime - m_pCurrentEntity->curstate.animtime ) / 0.1f; + if( dadt > 2.0f ) { - dadt = 2.0; + dadt = 2.0f; } } return dadt; @@ -598,14 +596,14 @@ void CStudioModelRenderer::StudioCalcRotations( float pos[][3], vec4_t *q, mstud if( f > pseqdesc->numframes - 1 ) { - f = 0; // bah, fix this bug with changing sequences too fast + f = 0.0f; // bah, fix this bug with changing sequences too fast } // BUG ( somewhere else ) but this code should validate this data. // This could cause a crash if the frame # is negative, so we'll go ahead // and clamp it here - else if( f < -0.01 ) + else if( f < -0.01f ) { - f = -0.01; + f = -0.01f; } frame = (int)f; @@ -635,18 +633,18 @@ void CStudioModelRenderer::StudioCalcRotations( float pos[][3], vec4_t *q, mstud if( pseqdesc->motiontype & STUDIO_X ) { - pos[pseqdesc->motionbone][0] = 0.0; + pos[pseqdesc->motionbone][0] = 0.0f; } if( pseqdesc->motiontype & STUDIO_Y ) { - pos[pseqdesc->motionbone][1] = 0.0; + pos[pseqdesc->motionbone][1] = 0.0f; } if( pseqdesc->motiontype & STUDIO_Z ) { - pos[pseqdesc->motionbone][2] = 0.0; + pos[pseqdesc->motionbone][2] = 0.0f; } - s = 0 * ( ( 1.0 - ( f - (int)( f ) ) ) / ( pseqdesc->numframes ) ) * m_pCurrentEntity->curstate.framerate; + s = 0 * ( ( 1.0f - ( f - (int)( f ) ) ) / ( pseqdesc->numframes ) ) * m_pCurrentEntity->curstate.framerate; if( pseqdesc->motiontype & STUDIO_LX ) { @@ -679,15 +677,15 @@ void CStudioModelRenderer::StudioFxTransform( cl_entity_t *ent, float transform[ int axis = gEngfuncs.pfnRandomLong( 0, 1 ); if( axis == 1 ) // Choose between x & z axis = 2; - VectorScale( transform[axis], gEngfuncs.pfnRandomFloat( 1, 1.484 ), transform[axis] ); + VectorScale( transform[axis], gEngfuncs.pfnRandomFloat( 1.0f, 1.484f ), transform[axis] ); } else if( gEngfuncs.pfnRandomLong( 0, 49 ) == 0 ) { float offset; - int axis = gEngfuncs.pfnRandomLong(0,1); + /*int axis = gEngfuncs.pfnRandomLong(0,1); if( axis == 1 ) // Choose between x & z - axis = 2; - offset = gEngfuncs.pfnRandomFloat( -10, 10 ); + axis = 2;*/ + offset = gEngfuncs.pfnRandomFloat( -10.0f, 10.0f ); transform[gEngfuncs.pfnRandomLong( 0, 2 )][3] += offset; } break; @@ -695,7 +693,7 @@ void CStudioModelRenderer::StudioFxTransform( cl_entity_t *ent, float transform[ { float scale; - scale = 1.0 + ( m_clTime - ent->curstate.animtime ) * 10.0; + scale = 1.0f + ( m_clTime - ent->curstate.animtime ) * 10.0f; if( scale > 2 ) // Don't blow up more than 200% scale = 2; transform[0][1] *= scale; @@ -734,7 +732,7 @@ float CStudioModelRenderer::StudioEstimateFrame( mstudioseqdesc_t *pseqdesc ) if( pseqdesc->numframes <= 1 ) { - f = 0; + f = 0.0; } else { @@ -1188,10 +1186,10 @@ void CStudioModelRenderer::StudioEstimateGait( entity_state_t *pplayer ) vec3_t est_velocity; dt = ( m_clTime - m_clOldTime ); - if( dt < 0 ) - dt = 0; - else if( dt > 1.0 ) - dt = 1; + if( dt < 0.0f ) + dt = 0.0f; + else if( dt > 1.0f ) + dt = 1.0f; if( dt == 0 || m_pPlayerInfo->renderframe == m_nFrameCount ) { @@ -1221,29 +1219,29 @@ void CStudioModelRenderer::StudioEstimateGait( entity_state_t *pplayer ) if( est_velocity[1] == 0 && est_velocity[0] == 0 ) { float flYawDiff = m_pCurrentEntity->angles[YAW] - m_pPlayerInfo->gaityaw; - flYawDiff = flYawDiff - (int)( flYawDiff / 360 ) * 360; - if( flYawDiff > 180 ) - flYawDiff -= 360; - if( flYawDiff < -180 ) - flYawDiff += 360; + flYawDiff = flYawDiff - (int)( flYawDiff / 360.0f ) * 360.0f; + if( flYawDiff > 180.0f ) + flYawDiff -= 360.0f; + if( flYawDiff < -180.0f ) + flYawDiff += 360.0f; - if( dt < 0.25 ) - flYawDiff *= dt * 4; + if( dt < 0.25f ) + flYawDiff *= dt * 4.0f; else flYawDiff *= dt; m_pPlayerInfo->gaityaw += flYawDiff; - m_pPlayerInfo->gaityaw = m_pPlayerInfo->gaityaw - (int)( m_pPlayerInfo->gaityaw / 360 ) * 360; + m_pPlayerInfo->gaityaw = m_pPlayerInfo->gaityaw - (int)( m_pPlayerInfo->gaityaw / 360.0f ) * 360.0f; m_flGaitMovement = 0; } else { - m_pPlayerInfo->gaityaw = ( atan2( est_velocity[1], est_velocity[0] ) * 180 / M_PI ); - if( m_pPlayerInfo->gaityaw > 180 ) - m_pPlayerInfo->gaityaw = 180; - if( m_pPlayerInfo->gaityaw < -180 ) - m_pPlayerInfo->gaityaw = -180; + m_pPlayerInfo->gaityaw = ( atan2( est_velocity[1], est_velocity[0] ) * 180.0f / M_PI_F ); + if( m_pPlayerInfo->gaityaw > 180.0f ) + m_pPlayerInfo->gaityaw = 180.0f; + if( m_pPlayerInfo->gaityaw < -180.0f ) + m_pPlayerInfo->gaityaw = -180.0f; } } @@ -1277,10 +1275,10 @@ void CStudioModelRenderer::StudioProcessGait( entity_state_t *pplayer ) // Con_DPrintf( "%f %d\n", m_pCurrentEntity->angles[PITCH], m_pCurrentEntity->blending[0] ); dt = ( m_clTime - m_clOldTime ); - if( dt < 0 ) - dt = 0; - else if( dt > 1.0 ) - dt = 1; + if( dt < 0.0f ) + dt = 0.0f; + else if( dt > 1.0f ) + dt = 1.0f; StudioEstimateGait( pplayer ); @@ -1288,38 +1286,38 @@ void CStudioModelRenderer::StudioProcessGait( entity_state_t *pplayer ) // calc side to side turning flYaw = m_pCurrentEntity->angles[YAW] - m_pPlayerInfo->gaityaw; - flYaw = flYaw - (int)( flYaw / 360 ) * 360; - if( flYaw < -180 ) - flYaw = flYaw + 360; - if( flYaw > 180 ) - flYaw = flYaw - 360; + flYaw = flYaw - (int)( flYaw / 360.0f ) * 360.0f; + if( flYaw < -180.0f ) + flYaw = flYaw + 360.0f; + if( flYaw > 180.0f ) + flYaw = flYaw - 360.0f; - if( flYaw > 120 ) + if( flYaw > 120.0f ) { - m_pPlayerInfo->gaityaw = m_pPlayerInfo->gaityaw - 180; + m_pPlayerInfo->gaityaw = m_pPlayerInfo->gaityaw - 180.0f; m_flGaitMovement = -m_flGaitMovement; - flYaw = flYaw - 180; + flYaw = flYaw - 180.0f; } - else if( flYaw < -120 ) + else if( flYaw < -120.0f ) { - m_pPlayerInfo->gaityaw = m_pPlayerInfo->gaityaw + 180; + m_pPlayerInfo->gaityaw = m_pPlayerInfo->gaityaw + 180.0f; m_flGaitMovement = -m_flGaitMovement; - flYaw = flYaw + 180; + flYaw = flYaw + 180.0f; } // adjust torso - m_pCurrentEntity->curstate.controller[0] = ( ( flYaw / 4.0 ) + 30 ) / ( 60.0 / 255.0 ); - m_pCurrentEntity->curstate.controller[1] = ( ( flYaw / 4.0 ) + 30 ) / ( 60.0 / 255.0 ); - m_pCurrentEntity->curstate.controller[2] = ( ( flYaw / 4.0 ) + 30 ) / ( 60.0 / 255.0 ); - m_pCurrentEntity->curstate.controller[3] = ( ( flYaw / 4.0 ) + 30 ) / ( 60.0 / 255.0 ); + m_pCurrentEntity->curstate.controller[0] = ( ( flYaw / 4.0f ) + 30.0f ) / ( 60.0f / 255.0f ); + m_pCurrentEntity->curstate.controller[1] = ( ( flYaw / 4.0f ) + 30.0f ) / ( 60.0f / 255.0f ); + m_pCurrentEntity->curstate.controller[2] = ( ( flYaw / 4.0f ) + 30.0f ) / ( 60.0f / 255.0f ); + m_pCurrentEntity->curstate.controller[3] = ( ( flYaw / 4.0f ) + 30.0f ) / ( 60.0f / 255.0f ); m_pCurrentEntity->latched.prevcontroller[0] = m_pCurrentEntity->curstate.controller[0]; m_pCurrentEntity->latched.prevcontroller[1] = m_pCurrentEntity->curstate.controller[1]; m_pCurrentEntity->latched.prevcontroller[2] = m_pCurrentEntity->curstate.controller[2]; m_pCurrentEntity->latched.prevcontroller[3] = m_pCurrentEntity->curstate.controller[3]; m_pCurrentEntity->angles[YAW] = m_pPlayerInfo->gaityaw; - if( m_pCurrentEntity->angles[YAW] < -0 ) - m_pCurrentEntity->angles[YAW] += 360; + if( m_pCurrentEntity->angles[YAW] < -0.0f ) + m_pCurrentEntity->angles[YAW] += 360.0f; m_pCurrentEntity->latched.prevangles[YAW] = m_pCurrentEntity->angles[YAW]; if( pplayer->gaitsequence >= m_pStudioHeader->numseq ) diff --git a/cl_dll/ammo.cpp b/cl_dll/ammo.cpp index 4a4437bb..0e3d0a07 100644 --- a/cl_dll/ammo.cpp +++ b/cl_dll/ammo.cpp @@ -27,6 +27,9 @@ #include #include "ammohistory.h" +#if USE_VGUI +#include "vgui_TeamFortressViewport.h" +#endif WEAPON *gpActiveSel; // NULL means off, 1 means just the menu bar, otherwise // this points to the active weapon menu item @@ -77,7 +80,7 @@ void WeaponsResource::LoadWeaponSprites( WEAPON *pWeapon ) else iRes = 640; - char sz[128]; + char sz[256]; if( !pWeapon ) return; @@ -356,7 +359,7 @@ void CHudAmmo::Think( void ) { WEAPON *p = gWR.GetWeapon( i ); - if( p ) + if( p && p->iId ) { if( gHUD.m_iWeaponBits & ( 1 << p->iId ) ) gWR.PickupWeapon( p ); @@ -673,10 +676,11 @@ int CHudAmmo::MsgFunc_WeaponList( const char *pszName, int iSize, void *pbuf ) // Slot button pressed void CHudAmmo::SlotInput( int iSlot ) { +#if USE_VGUI // Let the Viewport use it first, for menus -// if( gViewPort && gViewPort->SlotInput( iSlot ) ) -// return; - + if( gViewPort && gViewPort->SlotInput( iSlot ) ) + return; +#endif gWR.SelectSlot(iSlot, FALSE, 1); } @@ -864,7 +868,7 @@ int CHudAmmo::Draw( float flTime ) a = (int)Q_max( MIN_ALPHA, m_fFade ); if( m_fFade > 0 ) - m_fFade -= ( gHUD.m_flTimeDelta * 20 ); + m_fFade -= ( (float)gHUD.m_flTimeDelta * 20.0f ); UnpackRGB( r, g, b, RGB_YELLOWISH ); diff --git a/cl_dll/ammo.h b/cl_dll/ammo.h index 57c08805..bb2a7325 100644 --- a/cl_dll/ammo.h +++ b/cl_dll/ammo.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef __AMMO_H__ +#if !defined(__AMMO_H__) #define __AMMO_H__ #define MAX_WEAPON_NAME 128 diff --git a/cl_dll/ammo_secondary.cpp b/cl_dll/ammo_secondary.cpp index 786f862d..4034c86f 100644 --- a/cl_dll/ammo_secondary.cpp +++ b/cl_dll/ammo_secondary.cpp @@ -63,7 +63,7 @@ int CHudAmmoSecondary::Draw( float flTime ) UnpackRGB( r, g, b, RGB_YELLOWISH ); a = (int)Q_max( MIN_ALPHA, m_fFade ); if( m_fFade > 0 ) - m_fFade -= ( gHUD.m_flTimeDelta * 20 ); // slowly lower alpha to fade out icons + m_fFade -= ( (float)gHUD.m_flTimeDelta * 20.0f ); // slowly lower alpha to fade out icons ScaleColors( r, g, b, a ); AmmoWidth = gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).right - gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).left; diff --git a/cl_dll/ammohistory.h b/cl_dll/ammohistory.h index 44edc916..c896941a 100644 --- a/cl_dll/ammohistory.h +++ b/cl_dll/ammohistory.h @@ -16,7 +16,7 @@ // ammohistory.h // #pragma once -#ifndef AMMOHISTORY_H +#if !defined(AMMOHISTORY_H) #define AMMOHISTORY_H // this is the max number of items in each bucket diff --git a/cl_dll/battery.cpp b/cl_dll/battery.cpp index b939a8b1..b6cd9e0b 100644 --- a/cl_dll/battery.cpp +++ b/cl_dll/battery.cpp @@ -78,7 +78,7 @@ int CHudBattery::Draw( float flTime ) wrect_t rc; rc = *m_prc2; - rc.top += m_iHeight * ( (float)( 100 - ( Q_min( 100, m_iBat ) ) ) * 0.01 ); // battery can go from 0 to 100 so * 0.01 goes from 0 to 1 + rc.top += m_iHeight * ( (float)( 100 - ( Q_min( 100, m_iBat ) ) ) * 0.01f ); // battery can go from 0 to 100 so * 0.01 goes from 0 to 1 UnpackRGB( r, g, b, RGB_YELLOWISH ); @@ -91,7 +91,7 @@ int CHudBattery::Draw( float flTime ) if( m_fFade > FADE_TIME ) m_fFade = FADE_TIME; - m_fFade -= ( gHUD.m_flTimeDelta * 20 ); + m_fFade -= ( (float)gHUD.m_flTimeDelta * 20.0f ); if( m_fFade <= 0 ) { a = 128; diff --git a/cl_dll/camera.h b/cl_dll/camera.h index 1ecb9563..1c196c51 100644 --- a/cl_dll/camera.h +++ b/cl_dll/camera.h @@ -8,7 +8,7 @@ // Camera.h -- defines and such for a 3rd person camera // NOTE: must include quakedef.h first #pragma once -#ifndef _CAMERA_H_ +#if !defined(_CAMERA_H_) #define _CAMERA_H_ // pitch, yaw, dist diff --git a/cl_dll/cdll_int.cpp b/cl_dll/cdll_int.cpp index 45bbcd67..17fc06f3 100644 --- a/cl_dll/cdll_int.cpp +++ b/cl_dll/cdll_int.cpp @@ -23,11 +23,18 @@ #include "netadr.h" #include "parsemsg.h" -#if defined(GOLDSOURCE_SUPPORT) && (defined(_WIN32) || defined(__linux__) || defined(__APPLE__)) && (defined(__i386) || defined(_M_IX86)) -#define USE_VGUI_FOR_GOLDSOURCE_SUPPORT +#if USE_VGUI +#include "vgui_int.h" +#include "vgui_TeamFortressViewport.h" +#endif + +#if GOLDSOURCE_SUPPORT && (_WIN32 || __linux__ || __APPLE__) && (__i386 || _M_IX86) +#define USE_FAKE_VGUI !USE_VGUI +#if USE_FAKE_VGUI #include "VGUI_Panel.h" #include "VGUI_App.h" #endif +#endif extern "C" { @@ -38,6 +45,9 @@ extern "C" cl_enginefunc_t gEngfuncs; CHud gHUD; +#if USE_VGUI +TeamFortressViewport *gViewPort = NULL; +#endif mobile_engfuncs_t *gMobileEngfuncs = NULL; extern "C" int g_bhopcap; @@ -124,7 +134,7 @@ HUD_ConnectionlessPacket int DLLEXPORT HUD_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size ) { // Parse stuff from args - int max_buffer_size = *response_buffer_size; + // int max_buffer_size = *response_buffer_size; // Zero it out since we aren't going to respond. // If we wanted to response, we'd write data into response_buffer @@ -157,7 +167,17 @@ int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion ) if( iVersion != CLDLL_INTERFACE_VERSION ) return 0; - memcpy( &gEngfuncs, pEnginefuncs, sizeof(cl_enginefunc_t) ); + // for now filterstuffcmd is last in the engine interface + memcpy( &gEngfuncs, pEnginefuncs, sizeof(cl_enginefunc_t) - sizeof( void * ) ); + + if( gEngfuncs.pfnGetCvarPointer( "cl_filterstuffcmd" ) == 0 ) + { + gEngfuncs.pfnFilteredClientCmd = gEngfuncs.pfnClientCmd; + } + else + { + gEngfuncs.pfnFilteredClientCmd = pEnginefuncs->pfnFilteredClientCmd; + } EV_HookEvents(); @@ -183,7 +203,7 @@ int *HUD_GetRect( void ) return extent; } -#ifdef USE_VGUI_FOR_GOLDSOURCE_SUPPORT +#if USE_FAKE_VGUI class TeamFortressViewport : public vgui::Panel { public: @@ -238,7 +258,7 @@ so the HUD can reinitialize itself. int DLLEXPORT HUD_VidInit( void ) { gHUD.VidInit(); -#ifdef USE_VGUI_FOR_GOLDSOURCE_SUPPORT +#if USE_FAKE_VGUI vgui::Panel* root=(vgui::Panel*)gEngfuncs.VGui_GetPanel(); if (root) { gEngfuncs.Con_Printf( "Root VGUI panel exists\n" ); @@ -256,6 +276,8 @@ int DLLEXPORT HUD_VidInit( void ) } else { gEngfuncs.Con_Printf( "Root VGUI panel does not exist\n" ); } +#elif USE_VGUI + VGui_Startup(); #endif return 1; } @@ -274,6 +296,9 @@ void DLLEXPORT HUD_Init( void ) { InitInput(); gHUD.Init(); +#if USE_VGUI + Scheme_Init(); +#endif gEngfuncs.pfnHookUserMsg( "Bhopcap", __MsgFunc_Bhopcap ); } @@ -337,7 +362,9 @@ Called by engine every frame that client .dll is loaded void DLLEXPORT HUD_Frame( double time ) { -#ifdef USE_VGUI_FOR_GOLDSOURCE_SUPPORT +#if USE_VGUI + GetClientVoiceMgr()->Frame(time); +#elif USE_FAKE_VGUI if (!gViewPort) gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect()); #else @@ -355,7 +382,9 @@ Called when a player starts or stops talking. void DLLEXPORT HUD_VoiceStatus( int entindex, qboolean bTalking ) { - +#if USE_VGUI + GetClientVoiceMgr()->UpdateSpeakerStatus(entindex, bTalking); +#endif } /* diff --git a/cl_dll/cl_dll.h b/cl_dll/cl_dll.h index 6ba3db67..5e5fe905 100644 --- a/cl_dll/cl_dll.h +++ b/cl_dll/cl_dll.h @@ -26,26 +26,31 @@ // - Handling the custum HUD-update packets // #pragma once -#ifndef CL_DLL_H +#if !defined(CL_DLL_H) #define CL_DLL_H typedef unsigned char byte; typedef unsigned short word; typedef float vec_t; -typedef int ( *pfnUserMsgHook )( const char *pszName, int iSize, void *pbuf ); +// redefine +//typedef int ( *pfnUserMsgHook )( const char *pszName, int iSize, void *pbuf ); #include "util_vector.h" #include "../engine/cdll_int.h" #include "../dlls/cdll_dll.h" -#if !defined(_WIN32) +#if !_WIN32 #define _cdecl #endif #include "exportdef.h" #include - -#if defined(__LP64__) || defined(__LLP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) - #define XASH_64BIT +#if HAVE_CMATH +#include +#else +#include +#endif +#if __LP64__ || __LLP64__ || _WIN64 || (__x86_64__ && !__ILP32__) || _M_X64 || __ia64 || _M_IA64 || __aarch64__ || __powerpc64__ + #define XASH_64BIT 1 #endif extern cl_enginefunc_t gEngfuncs; diff --git a/cl_dll/cl_util.h b/cl_dll/cl_util.h index 7ba3bc7e..91615660 100644 --- a/cl_dll/cl_util.h +++ b/cl_dll/cl_util.h @@ -15,12 +15,12 @@ // // cl_util.h // -#ifndef CL_UTIL_H +#if !defined(CL_UTIL_H) #define CL_UTIL_H #include "exportdef.h" #include "cvardef.h" -#ifndef TRUE +#if !defined(TRUE) #define TRUE 1 #define FALSE 0 #endif @@ -108,7 +108,8 @@ inline int TextMessageDrawChar( int x, int y, int number, int r, int g, int b ) inline int DrawConsoleString( int x, int y, const char *string ) { if( hud_textmode->value == 1 ) - return gHUD.DrawHudString( x, y, 9999, (char*)string, 255 * g_hud_text_color[0], 255 * g_hud_text_color[1], 255 * g_hud_text_color[2] ); + return gHUD.DrawHudString( x, y, 9999, (char*)string, (int)( (float)g_hud_text_color[0] * 255.0f ), + (int)( (float)g_hud_text_color[1] * 255.0f ), (int)( (float)g_hud_text_color[2] * 255.0f ) ); return gEngfuncs.pfnDrawConsoleString( x, y, (char*) string ); } diff --git a/cl_dll/com_weapons.cpp b/cl_dll/com_weapons.cpp index 198c533a..854f8689 100644 --- a/cl_dll/com_weapons.cpp +++ b/cl_dll/com_weapons.cpp @@ -137,7 +137,7 @@ void HUD_PlaybackEvent( int flags, const edict_t *pInvoker, unsigned short event // Weapon prediction events are assumed to occur at the player's origin org = g_finalstate->playerstate.origin; - ang = v_angles; + ang = v_client_aimangles; gEngfuncs.pfnPlaybackEvent( flags, pInvoker, eventindex, delay, org, ang, fparam1, fparam2, iparam1, iparam2, bparam1, bparam2 ); } @@ -161,7 +161,7 @@ Always 0.0 on client, even if not predicting weapons ( won't get called */ float UTIL_WeaponTimeBase( void ) { - return 0.0; + return 0.0f; } static unsigned int glSeed = 0; @@ -254,7 +254,7 @@ float UTIL_SharedRandomFloat( unsigned int seed, float low, float high ) tensixrand = U_Random() & 65535; - offset = (float)tensixrand / 65536.0; + offset = (float)tensixrand / 65536.0f; return ( low + offset * range ); } diff --git a/cl_dll/com_weapons.h b/cl_dll/com_weapons.h index 89fb3cfe..349a848d 100644 --- a/cl_dll/com_weapons.h +++ b/cl_dll/com_weapons.h @@ -39,6 +39,7 @@ extern cvar_t *cl_lw; extern int g_runfuncs; extern vec3_t v_angles; +extern vec3_t v_client_aimangles; extern float g_lastFOV; extern struct local_state_s *g_finalstate; #endif diff --git a/cl_dll/compile.bat b/cl_dll/compile.bat index 18b45459..720d1e3f 100644 --- a/cl_dll/compile.bat +++ b/cl_dll/compile.bat @@ -7,7 +7,7 @@ set PATH=%MSVCDir%\VC98\Bin;%MSVCDir%\Common\MSDev98\Bin\;%PATH% echo -- Compiler is MSVC6 set XASH3DSRC=..\..\Xash3D_original -set INCLUDES=-I../common -I../engine -I../pm_shared -I../game_shared -I../public -I../external -I../dlls -I../utils/false_vgui/include +set INCLUDES=-I../common -I../engine -I../pm_shared -I../game_shared -I../public -I../external -I../dlls -I../utils/fake_vgui/include set SOURCES=../dlls/crossbow.cpp ^ ../dlls/crowbar.cpp ^ ../dlls/egon.cpp ^ @@ -54,7 +54,6 @@ set SOURCES=../dlls/crossbow.cpp ^ input_xash3d.cpp ^ menu.cpp ^ message.cpp ^ - overview.cpp ^ parsemsg.cpp ^ ../pm_shared/pm_debug.c ^ ../pm_shared/pm_math.c ^ @@ -71,12 +70,11 @@ set SOURCES=../dlls/crossbow.cpp ^ view.cpp ^ scoreboard.cpp ^ MOTD.cpp -set DEFINES=/DCLIENT_DLL /DCLIENT_WEAPONS /Dsnprintf=_snprintf /DNO_VOICEGAMEMGR /DGOLDSOURCE_SUPPORT +set DEFINES=/DCLIENT_DLL /DCLIENT_WEAPONS /Dsnprintf=_snprintf /DNO_VOICEGAMEMGR /DGOLDSOURCE_SUPPORT /DNDEBUG set LIBS=user32.lib Winmm.lib set OUTNAME=client.dll -set DEBUG=/debug -cl %DEFINES% %LIBS% %SOURCES% %INCLUDES% -o %OUTNAME% /link /dll /out:%OUTNAME% %DEBUG% +cl %DEFINES% %LIBS% %SOURCES% %INCLUDES% -o %OUTNAME% /link /dll /out:%OUTNAME% /release echo -- Compile done. Cleaning... diff --git a/cl_dll/death.cpp b/cl_dll/death.cpp index b0667ec2..90024245 100644 --- a/cl_dll/death.cpp +++ b/cl_dll/death.cpp @@ -23,6 +23,10 @@ #include #include +#if USE_VGUI +#include "vgui_TeamFortressViewport.h" +#endif + DECLARE_MESSAGE( m_DeathNotice, DeathMsg ) struct DeathNoticeItem { @@ -71,7 +75,7 @@ int CHudDeathNotice::Init( void ) HOOK_MESSAGE( DeathMsg ); - CVAR_CREATE( "hud_deathnotice_time", "6", 0 ); + CVAR_CREATE( "hud_deathnotice_time", "6", FCVAR_ARCHIVE ); return 1; } @@ -110,7 +114,9 @@ int CHudDeathNotice::Draw( float flTime ) // Only draw if the viewport will let me // vgui dropped out - //if( gViewPort && gViewPort->AllowedToPrintText() ) +#if USE_VGUI + if( gViewPort && gViewPort->AllowedToPrintText() ) +#endif { // Draw the death notice y = YRES( DEATHNOTICE_TOP ) + 2 + ( 20 * i ); //!!! @@ -167,6 +173,12 @@ int CHudDeathNotice::MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbu char killedwith[32]; strcpy( killedwith, "d_" ); strncat( killedwith, READ_STRING(), sizeof(killedwith) - strlen(killedwith) - 1 ); + killedwith[sizeof(killedwith) - 1] = '\0'; + +#if USE_VGUI + if (gViewPort) + gViewPort->DeathMsg( killer, victim ); +#endif gHUD.m_Spectator.DeathMessage( victim ); @@ -182,9 +194,7 @@ int CHudDeathNotice::MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbu i = MAX_DEATHNOTICES - 1; } - //if(gViewPort) - // gViewPort->GetAllPlayersInfo(); - gHUD.m_Scoreboard.GetAllPlayersInfo(); + gHUD.GetAllPlayersInfo(); // Get the Killer's name const char *killer_name = ""; @@ -197,14 +207,14 @@ int CHudDeathNotice::MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbu else { rgDeathNoticeList[i].KillerColor = GetClientColor( killer ); - strncpy( rgDeathNoticeList[i].szKiller, killer_name, MAX_PLAYER_NAME_LENGTH ); + strncpy( rgDeathNoticeList[i].szKiller, killer_name, MAX_PLAYER_NAME_LENGTH - 1 ); rgDeathNoticeList[i].szKiller[MAX_PLAYER_NAME_LENGTH - 1] = 0; } // Get the Victim's name const char *victim_name = ""; // If victim is -1, the killer killed a specific, non-player object (like a sentrygun) - if( ( (char)victim ) != -1 ) + if( ( (signed char)victim ) != -1 ) victim_name = g_PlayerInfoList[victim].name; if( !victim_name ) { @@ -214,12 +224,12 @@ int CHudDeathNotice::MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbu else { rgDeathNoticeList[i].VictimColor = GetClientColor( victim ); - strncpy( rgDeathNoticeList[i].szVictim, victim_name, MAX_PLAYER_NAME_LENGTH ); + strncpy( rgDeathNoticeList[i].szVictim, victim_name, MAX_PLAYER_NAME_LENGTH - 1 ); rgDeathNoticeList[i].szVictim[MAX_PLAYER_NAME_LENGTH - 1] = 0; } // Is it a non-player object kill? - if( ( (char)victim ) == -1 ) + if( ( (signed char)victim ) == -1 ) { rgDeathNoticeList[i].iNonPlayerKill = TRUE; diff --git a/cl_dll/demo.cpp b/cl_dll/demo.cpp index f114ead0..8f5fb0a8 100644 --- a/cl_dll/demo.cpp +++ b/cl_dll/demo.cpp @@ -17,7 +17,6 @@ #include "cl_util.h" #include "demo.h" #include "demo_api.h" -#include int g_demosniper = 0; int g_demosniperdamage = 0; @@ -88,12 +87,12 @@ void DLLEXPORT Demo_ReadBuffer( int size, unsigned char *buffer ) g_demosniperorg[1] = *(float *)&buffer[i]; i += sizeof(float); g_demosniperorg[2] = *(float *)&buffer[i]; - i += sizeof(float); + // i += sizeof(float); } break; case TYPE_ZOOM: g_demozoom = *(float *)&buffer[i]; - i += sizeof(float); + // i += sizeof(float); break; default: gEngfuncs.Con_DPrintf( "Unknown demo buffer type, skipping.\n" ); diff --git a/cl_dll/entity.cpp b/cl_dll/entity.cpp index 40649fa7..36705466 100644 --- a/cl_dll/entity.cpp +++ b/cl_dll/entity.cpp @@ -222,12 +222,12 @@ void DLLEXPORT HUD_TxferPredictionData( struct entity_state_s *ps, const struct VectorCopy( ppcd->vuser3, pcd->vuser3 ); VectorCopy( ppcd->vuser4, pcd->vuser4 ); - memcpy( wd, pwd, 32 * sizeof(weapon_data_t) ); + memcpy( wd, pwd, MAX_WEAPONS * sizeof(weapon_data_t) ); } /* -//#define TEST_IT -#if defined( TEST_IT ) +//#define TEST_IT 1 +#if TEST_IT cl_entity_t mymodel[9]; @@ -269,8 +269,8 @@ void MoveModel( void ) } #endif -//#define TRACE_TEST -#if defined( TRACE_TEST ) +//#define TRACE_TEST 1 +#if TRACE_TEST extern int hitent; @@ -319,12 +319,12 @@ void Particles( void ) curtime = gEngfuncs.GetClientTime(); - if( ( curtime - lasttime ) < 2.0 ) + if( ( curtime - lasttime ) < 2.0f ) return; if( !color ) { - color = gEngfuncs.pfnRegisterVariable ( "color","255 0 0", 0 ); + color = gEngfuncs.pfnRegisterVariable( "color", "255 0 0", 0 ); } lasttime = curtime; @@ -342,8 +342,8 @@ void Particles( void ) for( j = 0; j < 3; j++ ) { - p->org[j] = v_origin[j] + gEngfuncs.pfnRandomFloat( -32.0, 32.0 ); - p->vel[j] = gEngfuncs.pfnRandomFloat( -100.0, 100.0 ); + p->org[j] = v_origin[j] + gEngfuncs.pfnRandomFloat( -32.0f, 32.0f ); + p->vel[j] = gEngfuncs.pfnRandomFloat( -100.0f, 100.0f ); } if( color ) @@ -361,7 +361,7 @@ void Particles( void ) gEngfuncs.pEfxAPI->R_GetPackedColor( &p->packedColor, p->color ); // p->die is set to current time so all you have to do is add an additional time to it - p->die += 3.0; + p->die += 3.0f; } } */ @@ -384,7 +384,7 @@ void TempEnts( void ) curtime = gEngfuncs.GetClientTime(); - if( ( curtime - lasttime ) < 10.0 ) + if( ( curtime - lasttime ) < 10.0f ) return; lasttime = curtime; @@ -417,16 +417,16 @@ void TempEnts( void ) p->entity.curstate.origin[j] = origin[j]; // Store velocity in baseline origin - p->entity.baseline.origin[j] = gEngfuncs.pfnRandomFloat( -100, 100 ); + p->entity.baseline.origin[j] = gEngfuncs.pfnRandomFloat( -100.0f, 100.0f ); } // p->die is set to current time so all you have to do is add an additional time to it - p->die += 10.0; + p->die += 10.0f; } } */ -#if defined( BEAM_TEST ) +#if BEAM_TEST // Note can't index beam[0] in Beam callback, so don't use that index // Room for 1 beam ( 0 can't be used ) static cl_entity_t beams[2]; @@ -510,10 +510,10 @@ void DLLEXPORT HUD_CreateEntities( void ) // Load an appropriate model into it ( gEngfuncs.CL_LoadModel ) // Call gEngfuncs.CL_CreateVisibleEntity to add it to the visedicts list /* -#if defined( TEST_IT ) +#if TEST_IT MoveModel(); #endif -#if defined( TRACE_TEST ) +#if TRACE_TEST TraceModel(); #endif */ @@ -523,11 +523,15 @@ void DLLEXPORT HUD_CreateEntities( void ) /* TempEnts(); */ -#if defined( BEAM_TEST ) +#if BEAM_TEST Beams(); #endif // Add in any game specific objects Game_AddObjects(); + +#if USE_VGUI + GetClientVoiceMgr()->CreateEntities(); +#endif } /* @@ -626,7 +630,7 @@ void DLLEXPORT HUD_TempEntUpdate ( //freq = client_time * 0.01; fastFreq = client_time * 5.5; gravity = -frametime * cl_gravity; - gravitySlow = gravity * 0.5; + gravitySlow = gravity * 0.5f; while( pTemp ) { @@ -634,7 +638,7 @@ void DLLEXPORT HUD_TempEntUpdate ( active = 1; - life = pTemp->die - client_time; + life = pTemp->die - (float)client_time; pnext = pTemp->next; if( life < 0 ) { @@ -674,9 +678,9 @@ void DLLEXPORT HUD_TempEntUpdate ( gEngfuncs.pEfxAPI->R_SparkEffect( pTemp->entity.origin, 8, -200, 200 ); // Reduce life - pTemp->entity.baseline.framerate -= 0.1; + pTemp->entity.baseline.framerate -= 0.1f; - if( pTemp->entity.baseline.framerate <= 0.0 ) + if( pTemp->entity.baseline.framerate <= 0.0f ) { pTemp->die = client_time; } @@ -700,11 +704,11 @@ void DLLEXPORT HUD_TempEntUpdate ( } else if( pTemp->flags & FTENT_SINEWAVE ) { - pTemp->x += pTemp->entity.baseline.origin[0] * frametime; - pTemp->y += pTemp->entity.baseline.origin[1] * frametime; + pTemp->x += pTemp->entity.baseline.origin[0] * (float)frametime; + pTemp->y += pTemp->entity.baseline.origin[1] * (float)frametime; pTemp->entity.origin[0] = pTemp->x + sin( pTemp->entity.baseline.origin[2] + client_time * pTemp->entity.prevstate.frame ) * ( 10 * pTemp->entity.curstate.framerate ); - pTemp->entity.origin[1] = pTemp->y + sin( pTemp->entity.baseline.origin[2] + fastFreq + 0.7 ) * ( 8 * pTemp->entity.curstate.framerate ); + pTemp->entity.origin[1] = pTemp->y + sin( pTemp->entity.baseline.origin[2] + fastFreq + 0.7f ) * ( 8 * pTemp->entity.curstate.framerate ); pTemp->entity.origin[2] += pTemp->entity.baseline.origin[2] * frametime; } else if( pTemp->flags & FTENT_SPIRAL ) @@ -713,19 +717,19 @@ void DLLEXPORT HUD_TempEntUpdate ( s = sin( pTemp->entity.baseline.origin[2] + fastFreq ); c = cos( pTemp->entity.baseline.origin[2] + fastFreq );*/ - pTemp->entity.origin[0] += pTemp->entity.baseline.origin[0] * frametime + 8 * sin( client_time * 20 + (size_t)pTemp ); - pTemp->entity.origin[1] += pTemp->entity.baseline.origin[1] * frametime + 4 * sin( client_time * 30 + (size_t)pTemp ); - pTemp->entity.origin[2] += pTemp->entity.baseline.origin[2] * frametime; + pTemp->entity.origin[0] += pTemp->entity.baseline.origin[0] * (float)frametime + 8 * sin( client_time * 20 + (size_t)pTemp ); + pTemp->entity.origin[1] += pTemp->entity.baseline.origin[1] * (float)frametime + 4 * sin( client_time * 30 + (size_t)pTemp ); + pTemp->entity.origin[2] += pTemp->entity.baseline.origin[2] * (float)frametime; } else { for( i = 0; i < 3; i++ ) - pTemp->entity.origin[i] += pTemp->entity.baseline.origin[i] * frametime; + pTemp->entity.origin[i] += pTemp->entity.baseline.origin[i] * (float)frametime; } if( pTemp->flags & FTENT_SPRANIMATE ) { - pTemp->entity.curstate.frame += frametime * pTemp->entity.curstate.framerate; + pTemp->entity.curstate.frame += (float)frametime * pTemp->entity.curstate.framerate; if( pTemp->entity.curstate.frame >= pTemp->frameMax ) { pTemp->entity.curstate.frame = pTemp->entity.curstate.frame - (int)( pTemp->entity.curstate.frame ); @@ -755,9 +759,9 @@ void DLLEXPORT HUD_TempEntUpdate ( if( pTemp->flags & FTENT_ROTATE ) { - pTemp->entity.angles[0] += pTemp->entity.baseline.angles[0] * frametime; - pTemp->entity.angles[1] += pTemp->entity.baseline.angles[1] * frametime; - pTemp->entity.angles[2] += pTemp->entity.baseline.angles[2] * frametime; + pTemp->entity.angles[0] += pTemp->entity.baseline.angles[0] * (float)frametime; + pTemp->entity.angles[1] += pTemp->entity.baseline.angles[1] * (float)frametime; + pTemp->entity.angles[2] += pTemp->entity.baseline.angles[2] * (float)frametime; VectorCopy( pTemp->entity.angles, pTemp->entity.latched.prevangles ); } @@ -809,7 +813,7 @@ void DLLEXPORT HUD_TempEntUpdate ( { // Chop spark speeds a bit more // - VectorScale( pTemp->entity.baseline.origin, 0.6, pTemp->entity.baseline.origin ); + VectorScale( pTemp->entity.baseline.origin, 0.6f, pTemp->entity.baseline.origin ); if( Length( pTemp->entity.baseline.origin ) < 10 ) { @@ -829,13 +833,13 @@ void DLLEXPORT HUD_TempEntUpdate ( float proj, damp; // Place at contact point - VectorMA( pTemp->entity.prevstate.origin, traceFraction * frametime, pTemp->entity.baseline.origin, pTemp->entity.origin ); + VectorMA( pTemp->entity.prevstate.origin, traceFraction * (float)frametime, pTemp->entity.baseline.origin, pTemp->entity.origin ); // Damp velocity damp = pTemp->bounceFactor; if( pTemp->flags & ( FTENT_GRAVITY | FTENT_SLOWGRAVITY ) ) { - damp *= 0.5; - if( traceNormal[2] > 0.9 ) // Hit floor? + damp *= 0.5f; + if( traceNormal[2] > 0.9f ) // Hit floor? { if( pTemp->entity.baseline.origin[2] <= 0 && pTemp->entity.baseline.origin[2] >= gravity*3 ) { @@ -942,7 +946,7 @@ Indices must start at 1, not zero. */ cl_entity_t DLLEXPORT *HUD_GetUserEntity( int index ) { -#if defined( BEAM_TEST ) +#if BEAM_TEST // None by default, you would return a valic pointer if you create a client side // beam and attach it to a client side entity. if( index > 0 && index <= 1 ) diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index f8fefad5..166f86bd 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -72,18 +72,18 @@ void EV_SnarkFire( struct event_args_s *args ); void EV_TrainPitchAdjust( struct event_args_s *args ); } -#define VECTOR_CONE_1DEGREES Vector( 0.00873, 0.00873, 0.00873 ) -#define VECTOR_CONE_2DEGREES Vector( 0.01745, 0.01745, 0.01745 ) -#define VECTOR_CONE_3DEGREES Vector( 0.02618, 0.02618, 0.02618 ) -#define VECTOR_CONE_4DEGREES Vector( 0.03490, 0.03490, 0.03490 ) -#define VECTOR_CONE_5DEGREES Vector( 0.04362, 0.04362, 0.04362 ) -#define VECTOR_CONE_6DEGREES Vector( 0.05234, 0.05234, 0.05234 ) -#define VECTOR_CONE_7DEGREES Vector( 0.06105, 0.06105, 0.06105 ) -#define VECTOR_CONE_8DEGREES Vector( 0.06976, 0.06976, 0.06976 ) -#define VECTOR_CONE_9DEGREES Vector( 0.07846, 0.07846, 0.07846 ) -#define VECTOR_CONE_10DEGREES Vector( 0.08716, 0.08716, 0.08716 ) -#define VECTOR_CONE_15DEGREES Vector( 0.13053, 0.13053, 0.13053 ) -#define VECTOR_CONE_20DEGREES Vector( 0.17365, 0.17365, 0.17365 ) +#define VECTOR_CONE_1DEGREES Vector( 0.00873f, 0.00873f, 0.00873f ) +#define VECTOR_CONE_2DEGREES Vector( 0.01745f, 0.01745f, 0.01745f ) +#define VECTOR_CONE_3DEGREES Vector( 0.02618f, 0.02618f, 0.02618f ) +#define VECTOR_CONE_4DEGREES Vector( 0.03490f, 0.03490f, 0.03490f ) +#define VECTOR_CONE_5DEGREES Vector( 0.04362f, 0.04362f, 0.04362f ) +#define VECTOR_CONE_6DEGREES Vector( 0.05234f, 0.05234f, 0.05234f ) +#define VECTOR_CONE_7DEGREES Vector( 0.06105f, 0.06105f, 0.06105f ) +#define VECTOR_CONE_8DEGREES Vector( 0.06976f, 0.06976f, 0.06976f ) +#define VECTOR_CONE_9DEGREES Vector( 0.07846f, 0.07846f, 0.07846f ) +#define VECTOR_CONE_10DEGREES Vector( 0.08716f, 0.08716f, 0.08716f ) +#define VECTOR_CONE_15DEGREES Vector( 0.13053f, 0.13053f, 0.13053f ) +#define VECTOR_CONE_20DEGREES Vector( 0.17365f, 0.17365f, 0.17365f ) // play a strike sound based on the texture that was hit by the attack traceline. VecSrc/VecEnd are the // original traceline endpoints used by the attacker, iBulletType is the type of bullet that hit the texture. @@ -247,7 +247,7 @@ char *EV_HLDM_DamageDecal( physent_t *pe ) } else if( pe->rendermode != kRenderNormal ) { - sprintf( decalname, "{bproof1" ); + strcpy( decalname, "{bproof1" ); } else { @@ -425,7 +425,7 @@ void EV_HLDM_FireBullets( int idx, float *forward, float *right, float *up, int tracer = EV_HLDM_CheckTracer( idx, vecSrc, tr.endpos, forward, right, iBulletType, iTracerFreq, tracerCount ); // do damage, paint decals - if( tr.fraction != 1.0 ) + if( tr.fraction != 1.0f ) { switch( iBulletType ) { @@ -458,7 +458,8 @@ void EV_HLDM_FireBullets( int idx, float *forward, float *right, float *up, int //====================== // GLOCK START //====================== -void EV_FireGlock1( event_args_t *args ) +// Shared Glock fire implementation for EV_FireGlock1 and EV_FireGlock2. +static void EV_FireGlock_Impl( event_args_t *args ) { int idx; vec3_t origin; @@ -485,7 +486,7 @@ void EV_FireGlock1( event_args_t *args ) if( EV_IsLocal( idx ) ) { EV_MuzzleFlash(); - gEngfuncs.pEventAPI->EV_WeaponAnimation( empty ? GLOCK_SHOOT_EMPTY : GLOCK_SHOOT, 2 ); + gEngfuncs.pEventAPI->EV_WeaponAnimation( empty ? GLOCK_SHOOT_EMPTY : GLOCK_SHOOT, 0 ); V_PunchAxis( 0, -2.0 ); } @@ -500,53 +501,17 @@ void EV_FireGlock1( event_args_t *args ) VectorCopy( forward, vecAiming ); - EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_9MM, 0, 0, args->fparam1, args->fparam2 ); + EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_9MM, 0, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 ); +} + +void EV_FireGlock1( event_args_t *args ) +{ + EV_FireGlock_Impl( args ); } void EV_FireGlock2( event_args_t *args ) { - int idx; - vec3_t origin; - vec3_t angles; - vec3_t velocity; - - vec3_t ShellVelocity; - vec3_t ShellOrigin; - int shell; - vec3_t vecSrc, vecAiming; - vec3_t vecSpread; - vec3_t up, right, forward; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - VectorCopy( args->angles, angles ); - VectorCopy( args->velocity, velocity ); - int empty = args->bparam1; - - AngleVectors( angles, forward, right, up ); - - shell = gEngfuncs.pEventAPI->EV_FindModelIndex( "models/shell.mdl" );// brass shell - - if( EV_IsLocal( idx ) ) - { - // Add muzzle flash to current weapon model - EV_MuzzleFlash(); - gEngfuncs.pEventAPI->EV_WeaponAnimation( empty ? GLOCK_SHOOT_EMPTY : GLOCK_SHOOT, 2 ); - - V_PunchAxis( 0, -2.0 ); - } - - EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 20, -12, 4 ); - - EV_EjectBrass ( ShellOrigin, ShellVelocity, angles[YAW], shell, TE_BOUNCE_SHELL ); - - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/pl_gun3.wav", gEngfuncs.pfnRandomFloat( 0.92, 1.0 ), ATTN_NORM, 0, 98 + gEngfuncs.pfnRandomLong( 0, 3 ) ); - - EV_GetGunPosition( args, vecSrc, origin ); - - VectorCopy( forward, vecAiming ); - - EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_9MM, 0, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 ); + EV_FireGlock_Impl( args ); } //====================== // GLOCK END @@ -567,7 +532,7 @@ void EV_FireShotGunDouble( event_args_t *args ) vec3_t ShellOrigin; int shell; vec3_t vecSrc, vecAiming; - vec3_t vecSpread; + //vec3_t vecSpread; vec3_t up, right, forward; //float flSpread = 0.01; @@ -584,7 +549,7 @@ void EV_FireShotGunDouble( event_args_t *args ) { // Add muzzle flash to current weapon model EV_MuzzleFlash(); - gEngfuncs.pEventAPI->EV_WeaponAnimation( SHOTGUN_FIRE2, 2 ); + gEngfuncs.pEventAPI->EV_WeaponAnimation( SHOTGUN_FIRE2, 0 ); V_PunchAxis( 0, -10.0 ); } @@ -621,7 +586,7 @@ void EV_FireShotGunSingle( event_args_t *args ) vec3_t ShellOrigin; int shell; vec3_t vecSrc, vecAiming; - vec3_t vecSpread; + //vec3_t vecSpread; vec3_t up, right, forward; //float flSpread = 0.01; @@ -638,7 +603,7 @@ void EV_FireShotGunSingle( event_args_t *args ) { // Add muzzle flash to current weapon model EV_MuzzleFlash(); - gEngfuncs.pEventAPI->EV_WeaponAnimation( SHOTGUN_FIRE, 2 ); + gEngfuncs.pEventAPI->EV_WeaponAnimation( SHOTGUN_FIRE, 0 ); V_PunchAxis( 0, -5.0 ); } @@ -695,7 +660,7 @@ void EV_FireMP5( event_args_t *args ) { // Add muzzle flash to current weapon model EV_MuzzleFlash(); - gEngfuncs.pEventAPI->EV_WeaponAnimation( MP5_FIRE1 + gEngfuncs.pfnRandomLong( 0, 2 ), 2 ); + gEngfuncs.pEventAPI->EV_WeaponAnimation( MP5_FIRE1 + gEngfuncs.pfnRandomLong( 0, 2 ), 0 ); V_PunchAxis( 0, gEngfuncs.pfnRandomFloat( -2, 2 ) ); } @@ -717,14 +682,7 @@ void EV_FireMP5( event_args_t *args ) EV_GetGunPosition( args, vecSrc, origin ); VectorCopy( forward, vecAiming ); - if( gEngfuncs.GetMaxClients() > 1 ) - { - EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_MP5, 2, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 ); - } - else - { - EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_MP5, 2, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 ); - } + EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_MP5, 2, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 ); } // We only predict the animation and sound @@ -739,7 +697,7 @@ void EV_FireMP52( event_args_t *args ) if( EV_IsLocal( idx ) ) { - gEngfuncs.pEventAPI->EV_WeaponAnimation( MP5_LAUNCH, 2 ); + gEngfuncs.pEventAPI->EV_WeaponAnimation( MP5_LAUNCH, 0 ); V_PunchAxis( 0, -10 ); } @@ -805,7 +763,7 @@ void EV_FirePython( event_args_t *args ) VectorCopy( forward, vecAiming ); - EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_357, 0, 0, args->fparam1, args->fparam2 ); + EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_357, 0, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 ); } //====================== // PHYTON END @@ -815,6 +773,7 @@ void EV_FirePython( event_args_t *args ) //====================== // GAUSS START //====================== +#define SND_STOP (1 << 5) #define SND_CHANGE_PITCH (1 << 7) // duplicated in protocol.h change sound pitch void EV_SpinGauss( event_args_t *args ) @@ -835,6 +794,7 @@ void EV_SpinGauss( event_args_t *args ) pitch = args->iparam1; iSoundState = args->bparam1 ? SND_CHANGE_PITCH : 0; + iSoundState = args->bparam2 ? SND_STOP : iSoundState; gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "ambience/pulsemachine.wav", 1.0, ATTN_NORM, iSoundState, pitch ); } @@ -901,14 +861,14 @@ void EV_FireGauss( event_args_t *args ) if( EV_IsLocal( idx ) ) { - V_PunchAxis( 0, -2.0 ); - gEngfuncs.pEventAPI->EV_WeaponAnimation( GAUSS_FIRE2, 2 ); + V_PunchAxis( 0.0f, -2.0f ); + gEngfuncs.pEventAPI->EV_WeaponAnimation( GAUSS_FIRE2, 0 ); if( m_fPrimaryFire == false ) g_flApplyVel = flDamage; } - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/gauss2.wav", 0.5 + flDamage * ( 1.0 / 400.0 ), ATTN_NORM, 0, 85 + gEngfuncs.pfnRandomLong( 0, 0x1f ) ); + gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/gauss2.wav", 0.5f + flDamage * ( 1.0f / 400.0f ), ATTN_NORM, 0, 85 + gEngfuncs.pfnRandomLong( 0, 0x1f ) ); while( flDamage > 10 && nMaxHits > 0 ) { @@ -943,16 +903,16 @@ void EV_FireGauss( event_args_t *args ) idx | 0x1000, tr.endpos, m_iBeam, - 0.1, - m_fPrimaryFire ? 1.0 : 2.5, - 0.0, - m_fPrimaryFire ? 128.0 : flDamage, + 0.1f, + m_fPrimaryFire ? 1.0f : 2.5f, + 0.0f, + (m_fPrimaryFire ? 128.0f : flDamage) / 255.0f, 0, 0, 0, - m_fPrimaryFire ? 255 : 255, - m_fPrimaryFire ? 128 : 255, - m_fPrimaryFire ? 0 : 255 + (m_fPrimaryFire ? 255 : 255) / 255.0f, + (m_fPrimaryFire ? 128 : 255) / 255.0f, + (m_fPrimaryFire ? 0 : 255) / 255.0f ); } else @@ -960,16 +920,16 @@ void EV_FireGauss( event_args_t *args ) gEngfuncs.pEfxAPI->R_BeamPoints( vecSrc, tr.endpos, m_iBeam, - 0.1, - m_fPrimaryFire ? 1.0 : 2.5, - 0.0, - m_fPrimaryFire ? 128.0 : flDamage, + 0.1f, + m_fPrimaryFire ? 1.0f : 2.5f, + 0.0f, + (m_fPrimaryFire ? 128.0f : flDamage) / 255.0f, 0, 0, 0, - m_fPrimaryFire ? 255 : 255, - m_fPrimaryFire ? 128 : 255, - m_fPrimaryFire ? 0 : 255 + (m_fPrimaryFire ? 255 : 255) / 255.0f, + (m_fPrimaryFire ? 128 : 255) / 255.0f, + (m_fPrimaryFire ? 0 : 255) / 255.0f ); } @@ -985,13 +945,13 @@ void EV_FireGauss( event_args_t *args ) n = -DotProduct( tr.plane.normal, forward ); - if( n < 0.5 ) // 60 degrees + if( n < 0.5f ) // 60 degrees { // ALERT( at_console, "reflect %f\n", n ); // reflect vec3_t r; - VectorMA( forward, 2.0 * n, tr.plane.normal, r ); + VectorMA( forward, 2.0f * n, tr.plane.normal, r ); flMaxFrac = flMaxFrac - tr.fraction; @@ -1000,18 +960,18 @@ void EV_FireGauss( event_args_t *args ) VectorMA( tr.endpos, 8.0, forward, vecSrc ); VectorMA( vecSrc, 8192.0, forward, vecDest ); - gEngfuncs.pEfxAPI->R_TempSprite( tr.endpos, vec3_origin, 0.2, m_iGlow, kRenderGlow, kRenderFxNoDissipation, flDamage * n / 255.0, flDamage * n * 0.5 * 0.1, FTENT_FADEOUT ); + gEngfuncs.pEfxAPI->R_TempSprite( tr.endpos, vec3_origin, 0.2, m_iGlow, kRenderGlow, kRenderFxNoDissipation, flDamage * n / 255.0f, flDamage * n * 0.5f * 0.1f, FTENT_FADEOUT ); vec3_t fwd; VectorAdd( tr.endpos, tr.plane.normal, fwd ); - gEngfuncs.pEfxAPI->R_Sprite_Trail( TE_SPRITETRAIL, tr.endpos, fwd, m_iBalls, 3, 0.1, gEngfuncs.pfnRandomFloat( 10, 20 ) / 100.0, 100, + gEngfuncs.pEfxAPI->R_Sprite_Trail( TE_SPRITETRAIL, tr.endpos, fwd, m_iBalls, 3, 0.1, gEngfuncs.pfnRandomFloat( 10.0f, 20.0f ) / 100.0f, 100, 255, 100 ); // lose energy - if( n == 0 ) + if( n == 0.0f ) { - n = 0.1; + n = 0.1f; } flDamage = flDamage * ( 1 - n ); @@ -1021,7 +981,7 @@ void EV_FireGauss( event_args_t *args ) // tunnel EV_HLDM_DecalGunshot( &tr, BULLET_MONSTER_12MM ); - gEngfuncs.pEfxAPI->R_TempSprite( tr.endpos, vec3_origin, 1.0, m_iGlow, kRenderGlow, kRenderFxNoDissipation, flDamage / 255.0, 6.0, FTENT_FADEOUT ); + gEngfuncs.pEfxAPI->R_TempSprite( tr.endpos, vec3_origin, 1.0, m_iGlow, kRenderGlow, kRenderFxNoDissipation, flDamage / 255.0f, 6.0f, FTENT_FADEOUT ); // limit it to one hole punch if( fHasPunched ) @@ -1067,7 +1027,7 @@ void EV_FireGauss( event_args_t *args ) { vec3_t fwd; VectorSubtract( tr.endpos, forward, fwd ); - gEngfuncs.pEfxAPI->R_Sprite_Trail( TE_SPRITETRAIL, tr.endpos, fwd, m_iBalls, 3, 0.1, gEngfuncs.pfnRandomFloat( 10, 20 ) / 100.0, 100, + gEngfuncs.pEfxAPI->R_Sprite_Trail( TE_SPRITETRAIL, tr.endpos, fwd, m_iBalls, 3, 0.1, gEngfuncs.pfnRandomFloat( 10.0f, 20.0f ) / 100.0f, 100, 255, 100 ); } @@ -1076,13 +1036,13 @@ void EV_FireGauss( event_args_t *args ) EV_HLDM_DecalGunshot( &beam_tr, BULLET_MONSTER_12MM ); - gEngfuncs.pEfxAPI->R_TempSprite( beam_tr.endpos, vec3_origin, 0.1, m_iGlow, kRenderGlow, kRenderFxNoDissipation, flDamage / 255.0, 6.0, FTENT_FADEOUT ); + gEngfuncs.pEfxAPI->R_TempSprite( beam_tr.endpos, vec3_origin, 0.1, m_iGlow, kRenderGlow, kRenderFxNoDissipation, flDamage / 255.0f, 6.0f, FTENT_FADEOUT ); // balls { vec3_t fwd; VectorSubtract( beam_tr.endpos, forward, fwd ); - gEngfuncs.pEfxAPI->R_Sprite_Trail( TE_SPRITETRAIL, beam_tr.endpos, fwd, m_iBalls, (int)( flDamage * 0.3 ), 0.1, gEngfuncs.pfnRandomFloat( 10, 20 ) / 100.0, 200, + gEngfuncs.pEfxAPI->R_Sprite_Trail( TE_SPRITETRAIL, beam_tr.endpos, fwd, m_iBalls, (int)( flDamage * 0.3f ), 0.1, gEngfuncs.pfnRandomFloat( 10.0f, 20.0f ) / 100.0f, 200, 255, 40 ); } @@ -1102,11 +1062,11 @@ void EV_FireGauss( event_args_t *args ) { // slug doesn't punch through ever with primary // fire, so leave a little glowy bit and make some balls - gEngfuncs.pEfxAPI->R_TempSprite( tr.endpos, vec3_origin, 0.2, m_iGlow, kRenderGlow, kRenderFxNoDissipation, 200.0 / 255.0, 0.3, FTENT_FADEOUT ); + gEngfuncs.pEfxAPI->R_TempSprite( tr.endpos, vec3_origin, 0.2, m_iGlow, kRenderGlow, kRenderFxNoDissipation, 200.0f / 255.0f, 0.3, FTENT_FADEOUT ); { vec3_t fwd; VectorAdd( tr.endpos, tr.plane.normal, fwd ); - gEngfuncs.pEfxAPI->R_Sprite_Trail( TE_SPRITETRAIL, tr.endpos, fwd, m_iBalls, 8, 0.6, gEngfuncs.pfnRandomFloat( 10, 20 ) / 100.0, 100, + gEngfuncs.pEfxAPI->R_Sprite_Trail( TE_SPRITETRAIL, tr.endpos, fwd, m_iBalls, 8, 0.6, gEngfuncs.pfnRandomFloat( 10.0f, 20.0f ) / 100.0f, 100, 255, 200 ); } } @@ -1138,7 +1098,7 @@ enum crowbar_e CROWBAR_ATTACK2MISS, CROWBAR_ATTACK2HIT, CROWBAR_ATTACK3MISS, -#ifndef CROWBAR_IDLE_ANIM +#if !CROWBAR_IDLE_ANIM CROWBAR_ATTACK3HIT #else CROWBAR_ATTACK3HIT, @@ -1155,8 +1115,8 @@ void EV_Crowbar( event_args_t *args ) { int idx; vec3_t origin; - vec3_t angles; - vec3_t velocity; + //vec3_t angles; + //vec3_t velocity; idx = args->entindex; VectorCopy( args->origin, origin ); @@ -1169,13 +1129,13 @@ void EV_Crowbar( event_args_t *args ) switch( (g_iSwing++) % 3 ) { case 0: - gEngfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK1MISS, 1 ); + gEngfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK1MISS, 0 ); break; case 1: - gEngfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK2MISS, 1 ); + gEngfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK2MISS, 0 ); break; case 2: - gEngfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK3MISS, 1 ); + gEngfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK3MISS, 0 ); break; } } @@ -1238,14 +1198,14 @@ void EV_FireCrossbow2( event_args_t *args ) VectorMA( vecSrc, 8192, forward, vecEnd ); gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/xbow_fire1.wav", 1, ATTN_NORM, 0, 93 + gEngfuncs.pfnRandomLong( 0, 0xF ) ); - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_ITEM, "weapons/xbow_reload1.wav", gEngfuncs.pfnRandomFloat( 0.95, 1.0 ), ATTN_NORM, 0, 93 + gEngfuncs.pfnRandomLong( 0, 0xF ) ); + gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_ITEM, "weapons/xbow_reload1.wav", gEngfuncs.pfnRandomFloat( 0.95f, 1.0f ), ATTN_NORM, 0, 93 + gEngfuncs.pfnRandomLong( 0, 0xF ) ); if( EV_IsLocal( idx ) ) { if( args->iparam1 ) - gEngfuncs.pEventAPI->EV_WeaponAnimation( CROSSBOW_FIRE1, 1 ); - else if( args->iparam2 ) - gEngfuncs.pEventAPI->EV_WeaponAnimation( CROSSBOW_FIRE3, 1 ); + gEngfuncs.pEventAPI->EV_WeaponAnimation( CROSSBOW_FIRE1, 0 ); + else + gEngfuncs.pEventAPI->EV_WeaponAnimation( CROSSBOW_FIRE3, 0 ); } // Store off the old count @@ -1257,7 +1217,7 @@ void EV_FireCrossbow2( event_args_t *args ) gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecEnd, PM_STUDIO_BOX, -1, &tr ); //We hit something - if( tr.fraction < 1.0 ) + if( tr.fraction < 1.0f ) { physent_t *pe = gEngfuncs.pEventAPI->EV_GetPhysent( tr.ent ); @@ -1277,7 +1237,7 @@ void EV_FireCrossbow2( event_args_t *args ) //Stick to world but don't stick to glass, it might break and leave the bolt floating. It can still stick to other non-transparent breakables though. else if( pe->rendermode == kRenderNormal ) { - gEngfuncs.pEventAPI->EV_PlaySound( 0, tr.endpos, CHAN_BODY, "weapons/xbow_hit1.wav", gEngfuncs.pfnRandomFloat( 0.95, 1.0 ), ATTN_NORM, 0, PITCH_NORM ); + gEngfuncs.pEventAPI->EV_PlaySound( 0, tr.endpos, CHAN_BODY, "weapons/xbow_hit1.wav", gEngfuncs.pfnRandomFloat( 0.95f, 1.0f ), ATTN_NORM, 0, PITCH_NORM ); //Not underwater, do some sparks... if( gEngfuncs.PM_PointContents( tr.endpos, NULL ) != CONTENTS_WATER ) @@ -1313,17 +1273,17 @@ void EV_FireCrossbow( event_args_t *args ) VectorCopy( args->origin, origin ); gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/xbow_fire1.wav", 1, ATTN_NORM, 0, 93 + gEngfuncs.pfnRandomLong( 0, 0xF ) ); - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_ITEM, "weapons/xbow_reload1.wav", gEngfuncs.pfnRandomFloat( 0.95, 1.0 ), ATTN_NORM, 0, 93 + gEngfuncs.pfnRandomLong( 0, 0xF ) ); + gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_ITEM, "weapons/xbow_reload1.wav", gEngfuncs.pfnRandomFloat( 0.95f, 1.0f ), ATTN_NORM, 0, 93 + gEngfuncs.pfnRandomLong( 0, 0xF ) ); //Only play the weapon anims if I shot it. if( EV_IsLocal( idx ) ) { if( args->iparam1 ) - gEngfuncs.pEventAPI->EV_WeaponAnimation( CROSSBOW_FIRE1, 1 ); - else if ( args->iparam2 ) - gEngfuncs.pEventAPI->EV_WeaponAnimation( CROSSBOW_FIRE3, 1 ); + gEngfuncs.pEventAPI->EV_WeaponAnimation( CROSSBOW_FIRE1, 0 ); + else + gEngfuncs.pEventAPI->EV_WeaponAnimation( CROSSBOW_FIRE3, 0 ); - V_PunchAxis( 0, -2.0 ); + V_PunchAxis( 0.0f, -2.0f ); } } //====================== @@ -1361,7 +1321,7 @@ void EV_FireRpg( event_args_t *args ) //Only play the weapon anims if I shot it. if( EV_IsLocal( idx ) ) { - gEngfuncs.pEventAPI->EV_WeaponAnimation( RPG_FIRE2, 1 ); + gEngfuncs.pEventAPI->EV_WeaponAnimation( RPG_FIRE2, 0 ); V_PunchAxis( 0, -5.0 ); } @@ -1371,7 +1331,7 @@ void EV_FireRpg( event_args_t *args ) //====================== //====================== -// EGON END +// EGON START //====================== enum egon_e { @@ -1462,7 +1422,7 @@ void EV_EgonFire( event_args_t *args ) //Only play the weapon anims if I shot it. if( EV_IsLocal( idx ) ) - gEngfuncs.pEventAPI->EV_WeaponAnimation( g_fireAnims1[gEngfuncs.pfnRandomLong( 0, 3 )], 1 ); + gEngfuncs.pEventAPI->EV_WeaponAnimation( g_fireAnims1[gEngfuncs.pfnRandomLong( 0, 3 )], 0 ); if( iStartup == 1 && EV_IsLocal( idx ) && !( pBeam || pBeam2 || pFlare ) && cl_lw->value ) //Adrian: Added the cl_lw check for those lital people that hate weapon prediction. { @@ -1500,10 +1460,11 @@ void EV_EgonFire( event_args_t *args ) float g = 50.0f; float b = 125.0f; - if( IEngineStudio.IsHardware() ) + // if( IEngineStudio.IsHardware() ) { - r /= 100.0f; - g /= 100.0f; + r /= 255.0f; + g /= 255.0f; + b /= 255.0f; } pBeam = gEngfuncs.pEfxAPI->R_BeamEntPoint( idx | 0x1000, tr.endpos, iBeamModelIndex, 99999, 3.5, 0.2, 0.7, 55, 0, 0, r, g, b ); @@ -1541,13 +1502,13 @@ void EV_EgonStop( event_args_t *args ) { if( pBeam ) { - pBeam->die = 0.0; + pBeam->die = 0.0f; pBeam = NULL; } if( pBeam2 ) { - pBeam2->die = 0.0; + pBeam2->die = 0.0f; pBeam2 = NULL; } @@ -1592,7 +1553,7 @@ enum hgun_e void EV_HornetGunFire( event_args_t *args ) { int idx; //, iFireMode; - vec3_t origin, angles, vecSrc, forward, right, up; + vec3_t origin, angles; //, vecSrc, forward, right, up; idx = args->entindex; VectorCopy( args->origin, origin ); @@ -1603,7 +1564,7 @@ void EV_HornetGunFire( event_args_t *args ) if( EV_IsLocal( idx ) ) { V_PunchAxis( 0, gEngfuncs.pfnRandomLong( 0, 2 ) ); - gEngfuncs.pEventAPI->EV_WeaponAnimation( HGUN_SHOOT, 1 ); + gEngfuncs.pEventAPI->EV_WeaponAnimation( HGUN_SHOOT, 0 ); } switch( gEngfuncs.pfnRandomLong( 0, 2 ) ) @@ -1648,6 +1609,7 @@ void EV_TripmineFire( event_args_t *args ) pmtrace_t tr; idx = args->entindex; + const bool last = args->bparam1 != 0; VectorCopy( args->origin, vecSrc ); VectorCopy( args->angles, angles ); @@ -1667,10 +1629,10 @@ void EV_TripmineFire( event_args_t *args ) // Now add in all of the players. gEngfuncs.pEventAPI->EV_SetSolidPlayers ( idx - 1 ); gEngfuncs.pEventAPI->EV_SetTraceHull( 2 ); - gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecSrc + forward * 128, PM_NORMAL, -1, &tr ); + gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecSrc + forward * 128.0f, PM_NORMAL, -1, &tr ); //Hit something solid - if( tr.fraction < 1.0 ) + if( tr.fraction < 1.0f && !last ) gEngfuncs.pEventAPI->EV_WeaponAnimation ( TRIPMINE_DRAW, 0 ); gEngfuncs.pEventAPI->EV_PopPMStates(); @@ -1698,7 +1660,7 @@ enum squeak_e void EV_SnarkFire( event_args_t *args ) { int idx; - vec3_t vecSrc, angles, view_ofs, forward; + vec3_t vecSrc, angles, /*view_ofs,*/ forward; pmtrace_t tr; idx = args->entindex; @@ -1722,7 +1684,7 @@ void EV_SnarkFire( event_args_t *args ) gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc + forward * 20, vecSrc + forward * 64, PM_NORMAL, -1, &tr ); //Find space to drop the thing. - if( tr.allsolid == 0 && tr.startsolid == 0 && tr.fraction > 0.25 ) + if( tr.allsolid == 0 && tr.startsolid == 0 && tr.fraction > 0.25f ) gEngfuncs.pEventAPI->EV_WeaponAnimation( SQUEAK_THROW, 0 ); gEngfuncs.pEventAPI->EV_PopPMStates(); @@ -1751,9 +1713,9 @@ void EV_TrainPitchAdjust( event_args_t *args ) us_params = (unsigned short)args->iparam1; stop = args->bparam1; - m_flVolume = (float)( us_params & 0x003f ) / 40.0; + m_flVolume = (float)( us_params & 0x003f ) / 40.0f; noise = (int)( ( ( us_params ) >> 12 ) & 0x0007 ); - pitch = (int)( 10.0 * (float)( ( us_params >> 6 ) & 0x003f ) ); + pitch = (int)( 10.0f * (float)( ( us_params >> 6 ) & 0x003f ) ); switch( noise ) { diff --git a/cl_dll/flashlight.cpp b/cl_dll/flashlight.cpp index ee3d6d22..3ec69973 100644 --- a/cl_dll/flashlight.cpp +++ b/cl_dll/flashlight.cpp @@ -50,7 +50,7 @@ void CHudFlashlight::Reset( void ) m_fFade = 0; m_fOn = 0; m_iBat = 100; - m_flBat = 1.0; + m_flBat = 1.0f; } int CHudFlashlight::VidInit( void ) @@ -75,7 +75,7 @@ int CHudFlashlight::MsgFunc_FlashBat( const char *pszName, int iSize, void *pbu BEGIN_READ( pbuf, iSize ); int x = READ_BYTE(); m_iBat = x; - m_flBat = ( (float)x ) / 100.0; + m_flBat = ( (float)x ) / 100.0f; return 1; } @@ -86,7 +86,7 @@ int CHudFlashlight::MsgFunc_Flashlight( const char *pszName, int iSize, void *p m_fOn = READ_BYTE(); int x = READ_BYTE(); m_iBat = x; - m_flBat = ( (float)x ) / 100.0; + m_flBat = ( (float)x ) / 100.0f; return 1; } @@ -119,7 +119,7 @@ int CHudFlashlight::Draw( float flTime ) else a = MIN_ALPHA; - if( m_flBat < 0.20 ) + if( m_flBat < 0.20f ) UnpackRGB( r,g,b, RGB_REDISH ); else UnpackRGB( r,g,b, RGB_YELLOWISH ); @@ -144,7 +144,7 @@ int CHudFlashlight::Draw( float flTime ) // draw the flashlight energy level x = ScreenWidth - m_iWidth - m_iWidth / 2; - int iOffset = m_iWidth * ( 1.0 - m_flBat ); + int iOffset = m_iWidth * ( 1.0f - m_flBat ); if( iOffset < m_iWidth ) { rc = *m_prc2; diff --git a/cl_dll/geiger.cpp b/cl_dll/geiger.cpp index 097889b9..89d2b951 100644 --- a/cl_dll/geiger.cpp +++ b/cl_dll/geiger.cpp @@ -66,7 +66,7 @@ int CHudGeiger::Draw( float flTime ) int pct; float flvol = 0.0f; //int rg[3]; - int i; + int i = 0; if( m_iGeigerRange < 1000 && m_iGeigerRange > 0 ) { @@ -78,7 +78,7 @@ int CHudGeiger::Draw( float flTime ) else if( m_iGeigerRange > 600 ) { pct = 2; - flvol = 0.4; //Con_Printf( "range > 600\n" ); + flvol = 0.4f; //Con_Printf( "range > 600\n" ); //rg[0] = 1; //rg[1] = 1; i = 2; @@ -86,7 +86,7 @@ int CHudGeiger::Draw( float flTime ) else if( m_iGeigerRange > 500 ) { pct = 4; - flvol = 0.5; //Con_Printf( "range > 500\n" ); + flvol = 0.5f; //Con_Printf( "range > 500\n" ); //rg[0] = 1; //rg[1] = 2; i = 2; @@ -94,7 +94,7 @@ int CHudGeiger::Draw( float flTime ) else if( m_iGeigerRange > 400 ) { pct = 8; - flvol = 0.6; //Con_Printf( "range > 400\n" ); + flvol = 0.6f; //Con_Printf( "range > 400\n" ); //rg[0] = 1; //rg[1] = 2; //rg[2] = 3; @@ -103,7 +103,7 @@ int CHudGeiger::Draw( float flTime ) else if( m_iGeigerRange > 300 ) { pct = 8; - flvol = 0.7; //Con_Printf( "range > 300\n" ); + flvol = 0.7f; //Con_Printf( "range > 300\n" ); //rg[0] = 2; //rg[1] = 3; //rg[2] = 4; @@ -112,7 +112,7 @@ int CHudGeiger::Draw( float flTime ) else if( m_iGeigerRange > 200 ) { pct = 28; - flvol = 0.78; //Con_Printf( "range > 200\n" ); + flvol = 0.78f; //Con_Printf( "range > 200\n" ); //rg[0] = 2; //rg[1] = 3; //rg[2] = 4; @@ -121,7 +121,7 @@ int CHudGeiger::Draw( float flTime ) else if( m_iGeigerRange > 150 ) { pct = 40; - flvol = 0.80; //Con_Printf( "range > 150\n" ); + flvol = 0.80f; //Con_Printf( "range > 150\n" ); //rg[0] = 3; //rg[1] = 4; //rg[2] = 5; @@ -139,7 +139,7 @@ int CHudGeiger::Draw( float flTime ) else if( m_iGeigerRange > 75 ) { pct = 80; - flvol = 0.9; //Con_Printf( "range > 75\n" ); + flvol = 0.9f; //Con_Printf( "range > 75\n" ); //gflGeigerDelay = cl.time + GEIGERDELAY * 0.75; //rg[0] = 4; //rg[1] = 5; @@ -149,7 +149,7 @@ int CHudGeiger::Draw( float flTime ) else if( m_iGeigerRange > 50 ) { pct = 90; - flvol = 0.95; //Con_Printf( "range > 50\n" ); + flvol = 0.95f; //Con_Printf( "range > 50\n" ); //rg[0] = 5; //rg[1] = 6; i = 2; @@ -157,17 +157,17 @@ int CHudGeiger::Draw( float flTime ) else { pct = 95; - flvol = 1.0; //Con_Printf( "range < 50\n" ); + flvol = 1.0f; //Con_Printf( "range < 50\n" ); //rg[0] = 5; //rg[1] = 6; i = 2; } - flvol = ( flvol * ( ( rand() & 127 ) ) / 255 ) + 0.25; // UTIL_RandomFloat( 0.25, 0.5 ); + flvol = ( flvol * ( ( rand() & 127 ) ) / 255 ) + 0.25f; // UTIL_RandomFloat( 0.25f, 0.5f ); if( ( rand() & 127 ) < pct || ( rand() & 127 ) < pct ) { - //S_StartDynamicSound( -1, 0, rgsfx[rand() % i], r_origin, flvol, 1.0, 0, 100 ); + //S_StartDynamicSound( -1, 0, rgsfx[rand() % i], r_origin, flvol, 1.0f, 0, 100 ); char sz[256]; int j = rand() & 1; diff --git a/cl_dll/health.cpp b/cl_dll/health.cpp index bde24f96..e14182b8 100644 --- a/cl_dll/health.cpp +++ b/cl_dll/health.cpp @@ -18,9 +18,9 @@ // implementation of CHudHealth class // -#include "stdio.h" -#include "stdlib.h" -#include "math.h" +#include +#include +#include #include "hud.h" #include "cl_util.h" @@ -152,13 +152,14 @@ int CHudHealth::MsgFunc_Damage( const char *pszName, int iSize, void *pbuf ) // Green <-> Yellow <-> Red ramp void CHudHealth::GetPainColor( int &r, int &g, int &b ) { +#if 0 int iHealth = m_iHealth; if( iHealth > 25 ) iHealth -= 25; else if( iHealth < 0 ) iHealth = 0; -#if 0 + g = iHealth * 255 / 100; r = 255 - g; b = 0; @@ -191,7 +192,7 @@ int CHudHealth::Draw( float flTime ) // Has health changed? Flash the health # if( m_fFade ) { - m_fFade -= ( gHUD.m_flTimeDelta * 20 ); + m_fFade -= ( (float)gHUD.m_flTimeDelta * 20.0f ); if( m_fFade <= 0 ) { a = MIN_ALPHA; @@ -270,27 +271,27 @@ void CHudHealth::CalcDamageDirection( vec3_t vecFrom ) } else { - if( side > 0 ) + if( side > 0.0f ) { - if( side > 0.3 ) + if( side > 0.3f ) m_fAttackFront = Q_max( m_fAttackFront, side ); } else { float f = fabs( side ); - if( f > 0.3 ) + if( f > 0.3f ) m_fAttackRear = Q_max( m_fAttackRear, f ); } - if( front > 0 ) + if( front > 0.0f ) { - if( front > 0.3 ) + if( front > 0.3f ) m_fAttackRight = Q_max( m_fAttackRight, front ); } else { float f = fabs( front ); - if( f > 0.3 ) + if( f > 0.3f ) m_fAttackLeft = Q_max( m_fAttackLeft, f ); } } @@ -310,10 +311,10 @@ int CHudHealth::DrawPain( float flTime ) float fFade = gHUD.m_flTimeDelta * 2; // SPR_Draw top - if( m_fAttackFront > 0.4 ) + if( m_fAttackFront > 0.4f ) { GetPainColor( r, g, b ); - shade = a * Q_max( m_fAttackFront, 0.5 ); + shade = a * Q_max( m_fAttackFront, 0.5f ); ScaleColors( r, g, b, shade ); SPR_Set( m_hSprite, r, g, b ); @@ -324,10 +325,10 @@ int CHudHealth::DrawPain( float flTime ) } else m_fAttackFront = 0; - if( m_fAttackRight > 0.4 ) + if( m_fAttackRight > 0.4f ) { GetPainColor( r, g, b ); - shade = a * Q_max( m_fAttackRight, 0.5 ); + shade = a * Q_max( m_fAttackRight, 0.5f ); ScaleColors( r, g, b, shade ); SPR_Set( m_hSprite, r, g, b ); @@ -339,10 +340,10 @@ int CHudHealth::DrawPain( float flTime ) else m_fAttackRight = 0; - if( m_fAttackRear > 0.4 ) + if( m_fAttackRear > 0.4f ) { GetPainColor( r, g, b ); - shade = a * Q_max( m_fAttackRear, 0.5 ); + shade = a * Q_max( m_fAttackRear, 0.5f ); ScaleColors( r, g, b, shade ); SPR_Set( m_hSprite, r, g, b ); @@ -354,10 +355,10 @@ int CHudHealth::DrawPain( float flTime ) else m_fAttackRear = 0; - if( m_fAttackLeft > 0.4 ) + if( m_fAttackLeft > 0.4f ) { GetPainColor( r, g, b ); - shade = a * Q_max( m_fAttackLeft, 0.5 ); + shade = a * Q_max( m_fAttackLeft, 0.5f ); ScaleColors( r, g, b, shade ); SPR_Set( m_hSprite, r, g, b ); @@ -382,7 +383,7 @@ int CHudHealth::DrawDamage( float flTime ) UnpackRGB( r, g, b, RGB_YELLOWISH ); - a = (int)( fabs( sin( flTime * 2 ) ) * 256.0 ); + a = (int)( fabs( sin( flTime * 2.0f ) ) * 256.0f ); ScaleColors( r, g, b, a ); @@ -461,7 +462,7 @@ void CHudHealth::UpdateTiles( float flTime, long bitsDamage ) if( pdmg->y ) pdmg->y -= giDmgHeight; } - pdmg = &m_dmg[i]; + // pdmg = &m_dmg[i]; } } diff --git a/cl_dll/health.h b/cl_dll/health.h index 62d7e0bc..41375a69 100644 --- a/cl_dll/health.h +++ b/cl_dll/health.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef HEALTH_H +#if !defined(HEALTH_H) #define HEALTH_H #define DMG_IMAGE_LIFE 2 // seconds that image is up diff --git a/cl_dll/hl/hl_baseentity.cpp b/cl_dll/hl/hl_baseentity.cpp index 7dc9ffdb..9f26f758 100644 --- a/cl_dll/hl/hl_baseentity.cpp +++ b/cl_dll/hl/hl_baseentity.cpp @@ -350,3 +350,4 @@ float CBasePlayer::TouchGravGun( CBaseEntity*e, int s ) { return 0; } void CBasePlayer::Touch( CBaseEntity * ) {} void RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType ){} +void CSprite::AnimateUntilDead( void ) {} diff --git a/cl_dll/hl/hl_objects.cpp b/cl_dll/hl/hl_objects.cpp index 55822dcb..788b09e3 100644 --- a/cl_dll/hl/hl_objects.cpp +++ b/cl_dll/hl/hl_objects.cpp @@ -68,25 +68,25 @@ void UpdateBeams( void ) if( pBeam ) { pBeam->target = tr.endpos; - pBeam->die = gEngfuncs.GetClientTime() + 0.1; // We keep it alive just a little bit forward in the future, just in case. + pBeam->die = gEngfuncs.GetClientTime() + 0.1f; // We keep it alive just a little bit forward in the future, just in case. } if( pBeam2 ) { pBeam2->target = tr.endpos; - pBeam2->die = gEngfuncs.GetClientTime() + 0.1; // We keep it alive just a little bit forward in the future, just in case. + pBeam2->die = gEngfuncs.GetClientTime() + 0.1f; // We keep it alive just a little bit forward in the future, just in case. } if( pFlare ) // Vit_amiN: beam flare { pFlare->entity.origin = tr.endpos; - pFlare->die = gEngfuncs.GetClientTime() + 0.1; // We keep it alive just a little bit forward in the future, just in case. + pFlare->die = gEngfuncs.GetClientTime() + 0.1f; // We keep it alive just a little bit forward in the future, just in case. if( gEngfuncs.GetMaxClients() != 1 ) // Singleplayer always draws the egon's energy beam flare { pFlare->flags |= FTENT_NOMODEL; - if( !( tr.allsolid || tr.ent <= 0 || tr.fraction == 1.0 ) ) // Beam hit some non-world entity + if( !( tr.allsolid || tr.ent <= 0 || tr.fraction == 1.0f ) ) // Beam hit some non-world entity { physent_t *pEntity = gEngfuncs.pEventAPI->EV_GetPhysent( tr.ent ); diff --git a/cl_dll/hl/hl_weapons.cpp b/cl_dll/hl/hl_weapons.cpp index 75161a9e..4f119f02 100644 --- a/cl_dll/hl/hl_weapons.cpp +++ b/cl_dll/hl/hl_weapons.cpp @@ -36,7 +36,7 @@ extern globalvars_t *gpGlobals; extern int g_iUser1; // Pool of client side entities/entvars_t -static entvars_t ev[32]; +static entvars_t ev[MAX_WEAPONS]; static int num_ents = 0; // The entity we'll use to represent the local client @@ -45,7 +45,7 @@ static CBasePlayer player; // Local version of game .dll global variables ( time, etc. ) static globalvars_t Globals; -static CBasePlayerWeapon *g_pWpns[32]; +static CBasePlayerWeapon *g_pWpns[MAX_WEAPONS]; float g_flApplyVel = 0.0; int g_irunninggausspred = 0; @@ -163,7 +163,7 @@ BOOL CBasePlayerWeapon::DefaultReload( int iClipSize, int iAnim, float fDelay, i m_fInReload = TRUE; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3.0f; return TRUE; } @@ -218,8 +218,8 @@ BOOL CBasePlayerWeapon::DefaultDeploy( const char *szViewModel, const char *szWe SendWeaponAnim( iAnim, skiplocal, body ); g_irunninggausspred = false; - m_pPlayer->m_flNextAttack = 0.5; - m_flTimeWeaponIdle = 1.0; + m_pPlayer->m_flNextAttack = 0.5f; + m_flTimeWeaponIdle = 1.0f; return TRUE; } @@ -233,7 +233,7 @@ BOOL CBasePlayerWeapon::PlayEmptySound( void ) { if( m_iPlayEmptySound ) { - HUD_PlaySound( "weapons/357_cock1.wav", 0.8 ); + HUD_PlaySound( "weapons/357_cock1.wav", 0.8f ); m_iPlayEmptySound = 0; return 0; } @@ -296,8 +296,8 @@ Vector CBaseEntity::FireBulletsPlayer ( ULONG cShots, Vector vecSrc, Vector vecD { // get circular gaussian spread do { - x = RANDOM_FLOAT( -0.5, 0.5 ) + RANDOM_FLOAT( -0.5, 0.5 ); - y = RANDOM_FLOAT( -0.5, 0.5 ) + RANDOM_FLOAT( -0.5, 0.5 ); + x = RANDOM_FLOAT( -0.5f, 0.5f ) + RANDOM_FLOAT( -0.5f, 0.5f ); + y = RANDOM_FLOAT( -0.5f, 0.5f ) + RANDOM_FLOAT( -0.5f, 0.5f ); z = x * x + y * y; } while( z > 1 ); } @@ -305,13 +305,13 @@ Vector CBaseEntity::FireBulletsPlayer ( ULONG cShots, Vector vecSrc, Vector vecD { //Use player's random seed. // get circular gaussian spread - x = UTIL_SharedRandomFloat( shared_rand + iShot, -0.5, 0.5 ) + UTIL_SharedRandomFloat( shared_rand + ( 1 + iShot ) , -0.5, 0.5 ); - y = UTIL_SharedRandomFloat( shared_rand + ( 2 + iShot ), -0.5, 0.5 ) + UTIL_SharedRandomFloat( shared_rand + ( 3 + iShot ), -0.5, 0.5 ); - z = x * x + y * y; + x = UTIL_SharedRandomFloat( shared_rand + iShot, -0.5f, 0.5f ) + UTIL_SharedRandomFloat( shared_rand + ( 1 + iShot ) , -0.5f, 0.5f ); + y = UTIL_SharedRandomFloat( shared_rand + ( 2 + iShot ), -0.5f, 0.5f ) + UTIL_SharedRandomFloat( shared_rand + ( 3 + iShot ), -0.5f, 0.5f ); + // z = x * x + y * y; } } - return Vector( x * vecSpread.x, y * vecSpread.y, 0.0 ); + return Vector( x * vecSpread.x, y * vecSpread.y, 0.0f ); } /* @@ -323,11 +323,15 @@ Handles weapon firing, reloading, etc. */ void CBasePlayerWeapon::ItemPostFrame( void ) { - if( ( m_fInReload ) && ( m_pPlayer->m_flNextAttack <= 0.0 ) ) + if( ( m_fInReload ) && ( m_pPlayer->m_flNextAttack <= 0.0f ) ) { -#if 0 // FIXME, need ammo on client to make this work right +#if 1 // complete the reload. - int j = min( iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ); + ItemInfo itemInfo; + memset( &itemInfo, 0, sizeof( itemInfo ) ); + GetItemInfo( &itemInfo ); + + int j = Q_min( itemInfo.iMaxClip - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ); // Add them to the clip m_iClip += j; @@ -338,7 +342,7 @@ void CBasePlayerWeapon::ItemPostFrame( void ) m_fInReload = FALSE; } - if( ( m_pPlayer->pev->button & IN_ATTACK2 ) && ( m_flNextSecondaryAttack <= 0.0 ) ) + if( ( m_pPlayer->pev->button & IN_ATTACK2 ) && ( m_flNextSecondaryAttack <= 0.0f ) ) { if( pszAmmo2() && !m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()] ) { @@ -348,7 +352,7 @@ void CBasePlayerWeapon::ItemPostFrame( void ) SecondaryAttack(); m_pPlayer->pev->button &= ~IN_ATTACK2; } - else if( ( m_pPlayer->pev->button & IN_ATTACK ) && ( m_flNextPrimaryAttack <= 0.0 ) ) + else if( ( m_pPlayer->pev->button & IN_ATTACK ) && ( m_flNextPrimaryAttack <= 0.0f ) ) { if( ( m_iClip == 0 && pszAmmo1() ) || ( iMaxClip() == -1 && !m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] ) ) { @@ -368,7 +372,7 @@ void CBasePlayerWeapon::ItemPostFrame( void ) m_fFireOnEmpty = FALSE; // weapon is useable. Reload if empty and weapon has waited as long as it has to after firing - if( m_iClip == 0 && !( iFlags() & ITEM_FLAG_NOAUTORELOAD ) && m_flNextPrimaryAttack < 0.0 ) + if( m_iClip == 0 && !( iFlags() & ITEM_FLAG_NOAUTORELOAD ) && m_flNextPrimaryAttack <= 0.0f ) { Reload(); return; @@ -483,7 +487,7 @@ Don't actually trace, but act like the trace didn't hit anything. void UTIL_TraceLine( const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, edict_t *pentIgnore, TraceResult *ptr ) { memset( ptr, 0, sizeof(*ptr) ); - ptr->flFraction = 1.0; + ptr->flFraction = 1.0f; } /* @@ -748,7 +752,7 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm if( !pWeapon ) return; - for( i = 0; i < 32; i++ ) + for( i = 0; i < MAX_WEAPONS; i++ ) { pCurrent = g_pWpns[i]; if( !pCurrent ) @@ -895,19 +899,15 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm if( player.m_pActiveItem->m_iId == WEAPON_RPG ) { - from->client.vuser2[1] = ( (CRpg *)player.m_pActiveItem)->m_fSpotActive; - from->client.vuser2[2] = ( (CRpg *)player.m_pActiveItem)->m_cActiveRockets; + to->client.vuser2[1] = ( (CRpg *)player.m_pActiveItem)->m_fSpotActive; + to->client.vuser2[2] = ( (CRpg *)player.m_pActiveItem)->m_cActiveRockets; } // Make sure that weapon animation matches what the game .dll is telling us // over the wire ( fixes some animation glitches ) if( g_runfuncs && ( HUD_GetWeaponAnim() != to->client.weaponanim ) ) { - int body = 2; - - //Pop the model to body 0. - if( pWeapon == &g_Tripmine ) - body = 0; + int body = 0; //Show laser sight/scope combo if( pWeapon == &g_Python && bIsMultiplayer() ) @@ -917,7 +917,7 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm HUD_SendWeaponAnim( to->client.weaponanim, body, 1 ); } - for( i = 0; i < 32; i++ ) + for( i = 0; i < MAX_WEAPONS; i++ ) { pCurrent = g_pWpns[i]; @@ -944,73 +944,73 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm pto->iuser3 = pCurrent->m_fireState; // Decrement weapon counters, server does this at same time ( during post think, after doing everything else ) - pto->m_flNextReload -= cmd->msec / 1000.0; - pto->m_fNextAimBonus -= cmd->msec / 1000.0; - pto->m_flNextPrimaryAttack -= cmd->msec / 1000.0; - pto->m_flNextSecondaryAttack -= cmd->msec / 1000.0; - pto->m_flTimeWeaponIdle -= cmd->msec / 1000.0; - pto->fuser1 -= cmd->msec / 1000.0; + pto->m_flNextReload -= cmd->msec / 1000.0f; + pto->m_fNextAimBonus -= cmd->msec / 1000.0f; + pto->m_flNextPrimaryAttack -= cmd->msec / 1000.0f; + pto->m_flNextSecondaryAttack -= cmd->msec / 1000.0f; + pto->m_flTimeWeaponIdle -= cmd->msec / 1000.0f; + pto->fuser1 -= cmd->msec / 1000.0f; to->client.vuser3[2] = pCurrent->m_iSecondaryAmmoType; to->client.vuser4[0] = pCurrent->m_iPrimaryAmmoType; to->client.vuser4[1] = player.m_rgAmmo[pCurrent->m_iPrimaryAmmoType]; to->client.vuser4[2] = player.m_rgAmmo[pCurrent->m_iSecondaryAmmoType]; -/* if( pto->m_flPumpTime != -9999 ) +/* if( pto->m_flPumpTime != -9999.0f ) { - pto->m_flPumpTime -= cmd->msec / 1000.0; - if( pto->m_flPumpTime < -0.001 ) - pto->m_flPumpTime = -0.001; + pto->m_flPumpTime -= cmd->msec / 1000.0f; + if( pto->m_flPumpTime < -0.001f ) + pto->m_flPumpTime = -0.001f; }*/ - if( pto->m_fNextAimBonus < -1.0 ) + if( pto->m_fNextAimBonus < -1.0f ) { - pto->m_fNextAimBonus = -1.0; + pto->m_fNextAimBonus = -1.0f; } - if( pto->m_flNextPrimaryAttack < -1.0 ) + if( pto->m_flNextPrimaryAttack < -1.0f ) { - pto->m_flNextPrimaryAttack = -1.0; + pto->m_flNextPrimaryAttack = -1.0f; } - if( pto->m_flNextSecondaryAttack < -0.001 ) + if( pto->m_flNextSecondaryAttack < -0.001f ) { - pto->m_flNextSecondaryAttack = -0.001; + pto->m_flNextSecondaryAttack = -0.001f; } - if( pto->m_flTimeWeaponIdle < -0.001 ) + if( pto->m_flTimeWeaponIdle < -0.001f ) { - pto->m_flTimeWeaponIdle = -0.001; + pto->m_flTimeWeaponIdle = -0.001f; } - if( pto->m_flNextReload < -0.001 ) + if( pto->m_flNextReload < -0.001f ) { - pto->m_flNextReload = -0.001; + pto->m_flNextReload = -0.001f; } - if( pto->fuser1 < -0.001 ) + if( pto->fuser1 < -0.001f ) { - pto->fuser1 = -0.001; + pto->fuser1 = -0.001f; } } // m_flNextAttack is now part of the weapons, but is part of the player instead - to->client.m_flNextAttack -= cmd->msec / 1000.0; - if( to->client.m_flNextAttack < -0.001 ) + to->client.m_flNextAttack -= cmd->msec / 1000.0f; + if( to->client.m_flNextAttack < -0.001f ) { - to->client.m_flNextAttack = -0.001; + to->client.m_flNextAttack = -0.001f; } - to->client.fuser2 -= cmd->msec / 1000.0; - if( to->client.fuser2 < -0.001 ) + to->client.fuser2 -= cmd->msec / 1000.0f; + if( to->client.fuser2 < -0.001f ) { - to->client.fuser2 = -0.001; + to->client.fuser2 = -0.001f; } - to->client.fuser3 -= cmd->msec / 1000.0; - if( to->client.fuser3 < -0.001 ) + to->client.fuser3 -= cmd->msec / 1000.0f; + if( to->client.fuser3 < -0.001f ) { - to->client.fuser3 = -0.001; + to->client.fuser3 = -0.001f; } // Store off the last position from the predicted state. @@ -1035,7 +1035,7 @@ void _DLLEXPORT HUD_PostRunCmd( struct local_state_s *from, struct local_state_s { g_runfuncs = runfuncs; -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS if( cl_lw && cl_lw->value ) { HUD_WeaponsPostThink( from, to, cmd, time, random_seed ); diff --git a/cl_dll/hud.cpp b/cl_dll/hud.cpp index 62c32b41..f16e30b9 100644 --- a/cl_dll/hud.cpp +++ b/cl_dll/hud.cpp @@ -23,11 +23,72 @@ #include #include #include "parsemsg.h" -#include "hud_servers.h" +#if USE_VGUI +#include "vgui_int.h" +#include "vgui_TeamFortressViewport.h" +#endif #include "demo.h" #include "demo_api.h" +hud_player_info_t g_PlayerInfoList[MAX_PLAYERS+1]; // player info from the engine +extra_player_info_t g_PlayerExtraInfo[MAX_PLAYERS+1]; // additional player info sent directly to the client dll +team_info_t g_TeamInfo[MAX_TEAMS + 1]; +int g_IsSpectator[MAX_PLAYERS+1]; +int g_iPlayerClass; +int g_iTeamNumber; +int g_iUser1 = 0; +int g_iUser2 = 0; +int g_iUser3 = 0; + +#if USE_VGUI +#include "vgui_ScorePanel.h" + +class CHLVoiceStatusHelper : public IVoiceStatusHelper +{ +public: + virtual void GetPlayerTextColor(int entindex, int color[3]) + { + color[0] = color[1] = color[2] = 255; + + if( entindex >= 0 && entindex < sizeof(g_PlayerExtraInfo)/sizeof(g_PlayerExtraInfo[0]) ) + { + int iTeam = g_PlayerExtraInfo[entindex].teamnumber; + + if ( iTeam < 0 ) + { + iTeam = 0; + } + + iTeam = iTeam % iNumberOfTeamColors; + + color[0] = iTeamColors[iTeam][0]; + color[1] = iTeamColors[iTeam][1]; + color[2] = iTeamColors[iTeam][2]; + } + } + + virtual void UpdateCursorState() + { + gViewPort->UpdateCursorState(); + } + + virtual int GetAckIconHeight() + { + return ScreenHeight - gHUD.m_iFontHeight*3 - 6; + } + + virtual bool CanShowSpeakerLabels() + { + if( gViewPort && gViewPort->m_pScoreBoard ) + return !gViewPort->m_pScoreBoard->isVisible(); + else + return false; + } +}; +static CHLVoiceStatusHelper g_VoiceStatusHelper; +#endif + cvar_t *hud_textmode; float g_hud_text_color[3]; @@ -81,73 +142,182 @@ int __MsgFunc_GameMode( const char *pszName, int iSize, void *pbuf ) // TFFree Command Menu void __CmdFunc_OpenCommandMenu( void ) { +#if USE_VGUI + if ( gViewPort ) + { + gViewPort->ShowCommandMenu( gViewPort->m_StandardMenu ); + } +#endif } // TFC "special" command void __CmdFunc_InputPlayerSpecial( void ) { +#if USE_VGUI + if ( gViewPort ) + { + gViewPort->InputPlayerSpecial(); + } +#endif } void __CmdFunc_CloseCommandMenu( void ) { +#if USE_VGUI + if ( gViewPort ) + { + gViewPort->InputSignalHideCommandMenu(); + } +#endif } void __CmdFunc_ForceCloseCommandMenu( void ) { -} - -void __CmdFunc_ToggleServerBrowser( void ) -{ +#if USE_VGUI + if ( gViewPort ) + { + gViewPort->HideCommandMenu(); + } +#endif } // TFFree Command Menu Message Handlers int __MsgFunc_ValClass( const char *pszName, int iSize, void *pbuf ) { +#if USE_VGUI + if (gViewPort) + return gViewPort->MsgFunc_ValClass( pszName, iSize, pbuf ); +#endif return 0; } int __MsgFunc_TeamNames( const char *pszName, int iSize, void *pbuf ) { +#if USE_VGUI + if (gViewPort) + return gViewPort->MsgFunc_TeamNames( pszName, iSize, pbuf ); +#endif return 0; } int __MsgFunc_Feign( const char *pszName, int iSize, void *pbuf ) { +#if USE_VGUI + if (gViewPort) + return gViewPort->MsgFunc_Feign( pszName, iSize, pbuf ); +#endif return 0; } int __MsgFunc_Detpack( const char *pszName, int iSize, void *pbuf ) { +#if USE_VGUI + if (gViewPort) + return gViewPort->MsgFunc_Detpack( pszName, iSize, pbuf ); +#endif return 0; } int __MsgFunc_VGUIMenu( const char *pszName, int iSize, void *pbuf ) { +#if USE_VGUI + if (gViewPort) + return gViewPort->MsgFunc_VGUIMenu( pszName, iSize, pbuf ); +#endif return 0; } +#if USE_VGUI && !USE_NOVGUI_MOTD +int __MsgFunc_MOTD(const char *pszName, int iSize, void *pbuf) +{ + if (gViewPort) + return gViewPort->MsgFunc_MOTD( pszName, iSize, pbuf ); + return 0; +} +#endif + int __MsgFunc_BuildSt( const char *pszName, int iSize, void *pbuf ) { +#if USE_VGUI + if (gViewPort) + return gViewPort->MsgFunc_BuildSt( pszName, iSize, pbuf ); +#endif return 0; } int __MsgFunc_RandomPC( const char *pszName, int iSize, void *pbuf ) { +#if USE_VGUI + if (gViewPort) + return gViewPort->MsgFunc_RandomPC( pszName, iSize, pbuf ); +#endif return 0; } int __MsgFunc_ServerName( const char *pszName, int iSize, void *pbuf ) { +#if USE_VGUI + if (gViewPort) + return gViewPort->MsgFunc_ServerName( pszName, iSize, pbuf ); +#endif return 0; } +#if USE_VGUI && !USE_NOVGUI_SCOREBOARD +int __MsgFunc_ScoreInfo(const char *pszName, int iSize, void *pbuf) +{ + if (gViewPort) + return gViewPort->MsgFunc_ScoreInfo( pszName, iSize, pbuf ); + return 0; +} + +int __MsgFunc_TeamScore(const char *pszName, int iSize, void *pbuf) +{ + if (gViewPort) + return gViewPort->MsgFunc_TeamScore( pszName, iSize, pbuf ); + return 0; +} + +int __MsgFunc_TeamInfo(const char *pszName, int iSize, void *pbuf) +{ + if (gViewPort) + return gViewPort->MsgFunc_TeamInfo( pszName, iSize, pbuf ); + return 0; +} +#endif + int __MsgFunc_Spectator( const char *pszName, int iSize, void *pbuf ) { +#if USE_VGUI + if (gViewPort) + return gViewPort->MsgFunc_Spectator( pszName, iSize, pbuf ); +#endif return 0; } +#if USE_VGUI +int __MsgFunc_SpecFade(const char *pszName, int iSize, void *pbuf) +{ + if (gViewPort) + return gViewPort->MsgFunc_SpecFade( pszName, iSize, pbuf ); + return 0; +} + +int __MsgFunc_ResetFade(const char *pszName, int iSize, void *pbuf) +{ + if (gViewPort) + return gViewPort->MsgFunc_ResetFade( pszName, iSize, pbuf ); + return 0; + +} +#endif + int __MsgFunc_AllowSpec( const char *pszName, int iSize, void *pbuf ) { +#if USE_VGUI + if (gViewPort) + return gViewPort->MsgFunc_AllowSpec( pszName, iSize, pbuf ); +#endif return 0; } @@ -167,7 +337,6 @@ void CHud::Init( void ) HOOK_COMMAND( "-commandmenu", CloseCommandMenu ); HOOK_COMMAND( "ForceCloseCommandMenu", ForceCloseCommandMenu ); HOOK_COMMAND( "special", InputPlayerSpecial ); - HOOK_COMMAND( "togglebrowser", ToggleServerBrowser ); HOOK_MESSAGE( ValClass ); HOOK_MESSAGE( TeamNames ); @@ -177,9 +346,24 @@ void CHud::Init( void ) HOOK_MESSAGE( RandomPC ); HOOK_MESSAGE( ServerName ); +#if USE_VGUI && !USE_NOVGUI_MOTD + HOOK_MESSAGE( MOTD ); +#endif + +#if USE_VGUI && !USE_NOVGUI_SCOREBOARD + HOOK_MESSAGE( ScoreInfo ); + HOOK_MESSAGE( TeamScore ); + HOOK_MESSAGE( TeamInfo ); +#endif + HOOK_MESSAGE( Spectator ); HOOK_MESSAGE( AllowSpec ); +#if USE_VGUI + HOOK_MESSAGE( SpecFade ); + HOOK_MESSAGE( ResetFade ); +#endif + // VGUI Menus HOOK_MESSAGE( VGUIMenu ); @@ -190,8 +374,9 @@ void CHud::Init( void ) m_iLogo = 0; m_iFOV = 0; - CVAR_CREATE( "zoom_sensitivity_ratio", "1.2", 0 ); - default_fov = CVAR_CREATE( "default_fov", "90", 0 ); + CVAR_CREATE( "zoom_sensitivity_ratio", "1.2", FCVAR_ARCHIVE ); + CVAR_CREATE( "cl_autowepswitch", "1", FCVAR_ARCHIVE | FCVAR_USERINFO ); + default_fov = CVAR_CREATE( "default_fov", "90", FCVAR_ARCHIVE ); m_pCvarStealMouse = CVAR_CREATE( "hud_capturemouse", "1", FCVAR_ARCHIVE ); m_pCvarDraw = CVAR_CREATE( "hud_draw", "1", FCVAR_ARCHIVE ); cl_lw = gEngfuncs.pfnGetCvarPointer( "cl_lw" ); @@ -229,11 +414,19 @@ void CHud::Init( void ) m_AmmoSecondary.Init(); m_TextMessage.Init(); m_StatusIcons.Init(); +#if USE_VGUI + GetClientVoiceMgr()->Init(&g_VoiceStatusHelper, (vgui::Panel**)&gViewPort); +#endif + +#if !USE_VGUI || USE_NOVGUI_MOTD m_MOTD.Init(); +#endif +#if !USE_VGUI || USE_NOVGUI_SCOREBOARD m_Scoreboard.Init(); +#endif m_Menu.Init(); - + MsgFunc_ResetHUD( 0, 0, NULL ); } @@ -326,8 +519,8 @@ void CHud::VidInit( void ) sprintf( sz, "sprites/%s.spr", p->szSprite ); m_rghSprites[index] = SPR_Load( sz ); m_rgrcRects[index] = p->rc; - strncpy( &m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH], p->szName, MAX_SPRITE_NAME_LENGTH ); - + strncpy( &m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH], p->szName, MAX_SPRITE_NAME_LENGTH - 1 ); + m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH + ( MAX_SPRITE_NAME_LENGTH - 1 )] = '\0'; index++; } @@ -369,8 +562,8 @@ void CHud::VidInit( void ) sprintf( sz, "sprites/%s.spr", p->szSprite ); m_rghSprites[index] = SPR_Load( sz ); m_rgrcRects[index] = p->rc; - strncpy( &m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH], p->szName, MAX_SPRITE_NAME_LENGTH ); - + strncpy( &m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH], p->szName, MAX_SPRITE_NAME_LENGTH - 1 ); + m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH + ( MAX_SPRITE_NAME_LENGTH - 1 )] = '\0'; index++; } @@ -410,8 +603,15 @@ void CHud::VidInit( void ) m_AmmoSecondary.VidInit(); m_TextMessage.VidInit(); m_StatusIcons.VidInit(); - m_Scoreboard.VidInit(); +#if USE_VGUI + GetClientVoiceMgr()->VidInit(); +#endif +#if !USE_VGUI || USE_NOVGUI_MOTD m_MOTD.VidInit(); +#endif +#if !USE_VGUI || USE_NOVGUI_SCOREBOARD + m_Scoreboard.VidInit(); +#endif } int CHud::MsgFunc_Logo( const char *pszName, int iSize, void *pbuf ) @@ -587,3 +787,22 @@ float CHud::GetSensitivity( void ) { return m_flMouseSensitivity; } + +void CHud::GetAllPlayersInfo() +{ + for( int i = 1; i < MAX_PLAYERS; i++ ) + { + GetPlayerInfo( i, &g_PlayerInfoList[i] ); + + if( g_PlayerInfoList[i].thisplayer ) + { +#if USE_VGUI + if(gViewPort) + gViewPort->m_pScoreBoard->m_iPlayerNum = i; +#endif +#if !USE_VGUI || USE_NOVGUI_SCOREBOARD + m_Scoreboard.m_iPlayerNum = i; // !!!HACK: this should be initialized elsewhere... maybe gotten from the engine +#endif + } + } +} diff --git a/cl_dll/hud.h b/cl_dll/hud.h index f3e1ed85..69c6646f 100644 --- a/cl_dll/hud.h +++ b/cl_dll/hud.h @@ -20,7 +20,7 @@ // CHud handles the message, calculation, and drawing the HUD // #pragma once -#ifndef HUD_H +#if !defined(HUD_H) #define HUD_H #define RGB_YELLOWISH 0x00FFA000 //255,160,0 #define RGB_REDISH 0x00FF1010 //255,160,0 @@ -63,6 +63,9 @@ typedef struct cvar_s cvar_t; #define MAX_MOTD_LENGTH 1536 +#define MAX_SERVERNAME_LENGTH 64 +#define MAX_TEAMNAME_SIZE 32 + // //----------------------------------------------------- // @@ -89,6 +92,9 @@ struct HUDLIST // //----------------------------------------------------- +#if USE_VGUI +#include "voice_status.h" // base voice handling class +#endif #include "hud_spectator.h" // @@ -196,11 +202,7 @@ private: int m_iPos; }; -// -//----------------------------------------------------- -// -// REMOVED: Vgui has replaced this. -// +#if !USE_VGUI || USE_NOVGUI_MOTD class CHudMOTD : public CHudBase { public: @@ -222,7 +224,9 @@ protected: int m_iLines; int m_iMaxLength; }; +#endif +#if !USE_VGUI || USE_NOVGUI_SCOREBOARD class CHudScoreboard : public CHudBase { public: @@ -249,6 +253,7 @@ public: void GetAllPlayersInfo( void ); }; +#endif // //----------------------------------------------------- @@ -283,41 +288,6 @@ protected: float *m_pflNameColors[MAX_STATUSBAR_LINES]; }; -// -//----------------------------------------------------- -// -// REMOVED: Vgui has replaced this. -// -/* -class CHudScoreboard : public CHudBase -{ -public: - int Init( void ); - void InitHUDData( void ); - int VidInit( void ); - int Draw( float flTime ); - int DrawPlayers( int xoffset, float listslot, int nameoffset = 0, char *team = NULL ); // returns the ypos where it finishes drawing - void UserCmd_ShowScores( void ); - void UserCmd_HideScores( void ); - int MsgFunc_ScoreInfo( const char *pszName, int iSize, void *pbuf ); - int MsgFunc_TeamInfo( const char *pszName, int iSize, void *pbuf ); - int MsgFunc_TeamScore( const char *pszName, int iSize, void *pbuf ); - void DeathMsg( int killer, int victim ); - - int m_iNumTeams; - - int m_iLastKilledBy; - int m_fLastKillTime; - int m_iPlayerNum; - int m_iShowscoresHeld; - - void GetAllPlayersInfo( void ); - -private: - struct cvar_s *cl_showpacketloss; -}; -*/ - struct extra_player_info_t { short frags; @@ -633,8 +603,12 @@ public: CHudAmmoSecondary m_AmmoSecondary; CHudTextMessage m_TextMessage; CHudStatusIcons m_StatusIcons; +#if !USE_VGUI || USE_NOVGUI_SCOREBOARD CHudScoreboard m_Scoreboard; +#endif +#if !USE_VGUI || USE_NOVGUI_MOTD CHudMOTD m_MOTD; +#endif void Init( void ); void VidInit( void ); @@ -670,6 +644,8 @@ public: void AddHudElem( CHudBase *p ); float GetSensitivity(); + + void GetAllPlayersInfo( void ); }; extern CHud gHUD; diff --git a/cl_dll/hud_iface.h b/cl_dll/hud_iface.h index 73464c83..be5e390b 100644 --- a/cl_dll/hud_iface.h +++ b/cl_dll/hud_iface.h @@ -10,8 +10,8 @@ #define HUD_IFACEH #include "exportdef.h" - -typedef int (*pfnUserMsgHook)( const char *pszName, int iSize, void *pbuf ); +// redefine +// typedef int (*pfnUserMsgHook)( const char *pszName, int iSize, void *pbuf ); #include "wrect.h" #include "../engine/cdll_int.h" extern cl_enginefunc_t gEngfuncs; diff --git a/cl_dll/hud_redraw.cpp b/cl_dll/hud_redraw.cpp index 000c0c1b..64e24e1c 100644 --- a/cl_dll/hud_redraw.cpp +++ b/cl_dll/hud_redraw.cpp @@ -15,11 +15,16 @@ // // hud_redraw.cpp // -#include +#include + #include "hud.h" #include "cl_util.h" //#include "triangleapi.h" +#if USE_VGUI +#include "vgui_TeamFortressViewport.h" +#endif + #define MAX_LOGO_FRAMES 56 int grgLogoFrame[MAX_LOGO_FRAMES] = @@ -38,6 +43,11 @@ extern cvar_t *sensitivity; // Think void CHud::Think( void ) { +#if USE_VGUI + m_scrinfo.iSize = sizeof(m_scrinfo); + GetScreenInfo(&m_scrinfo); +#endif + int newfov; HUDLIST *pList = m_pHudList; @@ -86,20 +96,47 @@ int CHud::Redraw( float flTime, int intermission ) { m_fOldTime = m_flTime; // save time of previous redraw m_flTime = flTime; - m_flTimeDelta = (double)m_flTime - m_fOldTime; + m_flTimeDelta = (double)( m_flTime - m_fOldTime ); static float m_flShotTime = 0; // Clock was reset, reset delta if( m_flTimeDelta < 0 ) m_flTimeDelta = 0; +#if USE_VGUI + // Bring up the scoreboard during intermission + if (gViewPort) + { + if( m_iIntermission && !intermission ) + { + // Have to do this here so the scoreboard goes away + m_iIntermission = intermission; + gViewPort->HideCommandMenu(); + gViewPort->HideScoreBoard(); + gViewPort->UpdateSpectatorPanel(); + } + else if( !m_iIntermission && intermission ) + { + m_iIntermission = intermission; + gViewPort->HideCommandMenu(); + gViewPort->HideVGUIMenu(); +#if !USE_NOVGUI_SCOREBOARD + gViewPort->ShowScoreBoard(); +#endif + gViewPort->UpdateSpectatorPanel(); + // Take a screenshot if the client's got the cvar set + if( CVAR_GET_FLOAT( "hud_takesshots" ) != 0 ) + m_flShotTime = flTime + 1.0; // Take a screenshot in a second + } + } +#else if( !m_iIntermission && intermission ) { // Take a screenshot if the client's got the cvar set if( CVAR_GET_FLOAT( "hud_takesshots" ) != 0 ) - m_flShotTime = flTime + 1.0; // Take a screenshot in a second + m_flShotTime = flTime + 1.0f; // Take a screenshot in a second } - +#endif if( m_flShotTime && m_flShotTime < flTime ) { gEngfuncs.pfnClientCmd( "snapshot\n" ); @@ -164,9 +201,7 @@ int CHud::Redraw( float flTime, int intermission ) if( m_hsprCursor == 0 ) { - char sz[256]; - sprintf( sz, "sprites/cursor.spr" ); - m_hsprCursor = SPR_Load( sz ); + m_hsprCursor = SPR_Load( "sprites/cursor.spr" ); } SPR_Set( m_hsprCursor, 250, 250, 250 ); diff --git a/cl_dll/hud_servers.cpp b/cl_dll/hud_servers.cpp deleted file mode 100644 index fa6d5585..00000000 --- a/cl_dll/hud_servers.cpp +++ /dev/null @@ -1,1226 +0,0 @@ -//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -// hud_servers.cpp -#include "hud.h" -#include "cl_util.h" -#include "hud_servers_priv.h" -#include "hud_servers.h" -#include "net_api.h" -#include -#include - -static int context_id; - -// Default master server address in case we can't read any from woncomm.lst file -#define VALVE_MASTER_ADDRESS "half-life.east.won.net" -#define PORT_MASTER 27010 -#define PORT_SERVER 27015 - -// File where we really should look for master servers -#define MASTER_PARSE_FILE "woncomm.lst" - -#define MAX_QUERIES 20 - -#define NET_API gEngfuncs.pNetAPI - -static CHudServers *g_pServers = NULL; - -/* -=================== -ListResponse - -Callback from engine -=================== -*/ -void NET_CALLBACK ListResponse( struct net_response_s *response ) -{ - if( g_pServers ) - { - g_pServers->ListResponse( response ); - } -} - -/* -=================== -ServerResponse - -Callback from engine -=================== -*/ -void NET_CALLBACK ServerResponse( struct net_response_s *response ) -{ - if( g_pServers ) - { - g_pServers->ServerResponse( response ); - } -} - -/* -=================== -PingResponse - -Callback from engine -=================== -*/ -void NET_CALLBACK PingResponse( struct net_response_s *response ) -{ - if( g_pServers ) - { - g_pServers->PingResponse( response ); - } -} - -/* -=================== -RulesResponse - -Callback from engine -=================== -*/ -void NET_CALLBACK RulesResponse( struct net_response_s *response ) -{ - if( g_pServers ) - { - g_pServers->RulesResponse( response ); - } -} - -/* -=================== -PlayersResponse - -Callback from engine -=================== -*/ -void NET_CALLBACK PlayersResponse( struct net_response_s *response ) -{ - if( g_pServers ) - { - g_pServers->PlayersResponse( response ); - } -} - -/* -=================== -ListResponse - -=================== -*/ -void CHudServers::ListResponse( struct net_response_s *response ) -{ - request_t *list; - request_t *p; - int c = 0; - - if( !( response->error == NET_SUCCESS ) ) - return; - - if( response->type != NETAPI_REQUEST_SERVERLIST ) - return; - - if( response->response ) - { - list = ( request_t * ) response->response; - while ( list ) - { - c++; - - //if( c < 40 ) - { - // Copy from parsed stuff - p = new request_t; - p->context = -1; - p->remote_address = list->remote_address; - p->next = m_pServerList; - m_pServerList = p; - } - - // Move on - list = list->next; - } - } - - gEngfuncs.Con_Printf( "got list\n" ); - - m_nQuerying = 1; - m_nActiveQueries = 0; -} - -/* -=================== -ServerResponse - -=================== -*/ -void CHudServers::ServerResponse( struct net_response_s *response ) -{ - char *szresponse; - request_t *p; - server_t *browser; - int len; - char sz[32]; - - // Remove from active list - p = FindRequest( response->context, m_pActiveList ); - if( p ) - { - RemoveServerFromList( &m_pActiveList, p ); - m_nActiveQueries--; - } - - if( response->error != NET_SUCCESS ) - return; - - switch ( response->type ) - { - case NETAPI_REQUEST_DETAILS: - if( response->response ) - { - szresponse = (char *)response->response; - len = strlen( szresponse ) + 100 + 1; - sprintf( sz, "%i", (int)( 1000.0 * response->ping ) ); - - browser = new server_t; - browser->remote_address = response->remote_address; - browser->info = new char[len]; - browser->ping = (int)( 1000.0 * response->ping ); - strcpy( browser->info, szresponse ); - - NET_API->SetValueForKey( browser->info, "address", gEngfuncs.pNetAPI->AdrToString( &response->remote_address ), len ); - NET_API->SetValueForKey( browser->info, "ping", sz, len ); - - AddServer( &m_pServers, browser ); - } - break; - default: - break; - } -} - -/* -=================== -PingResponse - -=================== -*/ -void CHudServers::PingResponse( struct net_response_s *response ) -{ - char sz[32]; - - if( response->error != NET_SUCCESS ) - return; - - switch( response->type ) - { - case NETAPI_REQUEST_PING: - sprintf( sz, "%.2f", 1000.0 * response->ping ); - - gEngfuncs.Con_Printf( "ping == %s\n", sz ); - break; - default: - break; - } -} - -/* -=================== -RulesResponse - -=================== -*/ -void CHudServers::RulesResponse( struct net_response_s *response ) -{ - char *szresponse; - - if( response->error != NET_SUCCESS ) - return; - - switch( response->type ) - { - case NETAPI_REQUEST_RULES: - if( response->response ) - { - szresponse = (char *)response->response; - - gEngfuncs.Con_Printf( "rules %s\n", szresponse ); - } - break; - default: - break; - } -} - -/* -=================== -PlayersResponse - -=================== -*/ -void CHudServers::PlayersResponse( struct net_response_s *response ) -{ - char *szresponse; - - if( response->error != NET_SUCCESS ) - return; - - switch( response->type ) - { - case NETAPI_REQUEST_PLAYERS: - if( response->response ) - { - szresponse = (char *)response->response; - - gEngfuncs.Con_Printf( "players %s\n", szresponse ); - } - break; - default: - break; - } -} - -/* -=================== -CompareServers - -Return 1 if p1 is "less than" p2, 0 otherwise -=================== -*/ -int CHudServers::CompareServers( server_t *p1, server_t *p2 ) -{ - const char *n1, *n2; - - if( p1->ping < p2->ping ) - return 1; - - if( p1->ping == p2->ping ) - { - // Pings equal, sort by second key: hostname - if( p1->info && p2->info ) - { - n1 = NET_API->ValueForKey( p1->info, "hostname" ); - n2 = NET_API->ValueForKey( p2->info, "hostname" ); - - if( n1 && n2 ) - { - if( stricmp( n1, n2 ) < 0 ) - return 1; - } - } - } - - return 0; -} - -/* -=================== -AddServer - -=================== -*/ -void CHudServers::AddServer( server_t **ppList, server_t *p ) -{ - server_t *list; - - if( !ppList || ! p ) - return; - - m_nServerCount++; - - // What sort key? Ping? - list = *ppList; - - // Head of list? - if( !list ) - { - p->next = NULL; - *ppList = p; - return; - } - - // Put on head of list - if( CompareServers( p, list ) ) - { - p->next = *ppList; - *ppList = p; - } - else - { - while( list->next ) - { - // Insert before list next - if( CompareServers( p, list->next ) ) - { - p->next = list->next->next; - list->next = p; - return; - } - - list = list->next; - } - - // Just add at end - p->next = NULL; - list->next = p; - } -} - -/* -=================== -Think - -=================== -*/ -void CHudServers::Think( double time ) -{ - m_fElapsed += time; - - if( !m_nRequesting ) - return; - - if( !m_nQuerying ) - return; - - QueryThink(); - - if( ServerListSize() > 0 ) - return; - - m_dStarted = 0.0; - m_nRequesting = 0; - m_nDone = 0; - m_nQuerying = 0; - m_nActiveQueries = 0; -} - -/* -=================== -QueryThink - -=================== -*/ -void CHudServers::QueryThink( void ) -{ - request_t *p; - - if( !m_nRequesting || m_nDone ) - return; - - if( !m_nQuerying ) - return; - - if( m_nActiveQueries > MAX_QUERIES ) - return; - - // Nothing left - if( !m_pServerList ) - return; - - while( 1 ) - { - p = m_pServerList; - - // No more in list? - if( !p ) - break; - - // Move to next - m_pServerList = m_pServerList->next; - - // Setup context_id - p->context = context_id; - - // Start up query on this one - NET_API->SendRequest( context_id++, NETAPI_REQUEST_DETAILS, 0, 2.0, &p->remote_address, ::ServerResponse ); - - // Increment active list - m_nActiveQueries++; - - // Add to active list - p->next = m_pActiveList; - m_pActiveList = p; - - // Too many active? - if( m_nActiveQueries > MAX_QUERIES ) - break; - } -} - -/* -================== -ServerListSize - -# of servers in active query and in pending to be queried lists -================== -*/ -int CHudServers::ServerListSize( void ) -{ - int c = 0; - request_t *p; - - p = m_pServerList; - while( p ) - { - c++; - p = p->next; - } - - p = m_pActiveList; - while( p ) - { - c++; - p = p->next; - } - - return c; -} - -/* -=================== -FindRequest - -Look up a request by context id -=================== -*/ -CHudServers::request_t *CHudServers::FindRequest( int context, request_t *pList ) -{ - request_t *p; - p = pList; - while( p ) - { - if( context == p->context ) - return p; - - p = p->next; - } - return NULL; -} - -/* -=================== -RemoveServerFromList - -Remote, but don't delete, item from *ppList -=================== -*/ -void CHudServers::RemoveServerFromList( request_t **ppList, request_t *item ) -{ - request_t *p, *n; - request_t *newlist = NULL; - - if( !ppList ) - return; - - p = *ppList; - while( p ) - { - n = p->next; - if( p != item ) - { - p->next = newlist; - newlist = p; - } - p = n; - } - *ppList = newlist; -} - -/* -=================== -ClearRequestList - -=================== -*/ -void CHudServers::ClearRequestList( request_t **ppList ) -{ - request_t *p, *n; - - if( !ppList ) - return; - - p = *ppList; - while( p ) - { - n = p->next; - delete p; - p = n; - } - *ppList = NULL; -} - -/* -=================== -ClearServerList - -=================== -*/ -void CHudServers::ClearServerList( server_t **ppList ) -{ - server_t *p, *n; - - if( !ppList ) - return; - - p = *ppList; - while( p ) - { - n = p->next; - delete[] p->info; - delete p; - p = n; - } - *ppList = NULL; -} - -int CompareField( CHudServers::server_t *p1, CHudServers::server_t *p2, const char *fieldname, int iSortOrder ) -{ - const char *sz1, *sz2; - float fv1, fv2; - - sz1 = NET_API->ValueForKey( p1->info, fieldname ); - sz2 = NET_API->ValueForKey( p2->info, fieldname ); - - fv1 = atof( sz1 ); - fv2 = atof( sz2 ); - - if( fv1 && fv2 ) - { - if( fv1 > fv2 ) - return iSortOrder; - else if( fv1 < fv2 ) - return -iSortOrder; - else - return 0; - } - - // String compare - return stricmp( sz1, sz2 ); -} - -int CALLBACK ServerListCompareFunc( CHudServers::server_t *p1, CHudServers::server_t *p2, const char *fieldname ) -{ - if(!p1 || !p2) // No meaningful comparison - return 0; - - int iSortOrder = 1; - - int retval = 0; - - retval = CompareField( p1, p2, fieldname, iSortOrder ); - - return retval; -} - -static char g_fieldname[256]; -int __cdecl FnServerCompare( const void *elem1, const void *elem2 ) -{ - CHudServers::server_t *list1, *list2; - - list1 = *(CHudServers::server_t **)elem1; - list2 = *(CHudServers::server_t **)elem2; - - return ServerListCompareFunc( list1, list2, g_fieldname ); -} - -void CHudServers::SortServers( const char *fieldname ) -{ - server_t *p; - // Create a list - if( !m_pServers ) - return; - - strcpy( g_fieldname, fieldname ); - - int i; - int c = 0; - - p = m_pServers; - while( p ) - { - c++; - p = p->next; - } - - server_t **pSortArray; - - pSortArray = new server_t *[c]; - memset( pSortArray, 0, c * sizeof(server_t*) ); - - // Now copy the list into the pSortArray: - p = m_pServers; - i = 0; - while( p ) - { - pSortArray[i++] = p; - p = p->next; - } - - // Now do that actual sorting. - size_t nCount = c; - size_t nSize = sizeof(server_t*); - - qsort( - pSortArray, - (size_t)nCount, - (size_t)nSize, - FnServerCompare - ); - - // Now rebuild the list. - m_pServers = pSortArray[0]; - for( i = 0; i < c - 1; i++ ) - { - pSortArray[i]->next = pSortArray[i + 1]; - } - pSortArray[c - 1]->next = NULL; - - // Clean Up. - delete[] pSortArray; -} - -/* -=================== -GetServer - -Return particular server -=================== -*/ -CHudServers::server_t *CHudServers::GetServer( int server ) -{ - int c = 0; - server_t *p; - - p = m_pServers; - while( p ) - { - if( c == server ) - return p; - - c++; - p = p->next; - } - return NULL; -} - -/* -=================== -GetServerInfo - -Return info ( key/value ) string for particular server -=================== -*/ -char *CHudServers::GetServerInfo( int server ) -{ - server_t *p = GetServer( server ); - if( p ) - { - return p->info; - } - return NULL; -} - -/* -=================== -CancelRequest - -Kill all pending requests in engine -=================== -*/ -void CHudServers::CancelRequest( void ) -{ - m_nRequesting = 0; - m_nQuerying = 0; - m_nDone = 1; - - NET_API->CancelAllRequests(); -} - -/* -================== -LoadMasterAddresses - -Loads the master server addresses from file and into the passed in array -================== -*/ -int CHudServers::LoadMasterAddresses( int maxservers, int *count, netadr_t *padr ) -{ - int i; - char szMaster[256]; - char szMasterFile[256]; - char *pbuffer = NULL; - char *pstart = NULL ; - netadr_t adr; - char szAdr[64]; - int nPort; - int nCount = 0; - bool bIgnore; - int nDefaultPort; - - // Assume default master and master file - strcpy( szMaster, VALVE_MASTER_ADDRESS ); // IP:PORT string - strcpy( szMasterFile, MASTER_PARSE_FILE ); - - // See if there is a command line override - i = gEngfuncs.CheckParm( "-comm", &pstart ); - if( i && pstart ) - { - strcpy( szMasterFile, pstart ); - } - - // Read them in from proper file - pbuffer = (char *)gEngfuncs.COM_LoadFile( szMasterFile, 5, NULL ); // Use malloc - if( !pbuffer ) - { - goto finish_master; - } - - pstart = pbuffer; - - while( nCount < maxservers ) - { - pstart = gEngfuncs.COM_ParseFile( pstart, m_szToken ); - - if( strlen( m_szToken ) <= 0) - break; - - bIgnore = true; - - if( !stricmp( m_szToken, "Master" ) ) - { - nDefaultPort = PORT_MASTER; - bIgnore = FALSE; - } - - // Now parse all addresses between { } - pstart = gEngfuncs.COM_ParseFile( pstart, m_szToken ); - if( strlen( m_szToken ) <= 0 ) - break; - - if( stricmp( m_szToken, "{" ) ) - break; - - // Parse addresses until we get to "}" - while( nCount < maxservers ) - { - char base[256]; - - // Now parse all addresses between { } - pstart = gEngfuncs.COM_ParseFile( pstart, m_szToken ); - - if( strlen( m_szToken ) <= 0 ) - break; - - if( !stricmp ( m_szToken, "}" ) ) - break; - - sprintf( base, "%s", m_szToken ); - - pstart = gEngfuncs.COM_ParseFile( pstart, m_szToken ); - - if( strlen( m_szToken ) <= 0 ) - break; - - if( stricmp( m_szToken, ":" ) ) - break; - - pstart = gEngfuncs.COM_ParseFile( pstart, m_szToken ); - - if( strlen( m_szToken ) <= 0 ) - break; - - nPort = atoi( m_szToken ); - if( !nPort ) - nPort = nDefaultPort; - - sprintf( szAdr, "%s:%i", base, nPort ); - - // Can we resolve it any better - if( !NET_API->StringToAdr( szAdr, &adr ) ) - bIgnore = true; - - if( !bIgnore ) - { - padr[nCount++] = adr; - } - } - } -finish_master: - if( !nCount ) - { - sprintf( szMaster, VALVE_MASTER_ADDRESS ); // IP:PORT string - - // Convert to netadr_t - if( NET_API->StringToAdr( szMaster, &adr ) ) - { - padr[nCount++] = adr; - } - } - - *count = nCount; - - if( pbuffer ) - { - gEngfuncs.COM_FreeFile( pbuffer ); - } - - return ( nCount > 0 ) ? 1 : 0; -} - -/* -=================== -RequestList - -Request list of game servers from master -=================== -*/ -void CHudServers::RequestList( void ) -{ - m_nRequesting = 1; - m_nDone = 0; - m_dStarted = m_fElapsed; - - int count = 0; - netadr_t adr; - - if( !LoadMasterAddresses( 1, &count, &adr ) ) - { - gEngfuncs.Con_DPrintf( "SendRequest: Unable to read master server addresses\n" ); - return; - } - - ClearRequestList( &m_pActiveList ); - ClearRequestList( &m_pServerList ); - ClearServerList( &m_pServers ); - - m_nServerCount = 0; - - // Make sure networking system has started. - NET_API->InitNetworking(); - - // Kill off left overs if any - NET_API->CancelAllRequests(); - - // Request Server List from master - NET_API->SendRequest( context_id++, NETAPI_REQUEST_SERVERLIST, 0, 5.0, &adr, ::ListResponse ); -} - -void CHudServers::RequestBroadcastList( int clearpending ) -{ - m_nRequesting = 1; - m_nDone = 0; - m_dStarted = m_fElapsed; - - netadr_t adr = {0}; - - if( clearpending ) - { - ClearRequestList( &m_pActiveList ); - ClearRequestList( &m_pServerList ); - ClearServerList( &m_pServers ); - - m_nServerCount = 0; - } - - // Make sure to byte swap server if necessary ( using "host" to "net" conversion - adr.port = htons( PORT_SERVER ); - - // Make sure networking system has started. - NET_API->InitNetworking(); - - if( clearpending ) - { - // Kill off left overs if any - NET_API->CancelAllRequests(); - } - - adr.type = NA_BROADCAST; - - // Request Servers from LAN via IP - NET_API->SendRequest( context_id++, NETAPI_REQUEST_DETAILS, FNETAPI_MULTIPLE_RESPONSE, 5.0, &adr, ::ServerResponse ); - - adr.type = NA_BROADCAST_IPX; - - // Request Servers from LAN via IPX ( if supported ) - NET_API->SendRequest( context_id++, NETAPI_REQUEST_DETAILS, FNETAPI_MULTIPLE_RESPONSE, 5.0, &adr, ::ServerResponse ); -} - -void CHudServers::ServerPing( int server ) -{ - server_t *p; - - p = GetServer( server ); - if( !p ) - return; - - // Make sure networking system has started. - NET_API->InitNetworking(); - - // Request Server List from master - NET_API->SendRequest( context_id++, NETAPI_REQUEST_PING, 0, 5.0, &p->remote_address, ::PingResponse ); -} - -void CHudServers::ServerRules( int server ) -{ - server_t *p; - - p = GetServer( server ); - if( !p ) - return; - - // Make sure networking system has started. - NET_API->InitNetworking(); - - // Request Server List from master - NET_API->SendRequest( context_id++, NETAPI_REQUEST_RULES, 0, 5.0, &p->remote_address, ::RulesResponse ); -} - -void CHudServers::ServerPlayers( int server ) -{ - server_t *p; - - p = GetServer( server ); - if( !p ) - return; - - // Make sure networking system has started. - NET_API->InitNetworking(); - - // Request Server List from master - NET_API->SendRequest( context_id++, NETAPI_REQUEST_PLAYERS, 0, 5.0, &p->remote_address, ::PlayersResponse ); -} - -int CHudServers::isQuerying() -{ - return m_nRequesting ? 1 : 0; -} - -/* -=================== -GetServerCount - -Return number of servers in browser list -=================== -*/ -int CHudServers::GetServerCount( void ) -{ - return m_nServerCount; -} - -/* -=================== -CHudServers - -=================== -*/ -CHudServers::CHudServers( void ) -{ - m_nRequesting = 0; - m_dStarted = 0.0; - m_nDone = 0; - m_pServerList = NULL; - m_pServers = NULL; - m_pActiveList = NULL; - m_nQuerying = 0; - m_nActiveQueries = 0; - - m_fElapsed = 0.0; - - m_pPingRequest = NULL; - m_pRulesRequest = NULL; - m_pPlayersRequest = NULL; -} - -/* -=================== -~CHudServers - -=================== -*/ -CHudServers::~CHudServers( void ) -{ - ClearRequestList( &m_pActiveList ); - ClearRequestList( &m_pServerList ); - ClearServerList( &m_pServers ); - - m_nServerCount = 0; - - if( m_pPingRequest ) - { - delete m_pPingRequest; - m_pPingRequest = NULL; - } - - if( m_pRulesRequest ) - { - delete m_pRulesRequest; - m_pRulesRequest = NULL; - } - - if( m_pPlayersRequest ) - { - delete m_pPlayersRequest; - m_pPlayersRequest = NULL; - } -} - -/////////////////////////////// -// -// PUBLIC APIs -// -/////////////////////////////// - -/* -=================== -ServersGetCount - -=================== -*/ -int ServersGetCount( void ) -{ - if( g_pServers ) - { - return g_pServers->GetServerCount(); - } - return 0; -} - -int ServersIsQuerying( void ) -{ - if( g_pServers ) - { - return g_pServers->isQuerying(); - } - return 0; -} - -/* -=================== -ServersGetInfo - -=================== -*/ -const char *ServersGetInfo( int server ) -{ - if( g_pServers ) - { - return g_pServers->GetServerInfo( server ); - } - - return NULL; -} - -void SortServers( const char *fieldname ) -{ - if( g_pServers ) - { - g_pServers->SortServers( fieldname ); - } -} - -/* -=================== -ServersShutdown - -=================== -*/ -void ServersShutdown( void ) -{ - if( g_pServers ) - { - delete g_pServers; - g_pServers = NULL; - } -} - -/* -=================== -ServersInit - -=================== -*/ -void ServersInit( void ) -{ - // Kill any previous instance - ServersShutdown(); - - g_pServers = new CHudServers(); -} - -/* -=================== -ServersThink - -=================== -*/ -void ServersThink( double time ) -{ - if( g_pServers ) - { - g_pServers->Think( time ); - } -} - -/* -=================== -ServersCancel - -=================== -*/ -void ServersCancel( void ) -{ - if( g_pServers ) - { - g_pServers->CancelRequest(); - } -} - -// Requests -/* -=================== -ServersList - -=================== -*/ -void ServersList( void ) -{ - if( g_pServers ) - { - g_pServers->RequestList(); - } -} - -void BroadcastServersList( int clearpending ) -{ - if( g_pServers ) - { - g_pServers->RequestBroadcastList( clearpending ); - } -} - -void ServerPing( int server ) -{ - if( g_pServers ) - { - g_pServers->ServerPing( server ); - } -} - -void ServerRules( int server ) -{ - if( g_pServers ) - { - g_pServers->ServerRules( server ); - } -} - -void ServerPlayers( int server ) -{ - if( g_pServers ) - { - g_pServers->ServerPlayers( server ); - } -} diff --git a/cl_dll/hud_servers.h b/cl_dll/hud_servers.h deleted file mode 100644 index 5e886560..00000000 --- a/cl_dll/hud_servers.h +++ /dev/null @@ -1,40 +0,0 @@ -//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#if !defined( HUD_SERVERSH ) -#define HUD_SERVERSH -#pragma once - -#define NET_CALLBACK /* */ - -// Dispatchers -void NET_CALLBACK ListResponse( struct net_response_s *response ); -void NET_CALLBACK ServerResponse( struct net_response_s *response ); -void NET_CALLBACK PingResponse( struct net_response_s *response ); -void NET_CALLBACK RulesResponse( struct net_response_s *response ); -void NET_CALLBACK PlayersResponse( struct net_response_s *response ); - -void ServersInit( void ); -void ServersShutdown( void ); -void ServersThink( double time ); -void ServersCancel( void ); - -// Get list and get server info from each -void ServersList( void ); - -// Query for IP / IPX LAN servers -void BroadcastServersList( int clearpending ); - -void ServerPing( int server ); -void ServerRules( int server ); -void ServerPlayers( int server ); - -int ServersGetCount( void ); -const char *ServersGetInfo( int server ); -int ServersIsQuerying( void ); -void SortServers( const char *fieldname ); -#endif // HUD_SERVERSH diff --git a/cl_dll/hud_spectator.cpp b/cl_dll/hud_spectator.cpp index edb743ba..7e115f51 100644 --- a/cl_dll/hud_spectator.cpp +++ b/cl_dll/hud_spectator.cpp @@ -9,6 +9,10 @@ #include "cl_util.h" #include "cl_entity.h" #include "triangleapi.h" +#if USE_VGUI +#include "vgui_TeamFortressViewport.h" +#include "vgui_SpectatorPanel.h" +#endif #include "hltv.h" #include "pm_shared.h" @@ -69,15 +73,23 @@ void SpectatorSpray( void ) VectorScale( forward, 128, forward ); VectorAdd( forward, v_origin, forward ); pmtrace_t * trace = gEngfuncs.PM_TraceLine( v_origin, forward, PM_TRACELINE_PHYSENTSONLY, 2, -1 ); - if( trace->fraction != 1.0 ) + if( trace->fraction != 1.0f ) { sprintf( string, "drc_spray %.2f %.2f %.2f %i", - trace->endpos[0], trace->endpos[1], trace->endpos[2], trace->ent ); + (double)trace->endpos[0], (double)trace->endpos[1], (double)trace->endpos[2], trace->ent ); gEngfuncs.pfnServerCmd( string ); } } + void SpectatorHelp( void ) { +#if USE_VGUI + if( gViewPort ) + { + gViewPort->ShowVGUIMenu( MENU_SPECHELP ); + } + else +#endif { char *text = CHudTextMessage::BufferedLocaliseTextString( "#Spec_Help_Text" ); @@ -100,10 +112,33 @@ void SpectatorMenu( void ) gEngfuncs.Con_Printf( "usage: spec_menu <0|1>\n" ); return; } + +#if USE_VGUI + gViewPort->m_pSpectatorPanel->ShowMenu( atoi( gEngfuncs.Cmd_Argv( 1 ) ) != 0 ); +#endif } void ToggleScores( void ) { +#if USE_VGUI && !USE_NOVGUI_SCOREBOARD + if( gViewPort ) + { + if( gViewPort->IsScoreBoardVisible() ) + { + gViewPort->HideScoreBoard(); + } + else + { + gViewPort->ShowScoreBoard(); + } + } +#else + if (gHUD.m_Scoreboard.m_iShowscoresHeld) { + gHUD.m_Scoreboard.UserCmd_HideScores(); + } else { + gHUD.m_Scoreboard.UserCmd_ShowScores(); + } +#endif } //----------------------------------------------------------------------------- @@ -355,7 +390,7 @@ int CHudSpectator::Draw( float flTime ) int lx; char string[256]; - float * color; + float *color; // draw only in spectator mode if( !g_iUser1 ) @@ -392,8 +427,7 @@ int CHudSpectator::Draw( float flTime ) return 1; // make sure we have player info - //gViewPort->GetAllPlayersInfo(); - gHUD.m_Scoreboard.GetAllPlayersInfo(); + gHUD.GetAllPlayersInfo(); // loop through all the players and draw additional infos to their sprites on the map for( int i = 0; i < MAX_PLAYERS; i++ ) @@ -414,12 +448,12 @@ int CHudSpectator::Draw( float flTime ) color = GetClientColor( i + 1 ); // draw the players name and health underneath - sprintf( string, "%s", g_PlayerInfoList[i + 1].name ); + strcpy( string, g_PlayerInfoList[i + 1].name ); lx = strlen( string ) * 3; // 3 is avg. character length :) DrawSetTextColor( color[0], color[1], color[2] ); - DrawConsoleString( m_vPlayerPos[i][0] - lx,m_vPlayerPos[i][1], string ); + DrawConsoleString( m_vPlayerPos[i][0] - lx,m_vPlayerPos[i][1], string ); } return 1; @@ -503,7 +537,7 @@ void CHudSpectator::DirectorMessage( int iSize, void *pbuf ) msg->holdtime = READ_FLOAT(); // holdtime msg->fxtime = READ_FLOAT(); // fxtime; - strncpy( m_HUDMessageText[m_lastHudMessage], READ_STRING(), 128 ); + strncpy( m_HUDMessageText[m_lastHudMessage], READ_STRING(), 127 ); m_HUDMessageText[m_lastHudMessage][127] = 0; // text msg->pMessage = m_HUDMessageText[m_lastHudMessage]; @@ -529,14 +563,21 @@ void CHudSpectator::DirectorMessage( int iSize, void *pbuf ) READ_LONG(); // total number of spectator slots m_iSpectatorNumber = READ_LONG(); // total number of spectator READ_WORD(); // total number of relay proxies +#if USE_VGUI + gViewPort->UpdateSpectatorPanel(); +#endif break; case DRC_CMD_BANNER: // gEngfuncs.Con_DPrintf( "GUI: Banner %s\n",READ_STRING() ); // name of banner tga eg gfx/temp/7454562234563475.tga +#if USE_VGUI + gViewPort->m_pSpectatorPanel->m_TopBanner->LoadImage( READ_STRING() ); + gViewPort->UpdateSpectatorPanel(); +#endif break; case DRC_CMD_FADE: break; case DRC_CMD_STUFFTEXT: - ClientCmd( READ_STRING() ); + gEngfuncs.pfnFilteredClientCmd( READ_STRING() ); break; default: gEngfuncs.Con_DPrintf( "CHudSpectator::DirectorMessage: unknown command %i.\n", cmd ); @@ -573,8 +614,7 @@ void CHudSpectator::FindNextPlayer( bool bReverse ) int iDir = bReverse ? -1 : 1; // make sure we have player info - //gViewPort->GetAllPlayersInfo(); - gHUD.m_Scoreboard.GetAllPlayersInfo(); + gHUD.GetAllPlayersInfo(); do { @@ -611,6 +651,68 @@ void CHudSpectator::FindNextPlayer( bool bReverse ) VectorCopy( pEnt->angles, vJumpAngles ); } iJumpSpectator = 1; +#if USE_VGUI + gViewPort->MsgFunc_ResetFade( NULL, 0, NULL ); +#endif +} + +void CHudSpectator::FindPlayer(const char *name) +{ + // MOD AUTHORS: Modify the logic of this function if you want to restrict the observer to watching + // only a subset of the players. e.g. Make it check the target's team. + + // if we are NOT in HLTV mode, spectator targets are set on server + if ( !gEngfuncs.IsSpectateOnly() ) + { + char cmdstring[32]; + // forward command to server + sprintf(cmdstring,"follow %s",name); + gEngfuncs.pfnServerCmd(cmdstring); + return; + } + + g_iUser2 = 0; + + // make sure we have player info + gHUD.GetAllPlayersInfo(); + + cl_entity_t * pEnt = NULL; + + for (int i = 1; i < MAX_PLAYERS; i++ ) + { + + pEnt = gEngfuncs.GetEntityByIndex( i ); + + if ( !IsActivePlayer( pEnt ) ) + continue; + + if(!stricmp(g_PlayerInfoList[pEnt->index].name,name)) + { + g_iUser2 = i; + break; + } + + } + + // Did we find a target? + if ( !g_iUser2 ) + { + gEngfuncs.Con_DPrintf( "No observer targets.\n" ); + // take save camera position + VectorCopy(m_cameraOrigin, vJumpOrigin); + VectorCopy(m_cameraAngles, vJumpAngles); + } + else + { + // use new entity position for roaming + VectorCopy ( pEnt->origin, vJumpOrigin ); + VectorCopy ( pEnt->angles, vJumpAngles ); + } + + iJumpSpectator = 1; +#if USE_VGUI + gViewPort->MsgFunc_ResetFade( NULL, 0, NULL ); +#endif } void CHudSpectator::HandleButtonsDown( int ButtonPressed ) @@ -622,6 +724,11 @@ void CHudSpectator::HandleButtonsDown( int ButtonPressed ) // gEngfuncs.Con_Printf( " HandleButtons:%i\n", ButtonPressed ); +#if USE_VGUI + if( !gViewPort ) + return; +#endif + //Not in intermission. if( gHUD.m_iIntermission ) return; @@ -637,8 +744,10 @@ void CHudSpectator::HandleButtonsDown( int ButtonPressed ) return; // enable spectator screen - //if( ButtonPressed & IN_DUCK ) - // gViewPort->m_pSpectatorPanel->ShowMenu( !gViewPort->m_pSpectatorPanel->m_menuVisible ); +#if USE_VGUI + if( ButtonPressed & IN_DUCK ) + gViewPort->m_pSpectatorPanel->ShowMenu( !gViewPort->m_pSpectatorPanel->m_menuVisible ); +#endif // 'Use' changes inset window mode if( ButtonPressed & IN_USE ) @@ -705,6 +814,14 @@ void CHudSpectator::HandleButtonsDown( int ButtonPressed ) void CHudSpectator::HandleButtonsUp( int ButtonPressed ) { +#if USE_VGUI + if( !gViewPort ) + return; + + if( !gViewPort->m_pSpectatorPanel->isVisible() ) + return; // dont do anything if not in spectator mode +#endif + if( ButtonPressed & ( IN_FORWARD | IN_BACK ) ) m_zoomDelta = 0.0f; @@ -800,12 +917,19 @@ void CHudSpectator::SetModes( int iNewMainMode, int iNewInsetMode ) SetCrosshair( 0, m_crosshairRect, 0, 0, 0 ); } +#if USE_VGUI + gViewPort->MsgFunc_ResetFade( NULL, 0, NULL ); +#endif + char string[128]; sprintf( string, "#Spec_Mode%d", g_iUser1 ); sprintf( string, "%c%s", HUD_PRINTCENTER, CHudTextMessage::BufferedLocaliseTextString( string ) ); gHUD.m_TextMessage.MsgFunc_TextMsg( NULL, strlen( string ) + 1, string ); } +#if USE_VGUI + gViewPort->UpdateSpectatorPanel(); +#endif } bool CHudSpectator::IsActivePlayer( cl_entity_t *ent ) @@ -820,12 +944,13 @@ bool CHudSpectator::IsActivePlayer( cl_entity_t *ent ) bool CHudSpectator::ParseOverviewFile() { - char filename[255] = { 0 }; - char levelname[255] = { 0 }; + char filename[512] = { 0 }; + char levelname[256] = { 0 }; char token[1024] = { 0 }; float height; + bool ret = false; - char *pfile = NULL; + char *afile = NULL, *pfile = NULL; memset( &m_OverviewData, 0, sizeof(m_OverviewData) ); @@ -842,20 +967,20 @@ bool CHudSpectator::ParseOverviewFile() m_OverviewData.layersHeights[0] = 0.0f; strcpy( m_OverviewData.map, gEngfuncs.pfnGetLevelName() ); - if( strlen( m_OverviewData.map ) == 0 ) - return false; // not active yet + if( m_OverviewData.map[0] == '\0' ) + return ret; // not active yet strcpy( levelname, m_OverviewData.map + 5 ); levelname[strlen( levelname ) - 4] = 0; sprintf( filename, "overviews/%s.txt", levelname ); - pfile = (char *)gEngfuncs.COM_LoadFile( filename, 5, NULL ); + afile = pfile = (char *)gEngfuncs.COM_LoadFile( filename, 5, NULL ); if( !pfile ) { gEngfuncs.Con_DPrintf( "Couldn't open file %s. Using default values for overiew mode.\n", filename ); - return false; + return ret; } while( true ) @@ -872,7 +997,7 @@ bool CHudSpectator::ParseOverviewFile() if( stricmp( token, "{" ) ) { gEngfuncs.Con_Printf( "Error parsing overview file %s. (expected { )\n", filename ); - return false; + goto end; } pfile = gEngfuncs.COM_ParseFile( pfile, token ); @@ -912,7 +1037,7 @@ bool CHudSpectator::ParseOverviewFile() else { gEngfuncs.Con_Printf( "Error parsing overview file %s. (%s unkown)\n", filename, token ); - return false; + goto end; } pfile = gEngfuncs.COM_ParseFile( pfile, token ); // parse next token @@ -924,7 +1049,7 @@ bool CHudSpectator::ParseOverviewFile() if( m_OverviewData.layers == OVERVIEW_MAX_LAYERS ) { gEngfuncs.Con_Printf( "Error parsing overview file %s. ( too many layers )\n", filename ); - return false; + goto end; } pfile = gEngfuncs.COM_ParseFile( pfile, token ); @@ -932,7 +1057,7 @@ bool CHudSpectator::ParseOverviewFile() if( stricmp( token, "{" ) ) { gEngfuncs.Con_Printf( "Error parsing overview file %s. (expected { )\n", filename ); - return false; + goto end; } pfile = gEngfuncs.COM_ParseFile( pfile, token ); @@ -953,7 +1078,7 @@ bool CHudSpectator::ParseOverviewFile() else { gEngfuncs.Con_Printf( "Error parsing overview file %s. (%s unkown)\n", filename, token ); - return false; + goto end; } pfile = gEngfuncs.COM_ParseFile( pfile, token ); // parse next token @@ -963,12 +1088,14 @@ bool CHudSpectator::ParseOverviewFile() } } - gEngfuncs.COM_FreeFile( pfile ); - m_mapZoom = m_OverviewData.zoom; m_mapOrigin = m_OverviewData.origin; - return true; + ret = true; +end: + gEngfuncs.COM_FreeFile( afile ); + + return ret; } void CHudSpectator::LoadMapSprites() @@ -987,15 +1114,15 @@ void CHudSpectator::DrawOverviewLayer() float screenaspect, xs, ys, xStep, yStep, x, y, z; int ix, iy, i, xTiles, yTiles, frame; - qboolean hasMapImage = m_MapSprite?TRUE:FALSE; - model_t * dummySprite = (struct model_s *)gEngfuncs.GetSpritePointer( m_hsprUnkownMap); + qboolean hasMapImage = m_MapSprite ? TRUE : FALSE; + model_t *dummySprite = (struct model_s *)gEngfuncs.GetSpritePointer( m_hsprUnkownMap ); - if ( hasMapImage) + if( hasMapImage ) { - i = m_MapSprite->numframes / (4*3); - i = sqrt(float(i)); - xTiles = i*4; - yTiles = i*3; + i = m_MapSprite->numframes / ( 4 * 3 ); + i = sqrt( float( i ) ); + xTiles = i * 4; + yTiles = i * 3; } else { @@ -1014,7 +1141,7 @@ void CHudSpectator::DrawOverviewLayer() gEngfuncs.pTriAPI->RenderMode( kRenderTransTexture ); gEngfuncs.pTriAPI->CullFace( TRI_NONE ); - gEngfuncs.pTriAPI->Color4f( 1.0, 1.0, 1.0, 1.0 ); + gEngfuncs.pTriAPI->Color4f( 1.0f, 1.0f, 1.0f, 1.0f ); frame = 0; @@ -1143,7 +1270,7 @@ void CHudSpectator::DrawOverviewEntities() gEngfuncs.pTriAPI->Begin( TRI_QUADS ); - gEngfuncs.pTriAPI->Color4f( 1.0, 1.0, 1.0, 1.0 ); + gEngfuncs.pTriAPI->Color4f( 1.0f, 1.0f, 1.0f, 1.0f ); gEngfuncs.pTriAPI->TexCoord2f(1, 0); VectorMA( origin, 16.0f * sizeScale, up, point ); @@ -1183,28 +1310,28 @@ void CHudSpectator::DrawOverviewEntities() hSpriteModel = (struct model_s *)gEngfuncs.GetSpritePointer( m_hsprBeam ); gEngfuncs.pTriAPI->SpriteTexture( hSpriteModel, 0 ); - gEngfuncs.pTriAPI->Color4f( r, g, b, 0.3 ); + gEngfuncs.pTriAPI->Color4f( r, g, b, 0.3f ); gEngfuncs.pTriAPI->Begin( TRI_QUADS ); - gEngfuncs.pTriAPI->TexCoord2f( 1, 0 ); - gEngfuncs.pTriAPI->Vertex3f( origin[0] + 4, origin[1] + 4, origin[2] - zScale ); - gEngfuncs.pTriAPI->TexCoord2f( 0, 0 ); - gEngfuncs.pTriAPI->Vertex3f( origin[0] - 4, origin[1] - 4, origin[2] - zScale ); - gEngfuncs.pTriAPI->TexCoord2f( 0, 1 ); - gEngfuncs.pTriAPI->Vertex3f( origin[0] - 4, origin[1] - 4, z ); - gEngfuncs.pTriAPI->TexCoord2f( 1, 1 ); - gEngfuncs.pTriAPI->Vertex3f( origin[0] + 4, origin[1] + 4, z ); + gEngfuncs.pTriAPI->TexCoord2f( 1.0f, 0.0f ); + gEngfuncs.pTriAPI->Vertex3f( origin[0] + 4.0f, origin[1] + 4.0f, origin[2] - zScale ); + gEngfuncs.pTriAPI->TexCoord2f( 0.0f, 0.0f ); + gEngfuncs.pTriAPI->Vertex3f( origin[0] - 4.0f, origin[1] - 4.0f, origin[2] - zScale ); + gEngfuncs.pTriAPI->TexCoord2f( 0.0f, 1.0f ); + gEngfuncs.pTriAPI->Vertex3f( origin[0] - 4.0f, origin[1] - 4.0f, z ); + gEngfuncs.pTriAPI->TexCoord2f( 1.0f, 1.0f ); + gEngfuncs.pTriAPI->Vertex3f( origin[0] + 4.0f, origin[1] + 4.0f, z ); gEngfuncs.pTriAPI->End(); gEngfuncs.pTriAPI->Begin( TRI_QUADS ); - gEngfuncs.pTriAPI->TexCoord2f( 1, 0 ); - gEngfuncs.pTriAPI->Vertex3f( origin[0] - 4, origin[1] + 4, origin[2] - zScale ); - gEngfuncs.pTriAPI->TexCoord2f( 0, 0 ); - gEngfuncs.pTriAPI->Vertex3f( origin[0] + 4, origin[1] - 4, origin[2] - zScale ); - gEngfuncs.pTriAPI->TexCoord2f( 0, 1 ); - gEngfuncs.pTriAPI->Vertex3f( origin[0] + 4, origin[1] - 4, z ); - gEngfuncs.pTriAPI->TexCoord2f( 1, 1 ); - gEngfuncs.pTriAPI->Vertex3f( origin[0] - 4, origin[1] + 4, z ); + gEngfuncs.pTriAPI->TexCoord2f( 1.0f, 0.0f ); + gEngfuncs.pTriAPI->Vertex3f( origin[0] - 4.0f, origin[1] + 4.0f, origin[2] - zScale ); + gEngfuncs.pTriAPI->TexCoord2f( 0.0f, 0.0f ); + gEngfuncs.pTriAPI->Vertex3f( origin[0] + 4.0f, origin[1] - 4.0f, origin[2] - zScale ); + gEngfuncs.pTriAPI->TexCoord2f( 0.0f, 1.0f ); + gEngfuncs.pTriAPI->Vertex3f( origin[0] + 4.0f, origin[1] - 4.0f, z ); + gEngfuncs.pTriAPI->TexCoord2f( 1.0f, 1.0f ); + gEngfuncs.pTriAPI->Vertex3f( origin[0] - 4.0f, origin[1] + 4.0f, z ); gEngfuncs.pTriAPI->End(); // calculate screen position for name and infromation in hud::draw() @@ -1265,7 +1392,7 @@ void CHudSpectator::DrawOverviewEntities() gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd ); gEngfuncs.pTriAPI->SpriteTexture( hSpriteModel, 0 ); - gEngfuncs.pTriAPI->Color4f( r, g, b, 1.0 ); + gEngfuncs.pTriAPI->Color4f( r, g, b, 1.0f ); AngleVectors( angles, forward, NULL, NULL ); VectorScale( forward, 512.0f, forward ); @@ -1282,13 +1409,13 @@ void CHudSpectator::DrawOverviewEntities() VectorTransform( forward, rmatrix , left ); gEngfuncs.pTriAPI->Begin( TRI_TRIANGLES ); - gEngfuncs.pTriAPI->TexCoord2f( 0, 0 ); + gEngfuncs.pTriAPI->TexCoord2f( 0.0f, 0.0f ); gEngfuncs.pTriAPI->Vertex3f( x + right[0], y + right[1], ( z + right[2] ) * zScale); - gEngfuncs.pTriAPI->TexCoord2f( 0, 1 ); + gEngfuncs.pTriAPI->TexCoord2f( 0.0f, 1.0f ); gEngfuncs.pTriAPI->Vertex3f( x, y, z * zScale ); - gEngfuncs.pTriAPI->TexCoord2f( 1, 1 ); + gEngfuncs.pTriAPI->TexCoord2f( 1.0f, 1.0f ); gEngfuncs.pTriAPI->Vertex3f( x + left[0], y + left[1], ( z + left[2] ) * zScale ); gEngfuncs.pTriAPI->End (); } @@ -1329,7 +1456,7 @@ void CHudSpectator::CheckOverviewEntities() bool CHudSpectator::AddOverviewEntity( int type, struct cl_entity_s *ent, const char *modelname) { HSPRITE hSprite = 0; - double duration = -1.0f; // duration -1 means show it only this frame; + double duration = -1.0; // duration -1 means show it only this frame; if( !ent ) return false; @@ -1451,6 +1578,9 @@ void CHudSpectator::CheckSettings() m_pip->value = INSET_OFF; // draw small border around inset view, adjust upper black bar +#if USE_VGUI + gViewPort->m_pSpectatorPanel->EnableInsetView( m_pip->value != INSET_OFF ); +#endif } int CHudSpectator::ToggleInset( bool allowOff ) diff --git a/cl_dll/hud_spectator.h b/cl_dll/hud_spectator.h index 9b3391e2..800928e0 100644 --- a/cl_dll/hud_spectator.h +++ b/cl_dll/hud_spectator.h @@ -6,7 +6,7 @@ //============================================================================= #pragma once -#ifndef HUD_SPECTATOR_H +#if !defined(HUD_SPECTATOR_H) #define HUD_SPECTATOR_H #include "cl_entity.h" @@ -73,6 +73,7 @@ public: void HandleButtonsDown( int ButtonPressed ); void HandleButtonsUp( int ButtonPressed ); void FindNextPlayer( bool bReverse ); + void FindPlayer(const char *name); void DirectorMessage( int iSize, void *pbuf ); void SetSpectatorStartPosition(); int Init(); diff --git a/cl_dll/hud_update.cpp b/cl_dll/hud_update.cpp index cecbb625..8c807d1c 100644 --- a/cl_dll/hud_update.cpp +++ b/cl_dll/hud_update.cpp @@ -16,11 +16,10 @@ // hud_update.cpp // -#include +#include #include "hud.h" #include "cl_util.h" #include -#include int CL_ButtonBits( int ); void CL_ResetButtonBits( int bits ); diff --git a/cl_dll/in_camera.cpp b/cl_dll/in_camera.cpp index 12ad41f4..7a81a15f 100644 --- a/cl_dll/in_camera.cpp +++ b/cl_dll/in_camera.cpp @@ -15,6 +15,22 @@ #include "camera.h" #include "in_defs.h" +#if _WIN32 +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#define WIN32_EXTRA_LEAN +#define HSPRITE WINDOWS_HSPRITE +#include +#undef HSPRITE +#else +typedef struct point_s +{ + int x; + int y; +} POINT; +#define GetCursorPos(x) +#define SetCursorPos(x,y) +#endif + float CL_KeyState( kbutton_t *key ); extern "C" @@ -28,16 +44,16 @@ extern cl_enginefunc_t gEngfuncs; //-------------------------------------------------- Constants -#define CAM_DIST_DELTA 1.0 -#define CAM_ANGLE_DELTA 2.5 -#define CAM_ANGLE_SPEED 2.5 -#define CAM_MIN_DIST 30.0 -#define CAM_ANGLE_MOVE .5 -#define MAX_ANGLE_DIFF 10.0 -#define PITCH_MAX 90.0 -#define PITCH_MIN 0 -#define YAW_MAX 135.0 -#define YAW_MIN -135.0 +#define CAM_DIST_DELTA 1.0f +#define CAM_ANGLE_DELTA 2.5f +#define CAM_ANGLE_SPEED 2.5f +#define CAM_MIN_DIST 30.0f +#define CAM_ANGLE_MOVE 0.5f +#define MAX_ANGLE_DIFF 10.0f +#define PITCH_MAX 90.0f +#define PITCH_MIN 0.0f +#define YAW_MAX 135.0f +#define YAW_MIN -135.0f enum ECAM_Command { @@ -91,35 +107,35 @@ float MoveToward( float cur, float goal, float maxspeed ) { if( cur != goal ) { - if( fabs( cur - goal ) > 180.0 ) + if( fabs( cur - goal ) > 180.0f ) { if( cur < goal ) - cur += 360.0; + cur += 360.0f; else - cur -= 360.0; + cur -= 360.0f; } if( cur < goal ) { - if( cur < goal - 1.0 ) - cur += ( goal - cur ) / 4.0; + if( cur < goal - 1.0f ) + cur += ( goal - cur ) * 0.25f; else cur = goal; } else { - if( cur > goal + 1.0 ) - cur -= ( cur - goal ) / 4.0; + if( cur > goal + 1.0f ) + cur -= ( cur - goal ) * 0.25f; else cur = goal; } } // bring cur back into range - if( cur < 0 ) - cur += 360.0; - else if( cur >= 360 ) - cur -= 360; + if( cur < 0.0f ) + cur += 360.0f; + else if( cur >= 360.0f ) + cur -= 360.0f; return cur; } @@ -148,11 +164,14 @@ void DLLEXPORT CAM_Think( void ) float dist; vec3_t camAngles; float flSensitivity; -#ifdef LATER +#if LATER int i; #endif vec3_t viewangles; + if( gEngfuncs.GetMaxClients() > 1 && CL_IsThirdPerson() ) + CAM_ToFirstPerson(); + switch( (int)cam_command->value ) { case CAM_COMMAND_TOTHIRDPERSON: @@ -168,11 +187,11 @@ void DLLEXPORT CAM_Think( void ) if( !cam_thirdperson ) return; -#ifdef LATER +#if LATER if( cam_contain->value ) { gEngfuncs.GetClientOrigin( origin ); - ext[0] = ext[1] = ext[2] = 0.0; + ext[0] = ext[1] = ext[2] = 0.0f; } #endif camAngles[PITCH] = cam_idealpitch->value; @@ -195,7 +214,7 @@ void DLLEXPORT CAM_Think( void ) //keep the camera within certain limits around the player (ie avoid certain bad viewing angles) if( cam_mouse.x>gEngfuncs.GetWindowCenterX() ) { - //if( ( camAngles[YAW] >= 225.0 ) || ( camAngles[YAW] < 135.0 ) ) + //if( ( camAngles[YAW] >= 225.0f ) || ( camAngles[YAW] < 135.0f ) ) if( camAngles[YAW] < c_maxyaw->value ) { camAngles[YAW] += CAM_ANGLE_MOVE * ( ( cam_mouse.x - gEngfuncs.GetWindowCenterX() ) / 2 ); @@ -207,7 +226,7 @@ void DLLEXPORT CAM_Think( void ) } else if( cam_mouse.x 225.0 ) ) + //if( ( camAngles[YAW] <= 135.0f ) || ( camAngles[YAW] > 225.0f ) ) if( camAngles[YAW] > c_minyaw->value ) { camAngles[YAW] -= CAM_ANGLE_MOVE * ( ( gEngfuncs.GetWindowCenterX() - cam_mouse.x ) / 2 ); @@ -315,7 +334,7 @@ void DLLEXPORT CAM_Think( void ) cam_old_mouse_y = cam_mouse.y * gHUD.GetSensitivity(); SetCursorPos( gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY() ); } -#ifdef LATER +#if LATER if( cam_contain->value ) { // check new ideal @@ -363,12 +382,12 @@ void DLLEXPORT CAM_Think( void ) if( camAngles[PITCH] - viewangles[PITCH] != cam_idealpitch->value ) camAngles[PITCH] = MoveToward( camAngles[PITCH], cam_idealpitch->value + viewangles[PITCH], CAM_ANGLE_SPEED ); - if( fabs( camAngles[2] - cam_idealdist->value ) < 2.0 ) + if( fabs( camAngles[2] - cam_idealdist->value ) < 2.0f ) camAngles[2] = cam_idealdist->value; else - camAngles[2] += ( cam_idealdist->value - camAngles[2] ) / 4.0; + camAngles[2] += ( cam_idealdist->value - camAngles[2] ) * 0.25f; } -#ifdef LATER +#if LATER if( cam_contain->value ) { // Test new position @@ -382,9 +401,9 @@ void DLLEXPORT CAM_Think( void ) // check line from r_refdef.vieworg to pnt memset( &clip, 0, sizeof(moveclip_t) ); - ext[0] = ext[1] = ext[2] = 0.0; + ext[0] = ext[1] = ext[2] = 0.0f; clip.trace = SV_ClipMoveToEntity( sv.edicts, r_refdef.vieworg, ext, ext, pnt ); - if( clip.trace.fraction != 1.0 ) + if( clip.trace.fraction != 1.0f ) return; } #endif @@ -459,7 +478,7 @@ void CAM_OutUp( void ) void CAM_ToThirdPerson( void ) { vec3_t viewangles; -#if !defined( _DEBUG ) +#if !_DEBUG if( gEngfuncs.GetMaxClients() > 1 ) { // no thirdperson in multiplayer. @@ -516,9 +535,9 @@ void CAM_Init( void ) cam_command = gEngfuncs.pfnRegisterVariable( "cam_command", "0", 0 ); // tells camera to go to thirdperson cam_snapto = gEngfuncs.pfnRegisterVariable( "cam_snapto", "0", 0 ); // snap to thirdperson view - cam_idealyaw = gEngfuncs.pfnRegisterVariable( "cam_idealyaw", "90", 0 ); // thirdperson yaw + cam_idealyaw = gEngfuncs.pfnRegisterVariable( "cam_idealyaw", "0", 0 ); // thirdperson yaw cam_idealpitch = gEngfuncs.pfnRegisterVariable( "cam_idealpitch", "0", 0 ); // thirperson pitch - cam_idealdist = gEngfuncs.pfnRegisterVariable( "cam_idealdist", "64", 0 ); // thirdperson distance + cam_idealdist = gEngfuncs.pfnRegisterVariable( "cam_idealdist", "128", 0 ); // thirdperson distance cam_contain = gEngfuncs.pfnRegisterVariable( "cam_contain", "0", 0 ); // contain camera to world c_maxpitch = gEngfuncs.pfnRegisterVariable( "c_maxpitch", "90.0", 0 ); diff --git a/cl_dll/in_defs.h b/cl_dll/in_defs.h index b4c51730..0b6cca8b 100644 --- a/cl_dll/in_defs.h +++ b/cl_dll/in_defs.h @@ -16,17 +16,4 @@ // fall over #define ROLL 2 -#ifdef _WIN32 -#define HSPRITE HSPRITE_win32 -#include -#undef HSPRITE -#else -typedef struct point_s -{ - int x; - int y; -} POINT; -#define GetCursorPos(x) -#define SetCursorPos(x,y) -#endif #endif diff --git a/cl_dll/input.cpp b/cl_dll/input.cpp index 0abd542b..d11abf56 100644 --- a/cl_dll/input.cpp +++ b/cl_dll/input.cpp @@ -28,6 +28,10 @@ extern "C" #include #include +#if USE_VGUI +#include "vgui_TeamFortressViewport.h" +#endif + extern "C" { struct kbutton_s DLLEXPORT *KB_Find( const char *name ); @@ -169,7 +173,7 @@ int KB_ConvertString( char *in, char **ppout ) *pEnd = '\0'; pBinding = NULL; - if( strlen( binding + 1 ) > 0 ) + if( binding[1] != '\0' ) { // See if there is a binding for binding? pBinding = gEngfuncs.Key_LookupBinding( binding + 1 ); @@ -376,7 +380,11 @@ Return 1 to allow engine to process the key, otherwise, act on it as needed ============ */ int DLLEXPORT HUD_Key_Event( int down, int keynum, const char *pszCurrentBinding ) -{ +{ +#if USE_VGUI + if (gViewPort) + return gViewPort->KeyInput(down, keynum, pszCurrentBinding); +#endif return 1; } @@ -645,11 +653,27 @@ void IN_Impulse( void ) void IN_ScoreDown( void ) { KeyDown( &in_score ); +#if USE_VGUI && !USE_NOVGUI_SCOREBOARD + if ( gViewPort ) + { + gViewPort->ShowScoreBoard(); + } +#else + gHUD.m_Scoreboard.UserCmd_ShowScores(); +#endif } void IN_ScoreUp( void ) { KeyUp( &in_score ); +#if USE_VGUI && !USE_NOVGUI_SCOREBOARD + if ( gViewPort ) + { + gViewPort->HideScoreBoard(); + } +#else + gHUD.m_Scoreboard.UserCmd_HideScores(); +#endif } void IN_MLookUp( void ) @@ -819,7 +843,7 @@ void DLLEXPORT CL_CreateMove( float frametime, struct usercmd_s *cmd, int active // clip to maxspeed spd = gEngfuncs.GetClientMaxspeed(); - if( spd != 0.0 ) + if( spd != 0.0f ) { // scale the 3 speeds so that the total velocity is not > cl.maxspeed float fmov = sqrt( ( cmd->forwardmove * cmd->forwardmove ) + ( cmd->sidemove * cmd->sidemove ) + ( cmd->upmove * cmd->upmove ) ); @@ -847,6 +871,12 @@ void DLLEXPORT CL_CreateMove( float frametime, struct usercmd_s *cmd, int active // cmd->buttons = CL_ButtonBits( 1 ); +#if USE_VGUI + // If they're in a modal dialog, ignore the attack button. + if(GetClientVoiceMgr()->IsInSquelchMode()) + cmd->buttons &= ~IN_ATTACK; +#endif + // Using joystick? if( in_joystick->value ) { @@ -901,9 +931,11 @@ int CL_ButtonBits( int bResetState ) if( in_attack.state & 3 ) { +#if !USE_VGUI || USE_NOVGUI_MOTD if( gHUD.m_MOTD.m_bShow ) gHUD.m_MOTD.Reset(); else +#endif bits |= IN_ATTACK; } @@ -1082,6 +1114,10 @@ void InitInput( void ) gEngfuncs.pfnAddCommand( "-reload", IN_ReloadUp ); gEngfuncs.pfnAddCommand( "+alt1", IN_Alt1Down ); gEngfuncs.pfnAddCommand( "-alt1", IN_Alt1Up ); + gEngfuncs.pfnAddCommand( "+score", IN_ScoreDown ); + gEngfuncs.pfnAddCommand( "-score", IN_ScoreUp ); + gEngfuncs.pfnAddCommand( "+showscores", IN_ScoreDown ); + gEngfuncs.pfnAddCommand( "-showscores", IN_ScoreUp ); gEngfuncs.pfnAddCommand( "+graph", IN_GraphDown ); gEngfuncs.pfnAddCommand( "-graph", IN_GraphUp ); gEngfuncs.pfnAddCommand( "+break", IN_BreakDown ); diff --git a/cl_dll/input_goldsource.cpp b/cl_dll/input_goldsource.cpp index be85ee3a..89408423 100644 --- a/cl_dll/input_goldsource.cpp +++ b/cl_dll/input_goldsource.cpp @@ -10,7 +10,7 @@ #include "input_mouse.h" -#ifdef SUPPORT_GOLDSOURCE_INPUT +#if SUPPORT_GOLDSOURCE_INPUT #include "hud.h" #include "cl_util.h" @@ -23,11 +23,11 @@ #include "keydefs.h" #include "view.h" -#ifndef _WIN32 -#define USE_SDL2 +#if !_WIN32 +#define USE_SDL2 1 #endif -#ifdef USE_SDL2 +#if USE_SDL2 #define ARRAYSIZE(p) ( sizeof(p) /sizeof(p[0]) ) #include #include @@ -114,7 +114,7 @@ static SDLFunction sdlFunctions[] = { }; #endif -#ifdef _WIN32 +#if _WIN32 #include #else typedef unsigned int DWORD; @@ -149,16 +149,16 @@ extern cvar_t *cl_forwardspeed; extern cvar_t *cl_pitchspeed; extern cvar_t *cl_movespeedkey; -#ifdef _WIN32 +#if _WIN32 +static cvar_t* m_rawinput = NULL; static double s_flRawInputUpdateTime = 0.0f; static bool m_bRawInput = false; static bool m_bMouseThread = false; bool isMouseRelative = false; #endif -#ifdef _WIN32 +#if _WIN32 #include "progdefs.h" -extern globalvars_t *gpGlobals; #endif int CL_IsDead( void ); @@ -184,7 +184,7 @@ static cvar_t *m_customaccel_max; //Mouse move is raised to this power before being scaled by scale factor static cvar_t *m_customaccel_exponent; -#ifdef _WIN32 +#if _WIN32 // if threaded mouse is enabled then the time to sleep between polls static cvar_t *m_mousethread_sleep; #endif @@ -218,7 +218,7 @@ enum _ControlList AxisTurn }; -#if !defined(USE_SDL2) && defined(_WIN32) +#if !USE_SDL2 && _WIN32 DWORD dwAxisFlags[JOY_MAX_AXES] = { JOY_RETURNX, @@ -232,9 +232,9 @@ DWORD dwAxisFlags[JOY_MAX_AXES] = DWORD dwAxisMap[ JOY_MAX_AXES ]; DWORD dwControlMap[ JOY_MAX_AXES ]; -#if defined(USE_SDL2) +#if USE_SDL2 int pdwRawValue[ JOY_MAX_AXES ]; -#elif defined(_WIN32) +#elif _WIN32 PDWORD pdwRawValue[ JOY_MAX_AXES ]; #endif DWORD joy_oldbuttonstate, joy_oldpovstate; @@ -242,9 +242,9 @@ DWORD joy_oldbuttonstate, joy_oldpovstate; int joy_id; DWORD joy_numbuttons; -#ifdef USE_SDL2 +#if USE_SDL2 SDL_GameController *s_pJoystick = NULL; -#elif defined(_WIN32) +#elif _WIN32 DWORD joy_flags; static JOYINFOEX ji; #endif @@ -276,7 +276,7 @@ cvar_t *joy_wwhack2; int joy_avail, joy_advancedinit, joy_haspov; -#ifdef _WIN32 +#if _WIN32 unsigned int s_hMouseThreadId = 0; HANDLE s_hMouseThread = 0; HANDLE s_hMouseQuitEvent = 0; @@ -300,7 +300,7 @@ void Force_CenterView_f (void) } } -#ifdef _WIN32 +#if _WIN32 LONG mouseThreadActive = 0; LONG mouseThreadCenterX = 0; @@ -382,14 +382,14 @@ void IN_SetMouseMode(bool enable) if(enable) { -#ifdef _WIN32 +#if _WIN32 if (mouseparmsvalid) restore_spi = SystemParametersInfo (SPI_SETMOUSE, 0, newmouseparms, 0); - m_bRawInput = CVAR_GET_FLOAT( "m_rawinput" ) != 0; + m_bRawInput = m_rawinput && m_rawinput->value != 0; if(m_bRawInput) { -#ifdef USE_SDL2 +#if USE_SDL2 safe_pfnSDL_SetRelativeMouseMode(SDL_TRUE); #endif isMouseRelative = true; @@ -402,10 +402,10 @@ void IN_SetMouseMode(bool enable) } else { -#ifdef _WIN32 +#if _WIN32 if(isMouseRelative) { -#ifdef USE_SDL2 +#if USE_SDL2 safe_pfnSDL_SetRelativeMouseMode(SDL_FALSE); #endif isMouseRelative = false; @@ -423,7 +423,7 @@ void IN_SetMouseMode(bool enable) void IN_SetVisibleMouse(bool visible) { -#ifdef _WIN32 +#if _WIN32 bool lockEntered = MouseThread_ActiveLock_Enter(); #endif @@ -431,7 +431,7 @@ void IN_SetVisibleMouse(bool visible) IN_SetMouseMode(!visible); -#ifdef _WIN32 +#if _WIN32 UpdateMouseThreadActive(); if(lockEntered) MouseThread_ActiveLock_Exit(); #endif @@ -448,7 +448,7 @@ void GoldSourceInput::IN_ActivateMouse (void) { if (mouseinitialized) { -#ifdef _WIN32 +#if _WIN32 bool lockEntered = MouseThread_ActiveLock_Enter(); #endif @@ -456,7 +456,7 @@ void GoldSourceInput::IN_ActivateMouse (void) mouseactive = 1; -#ifdef _WIN32 +#if _WIN32 UpdateMouseThreadActive(); if(lockEntered) MouseThread_ActiveLock_Exit(); #endif @@ -476,7 +476,7 @@ void GoldSourceInput::IN_DeactivateMouse (void) { if (mouseinitialized) { -#ifdef _WIN32 +#if _WIN32 bool lockEntered = MouseThread_ActiveLock_Enter(); #endif @@ -484,7 +484,7 @@ void GoldSourceInput::IN_DeactivateMouse (void) mouseactive = 0; -#ifdef _WIN32 +#if _WIN32 UpdateMouseThreadActive(); if(lockEntered) MouseThread_ActiveLock_Exit(); #endif @@ -502,7 +502,7 @@ void GoldSourceInput::IN_StartupMouse (void) return; mouseinitialized = 1; -#ifdef _WIN32 +#if _WIN32 mouseparmsvalid = SystemParametersInfo (SPI_GETMOUSE, 0, originalmouseparms, 0); if (mouseparmsvalid) @@ -537,7 +537,7 @@ void GoldSourceInput::IN_Shutdown (void) { IN_DeactivateMouse (); -#ifdef _WIN32 +#if _WIN32 if ( s_hMouseQuitEvent ) { SetEvent( s_hMouseQuitEvent ); @@ -566,7 +566,7 @@ void GoldSourceInput::IN_Shutdown (void) } #endif -#ifdef USE_SDL2 +#if USE_SDL2 for (int j=0; jtime - s_flRawInputUpdateTime > 1.0f ) + const float currentTime = gEngfuncs.GetClientTime(); + if ( currentTime - s_flRawInputUpdateTime > 1.0f || s_flRawInputUpdateTime == 0.0f ) { - s_flRawInputUpdateTime = gpGlobals->time; + s_flRawInputUpdateTime = currentTime; bool lockEntered = MouseThread_ActiveLock_Enter(); - m_bRawInput = CVAR_GET_FLOAT( "m_rawinput" ) != 0; + m_bRawInput = m_rawinput && m_rawinput->value != 0; if(m_bRawInput && !isMouseRelative) { -#ifdef USE_SDL2 +#if USE_SDL2 safe_pfnSDL_SetRelativeMouseMode(SDL_TRUE); #endif isMouseRelative = true; } else if(!m_bRawInput && isMouseRelative) { -#ifdef USE_SDL2 +#if USE_SDL2 safe_pfnSDL_SetRelativeMouseMode(SDL_FALSE); #endif isMouseRelative = false; @@ -904,8 +905,8 @@ void GoldSourceInput::IN_MouseMove ( float frametime, usercmd_t *cmd) dead_viewangles = viewangles; // keep them actual /* -//#define TRACE_TEST -#if defined( TRACE_TEST ) +//#define TRACE_TEST 1 +#if TRACE_TEST { int mx, my; void V_Move( int mx, int my ); @@ -928,7 +929,7 @@ void GoldSourceInput::IN_Accumulate (void) { if (mouseactive) { -#ifdef _WIN32 +#if _WIN32 if ( !m_bRawInput ) { if ( !m_bMouseThread ) @@ -942,7 +943,7 @@ void GoldSourceInput::IN_Accumulate (void) else #endif { -#ifdef USE_SDL2 +#if USE_SDL2 int deltaX, deltaY; safe_pfnSDL_GetRelativeMouseState( &deltaX, &deltaY ); mx_accum += deltaX; @@ -956,7 +957,7 @@ void GoldSourceInput::IN_Accumulate (void) } // force the mouse to the center, so there's room to move -#ifdef _WIN32 +#if _WIN32 // do not reset if mousethread would do it: if ( m_bRawInput || !m_bMouseThread ) #else @@ -997,7 +998,7 @@ void IN_StartupJoystick (void) // assume no joystick joy_avail = 0; -#ifdef USE_SDL2 +#if USE_SDL2 int nJoysticks = safe_pfnSDL_NumJoysticks(); if ( nJoysticks > 0 ) { @@ -1029,7 +1030,7 @@ void IN_StartupJoystick (void) { gEngfuncs.Con_DPrintf ("joystick not found -- driver not present\n\n"); } -#elif defined(_WIN32) +#elif _WIN32 int numdevs; JOYCAPS jc; MMRESULT mmr; @@ -1084,7 +1085,7 @@ void IN_StartupJoystick (void) #endif } -#ifdef USE_SDL2 +#if USE_SDL2 int RawValuePointer (int axis) { switch (axis) @@ -1101,7 +1102,7 @@ int RawValuePointer (int axis) } } -#elif defined(_WIN32) +#elif _WIN32 PDWORD RawValuePointer (int axis) { switch (axis) @@ -1184,7 +1185,7 @@ void Joy_AdvancedUpdate_f (void) dwControlMap[JOY_AXIS_V] = dwTemp & JOY_RELATIVE_AXIS; } -#if !defined(USE_SDL2) && defined(_WIN32) +#if !USE_SDL2 && _WIN32 // compute the axes to collect from DirectInput joy_flags = JOY_RETURNCENTERED | JOY_RETURNBUTTONS | JOY_RETURNPOV; for (i = 0; i < JOY_MAX_AXES; i++) @@ -1216,7 +1217,7 @@ void GoldSourceInput::IN_Commands (void) // loop through the joystick buttons // key a joystick event or auxillary event for higher number buttons for each state change -#ifdef USE_SDL2 +#if USE_SDL2 buttonstate = 0; for ( i = 0; i < SDL_CONTROLLER_BUTTON_MAX; i++ ) { @@ -1230,7 +1231,7 @@ void GoldSourceInput::IN_Commands (void) { pdwRawValue[i] = RawValuePointer(i); } -#elif defined(_WIN32) +#elif _WIN32 buttonstate = ji.dwButtons; #endif @@ -1256,7 +1257,7 @@ void GoldSourceInput::IN_Commands (void) // this avoids any potential problems related to moving from one // direction to another without going through the center position povstate = 0; -#if !defined(USE_SDL2) && defined(_WIN32) +#if !USE_SDL2 && _WIN32 if(ji.dwPOV != JOY_POVCENTERED) { if (ji.dwPOV == JOY_POVFORWARD) @@ -1294,10 +1295,10 @@ IN_ReadJoystick */ int IN_ReadJoystick (void) { -#ifdef USE_SDL2 +#if USE_SDL2 safe_pfnSDL_JoystickUpdate(); return 1; -#elif defined(_WIN32) +#elif _WIN32 memset (&ji, 0, sizeof(ji)); ji.dwSize = sizeof(ji); ji.dwFlags = joy_flags; @@ -1374,9 +1375,9 @@ void IN_JoyMove ( float frametime, usercmd_t *cmd ) for (i = 0; i < JOY_MAX_AXES; i++) { // get the floating point zero-centered, potentially-inverted data for the current axis -#ifdef USE_SDL2 +#if USE_SDL2 fAxisValue = (float)pdwRawValue[i]; -#elif defined(_WIN32) +#elif _WIN32 fAxisValue = (float) *pdwRawValue[i]; fAxisValue -= 32768.0; #endif @@ -1570,8 +1571,9 @@ void GoldSourceInput::IN_Init (void) m_customaccel_max = gEngfuncs.pfnRegisterVariable ( "m_customaccel_max", "0", FCVAR_ARCHIVE ); m_customaccel_exponent = gEngfuncs.pfnRegisterVariable ( "m_customaccel_exponent", "1", FCVAR_ARCHIVE ); -#ifdef _WIN32 - m_bRawInput = CVAR_GET_FLOAT( "m_rawinput" ) != 0; +#if _WIN32 + m_rawinput = gEngfuncs.pfnGetCvarPointer("m_rawinput"); + m_bRawInput = m_rawinput && m_rawinput->value != 0; m_bMouseThread = gEngfuncs.CheckParm ("-mousethread", NULL ) != NULL; m_mousethread_sleep = gEngfuncs.pfnRegisterVariable ( "m_mousethread_sleep", "1", FCVAR_ARCHIVE ); // default to less than 1000 Hz @@ -1600,8 +1602,8 @@ void GoldSourceInput::IN_Init (void) } #endif -#ifdef USE_SDL2 -#ifdef __APPLE__ +#if USE_SDL2 +#if __APPLE__ #define SDL2_FULL_LIBNAME "libsdl2-2.0.0.dylib" #else #define SDL2_FULL_LIBNAME "libSDL2-2.0.so.0" diff --git a/cl_dll/input_mouse.cpp b/cl_dll/input_mouse.cpp index 3233d797..c5b1df6b 100644 --- a/cl_dll/input_mouse.cpp +++ b/cl_dll/input_mouse.cpp @@ -10,7 +10,7 @@ cvar_t *in_joystick; FWGSInput fwgsInput; -#ifdef SUPPORT_GOLDSOURCE_INPUT +#if SUPPORT_GOLDSOURCE_INPUT GoldSourceInput goldSourceInput; AbstractInput* currentInput = &goldSourceInput; #else @@ -68,7 +68,7 @@ void IN_Shutdown( void ) void IN_Init( void ) { -#ifdef SUPPORT_GOLDSOURCE_INPUT +#if SUPPORT_GOLDSOURCE_INPUT if (IsXashFWGS()) { gEngfuncs.Con_Printf( "FWGS Xash3D input is in use\n" ); currentInput = &fwgsInput; diff --git a/cl_dll/input_mouse.h b/cl_dll/input_mouse.h index c13b7fa2..814e239f 100644 --- a/cl_dll/input_mouse.h +++ b/cl_dll/input_mouse.h @@ -1,5 +1,8 @@ #pragma once -#ifndef INPUT_MOUSE_H + +#include "build.h" + +#if !defined(INPUT_MOUSE_H) #define INPUT_MOUSE_H #include "cl_dll.h" #include "usercmd.h" @@ -45,8 +48,23 @@ protected: }; // No need for goldsource input support on the platforms that are not supported by GoldSource. -#if defined(GOLDSOURCE_SUPPORT) && (defined(_WIN32) || defined(__linux__) || defined(__APPLE__)) && (defined(__i386) || defined(_M_IX86)) -#define SUPPORT_GOLDSOURCE_INPUT +#if GOLDSOURCE_SUPPORT && ( XASH_WIN32 || ( XASH_LINUX && !XASH_ANDROID ) || XASH_APPLE ) && XASH_X86 +#define SUPPORT_GOLDSOURCE_INPUT 1 + +#if _WIN32 +#define HSPRITE WINDOWS_HSPRITE +#include +#undef HSPRITE +#else +typedef struct point_s +{ + int x; + int y; +} POINT; +#define GetCursorPos(x) +#define SetCursorPos(x,y) +#endif + class GoldSourceInput : public AbstractInput { public: diff --git a/cl_dll/input_xash3d.cpp b/cl_dll/input_xash3d.cpp index 2ff572ee..ba5b14fd 100644 --- a/cl_dll/input_xash3d.cpp +++ b/cl_dll/input_xash3d.cpp @@ -82,42 +82,42 @@ void IN_ToggleButtons( float forwardmove, float sidemove ) } } - if( forwardmove > 0.7 && !( moveflags & F ) ) + if( forwardmove > 0.7f && !( moveflags & F ) ) { moveflags |= F; in_forward.state |= BUTTON_DOWN; } - if( forwardmove < 0.7 && ( moveflags & F ) ) + if( forwardmove < 0.7f && ( moveflags & F ) ) { moveflags &= ~F; in_forward.state &= ~BUTTON_DOWN; } - if( forwardmove < -0.7 && !( moveflags & B ) ) + if( forwardmove < -0.7f && !( moveflags & B ) ) { moveflags |= B; in_back.state |= BUTTON_DOWN; } - if( forwardmove > -0.7 && ( moveflags & B ) ) + if( forwardmove > -0.7f && ( moveflags & B ) ) { moveflags &= ~B; in_back.state &= ~BUTTON_DOWN; } - if( sidemove > 0.9 && !( moveflags & R ) ) + if( sidemove > 0.9f && !( moveflags & R ) ) { moveflags |= R; in_moveright.state |= BUTTON_DOWN; } - if( sidemove < 0.9 && ( moveflags & R ) ) + if( sidemove < 0.9f && ( moveflags & R ) ) { moveflags &= ~R; in_moveright.state &= ~BUTTON_DOWN; } - if( sidemove < -0.9 && !( moveflags & L ) ) + if( sidemove < -0.9f && !( moveflags & L ) ) { moveflags |= L; in_moveleft.state |= BUTTON_DOWN; } - if( sidemove > -0.9 && ( moveflags & L ) ) + if( sidemove > -0.9f && ( moveflags & L ) ) { moveflags &= ~L; in_moveleft.state &= ~BUTTON_DOWN; @@ -187,9 +187,11 @@ void FWGSInput::IN_Move( float frametime, usercmd_t *cmd ) viewangles[YAW] -= ac_sidemove * 5; ac_sidemove = 0; } +#if !USE_VGUI || USE_NOVGUI_MOTD if( gHUD.m_MOTD.m_bShow ) gHUD.m_MOTD.scroll += rel_pitch; else +#endif viewangles[PITCH] += rel_pitch; if( viewangles[PITCH] > cl_pitchdown->value ) diff --git a/cl_dll/menu.cpp b/cl_dll/menu.cpp index fc24b917..45147e78 100644 --- a/cl_dll/menu.cpp +++ b/cl_dll/menu.cpp @@ -24,6 +24,10 @@ #include #include +#if USE_VGUI +#include "vgui_TeamFortressViewport.h" +#endif + #define MAX_MENU_STRING 512 char g_szMenuString[MAX_MENU_STRING]; char g_szPrelocalisedMenuString[MAX_MENU_STRING]; @@ -78,6 +82,11 @@ int CHudMenu::Draw( float flTime ) } // don't draw the menu if the scoreboard is being shown +#if USE_VGUI + if( gViewPort && gViewPort->IsScoreBoardVisible() ) + return 1; +#endif + // draw the menu, along the left-hand side of the screen // count the number of newlines int nlc = 0; @@ -148,7 +157,7 @@ int CHudMenu::MsgFunc_ShowMenu( const char *pszName, int iSize, void *pbuf ) { if( !m_fWaitingForMore ) // this is the start of a new menu { - strncpy( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING ); + strncpy( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING - 1 ); } else { @@ -160,13 +169,13 @@ int CHudMenu::MsgFunc_ShowMenu( const char *pszName, int iSize, void *pbuf ) if( !NeedMore ) { // we have the whole string, so we can localise it now - strncpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString( g_szPrelocalisedMenuString ), MAX_MENU_STRING ); + strncpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString( g_szPrelocalisedMenuString ), MAX_MENU_STRING - 1 ); g_szMenuString[MAX_MENU_STRING - 1] = '\0'; // Swap in characters if( KB_ConvertString( g_szMenuString, &temp ) ) { - strncpy( g_szMenuString, temp, MAX_MENU_STRING ); + strncpy( g_szMenuString, temp, MAX_MENU_STRING - 1 ); g_szMenuString[MAX_MENU_STRING - 1] = '\0'; free( temp ); } diff --git a/cl_dll/message.cpp b/cl_dll/message.cpp index bbd59d9a..a07e85d5 100644 --- a/cl_dll/message.cpp +++ b/cl_dll/message.cpp @@ -66,22 +66,22 @@ float CHudMessage::FadeBlend( float fadein, float fadeout, float hold, float loc float fadeTime = fadein + hold; float fadeBlend; - if( localTime < 0 ) + if( localTime < 0.0f ) return 0; if( localTime < fadein ) { - fadeBlend = 1 - ( ( fadein - localTime ) / fadein ); + fadeBlend = 1.0f - ( ( fadein - localTime ) / fadein ); } else if( localTime > fadeTime ) { - if( fadeout > 0 ) - fadeBlend = 1 - ( ( localTime - fadeTime ) / fadeout ); + if( fadeout > 0.0f ) + fadeBlend = 1.0f - ( ( localTime - fadeTime ) / fadeout ); else - fadeBlend = 0; + fadeBlend = 0.0f; } else - fadeBlend = 1; + fadeBlend = 1.0f; return fadeBlend; } @@ -91,14 +91,14 @@ int CHudMessage::XPosition( float x, int width, int totalWidth ) { int xPos; - if( x == -1 ) + if( x == -1.0f ) { xPos = ( ScreenWidth - width ) / 2; } else { - if( x < 0 ) - xPos = ( 1.0 + x ) * ScreenWidth - totalWidth; // Alight right + if( x < 0.0f ) + xPos = ( 1.0f + x ) * ScreenWidth - totalWidth; // Alight right else xPos = x * ScreenWidth; } @@ -116,12 +116,12 @@ int CHudMessage::YPosition( float y, int height ) int yPos; if( y == -1 ) // Centered? - yPos = ( ScreenHeight - height ) * 0.5; + yPos = ( ScreenHeight - height ) * 0.5f; else { // Alight bottom? if ( y < 0 ) - yPos = ( 1.0 + y ) * ScreenHeight - height; // Alight bottom + yPos = ( 1.0f + y ) * ScreenHeight - height; // Alight bottom else // align top yPos = y * ScreenHeight; } @@ -164,18 +164,20 @@ void CHudMessage::MessageScanNextChar( void ) float deltaTime = m_parms.time - m_parms.charTime; destRed = destGreen = destBlue = 0; - if ( m_parms.time > m_parms.fadeTime ) + if( m_parms.time > m_parms.fadeTime ) { blend = m_parms.fadeBlend; } - else if ( deltaTime > m_parms.pMessage->fxtime ) + else if( deltaTime > m_parms.pMessage->fxtime ) + { blend = 0; // pure dest + } else { destRed = m_parms.pMessage->r2; destGreen = m_parms.pMessage->g2; destBlue = m_parms.pMessage->b2; - blend = 255 - (deltaTime * (1.0/m_parms.pMessage->fxtime) * 255.0 + 0.5); + blend = 255 - ( deltaTime * ( 1.0f / m_parms.pMessage->fxtime) * 255.0f + 0.5f ); } } break; @@ -208,7 +210,7 @@ void CHudMessage::MessageScanStart( void ) if( m_parms.time < m_parms.pMessage->fadein ) { - m_parms.fadeBlend = ( ( m_parms.pMessage->fadein - m_parms.time ) * ( 1.0 / m_parms.pMessage->fadein ) * 255 ); + m_parms.fadeBlend = ( ( m_parms.pMessage->fadein - m_parms.time ) * ( 1.0f / m_parms.pMessage->fadein ) * 255 ); } else if( m_parms.time > m_parms.fadeTime ) { @@ -292,7 +294,7 @@ void CHudMessage::MessageDrawScan( client_textmessage_t *pMessage, float time ) for( j = 0; j < m_parms.lineLength; j++ ) { - m_parms.text = pLineStart[j]; + m_parms.text = (unsigned char)pLineStart[j]; int next = m_parms.x + gHUD.m_scrinfo.charWidths[m_parms.text]; MessageScanNextChar(); @@ -350,9 +352,9 @@ int CHudMessage::Draw( float fTime ) // Assume m_parms.time contains last time if( m_pMessages[i] ) { - pMessage = m_pMessages[i]; + // pMessage = m_pMessages[i]; if( m_startTime[i] > gHUD.m_flTime ) - m_startTime[i] = gHUD.m_flTime + m_parms.time - m_startTime[i] + 0.2; // Server takes 0.2 seconds to spawn, adjust for this + m_startTime[i] = gHUD.m_flTime + m_parms.time - m_startTime[i] + 0.2f; // Server takes 0.2 seconds to spawn, adjust for this } } @@ -428,11 +430,11 @@ void CHudMessage::MessageAdd( const char *pName, float time ) g_pCustomMessage.g2 = 110; g_pCustomMessage.b2 = 0; g_pCustomMessage.a2 = 0; - g_pCustomMessage.x = -1; // Centered - g_pCustomMessage.y = 0.7; - g_pCustomMessage.fadein = 0.01; - g_pCustomMessage.fadeout = 1.5; - g_pCustomMessage.fxtime = 0.25; + g_pCustomMessage.x = -1.0f; // Centered + g_pCustomMessage.y = 0.7f; + g_pCustomMessage.fadein = 0.01f; + g_pCustomMessage.fadeout = 1.5f; + g_pCustomMessage.fxtime = 0.25f; g_pCustomMessage.holdtime = 5; g_pCustomMessage.pName = g_pCustomName; strcpy( g_pCustomText, pName ); @@ -452,9 +454,9 @@ void CHudMessage::MessageAdd( const char *pName, float time ) } // get rid of any other messages in same location (only one displays at a time) - if( fabs( tempMessage->y - m_pMessages[j]->y ) < 0.0001 ) + if( fabs( tempMessage->y - m_pMessages[j]->y ) < 0.0001f ) { - if ( fabs( tempMessage->x - m_pMessages[j]->x ) < 0.0001 ) + if( fabs( tempMessage->x - m_pMessages[j]->x ) < 0.0001f ) { m_pMessages[j] = NULL; } diff --git a/cl_dll/overview.cpp b/cl_dll/overview.cpp deleted file mode 100644 index 81f028e2..00000000 --- a/cl_dll/overview.cpp +++ /dev/null @@ -1,161 +0,0 @@ -//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#include "hud.h" -#include "cl_util.h" -#include "cl_entity.h" -#include "triangleapi.h" -#include "overview.h" - -// these are included for the math functions -#include "com_model.h" -#include "studio_util.h" - -#pragma warning(disable: 4244) - -//----------------------------------------------------------------------------- -// Purpose: -//----------------------------------------------------------------------------- -int CHudOverview::Init() -{ - gHUD.AddHudElem(this); - - m_iFlags |= HUD_ACTIVE; - - return 1; -} - -//----------------------------------------------------------------------------- -// Purpose: Loads new icons -//----------------------------------------------------------------------------- -int CHudOverview::VidInit() -{ - m_hsprPlayer = gEngfuncs.pfnSPR_Load( "sprites/ring.spr" ); - m_hsprViewcone = gEngfuncs.pfnSPR_Load( "sprites/camera.spr" ); - - return 1; -} - -//----------------------------------------------------------------------------- -// Purpose: -// Input : flTime - -// intermission - -//----------------------------------------------------------------------------- -int CHudOverview::Draw( float flTime ) -{ -#if 0 - // only draw in overview mode - if( !gEngfuncs.Overview_GetOverviewState() ) - return 1; - - // make sure we have player info - //gViewPort->GetAllPlayersInfo(); - gHUD.m_Scoreboard.GetAllPlayersInfo(); - - // calculate player size on the overview - int x1, y1, x2, y2; - float v0[3] = { 0.0f }, v1[3] = { 64.0f, 64.0f }; - gEngfuncs.Overview_WorldToScreen( v0, &x1, &y1 ); - gEngfuncs.Overview_WorldToScreen( v1, &x2, &y2 ); - float scale = abs( x2 - x1 ); - - // loop through all the players and draw them on the map - for( int i = 1; i < MAX_PLAYERS; i++ ) - { - cl_entity_t *pl = gEngfuncs.GetEntityByIndex( i ); - - if( pl && pl->player && pl->curstate.health > 0 && pl->curstate.solid != SOLID_NOT ) - { - int x, y, z = 0; - float v[3] = { pl->origin[0], pl->origin[1], 0 }; - gEngfuncs.Overview_WorldToScreen( v, &x, &y ); - - // hack in some team colors - float r, g, bc; - if( g_PlayerExtraInfo[i].teamnumber == 1 ) - { - r = 0.0f; g = 0.0f; bc = 1.0f; - } - else if( g_PlayerExtraInfo[i].teamnumber == 2 ) - { - r = 1.0f; g = 0.0f; bc = 0.0f; - } - else - { - // just use the default orange color if the team isn't set - r = 1.0f; g = 0.7f; bc = 0.0f; - } - - // set the current texture - gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)gEngfuncs.GetSpritePointer( m_hsprPlayer ), 0 ); - - // additive render mode - gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd ); - - // no culling - gEngfuncs.pTriAPI->CullFace( TRI_NONE ); - - // draw a square - gEngfuncs.pTriAPI->Begin( TRI_QUADS ); - - // set the color to be that of the team - gEngfuncs.pTriAPI->Color4f( r, g, bc, 1.0f ); - - // calculate rotational matrix - vec3_t a, b, angles; - float rmatrix[3][4]; // transformation matrix - VectorCopy( pl->angles, angles ); - angles[0] = 0.0f; - angles[1] += 90.f; - angles[1] = -angles[1]; - angles[2] = 0.0f; - AngleMatrix( angles, rmatrix ); - a[2] = 0; - - a[0] = -scale; a[1] = -scale; - VectorTransform( a, rmatrix, b ); - gEngfuncs.pTriAPI->TexCoord2f( 0, 0 ); - gEngfuncs.pTriAPI->Vertex3f( x + b[0], y + b[1], z ); - - a[0] = -scale; a[1] = scale; - VectorTransform( a, rmatrix, b ); - gEngfuncs.pTriAPI->TexCoord2f( 0, 1 ); - gEngfuncs.pTriAPI->Vertex3f( x + b[0], y + b[1], z ); - - a[0] = scale; a[1] = scale; - VectorTransform( a, rmatrix, b ); - gEngfuncs.pTriAPI->TexCoord2f( 1, 1 ); - gEngfuncs.pTriAPI->Vertex3f( x + b[0], y + b[1], z ); - - a[0] = scale; a[1] = -scale; - VectorTransform( a, rmatrix, b ); - gEngfuncs.pTriAPI->TexCoord2f( 1, 0 ); - gEngfuncs.pTriAPI->Vertex3f( x + b[0], y + b[1], z ); - - // finish up - gEngfuncs.pTriAPI->End(); - gEngfuncs.pTriAPI->RenderMode( kRenderNormal ); - - // draw the players name and health underneath - char string[256]; - sprintf( string, "%s (%i%%)", g_PlayerInfoList[i].name, pl->curstate.health ); - DrawConsoleString( x, y + ( 1.1 * scale ), string ); - } - } -#endif - return 1; -} - -//----------------------------------------------------------------------------- -// Purpose: called every time a server is connected to -//----------------------------------------------------------------------------- -void CHudOverview::InitHUDData() -{ - //this block would force the spectator view to be on - //gEngfuncs.Overview_SetDrawOverview( 1 ); - //gEngfuncs.Overview_SetDrawInset( 0 ); -} diff --git a/cl_dll/overview.h b/cl_dll/overview.h deleted file mode 100644 index c1675e98..00000000 --- a/cl_dll/overview.h +++ /dev/null @@ -1,28 +0,0 @@ -//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#pragma once -#ifndef OVERVIEW_H -#define OVERVIEW_H - -//----------------------------------------------------------------------------- -// Purpose: Handles the drawing of the top-down map and all the things on it -//----------------------------------------------------------------------------- -class CHudOverview : public CHudBase -{ -public: - int Init(); - int VidInit(); - - int Draw( float flTime ); - void InitHUDData( void ); - -private: - HSPRITE m_hsprPlayer; - HSPRITE m_hsprViewcone; -}; -#endif // OVERVIEW_H diff --git a/cl_dll/parsemsg.h b/cl_dll/parsemsg.h index 05efefc3..a37a100a 100644 --- a/cl_dll/parsemsg.h +++ b/cl_dll/parsemsg.h @@ -16,7 +16,7 @@ // parsemsg.h // #pragma once -#ifndef PARSEMSG_H +#if !defined(PARSEMSG_H) #define PARSEMSG_H #define ASSERT( x ) diff --git a/cl_dll/saytext.cpp b/cl_dll/saytext.cpp index b084f44b..35d08bec 100644 --- a/cl_dll/saytext.cpp +++ b/cl_dll/saytext.cpp @@ -25,6 +25,10 @@ #include #include +#if USE_VGUI +#include "vgui_TeamFortressViewport.h" +#endif + extern float *GetClientColor( int clientIndex ); #define MAX_LINES 5 @@ -95,6 +99,12 @@ int CHudSayText::Draw( float flTime ) { int y = Y_START; +#if USE_VGUI + if( ( gViewPort && gViewPort->AllowedToPrintText() == FALSE ) || !m_HUD_saytext->value ) + return 1; +#endif + + // make sure the scrolltime is within reasonable bounds, to guard against the clock being reset flScrollTime = Q_min( flScrollTime, flTime + m_HUD_saytext_time->value ); @@ -123,7 +133,7 @@ int CHudSayText::Draw( float flTime ) static char buf[MAX_PLAYER_NAME_LENGTH + 32]; // draw the first x characters in the player color - strncpy( buf, g_szLineBuffer[i], Q_min(g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH + 32 ) ); + strncpy( buf, g_szLineBuffer[i], Q_min(g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH + 31 ) ); buf[Q_min( g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH + 31 )] = 0; DrawSetTextColor( g_pflNameColors[i][0], g_pflNameColors[i][1], g_pflNameColors[i][2] ); int x = DrawConsoleString( LINE_START, y, buf ); @@ -156,9 +166,18 @@ int CHudSayText::MsgFunc_SayText( const char *pszName, int iSize, void *pbuf ) void CHudSayText::SayTextPrint( const char *pszBuf, int iBufSize, int clientIndex ) { - int i; +#if USE_VGUI + if( gViewPort && gViewPort->AllowedToPrintText() == FALSE ) + { + // Print it straight to the console + ConsolePrint( pszBuf ); + return; + } +#else ConsolePrint( pszBuf ); +#endif + int i; // find an empty string slot for( i = 0; i < MAX_LINES; i++ ) { @@ -259,7 +278,7 @@ void CHudSayText::EnsureTextFitsInOneLineAndWrapIfHaveTo( int line ) if( !last_break ) last_break = x - 1; - x = last_break; + // x = last_break; // find an empty string slot int j; diff --git a/cl_dll/scoreboard.cpp b/cl_dll/scoreboard.cpp index 3361aa0a..007585f5 100644 --- a/cl_dll/scoreboard.cpp +++ b/cl_dll/scoreboard.cpp @@ -28,35 +28,34 @@ cvar_t *cl_scoreboard_bg; cvar_t *cl_showpacketloss; -hud_player_info_t g_PlayerInfoList[MAX_PLAYERS + 1]; // player info from the engine -extra_player_info_t g_PlayerExtraInfo[MAX_PLAYERS + 1]; // additional player info sent directly to the client dll -team_info_t g_TeamInfo[MAX_TEAMS + 1]; -int g_iUser1; -int g_iUser2; -int g_iUser3; -int g_iTeamNumber; -int g_iPlayerClass; -//#include "vgui_TeamFortressViewport.h" + +#if USE_VGUI +#include "vgui_TeamFortressViewport.h" +#endif DECLARE_COMMAND( m_Scoreboard, ShowScores ) DECLARE_COMMAND( m_Scoreboard, HideScores ) +#if !USE_VGUI || USE_NOVGUI_SCOREBOARD DECLARE_MESSAGE( m_Scoreboard, ScoreInfo ) DECLARE_MESSAGE( m_Scoreboard, TeamInfo ) DECLARE_MESSAGE( m_Scoreboard, TeamScore ) +#endif int CHudScoreboard::Init( void ) { gHUD.AddHudElem( this ); // Hook messages & commands here - HOOK_COMMAND( "+showscores", ShowScores ); - HOOK_COMMAND( "-showscores", HideScores ); + // HOOK_COMMAND( "+showscores", ShowScores ); + // HOOK_COMMAND( "-showscores", HideScores ); +#if !USE_VGUI || USE_NOVGUI_SCOREBOARD HOOK_MESSAGE( ScoreInfo ); HOOK_MESSAGE( TeamScore ); HOOK_MESSAGE( TeamInfo ); +#endif InitHUDData(); @@ -171,12 +170,12 @@ int CHudScoreboard::Draw( float fTime ) DrawUtfString( PL_RANGE_MAX + xpos_rel - 35, ypos, ScreenWidth, "pkt loss", 255, 140, 0 ); } - list_slot += 1.2; + list_slot += 1.2f; ypos = ROW_RANGE_MIN + ( list_slot * ROW_GAP ); // xpos = NAME_RANGE_MIN + xpos_rel; FillRGBA( xpos - 4, ypos, FAR_RIGHT -2, 1, 255, 140, 0, 255 ); // draw the seperator line - list_slot += 0.8; + list_slot += 0.8f; if( !gHUD.m_Teamplay ) { @@ -328,7 +327,7 @@ int CHudScoreboard::Draw( float fTime ) } // draw all the players who are not in a team - list_slot += 0.5; + list_slot += 0.5f; DrawPlayers( xpos_rel, list_slot, 0, "" ); return 1; @@ -454,7 +453,7 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, if( g_PlayerInfoList[best_player].packetloss >= 63 ) { UnpackRGB( r, g, b, RGB_REDISH ); - sprintf( buf, " !!!!" ); + strcpy( buf, " !!!!" ); } else { @@ -502,7 +501,9 @@ int CHudScoreboard::MsgFunc_ScoreInfo( const char *pszName, int iSize, void *pbu g_PlayerExtraInfo[cl].playerclass = playerclass; g_PlayerExtraInfo[cl].teamnumber = teamnumber; - //gViewPort->UpdateOnPlayerInfo(); +#if USE_VGUI + gViewPort->UpdateOnPlayerInfo(); +#endif } return 1; @@ -521,7 +522,7 @@ int CHudScoreboard::MsgFunc_TeamInfo( const char *pszName, int iSize, void *pbuf if( cl > 0 && cl <= MAX_PLAYERS ) { // set the players team - strncpy( g_PlayerExtraInfo[cl].teamname, READ_STRING(), MAX_TEAM_NAME ); + strncpy( g_PlayerExtraInfo[cl].teamname, READ_STRING(), MAX_TEAM_NAME - 1 ); } // rebuild the list of teams @@ -563,7 +564,7 @@ int CHudScoreboard::MsgFunc_TeamInfo( const char *pszName, int iSize, void *pbuf } m_iNumTeams = Q_max( j, m_iNumTeams ); - strncpy( g_TeamInfo[j].name, g_PlayerExtraInfo[i].teamname, MAX_TEAM_NAME ); + strncpy( g_TeamInfo[j].name, g_PlayerExtraInfo[i].teamname, MAX_TEAM_NAME - 1 ); g_TeamInfo[j].players = 0; } diff --git a/cl_dll/soundsystem.cpp b/cl_dll/soundsystem.cpp deleted file mode 100644 index 9ee33861..00000000 --- a/cl_dll/soundsystem.cpp +++ /dev/null @@ -1,163 +0,0 @@ -//======== (C) Copyright 1996-2002 Valve, L.L.C. All rights reserved. ======== -// -// The copyright to the contents herein is the property of Valve, L.L.C. -// The contents may be used and/or copied only with the written permission of -// Valve, L.L.C., or in accordance with the terms and conditions stipulated in -// the agreement/contract under which the contents have been supplied. -// -// Purpose: -// -// $Workfile: $ -// $Date: $ -// -//----------------------------------------------------------------------------- -// $Log: $ -// -// $NoKeywords: $ -//============================================================================= - -#include -#include -#include -#include "r_studioint.h" - -extern engine_studio_api_t IEngineStudio; - -#define RENDERTYPE_UNDEFINED 0 -#define RENDERTYPE_SOFTWARE 1 -#define RENDERTYPE_HARDWARE 2 - -#define ENGINE_LAUNCHER_API_VERSION 1 - -LPDIRECTSOUND lpDS = NULL; -LPDIRECTSOUNDBUFFER lpDSBuf = NULL; -LPHWAVEOUT lpHW = NULL; - -static HMODULE hEngine = 0; - -typedef struct engine_api_s -{ - int version; - int rendertype; - int size; - - // Functions - void ( *unused1 ) ( void ); - void ( *unused2 ) ( void ); - void ( *unused3 ) ( void ); - void ( *unused4 ) ( void ); - void ( *unused5 ) ( void ); - void ( *unused6 ) ( void ); - void ( *unused7 ) ( void ); - void ( *unused8 ) ( void ); - void ( *unused9 ) ( void ); - void ( *unused10 ) ( void ); - void ( *unused11 ) ( void ); - void ( *unused12 ) ( void ); - void ( *unused13 ) ( void ); - void ( *unused14 ) ( void ); - void ( *unused15 ) ( void ); - void ( *unused16 ) ( void ); - void ( *unused17 ) ( void ); - void ( *unused18 ) ( void ); - void ( *unused19 ) ( void ); - void ( *unused20 ) ( void ); - void ( *unused21 ) ( void ); - void ( *unused22 ) ( void ); - void ( *unused23 ) ( void ); - void ( *unused24 ) ( void ); - void ( *unused25 ) ( void ); - void ( *unused26 ) ( void ); - void ( *unused27 ) ( void ); - void ( *unused28 ) ( void ); - void ( *unused29 ) ( void ); - void ( *unused30 ) ( void ); - void ( *unused31 ) ( void ); - void ( *unused32 ) ( void ); - void ( *unused33 ) ( void ); - void ( *unused34 ) ( void ); - - void ( *S_GetDSPointer ) ( struct IDirectSound **lpDS, struct IDirectSoundBuffer **lpDSBuf ); - void *( *S_GetWAVPointer ) ( void ); - - void ( *unused35 ) ( void ); - void ( *unused36 ) ( void ); - void ( *unused37 ) ( void ); - void ( *unused38 ) ( void ); - void ( *unused39 ) ( void ); - void ( *unused40 ) ( void ); - void ( *unused41 ) ( void ); - void ( *unused42 ) ( void ); - void ( *unused43 ) ( void ); - void ( *unused44 ) ( void ); - void ( *unused45 ) ( void ); - void ( *unused46 ) ( void ); - void ( *unused47 ) ( void ); - void ( *unused48 ) ( void ); - void ( *unused49 ) ( void ); - void ( *unused50 ) ( void ); - void ( *unused51 ) ( void ); - void ( *unused52 ) ( void ); - void ( *unused53 ) ( void ); - void ( *unused54 ) ( void ); - void ( *unused55 ) ( void ); -} engine_api_t; - -static engine_api_t engineapi; - -typedef int (*engine_api_func)( int version, int size, struct engine_api_s *api ); - -//----------------------------------------------------------------------------- -// Purpose: Get launcher/engine interface from engine module -// Input : hMod - -// Output : int -//----------------------------------------------------------------------------- -int Eng_LoadFunctions( HMODULE hMod ) -{ - engine_api_func pfnEngineAPI; - - pfnEngineAPI = ( engine_api_func )GetProcAddress( hMod, "Sys_EngineAPI" ); - if( !pfnEngineAPI ) - return 0; - - if( !(*pfnEngineAPI)( ENGINE_LAUNCHER_API_VERSION, sizeof( engine_api_t ), &engineapi ) ) - return 0; - - // All is okay - return 1; -} - -//----------------------------------------------------------------------------- -// Purpose: Load proper engine .dll and get pointer to either DSound and primary buffer or HWAVEOUT ( NT 4.0, e.g. ) -//----------------------------------------------------------------------------- -void LoadSoundAPIs( void ) -{ - hEngine = ::LoadLibrary( IEngineStudio.IsHardware() ? "hw.dll" : "sw.dll" ); - if( hEngine ) - { - if( Eng_LoadFunctions( hEngine ) ) - { - if( engineapi.S_GetDSPointer && engineapi.S_GetWAVPointer ) - { - engineapi.S_GetDSPointer(&lpDS, &lpDSBuf); - lpHW = (HWAVEOUT FAR *)engineapi.S_GetWAVPointer(); - } - } - } -} - -//----------------------------------------------------------------------------- -// Purpose: Close engine library, release sound pointers -//----------------------------------------------------------------------------- -void ShutdownSoundAPIs( void ) -{ - if( hEngine ) - { - FreeLibrary( hEngine ); - hEngine = 0; - } - - lpDS = 0; - lpDSBuf = 0; - lpHW = 0; -} diff --git a/cl_dll/statusbar.cpp b/cl_dll/statusbar.cpp index 79f30b7e..41b5008e 100644 --- a/cl_dll/statusbar.cpp +++ b/cl_dll/statusbar.cpp @@ -141,7 +141,8 @@ void CHudStatusBar::ParseStatusString( int line_num ) GetPlayerInfo( indexval, &g_PlayerInfoList[indexval] ); if( g_PlayerInfoList[indexval].name != NULL ) { - strncpy( szRepString, g_PlayerInfoList[indexval].name, MAX_PLAYER_NAME_LENGTH ); + strncpy( szRepString, g_PlayerInfoList[indexval].name, MAX_PLAYER_NAME_LENGTH - 1 ); + szRepString[MAX_PLAYER_NAME_LENGTH - 1] = '\0'; m_pflNameColors[line_num] = GetClientColor( indexval ); } else @@ -231,7 +232,7 @@ int CHudStatusBar::MsgFunc_StatusText( const char *pszName, int iSize, void *pbu if( line < 0 || line >= MAX_STATUSBAR_LINES ) return 1; - strncpy( m_szStatusText[line], READ_STRING(), MAX_STATUSTEXT_LENGTH ); + strncpy( m_szStatusText[line], READ_STRING(), MAX_STATUSTEXT_LENGTH - 1 ); m_szStatusText[line][MAX_STATUSTEXT_LENGTH - 1] = 0; // ensure it's null terminated ( strncpy() won't null terminate if read string too long) if( m_szStatusText[0] == 0 ) diff --git a/cl_dll/studio_util.cpp b/cl_dll/studio_util.cpp index 6e488dcb..3e676654 100644 --- a/cl_dll/studio_util.cpp +++ b/cl_dll/studio_util.cpp @@ -5,7 +5,6 @@ // $NoKeywords: $ //============================================================================= -#include #include "hud.h" #include "cl_util.h" #include "const.h" @@ -23,13 +22,13 @@ void AngleMatrix( const float *angles, float (*matrix)[4] ) float angle; float sr, sp, sy, cr, cp, cy; - angle = angles[YAW] * ( M_PI*2 / 360 ); + angle = angles[YAW] * ( M_PI_F * 2.0f / 360.0f ); sy = sin( angle ); cy = cos( angle ); - angle = angles[PITCH] * ( M_PI*2 / 360 ); + angle = angles[PITCH] * ( M_PI_F * 2.0f / 360.0f ); sp = sin( angle ); cp = cos( angle ); - angle = angles[ROLL] * ( M_PI*2 / 360 ); + angle = angles[ROLL] * ( M_PI_F * 2.0f / 360.0f ); sr = sin( angle ); cr = cos( angle ); @@ -43,9 +42,9 @@ void AngleMatrix( const float *angles, float (*matrix)[4] ) matrix[0][2] = (cr * sp * cy + -sr * -sy); matrix[1][2] = (cr * sp * sy + -sr* cy); matrix[2][2] = cr * cp; - matrix[0][3] = 0.0; - matrix[1][3] = 0.0; - matrix[2][3] = 0.0; + matrix[0][3] = 0.0f; + matrix[1][3] = 0.0f; + matrix[2][3] = 0.0f; } /* @@ -73,9 +72,9 @@ CrossProduct */ void CrossProduct( const float *v1, const float *v2, float *cross ) { - cross[0] = v1[1]*v2[2] - v1[2]*v2[1]; - cross[1] = v1[2]*v2[0] - v1[0]*v2[2]; - cross[2] = v1[0]*v2[1] - v1[1]*v2[0]; + cross[0] = v1[1] * v2[2] - v1[2] * v2[1]; + cross[1] = v1[2] * v2[0] - v1[0] * v2[2]; + cross[2] = v1[0] * v2[1] - v1[1] * v2[0]; } /* @@ -139,13 +138,13 @@ void AngleQuaternion( float *angles, vec4_t quaternion ) float sr, sp, sy, cr, cp, cy; // FIXME: rescale the inputs to 1/2 angle - angle = angles[2] * 0.5; + angle = angles[2] * 0.5f; sy = sin( angle ); cy = cos( angle ); - angle = angles[1] * 0.5; + angle = angles[1] * 0.5f; sp = sin( angle ); cp = cos( angle ); - angle = angles[0] * 0.5; + angle = angles[0] * 0.5f; sr = sin( angle ); cr = cos( angle ); @@ -185,18 +184,18 @@ void QuaternionSlerp( vec4_t p, vec4_t q, float t, vec4_t qt ) cosom = p[0] * q[0] + p[1] * q[1] + p[2] * q[2] + p[3] * q[3]; - if( ( 1.0 + cosom ) > 0.000001 ) + if( ( 1.0f + cosom ) > 0.000001f ) { - if( ( 1.0 - cosom ) > 0.000001 ) + if( ( 1.0f - cosom ) > 0.000001f ) { omega = acos( cosom ); sinom = sin( omega ); - sclp = sin( ( 1.0 - t ) * omega ) / sinom; + sclp = sin( ( 1.0f - t ) * omega ) / sinom; sclq = sin( t * omega ) / sinom; } else { - sclp = 1.0 - t; + sclp = 1.0f - t; sclq = t; } for( i = 0; i < 4; i++ ) @@ -210,8 +209,8 @@ void QuaternionSlerp( vec4_t p, vec4_t q, float t, vec4_t qt ) qt[1] = q[0]; qt[2] = -q[3]; qt[3] = q[2]; - sclp = sin( ( 1.0 - t ) * ( 0.5 * M_PI ) ); - sclq = sin( t * ( 0.5 * M_PI ) ); + sclp = sin( ( 1.0f - t ) * ( 0.5f * M_PI_F ) ); + sclq = sin( t * ( 0.5f * M_PI_F ) ); for( i = 0; i < 3; i++ ) { qt[i] = sclp * p[i] + sclq * qt[i]; @@ -227,17 +226,17 @@ QuaternionMatrix */ void QuaternionMatrix( vec4_t quaternion, float (*matrix)[4] ) { - matrix[0][0] = 1.0 - 2.0 * quaternion[1] * quaternion[1] - 2.0 * quaternion[2] * quaternion[2]; - matrix[1][0] = 2.0 * quaternion[0] * quaternion[1] + 2.0 * quaternion[3] * quaternion[2]; - matrix[2][0] = 2.0 * quaternion[0] * quaternion[2] - 2.0 * quaternion[3] * quaternion[1]; + matrix[0][0] = 1.0f - 2.0f * quaternion[1] * quaternion[1] - 2.0f * quaternion[2] * quaternion[2]; + matrix[1][0] = 2.0f * quaternion[0] * quaternion[1] + 2.0f * quaternion[3] * quaternion[2]; + matrix[2][0] = 2.0f * quaternion[0] * quaternion[2] - 2.0f * quaternion[3] * quaternion[1]; - matrix[0][1] = 2.0 * quaternion[0] * quaternion[1] - 2.0 * quaternion[3] * quaternion[2]; - matrix[1][1] = 1.0 - 2.0 * quaternion[0] * quaternion[0] - 2.0 * quaternion[2] * quaternion[2]; - matrix[2][1] = 2.0 * quaternion[1] * quaternion[2] + 2.0 * quaternion[3] * quaternion[0]; + matrix[0][1] = 2.0f * quaternion[0] * quaternion[1] - 2.0f * quaternion[3] * quaternion[2]; + matrix[1][1] = 1.0f - 2.0f * quaternion[0] * quaternion[0] - 2.0f * quaternion[2] * quaternion[2]; + matrix[2][1] = 2.0f * quaternion[1] * quaternion[2] + 2.0f * quaternion[3] * quaternion[0]; - matrix[0][2] = 2.0 * quaternion[0] * quaternion[2] + 2.0 * quaternion[3] * quaternion[1]; - matrix[1][2] = 2.0 * quaternion[1] * quaternion[2] - 2.0 * quaternion[3] * quaternion[0]; - matrix[2][2] = 1.0 - 2.0 * quaternion[0] * quaternion[0] - 2.0 * quaternion[1] * quaternion[1]; + matrix[0][2] = 2.0f * quaternion[0] * quaternion[2] + 2.0f * quaternion[3] * quaternion[1]; + matrix[1][2] = 2.0f * quaternion[1] * quaternion[2] - 2.0f * quaternion[3] * quaternion[0]; + matrix[2][2] = 1.0f - 2.0f * quaternion[0] * quaternion[0] - 2.0f * quaternion[1] * quaternion[1]; } /* diff --git a/cl_dll/studio_util.h b/cl_dll/studio_util.h index 83de704c..de54d440 100644 --- a/cl_dll/studio_util.h +++ b/cl_dll/studio_util.h @@ -4,16 +4,19 @@ // // $NoKeywords: $ //============================================================================= - #pragma once -#if !defined( STUDIO_UTIL_H ) +#if !defined(STUDIO_UTIL_H) #define STUDIO_UTIL_H -#ifndef M_PI +#if !defined(M_PI) #define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h #endif -#ifndef PITCH +#if !defined(M_PI_F) +#define M_PI_F (float)M_PI +#endif + +#if !defined(PITCH) // MOVEMENT INFO // up / down #define PITCH 0 diff --git a/cl_dll/text_message.cpp b/cl_dll/text_message.cpp index 512623dd..9f1a55ad 100644 --- a/cl_dll/text_message.cpp +++ b/cl_dll/text_message.cpp @@ -26,6 +26,10 @@ #include #include "parsemsg.h" +#if USE_VGUI +#include "vgui_TeamFortressViewport.h" +#endif + DECLARE_MESSAGE( m_TextMessage, TextMsg ) int CHudTextMessage::Init( void ) @@ -178,23 +182,32 @@ int CHudTextMessage::MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf char *psz = szBuf[5]; +#if USE_VGUI + if( gViewPort && gViewPort->AllowedToPrintText() == FALSE ) + return 1; +#endif + switch( msg_dest ) { case HUD_PRINTCENTER: _snprintf( psz, MSG_BUF_SIZE, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); + psz[MSG_BUF_SIZE - 1] = '\0'; CenterPrint( ConvertCRtoNL( psz ) ); break; case HUD_PRINTNOTIFY: psz[0] = 1; // mark this message to go into the notify buffer _snprintf( psz + 1, MSG_BUF_SIZE - 1, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); + psz[MSG_BUF_SIZE - 2] = '\0'; ConsolePrint( ConvertCRtoNL( psz ) ); break; case HUD_PRINTTALK: _snprintf( psz, MSG_BUF_SIZE, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); + psz[MSG_BUF_SIZE - 1] = '\0'; gHUD.m_SayText.SayTextPrint( ConvertCRtoNL( psz ), MSG_BUF_SIZE ); break; case HUD_PRINTCONSOLE: _snprintf( psz, MSG_BUF_SIZE, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); + psz[MSG_BUF_SIZE - 1] = '\0'; ConsolePrint( ConvertCRtoNL( psz ) ); break; } diff --git a/cl_dll/tf_defs.h b/cl_dll/tf_defs.h index a9270f1e..e445f2fc 100644 --- a/cl_dll/tf_defs.h +++ b/cl_dll/tf_defs.h @@ -7,8 +7,7 @@ * All Rights Reserved. * ****/ - -#ifndef __TF_DEFS_H +#if !defined(__TF_DEFS_H) #define __TF_DEFS_H //=========================================================================== @@ -46,7 +45,7 @@ // Debug Options //#define MAP_DEBUG // Debug for Map code. I suggest running in a hi-res // mode and/or piping the output from the server to a file. -#ifdef MAP_DEBUG +#if MAP_DEBUG #define MDEBUG(x) x #else #define MDEBUG(x) @@ -1155,7 +1154,7 @@ float already_chosen_map; #define TS_PRINT_LONG 2 #define TS_PRINT_LONG_TO_ALL 3 -#ifndef TF_DEFS_ONLY +#if !defined(TF_DEFS_ONLY) typedef struct { diff --git a/cl_dll/tri.cpp b/cl_dll/tri.cpp index ab8f3730..0088daf3 100644 --- a/cl_dll/tri.cpp +++ b/cl_dll/tri.cpp @@ -23,8 +23,8 @@ extern "C" void DLLEXPORT HUD_DrawTransparentTriangles( void ); } -//#define TEST_IT -#if defined( TEST_IT ) +//#define TEST_IT 1 +#if TEST_IT /* ================= @@ -50,9 +50,7 @@ void Draw_Triangles( void ) if( gHUD.m_hsprCursor == 0 ) { - char sz[256]; - sprintf( sz, "sprites/cursor.spr" ); - gHUD.m_hsprCursor = SPR_Load( sz ); + gHUD.m_hsprCursor = SPR_Load( "sprites/cursor.spr" ); } if( !gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)gEngfuncs.GetSpritePointer( gHUD.m_hsprCursor ), 0 ) ) @@ -98,7 +96,7 @@ Non-transparent triangles-- add them here void DLLEXPORT HUD_DrawNormalTriangles( void ) { gHUD.m_Spectator.DrawOverview(); -#if defined( TEST_IT ) +#if TEST_IT // Draw_Triangles(); #endif } @@ -112,7 +110,7 @@ Render any triangles with transparent rendermode needs here */ void DLLEXPORT HUD_DrawTransparentTriangles( void ) { -#if defined( TEST_IT ) +#if TEST_IT // Draw_Triangles(); #endif } diff --git a/cl_dll/util.cpp b/cl_dll/util.cpp index 655bde64..7d6b6669 100644 --- a/cl_dll/util.cpp +++ b/cl_dll/util.cpp @@ -18,32 +18,34 @@ // implementation of class-less helper functions // -#include "stdio.h" -#include "stdlib.h" -#include "math.h" +#include +#include +#include #include "hud.h" #include "cl_util.h" #include -#ifndef M_PI +#if !defined(M_PI) #define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h #endif +#if !defined(M_PI_F) +#define M_PI_F (float)M_PI +#endif extern vec3_t vec3_origin; -#ifdef _MSC_VER +// if C++ mangling differs from C symbol name +#if _MSC_VER || __WATCOMC__ vec3_t vec3_origin; #endif -double sqrt( double x ); - float Length( const float *v ) { int i; float length; - length = 0; + length = 0.0f; for( i = 0; i < 3; i++ ) length += v[i] * v[i]; length = sqrt( length ); // FIXME @@ -55,29 +57,29 @@ void VectorAngles( const float *forward, float *angles ) { float tmp, yaw, pitch; - if( forward[1] == 0 && forward[0] == 0 ) + if( forward[1] == 0.0f && forward[0] == 0.0f ) { - yaw = 0; - if( forward[2] > 0 ) - pitch = 90; + yaw = 0.0f; + if( forward[2] > 0.0f ) + pitch = 90.0f; else - pitch = 270; + pitch = 270.0f; } else { - yaw = ( atan2( forward[1], forward[0]) * 180 / M_PI ); - if( yaw < 0 ) - yaw += 360; + yaw = ( atan2( forward[1], forward[0]) * 180.0f / M_PI_F ); + if( yaw < 0.0f ) + yaw += 360.0f; tmp = sqrt( forward[0] * forward[0] + forward[1] * forward[1] ); - pitch = ( atan2( forward[2], tmp ) * 180 / M_PI ); - if( pitch < 0 ) - pitch += 360; + pitch = ( atan2( forward[2], tmp ) * 180.0f / M_PI_F ); + if( pitch < 0.0f ) + pitch += 360.0f; } angles[0] = pitch; angles[1] = yaw; - angles[2] = 0; + angles[2] = 0.0f; } float VectorNormalize( float *v ) @@ -89,7 +91,7 @@ float VectorNormalize( float *v ) if( length ) { - ilength = 1 / length; + ilength = 1.0f / length; v[0] *= ilength; v[1] *= ilength; v[2] *= ilength; diff --git a/cl_dll/util_vector.h b/cl_dll/util_vector.h index 477d97be..6d900446 100644 --- a/cl_dll/util_vector.h +++ b/cl_dll/util_vector.h @@ -16,14 +16,17 @@ // A subset of the extdll.h in the project HL Entity DLL // #pragma once -#ifndef UTIL_VECTOR_H +#if !defined(UTIL_VECTOR_H) #define UTIL_VECTOR_H // Misc C-runtime library headers -#include "stdio.h" -#include "stdlib.h" -#include "math.h" - +#include +#include +#if HAVE_CMATH +#include +#else +#include +#endif // Header file containing definition of globalvars_t and entvars_t typedef unsigned int func_t; // typedef int string_t; // from engine's pr_comp.h; diff --git a/cl_dll/vgui_ClassMenu.cpp b/cl_dll/vgui_ClassMenu.cpp new file mode 100644 index 00000000..02a0a389 --- /dev/null +++ b/cl_dll/vgui_ClassMenu.cpp @@ -0,0 +1,196 @@ +//=========== (C) Copyright 1996-2002 Valve, L.L.C. All rights reserved. =========== +// +// The copyright to the contents herein is the property of Valve, L.L.C. +// The contents may be used and/or copied only with the written permission of +// Valve, L.L.C., or in accordance with the terms and conditions stipulated in +// the agreement/contract under which the contents have been supplied. +// +// Purpose: TFC Class Menu +// +// $Workfile: $ +// $Date: $ +// +//----------------------------------------------------------------------------- +// $Log: $ +// +// $NoKeywords: $ +//============================================================================= + +#include "VGUI_Font.h" +#include + +#include "hud.h" +#include "cl_util.h" +#include "camera.h" +#include "kbutton.h" +#include "cvardef.h" +#include "usercmd.h" +#include "const.h" +#include "camera.h" +#include "in_defs.h" +#include "parsemsg.h" + +#include "vgui_int.h" +#include "vgui_TeamFortressViewport.h" + +// Class Menu Dimensions +#define CLASSMENU_TITLE_X XRES(40) +#define CLASSMENU_TITLE_Y YRES(32) +#define CLASSMENU_TOPLEFT_BUTTON_X XRES(40) +#define CLASSMENU_TOPLEFT_BUTTON_Y YRES(80) +#define CLASSMENU_BUTTON_SIZE_X XRES(124) +#define CLASSMENU_BUTTON_SIZE_Y YRES(24) +#define CLASSMENU_BUTTON_SPACER_Y YRES(8) +#define CLASSMENU_WINDOW_X XRES(176) +#define CLASSMENU_WINDOW_Y YRES(80) +#define CLASSMENU_WINDOW_SIZE_X XRES(424) +#define CLASSMENU_WINDOW_SIZE_Y YRES(312) +#define CLASSMENU_WINDOW_TEXT_X XRES(150) +#define CLASSMENU_WINDOW_TEXT_Y YRES(80) +#define CLASSMENU_WINDOW_NAME_X XRES(150) +#define CLASSMENU_WINDOW_NAME_Y YRES(8) +#define CLASSMENU_WINDOW_PLAYERS_Y YRES(42) + +// Creation +CClassMenuPanel::CClassMenuPanel( int iTrans, int iRemoveMe, int x, int y, int wide, int tall ) : CMenuPanel( iTrans, iRemoveMe, x, y, wide, tall ) +{ + // don't show class graphics at below 640x480 resolution + bool bShowClassGraphic = true; + if( ScreenWidth < 640 ) + { + bShowClassGraphic = false; + } + + memset( m_pClassImages, 0, sizeof(m_pClassImages) ); + + // Get the scheme used for the Titles + CSchemeManager *pSchemes = gViewPort->GetSchemeManager(); + + // schemes + SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle( "Title Font" ); + SchemeHandle_t hClassWindowText = pSchemes->getSchemeHandle( "Briefing Text" ); + + // color schemes + int r, g, b, a; + + // Create the title + Label *pLabel = new Label( "", CLASSMENU_TITLE_X, CLASSMENU_TITLE_Y ); + pLabel->setParent( this ); + pLabel->setFont( pSchemes->getFont( hTitleScheme ) ); + pSchemes->getFgColor( hTitleScheme, r, g, b, a ); + pLabel->setFgColor( r, g, b, a ); + pSchemes->getBgColor( hTitleScheme, r, g, b, a ); + pLabel->setBgColor( r, g, b, a ); + pLabel->setContentAlignment( vgui::Label::a_west ); + pLabel->setText(gHUD.m_TextMessage.BufferedLocaliseTextString( "#Title_SelectYourClass" ) ); + + // Create the Scroll panel + m_pScrollPanel = new CTFScrollPanel( CLASSMENU_WINDOW_X, CLASSMENU_WINDOW_Y, CLASSMENU_WINDOW_SIZE_X, CLASSMENU_WINDOW_SIZE_Y ); + m_pScrollPanel->setParent( this ); + //force the scrollbars on, so after the validate clientClip will be smaller + m_pScrollPanel->setScrollBarAutoVisible( false, false ); + m_pScrollPanel->setScrollBarVisible( true, true ); + m_pScrollPanel->setBorder( new LineBorder( Color( 255 * 0.7, 170 * 0.7, 0, 0 ) ) ); + m_pScrollPanel->validate(); + + int clientWide=m_pScrollPanel->getClient()->getWide(); + + //turn scrollpanel back into auto show scrollbar mode and validate + m_pScrollPanel->setScrollBarAutoVisible( false, true ); + m_pScrollPanel->setScrollBarVisible( false, false ); + m_pScrollPanel->validate(); + + // Create the Cancel button + m_pCancelButton = new CommandButton( gHUD.m_TextMessage.BufferedLocaliseTextString( "#Menu_Cancel" ), CLASSMENU_TOPLEFT_BUTTON_X, 0, CLASSMENU_BUTTON_SIZE_X, CLASSMENU_BUTTON_SIZE_Y ); + m_pCancelButton->setParent( this ); + m_pCancelButton->addActionSignal( new CMenuHandler_TextWindow( HIDE_TEXTWINDOW ) ); + + m_iCurrentInfo = 0; +} + +// Update +void CClassMenuPanel::Update() +{ + // Don't allow the player to join a team if they're not in a team + if( !g_iTeamNumber ) + return; + + int iYPos = CLASSMENU_TOPLEFT_BUTTON_Y; + + // If the player already has a class, make the cancel button visible + if( g_iPlayerClass ) + { + m_pCancelButton->setPos( CLASSMENU_TOPLEFT_BUTTON_X, iYPos ); + m_pCancelButton->setVisible( true ); + } + else + { + m_pCancelButton->setVisible( false ); + } +} + +//====================================== +// Key inputs for the Class Menu +bool CClassMenuPanel::SlotInput( int iSlot ) +{ + if( ( iSlot < 0 ) || ( iSlot > 9 ) ) + return false; + + if( !m_pButtons[iSlot] ) + return false; + + // Is the button pushable? (0 is special case) + if( iSlot == 0 ) + { + // Selects Civilian and RandomPC + if( gViewPort->GetValidClasses( g_iTeamNumber ) == -1 ) + { + m_pButtons[0]->fireActionSignal(); + return true; + } + + // Select RandomPC + iSlot = 10; + } + + if( !( m_pButtons[iSlot]->IsNotValid() ) ) + { + m_pButtons[iSlot]->fireActionSignal(); + return true; + } + + return false; +} + +//====================================== +// Update the Class menu before opening it +void CClassMenuPanel::Open( void ) +{ + Update(); + CMenuPanel::Open(); +} + +//----------------------------------------------------------------------------- +// Purpose: Called each time a new level is started. +//----------------------------------------------------------------------------- +void CClassMenuPanel::Initialize( void ) +{ + setVisible( false ); + m_pScrollPanel->setScrollValue( 0, 0 ); +} + +//====================================== +// Mouse is over a class button, bring up the class info +void CClassMenuPanel::SetActiveInfo( int iInput ) +{ + // Remove all the Info panels and bring up the specified one + iInput = 0; + + m_pButtons[iInput]->setArmed( true ); + m_pClassInfoPanel[iInput]->setVisible( true ); + m_iCurrentInfo = iInput; + + m_pScrollPanel->setScrollValue( 0, 0 ); + m_pScrollPanel->validate(); +} + diff --git a/cl_dll/vgui_ConsolePanel.cpp b/cl_dll/vgui_ConsolePanel.cpp new file mode 100644 index 00000000..ca33636a --- /dev/null +++ b/cl_dll/vgui_ConsolePanel.cpp @@ -0,0 +1,97 @@ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#include "vgui_ConsolePanel.h" +#include "hud.h" +#include +#include +#include +#include +#include + +using namespace vgui; + +namespace +{ + +class Handler : public ActionSignal +{ +private: + + ConsolePanel *_consolePanel; + +public: + + Handler( ConsolePanel *consolePanel ) + { + _consolePanel = consolePanel; + } + +public: + + virtual void actionPerformed( Panel *panel ) + { + _consolePanel->doExecCommand(); + } +}; + +} + +ConsolePanel::ConsolePanel( int x, int y, int wide, int tall ) : Panel( x, y, wide, tall ) +{ + setBorder( new EtchedBorder() ); + + _textGrid = new TextGrid( 80, 21, 5, 5, 200, 100 ); + _textGrid->setBorder( new LoweredBorder() ); + _textGrid->setParent( this ); + + _textEntry=new TextEntry( "", 5, 5, 200, 20 ); + _textEntry->setParent( this ); + _textEntry->addActionSignal( new Handler( this ) ); +} + +int ConsolePanel::print( const char *text ) +{ + return _textGrid->printf( "%s", text ); +} + +int ConsolePanel::vprintf( const char *format, va_list argList ) +{ + return _textGrid->vprintf( format, argList ); +} + +int ConsolePanel::printf( const char* format, ... ) +{ + va_list argList; + va_start( argList, format ); + int ret = vprintf( format, argList ); + va_end( argList ); + return ret; +} + +void ConsolePanel::doExecCommand() +{ + char buf[2048]; + _textEntry->getText( 0, buf, sizeof buf ); + _textEntry->setText( null, 0 ); + gEngfuncs.pfnClientCmd( buf ); +} + +void ConsolePanel::setSize( int wide, int tall ) +{ + Panel::setSize( wide, tall ); + + getPaintSize( wide, tall ); + + _textGrid->setBounds( 5, 5, wide - 10, tall - 35 ); + _textEntry->setBounds( 5, tall - 25, wide - 10, 20 ); +} + + + + + diff --git a/cl_dll/vgui_ConsolePanel.h b/cl_dll/vgui_ConsolePanel.h new file mode 100644 index 00000000..cc255a73 --- /dev/null +++ b/cl_dll/vgui_ConsolePanel.h @@ -0,0 +1,37 @@ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef CONSOLEPANEL_H +#define CONSOLEPANEL_H + +#include +#include + +namespace vgui +{ + class TextGrid; + class TextEntry; +} + +class ConsolePanel : public vgui::Panel +{ +private: + vgui::TextGrid *_textGrid; + vgui::TextEntry *_textEntry; +public: + ConsolePanel( int x, int y, int wide, int tall ); +public: + virtual void setSize( int wide, int tall ); + virtual int print( const char *text ); + virtual int vprintf( const char *format, va_list argList ); + virtual int printf( const char *format, ... ); + virtual void doExecCommand(); +}; + + + +#endif diff --git a/cl_dll/vgui_ControlConfigPanel.cpp b/cl_dll/vgui_ControlConfigPanel.cpp new file mode 100644 index 00000000..dbef1a3f --- /dev/null +++ b/cl_dll/vgui_ControlConfigPanel.cpp @@ -0,0 +1,216 @@ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#include +#include "vgui_ControlConfigPanel.h" +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace vgui; + +namespace +{ +class FooTablePanel : public TablePanel +{ +private: + Label *_label; + TextEntry *_textEntry; + ControlConfigPanel *_controlConfigPanel; +public: + FooTablePanel( ControlConfigPanel *controlConfigPanel, int x, int y, int wide, int tall, int columnCount ) : TablePanel( x, y, wide, tall, columnCount ) + { + _controlConfigPanel = controlConfigPanel; + _label = new Label( "You are a dumb monkey", 0, 0, 100, 20 ); + _label->setBgColor( Scheme::sc_primary3 ); + _label->setFgColor( Scheme::sc_primary1 ); + _label->setFont( Scheme::sf_primary3 ); + + _textEntry=new TextEntry( "", 0, 0, 100, 20 ); + // _textEntry->setFont( Scheme::sf_primary3 ); + } +public: + virtual int getRowCount() + { + return _controlConfigPanel->GetCVarCount(); + } + + virtual int getCellTall( int row ) + { + return 12; + } + + virtual Panel *getCellRenderer( int column, int row,bool columnSelected, bool rowSelected, bool cellSelected ) + { + char cvar[128], desc[128], bind[128], bindAlt[128]; + _controlConfigPanel->GetCVar( row, cvar, 128, desc, 128 ); + + if( cellSelected ) + { + _label->setBgColor( Scheme::sc_primary1 ); + _label->setFgColor( Scheme::sc_primary3 ); + } + else if( rowSelected ) + { + _label->setBgColor( Scheme::sc_primary2 ); + _label->setFgColor( Scheme::sc_primary1 ); + } + else + { + _label->setBgColor( Scheme::sc_primary3 ); + _label->setFgColor( Scheme::sc_primary1 ); + } + + switch( column ) + { + case 0: + { + _label->setText( desc ); + _label->setContentAlignment( Label::a_west ); + break; + } + case 1: + { + _controlConfigPanel->GetCVarBind( cvar, bind, 128, bindAlt, 128 ); + _label->setText( bind ); + _label->setContentAlignment( Label::a_center ); + break; + } + case 2: + { + _controlConfigPanel->GetCVarBind( cvar, bind, 128, bindAlt, 128 ); + _label->setText( bindAlt ); + _label->setContentAlignment( Label::a_center ); + break; + } + default: + { + _label->setText( "" ); + break; + } + } + + return _label; + } + virtual Panel *startCellEditing( int column, int row ) + { + _textEntry->setText( "Goat", strlen( "Goat" ) ); + _textEntry->requestFocus(); + return _textEntry; + } +}; +} + +ControlConfigPanel::ControlConfigPanel( int x, int y, int wide, int tall ) : Panel( x, y, wide, tall ) +{ + setPaintBorderEnabled( false ); + setPaintBackgroundEnabled( false ); + setPaintEnabled( false ); + + _actionLabel = new Label( "Action" ); + _actionLabel->setBgColor( Scheme::sc_primary3 ); + _actionLabel->setFgColor( Scheme::sc_primary3 ); + + _keyButtonLabel = new Label( "Key / Button" ); + _keyButtonLabel->setBgColor( Scheme::sc_primary3 ); + _keyButtonLabel->setFgColor( Scheme::sc_primary3 ); + + _alternateLabel = new Label( "Alternate" ); + _alternateLabel->setBgColor( Scheme::sc_primary3 ); + _alternateLabel->setFgColor( Scheme::sc_primary3 ); + + _headerPanel=new HeaderPanel( 0, 0, wide, 20 ); + _headerPanel->setParent( this ); + + _headerPanel->addSectionPanel( _actionLabel ); + _headerPanel->addSectionPanel( _keyButtonLabel ); + _headerPanel->addSectionPanel( _alternateLabel ); + + _headerPanel->setSliderPos( 0, wide / 2 ); + _headerPanel->setSliderPos( 1, ( wide / 2 ) + ( wide / 4 ) ); + _headerPanel->setSliderPos( 2, wide ); + + _scrollPanel=new ScrollPanel( 0, 20, wide, tall - 20 ); + _scrollPanel->setParent( this ); + _scrollPanel->setPaintBorderEnabled( false ); + _scrollPanel->setPaintBackgroundEnabled( false ); + _scrollPanel->setPaintEnabled( false ); + _scrollPanel->getClient()->setPaintBorderEnabled( false ); + _scrollPanel->getClient()->setPaintBackgroundEnabled( false ); + _scrollPanel->getClient()->setPaintEnabled( false ); + _scrollPanel->setScrollBarVisible( false, true ); + + _tablePanel = new FooTablePanel( this, 0, 0, _scrollPanel->getClient()->getWide(), 800, 3 ); + _tablePanel->setParent( _scrollPanel->getClient() ); + _tablePanel->setHeaderPanel( _headerPanel ); + _tablePanel->setBgColor( Color( 200, 0, 0, 255 ) ); + _tablePanel->setFgColor( Color( Scheme::sc_primary2 ) ); + _tablePanel->setGridVisible( true, true ); + _tablePanel->setGridSize( 1, 1 ); +} + +void ControlConfigPanel::AddCVar( const char *cvar, const char *desc ) +{ + _cvarDar.addElement( vgui_strdup( cvar ) ); + _descDar.addElement( vgui_strdup( desc ) ); +} + +int ControlConfigPanel::GetCVarCount() +{ + return _cvarDar.getCount(); +} + +void ControlConfigPanel::GetCVar( int index, char *cvar, int cvarLen, char *desc, int descLen ) +{ + vgui_strcpy( cvar, cvarLen, _cvarDar[index] ); + vgui_strcpy( desc, descLen, _descDar[index] ); +} + +void ControlConfigPanel::AddCVarFromInputStream( InputStream *is ) +{ + if( is == null ) + { + return; + } + + DataInputStream dis( is ); + + bool success; + + while( 1 ) + { + char buf[256], cvar[128], desc[128]; + + dis.readLine( buf, 256, success ); + + if( !success ) + { + break; + } + + if( sscanf( buf, "\"%[^\"]\" \"%[^\"]\"", cvar, desc ) == 2 ) + { + AddCVar( cvar, desc ); + } + } +} + +void ControlConfigPanel::GetCVarBind( const char *cvar, char *bind, int bindLen, char *bindAlt, int bindAltLen ) +{ + sprintf( bind,"%s : Bind", cvar ); + sprintf( bindAlt,"%s : BindAlt", cvar ); +} + +void ControlConfigPanel::SetCVarBind( const char *cvar, const char *bind, const char *bindAlt ) +{ +} + diff --git a/cl_dll/vgui_ControlConfigPanel.h b/cl_dll/vgui_ControlConfigPanel.h new file mode 100644 index 00000000..963adb14 --- /dev/null +++ b/cl_dll/vgui_ControlConfigPanel.h @@ -0,0 +1,43 @@ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef CONTROLCONFIGPANEL_H +#define CONTROLCONFIGPANEL_H + +#include +#include + +namespace vgui +{ + class HeaderPanel; + class TablePanel; + class ScrollPanel; + class InputStream; + class Label; +} + +class ControlConfigPanel : public vgui::Panel +{ +private: + vgui::HeaderPanel *_headerPanel; + vgui::TablePanel *_tablePanel; + vgui::ScrollPanel *_scrollPanel; + vgui::Dar _cvarDar; + vgui::Dar _descDar; + vgui::Label *_actionLabel; + vgui::Label *_keyButtonLabel; + vgui::Label *_alternateLabel; +public: + ControlConfigPanel( int x, int y, int wide, int tall ); + void AddCVar( const char *cvar, const char *desc ); + void AddCVarFromInputStream( vgui::InputStream *is ); + int GetCVarCount(); + void GetCVar( int index, char *cvar, int cvarLen, char *desc, int descLen ); + void GetCVarBind( const char *cvar, char *bind, int bindLen, char *bindAlt, int bindAltLen ); + void SetCVarBind( const char *cvar, const char *bind, const char *bindAlt ); +}; +#endif diff --git a/cl_dll/vgui_CustomObjects.cpp b/cl_dll/vgui_CustomObjects.cpp new file mode 100644 index 00000000..d14e59bc --- /dev/null +++ b/cl_dll/vgui_CustomObjects.cpp @@ -0,0 +1,540 @@ +//=========== (C) Copyright 1996-2002 Valve, L.L.C. All rights reserved. =========== +// +// The copyright to the contents herein is the property of Valve, L.L.C. +// The contents may be used and/or copied only with the written permission of +// Valve, L.L.C., or in accordance with the terms and conditions stipulated in +// the agreement/contract under which the contents have been supplied. +// +// Purpose: Contains implementation of various VGUI-derived objects +// +// $Workfile: $ +// $Date: $ +// +//----------------------------------------------------------------------------- +// $Log: $ +// +// $NoKeywords: $ +//============================================================================= + +#include "VGUI_Font.h" + +#include "hud.h" +#include "cl_util.h" +#include "camera.h" +#include "kbutton.h" +#include "cvardef.h" +#include "usercmd.h" +#include "const.h" +#include "camera.h" +#include "in_defs.h" +#include "parsemsg.h" + +#include "vgui_int.h" +#include "vgui_TeamFortressViewport.h" +#include "vgui_loadtga.h" + +// Arrow filenames +const char *sArrowFilenames[] = +{ + "arrowup", + "arrowdn", + "arrowlt", + "arrowrt", +}; + +// Get the name of TGA file, without a gamedir +char *GetTGANameForRes( const char *pszName ) +{ + int i; + char sz[256]; + static char gd[256]; + + if( ScreenWidth < 640 ) + i = 320; + else + i = 640; + + sprintf( sz, pszName, i ); + sprintf( gd, "gfx/vgui/%s.tga", sz ); + return gd; +} + +//----------------------------------------------------------------------------- +// Purpose: Loads a .tga file and returns a pointer to the VGUI tga object +//----------------------------------------------------------------------------- +BitmapTGA *LoadTGAForRes( const char* pImageName ) +{ + BitmapTGA *pTGA; + char sz[256]; + + sprintf( sz, "%%d_%s", pImageName ); + pTGA = vgui_LoadTGA( GetTGANameForRes( sz ) ); + + return pTGA; +} + +//=========================================================== +// All TFC Hud buttons are derived from this one. +CommandButton::CommandButton( const char *text, int x, int y, int wide, int tall, bool bNoHighlight ) : Button( "", x, y, wide, tall ) +{ + m_iPlayerClass = 0; + m_bNoHighlight = bNoHighlight; + m_bFlat = false; + Init(); + setText( text ); +} + +CommandButton::CommandButton( int iPlayerClass, const char *text, int x, int y, int wide, int tall, bool bFlat ) : Button( "", x, y, wide, tall ) +{ + m_iPlayerClass = iPlayerClass; + m_bNoHighlight = false; + m_bFlat = bFlat; + Init(); + setText( text ); +} + +CommandButton::CommandButton( const char *text, int x, int y, int wide, int tall, bool bNoHighlight, bool bFlat ) : Button( "", x, y, wide, tall ) +{ + m_iPlayerClass = 0; + m_bFlat = bFlat; + m_bNoHighlight = bNoHighlight; + Init(); + setText( text ); +} + +void CommandButton::Init( void ) +{ + m_pSubMenu = NULL; + m_pSubLabel = NULL; + m_pParentMenu = NULL; + + // Set text color to orange + setFgColor( Scheme::sc_primary1 ); + + // left align + setContentAlignment( vgui::Label::a_west ); + + // Add the Highlight signal + if( !m_bNoHighlight ) + addInputSignal( new CHandler_CommandButtonHighlight( this ) ); + + // not bound to any button yet + m_cBoundKey = 0; +} + +//----------------------------------------------------------------------------- +// Purpose: Prepends the button text with the current bound key +// if no bound key, then a clear space ' ' instead +//----------------------------------------------------------------------------- +void CommandButton::RecalculateText( void ) +{ + char szBuf[128]; + + if( m_cBoundKey != 0 ) + { + if( m_cBoundKey == (char)255 ) + { + strcpy( szBuf, m_sMainText ); + } + else + { + sprintf( szBuf, " %c %s", m_cBoundKey, m_sMainText ); + } + szBuf[MAX_BUTTON_SIZE-1] = 0; + } + else + { + // just draw a space if no key bound + sprintf( szBuf, " %s", m_sMainText ); + szBuf[MAX_BUTTON_SIZE - 1] = 0; + } + + Button::setText( szBuf ); +} + +void CommandButton::setText( const char *text ) +{ + strncpy( m_sMainText, text, MAX_BUTTON_SIZE - 1 ); + m_sMainText[MAX_BUTTON_SIZE - 1] = 0; + + RecalculateText(); +} + +void CommandButton::setBoundKey( char boundKey ) +{ + m_cBoundKey = boundKey; + RecalculateText(); +} + +char CommandButton::getBoundKey( void ) +{ + return m_cBoundKey; +} + +void CommandButton::AddSubMenu( CCommandMenu *pNewMenu ) +{ + m_pSubMenu = pNewMenu; + + // Prevent this button from being pushed + setMouseClickEnabled( MOUSE_LEFT, false ); +} + +void CommandButton::UpdateSubMenus( int iAdjustment ) +{ + if( m_pSubMenu ) + m_pSubMenu->RecalculatePositions( iAdjustment ); +} + +void CommandButton::paint() +{ + // Make the sub label paint the same as the button + if( m_pSubLabel ) + { + if( isSelected() ) + m_pSubLabel->PushDown(); + else + m_pSubLabel->PushUp(); + } + + // draw armed button text in white + if( isArmed() ) + { + setFgColor( Scheme::sc_secondary2 ); + } + else + { + setFgColor( Scheme::sc_primary1 ); + } + + Button::paint(); +} + +void CommandButton::paintBackground() +{ + if( m_bFlat ) + { + if( isArmed() ) + { + // Orange Border + drawSetColor( Scheme::sc_secondary1 ); + drawOutlinedRect( 0, 0, _size[0], _size[1] ); + } + } + else + { + if( isArmed() ) + { + // Orange highlight background + drawSetColor( Scheme::sc_primary2 ); + drawFilledRect( 0, 0, _size[0], _size[1] ); + } + + // Orange Border + drawSetColor( Scheme::sc_secondary1 ); + drawOutlinedRect( 0, 0, _size[0], _size[1] ); + } +} + +//----------------------------------------------------------------------------- +// Purpose: Highlights the current button, and all it's parent menus +//----------------------------------------------------------------------------- +void CommandButton::cursorEntered( void ) +{ + // unarm all the other buttons in this menu + CCommandMenu *containingMenu = getParentMenu(); + if( containingMenu ) + { + containingMenu->ClearButtonsOfArmedState(); + + // make all our higher buttons armed + CCommandMenu *pCParent = containingMenu->GetParentMenu(); + if( pCParent ) + { + CommandButton *pParentButton = pCParent->FindButtonWithSubmenu( containingMenu ); + + pParentButton->cursorEntered(); + } + } + + // arm ourselves + setArmed( true ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CommandButton::cursorExited( void ) +{ + // only clear ourselves if we have do not have a containing menu + // only stay armed if we have a sub menu + // the buttons only unarm themselves when another button is armed instead + if( !getParentMenu() || !GetSubMenu() ) + { + setArmed( false ); + } +} + +//----------------------------------------------------------------------------- +// Purpose: Returns the command menu that the button is part of, if any +// Output : CCommandMenu * +//----------------------------------------------------------------------------- +CCommandMenu *CommandButton::getParentMenu( void ) +{ + return m_pParentMenu; +} + +//----------------------------------------------------------------------------- +// Purpose: Sets the menu that contains this button +// Input : *pParentMenu - +//----------------------------------------------------------------------------- +void CommandButton::setParentMenu( CCommandMenu *pParentMenu ) +{ + m_pParentMenu = pParentMenu; +} + +//=========================================================== +int ClassButton::IsNotValid() +{ + // If this is the main ChangeClass button, remove it if the player's only able to be civilians + if( m_iPlayerClass == -1 ) + { + if( gViewPort->GetValidClasses( g_iTeamNumber ) == -1 ) + return true; + + return false; + } + + // Only check current class if they've got autokill on + bool bAutoKill = CVAR_GET_FLOAT( "hud_classautokill" ) != 0; + if( bAutoKill ) + { + // Is it the player's current class? + if ( + (!gViewPort->IsRandomPC() && (m_iPlayerClass == g_iPlayerClass)) ) + return true; + } + + return false; +} + +//=========================================================== +// Button with Class image beneath it +CImageLabel::CImageLabel( const char *pImageName,int x,int y ) : Label( "", x, y ) +{ + setContentFitted( true ); + m_pTGA = LoadTGAForRes( pImageName ); + setImage( m_pTGA ); +} + +CImageLabel::CImageLabel( const char *pImageName, int x, int y, int wide, int tall ) : Label( "", x, y, wide, tall ) +{ + setContentFitted( true ); + m_pTGA = LoadTGAForRes( pImageName ); + setImage( m_pTGA ); +} + +//=========================================================== +// Image size +int CImageLabel::getImageWide( void ) +{ + if( m_pTGA ) + { + int iXSize, iYSize; + + m_pTGA->getSize( iXSize, iYSize ); + + return iXSize; + } + else + { + return 1; + } +} + +int CImageLabel::getImageTall( void ) +{ + if( m_pTGA ) + { + int iXSize, iYSize; + + m_pTGA->getSize( iXSize, iYSize ); + + return iYSize; + } + else + { + return 1; + } +} + +void CImageLabel::LoadImage( const char *pImageName ) +{ + if( m_pTGA ) + delete m_pTGA; + + // Load the Image + m_pTGA = LoadTGAForRes( pImageName ); + + if( m_pTGA == NULL ) + { + // we didn't find a matching image file for this resolution + // try to load file resolution independent + char sz[256]; + + sprintf( sz, "%s/%s", gEngfuncs.pfnGetGameDirectory(), pImageName ); + FileInputStream fis( sz, false ); + m_pTGA = new BitmapTGA( &fis, true ); + fis.close(); + } + + if( m_pTGA == NULL ) + return; // unable to load image + + int w,t; + + m_pTGA->getSize( w, t ); + + setSize( XRES ( w ),YRES ( t) ); + setImage( m_pTGA ); +} + +//=========================================================== +// Various overloaded paint functions for Custom VGUI objects +void CCommandMenu::paintBackground() +{ + // Transparent black background + + if( m_iSpectCmdMenu ) + drawSetColor( 0, 0, 0, 64 ); + else + drawSetColor( Scheme::sc_primary3 ); + + drawFilledRect( 0, 0, _size[0], _size[1] ); +} + +//================================================================================= +// CUSTOM SCROLLPANEL +//================================================================================= +CTFScrollButton::CTFScrollButton( int iArrow, const char *text, int x, int y, int wide, int tall ) : CommandButton( text, x, y, wide, tall ) +{ + // Set text color to orange + setFgColor( Scheme::sc_primary1 ); + + // Load in the arrow + m_pTGA = LoadTGAForRes( sArrowFilenames[iArrow] ); + setImage( m_pTGA ); + + // Highlight signal + InputSignal *pISignal = new CHandler_CommandButtonHighlight( this ); + addInputSignal( pISignal ); +} + +void CTFScrollButton::paint( void ) +{ + if( !m_pTGA ) + return; + + // draw armed button text in white + if( isArmed() ) + { + m_pTGA->setColor( Color( 255, 255, 255, 0 ) ); + } + else + { + m_pTGA->setColor( Color( 255, 255, 255, 128 ) ); + } + + m_pTGA->doPaint( this ); +} + +void CTFScrollButton::paintBackground( void ) +{ +/* + if( isArmed() ) + { + // Orange highlight background + drawSetColor( Scheme::sc_primary2 ); + drawFilledRect( 0, 0, _size[0], _size[1] ); + } + + // Orange Border + drawSetColor( Scheme::sc_secondary1 ); + drawOutlinedRect( 0, 0, _size[0] - 1, _size[1] ); +*/ +} + +void CTFSlider::paintBackground( void ) +{ + int wide, tall, nobx, noby; + + getPaintSize( wide, tall ); + getNobPos( nobx, noby ); + + // Border + drawSetColor( Scheme::sc_secondary1 ); + drawOutlinedRect( 0, 0, wide, tall ); + + if( isVertical() ) + { + // Nob Fill + drawSetColor( Scheme::sc_primary2 ); + drawFilledRect( 0, nobx, wide, noby ); + + // Nob Outline + drawSetColor( Scheme::sc_primary1 ); + drawOutlinedRect( 0, nobx, wide, noby ); + } + else + { + // Nob Fill + drawSetColor( Scheme::sc_primary2 ); + drawFilledRect( nobx, 0, noby, tall ); + + // Nob Outline + drawSetColor( Scheme::sc_primary1 ); + drawOutlinedRect( nobx, 0, noby, tall ); + } +} + +CTFScrollPanel::CTFScrollPanel( int x, int y, int wide, int tall ) : ScrollPanel( x, y, wide, tall ) +{ + ScrollBar *pScrollBar = getVerticalScrollBar(); + pScrollBar->setButton( new CTFScrollButton( ARROW_UP, "", 0, 0, 16, 16 ), 0 ); + pScrollBar->setButton( new CTFScrollButton( ARROW_DOWN, "", 0, 0, 16, 16 ), 1 ); + pScrollBar->setSlider( new CTFSlider( 0, wide - 1, wide, ( tall - ( wide * 2 ) ) + 2, true ) ); + pScrollBar->setPaintBorderEnabled( false ); + pScrollBar->setPaintBackgroundEnabled( false ); + pScrollBar->setPaintEnabled( false ); + + pScrollBar = getHorizontalScrollBar(); + pScrollBar->setButton( new CTFScrollButton( ARROW_LEFT, "", 0, 0, 16, 16 ), 0 ); + pScrollBar->setButton( new CTFScrollButton( ARROW_RIGHT, "", 0, 0, 16, 16 ), 1 ); + pScrollBar->setSlider( new CTFSlider( tall, 0, wide - ( tall * 2 ), tall, false ) ); + pScrollBar->setPaintBorderEnabled( false ); + pScrollBar->setPaintBackgroundEnabled( false ); + pScrollBar->setPaintEnabled( false ); +} + +//================================================================================= +// CUSTOM HANDLERS +//================================================================================= +void CHandler_MenuButtonOver::cursorEntered(Panel *panel) +{ + if( gViewPort && m_pMenuPanel ) + { + m_pMenuPanel->SetActiveInfo( m_iButton ); + } +} + +void CMenuHandler_StringCommandClassSelect::actionPerformed( Panel *panel ) +{ + CMenuHandler_StringCommand::actionPerformed( panel ); + + // THIS IS NOW BEING DONE ON THE TFC SERVER TO AVOID KILLING SOMEONE THEN + // HAVE THE SERVER SAY "SORRY...YOU CAN'T BE THAT CLASS". + + bool bAutoKill = CVAR_GET_FLOAT( "hud_classautokill" ) != 0; + if( bAutoKill && g_iPlayerClass != 0 ) + gEngfuncs.pfnClientCmd( "kill" ); +} + diff --git a/cl_dll/vgui_MOTDWindow.cpp b/cl_dll/vgui_MOTDWindow.cpp new file mode 100644 index 00000000..d5715b92 --- /dev/null +++ b/cl_dll/vgui_MOTDWindow.cpp @@ -0,0 +1,151 @@ +//=========== (C) Copyright 1996-2002 Valve, L.L.C. All rights reserved. =========== +// +// The copyright to the contents herein is the property of Valve, L.L.C. +// The contents may be used and/or copied only with the written permission of +// Valve, L.L.C., or in accordance with the terms and conditions stipulated in +// the agreement/contract under which the contents have been supplied. +// +// Purpose: +// +// $Workfile: $ +// $Date: $ +// +//----------------------------------------------------------------------------- +// $Log: $ +// +// $NoKeywords: $ +//============================================================================= + +#include "VGUI_Font.h" +#include "VGUI_ScrollPanel.h" +#include "VGUI_TextImage.h" + +#include + +#include "hud.h" +#include "cl_util.h" +#include "camera.h" +#include "kbutton.h" +#include "const.h" + +#include "vgui_int.h" +#include "vgui_TeamFortressViewport.h" + +#define MOTD_TITLE_X XRES(16) +#define MOTD_TITLE_Y YRES(16) + +#define MOTD_WINDOW_X XRES(112) +#define MOTD_WINDOW_Y YRES(80) +#define MOTD_WINDOW_SIZE_X XRES(424) +#define MOTD_WINDOW_SIZE_Y YRES(312) + +//----------------------------------------------------------------------------- +// Purpose: Displays the MOTD and basic server information +//----------------------------------------------------------------------------- +class CMessageWindowPanel : public CMenuPanel +{ +public: + CMessageWindowPanel( const char *szMOTD, const char *szTitle, int iShadeFullScreen, int iRemoveMe, int x, int y, int wide, int tall ); + +private: + CTransparentPanel *m_pBackgroundPanel; +}; + +//----------------------------------------------------------------------------- +// Purpose: Creates a new CMessageWindowPanel +// Output : CMenuPanel - interface to the panel +//----------------------------------------------------------------------------- +CMenuPanel *CMessageWindowPanel_Create( const char *szMOTD, const char *szTitle, int iShadeFullscreen, int iRemoveMe, int x, int y, int wide, int tall ) +{ + return new CMessageWindowPanel( szMOTD, szTitle, iShadeFullscreen, iRemoveMe, x, y, wide, tall ); +} + +//----------------------------------------------------------------------------- +// Purpose: Constructs a message panel +//----------------------------------------------------------------------------- +CMessageWindowPanel::CMessageWindowPanel( const char *szMOTD, const char *szTitle, int iShadeFullscreen, int iRemoveMe, int x, int y, int wide, int tall ) : CMenuPanel( iShadeFullscreen ? 100 : 255, iRemoveMe, x, y, wide, tall ) +{ + // Get the scheme used for the Titles + CSchemeManager *pSchemes = gViewPort->GetSchemeManager(); + + // schemes + SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle( "Title Font" ); + SchemeHandle_t hMOTDText = pSchemes->getSchemeHandle( "Briefing Text" ); + + // color schemes + int r, g, b, a; + + // Create the window + m_pBackgroundPanel = new CTransparentPanel( iShadeFullscreen ? 255 : 100, MOTD_WINDOW_X, MOTD_WINDOW_Y, MOTD_WINDOW_SIZE_X, MOTD_WINDOW_SIZE_Y ); + m_pBackgroundPanel->setParent( this ); + m_pBackgroundPanel->setBorder( new LineBorder( Color( 255 * 0.7, 170 * 0.7, 0, 0 ) ) ); + m_pBackgroundPanel->setVisible( true ); + + int iXSize,iYSize,iXPos,iYPos; + m_pBackgroundPanel->getPos( iXPos, iYPos ); + m_pBackgroundPanel->getSize( iXSize, iYSize ); + + // Create the title + Label *pLabel = new Label( "", iXPos + MOTD_TITLE_X, iYPos + MOTD_TITLE_Y ); + pLabel->setParent( this ); + pLabel->setFont( pSchemes->getFont( hTitleScheme ) ); + pLabel->setFont( Scheme::sf_primary1 ); + + pSchemes->getFgColor( hTitleScheme, r, g, b, a ); + pLabel->setFgColor( r, g, b, a ); + pLabel->setFgColor( Scheme::sc_primary1 ); + pSchemes->getBgColor( hTitleScheme, r, g, b, a ); + pLabel->setBgColor( r, g, b, a ); + pLabel->setContentAlignment( vgui::Label::a_west ); + pLabel->setText( "%s", szTitle); + + // Create the Scroll panel + ScrollPanel *pScrollPanel = new CTFScrollPanel( iXPos + XRES( 16 ), iYPos + MOTD_TITLE_Y * 2 + YRES( 16 ), iXSize - XRES( 32 ), iYSize - ( YRES( 48 ) + BUTTON_SIZE_Y * 2 ) ); + pScrollPanel->setParent( this ); + + // force the scrollbars on so clientClip will take them in account after the validate + pScrollPanel->setScrollBarAutoVisible( false, false ); + pScrollPanel->setScrollBarVisible( true, true ); + pScrollPanel->validate(); + + // Create the text panel + TextPanel *pText = new TextPanel( "", 0, 0, 64, 64 ); + pText->setParent( pScrollPanel->getClient() ); + + // get the font and colors from the scheme + pText->setFont( pSchemes->getFont( hMOTDText ) ); + pSchemes->getFgColor( hMOTDText, r, g, b, a ); + pText->setFgColor( r, g, b, a ); + pSchemes->getBgColor( hMOTDText, r, g, b, a ); + pText->setBgColor( r, g, b, a ); + pText->setText( szMOTD ); + + // Get the total size of the MOTD text and resize the text panel + int iScrollSizeX, iScrollSizeY; + + // First, set the size so that the client's wdith is correct at least because the + // width is critical for getting the "wrapped" size right. + // You'll see a horizontal scroll bar if there is a single word that won't wrap in the + // specified width. + pText->getTextImage()->setSize( pScrollPanel->getClientClip()->getWide(), pScrollPanel->getClientClip()->getTall() ); + pText->getTextImage()->getTextSizeWrapped( iScrollSizeX, iScrollSizeY ); + + // Now resize the textpanel to fit the scrolled size + pText->setSize( iScrollSizeX, iScrollSizeY ); + + //turn the scrollbars back into automode + pScrollPanel->setScrollBarAutoVisible( true, true ); + pScrollPanel->setScrollBarVisible( false, false ); + + pScrollPanel->validate(); + + CommandButton *pButton = new CommandButton( CHudTextMessage::BufferedLocaliseTextString( "#Menu_OK" ), iXPos + XRES( 16 ), iYPos + iYSize - YRES( 16 ) - BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y ); + pButton->addActionSignal( new CMenuHandler_TextWindow( HIDE_TEXTWINDOW ) ); + pButton->setParent( this ); +} + + + + + + diff --git a/cl_dll/vgui_SchemeManager.cpp b/cl_dll/vgui_SchemeManager.cpp new file mode 100644 index 00000000..e50e5b73 --- /dev/null +++ b/cl_dll/vgui_SchemeManager.cpp @@ -0,0 +1,556 @@ +//=========== (C) Copyright 1996-2002 Valve, L.L.C. All rights reserved. =========== +// +// The copyright to the contents herein is the property of Valve, L.L.C. +// The contents may be used and/or copied only with the written permission of +// Valve, L.L.C., or in accordance with the terms and conditions stipulated in +// the agreement/contract under which the contents have been supplied. +// +// Purpose: +// +// $Workfile: $ +// $Date: $ +// +//----------------------------------------------------------------------------- +// $Log: $ +// +// $NoKeywords: $ +//============================================================================= + +#include "hud.h" +#include "vgui_SchemeManager.h" +#include "cvardef.h" + +#include + + +cvar_t *g_CV_BitmapFonts; + + +void Scheme_Init() +{ + g_CV_BitmapFonts = gEngfuncs.pfnRegisterVariable("bitmapfonts", "1", 0); +} + + + +//----------------------------------------------------------------------------- +// Purpose: Scheme managers data container +//----------------------------------------------------------------------------- +class CSchemeManager::CScheme +{ +public: + enum { + SCHEME_NAME_LENGTH = 32, + FONT_NAME_LENGTH = 48, + FONT_FILENAME_LENGTH = 64, + }; + + // name + char schemeName[SCHEME_NAME_LENGTH]; + + // font + char fontName[FONT_NAME_LENGTH]; + + int fontSize; + int fontWeight; + + vgui::Font *font; + int ownFontPointer; // true if the font is ours to delete + + // scheme + byte fgColor[4]; + byte bgColor[4]; + byte armedFgColor[4]; + byte armedBgColor[4]; + byte mousedownFgColor[4]; + byte mousedownBgColor[4]; + byte borderColor[4]; + + // construction/destruction + CScheme(); + ~CScheme(); +}; + +CSchemeManager::CScheme::CScheme() +{ + schemeName[0] = 0; + fontName[0] = 0; + fontSize = 0; + fontWeight = 0; + font = NULL; + ownFontPointer = false; +} + +CSchemeManager::CScheme::~CScheme() +{ + // only delete our font pointer if we own it + if ( ownFontPointer ) + { + delete font; + } +} + +//----------------------------------------------------------------------------- +// Purpose: resolution information +// !! needs to be shared out +//----------------------------------------------------------------------------- +static int g_ResArray[] = +{ + 320, + 400, + 512, + 640, + 800, + 1024, + 1152, + 1280, + 1600 +}; +static int g_NumReses = sizeof(g_ResArray) / sizeof(int); + +static byte *LoadFileByResolution( const char *filePrefix, int xRes, const char *filePostfix ) +{ + // find our resolution in the res array + int resNum = g_NumReses - 1; + while ( g_ResArray[resNum] > xRes ) + { + resNum--; + + if ( resNum < 0 ) + return NULL; + } + + // try open the file + byte *pFile = NULL; + while ( 1 ) + { + + // try load + char fname[256]; + sprintf( fname, "%s%d%s", filePrefix, g_ResArray[resNum], filePostfix ); + pFile = gEngfuncs.COM_LoadFile( fname, 5, NULL ); + + if ( pFile ) + break; + + if ( resNum == 0 ) + return NULL; + + resNum--; + }; + + return pFile; +} + +static void ParseRGBAFromString( byte colorArray[4], const char *colorVector ) +{ + int r, g, b, a; + sscanf( colorVector, "%d %d %d %d", &r, &g, &b, &a ); + colorArray[0] = r; + colorArray[1] = g; + colorArray[2] = b; + colorArray[3] = a; +} + +//----------------------------------------------------------------------------- +// Purpose: initializes the scheme manager +// loading the scheme files for the current resolution +// Input : xRes - +// yRes - dimensions of output window +//----------------------------------------------------------------------------- +CSchemeManager::CSchemeManager( int xRes, int yRes ) +{ + // basic setup + m_pSchemeList = NULL; + m_iNumSchemes = 0; + + // find the closest matching scheme file to our resolution + char token[1024]; + char *pFile = (char*)LoadFileByResolution( "", xRes, "_textscheme.txt" ); + m_xRes = xRes; + + char *pFileStart = pFile; + + byte *pFontData; + int fontFileLength; + char fontFilename[512]; + + // + // Read the scheme descriptions from the text file, into a temporary array + // format is simply: + // = + // + // a of "SchemeName" signals a new scheme is being described + // + + const static int numTmpSchemes = 64; + static CScheme tmpSchemes[numTmpSchemes]; + memset( tmpSchemes, 0, sizeof(tmpSchemes) ); + int currentScheme = -1; + CScheme *pScheme = NULL; + + if ( !pFile ) + { + gEngfuncs.Con_DPrintf( "Unable to find *_textscheme.txt\n"); + goto buildDefaultFont; + } + + // record what has been entered so we can create defaults from the different values + bool hasFgColor, hasBgColor, hasArmedFgColor, hasArmedBgColor, hasMouseDownFgColor, hasMouseDownBgColor; + + pFile = gEngfuncs.COM_ParseFile( pFile, token ); + while ( strlen(token) > 0 && (currentScheme < numTmpSchemes) ) + { + // get the paramName name + static const int tokenSize = 64; + char paramName[tokenSize], paramValue[tokenSize]; + + strncpy( paramName, token, tokenSize - 1 ); + paramName[tokenSize-1] = 0; // ensure null termination + + // get the '=' character + pFile = gEngfuncs.COM_ParseFile( pFile, token ); + if ( stricmp( token, "=" ) ) + { + if ( currentScheme < 0 ) + { + gEngfuncs.Con_Printf( "error parsing font scheme text file at file start - expected '=', found '%s''\n", token ); + } + else + { + gEngfuncs.Con_Printf( "error parsing font scheme text file at scheme '%s' - expected '=', found '%s''\n", tmpSchemes[currentScheme].schemeName, token ); + } + break; + } + + // get paramValue + pFile = gEngfuncs.COM_ParseFile( pFile, token ); + strncpy( paramValue, token, tokenSize - 1 ); + paramValue[tokenSize-1] = 0; // ensure null termination + + // is this a new scheme? + if ( !stricmp(paramName, "SchemeName") ) + { + // setup the defaults for the current scheme + if ( pScheme ) + { + // foreground color defaults (normal -> armed -> mouse down) + if ( !hasFgColor ) + { + pScheme->fgColor[0] = pScheme->fgColor[1] = pScheme->fgColor[2] = pScheme->fgColor[3] = 255; + } + if ( !hasArmedFgColor ) + { + memcpy( pScheme->armedFgColor, pScheme->fgColor, sizeof(pScheme->armedFgColor) ); + } + if ( !hasMouseDownFgColor ) + { + memcpy( pScheme->mousedownFgColor, pScheme->armedFgColor, sizeof(pScheme->mousedownFgColor) ); + } + + // background color (normal -> armed -> mouse down) + if ( !hasBgColor ) + { + pScheme->bgColor[0] = pScheme->bgColor[1] = pScheme->bgColor[2] = pScheme->bgColor[3] = 0; + } + if ( !hasArmedBgColor ) + { + memcpy( pScheme->armedBgColor, pScheme->bgColor, sizeof(pScheme->armedBgColor) ); + } + if ( !hasMouseDownBgColor ) + { + memcpy( pScheme->mousedownBgColor, pScheme->armedBgColor, sizeof(pScheme->mousedownBgColor) ); + } + + // font size + if ( !pScheme->fontSize ) + { + pScheme->fontSize = 17; + } + if ( !pScheme->fontName[0] ) + { + strcpy( pScheme->fontName, "Arial" ); + } + } + + // create the new scheme + currentScheme++; + pScheme = &tmpSchemes[currentScheme]; + hasFgColor = hasBgColor = hasArmedFgColor = hasArmedBgColor = hasMouseDownFgColor = hasMouseDownBgColor = false; + + strncpy( pScheme->schemeName, paramValue, CScheme::SCHEME_NAME_LENGTH - 1 ); + pScheme->schemeName[CScheme::SCHEME_NAME_LENGTH-1] = '\0'; // ensure null termination of string + } + + if ( !pScheme ) + { + gEngfuncs.Con_Printf( "font scheme text file MUST start with a 'SchemeName'\n"); + break; + } + + // pull the data out into the scheme + if ( !stricmp(paramName, "FontName") ) + { + strncpy( pScheme->fontName, paramValue, CScheme::FONT_NAME_LENGTH - 1 ); + pScheme->fontName[CScheme::FONT_NAME_LENGTH-1] = 0; + } + else if ( !stricmp(paramName, "FontSize") ) + { + pScheme->fontSize = atoi( paramValue ); + } + else if ( !stricmp(paramName, "FontWeight") ) + { + pScheme->fontWeight = atoi( paramValue ); + } + else if ( !stricmp(paramName, "FgColor") ) + { + ParseRGBAFromString( pScheme->fgColor, paramValue ); + hasFgColor = true; + } + else if ( !stricmp(paramName, "BgColor") ) + { + ParseRGBAFromString( pScheme->bgColor, paramValue ); + hasBgColor = true; + } + else if ( !stricmp(paramName, "FgColorArmed") ) + { + ParseRGBAFromString( pScheme->armedFgColor, paramValue ); + hasArmedFgColor = true; + } + else if ( !stricmp(paramName, "BgColorArmed") ) + { + ParseRGBAFromString( pScheme->armedBgColor, paramValue ); + hasArmedBgColor = true; + } + else if ( !stricmp(paramName, "FgColorMousedown") ) + { + ParseRGBAFromString( pScheme->mousedownFgColor, paramValue ); + hasMouseDownFgColor = true; + } + else if ( !stricmp(paramName, "BgColorMousedown") ) + { + ParseRGBAFromString( pScheme->mousedownBgColor, paramValue ); + hasMouseDownBgColor = true; + } + else if ( !stricmp(paramName, "BorderColor") ) + { + ParseRGBAFromString( pScheme->borderColor, paramValue ); + hasMouseDownBgColor = true; + } + + // get the new token last, so we now if the loop needs to be continued or not + pFile = gEngfuncs.COM_ParseFile( pFile, token ); + } + + // free the file + gEngfuncs.COM_FreeFile( pFileStart ); + + +buildDefaultFont: + + // make sure we have at least 1 valid font + if ( currentScheme < 0 ) + { + currentScheme = 0; + strcpy( tmpSchemes[0].schemeName, "Default Scheme" ); + strcpy( tmpSchemes[0].fontName, "Arial" ); + tmpSchemes[0].fontSize = 0; + tmpSchemes[0].fgColor[0] = tmpSchemes[0].fgColor[1] = tmpSchemes[0].fgColor[2] = tmpSchemes[0].fgColor[3] = 255; + tmpSchemes[0].armedFgColor[0] = tmpSchemes[0].armedFgColor[1] = tmpSchemes[0].armedFgColor[2] = tmpSchemes[0].armedFgColor[3] = 255; + tmpSchemes[0].mousedownFgColor[0] = tmpSchemes[0].mousedownFgColor[1] = tmpSchemes[0].mousedownFgColor[2] = tmpSchemes[0].mousedownFgColor[3] = 255; + } + + // we have the full list of schemes in the tmpSchemes array + // now allocate the correct sized list + m_iNumSchemes = currentScheme + 1; // 0-based index + m_pSchemeList = new CScheme[ m_iNumSchemes ]; + + // copy in the data + memcpy( m_pSchemeList, tmpSchemes, sizeof(CScheme) * m_iNumSchemes ); + + // create the fonts + for ( int i = 0; i < m_iNumSchemes; i++ ) + { + m_pSchemeList[i].font = NULL; + + // see if the current font values exist in a previously loaded font + for ( int j = 0; j < i; j++ ) + { + // check if the font name, size, and weight are the same + if ( !stricmp(m_pSchemeList[i].fontName, m_pSchemeList[j].fontName) + && m_pSchemeList[i].fontSize == m_pSchemeList[j].fontSize + && m_pSchemeList[i].fontWeight == m_pSchemeList[j].fontWeight ) + { + // copy the pointer, but mark i as not owning it + m_pSchemeList[i].font = m_pSchemeList[j].font; + m_pSchemeList[i].ownFontPointer = false; + } + } + + // if we haven't found the font already, load it ourselves + if ( !m_pSchemeList[i].font ) + { + fontFileLength = -1; + pFontData = NULL; + + if(g_CV_BitmapFonts && g_CV_BitmapFonts->value) + { + int fontRes = 640; + if ( m_xRes >= 1600 ) + fontRes = 1600; + else if ( m_xRes >= 1280 ) + fontRes = 1280; + else if ( m_xRes >= 1152 ) + fontRes = 1152; + else if ( m_xRes >= 1024 ) + fontRes = 1024; + else if ( m_xRes >= 800 ) + fontRes = 800; + + sprintf(fontFilename, "gfx\\vgui\\fonts\\%d_%s.tga", fontRes, m_pSchemeList[i].schemeName); + pFontData = gEngfuncs.COM_LoadFile( fontFilename, 5, &fontFileLength ); + if(!pFontData) + gEngfuncs.Con_Printf("Missing bitmap font: %s\n", fontFilename); + } + + m_pSchemeList[i].font = new vgui::Font( + m_pSchemeList[i].fontName, + pFontData, + fontFileLength, + m_pSchemeList[i].fontSize, + 0, + 0, + m_pSchemeList[i].fontWeight, + false, + false, + false, + false); + + m_pSchemeList[i].ownFontPointer = true; + } + + // fix up alpha values; VGUI uses 1-A (A=0 being solid, A=255 transparent) + m_pSchemeList[i].fgColor[3] = 255 - m_pSchemeList[i].fgColor[3]; + m_pSchemeList[i].bgColor[3] = 255 - m_pSchemeList[i].bgColor[3]; + m_pSchemeList[i].armedFgColor[3] = 255 - m_pSchemeList[i].armedFgColor[3]; + m_pSchemeList[i].armedBgColor[3] = 255 - m_pSchemeList[i].armedBgColor[3]; + m_pSchemeList[i].mousedownFgColor[3] = 255 - m_pSchemeList[i].mousedownFgColor[3]; + m_pSchemeList[i].mousedownBgColor[3] = 255 - m_pSchemeList[i].mousedownBgColor[3]; + } +} + +//----------------------------------------------------------------------------- +// Purpose: frees all the memory used by the scheme manager +//----------------------------------------------------------------------------- +CSchemeManager::~CSchemeManager() +{ + delete [] m_pSchemeList; + m_iNumSchemes = 0; +} + +//----------------------------------------------------------------------------- +// Purpose: Finds a scheme in the list, by name +// Input : char *schemeName - string name of the scheme +// Output : SchemeHandle_t handle to the scheme +//----------------------------------------------------------------------------- +SchemeHandle_t CSchemeManager::getSchemeHandle( const char *schemeName ) +{ + // iterate through the list + for ( int i = 0; i < m_iNumSchemes; i++ ) + { + if ( !stricmp(schemeName, m_pSchemeList[i].schemeName) ) + return i; + } + + return 0; +} + +//----------------------------------------------------------------------------- +// Purpose: always returns a valid scheme handle +// Input : schemeHandle - +// Output : CScheme +//----------------------------------------------------------------------------- +CSchemeManager::CScheme *CSchemeManager::getSafeScheme( SchemeHandle_t schemeHandle ) +{ + if ( schemeHandle < m_iNumSchemes ) + return m_pSchemeList + schemeHandle; + + return m_pSchemeList; +} + + +//----------------------------------------------------------------------------- +// Purpose: Returns the schemes pointer to a font +// Input : schemeHandle - +// Output : vgui::Font +//----------------------------------------------------------------------------- +vgui::Font *CSchemeManager::getFont( SchemeHandle_t schemeHandle ) +{ + return getSafeScheme( schemeHandle )->font; +} + +void CSchemeManager::getFgColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a ) +{ + CScheme *pScheme = getSafeScheme( schemeHandle ); + r = pScheme->fgColor[0]; + g = pScheme->fgColor[1]; + b = pScheme->fgColor[2]; + a = pScheme->fgColor[3]; +} + +void CSchemeManager::getBgColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a ) +{ + CScheme *pScheme = getSafeScheme( schemeHandle ); + r = pScheme->bgColor[0]; + g = pScheme->bgColor[1]; + b = pScheme->bgColor[2]; + a = pScheme->bgColor[3]; +} + +void CSchemeManager::getFgArmedColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a ) +{ + CScheme *pScheme = getSafeScheme( schemeHandle ); + r = pScheme->armedFgColor[0]; + g = pScheme->armedFgColor[1]; + b = pScheme->armedFgColor[2]; + a = pScheme->armedFgColor[3]; +} + +void CSchemeManager::getBgArmedColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a ) +{ + CScheme *pScheme = getSafeScheme( schemeHandle ); + r = pScheme->armedBgColor[0]; + g = pScheme->armedBgColor[1]; + b = pScheme->armedBgColor[2]; + a = pScheme->armedBgColor[3]; +} + +void CSchemeManager::getFgMousedownColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a ) +{ + CScheme *pScheme = getSafeScheme( schemeHandle ); + r = pScheme->mousedownFgColor[0]; + g = pScheme->mousedownFgColor[1]; + b = pScheme->mousedownFgColor[2]; + a = pScheme->mousedownFgColor[3]; +} + +void CSchemeManager::getBgMousedownColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a ) +{ + CScheme *pScheme = getSafeScheme( schemeHandle ); + r = pScheme->mousedownBgColor[0]; + g = pScheme->mousedownBgColor[1]; + b = pScheme->mousedownBgColor[2]; + a = pScheme->mousedownBgColor[3]; +} + +void CSchemeManager::getBorderColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a ) +{ + CScheme *pScheme = getSafeScheme( schemeHandle ); + r = pScheme->borderColor[0]; + g = pScheme->borderColor[1]; + b = pScheme->borderColor[2]; + a = pScheme->borderColor[3]; +} + + + diff --git a/cl_dll/vgui_SchemeManager.h b/cl_dll/vgui_SchemeManager.h new file mode 100644 index 00000000..acde6c4b --- /dev/null +++ b/cl_dll/vgui_SchemeManager.h @@ -0,0 +1,50 @@ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#include + +// handle to an individual scheme +typedef int SchemeHandle_t; + +// Register console variables, etc.. +void Scheme_Init(); + +//----------------------------------------------------------------------------- +// Purpose: Handles the loading of text scheme description from disk +// supports different font/color/size schemes at different resolutions +//----------------------------------------------------------------------------- +class CSchemeManager +{ +public: + // initialization + CSchemeManager( int xRes, int yRes ); + virtual ~CSchemeManager(); + + // scheme handling + SchemeHandle_t getSchemeHandle( const char *schemeName ); + + // getting info from schemes + vgui::Font *getFont( SchemeHandle_t schemeHandle ); + void getFgColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a ); + void getBgColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a ); + void getFgArmedColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a ); + void getBgArmedColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a ); + void getFgMousedownColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a ); + void getBgMousedownColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a ); + void getBorderColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a ); + +private: + class CScheme; + CScheme *m_pSchemeList; + int m_iNumSchemes; + + // Resolution we were initted at. + int m_xRes; + + CScheme *getSafeScheme( SchemeHandle_t schemeHandle ); +}; + diff --git a/cl_dll/vgui_ScorePanel.cpp b/cl_dll/vgui_ScorePanel.cpp new file mode 100644 index 00000000..13c2fb19 --- /dev/null +++ b/cl_dll/vgui_ScorePanel.cpp @@ -0,0 +1,1121 @@ +//=========== (C) Copyright 1996-2002 Valve, L.L.C. All rights reserved. =========== +// +// The copyright to the contents herein is the property of Valve, L.L.C. +// The contents may be used and/or copied only with the written permission of +// Valve, L.L.C., or in accordance with the terms and conditions stipulated in +// the agreement/contract under which the contents have been supplied. +// +// Purpose: VGUI scoreboard +// +// $Workfile: $ +// $Date: $ +// +//----------------------------------------------------------------------------- +// $Log: $ +// +// $NoKeywords: $ +//============================================================================= + + +#include + +#include "hud.h" +#include "cl_util.h" +#include "const.h" +#include "entity_state.h" +#include "cl_entity.h" +#include "vgui_TeamFortressViewport.h" +#include "vgui_ScorePanel.h" +#include "vgui_helpers.h" +#include "vgui_loadtga.h" +#include "voice_status.h" +#include "vgui_SpectatorPanel.h" + +int HUD_IsGame( const char *game ); +int EV_TFC_IsAllyTeam( int iTeam1, int iTeam2 ); + +// Scoreboard dimensions +#define SBOARD_TITLE_SIZE_Y YRES(22) + +#define X_BORDER XRES(4) + +// Column sizes +class SBColumnInfo +{ +public: + const char *m_pTitle; // If null, ignore, if starts with #, it's localized, otherwise use the string directly. + int m_Width; // Based on 640 width. Scaled to fit other resolutions. + Label::Alignment m_Alignment; +}; + +// grid size is marked out for 640x480 screen + +SBColumnInfo g_ColumnInfo[NUM_COLUMNS] = +{ + {NULL, 24, Label::a_east}, // tracker column + {NULL, 140, Label::a_east}, // name + {NULL, 56, Label::a_east}, // class + {"#SCORE", 40, Label::a_east}, + {"#DEATHS", 46, Label::a_east}, + {"#LATENCY", 46, Label::a_east}, + {"#VOICE", 40, Label::a_east}, + {NULL, 2, Label::a_east}, // blank column to take up the slack +}; + + +#define TEAM_NO 0 +#define TEAM_YES 1 +#define TEAM_SPECTATORS 2 +#define TEAM_BLANK 3 + + +//----------------------------------------------------------------------------- +// ScorePanel::HitTestPanel. +//----------------------------------------------------------------------------- + +void ScorePanel::HitTestPanel::internalMousePressed( MouseCode code ) +{ + for( int i = 0; i < _inputSignalDar.getCount(); i++ ) + { + _inputSignalDar[i]->mousePressed( code, this ); + } +} + +//----------------------------------------------------------------------------- +// Purpose: Create the ScoreBoard panel +//----------------------------------------------------------------------------- +ScorePanel::ScorePanel( int x, int y, int wide, int tall ) : Panel( x, y, wide, tall ) +{ + CSchemeManager *pSchemes = gViewPort->GetSchemeManager(); + SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle( "Scoreboard Title Text" ); + SchemeHandle_t hSmallScheme = pSchemes->getSchemeHandle( "Scoreboard Small Text" ); + Font *tfont = pSchemes->getFont( hTitleScheme ); + Font *smallfont = pSchemes->getFont( hSmallScheme ); + + setBgColor( 0, 0, 0, 96 ); + m_pCurrentHighlightLabel = NULL; + m_iHighlightRow = -1; + + //m_pTrackerIcon = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_scoreboardtracker.tga"); + + // Initialize the top title. + m_TitleLabel.setFont( tfont ); + m_TitleLabel.setText( "" ); + m_TitleLabel.setBgColor( 0, 0, 0, 255 ); + m_TitleLabel.setFgColor( Scheme::sc_primary1 ); + m_TitleLabel.setContentAlignment( vgui::Label::a_west ); + + LineBorder *border = new LineBorder( Color( 60, 60, 60, 128 ) ); + setBorder( border ); + setPaintBorderEnabled( true ); + + int xpos = g_ColumnInfo[0].m_Width + 3; + if( ScreenWidth >= 640 ) + { + // only expand column size for res greater than 640 + xpos = XRES( xpos ); + } + m_TitleLabel.setBounds( xpos, 4, wide, SBOARD_TITLE_SIZE_Y ); + m_TitleLabel.setContentFitted( false ); + m_TitleLabel.setParent( this ); + + // Setup the header (labels like "name", "class", etc..). + m_HeaderGrid.SetDimensions( NUM_COLUMNS, 1 ); + m_HeaderGrid.SetSpacing( 0, 0 ); + + for( int i = 0; i < NUM_COLUMNS; i++ ) + { + if( g_ColumnInfo[i].m_pTitle && g_ColumnInfo[i].m_pTitle[0] == '#' ) + m_HeaderLabels[i].setText( CHudTextMessage::BufferedLocaliseTextString( g_ColumnInfo[i].m_pTitle ) ); + else if( g_ColumnInfo[i].m_pTitle ) + m_HeaderLabels[i].setText( g_ColumnInfo[i].m_pTitle ); + + int xwide = g_ColumnInfo[i].m_Width; + if( ScreenWidth >= 640 ) + { + xwide = XRES( xwide ); + } + else if( ScreenWidth == 400 ) + { + // hack to make 400x300 resolution scoreboard fit + if( i == 1 ) + { + // reduces size of player name cell + xwide -= 28; + } + else if( i == 0 ) + { + // tracker icon cell + xwide -= 8; + } + } + + m_HeaderGrid.SetColumnWidth( i, xwide ); + m_HeaderGrid.SetEntry( i, 0, &m_HeaderLabels[i] ); + + m_HeaderLabels[i].setBgColor( 0, 0, 0, 255 ); + m_HeaderLabels[i].setFgColor( Scheme::sc_primary1 ); + m_HeaderLabels[i].setFont( smallfont ); + m_HeaderLabels[i].setContentAlignment( g_ColumnInfo[i].m_Alignment ); + + int yres = 12; + if( ScreenHeight >= 480 ) + { + yres = YRES( yres ); + } + m_HeaderLabels[i].setSize( 50, yres ); + } + + // Set the width of the last column to be the remaining space. + int ex, ey, ew, eh; + + m_HeaderGrid.GetEntryBox( NUM_COLUMNS - 2, 0, ex, ey, ew, eh ); + m_HeaderGrid.SetColumnWidth( NUM_COLUMNS - 1, ( wide - X_BORDER ) - ( ex + ew ) ); + + m_HeaderGrid.AutoSetRowHeights(); + m_HeaderGrid.setBounds( X_BORDER, SBOARD_TITLE_SIZE_Y, wide - X_BORDER * 2, m_HeaderGrid.GetRowHeight( 0 ) ); + m_HeaderGrid.setParent( this ); + m_HeaderGrid.setBgColor( 0, 0, 0, 255 ); + + // Now setup the listbox with the actual player data in it. + int headerX, headerY, headerWidth, headerHeight; + + m_HeaderGrid.getBounds( headerX, headerY, headerWidth, headerHeight ); + m_PlayerList.setBounds( headerX, headerY+headerHeight, headerWidth, tall - headerY - headerHeight - 6 ); + m_PlayerList.setBgColor( 0, 0, 0, 255 ); + m_PlayerList.setParent( this ); + + for( int row=0; row < NUM_ROWS; row++ ) + { + CGrid *pGridRow = &m_PlayerGrids[row]; + + pGridRow->SetDimensions( NUM_COLUMNS, 1 ); + + for( int col = 0; col < NUM_COLUMNS; col++ ) + { + m_PlayerEntries[col][row].setContentFitted( false ); + m_PlayerEntries[col][row].setRow( row ); + m_PlayerEntries[col][row].addInputSignal( this ); + pGridRow->SetEntry(col, 0, &m_PlayerEntries[col][row]); + } + + pGridRow->setBgColor( 0, 0, 0, 255 ); + pGridRow->SetSpacing( 0, 0 ); + pGridRow->CopyColumnWidths( &m_HeaderGrid ); + pGridRow->AutoSetRowHeights(); + pGridRow->setSize( PanelWidth( pGridRow ), pGridRow->CalcDrawHeight() ); + pGridRow->RepositionContents(); + + m_PlayerList.AddItem( pGridRow ); + } + + // Add the hit test panel. It is invisible and traps mouse clicks so we can go into squelch mode. + m_HitTestPanel.setBgColor( 0, 0, 0, 255 ); + m_HitTestPanel.setParent( this ); + m_HitTestPanel.setBounds( 0, 0, wide, tall ); + m_HitTestPanel.addInputSignal( this ); + + m_pCloseButton = new CommandButton( "x", wide - XRES( 12 + 4 ), YRES( 2 ), XRES( 12 ) , YRES( 12 ) ); + m_pCloseButton->setParent( this ); + m_pCloseButton->addActionSignal( new CMenuHandler_StringCommandWatch( "-showscores", true ) ); + m_pCloseButton->setBgColor( 0, 0, 0, 255 ); + m_pCloseButton->setFgColor( 255, 255, 255, 0 ); + m_pCloseButton->setFont( tfont ); + m_pCloseButton->setBoundKey( (char)255 ); + m_pCloseButton->setContentAlignment( Label::a_center ); + + Initialize(); +} + +//----------------------------------------------------------------------------- +// Purpose: Called each time a new level is started. +//----------------------------------------------------------------------------- +void ScorePanel::Initialize( void ) +{ + // Clear out scoreboard data + m_iLastKilledBy = 0; + m_fLastKillTime = 0; + m_iPlayerNum = 0; + m_iNumTeams = 0; + memset( g_PlayerExtraInfo, 0, sizeof g_PlayerExtraInfo ); + memset( g_TeamInfo, 0, sizeof g_TeamInfo ); +} + +bool HACK_GetPlayerUniqueID( int iPlayer, char playerID[16] ) +{ + return !!gEngfuncs.GetPlayerUniqueID( iPlayer, playerID ); // TODO remove after testing +} + +//----------------------------------------------------------------------------- +// Purpose: Recalculate the internal scoreboard data +//----------------------------------------------------------------------------- +void ScorePanel::Update() +{ + int i; + + // Set the title + if( gViewPort->m_szServerName[0] != '\0' ) + { + m_TitleLabel.setText( gViewPort->m_szServerName ); + } + + m_iRows = 0; + gViewPort->GetAllPlayersInfo(); + + // Clear out sorts + for (i = 0; i < NUM_ROWS; i++) + { + m_iSortedRows[i] = 0; + m_iIsATeam[i] = TEAM_NO; + } + for (i = 0; i < MAX_PLAYERS; i++) + { + m_bHasBeenSorted[i] = false; + } + + // If it's not teamplay, sort all the players. Otherwise, sort the teams. + if( !gHUD.m_Teamplay ) + SortPlayers( 0, NULL ); + else + SortTeams(); + + // set scrollbar range + m_PlayerList.SetScrollRange(m_iRows); + + FillGrid(); + + if( gViewPort->m_pSpectatorPanel->m_menuVisible ) + { + m_pCloseButton->setVisible ( true ); + } + else + { + m_pCloseButton->setVisible ( false ); + } +} + +//----------------------------------------------------------------------------- +// Purpose: Sort all the teams +//----------------------------------------------------------------------------- +void ScorePanel::SortTeams() +{ + // clear out team scores + int i; + for ( i = 1; i <= m_iNumTeams; i++ ) + { + if( !g_TeamInfo[i].scores_overriden ) + g_TeamInfo[i].frags = g_TeamInfo[i].deaths = 0; + g_TeamInfo[i].ping = g_TeamInfo[i].packetloss = 0; + } + + // recalc the team scores, then draw them + for( i = 1; i < MAX_PLAYERS; i++ ) + { + if( g_PlayerInfoList[i].name == 0 ) + continue; // empty player slot, skip + + if( g_PlayerExtraInfo[i].teamname[0] == 0 ) + continue; // skip over players who are not in a team + + // find what team this player is in + int j; + for ( j = 1; j <= m_iNumTeams; j++ ) + { + if( !stricmp( g_PlayerExtraInfo[i].teamname, g_TeamInfo[j].name ) ) + break; + } + if( j > m_iNumTeams ) // player is not in a team, skip to the next guy + continue; + + if( !g_TeamInfo[j].scores_overriden ) + { + g_TeamInfo[j].frags += g_PlayerExtraInfo[i].frags; + g_TeamInfo[j].deaths += g_PlayerExtraInfo[i].deaths; + } + + g_TeamInfo[j].ping += g_PlayerInfoList[i].ping; + g_TeamInfo[j].packetloss += g_PlayerInfoList[i].packetloss; + + if( g_PlayerInfoList[i].thisplayer ) + g_TeamInfo[j].ownteam = TRUE; + else + g_TeamInfo[j].ownteam = FALSE; + + // Set the team's number (used for team colors) + g_TeamInfo[j].teamnumber = g_PlayerExtraInfo[i].teamnumber; + } + + // find team ping/packetloss averages + for( i = 1; i <= m_iNumTeams; i++ ) + { + g_TeamInfo[i].already_drawn = FALSE; + + if( g_TeamInfo[i].players > 0 ) + { + g_TeamInfo[i].ping /= g_TeamInfo[i].players; // use the average ping of all the players in the team as the teams ping + g_TeamInfo[i].packetloss /= g_TeamInfo[i].players; // use the average ping of all the players in the team as the teams ping + } + } + + // Draw the teams + while( 1 ) + { + int highest_frags = -99999; int lowest_deaths = 99999; + int best_team = 0; + + for( i = 1; i <= m_iNumTeams; i++ ) + { + if( g_TeamInfo[i].players < 1 ) + continue; + + if( !g_TeamInfo[i].already_drawn && g_TeamInfo[i].frags >= highest_frags ) + { + if( g_TeamInfo[i].frags > highest_frags || g_TeamInfo[i].deaths < lowest_deaths ) + { + best_team = i; + lowest_deaths = g_TeamInfo[i].deaths; + highest_frags = g_TeamInfo[i].frags; + } + } + } + + // draw the best team on the scoreboard + if( !best_team ) + break; + + // Put this team in the sorted list + m_iSortedRows[m_iRows] = best_team; + m_iIsATeam[m_iRows] = TEAM_YES; + g_TeamInfo[best_team].already_drawn = TRUE; // set the already_drawn to be TRUE, so this team won't get sorted again + m_iRows++; + + // Now sort all the players on this team + SortPlayers( 0, g_TeamInfo[best_team].name ); + } + + // Add all the players who aren't in a team yet into spectators + SortPlayers( TEAM_SPECTATORS, NULL ); +} + +//----------------------------------------------------------------------------- +// Purpose: Sort a list of players +//----------------------------------------------------------------------------- +void ScorePanel::SortPlayers( int iTeam, char *team ) +{ + bool bCreatedTeam = false; + + // draw the players, in order, and restricted to team if set + while ( 1 ) + { + // Find the top ranking player + int highest_frags = -99999; int lowest_deaths = 99999; + int best_player; + best_player = 0; + + for ( int i = 1; i < MAX_PLAYERS; i++ ) + { + if ( m_bHasBeenSorted[i] == false && g_PlayerInfoList[i].name && g_PlayerExtraInfo[i].frags >= highest_frags ) + { + cl_entity_t *ent = gEngfuncs.GetEntityByIndex( i ); + + if ( ent && !(team && stricmp(g_PlayerExtraInfo[i].teamname, team)) ) + { + extra_player_info_t *pl_info = &g_PlayerExtraInfo[i]; + if ( pl_info->frags > highest_frags || pl_info->deaths < lowest_deaths ) + { + best_player = i; + lowest_deaths = pl_info->deaths; + highest_frags = pl_info->frags; + } + } + } + } + + if ( !best_player ) + break; + + // If we haven't created the Team yet, do it first + if (!bCreatedTeam && iTeam) + { + m_iIsATeam[ m_iRows ] = iTeam; + m_iRows++; + + bCreatedTeam = true; + } + + // Put this player in the sorted list + m_iSortedRows[ m_iRows ] = best_player; + m_bHasBeenSorted[ best_player ] = true; + m_iRows++; + } + + if (team) + { + m_iIsATeam[m_iRows++] = TEAM_BLANK; + } +} + +//----------------------------------------------------------------------------- +// Purpose: Recalculate the existing teams in the match +//----------------------------------------------------------------------------- +void ScorePanel::RebuildTeams() +{ + // clear out player counts from teams + int i; + for ( i = 1; i <= m_iNumTeams; i++ ) + { + g_TeamInfo[i].players = 0; + } + + // rebuild the team list + gViewPort->GetAllPlayersInfo(); + m_iNumTeams = 0; + for ( i = 1; i < MAX_PLAYERS; i++ ) + { + if ( g_PlayerInfoList[i].name == NULL ) + continue; + + if ( g_PlayerExtraInfo[i].teamname[0] == 0 ) + continue; // skip over players who are not in a team + + // is this player in an existing team? + int j; + for ( j = 1; j <= m_iNumTeams; j++ ) + { + if ( g_TeamInfo[j].name[0] == '\0' ) + break; + + if ( !stricmp( g_PlayerExtraInfo[i].teamname, g_TeamInfo[j].name ) ) + break; + } + + if ( j > m_iNumTeams ) + { // they aren't in a listed team, so make a new one + // search through for an empty team slot + for ( j = 1; j <= m_iNumTeams; j++ ) + { + if ( g_TeamInfo[j].name[0] == '\0' ) + break; + } + m_iNumTeams = Q_max( j, m_iNumTeams ); + + strncpy( g_TeamInfo[j].name, g_PlayerExtraInfo[i].teamname, MAX_TEAM_NAME - 1 ); + g_TeamInfo[j].players = 0; + } + + g_TeamInfo[j].players++; + } + + // clear out any empty teams + for ( i = 1; i <= m_iNumTeams; i++ ) + { + if ( g_TeamInfo[i].players < 1 ) + memset( &g_TeamInfo[i], 0, sizeof(team_info_t) ); + } + + // Update the scoreboard + Update(); +} + + +void ScorePanel::FillGrid() +{ + CSchemeManager *pSchemes = gViewPort->GetSchemeManager(); + SchemeHandle_t hScheme = pSchemes->getSchemeHandle("Scoreboard Text"); + SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle("Scoreboard Title Text"); + SchemeHandle_t hSmallScheme = pSchemes->getSchemeHandle("Scoreboard Small Text"); + + Font *sfont = pSchemes->getFont(hScheme); + Font *tfont = pSchemes->getFont(hTitleScheme); + Font *smallfont = pSchemes->getFont(hSmallScheme); + + // update highlight position + int x, y; + getApp()->getCursorPos(x, y); + cursorMoved(x, y, this); + + // remove highlight row if we're not in squelch mode + if (!GetClientVoiceMgr()->IsInSquelchMode()) + { + m_iHighlightRow = -1; + } + + bool bNextRowIsGap = false; + int row; + for(row=0; row < NUM_ROWS; row++) + { + CGrid *pGridRow = &m_PlayerGrids[row]; + pGridRow->SetRowUnderline(0, false, 0, 0, 0, 0, 0); + + if(row >= m_iRows) + { + for(int col=0; col < NUM_COLUMNS; col++) + m_PlayerEntries[col][row].setVisible(false); + + continue; + } + + bool bRowIsGap = false; + if (bNextRowIsGap) + { + bNextRowIsGap = false; + bRowIsGap = true; + } + + for(int col=0; col < NUM_COLUMNS; col++) + { + CLabelHeader *pLabel = &m_PlayerEntries[col][row]; + + pLabel->setVisible(true); + pLabel->setText2(""); + pLabel->setImage(NULL); + pLabel->setFont(sfont); + pLabel->setTextOffset(0, 0); + + int rowheight = 13; + if (ScreenHeight > 480) + { + rowheight = YRES(rowheight); + } + else + { + // more tweaking, make sure icons fit at low res + rowheight = 15; + } + pLabel->setSize(pLabel->getWide(), rowheight); + pLabel->setBgColor(0, 0, 0, 255); + + char sz[128]; + hud_player_info_t *pl_info = NULL; + team_info_t *team_info = NULL; + + if (m_iIsATeam[row] == TEAM_BLANK) + { + pLabel->setText(" "); + continue; + } + else if ( m_iIsATeam[row] == TEAM_YES ) + { + // Get the team's data + team_info = &g_TeamInfo[ m_iSortedRows[row] ]; + + // team color text for team names + pLabel->setFgColor( iTeamColors[team_info->teamnumber % iNumberOfTeamColors][0], + iTeamColors[team_info->teamnumber % iNumberOfTeamColors][1], + iTeamColors[team_info->teamnumber % iNumberOfTeamColors][2], + 0 ); + + // different height for team header rows + rowheight = 20; + if (ScreenHeight >= 480) + { + rowheight = YRES(rowheight); + } + pLabel->setSize(pLabel->getWide(), rowheight); + pLabel->setFont(tfont); + + pGridRow->SetRowUnderline( 0, + true, + YRES(3), + iTeamColors[team_info->teamnumber % iNumberOfTeamColors][0], + iTeamColors[team_info->teamnumber % iNumberOfTeamColors][1], + iTeamColors[team_info->teamnumber % iNumberOfTeamColors][2], + 0 ); + } + else if ( m_iIsATeam[row] == TEAM_SPECTATORS ) + { + // grey text for spectators + pLabel->setFgColor(100, 100, 100, 0); + + // different height for team header rows + rowheight = 20; + if (ScreenHeight >= 480) + { + rowheight = YRES(rowheight); + } + pLabel->setSize(pLabel->getWide(), rowheight); + pLabel->setFont(tfont); + + pGridRow->SetRowUnderline(0, true, YRES(3), 100, 100, 100, 0); + } + else + { + // team color text for player names + pLabel->setFgColor( iTeamColors[ g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber % iNumberOfTeamColors ][0], + iTeamColors[ g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber % iNumberOfTeamColors ][1], + iTeamColors[ g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber % iNumberOfTeamColors ][2], + 0 ); + + // Get the player's data + pl_info = &g_PlayerInfoList[ m_iSortedRows[row] ]; + + // Set background color + if ( pl_info->thisplayer ) // if it is their name, draw it a different color + { + // Highlight this player + pLabel->setFgColor(Scheme::sc_white); + pLabel->setBgColor( iTeamColors[ g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber % iNumberOfTeamColors ][0], + iTeamColors[ g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber % iNumberOfTeamColors ][1], + iTeamColors[ g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber % iNumberOfTeamColors ][2], + 196 ); + } + else if ( m_iSortedRows[row] == m_iLastKilledBy && m_fLastKillTime && m_fLastKillTime > gHUD.m_flTime ) + { + // Killer's name + pLabel->setBgColor( 255,0,0, 255 - ((float)15 * (float)(m_fLastKillTime - gHUD.m_flTime)) ); + } + } + + // Align + if (col == COLUMN_NAME || col == COLUMN_CLASS) + { + pLabel->setContentAlignment( vgui::Label::a_west ); + } + else if (col == COLUMN_TRACKER) + { + pLabel->setContentAlignment( vgui::Label::a_center ); + } + else + { + pLabel->setContentAlignment( vgui::Label::a_east ); + } + + // Fill out with the correct data + sz[0] = '\0'; + if ( m_iIsATeam[row] ) + { + char sz2[128]; + + switch (col) + { + case COLUMN_NAME: + if ( m_iIsATeam[row] == TEAM_SPECTATORS ) + { + strcpy( sz2, CHudTextMessage::BufferedLocaliseTextString( "#Spectators" ) ); + } + else + { + strcpy( sz2, gViewPort->GetTeamName(team_info->teamnumber) ); + } + + strcpy(sz, sz2); + + // Append the number of players + if ( m_iIsATeam[row] == TEAM_YES ) + { + if (team_info->players == 1) + { + sprintf(sz2, "(%d %s)", team_info->players, CHudTextMessage::BufferedLocaliseTextString( "#Player" ) ); + } + else + { + sprintf(sz2, "(%d %s)", team_info->players, CHudTextMessage::BufferedLocaliseTextString( "#Player_plural" ) ); + } + + pLabel->setText2(sz2); + pLabel->setFont2(smallfont); + } + break; + case COLUMN_VOICE: + break; + case COLUMN_CLASS: + break; + case COLUMN_KILLS: + if ( m_iIsATeam[row] == TEAM_YES ) + sprintf(sz, "%d", team_info->frags ); + break; + case COLUMN_DEATHS: + if ( m_iIsATeam[row] == TEAM_YES ) + sprintf(sz, "%d", team_info->deaths ); + break; + case COLUMN_LATENCY: + if ( m_iIsATeam[row] == TEAM_YES ) + sprintf(sz, "%d", team_info->ping ); + break; + default: + break; + } + } + else + { + bool bShowClass = false; + + switch (col) + { + case COLUMN_NAME: + /* + if (g_pTrackerUser) + { + int playerSlot = m_iSortedRows[row]; + int trackerID = gEngfuncs.GetTrackerIDForPlayer(playerSlot); + const char *trackerName = g_pTrackerUser->GetUserName(trackerID); + if (trackerName && *trackerName) + { + sprintf(sz, " (%s)", trackerName); + pLabel->setText2(sz); + } + } + */ + sprintf(sz, "%s ", pl_info->name); + break; + case COLUMN_VOICE: + sz[0] = 0; + // in HLTV mode allow spectator to turn on/off commentator voice + //if (!pl_info->thisplayer || gEngfuncs.IsSpectateOnly() ) + //{ + GetClientVoiceMgr()->UpdateSpeakerImage(pLabel, m_iSortedRows[row]); + //} + break; + case COLUMN_CLASS: + // No class for other team's members (unless allied or spectator) + if ( gViewPort && EV_TFC_IsAllyTeam( g_iTeamNumber, g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber ) ) + bShowClass = true; + // Don't show classes if this client hasnt picked a team yet + if ( g_iTeamNumber == 0 ) + bShowClass = false; + + if (bShowClass) + { + // Only print Civilian if this team are all civilians + bool bNoClass = false; + if ( g_PlayerExtraInfo[ m_iSortedRows[row] ].playerclass == 0 ) + { + if ( gViewPort->GetValidClasses( g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber ) != -1 ) + bNoClass = true; + } + + if (bNoClass) + sz[0] = '\0'; + else + strcpy( sz, CHudTextMessage::BufferedLocaliseTextString( sLocalisedClasses[ g_PlayerExtraInfo[ m_iSortedRows[row] ].playerclass ] ) ); + } + else + { + sz[0] = '\0'; + } + break; + + case COLUMN_TRACKER: + /* + if (g_pTrackerUser) + { + int playerSlot = m_iSortedRows[row]; + int trackerID = gEngfuncs.GetTrackerIDForPlayer(playerSlot); + + if (g_pTrackerUser->IsFriend(trackerID) && trackerID != g_pTrackerUser->GetTrackerID()) + { + pLabel->setImage(m_pTrackerIcon); + pLabel->setFgColorAsImageColor(false); + m_pTrackerIcon->setColor(Color(255, 255, 255, 0)); + } + } + */ + break; + case COLUMN_KILLS: + sprintf(sz, "%d", g_PlayerExtraInfo[ m_iSortedRows[row] ].frags ); + break; + case COLUMN_DEATHS: + sprintf(sz, "%d", g_PlayerExtraInfo[ m_iSortedRows[row] ].deaths ); + break; + case COLUMN_LATENCY: + sprintf(sz, "%d", g_PlayerInfoList[ m_iSortedRows[row] ].ping ); + break; + default: + break; + } + } + + pLabel->setText(sz); + } + } + + for(row=0; row < NUM_ROWS; row++) + { + CGrid *pGridRow = &m_PlayerGrids[row]; + + pGridRow->AutoSetRowHeights(); + pGridRow->setSize(PanelWidth(pGridRow), pGridRow->CalcDrawHeight()); + pGridRow->RepositionContents(); + } + + // hack, for the thing to resize + m_PlayerList.getSize(x, y); + m_PlayerList.setSize(x, y); +} + + +//----------------------------------------------------------------------------- +// Purpose: Setup highlights for player names in scoreboard +//----------------------------------------------------------------------------- +void ScorePanel::DeathMsg( int killer, int victim ) +{ + // if we were the one killed, or the world killed us, set the scoreboard to indicate suicide + if ( victim == m_iPlayerNum || killer == 0 ) + { + m_iLastKilledBy = killer ? killer : m_iPlayerNum; + m_fLastKillTime = gHUD.m_flTime + 10; // display who we were killed by for 10 seconds + + if ( killer == m_iPlayerNum ) + m_iLastKilledBy = m_iPlayerNum; + } +} + + +void ScorePanel::Open( void ) +{ + RebuildTeams(); + setVisible(true); + m_HitTestPanel.setVisible(true); +} + + +void ScorePanel::mousePressed(MouseCode code, Panel* panel) +{ + if(gHUD.m_iIntermission) + return; + + if (!GetClientVoiceMgr()->IsInSquelchMode()) + { + GetClientVoiceMgr()->StartSquelchMode(); + m_HitTestPanel.setVisible(false); + } + else if (m_iHighlightRow >= 0) + { + // mouse has been pressed, toggle mute state + int iPlayer = m_iSortedRows[m_iHighlightRow]; + if (iPlayer > 0) + { + // print text message + hud_player_info_t *pl_info = &g_PlayerInfoList[iPlayer]; + + if (pl_info && pl_info->name && pl_info->name[0]) + { + char string[256]; + if (GetClientVoiceMgr()->IsPlayerBlocked(iPlayer)) + { + char string1[1024]; + + // remove mute + GetClientVoiceMgr()->SetPlayerBlockedState(iPlayer, false); + + sprintf( string1, CHudTextMessage::BufferedLocaliseTextString( "#Unmuted" ), pl_info->name ); + sprintf( string, "%c** %s\n", HUD_PRINTTALK, string1 ); + + gHUD.m_TextMessage.MsgFunc_TextMsg(NULL, strlen(string)+1, string ); + } + else + { + char string1[1024]; + + // mute the player + GetClientVoiceMgr()->SetPlayerBlockedState(iPlayer, true); + + sprintf( string1, CHudTextMessage::BufferedLocaliseTextString( "#Muted" ), pl_info->name ); + sprintf( string, "%c** %s %s\n", HUD_PRINTTALK, string1, CHudTextMessage::BufferedLocaliseTextString( "#No_longer_hear_that_player" ) ); + + gHUD.m_TextMessage.MsgFunc_TextMsg(NULL, strlen(string)+1, string ); + } + } + } + } +} + +void ScorePanel::cursorMoved(int x, int y, Panel *panel) +{ + if (GetClientVoiceMgr()->IsInSquelchMode()) + { + // look for which cell the mouse is currently over + for (int i = 0; i < NUM_ROWS; i++) + { + int row, col; + if (m_PlayerGrids[i].getCellAtPoint(x, y, row, col)) + { + MouseOverCell(i, col); + return; + } + } + } +} + +//----------------------------------------------------------------------------- +// Purpose: Handles mouse movement over a cell +// Input : row - +// col - +//----------------------------------------------------------------------------- +void ScorePanel::MouseOverCell(int row, int col) +{ + CLabelHeader *label = &m_PlayerEntries[col][row]; + + // clear the previously highlighted label + if (m_pCurrentHighlightLabel != label) + { + m_pCurrentHighlightLabel = NULL; + m_iHighlightRow = -1; + } + if (!label) + return; + + // don't act on teams + if (m_iIsATeam[row] != TEAM_NO) + return; + + // don't act on disconnected players or ourselves + hud_player_info_t *pl_info = &g_PlayerInfoList[ m_iSortedRows[row] ]; + if (!pl_info->name || !pl_info->name[0]) + return; + + if (pl_info->thisplayer && !gEngfuncs.IsSpectateOnly() ) + return; + + // setup the new highlight + m_pCurrentHighlightLabel = label; + m_iHighlightRow = row; +} + +//----------------------------------------------------------------------------- +// Purpose: Label paint functions - take into account current highligh status +//----------------------------------------------------------------------------- +void CLabelHeader::paintBackground() +{ + Color oldBg; + getBgColor(oldBg); + + if (gViewPort->GetScoreBoard()->m_iHighlightRow == _row) + { + setBgColor(134, 91, 19, 0); + } + + Panel::paintBackground(); + + setBgColor(oldBg); +} + + +//----------------------------------------------------------------------------- +// Purpose: Label paint functions - take into account current highligh status +//----------------------------------------------------------------------------- +void CLabelHeader::paint() +{ + Color oldFg; + getFgColor(oldFg); + + if (gViewPort->GetScoreBoard()->m_iHighlightRow == _row) + { + setFgColor(255, 255, 255, 0); + } + + // draw text + int x, y, iwide, itall; + getTextSize(iwide, itall); + calcAlignment(iwide, itall, x, y); + _dualImage->setPos(x, y); + + int x1, y1; + _dualImage->GetImage(1)->getPos(x1, y1); + _dualImage->GetImage(1)->setPos(_gap, y1); + + _dualImage->doPaint(this); + + // get size of the panel and the image + if (_image) + { + Color imgColor; + getFgColor( imgColor ); + if( _useFgColorAsImageColor ) + { + _image->setColor( imgColor ); + } + + _image->getSize(iwide, itall); + calcAlignment(iwide, itall, x, y); + _image->setPos(x, y); + _image->doPaint(this); + } + + setFgColor(oldFg[0], oldFg[1], oldFg[2], oldFg[3]); +} + + +void CLabelHeader::calcAlignment(int iwide, int itall, int &x, int &y) +{ + // calculate alignment ourselves, since vgui is so broken + int wide, tall; + getSize(wide, tall); + + x = 0, y = 0; + + // align left/right + switch (_contentAlignment) + { + // left + case Label::a_northwest: + case Label::a_west: + case Label::a_southwest: + { + x = 0; + break; + } + + // center + case Label::a_north: + case Label::a_center: + case Label::a_south: + { + x = (wide - iwide) / 2; + break; + } + + // right + case Label::a_northeast: + case Label::a_east: + case Label::a_southeast: + { + x = wide - iwide; + break; + } + } + + // top/down + switch (_contentAlignment) + { + // top + case Label::a_northwest: + case Label::a_north: + case Label::a_northeast: + { + y = 0; + break; + } + + // center + case Label::a_west: + case Label::a_center: + case Label::a_east: + { + y = (tall - itall) / 2; + break; + } + + // south + case Label::a_southwest: + case Label::a_south: + case Label::a_southeast: + { + y = tall - itall; + break; + } + } + +// don't clip to Y +// if (y < 0) +// { +// y = 0; +// } + if (x < 0) + { + x = 0; + } + + x += _offset[0]; + y += _offset[1]; +} diff --git a/cl_dll/vgui_ScorePanel.h b/cl_dll/vgui_ScorePanel.h new file mode 100644 index 00000000..b17770a4 --- /dev/null +++ b/cl_dll/vgui_ScorePanel.h @@ -0,0 +1,311 @@ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef SCOREPANEL_H +#define SCOREPANEL_H + +#include +#include +#include +#include +#include +#include +#include "../game_shared/vgui_listbox.h" +#include "cl_util.h" + +#include + +#define MAX_SCORES 10 +#define MAX_SCOREBOARD_TEAMS 5 + +// Scoreboard cells +#define COLUMN_TRACKER 0 +#define COLUMN_NAME 1 +#define COLUMN_CLASS 2 +#define COLUMN_KILLS 3 +#define COLUMN_DEATHS 4 +#define COLUMN_LATENCY 5 +#define COLUMN_VOICE 6 +#define COLUMN_BLANK 7 +#define NUM_COLUMNS 8 +#define NUM_ROWS (MAX_PLAYERS + (MAX_SCOREBOARD_TEAMS * 2)) + +using namespace vgui; + +class CTextImage2 : public Image +{ +public: + CTextImage2() + { + _image[0] = new TextImage(""); + _image[1] = new TextImage(""); + } + + ~CTextImage2() + { + delete _image[0]; + delete _image[1]; + } + + TextImage *GetImage(int image) + { + return _image[image]; + } + + void getSize(int &wide, int &tall) + { + int w1, w2, t1, t2; + _image[0]->getTextSize(w1, t1); + _image[1]->getTextSize(w2, t2); + + wide = w1 + w2; + tall = Q_max(t1, t2); + setSize(wide, tall); + } + + void doPaint(Panel *panel) + { + _image[0]->doPaint(panel); + _image[1]->doPaint(panel); + } + + void setPos(int x, int y) + { + _image[0]->setPos(x, y); + + int swide, stall; + _image[0]->getSize(swide, stall); + + int wide, tall; + _image[1]->getSize(wide, tall); + _image[1]->setPos(x + wide, y + (stall * 0.9) - tall); + } + + void setColor(Color color) + { + _image[0]->setColor(color); + } + + void setColor2(Color color) + { + _image[1]->setColor(color); + } + +private: + TextImage *_image[2]; + +}; + +//----------------------------------------------------------------------------- +// Purpose: Custom label for cells in the Scoreboard's Table Header +//----------------------------------------------------------------------------- +class CLabelHeader : public Label +{ +public: + CLabelHeader() : Label("") + { + _dualImage = new CTextImage2(); + _dualImage->setColor2(Color(255, 170, 0, 0)); + _row = -2; + _useFgColorAsImageColor = true; + _offset[0] = 0; + _offset[1] = 0; + } + + ~CLabelHeader() + { + delete _dualImage; + } + + void setRow(int row) + { + _row = row; + } + + void setFgColorAsImageColor(bool state) + { + _useFgColorAsImageColor = state; + } + + virtual void setText(int textBufferLen, const char* text) + { + _dualImage->GetImage(0)->setText(text); + + // calculate the text size + Font *font = _dualImage->GetImage(0)->getFont(); + _gap = 0; + for (const char *ch = text; *ch != 0; ch++) + { + int a, b, c; + font->getCharABCwide(*ch, a, b, c); + _gap += (a + b + c); + } + + _gap += XRES(5); + } + + virtual void setText(const char* text) + { + // strip any non-alnum characters from the end + char buf[512]; + strcpy(buf, text); + + int len = strlen(buf); + while (len && isspace(buf[--len])) + { + buf[len] = 0; + } + + CLabelHeader::setText(0, buf); + } + + void setText2(const char *text) + { + _dualImage->GetImage(1)->setText(text); + } + + void getTextSize(int &wide, int &tall) + { + _dualImage->getSize(wide, tall); + } + + void setFgColor(int r,int g,int b,int a) + { + Label::setFgColor(r,g,b,a); + Color color(r,g,b,a); + _dualImage->setColor(color); + _dualImage->setColor2(color); + repaint(); + } + + void setFgColor(Scheme::SchemeColor sc) + { + int r, g, b, a; + Label::setFgColor(sc); + Label::getFgColor( r, g, b, a ); + + // Call the r,g,b,a version so it sets the color in the dualImage.. + setFgColor( r, g, b, a ); + } + + void setFont(Font *font) + { + _dualImage->GetImage(0)->setFont(font); + } + + void setFont2(Font *font) + { + _dualImage->GetImage(1)->setFont(font); + } + + // this adjust the absolute position of the text after alignment is calculated + void setTextOffset(int x, int y) + { + _offset[0] = x; + _offset[1] = y; + } + + void paint(); + void paintBackground(); + void calcAlignment(int iwide, int itall, int &x, int &y); + +private: + CTextImage2 *_dualImage; + int _row; + int _gap; + int _offset[2]; + bool _useFgColorAsImageColor; +}; + +class ScoreTablePanel; + +#include "../game_shared/vgui_grid.h" +#include "../game_shared/vgui_defaultinputsignal.h" + +//----------------------------------------------------------------------------- +// Purpose: Scoreboard back panel +//----------------------------------------------------------------------------- +class ScorePanel : public Panel, public vgui::CDefaultInputSignal +{ +private: + // Default panel implementation doesn't forward mouse messages when there is no cursor and we need them. + class HitTestPanel : public Panel + { + public: + virtual void internalMousePressed(MouseCode code); + }; + + +private: + + Label m_TitleLabel; + + // Here is how these controls are arranged hierarchically. + // m_HeaderGrid + // m_HeaderLabels + + // m_PlayerGridScroll + // m_PlayerGrid + // m_PlayerEntries + + CGrid m_HeaderGrid; + CLabelHeader m_HeaderLabels[NUM_COLUMNS]; // Labels above the + CLabelHeader *m_pCurrentHighlightLabel; + int m_iHighlightRow; + + vgui::CListBox m_PlayerList; + CGrid m_PlayerGrids[NUM_ROWS]; // The grid with player and team info. + CLabelHeader m_PlayerEntries[NUM_COLUMNS][NUM_ROWS]; // Labels for the grid entries. + + ScorePanel::HitTestPanel m_HitTestPanel; + CommandButton *m_pCloseButton; + CLabelHeader* GetPlayerEntry(int x, int y) {return &m_PlayerEntries[x][y];} + +public: + + int m_iNumTeams; + int m_iPlayerNum; + int m_iShowscoresHeld; + + int m_iRows; + int m_iSortedRows[NUM_ROWS]; + int m_iIsATeam[NUM_ROWS]; + bool m_bHasBeenSorted[MAX_PLAYERS]; + int m_iLastKilledBy; + int m_fLastKillTime; + + +public: + + ScorePanel(int x,int y,int wide,int tall); + + void Update( void ); + + void SortTeams( void ); + void SortPlayers( int iTeam, char *team ); + void RebuildTeams( void ); + + void FillGrid(); + + void DeathMsg( int killer, int victim ); + + void Initialize( void ); + + void Open( void ); + + void MouseOverCell(int row, int col); + +// InputSignal overrides. +public: + + virtual void mousePressed(MouseCode code, Panel* panel); + virtual void cursorMoved(int x, int y, Panel *panel); + + friend class CLabelHeader; +}; + +#endif diff --git a/cl_dll/vgui_SpectatorPanel.cpp b/cl_dll/vgui_SpectatorPanel.cpp new file mode 100644 index 00000000..2d78b932 --- /dev/null +++ b/cl_dll/vgui_SpectatorPanel.cpp @@ -0,0 +1,420 @@ +//========= Copyright � 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +// vgui_SpectatorPanel.cpp: implementation of the SpectatorPanel class. +// +////////////////////////////////////////////////////////////////////// + +#include "hud.h" +#include "cl_util.h" +#include "const.h" +#include "entity_state.h" +#include "cl_entity.h" +#include "pm_shared.h" +#include "vgui_TeamFortressViewport.h" +#include "vgui_SpectatorPanel.h" +#include "vgui_ScorePanel.h" + +//#include "Exports.h" + +/* +========================== +HUD_ChatInputPosition + +Sets the location of the input for chat text +========================== +*/ + +extern "C" void DLLEXPORT HUD_ChatInputPosition( int *x, int *y ) +{ +// RecClChatInputPosition( x, y ); + + if ( g_iUser1 != 0 || gEngfuncs.IsSpectateOnly() ) + { + if ( gHUD.m_Spectator.m_pip->value == INSET_OFF ) + { + *y = YRES( PANEL_HEIGHT ); + } + else + { + *y = YRES( gHUD.m_Spectator.m_OverviewData.insetWindowHeight + 5 ); + } + } +} + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +SpectatorPanel::SpectatorPanel( int x, int y, int wide, int tall ) : Panel( x, y, wide, tall ) +{ +} + +SpectatorPanel::~SpectatorPanel() +{ +} + +void SpectatorPanel::ActionSignal( int cmd ) +{ + switch( cmd ) + { + case SPECTATOR_PANEL_CMD_NONE : break; + + case SPECTATOR_PANEL_CMD_OPTIONS : gViewPort->ShowCommandMenu( gViewPort->m_SpectatorOptionsMenu ); + break; + + case SPECTATOR_PANEL_CMD_NEXTPLAYER : gHUD.m_Spectator.FindNextPlayer(true); + break; + + case SPECTATOR_PANEL_CMD_PREVPLAYER : gHUD.m_Spectator.FindNextPlayer(false); + break; + + case SPECTATOR_PANEL_CMD_PLAYERS : gViewPort->ShowCommandMenu( gViewPort->m_PlayerMenu ); + break; + + case SPECTATOR_PANEL_CMD_HIDEMENU : ShowMenu(false); + break; + + case SPECTATOR_PANEL_CMD_CAMERA : gViewPort->ShowCommandMenu( gViewPort->m_SpectatorCameraMenu ); + break; + + case SPECTATOR_PANEL_CMD_TOGGLE_INSET : gHUD.m_Spectator.SetModes( -1, + gHUD.m_Spectator.ToggleInset(false) ); + break; + + + default : gEngfuncs.Con_DPrintf("Unknown SpectatorPanel ActionSingal %i.\n",cmd); break; + } +} + +void SpectatorPanel::Initialize() +{ + int x, y, wide, tall; + + getBounds( x, y, wide, tall ); + + CSchemeManager *pSchemes = gViewPort->GetSchemeManager(); + + SchemeHandle_t hSmallScheme = pSchemes->getSchemeHandle( "Team Info Text" ); + + m_TopBorder = new CTransparentPanel( 64, 0, 0, ScreenWidth, YRES( PANEL_HEIGHT ) ); + m_TopBorder->setParent( this ); + + m_BottomBorder = new CTransparentPanel( 64, 0, ScreenHeight - YRES( 32 ), ScreenWidth, YRES( PANEL_HEIGHT ) ); + m_BottomBorder->setParent( this ); + + setPaintBackgroundEnabled( false ); + + m_ExtraInfo = new Label( "Extra Info", 0, 0, wide, YRES( PANEL_HEIGHT ) ); + m_ExtraInfo->setParent( m_TopBorder ); + m_ExtraInfo->setFont( pSchemes->getFont( hSmallScheme ) ); + + m_ExtraInfo->setPaintBackgroundEnabled( false ); + m_ExtraInfo->setFgColor( 143, 143, 54, 0 ); + m_ExtraInfo->setContentAlignment( vgui::Label::a_west ); + + m_TimerImage = new CImageLabel( "timer", 0, 0, 14, 14 ); + m_TimerImage->setParent( m_TopBorder ); + + m_TopBanner = new CImageLabel( "banner", 0, 0, XRES( BANNER_WIDTH ), YRES( BANNER_HEIGHT ) ); + m_TopBanner->setParent( this ); + + m_CurrentTime = new Label( "00:00", 0, 0, wide, YRES( PANEL_HEIGHT ) ); + m_CurrentTime->setParent( m_TopBorder ); + m_CurrentTime->setFont( pSchemes->getFont( hSmallScheme ) ); + m_CurrentTime->setPaintBackgroundEnabled( false ); + m_CurrentTime->setFgColor( 143, 143, 54, 0 ); + m_CurrentTime->setContentAlignment( vgui::Label::a_west ); + + m_Separator = new Panel( 0, 0, XRES( 64 ), YRES( 96 ) ); + m_Separator->setParent( m_TopBorder ); + m_Separator->setFgColor( 59, 58, 34, 48 ); + m_Separator->setBgColor( 59, 58, 34, 48 ); + + for( int j = 0; j < TEAM_NUMBER; j++ ) + { + m_TeamScores[j] = new Label( " ", 0, 0, wide, YRES( PANEL_HEIGHT ) ); + m_TeamScores[j]->setParent( m_TopBorder ); + m_TeamScores[j]->setFont( pSchemes->getFont( hSmallScheme ) ); + m_TeamScores[j]->setPaintBackgroundEnabled( false ); + m_TeamScores[j]->setFgColor( 143, 143, 54, 0 ); + m_TeamScores[j]->setContentAlignment( vgui::Label::a_west ); + m_TeamScores[j]->setVisible( false ); + } + + // Initialize command buttons. +// m_OptionButton = new ColorButton( CHudTextMessage::BufferedLocaliseTextString( "#SPECT_OPTIONS" ), XRES(15), YRES(6), XRES(OPTIONS_BUTTON_X), YRES(20), false, false ); + m_OptionButton = new DropDownButton( CHudTextMessage::BufferedLocaliseTextString( "#SPECT_OPTIONS" ), XRES(15), YRES(6), XRES(OPTIONS_BUTTON_X), YRES(20), false, false ); + m_OptionButton->setParent( m_BottomBorder ); + m_OptionButton->setContentAlignment( vgui::Label::a_center ); + m_OptionButton->setBoundKey( (char)255 ); // special no bound to avoid leading spaces in name + m_OptionButton->addActionSignal( new CSpectatorHandler_Command( this, SPECTATOR_PANEL_CMD_OPTIONS ) ); + m_OptionButton->setUnArmedBorderColor( 59, 58, 34, 48 ); + m_OptionButton->setArmedBorderColor( 194, 202, 54, 0 ); + m_OptionButton->setUnArmedColor( 143, 143, 54, 0 ); + m_OptionButton->setArmedColor( 194, 202, 54, 0 ); + + m_CamButton = new DropDownButton( CHudTextMessage::BufferedLocaliseTextString( "#CAM_OPTIONS" ), ScreenWidth - ( XRES ( CAMOPTIONS_BUTTON_X ) + 15 ), YRES(6), XRES ( CAMOPTIONS_BUTTON_X ), YRES(20), false, false ); + m_CamButton->setParent( m_BottomBorder ); + m_CamButton->setContentAlignment( vgui::Label::a_center ); + m_CamButton->setBoundKey( (char)255 ); // special no bound to avoid leading spaces in name + m_CamButton->addActionSignal( new CSpectatorHandler_Command( this, SPECTATOR_PANEL_CMD_CAMERA ) ); + m_CamButton->setUnArmedBorderColor( 59, 58, 34, 48 ); + m_CamButton->setArmedBorderColor( 194, 202, 54, 0 ); + m_CamButton->setUnArmedColor( 143, 143, 54, 0 ); + m_CamButton->setArmedColor( 194, 202, 54, 0 ); + +// m_PrevPlayerButton= new ColorButton("<", XRES( 15 + OPTIONS_BUTTON_X + 15 ), YRES(6), XRES(24), YRES(20), false, false ); + m_PrevPlayerButton= new CImageButton("arrowleft", XRES( 15 + OPTIONS_BUTTON_X + 15 ), YRES(6), XRES(24), YRES(20), false, false ); + m_PrevPlayerButton->setParent( m_BottomBorder ); + m_PrevPlayerButton->setContentAlignment( vgui::Label::a_center ); + m_PrevPlayerButton->setBoundKey( (char)255 ); // special no bound to avoid leading spaces in name + m_PrevPlayerButton->addActionSignal( new CSpectatorHandler_Command( this, SPECTATOR_PANEL_CMD_PREVPLAYER ) ); + m_PrevPlayerButton->setUnArmedBorderColor( 59, 58, 34, 48 ); + m_PrevPlayerButton->setArmedBorderColor( 194, 202, 54, 0 ); + m_PrevPlayerButton->setUnArmedColor( 143, 143, 54, 0 ); + m_PrevPlayerButton->setArmedColor( 194, 202, 54, 0 ); + +// m_NextPlayerButton= new ColorButton(">", (ScreenWidth - (XRES ( CAMOPTIONS_BUTTON_X ) + 15)) - XRES ( 24 + 15 ), YRES(6), XRES(24), YRES(20),false, false ); + m_NextPlayerButton= new CImageButton("arrowright", (ScreenWidth - (XRES ( CAMOPTIONS_BUTTON_X ) + 15)) - XRES ( 24 + 15 ), YRES(6), XRES(24), YRES(20),false, false ); + m_NextPlayerButton->setParent( m_BottomBorder ); + m_NextPlayerButton->setContentAlignment( vgui::Label::a_center ); + m_NextPlayerButton->setBoundKey( (char)255 ); // special no bound to avoid leading spaces in name + m_NextPlayerButton->addActionSignal( new CSpectatorHandler_Command( this, SPECTATOR_PANEL_CMD_NEXTPLAYER ) ); + m_NextPlayerButton->setUnArmedBorderColor( 59, 58, 34, 48 ); + m_NextPlayerButton->setArmedBorderColor( 194, 202, 54, 0 ); + m_NextPlayerButton->setUnArmedColor( 143, 143, 54, 0 ); + m_NextPlayerButton->setArmedColor( 194, 202, 54, 0 ); + + // Initialize the bottom title. + float flLabelSize = ( ( ScreenWidth - ( XRES ( CAMOPTIONS_BUTTON_X ) + 15 ) ) - XRES( 24 + 15 ) ) - XRES( ( 15 + OPTIONS_BUTTON_X + 15 ) + 38 ); + + m_BottomMainButton = new DropDownButton("Spectator Bottom", + XRES( ( 15 + OPTIONS_BUTTON_X + 15 ) + 31 ), YRES(6), flLabelSize, YRES(20), + false, false ); + + m_BottomMainButton->setParent(m_BottomBorder); + m_BottomMainButton->setPaintBackgroundEnabled(false); + m_BottomMainButton->setFgColor( Scheme::sc_primary1 ); + m_BottomMainButton->setContentAlignment( vgui::Label::a_center ); + m_BottomMainButton->setBorder( new LineBorder( Color( 59, 58, 34, 48 ) ) ); + m_BottomMainButton->setBoundKey( (char)255 ); // special no bound to avoid leading spaces in name + m_BottomMainButton->addActionSignal( new CSpectatorHandler_Command(this,SPECTATOR_PANEL_CMD_PLAYERS) ); + m_BottomMainButton->setUnArmedBorderColor ( 59, 58, 34, 48 ); + m_BottomMainButton->setArmedBorderColor ( 194, 202, 54, 0 ); + m_BottomMainButton->setUnArmedColor ( 143, 143, 54, 0 ); + m_BottomMainButton->setArmedColor ( 194, 202, 54, 0 ); + + + m_BottomMainLabel = new Label("Spectator Bottom", + XRES( ( 15 + OPTIONS_BUTTON_X + 15 ) + 31 ), YRES(6), flLabelSize, YRES(20)); + + m_BottomMainLabel->setParent( m_BottomBorder ); + m_BottomMainLabel->setPaintBackgroundEnabled( false ); + m_BottomMainLabel->setFgColor( Scheme::sc_primary1 ); + m_BottomMainLabel->setContentAlignment( vgui::Label::a_center ); + m_BottomMainLabel->setBorder( NULL ); + m_BottomMainLabel->setVisible(false); + + m_InsetViewButton = new ColorButton( "", XRES( 2 ), YRES( 2 ), XRES( 240 ), YRES( 180 ), false, false ); + m_InsetViewButton->setParent( this ); + m_InsetViewButton->setBoundKey( (char)255 ); + m_InsetViewButton->addActionSignal( new CSpectatorHandler_Command( this, SPECTATOR_PANEL_CMD_TOGGLE_INSET ) ); + m_InsetViewButton->setUnArmedBorderColor( 59, 58, 34, 48 ); + m_InsetViewButton->setArmedBorderColor( 194, 202, 54, 0 ); + m_InsetViewButton->setUnArmedColor( 143, 143, 54, 0 ); + m_InsetViewButton->setArmedColor( 194, 202, 54, 0 ); + + m_menuVisible = false; + m_insetVisible = false; + // m_HideButton->setVisible( false ); + m_CamButton->setVisible( false ); + m_OptionButton->setVisible( false ); + m_NextPlayerButton->setVisible( false ); + m_PrevPlayerButton->setVisible( false ); + m_TopBanner->setVisible( false ); + m_ExtraInfo->setVisible( false ); + m_Separator->setVisible( false ); + m_TimerImage->setVisible( false ); +} + +void SpectatorPanel::ShowMenu( bool isVisible ) +{ +// m_HideButton->setVisible(isVisible); m_HideButton->setArmed( false ); + m_OptionButton->setVisible(isVisible); m_OptionButton->setArmed( false ); + m_CamButton->setVisible(isVisible); m_CamButton->setArmed( false ); + m_NextPlayerButton->setVisible(isVisible); m_NextPlayerButton->setArmed( false ); + m_PrevPlayerButton->setVisible(isVisible); m_PrevPlayerButton->setArmed( false ); + + if( !isVisible ) + { + int iLabelSizeX, iLabelSizeY; + m_BottomMainLabel->setVisible(true); + m_BottomMainButton->setVisible(false); + + m_BottomMainLabel->getSize( iLabelSizeX, iLabelSizeY ); + m_BottomMainLabel->setPos( ( ScreenWidth / 2 ) - ( iLabelSizeX / 2 ), YRES( 6 ) ); + } + else + { + m_BottomMainButton->setPos( XRES( ( 15 + OPTIONS_BUTTON_X + 15 ) + 31 ), YRES(6) ); + m_BottomMainLabel->setVisible(false); + m_BottomMainButton->setVisible(true); + } + + if( !isVisible ) + { + gViewPort->HideCommandMenu(); + + // if switching from visible menu to invisible menu, show help text + if( m_menuVisible && this->isVisible() ) + { + char string[64]; + + _snprintf( string, sizeof(string) - 1, "%c%s", HUD_PRINTCENTER, CHudTextMessage::BufferedLocaliseTextString( "#Spec_Duck" ) ); + string[sizeof(string) - 1] = '\0'; + + gHUD.m_TextMessage.MsgFunc_TextMsg( NULL, strlen( string ) + 1, string ); + } + } + + m_menuVisible = isVisible; + + gViewPort->UpdateCursorState(); +} + +const char *GetSpectatorLabel( int iMode ) +{ + switch( iMode ) + { + case OBS_CHASE_LOCKED: + return "#OBS_CHASE_LOCKED"; + + case OBS_CHASE_FREE: + return "#OBS_CHASE_FREE"; + + case OBS_ROAMING: + return "#OBS_ROAMING"; + + case OBS_IN_EYE: + return "#OBS_IN_EYE"; + + case OBS_MAP_FREE: + return "#OBS_MAP_FREE"; + + case OBS_MAP_CHASE: + return "#OBS_MAP_CHASE"; + + case OBS_NONE: + default: + return "#OBS_NONE"; + } + + return ""; +} + +void SpectatorPanel::EnableInsetView(bool isEnabled) +{ + int x = gHUD.m_Spectator.m_OverviewData.insetWindowX; + int y = gHUD.m_Spectator.m_OverviewData.insetWindowY; + int wide = gHUD.m_Spectator.m_OverviewData.insetWindowWidth; + int tall = gHUD.m_Spectator.m_OverviewData.insetWindowHeight; + int offset = x + wide + 2; + + if( isEnabled ) + { + // short black bar to see full inset + m_TopBorder->setBounds( XRES( offset ), 0, XRES(640 - offset ), YRES( PANEL_HEIGHT ) ); + + if( gEngfuncs.IsSpectateOnly() ) + { + m_TopBanner->setVisible( true ); + m_TopBanner->setPos( XRES( offset ), 0 ); + } + else + m_TopBanner->setVisible( false ); + + m_InsetViewButton->setBounds( XRES( x -1 ), YRES( y ), + XRES( wide +2), YRES( tall ) ); + m_InsetViewButton->setVisible( true ); + } + else + { + // full black bar, no inset border + // show banner only in real HLTV mode + if( gEngfuncs.IsSpectateOnly() ) + { + m_TopBanner->setVisible( true ); + m_TopBanner->setPos( 0, 0 ); + } + else + m_TopBanner->setVisible( false ); + + m_TopBorder->setBounds( 0, 0, ScreenWidth, YRES( PANEL_HEIGHT ) ); + + m_InsetViewButton->setVisible( false ); + } + + m_insetVisible = isEnabled; + + Update(); + + m_CamButton->setText( CHudTextMessage::BufferedLocaliseTextString( GetSpectatorLabel( g_iUser1 ) ) ); +} + +void SpectatorPanel::Update() +{ + int iTextWidth, iTextHeight; + int iTimeHeight, iTimeWidth; + int offset, j; + + if( m_insetVisible ) + offset = gHUD.m_Spectator.m_OverviewData.insetWindowX + gHUD.m_Spectator.m_OverviewData.insetWindowWidth + 2; + else + offset = 0; + + bool visible = gHUD.m_Spectator.m_drawstatus->value != 0; + + m_ExtraInfo->setVisible( visible ); + m_TimerImage->setVisible( visible ); + m_CurrentTime->setVisible( visible ); + m_Separator->setVisible( visible ); + + for( j = 0; j < TEAM_NUMBER; j++ ) + m_TeamScores[j]->setVisible( visible ); + + if( !visible ) + return; + + m_ExtraInfo->getTextSize( iTextWidth, iTextHeight ); + m_CurrentTime->getTextSize( iTimeWidth, iTimeHeight ); + + iTimeWidth += XRES ( SEPERATOR_WIDTH*2 + 1 ); // +timer icon + iTimeWidth += ( SEPERATOR_WIDTH-(iTimeWidth%SEPERATOR_WIDTH) ); + + if( iTimeWidth > iTextWidth ) + iTextWidth = iTimeWidth; + + int xPos = ScreenWidth - ( iTextWidth + XRES ( SEPERATOR_WIDTH + offset ) ); + + m_ExtraInfo->setBounds( xPos, YRES( SEPERATOR_HEIGHT ), iTextWidth, iTextHeight ); + + m_TimerImage->setBounds( xPos, YRES( SEPERATOR_HEIGHT ) + iTextHeight , XRES(SEPERATOR_WIDTH*2 + 1), YRES(SEPERATOR_HEIGHT + 1) ); + + m_CurrentTime->setBounds( xPos + XRES ( SEPERATOR_WIDTH*2 + 1 ), YRES( SEPERATOR_HEIGHT ) + iTextHeight , iTimeWidth, iTimeHeight ); + + m_Separator->setPos( ScreenWidth - ( iTextWidth + XRES ( 2*SEPERATOR_WIDTH+SEPERATOR_WIDTH/2+offset ) ) , YRES( 5 ) ); + m_Separator->setSize( XRES( 1 ), PANEL_HEIGHT - 10 ); + + for( j = 0; j < TEAM_NUMBER; j++ ) + { + int iwidth, iheight; + + m_TeamScores[j]->getTextSize( iwidth, iheight ); + m_TeamScores[j]->setBounds( ScreenWidth - ( iTextWidth + XRES ( 2*SEPERATOR_WIDTH+2*SEPERATOR_WIDTH/2+offset ) + iwidth ), YRES( SEPERATOR_HEIGHT ) + ( iheight * j ), iwidth, iheight ); + } +} diff --git a/cl_dll/vgui_SpectatorPanel.h b/cl_dll/vgui_SpectatorPanel.h new file mode 100644 index 00000000..5312e963 --- /dev/null +++ b/cl_dll/vgui_SpectatorPanel.h @@ -0,0 +1,111 @@ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +// vgui_SpectatorPanel.h: interface for the SpectatorPanel class. +// +////////////////////////////////////////////////////////////////////// + +#ifndef SPECTATORPANEL_H +#define SPECTATORPANEL_H + +#include +#include +#include + +using namespace vgui; + +#define SPECTATOR_PANEL_CMD_NONE 0 + +#define SPECTATOR_PANEL_CMD_OPTIONS 1 +#define SPECTATOR_PANEL_CMD_PREVPLAYER 2 +#define SPECTATOR_PANEL_CMD_NEXTPLAYER 3 +#define SPECTATOR_PANEL_CMD_HIDEMENU 4 +#define SPECTATOR_PANEL_CMD_TOGGLE_INSET 5 +#define SPECTATOR_PANEL_CMD_CAMERA 6 +#define SPECTATOR_PANEL_CMD_PLAYERS 7 + +// spectator panel sizes +#define PANEL_HEIGHT 64 + +#define BANNER_WIDTH 256 +#define BANNER_HEIGHT 64 + +#define OPTIONS_BUTTON_X 96 +#define CAMOPTIONS_BUTTON_X 200 + + +#define SEPERATOR_WIDTH 15 +#define SEPERATOR_HEIGHT 15 + + +#define TEAM_NUMBER 2 + +class SpectatorPanel : public Panel //, public vgui::CDefaultInputSignal +{ + +public: + SpectatorPanel( int x, int y, int wide, int tall ); + virtual ~SpectatorPanel(); + + void ActionSignal( int cmd ); + + // InputSignal overrides. +public: + void Initialize(); + void Update(); + + void EnableInsetView( bool isEnabled ); + void ShowMenu( bool isVisible ); + + DropDownButton * m_OptionButton; + // CommandButton *m_HideButton; + //ColorButton * m_PrevPlayerButton; + //ColorButton * m_NextPlayerButton; + CImageButton * m_PrevPlayerButton; + CImageButton * m_NextPlayerButton; + DropDownButton * m_CamButton; + + CTransparentPanel *m_TopBorder; + CTransparentPanel *m_BottomBorder; + + ColorButton *m_InsetViewButton; + + DropDownButton *m_BottomMainButton; + CImageLabel *m_TimerImage; + Label *m_BottomMainLabel; + Label *m_CurrentTime; + Label *m_ExtraInfo; + Panel *m_Separator; + + Label *m_TeamScores[TEAM_NUMBER]; + + CImageLabel *m_TopBanner; + + bool m_menuVisible; + bool m_insetVisible; +}; + +class CSpectatorHandler_Command : public ActionSignal +{ + +private: + SpectatorPanel *m_pFather; + int m_cmd; + +public: + CSpectatorHandler_Command( SpectatorPanel *panel, int cmd ) + { + m_pFather = panel; + m_cmd = cmd; + } + + virtual void actionPerformed( Panel *panel ) + { + m_pFather->ActionSignal( m_cmd ); + } +}; +#endif // !defined SPECTATORPANEL_H diff --git a/cl_dll/vgui_TeamFortressViewport.cpp b/cl_dll/vgui_TeamFortressViewport.cpp new file mode 100644 index 00000000..21a8a928 --- /dev/null +++ b/cl_dll/vgui_TeamFortressViewport.cpp @@ -0,0 +1,2172 @@ +//=========== (C) Copyright 1996-2002 Valve, L.L.C. All rights reserved. =========== +// +// The copyright to the contents herein is the property of Valve, L.L.C. +// The contents may be used and/or copied only with the written permission of +// Valve, L.L.C., or in accordance with the terms and conditions stipulated in +// the agreement/contract under which the contents have been supplied. +// +// Purpose: Client DLL VGUI Viewport +// +// $Workfile: $ +// $Date: $ +// +//----------------------------------------------------------------------------- +// $Log: $ +// +// $NoKeywords: $ +//============================================================================= +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "hud.h" +#include "cl_util.h" +#include "camera.h" +#include "kbutton.h" +#include "cvardef.h" +#include "usercmd.h" +#include "const.h" +#include "camera.h" +#include "in_defs.h" +#include "parsemsg.h" +#include "pm_shared.h" +#include "keydefs.h" +#include "demo.h" +#include "demo_api.h" + +#include "vgui_int.h" +#include "vgui_TeamFortressViewport.h" +#include "vgui_ScorePanel.h" +#include "vgui_SpectatorPanel.h" + +#include "shake.h" +#include "screenfade.h" + +void IN_SetVisibleMouse(bool visible); +class CCommandMenu; + +// Scoreboard positions +#define SBOARD_INDENT_X XRES( 104 ) +#define SBOARD_INDENT_Y YRES( 40 ) + +// low-res scoreboard indents +#define SBOARD_INDENT_X_512 30 +#define SBOARD_INDENT_Y_512 30 + +#define SBOARD_INDENT_X_400 0 +#define SBOARD_INDENT_Y_400 20 + +void IN_ResetMouse( void ); +extern CMenuPanel *CMessageWindowPanel_Create( const char *szMOTD, const char *szTitle, int iShadeFullscreen, int iRemoveMe, int x, int y, int wide, int tall ); +extern float *GetClientColor( int clientIndex ); + +using namespace vgui; + +// Team Colors +int iNumberOfTeamColors = 5; +int iTeamColors[5][3] = +{ + { 255, 170, 0 }, // HL orange (default) + { 125, 165, 210 }, // Blue + { 200, 90, 70 }, // Red + { 225, 205, 45 }, // Yellow + { 145, 215, 140 }, // Green +}; + +// Used for Class specific buttons +const char *sTFClasses[] = +{ + "", + "SCOUT", + "SNIPER", + "SOLDIER", + "DEMOMAN", + "MEDIC", + "HWGUY", + "PYRO", + "SPY", + "ENGINEER", + "CIVILIAN", +}; + +const char *sLocalisedClasses[] = +{ + "#Civilian", + "#Scout", + "#Sniper", + "#Soldier", + "#Demoman", + "#Medic", + "#HWGuy", + "#Pyro", + "#Spy", + "#Engineer", + "#Random", + "#Civilian", +}; + +const char *sTFClassSelection[] = +{ + "civilian", + "scout", + "sniper", + "soldier", + "demoman", + "medic", + "hwguy", + "pyro", + "spy", + "engineer", + "randompc", + "civilian", +}; + + +// Get the name of TGA file, based on GameDir +char *GetVGUITGAName( const char *pszName ) +{ + int i; + char sz[256]; + static char gd[256]; + const char *gamedir; + + if( ScreenWidth < 640 ) + i = 320; + else + i = 640; + + sprintf( sz, pszName, i ); + + gamedir = gEngfuncs.pfnGetGameDirectory(); + sprintf( gd, "%s/gfx/vgui/%s.tga", gamedir, sz ); + + return gd; +} + +//================================================================ +// COMMAND MENU +//================================================================ +void CCommandMenu::AddButton( CommandButton *pButton ) +{ + if( m_iButtons >= MAX_BUTTONS ) + return; + + m_aButtons[m_iButtons] = pButton; + m_iButtons++; + pButton->setParent( this ); + pButton->setFont( Scheme::sf_primary3 ); + + // give the button a default key binding + if( m_iButtons < 10 ) + { + pButton->setBoundKey( m_iButtons + '0' ); + } + else if( m_iButtons == 10 ) + { + pButton->setBoundKey( '0' ); + } +} + +void CCommandMenu::RemoveAllButtons(void) +{ + /* + for(int i=0;iIsNotValid() ) + { + if( m_aButtons[i]->getBoundKey() == keyNum ) + { + // hit the button + if( m_aButtons[i]->GetSubMenu() ) + { + // open the sub menu + gViewPort->SetCurrentCommandMenu( m_aButtons[i]->GetSubMenu() ); + return false; + } + else + { + // run the bound command + m_aButtons[i]->fireActionSignal(); + return true; + } + } + } + } + + return false; +} + +//----------------------------------------------------------------------------- +// Purpose: clears the current menus buttons of any armed (highlighted) +// state, and all their sub buttons +//----------------------------------------------------------------------------- +void CCommandMenu::ClearButtonsOfArmedState( void ) +{ + for( int i = 0; i < GetNumButtons(); i++ ) + { + m_aButtons[i]->setArmed( false ); + + if( m_aButtons[i]->GetSubMenu() ) + { + m_aButtons[i]->GetSubMenu()->ClearButtonsOfArmedState(); + } + } +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : *pSubMenu - +// Output : CommandButton +//----------------------------------------------------------------------------- +CommandButton *CCommandMenu::FindButtonWithSubmenu( CCommandMenu *pSubMenu ) +{ + for( int i = 0; i < GetNumButtons(); i++ ) + { + if( m_aButtons[i]->GetSubMenu() == pSubMenu ) + return m_aButtons[i]; + } + + return NULL; +} + +// Recalculate the visible buttons +bool CCommandMenu::RecalculateVisibles( int iYOffset, bool bHideAll ) +{ + int i, iCurrentY = 0; + int iVisibleButtons = 0; + + // Cycle through all the buttons in this menu, and see which will be visible + for( i = 0; i < m_iButtons; i++ ) + { + int iClass = m_aButtons[i]->GetPlayerClass(); + + if( ( iClass && iClass != g_iPlayerClass ) || ( m_aButtons[i]->IsNotValid() ) || bHideAll ) + { + m_aButtons[i]->setVisible( false ); + if( m_aButtons[i]->GetSubMenu() != NULL ) + { + (m_aButtons[i]->GetSubMenu())->RecalculateVisibles( 0, true ); + } + } + else + { + // If it's got a submenu, force it to check visibilities + if( m_aButtons[i]->GetSubMenu() != NULL ) + { + if( !( m_aButtons[i]->GetSubMenu() )->RecalculateVisibles( 0, false ) ) + { + // The submenu had no visible buttons, so don't display this button + m_aButtons[i]->setVisible( false ); + continue; + } + } + + m_aButtons[i]->setVisible( true ); + iVisibleButtons++; + } + } + + // Set Size + setSize( _size[0], ( iVisibleButtons * ( m_flButtonSizeY - 1 ) ) + 1 ); + + if( iYOffset ) + { + m_iYOffset = iYOffset; + } + + for( i = 0; i < m_iButtons; i++ ) + { + if( m_aButtons[i]->isVisible() ) + { + if( m_aButtons[i]->GetSubMenu() != NULL ) + ( m_aButtons[i]->GetSubMenu() )->RecalculateVisibles( iCurrentY + m_iYOffset, false ); + + // Make sure it's at the right Y position + // m_aButtons[i]->getPos( iXPos, iYPos ); + if( m_iDirection ) + { + m_aButtons[i]->setPos( 0, ( iVisibleButtons - 1 ) * ( m_flButtonSizeY - 1 ) - iCurrentY ); + } + else + { + m_aButtons[i]->setPos( 0, iCurrentY ); + } + + iCurrentY += ( m_flButtonSizeY - 1 ); + } + } + + return iVisibleButtons ? true : false; +} + +// Make sure all submenus can fit on the screen +void CCommandMenu::RecalculatePositions( int iYOffset ) +{ + int iTop; + int iAdjust = 0; + + m_iYOffset+= iYOffset; + + if( m_iDirection ) + iTop = ScreenHeight - ( m_iYOffset + _size[1] ); + else + iTop = m_iYOffset; + + if( iTop < 0 ) + iTop = 0; + + // Calculate if this is going to fit onscreen, and shuffle it up if it won't + int iBottom = iTop + _size[1]; + + if( iBottom > ScreenHeight ) + { + // Move in increments of button sizes + while( iAdjust < ( iBottom - ScreenHeight ) ) + { + iAdjust += m_flButtonSizeY - 1; + } + + iTop -= iAdjust; + + // Make sure it doesn't move off the top of the screen (the menu's too big to fit it all) + if( iTop < 0 ) + { + iAdjust -= ( 0 - iTop ); + iTop = 0; + } + } + + setPos( _pos[0], iTop ); + + // We need to force all menus below this one to update their positions now, because they + // might have submenus riding off buttons in this menu that have just shifted. + for( int i = 0; i < m_iButtons; i++ ) + m_aButtons[i]->UpdateSubMenus( iAdjust ); +} + +// Make this menu and all menus above it in the chain visible +void CCommandMenu::MakeVisible( CCommandMenu *pChildMenu ) +{ +/* + // Push down the button leading to the child menu + for( int i = 0; i < m_iButtons; i++ ) + { + if( ( pChildMenu != NULL ) && ( m_aButtons[i]->GetSubMenu() == pChildMenu ) ) + { + m_aButtons[i]->setArmed( true ); + } + else + { + m_aButtons[i]->setArmed( false ); + } + } +*/ + + setVisible( true ); + if( m_pParentMenu ) + m_pParentMenu->MakeVisible( this ); +} + +//================================================================ +// CreateSubMenu +CCommandMenu *TeamFortressViewport::CreateSubMenu( CommandButton *pButton, CCommandMenu *pParentMenu, int iYOffset, int iXOffset ) +{ + int iXPos = 0; + int iYPos = 0; + int iWide = CMENU_SIZE_X; + int iTall = 0; + int iDirection = 0; + + if( pParentMenu ) + { + iXPos = m_pCurrentCommandMenu->GetXOffset() + ( CMENU_SIZE_X - 1 ) + iXOffset; + iYPos = m_pCurrentCommandMenu->GetYOffset() + iYOffset; + iDirection = pParentMenu->GetDirection(); + } + + CCommandMenu *pMenu = new CCommandMenu( pParentMenu, iDirection, iXPos, iYPos, iWide, iTall ); + pMenu->setParent( this ); + pButton->AddSubMenu( pMenu ); + pButton->setFont( Scheme::sf_primary3 ); + pMenu->m_flButtonSizeY = m_pCurrentCommandMenu->m_flButtonSizeY; + + // Create the Submenu-open signal + InputSignal *pISignal = new CMenuHandler_PopupSubMenuInput( pButton, pMenu ); + pButton->addInputSignal( pISignal ); + + // Put a > to show it's a submenu + CImageLabel *pLabel = new CImageLabel( "arrow", CMENU_SIZE_X - SUBMENU_SIZE_X, SUBMENU_SIZE_Y ); + pLabel->setParent( pButton ); + pLabel->addInputSignal( pISignal ); + + // Reposition + pLabel->getPos( iXPos, iYPos ); + pLabel->setPos( CMENU_SIZE_X - pLabel->getImageWide(), ( BUTTON_SIZE_Y - pLabel->getImageTall() ) / 2 ); + + // Create the mouse off signal for the Label too + if( !pButton->m_bNoHighlight ) + pLabel->addInputSignal( new CHandler_CommandButtonHighlight( pButton ) ); + + return pMenu; +} + +//----------------------------------------------------------------------------- +// Purpose: Makes sure the memory allocated for TeamFortressViewport is nulled out +// Input : stAllocateBlock - +// Output : void * +//----------------------------------------------------------------------------- +void *TeamFortressViewport::operator new( size_t stAllocateBlock ) +{ +// void *mem = Panel::operator new( stAllocateBlock ); + void *mem = ::operator new( stAllocateBlock ); + memset( mem, 0, stAllocateBlock ); + return mem; +} + +//----------------------------------------------------------------------------- +// Purpose: InputSignal handler for the main viewport +//----------------------------------------------------------------------------- +class CViewPortInputHandler : public InputSignal +{ +public: + bool bPressed; + + CViewPortInputHandler() + { + } + + virtual void cursorMoved( int x, int y, Panel *panel ) {} + virtual void cursorEntered( Panel *panel ) {} + virtual void cursorExited( Panel *panel ) {} + virtual void mousePressed( MouseCode code, Panel *panel ) + { + if( code != MOUSE_LEFT ) + { + // send a message to close the command menu + // this needs to be a message, since a direct call screws the timing + gEngfuncs.pfnClientCmd( "ForceCloseCommandMenu\n" ); + } + } + + virtual void mouseReleased( MouseCode code, Panel *panel ) + { + } + + virtual void mouseDoublePressed( MouseCode code, Panel *panel ) {} + virtual void mouseWheeled( int delta, Panel *panel ) {} + virtual void keyPressed( KeyCode code, Panel *panel ) {} + virtual void keyTyped( KeyCode code, Panel *panel ) {} + virtual void keyReleased( KeyCode code, Panel *panel ) {} + virtual void keyFocusTicked( Panel *panel ) {} +}; + +//================================================================ +TeamFortressViewport::TeamFortressViewport( int x, int y, int wide, int tall ) : Panel( x, y, wide, tall ), m_SchemeManager( wide, tall ) +{ + gViewPort = this; + m_iInitialized = false; + m_pTeamMenu = NULL; + m_pClassMenu = NULL; + m_pScoreBoard = NULL; + m_pSpectatorPanel = NULL; + m_pCurrentMenu = NULL; + m_pCurrentCommandMenu = NULL; + + Initialize(); + addInputSignal( new CViewPortInputHandler ); + + int r, g, b, a; + + Scheme* pScheme = App::getInstance()->getScheme(); + + // primary text color + // Get the colors + //!! two different types of scheme here, need to integrate + SchemeHandle_t hPrimaryScheme = m_SchemeManager.getSchemeHandle( "Primary Button Text" ); + { + // font + pScheme->setFont( Scheme::sf_primary1, m_SchemeManager.getFont( hPrimaryScheme ) ); + + // text color + m_SchemeManager.getFgColor( hPrimaryScheme, r, g, b, a ); + pScheme->setColor( Scheme::sc_primary1, r, g, b, a ); // sc_primary1 is non-transparent orange + + // background color (transparent black) + m_SchemeManager.getBgColor( hPrimaryScheme, r, g, b, a ); + pScheme->setColor( Scheme::sc_primary3, r, g, b, a ); + + // armed foreground color + m_SchemeManager.getFgArmedColor( hPrimaryScheme, r, g, b, a ); + pScheme->setColor( Scheme::sc_secondary2, r, g, b, a ); + + // armed background color + m_SchemeManager.getBgArmedColor( hPrimaryScheme, r, g, b, a ); + pScheme->setColor( Scheme::sc_primary2, r, g, b, a ); + + //!! need to get this color from scheme file + // used for orange borders around buttons + m_SchemeManager.getBorderColor( hPrimaryScheme, r, g, b, a ); + // pScheme->setColor( Scheme::sc_secondary1, r, g, b, a ); + pScheme->setColor( Scheme::sc_secondary1, 255 * 0.7, 170 * 0.7, 0, 0); + } + + // Change the second primary font (used in the scoreboard) + SchemeHandle_t hScoreboardScheme = m_SchemeManager.getSchemeHandle( "Scoreboard Text" ); + { + pScheme->setFont( Scheme::sf_primary2, m_SchemeManager.getFont( hScoreboardScheme ) ); + } + + // Change the third primary font (used in command menu) + SchemeHandle_t hCommandMenuScheme = m_SchemeManager.getSchemeHandle( "CommandMenu Text" ); + { + pScheme->setFont( Scheme::sf_primary3, m_SchemeManager.getFont( hCommandMenuScheme ) ); + } + + App::getInstance()->setScheme( pScheme ); + + // VGUI MENUS + CreateTeamMenu(); + CreateClassMenu(); + CreateSpectatorMenu(); + CreateScoreBoard(); + // Init command menus + m_iNumMenus = 0; + m_iCurrentTeamNumber = m_iUser1 = m_iUser2 = m_iUser3 = 0; + + m_StandardMenu = CreateCommandMenu( "commandmenu.txt", 0, CMENU_TOP, false, CMENU_SIZE_X, BUTTON_SIZE_Y, 0 ); + m_SpectatorOptionsMenu = CreateCommandMenu("spectatormenu.txt", 1, PANEL_HEIGHT, true, CMENU_SIZE_X, BUTTON_SIZE_Y / 2, 0 ); // above bottom bar, flat design + m_SpectatorCameraMenu = CreateCommandMenu("spectcammenu.txt", 1, PANEL_HEIGHT, true, XRES( 200 ), BUTTON_SIZE_Y / 2, ScreenWidth - ( XRES ( 200 ) + 15 ) ); // above bottom bar, flat design + + m_PlayerMenu = m_iNumMenus; + m_iNumMenus++; + + float flLabelSize = ( (ScreenWidth - (XRES ( CAMOPTIONS_BUTTON_X ) + 15)) - XRES ( 24 + 15 ) ) - XRES( (15 + OPTIONS_BUTTON_X + 15) + 38 ); + + m_pCommandMenus[m_PlayerMenu] = new CCommandMenu(NULL, 1, + XRES( ( 15 + OPTIONS_BUTTON_X + 15 ) + 31 ),PANEL_HEIGHT, flLabelSize,300); + m_pCommandMenus[m_PlayerMenu]->setParent(this); + m_pCommandMenus[m_PlayerMenu]->setVisible(false); + m_pCommandMenus[m_PlayerMenu]->m_flButtonSizeY = BUTTON_SIZE_Y /2; + m_pCommandMenus[m_PlayerMenu]->m_iSpectCmdMenu = 1; + + UpdatePlayerMenu(m_PlayerMenu); +} + +//----------------------------------------------------------------------------- +// Purpose: Called everytime a new level is started. Viewport clears out it's data. +//----------------------------------------------------------------------------- +void TeamFortressViewport::Initialize( void ) +{ + // Force each menu to Initialize + if( m_pTeamMenu ) + { + m_pTeamMenu->Initialize(); + } + if( m_pClassMenu ) + { + m_pClassMenu->Initialize(); + } + if( m_pScoreBoard ) + { + m_pScoreBoard->Initialize(); + HideScoreBoard(); + } + if( m_pSpectatorPanel ) + { + // Spectator menu doesn't need initializing + m_pSpectatorPanel->setVisible( false ); + } + + // Make sure all menus are hidden + HideVGUIMenu(); + HideCommandMenu(); + + // Clear out some data + m_iGotAllMOTD = true; + m_iRandomPC = false; + m_flScoreBoardLastUpdated = 0; + m_flSpectatorPanelLastUpdated = 0; + + // reset player info + g_iPlayerClass = 0; + g_iTeamNumber = 0; + + m_sMapName[0] = '\0'; + m_szServerName[0] = '\0'; + for( int i = 0; i < 5; i++ ) + { + m_iValidClasses[i] = 0; + m_sTeamNames[i][0] = '\0'; + } + + App::getInstance()->setCursorOveride( App::getInstance()->getScheme()->getCursor(Scheme::scu_none) ); +} + +class CException; +//----------------------------------------------------------------------------- +// Purpose: Read the Command Menu structure from the txt file and create the menu. +// Returns Index of menu in m_pCommandMenus +//----------------------------------------------------------------------------- +int TeamFortressViewport::CreateCommandMenu( const char *menuFile, int direction, int yOffset, bool flatDesign, float flButtonSizeX, float flButtonSizeY, int xOffset ) +{ + // COMMAND MENU + // Create the root of this new Command Menu + int newIndex = m_iNumMenus; + + m_pCommandMenus[newIndex] = new CCommandMenu( NULL, direction, xOffset, yOffset, flButtonSizeX, 300 ); // This will be resized once we know how many items are in it + m_pCommandMenus[newIndex]->setParent( this ); + m_pCommandMenus[newIndex]->setVisible( false ); + m_pCommandMenus[newIndex]->m_flButtonSizeY = flButtonSizeY; + m_pCommandMenus[newIndex]->m_iSpectCmdMenu = direction; + + m_iNumMenus++; + + // Read Command Menu from the txt file + char token[1024]; + char *pFileStart = (char*)gEngfuncs.COM_LoadFile( menuFile, 5, NULL ); + if( !pFileStart ) + { + gEngfuncs.Con_DPrintf( "Unable to open %s\n", menuFile); + SetCurrentCommandMenu( NULL ); + return newIndex; + } + +#ifdef _WIN32 + try + { +#endif + // First, read in the localisation strings + + // Detpack strings + gHUD.m_TextMessage.LocaliseTextString( "#DetpackSet_For5Seconds", m_sDetpackStrings[0], MAX_BUTTON_SIZE ); + gHUD.m_TextMessage.LocaliseTextString( "#DetpackSet_For20Seconds", m_sDetpackStrings[1], MAX_BUTTON_SIZE ); + gHUD.m_TextMessage.LocaliseTextString( "#DetpackSet_For50Seconds", m_sDetpackStrings[2], MAX_BUTTON_SIZE ); + + // Now start parsing the menu structure + m_pCurrentCommandMenu = m_pCommandMenus[newIndex]; + char szLastButtonText[32] = "file start"; + char* pfile = gEngfuncs.COM_ParseFile( pFileStart, token ); + while( ( strlen ( token ) > 0 ) && ( m_iNumMenus < MAX_MENUS ) ) + { + // Keep looping until we hit the end of this menu + while( token[0] != '}' && ( strlen( token ) > 0 ) ) + { + char cText[32] = ""; + char cBoundKey[32] = ""; + char cCustom[32] = ""; + static const int cCommandLength = 128; + char cCommand[cCommandLength] = ""; + char szMap[MAX_MAPNAME] = ""; + int iPlayerClass = 0; + int iCustom = false; + int iTeamOnly = -1; + int iToggle = 0; + int iButtonY; + bool bGetExtraToken = true; + CommandButton *pButton = NULL; + + // We should never be here without a Command Menu + if( !m_pCurrentCommandMenu ) + { + gEngfuncs.Con_Printf( "Error in %s file after '%s'.\n", menuFile, szLastButtonText ); + gEngfuncs.COM_FreeFile( pFileStart ); // Vit_amiN: prevent the memory leak + m_iInitialized = false; + + return newIndex; + } + + // token should already be the bound key, or the custom name + strncpy( cCustom, token, sizeof(cCustom) - 1 ); + cCustom[sizeof(cCustom) - 1] = '\0'; + + // See if it's a custom button + if( !strcmp( cCustom, "CUSTOM" ) ) + { + iCustom = true; + + // Get the next token + pfile = gEngfuncs.COM_ParseFile( pfile, token ); + } + // See if it's a map + else if( !strcmp( cCustom, "MAP" ) ) + { + // Get the mapname + pfile = gEngfuncs.COM_ParseFile( pfile, token ); + strncpy( szMap, token, MAX_MAPNAME - 1 ); + szMap[MAX_MAPNAME - 1] = '\0'; + + // Get the next token + pfile = gEngfuncs.COM_ParseFile( pfile, token ); + } + else if( !strncmp( cCustom, "TEAM", 4 ) ) // TEAM1, TEAM2, TEAM3, TEAM4 + { + // make it a team only button + iTeamOnly = atoi( cCustom + 4 ); + + // Get the next token + pfile = gEngfuncs.COM_ParseFile( pfile, token ); + } + else if( !strncmp( cCustom, "TOGGLE", 6 ) ) + { + iToggle = true; + + // Get the next token + pfile = gEngfuncs.COM_ParseFile( pfile, token ); + } + else + { + // See if it's a Class + } + + // Get the button bound key + strncpy( cBoundKey, token, 31 ); + cBoundKey[31] = '\0'; + + // Get the button text + pfile = gEngfuncs.COM_ParseFile( pfile, token ); + strncpy( cText, CHudTextMessage::BufferedLocaliseTextString( token ), 31 ); // Vit_amiN: localize button text + cText[31] = '\0'; + + // save off the last button text we've come across (for error reporting) + strcpy( szLastButtonText, cText ); + + // Get the button command + pfile = gEngfuncs.COM_ParseFile( pfile, token ); + strncpy( cCommand, token, cCommandLength - 1 ); + cCommand[cCommandLength - 1] = '\0'; + + iButtonY = ( BUTTON_SIZE_Y - 1 ) * m_pCurrentCommandMenu->GetNumButtons(); + + // Custom button handling + if( iCustom ) + { + pButton = CreateCustomButton( cText, cCommand, iButtonY ); + + // Get the next token to see if we're a menu + pfile = gEngfuncs.COM_ParseFile( pfile, token ); + + if( token[0] == '{' ) + { + strcpy( cCommand, token ); + } + else + { + bGetExtraToken = false; + } + } + else if( szMap[0] != '\0' ) + { + // create a map button + pButton = new MapButton( szMap, cText, xOffset, iButtonY, flButtonSizeX, flButtonSizeY ); + } + else if( iTeamOnly != -1 ) + { + // button that only shows up if the player is on team iTeamOnly + pButton = new TeamOnlyCommandButton( iTeamOnly, cText, xOffset, iButtonY, flButtonSizeX, flButtonSizeY, flatDesign ); + } + else if( iToggle && direction == 0 ) + { + pButton = new ToggleCommandButton( cCommand, cText, xOffset, iButtonY, flButtonSizeX, flButtonSizeY, flatDesign ); + } + else if( direction == 1 ) + { + if( iToggle ) + pButton = new SpectToggleButton( cCommand, cText, xOffset, iButtonY, flButtonSizeX, flButtonSizeY, flatDesign ); + else + pButton = new SpectButton( iPlayerClass, cText, xOffset, iButtonY, flButtonSizeX, flButtonSizeY ); + } + else + { + // normal button + pButton = new CommandButton( iPlayerClass, cText, xOffset, iButtonY, flButtonSizeX, flButtonSizeY, flatDesign ); + } + + // add the button into the command menu + if( pButton ) + { + m_pCurrentCommandMenu->AddButton( pButton ); + pButton->setBoundKey( cBoundKey[0] ); + pButton->setParentMenu( m_pCurrentCommandMenu ); + + // Override font in CommandMenu + pButton->setFont( Scheme::sf_primary3 ); + } + + // Find out if it's a submenu or a button we're dealing with + if( cCommand[0] == '{' ) + { + if( m_iNumMenus >= MAX_MENUS ) + { + gEngfuncs.Con_Printf( "Too many menus in %s past '%s'\n", menuFile, szLastButtonText ); + } + else + { + // Create the menu + m_pCommandMenus[m_iNumMenus] = CreateSubMenu( pButton, m_pCurrentCommandMenu, iButtonY ); + m_pCurrentCommandMenu = m_pCommandMenus[m_iNumMenus]; + m_iNumMenus++; + } + } + else if( !iCustom ) + { + // Create the button and attach it to the current menu + if( iToggle ) + pButton->addActionSignal( new CMenuHandler_ToggleCvar( cCommand ) ); + else + pButton->addActionSignal( new CMenuHandler_StringCommand( cCommand ) ); + + // Create an input signal that'll popup the current menu + pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput( pButton, m_pCurrentCommandMenu ) ); + } + + // Get the next token + if( bGetExtraToken ) + { + pfile = gEngfuncs.COM_ParseFile( pfile, token ); + } + } + + // Move back up a menu + m_pCurrentCommandMenu = m_pCurrentCommandMenu->GetParentMenu(); + + pfile = gEngfuncs.COM_ParseFile( pfile, token ); + } +#ifdef _WIN32 + } + catch( CException *e ) + { + e; + //e->Delete(); + e = NULL; + gEngfuncs.COM_FreeFile( pFileStart ); // Vit_amiN: prevent the memory leak + m_iInitialized = false; + return newIndex; + } +#endif + + SetCurrentMenu( NULL ); + SetCurrentCommandMenu( NULL ); + gEngfuncs.COM_FreeFile( pFileStart ); + + m_iInitialized = true; + + return newIndex; +} + +//----------------------------------------------------------------------------- +// Purpose: Creates all the class choices under a spy's disguise menus, and +// maps a command to them +// Output : CCommandMenu +//----------------------------------------------------------------------------- +CCommandMenu *TeamFortressViewport::CreateDisguiseSubmenu( CommandButton *pButton, CCommandMenu *pParentMenu, const char *commandText, int iYOffset, int iXOffset ) +{ + // create the submenu, under which the class choices will be listed + CCommandMenu *pMenu = CreateSubMenu( pButton, pParentMenu, iYOffset, iXOffset ); + m_pCommandMenus[m_iNumMenus] = pMenu; + m_iNumMenus++; + + return pMenu; +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : *pButtonText - +// *pButtonName - +// Output : CommandButton +//----------------------------------------------------------------------------- +CommandButton *TeamFortressViewport::CreateCustomButton( char *pButtonText, char *pButtonName, int iYOffset ) +{ + CommandButton *pButton = NULL; + CCommandMenu *pMenu = NULL; + + // ChangeTeam + if( !strcmp( pButtonName, "!CHANGETEAM" ) ) + { + // ChangeTeam Submenu + pButton = new CommandButton( pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y ); + + // Create the submenu + pMenu = CreateSubMenu(pButton, m_pCurrentCommandMenu, iYOffset ); + m_pCommandMenus[m_iNumMenus] = pMenu; + m_iNumMenus++; + + // ChangeTeam buttons + for( int i = 0; i < 4; i++ ) + { + char sz[256]; + + sprintf( sz, "jointeam %d", i + 1 ); + m_pTeamButtons[i] = new TeamButton( i + 1, "teamname", 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y ); + m_pTeamButtons[i]->addActionSignal( new CMenuHandler_StringCommandWatch( sz ) ); + pMenu->AddButton( m_pTeamButtons[i] ); + } + + // Auto Assign button + m_pTeamButtons[4] = new TeamButton( 5, gHUD.m_TextMessage.BufferedLocaliseTextString( "#Team_AutoAssign" ), 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y ); + m_pTeamButtons[4]->addActionSignal( new CMenuHandler_StringCommand( "jointeam 5" ) ); + pMenu->AddButton( m_pTeamButtons[4] ); + + // Spectate button + m_pTeamButtons[5] = new SpectateButton( CHudTextMessage::BufferedLocaliseTextString( "#Menu_Spectate" ), 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y, false ); + m_pTeamButtons[5]->addActionSignal( new CMenuHandler_StringCommand( "spectate" ) ); + pMenu->AddButton( m_pTeamButtons[5] ); + } + // ChangeClass + else if( !strcmp( pButtonName, "!CHANGECLASS" ) ) + { + // Create the Change class menu + pButton = new ClassButton( -1, pButtonText, 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y, false ); + + // ChangeClass Submenu + pMenu = CreateSubMenu( pButton, m_pCurrentCommandMenu, iYOffset ); + m_pCommandMenus[m_iNumMenus] = pMenu; + m_iNumMenus++; + } + + return pButton; +} + +//======================================================================= +void TeamFortressViewport::ShowCommandMenu( int menuIndex ) +{ + if( !m_iInitialized ) + return; + + // Already have a menu open. + if( m_pCurrentMenu ) + return; + + // is the command menu open? + if( m_pCurrentCommandMenu == m_pCommandMenus[menuIndex] ) + { + HideCommandMenu(); + return; + } + + // Not visible while in intermission + if( gHUD.m_iIntermission ) + return; + + // Recalculate visible menus + UpdateCommandMenu( menuIndex ); + HideVGUIMenu(); + + SetCurrentCommandMenu( m_pCommandMenus[menuIndex] ); + m_flMenuOpenTime = gHUD.m_flTime; + UpdateCursorState(); + + // get command menu parameters + for( int i = 2; i < gEngfuncs.Cmd_Argc(); i++ ) + { + const char *param = gEngfuncs.Cmd_Argv( i - 1 ); + if( param ) + { + if( m_pCurrentCommandMenu->KeyInput(param[0]) ) + { + // kill the menu open time, since the key input is final + HideCommandMenu(); + } + } + } +} + +//----------------------------------------------------------------------------- +// Purpose: Handles the key input of "-commandmenu" +// Input : +//----------------------------------------------------------------------------- +void TeamFortressViewport::InputSignalHideCommandMenu() +{ + if( !m_iInitialized ) + return; + + // if they've just tapped the command menu key, leave it open + if( (m_flMenuOpenTime + 0.3 ) > gHUD.m_flTime ) + return; + + HideCommandMenu(); +} + +//----------------------------------------------------------------------------- +// Purpose: Hides the command menu +//----------------------------------------------------------------------------- +void TeamFortressViewport::HideCommandMenu() +{ + if( !m_iInitialized ) + return; + + if( m_pCommandMenus[m_StandardMenu] ) + { + m_pCommandMenus[m_StandardMenu]->ClearButtonsOfArmedState(); + } + + if( m_pCommandMenus[m_SpectatorOptionsMenu] ) + { + m_pCommandMenus[m_SpectatorOptionsMenu]->ClearButtonsOfArmedState(); + } + + if( m_pCommandMenus[m_SpectatorCameraMenu] ) + { + m_pCommandMenus[m_SpectatorCameraMenu]->ClearButtonsOfArmedState(); + } + + if ( m_pCommandMenus[m_PlayerMenu] ) + { + m_pCommandMenus[m_PlayerMenu]->ClearButtonsOfArmedState(); + } + + + m_flMenuOpenTime = 0.0f; + SetCurrentCommandMenu( NULL ); + UpdateCursorState(); +} + +//----------------------------------------------------------------------------- +// Purpose: Bring up the scoreboard +//----------------------------------------------------------------------------- +void TeamFortressViewport::ShowScoreBoard( void ) +{ + if( m_pScoreBoard ) + { + // No Scoreboard in single-player + if( gEngfuncs.GetMaxClients() > 1 ) + { + m_pScoreBoard->Open(); + UpdateCursorState(); + } + } +} + +//----------------------------------------------------------------------------- +// Purpose: Returns true if the scoreboard is up +//----------------------------------------------------------------------------- +bool TeamFortressViewport::IsScoreBoardVisible( void ) +{ + if( m_pScoreBoard ) + return m_pScoreBoard->isVisible(); + + return false; +} + +//----------------------------------------------------------------------------- +// Purpose: Hide the scoreboard +//----------------------------------------------------------------------------- +void TeamFortressViewport::HideScoreBoard( void ) +{ + // Prevent removal of scoreboard during intermission + if( gHUD.m_iIntermission ) + return; + + if( m_pScoreBoard ) + { + m_pScoreBoard->setVisible( false ); + + GetClientVoiceMgr()->StopSquelchMode(); + + UpdateCursorState(); + } +} + +//----------------------------------------------------------------------------- +// Purpose: Activate's the player special ability +// called when the player hits their "special" key +//----------------------------------------------------------------------------- +void TeamFortressViewport::InputPlayerSpecial( void ) +{ + if( !m_iInitialized ) + return; + + // if it's any other class, just send the command down to the server + ClientCmd( "_special" ); +} + +// Set the submenu of the Command Menu +void TeamFortressViewport::SetCurrentCommandMenu( CCommandMenu *pNewMenu ) +{ + for( int i = 0; i < m_iNumMenus; i++ ) + m_pCommandMenus[i]->setVisible( false ); + + m_pCurrentCommandMenu = pNewMenu; + + if( m_pCurrentCommandMenu ) + m_pCurrentCommandMenu->MakeVisible( NULL ); +} + +void TeamFortressViewport::UpdateCommandMenu( int menuIndex ) +{ + // if its the player menu update the player list + if(menuIndex==m_PlayerMenu) + { + m_pCommandMenus[m_PlayerMenu]->RemoveAllButtons(); + UpdatePlayerMenu(m_PlayerMenu); + } + + m_pCommandMenus[menuIndex]->RecalculateVisibles( 0, false ); + m_pCommandMenus[menuIndex]->RecalculatePositions( 0 ); +} + +void TeamFortressViewport::UpdatePlayerMenu(int menuIndex) +{ + + cl_entity_t * pEnt = NULL; + float flLabelSize = ( (ScreenWidth - (XRES ( CAMOPTIONS_BUTTON_X ) + 15)) - XRES ( 24 + 15 ) ) - XRES( (15 + OPTIONS_BUTTON_X + 15) + 38 ); + gViewPort->GetAllPlayersInfo(); + + + for (int i = 1; i < MAX_PLAYERS; i++ ) + { + //if ( g_PlayerInfoList[i].name == NULL ) + // continue; // empty player slot, skip + + pEnt = gEngfuncs.GetEntityByIndex( i ); + + if ( !gHUD.m_Spectator.IsActivePlayer( pEnt ) ) + continue; + + //if ( g_PlayerExtraInfo[i].teamname[0] == 0 ) + // continue; // skip over players who are not in a team + + SpectButton *pButton = new SpectButton(1 , g_PlayerInfoList[pEnt->index].name , + XRES( ( 15 + OPTIONS_BUTTON_X + 15 ) + 31 ),PANEL_HEIGHT+(i-1)*CMENU_SIZE_X, flLabelSize, BUTTON_SIZE_Y /2 ); + + pButton->setBoundKey( (char)255 ); + pButton->setContentAlignment( vgui::Label::a_center ); + m_pCommandMenus[menuIndex]->AddButton( pButton ); + pButton->setParentMenu( m_pCommandMenus[menuIndex] ); + + // Override font in CommandMenu + pButton->setFont( Scheme::sf_primary3 ); + + pButton->addActionSignal(new CMenuHandler_SpectateFollow( g_PlayerInfoList[pEnt->index].name)); + // Create an input signal that'll popup the current menu + pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput(pButton, m_pCommandMenus[menuIndex]) ); + + } + +} + + + +void COM_FileBase( const char *in, char *out ); + +void TeamFortressViewport::UpdateSpectatorPanel() +{ + m_iUser1 = g_iUser1; + m_iUser2 = g_iUser2; + m_iUser3 = g_iUser3; + + if( !m_pSpectatorPanel ) + return; + + if( g_iUser1 && gHUD.m_pCvarDraw->value && !gHUD.m_iIntermission ) // don't draw in dev_overview mode + { + char bottomText[128]; + char helpString2[128]; + char tempString[128]; + char *name; + char *pBottomText = NULL; + int player = 0; + + // check if spectator combinations are still valid + gHUD.m_Spectator.CheckSettings(); + + if( !m_pSpectatorPanel->isVisible() ) + { + m_pSpectatorPanel->setVisible( true ); // show spectator panel, but + m_pSpectatorPanel->ShowMenu( false ); // dsiable all menus/buttons + + _snprintf( tempString, sizeof(tempString) - 1, "%c%s", HUD_PRINTCENTER, CHudTextMessage::BufferedLocaliseTextString( "#Spec_Duck" ) ); + tempString[sizeof(tempString) - 1] = '\0'; + + gHUD.m_TextMessage.MsgFunc_TextMsg( NULL, strlen( tempString ) + 1, tempString ); + } + + sprintf(bottomText,"#Spec_Mode%d", g_iUser1 ); + sprintf(helpString2,"#Spec_Mode%d", g_iUser1 ); + + if( gEngfuncs.IsSpectateOnly() ) + strcat( helpString2, " - HLTV" ); + + // check if we're locked onto a target, show the player's name + if( ( g_iUser2 > 0 ) && ( g_iUser2 <= gEngfuncs.GetMaxClients() ) && ( g_iUser1 != OBS_ROAMING ) ) + { + player = g_iUser2; + } + + // special case in free map and inset off, don't show names + if( ( g_iUser1 == OBS_MAP_FREE ) && !gHUD.m_Spectator.m_pip->value ) + name = NULL; + else + name = g_PlayerInfoList[player].name; + + // create player & health string + if( player && name ) + { + strncpy( bottomText, name, sizeof(bottomText) - 1 ); + bottomText[ sizeof(bottomText) - 1 ] = 0; + pBottomText = bottomText; + } + else + { + pBottomText = CHudTextMessage::BufferedLocaliseTextString( bottomText ); + } + + // in first person mode colorize player names + if( ( g_iUser1 == OBS_IN_EYE ) && player ) + { + float *color = GetClientColor( player ); + int r = color[0]*255; + int g = color[1]*255; + int b = color[2]*255; + + // set team color, a bit transparent + m_pSpectatorPanel->m_BottomMainLabel->setFgColor( r, g, b, 0 ); + } + else + { // restore GUI color + m_pSpectatorPanel->m_BottomMainLabel->setFgColor( 143, 143, 54, 0 ); + } + + // add sting auto if we are in auto directed mode + if( gHUD.m_Spectator.m_autoDirector->value ) + { + char tempString[128]; + + sprintf( tempString, "#Spec_Auto %s", helpString2 ); + strcpy( helpString2, tempString ); + } + + m_pSpectatorPanel->m_BottomMainLabel->setText( "%s", pBottomText ); + m_pSpectatorPanel->m_BottomMainButton->setText( pBottomText ); + + + // update extra info field + char szText[64]; + + if( gEngfuncs.IsSpectateOnly() ) + { + // in HLTV mode show number of spectators + _snprintf( szText, sizeof(szText) - 1, "%s: %d", CHudTextMessage::BufferedLocaliseTextString( "#Spectators" ), gHUD.m_Spectator.m_iSpectatorNumber ); + } + else + { + // otherwise show map name + char szMapName[64]; + + COM_FileBase( gEngfuncs.pfnGetLevelName(), szMapName ); + + _snprintf( szText, sizeof(szText) - 1, "%s: %s",CHudTextMessage::BufferedLocaliseTextString( "#Spec_Map" ), szMapName ); + } + + szText[sizeof(szText) - 1] = '\0'; + + m_pSpectatorPanel->m_ExtraInfo->setText( szText ); + + /* + int timer = (int)( gHUD.m_roundTimer.m_flTimeEnd - gHUD.m_flTime ); + + if( timer < 0 ) + timer = 0; + + _snprintf( szText, sizeof(szText) - 1, "%d:%02d\n", ( timer / 60 ), ( timer % 60 ) ); + + szText[sizeof(szText) - 1] = '\0'; + + m_pSpectatorPanel->m_CurrentTime->setText( szText ); */ + + // update spectator panel + gViewPort->m_pSpectatorPanel->Update(); + } + else + { + if( m_pSpectatorPanel->isVisible() ) + { + m_pSpectatorPanel->setVisible( false ); + m_pSpectatorPanel->ShowMenu( false ); // dsiable all menus/buttons + } + } + + m_flSpectatorPanelLastUpdated = gHUD.m_flTime + 1.0; // update every second +} + +//====================================================================== +void TeamFortressViewport::CreateScoreBoard( void ) +{ + int xdent = SBOARD_INDENT_X, ydent = SBOARD_INDENT_Y; + if( ScreenWidth == 512 ) + { + xdent = SBOARD_INDENT_X_512; + ydent = SBOARD_INDENT_Y_512; + } + else if( ScreenWidth == 400 ) + { + xdent = SBOARD_INDENT_X_400; + ydent = SBOARD_INDENT_Y_400; + } + + m_pScoreBoard = new ScorePanel( xdent, ydent, ScreenWidth - ( xdent * 2 ), ScreenHeight - ( ydent * 2 ) ); + m_pScoreBoard->setParent( this ); + m_pScoreBoard->setVisible( false ); +} + +//====================================================================== +// Set the VGUI Menu +void TeamFortressViewport::SetCurrentMenu( CMenuPanel *pMenu ) +{ + m_pCurrentMenu = pMenu; + if( m_pCurrentMenu ) + { + // Don't open menus in demo playback + if( gEngfuncs.pDemoAPI->IsPlayingback() ) + return; + + m_pCurrentMenu->Open(); + } + else + { + gEngfuncs.pfnClientCmd( "closemenus;" ); + } +} + +//================================================================ +// Text Window +CMenuPanel *TeamFortressViewport::CreateTextWindow( int iTextToShow ) +{ + char sz[256]; + char *cText; + char *pfile = NULL; + static const int MAX_TITLE_LENGTH = 64; + char cTitle[MAX_TITLE_LENGTH]; + + if( iTextToShow == SHOW_MOTD ) + { + if( !m_szServerName[0] ) + strcpy( cTitle, "Half-Life" ); + else + { + strncpy( cTitle, m_szServerName, MAX_TITLE_LENGTH - 1 ); + cTitle[MAX_TITLE_LENGTH - 1] = '\0'; + } + + cText = m_szMOTD; + } + else if( iTextToShow == SHOW_MAPBRIEFING ) + { + // Get the current mapname, and open it's map briefing text + if( m_sMapName[0] ) + { + strcpy( sz, "maps/"); + strcat( sz, m_sMapName ); + strcat( sz, ".txt" ); + } + else + { + const char *level = gEngfuncs.pfnGetLevelName(); + if( !level ) + return NULL; + + strcpy( sz, level ); + char *ch = strchr( sz, '.' ); + *ch = '\0'; + strcat( sz, ".txt" ); + + // pull out the map name + strcpy( m_sMapName, level ); + ch = strchr( m_sMapName, '.' ); + if( ch ) + { + *ch = 0; + } + + ch = strchr( m_sMapName, '/' ); + if( ch ) + { + // move the string back over the '/' + memmove( m_sMapName, ch + 1, strlen( ch ) + 1 ); + } + } + + pfile = (char*)gEngfuncs.COM_LoadFile( sz, 5, NULL ); + + if( !pfile ) + return NULL; + + cText = pfile; + + strncpy( cTitle, m_sMapName, MAX_TITLE_LENGTH - 1 ); + cTitle[MAX_TITLE_LENGTH - 1] = 0; + } + else if( iTextToShow == SHOW_SPECHELP ) + { + CHudTextMessage::LocaliseTextString( "#Spec_Help_Title", cTitle, MAX_TITLE_LENGTH ); + cTitle[MAX_TITLE_LENGTH - 1] = 0; + + char *pfile = CHudTextMessage::BufferedLocaliseTextString( "#Spec_Help_Text" ); + if( pfile ) + { + cText = pfile; + } + } + + // if we're in the game (ie. have selected a class), flag the menu to be only grayed in the dialog box, instead of full screen + CMenuPanel *pMOTDPanel = CMessageWindowPanel_Create( cText, cTitle, g_iPlayerClass == PC_UNDEFINED, false, 0, 0, ScreenWidth, ScreenHeight ); + pMOTDPanel->setParent( this ); + + if( pfile ) + gEngfuncs.COM_FreeFile( pfile ); + + return pMOTDPanel; +} + +//================================================================ +// VGUI Menus +void TeamFortressViewport::ShowVGUIMenu( int iMenu ) +{ + CMenuPanel *pNewMenu = NULL; + + // Don't open menus in demo playback + if( gEngfuncs.pDemoAPI->IsPlayingback() ) + return; + + // Don't open any menus except the MOTD during intermission + // MOTD needs to be accepted because it's sent down to the client + // after map change, before intermission's turned off + if( gHUD.m_iIntermission && iMenu != MENU_INTRO ) + return; + + // Don't create one if it's already in the list + if( m_pCurrentMenu ) + { + CMenuPanel *pMenu = m_pCurrentMenu; + while( pMenu != NULL ) + { + if( pMenu->GetMenuID() == iMenu ) + return; + + pMenu = pMenu->GetNextMenu(); + } + } + + switch( iMenu ) + { + case MENU_TEAM: + pNewMenu = ShowTeamMenu(); + break; + + // Map Briefing removed now that it appears in the team menu + case MENU_MAPBRIEFING: + pNewMenu = CreateTextWindow( SHOW_MAPBRIEFING ); + break; + + case MENU_INTRO: + pNewMenu = CreateTextWindow( SHOW_MOTD ); + break; + + case MENU_CLASSHELP: + pNewMenu = CreateTextWindow( SHOW_CLASSDESC ); + break; + + case MENU_SPECHELP: + pNewMenu = CreateTextWindow( SHOW_SPECHELP ); + break; + case MENU_CLASS: + pNewMenu = ShowClassMenu(); + break; + + default: + break; + } + + if( !pNewMenu ) + return; + + // Close the Command Menu if it's open + HideCommandMenu(); + + pNewMenu->SetMenuID( iMenu ); + pNewMenu->SetActive( true ); + pNewMenu->setParent( this ); + + // See if another menu is visible, and if so, cache this one for display once the other one's finished + if( m_pCurrentMenu ) + { + if( m_pCurrentMenu->GetMenuID() == MENU_CLASS && iMenu == MENU_TEAM ) + { + CMenuPanel *temp = m_pCurrentMenu; + m_pCurrentMenu->Close(); + m_pCurrentMenu = pNewMenu; + m_pCurrentMenu->SetNextMenu( temp ); + m_pCurrentMenu->Open(); + UpdateCursorState(); + } + else + { + m_pCurrentMenu->SetNextMenu( pNewMenu ); + } + } + else + { + m_pCurrentMenu = pNewMenu; + m_pCurrentMenu->Open(); + UpdateCursorState(); + } +} + +// Removes all VGUI Menu's onscreen +void TeamFortressViewport::HideVGUIMenu() +{ + while( m_pCurrentMenu ) + { + HideTopMenu(); + } +} + +// Remove the top VGUI menu, and bring up the next one +void TeamFortressViewport::HideTopMenu() +{ + if( m_pCurrentMenu ) + { + // Close the top one + m_pCurrentMenu->Close(); + + // Bring up the next one + gViewPort->SetCurrentMenu( m_pCurrentMenu->GetNextMenu() ); + } + + UpdateCursorState(); +} + +// Return TRUE if the HUD's allowed to print text messages +bool TeamFortressViewport::AllowedToPrintText( void ) +{ + // Prevent text messages when fullscreen menus are up + if( m_pCurrentMenu && g_iPlayerClass == 0 ) + { + int iId = m_pCurrentMenu->GetMenuID(); + if( iId == MENU_TEAM || iId == MENU_CLASS || iId == MENU_INTRO || iId == MENU_CLASSHELP ) + return FALSE; + } + + return TRUE; +} + +//====================================================================================== +// TEAM MENU +//====================================================================================== +// Bring up the Team selection Menu +CMenuPanel* TeamFortressViewport::ShowTeamMenu() +{ + // Don't open menus in demo playback + if( gEngfuncs.pDemoAPI->IsPlayingback() ) + return NULL; + + m_pTeamMenu->Reset(); + return m_pTeamMenu; +} + +void TeamFortressViewport::CreateTeamMenu() +{ + // Create the panel + m_pTeamMenu = new CTeamMenuPanel( 100, false, 0, 0, ScreenWidth, ScreenHeight ); + m_pTeamMenu->setParent( this ); + m_pTeamMenu->setVisible( false ); +} + +//====================================================================================== +// CLASS MENU +//====================================================================================== +// Bring up the Class selection Menu +CMenuPanel* TeamFortressViewport::ShowClassMenu() +{ + // Don't open menus in demo playback + if( gEngfuncs.pDemoAPI->IsPlayingback() ) + return NULL; + + m_pClassMenu->Reset(); + return m_pClassMenu; +} + +void TeamFortressViewport::CreateClassMenu() +{ + // Create the panel + m_pClassMenu = new CClassMenuPanel( 100, false, 0, 0, ScreenWidth, ScreenHeight ); + m_pClassMenu->setParent( this ); + m_pClassMenu->setVisible( false ); +} + +//====================================================================================== +//====================================================================================== +// SPECTATOR MENU +//====================================================================================== +// Spectator "Menu" explaining the Spectator buttons +void TeamFortressViewport::CreateSpectatorMenu() +{ + // Create the Panel + m_pSpectatorPanel = new SpectatorPanel( 0, 0, ScreenWidth, ScreenHeight ); + m_pSpectatorPanel->setParent( this ); + m_pSpectatorPanel->setVisible( false ); + m_pSpectatorPanel->Initialize(); +} + +//====================================================================================== +// UPDATE HUD SECTIONS +//====================================================================================== +// We've got an update on player info +// Recalculate any menus that use it. +void TeamFortressViewport::UpdateOnPlayerInfo() +{ + if( m_pTeamMenu ) + m_pTeamMenu->Update(); + + if( m_pClassMenu ) + m_pClassMenu->Update(); + + if( m_pScoreBoard ) + m_pScoreBoard->Update(); +} + +void TeamFortressViewport::UpdateCursorState() +{ + // Need cursor if any VGUI window is up + if( m_pSpectatorPanel->m_menuVisible || m_pCurrentMenu || m_pTeamMenu->isVisible() || GetClientVoiceMgr()->IsInSquelchMode() ) + { + IN_SetVisibleMouse(true); + App::getInstance()->setCursorOveride( App::getInstance()->getScheme()->getCursor(Scheme::scu_arrow) ); + return; + } + else if( m_pCurrentCommandMenu ) + { + // commandmenu doesn't have cursor if hud_capturemouse is turned off + if( gHUD.m_pCvarStealMouse->value != 0.0f ) + { + IN_SetVisibleMouse(true); + App::getInstance()->setCursorOveride( App::getInstance()->getScheme()->getCursor(Scheme::scu_arrow) ); + return; + } + } + + App::getInstance()->setCursorOveride( App::getInstance()->getScheme()->getCursor(Scheme::scu_none) ); + IN_SetVisibleMouse(false); + + // Don't reset mouse in demo playback + if( !gEngfuncs.pDemoAPI->IsPlayingback() ) + { + IN_ResetMouse(); + } +} + +void TeamFortressViewport::UpdateHighlights() +{ + if( m_pCurrentCommandMenu ) + m_pCurrentCommandMenu->MakeVisible( NULL ); +} + +void TeamFortressViewport::GetAllPlayersInfo( void ) +{ + for( int i = 1; i < MAX_PLAYERS; i++ ) + { + GetPlayerInfo( i, &g_PlayerInfoList[i] ); + + if( g_PlayerInfoList[i].thisplayer ) + m_pScoreBoard->m_iPlayerNum = i; // !!!HACK: this should be initialized elsewhere... maybe gotten from the engine + } +} + +void TeamFortressViewport::paintBackground() +{ + int wide, tall; + getParent()->getSize( wide, tall ); + setSize( wide, tall ); + if( m_pScoreBoard ) + { + int x, y; + getApp()->getCursorPos( x, y ); + m_pScoreBoard->cursorMoved( x, y, m_pScoreBoard ); + } + + // See if the command menu is visible and needs recalculating due to some external change + if( g_iTeamNumber != m_iCurrentTeamNumber ) + { + UpdateCommandMenu( m_StandardMenu ); + + if( m_pClassMenu ) + { + m_pClassMenu->Update(); + } + + m_iCurrentTeamNumber = g_iTeamNumber; + } + + if( g_iPlayerClass != m_iCurrentPlayerClass ) + { + UpdateCommandMenu( m_StandardMenu ); + + m_iCurrentPlayerClass = g_iPlayerClass; + } + + // See if the Spectator Menu needs to be update + if( ( g_iUser1 != m_iUser1 || g_iUser2 != m_iUser2 ) || + ( m_flSpectatorPanelLastUpdated < gHUD.m_flTime ) ) + { + UpdateSpectatorPanel(); + } + + // Update the Scoreboard, if it's visible + if( m_pScoreBoard->isVisible() && ( m_flScoreBoardLastUpdated < gHUD.m_flTime ) ) + { + m_pScoreBoard->Update(); + m_flScoreBoardLastUpdated = gHUD.m_flTime + 0.5; + } + + int extents[4]; + + getAbsExtents( extents[0], extents[1], extents[2], extents[3] ); + + VGui_ViewportPaintBackground( extents ); +} + +//================================================================ +// Input Handler for Drag N Drop panels +void CDragNDropHandler::cursorMoved( int x, int y, Panel *panel ) +{ + if( m_bDragging ) + { + App::getInstance()->getCursorPos( x, y ); + m_pPanel->setPos( m_iaDragOrgPos[0] + ( x - m_iaDragStart[0] ), m_iaDragOrgPos[1] + ( y - m_iaDragStart[1] ) ); + + if( m_pPanel->getParent() != null ) + { + m_pPanel->getParent()->repaint(); + } + } +} + +void CDragNDropHandler::mousePressed( MouseCode code, Panel *panel ) +{ + int x, y; + App::getInstance()->getCursorPos( x, y ); + m_bDragging = true; + m_iaDragStart[0] = x; + m_iaDragStart[1] = y; + m_pPanel->getPos( m_iaDragOrgPos[0], m_iaDragOrgPos[1] ); + App::getInstance()->setMouseCapture( panel ); + + m_pPanel->setDragged( m_bDragging ); + m_pPanel->requestFocus(); +} + +void CDragNDropHandler::mouseReleased( MouseCode code, Panel *panel ) +{ + m_bDragging = false; + m_pPanel->setDragged( m_bDragging ); + App::getInstance()->setMouseCapture( null ); +} + +//================================================================ +// Number Key Input +bool TeamFortressViewport::SlotInput( int iSlot ) +{ + // If there's a menu up, give it the input + if( m_pCurrentMenu ) + return m_pCurrentMenu->SlotInput( iSlot ); + + return FALSE; +} + +// Direct Key Input +int TeamFortressViewport::KeyInput( int down, int keynum, const char *pszCurrentBinding ) +{ + // Enter gets out of Spectator Mode by bringing up the Team Menu + if( m_iUser1 && gEngfuncs.Con_IsVisible() == false ) + { + if( down && ( keynum == K_ENTER || keynum == K_KP_ENTER ) ) + ShowVGUIMenu( MENU_TEAM ); + } + + // Open Text Window? + if( m_pCurrentMenu && gEngfuncs.Con_IsVisible() == false ) + { + int iMenuID = m_pCurrentMenu->GetMenuID(); + + // Get number keys as Input for Team/Class menus + if( iMenuID == MENU_TEAM || iMenuID == MENU_CLASS ) + { + // Escape gets you out of Team/Class menus if the Cancel button is visible + if( keynum == K_ESCAPE ) + { + if( ( iMenuID == MENU_TEAM && g_iTeamNumber ) || ( iMenuID == MENU_CLASS && g_iPlayerClass ) ) + { + HideTopMenu(); + return 0; + } + } + + for( int i = '0'; i <= '9'; i++ ) + { + if( down && ( keynum == i ) ) + { + SlotInput( i - '0' ); + return 0; + } + } + } + + // Grab enter keys to close TextWindows + if( down && ( keynum == K_ENTER || keynum == K_KP_ENTER || keynum == K_SPACE || keynum == K_ESCAPE ) ) + { + if( iMenuID == MENU_MAPBRIEFING || iMenuID == MENU_INTRO || iMenuID == MENU_CLASSHELP ) + { + HideTopMenu(); + return 0; + } + } + + // Grab jump key on Team Menu as autoassign + if( pszCurrentBinding && down && !strcmp( pszCurrentBinding, "+jump" ) ) + { + if( iMenuID == MENU_TEAM ) + { + m_pTeamMenu->SlotInput( 5 ); + return 0; + } + } + + } + + // if we're in a command menu, try hit one of it's buttons + if( down && m_pCurrentCommandMenu ) + { + // Escape hides the command menu + if( keynum == K_ESCAPE ) + { + HideCommandMenu(); + return 0; + } + + // only trap the number keys + if( keynum >= '0' && keynum <= '9' ) + { + if( m_pCurrentCommandMenu->KeyInput( keynum ) ) + { + // a final command has been issued, so close the command menu + HideCommandMenu(); + } + + return 0; + } + } + + return 1; +} + +//================================================================ +// Message Handlers +int TeamFortressViewport::MsgFunc_ValClass( const char *pszName, int iSize, void *pbuf ) +{ + BEGIN_READ( pbuf, iSize ); + + for( int i = 0; i < 5; i++ ) + m_iValidClasses[i] = READ_SHORT(); + + // Force the menu to update + UpdateCommandMenu( m_StandardMenu ); + + return 1; +} + +int TeamFortressViewport::MsgFunc_TeamNames( const char *pszName, int iSize, void *pbuf ) +{ + BEGIN_READ( pbuf, iSize ); + + m_iNumberOfTeams = READ_BYTE(); + + for( int i = 0; i < m_iNumberOfTeams; i++ ) + { + int teamNum = i + 1; + + gHUD.m_TextMessage.LocaliseTextString( READ_STRING(), m_sTeamNames[teamNum], MAX_TEAMNAME_SIZE ); + + // Set the team name buttons + if( m_pTeamButtons[i] ) + m_pTeamButtons[i]->setText( m_sTeamNames[teamNum] ); + + // range check this value...m_pDisguiseButtons[5]; + if( teamNum < 5 ) + { + // Set the disguise buttons + if( m_pDisguiseButtons[teamNum] ) + m_pDisguiseButtons[teamNum]->setText( m_sTeamNames[teamNum] ); + } + } + + // Update the Team Menu + if( m_pTeamMenu ) + m_pTeamMenu->Update(); + + return 1; +} + +int TeamFortressViewport::MsgFunc_Feign( const char *pszName, int iSize, void *pbuf ) +{ + BEGIN_READ( pbuf, iSize ); + + m_iIsFeigning = READ_BYTE(); + + // Force the menu to update + UpdateCommandMenu( m_StandardMenu ); + + return 1; +} + +int TeamFortressViewport::MsgFunc_Detpack( const char *pszName, int iSize, void *pbuf ) +{ + BEGIN_READ( pbuf, iSize ); + + m_iIsSettingDetpack = READ_BYTE(); + + // Force the menu to update + UpdateCommandMenu( m_StandardMenu ); + + return 1; +} + +int TeamFortressViewport::MsgFunc_VGUIMenu( const char *pszName, int iSize, void *pbuf ) +{ + BEGIN_READ( pbuf, iSize ); + + int iMenu = READ_BYTE(); + + // Map briefing includes the name of the map (because it's sent down before the client knows what map it is) + if( iMenu == MENU_MAPBRIEFING ) + { + strncpy( m_sMapName, READ_STRING(), sizeof(m_sMapName) - 1 ); + m_sMapName[sizeof(m_sMapName) - 1] = '\0'; + } + + // Bring up the menu6 + ShowVGUIMenu( iMenu ); + + return 1; +} + +int TeamFortressViewport::MsgFunc_MOTD( const char *pszName, int iSize, void *pbuf ) +{ + if( m_iGotAllMOTD ) + m_szMOTD[0] = 0; + + BEGIN_READ( pbuf, iSize ); + + m_iGotAllMOTD = READ_BYTE(); + + int roomInArray = sizeof(m_szMOTD) - strlen( m_szMOTD ) - 1; + + strncat( m_szMOTD, READ_STRING(), roomInArray >= 0 ? roomInArray : 0 ); + m_szMOTD[sizeof(m_szMOTD) - 1] = '\0'; + + // don't show MOTD for HLTV spectators + if( m_iGotAllMOTD && !gEngfuncs.IsSpectateOnly() ) + { + ShowVGUIMenu( MENU_INTRO ); + } + + return 1; +} + +int TeamFortressViewport::MsgFunc_BuildSt( const char *pszName, int iSize, void *pbuf ) +{ + BEGIN_READ( pbuf, iSize ); + + m_iBuildState = READ_SHORT(); + + // Force the menu to update + UpdateCommandMenu( m_StandardMenu ); + + return 1; +} + +int TeamFortressViewport::MsgFunc_RandomPC( const char *pszName, int iSize, void *pbuf ) +{ + BEGIN_READ( pbuf, iSize ); + + m_iRandomPC = READ_BYTE(); + + return 1; +} + +int TeamFortressViewport::MsgFunc_ServerName( const char *pszName, int iSize, void *pbuf ) +{ + BEGIN_READ( pbuf, iSize ); + + strncpy( m_szServerName, READ_STRING(), sizeof(m_szServerName) - 1 ); + m_szServerName[sizeof(m_szServerName) - 1] = 0; + + return 1; +} + +int TeamFortressViewport::MsgFunc_ScoreInfo( const char *pszName, int iSize, void *pbuf ) +{ + BEGIN_READ( pbuf, iSize ); + short cl = READ_BYTE(); + short frags = READ_SHORT(); + short deaths = READ_SHORT(); + short playerclass = READ_SHORT(); + short teamnumber = READ_SHORT(); + + if( cl > 0 && cl <= MAX_PLAYERS ) + { + g_PlayerExtraInfo[cl].frags = frags; + g_PlayerExtraInfo[cl].deaths = deaths; + g_PlayerExtraInfo[cl].playerclass = playerclass; + g_PlayerExtraInfo[cl].teamnumber = teamnumber; + + //Dont go bellow 0! + if( g_PlayerExtraInfo[cl].teamnumber < 0 ) + g_PlayerExtraInfo[cl].teamnumber = 0; + + UpdateOnPlayerInfo(); + } + + return 1; +} + +// Message handler for TeamScore message +// accepts three values: +// string: team name +// short: teams kills +// short: teams deaths +// if this message is never received, then scores will simply be the combined totals of the players. +int TeamFortressViewport::MsgFunc_TeamScore( const char *pszName, int iSize, void *pbuf ) +{ + BEGIN_READ( pbuf, iSize ); + char *TeamName = READ_STRING(); + + int i; + // find the team matching the name + for( i = 1; i <= m_pScoreBoard->m_iNumTeams; i++ ) + { + if( !stricmp( TeamName, g_TeamInfo[i].name ) ) + break; + } + + if( i > m_pScoreBoard->m_iNumTeams ) + return 1; + + // use this new score data instead of combined player scoresw + g_TeamInfo[i].scores_overriden = TRUE; + g_TeamInfo[i].frags = READ_SHORT(); + g_TeamInfo[i].deaths = READ_SHORT(); + + return 1; +} + +// Message handler for TeamInfo message +// accepts two values: +// byte: client number +// string: client team name +int TeamFortressViewport::MsgFunc_TeamInfo( const char *pszName, int iSize, void *pbuf ) +{ + if( !m_pScoreBoard ) + return 1; + + BEGIN_READ( pbuf, iSize ); + short cl = READ_BYTE(); + + if( cl > 0 && cl <= MAX_PLAYERS ) + { + // set the players team + strncpy( g_PlayerExtraInfo[cl].teamname, READ_STRING(), MAX_TEAM_NAME - 1 ); + g_PlayerExtraInfo[cl].teamname[MAX_TEAM_NAME - 1] = '\0'; + } + + // rebuild the list of teams + m_pScoreBoard->RebuildTeams(); + + return 1; +} + +void TeamFortressViewport::DeathMsg( int killer, int victim ) +{ + m_pScoreBoard->DeathMsg( killer, victim ); +} + +int TeamFortressViewport::MsgFunc_Spectator( const char *pszName, int iSize, void *pbuf ) +{ + BEGIN_READ( pbuf, iSize ); + + short cl = READ_BYTE(); + if( cl > 0 && cl <= MAX_PLAYERS ) + { + g_IsSpectator[cl] = READ_BYTE(); + } + + return 1; +} + +int TeamFortressViewport::MsgFunc_AllowSpec( const char *pszName, int iSize, void *pbuf ) +{ + BEGIN_READ( pbuf, iSize ); + + m_iAllowSpectators = READ_BYTE(); + + // Force the menu to update + UpdateCommandMenu( m_StandardMenu ); + + // If the team menu is up, update it too + if( m_pTeamMenu ) + m_pTeamMenu->Update(); + + return 1; +} + +// used to reset the player's screen immediately +int TeamFortressViewport::MsgFunc_ResetFade( const char *pszName, int iSize, void *pbuf ) +{ + return 1; +} + +// used to fade a player's screen out/in when they're spectating someone who is teleported +int TeamFortressViewport::MsgFunc_SpecFade( const char *pszName, int iSize, void *pbuf ) +{ + return 1; +} diff --git a/cl_dll/vgui_TeamFortressViewport.h b/cl_dll/vgui_TeamFortressViewport.h new file mode 100644 index 00000000..023d716d --- /dev/null +++ b/cl_dll/vgui_TeamFortressViewport.h @@ -0,0 +1,1736 @@ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef TEAMFORTRESSVIEWPORT_H +#define TEAMFORTRESSVIEWPORT_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// custom scheme handling +#include "vgui_SchemeManager.h" + +#define TF_DEFS_ONLY +#define PC_LASTCLASS 10 +#define PC_UNDEFINED 0 +#define MENU_DEFAULT 1 +#define MENU_TEAM 2 +#define MENU_CLASS 3 +#define MENU_MAPBRIEFING 4 +#define MENU_INTRO 5 +#define MENU_CLASSHELP 6 +#define MENU_CLASSHELP2 7 +#define MENU_REPEATHELP 8 +#define MENU_SPECHELP 9 +using namespace vgui; + +class Cursor; +class ScorePanel; +class SpectatorPanel; +class CCommandMenu; +class CommandLabel; +class CommandButton; +class BuildButton; +class ClassButton; +class CMenuPanel; +class DragNDropPanel; +class CTransparentPanel; +class CClassMenuPanel; +class CTeamMenuPanel; +class TeamFortressViewport; + +char *GetVGUITGAName( const char *pszName ); +BitmapTGA *LoadTGAForRes( const char* pImageName ); +void ScaleColors( int &r, int &g, int &b, int a ); +extern const char *sTFClassSelection[]; +extern int sTFValidClassInts[]; +extern const char *sLocalisedClasses[]; +extern int iTeamColors[5][3]; +extern int iNumberOfTeamColors; +extern TeamFortressViewport *gViewPort; + + +// Command Menu positions +#define MAX_MENUS 80 +#define MAX_BUTTONS 100 + +#define BUTTON_SIZE_Y YRES(30) +#define CMENU_SIZE_X XRES(160) + +#define SUBMENU_SIZE_X (CMENU_SIZE_X / 8) +#define SUBMENU_SIZE_Y (BUTTON_SIZE_Y / 6) + +#define CMENU_TOP (BUTTON_SIZE_Y * 4) + +//#define MAX_TEAMNAME_SIZE 64 +#define MAX_BUTTON_SIZE 32 + +// Map Briefing Window +#define MAPBRIEF_INDENT 30 + +// Team Menu +#define TMENU_INDENT_X (30 * ((float)ScreenHeight / 640)) +#define TMENU_HEADER 100 +#define TMENU_SIZE_X (ScreenWidth - (TMENU_INDENT_X * 2)) +#define TMENU_SIZE_Y (TMENU_HEADER + BUTTON_SIZE_Y * 7) +#define TMENU_PLAYER_INDENT (((float)TMENU_SIZE_X / 3) * 2) +#define TMENU_INDENT_Y (((float)ScreenHeight - TMENU_SIZE_Y) / 2) + +// Class Menu +#define CLMENU_INDENT_X (30 * ((float)ScreenHeight / 640)) +#define CLMENU_HEADER 100 +#define CLMENU_SIZE_X (ScreenWidth - (CLMENU_INDENT_X * 2)) +#define CLMENU_SIZE_Y (CLMENU_HEADER + BUTTON_SIZE_Y * 11) +#define CLMENU_PLAYER_INDENT (((float)CLMENU_SIZE_X / 3) * 2) +#define CLMENU_INDENT_Y (((float)ScreenHeight - CLMENU_SIZE_Y) / 2) + +// Arrows +enum +{ + ARROW_UP, + ARROW_DOWN, + ARROW_LEFT, + ARROW_RIGHT, +}; + +//============================================================================== +// VIEWPORT PIECES +//============================================================ +// Wrapper for an Image Label without a background +class CImageLabel : public Label +{ +public: + BitmapTGA *m_pTGA; + + void LoadImage(const char * pImageName); + CImageLabel( const char* pImageName,int x,int y ); + CImageLabel( const char* pImageName,int x,int y,int wide,int tall ); + + virtual int getImageTall(); + virtual int getImageWide(); + + virtual void paintBackground() + { + // Do nothing, so the background's left transparent. + } +}; + +// Command Label +// Overridden label so we can darken it when submenus open +class CommandLabel : public Label +{ +private: + int m_iState; + +public: + CommandLabel( const char *text, int x, int y, int wide, int tall ) : Label( text, x, y, wide, tall ) + { + m_iState = false; + } + + void PushUp() + { + m_iState = false; + repaint(); + } + + void PushDown() + { + m_iState = true; + repaint(); + } +}; + +//============================================================ +// Command Buttons +class CommandButton : public Button +{ +private: + int m_iPlayerClass; + bool m_bFlat; + + // Submenus under this button + CCommandMenu *m_pSubMenu; + CCommandMenu *m_pParentMenu; + CommandLabel *m_pSubLabel; + + char m_sMainText[MAX_BUTTON_SIZE]; + char m_cBoundKey; + + SchemeHandle_t m_hTextScheme; + + void RecalculateText( void ); + +public: + bool m_bNoHighlight; + + CommandButton(const char* text,int x,int y,int wide,int tall, bool bNoHighlight, bool bFlat); + // Constructors + CommandButton( const char* text,int x,int y,int wide,int tall, bool bNoHighlight = false); + CommandButton( int iPlayerClass, const char* text,int x,int y,int wide,int tall, bool bFlat ); + + void Init( void ); + + // Menu Handling + void AddSubMenu( CCommandMenu *pNewMenu ); + void AddSubLabel( CommandLabel *pSubLabel ) + { + m_pSubLabel = pSubLabel; + } + + virtual int IsNotValid( void ) + { + return false; + } + + void UpdateSubMenus( int iAdjustment ); + int GetPlayerClass() { return m_iPlayerClass; }; + CCommandMenu *GetSubMenu() { return m_pSubMenu; }; + + CCommandMenu *getParentMenu( void ); + void setParentMenu( CCommandMenu *pParentMenu ); + + // Overloaded vgui functions + virtual void paint(); + virtual void setText( const char *text ); + virtual void paintBackground(); + + void cursorEntered( void ); + void cursorExited( void ); + + void setBoundKey( char boundKey ); + char getBoundKey( void ); +}; + +class ColorButton : public CommandButton +{ +private: + + Color *ArmedColor; + Color *UnArmedColor; + + Color *ArmedBorderColor; + Color *UnArmedBorderColor; + +public: + ColorButton( const char *text, int x, int y, int wide, int tall, bool bNoHighlight, bool bFlat ) : + CommandButton( text, x, y, wide, tall, bNoHighlight, bFlat ) + { + ArmedColor = NULL; + UnArmedColor = NULL; + ArmedBorderColor = NULL; + UnArmedBorderColor = NULL; + } + + virtual void paintBackground() + { + int r, g, b, a; + Color bgcolor; + + if( isArmed() ) + { + // Highlight background + /* getBgColor( bgcolor ); + bgcolor.getColor( r, g, b, a ); + drawSetColor( r, g, b, a ); + drawFilledRect( 0, 0, _size[0], _size[1] );*/ + + if( ArmedBorderColor ) + { + ArmedBorderColor->getColor( r, g, b, a ); + drawSetColor( r, g, b, a ); + drawOutlinedRect( 0, 0, _size[0], _size[1]); + } + } + else + { + if( UnArmedBorderColor ) + { + UnArmedBorderColor->getColor( r, g, b, a ); + drawSetColor( r, g, b, a ); + drawOutlinedRect( 0, 0, _size[0], _size[1]); + } + } + } + + void paint() + { + int r, g, b, a; + if( isArmed() ) + { + if( ArmedColor ) + { + ArmedColor->getColor( r, g, b, a ); + setFgColor( r, g, b, a ); + } + else + setFgColor( Scheme::sc_secondary2 ); + } + else + { + if( UnArmedColor ) + { + UnArmedColor->getColor( r, g, b, a ); + setFgColor( r, g, b, a ); + } + else + setFgColor( Scheme::sc_primary1 ); + } + + Button::paint(); + } + + void setArmedColor( int r, int g, int b, int a ) + { + ArmedColor = new Color( r, g, b, a ); + } + + void setUnArmedColor( int r, int g, int b, int a ) + { + UnArmedColor = new Color( r, g, b, a ); + } + + void setArmedBorderColor( int r, int g, int b, int a ) + { + ArmedBorderColor = new Color( r, g, b, a ); + } + + void setUnArmedBorderColor( int r, int g, int b, int a ) + { + UnArmedBorderColor = new Color( r, g, b, a ); + } +}; + +class SpectButton : public CommandButton +{ +private: + +public: + SpectButton( int iPlayerClass, const char *text, int x, int y, int wide, int tall ) : + CommandButton( text, x, y, wide, tall, false ) + { + Init(); + + setText( text ); + } + + virtual void paintBackground() + { + if( isArmed() ) + { + drawSetColor( 143,143, 54, 125 ); + drawFilledRect( 5, 0, _size[0] - 5, _size[1] ); + } + } + + virtual void paint() + { + + if( isArmed() ) + { + setFgColor( 194, 202, 54, 0 ); + } + else + { + setFgColor( 143, 143, 54, 15 ); + } + + Button::paint(); + } +}; + +//============================================================ +// Command Menus +class CCommandMenu : public Panel +{ +private: + CCommandMenu *m_pParentMenu; + int m_iXOffset; + int m_iYOffset; + + // Buttons in this menu + CommandButton *m_aButtons[ MAX_BUTTONS ]; + int m_iButtons; + + // opens menu from top to bottom (0 = default), or from bottom to top (1)? + int m_iDirection; +public: + CCommandMenu( CCommandMenu *pParentMenu, int x, int y, int wide, int tall ) : Panel( x, y, wide, tall ) + { + m_pParentMenu = pParentMenu; + m_iXOffset = x; + m_iYOffset = y; + m_iButtons = 0; + m_iDirection = 0; + } + + CCommandMenu( CCommandMenu *pParentMenu, int direction, int x, int y, int wide, int tall ) : Panel( x, y, wide, tall ) + { + m_pParentMenu = pParentMenu; + m_iXOffset = x; + m_iYOffset = y; + m_iButtons = 0; + m_iDirection = direction; + } + + float m_flButtonSizeY; + int m_iSpectCmdMenu; + void AddButton( CommandButton *pButton ); + bool RecalculateVisibles( int iNewYPos, bool bHideAll ); + void RecalculatePositions( int iYOffset ); + void MakeVisible( CCommandMenu *pChildMenu ); + + CCommandMenu *GetParentMenu() { return m_pParentMenu; }; + int GetXOffset() { return m_iXOffset; }; + int GetYOffset() { return m_iYOffset; }; + int GetDirection() { return m_iDirection; }; + int GetNumButtons() { return m_iButtons; }; + CommandButton *FindButtonWithSubmenu( CCommandMenu *pSubMenu ); + + void ClearButtonsOfArmedState( void ); + + void RemoveAllButtons(void); + + + bool KeyInput( int keyNum ); + + virtual void paintBackground(); +}; + +//============================================================================== +// Command menu root button (drop down box style) + +class DropDownButton : public ColorButton +{ +private: + CImageLabel *m_pOpenButton; + +public: + + DropDownButton( const char* text,int x,int y,int wide,int tall, bool bNoHighlight, bool bFlat ) : + ColorButton( text, x, y, wide, tall, bNoHighlight, bFlat ) + { + // Put a > to show it's a submenu + m_pOpenButton = new CImageLabel( "arrowup", XRES( CMENU_SIZE_X-2 ) , YRES( BUTTON_SIZE_Y-2 ) ); + m_pOpenButton->setParent(this); + + int textwide, texttall; + getSize( textwide, texttall); + + // Reposition + m_pOpenButton->setPos( textwide-(m_pOpenButton->getImageWide()+6), -2 /*(tall - m_pOpenButton->getImageTall()*2) / 2*/ ); + m_pOpenButton->setVisible(true); + + } + + virtual void setVisible(bool state) + { + m_pOpenButton->setVisible(state); + ColorButton::setVisible(state); + } + + +}; + +//============================================================================== +// Button with image instead of text + +class CImageButton : public ColorButton +{ +private: + CImageLabel *m_pOpenButton; + +public: + + CImageButton( const char* text,int x,int y,int wide,int tall, bool bNoHighlight, bool bFlat ) : + ColorButton( " ", x, y, wide, tall, bNoHighlight, bFlat ) + { + m_pOpenButton = new CImageLabel( text,1,1,wide-2 , tall-2 ); + m_pOpenButton->setParent(this); + + // Reposition + // m_pOpenButton->setPos( x+1,y+1 ); + // m_pOpenButton->setSize(wide-2,tall-2); + + m_pOpenButton->setVisible(true); + } + + virtual void setVisible(bool state) + { + m_pOpenButton->setVisible(state); + ColorButton::setVisible(state); + } + + +}; + +//============================================================================== +class TeamFortressViewport : public Panel +{ +private: + vgui::Cursor* _cursorNone; + vgui::Cursor* _cursorArrow; + + int m_iInitialized; + + CCommandMenu *m_pCommandMenus[MAX_MENUS]; + CCommandMenu *m_pCurrentCommandMenu; + float m_flMenuOpenTime; + float m_flScoreBoardLastUpdated; + float m_flSpectatorPanelLastUpdated; + int m_iNumMenus; + int m_iCurrentTeamNumber; + int m_iCurrentPlayerClass; + int m_iUser1; + int m_iUser2; + int m_iUser3; + + // VGUI Menus + void CreateTeamMenu( void ); + CMenuPanel* ShowTeamMenu( void ); + void CreateClassMenu( void ); + CMenuPanel* ShowClassMenu( void ); + void CreateSpectatorMenu( void ); + + // Scheme handler + CSchemeManager m_SchemeManager; + + // MOTD + int m_iGotAllMOTD; + char m_szMOTD[ MAX_MOTD_LENGTH ]; + + // Command Menu Team buttons + CommandButton *m_pTeamButtons[6]; + CommandButton *m_pDisguiseButtons[5]; + BuildButton *m_pBuildButtons[3]; + BuildButton *m_pBuildActiveButtons[3]; + + int m_iAllowSpectators; + + // Data for specific sections of the Command Menu + int m_iValidClasses[5]; + int m_iIsFeigning; + int m_iIsSettingDetpack; + int m_iNumberOfTeams; + int m_iBuildState; + int m_iRandomPC; + char m_sTeamNames[5][MAX_TEAMNAME_SIZE]; + + // Localisation strings + char m_sDetpackStrings[3][MAX_BUTTON_SIZE]; + + char m_sMapName[64]; + + // helper function to update the player menu entries + void UpdatePlayerMenu(int menuIndex); + +public: + TeamFortressViewport(int x,int y,int wide,int tall); + void Initialize( void ); + + int CreateCommandMenu( const char * menuFile, int direction, int yOffset, bool flatDesign, float flButtonSizeX, float flButtonSizeY, int xOffset ); + void CreateScoreBoard( void ); + CommandButton * CreateCustomButton( char *pButtonText, char * pButtonName, int iYOffset ); + CCommandMenu * CreateDisguiseSubmenu( CommandButton *pButton, CCommandMenu *pParentMenu, const char *commandText, int iYOffset, int iXOffset = 0 ); + + void UpdateCursorState( void ); + void UpdateCommandMenu(int menuIndex); + void UpdateOnPlayerInfo( void ); + void UpdateHighlights( void ); + void UpdateSpectatorPanel( void ); + + int KeyInput( int down, int keynum, const char *pszCurrentBinding ); + void InputPlayerSpecial( void ); + void GetAllPlayersInfo( void ); + void DeathMsg( int killer, int victim ); + + void ShowCommandMenu(int menuIndex); + void InputSignalHideCommandMenu( void ); + void HideCommandMenu( void ); + void SetCurrentCommandMenu( CCommandMenu *pNewMenu ); + void SetCurrentMenu( CMenuPanel *pMenu ); + + void ShowScoreBoard( void ); + void HideScoreBoard( void ); + bool IsScoreBoardVisible( void ); + + bool AllowedToPrintText( void ); + + void ShowVGUIMenu( int iMenu ); + void HideVGUIMenu( void ); + void HideTopMenu( void ); + + CMenuPanel* CreateTextWindow( int iTextToShow ); + + CCommandMenu *CreateSubMenu( CommandButton *pButton, CCommandMenu *pParentMenu, int iYOffset, int iXOffset = 0 ); + + // Data Handlers + int GetValidClasses(int iTeam) { return m_iValidClasses[iTeam]; }; + int GetNumberOfTeams() { return m_iNumberOfTeams; }; + int GetIsFeigning() { return m_iIsFeigning; }; + int GetIsSettingDetpack() { return m_iIsSettingDetpack; }; + int GetBuildState() { return m_iBuildState; }; + int IsRandomPC() { return m_iRandomPC; }; + char *GetTeamName( int iTeam ) { return m_sTeamNames[iTeam]; }; + int GetAllowSpectators() { return m_iAllowSpectators; }; + + // Message Handlers + int MsgFunc_ValClass(const char *pszName, int iSize, void *pbuf ); + int MsgFunc_TeamNames(const char *pszName, int iSize, void *pbuf ); + int MsgFunc_Feign(const char *pszName, int iSize, void *pbuf ); + int MsgFunc_Detpack(const char *pszName, int iSize, void *pbuf ); + int MsgFunc_VGUIMenu(const char *pszName, int iSize, void *pbuf ); + int MsgFunc_MOTD( const char *pszName, int iSize, void *pbuf ); + int MsgFunc_BuildSt( const char *pszName, int iSize, void *pbuf ); + int MsgFunc_RandomPC( const char *pszName, int iSize, void *pbuf ); + int MsgFunc_ServerName( const char *pszName, int iSize, void *pbuf ); + int MsgFunc_ScoreInfo( const char *pszName, int iSize, void *pbuf ); + int MsgFunc_TeamScore( const char *pszName, int iSize, void *pbuf ); + int MsgFunc_TeamInfo( const char *pszName, int iSize, void *pbuf ); + int MsgFunc_Spectator( const char *pszName, int iSize, void *pbuf ); + int MsgFunc_AllowSpec( const char *pszName, int iSize, void *pbuf ); + int MsgFunc_SpecFade( const char *pszName, int iSize, void *pbuf ); + int MsgFunc_ResetFade( const char *pszName, int iSize, void *pbuf ); + + // Input + bool SlotInput( int iSlot ); + + virtual void paintBackground(); + + CSchemeManager *GetSchemeManager( void ) { return &m_SchemeManager; } + ScorePanel *GetScoreBoard( void ) { return m_pScoreBoard; } + + void *operator new( size_t stAllocateBlock ); + +public: + // VGUI Menus + CMenuPanel *m_pCurrentMenu; + CTeamMenuPanel *m_pTeamMenu; + int m_StandardMenu; // indexs in m_pCommandMenus + int m_SpectatorOptionsMenu; + int m_SpectatorCameraMenu; + int m_PlayerMenu; // a list of current player + CClassMenuPanel *m_pClassMenu; + ScorePanel *m_pScoreBoard; + SpectatorPanel *m_pSpectatorPanel; + char m_szServerName[ MAX_SERVERNAME_LENGTH ]; +}; + +//============================================================ +// Command Menu Button Handlers +#define MAX_COMMAND_SIZE 256 + +class CMenuHandler_StringCommand : public ActionSignal +{ +protected: + char m_pszCommand[MAX_COMMAND_SIZE]; + int m_iCloseVGUIMenu; +public: + CMenuHandler_StringCommand( const char *pszCommand ) + { + strncpy( m_pszCommand, pszCommand, MAX_COMMAND_SIZE - 1 ); + m_pszCommand[MAX_COMMAND_SIZE - 1] = '\0'; + m_iCloseVGUIMenu = false; + } + + CMenuHandler_StringCommand( const char *pszCommand, int iClose ) + { + strncpy( m_pszCommand, pszCommand, MAX_COMMAND_SIZE - 1 ); + m_pszCommand[MAX_COMMAND_SIZE - 1] = '\0'; + m_iCloseVGUIMenu = true; + } + + virtual void actionPerformed(Panel *panel) + { + gEngfuncs.pfnFilteredClientCmd( m_pszCommand ); + + if( m_iCloseVGUIMenu ) + gViewPort->HideTopMenu(); + else + gViewPort->HideCommandMenu(); + } +}; + +// This works the same as CMenuHandler_StringCommand, except it watches the string command +// for specific commands, and modifies client vars based upon them. +class CMenuHandler_StringCommandWatch : public CMenuHandler_StringCommand +{ +private: +public: + CMenuHandler_StringCommandWatch( const char *pszCommand ) : CMenuHandler_StringCommand( pszCommand ) + { + } + + CMenuHandler_StringCommandWatch( const char *pszCommand, int iClose ) : CMenuHandler_StringCommand( pszCommand, iClose ) + { + } + + virtual void actionPerformed( Panel *panel ) + { + CMenuHandler_StringCommand::actionPerformed( panel ); + + // Try to guess the player's new team (it'll be corrected if it's wrong) + if( !strcmp( m_pszCommand, "jointeam 1" ) ) + g_iTeamNumber = 1; + else if( !strcmp( m_pszCommand, "jointeam 2" ) ) + g_iTeamNumber = 2; + else if( !strcmp( m_pszCommand, "jointeam 3" ) ) + g_iTeamNumber = 3; + else if( !strcmp( m_pszCommand, "jointeam 4" ) ) + g_iTeamNumber = 4; + } +}; + +// Used instead of CMenuHandler_StringCommand for Class Selection buttons. +// Checks the state of hud_classautokill and kills the player if set +class CMenuHandler_StringCommandClassSelect : public CMenuHandler_StringCommand +{ +private: +public: + CMenuHandler_StringCommandClassSelect( char *pszCommand ) : CMenuHandler_StringCommand( pszCommand ) + { + } + + CMenuHandler_StringCommandClassSelect( char *pszCommand, int iClose ) : CMenuHandler_StringCommand( pszCommand, iClose ) + { + } + + virtual void actionPerformed( Panel *panel ); +}; + +class CMenuHandler_PopupSubMenuInput : public InputSignal +{ +private: + CCommandMenu *m_pSubMenu; + Button *m_pButton; +public: + CMenuHandler_PopupSubMenuInput( Button *pButton, CCommandMenu *pSubMenu ) + { + m_pSubMenu = pSubMenu; + m_pButton = pButton; + } + + virtual void cursorMoved( int x, int y, Panel *panel ) + { + // gViewPort->SetCurrentCommandMenu( m_pSubMenu ); + } + + virtual void cursorEntered( Panel *panel ) + { + gViewPort->SetCurrentCommandMenu( m_pSubMenu ); + + if( m_pButton ) + m_pButton->setArmed( true ); + }; + virtual void cursorExited(Panel* Panel) {}; + virtual void mousePressed(MouseCode code,Panel* panel) {}; + virtual void mouseDoublePressed(MouseCode code,Panel* panel) {}; + virtual void mouseReleased(MouseCode code,Panel* panel) {}; + virtual void mouseWheeled(int delta,Panel* panel) {}; + virtual void keyPressed(KeyCode code,Panel* panel) {}; + virtual void keyTyped(KeyCode code,Panel* panel) {}; + virtual void keyReleased(KeyCode code,Panel* panel) {}; + virtual void keyFocusTicked(Panel* panel) {}; +}; + +class CMenuHandler_LabelInput : public InputSignal +{ +private: + ActionSignal *m_pActionSignal; +public: + CMenuHandler_LabelInput( ActionSignal *pSignal ) + { + m_pActionSignal = pSignal; + } + + virtual void mousePressed( MouseCode code, Panel *panel ) + { + m_pActionSignal->actionPerformed( panel ); + } + + virtual void mouseReleased( MouseCode code, Panel *panel ) {}; + virtual void cursorEntered( Panel *panel ) {}; + virtual void cursorExited( Panel *Panel ) {}; + virtual void cursorMoved( int x, int y, Panel *panel ) {}; + virtual void mouseDoublePressed( MouseCode code, Panel *panel ) {}; + virtual void mouseWheeled( int delta, Panel *panel ) {}; + virtual void keyPressed( KeyCode code, Panel *panel ) {}; + virtual void keyTyped( KeyCode code, Panel *panel ) {}; + virtual void keyReleased( KeyCode code, Panel *panel ) {}; + virtual void keyFocusTicked( Panel *panel ) {}; +}; + +#define HIDE_TEXTWINDOW 0 +#define SHOW_MAPBRIEFING 1 +#define SHOW_CLASSDESC 2 +#define SHOW_MOTD 3 +#define SHOW_SPECHELP 4 + +class CMenuHandler_TextWindow : public ActionSignal +{ +private: + int m_iState; + +public: + CMenuHandler_TextWindow( int iState ) + { + m_iState = iState; + } + + virtual void actionPerformed( Panel *panel ) + { + if( m_iState == HIDE_TEXTWINDOW ) + { + gViewPort->HideTopMenu(); + } + else + { + gViewPort->HideCommandMenu(); + gViewPort->ShowVGUIMenu( m_iState ); + } + } +}; + +class CMenuHandler_ToggleCvar : public ActionSignal +{ +private: + struct cvar_s *m_cvar; + +public: + CMenuHandler_ToggleCvar( char *cvarname ) + { + m_cvar = gEngfuncs.pfnGetCvarPointer( cvarname ); + } + + virtual void actionPerformed( Panel *panel ) + { + if( m_cvar->value ) + m_cvar->value = 0.0f; + else + m_cvar->value = 1.0f; + + // hide the menu + gViewPort->HideCommandMenu(); + + gViewPort->UpdateSpectatorPanel(); + } +}; + + + +class CMenuHandler_SpectateFollow : public ActionSignal +{ +protected: + char m_szplayer[MAX_COMMAND_SIZE]; +public: + CMenuHandler_SpectateFollow( char *player ) + { + strncpy( m_szplayer, player, MAX_COMMAND_SIZE - 1 ); + m_szplayer[MAX_COMMAND_SIZE-1] = '\0'; + } + + virtual void actionPerformed(Panel* panel) + { + gHUD.m_Spectator.FindPlayer(m_szplayer); + gViewPort->HideCommandMenu(); + } +}; + + + +class CDragNDropHandler : public InputSignal +{ +private: + DragNDropPanel *m_pPanel; + bool m_bDragging; + int m_iaDragOrgPos[2]; + int m_iaDragStart[2]; + +public: + CDragNDropHandler( DragNDropPanel *pPanel ) + { + m_pPanel = pPanel; + m_bDragging = false; + } + + void cursorMoved( int x, int y, Panel *panel ); + void mousePressed( MouseCode code, Panel *panel ); + void mouseReleased( MouseCode code, Panel *panel ); + + void mouseDoublePressed( MouseCode code, Panel *panel ) {}; + void cursorEntered( Panel *panel ) {}; + void cursorExited( Panel *panel ) {}; + void mouseWheeled( int delta, Panel *panel ) {}; + void keyPressed( KeyCode code, Panel *panel ) {}; + void keyTyped( KeyCode code, Panel *panel ) {}; + void keyReleased( KeyCode code, Panel *panel ) {}; + void keyFocusTicked( Panel *panel ) {}; +}; + +class CHandler_MenuButtonOver : public InputSignal +{ +private: + int m_iButton; + CMenuPanel *m_pMenuPanel; +public: + CHandler_MenuButtonOver( CMenuPanel *pPanel, int iButton ) + { + m_iButton = iButton; + m_pMenuPanel = pPanel; + } + + void cursorEntered( Panel *panel ); + + void cursorMoved( int x, int y, Panel *panel ) {}; + void mousePressed( MouseCode code, Panel *panel ) {}; + void mouseReleased( MouseCode code, Panel *panel ) {}; + void mouseDoublePressed( MouseCode code, Panel *panel ) {}; + void cursorExited( Panel *panel) {}; + void mouseWheeled( int delta, Panel *panel ) {}; + void keyPressed( KeyCode code, Panel *panel ) {}; + void keyTyped( KeyCode code, Panel *panel ) {}; + void keyReleased( KeyCode code, Panel *panel ) {}; + void keyFocusTicked( Panel *panel ) {}; +}; + +class CHandler_ButtonHighlight : public InputSignal +{ +private: + Button *m_pButton; +public: + CHandler_ButtonHighlight( Button *pButton ) + { + m_pButton = pButton; + } + + virtual void cursorEntered( Panel *panel ) + { + m_pButton->setArmed( true ); + }; + + virtual void cursorExited( Panel *Panel ) + { + m_pButton->setArmed( false ); + }; + + virtual void mousePressed( MouseCode code, Panel *panel ) {}; + virtual void mouseReleased( MouseCode code, Panel *panel ) {}; + virtual void cursorMoved( int x, int y, Panel *panel ) {}; + virtual void mouseDoublePressed( MouseCode code, Panel *panel ) {}; + virtual void mouseWheeled( int delta, Panel *panel ) {}; + virtual void keyPressed( KeyCode code, Panel *panel ) {}; + virtual void keyTyped( KeyCode code, Panel *panel ) {}; + virtual void keyReleased( KeyCode code, Panel *panel ) {}; + virtual void keyFocusTicked( Panel *panel ) {}; +}; + +//----------------------------------------------------------------------------- +// Purpose: Special handler for highlighting of command menu buttons +//----------------------------------------------------------------------------- +class CHandler_CommandButtonHighlight : public CHandler_ButtonHighlight +{ +private: + CommandButton *m_pCommandButton; +public: + CHandler_CommandButtonHighlight( CommandButton *pButton ) : CHandler_ButtonHighlight( pButton ) + { + m_pCommandButton = pButton; + } + + virtual void cursorEntered( Panel *panel ) + { + m_pCommandButton->cursorEntered(); + } + + virtual void cursorExited( Panel *panel ) + { + m_pCommandButton->cursorExited(); + } +}; + + +//================================================================ +// Overidden Command Buttons for special visibilities +class ClassButton : public CommandButton +{ +protected: + int m_iPlayerClass; + +public: + ClassButton( int iClass, const char *text, int x, int y, int wide, int tall, bool bNoHighlight ) : CommandButton( text, x, y, wide, tall, bNoHighlight ) + { + m_iPlayerClass = iClass; + } + + virtual int IsNotValid(); +}; + +class TeamButton : public CommandButton +{ +private: + int m_iTeamNumber; +public: + TeamButton( int iTeam, const char *text, int x, int y, int wide, int tall ) : CommandButton( text, x, y, wide, tall ) + { + m_iTeamNumber = iTeam; + } + + virtual int IsNotValid() + { + int iTeams = gViewPort->GetNumberOfTeams(); + + // Never valid if there's only 1 team + if( iTeams == 1 ) + return true; + + // Auto Team's always visible + if( m_iTeamNumber == 5 ) + return false; + + if( iTeams >= m_iTeamNumber && m_iTeamNumber != g_iTeamNumber ) + return false; + + return true; + } +}; + +class FeignButton : public CommandButton +{ +private: + int m_iFeignState; +public: + FeignButton( int iState, const char *text, int x, int y, int wide, int tall ) : CommandButton( text, x, y, wide, tall ) + { + m_iFeignState = iState; + } + + virtual int IsNotValid() + { + if( m_iFeignState == gViewPort->GetIsFeigning() ) + return false; + + return true; + } +}; + +class SpectateButton : public CommandButton +{ +public: + SpectateButton( const char *text, int x, int y, int wide, int tall, bool bNoHighlight ) : CommandButton( text, x, y, wide, tall, bNoHighlight ) + { + } + + virtual int IsNotValid() + { + // Only visible if the server allows it + if( gViewPort->GetAllowSpectators() != 0 ) + return false; + + return true; + } +}; + +#define DISGUISE_TEAM1 (1<<0) +#define DISGUISE_TEAM2 (1<<1) +#define DISGUISE_TEAM3 (1<<2) +#define DISGUISE_TEAM4 (1<<3) + +class DisguiseButton : public CommandButton +{ +private: + int m_iValidTeamsBits; + int m_iThisTeam; +public: + DisguiseButton( int iValidTeamNumsBits, const char *text, int x, int y, int wide, int tall ) : CommandButton( text, x, y, wide, tall, false ) + { + m_iValidTeamsBits = iValidTeamNumsBits; + } + + virtual int IsNotValid() + { + // if it's not tied to a specific team, then always show (for spies) + if( !m_iValidTeamsBits ) + return false; + + // if we're tied to a team make sure we can change to that team + int iTmp = 1 << ( gViewPort->GetNumberOfTeams() - 1 ); + if( m_iValidTeamsBits & iTmp ) + return false; + + return true; + } +}; + +class DetpackButton : public CommandButton +{ +private: + int m_iDetpackState; +public: + DetpackButton( int iState, const char *text, int x, int y, int wide, int tall ) : CommandButton( text, x, y, wide, tall ) + { + m_iDetpackState = iState; + } + + virtual int IsNotValid() + { + if( m_iDetpackState == gViewPort->GetIsSettingDetpack() ) + return false; + + return true; + } +}; + +extern int iBuildingCosts[]; +#define BUILDSTATE_HASBUILDING (1<<0) // Data is building ID (1 = Dispenser, 2 = Sentry, 3 = Entry Teleporter, 4 = Exit Teleporter) +#define BUILDSTATE_BUILDING (1<<1) +#define BUILDSTATE_BASE (1<<2) +#define BUILDSTATE_CANBUILD (1<<3) // Data is building ID (1 = Dispenser, 2 = Sentry, 3 = Entry Teleporter, 4 = Exit Teleporter) + +class BuildButton : public CommandButton +{ +private: + int m_iBuildState; + int m_iBuildData; + +public: + enum Buildings + { + DISPENSER = 0, + SENTRYGUN = 1, + ENTRY_TELEPORTER = 2, + EXIT_TELEPORTER = 3 + }; + + BuildButton( int iState, int iData, const char *text, int x, int y, int wide, int tall ) : CommandButton( text, x, y, wide, tall ) + { + m_iBuildState = iState; + m_iBuildData = iData; + } + + virtual int IsNotValid() + { + return false; + } +}; + +#define MAX_MAPNAME 256 + +class MapButton : public CommandButton +{ +private: + char m_szMapName[MAX_MAPNAME]; + +public: + MapButton( const char *pMapName, const char *text, int x, int y, int wide, int tall ) : CommandButton( text, x, y, wide, tall ) + { + sprintf( m_szMapName, "maps/%s.bsp", pMapName ); + } + + virtual int IsNotValid() + { + const char *level = gEngfuncs.pfnGetLevelName(); + if( !level ) + return true; + + // Does it match the current map name? + if( strcmp( m_szMapName, level ) ) + return true; + + return false; + } +}; + +//----------------------------------------------------------------------------- +// Purpose: CommandButton which is only displayed if the player is on team X +//----------------------------------------------------------------------------- +class TeamOnlyCommandButton : public CommandButton +{ +private: + int m_iTeamNum; + +public: + TeamOnlyCommandButton( int iTeamNum, const char *text, int x, int y, int wide, int tall, bool flat ) : + CommandButton( text, x, y, wide, tall, false, flat ), m_iTeamNum( iTeamNum ) {} + + virtual int IsNotValid() + { + if( g_iTeamNumber != m_iTeamNum ) + return true; + + return CommandButton::IsNotValid(); + } +}; + +//----------------------------------------------------------------------------- +// Purpose: CommandButton which is only displayed if the player is on team X +//----------------------------------------------------------------------------- +class ToggleCommandButton : public CommandButton, public InputSignal +{ +private: + struct cvar_s *m_cvar; + CImageLabel *pLabelOn; + CImageLabel *pLabelOff; + +public: + ToggleCommandButton( const char *cvarname, const char *text, int x, int y, int wide, int tall, bool flat ) : + CommandButton( text, x, y, wide, tall, false, flat ) + { + m_cvar = gEngfuncs.pfnGetCvarPointer( cvarname ); + + // Put a > to show it's a submenu + pLabelOn = new CImageLabel( "checked", 0, 0 ); + pLabelOn->setParent(this); + pLabelOn->addInputSignal(this); + + pLabelOff = new CImageLabel( "unchecked", 0, 0 ); + pLabelOff->setParent(this); + pLabelOff->setEnabled(true); + pLabelOff->addInputSignal(this); + + int textwide, texttall; + getTextSize( textwide, texttall ); + + // Reposition + pLabelOn->setPos( textwide, ( tall - pLabelOn->getTall() ) / 2 ); + + pLabelOff->setPos( textwide, ( tall - pLabelOff->getTall() ) / 2 ); + + // Set text color to orange + setFgColor( Scheme::sc_primary1 ); + } + + virtual void cursorEntered( Panel *panel ) + { + CommandButton::cursorEntered(); + } + + virtual void cursorExited( Panel *panel ) + { + CommandButton::cursorExited(); + } + + virtual void mousePressed( MouseCode code, Panel *panel ) + { + doClick(); + }; + + virtual void cursorMoved( int x, int y, Panel *panel ) {}; + + virtual void mouseDoublePressed( MouseCode code, Panel *panel) {}; + virtual void mouseReleased( MouseCode code, Panel *panel ) {}; + virtual void mouseWheeled( int delta, Panel *panel ) {}; + virtual void keyPressed( KeyCode code, Panel *panel ) {}; + virtual void keyTyped( KeyCode code, Panel *panel ) {}; + virtual void keyReleased( KeyCode code, Panel *panel ) {}; + virtual void keyFocusTicked( Panel *panel) {}; + + virtual void paint( void ) + { + if( !m_cvar ) + { + pLabelOff->setVisible( false ); + pLabelOn->setVisible( false ); + } + else if( m_cvar->value ) + { + pLabelOff->setVisible( false ); + pLabelOn->setVisible( true ); + } + else + { + pLabelOff->setVisible( true ); + pLabelOn->setVisible( false ); + } + + CommandButton::paint(); + } +}; +class SpectToggleButton : public CommandButton, public InputSignal +{ +private: + struct cvar_s *m_cvar; + CImageLabel *pLabelOn; + +public: + SpectToggleButton( const char *cvarname, const char *text, int x, int y, int wide, int tall, bool flat ) : + CommandButton( text, x, y, wide, tall, false, flat ) + { + m_cvar = gEngfuncs.pfnGetCvarPointer( cvarname ); + + // Put a > to show it's a submenu + pLabelOn = new CImageLabel( "checked", 0, 0 ); + pLabelOn->setParent( this ); + pLabelOn->addInputSignal( this ); + + int textwide, texttall; + getTextSize( textwide, texttall ); + + // Reposition + pLabelOn->setPos( textwide, ( tall - pLabelOn->getTall() ) / 2 ); + } + + virtual void cursorEntered( Panel *panel ) + { + CommandButton::cursorEntered(); + } + + virtual void cursorExited( Panel *panel ) + { + CommandButton::cursorExited(); + } + + virtual void mousePressed( MouseCode code, Panel *panel ) + { + doClick(); + }; + + virtual void cursorMoved( int x, int y, Panel *panel ) {}; + + virtual void mouseDoublePressed( MouseCode code, Panel *panel ) {}; + virtual void mouseReleased( MouseCode code, Panel *panel ) {}; + virtual void mouseWheeled( int delta, Panel *panel ) {}; + virtual void keyPressed( KeyCode code, Panel *panel ) {}; + virtual void keyTyped( KeyCode code, Panel *panel ) {}; + virtual void keyReleased( KeyCode code, Panel *panel ) {}; + virtual void keyFocusTicked( Panel *panel ) {}; + + virtual void paintBackground() + { + if( isArmed() ) + { + drawSetColor( 143, 143, 54, 125 ); + drawFilledRect( 5, 0, _size[0] - 5, _size[1] ); + } + } + + virtual void paint( void ) + { + if( isArmed() ) + { + setFgColor( 194, 202, 54, 0 ); + } + else + { + setFgColor( 143, 143, 54, 15 ); + } + + if( !m_cvar ) + { + pLabelOn->setVisible( false ); + } + else if( m_cvar->value ) + { + pLabelOn->setVisible( true ); + } + else + { + pLabelOn->setVisible( false ); + } + + Button::paint(); + } +}; + +/* +class SpectToggleButton : public ToggleCommandButton +{ +private: + struct cvar_s *m_cvar; + CImageLabel *pLabelOn; + CImageLabel *pLabelOff; + +public: + SpectToggleButton( const char *cvarname, const char *text, int x, int y, int wide, int tall, bool flat ) : + ToggleCommandButton( cvarname, text, x, y, wide, tall, flat, TRUE ) + { + m_cvar = gEngfuncs.pfnGetCvarPointer( cvarname ); + + // Put a > to show it's a submenu + pLabelOn = new CImageLabel( "checked", 0, 0 ); + pLabelOn->setParent( this ); + pLabelOn->addInputSignal( this ); + + pLabelOff = new CImageLabel( "unchecked", 0, 0 ); + pLabelOff->setParent( this ); + pLabelOff->setEnabled( true ); + pLabelOff->addInputSignal( this ); + + int textwide, texttall; + getTextSize( textwide, texttall ); + + // Reposition + pLabelOn->setPos( textwide, ( tall - pLabelOn->getTall() ) / 2 ); + + pLabelOff->setPos( textwide, ( tall - pLabelOff->getTall() ) / 2 ); + + // Set text color to orange + setFgColor( Scheme::sc_primary1 ); + } + + virtual void paintBackground() + { + if( isArmed() ) + { + drawSetColor( 143,143, 54, 125 ); + drawFilledRect( 5, 0, _size[0] - 5,_size[1] ); + } + } + + virtual void paint() + { + + if( isArmed() ) + { + setFgColor( 194, 202, 54, 0 ); + } + else + { + setFgColor( 143, 143, 54, 15 ); + } + + if( !m_cvar ) + { + pLabelOff->setVisible( false ); + pLabelOn->setVisible( false ); + } + else if( m_cvar->value ) + { + pLabelOff->setVisible( false ); + pLabelOn->setVisible( true ); + } + else + { + pLabelOff->setVisible( true ); + pLabelOn->setVisible( false ); + } + + Button::paint(); + } +}; +*/ + +//============================================================ +// Panel that can be dragged around +class DragNDropPanel : public Panel +{ +private: + bool m_bBeingDragged; + LineBorder *m_pBorder; +public: + DragNDropPanel( int x, int y, int wide, int tall ) : Panel( x, y, wide, tall ) + { + m_bBeingDragged = false; + + // Create the Drag Handler + addInputSignal( new CDragNDropHandler( this ) ); + + // Create the border (for dragging) + m_pBorder = new LineBorder(); + } + + virtual void setDragged( bool bState ) + { + m_bBeingDragged = bState; + + if( m_bBeingDragged ) + setBorder( m_pBorder ); + else + setBorder( NULL ); + } +}; + +//================================================================ +// Panel that draws itself with a transparent black background +class CTransparentPanel : public Panel +{ +private: + int m_iTransparency; +public: + CTransparentPanel( int iTrans, int x, int y, int wide, int tall ) : Panel( x, y, wide, tall ) + { + m_iTransparency = iTrans; + } + + virtual void paintBackground() + { + if( m_iTransparency ) + { + // Transparent black background + drawSetColor( 0, 0, 0, m_iTransparency ); + drawFilledRect( 0, 0, _size[0], _size[1] ); + } + } +}; + +//================================================================ +// Menu Panel that supports buffering of menus +class CMenuPanel : public CTransparentPanel +{ +private: + CMenuPanel *m_pNextMenu; + int m_iMenuID; + int m_iRemoveMe; + int m_iIsActive; + float m_flOpenTime; +public: + CMenuPanel( int iRemoveMe, int x, int y, int wide, int tall ) : CTransparentPanel( 100, x, y, wide, tall ) + { + Reset(); + m_iRemoveMe = iRemoveMe; + } + + CMenuPanel( int iTrans, int iRemoveMe, int x, int y, int wide, int tall ) : CTransparentPanel( iTrans, x, y, wide, tall ) + { + Reset(); + m_iRemoveMe = iRemoveMe; + } + + virtual void Reset( void ) + { + m_pNextMenu = NULL; + m_iIsActive = false; + m_flOpenTime = 0; + } + + void SetNextMenu( CMenuPanel *pNextPanel ) + { + if( m_pNextMenu ) + m_pNextMenu->SetNextMenu( pNextPanel ); + else + m_pNextMenu = pNextPanel; + } + + void SetMenuID( int iID ) + { + m_iMenuID = iID; + } + + void SetActive( int iState ) + { + m_iIsActive = iState; + } + + virtual void Open( void ) + { + setVisible( true ); + + // Note the open time, so we can delay input for a bit + m_flOpenTime = gHUD.m_flTime; + } + + virtual void Close( void ) + { + setVisible( false ); + m_iIsActive = false; + + if ( m_iRemoveMe ) + gViewPort->removeChild( this ); + + // This MenuPanel has now been deleted. Don't append code here. + } + + int ShouldBeRemoved() { return m_iRemoveMe; }; + CMenuPanel* GetNextMenu() { return m_pNextMenu; }; + int GetMenuID() { return m_iMenuID; }; + int IsActive() { return m_iIsActive; }; + float GetOpenTime() { return m_flOpenTime; }; + + // Numeric input + virtual bool SlotInput( int iSlot ) { return false; }; + virtual void SetActiveInfo( int iInput ) {}; +}; + +//================================================================ +// Custom drawn scroll bars +class CTFScrollButton : public CommandButton +{ +private: + BitmapTGA *m_pTGA; + +public: + CTFScrollButton( int iArrow, const char *text, int x, int y, int wide, int tall ); + + virtual void paint( void ); + virtual void paintBackground( void ); +}; + +// Custom drawn slider bar +class CTFSlider : public Slider +{ +public: + CTFSlider( int x, int y, int wide, int tall, bool vertical ) : Slider( x, y, wide, tall, vertical ) + { + }; + + virtual void paintBackground( void ); +}; + +// Custom drawn scrollpanel +class CTFScrollPanel : public ScrollPanel +{ +public: + CTFScrollPanel(int x,int y,int wide,int tall); +}; + +//================================================================ +// Menu Panels that take key input +//============================================================ +class CClassMenuPanel : public CMenuPanel +{ +private: + CTransparentPanel *m_pClassInfoPanel[PC_LASTCLASS]; + Label *m_pPlayers[PC_LASTCLASS]; + ClassButton *m_pButtons[PC_LASTCLASS]; + CommandButton *m_pCancelButton; + ScrollPanel *m_pScrollPanel; + + CImageLabel *m_pClassImages[MAX_TEAMS][PC_LASTCLASS]; + + int m_iCurrentInfo; + + enum { STRLENMAX_PLAYERSONTEAM = 128 }; + char m_sPlayersOnTeamString[STRLENMAX_PLAYERSONTEAM]; + +public: + CClassMenuPanel( int iTrans, int iRemoveMe, int x, int y, int wide, int tall ); + + virtual bool SlotInput( int iSlot ); + virtual void Open( void ); + virtual void Update( void ); + virtual void SetActiveInfo( int iInput ); + virtual void Initialize( void ); + + virtual void Reset( void ) + { + CMenuPanel::Reset(); + m_iCurrentInfo = 0; + } +}; + +class CTeamMenuPanel : public CMenuPanel +{ +public: + ScrollPanel *m_pScrollPanel; + CTransparentPanel *m_pTeamWindow; + Label *m_pMapTitle; + TextPanel *m_pBriefing; + TextPanel *m_pTeamInfoPanel[6]; + CommandButton *m_pButtons[6]; + bool m_bUpdatedMapName; + CommandButton *m_pCancelButton; + CommandButton *m_pSpectateButton; + + int m_iCurrentInfo; + +public: + CTeamMenuPanel( int iTrans, int iRemoveMe, int x, int y, int wide, int tall ); + + virtual bool SlotInput( int iSlot ); + virtual void Open( void ); + virtual void Update( void ); + virtual void SetActiveInfo( int iInput ); + virtual void paintBackground( void ); + + virtual void Initialize( void ); + + virtual void Reset( void ) + { + CMenuPanel::Reset(); + m_iCurrentInfo = 0; + } +}; + +//========================================================= +// Specific Menus to handle old HUD sections +class CHealthPanel : public DragNDropPanel +{ +private: + BitmapTGA *m_pHealthTGA; + Label *m_pHealthLabel; +public: + CHealthPanel( int x, int y, int wide, int tall ) : DragNDropPanel( x, y, wide, tall ) + { + // Load the Health icon + FileInputStream *fis = new FileInputStream( GetVGUITGAName( "%d_hud_health" ), false ); + m_pHealthTGA = new BitmapTGA( fis, true ); + fis->close(); + + // Create the Health Label + int iXSize, iYSize; + m_pHealthTGA->getSize( iXSize, iYSize ); + m_pHealthLabel = new Label( "", 0, 0, iXSize, iYSize ); + m_pHealthLabel->setImage( m_pHealthTGA ); + m_pHealthLabel->setParent( this ); + + // Set panel dimension + // Shouldn't be needed once Billy's fized setImage not recalculating the size + // setSize( iXSize + 100, gHUD.m_iFontHeight + 10 ); + // m_pHealthLabel->setPos( 10, ( getTall() - iYSize ) / 2 ); + } + + virtual void paintBackground() + { + } + + void paint() + { + // Get the paint color + int r,g,b,a; + // Has health changed? Flash the health # + if( gHUD.m_Health.m_fFade ) + { + gHUD.m_Health.m_fFade -= ( gHUD.m_flTimeDelta * 20 ); + if( gHUD.m_Health.m_fFade <= 0 ) + { + a = MIN_ALPHA; + gHUD.m_Health.m_fFade = 0; + } + + // Fade the health number back to dim + a = MIN_ALPHA + ( gHUD.m_Health.m_fFade / FADE_TIME ) * 128; + } + else + a = MIN_ALPHA; + + gHUD.m_Health.GetPainColor( r, g, b ); + ScaleColors(r, g, b, a ); + + // If health is getting low, make it bright red + if( gHUD.m_Health.m_iHealth <= 15 ) + a = 255; + + int iXSize, iYSize, iXPos, iYPos; + m_pHealthTGA->getSize( iXSize, iYSize ); + m_pHealthTGA->getPos( iXPos, iYPos ); + + // Paint the player's health + int x = gHUD.DrawHudNumber( iXPos + iXSize + 5, iYPos + 5, DHN_3DIGITS | DHN_DRAWZERO, gHUD.m_Health.m_iHealth, r, g, b ); + + // Draw the vertical line + int HealthWidth = gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).right - gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).left; + x += HealthWidth / 2; + FillRGBA( x, iYPos + 5, HealthWidth / 10, gHUD.m_iFontHeight, 255, 160, 0, a ); + } +}; +#endif diff --git a/cl_dll/vgui_int.cpp b/cl_dll/vgui_int.cpp new file mode 100644 index 00000000..2a4272d8 --- /dev/null +++ b/cl_dll/vgui_int.cpp @@ -0,0 +1,127 @@ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#include "vgui_int.h" +#include +#include +#include +#include +#include +#include +#include +#include "hud.h" +#include "cl_util.h" +#include "camera.h" +#include "kbutton.h" +#include "cvardef.h" +#include "usercmd.h" +#include "const.h" +#include "camera.h" +#include "in_defs.h" +#include "vgui_TeamFortressViewport.h" +#include "vgui_ControlConfigPanel.h" + +namespace +{ + +class TexturePanel : public Panel, public ActionSignal +{ +private: + int _bindIndex; + TextEntry *_textEntry; +public: + TexturePanel() : Panel( 0, 0, 256, 276 ) + { + _bindIndex = 2700; + _textEntry = new TextEntry( "2700", 0, 0, 128, 20 ); + _textEntry->setParent( this ); + _textEntry->addActionSignal( this ); + } + + virtual bool isWithin( int x, int y ) + { + return _textEntry->isWithin( x, y ); + } + + virtual void actionPerformed( Panel *panel ) + { + char buf[256]; + + _textEntry->getText( 0, buf, 256 ); + sscanf( buf, "%d", &_bindIndex); + } +protected: + virtual void paintBackground() + { + Panel::paintBackground(); + + int wide, tall; + + getPaintSize( wide, tall ); + + drawSetColor( 0, 0, 255, 0 ); + drawSetTexture( _bindIndex ); + drawTexturedRect( 0, 19, 257, 257 ); + } +}; + +} + +using namespace vgui; + +void VGui_ViewportPaintBackground( int extents[4] ) +{ + gEngfuncs.VGui_ViewportPaintBackground( extents ); +} + +void* VGui_GetPanel() +{ + return (Panel*)gEngfuncs.VGui_GetPanel(); +} + +void VGui_Startup() +{ + Panel *root = (Panel*)VGui_GetPanel(); + root->setBgColor( 128, 128, 0, 0 ); + // root->setNonPainted( false ); + // root->setBorder( new LineBorder() ); + root->setLayout( new BorderLayout( 0 ) ); + + // root->getSurfaceBase()->setEmulatedCursorVisible( true ); + + if( gViewPort != NULL ) + { +// root->removeChild( gViewPort ); + + // free the memory +// delete gViewPort; +// gViewPort = NULL; + + gViewPort->Initialize(); + } + else + { + gViewPort = new TeamFortressViewport( 0, 0, root->getWide(), root->getTall() ); + gViewPort->setParent( root ); + } + + /* + TexturePanel *texturePanel = new TexturePanel(); + texturePanel->setParent( gViewPort ); + */ +} + +void VGui_Shutdown() +{ + delete gViewPort; + gViewPort = NULL; +} + + + + + diff --git a/cl_dll/vgui_int.h b/cl_dll/vgui_int.h new file mode 100644 index 00000000..6510853e --- /dev/null +++ b/cl_dll/vgui_int.h @@ -0,0 +1,21 @@ +//========= Copyright 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_INT_H +#define VGUI_INT_H + +extern "C" +{ +void VGui_Startup(); +void VGui_Shutdown(); + +//Only safe to call from inside subclass of Panel::paintBackground +void VGui_ViewportPaintBackground(int extents[4]); +} + + +#endif \ No newline at end of file diff --git a/cl_dll/vgui_teammenu.cpp b/cl_dll/vgui_teammenu.cpp new file mode 100644 index 00000000..bc7b22e6 --- /dev/null +++ b/cl_dll/vgui_teammenu.cpp @@ -0,0 +1,394 @@ +//=========== (C) Copyright 1996-2002 Valve, L.L.C. All rights reserved. =========== +// +// The copyright to the contents herein is the property of Valve, L.L.C. +// The contents may be used and/or copied only with the written permission of +// Valve, L.L.C., or in accordance with the terms and conditions stipulated in +// the agreement/contract under which the contents have been supplied. +// +// Purpose: TFC Team Menu +// +// $Workfile: $ +// $Date: $ +// +//----------------------------------------------------------------------------- +// $Log: $ +// +// $NoKeywords: $ +//============================================================================= + +#include "vgui_int.h" +#include "VGUI_Font.h" +#include "VGUI_ScrollPanel.h" +#include "VGUI_TextImage.h" + +#include "hud.h" +#include "cl_util.h" +#include "vgui_TeamFortressViewport.h" + +// Team Menu Dimensions +#define TEAMMENU_TITLE_X XRES(40) +#define TEAMMENU_TITLE_Y YRES(32) +#define TEAMMENU_TOPLEFT_BUTTON_X XRES(40) +#define TEAMMENU_TOPLEFT_BUTTON_Y YRES(80) +#define TEAMMENU_BUTTON_SIZE_X XRES(124) +#define TEAMMENU_BUTTON_SIZE_Y YRES(24) +#define TEAMMENU_BUTTON_SPACER_Y YRES(8) +#define TEAMMENU_WINDOW_X XRES(176) +#define TEAMMENU_WINDOW_Y YRES(80) +#define TEAMMENU_WINDOW_SIZE_X XRES(424) +#define TEAMMENU_WINDOW_SIZE_Y YRES(312) +#define TEAMMENU_WINDOW_TITLE_X XRES(16) +#define TEAMMENU_WINDOW_TITLE_Y YRES(16) +#define TEAMMENU_WINDOW_TEXT_X XRES(16) +#define TEAMMENU_WINDOW_TEXT_Y YRES(48) +#define TEAMMENU_WINDOW_TEXT_SIZE_Y YRES(178) +#define TEAMMENU_WINDOW_INFO_X XRES(16) +#define TEAMMENU_WINDOW_INFO_Y YRES(234) + +// Creation +CTeamMenuPanel::CTeamMenuPanel( int iTrans, int iRemoveMe, int x, int y, int wide, int tall ) : CMenuPanel( iTrans, iRemoveMe, x, y, wide, tall ) +{ + // Get the scheme used for the Titles + CSchemeManager *pSchemes = gViewPort->GetSchemeManager(); + + // schemes + SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle( "Title Font" ); + SchemeHandle_t hTeamWindowText = pSchemes->getSchemeHandle( "Briefing Text" ); + SchemeHandle_t hTeamInfoText = pSchemes->getSchemeHandle( "Team Info Text" ); + + // get the Font used for the Titles + Font *pTitleFont = pSchemes->getFont( hTitleScheme ); + int r, g, b, a; + + // Create the title + Label *pLabel = new Label( "", TEAMMENU_TITLE_X, TEAMMENU_TITLE_Y ); + pLabel->setParent( this ); + pLabel->setFont( pTitleFont ); + pSchemes->getFgColor( hTitleScheme, r, g, b, a ); + pLabel->setFgColor( r, g, b, a ); + pSchemes->getBgColor( hTitleScheme, r, g, b, a ); + pLabel->setBgColor( r, g, b, a ); + pLabel->setContentAlignment( vgui::Label::a_west ); + pLabel->setText( "%s", gHUD.m_TextMessage.BufferedLocaliseTextString("#Title_SelectYourTeam")); + + // Create the Info Window + m_pTeamWindow = new CTransparentPanel( 255, TEAMMENU_WINDOW_X, TEAMMENU_WINDOW_Y, TEAMMENU_WINDOW_SIZE_X, TEAMMENU_WINDOW_SIZE_Y ); + m_pTeamWindow->setParent( this ); + m_pTeamWindow->setBorder( new LineBorder( Color( 255 * 0.7, 170 * 0.7 ,0 ,0 ) ) ); + + // Create the Map Name Label + m_pMapTitle = new Label( "", TEAMMENU_WINDOW_TITLE_X, TEAMMENU_WINDOW_TITLE_Y ); + m_pMapTitle->setFont( pTitleFont ); + m_pMapTitle->setParent( m_pTeamWindow ); + pSchemes->getFgColor( hTitleScheme, r, g, b, a ); + m_pMapTitle->setFgColor( r, g, b, a ); + pSchemes->getBgColor( hTitleScheme, r, g, b, a ); + m_pMapTitle->setBgColor( r, g, b, a ); + m_pMapTitle->setContentAlignment( vgui::Label::a_west ); + + // Create the Scroll panel + m_pScrollPanel = new CTFScrollPanel( TEAMMENU_WINDOW_TEXT_X, TEAMMENU_WINDOW_TEXT_Y, TEAMMENU_WINDOW_SIZE_X - ( TEAMMENU_WINDOW_TEXT_X * 2 ), TEAMMENU_WINDOW_TEXT_SIZE_Y ); + m_pScrollPanel->setParent( m_pTeamWindow ); + m_pScrollPanel->setScrollBarVisible( false, false ); + + // Create the Map Briefing panel + m_pBriefing = new TextPanel("", 0, 0, TEAMMENU_WINDOW_SIZE_X - TEAMMENU_WINDOW_TEXT_X, TEAMMENU_WINDOW_TEXT_SIZE_Y ); + m_pBriefing->setParent( m_pScrollPanel->getClient() ); + m_pBriefing->setFont( pSchemes->getFont( hTeamWindowText ) ); + pSchemes->getFgColor( hTeamWindowText, r, g, b, a ); + m_pBriefing->setFgColor( r, g, b, a ); + pSchemes->getBgColor( hTeamWindowText, r, g, b, a ); + m_pBriefing->setBgColor( r, g, b, a ); + + m_pBriefing->setText( gHUD.m_TextMessage.BufferedLocaliseTextString( "#Map_Description_not_available" ) ); + + // Team Menu buttons + for( int i = 1; i <= 5; i++ ) + { + char sz[256]; + + int iYPos = TEAMMENU_TOPLEFT_BUTTON_Y + ( ( TEAMMENU_BUTTON_SIZE_Y + TEAMMENU_BUTTON_SPACER_Y ) * i ); + + // Team button + m_pButtons[i] = new CommandButton( "", TEAMMENU_TOPLEFT_BUTTON_X, iYPos, TEAMMENU_BUTTON_SIZE_X, TEAMMENU_BUTTON_SIZE_Y, true ); + m_pButtons[i]->setParent( this ); + m_pButtons[i]->setContentAlignment( vgui::Label::a_west ); + m_pButtons[i]->setVisible( false ); + + // AutoAssign button uses special case + if( i == 5 ) + { + m_pButtons[5]->setBoundKey( '5' ); + m_pButtons[5]->setText( gHUD.m_TextMessage.BufferedLocaliseTextString( "#Team_AutoAssign" ) ); + m_pButtons[5]->setVisible( true ); + } + + // Create the Signals + sprintf( sz, "jointeam %d", i ); + m_pButtons[i]->addActionSignal( new CMenuHandler_StringCommandWatch( sz, true ) ); + m_pButtons[i]->addInputSignal( new CHandler_MenuButtonOver( this, i ) ); + + // Create the Team Info panel + m_pTeamInfoPanel[i] = new TextPanel( "", TEAMMENU_WINDOW_INFO_X, TEAMMENU_WINDOW_INFO_Y, TEAMMENU_WINDOW_SIZE_X - TEAMMENU_WINDOW_INFO_X, TEAMMENU_WINDOW_SIZE_X - TEAMMENU_WINDOW_INFO_Y ); + m_pTeamInfoPanel[i]->setParent( m_pTeamWindow ); + m_pTeamInfoPanel[i]->setFont( pSchemes->getFont( hTeamInfoText ) ); + m_pTeamInfoPanel[i]->setFgColor( iTeamColors[i % iNumberOfTeamColors][0], + iTeamColors[i % iNumberOfTeamColors][1], + iTeamColors[i % iNumberOfTeamColors][2], + 0 ); + m_pTeamInfoPanel[i]->setBgColor( 0, 0, 0, 255 ); + } + + // Create the Cancel button + m_pCancelButton = new CommandButton( CHudTextMessage::BufferedLocaliseTextString( "#Menu_Cancel" ), TEAMMENU_TOPLEFT_BUTTON_X, 0, TEAMMENU_BUTTON_SIZE_X, TEAMMENU_BUTTON_SIZE_Y ); + m_pCancelButton->setParent( this ); + m_pCancelButton->addActionSignal( new CMenuHandler_TextWindow( HIDE_TEXTWINDOW ) ); + + // Create the Spectate button + m_pSpectateButton = new SpectateButton( CHudTextMessage::BufferedLocaliseTextString( "#Menu_Spectate" ), TEAMMENU_TOPLEFT_BUTTON_X, 0, TEAMMENU_BUTTON_SIZE_X, TEAMMENU_BUTTON_SIZE_Y, true ); + m_pSpectateButton->setParent( this ); + m_pSpectateButton->addActionSignal( new CMenuHandler_StringCommand( "spectate", true ) ); + m_pSpectateButton->setBoundKey( '6' ); + m_pSpectateButton->addInputSignal( new CHandler_MenuButtonOver( this, 6 ) ); + + Initialize(); +} + +//----------------------------------------------------------------------------- +// Purpose: Called each time a new level is started. +//----------------------------------------------------------------------------- +void CTeamMenuPanel::Initialize( void ) +{ + m_bUpdatedMapName = false; + m_iCurrentInfo = 0; + m_pScrollPanel->setScrollValue( 0, 0 ); +} + +//----------------------------------------------------------------------------- +// Purpose: Called everytime the Team Menu is displayed +//----------------------------------------------------------------------------- +void CTeamMenuPanel::Update( void ) +{ + int iYPos = TEAMMENU_TOPLEFT_BUTTON_Y; + + // Set the team buttons + for( int i = 1; i <= 4; i++ ) + { + if( m_pButtons[i] ) + { + if( i <= gViewPort->GetNumberOfTeams() ) + { + m_pButtons[i]->setText( gViewPort->GetTeamName( i ) ); + + // bound key replacement + char sz[32]; + sprintf( sz, "%d", i ); + m_pButtons[i]->setBoundKey( sz[0] ); + + m_pButtons[i]->setVisible( true ); + m_pButtons[i]->setPos( TEAMMENU_TOPLEFT_BUTTON_X, iYPos ); + iYPos += TEAMMENU_BUTTON_SIZE_Y + TEAMMENU_BUTTON_SPACER_Y; + + // Start with the first option up + if( !m_iCurrentInfo ) + SetActiveInfo( i ); + + char szPlayerList[( MAX_PLAYER_NAME_LENGTH + 3 ) * 31]; // name + ", " + strcpy(szPlayerList, "\n"); + // Update the Team Info + // Now count the number of teammembers of this class + int iTotal = 0; + for( int j = 1; j < MAX_PLAYERS; j++ ) + { + if( g_PlayerInfoList[j].name == NULL ) + continue; // empty player slot, skip + if( g_PlayerInfoList[j].thisplayer ) + continue; // skip this player + if( g_PlayerExtraInfo[j].teamnumber != i ) + continue; // skip over players in other teams + + iTotal++; + if( iTotal > 1 ) + strncat( szPlayerList, ", ", sizeof(szPlayerList) - strlen( szPlayerList ) - 1 ); + strncat( szPlayerList, g_PlayerInfoList[j].name, sizeof(szPlayerList) - strlen( szPlayerList ) - 1 ); + szPlayerList[sizeof(szPlayerList) - 1] = '\0'; + } + + if( iTotal > 0 ) + { + // Set the text of the info Panel + char szText[( ( MAX_PLAYER_NAME_LENGTH + 3 ) * 31 ) + 256]; + if( iTotal == 1 ) + sprintf( szText, "%s: %d Player (%d points)", gViewPort->GetTeamName( i ), iTotal, g_TeamInfo[i].frags ); + else + sprintf( szText, "%s: %d Players (%d points)", gViewPort->GetTeamName( i ), iTotal, g_TeamInfo[i].frags ); + strncat( szText, szPlayerList, sizeof(szText) - strlen( szText ) - 1 ); + szText[sizeof(szText) - 1] = '\0'; + + m_pTeamInfoPanel[i]->setText( szText ); + } + else + { + m_pTeamInfoPanel[i]->setText( "" ); + } + } + else + { + // Hide the button (may be visible from previous maps) + m_pButtons[i]->setVisible( false ); + } + } + } + + // Move the AutoAssign button into place + m_pButtons[5]->setPos( TEAMMENU_TOPLEFT_BUTTON_X, iYPos ); + iYPos += TEAMMENU_BUTTON_SIZE_Y + TEAMMENU_BUTTON_SPACER_Y; + + // Spectate button + if( m_pSpectateButton->IsNotValid() ) + { + m_pSpectateButton->setVisible( false ); + } + else + { + m_pSpectateButton->setPos( TEAMMENU_TOPLEFT_BUTTON_X, iYPos ); + m_pSpectateButton->setVisible( true ); + iYPos += TEAMMENU_BUTTON_SIZE_Y + TEAMMENU_BUTTON_SPACER_Y; + } + + // If the player is already in a team, make the cancel button visible + if( g_iTeamNumber ) + { + m_pCancelButton->setPos( TEAMMENU_TOPLEFT_BUTTON_X, iYPos ); + iYPos += TEAMMENU_BUTTON_SIZE_Y + TEAMMENU_BUTTON_SPACER_Y; + m_pCancelButton->setVisible( true ); + } + else + { + m_pCancelButton->setVisible( false ); + } + + // Set the Map Title + if( !m_bUpdatedMapName ) + { + const char *level = gEngfuncs.pfnGetLevelName(); + if( level && level[0] ) + { + char sz[256]; + char szTitle[256]; + char *ch; + + // Update the level name + strcpy( sz, level ); + ch = strchr( sz, '/' ); + if( !ch ) + ch = strchr( sz, '\\' ); + strcpy( szTitle, ch + 1 ); + ch = strchr( szTitle, '.' ); + *ch = '\0'; + m_pMapTitle->setText( "%s", szTitle ); + *ch = '.'; + + // Update the map briefing + strcpy( sz, level ); + ch = strchr( sz, '.' ); + *ch = '\0'; + strcat( sz, ".txt" ); + char *pfile = (char*)gEngfuncs.COM_LoadFile( sz, 5, NULL ); + if( pfile ) + { + m_pBriefing->setText( pfile ); + + // Get the total size of the Briefing text and resize the text panel + int iXSize, iYSize; + m_pBriefing->getTextImage()->getTextSize( iXSize, iYSize ); + m_pBriefing->setSize( iXSize, iYSize ); + gEngfuncs.COM_FreeFile( pfile ); + } + + m_bUpdatedMapName = true; + } + } + + m_pScrollPanel->validate(); +} + +//===================================== +// Key inputs +bool CTeamMenuPanel::SlotInput( int iSlot ) +{ + // Check for AutoAssign + if( iSlot == 5 ) + { + m_pButtons[5]->fireActionSignal(); + return true; + } + + // Spectate + if( iSlot == 6 ) + { + m_pSpectateButton->fireActionSignal(); + return true; + } + + // Otherwise, see if a particular team is selectable + if( ( iSlot < 1 ) || ( iSlot > gViewPort->GetNumberOfTeams() ) ) + return false; + + if( !m_pButtons[iSlot] ) + return false; + + // Is the button pushable? + if( m_pButtons[iSlot]->isVisible() ) + { + m_pButtons[iSlot]->fireActionSignal(); + return true; + } + + return false; +} + +//====================================== +// Update the Team menu before opening it +void CTeamMenuPanel::Open( void ) +{ + Update(); + CMenuPanel::Open(); +} + +void CTeamMenuPanel::paintBackground() +{ + // make sure we get the map briefing up + if( !m_bUpdatedMapName ) + Update(); + + CMenuPanel::paintBackground(); +} + +//====================================== +// Mouse is over a team button, bring up the class info +void CTeamMenuPanel::SetActiveInfo( int iInput ) +{ + // Remove all the Info panels and bring up the specified one + m_pSpectateButton->setArmed( false ); + for( int i = 1; i <= 5; i++ ) + { + m_pButtons[i]->setArmed( false ); + m_pTeamInfoPanel[i]->setVisible( false ); + } + + // 6 is Spectate + if( iInput == 6 ) + { + m_pSpectateButton->setArmed( true ); + } + else + { + m_pButtons[iInput]->setArmed( true ); + m_pTeamInfoPanel[iInput]->setVisible( true ); + } + + m_iCurrentInfo = iInput; + + m_pScrollPanel->validate(); +} diff --git a/cl_dll/view.cpp b/cl_dll/view.cpp index 2555d4a1..4c93fb87 100644 --- a/cl_dll/view.cpp +++ b/cl_dll/view.cpp @@ -25,6 +25,7 @@ #include "screenfade.h" #include "shake.h" #include "hltv.h" +#include "view.h" // Spectator Mode extern "C" @@ -36,10 +37,6 @@ extern "C" int iIsSpectator; } -#ifndef M_PI -#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h -#endif - extern "C" { int CL_IsThirdPerson( void ); @@ -91,6 +88,7 @@ float v_cameraFocusAngle = 35.0f; int v_cameraMode = CAM_MODE_FOCUS; qboolean v_resetCamera = 1; +vec3_t v_client_aimangles; vec3_t g_ev_punchangle; cvar_t *scr_ofsx; @@ -126,13 +124,13 @@ void V_NormalizeAngles( float *angles ) // Normalize angles for( i = 0; i < 3; i++ ) { - if( angles[i] > 180.0 ) + if( angles[i] > 180.0f ) { - angles[i] -= 360.0; + angles[i] -= 360.0f; } - else if( angles[i] < -180.0 ) + else if( angles[i] < -180.0f ) { - angles[i] += 360.0; + angles[i] += 360.0f; } } } @@ -160,13 +158,13 @@ void V_InterpolateAngles( float *start, float *end, float *output, float frac ) ang2 = end[i]; d = ang2 - ang1; - if( d > 180 ) + if( d > 180.0f ) { - d -= 360; + d -= 360.0f; } - else if( d < -180 ) + else if( d < -180.0f ) { - d += 360; + d += 360.0f; } output[i] = ang1 + d * frac; @@ -199,11 +197,11 @@ float V_CalcBob( struct ref_params_s *pparams ) if( cycle < cl_bobup->value ) { - cycle = M_PI * cycle / cl_bobup->value; + cycle = M_PI_F * cycle / cl_bobup->value; } else { - cycle = M_PI + M_PI * ( cycle - cl_bobup->value )/( 1.0 - cl_bobup->value ); + cycle = M_PI_F + M_PI_F * ( cycle - cl_bobup->value )/( 1.0f - cl_bobup->value ); } // bob is proportional to simulated velocity in the xy plane @@ -212,9 +210,9 @@ float V_CalcBob( struct ref_params_s *pparams ) vel[2] = 0; bob = sqrt( vel[0] * vel[0] + vel[1] * vel[1] ) * cl_bob->value; - bob = bob * 0.3 + bob * 0.7 * sin(cycle); - bob = Q_min( bob, 4 ); - bob = Q_max( bob, -7 ); + bob = bob * 0.3f + bob * 0.7f * sin(cycle); + bob = Q_min( bob, 4.0f ); + bob = Q_max( bob, -7.0f ); return bob; } @@ -234,7 +232,7 @@ float V_CalcRoll( vec3_t angles, vec3_t velocity, float rollangle, float rollspe AngleVectors( angles, forward, right, up ); side = DotProduct( velocity, right ); - sign = side < 0 ? -1 : 1; + sign = side < 0.0f ? -1.0f : 1.0f; side = fabs( side ); value = rollangle; @@ -290,11 +288,11 @@ void V_CalcGunAngle( struct ref_params_s *pparams ) return; viewent->angles[YAW] = pparams->viewangles[YAW] + pparams->crosshairangle[YAW]; - viewent->angles[PITCH] = -pparams->viewangles[PITCH] + pparams->crosshairangle[PITCH] * 0.25; + viewent->angles[PITCH] = -pparams->viewangles[PITCH] + pparams->crosshairangle[PITCH] * 0.25f; viewent->angles[ROLL] -= v_idlescale * sin( pparams->time * v_iroll_cycle.value ) * v_iroll_level.value; // don't apply all of the v_ipitch to prevent normally unseen parts of viewmodel from coming into view. - viewent->angles[PITCH] -= v_idlescale * sin( pparams->time * v_ipitch_cycle.value ) * ( v_ipitch_level.value * 0.5 ); + viewent->angles[PITCH] -= v_idlescale * sin( pparams->time * v_ipitch_cycle.value ) * ( v_ipitch_level.value * 0.5f ); viewent->angles[YAW] -= v_idlescale * sin( pparams->time * v_iyaw_cycle.value ) * v_iyaw_level.value; VectorCopy( viewent->angles, viewent->curstate.angles ); @@ -453,15 +451,15 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams ) } gEngfuncs.V_CalcShake(); - gEngfuncs.V_ApplyShake( pparams->vieworg, pparams->viewangles, 1.0 ); + gEngfuncs.V_ApplyShake( pparams->vieworg, pparams->viewangles, 1.0f ); // never let view origin sit exactly on a node line, because a water plane can // dissapear when viewed with the eye exactly on it. // FIXME, we send origin at 1/128 now, change this? // the server protocol only specifies to 1/16 pixel, so add 1/32 in each axis - pparams->vieworg[0] += 1.0 / 32; - pparams->vieworg[1] += 1.0 / 32; - pparams->vieworg[2] += 1.0 / 32; + pparams->vieworg[0] += 1.0f / 32.0f; + pparams->vieworg[1] += 1.0f / 32.0f; + pparams->vieworg[2] += 1.0f / 32.0f; // Check for problems around water, move the viewer artificially if necessary // -- this prevents drawing errors in GL due to waves @@ -481,13 +479,13 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams ) pwater = gEngfuncs.GetEntityByIndex( waterEntity ); if( pwater && ( pwater->model != NULL ) ) { - waterDist += ( pwater->curstate.scale * 16 ); // Add in wave height + waterDist += ( pwater->curstate.scale * 16.0f ); // Add in wave height } } } else { - waterEntity = 0; // Don't need this in software + // waterEntity = 0; // Don't need this in software } VectorCopy( pparams->vieworg, point ); @@ -553,7 +551,7 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams ) { vec3_t ofs; - ofs[0] = ofs[1] = ofs[2] = 0.0; + ofs[0] = ofs[1] = ofs[2] = 0.0f; CL_CameraOffset( (float *)&ofs ); @@ -586,18 +584,18 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams ) VectorAdd( view->origin, pparams->viewheight, view->origin ); // Let the viewmodel shake at about 10% of the amplitude - gEngfuncs.V_ApplyShake( view->origin, view->angles, 0.9 ); + gEngfuncs.V_ApplyShake( view->origin, view->angles, 0.9f ); for( i = 0; i < 3; i++ ) { - view->origin[i] += bob * 0.4 * pparams->forward[i]; + view->origin[i] += bob * 0.4f * pparams->forward[i]; } view->origin[2] += bob; // throw in a little tilt. - view->angles[YAW] -= bob * 0.5; - view->angles[ROLL] -= bob * 1; - view->angles[PITCH] -= bob * 0.3; + view->angles[YAW] -= bob * 0.5f; + view->angles[ROLL] -= bob * 1.0f; + view->angles[PITCH] -= bob * 0.3f; if( cl_viewbob && cl_viewbob->value ) VectorCopy( view->angles, view->curstate.angles ); @@ -605,25 +603,25 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams ) // pushing the view origin down off of the same X/Z plane as the ent's origin will give the // gun a very nice 'shifting' effect when the player looks up/down. If there is a problem // with view model distortion, this may be a cause. (SJB). - view->origin[2] -= 1; + view->origin[2] -= 1.0f; // fudge position around to keep amount of weapon visible // roughly equal with different FOV - if( pparams->viewsize == 110 ) + if( pparams->viewsize == 110.0f ) { - view->origin[2] += 1; + view->origin[2] += 1.0f; } - else if( pparams->viewsize == 100 ) + else if( pparams->viewsize == 100.0f ) { - view->origin[2] += 2; + view->origin[2] += 2.0f; } - else if( pparams->viewsize == 90 ) + else if( pparams->viewsize == 90.0f ) { - view->origin[2] += 1; + view->origin[2] += 1.0f; } - else if( pparams->viewsize == 80 ) + else if( pparams->viewsize == 80.0f ) { - view->origin[2] += 0.5; + view->origin[2] += 0.5f; } // Add in the punchangle, if any @@ -636,7 +634,7 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams ) // smooth out stair step ups #if 1 - if( !pparams->smoothing && pparams->onground && pparams->simorg[2] - oldz > 0 ) + if( !pparams->smoothing && pparams->onground && pparams->simorg[2] - oldz > 0.0f ) { float steptime; @@ -646,11 +644,11 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams ) //FIXME I_Error( "steptime < 0" ); steptime = 0; - oldz += steptime * 150; + oldz += steptime * 150.0f; if( oldz > pparams->simorg[2] ) oldz = pparams->simorg[2]; - if( pparams->simorg[2] - oldz > 18 ) - oldz = pparams->simorg[2]- 18; + if( pparams->simorg[2] - oldz > 18.0f ) + oldz = pparams->simorg[2]- 18.0f; pparams->vieworg[2] += oldz - pparams->simorg[2]; view->origin[2] += oldz - pparams->simorg[2]; } @@ -665,7 +663,7 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams ) VectorSubtract( pparams->simorg, lastorg, delta ); - if( Length( delta ) != 0.0 ) + if( Length( delta ) != 0.0f ) { VectorCopy( pparams->simorg, ViewInterp.Origins[ViewInterp.CurrentOrigin & ORIGIN_MASK] ); ViewInterp.OriginTime[ViewInterp.CurrentOrigin & ORIGIN_MASK] = pparams->time; @@ -682,9 +680,9 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams ) int foundidx; float t; - if( cl_vsmoothing->value < 0.0 ) + if( cl_vsmoothing->value < 0.0f ) { - gEngfuncs.Cvar_SetValue( "cl_vsmoothing", 0.0 ); + gEngfuncs.Cvar_SetValue( "cl_vsmoothing", 0.0f ); } t = pparams->time - cl_vsmoothing->value; @@ -696,7 +694,7 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams ) break; } - if( i < ORIGIN_MASK && ViewInterp.OriginTime[foundidx & ORIGIN_MASK] != 0.0 ) + if( i < ORIGIN_MASK && ViewInterp.OriginTime[foundidx & ORIGIN_MASK] != 0.0f ) { // Interpolate vec3_t delta; @@ -713,7 +711,7 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams ) VectorMA( ViewInterp.Origins[foundidx & ORIGIN_MASK], frac, delta, neworg ); // Dont interpolate large changes - if( Length( delta ) < 64 ) + if( Length( delta ) < 64.0f ) { VectorSubtract( neworg, pparams->simorg, delta ); @@ -727,21 +725,26 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams ) // Store off v_angles before munging for third person v_angles = pparams->viewangles; + v_client_aimangles = pparams->cl_viewangles; v_lastAngles = pparams->viewangles; //v_cl_angles = pparams->cl_viewangles; // keep old user mouse angles ! if( CL_IsThirdPerson() ) { VectorCopy( camAngles, pparams->viewangles ); - float pitch = camAngles[0]; + } + + // Apply this at all times + { + float pitch = pparams->viewangles[0]; // Normalize angles - if( pitch > 180 ) - pitch -= 360.0; - else if( pitch < -180 ) - pitch += 360; + if( pitch > 180.0f ) + pitch -= 360.0f; + else if( pitch < -180.0f ) + pitch += 360.0f; // Player pitch is inverted - pitch /= -3.0; + pitch /= -3.0f; // Slam local player's pitch value ent->angles[0] = pitch; @@ -796,7 +799,7 @@ void V_SmoothInterpolateAngles( float * startAngle, float * endAngle, float * fi { frac = degreesPerSec * v_frametime; - threshhold= degreesPerSec / 4; + threshhold= degreesPerSec / 4.0f; if( absd < threshhold ) { @@ -811,7 +814,7 @@ void V_SmoothInterpolateAngles( float * startAngle, float * endAngle, float * fi } else { - if( d > 0 ) + if( d > 0.0f ) finalAngle[i] = startAngle[i] + frac; else finalAngle[i] = startAngle[i] - frac; @@ -907,7 +910,7 @@ void V_GetChaseOrigin( float * angles, float * origin, float distance, float * r VectorCopy( ent1->origin, newOrigin ); if( ent1->player ) - newOrigin[2] += 17; // head level of living player + newOrigin[2] += 17.0f; // head level of living player // get new angle towards second target if( ent2 ) @@ -921,7 +924,7 @@ void V_GetChaseOrigin( float * angles, float * origin, float distance, float * r // if no second target is given, look down to dead player newAngle[0] = 90.0f; newAngle[1] = 0.0f; - newAngle[2] = 0; + newAngle[2] = 0.0f; } // and smooth view @@ -962,12 +965,12 @@ void V_GetSingleTargetCam( cl_entity_t * ent1, float * angle, float * origin ) if( ent1->player ) { if( deadPlayer ) - newOrigin[2] += 2; //laying on ground + newOrigin[2] += 2.0f; //laying on ground else - newOrigin[2] += 17; // head level of living player + newOrigin[2] += 17.0f; // head level of living player } else - newOrigin[2]+= 8; // object, tricky, must be above bomb in CS + newOrigin[2]+= 8.0f; // object, tricky, must be above bomb in CS // we have no second target, choose view direction based on // show front of primary target @@ -1005,13 +1008,13 @@ float MaxAngleBetweenAngles( float *a1, float *a2 ) for( int i = 0; i < 3; i++ ) { d = a2[i] - a1[i]; - if( d > 180 ) + if( d > 180.0f ) { - d -= 360; + d -= 360.0f; } - else if( d < -180 ) + else if( d < -180.0f ) { - d += 360; + d += 360.0f; } d = fabs( d ); @@ -1046,9 +1049,9 @@ void V_GetDoubleTargetsCam( cl_entity_t *ent1, cl_entity_t *ent2, float *angle, VectorCopy( ent1->origin, newOrigin ); if( ent1->player ) - newOrigin[2] += 17; // head level of living player + newOrigin[2] += 17.0f; // head level of living player else - newOrigin[2] += 8; // object, tricky, must be above bomb in CS + newOrigin[2] += 8.0f; // object, tricky, must be above bomb in CS // get new angle towards second target VectorSubtract( ent2->origin, ent1->origin, newAngle ); @@ -1151,9 +1154,9 @@ void V_GetDirectedChasePosition(cl_entity_t *ent1, cl_entity_t *ent2,float *angl VectorCopy( ent1->origin, newOrigin ); if( ent1->player ) - newOrigin[2] += 17; // head level of living player + newOrigin[2] += 17.0f; // head level of living player else - newOrigin[2] += 8; // object, tricky, must be above bomb in CS + newOrigin[2] += 8.0f; // object, tricky, must be above bomb in CS V_GetChaseOrigin( angle, newOrigin, distance, origin ); } @@ -1192,14 +1195,14 @@ void V_GetChasePos( int target, float *cl_angles, float *origin, float *angles ) if( cl_angles == NULL ) // no mouse angles given, use entity angles ( locked mode ) { VectorCopy( ent->angles, angles); - angles[0] *= -1; + angles[0] *= -1.0f; } else VectorCopy( cl_angles, angles ); VectorCopy( ent->origin, origin ); - origin[2] += 28; // DEFAULT_VIEWHEIGHT - some offset + origin[2] += 28.0f; // DEFAULT_VIEWHEIGHT - some offset V_GetChaseOrigin( angles, origin, cl_chasedist->value, origin ); } @@ -1234,15 +1237,15 @@ void V_GetInEyePos( int target, float *origin, float *angles ) if( ent->curstate.solid == SOLID_NOT ) { - angles[ROLL] = 80; // dead view angle - origin[2] += -8 ; // PM_DEAD_VIEWHEIGHT + angles[ROLL] = 80.0f; // dead view angle + origin[2] += -8.0f; // PM_DEAD_VIEWHEIGHT } else if( ent->curstate.usehull == 1 ) - origin[2] += 12; // VEC_DUCK_VIEW; + origin[2] += 12.0f; // VEC_DUCK_VIEW; else // exacty eye position can't be caluculated since it depends on // client values like cl_bobcycle, this offset matches the default values - origin[2] += 28; // DEFAULT_VIEWHEIGHT + origin[2] += 28.0f; // DEFAULT_VIEWHEIGHT } void V_GetMapFreePosition( float *cl_angles, float *origin, float *angles ) @@ -1306,7 +1309,7 @@ void V_GetMapChasePosition( int target, float *cl_angles, float *origin, float * VectorNormalize( forward ); - VectorMA( origin, -1536, forward, origin ); + VectorMA( origin, -1536.0f, forward, origin ); } int V_FindViewModelByWeaponModel( int weaponindex ) @@ -1536,8 +1539,8 @@ void DLLEXPORT V_CalcRefdef( struct ref_params_s *pparams ) } /* // Example of how to overlay the whole screen with red at 50 % alpha -#define SF_TEST -#if defined SF_TEST +#define SF_TEST 1 +#if SF_TEST { screenfade_t sf; gEngfuncs.pfnGetScreenFade( &sf ); @@ -1565,8 +1568,8 @@ void V_DropPunchAngle( float frametime, float *ev_punchangle ) float len; len = VectorNormalize( ev_punchangle ); - len -= ( 10.0 + len * 0.5 ) * frametime; - len = Q_max( len, 0.0 ); + len -= ( 10.0f + len * 0.5f ) * (float)frametime; + len = Q_max( len, 0.0f ); VectorScale( ev_punchangle, len, ev_punchangle ); } @@ -1603,8 +1606,8 @@ void V_Init( void ) cl_chasedist = gEngfuncs.pfnRegisterVariable( "cl_chasedist","112", 0 ); } -//#define TRACE_TEST -#if defined( TRACE_TEST ) +//#define TRACE_TEST 1 +#if TRACE_TEST extern float in_fov; /* @@ -1617,14 +1620,14 @@ float CalcFov( float fov_x, float width, float height ) float a; float x; - if( fov_x < 1 || fov_x > 179 ) - fov_x = 90; // error, set to 90 + if( fov_x < 1.0f || fov_x > 179.0f ) + fov_x = 90.0f; // error, set to 90 - x = width / tan( fov_x / 360 * M_PI ); + x = width / tan( fov_x / 360.0f * M_PI_F ); a = atan ( height / x ); - a = a * 360 / M_PI; + a = a * 360.0f / M_PI_F; return a; } @@ -1646,8 +1649,8 @@ void V_Move( int mx, int my ) fov = CalcFov( in_fov, (float)ScreenWidth, (float)ScreenHeight ); - c_x = (float)ScreenWidth / 2.0; - c_y = (float)ScreenHeight / 2.0; + c_x = (float)ScreenWidth / 2.0f; + c_y = (float)ScreenHeight / 2.0f; dx = (float)mx - c_x; dy = (float)my - c_y; @@ -1656,8 +1659,8 @@ void V_Move( int mx, int my ) fx = dx / c_x; fy = dy / c_y; - dX = fx * in_fov / 2.0 ; - dY = fy * fov / 2.0; + dX = fx * in_fov / 2.0f; + dY = fy * fov / 2.0f; newangles = v_angles; @@ -1672,10 +1675,10 @@ void V_Move( int mx, int my ) // Trace tr = *( gEngfuncs.PM_TraceLine( (float *)&v_origin, (float *)&farpoint, PM_TRACELINE_PHYSENTSONLY, 2 /*point sized hull*/, -1 ) ); - if( tr.fraction != 1.0 && tr.ent != 0 ) + if( tr.fraction != 1.0f && tr.ent != 0 ) { hitent = PM_GetPhysEntInfo( tr.ent ); - PM_ParticleLine( (float *)&v_origin, (float *)&tr.endpos, 5, 1.0, 0.0 ); + PM_ParticleLine( (float *)&v_origin, (float *)&tr.endpos, 5, 1.0f, 0.0f ); } else { diff --git a/cl_dll/view.h b/cl_dll/view.h index 6ca818d5..80a2f065 100644 --- a/cl_dll/view.h +++ b/cl_dll/view.h @@ -9,6 +9,14 @@ #define VIEWH #pragma once +#if !defined(M_PI) +#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h +#endif + +#if !defined(M_PI_F) +#define M_PI_F (float)M_PI +#endif + void V_StartPitchDrift( void ); void V_StopPitchDrift( void ); #endif // !VIEWH diff --git a/cl_dll/voice_status.cpp b/cl_dll/voice_status.cpp new file mode 100644 index 00000000..1f1c33ac --- /dev/null +++ b/cl_dll/voice_status.cpp @@ -0,0 +1,873 @@ +//========= Copyright � 1996-2001, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#include "hud.h" + +#include "cl_util.h" +#include +#include +#include +#include "parsemsg.h" +#include "demo.h" +#include "demo_api.h" +#include "voice_status.h" +#include "r_efx.h" +#include "entity_types.h" +#include "VGUI_ActionSignal.h" +#include "VGUI_Scheme.h" +#include "VGUI_TextImage.h" +#include "vgui_loadtga.h" +#include "vgui_helpers.h" +#include "VGUI_MouseCode.h" + + + +using namespace vgui; + + +extern int cam_thirdperson; + + +#define VOICE_MODEL_INTERVAL 0.3 +#define SCOREBOARD_BLINK_FREQUENCY 0.3 // How often to blink the scoreboard icons. +#define SQUELCHOSCILLATE_PER_SECOND 2.0f + + +extern BitmapTGA *LoadTGA( const char* pImageName ); + + + +// ---------------------------------------------------------------------- // +// The voice manager for the client. +// ---------------------------------------------------------------------- // +CVoiceStatus g_VoiceStatus; + +CVoiceStatus* GetClientVoiceMgr() +{ + return &g_VoiceStatus; +} + + + +// ---------------------------------------------------------------------- // +// CVoiceStatus. +// ---------------------------------------------------------------------- // + +static CVoiceStatus *g_pInternalVoiceStatus = NULL; + +int __MsgFunc_VoiceMask(const char *pszName, int iSize, void *pbuf) +{ + if(g_pInternalVoiceStatus) + g_pInternalVoiceStatus->HandleVoiceMaskMsg(iSize, pbuf); + + return 1; +} + +int __MsgFunc_ReqState(const char *pszName, int iSize, void *pbuf) +{ + if(g_pInternalVoiceStatus) + g_pInternalVoiceStatus->HandleReqStateMsg(iSize, pbuf); + + return 1; +} + + +int g_BannedPlayerPrintCount; +void ForEachBannedPlayer(char id[16]) +{ + char str[256]; + sprintf(str, "BAN %d: %2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X\n", + g_BannedPlayerPrintCount++, + id[0], id[1], id[2], id[3], + id[4], id[5], id[6], id[7], + id[8], id[9], id[10], id[11], + id[12], id[13], id[14], id[15] + ); + + gEngfuncs.pfnConsolePrint(str); +} + + +void ShowBannedCallback() +{ + if(g_pInternalVoiceStatus) + { + g_BannedPlayerPrintCount = 0; + gEngfuncs.pfnConsolePrint("------- BANNED PLAYERS -------\n"); + g_pInternalVoiceStatus->m_BanMgr.ForEachBannedPlayer(ForEachBannedPlayer); + gEngfuncs.pfnConsolePrint("------------------------------\n"); + } +} + + +// ---------------------------------------------------------------------- // +// CVoiceStatus. +// ---------------------------------------------------------------------- // + +CVoiceStatus::CVoiceStatus() +{ + m_bBanMgrInitialized = false; + m_LastUpdateServerState = 0; + + m_pSpeakerLabelIcon = NULL; + m_pScoreboardNeverSpoken = NULL; + m_pScoreboardNotSpeaking = NULL; + m_pScoreboardSpeaking = NULL; + m_pScoreboardSpeaking2 = NULL; + m_pScoreboardSquelch = NULL; + m_pScoreboardBanned = NULL; + + m_pLocalBitmap = NULL; + m_pAckBitmap = NULL; + + m_bTalking = m_bServerAcked = false; + + memset(m_pBanButtons, 0, sizeof(m_pBanButtons)); + + m_pParentPanel = NULL; + + m_bServerModEnable = -1; + + m_pchGameDir = NULL; +} + + +CVoiceStatus::~CVoiceStatus() +{ + g_pInternalVoiceStatus = NULL; + + for(int i=0; i < MAX_VOICE_SPEAKERS; i++) + { + delete m_Labels[i].m_pLabel; + m_Labels[i].m_pLabel = NULL; + + delete m_Labels[i].m_pIcon; + m_Labels[i].m_pIcon = NULL; + + delete m_Labels[i].m_pBackground; + m_Labels[i].m_pBackground = NULL; + } + + delete m_pLocalLabel; + m_pLocalLabel = NULL; + + FreeBitmaps(); + + if(m_pchGameDir) + { + if(m_bBanMgrInitialized) + { + m_BanMgr.SaveState(m_pchGameDir); + } + + free(m_pchGameDir); + } +} + + +int CVoiceStatus::Init( + IVoiceStatusHelper *pHelper, + Panel **pParentPanel) +{ + // Setup the voice_modenable cvar. + gEngfuncs.pfnRegisterVariable("voice_modenable", "1", FCVAR_ARCHIVE); + + gEngfuncs.pfnRegisterVariable("voice_clientdebug", "0", 0); + + gEngfuncs.pfnAddCommand("voice_showbanned", ShowBannedCallback); + + if(gEngfuncs.pfnGetGameDirectory()) + { + m_BanMgr.Init(gEngfuncs.pfnGetGameDirectory()); + m_bBanMgrInitialized = true; + } + + assert(!g_pInternalVoiceStatus); + g_pInternalVoiceStatus = this; + + m_BlinkTimer = 0; + m_VoiceHeadModel = 0; + memset(m_Labels, 0, sizeof(m_Labels)); + + for(int i=0; i < MAX_VOICE_SPEAKERS; i++) + { + CVoiceLabel *pLabel = &m_Labels[i]; + + pLabel->m_pBackground = new Label(""); + + if((pLabel->m_pLabel = new Label("")) != 0) + { + pLabel->m_pLabel->setVisible( true ); + pLabel->m_pLabel->setFont( Scheme::sf_primary2 ); + pLabel->m_pLabel->setTextAlignment( Label::a_east ); + pLabel->m_pLabel->setContentAlignment( Label::a_east ); + pLabel->m_pLabel->setParent( pLabel->m_pBackground ); + } + + if( (pLabel->m_pIcon = new ImagePanel( NULL )) != 0 ) + { + pLabel->m_pIcon->setVisible( true ); + pLabel->m_pIcon->setParent( pLabel->m_pBackground ); + } + + pLabel->m_clientindex = -1; + } + + m_pLocalLabel = new ImagePanel(NULL); + + m_bInSquelchMode = false; + + m_pHelper = pHelper; + m_pParentPanel = pParentPanel; + gHUD.AddHudElem(this); + m_iFlags = HUD_ACTIVE; + HOOK_MESSAGE(VoiceMask); + HOOK_MESSAGE(ReqState); + + // Cache the game directory for use when we shut down + const char *pchGameDirT = gEngfuncs.pfnGetGameDirectory(); + m_pchGameDir = (char *)malloc(strlen(pchGameDirT) + 1); + strcpy(m_pchGameDir, pchGameDirT); + + return 1; +} + + +int CVoiceStatus::VidInit() +{ + FreeBitmaps(); + + + if( (m_pLocalBitmap = vgui_LoadTGA("gfx/vgui/icntlk_pl.tga")) != 0 ) + { + m_pLocalBitmap->setColor(Color(255,255,255,135)); + } + + if( (m_pAckBitmap = vgui_LoadTGA("gfx/vgui/icntlk_sv.tga")) != 0 ) + { + m_pAckBitmap->setColor(Color(255,255,255,135)); // Give just a tiny bit of translucency so software draws correctly. + } + + m_pLocalLabel->setImage( m_pLocalBitmap ); + m_pLocalLabel->setVisible( false ); + + + if( (m_pSpeakerLabelIcon = vgui_LoadTGANoInvertAlpha("gfx/vgui/speaker4.tga" )) != 0 ) + m_pSpeakerLabelIcon->setColor( Color(255,255,255,1) ); // Give just a tiny bit of translucency so software draws correctly. + + if ((m_pScoreboardNeverSpoken = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_speaker1.tga")) != 0) + m_pScoreboardNeverSpoken->setColor(Color(255,255,255,1)); // Give just a tiny bit of translucency so software draws correctly. + + if((m_pScoreboardNotSpeaking = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_speaker2.tga")) != 0) + m_pScoreboardNotSpeaking->setColor(Color(255,255,255,1)); // Give just a tiny bit of translucency so software draws correctly. + + if((m_pScoreboardSpeaking = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_speaker3.tga")) != 0) + m_pScoreboardSpeaking->setColor(Color(255,255,255,1)); // Give just a tiny bit of translucency so software draws correctly. + + if((m_pScoreboardSpeaking2 = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_speaker4.tga")) != 0) + m_pScoreboardSpeaking2->setColor(Color(255,255,255,1)); // Give just a tiny bit of translucency so software draws correctly. + + if((m_pScoreboardSquelch = vgui_LoadTGA("gfx/vgui/icntlk_squelch.tga")) != 0) + m_pScoreboardSquelch->setColor(Color(255,255,255,1)); // Give just a tiny bit of translucency so software draws correctly. + + if((m_pScoreboardBanned = vgui_LoadTGA("gfx/vgui/640_voiceblocked.tga")) != 0) + m_pScoreboardBanned->setColor(Color(255,255,255,1)); // Give just a tiny bit of translucency so software draws correctly. + + // Figure out the voice head model height. + m_VoiceHeadModelHeight = 45; + char *pFile = (char *)gEngfuncs.COM_LoadFile("scripts/voicemodel.txt", 5, NULL); + if(pFile) + { + char token[4096]; + gEngfuncs.COM_ParseFile(pFile, token); + if(token[0] >= '0' && token[0] <= '9') + { + m_VoiceHeadModelHeight = (float)atof(token); + } + + gEngfuncs.COM_FreeFile(pFile); + } + + m_VoiceHeadModel = gEngfuncs.pfnSPR_Load("sprites/voiceicon.spr"); + return TRUE; +} + + +void CVoiceStatus::Frame(double frametime) +{ + // check server banned players once per second + if(gEngfuncs.GetClientTime() - m_LastUpdateServerState > 1) + { + UpdateServerState(false); + } + + m_BlinkTimer += frametime; + + // Update speaker labels. + if( m_pHelper->CanShowSpeakerLabels() ) + { + for( int i=0; i < MAX_VOICE_SPEAKERS; i++ ) + m_Labels[i].m_pBackground->setVisible( m_Labels[i].m_clientindex != -1 ); + } + else + { + for( int i=0; i < MAX_VOICE_SPEAKERS; i++ ) + m_Labels[i].m_pBackground->setVisible( false ); + } + + for(int i=0; i < VOICE_MAX_PLAYERS; i++) + UpdateBanButton(i); +} + + +void CVoiceStatus::CreateEntities() +{ + if(!m_VoiceHeadModel) + return; + + cl_entity_t *localPlayer = gEngfuncs.GetLocalPlayer(); + + int iOutModel = 0; + for(int i=0; i < VOICE_MAX_PLAYERS; i++) + { + if(!m_VoicePlayers[i]) + continue; + + cl_entity_s *pClient = gEngfuncs.GetEntityByIndex(i+1); + + // Don't show an icon if the player is not in our PVS. + if(!pClient || pClient->curstate.messagenum < localPlayer->curstate.messagenum) + continue; + + // Don't show an icon for dead or spectating players (ie: invisible entities). + if(pClient->curstate.effects & EF_NODRAW) + continue; + + // Don't show an icon for the local player unless we're in thirdperson mode. + if(pClient == localPlayer && !cam_thirdperson) + continue; + + cl_entity_s *pEnt = &m_VoiceHeadModels[iOutModel]; + ++iOutModel; + + memset(pEnt, 0, sizeof(*pEnt)); + + pEnt->curstate.rendermode = kRenderTransAdd; + pEnt->curstate.renderamt = 255; + pEnt->baseline.renderamt = 255; + pEnt->curstate.renderfx = kRenderFxNoDissipation; + pEnt->curstate.framerate = 1; + pEnt->curstate.frame = 0; + pEnt->model = (struct model_s*)gEngfuncs.GetSpritePointer(m_VoiceHeadModel); + pEnt->angles[0] = pEnt->angles[1] = pEnt->angles[2] = 0; + pEnt->curstate.scale = 0.5f; + + pEnt->origin[0] = pEnt->origin[1] = 0; + pEnt->origin[2] = 45; + + VectorAdd(pEnt->origin, pClient->origin, pEnt->origin); + + // Tell the engine. + gEngfuncs.CL_CreateVisibleEntity(ET_NORMAL, pEnt); + } +} + + +void CVoiceStatus::UpdateSpeakerStatus( int entindex, qboolean bTalking ) +{ + cvar_t *pVoiceLoopback = NULL; + + if ( !m_pParentPanel || !*m_pParentPanel ) + { + return; + } + + if ( gEngfuncs.pfnGetCvarFloat( "voice_clientdebug" ) ) + { + char msg[256]; + sprintf( msg, "CVoiceStatus::UpdateSpeakerStatus: ent %d talking = %d\n", entindex, bTalking ); + gEngfuncs.pfnConsolePrint( msg ); + } + + int iLocalPlayerIndex = gEngfuncs.GetLocalPlayer()->index; + + // Is it the local player talking? + if ( entindex == -1 ) + { + m_bTalking = !!bTalking; + if( bTalking ) + { + // Enable voice for them automatically if they try to talk. + gEngfuncs.pfnClientCmd( "voice_modenable 1" ); + } + + // now set the player index to the correct index for the local player + // this will allow us to have the local player's icon flash in the scoreboard + entindex = iLocalPlayerIndex; + + pVoiceLoopback = gEngfuncs.pfnGetCvarPointer( "voice_loopback" ); + } + else if ( entindex == -2 ) + { + m_bServerAcked = !!bTalking; + } + + if ( entindex >= 0 && entindex <= VOICE_MAX_PLAYERS ) + { + int iClient = entindex - 1; + if ( iClient < 0 ) + { + return; + } + + CVoiceLabel *pLabel = FindVoiceLabel( iClient ); + if ( bTalking ) + { + m_VoicePlayers[iClient] = true; + m_VoiceEnabledPlayers[iClient] = true; + + // If we don't have a label for this guy yet, then create one. + if ( !pLabel ) + { + // if this isn't the local player (unless they have voice_loopback on) + if ( ( entindex != iLocalPlayerIndex ) || ( pVoiceLoopback && pVoiceLoopback->value ) ) + { + if ( (pLabel = GetFreeVoiceLabel()) != 0 ) + { + // Get the name from the engine. + hud_player_info_t info; + memset( &info, 0, sizeof( info ) ); + gEngfuncs.pfnGetPlayerInfo( entindex, &info ); + + char paddedName[512]; + _snprintf( paddedName, sizeof( paddedName ) - 1, "%s ", info.name ); + paddedName[sizeof(paddedName) - 1] = '\0'; + + int color[3]; + m_pHelper->GetPlayerTextColor( entindex, color ); + + if ( pLabel->m_pBackground ) + { + pLabel->m_pBackground->setBgColor( color[0], color[1], color[2], 135 ); + pLabel->m_pBackground->setParent( *m_pParentPanel ); + pLabel->m_pBackground->setVisible( m_pHelper->CanShowSpeakerLabels() ); + } + + if ( pLabel->m_pLabel ) + { + pLabel->m_pLabel->setFgColor( 255, 255, 255, 0 ); + pLabel->m_pLabel->setBgColor( 0, 0, 0, 255 ); + pLabel->m_pLabel->setText( "%s", paddedName ); + } + + pLabel->m_clientindex = iClient; + } + } + } + } + else + { + m_VoicePlayers[iClient] = false; + + // If we have a label for this guy, kill it. + if ( pLabel ) + { + pLabel->m_pBackground->setVisible( false ); + pLabel->m_clientindex = -1; + } + } + } + + RepositionLabels(); +} + + +void CVoiceStatus::UpdateServerState(bool bForce) +{ + // Can't do anything when we're not in a level. + char const *pLevelName = gEngfuncs.pfnGetLevelName(); + if( pLevelName[0] == 0 ) + { + if( gEngfuncs.pfnGetCvarFloat("voice_clientdebug") ) + { + gEngfuncs.pfnConsolePrint( "CVoiceStatus::UpdateServerState: pLevelName[0]==0\n" ); + } + + return; + } + + int bCVarModEnable = !!gEngfuncs.pfnGetCvarFloat("voice_modenable"); + if(bForce || m_bServerModEnable != bCVarModEnable) + { + m_bServerModEnable = bCVarModEnable; + + char str[256]; + sprintf(str, "VModEnable %d", m_bServerModEnable); + ServerCmd(str); + + if(gEngfuncs.pfnGetCvarFloat("voice_clientdebug")) + { + char msg[256]; + sprintf(msg, "CVoiceStatus::UpdateServerState: Sending '%s'\n", str); + gEngfuncs.pfnConsolePrint(msg); + } + } + + char str[2048] = "vban"; + bool bChange = false; + + for(unsigned long dw=0; dw < VOICE_MAX_PLAYERS_DW; dw++) + { + unsigned int serverBanMask = 0; + unsigned int banMask = 0; + for(unsigned int i=0; i < 32; i++) + { + char playerID[16]; + if(!gEngfuncs.GetPlayerUniqueID(i+1, playerID)) + continue; + + if(m_BanMgr.GetPlayerBan(playerID)) + banMask |= 1 << i; + + if(m_ServerBannedPlayers[dw*32 + i]) + serverBanMask |= 1 << i; + } + + if(serverBanMask != banMask) + bChange = true; + + // Ok, the server needs to be updated. + char numStr[512]; + sprintf(numStr, " %x", banMask); + strcat(str, numStr); + } + + if(bChange || bForce) + { + if(gEngfuncs.pfnGetCvarFloat("voice_clientdebug")) + { + char msg[256]; + sprintf(msg, "CVoiceStatus::UpdateServerState: Sending '%s'\n", str); + gEngfuncs.pfnConsolePrint(msg); + } + + gEngfuncs.pfnServerCmdUnreliable(str); // Tell the server.. + } + else + { + if (gEngfuncs.pfnGetCvarFloat("voice_clientdebug")) + { + gEngfuncs.pfnConsolePrint( "CVoiceStatus::UpdateServerState: no change\n" ); + } + } + + m_LastUpdateServerState = gEngfuncs.GetClientTime(); +} + +void CVoiceStatus::UpdateSpeakerImage(Label *pLabel, int iPlayer) +{ + m_pBanButtons[iPlayer-1] = pLabel; + UpdateBanButton(iPlayer-1); +} + +void CVoiceStatus::UpdateBanButton(int iClient) +{ + Label *pPanel = m_pBanButtons[iClient]; + + if (!pPanel) + return; + + char playerID[16]; + extern bool HACK_GetPlayerUniqueID( int iPlayer, char playerID[16] ); + if(!HACK_GetPlayerUniqueID(iClient+1, playerID)) + return; + + // Figure out if it's blinking or not. + bool bBlink = fmod(m_BlinkTimer, SCOREBOARD_BLINK_FREQUENCY*2) < SCOREBOARD_BLINK_FREQUENCY; + bool bTalking = !!m_VoicePlayers[iClient]; + bool bBanned = m_BanMgr.GetPlayerBan(playerID); + bool bNeverSpoken = !m_VoiceEnabledPlayers[iClient]; + + // Get the appropriate image to display on the panel. + if (bBanned) + { + pPanel->setImage(m_pScoreboardBanned); + } + else if (bTalking) + { + if (bBlink) + { + pPanel->setImage(m_pScoreboardSpeaking2); + } + else + { + pPanel->setImage(m_pScoreboardSpeaking); + } + pPanel->setFgColor(255, 170, 0, 1); + } + else if (bNeverSpoken) + { + pPanel->setImage(m_pScoreboardNeverSpoken); + pPanel->setFgColor(100, 100, 100, 1); + } + else + { + pPanel->setImage(m_pScoreboardNotSpeaking); + } +} + + +void CVoiceStatus::HandleVoiceMaskMsg(int iSize, void *pbuf) +{ + BEGIN_READ( pbuf, iSize ); + + unsigned int dw; + for(dw=0; dw < VOICE_MAX_PLAYERS_DW; dw++) + { + m_AudiblePlayers.SetDWord(dw, (unsigned long)READ_LONG()); + m_ServerBannedPlayers.SetDWord(dw, (unsigned long)READ_LONG()); + + if(gEngfuncs.pfnGetCvarFloat("voice_clientdebug")) + { + char str[256]; + gEngfuncs.pfnConsolePrint("CVoiceStatus::HandleVoiceMaskMsg\n"); + + sprintf(str, " - m_AudiblePlayers[%d] = %lu\n", dw, m_AudiblePlayers.GetDWord(dw)); + gEngfuncs.pfnConsolePrint(str); + + sprintf(str, " - m_ServerBannedPlayers[%d] = %lu\n", dw, m_ServerBannedPlayers.GetDWord(dw)); + gEngfuncs.pfnConsolePrint(str); + } + } + + m_bServerModEnable = READ_BYTE(); +} + +void CVoiceStatus::HandleReqStateMsg(int iSize, void *pbuf) +{ + if(gEngfuncs.pfnGetCvarFloat("voice_clientdebug")) + { + gEngfuncs.pfnConsolePrint("CVoiceStatus::HandleReqStateMsg\n"); + } + + UpdateServerState(true); +} + +void CVoiceStatus::StartSquelchMode() +{ + if(m_bInSquelchMode) + return; + + m_bInSquelchMode = true; + m_pHelper->UpdateCursorState(); +} + +void CVoiceStatus::StopSquelchMode() +{ + m_bInSquelchMode = false; + m_pHelper->UpdateCursorState(); +} + +bool CVoiceStatus::IsInSquelchMode() +{ + return m_bInSquelchMode; +} + +CVoiceLabel* CVoiceStatus::FindVoiceLabel(int clientindex) +{ + for(int i=0; i < MAX_VOICE_SPEAKERS; i++) + { + if(m_Labels[i].m_clientindex == clientindex) + return &m_Labels[i]; + } + + return NULL; +} + + +CVoiceLabel* CVoiceStatus::GetFreeVoiceLabel() +{ + return FindVoiceLabel(-1); +} + + +void CVoiceStatus::RepositionLabels() +{ + // find starting position to draw from, along right-hand side of screen + int y = ScreenHeight / 2; + + int iconWide = 8, iconTall = 8; + if( m_pSpeakerLabelIcon ) + { + m_pSpeakerLabelIcon->getSize( iconWide, iconTall ); + } + + // Reposition active labels. + for(int i = 0; i < MAX_VOICE_SPEAKERS; i++) + { + CVoiceLabel *pLabel = &m_Labels[i]; + + if( pLabel->m_clientindex == -1 || !pLabel->m_pLabel ) + { + if( pLabel->m_pBackground ) + pLabel->m_pBackground->setVisible( false ); + + continue; + } + + int textWide, textTall; + pLabel->m_pLabel->getContentSize( textWide, textTall ); + + // Don't let it stretch too far across their screen. + if( textWide > (ScreenWidth*2)/3 ) + textWide = (ScreenWidth*2)/3; + + // Setup the background label to fit everything in. + int border = 2; + int bgWide = textWide + iconWide + border*3; + int bgTall = Q_max( textTall, iconTall ) + border*2; + pLabel->m_pBackground->setBounds( ScreenWidth - bgWide - 8, y, bgWide, bgTall ); + + // Put the text at the left. + pLabel->m_pLabel->setBounds( border, (bgTall - textTall) / 2, textWide, textTall ); + + // Put the icon at the right. + int iconLeft = border + textWide + border; + int iconTop = (bgTall - iconTall) / 2; + if( pLabel->m_pIcon ) + { + pLabel->m_pIcon->setImage( m_pSpeakerLabelIcon ); + pLabel->m_pIcon->setBounds( iconLeft, iconTop, iconWide, iconTall ); + } + + y += bgTall + 2; + } + + if( m_pLocalBitmap && m_pAckBitmap && m_pLocalLabel && (m_bTalking || m_bServerAcked) ) + { + m_pLocalLabel->setParent(*m_pParentPanel); + m_pLocalLabel->setVisible( true ); + + if( m_bServerAcked && !!gEngfuncs.pfnGetCvarFloat("voice_clientdebug") ) + m_pLocalLabel->setImage( m_pAckBitmap ); + else + m_pLocalLabel->setImage( m_pLocalBitmap ); + + int sizeX, sizeY; + m_pLocalBitmap->getSize(sizeX, sizeY); + + int local_xPos = ScreenWidth - sizeX - 10; + int local_yPos = m_pHelper->GetAckIconHeight() - sizeY; + + m_pLocalLabel->setPos( local_xPos, local_yPos ); + } + else + { + m_pLocalLabel->setVisible( false ); + } +} + + +void CVoiceStatus::FreeBitmaps() +{ + // Delete all the images we have loaded. + delete m_pLocalBitmap; + m_pLocalBitmap = NULL; + + delete m_pAckBitmap; + m_pAckBitmap = NULL; + + delete m_pSpeakerLabelIcon; + m_pSpeakerLabelIcon = NULL; + + delete m_pScoreboardNeverSpoken; + m_pScoreboardNeverSpoken = NULL; + + delete m_pScoreboardNotSpeaking; + m_pScoreboardNotSpeaking = NULL; + + delete m_pScoreboardSpeaking; + m_pScoreboardSpeaking = NULL; + + delete m_pScoreboardSpeaking2; + m_pScoreboardSpeaking2 = NULL; + + delete m_pScoreboardSquelch; + m_pScoreboardSquelch = NULL; + + delete m_pScoreboardBanned; + m_pScoreboardBanned = NULL; + + // Clear references to the images in panels. + for(int i=0; i < VOICE_MAX_PLAYERS; i++) + { + if (m_pBanButtons[i]) + { + m_pBanButtons[i]->setImage(NULL); + } + } + + if(m_pLocalLabel) + m_pLocalLabel->setImage(NULL); +} + +//----------------------------------------------------------------------------- +// Purpose: returns true if the target client has been banned +// Input : playerID - +// Output : Returns true on success, false on failure. +//----------------------------------------------------------------------------- +bool CVoiceStatus::IsPlayerBlocked(int iPlayer) +{ + char playerID[16]; + if (!gEngfuncs.GetPlayerUniqueID(iPlayer, playerID)) + return false; + + return m_BanMgr.GetPlayerBan(playerID); +} + +//----------------------------------------------------------------------------- +// Purpose: returns true if the player can't hear the other client due to game rules (eg. the other team) +// Input : playerID - +// Output : Returns true on success, false on failure. +//----------------------------------------------------------------------------- +bool CVoiceStatus::IsPlayerAudible(int iPlayer) +{ + return !!m_AudiblePlayers[iPlayer-1]; +} + +//----------------------------------------------------------------------------- +// Purpose: blocks/unblocks the target client from being heard +// Input : playerID - +// Output : Returns true on success, false on failure. +//----------------------------------------------------------------------------- +void CVoiceStatus::SetPlayerBlockedState(int iPlayer, bool blocked) +{ + if (gEngfuncs.pfnGetCvarFloat("voice_clientdebug")) + { + gEngfuncs.pfnConsolePrint( "CVoiceStatus::SetPlayerBlockedState part 1\n" ); + } + + char playerID[16]; + if (!gEngfuncs.GetPlayerUniqueID(iPlayer, playerID)) + return; + + if (gEngfuncs.pfnGetCvarFloat("voice_clientdebug")) + { + gEngfuncs.pfnConsolePrint( "CVoiceStatus::SetPlayerBlockedState part 2\n" ); + } + + // Squelch or (try to) unsquelch this player. + if (gEngfuncs.pfnGetCvarFloat("voice_clientdebug")) + { + char str[256]; + sprintf(str, "CVoiceStatus::SetPlayerBlockedState: setting player %d ban to %d\n", iPlayer, !m_BanMgr.GetPlayerBan(playerID)); + gEngfuncs.pfnConsolePrint(str); + } + + m_BanMgr.SetPlayerBan( playerID, blocked ); + UpdateServerState(false); +} diff --git a/cl_dll/voice_status.h b/cl_dll/voice_status.h new file mode 100644 index 00000000..48f00db2 --- /dev/null +++ b/cl_dll/voice_status.h @@ -0,0 +1,228 @@ +//========= Copyright (c) 1996-2001, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VOICE_STATUS_H +#define VOICE_STATUS_H +#pragma once + + +#include "VGUI_Label.h" +#include "VGUI_LineBorder.h" +#include "VGUI_ImagePanel.h" +#include "VGUI_BitmapTGA.h" +#include "VGUI_InputSignal.h" +#include "VGUI_Button.h" +#include "voice_common.h" +#include "cl_entity.h" +#include "voice_banmgr.h" +#include "vgui_checkbutton2.h" +#include "vgui_defaultinputsignal.h" + + +class CVoiceStatus; + + +class CVoiceLabel +{ +public: + vgui::Label *m_pLabel; + vgui::Label *m_pBackground; + vgui::ImagePanel *m_pIcon; // Voice icon next to player name. + int m_clientindex; // Client index of the speaker. -1 if this label isn't being used. +}; + + +// This is provided by each mod to access data that may not be the same across mods. +class IVoiceStatusHelper +{ +public: + virtual ~IVoiceStatusHelper() {} + + // Get RGB color for voice status text about this player. + virtual void GetPlayerTextColor(int entindex, int color[3]) = 0; + + // Force it to update the cursor state. + virtual void UpdateCursorState() = 0; + + // Return the height above the bottom that the voice ack icons should be drawn at. + virtual int GetAckIconHeight() = 0; + + // Return true if the voice manager is allowed to show speaker labels + // (mods usually return false when the scoreboard is up). + virtual bool CanShowSpeakerLabels() = 0; +}; + +//----------------------------------------------------------------------------- +// Purpose: Holds a color for the shared image +//----------------------------------------------------------------------------- +class VoiceImagePanel : public vgui::ImagePanel +{ + virtual void paintBackground() + { + if (_image!=null) + { + vgui::Color col; + getFgColor(col); + _image->setColor(col); + _image->doPaint(this); + } + } +}; + + +class CVoiceStatus : public CHudBase, public vgui::CDefaultInputSignal +{ +public: + CVoiceStatus(); + virtual ~CVoiceStatus(); + +// CHudBase overrides. +public: + + // Initialize the cl_dll's voice manager. + virtual int Init( + IVoiceStatusHelper *m_pHelper, + vgui::Panel **pParentPanel); + + // ackPosition is the bottom position of where CVoiceStatus will draw the voice acknowledgement labels. + virtual int VidInit(); + + +public: + + // Call from HUD_Frame each frame. + void Frame(double frametime); + + // Called when a player starts or stops talking. + // entindex is -1 to represent the local client talking (before the data comes back from the server). + // When the server acknowledges that the local client is talking, then entindex will be gEngfuncs.GetLocalPlayer(). + // entindex is -2 to represent the local client's voice being acked by the server. + void UpdateSpeakerStatus(int entindex, qboolean bTalking); + + // sets the correct image in the label for the player + void UpdateSpeakerImage(vgui::Label *pLabel, int iPlayer); + + // Call from the HUD_CreateEntities function so it can add sprites above player heads. + void CreateEntities(); + + // Called when the server registers a change to who this client can hear. + void HandleVoiceMaskMsg(int iSize, void *pbuf); + + // The server sends this message initially to tell the client to send their state. + void HandleReqStateMsg(int iSize, void *pbuf); + + +// Squelch mode functions. +public: + + // When you enter squelch mode, pass in + void StartSquelchMode(); + void StopSquelchMode(); + bool IsInSquelchMode(); + + // returns true if the target client has been banned + // playerIndex is of range 1..maxplayers + bool IsPlayerBlocked(int iPlayerIndex); + + // returns false if the player can't hear the other client due to game rules (eg. the other team) + bool IsPlayerAudible(int iPlayerIndex); + + // blocks the target client from being heard + void SetPlayerBlockedState(int iPlayerIndex, bool blocked); + +public: + + CVoiceLabel* FindVoiceLabel(int clientindex); // Find a CVoiceLabel representing the specified speaker. + // Returns NULL if none. + // entindex can be -1 if you want a currently-unused voice label. + CVoiceLabel* GetFreeVoiceLabel(); // Get an unused voice label. Returns NULL if none. + + void RepositionLabels(); + + void FreeBitmaps(); + + void UpdateServerState(bool bForce); + + // Update the button artwork to reflect the client's current state. + void UpdateBanButton(int iClient); + + +public: + + enum {MAX_VOICE_SPEAKERS=7}; + + float m_LastUpdateServerState; // Last time we called this function. + int m_bServerModEnable; // What we've sent to the server about our "voice_modenable" cvar. + + vgui::Panel **m_pParentPanel; + CPlayerBitVec m_VoicePlayers; // Who is currently talking. Indexed by client index. + + // This is the gamerules-defined list of players that you can hear. It is based on what teams people are on + // and is totally separate from the ban list. Indexed by client index. + CPlayerBitVec m_AudiblePlayers; + + // Players who have spoken at least once in the game so far + CPlayerBitVec m_VoiceEnabledPlayers; + + // This is who the server THINKS we have banned (it can become incorrect when a new player arrives on the server). + // It is checked periodically, and the server is told to squelch or unsquelch the appropriate players. + CPlayerBitVec m_ServerBannedPlayers; + + cl_entity_s m_VoiceHeadModels[VOICE_MAX_PLAYERS]; // These aren't necessarily in the order of players. They are just + // a place for it to put data in during CreateEntities. + + IVoiceStatusHelper *m_pHelper; // Each mod provides an implementation of this. + + + // Scoreboard icons. + double m_BlinkTimer; // Blink scoreboard icons.. + vgui::BitmapTGA *m_pScoreboardNeverSpoken; + vgui::BitmapTGA *m_pScoreboardNotSpeaking; + vgui::BitmapTGA *m_pScoreboardSpeaking; + vgui::BitmapTGA *m_pScoreboardSpeaking2; + vgui::BitmapTGA *m_pScoreboardSquelch; + vgui::BitmapTGA *m_pScoreboardBanned; + + vgui::Label *m_pBanButtons[VOICE_MAX_PLAYERS]; // scoreboard buttons. + + // Squelch mode stuff. + bool m_bInSquelchMode; + + HSPRITE m_VoiceHeadModel; // Voice head model (goes above players who are speaking). + float m_VoiceHeadModelHeight; // Height above their head to place the model. + + vgui::Image *m_pSpeakerLabelIcon; // Icon next to speaker labels. + + // Lower-right icons telling when the local player is talking.. + vgui::BitmapTGA *m_pLocalBitmap; // Represents the local client talking. + vgui::BitmapTGA *m_pAckBitmap; // Represents the server ack'ing the client talking. + vgui::ImagePanel *m_pLocalLabel; // Represents the local client talking. + + bool m_bTalking; // Set to true when the client thinks it's talking. + bool m_bServerAcked; // Set to true when the server knows the client is talking. + +public: + + CVoiceBanMgr m_BanMgr; // Tracks which users we have squelched and don't want to hear. + +public: + + bool m_bBanMgrInitialized; + + // Labels telling who is speaking. + CVoiceLabel m_Labels[MAX_VOICE_SPEAKERS]; + + // Cache the game directory for use when we shut down + char * m_pchGameDir; +}; + + +// Get the (global) voice manager. +CVoiceStatus* GetClientVoiceMgr(); + + +#endif // VOICE_STATUS_H diff --git a/cl_dll/wrect.h b/cl_dll/wrect.h new file mode 100644 index 00000000..007f7dec --- /dev/null +++ b/cl_dll/wrect.h @@ -0,0 +1,16 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= +#pragma once +#if !defined( WRECTH ) +#define WRECTH + +typedef struct rect_s +{ + int left, right, top, bottom; +} wrect_t; + +#endif diff --git a/cl_dll/wscript b/cl_dll/wscript index d0bd0951..b368ebd8 100644 --- a/cl_dll/wscript +++ b/cl_dll/wscript @@ -4,63 +4,129 @@ from waflib import Utils import os - + def options(opt): # stub return def configure(conf): + if conf.env.DEST_OS == 'win32': + conf.check_cxx(lib='user32') + if conf.env.GOLDSRC: - if conf.env.DEST_OS != 'win32': + if conf.env.DEST_OS == 'win32': + conf.check_cxx(lib='winmm') + else: conf.check_cc(lib='dl') def build(bld): source = bld.path.parent.ant_glob([ - 'pm_shared/*.c', - 'dlls/crossbow.cpp', 'dlls/crowbar.cpp', 'dlls/egon.cpp', 'dlls/gauss.cpp', 'dlls/handgrenade.cpp', - 'dlls/hornetgun.cpp', 'dlls/mp5.cpp', 'dlls/python.cpp', 'dlls/rpg.cpp', 'dlls/satchel.cpp', - 'dlls/shotgun.cpp', 'dlls/squeakgrenade.cpp', 'dlls/tripmine.cpp', 'dlls/glock.cpp' + 'pm_shared/*.c' + ]) + source += bld.path.ant_glob([ + 'hl/*.cpp' + ]) + source += bld.path.parent.ant_glob([ + 'dlls/crossbow.cpp', + 'dlls/crowbar.cpp', + 'dlls/egon.cpp', + 'dlls/gauss.cpp', + 'dlls/glock.cpp', + 'dlls/handgrenade.cpp', + 'dlls/hornetgun.cpp', + 'dlls/mp5.cpp', + 'dlls/python.cpp', + 'dlls/rpg.cpp', + 'dlls/satchel.cpp', + 'dlls/shotgun.cpp', + 'dlls/squeakgrenade.cpp', + 'dlls/tripmine.cpp' ]) - - source += bld.path.ant_glob(['hl/*.cpp']) source += [ - 'ev_hldm.cpp', 'ammo.cpp', 'ammo_secondary.cpp', 'ammohistory.cpp', - 'battery.cpp', 'cdll_int.cpp', 'com_weapons.cpp', 'death.cpp', - 'demo.cpp', 'entity.cpp', 'ev_common.cpp', 'events.cpp', - 'flashlight.cpp', 'GameStudioModelRenderer.cpp', 'geiger.cpp', - 'health.cpp', 'hud.cpp', 'hud_msg.cpp', 'hud_redraw.cpp', - 'hud_spectator.cpp', 'hud_update.cpp', 'in_camera.cpp', - 'input.cpp', 'input_goldsource.cpp', 'input_mouse.cpp', - 'input_xash3d.cpp', 'menu.cpp', 'message.cpp', - 'overview.cpp', 'parsemsg.cpp', 'saytext.cpp', - 'status_icons.cpp', 'statusbar.cpp', 'studio_util.cpp', - 'StudioModelRenderer.cpp', 'text_message.cpp', 'train.cpp', - 'tri.cpp', 'util.cpp', 'view.cpp', 'scoreboard.cpp', 'MOTD.cpp' + 'GameStudioModelRenderer.cpp', + 'MOTD.cpp', + 'StudioModelRenderer.cpp', + 'ammo.cpp', + 'ammo_secondary.cpp', + 'ammohistory.cpp', + 'battery.cpp', + 'cdll_int.cpp', + 'com_weapons.cpp', + 'death.cpp', + 'demo.cpp', + 'entity.cpp', + 'ev_hldm.cpp', + 'ev_common.cpp', + 'events.cpp', + 'flashlight.cpp', + 'geiger.cpp', + 'health.cpp', + 'hud.cpp', + 'hud_msg.cpp', + 'hud_redraw.cpp', + 'hud_spectator.cpp', + 'hud_update.cpp', + 'in_camera.cpp', + 'input.cpp', + 'input_goldsource.cpp', + 'input_mouse.cpp', + 'input_xash3d.cpp', + 'menu.cpp', + 'message.cpp', + 'parsemsg.cpp', + 'saytext.cpp', + 'scoreboard.cpp', + 'status_icons.cpp', + 'statusbar.cpp', + 'studio_util.cpp', + 'text_message.cpp', + 'train.cpp', + 'tri.cpp', + 'util.cpp', + 'view.cpp' ] - includes = Utils.to_list('. hl/ ../dlls ../dlls/wpn_shared ../common ../engine ../pm_shared ../game_shared ../public ../utils/false_vgui/include') + includes = [ + '.', + 'hl/', + '../dlls', + '../common', + '../engine', + '../pm_shared', + '../game_shared', + '../public', + '../utils/fake_vgui/include' + ] defines = ['CLIENT_DLL'] if bld.env.GOLDSRC: defines += ['GOLDSOURCE_SUPPORT'] libs = [] - if bld.env.GOLDSRC: - libs += ['DL'] + if bld.env.DEST_OS == 'win32': + libs += ["USER32"] - if bld.env.DEST_OS2 not in ['android']: + if bld.env.GOLDSRC: + if bld.env.DEST_OS == 'win32': + libs += ["WINMM"] + else: + libs += ['DL'] + + if bld.env.DEST_OS not in ['android', 'dos']: install_path = os.path.join(bld.env.GAMEDIR, bld.env.CLIENT_DIR) else: install_path = bld.env.PREFIX bld.shlib( source = source, - target = 'client', + target = 'client' + bld.env.POSTFIX, + name = 'client', features = 'c cxx', includes = includes, defines = defines, use = libs, install_path = install_path, subsystem = bld.env.MSVC_SUBSYSTEM, - idx = 1 + idx = bld.get_taskgen_count() ) + diff --git a/cmake/LibraryNaming.cmake b/cmake/LibraryNaming.cmake new file mode 100644 index 00000000..3c2b8968 --- /dev/null +++ b/cmake/LibraryNaming.cmake @@ -0,0 +1,162 @@ +include(CheckSymbolExists) + +# generated(see comments in public/build.h) +# cat build.h | grep '^#undef XASH' | awk '{ print "check_symbol_exists(" $2 " \"build.h\" " $2 ")" }' +set(CMAKE_REQUIRED_INCLUDES "${PROJECT_SOURCE_DIR}/public/") +check_symbol_exists(XASH_64BIT "build.h" XASH_64BIT) +check_symbol_exists(XASH_AMD64 "build.h" XASH_AMD64) +check_symbol_exists(XASH_ANDROID "build.h" XASH_ANDROID) +check_symbol_exists(XASH_APPLE "build.h" XASH_APPLE) +check_symbol_exists(XASH_ARM "build.h" XASH_ARM) +check_symbol_exists(XASH_ARM_HARDFP "build.h" XASH_ARM_HARDFP) +check_symbol_exists(XASH_ARM_SOFTFP "build.h" XASH_ARM_SOFTFP) +check_symbol_exists(XASH_ARMv4 "build.h" XASH_ARMv4) +check_symbol_exists(XASH_ARMv5 "build.h" XASH_ARMv5) +check_symbol_exists(XASH_ARMv6 "build.h" XASH_ARMv6) +check_symbol_exists(XASH_ARMv7 "build.h" XASH_ARMv7) +check_symbol_exists(XASH_ARMv8 "build.h" XASH_ARMv8) +check_symbol_exists(XASH_BIG_ENDIAN "build.h" XASH_BIG_ENDIAN) +check_symbol_exists(XASH_BSD "build.h" XASH_BSD) +check_symbol_exists(XASH_DOS4GW "build.h" XASH_DOS4GW) +check_symbol_exists(XASH_E2K "build.h" XASH_E2K) +check_symbol_exists(XASH_EMSCRIPTEN "build.h" XASH_EMSCRIPTEN) +check_symbol_exists(XASH_FREEBSD "build.h" XASH_FREEBSD) +check_symbol_exists(XASH_HAIKU "build.h" XASH_HAIKU) +check_symbol_exists(XASH_IOS "build.h" XASH_IOS) +check_symbol_exists(XASH_JS "build.h" XASH_JS) +check_symbol_exists(XASH_LINUX "build.h" XASH_LINUX) +check_symbol_exists(XASH_LITTLE_ENDIAN "build.h" XASH_LITTLE_ENDIAN) +check_symbol_exists(XASH_MINGW "build.h" XASH_MINGW) +check_symbol_exists(XASH_MIPS "build.h" XASH_MIPS) +check_symbol_exists(XASH_PPC "build.h" XASH_PPC) +check_symbol_exists(XASH_MOBILE_PLATFORM "build.h" XASH_MOBILE_PLATFORM) +check_symbol_exists(XASH_MSVC "build.h" XASH_MSVC) +check_symbol_exists(XASH_NETBSD "build.h" XASH_NETBSD) +check_symbol_exists(XASH_OPENBSD "build.h" XASH_OPENBSD) +check_symbol_exists(XASH_POSIX "build.h" XASH_POSIX) +check_symbol_exists(XASH_RISCV "build.h" XASH_RISCV) +check_symbol_exists(XASH_RISCV_DOUBLEFP "build.h" XASH_RISCV_DOUBLEFP) +check_symbol_exists(XASH_RISCV_SINGLEFP "build.h" XASH_RISCV_SINGLEFP) +check_symbol_exists(XASH_RISCV_SOFTFP "build.h" XASH_RISCV_SOFTFP) +check_symbol_exists(XASH_SERENITY "build.h" XASH_SERENITY) +check_symbol_exists(XASH_WIN32 "build.h" XASH_WIN32) +check_symbol_exists(XASH_WIN64 "build.h" XASH_WIN64) +check_symbol_exists(XASH_X86 "build.h" XASH_X86) +check_symbol_exists(XASH_NSWITCH "build.h" XASH_NSWITCH) +check_symbol_exists(XASH_PSVITA "build.h" XASH_PSVITA) +unset(CMAKE_REQUIRED_INCLUDES) + +# engine/common/build.c +if(XASH_ANDROID) + set(BUILDOS "android") +elseif(XASH_WIN32 OR XASH_LINUX OR XASH_APPLE) + set(BUILDOS "") # no prefix for default OS +elseif(XASH_FREEBSD) + set(BUILDOS "freebsd") +elseif(XASH_NETBSD) + set(BUILDOS "netbsd") +elseif(XASH_OPENBSD) + set(BUILDOS "openbsd") +elseif(XASH_EMSCRIPTEN) + set(BUILDOS "emscripten") +elseif(XASH_DOS4GW) + set(BUILDOS "DOS4GW") +elseif(XASH_HAIKU) + set(BUILDOS "haiku") +elseif(XASH_SERENITY) + set(BUILDOS "serenityos") +elseif(XASH_NSWITCH) + set(BUILDOS "nswitch") +elseif(XASH_PSVITA) + set(BUILDOS "psvita") +else() + message(SEND_ERROR "Place your operating system name here! If this is a mistake, try to fix conditions above and report a bug") +endif() + +if(XASH_AMD64) + set(BUILDARCH "amd64") +elseif(XASH_X86) + if(XASH_WIN32 OR XASH_LINUX OR XASH_APPLE) + set(BUILDARCH "") # no prefix for default OS + else() + set(BUILDARCH "i386") + endif() +elseif(XASH_ARM AND XASH_64BIT) + set(BUILDARCH "arm64") +elseif(XASH_ARM) + set(BUILDARCH "armv") + if(XASH_ARMv8) + set(BUILDARCH "${BUILDARCH}8_32") + elseif(XASH_ARMv7) + set(BUILDARCH "${BUILDARCH}7") + elseif(XASH_ARMv6) + set(BUILDARCH "${BUILDARCH}6") + elseif(XASH_ARMv5) + set(BUILDARCH "${BUILDARCH}5") + elseif(XASH_ARMv4) + set(BUILDARCH "${BUILDARCH}4") + else() + message(SEND_ERROR "Unknown ARM") + endif() + + if(XASH_ARM_HARDFP) + set(BUILDARCH "${BUILDARCH}hf") + else() + set(BUILDARCH "${BUILDARCH}l") + endif() +elseif(XASH_MIPS) + set(BUILDARCH "mips") + if(XASH_64BIT) + set(BUILDARCH "${BUILDARCH}64") + endif() + + if(XASH_LITTLE_ENDIAN) + set(BUILDARCH "${BUILDARCH}el") + endif() +elseif(XASH_PPC) + set(BUILDARCH "powerpc") + if(XASH_64BIT) + set(BUILDARCH "${BUILDARCH}64") + endif() + + if(XASH_LITTLE_ENDIAN) + set(BUILDARCH "${BUILDARCH}le") + endif() +elseif(XASH_RISCV) + set(BUILDARCH "riscv") + if(XASH_64BIT) + set(BUILDARCH "${BUILDARCH}64") + else() + set(BUILDARCH "${BUILDARCH}32") + endif() + + if(XASH_RISCV_DOUBLEFP) + set(BUILDARCH "${BUILDARCH}d") + elseif(XASH_RISCV_SINGLEFP) + set(BUILDARCH "${BUILDARCH}f") + endif() +elseif(XASH_JS) + set(BUILDARCH "javascript") +elseif(XASH_E2K) + set(BUILDARCH "e2k") +else() + message(SEND_ERROR "Place your architecture name here! If this is a mistake, try to fix conditions above and report a bug") +endif() + +if(BUILDOS STREQUAL "android") + set(POSTFIX "") # force disable for Android, as Android ports aren't distributed in normal way and doesn't follow library naming +elseif(BUILDOS AND BUILDARCH) + set(POSTFIX "_${BUILDOS}_${BUILDARCH}") +elseif(BUILDARCH) + set(POSTFIX "_${BUILDARCH}") +else() + set(POSTFIX "") +endif() + +message(STATUS "Library postfix: " ${POSTFIX}) + +set(CMAKE_RELEASE_POSTFIX ${POSTFIX}) +set(CMAKE_DEBUG_POSTFIX ${POSTFIX}) +set(CMAKE_RELWITHDEBINFO_POSTFIX ${POSTFIX}) +set(CMAKE_MINSIZEREL_POSTFIX ${POSTFIX}) +set(CMAKE_POSTFIX ${POSTFIX}) diff --git a/common/beamdef.h b/common/beamdef.h index f254428c..c578dded 100644 --- a/common/beamdef.h +++ b/common/beamdef.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef BEAMDEF_H +#if !defined(BEAMDEF_H) #define BEAMDEF_H #define FBEAM_STARTENTITY 0x00000001 diff --git a/common/bspfile.h b/common/bspfile.h deleted file mode 100644 index 079e1b21..00000000 --- a/common/bspfile.h +++ /dev/null @@ -1,246 +0,0 @@ -/* -bspfile.h - BSP format included q1, hl1 support -Copyright (C) 2010 Uncle Mike - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -*/ -#pragma once -#ifndef BSPFILE_H -#define BSPFILE_H - -/* -============================================================================== - -BRUSH MODELS - -.bsp contain level static geometry with including PVS and lightning info -============================================================================== -*/ - -// header -#define Q1BSP_VERSION 29 // quake1 regular version (beta is 28) -#define HLBSP_VERSION 30 // half-life regular version -#define XTBSP_VERSION 31 // extended lightmaps and expanded clipnodes limit - -#define IDEXTRAHEADER (('H'<<24)+('S'<<16)+('A'<<8)+'X') // little-endian "XASH" -#define EXTRA_VERSION 2 // because version 1 was occupied by old versions of XashXT - -#define DELUXEMAP_VERSION 1 -#define IDDELUXEMAPHEADER (('T'<<24)+('I'<<16)+('L'<<8)+'Q') // little-endian "QLIT" - -// worldcraft predefined angles -#define ANGLE_UP -1 -#define ANGLE_DOWN -2 - -// bmodel limits -#define MAX_MAP_HULLS 4 // MAX_HULLS - -#define SURF_NOCULL BIT( 0 ) // two-sided polygon (e.g. 'water4b') -#define SURF_PLANEBACK BIT( 1 ) // plane should be negated -#define SURF_DRAWSKY BIT( 2 ) // sky surface -#define SURF_WATERCSG BIT( 3 ) // culled by csg (was SURF_DRAWSPRITE) -#define SURF_DRAWTURB BIT( 4 ) // warp surface -#define SURF_DRAWTILED BIT( 5 ) // face without lighmap -#define SURF_CONVEYOR BIT( 6 ) // scrolled texture (was SURF_DRAWBACKGROUND) -#define SURF_UNDERWATER BIT( 7 ) // caustics -#define SURF_TRANSPARENT BIT( 8 ) // it's a transparent texture (was SURF_DONTWARP) - -#define SURF_REFLECT BIT( 31 ) // reflect surface (mirror) - -// lightstyle management -#define LM_STYLES 4 // MAXLIGHTMAPS -#define LS_NORMAL 0x00 -#define LS_UNUSED 0xFE -#define LS_NONE 0xFF - -#define MAX_MAP_MODELS 1024 // can be increased up to 2048 if needed -#define MAX_MAP_BRUSHES 32768 // unsigned short limit -#define MAX_MAP_ENTITIES 8192 // can be increased up to 32768 if needed -#define MAX_MAP_ENTSTRING 0x80000 // 512 kB should be enough -#define MAX_MAP_PLANES 65536 // can be increased without problems -#define MAX_MAP_NODES 32767 // because negative shorts are leafs -#define MAX_MAP_CLIPNODES 32767 // because negative shorts are contents -#define MAX_MAP_LEAFS 32767 // signed short limit -#define MAX_MAP_VERTS 65535 // unsigned short limit -#define MAX_MAP_FACES 65535 // unsigned short limit -#define MAX_MAP_MARKSURFACES 65535 // unsigned short limit -#define MAX_MAP_TEXINFO MAX_MAP_FACES // in theory each face may have personal texinfo -#define MAX_MAP_EDGES 0x100000 // can be increased but not needed -#define MAX_MAP_SURFEDGES 0x200000 // can be increased but not needed -#define MAX_MAP_TEXTURES 2048 // can be increased but not needed -#define MAX_MAP_MIPTEX 0x2000000 // 32 Mb internal textures data -#define MAX_MAP_LIGHTING 0x2000000 // 32 Mb lightmap raw data (can contain deluxemaps) -#define MAX_MAP_VISIBILITY 0x800000 // 8 Mb visdata - -// quake lump ordering -#define LUMP_ENTITIES 0 -#define LUMP_PLANES 1 -#define LUMP_TEXTURES 2 // internal textures -#define LUMP_VERTEXES 3 -#define LUMP_VISIBILITY 4 -#define LUMP_NODES 5 -#define LUMP_TEXINFO 6 -#define LUMP_FACES 7 -#define LUMP_LIGHTING 8 -#define LUMP_CLIPNODES 9 -#define LUMP_LEAFS 10 -#define LUMP_MARKSURFACES 11 -#define LUMP_EDGES 12 -#define LUMP_SURFEDGES 13 -#define LUMP_MODELS 14 // internal submodels -#define HEADER_LUMPS 15 - -// version 31 -#define LUMP_CLIPNODES2 15 // hull0 goes into LUMP_NODES, hull1 goes into LUMP_CLIPNODES, -#define LUMP_CLIPNODES3 16 // hull2 goes into LUMP_CLIPNODES2, hull3 goes into LUMP_CLIPNODES3 -#define HEADER_LUMPS_31 17 - -#define LUMP_FACES_EXTRADATA 0 // extension of dface_t -#define LUMP_VERTS_EXTRADATA 1 // extension of dvertex_t -#define LUMP_CUBEMAPS 2 // cubemap description - -#define EXTRA_LUMPS 8 // g-cont. just for future expansions - -// texture flags -#define TEX_SPECIAL BIT( 0 ) // sky or slime, no lightmap or 256 subdivision - -// ambient sound types -enum -{ - AMBIENT_WATER = 0, // waterfall - AMBIENT_SKY, // wind - AMBIENT_SLIME, // never used in quake - AMBIENT_LAVA, // never used in quake - NUM_AMBIENTS // automatic ambient sounds -}; - -// -// BSP File Structures -// - -typedef struct -{ - int fileofs; - int filelen; -} dlump_t; - -typedef struct -{ - int version; - dlump_t lumps[HEADER_LUMPS]; -} dheader_t; - -typedef struct -{ - int version; - dlump_t lumps[HEADER_LUMPS_31]; -} dheader31_t; - -typedef struct -{ - int id; // must be little endian XASH - int version; - dlump_t lumps[EXTRA_LUMPS]; -} dextrahdr_t; - -typedef struct -{ - vec3_t mins; - vec3_t maxs; - vec3_t origin; // for sounds or lights - int headnode[MAX_MAP_HULLS]; - int visleafs; // not including the solid leaf 0 - int firstface; - int numfaces; -} dmodel_t; - -typedef struct -{ - int nummiptex; - int dataofs[4]; // [nummiptex] -} dmiptexlump_t; - -typedef struct -{ - vec3_t point; -} dvertex_t; - -typedef struct -{ - vec3_t normal; - float dist; - int type; // PLANE_X - PLANE_ANYZ ? -} dplane_t; - -typedef struct -{ - int planenum; - short children[2]; // negative numbers are -(leafs + 1), not nodes - short mins[3]; // for sphere culling - short maxs[3]; - word firstface; - word numfaces; // counting both sides -} dnode_t; - -// leaf 0 is the generic CONTENTS_SOLID leaf, used for all solid areas -// all other leafs need visibility info -typedef struct -{ - int contents; - int visofs; // -1 = no visibility info - - short mins[3]; // for frustum culling - short maxs[3]; - word firstmarksurface; - word nummarksurfaces; - - // automatic ambient sounds - byte ambient_level[NUM_AMBIENTS]; // ambient sound level (0 - 255) -} dleaf_t; - -typedef struct -{ - int planenum; - short children[2]; // negative numbers are contents -} dclipnode_t; - -typedef struct -{ - float vecs[2][4]; // texmatrix [s/t][xyz offset] - int miptex; - int flags; -} dtexinfo_t; - -typedef word dmarkface_t; // leaf marksurfaces indexes -typedef int dsurfedge_t; // map surfedges - -// NOTE: that edge 0 is never used, because negative edge nums -// are used for counterclockwise use of the edge in a face -typedef struct -{ - word v[2]; // vertex numbers -} dedge_t; - -typedef struct -{ - word planenum; - short side; - - int firstedge; // we must support > 64k edges - short numedges; - short texinfo; - - // lighting info - byte styles[LM_STYLES]; - int lightofs; // start of [numstyles*surfsize] samples -} dface_t; - -#endif//BSPFILE_H diff --git a/common/cl_entity.h b/common/cl_entity.h index c003ce30..d5323aa1 100644 --- a/common/cl_entity.h +++ b/common/cl_entity.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef CL_ENTITY_H +#if !defined(CL_ENTITY_H) #define CL_ENTITY_H typedef struct efrag_s diff --git a/common/com_model.h b/common/com_model.h index abc8e8e6..61c0434a 100644 --- a/common/com_model.h +++ b/common/com_model.h @@ -1,59 +1,77 @@ -/* -com_model.h - cient model structures -Copyright (C) 2010 Uncle Mike - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -*/ +//========= Copyright 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= +// com_model.h #pragma once -#ifndef COM_MODEL_H +#if !defined( COM_MODEL_H ) #define COM_MODEL_H -#include "bspfile.h" // we need some declarations from it +#define STUDIO_RENDER 1 +#define STUDIO_EVENTS 2 -typedef vec_t vec2_t[2]; -typedef vec_t vec4_t[4]; +#define MAX_CLIENTS 32 +#define MAX_EDICTS 900 -/* -============================================================================== +#define MAX_MODEL_NAME 64 +#define MAX_MAP_HULLS 4 +#define MIPLEVELS 4 +#define NUM_AMBIENTS 4 // automatic ambient sounds +#define MAXLIGHTMAPS 4 +#define PLANE_ANYZ 5 - ENGINE MODEL FORMAT -============================================================================== -*/ -#define STUDIO_RENDER 1 -#define STUDIO_EVENTS 2 +#define ALIAS_Z_CLIP_PLANE 5 -#define ZISCALE ((float)0x8000) +// flags in finalvert_t.flags +#define ALIAS_LEFT_CLIP 0x0001 +#define ALIAS_TOP_CLIP 0x0002 +#define ALIAS_RIGHT_CLIP 0x0004 +#define ALIAS_BOTTOM_CLIP 0x0008 +#define ALIAS_Z_CLIP 0x0010 +#define ALIAS_ONSEAM 0x0020 +#define ALIAS_XY_CLIP_MASK 0x000F -#define MIPLEVELS 4 -#define VERTEXSIZE 7 -#define MAXLIGHTMAPS 4 -#define NUM_AMBIENTS 4 // automatic ambient sounds +#define ZISCALE ((float)0x8000) -// model types typedef enum { - mod_bad = -1, mod_brush, mod_sprite, mod_alias, mod_studio } modtype_t; +// must match definition in modelgen.h +#if !defined(SYNCTYPE_T) +#define SYNCTYPE_T + +typedef enum +{ + ST_SYNC=0, + ST_RAND +} synctype_t; + +#endif + +typedef struct +{ + float mins[3], maxs[3]; + float origin[3]; + int headnode[MAX_MAP_HULLS]; + int visleafs; // not including the solid leaf 0 + int firstface, numfaces; +} dmodel_t; + +// plane_t structure typedef struct mplane_s { - vec3_t normal; - float dist; - byte type; // for fast side tests - byte signbits; // signx + (signy<<1) + (signz<<1) - byte pad[2]; + vec3_t normal; // surface normal + float dist; // closest appoach to origin + byte type; // for texture axis selection and fast side tests + byte signbits; // signx + signy<<1 + signz<<1 + byte pad[2]; } mplane_t; typedef struct @@ -70,292 +88,246 @@ typedef struct typedef struct texture_s { char name[16]; - unsigned int width, height; - int gl_texturenum; - struct msurface_s *texturechain; // for gl_texsort drawing - int anim_total; // total tenths in sequence ( 0 = no) - int anim_min, anim_max; // time for this frame min <=time< max - struct texture_s *anim_next; // in the animation sequence - struct texture_s *alternate_anims; // bmodels in frame 1 use these - unsigned short fb_texturenum; // auto-luma texturenum - unsigned short dt_texturenum; // detail-texture binding - unsigned int unused[3]; // reserved + unsigned width, height; + int anim_total; // total tenths in sequence ( 0 = no) + int anim_min, anim_max; // time for this frame min <=time< max + struct texture_s *anim_next; // in the animation sequence + struct texture_s *alternate_anims; // bmodels in frame 1 use these + unsigned offsets[MIPLEVELS]; // four mip maps stored + unsigned paloffset; } texture_t; typedef struct { - float vecs[2][4]; // [s/t] unit vectors in world space. - // [i][3] is the s/t offset relative to the origin. - // s or t = dot( 3Dpoint, vecs[i] ) + vecs[i][3] - float mipadjust; // mipmap limits for very small surfaces - texture_t *texture; - int flags; // sky or slime, no lightmap or 256 subdivision + float vecs[2][4]; // [s/t] unit vectors in world space. + // [i][3] is the s/t offset relative to the origin. + // s or t = dot(3Dpoint,vecs[i])+vecs[i][3] + float mipadjust; // ?? mipmap limits for very small surfaces + texture_t *texture; + int flags; // sky or slime, no lightmap or 256 subdivision } mtexinfo_t; -// 73 bytes per VBO vertex -// FIXME: align to 32 bytes -typedef struct glvert_s -{ - vec3_t vertex; // position - vec3_t normal; // normal - vec2_t stcoord; // ST texture coords - vec2_t lmcoord; // ST lightmap coords - vec2_t sccoord; // ST scissor coords (decals only) - for normalmap coords migration - vec3_t tangent; // tangent - vec3_t binormal; // binormal - byte color[4]; // colors per vertex -} glvert_t; - -typedef struct glpoly_s -{ - struct glpoly_s *next; - struct glpoly_s *chain; - int numverts; - int flags; // for SURF_UNDERWATER - float verts[4][VERTEXSIZE]; // variable sized (xyz s1t1 s2t2) -} glpoly_t; - typedef struct mnode_s { // common with leaf - int contents; // 0, to differentiate from leafs - int visframe; // node needs to be traversed if current + int contents; // 0, to differentiate from leafs + int visframe; // node needs to be traversed if current + + short minmaxs[6]; // for bounding box culling - float minmaxs[6]; // for bounding box culling struct mnode_s *parent; // node specific - mplane_t *plane; + mplane_t *plane; struct mnode_s *children[2]; - unsigned short firstsurface; - unsigned short numsurfaces; + unsigned short firstsurface; + unsigned short numsurfaces; } mnode_t; typedef struct msurface_s msurface_t; -typedef struct decal_s decal_t; +typedef struct decal_s decal_t; // JAY: Compress this as much as possible struct decal_s { - decal_t *pnext; // linked list for each surface - msurface_t *psurface; // Surface id for persistence / unlinking - float dx; // local texture coordinates - float dy; // - float scale; // Pixel scale + decal_t *pnext; // linked list for each surface + msurface_t *psurface; // Surface id for persistence / unlinking + short dx; // Offsets into surface texture (in texture coordinates, so we don't need floats) + short dy; short texture; // Decal texture - byte flags; // Decal flags FDECAL_* + byte scale; // Pixel scale + byte flags; // Decal flags + short entityIndex; // Entity this is attached to -// Xash3D added - vec3_t position; // location of the decal center in world space. - vec3_t saxis; // direction of the s axis in world space - struct msurfmesh_s *mesh; // decal mesh in local space - int reserved[4]; // for future expansions }; typedef struct mleaf_s { // common with node - int contents; - int visframe; // node needs to be traversed if current + int contents; // wil be a negative contents number + int visframe; // node needs to be traversed if current - float minmaxs[6]; // for bounding box culling + short minmaxs[6]; // for bounding box culling struct mnode_s *parent; + // leaf specific byte *compressed_vis; struct efrag_s *efrags; msurface_t **firstmarksurface; - int nummarksurfaces; - byte *compressed_pas; + int nummarksurfaces; + int key; // BSP sequence number for leaf's contents byte ambient_sound_level[NUM_AMBIENTS]; - } mleaf_t; -typedef struct msurface_s +struct msurface_s { - int visframe; // should be drawn when node is crossed + int visframe; // should be drawn when node is crossed - mplane_t *plane; // pointer to shared plane - int flags; // see SURF_ #defines + int dlightframe; // last frame the surface was checked by an animated light + int dlightbits; // dynamically generated. Indicates if the surface illumination + // is modified by an animated light. - int firstedge; // look up in model->surfedges[], negative numbers - int numedges; // are backwards edges + mplane_t *plane; // pointer to shared plane + int flags; // see SURF_ #defines - short texturemins[2]; - short extents[2]; + int firstedge; // look up in model->surfedges[], negative numbers + int numedges; // are backwards edges + +// surface generation data + struct surfcache_s *cachespots[MIPLEVELS]; - int light_s, light_t; // gl lightmap coordinates + short texturemins[2]; // smallest s/t position on the surface. + short extents[2]; // ?? s/t texture size, 1..256 for all non-sky surfaces - glpoly_t *polys; // multiple if warped - struct msurface_s *texturechain; - - mtexinfo_t *texinfo; - - // lighting info - int dlightframe; // last frame the surface was checked by an animated light - int dlightbits; // dynamically generated. Indicates if the surface illumination - // is modified by an animated light. - - int lightmaptexturenum; - byte styles[MAXLIGHTMAPS]; - int cached_light[MAXLIGHTMAPS]; // values currently used in lightmap - struct msurface_s *lightmapchain; // for new dlights rendering (was cached_dlight) - - color24 *samples; // note: this is the actual lightmap data for this surface + mtexinfo_t *texinfo; + +// lighting info + byte styles[MAXLIGHTMAPS]; // index into d_lightstylevalue[] for animated lights + // no one surface can be effected by more than 4 + // animated lights. + color24 *samples; + decal_t *pdecals; -} msurface_t; +}; -typedef struct msurfmesh_s +typedef struct { - unsigned short numVerts; - unsigned short numElems; // ~ 20 000 vertex per one surface. Should be enough - unsigned int startVert; // user-variable. may be used for construct world single-VBO - unsigned int startElem; // user-variable. may be used for construct world single-VBO - - glvert_t *verts; // vertexes array - unsigned short *elems; // indices - - struct msurface_s *surf; // pointer to parent surface. Just for consistency - struct msurfmesh_s *next; // temporary chain of subdivided surfaces -} msurfmesh_t; - -// surface extradata stored in cache.data for all brushmodels -typedef struct mextrasurf_s -{ - vec3_t mins, maxs; - vec3_t origin; // surface origin - msurfmesh_t *mesh; // VBO\VA ready surface mesh. Not used by engine but can be used by mod-makers - - int dlight_s, dlight_t; // gl lightmap coordinates for dynamic lightmaps - - int mirrortexturenum; // gl texnum - float mirrormatrix[4][4]; - struct mextrasurf_s *mirrorchain; // for gl_texsort drawing - struct mextrasurf_s *detailchain; // for detail textures drawing - color24 *deluxemap; // note: this is the actual deluxemap data for this surface - - int reserved[32]; // just for future expansions or mod-makers -} mextrasurf_t; + int planenum; + short children[2]; // negative numbers are contents +} dclipnode_t; typedef struct hull_s { dclipnode_t *clipnodes; - mplane_t *planes; - int firstclipnode; - int lastclipnode; + mplane_t *planes; + int firstclipnode; + int lastclipnode; vec3_t clip_mins; vec3_t clip_maxs; } hull_t; -#ifndef CACHE_USER +#if !defined( CACHE_USER ) && !defined( QUAKEDEF_H ) #define CACHE_USER typedef struct cache_user_s { - void *data; // extradata + void *data; } cache_user_t; #endif typedef struct model_s { - char name[64]; // model name - qboolean needload; // bmodels and sprites don't cache normally + char name[ MAX_MODEL_NAME ]; + qboolean needload; // bmodels and sprites don't cache normally - // shared modelinfo - modtype_t type; // model type - int numframes; // sprite's framecount - byte *mempool; // private mempool (was synctype) - int flags; // hl compatibility + modtype_t type; + int numframes; + synctype_t synctype; + + int flags; // // volume occupied by the model -// - vec3_t mins, maxs; // bounding box at angles '0 0 0' +// + vec3_t mins, maxs; float radius; - - // brush model - int firstmodelsurface; - int nummodelsurfaces; - int numsubmodels; - dmodel_t *submodels; // or studio animations +// +// brush model +// + int firstmodelsurface, nummodelsurfaces; - int numplanes; - mplane_t *planes; + int numsubmodels; + dmodel_t *submodels; - int numleafs; // number of visible leafs, not counting 0 - mleaf_t *leafs; + int numplanes; + mplane_t *planes; - int numvertexes; - mvertex_t *vertexes; + int numleafs; // number of visible leafs, not counting 0 + struct mleaf_s *leafs; - int numedges; + int numvertexes; + mvertex_t *vertexes; + + int numedges; medge_t *edges; - int numnodes; + int numnodes; mnode_t *nodes; - int numtexinfo; + int numtexinfo; mtexinfo_t *texinfo; - int numsurfaces; + int numsurfaces; msurface_t *surfaces; - int numsurfedges; - int *surfedges; + int numsurfedges; + int *surfedges; - int numclipnodes; + int numclipnodes; dclipnode_t *clipnodes; - int nummarksurfaces; + int nummarksurfaces; msurface_t **marksurfaces; hull_t hulls[MAX_MAP_HULLS]; - int numtextures; - texture_t **textures; + int numtextures; + texture_t **textures; byte *visdata; color24 *lightdata; + char *entities; + // // additional model data // cache_user_t cache; // only access through Mod_Extradata + } model_t; +typedef vec_t vec4_t[4]; + typedef struct alight_s { - int ambientlight; // clip at 128 - int shadelight; // clip at 192 - ambientlight + int ambientlight; // clip at 128 + int shadelight; // clip at 192 - ambientlight vec3_t color; float *plightvec; } alight_t; typedef struct auxvert_s { - float fv[3]; // viewspace x, y + float fv[3]; // viewspace x, y } auxvert_t; -#define MAX_SCOREBOARDNAME 32 -#define MAX_INFO_STRING 256 - #include "custom.h" +#define MAX_INFO_STRING 256 +#define MAX_SCOREBOARDNAME 32 typedef struct player_info_s { - int userid; // User id on server - char userinfo[MAX_INFO_STRING]; // User info string - char name[MAX_SCOREBOARDNAME]; // Name (extracted from userinfo) - int spectator; // Spectator or not, unused + // User id on server + int userid; + + // User info string + char userinfo[ MAX_INFO_STRING ]; + + // Name + char name[ MAX_SCOREBOARDNAME ]; + + // Spectator or not, unused + int spectator; int ping; int packet_loss; // skin information - char model[64]; + char model[MAX_QPATH]; int topcolor; int bottomcolor; @@ -364,50 +336,12 @@ typedef struct player_info_s // Gait frame estimation int gaitsequence; - float gaitframe; - float gaityaw; - vec3_t prevgaitorigin; + float gaitframe; + float gaityaw; + vec3_t prevgaitorigin; - customization_t customdata; + customization_t customdata; } player_info_t; -// -// sprite representation in memory -// -typedef enum { SPR_SINGLE = 0, SPR_GROUP, SPR_ANGLED } spriteframetype_t; +#endif // COM_MODEL_H -typedef struct mspriteframe_s -{ - int width; - int height; - float up, down, left, right; - int gl_texturenum; -} mspriteframe_t; - -typedef struct -{ - int numframes; - float *intervals; - mspriteframe_t *frames[1]; -} mspritegroup_t; - -typedef struct -{ - spriteframetype_t type; - mspriteframe_t *frameptr; -} mspriteframedesc_t; - -typedef struct -{ - short type; - short texFormat; - int maxwidth; - int maxheight; - int numframes; - int radius; - int facecull; - int synctype; - mspriteframedesc_t frames[1]; -} msprite_t; - -#endif//COM_MODEL_H diff --git a/common/con_nprint.h b/common/con_nprint.h index 615a1850..438e047f 100644 --- a/common/con_nprint.h +++ b/common/con_nprint.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef CON_NPRINT_H +#if !defined(CON_NPRINT_H) #define CON_NPRINT_H typedef struct con_nprint_s diff --git a/common/const.h b/common/const.h index fa0f33e6..3708371b 100644 --- a/common/const.h +++ b/common/const.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef CONST_H +#if !defined(CONST_H) #define CONST_H // // Constants shared by the engine and dlls @@ -742,7 +742,7 @@ typedef unsigned short word; #undef true #undef false -#ifndef __cplusplus +#if !__cplusplus typedef enum { false, true } qboolean; #else typedef int qboolean; diff --git a/common/cvardef.h b/common/cvardef.h index f461c329..1d55f7ca 100644 --- a/common/cvardef.h +++ b/common/cvardef.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef CVARDEF_H +#if !defined(CVARDEF_H) #define CVARDEF_H #define FCVAR_ARCHIVE (1<<0) // set to cause it to be saved to vars.rc diff --git a/common/demo_api.h b/common/demo_api.h index 1a678b60..09ab0511 100644 --- a/common/demo_api.h +++ b/common/demo_api.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef DEMO_API_H +#if !defined(DEMO_API_H) #define DEMO_API_H typedef struct demo_api_s diff --git a/common/dlight.h b/common/dlight.h index ecb01445..6cfab021 100644 --- a/common/dlight.h +++ b/common/dlight.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef DLIGHT_H +#if !defined(DLIGHT_H) #define DLIGHT_H typedef struct dlight_s diff --git a/common/entity_state.h b/common/entity_state.h index 2ffd70dc..51a807e9 100644 --- a/common/entity_state.h +++ b/common/entity_state.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef ENTITY_STATE_H +#if !defined(ENTITY_STATE_H) #define ENTITY_STATE_H // For entityType below diff --git a/common/entity_types.h b/common/entity_types.h index f5754fea..ec54ba26 100644 --- a/common/entity_types.h +++ b/common/entity_types.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef ENTITY_TYPES_H +#if !defined(ENTITY_TYPES_H) #define ENTITY_TYPES_H #define ET_NORMAL 0 diff --git a/common/event_api.h b/common/event_api.h index 86c5fbe9..43cb3b62 100644 --- a/common/event_api.h +++ b/common/event_api.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef EVENT_API_H +#if !defined(EVENT_API_H) #define EVENT_API_H #define EVENT_API_VERSION 1 diff --git a/common/event_args.h b/common/event_args.h index 4cf63741..07cd39cd 100644 --- a/common/event_args.h +++ b/common/event_args.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef EVENT_ARGS_H +#if !defined(EVENT_ARGS_H) #define EVENT_ARGS_H // Event was invoked with stated origin diff --git a/common/event_flags.h b/common/event_flags.h index a2d5f3b7..c3f1789f 100644 --- a/common/event_flags.h +++ b/common/event_flags.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef EVENT_FLAGS_H +#if !defined(EVENT_FLAGS_H) #define EVENT_FLAGS_H // Skip local host for event send. diff --git a/common/gameinfo.h b/common/gameinfo.h deleted file mode 100644 index ab5f649c..00000000 --- a/common/gameinfo.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -gameinfo.h - current game info -Copyright (C) 2010 Uncle Mike - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -*/ -#pragma once -#ifndef GAMEINFO_H -#define GAMEINFO_H - -#define GFL_NOMODELS (1<<0) - -/* -======================================================================== - -GAMEINFO stuff - -internal shared gameinfo structure (readonly for engine parts) -======================================================================== -*/ -typedef struct -{ - // filesystem info - char gamefolder[64]; // used for change game '-game x' - char startmap[64]; // map to start singleplayer game - char trainmap[64]; // map to start hazard course (if specified) - char title[64]; // Game Main Title - char version[14]; // game version (optional) - short flags; // game flags - - // about mod info - char game_url[256]; // link to a developer's site - char update_url[256]; // link to updates page - char type[64]; // single, toolkit, multiplayer etc - char date[64]; - char size[64]; // displayed mod size - - int gamemode; -} GAMEINFO; - -#endif//GAMEINFO_H diff --git a/common/hltv.h b/common/hltv.h index e64dd30b..970c4861 100644 --- a/common/hltv.h +++ b/common/hltv.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef HLTV_H +#if !defined(HLTV_H) #define HLTV_H #define TYPE_CLIENT 0 // client is a normal HL client (default) diff --git a/common/ivoicetweak.h b/common/ivoicetweak.h index 96879beb..d3fd7ed4 100644 --- a/common/ivoicetweak.h +++ b/common/ivoicetweak.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef IVOICETWEAK_H +#if !defined(IVOICETWEAK_H) #define IVOICETWEAK_H // These provide access to the voice controls. diff --git a/common/lightstyle.h b/common/lightstyle.h deleted file mode 100644 index a12702f4..00000000 --- a/common/lightstyle.h +++ /dev/null @@ -1,29 +0,0 @@ -/* -lightstyle.h - lighstyle description -Copyright (C) 2011 Uncle Mike - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -*/ -#pragma once -#ifndef LIGHTSTYLE_H -#define LIGHTSTYLE_H - -typedef struct -{ - char pattern[256]; - float map[256]; - int length; - float value; - qboolean interp; // allow to interpolate this lightstyle - float time; // local time is gurantee what new style begins from the start, not mid or end of the sequence -} lightstyle_t; - -#endif//LIGHTSTYLE_H diff --git a/common/mathlib.h b/common/mathlib.h index 6bcf76eb..427d896f 100644 --- a/common/mathlib.h +++ b/common/mathlib.h @@ -14,24 +14,37 @@ ****/ // mathlib.h #pragma once -#ifndef MATHLIB_H +#if !defined(MATHLIB_H) #define MATHLIB_H +#if !__cplusplus #include +#if HAVE_TGMATH_H +#include +#endif // HAVE_TGMATH_H +#else // __cplusplus +#if HAVE_CMATH +#include +#else +#include +#endif +#endif // __cplusplus typedef float vec_t; -typedef vec_t vec2_t[2]; -#ifndef DID_VEC3_T_DEFINE +#if !defined(DID_VEC3_T_DEFINE) #define DID_VEC3_T_DEFINE typedef vec_t vec3_t[3]; #endif -typedef vec_t vec4_t[4]; // x,y,z,w -#ifndef M_PI +#if !defined(M_PI) #define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h #endif +#if !defined(M_PI_F) +#define M_PI_F (float)M_PI +#endif + struct mplane_s; extern vec3_t vec3_origin; @@ -39,7 +52,7 @@ extern int nanmask; #define IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask) -#ifndef VECTOR_H +#if !defined(VECTOR_H) #define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2]) #endif diff --git a/common/net_api.h b/common/net_api.h index da18fc30..eccfc86b 100644 --- a/common/net_api.h +++ b/common/net_api.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef NET_API_H +#if !defined(NET_API_H) #define NET_API_H #include "netadr.h" diff --git a/common/netadr.h b/common/netadr.h index 0d70a22b..9f72921d 100644 --- a/common/netadr.h +++ b/common/netadr.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef NETADR_H +#if !defined(NETADR_H) #define NETADR_H typedef enum diff --git a/common/particledef.h b/common/particledef.h index 15c95feb..c8b972e7 100644 --- a/common/particledef.h +++ b/common/particledef.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef PARTICLEDEF_H +#if !defined(PARTICLEDEF_H) #define PARTICLEDEF_H typedef enum diff --git a/common/pmtrace.h b/common/pmtrace.h index d5dd1453..dbf59026 100644 --- a/common/pmtrace.h +++ b/common/pmtrace.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef PM_TRACE_H +#if !defined(PM_TRACE_H) #define PM_TRACE_H typedef struct diff --git a/common/qfont.h b/common/qfont.h index beb36ff9..589a9398 100644 --- a/common/qfont.h +++ b/common/qfont.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef QFONT_H +#if !defined(QFONT_H) #define QFONT_H // Font stuff diff --git a/common/r_efx.h b/common/r_efx.h index 1a55aa0b..0ed52ad3 100644 --- a/common/r_efx.h +++ b/common/r_efx.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef R_EFX_H +#if !defined(R_EFX_H) #define R_EFX_H // particle_t diff --git a/common/r_studioint.h b/common/r_studioint.h index b17e826f..d3cb82f5 100644 --- a/common/r_studioint.h +++ b/common/r_studioint.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef R_STUDIOINT_H +#if !defined(R_STUDIOINT_H) #define R_STUDIOINT_H #define STUDIO_INTERFACE_VERSION 1 diff --git a/common/ref_params.h b/common/ref_params.h index 61527eca..d804f8b8 100644 --- a/common/ref_params.h +++ b/common/ref_params.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef REF_PARAMS_H +#if !defined(REF_PARAMS_H) #define REF_PARAMS_H typedef struct ref_params_s diff --git a/common/render_api.h b/common/render_api.h deleted file mode 100644 index 03973f27..00000000 --- a/common/render_api.h +++ /dev/null @@ -1,261 +0,0 @@ -/* -render_api.h - Xash3D extension for client interface -Copyright (C) 2011 Uncle Mike - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -*/ -#pragma once -#ifndef RENDER_API_H -#define RENDER_API_H - -#include "lightstyle.h" -#include "dlight.h" - -// changes for version 28 -// replace decal_t from software declaration to hardware (matched to normal HL) -// mextrasurf_t->increased limit of reserved fields (up from 7 to 32) -// replace R_StoreEfrags with him extended version -// formed group for BSP decal manipulating -// move misc functions at end of the interface -// added new export for clearing studio decals - -#define CL_RENDER_INTERFACE_VERSION 35 -#define MAX_STUDIO_DECALS 4096 // + unused space of BSP decals - -#define SURF_INFO( surf, mod ) ((mextrasurf_t *)mod->cache.data + (surf - mod->surfaces)) -#define INFO_SURF( surf, mod ) (mod->surfaces + (surf - (mextrasurf_t *)mod->cache.data)) - -// render info parms -#define PARM_TEX_WIDTH 1 // all parms with prefix 'TEX_' receive arg as texnum -#define PARM_TEX_HEIGHT 2 // otherwise it's not used -#define PARM_TEX_SRC_WIDTH 3 -#define PARM_TEX_SRC_HEIGHT 4 -#define PARM_TEX_SKYBOX 5 // second arg as skybox ordering num -#define PARM_TEX_SKYTEXNUM 6 // skytexturenum for quake sky -#define PARM_TEX_LIGHTMAP 7 // second arg as number 0 - 128 -#define PARM_TEX_TARGET 8 -#define PARM_TEX_TEXNUM 9 -#define PARM_TEX_FLAGS 10 -#define PARM_TEX_TYPE 11 -#define PARM_TEX_CACHEFRAME 12 // compare with worldmodel->needload -#define PARM_TEX_GLFORMAT 13 // get a texture GL-format -// reserved -#define PARM_WORLD_VERSION 16 // return the version of bsp -#define PARM_SKY_SPHERE 17 // sky is quake sphere ? -#define PARM_MAP_HAS_MIRRORS 18 // current map has mirorrs -#define PARM_MAP_HAS_DELUXE 19 // map has deluxedata -#define PARM_MAX_ENTITIES 20 -#define PARM_WIDESCREEN 21 -#define PARM_FULLSCREEN 22 -#define PARM_SCREEN_WIDTH 23 -#define PARM_SCREEN_HEIGHT 24 -#define PARM_CLIENT_INGAME 25 -#define PARM_FEATURES 26 // same as movevars->features -#define PARM_ACTIVE_TMU 27 // for debug -#define PARM_CACHEFRAME 28 -#define PARM_MAX_IMAGE_UNITS 29 -#define PARM_CLIENT_ACTIVE 30 -#define PARM_REBUILD_GAMMA 31 // if true lightmaps rebuilding for gamma change - -enum -{ - // skybox ordering - SKYBOX_RIGHT = 0, - SKYBOX_BACK, - SKYBOX_LEFT, - SKYBOX_FORWARD, - SKYBOX_UP, - SKYBOX_DOWN, -}; - -typedef enum -{ - TEX_INVALID = 0, // free slot - TEX_SYSTEM, // generated by engine - TEX_NOMIP, // hud pics, menu etc - TEX_BRUSH, // a map texture - TEX_SPRITE, // sprite frames - TEX_STUDIO, // studio skins - TEX_LIGHTMAP, // lightmap textures - TEX_DECAL, // decals - TEX_VGUI, // vgui fonts or images - TEX_CUBEMAP, // cubemap textures (sky) - TEX_DETAIL, // detail textures - TEX_REMAP, // local copy of remap texture - TEX_SCREENCOPY, // keep screen copy e.g. for mirror - TEX_CUSTOM, // user created texture - TEX_DEPTHMAP // shadowmap texture -} texType_t; - -typedef enum -{ - TF_NEAREST = (1<<0), // disable texfilter - TF_KEEP_RGBDATA = (1<<1), // some images keep source - TF_NOFLIP_TGA = (1<<2), // Steam background completely ignore tga attribute 0x20 - TF_KEEP_8BIT = (1<<3), // keep original 8-bit image (if present) - TF_NOPICMIP = (1<<4), // ignore r_picmip resample rules - TF_UNCOMPRESSED = (1<<5), // don't compress texture in video memory - TF_CUBEMAP = (1<<6), // it's cubemap texture - TF_DEPTHMAP = (1<<7), // custom texture filter used - TF_INTENSITY = (1<<8), // monochrome intensity image - TF_LUMINANCE = (1<<9), // force image to grayscale - TF_SKYSIDE = (1<<10), // this is a part of skybox - TF_CLAMP = (1<<11), // clamp texcoords to [0..1] range - TF_NOMIPMAP = (1<<12), // don't build mips for this image - TF_HAS_LUMA = (1<<13), // sets by GL_UploadTexture - TF_MAKELUMA = (1<<14), // create luma from quake texture (only q1 textures contain luma-pixels) - TF_NORMALMAP = (1<<15), // is a normalmap - TF_HAS_ALPHA = (1<<16), // image has alpha (used only for GL_CreateTexture) - TF_FORCE_COLOR = (1<<17), // force upload monochrome textures as RGB (detail textures) - TF_TEXTURE_1D = (1<<18), // this is GL_TEXTURE_1D - TF_BORDER = (1<<19), // zero clamp for projected textures - TF_TEXTURE_3D = (1<<20), // this is GL_TEXTURE_3D - TF_STATIC = (1<<21), // a marker for purge mechanism (not used by engine) - TF_TEXTURE_RECTANGLE= (1<<22), // this is GL_TEXTURE_RECTANGLE - TF_ALPHA_BORDER = (1<<23), // clamp to (0,0,0,255) (probably no difference) - TF_IMAGE_PROGRAM = (1<<24), // enable image program support like in Doom3 - TF_ALPHACONTRAST = (1<<25), // special texture flags for internal usage - TF_FLOAT = (1<<26), // float textures - TF_NOCOMPARE = (1<<27), // disable comparing for depth textures - TF_FLOATDATA = (1<<28), // incoming dataType has type GL_FLOAT -} texFlags_t; - -typedef struct beam_s BEAM; -typedef struct particle_s particle_t; - -// 12 bytes here -typedef struct modelstate_s -{ - short sequence; - short frame; // 10 bits multiple by 4, should be enough - byte blending[2]; - byte controller[4]; - byte body; - byte skin; -} modelstate_t; - -typedef struct decallist_s -{ - vec3_t position; - char name[64]; - short entityIndex; - byte depth; - byte flags; - float scale; - - // this is the surface plane that we hit so that - // we can move certain decals across - // transitions if they hit similar geometry - vec3_t impactPlaneNormal; - - modelstate_t studio_state; // studio decals only -} decallist_t; - -typedef struct render_api_s -{ - // Get renderer info (doesn't changes engine state at all) - int (*RenderGetParm)( int parm, int arg ); // generic - void (*GetDetailScaleForTexture)( int texture, float *xScale, float *yScale ); - void (*GetExtraParmsForTexture)( int texture, byte *red, byte *green, byte *blue, byte *alpha ); - lightstyle_t* (*GetLightStyle)( int number ); - dlight_t* (*GetDynamicLight)( int number ); - dlight_t* (*GetEntityLight)( int number ); - byte (*TextureToTexGamma)( byte color ); // software gamma support - void (*GetBeamChains)( BEAM ***active_beams, BEAM ***free_beams, particle_t ***free_trails ); - - // Set renderer info (tell engine about changes) - void (*R_SetCurrentEntity)( struct cl_entity_s *ent ); // tell engine about both currententity and currentmodel - void (*R_SetCurrentModel)( struct model_s *mod ); // change currentmodel but leave currententity unchanged - void (*GL_SetWorldviewProjectionMatrix)( const float *glmatrix ); // update viewprojection matrix (tracers uses it) - void (*R_StoreEfrags)( struct efrag_s **ppefrag, int framecount );// store efrags for static entities - - // Texture tools - int (*GL_FindTexture)( const char *name ); - const char* (*GL_TextureName)( unsigned int texnum ); - const byte* (*GL_TextureData)( unsigned int texnum ); // may be NULL - int (*GL_LoadTexture)( const char *name, const byte *buf, size_t size, int flags ); - int (*GL_CreateTexture)( const char *name, int width, int height, const void *buffer, int flags ); - void (*GL_SetTextureType)( unsigned int texnum, unsigned int type ); - void (*GL_TextureCacheFrame)( unsigned int texnum ); - void (*GL_FreeTexture)( unsigned int texnum ); - - // Decals manipulating (draw & remove) - void (*DrawSingleDecal)( struct decal_s *pDecal, struct msurface_s *fa ); - float *(*R_DecalSetupVerts)( struct decal_s *pDecal, struct msurface_s *surf, int texture, int *outCount ); - void (*R_EntityRemoveDecals)( struct model_s *mod ); // remove all the decals from specified entity (BSP only) - - // AVIkit support - void *(*AVI_LoadVideo)( const char *filename, int ignore_hwgamma ); - int (*AVI_GetVideoInfo)( void *Avi, long *xres, long *yres, float *duration ); - long (*AVI_GetVideoFrameNumber)( void *Avi, float time ); - byte *(*AVI_GetVideoFrame)( void *Avi, long frame ); - void (*AVI_UploadRawFrame)( int texture, int cols, int rows, int width, int height, const byte *data ); - void (*AVI_FreeVideo)( void *Avi ); - int (*AVI_IsActive)( void *Avi ); - - // glState related calls (must use this instead of normal gl-calls to prevent de-synchornize local states between engine and the client) - void (*GL_Bind)( int tmu, unsigned int texnum ); - void (*GL_SelectTexture)( int tmu ); - void (*GL_LoadTextureMatrix)( const float *glmatrix ); - void (*GL_TexMatrixIdentity)( void ); - void (*GL_CleanUpTextureUnits)( int last ); // pass 0 for clear all the texture units - void (*GL_TexGen)( unsigned int coord, unsigned int mode ); - void (*GL_TextureTarget)( unsigned int target ); // change texture unit mode without bind texture - void (*GL_TexCoordArrayMode)( unsigned int texmode ); - void (*GL_Reserved0)( void ); // for potential interface expansion without broken compatibility - void (*GL_Reserved1)( void ); - void (*GL_Reserved2)( void ); - void (*GL_Reserved3)( void ); - - // Misc renderer functions - void (*GL_DrawParticles)( const float *vieworg, const float *fwd, const float *rt, const float *up, unsigned int clipFlags ); - void (*EnvShot)( const float *vieworg, const char *name, qboolean skyshot, int shotsize ); // creates a cubemap or skybox into gfx\env folder - int (*COM_CompareFileTime)( const char *filename1, const char *filename2, int *iCompare ); - void (*Host_Error)( const char *error, ... ); // cause Host Error - int (*SPR_LoadExt)( const char *szPicName, unsigned int texFlags ); // extended version of SPR_Load - void (*TessPolygon)( struct msurface_s *surf, struct model_s *mod, float tessSize ); - struct mstudiotex_s *( *StudioGetTexture )( struct cl_entity_s *e ); - const struct ref_overview_s *( *GetOverviewParms )( void ); - void (*S_FadeMusicVolume)( float fadePercent ); // fade background track (0-100 percents) - void (*SetRandomSeed)( long lSeed ); // set custom seed for RANDOM_FLOAT\RANDOM_LONG for predictable random - // static allocations - void *(*pfnMemAlloc)( size_t cb, const char *filename, const int fileline ); - void (*pfnMemFree)( void *mem, const char *filename, const int fileline ); - // find in files - char **(*pfnGetFilesList)( const char *pattern, int *numFiles, int gamedironly ); - // ONLY ADD NEW FUNCTIONS TO THE END OF THIS STRUCT. INTERFACE VERSION IS FROZEN AT 35 -} render_api_t; - -// render callbacks -typedef struct render_interface_s -{ - int version; - // passed through R_RenderFrame (0 - use engine renderer, 1 - use custom client renderer) - int (*GL_RenderFrame)( const struct ref_params_s *pparams, qboolean drawWorld ); - // build all the lightmaps on new level or when gamma is changed - void (*GL_BuildLightmaps)( void ); - // setup map bounds for ortho-projection when we in dev_overview mode - void (*GL_OrthoBounds)( const float *mins, const float *maxs ); - // handle decals which hit mod_studio or mod_sprite - void (*R_StudioDecalShoot)( int decalTexture, struct cl_entity_s *ent, const float *start, const float *pos, int flags, modelstate_t *state ); - // prepare studio decals for save - int (*R_CreateStudioDecalList)( decallist_t *pList, int count, qboolean changelevel ); - // clear decals by engine request (e.g. for demo recording or vid_restart) - void (*R_ClearStudioDecals)( void ); - // grab r_speeds message - qboolean (*R_SpeedsMessage)( char *out, size_t size ); - // replace with built-in R_DrawCubemapView for make skyshots or envshots - qboolean (*R_DrawCubemapView)( const float *origin, const float *angles, int size ); - // alloc or destroy studiomodel custom data - void (*Mod_ProcessUserData)( struct model_s *mod, qboolean create, const byte *buffer ); -} render_interface_t; - -#endif//RENDER_API_H diff --git a/common/screenfade.h b/common/screenfade.h index 1611f914..8555e812 100644 --- a/common/screenfade.h +++ b/common/screenfade.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef SCREENFADE_H +#if !defined(SCREENFADE_H) #define SCREENFADE_H typedef struct screenfade_s diff --git a/common/studio_event.h b/common/studio_event.h index cf21e82a..33878a69 100644 --- a/common/studio_event.h +++ b/common/studio_event.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef STUDIO_EVENT_H +#if !defined(STUDIO_EVENT_H) #define STUDIO_EVENT_H typedef struct mstudioevent_s diff --git a/common/triangleapi.h b/common/triangleapi.h index 49dc919f..801154e3 100644 --- a/common/triangleapi.h +++ b/common/triangleapi.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef TRIANGLEAPI_H +#if !defined(TRIANGLEAPI_H) #define TRIANGLEAPI_H typedef enum diff --git a/common/usercmd.h b/common/usercmd.h index 538c60a6..581662b7 100644 --- a/common/usercmd.h +++ b/common/usercmd.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef USERCMD_H +#if !defined(USERCMD_H) #define USERCMD_H typedef struct usercmd_s diff --git a/common/wadfile.h b/common/wadfile.h index 84ffbb2d..a3b8efeb 100644 --- a/common/wadfile.h +++ b/common/wadfile.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef WADFILE_H +#if !defined(WADFILE_H) #define WADFILE_H /* diff --git a/common/weaponinfo.h b/common/weaponinfo.h index b94857b6..8625103a 100644 --- a/common/weaponinfo.h +++ b/common/weaponinfo.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef WEAPONINFO_H +#if !defined(WEAPONINFO_H) #define WEAPONINFO_H // Info about weapons player might have in his/her possession diff --git a/common/winsani_in.h b/common/winsani_in.h new file mode 100644 index 00000000..d8c85271 --- /dev/null +++ b/common/winsani_in.h @@ -0,0 +1,7 @@ +#if _MSC_VER >= 1500 // MSVC++ 9.0 (Visual Studio 2008) +#pragma push_macro("ARRAYSIZE") +#ifdef ARRAYSIZE +#undef ARRAYSIZE +#endif +#define HSPRITE WINDOWS_HSPRITE +#endif diff --git a/common/winsani_out.h b/common/winsani_out.h new file mode 100644 index 00000000..27269500 --- /dev/null +++ b/common/winsani_out.h @@ -0,0 +1,4 @@ +#if _MSC_VER >= 1500 // MSVC++ 9.0 (Visual Studio 2008) +#undef HSPRITE +#pragma pop_macro("ARRAYSIZE") +#endif diff --git a/common/wrect.h b/common/wrect.h deleted file mode 100644 index 51e84d88..00000000 --- a/common/wrect.h +++ /dev/null @@ -1,24 +0,0 @@ -/* -wrect.h - rectangle definition -Copyright (C) 2010 Uncle Mike - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -*/ -#pragma once -#ifndef WRECT_H -#define WRECT_H - -typedef struct wrect_s -{ - int left, right, top, bottom; -} wrect_t; - -#endif//WRECT_H diff --git a/contrib/iZarif/premake5.lua b/contrib/iZarif/premake5.lua new file mode 100644 index 00000000..91817da5 --- /dev/null +++ b/contrib/iZarif/premake5.lua @@ -0,0 +1,347 @@ +local xash = require("xash") + +workspace("hlsdk-xash3d") +configurations{"Debug", "Release"} +language("C++") +kind("SharedLib") +rtti("Off") +exceptionhandling("Off") +pic("On") +targetprefix("") + +files{"pm_shared/pm_debug.c", +"pm_shared/pm_math.c", +"pm_shared/pm_shared.c", +"dlls/crossbow.cpp", +"dlls/crowbar.cpp", +"dlls/egon.cpp", +"dlls/gauss.cpp", +"dlls/glock.cpp", +"dlls/handgrenade.cpp", +"dlls/hornetgun.cpp", +"dlls/mp5.cpp", +"dlls/python.cpp", +"dlls/rpg.cpp", +"dlls/satchel.cpp", +"dlls/shotgun.cpp", +"dlls/squeakgrenade.cpp", +"dlls/tripmine.cpp"} + +includedirs{"dlls", +"common", +"engine", +"pm_shared", +"game_shared"} + +defines{"BARNACLE_FIX_VISIBILITY=0", +"CLIENT_WEAPONS=1", +"CROWBAR_IDLE_ANIM=0", +"CROWBAR_DELAY_FIX=0", +"CROWBAR_FIX_RAPID_CROWBAR=0", +"GAUSS_OVERCHARGE_FIX=0", +"OEM_BUILD=0", +"HLDEMO_BUILD=0"} + +newoption{trigger = "toolset-prefix", description = "Prefix for crosscompiler (should contain the final dash)"} + +xash.prefix = _OPTIONS["toolset-prefix"] +xash.find_cxx_compiler() + +newoption{trigger = "64bits", description = "Allow targetting 64-bit engine", default = false} +newoption{trigger = "voicemgr", description = "Enable voice manager", default = false} +newoption{trigger = "goldsrc", description = "Enable GoldSource engine support", default = false} +newoption{trigger = "lto", description = "Enable Link Time Optimization", default = false} + +newoption{trigger = "arch", description = "Destination arch", default = xash.get_arch(), allowed = { + {"amd64", ""}, + {"x86", ""}, + {"arm64", ""}, + {"armv8_32l", ""}, + {"armv7l", ""}, + {"armv6l", ""}, + {"armv5l", ""}, + {"armv4l", ""}, + {"armv8_32hf", ""}, + {"armv7hf", ""}, + {"armv6hf", ""}, + {"armv5hf", ""}, + {"armv4hf", ""}, + {"mips64", ""}, + {"mipsel", ""}, + {"riscv32d", ""}, + {"riscv32f", ""}, + {"riscv64d", ""}, + {"riscv64f", ""}, + {"javascript", ""}, + {"e2k", ""} +}} + +newoption{trigger = "bsd-flavour", description = "BSD flavour", allowed = { + {"freebsd", ""}, + {"openbsd", ""}, + {"netbsd", ""} +}} + +newoption{trigger = "vgui", description = "Enable VGUI1", default = false} +newoption{trigger = "novgui-motd", description = "Prefer non-VGUI MOTD when VGUI is enabled", default = false} +newoption{trigger = "novgui-scoreboard", description = "Prefer non-VGUI scoreboard when VGUI is enabled", default = false} + +xash.bsd_flavour = _OPTIONS["bsd-flavour"] + +if xash.is_cxx_header_exist("tgmath.h") then + defines{"HAVE_TGMATH_H"} +end + +if xash.is_cxx_header_exist("cmath") then + defines{"HAVE_CMATH"} +end + +if xash.prefix then + gccprefix(xash.prefix) +end + +if _OPTIONS["arch"] == "amd64" then + if not _OPTIONS["64bits"] then + xash.arch = "x86" + architecture(xash.arch) + end +end + +targetsuffix(xash.get_lib_suffix()) + +filter("options:lto") +flags{"LinkTimeOptimization"} + +filter("configurations:Release") +optimize("Full") +symbols("Off") +omitframepointer("On") + +filter("configurations:Debug") +optimize("Off") +symbols("On") +omitframepointer("Off") + +filter("toolset:msc") +buildoptions{"/D_USING_V110_SDK71_", "/Zc:threadSafeInit-"} +defines{"_CRT_SECURE_NO_WARNINGS=1", "_CRT_NONSTDC_NO_DEPRECATE=1"} + +filter("toolset:not msc") +visibility("Hidden") +defines{"stricmp=strcasecmp", +"strnicmp=strncasecmp", +"_snprintf=snprintf", +"_vsnprintf=vsnprintf", +"_LINUX", +"LINUX"} + +project("dlls") +targetname("hl") + +files{"dlls/agrunt.cpp", +"dlls/airtank.cpp", +"dlls/aflock.cpp", +"dlls/animating.cpp", +"dlls/animation.cpp", +"dlls/apache.cpp", +"dlls/barnacle.cpp", +"dlls/barney.cpp", +"dlls/bigmomma.cpp", +"dlls/bloater.cpp", +"dlls/bmodels.cpp", +"dlls/bullsquid.cpp", +"dlls/buttons.cpp", +"dlls/cbase.cpp", +"dlls/client.cpp", +"dlls/combat.cpp", +"dlls/controller.cpp", +"dlls/defaultai.cpp", +"dlls/doors.cpp", +"dlls/effects.cpp", +"dlls/explode.cpp", +"dlls/flyingmonster.cpp", +"dlls/func_break.cpp", +"dlls/func_tank.cpp", +"dlls/game.cpp", +"dlls/gamerules.cpp", +"dlls/gargantua.cpp", +"dlls/genericmonster.cpp", +"dlls/ggrenade.cpp", +"dlls/globals.cpp", +"dlls/gman.cpp", +"dlls/h_ai.cpp", +"dlls/h_battery.cpp", +"dlls/h_cine.cpp", +"dlls/h_cycler.cpp", +"dlls/h_export.cpp", +"dlls/hassassin.cpp", +"dlls/headcrab.cpp", +"dlls/healthkit.cpp", +"dlls/hgrunt.cpp", +"dlls/hornet.cpp", +"dlls/houndeye.cpp", +"dlls/ichthyosaur.cpp", +"dlls/islave.cpp", +"dlls/items.cpp", +"dlls/leech.cpp", +"dlls/lights.cpp", +"dlls/maprules.cpp", +"dlls/monstermaker.cpp", +"dlls/monsters.cpp", +"dlls/monsterstate.cpp", +"dlls/mortar.cpp", +"dlls/multiplay_gamerules.cpp", +"dlls/nihilanth.cpp", +"dlls/nodes.cpp", +"dlls/observer.cpp", +"dlls/osprey.cpp", +"dlls/pathcorner.cpp", +"dlls/plane.cpp", +"dlls/plats.cpp", +"dlls/player.cpp", +"dlls/playermonster.cpp", +"dlls/rat.cpp", +"dlls/roach.cpp", +"dlls/schedule.cpp", +"dlls/scientist.cpp", +"dlls/scripted.cpp", +"dlls/singleplay_gamerules.cpp", +"dlls/skill.cpp", +"dlls/sound.cpp", +"dlls/soundent.cpp", +"dlls/spectator.cpp", +"dlls/squadmonster.cpp", +"dlls/subs.cpp", +"dlls/talkmonster.cpp", +"dlls/teamplay_gamerules.cpp", +"dlls/tempmonster.cpp", +"dlls/tentacle.cpp", +"dlls/triggers.cpp", +"dlls/turret.cpp", +"dlls/util.cpp", +"dlls/weapons.cpp", +"dlls/world.cpp", +"dlls/xen.cpp", +"dlls/zombie.cpp"} + +includedirs{"public"} + +filter("options:voicemgr") +files{"game_shared/voice_gamemgr.cpp"} + +filter("options:not voicemgr") +defines{"NO_VOICEGAMEMGR"} + +filter("toolset:msc") +buildoptions{"/def:" .. path.getabsolute("dlls/hl.def")} + +project("cl_dll") +targetname("client") + +files{"cl_dll/hl/hl_baseentity.cpp", +"cl_dll/hl/hl_events.cpp", +"cl_dll/hl/hl_objects.cpp", +"cl_dll/hl/hl_weapons.cpp", +"cl_dll/GameStudioModelRenderer.cpp", +"cl_dll/StudioModelRenderer.cpp", +"cl_dll/ammo.cpp", +"cl_dll/ammo_secondary.cpp", +"cl_dll/ammohistory.cpp", +"cl_dll/battery.cpp", +"cl_dll/cdll_int.cpp", +"cl_dll/com_weapons.cpp", +"cl_dll/death.cpp", +"cl_dll/demo.cpp", +"cl_dll/entity.cpp", +"cl_dll/ev_hldm.cpp", +"cl_dll/ev_common.cpp", +"cl_dll/events.cpp", +"cl_dll/flashlight.cpp", +"cl_dll/geiger.cpp", +"cl_dll/health.cpp", +"cl_dll/hud.cpp", +"cl_dll/hud_msg.cpp", +"cl_dll/hud_redraw.cpp", +"cl_dll/hud_spectator.cpp", +"cl_dll/hud_update.cpp", +"cl_dll/in_camera.cpp", +"cl_dll/input.cpp", +"cl_dll/input_goldsource.cpp", +"cl_dll/input_mouse.cpp", +"cl_dll/input_xash3d.cpp", +"cl_dll/menu.cpp", +"cl_dll/message.cpp", +"cl_dll/overview.cpp", +"cl_dll/parsemsg.cpp", +"cl_dll/saytext.cpp", +"cl_dll/status_icons.cpp", +"cl_dll/statusbar.cpp", +"cl_dll/studio_util.cpp", +"cl_dll/text_message.cpp", +"cl_dll/train.cpp", +"cl_dll/tri.cpp", +"cl_dll/util.cpp", +"cl_dll/view.cpp"} + +includedirs{"cl_dll", +"cl_dll/hl"} + +defines{"CLIENT_DLL"} + +filter("options:goldsrc") +defines{"GOLDSOURCE_SUPPORT"} + +filter("options:vgui") +files{"cl_dll/vgui_int.cpp", +"cl_dll/vgui_ClassMenu.cpp", +"cl_dll/vgui_ConsolePanel.cpp", +"cl_dll/vgui_ControlConfigPanel.cpp", +"cl_dll/vgui_CustomObjects.cpp", +"cl_dll/vgui_MOTDWindow.cpp", +"cl_dll/vgui_SchemeManager.cpp", +"cl_dll/vgui_ScorePanel.cpp", +"cl_dll/vgui_TeamFortressViewport.cpp", +"cl_dll/vgui_SpectatorPanel.cpp", +"cl_dll/vgui_teammenu.cpp", +"cl_dll/voice_status.cpp", +"game_shared/vgui_checkbutton2.cpp", +"game_shared/vgui_grid.cpp", +"game_shared/vgui_helpers.cpp", +"game_shared/vgui_listbox.cpp", +"game_shared/vgui_loadtga.cpp", +"game_shared/vgui_scrollbar2.cpp", +"game_shared/vgui_slider2.cpp", +"game_shared/voice_banmgr.cpp"} +includedirs{"vgui-dev/include"} +defines{"USE_VGUI"} + +filter{"options:vgui", "system:windows"} +libdirs{"vgui-dev/lib/win32_vc6/"} + +filter{"options:vgui", "system:macosx"} +libdirs{"vgui-dev/lib"} + +filter{"options:vgui", "system:windows or macosx"} +links{"vgui"} + +filter{"options:vgui", "system:not windows or not macosx"} +linkoptions{path.getabsolute("vgui-dev/lib/vgui.so")} + +filter{"options:vgui", "options:novgui-motd"} +defines{"USE_NOVGUI_MOTD"} +files{"cl_dll/MOTD.cpp"} + +filter{"options:vgui", "options:novgui-scoreboard"} +defines{"USE_NOVGUI_SCOREBOARD"} +files{"cl_dll/scoreboard.cpp"} + +filter("options:not vgui") +files{"cl_dll/MOTD.cpp", +"cl_dll/scoreboard.cpp"} +includedirs{"utils/false_vgui/include"} + +filter("system:windows") +links{"user32", "winmm"} + +filter("system:not windows") +links{"dl"} diff --git a/contrib/iZarif/xash.lua b/contrib/iZarif/xash.lua new file mode 100644 index 00000000..0388602d --- /dev/null +++ b/contrib/iZarif/xash.lua @@ -0,0 +1,240 @@ +local m = {} +local toolsets = {gcc = {}, clang = {}, mingw = {}, msc = {}} +local toolset = nil +local cxx = nil + +function toolsets.gcc.is_cxx_compileable(code, include_dirs) + local include_dirs = include_dirs or {} + local code_file_path = _MAIN_SCRIPT_DIR .. "/tmp.cpp" + local code_file = io.open(code_file_path, "w") + + code_file:write(code) + code_file:close() + + local include_dirs_str = "" + + for _, include_dir in ipairs(include_dirs) do + include_dirs_str = include_dirs_str .. "-I" .. include_dir + end + + local cmd = string.format("%s %s -c %s", cxx, include_dirs_str, code_file_path) + local _, _, rc = os.execute(cmd) + local result = false + + if rc == 0 then + result = true + end + + return result +end + +function toolsets.msc.is_cxx_compileable(code, include_dirs) + local include_dirs = include_dirs or {} + local code_file_path = _XASHAIN_SCRIPT_DIR .. "/tmp.cpp" + local code_file = io.open(code_file_path, "w") + + code_file:write(code) + code_file:close() + + local include_dirs_str = "" + + for _, include_dir in ipairs(include_dirs) do + include_dirs_str = include_dirs_str .. "/I" .. include_dir + end + + local cmd = string.format("%s %s /c %s", cxx, include_dirs_str, code_file_path) + local _, _, rc = os.execute(cmd) + local result = false + + if rc == 0 then + result = true + end + + return result +end + +toolsets.clang.is_cxx_compileable = toolsets.gcc.is_cxx_compileable +toolsets.mingw.is_cxx_compileable = toolsets.gcc.is_cxx_compileable + +function m.is_cxx_symbol_defined(symbol, headers, include_dirs) + local headers = headers or {} + local include_dirs = include_dirs or {} + local code = "" + + for _, header in ipairs(headers) do + code = code .. string.format("#include <%s>\n", header) + end + + code = code .. string.format("#ifndef %s\n.\n#endif", symbol) + + return m.is_cxx_compileable(code, include_dirs) +end + +function m.is_cxx_header_exist(header, include_dirs) + local include_dirs = include_dirs or {} + local code = "" + + code = code .. string.format("#include <%s>\n", header) + + return m.is_cxx_compileable(code, include_dirs) +end + +function m.get_arch() + local arch = m.arch + + if not arch then + if m.is_cxx_symbol_defined("XASH_AMD64", {"build.h"}, {"public"}) then + arch = "amd64" + elseif m.is_cxx_symbol_defined("XASH_X86", {"build.h"}, {"public"}) then + arch = "x86" + elseif m.is_cxx_symbol_defined("XASH_ARM", {"build.h"}, {"public"}) then + if m.is_cxx_symbol_defined("XASH_64BIT", {"build.h"}, {"public"}) then + arch = "arm64" + else + arch = "armv" + + if m.is_cxx_symbol_defined("XASH_ARMv8", {"build.h"}, {"public"}) then + arch = arch .. "8_32" + elseif m.is_cxx_symbol_defined("XASH_ARMv7", {"build.h"}, {"public"}) then + arch = arch .. "7" + elseif m.is_cxx_symbol_defined("XASH_ARMv6", {"build.h"}, {"public"}) then + arch = arch .. "6" + elseif m.is_cxx_symbol_defined("XASH_ARMv5", {"build.h"}, {"public"}) then + arch = arch .. "5" + elseif m.is_cxx_symbol_defined("XASH_ARMv4", {"build.h"}, {"public"}) then + arch = arch .. "4" + end + + if m.is_cxx_symbol_defined("XASH_ARM_HARDFP", {"build.h"}, {"public"}) then + arch = arch .. "hf" + else + arch = arch .. "l" + end + end + elseif m.is_cxx_symbol_defined("XASH_MIPS", {"build.h"}, {"public"}) then + arch = "mips" + + if m.is_cxx_symbol_defined("XASH_64BIT", {"build.h"}, {"public"}) then + arch = arch .. "64" + end + + if m.is_cxx_symbol_defined("XASH_LITTLE_ENDIAN", {"build.h"}, {"public"}) then + arch = arch .. "el" + end + elseif m.is_cxx_symbol_defined("XASH_RISCV", {"build.h"}, {"public"}) then + arch = "riscv" + + if m.is_cxx_symbol_defined("XASH_64BIT", {"build.h"}, {"public"}) then + arch = arch .. "64" + else + arch = arch .. "32" + end + + if m.is_cxx_symbol_defined("XASH_RISCV_DOUBLEFP", {"build.h"}, {"public"}) then + arch = arch .. "d" + else + arch = arch .. "f" + end + elseif m.is_cxx_symbol_defined("XASH_JS", {"build.h"}, {"public"}) then + arch = "javascript" + elseif m.is_cxx_symbol_defined("XASH_E2K", {"build.h"}, {"public"}) then + arch = "e2k" + end + end + + return arch +end + +function m.get_os() + local dest_os = os.target() + + if dest_os == "bsd" then + dest_os = m.bsd_flavour + + if not dest_os then + if m.is_cxx_symbol_defined("XASH_FREEBSD", {"build.h"}, {"public"}) then + dest_os = "freebsd" + elseif m.is_cxx_symbol_defined("XASH_NETBSD", {"build.h"}, {"public"}) then + dest_os = "netbsd" + elseif m.is_cxx_symbol_defined("XASH_OPENBSD", {"build.h"}, {"public"}) then + dest_os = "openbsd" + end + end + end + + return dest_os +end + +function m.get_lib_suffix() + local dest_os = m.get_os() + local arch = m.get_arch() + + if dest_os == "windows" or dest_os == "linux" or dest_os == "macosx" then + dest_os = nil + elseif dest_os == "android" then + dest_os = nil + arch = nil + end + + if arch == "x86" then + arch = nil + end + + local suffix = "" + + if dest_os and arch then + suffix = string.format("%s_%s", dest_os, arch) + elseif arch then + suffix = string.format("_%s", arch) + end + + return suffix +end + +function m.find_cxx_compiler() + local prefix = m.prefix or "" + local host_os = os.host() + + toolset = _OPTIONS["cc"] + + if not toolset then + if host_os == "windows" then + toolset = "msc" + elseif host_os == "macosx" then + toolset = "clang" + else + toolset = "gcc" + end + end + + if toolset == "gcc" or "mingw" then + cxx = prefix .. "g++" + elseif toolset == "clang" then + cxx = prefix .. "clang++" + elseif toolset == "msc" then + cxx = "cl.exe" + end + + local is_found = false + + if cxx then + local cmd = "" + + if toolset == "msc" then + cmd = cxx .. " /HELP" + else + cmd = cxx .. " --help" + end + + _, _, rc = os.execute(cmd) + + if rc == 0 then + is_found = true + m.is_cxx_compileable = toolsets[toolset].is_cxx_compileable + end + end + + return is_found +end + +return m diff --git a/dlls/AI_BaseNPC_Schedule.cpp b/dlls/AI_BaseNPC_Schedule.cpp deleted file mode 100644 index 468bb358..00000000 --- a/dlls/AI_BaseNPC_Schedule.cpp +++ /dev/null @@ -1,1514 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* This source code contains proprietary and confidential information of -* Valve LLC and its suppliers. Access to this code is restricted to -* persons who have executed a written SDK license with Valve. Any access, -* use or distribution of this code by or to any unlicensed person is illegal. -* -****/ -//========================================================= -// schedule.cpp - functions and data pertaining to the -// monsters' AI scheduling system. -//========================================================= -#include "extdll.h" -#include "util.h" -#include "cbase.h" -#include "monsters.h" -#include "animation.h" -#include "scripted.h" -#include "nodes.h" -#include "defaultai.h" -#include "soundent.h" - -extern CGraph WorldGraph; - -//========================================================= -// FHaveSchedule - Returns TRUE if monster's m_pSchedule -// is anything other than NULL. -//========================================================= -BOOL CBaseMonster :: FHaveSchedule( void ) -{ - if ( m_pSchedule == NULL ) - { - return FALSE; - } - - return TRUE; -} - -//========================================================= -// ClearSchedule - blanks out the caller's schedule pointer -// and index. -//========================================================= -void CBaseMonster :: ClearSchedule( void ) -{ - m_iTaskStatus = TASKSTATUS_NEW; - m_pSchedule = NULL; - m_iScheduleIndex = 0; -} - -//========================================================= -// FScheduleDone - Returns TRUE if the caller is on the -// last task in the schedule -//========================================================= -BOOL CBaseMonster :: FScheduleDone ( void ) -{ - ASSERT( m_pSchedule != NULL ); - - if ( m_iScheduleIndex == m_pSchedule->cTasks ) - { - return TRUE; - } - - return FALSE; -} - -//========================================================= -// ChangeSchedule - replaces the monster's schedule pointer -// with the passed pointer, and sets the ScheduleIndex back -// to 0 -//========================================================= -void CBaseMonster :: ChangeSchedule ( Schedule_t *pNewSchedule ) -{ - ASSERT( pNewSchedule != NULL ); - - m_pSchedule = pNewSchedule; - m_iScheduleIndex = 0; - m_iTaskStatus = TASKSTATUS_NEW; - m_afConditions = 0;// clear all of the conditions - m_failSchedule = SCHED_NONE; - - if ( m_pSchedule->iInterruptMask & bits_COND_HEAR_SOUND && !(m_pSchedule->iSoundMask) ) - { - ALERT ( at_aiconsole, "COND_HEAR_SOUND with no sound mask!\n" ); - } - else if ( m_pSchedule->iSoundMask && !(m_pSchedule->iInterruptMask & bits_COND_HEAR_SOUND) ) - { - ALERT ( at_aiconsole, "Sound mask without COND_HEAR_SOUND!\n" ); - } - -#if _DEBUG - if ( !ScheduleFromName( pNewSchedule->pName ) ) - { - ALERT( at_console, "Schedule %s not in table!!!\n", pNewSchedule->pName ); - } -#endif - -// this is very useful code if you can isolate a test case in a level with a single monster. It will notify -// you of every schedule selection the monster makes. -#if 0 - if ( FClassnameIs( pev, "monster_human_grunt" ) ) - { - Task_t *pTask = GetTask(); - - if ( pTask ) - { - const char *pName = NULL; - - if ( m_pSchedule ) - { - pName = m_pSchedule->pName; - } - else - { - pName = "No Schedule"; - } - - if ( !pName ) - { - pName = "Unknown"; - } - - ALERT( at_aiconsole, "%s: picked schedule %s\n", STRING( pev->classname ), pName ); - } - } -#endif// 0 - -} - -//========================================================= -// NextScheduledTask - increments the ScheduleIndex -//========================================================= -void CBaseMonster :: NextScheduledTask ( void ) -{ - ASSERT( m_pSchedule != NULL ); - - m_iTaskStatus = TASKSTATUS_NEW; - m_iScheduleIndex++; - - if ( FScheduleDone() ) - { - // just completed last task in schedule, so make it invalid by clearing it. - SetConditions( bits_COND_SCHEDULE_DONE ); - //ClearSchedule(); - } -} - -//========================================================= -// IScheduleFlags - returns an integer with all Conditions -// bits that are currently set and also set in the current -// schedule's Interrupt mask. -//========================================================= -int CBaseMonster :: IScheduleFlags ( void ) -{ - if( !m_pSchedule ) - { - return 0; - } - - // strip off all bits excepts the ones capable of breaking this schedule. - return m_afConditions & m_pSchedule->iInterruptMask; -} - -//========================================================= -// FScheduleValid - returns TRUE as long as the current -// schedule is still the proper schedule to be executing, -// taking into account all conditions -//========================================================= -BOOL CBaseMonster :: FScheduleValid ( void ) -{ - if ( m_pSchedule == NULL ) - { - // schedule is empty, and therefore not valid. - return FALSE; - } - - if ( HasConditions( m_pSchedule->iInterruptMask | bits_COND_SCHEDULE_DONE | bits_COND_TASK_FAILED ) ) - { -#ifdef DEBUG - if ( HasConditions ( bits_COND_TASK_FAILED ) && m_failSchedule == SCHED_NONE ) - { - // fail! Send a visual indicator. - ALERT ( at_aiconsole, "Schedule: %s Failed\n", m_pSchedule->pName ); - - Vector tmp = pev->origin; - tmp.z = pev->absmax.z + 16; - UTIL_Sparks( tmp ); - } -#endif // DEBUG - - // some condition has interrupted the schedule, or the schedule is done - return FALSE; - } - - return TRUE; -} - -//========================================================= -// MaintainSchedule - does all the per-think schedule maintenance. -// ensures that the monster leaves this function with a valid -// schedule! -//========================================================= -void CBaseMonster :: MaintainSchedule ( void ) -{ - Schedule_t *pNewSchedule; - int i; - - // UNDONE: Tune/fix this 10... This is just here so infinite loops are impossible - for ( i = 0; i < 10; i++ ) - { - if ( m_pSchedule != NULL && TaskIsComplete() ) - { - NextScheduledTask(); - } - - // validate existing schedule - if ( !FScheduleValid() || m_MonsterState != m_IdealMonsterState ) - { - // if we come into this block of code, the schedule is going to have to be changed. - // if the previous schedule was interrupted by a condition, GetIdealState will be - // called. Else, a schedule finished normally. - - // Notify the monster that his schedule is changing - ScheduleChange(); - - // Call GetIdealState if we're not dead and one or more of the following... - // - in COMBAT state with no enemy (it died?) - // - conditions bits (excluding SCHEDULE_DONE) indicate interruption, - // - schedule is done but schedule indicates it wants GetIdealState called - // after successful completion (by setting bits_COND_SCHEDULE_DONE in iInterruptMask) - // DEAD & SCRIPT are not suggestions, they are commands! - if ( m_IdealMonsterState != MONSTERSTATE_DEAD && - (m_IdealMonsterState != MONSTERSTATE_SCRIPT || m_IdealMonsterState == m_MonsterState) ) - { - if ( (m_afConditions && !HasConditions(bits_COND_SCHEDULE_DONE)) || - (m_pSchedule && (m_pSchedule->iInterruptMask & bits_COND_SCHEDULE_DONE)) || - ((m_MonsterState == MONSTERSTATE_COMBAT) && (m_hEnemy == NULL)) ) - { - GetIdealState(); - } - } - if ( HasConditions( bits_COND_TASK_FAILED ) && m_MonsterState == m_IdealMonsterState ) - { - if ( m_failSchedule != SCHED_NONE ) - pNewSchedule = GetScheduleOfType( m_failSchedule ); - else - pNewSchedule = GetScheduleOfType( SCHED_FAIL ); - // schedule was invalid because the current task failed to start or complete - ALERT ( at_aiconsole, "Schedule Failed at %d!\n", m_iScheduleIndex ); - ChangeSchedule( pNewSchedule ); - } - else - { - SetState( m_IdealMonsterState ); - if ( m_MonsterState == MONSTERSTATE_SCRIPT || m_MonsterState == MONSTERSTATE_DEAD ) - pNewSchedule = CBaseMonster::GetSchedule(); - else - pNewSchedule = GetSchedule(); - ChangeSchedule( pNewSchedule ); - } - } - - if ( m_iTaskStatus == TASKSTATUS_NEW ) - { - Task_t *pTask = GetTask(); - ASSERT( pTask != NULL ); - TaskBegin(); - StartTask( pTask ); - } - - // UNDONE: Twice?!!! - if ( m_Activity != m_IdealActivity ) - { - SetActivity ( m_IdealActivity ); - } - - if ( !TaskIsComplete() && m_iTaskStatus != TASKSTATUS_NEW ) - break; - } - - if ( TaskIsRunning() ) - { - Task_t *pTask = GetTask(); - ASSERT( pTask != NULL ); - RunTask( pTask ); - } - - // UNDONE: We have to do this so that we have an animation set to blend to if RunTask changes the animation - // RunTask() will always change animations at the end of a script! - // Don't do this twice - if ( m_Activity != m_IdealActivity ) - { - SetActivity ( m_IdealActivity ); - } -} - -//========================================================= -// RunTask -//========================================================= -void CBaseMonster :: RunTask ( Task_t *pTask ) -{ - switch ( pTask->iTask ) - { - case TASK_TURN_RIGHT: - case TASK_TURN_LEFT: - { - ChangeYaw( pev->yaw_speed ); - - if ( FacingIdeal() ) - { - TaskComplete(); - } - break; - } - - case TASK_PLAY_SEQUENCE_FACE_ENEMY: - case TASK_PLAY_SEQUENCE_FACE_TARGET: - { - CBaseEntity *pTarget; - - if ( pTask->iTask == TASK_PLAY_SEQUENCE_FACE_TARGET ) - pTarget = m_hTargetEnt; - else - pTarget = m_hEnemy; - if ( pTarget ) - { - pev->ideal_yaw = UTIL_VecToYaw( pTarget->pev->origin - pev->origin ); - ChangeYaw( pev->yaw_speed ); - } - if ( m_fSequenceFinished ) - TaskComplete(); - } - break; - - case TASK_PLAY_SEQUENCE: - case TASK_PLAY_ACTIVE_IDLE: - { - if ( m_fSequenceFinished ) - { - TaskComplete(); - } - break; - } - - - case TASK_FACE_ENEMY: - { - MakeIdealYaw( m_vecEnemyLKP ); - - ChangeYaw( pev->yaw_speed ); - - if ( FacingIdeal() ) - { - TaskComplete(); - } - break; - } - case TASK_FACE_HINTNODE: - case TASK_FACE_LASTPOSITION: - case TASK_FACE_TARGET: - case TASK_FACE_IDEAL: - case TASK_FACE_ROUTE: - { - ChangeYaw( pev->yaw_speed ); - - if ( FacingIdeal() ) - { - TaskComplete(); - } - break; - } - case TASK_WAIT_PVS: - { - if ( !FNullEnt(FIND_CLIENT_IN_PVS(edict())) ) - { - TaskComplete(); - } - break; - } - case TASK_WAIT_INDEFINITE: - { - // don't do anything. - break; - } - case TASK_WAIT: - case TASK_WAIT_RANDOM: - { - if ( gpGlobals->time >= m_flWaitFinished ) - { - TaskComplete(); - } - break; - } - case TASK_WAIT_FACE_ENEMY: - { - MakeIdealYaw ( m_vecEnemyLKP ); - ChangeYaw( pev->yaw_speed ); - - if ( gpGlobals->time >= m_flWaitFinished ) - { - TaskComplete(); - } - break; - } - case TASK_MOVE_TO_TARGET_RANGE: - { - float distance; - - if ( m_hTargetEnt == NULL ) - TaskFail(); - else - { - distance = ( m_vecMoveGoal - pev->origin ).Length2D(); - // Re-evaluate when you think your finished, or the target has moved too far - if ( (distance < pTask->flData) || (m_vecMoveGoal - m_hTargetEnt->pev->origin).Length() > pTask->flData * 0.5 ) - { - m_vecMoveGoal = m_hTargetEnt->pev->origin; - distance = ( m_vecMoveGoal - pev->origin ).Length2D(); - FRefreshRoute(); - } - - // Set the appropriate activity based on an overlapping range - // overlap the range to prevent oscillation - if ( distance < pTask->flData ) - { - TaskComplete(); - RouteClear(); // Stop moving - } - else if ( distance < 190 && m_movementActivity != ACT_WALK ) - m_movementActivity = ACT_WALK; - else if ( distance >= 270 && m_movementActivity != ACT_RUN ) - m_movementActivity = ACT_RUN; - } - - break; - } - case TASK_WAIT_FOR_MOVEMENT: - { - if (MovementIsComplete()) - { - TaskComplete(); - RouteClear(); // Stop moving - } - break; - } - case TASK_DIE: - { - if ( m_fSequenceFinished && pev->frame >= 255 ) - { - pev->deadflag = DEAD_DEAD; - - SetThink( NULL ); - StopAnimation(); - - if ( !BBoxFlat() ) - { - // a bit of a hack. If a corpses' bbox is positioned such that being left solid so that it can be attacked will - // block the player on a slope or stairs, the corpse is made nonsolid. -// pev->solid = SOLID_NOT; - UTIL_SetSize ( pev, Vector ( -4, -4, 0 ), Vector ( 4, 4, 1 ) ); - } - else // !!!HACKHACK - put monster in a thin, wide bounding box until we fix the solid type/bounding volume problem - UTIL_SetSize ( pev, Vector ( pev->mins.x, pev->mins.y, pev->mins.z ), Vector ( pev->maxs.x, pev->maxs.y, pev->mins.z + 1 ) ); - - if ( ShouldFadeOnDeath() ) - { - // this monster was created by a monstermaker... fade the corpse out. - SUB_StartFadeOut(); - } - else - { - // body is gonna be around for a while, so have it stink for a bit. - CSoundEnt::InsertSound ( bits_SOUND_CARCASS, pev->origin, 384, 30 ); - } - } - break; - } - case TASK_RANGE_ATTACK1_NOTURN: - case TASK_MELEE_ATTACK1_NOTURN: - case TASK_MELEE_ATTACK2_NOTURN: - case TASK_RANGE_ATTACK2_NOTURN: - case TASK_RELOAD_NOTURN: - { - if ( m_fSequenceFinished ) - { - m_Activity = ACT_RESET; - TaskComplete(); - } - break; - } - case TASK_RANGE_ATTACK1: - case TASK_MELEE_ATTACK1: - case TASK_MELEE_ATTACK2: - case TASK_RANGE_ATTACK2: - case TASK_SPECIAL_ATTACK1: - case TASK_SPECIAL_ATTACK2: - case TASK_RELOAD: - { - MakeIdealYaw ( m_vecEnemyLKP ); - ChangeYaw ( pev->yaw_speed ); - - if ( m_fSequenceFinished ) - { - m_Activity = ACT_RESET; - TaskComplete(); - } - break; - } - case TASK_SMALL_FLINCH: - { - if ( m_fSequenceFinished ) - { - TaskComplete(); - } - } - break; - case TASK_WAIT_FOR_SCRIPT: - { - if ( m_pCine->m_iDelay <= 0 && gpGlobals->time >= m_pCine->m_startTime ) - { - TaskComplete(); - m_pCine->StartSequence( (CBaseMonster *)this, m_pCine->m_iszPlay, TRUE ); - if ( m_fSequenceFinished ) - ClearSchedule(); - pev->framerate = 1.0; - //ALERT( at_aiconsole, "Script %s has begun for %s\n", STRING( m_pCine->m_iszPlay ), STRING(pev->classname) ); - } - break; - } - case TASK_PLAY_SCRIPT: - { - if (m_fSequenceFinished) - { - m_pCine->SequenceDone( this ); - } - break; - } - } -} - -//========================================================= -// SetTurnActivity - measures the difference between the way -// the monster is facing and determines whether or not to -// select one of the 180 turn animations. -//========================================================= -void CBaseMonster :: SetTurnActivity ( void ) -{ - float flYD; - flYD = FlYawDiff(); - - if ( flYD <= -45 && LookupActivity ( ACT_TURN_RIGHT ) != ACTIVITY_NOT_AVAILABLE ) - {// big right turn - m_IdealActivity = ACT_TURN_RIGHT; - } - else if ( flYD > 45 && LookupActivity ( ACT_TURN_LEFT ) != ACTIVITY_NOT_AVAILABLE ) - {// big left turn - m_IdealActivity = ACT_TURN_LEFT; - } -} - -//========================================================= -// Start task - selects the correct activity and performs -// any necessary calculations to start the next task on the -// schedule. -//========================================================= -void CBaseMonster :: StartTask ( Task_t *pTask ) -{ - switch ( pTask->iTask ) - { - case TASK_TURN_RIGHT: - { - float flCurrentYaw; - - flCurrentYaw = UTIL_AngleMod( pev->angles.y ); - pev->ideal_yaw = UTIL_AngleMod( flCurrentYaw - pTask->flData ); - SetTurnActivity(); - break; - } - case TASK_TURN_LEFT: - { - float flCurrentYaw; - - flCurrentYaw = UTIL_AngleMod( pev->angles.y ); - pev->ideal_yaw = UTIL_AngleMod( flCurrentYaw + pTask->flData ); - SetTurnActivity(); - break; - } - case TASK_REMEMBER: - { - Remember ( (int)pTask->flData ); - TaskComplete(); - break; - } - case TASK_FORGET: - { - Forget ( (int)pTask->flData ); - TaskComplete(); - break; - } - case TASK_FIND_HINTNODE: - { - m_iHintNode = FindHintNode(); - - if ( m_iHintNode != NO_NODE ) - { - TaskComplete(); - } - else - { - TaskFail(); - } - break; - } - case TASK_STORE_LASTPOSITION: - { - m_vecLastPosition = pev->origin; - TaskComplete(); - break; - } - case TASK_CLEAR_LASTPOSITION: - { - m_vecLastPosition = g_vecZero; - TaskComplete(); - break; - } - case TASK_CLEAR_HINTNODE: - { - m_iHintNode = NO_NODE; - TaskComplete(); - break; - } - case TASK_STOP_MOVING: - { - if ( m_IdealActivity == m_movementActivity ) - { - m_IdealActivity = GetStoppedActivity(); - } - - RouteClear(); - TaskComplete(); - break; - } - case TASK_PLAY_SEQUENCE_FACE_ENEMY: - case TASK_PLAY_SEQUENCE_FACE_TARGET: - case TASK_PLAY_SEQUENCE: - { - m_IdealActivity = ( Activity )( int )pTask->flData; - break; - } - case TASK_PLAY_ACTIVE_IDLE: - { - // monsters verify that they have a sequence for the node's activity BEFORE - // moving towards the node, so it's ok to just set the activity without checking here. - m_IdealActivity = ( Activity )WorldGraph.m_pNodes[ m_iHintNode ].m_sHintActivity; - break; - } - case TASK_SET_SCHEDULE: - { - Schedule_t *pNewSchedule; - - pNewSchedule = GetScheduleOfType( (int)pTask->flData ); - - if ( pNewSchedule ) - { - ChangeSchedule( pNewSchedule ); - } - else - { - TaskFail(); - } - - break; - } - case TASK_FIND_NEAR_NODE_COVER_FROM_ENEMY: - { - if ( m_hEnemy == NULL ) - { - TaskFail(); - return; - } - - if ( FindCover( m_hEnemy->pev->origin, m_hEnemy->pev->view_ofs, 0, pTask->flData ) ) - { - // try for cover farther than the FLData from the schedule. - TaskComplete(); - } - else - { - // no coverwhatsoever. - TaskFail(); - } - break; - } - case TASK_FIND_FAR_NODE_COVER_FROM_ENEMY: - { - if ( m_hEnemy == NULL ) - { - TaskFail(); - return; - } - - if ( FindCover( m_hEnemy->pev->origin, m_hEnemy->pev->view_ofs, pTask->flData, CoverRadius() ) ) - { - // try for cover farther than the FLData from the schedule. - TaskComplete(); - } - else - { - // no coverwhatsoever. - TaskFail(); - } - break; - } - case TASK_FIND_NODE_COVER_FROM_ENEMY: - { - if ( m_hEnemy == NULL ) - { - TaskFail(); - return; - } - - if ( FindCover( m_hEnemy->pev->origin, m_hEnemy->pev->view_ofs, 0, CoverRadius() ) ) - { - // try for cover farther than the FLData from the schedule. - TaskComplete(); - } - else - { - // no coverwhatsoever. - TaskFail(); - } - break; - } - case TASK_FIND_COVER_FROM_ENEMY: - { - entvars_t *pevCover; - - if ( m_hEnemy == NULL ) - { - // Find cover from self if no enemy available - pevCover = pev; -// TaskFail(); -// return; - } - else - pevCover = m_hEnemy->pev; - - if ( FindLateralCover( pevCover->origin, pevCover->view_ofs ) ) - { - // try lateral first - m_flMoveWaitFinished = gpGlobals->time + pTask->flData; - TaskComplete(); - } - else if ( FindCover( pevCover->origin, pevCover->view_ofs, 0, CoverRadius() ) ) - { - // then try for plain ole cover - m_flMoveWaitFinished = gpGlobals->time + pTask->flData; - TaskComplete(); - } - else - { - // no coverwhatsoever. - TaskFail(); - } - break; - } - case TASK_FIND_COVER_FROM_ORIGIN: - { - if ( FindCover( pev->origin, pev->view_ofs, 0, CoverRadius() ) ) - { - // then try for plain ole cover - m_flMoveWaitFinished = gpGlobals->time + pTask->flData; - TaskComplete(); - } - else - { - // no cover! - TaskFail(); - } - } - break; - case TASK_FIND_COVER_FROM_BEST_SOUND: - { - CSound *pBestSound; - - pBestSound = PBestSound(); - - ASSERT( pBestSound != NULL ); - /* - if ( pBestSound && FindLateralCover( pBestSound->m_vecOrigin, g_vecZero ) ) - { - // try lateral first - m_flMoveWaitFinished = gpGlobals->time + pTask->flData; - TaskComplete(); - } - */ - - if ( pBestSound && FindCover( pBestSound->m_vecOrigin, g_vecZero, pBestSound->m_iVolume, CoverRadius() ) ) - { - // then try for plain ole cover - m_flMoveWaitFinished = gpGlobals->time + pTask->flData; - TaskComplete(); - } - else - { - // no coverwhatsoever. or no sound in list - TaskFail(); - } - break; - } - case TASK_FACE_HINTNODE: - { - pev->ideal_yaw = WorldGraph.m_pNodes[ m_iHintNode ].m_flHintYaw; - SetTurnActivity(); - break; - } - - case TASK_FACE_LASTPOSITION: - MakeIdealYaw ( m_vecLastPosition ); - SetTurnActivity(); - break; - - case TASK_FACE_TARGET: - if ( m_hTargetEnt != NULL ) - { - MakeIdealYaw ( m_hTargetEnt->pev->origin ); - SetTurnActivity(); - } - else - TaskFail(); - break; - case TASK_FACE_ENEMY: - { - MakeIdealYaw ( m_vecEnemyLKP ); - SetTurnActivity(); - break; - } - case TASK_FACE_IDEAL: - { - SetTurnActivity(); - break; - } - case TASK_FACE_ROUTE: - { - if (FRouteClear()) - { - ALERT(at_aiconsole, "No route to face!\n"); - TaskFail(); - } - else - { - MakeIdealYaw(m_Route[m_iRouteIndex].vecLocation); - SetTurnActivity(); - } - break; - } - case TASK_WAIT_PVS: - case TASK_WAIT_INDEFINITE: - { - // don't do anything. - break; - } - case TASK_WAIT: - case TASK_WAIT_FACE_ENEMY: - {// set a future time that tells us when the wait is over. - m_flWaitFinished = gpGlobals->time + pTask->flData; - break; - } - case TASK_WAIT_RANDOM: - {// set a future time that tells us when the wait is over. - m_flWaitFinished = gpGlobals->time + RANDOM_FLOAT( 0.1, pTask->flData ); - break; - } - case TASK_MOVE_TO_TARGET_RANGE: - { - if ( (m_hTargetEnt->pev->origin - pev->origin).Length() < 1 ) - TaskComplete(); - else - { - m_vecMoveGoal = m_hTargetEnt->pev->origin; - if ( !MoveToTarget( ACT_WALK, 2 ) ) - TaskFail(); - } - break; - } - case TASK_RUN_TO_TARGET: - case TASK_WALK_TO_TARGET: - { - Activity newActivity; - - if ( (m_hTargetEnt->pev->origin - pev->origin).Length() < 1 ) - TaskComplete(); - else - { - if ( pTask->iTask == TASK_WALK_TO_TARGET ) - newActivity = ACT_WALK; - else - newActivity = ACT_RUN; - // This monster can't do this! - if ( LookupActivity( newActivity ) == ACTIVITY_NOT_AVAILABLE ) - TaskComplete(); - else - { - if ( m_hTargetEnt == NULL || !MoveToTarget( newActivity, 2 ) ) - { - TaskFail(); - ALERT( at_aiconsole, "%s Failed to reach target!!!\n", STRING(pev->classname) ); - RouteClear(); - } - } - } - TaskComplete(); - break; - } - case TASK_CLEAR_MOVE_WAIT: - { - m_flMoveWaitFinished = gpGlobals->time; - TaskComplete(); - break; - } - case TASK_MELEE_ATTACK1_NOTURN: - case TASK_MELEE_ATTACK1: - { - m_IdealActivity = ACT_MELEE_ATTACK1; - break; - } - case TASK_MELEE_ATTACK2_NOTURN: - case TASK_MELEE_ATTACK2: - { - m_IdealActivity = ACT_MELEE_ATTACK2; - break; - } - case TASK_RANGE_ATTACK1_NOTURN: - case TASK_RANGE_ATTACK1: - { - m_IdealActivity = ACT_RANGE_ATTACK1; - break; - } - case TASK_RANGE_ATTACK2_NOTURN: - case TASK_RANGE_ATTACK2: - { - m_IdealActivity = ACT_RANGE_ATTACK2; - break; - } - case TASK_RELOAD_NOTURN: - case TASK_RELOAD: - { - m_IdealActivity = ACT_RELOAD; - break; - } - case TASK_SPECIAL_ATTACK1: - { - m_IdealActivity = ACT_SPECIAL_ATTACK1; - break; - } - case TASK_SPECIAL_ATTACK2: - { - m_IdealActivity = ACT_SPECIAL_ATTACK2; - break; - } - case TASK_SET_ACTIVITY: - { - m_IdealActivity = (Activity)(int)pTask->flData; - TaskComplete(); - break; - } - case TASK_GET_PATH_TO_ENEMY_LKP: - { - if ( BuildRoute ( m_vecEnemyLKP, bits_MF_TO_LOCATION, NULL ) ) - { - TaskComplete(); - } - else if (BuildNearestRoute( m_vecEnemyLKP, pev->view_ofs, 0, (m_vecEnemyLKP - pev->origin).Length() )) - { - TaskComplete(); - } - else - { - // no way to get there =( - ALERT ( at_aiconsole, "GetPathToEnemyLKP failed!!\n" ); - TaskFail(); - } - break; - } - case TASK_GET_PATH_TO_ENEMY: - { - CBaseEntity *pEnemy = m_hEnemy; - - if ( pEnemy == NULL ) - { - TaskFail(); - return; - } - - if ( BuildRoute ( pEnemy->pev->origin, bits_MF_TO_ENEMY, pEnemy ) ) - { - TaskComplete(); - } - else if (BuildNearestRoute( pEnemy->pev->origin, pEnemy->pev->view_ofs, 0, (pEnemy->pev->origin - pev->origin).Length() )) - { - TaskComplete(); - } - else - { - // no way to get there =( - ALERT ( at_aiconsole, "GetPathToEnemy failed!!\n" ); - TaskFail(); - } - break; - } - case TASK_GET_PATH_TO_ENEMY_CORPSE: - { - UTIL_MakeVectors( pev->angles ); - if ( BuildRoute ( m_vecEnemyLKP - gpGlobals->v_forward * 64, bits_MF_TO_LOCATION, NULL ) ) - { - TaskComplete(); - } - else - { - ALERT ( at_aiconsole, "GetPathToEnemyCorpse failed!!\n" ); - TaskFail(); - } - } - break; - case TASK_GET_PATH_TO_SPOT: - { - CBaseEntity *pPlayer = CBaseEntity::Instance( FIND_ENTITY_BY_CLASSNAME( NULL, "player" ) ); - if ( BuildRoute ( m_vecMoveGoal, bits_MF_TO_LOCATION, pPlayer ) ) - { - TaskComplete(); - } - else - { - // no way to get there =( - ALERT ( at_aiconsole, "GetPathToSpot failed!!\n" ); - TaskFail(); - } - break; - } - - case TASK_GET_PATH_TO_TARGET: - { - RouteClear(); - if ( m_hTargetEnt != NULL && MoveToTarget( m_movementActivity, 1 ) ) - { - TaskComplete(); - } - else - { - // no way to get there =( - ALERT ( at_aiconsole, "GetPathToSpot failed!!\n" ); - TaskFail(); - } - break; - } - case TASK_GET_PATH_TO_HINTNODE:// for active idles! - { - if ( MoveToLocation( m_movementActivity, 2, WorldGraph.m_pNodes[ m_iHintNode ].m_vecOrigin ) ) - { - TaskComplete(); - } - else - { - // no way to get there =( - ALERT ( at_aiconsole, "GetPathToHintNode failed!!\n" ); - TaskFail(); - } - break; - } - case TASK_GET_PATH_TO_LASTPOSITION: - { - m_vecMoveGoal = m_vecLastPosition; - - if ( MoveToLocation( m_movementActivity, 2, m_vecMoveGoal ) ) - { - TaskComplete(); - } - else - { - // no way to get there =( - ALERT ( at_aiconsole, "GetPathToLastPosition failed!!\n" ); - TaskFail(); - } - break; - } - case TASK_GET_PATH_TO_BESTSOUND: - { - CSound *pSound; - - pSound = PBestSound(); - - if ( pSound && MoveToLocation( m_movementActivity, 2, pSound->m_vecOrigin ) ) - { - TaskComplete(); - } - else - { - // no way to get there =( - ALERT ( at_aiconsole, "GetPathToBestSound failed!!\n" ); - TaskFail(); - } - break; - } -case TASK_GET_PATH_TO_BESTSCENT: - { - CSound *pScent; - - pScent = PBestScent(); - - if ( pScent && MoveToLocation( m_movementActivity, 2, pScent->m_vecOrigin ) ) - { - TaskComplete(); - } - else - { - // no way to get there =( - ALERT ( at_aiconsole, "GetPathToBestScent failed!!\n" ); - - TaskFail(); - } - break; - } - case TASK_RUN_PATH: - { - // UNDONE: This is in some default AI and some monsters can't run? -- walk instead? - if ( LookupActivity( ACT_RUN ) != ACTIVITY_NOT_AVAILABLE ) - { - m_movementActivity = ACT_RUN; - } - else - { - m_movementActivity = ACT_WALK; - } - TaskComplete(); - break; - } - case TASK_WALK_PATH: - { - if ( pev->movetype == MOVETYPE_FLY ) - { - m_movementActivity = ACT_FLY; - } - if ( LookupActivity( ACT_WALK ) != ACTIVITY_NOT_AVAILABLE ) - { - m_movementActivity = ACT_WALK; - } - else - { - m_movementActivity = ACT_RUN; - } - TaskComplete(); - break; - } - case TASK_STRAFE_PATH: - { - Vector2D vec2DirToPoint; - Vector2D vec2RightSide; - - // to start strafing, we have to first figure out if the target is on the left side or right side - UTIL_MakeVectors ( pev->angles ); - - vec2DirToPoint = ( m_Route[ 0 ].vecLocation - pev->origin ).Make2D().Normalize(); - vec2RightSide = gpGlobals->v_right.Make2D().Normalize(); - - if ( DotProduct ( vec2DirToPoint, vec2RightSide ) > 0 ) - { - // strafe right - m_movementActivity = ACT_STRAFE_RIGHT; - } - else - { - // strafe left - m_movementActivity = ACT_STRAFE_LEFT; - } - TaskComplete(); - break; - } - - - case TASK_WAIT_FOR_MOVEMENT: - { - if (FRouteClear()) - { - TaskComplete(); - } - break; - } - - case TASK_EAT: - { - Eat( pTask->flData ); - TaskComplete(); - break; - } - case TASK_SMALL_FLINCH: - { - m_IdealActivity = GetSmallFlinchActivity(); - break; - } - case TASK_DIE: - { - RouteClear(); - - m_IdealActivity = GetDeathActivity(); - - pev->deadflag = DEAD_DYING; - break; - } - case TASK_SOUND_WAKE: - { - AlertSound(); - TaskComplete(); - break; - } - case TASK_SOUND_DIE: - { - DeathSound(); - TaskComplete(); - break; - } - case TASK_SOUND_IDLE: - { - IdleSound(); - TaskComplete(); - break; - } - case TASK_SOUND_PAIN: - { - PainSound(); - TaskComplete(); - break; - } - case TASK_SOUND_DEATH: - { - DeathSound(); - TaskComplete(); - break; - } - case TASK_SOUND_ANGRY: - { - // sounds are complete as soon as we get here, cause we've already played them. - ALERT ( at_aiconsole, "SOUND\n" ); - TaskComplete(); - break; - } - case TASK_WAIT_FOR_SCRIPT: - { - if (m_pCine->m_iszIdle) - { - m_pCine->StartSequence( (CBaseMonster *)this, m_pCine->m_iszIdle, FALSE ); - if (FStrEq( STRING(m_pCine->m_iszIdle), STRING(m_pCine->m_iszPlay))) - { - pev->framerate = 0; - } - } - else - m_IdealActivity = ACT_IDLE; - - break; - } - case TASK_PLAY_SCRIPT: - { - pev->movetype = MOVETYPE_FLY; - ClearBits(pev->flags, FL_ONGROUND); - m_scriptState = SCRIPT_PLAYING; - break; - } - case TASK_ENABLE_SCRIPT: - { - m_pCine->DelayStart( 0 ); - TaskComplete(); - break; - } - case TASK_PLANT_ON_SCRIPT: - { - if ( m_hTargetEnt != NULL ) - { - pev->origin = m_hTargetEnt->pev->origin; // Plant on target - } - - TaskComplete(); - break; - } - case TASK_FACE_SCRIPT: - { - if ( m_hTargetEnt != NULL ) - { - pev->ideal_yaw = UTIL_AngleMod( m_hTargetEnt->pev->angles.y ); - } - - TaskComplete(); - m_IdealActivity = ACT_IDLE; - RouteClear(); - break; - } - - case TASK_SUGGEST_STATE: - { - m_IdealMonsterState = (MONSTERSTATE)(int)pTask->flData; - TaskComplete(); - break; - } - - case TASK_SET_FAIL_SCHEDULE: - m_failSchedule = (int)pTask->flData; - TaskComplete(); - break; - - case TASK_CLEAR_FAIL_SCHEDULE: - m_failSchedule = SCHED_NONE; - TaskComplete(); - break; - - default: - { - ALERT ( at_aiconsole, "No StartTask entry for %d\n", (SHARED_TASKS)pTask->iTask ); - break; - } - } -} - -//========================================================= -// GetTask - returns a pointer to the current -// scheduled task. NULL if there's a problem. -//========================================================= -Task_t *CBaseMonster :: GetTask ( void ) -{ - if ( m_iScheduleIndex < 0 || m_iScheduleIndex >= m_pSchedule->cTasks ) - { - // m_iScheduleIndex is not within valid range for the monster's current schedule. - return NULL; - } - else - { - return &m_pSchedule->pTasklist[ m_iScheduleIndex ]; - } -} - -//========================================================= -// GetSchedule - Decides which type of schedule best suits -// the monster's current state and conditions. Then calls -// monster's member function to get a pointer to a schedule -// of the proper type. -//========================================================= -Schedule_t *CBaseMonster :: GetSchedule ( void ) -{ - switch ( m_MonsterState ) - { - case MONSTERSTATE_PRONE: - { - return GetScheduleOfType( SCHED_BARNACLE_VICTIM_GRAB ); - break; - } - case MONSTERSTATE_NONE: - { - ALERT ( at_aiconsole, "MONSTERSTATE IS NONE!\n" ); - break; - } - case MONSTERSTATE_IDLE: - { - if ( HasConditions ( bits_COND_HEAR_SOUND ) ) - { - return GetScheduleOfType( SCHED_ALERT_FACE ); - } - else if ( FRouteClear() ) - { - // no valid route! - return GetScheduleOfType( SCHED_IDLE_STAND ); - } - else - { - // valid route. Get moving - return GetScheduleOfType( SCHED_IDLE_WALK ); - } - break; - } - case MONSTERSTATE_ALERT: - { - if ( HasConditions( bits_COND_ENEMY_DEAD ) && LookupActivity( ACT_VICTORY_DANCE ) != ACTIVITY_NOT_AVAILABLE ) - { - return GetScheduleOfType ( SCHED_VICTORY_DANCE ); - } - - if ( HasConditions(bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE) ) - { - if ( fabs( FlYawDiff() ) < (1.0 - m_flFieldOfView) * 60 ) // roughly in the correct direction - { - return GetScheduleOfType( SCHED_TAKE_COVER_FROM_ORIGIN ); - } - else - { - return GetScheduleOfType( SCHED_ALERT_SMALL_FLINCH ); - } - } - - else if ( HasConditions ( bits_COND_HEAR_SOUND ) ) - { - return GetScheduleOfType( SCHED_ALERT_FACE ); - } - else - { - return GetScheduleOfType( SCHED_ALERT_STAND ); - } - break; - } - case MONSTERSTATE_COMBAT: - { - if ( HasConditions( bits_COND_ENEMY_DEAD ) ) - { - // clear the current (dead) enemy and try to find another. - m_hEnemy = NULL; - - if ( GetEnemy() ) - { - ClearConditions( bits_COND_ENEMY_DEAD ); - return GetSchedule(); - } - else - { - SetState( MONSTERSTATE_ALERT ); - return GetSchedule(); - } - } - - if ( HasConditions(bits_COND_NEW_ENEMY) ) - { - return GetScheduleOfType ( SCHED_WAKE_ANGRY ); - } - else if (HasConditions(bits_COND_LIGHT_DAMAGE) && !HasMemory( bits_MEMORY_FLINCHED) ) - { - return GetScheduleOfType( SCHED_SMALL_FLINCH ); - } - else if ( !HasConditions(bits_COND_SEE_ENEMY) ) - { - // we can't see the enemy - if ( !HasConditions(bits_COND_ENEMY_OCCLUDED) ) - { - // enemy is unseen, but not occluded! - // turn to face enemy - return GetScheduleOfType( SCHED_COMBAT_FACE ); - } - else - { - // chase! - return GetScheduleOfType( SCHED_CHASE_ENEMY ); - } - } - else - { - // we can see the enemy - if ( HasConditions(bits_COND_CAN_RANGE_ATTACK1) ) - { - return GetScheduleOfType( SCHED_RANGE_ATTACK1 ); - } - if ( HasConditions(bits_COND_CAN_RANGE_ATTACK2) ) - { - return GetScheduleOfType( SCHED_RANGE_ATTACK2 ); - } - if ( HasConditions(bits_COND_CAN_MELEE_ATTACK1) ) - { - return GetScheduleOfType( SCHED_MELEE_ATTACK1 ); - } - if ( HasConditions(bits_COND_CAN_MELEE_ATTACK2) ) - { - return GetScheduleOfType( SCHED_MELEE_ATTACK2 ); - } - if ( !HasConditions(bits_COND_CAN_RANGE_ATTACK1 | bits_COND_CAN_MELEE_ATTACK1) ) - { - // if we can see enemy but can't use either attack type, we must need to get closer to enemy - return GetScheduleOfType( SCHED_CHASE_ENEMY ); - } - else if ( !FacingIdeal() ) - { - //turn - return GetScheduleOfType( SCHED_COMBAT_FACE ); - } - else - { - ALERT ( at_aiconsole, "No suitable combat schedule!\n" ); - } - } - break; - } - case MONSTERSTATE_DEAD: - { - return GetScheduleOfType( SCHED_DIE ); - break; - } - case MONSTERSTATE_SCRIPT: - { - ASSERT( m_pCine != NULL ); - if ( !m_pCine ) - { - ALERT( at_aiconsole, "Script failed for %s\n", STRING(pev->classname) ); - CineCleanup(); - return GetScheduleOfType( SCHED_IDLE_STAND ); - } - - return GetScheduleOfType( SCHED_AISCRIPT ); - } - default: - { - ALERT ( at_aiconsole, "Invalid State for GetSchedule!\n" ); - break; - } - } - - return &slError[ 0 ]; -} diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index 4ea35257..2378b03e 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -20,13 +20,11 @@ # SOFTWARE. # -cmake_minimum_required(VERSION 2.6.0) +cmake_minimum_required(VERSION 2.8.12) project (SVDLL) set (SVDLL_LIBRARY server) -add_definitions(-DCLIENT_WEAPONS) - if(NOT MSVC) add_compile_options(-fno-exceptions) # GCC/Clang flag add_compile_options(-Wno-invalid-offsetof) # GCC/Clang flag @@ -148,6 +146,12 @@ set (SVDLL_SOURCES include_directories (. wpn_shared ../common ../engine ../pm_shared ../game_shared ../public) +if(MSVC) + set(SVDLL_SOURCES + ${SVDLL_SOURCES} + hl.def) +endif() + if(USE_VOICEMGR) set(SVDLL_SOURCES ${SVDLL_SOURCES} @@ -161,17 +165,18 @@ add_library (${SVDLL_LIBRARY} SHARED ${SVDLL_SOURCES}) set_target_properties (${SVDLL_LIBRARY} PROPERTIES POSITION_INDEPENDENT_CODE 1) -if(APPLE OR WIN32 OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") +if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Android") set(SVDLL_NAME "${SERVER_LIBRARY_NAME}") - if(64BIT) - set(SVDLL_NAME "${SERVER_LIBRARY_NAME}64") - endif() set_target_properties(${SVDLL_LIBRARY} PROPERTIES OUTPUT_NAME ${SVDLL_NAME} PREFIX "") endif() +if(MSVC) + set_property(TARGET ${SVDLL_LIBRARY} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +endif() + install( TARGETS ${SVDLL_LIBRARY} DESTINATION "${GAMEDIR}/${SERVER_INSTALL_DIR}/" PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE diff --git a/dlls/Makefile b/dlls/Makefile deleted file mode 100644 index 3599b9c7..00000000 --- a/dlls/Makefile +++ /dev/null @@ -1,190 +0,0 @@ -# -# Half-Life Full SDK 2.3 hl_i386.so Makefile for x86 Linux -# -# October 2002 by Leon Hartwig (hartwig@valvesoftware.com) -# - -DLLNAME=hl - -ARCH=i386 - -#make sure this is the correct compiler for your system -CC?=gcc -CXX?=g++ - -DLL_SRCDIR=. -ENGINE_SRCDIR=../engine -COMMON_SRCDIR=../common -WPN_SHARED_SRCDIR=./wpn_shared -PM_SHARED_SRCDIR=../pm_shared -GAME_SHARED_SRCDIR=../game_shared - -DLL_OBJDIR=$(DLL_SRCDIR)/obj -WPN_SHARED_OBJDIR=$(WPN_SHARED_SRCDIR)/obj -PM_SHARED_OBJDIR=$(PM_SHARED_SRCDIR)/obj -GAME_SHARED_OBJDIR=$(GAME_SHARED_SRCDIR)/obj - -BASE_CFLAGS= -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ - -DCLIENT_WEAPONS -DNO_VOICEGAMEMGR - -#safe optimization -CFLAGS=$(BASE_CFLAGS) -m32 -w -O1 - -#full optimization -#CFLAGS=$(BASE_CFLAGS) -w -O1 -m486 -ffast-math -funroll-loops \ - -fomit-frame-pointer -fexpensive-optimizations \ - -malign-loops=2 -malign-jumps=2 -malign-functions=2 - -#use these when debugging -#CFLAGS=$(BASE_CFLAGS) -g - -INCLUDEDIRS=-I. -I$(ENGINE_SRCDIR) -I$(COMMON_SRCDIR) -I$(PM_SHARED_SRCDIR) -I$(GAME_SHARED_SRCDIR) - -LDFLAGS= - -SHLIBEXT=so -SHLIBCFLAGS=-fPIC -SHLIBLDFLAGS=-shared - -DO_CC=$(CC) $(CFLAGS) $(SHLIBCFLAGS) $(INCLUDEDIRS) -o $@ -c $< -DO_CXX=$(CXX) $(CFLAGS) $(SHLIBCFLAGS) $(INCLUDEDIRS) -o $@ -c $< - -############################################################################# -# SETUP AND BUILD -# GAME -############################################################################# - -$(DLL_OBJDIR)/%.o: $(DLL_SRCDIR)/%.cpp - $(DO_CXX) - -$(WPN_SHARED_OBJDIR)/%.o: $(WPN_SHARED_SRCDIR)/%.cpp - $(DO_CXX) - -$(GAME_SHARED_OBJDIR)/%.o: $(GAME_SHARED_SRCDIR)/%.cpp - $(DO_CXX) - -$(PM_SHARED_OBJDIR)/%.o: $(PM_SHARED_SRCDIR)/%.c - $(DO_CC) - -OBJ = \ - $(DLL_OBJDIR)/aflock.o \ - $(DLL_OBJDIR)/agrunt.o \ - $(DLL_OBJDIR)/airtank.o \ - $(DLL_OBJDIR)/animating.o \ - $(DLL_OBJDIR)/animation.o \ - $(DLL_OBJDIR)/apache.o \ - $(DLL_OBJDIR)/barnacle.o \ - $(DLL_OBJDIR)/barney.o \ - $(DLL_OBJDIR)/bigmomma.o \ - $(DLL_OBJDIR)/bloater.o \ - $(DLL_OBJDIR)/bmodels.o \ - $(DLL_OBJDIR)/bullsquid.o \ - $(DLL_OBJDIR)/buttons.o \ - $(DLL_OBJDIR)/cbase.o \ - $(DLL_OBJDIR)/client.o \ - $(DLL_OBJDIR)/combat.o \ - $(DLL_OBJDIR)/controller.o \ - $(DLL_OBJDIR)/crossbow.o \ - $(DLL_OBJDIR)/crowbar.o \ - $(DLL_OBJDIR)/defaultai.o \ - $(DLL_OBJDIR)/doors.o \ - $(DLL_OBJDIR)/effects.o \ - $(DLL_OBJDIR)/egon.o \ - $(DLL_OBJDIR)/explode.o \ - $(DLL_OBJDIR)/flyingmonster.o \ - $(DLL_OBJDIR)/func_break.o \ - $(DLL_OBJDIR)/func_tank.o \ - $(DLL_OBJDIR)/game.o \ - $(DLL_OBJDIR)/gamerules.o \ - $(DLL_OBJDIR)/gargantua.o \ - $(DLL_OBJDIR)/gauss.o \ - $(DLL_OBJDIR)/genericmonster.o \ - $(DLL_OBJDIR)/ggrenade.o \ - $(DLL_OBJDIR)/globals.o \ - $(DLL_OBJDIR)/gman.o \ - $(DLL_OBJDIR)/h_ai.o \ - $(DLL_OBJDIR)/h_battery.o \ - $(DLL_OBJDIR)/h_cine.o \ - $(DLL_OBJDIR)/h_cycler.o \ - $(DLL_OBJDIR)/h_export.o \ - $(DLL_OBJDIR)/handgrenade.o \ - $(DLL_OBJDIR)/hassassin.o \ - $(DLL_OBJDIR)/headcrab.o \ - $(DLL_OBJDIR)/healthkit.o \ - $(DLL_OBJDIR)/hgrunt.o \ - $(DLL_OBJDIR)/hornet.o \ - $(DLL_OBJDIR)/hornetgun.o \ - $(DLL_OBJDIR)/houndeye.o \ - $(DLL_OBJDIR)/ichthyosaur.o \ - $(DLL_OBJDIR)/islave.o \ - $(DLL_OBJDIR)/items.o \ - $(DLL_OBJDIR)/leech.o \ - $(DLL_OBJDIR)/lights.o \ - $(DLL_OBJDIR)/maprules.o \ - $(DLL_OBJDIR)/monstermaker.o \ - $(DLL_OBJDIR)/monsters.o \ - $(DLL_OBJDIR)/monsterstate.o \ - $(DLL_OBJDIR)/mortar.o \ - $(DLL_OBJDIR)/mp5.o \ - $(DLL_OBJDIR)/multiplay_gamerules.o \ - $(DLL_OBJDIR)/nihilanth.o \ - $(DLL_OBJDIR)/nodes.o \ - $(DLL_OBJDIR)/observer.o \ - $(DLL_OBJDIR)/osprey.o \ - $(DLL_OBJDIR)/pathcorner.o \ - $(DLL_OBJDIR)/plane.o \ - $(DLL_OBJDIR)/plats.o \ - $(DLL_OBJDIR)/player.o \ - $(DLL_OBJDIR)/playermonster.o \ - $(DLL_OBJDIR)/python.o \ - $(DLL_OBJDIR)/rat.o \ - $(DLL_OBJDIR)/roach.o \ - $(DLL_OBJDIR)/rpg.o \ - $(DLL_OBJDIR)/satchel.o \ - $(DLL_OBJDIR)/schedule.o \ - $(DLL_OBJDIR)/scientist.o \ - $(DLL_OBJDIR)/scripted.o \ - $(DLL_OBJDIR)/shotgun.o \ - $(DLL_OBJDIR)/singleplay_gamerules.o \ - $(DLL_OBJDIR)/skill.o \ - $(DLL_OBJDIR)/sound.o \ - $(DLL_OBJDIR)/soundent.o \ - $(DLL_OBJDIR)/spectator.o \ - $(DLL_OBJDIR)/squadmonster.o \ - $(DLL_OBJDIR)/squeakgrenade.o \ - $(DLL_OBJDIR)/subs.o \ - $(DLL_OBJDIR)/talkmonster.o \ - $(DLL_OBJDIR)/teamplay_gamerules.o \ - $(DLL_OBJDIR)/tempmonster.o \ - $(DLL_OBJDIR)/tentacle.o \ - $(DLL_OBJDIR)/triggers.o \ - $(DLL_OBJDIR)/tripmine.o \ - $(DLL_OBJDIR)/turret.o \ - $(DLL_OBJDIR)/util.o \ - $(DLL_OBJDIR)/weapons.o \ - $(DLL_OBJDIR)/world.o \ - $(DLL_OBJDIR)/xen.o \ - $(DLL_OBJDIR)/zombie.o \ - $(DLL_OBJDIR)/glock.o \ - $(PM_SHARED_OBJDIR)/pm_debug.o \ - $(PM_SHARED_OBJDIR)/pm_math.o \ - $(PM_SHARED_OBJDIR)/pm_shared.o -# $(GAME_SHARED_OBJDIR)/voice_gamemgr.o - -$(DLLNAME)_$(ARCH).$(SHLIBEXT) : neat $(OBJ) - $(CXX) $(CFLAGS) $(SHLIBLDFLAGS) $(LDFLAGS) -o $@ $(OBJ) - -neat: - -mkdir $(DLL_OBJDIR) - -mkdir $(WPN_SHARED_OBJDIR) - -mkdir $(GAME_SHARED_OBJDIR) - -mkdir $(PM_SHARED_OBJDIR) -clean: - -rm -f $(OBJ) - -rm -f $(DLLNAME)_$(ARCH).$(SHLIBEXT) -spotless: clean - -rm -r $(DLL_OBJDIR) - -rm -r $(WPN_SHARED_OBJDIR) - -rm -r $(GAME_SHARED_OBJDIR) - -rm -r $(PM_SHARED_OBJDIR) - diff --git a/dlls/activity.h b/dlls/activity.h index 90d85a08..b13cf522 100644 --- a/dlls/activity.h +++ b/dlls/activity.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef ACTIVITY_H +#if !defined(ACTIVITY_H) #define ACTIVITY_H typedef enum { diff --git a/dlls/activitymap.h b/dlls/activitymap.h index b5f789f9..8255edf0 100644 --- a/dlls/activitymap.h +++ b/dlls/activitymap.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef ACTIVITYMAP_H +#if !defined(ACTIVITYMAP_H) #define ACTIVITYMAP_H #define _A( a ) { a, #a } diff --git a/dlls/aflock.cpp b/dlls/aflock.cpp index d50a8165..f69a99a9 100644 --- a/dlls/aflock.cpp +++ b/dlls/aflock.cpp @@ -22,7 +22,7 @@ #include "squadmonster.h" #define AFLOCK_MAX_RECRUIT_RADIUS 1024 -#define AFLOCK_FLY_SPEED 125 +#define AFLOCK_FLY_SPEED 125.0f #define AFLOCK_TURN_RATE 75 #define AFLOCK_ACCELERATE 10 #define AFLOCK_CHECK_DIST 192 @@ -200,7 +200,7 @@ void CFlockingFlyerFlock::SpawnFlock( void ) vecSpot.x = RANDOM_FLOAT( -R, R ); vecSpot.y = RANDOM_FLOAT( -R, R ); - vecSpot.z = RANDOM_FLOAT( 0, 16 ); + vecSpot.z = RANDOM_FLOAT( 0.0f, 16.0f ); vecSpot = pev->origin + vecSpot; UTIL_SetOrigin( pBoid->pev, vecSpot ); @@ -211,7 +211,7 @@ void CFlockingFlyerFlock::SpawnFlock( void ) pBoid->pev->angles = pev->angles; pBoid->pev->frame = 0; - pBoid->pev->nextthink = gpGlobals->time + 0.2; + pBoid->pev->nextthink = gpGlobals->time + 0.2f; pBoid->SetThink( &CFlockingFlyer::IdleThink ); if( pBoid != pLeader ) @@ -229,7 +229,7 @@ void CFlockingFlyer::Spawn() SpawnCommonCode(); pev->frame = 0; - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; SetThink( &CFlockingFlyer::IdleThink ); } @@ -284,7 +284,7 @@ void CFlockingFlyer::Killed( entvars_t *pevAttacker, int iGib ) while( pSquad ) { - pSquad->m_flAlertTime = gpGlobals->time + 15; + pSquad->m_flAlertTime = gpGlobals->time + 15.0f; pSquad = (CFlockingFlyer *)pSquad->m_pSquadNext; } @@ -302,7 +302,7 @@ void CFlockingFlyer::Killed( entvars_t *pevAttacker, int iGib ) pev->movetype = MOVETYPE_TOSS; SetThink( &CFlockingFlyer::FallHack ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } void CFlockingFlyer::FallHack( void ) @@ -312,7 +312,7 @@ void CFlockingFlyer::FallHack( void ) if( !FClassnameIs ( pev->groundentity, "worldspawn" ) ) { pev->flags &= ~FL_ONGROUND; - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } else { @@ -334,13 +334,13 @@ void CFlockingFlyer::SpawnCommonCode() pev->health = 1; m_fPathBlocked = FALSE;// obstacles will be detected - m_flFieldOfView = 0.2; + m_flFieldOfView = 0.2f; //SET_MODEL( ENT( pev ), "models/aflock.mdl" ); SET_MODEL( ENT( pev ), "models/boid.mdl" ); - //UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) ); - UTIL_SetSize( pev, Vector( -5, -5, 0 ), Vector( 5, 5, 2 ) ); + //UTIL_SetSize( pev, Vector( 0.0f, 0.0f, 0.0f ), Vector( 0.0f, 0.0f, 0.0f ) ); + UTIL_SetSize( pev, Vector( -5.0f, -5.0f, 0.0f ), Vector( 5.0f, 5.0f, 2.0f ) ); } //========================================================= @@ -348,38 +348,38 @@ void CFlockingFlyer::SpawnCommonCode() void CFlockingFlyer::BoidAdvanceFrame() { float flapspeed = ( pev->speed - pev->armorvalue ) / AFLOCK_ACCELERATE; - pev->armorvalue = pev->armorvalue * .8 + pev->speed * .2; + pev->armorvalue = pev->armorvalue * 0.8f + pev->speed * 0.2f; - if( flapspeed < 0 ) + if( flapspeed < 0.0f ) flapspeed = -flapspeed; - if( flapspeed < 0.25 ) - flapspeed = 0.25; - if( flapspeed > 1.9 ) - flapspeed = 1.9; + if( flapspeed < 0.25f ) + flapspeed = 0.25f; + if( flapspeed > 1.9f ) + flapspeed = 1.9f; pev->framerate = flapspeed; // lean - pev->avelocity.x = -( pev->angles.x + flapspeed * 5 ); + pev->avelocity.x = -( pev->angles.x + flapspeed * 5.0f ); // bank pev->avelocity.z = -( pev->angles.z + pev->avelocity.y ); // pev->framerate = flapspeed; - StudioFrameAdvance( 0.1 ); + StudioFrameAdvance( 0.1f ); } //========================================================= //========================================================= void CFlockingFlyer::IdleThink( void ) { - pev->nextthink = gpGlobals->time + 0.2; + pev->nextthink = gpGlobals->time + 0.2f; // see if there's a client in the same pvs as the monster if( !FNullEnt( FIND_CLIENT_IN_PVS( edict() ) ) ) { SetThink( &CFlockingFlyer::Start ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } } @@ -388,7 +388,7 @@ void CFlockingFlyer::IdleThink( void ) //========================================================= void CFlockingFlyer::Start( void ) { - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; if( IsLeader() ) { @@ -473,7 +473,7 @@ void CFlockingFlyer::SpreadFlock() // can average in a course that points away from the leader. flSpeed = pList->pev->velocity.Length(); pList->pev->velocity = pList->pev->velocity.Normalize(); - pList->pev->velocity = ( pList->pev->velocity + vecDir ) * 0.5; + pList->pev->velocity = ( pList->pev->velocity + vecDir ) * 0.5f; pList->pev->velocity = pList->pev->velocity * flSpeed; } @@ -529,28 +529,28 @@ BOOL CFlockingFlyer::FPathBlocked() // check for obstacle ahead UTIL_TraceLine( pev->origin, pev->origin + gpGlobals->v_forward * AFLOCK_CHECK_DIST, ignore_monsters, ENT( pev ), &tr ); - if( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0f ) { m_flLastBlockedTime = gpGlobals->time; fBlocked = TRUE; } // extra wide checks - UTIL_TraceLine( pev->origin + gpGlobals->v_right * 12, pev->origin + gpGlobals->v_right * 12 + gpGlobals->v_forward * AFLOCK_CHECK_DIST, ignore_monsters, ENT( pev ), &tr ); - if( tr.flFraction != 1.0 ) + UTIL_TraceLine( pev->origin + gpGlobals->v_right * 12.0f, pev->origin + gpGlobals->v_right * 12.0f + gpGlobals->v_forward * AFLOCK_CHECK_DIST, ignore_monsters, ENT( pev ), &tr ); + if( tr.flFraction != 1.0f ) { m_flLastBlockedTime = gpGlobals->time; fBlocked = TRUE; } - UTIL_TraceLine( pev->origin - gpGlobals->v_right * 12, pev->origin - gpGlobals->v_right * 12 + gpGlobals->v_forward * AFLOCK_CHECK_DIST, ignore_monsters, ENT( pev ), &tr ); - if( tr.flFraction != 1.0 ) + UTIL_TraceLine( pev->origin - gpGlobals->v_right * 12.0f, pev->origin - gpGlobals->v_right * 12.0f + gpGlobals->v_forward * AFLOCK_CHECK_DIST, ignore_monsters, ENT( pev ), &tr ); + if( tr.flFraction != 1.0f ) { m_flLastBlockedTime = gpGlobals->time; fBlocked = TRUE; } - if( !fBlocked && gpGlobals->time - m_flLastBlockedTime > 6 ) + if( !fBlocked && gpGlobals->time - m_flLastBlockedTime > 6.0f ) { // not blocked, and it's been a few seconds since we've actually been blocked. m_flFakeBlockedTime = gpGlobals->time + RANDOM_LONG( 1, 3 ); @@ -570,7 +570,7 @@ void CFlockingFlyer::FlockLeaderThink( void ) float flLeftSide; float flRightSide; - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; UTIL_MakeVectors( pev->angles ); @@ -587,7 +587,7 @@ void CFlockingFlyer::FlockLeaderThink( void ) m_fPathBlocked = FALSE; if( pev->speed <= AFLOCK_FLY_SPEED ) - pev->speed += 5; + pev->speed += 5.0f; pev->velocity = gpGlobals->v_forward * pev->speed; @@ -643,8 +643,8 @@ void CFlockingFlyer::FlockLeaderThink( void ) // check and make sure we aren't about to plow into the ground, don't let it happen UTIL_TraceLine( pev->origin, pev->origin - gpGlobals->v_up * 16, ignore_monsters, ENT( pev ), &tr ); - if( tr.flFraction != 1.0 && pev->velocity.z < 0 ) - pev->velocity.z = 0; + if( tr.flFraction != 1.0f && pev->velocity.z < 0.0f ) + pev->velocity.z = 0.0f; // maybe it did, though. if( FBitSet( pev->flags, FL_ONGROUND ) ) @@ -675,7 +675,7 @@ void CFlockingFlyer::FlockFollowerThink( void ) Vector vecDirToLeader; float flDistToLeader; - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; if( IsLeader() || !InSquad() ) { @@ -698,19 +698,19 @@ void CFlockingFlyer::FlockFollowerThink( void ) // if we're too far away, speed up if( flDistToLeader > AFLOCK_TOO_FAR ) { - m_flGoalSpeed = m_pSquadLeader->pev->velocity.Length() * 1.5; + m_flGoalSpeed = m_pSquadLeader->pev->velocity.Length() * 1.5f; } // if we're too close, slow down else if( flDistToLeader < AFLOCK_TOO_CLOSE ) { - m_flGoalSpeed = m_pSquadLeader->pev->velocity.Length() * 0.5; + m_flGoalSpeed = m_pSquadLeader->pev->velocity.Length() * 0.5f; } } else { // wait up! the leader isn't out in front, so we slow down to let him pass - m_flGoalSpeed = m_pSquadLeader->pev->velocity.Length() * 0.5; + m_flGoalSpeed = m_pSquadLeader->pev->velocity.Length() * 0.5f; } SpreadFlock2(); @@ -722,13 +722,13 @@ void CFlockingFlyer::FlockFollowerThink( void ) if( flDistToLeader > AFLOCK_TOO_FAR ) { vecDirToLeader = vecDirToLeader.Normalize(); - pev->velocity = (pev->velocity + vecDirToLeader) * 0.5; + pev->velocity = (pev->velocity + vecDirToLeader) * 0.5f; } // clamp speeds and handle acceleration - if( m_flGoalSpeed > AFLOCK_FLY_SPEED * 2 ) + if( m_flGoalSpeed > AFLOCK_FLY_SPEED * 2.0f ) { - m_flGoalSpeed = AFLOCK_FLY_SPEED * 2; + m_flGoalSpeed = AFLOCK_FLY_SPEED * 2.0f; } if( pev->speed < m_flGoalSpeed ) @@ -783,7 +783,7 @@ void CFlockingFlyer::FlockFollowerThink( void ) // else slide left else { - m_vecAdjustedVelocity = gpGlobals->v_right * -1; + m_vecAdjustedVelocity = gpGlobals->v_right * -1.0f; } } return; diff --git a/dlls/agrunt.cpp b/dlls/agrunt.cpp index cb47ac65..6c58ba8c 100644 --- a/dlls/agrunt.cpp +++ b/dlls/agrunt.cpp @@ -64,7 +64,7 @@ int iAgruntMuzzleFlash; #define AGRUNT_AE_LEFT_PUNCH ( 12 ) #define AGRUNT_AE_RIGHT_PUNCH ( 13 ) -#define AGRUNT_MELEE_DIST 100 +#define AGRUNT_MELEE_DIST 100.0f class CAGrunt : public CSquadMonster { @@ -77,8 +77,8 @@ public: void HandleAnimEvent( MonsterEvent_t *pEvent ); void SetObjectCollisionBox( void ) { - pev->absmin = pev->origin + Vector( -32, -32, 0 ); - pev->absmax = pev->origin + Vector( 32, 32, 85 ); + pev->absmin = pev->origin + Vector( -32.0f, -32.0f, 0.0f ); + pev->absmax = pev->origin + Vector( 32.0f, 32.0f, 85.0f ); } Schedule_t *GetSchedule( void ); @@ -219,7 +219,7 @@ void CAGrunt::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir // hit armor if( pev->dmgtime != gpGlobals->time || ( RANDOM_LONG( 0, 10 ) < 1 ) ) { - UTIL_Ricochet( ptr->vecEndPos, RANDOM_FLOAT( 1, 2 ) ); + UTIL_Ricochet( ptr->vecEndPos, RANDOM_FLOAT( 1.0f, 2.0f ) ); pev->dmgtime = gpGlobals->time; } @@ -227,11 +227,11 @@ void CAGrunt::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir { Vector vecTracerDir = vecDir; - vecTracerDir.x += RANDOM_FLOAT( -0.3, 0.3 ); - vecTracerDir.y += RANDOM_FLOAT( -0.3, 0.3 ); - vecTracerDir.z += RANDOM_FLOAT( -0.3, 0.3 ); + vecTracerDir.x += RANDOM_FLOAT( -0.3f, 0.3f ); + vecTracerDir.y += RANDOM_FLOAT( -0.3f, 0.3f ); + vecTracerDir.z += RANDOM_FLOAT( -0.3f, 0.3f ); - vecTracerDir = vecTracerDir * -512; + vecTracerDir = vecTracerDir * -512.0f; MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, ptr->vecEndPos ); WRITE_BYTE( TE_TRACER ); @@ -245,9 +245,9 @@ void CAGrunt::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir MESSAGE_END(); } - flDamage -= 20; - if( flDamage <= 0 ) - flDamage = 0.1;// don't hurt the monster much, but allow bits_COND_LIGHT_DAMAGE to be generated + flDamage -= 20.0f; + if( flDamage <= 0.0f ) + flDamage = 0.1f;// don't hurt the monster much, but allow bits_COND_LIGHT_DAMAGE to be generated } else { @@ -263,7 +263,7 @@ void CAGrunt::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir //========================================================= void CAGrunt::StopTalking( void ) { - m_flNextWordTime = m_flNextSpeakTime = gpGlobals->time + 10 + RANDOM_LONG( 0, 10 ); + m_flNextWordTime = m_flNextSpeakTime = gpGlobals->time + 10.0f + RANDOM_LONG( 0, 10 ); } //========================================================= @@ -285,7 +285,7 @@ BOOL CAGrunt::ShouldSpeak( void ) // if not going to talk because of this, put the talk time // into the future a bit, so we don't talk immediately after // going into combat - m_flNextSpeakTime = gpGlobals->time + 3; + m_flNextSpeakTime = gpGlobals->time + 3.0f; return FALSE; } } @@ -312,7 +312,7 @@ void CAGrunt::PrescheduleThink( void ) m_iLastWord = num; // play a new sound - EMIT_SOUND( ENT( pev ), CHAN_VOICE, pIdleSounds[num], 1.0, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, pIdleSounds[num], 1.0f, ATTN_NORM ); // is this word our last? if( RANDOM_LONG( 1, 10 ) <= 1 ) @@ -322,7 +322,7 @@ void CAGrunt::PrescheduleThink( void ) } else { - m_flNextWordTime = gpGlobals->time + RANDOM_FLOAT( 0.5, 1 ); + m_flNextWordTime = gpGlobals->time + RANDOM_FLOAT( 0.5f, 1.0f ); } } } @@ -335,7 +335,7 @@ void CAGrunt::DeathSound( void ) { StopTalking(); - EMIT_SOUND( ENT( pev ), CHAN_VOICE, pDieSounds[RANDOM_LONG( 0, ARRAYSIZE( pDieSounds ) - 1 )], 1.0, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, RANDOM_SOUND_ARRAY( pDieSounds ), 1.0f, ATTN_NORM ); } //========================================================= @@ -345,7 +345,7 @@ void CAGrunt::AlertSound( void ) { StopTalking(); - EMIT_SOUND( ENT( pev ), CHAN_VOICE, pAlertSounds[RANDOM_LONG( 0, ARRAYSIZE( pAlertSounds ) - 1 )], 1.0, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, RANDOM_SOUND_ARRAY( pAlertSounds ), 1.0f, ATTN_NORM ); } //========================================================= @@ -355,7 +355,7 @@ void CAGrunt::AttackSound( void ) { StopTalking(); - EMIT_SOUND( ENT( pev ), CHAN_VOICE, pAttackSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackSounds ) - 1 )], 1.0, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, RANDOM_SOUND_ARRAY( pAttackSounds ), 1.0f, ATTN_NORM ); } //========================================================= @@ -368,11 +368,11 @@ void CAGrunt::PainSound( void ) return; } - m_flNextPainTime = gpGlobals->time + 0.6; + m_flNextPainTime = gpGlobals->time + 0.6f; StopTalking(); - EMIT_SOUND( ENT( pev ), CHAN_VOICE, pPainSounds[RANDOM_LONG( 0, ARRAYSIZE( pPainSounds ) - 1 )], 1.0, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, RANDOM_SOUND_ARRAY( pPainSounds ), 1.0f, ATTN_NORM ); } //========================================================= @@ -443,15 +443,15 @@ void CAGrunt::HandleAnimEvent( MonsterEvent_t *pEvent ) pev->effects = EF_MUZZLEFLASH; // make angles +-180 - if( angDir.x > 180 ) + if( angDir.x > 180.0f ) { - angDir.x = angDir.x - 360; + angDir.x = angDir.x - 360.0f; } SetBlending( 0, angDir.x ); GetAttachment( 0, vecArmPos, vecArmDir ); - vecArmPos = vecArmPos + vecDirToEnemy * 32; + vecArmPos = vecArmPos + vecDirToEnemy * 32.0f; MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecArmPos ); WRITE_BYTE( TE_SPRITE ); WRITE_COORD( vecArmPos.x ); // pos @@ -463,10 +463,10 @@ void CAGrunt::HandleAnimEvent( MonsterEvent_t *pEvent ) MESSAGE_END(); CBaseEntity *pHornet = CBaseEntity::Create( "hornet", vecArmPos, UTIL_VecToAngles( vecDirToEnemy ), edict() ); - UTIL_MakeVectors ( pHornet->pev->angles ); - pHornet->pev->velocity = gpGlobals->v_forward * 300; + UTIL_MakeVectors( pHornet->pev->angles ); + pHornet->pev->velocity = gpGlobals->v_forward * 300.0f; - switch( RANDOM_LONG ( 0 , 2 ) ) + switch( RANDOM_LONG( 0, 2 ) ) { case 0: EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "agrunt/ag_fire1.wav", 1.0, ATTN_NORM, 0, 100 ); @@ -507,7 +507,7 @@ void CAGrunt::HandleAnimEvent( MonsterEvent_t *pEvent ) EMIT_SOUND_DYN( ENT( pev ), CHAN_BODY, "player/pl_ladder1.wav", 1, ATTN_NORM, 0, 70 ); break; case 1: - EMIT_SOUND_DYN( ENT( pev ), CHAN_BODY, "player/pl_ladder3.wav", 1, ATTN_NORM, 0 ,70); + EMIT_SOUND_DYN( ENT( pev ), CHAN_BODY, "player/pl_ladder3.wav", 1, ATTN_NORM, 0, 70 ); break; } break; @@ -518,17 +518,17 @@ void CAGrunt::HandleAnimEvent( MonsterEvent_t *pEvent ) if( pHurt ) { - pHurt->pev->punchangle.y = -25; - pHurt->pev->punchangle.x = 8; + pHurt->pev->punchangle.y = -25.0f; + pHurt->pev->punchangle.x = 8.0f; // OK to use gpGlobals without calling MakeVectors, cause CheckTraceHullAttack called it above. if( pHurt->IsPlayer() ) { // this is a player. Knock him around. - pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_right * 250; + pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_right * 250.0f; } - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackHitSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackHitSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackHitSounds ), 1.0f, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); Vector vecArmPos, vecArmAng; GetAttachment( 0, vecArmPos, vecArmAng ); @@ -537,7 +537,7 @@ void CAGrunt::HandleAnimEvent( MonsterEvent_t *pEvent ) else { // Play a random attack miss sound - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackMissSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackMissSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackMissSounds ), 1.0f, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); } } break; @@ -547,17 +547,17 @@ void CAGrunt::HandleAnimEvent( MonsterEvent_t *pEvent ) if( pHurt ) { - pHurt->pev->punchangle.y = 25; - pHurt->pev->punchangle.x = 8; + pHurt->pev->punchangle.y = 25.0f; + pHurt->pev->punchangle.x = 8.0f; // OK to use gpGlobals without calling MakeVectors, cause CheckTraceHullAttack called it above. if( pHurt->IsPlayer() ) { // this is a player. Knock him around. - pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_right * -250; + pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_right * -250.0f; } - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackHitSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackHitSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackHitSounds ), 1.0f, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); Vector vecArmPos, vecArmAng; GetAttachment( 0, vecArmPos, vecArmAng ); @@ -566,7 +566,7 @@ void CAGrunt::HandleAnimEvent( MonsterEvent_t *pEvent ) else { // Play a random attack miss sound - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackMissSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackMissSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackMissSounds ), 1.0f, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); } } break; @@ -584,21 +584,21 @@ void CAGrunt::Spawn() Precache(); SET_MODEL( ENT( pev ), "models/agrunt.mdl" ); - UTIL_SetSize( pev, Vector( -32, -32, 0 ), Vector( 32, 32, 64 ) ); + UTIL_SetSize( pev, Vector( -32.0f, -32.0f, 0.0f ), Vector( 32.0f, 32.0f, 64.0f ) ); pev->solid = SOLID_SLIDEBOX; pev->movetype = MOVETYPE_STEP; m_bloodColor = BLOOD_COLOR_GREEN; pev->effects = 0; pev->health = gSkillData.agruntHealth; - m_flFieldOfView = 0.2;// indicates the width of this monster's forward view cone ( as a dotproduct result ) + m_flFieldOfView = 0.2f;// indicates the width of this monster's forward view cone ( as a dotproduct result ) m_MonsterState = MONSTERSTATE_NONE; m_afCapability = 0; m_afCapability |= bits_CAP_SQUAD; - m_HackedGunPos = Vector( 24, 64, 48 ); + m_HackedGunPos = Vector( 24.0f, 64.0f, 48.0f ); - m_flNextSpeakTime = m_flNextWordTime = gpGlobals->time + 10 + RANDOM_LONG( 0, 10 ); + m_flNextSpeakTime = m_flNextWordTime = gpGlobals->time + 10.0f + RANDOM_LONG( 0, 10 ); MonsterInit(); } @@ -608,30 +608,15 @@ void CAGrunt::Spawn() //========================================================= void CAGrunt::Precache() { - size_t i; - PRECACHE_MODEL( "models/agrunt.mdl" ); - for( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) - PRECACHE_SOUND( pAttackHitSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) - PRECACHE_SOUND( pAttackMissSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pIdleSounds ); i++ ) - PRECACHE_SOUND( pIdleSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pDieSounds ); i++ ) - PRECACHE_SOUND( pDieSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) - PRECACHE_SOUND( pPainSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) - PRECACHE_SOUND( pAttackSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) - PRECACHE_SOUND( pAlertSounds[i] ); + PRECACHE_SOUND_ARRAY( pAttackHitSounds ); + PRECACHE_SOUND_ARRAY( pAttackMissSounds ); + PRECACHE_SOUND_ARRAY( pIdleSounds ); + PRECACHE_SOUND_ARRAY( pDieSounds ); + PRECACHE_SOUND_ARRAY( pPainSounds ); + PRECACHE_SOUND_ARRAY( pAttackSounds ); + PRECACHE_SOUND_ARRAY( pAlertSounds ); PRECACHE_SOUND( "hassault/hw_shoot1.wav" ); @@ -651,8 +636,8 @@ Task_t tlAGruntFail[] = { { TASK_STOP_MOVING, 0 }, { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_WAIT, (float)2 }, - { TASK_WAIT_PVS, (float)0 }, + { TASK_WAIT, 2.0f }, + { TASK_WAIT_PVS, 0.0f }, }; Schedule_t slAGruntFail[] = @@ -674,8 +659,8 @@ Task_t tlAGruntCombatFail[] = { { TASK_STOP_MOVING, 0 }, { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_WAIT_FACE_ENEMY, (float)2 }, - { TASK_WAIT_PVS, (float)0 }, + { TASK_WAIT_FACE_ENEMY, 2.0f }, + { TASK_WAIT_PVS, 0.0f }, }; Schedule_t slAGruntCombatFail[] = @@ -697,9 +682,9 @@ Schedule_t slAGruntCombatFail[] = //========================================================= Task_t tlAGruntStandoff[] = { - { TASK_STOP_MOVING, (float)0 }, + { TASK_STOP_MOVING, 0.0f }, { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_WAIT_FACE_ENEMY, (float)2 }, + { TASK_WAIT_FACE_ENEMY, 2.0f }, }; Schedule_t slAGruntStandoff[] = @@ -722,8 +707,8 @@ Schedule_t slAGruntStandoff[] = //========================================================= Task_t tlAGruntSuppressHornet[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_RANGE_ATTACK1, (float)0 }, + { TASK_STOP_MOVING, 0.0f }, + { TASK_RANGE_ATTACK1, 0.0f }, }; Schedule_t slAGruntSuppress[] = @@ -742,9 +727,9 @@ Schedule_t slAGruntSuppress[] = //========================================================= Task_t tlAGruntRangeAttack1[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_RANGE_ATTACK1, (float)0 }, + { TASK_STOP_MOVING, 0.0f }, + { TASK_FACE_ENEMY, 0.0f }, + { TASK_RANGE_ATTACK1, 0.0f }, }; Schedule_t slAGruntRangeAttack1[] = @@ -788,13 +773,13 @@ Schedule_t slAGruntHiddenRangeAttack[] = //========================================================= Task_t tlAGruntTakeCoverFromEnemy[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_WAIT, (float)0.2 }, - { TASK_FIND_COVER_FROM_ENEMY, (float)0 }, - { TASK_RUN_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_STOP_MOVING, 0.0f }, + { TASK_WAIT, 0.2f }, + { TASK_FIND_COVER_FROM_ENEMY, 0.0f }, + { TASK_RUN_PATH, 0.0f }, + { TASK_WAIT_FOR_MOVEMENT, 0.0f }, { TASK_REMEMBER, (float)bits_MEMORY_INCOVER }, - { TASK_FACE_ENEMY, (float)0 }, + { TASK_FACE_ENEMY, 0.0f }, }; Schedule_t slAGruntTakeCoverFromEnemy[] = @@ -813,13 +798,13 @@ Schedule_t slAGruntTakeCoverFromEnemy[] = //========================================================= Task_t tlAGruntVictoryDance[] = { - { TASK_STOP_MOVING, (float)0 }, + { TASK_STOP_MOVING, 0.0f }, { TASK_SET_FAIL_SCHEDULE, (float)SCHED_AGRUNT_THREAT_DISPLAY }, - { TASK_WAIT, (float)0.2 }, - { TASK_AGRUNT_GET_PATH_TO_ENEMY_CORPSE, (float)0 }, - { TASK_WALK_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_FACE_ENEMY, (float)0 }, + { TASK_WAIT, 0.2f }, + { TASK_AGRUNT_GET_PATH_TO_ENEMY_CORPSE, 0.0f }, + { TASK_WALK_PATH, 0.0f }, + { TASK_WAIT_FOR_MOVEMENT, 0.0f }, + { TASK_FACE_ENEMY, 0.0f }, { TASK_PLAY_SEQUENCE, (float)ACT_CROUCH }, { TASK_PLAY_SEQUENCE, (float)ACT_VICTORY_DANCE }, { TASK_PLAY_SEQUENCE, (float)ACT_VICTORY_DANCE }, @@ -851,8 +836,8 @@ Schedule_t slAGruntVictoryDance[] = //========================================================= Task_t tlAGruntThreatDisplay[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_FACE_ENEMY, (float)0 }, + { TASK_STOP_MOVING, 0.0f }, + { TASK_FACE_ENEMY, 0.0f }, { TASK_PLAY_SEQUENCE, (float)ACT_THREAT_DISPLAY }, }; @@ -909,7 +894,7 @@ BOOL CAGrunt::FCanCheckAttacks( void ) //========================================================= BOOL CAGrunt::CheckMeleeAttack1( float flDot, float flDist ) { - if( HasConditions( bits_COND_SEE_ENEMY ) && flDist <= AGRUNT_MELEE_DIST && flDot >= 0.6 && m_hEnemy != 0 ) + if( HasConditions( bits_COND_SEE_ENEMY ) && flDist <= AGRUNT_MELEE_DIST && flDot >= 0.6f && m_hEnemy != 0 ) { return TRUE; } @@ -930,7 +915,7 @@ BOOL CAGrunt::CheckRangeAttack1( float flDot, float flDist ) return m_fCanHornetAttack; } - if( HasConditions( bits_COND_SEE_ENEMY ) && flDist >= AGRUNT_MELEE_DIST && flDist <= 1024 && flDot >= 0.5 && NoFriendlyFire() ) + if( HasConditions( bits_COND_SEE_ENEMY ) && flDist >= AGRUNT_MELEE_DIST && flDist <= 1024.0f && flDot >= 0.5f && NoFriendlyFire() ) { TraceResult tr; Vector vecArmPos, vecArmDir; @@ -939,18 +924,18 @@ BOOL CAGrunt::CheckRangeAttack1( float flDot, float flDist ) // !!!LATER - we may wish to do something different for projectile weapons as opposed to instant-hit UTIL_MakeVectors( pev->angles ); GetAttachment( 0, vecArmPos, vecArmDir ); - //UTIL_TraceLine( vecArmPos, vecArmPos + gpGlobals->v_forward * 256, ignore_monsters, ENT( pev ), &tr ); + //UTIL_TraceLine( vecArmPos, vecArmPos + gpGlobals->v_forward * 256.0f, ignore_monsters, ENT( pev ), &tr ); UTIL_TraceLine( vecArmPos, m_hEnemy->BodyTarget( vecArmPos ), dont_ignore_monsters, ENT( pev ), &tr ); - if( tr.flFraction == 1.0 || tr.pHit == m_hEnemy->edict() ) + if( tr.flFraction == 1.0f || tr.pHit == m_hEnemy->edict() ) { - m_flNextHornetAttackCheck = gpGlobals->time + RANDOM_FLOAT( 2, 5 ); + m_flNextHornetAttackCheck = gpGlobals->time + RANDOM_FLOAT( 2.0f, 5.0f ); m_fCanHornetAttack = TRUE; return m_fCanHornetAttack; } } - m_flNextHornetAttackCheck = gpGlobals->time + 0.2;// don't check for half second if this check wasn't successful + m_flNextHornetAttackCheck = gpGlobals->time + 0.2f;// don't check for half second if this check wasn't successful m_fCanHornetAttack = FALSE; return m_fCanHornetAttack; } @@ -965,7 +950,7 @@ void CAGrunt::StartTask( Task_t *pTask ) case TASK_AGRUNT_GET_PATH_TO_ENEMY_CORPSE: { UTIL_MakeVectors( pev->angles ); - if( BuildRoute( m_vecEnemyLKP - gpGlobals->v_forward * 50, bits_MF_TO_LOCATION, NULL ) ) + if( BuildRoute( m_vecEnemyLKP - gpGlobals->v_forward * 50.0f, bits_MF_TO_LOCATION, NULL ) ) { TaskComplete(); } @@ -995,20 +980,20 @@ void CAGrunt::StartTask( Task_t *pTask ) UTIL_VecToAngles( m_vecEnemyLKP - pev->origin ); - UTIL_TraceLine( Center() + gpGlobals->v_forward * 128, m_vecEnemyLKP, ignore_monsters, ENT( pev ), &tr ); - if( tr.flFraction == 1.0 ) + UTIL_TraceLine( Center() + gpGlobals->v_forward * 128.0f, m_vecEnemyLKP, ignore_monsters, ENT( pev ), &tr ); + if( tr.flFraction == 1.0f ) { - MakeIdealYaw( pev->origin + gpGlobals->v_right * 128 ); + MakeIdealYaw( pev->origin + gpGlobals->v_right * 128.0f ); fSkip = TRUE; TaskComplete(); } if( !fSkip ) { - UTIL_TraceLine( Center() - gpGlobals->v_forward * 128, m_vecEnemyLKP, ignore_monsters, ENT( pev ), &tr ); - if( tr.flFraction == 1.0 ) + UTIL_TraceLine( Center() - gpGlobals->v_forward * 128.0f, m_vecEnemyLKP, ignore_monsters, ENT( pev ), &tr ); + if( tr.flFraction == 1.0f ) { - MakeIdealYaw( pev->origin - gpGlobals->v_right * 128 ); + MakeIdealYaw( pev->origin - gpGlobals->v_right * 128.0f ); fSkip = TRUE; TaskComplete(); } @@ -1016,10 +1001,10 @@ void CAGrunt::StartTask( Task_t *pTask ) if( !fSkip ) { - UTIL_TraceLine( Center() + gpGlobals->v_forward * 256, m_vecEnemyLKP, ignore_monsters, ENT( pev ), &tr ); - if( tr.flFraction == 1.0 ) + UTIL_TraceLine( Center() + gpGlobals->v_forward * 256.0f, m_vecEnemyLKP, ignore_monsters, ENT( pev ), &tr ); + if( tr.flFraction == 1.0f ) { - MakeIdealYaw( pev->origin + gpGlobals->v_right * 256 ); + MakeIdealYaw( pev->origin + gpGlobals->v_right * 256.0f ); fSkip = TRUE; TaskComplete(); } @@ -1027,10 +1012,10 @@ void CAGrunt::StartTask( Task_t *pTask ) if( !fSkip ) { - UTIL_TraceLine( Center() - gpGlobals->v_forward * 256, m_vecEnemyLKP, ignore_monsters, ENT( pev ), &tr ); - if( tr.flFraction == 1.0 ) + UTIL_TraceLine( Center() - gpGlobals->v_forward * 256.0f, m_vecEnemyLKP, ignore_monsters, ENT( pev ), &tr ); + if( tr.flFraction == 1.0f ) { - MakeIdealYaw( pev->origin - gpGlobals->v_right * 256 ); + MakeIdealYaw( pev->origin - gpGlobals->v_right * 256.0f ); fSkip = TRUE; TaskComplete(); } diff --git a/dlls/animating.cpp b/dlls/animating.cpp index 95e8b86b..d6cb4190 100644 --- a/dlls/animating.cpp +++ b/dlls/animating.cpp @@ -28,11 +28,11 @@ TYPEDESCRIPTION CBaseAnimating::m_SaveData[] = { - DEFINE_FIELD( CBaseMonster, m_flFrameRate, FIELD_FLOAT ), - DEFINE_FIELD( CBaseMonster, m_flGroundSpeed, FIELD_FLOAT ), - DEFINE_FIELD( CBaseMonster, m_flLastEventCheck, FIELD_TIME ), - DEFINE_FIELD( CBaseMonster, m_fSequenceFinished, FIELD_BOOLEAN ), - DEFINE_FIELD( CBaseMonster, m_fSequenceLoops, FIELD_BOOLEAN ), + DEFINE_FIELD( CBaseAnimating, m_flFrameRate, FIELD_FLOAT ), + DEFINE_FIELD( CBaseAnimating, m_flGroundSpeed, FIELD_FLOAT ), + DEFINE_FIELD( CBaseAnimating, m_flLastEventCheck, FIELD_TIME ), + DEFINE_FIELD( CBaseAnimating, m_fSequenceFinished, FIELD_BOOLEAN ), + DEFINE_FIELD( CBaseAnimating, m_fSequenceLoops, FIELD_BOOLEAN ), }; IMPLEMENT_SAVERESTORE( CBaseAnimating, CBaseDelay ) @@ -43,27 +43,27 @@ IMPLEMENT_SAVERESTORE( CBaseAnimating, CBaseDelay ) //========================================================= float CBaseAnimating::StudioFrameAdvance( float flInterval ) { - if( flInterval == 0.0 ) + if( flInterval == 0.0f ) { flInterval = gpGlobals->time - pev->animtime; - if( flInterval <= 0.001 ) + if( flInterval <= 0.001f ) { pev->animtime = gpGlobals->time; - return 0.0; + return 0.0f; } } if( !pev->animtime ) - flInterval = 0.0; + flInterval = 0.0f; pev->frame += flInterval * m_flFrameRate * pev->framerate; pev->animtime = gpGlobals->time; - if( pev->frame < 0.0 || pev->frame >= 256.0 ) + if( pev->frame < 0.0f || pev->frame >= 256.0f ) { if( m_fSequenceLoops ) - pev->frame -= (int)( pev->frame / 256.0 ) * 256.0; + pev->frame -= (int)( pev->frame / 256.0f ) * 256.0f; else - pev->frame = ( pev->frame < 0.0 ) ? 0 : 255; + pev->frame = ( pev->frame < 0.0f ) ? 0.0f : 255.0f; m_fSequenceFinished = TRUE; // just in case it wasn't caught in GetEvents } @@ -142,7 +142,7 @@ void CBaseAnimating::DispatchAnimEvents( float flInterval ) } // FIXME: I have to do this or some events get missed, and this is probably causing the problem below - flInterval = 0.1; + flInterval = 0.1f; // FIX: this still sometimes hits events twice float flStart = pev->frame + ( m_flLastEventCheck - pev->animtime ) * m_flFrameRate * pev->framerate; @@ -150,7 +150,7 @@ void CBaseAnimating::DispatchAnimEvents( float flInterval ) m_flLastEventCheck = pev->animtime + flInterval; m_fSequenceFinished = FALSE; - if( flEnd >= 256 || flEnd <= 0.0 ) + if( flEnd >= 256.0f || flEnd <= 0.0f ) m_fSequenceFinished = TRUE; int index = 0; @@ -258,7 +258,7 @@ void CBaseAnimating::SetSequenceBox( void ) { // expand box for rotation // find min / max for rotations - float yaw = pev->angles.y * ( M_PI / 180.0 ); + float yaw = pev->angles.y * ( M_PI_F / 180.0f ); Vector xvector, yvector; xvector.x = cos( yaw ); @@ -270,8 +270,8 @@ void CBaseAnimating::SetSequenceBox( void ) bounds[0] = mins; bounds[1] = maxs; - Vector rmin( 9999, 9999, 9999 ); - Vector rmax( -9999, -9999, -9999 ); + Vector rmin( 9999.0f, 9999.0f, 9999.0f ); + Vector rmax( -9999.0f, -9999.0f, -9999.0f ); Vector base, transformed; for( int i = 0; i <= 1; i++ ) @@ -304,8 +304,8 @@ void CBaseAnimating::SetSequenceBox( void ) } } } - rmin.z = 0; - rmax.z = rmin.z + 1; + rmin.z = 0.0f; + rmax.z = rmin.z + 1.0f; UTIL_SetSize( pev, rmin, rmax ); } } diff --git a/dlls/animation.cpp b/dlls/animation.cpp index f84ec380..c66d49cd 100644 --- a/dlls/animation.cpp +++ b/dlls/animation.cpp @@ -13,6 +13,10 @@ * ****/ +/* all this mess was here to use quake mathlib instead of hlsdk vectors +* it may break debug info or even build because global symbols types differ +* it's better to define VectorCopy macro for Vector class */ +#if 0 #include #include #include @@ -32,25 +36,35 @@ typedef unsigned char byte; #include "studio.h" -#ifndef ACTIVITY_H +#if !defined(ACTIVITY_H) #include "activity.h" #endif #include "activitymap.h" -#ifndef ANIMATION_H +#if !defined(ANIMATION_H) #include "animation.h" #endif -#ifndef SCRIPTEVENT_H +#if !defined(SCRIPTEVENT_H) #include "scriptevent.h" #endif -#ifndef ENGINECALLBACK_H +#if !defined(ENGINECALLBACK_H) #include "enginecallback.h" #endif -extern globalvars_t *gpGlobals; +//extern globalvars_t *gpGlobals; +#else +#include "extdll.h" +#include "util.h" +#include "activity.h" +#include "activitymap.h" +#include "animation.h" +#include "scriptevent.h" +#include "studio.h" +#define VectorCopy(a,b) {(b)[0]=(a)[0];(b)[1]=(a)[1];(b)[2]=(a)[2];} +#endif #pragma warning( disable : 4244 ) @@ -203,7 +217,7 @@ void SequencePrecache( void *pmodel, const char *pSequenceName ) // of it's name if it is. if( IsSoundEvent( pevent[i].event ) ) { - if( !strlen( pevent[i].options ) ) + if( pevent[i].options[0] == '\0' ) { ALERT( at_error, "Bad sound event %d in sequence %s :: %s (sound is \"%s\")\n", pevent[i].event, pstudiohdr->name, pSequenceName, pevent[i].options ); } @@ -224,10 +238,10 @@ void GetSequenceInfo( void *pmodel, entvars_t *pev, float *pflFrameRate, float * mstudioseqdesc_t *pseqdesc; - if( pev->sequence >= pstudiohdr->numseq ) + if( pev->sequence < 0 || pev->sequence >= pstudiohdr->numseq ) { - *pflFrameRate = 0.0; - *pflGroundSpeed = 0.0; + *pflFrameRate = 0.0f; + *pflGroundSpeed = 0.0f; return; } @@ -235,14 +249,14 @@ void GetSequenceInfo( void *pmodel, entvars_t *pev, float *pflFrameRate, float * if( pseqdesc->numframes > 1 ) { - *pflFrameRate = 256 * pseqdesc->fps / ( pseqdesc->numframes - 1 ); + *pflFrameRate = 256.0f * pseqdesc->fps / ( pseqdesc->numframes - 1 ); *pflGroundSpeed = sqrt( pseqdesc->linearmovement[0] * pseqdesc->linearmovement[0] + pseqdesc->linearmovement[1] * pseqdesc->linearmovement[1] + pseqdesc->linearmovement[2] * pseqdesc->linearmovement[2] ); *pflGroundSpeed = *pflGroundSpeed * pseqdesc->fps / ( pseqdesc->numframes - 1 ); } else { - *pflFrameRate = 256.0; - *pflGroundSpeed = 0.0; + *pflFrameRate = 256.0f; + *pflGroundSpeed = 0.0f; } } @@ -251,7 +265,7 @@ int GetSequenceFlags( void *pmodel, entvars_t *pev ) studiohdr_t *pstudiohdr; pstudiohdr = (studiohdr_t *)pmodel; - if( !pstudiohdr || pev->sequence >= pstudiohdr->numseq ) + if( !pstudiohdr || pev->sequence < 0 || pev->sequence >= pstudiohdr->numseq ) return 0; mstudioseqdesc_t *pseqdesc; @@ -265,7 +279,7 @@ int GetAnimationEvent( void *pmodel, entvars_t *pev, MonsterEvent_t *pMonsterEve studiohdr_t *pstudiohdr; pstudiohdr = (studiohdr_t *)pmodel; - if( !pstudiohdr || pev->sequence >= pstudiohdr->numseq || !pMonsterEvent ) + if( !pstudiohdr || pev->sequence < 0 || pev->sequence >= pstudiohdr->numseq || !pMonsterEvent ) return 0; mstudioseqdesc_t *pseqdesc; @@ -279,13 +293,13 @@ int GetAnimationEvent( void *pmodel, entvars_t *pev, MonsterEvent_t *pMonsterEve if( pseqdesc->numframes > 1 ) { - flStart *= ( pseqdesc->numframes - 1 ) / 256.0; - flEnd *= (pseqdesc->numframes - 1) / 256.0; + flStart *= ( pseqdesc->numframes - 1 ) / 256.0f; + flEnd *= (pseqdesc->numframes - 1) / 256.0f; } else { - flStart = 0; - flEnd = 1.0; + flStart = 0.0f; + flEnd = 1.0f; } for( ; index < pseqdesc->numevents; index++ ) @@ -333,19 +347,19 @@ float SetController( void *pmodel, entvars_t *pev, int iController, float flValu flValue = -flValue; // does the controller not wrap? - if( pbonecontroller->start + 359.0 >= pbonecontroller->end ) + if( pbonecontroller->start + 359.0f >= pbonecontroller->end ) { - if( flValue > ( ( pbonecontroller->start + pbonecontroller->end ) / 2.0 ) + 180 ) - flValue = flValue - 360; - if( flValue < ( ( pbonecontroller->start + pbonecontroller->end) / 2.0 ) - 180 ) - flValue = flValue + 360; + if( flValue > ( ( pbonecontroller->start + pbonecontroller->end ) * 0.5f ) + 180.0f ) + flValue = flValue - 360.0f; + if( flValue < ( ( pbonecontroller->start + pbonecontroller->end ) * 0.5f ) - 180.0f ) + flValue = flValue + 360.0f; } else { - if( flValue > 360 ) - flValue = flValue - (int)( flValue / 360.0 ) * 360.0; - else if( flValue < 0 ) - flValue = flValue + (int)( ( flValue / -360.0 ) + 1 ) * 360.0; + if( flValue > 360.0f ) + flValue = flValue - (int)( flValue / 360.0f ) * 360.0f; + else if( flValue < 0.0f ) + flValue = flValue + (int)( ( flValue / -360.0f ) + 1.0f ) * 360.0f; } } @@ -357,7 +371,7 @@ float SetController( void *pmodel, entvars_t *pev, int iController, float flValu setting = 255; pev->controller[iController] = setting; - return setting * ( 1.0 / 255.0 ) * (pbonecontroller->end - pbonecontroller->start ) + pbonecontroller->start; + return setting * ( 1.0f / 255.0f ) * (pbonecontroller->end - pbonecontroller->start ) + pbonecontroller->start; } float SetBlending( void *pmodel, entvars_t *pev, int iBlender, float flValue ) @@ -365,7 +379,7 @@ float SetBlending( void *pmodel, entvars_t *pev, int iBlender, float flValue ) studiohdr_t *pstudiohdr; pstudiohdr = (studiohdr_t *)pmodel; - if( !pstudiohdr ) + if( !pstudiohdr || pev->sequence < 0 || pev->sequence >= pstudiohdr->numseq ) return flValue; mstudioseqdesc_t *pseqdesc; @@ -382,12 +396,12 @@ float SetBlending( void *pmodel, entvars_t *pev, int iBlender, float flValue ) flValue = -flValue; // does the controller not wrap? - if( pseqdesc->blendstart[iBlender] + 359.0 >= pseqdesc->blendend[iBlender] ) + if( pseqdesc->blendstart[iBlender] + 359.0f >= pseqdesc->blendend[iBlender] ) { - if( flValue > ( ( pseqdesc->blendstart[iBlender] + pseqdesc->blendend[iBlender] ) / 2.0 ) + 180 ) - flValue = flValue - 360; - if( flValue < ( ( pseqdesc->blendstart[iBlender] + pseqdesc->blendend[iBlender] ) / 2.0 ) - 180 ) - flValue = flValue + 360; + if( flValue > ( ( pseqdesc->blendstart[iBlender] + pseqdesc->blendend[iBlender] ) * 0.5f ) + 180.0f ) + flValue = flValue - 360.0f; + if( flValue < ( ( pseqdesc->blendstart[iBlender] + pseqdesc->blendend[iBlender] ) * 0.5f ) - 180.0f ) + flValue = flValue + 360.0f; } } @@ -400,7 +414,7 @@ float SetBlending( void *pmodel, entvars_t *pev, int iBlender, float flValue ) pev->blending[iBlender] = setting; - return setting * ( 1.0 / 255.0 ) * ( pseqdesc->blendend[iBlender] - pseqdesc->blendstart[iBlender] ) + pseqdesc->blendstart[iBlender]; + return setting * ( 1.0f / 255.0f ) * ( pseqdesc->blendend[iBlender] - pseqdesc->blendstart[iBlender] ) + pseqdesc->blendstart[iBlender]; } int FindTransition( void *pmodel, int iEndingAnim, int iGoalAnim, int *piDir ) diff --git a/dlls/animation.h b/dlls/animation.h index 6def910c..41e09ce6 100644 --- a/dlls/animation.h +++ b/dlls/animation.h @@ -13,12 +13,12 @@ * ****/ #pragma once -#ifndef ANIMATION_H +#if !defined(ANIMATION_H) #define ANIMATION_H #define ACTIVITY_NOT_AVAILABLE -1 -#ifndef MONSTEREVENT_H +#if !defined(MONSTEREVENT_H) #include "monsterevent.h" #endif diff --git a/dlls/apache.cpp b/dlls/apache.cpp index b3cfcf87..f37f8cb1 100644 --- a/dlls/apache.cpp +++ b/dlls/apache.cpp @@ -12,7 +12,7 @@ * use or distribution of this code by or to any unlicensed person is illegal. * ****/ -#ifndef OEM_BUILD +#if !OEM_BUILD #include "extdll.h" #include "util.h" @@ -42,8 +42,8 @@ class CApache : public CBaseMonster void SetObjectCollisionBox( void ) { - pev->absmin = pev->origin + Vector( -300, -300, -172 ); - pev->absmax = pev->origin + Vector( 300, 300, 8 ); + pev->absmin = pev->origin + Vector( -300.0f, -300.0f, -172.0f ); + pev->absmax = pev->origin + Vector( 300.0f, 300.0f, 8.0f ); } void EXPORT HuntThink( void ); @@ -123,14 +123,14 @@ void CApache::Spawn( void ) pev->solid = SOLID_BBOX; SET_MODEL( ENT( pev ), "models/apache.mdl" ); - UTIL_SetSize( pev, Vector( -32, -32, -64 ), Vector( 32, 32, 0 ) ); + UTIL_SetSize( pev, Vector( -32.0f, -32.0f, -64.0f ), Vector( 32.0f, 32.0f, 0.0f ) ); UTIL_SetOrigin( pev, pev->origin ); pev->flags |= FL_MONSTER; pev->takedamage = DAMAGE_AIM; pev->health = gSkillData.apacheHealth; - m_flFieldOfView = -0.707; // 270 degrees + m_flFieldOfView = -0.707f; // 270 degrees pev->sequence = 0; ResetSequenceInfo(); @@ -146,7 +146,7 @@ void CApache::Spawn( void ) { SetThink( &CApache::HuntThink ); SetTouch( &CApache::FlyTouch ); - pev->nextthink = gpGlobals->time + 1.0; + pev->nextthink = gpGlobals->time + 1.0f; } m_iRockets = 10; @@ -178,47 +178,47 @@ void CApache::Precache( void ) void CApache::NullThink( void ) { StudioFrameAdvance(); - pev->nextthink = gpGlobals->time + 0.5; + pev->nextthink = gpGlobals->time + 0.5f; } void CApache::StartupUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { SetThink( &CApache::HuntThink ); SetTouch( &CApache::FlyTouch ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; SetUse( NULL ); } void CApache::Killed( entvars_t *pevAttacker, int iGib ) { pev->movetype = MOVETYPE_TOSS; - pev->gravity = 0.3; + pev->gravity = 0.3f; STOP_SOUND( ENT( pev ), CHAN_STATIC, "apache/ap_rotor2.wav" ); - UTIL_SetSize( pev, Vector( -32, -32, -64 ), Vector( 32, 32, 0 ) ); + UTIL_SetSize( pev, Vector( -32.0f, -32.0f, -64.0f ), Vector( 32.0f, 32.0f, 0.0f ) ); SetThink( &CApache::DyingThink ); SetTouch( &CApache::CrashTouch ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; pev->health = 0; pev->takedamage = DAMAGE_NO; if( pev->spawnflags & SF_NOWRECKAGE ) { - m_flNextRocket = gpGlobals->time + 4.0; + m_flNextRocket = gpGlobals->time + 4.0f; } else { - m_flNextRocket = gpGlobals->time + 15.0; + m_flNextRocket = gpGlobals->time + 15.0f; } } void CApache::DyingThink( void ) { StudioFrameAdvance(); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; - pev->avelocity = pev->avelocity * 1.02; + pev->avelocity = pev->avelocity * 1.02f; // still falling? if( m_flNextRocket > gpGlobals->time ) @@ -226,9 +226,9 @@ void CApache::DyingThink( void ) // random explosions MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin ); WRITE_BYTE( TE_EXPLOSION ); // This just makes a dynamic light now - WRITE_COORD( pev->origin.x + RANDOM_FLOAT( -150, 150 ) ); - WRITE_COORD( pev->origin.y + RANDOM_FLOAT( -150, 150 ) ); - WRITE_COORD( pev->origin.z + RANDOM_FLOAT( -150, -50 ) ); + WRITE_COORD( pev->origin.x + RANDOM_FLOAT( -150.0f, 150.0f ) ); + WRITE_COORD( pev->origin.y + RANDOM_FLOAT( -150.0f, 150.0f ) ); + WRITE_COORD( pev->origin.z + RANDOM_FLOAT( -150.0f, -50.0f ) ); WRITE_SHORT( g_sModelIndexFireball ); WRITE_BYTE( RANDOM_LONG( 0, 29 ) + 30 ); // scale * 10 WRITE_BYTE( 12 ); // framerate @@ -238,15 +238,15 @@ void CApache::DyingThink( void ) // lots of smoke MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin ); WRITE_BYTE( TE_SMOKE ); - WRITE_COORD( pev->origin.x + RANDOM_FLOAT( -150, 150 ) ); - WRITE_COORD( pev->origin.y + RANDOM_FLOAT( -150, 150 ) ); - WRITE_COORD( pev->origin.z + RANDOM_FLOAT( -150, -50 ) ); + WRITE_COORD( pev->origin.x + RANDOM_FLOAT( -150.0f, 150.0f ) ); + WRITE_COORD( pev->origin.y + RANDOM_FLOAT( -150.0f, 150.0f ) ); + WRITE_COORD( pev->origin.z + RANDOM_FLOAT( -150.0f, -50.0f ) ); WRITE_SHORT( g_sModelIndexSmoke ); WRITE_BYTE( 100 ); // scale * 10 WRITE_BYTE( 10 ); // framerate MESSAGE_END(); - Vector vecSpot = pev->origin + ( pev->mins + pev->maxs ) * 0.5; + Vector vecSpot = pev->origin + ( pev->mins + pev->maxs ) * 0.5f; MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpot ); WRITE_BYTE( TE_BREAKMODEL ); @@ -283,19 +283,19 @@ void CApache::DyingThink( void ) // don't stop it we touch a entity pev->flags &= ~FL_ONGROUND; - pev->nextthink = gpGlobals->time + 0.2; + pev->nextthink = gpGlobals->time + 0.2f; return; } else { - Vector vecSpot = pev->origin + ( pev->mins + pev->maxs ) * 0.5; + Vector vecSpot = pev->origin + ( pev->mins + pev->maxs ) * 0.5f; /* MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_EXPLOSION); // This just makes a dynamic light now WRITE_COORD( vecSpot.x ); WRITE_COORD( vecSpot.y ); - WRITE_COORD( vecSpot.z + 300 ); + WRITE_COORD( vecSpot.z + 300.0f ); WRITE_SHORT( g_sModelIndexFireball ); WRITE_BYTE( 250 ); // scale * 10 WRITE_BYTE( 8 ); // framerate @@ -307,7 +307,7 @@ void CApache::DyingThink( void ) WRITE_BYTE( TE_SPRITE ); WRITE_COORD( vecSpot.x ); WRITE_COORD( vecSpot.y ); - WRITE_COORD( vecSpot.z + 256 ); + WRITE_COORD( vecSpot.z + 256.0f ); WRITE_SHORT( m_iExplode ); WRITE_BYTE( 120 ); // scale * 10 WRITE_BYTE( 255 ); // brightness @@ -318,7 +318,7 @@ void CApache::DyingThink( void ) WRITE_BYTE( TE_SMOKE ); WRITE_COORD( vecSpot.x ); WRITE_COORD( vecSpot.y ); - WRITE_COORD( vecSpot.z + 512 ); + WRITE_COORD( vecSpot.z + 512.0f ); WRITE_SHORT( g_sModelIndexSmoke ); WRITE_BYTE( 250 ); // scale * 10 WRITE_BYTE( 5 ); // framerate @@ -346,7 +346,7 @@ void CApache::DyingThink( void ) WRITE_BYTE( 0 ); // speed MESSAGE_END(); - EMIT_SOUND( ENT( pev ), CHAN_STATIC, "weapons/mortarhit.wav", 1.0, 0.3 ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, "weapons/mortarhit.wav", 1.0f, 0.3f ); RadiusDamage( pev->origin, pev, pev, 300, CLASS_NONE, DMG_BLAST ); @@ -354,22 +354,22 @@ void CApache::DyingThink( void ) { CBaseEntity *pWreckage = Create( "cycler_wreckage", pev->origin, pev->angles ); // SET_MODEL( ENT( pWreckage->pev ), STRING( pev->model ) ); - UTIL_SetSize( pWreckage->pev, Vector( -200, -200, -128 ), Vector( 200, 200, -32 ) ); + UTIL_SetSize( pWreckage->pev, Vector( -200.0f, -200.0f, -128.0f ), Vector( 200.0f, 200.0f, -32.0f ) ); pWreckage->pev->frame = pev->frame; pWreckage->pev->sequence = pev->sequence; pWreckage->pev->framerate = 0; - pWreckage->pev->dmgtime = gpGlobals->time + 5; + pWreckage->pev->dmgtime = gpGlobals->time + 5.0f; } // gibs - vecSpot = pev->origin + ( pev->mins + pev->maxs ) * 0.5; + vecSpot = pev->origin + ( pev->mins + pev->maxs ) * 0.5f; MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpot ); WRITE_BYTE( TE_BREAKMODEL); // position WRITE_COORD( vecSpot.x ); WRITE_COORD( vecSpot.y ); - WRITE_COORD( vecSpot.z + 64 ); + WRITE_COORD( vecSpot.z + 64.0f ); // size WRITE_COORD( 400 ); @@ -398,7 +398,7 @@ void CApache::DyingThink( void ) MESSAGE_END(); SetThink( &CBaseEntity::SUB_Remove ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } } @@ -410,7 +410,7 @@ void CApache::FlyTouch( CBaseEntity *pOther ) TraceResult tr = UTIL_GetGlobalTrace(); // UNDONE, do a real bounce - pev->velocity = pev->velocity + tr.vecPlaneNormal * ( pev->velocity.Length() + 200 ); + pev->velocity = pev->velocity + tr.vecPlaneNormal * ( pev->velocity.Length() + 200.0f ); } } @@ -427,13 +427,13 @@ void CApache::CrashTouch( CBaseEntity *pOther ) void CApache::GibMonster( void ) { - // EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "common/bodysplat.wav", 0.75, ATTN_NORM, 0, 200 ); + // EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "common/bodysplat.wav", 0.75f, ATTN_NORM, 0, 200 ); } void CApache::HuntThink( void ) { StudioFrameAdvance(); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; ShowDamage(); @@ -455,15 +455,15 @@ void CApache::HuntThink( void ) } // generic speed up - if( m_flGoalSpeed < 800 ) - m_flGoalSpeed += 5; + if( m_flGoalSpeed < 800.0f ) + m_flGoalSpeed += 5.0f; if( m_hEnemy != 0 ) { // ALERT( at_console, "%s\n", STRING( m_hEnemy->pev->classname ) ); if( FVisible( m_hEnemy ) ) { - if( m_flLastSeen < gpGlobals->time - 5 ) + if( m_flLastSeen < gpGlobals->time - 5.0f ) m_flPrevSeen = gpGlobals->time; m_flLastSeen = gpGlobals->time; m_posTarget = m_hEnemy->Center(); @@ -482,7 +482,7 @@ void CApache::HuntThink( void ) { // ALERT( at_console, "%.0f\n", flLength ); - if( flLength < 128 ) + if( flLength < 128.0f ) { m_pGoalEnt = UTIL_FindEntityByTargetname( NULL, STRING( m_pGoalEnt->pev->target ) ); if( m_pGoalEnt ) @@ -499,11 +499,11 @@ void CApache::HuntThink( void ) m_posDesired = pev->origin; } - if( flLength > 250 ) // 500 + if( flLength > 250.0f ) // 500 { - // float flLength2 = ( m_posTarget - pev->origin ).Length() * ( 1.5 - DotProduct( ( m_posTarget - pev->origin ).Normalize(), pev->velocity.Normalize() ) ); + // float flLength2 = ( m_posTarget - pev->origin ).Length() * ( 1.5f - DotProduct( ( m_posTarget - pev->origin ).Normalize(), pev->velocity.Normalize() ) ); // if( flLength2 < flLength ) - if( m_flLastSeen + 90 > gpGlobals->time && DotProduct( ( m_posTarget - pev->origin ).Normalize(), ( m_posDesired - pev->origin ).Normalize() ) > 0.25 ) + if( m_flLastSeen + 90.0f > gpGlobals->time && DotProduct( ( m_posTarget - pev->origin ).Normalize(), ( m_posDesired - pev->origin ).Normalize() ) > 0.25f ) { m_vecDesired = ( m_posTarget - pev->origin ).Normalize(); } @@ -520,47 +520,47 @@ void CApache::HuntThink( void ) Flight(); // ALERT( at_console, "%.0f %.0f %.0f\n", gpGlobals->time, m_flLastSeen, m_flPrevSeen ); - if( ( m_flLastSeen + 1 > gpGlobals->time ) && ( m_flPrevSeen + 2 < gpGlobals->time ) ) + if( ( m_flLastSeen + 1.0f > gpGlobals->time ) && ( m_flPrevSeen + 2.0f < gpGlobals->time ) ) { if( FireGun() ) { // slow down if we're fireing - if( m_flGoalSpeed > 400 ) - m_flGoalSpeed = 400; + if( m_flGoalSpeed > 400.0f ) + m_flGoalSpeed = 400.0f; } // don't fire rockets and gun on easy mode if( g_iSkillLevel == SKILL_EASY ) - m_flNextRocket = gpGlobals->time + 10.0; + m_flNextRocket = gpGlobals->time + 10.0f; } UTIL_MakeAimVectors( pev->angles ); - Vector vecEst = ( gpGlobals->v_forward * 800 + pev->velocity ).Normalize(); - // ALERT( at_console, "%d %d %d %4.2f\n", pev->angles.x < 0, DotProduct( pev->velocity, gpGlobals->v_forward ) > -100, m_flNextRocket < gpGlobals->time, DotProduct( m_vecTarget, vecEst ) ); + Vector vecEst = ( gpGlobals->v_forward * 800.0f + pev->velocity ).Normalize(); + // ALERT( at_console, "%d %d %d %4.2f\n", pev->angles.x < 0.0f, DotProduct( pev->velocity, gpGlobals->v_forward ) > -100.0f, m_flNextRocket < gpGlobals->time, DotProduct( m_vecTarget, vecEst ) ); if( ( m_iRockets % 2 ) == 1 ) { FireRocket(); - m_flNextRocket = gpGlobals->time + 0.5; + m_flNextRocket = gpGlobals->time + 0.5f; if( m_iRockets <= 0 ) { - m_flNextRocket = gpGlobals->time + 10; + m_flNextRocket = gpGlobals->time + 10.0f; m_iRockets = 10; } } - else if( pev->angles.x < 0 && DotProduct( pev->velocity, gpGlobals->v_forward ) > -100 && m_flNextRocket < gpGlobals->time ) + else if( pev->angles.x < 0.0f && DotProduct( pev->velocity, gpGlobals->v_forward ) > -100.0f && m_flNextRocket < gpGlobals->time ) { - if( m_flLastSeen + 60 > gpGlobals->time ) + if( m_flLastSeen + 60.0f > gpGlobals->time ) { if( m_hEnemy != 0 ) { // make sure it's a good shot - if( DotProduct( m_vecTarget, vecEst ) > .965 ) + if( DotProduct( m_vecTarget, vecEst ) > .965f ) { TraceResult tr; - UTIL_TraceLine( pev->origin, pev->origin + vecEst * 4096, ignore_monsters, edict(), &tr ); - if( (tr.vecEndPos - m_posTarget ).Length() < 512 ) + UTIL_TraceLine( pev->origin, pev->origin + vecEst * 4096.0f, ignore_monsters, edict(), &tr ); + if( (tr.vecEndPos - m_posTarget ).Length() < 512.0f ) FireRocket(); } } @@ -568,9 +568,9 @@ void CApache::HuntThink( void ) { TraceResult tr; - UTIL_TraceLine( pev->origin, pev->origin + vecEst * 4096, dont_ignore_monsters, edict(), &tr ); + UTIL_TraceLine( pev->origin, pev->origin + vecEst * 4096.0f, dont_ignore_monsters, edict(), &tr ); // just fire when close - if( ( tr.vecEndPos - m_posTarget ).Length() < 512 ) + if( ( tr.vecEndPos - m_posTarget ).Length() < 512.0f ) FireRocket(); } } @@ -580,34 +580,34 @@ void CApache::HuntThink( void ) void CApache::Flight( void ) { // tilt model 5 degrees - Vector vecAdj = Vector( 5.0, 0, 0 ); + Vector vecAdj = Vector( 5.0f, 0.0f, 0.0f ); // estimate where I'll be facing in one seconds - UTIL_MakeAimVectors( pev->angles + pev->avelocity * 2 + vecAdj ); - // Vector vecEst1 = pev->origin + pev->velocity + gpGlobals->v_up * m_flForce - Vector( 0, 0, 384 ); + UTIL_MakeAimVectors( pev->angles + pev->avelocity * 2.0f + vecAdj ); + // Vector vecEst1 = pev->origin + pev->velocity + gpGlobals->v_up * m_flForce - Vector( 0.0f, 0.0f, 384.0f ); // float flSide = DotProduct( m_posDesired - vecEst1, gpGlobals->v_right ); float flSide = DotProduct( m_vecDesired, gpGlobals->v_right ); - if( flSide < 0 ) + if( flSide < 0.0f ) { - if( pev->avelocity.y < 60 ) + if( pev->avelocity.y < 60.0f ) { - pev->avelocity.y += 8; // 9 * ( 3.0 / 2.0 ); + pev->avelocity.y += 8.0f; // 9 * ( 3.0 / 2.0 ); } } else { - if( pev->avelocity.y > -60 ) + if( pev->avelocity.y > -60.0f ) { - pev->avelocity.y -= 8; // 9 * ( 3.0 / 2.0 ); + pev->avelocity.y -= 8.0f; // 9 * ( 3.0 / 2.0 ); } } - pev->avelocity.y *= 0.98; + pev->avelocity.y *= 0.98f; // estimate where I'll be in two seconds - UTIL_MakeAimVectors( pev->angles + pev->avelocity * 1 + vecAdj ); - Vector vecEst = pev->origin + pev->velocity * 2.0 + gpGlobals->v_up * m_flForce * 20 - Vector( 0, 0, 384 * 2 ); + UTIL_MakeAimVectors( pev->angles + pev->avelocity * 1.0f + vecAdj ); + Vector vecEst = pev->origin + pev->velocity * 2.0f + gpGlobals->v_up * m_flForce * 20.0f - Vector( 0.0f, 0.0f, 384.0f * 2.0f ); // add immediate force UTIL_MakeAimVectors( pev->angles + vecAdj ); @@ -615,11 +615,11 @@ void CApache::Flight( void ) pev->velocity.y += gpGlobals->v_up.y * m_flForce; pev->velocity.z += gpGlobals->v_up.z * m_flForce; // add gravity - pev->velocity.z -= 38.4; // 32ft/sec + pev->velocity.z -= 38.4f; // 32ft/sec float flSpeed = pev->velocity.Length(); - float flDir = DotProduct( Vector( gpGlobals->v_forward.x, gpGlobals->v_forward.y, 0 ), Vector( pev->velocity.x, pev->velocity.y, 0 ) ); + float flDir = DotProduct( Vector( gpGlobals->v_forward.x, gpGlobals->v_forward.y, 0.0f ), Vector( pev->velocity.x, pev->velocity.y, 0.0f ) ); if( flDir < 0 ) flSpeed = -flSpeed; @@ -629,62 +629,62 @@ void CApache::Flight( void ) float flSlip = -DotProduct( m_posDesired - vecEst, gpGlobals->v_right ); // fly sideways - if( flSlip > 0 ) + if( flSlip > 0.0f ) { - if( pev->angles.z > -30 && pev->avelocity.z > -15 ) - pev->avelocity.z -= 4; + if( pev->angles.z > -30.0f && pev->avelocity.z > -15.0f ) + pev->avelocity.z -= 4.0f; else - pev->avelocity.z += 2; + pev->avelocity.z += 2.0f; } else { - if( pev->angles.z < 30 && pev->avelocity.z < 15 ) - pev->avelocity.z += 4; + if( pev->angles.z < 30 && pev->avelocity.z < 15.0f ) + pev->avelocity.z += 4.0f; else - pev->avelocity.z -= 2; + pev->avelocity.z -= 2.0f; } // sideways drag - pev->velocity.x = pev->velocity.x * ( 1.0 - fabs( gpGlobals->v_right.x ) * 0.05 ); - pev->velocity.y = pev->velocity.y * ( 1.0 - fabs( gpGlobals->v_right.y ) * 0.05 ); - pev->velocity.z = pev->velocity.z * ( 1.0 - fabs( gpGlobals->v_right.z ) * 0.05 ); + pev->velocity.x = pev->velocity.x * ( 1.0f - fabs( gpGlobals->v_right.x ) * 0.05f ); + pev->velocity.y = pev->velocity.y * ( 1.0f - fabs( gpGlobals->v_right.y ) * 0.05f ); + pev->velocity.z = pev->velocity.z * ( 1.0f - fabs( gpGlobals->v_right.z ) * 0.05f ); // general drag - pev->velocity = pev->velocity * 0.995; + pev->velocity = pev->velocity * 0.995f; // apply power to stay correct height - if( m_flForce < 80 && vecEst.z < m_posDesired.z ) + if( m_flForce < 80.0f && vecEst.z < m_posDesired.z ) { - m_flForce += 12; + m_flForce += 12.0f; } - else if( m_flForce > 30 ) + else if( m_flForce > 30.0f ) { if( vecEst.z > m_posDesired.z ) - m_flForce -= 8; + m_flForce -= 8.0f; } // pitch forward or back to get to target - if( flDist > 0 && flSpeed < m_flGoalSpeed /* && flSpeed < flDist */ && pev->angles.x + pev->avelocity.x > -40 ) + if( flDist > 0.0f && flSpeed < m_flGoalSpeed /* && flSpeed < flDist */ && pev->angles.x + pev->avelocity.x > -40.0f ) { // ALERT( at_console, "F " ); // lean forward - pev->avelocity.x -= 12.0; + pev->avelocity.x -= 12.0f; } - else if( flDist < 0 && flSpeed > -50 && pev->angles.x + pev->avelocity.x < 20 ) + else if( flDist < 0.0f && flSpeed > -50.0f && pev->angles.x + pev->avelocity.x < 20.0f ) { // ALERT( at_console, "B " ); // lean backward - pev->avelocity.x += 12.0; + pev->avelocity.x += 12.0f; } - else if( pev->angles.x + pev->avelocity.x > 0 ) + else if( pev->angles.x + pev->avelocity.x > 0.0f ) { // ALERT( at_console, "f " ); - pev->avelocity.x -= 4.0; + pev->avelocity.x -= 4.0f; } - else if( pev->angles.x + pev->avelocity.x < 0 ) + else if( pev->angles.x + pev->avelocity.x < 0.0f ) { // ALERT( at_console, "b " ); - pev->avelocity.x += 4.0; + pev->avelocity.x += 4.0f; } // ALERT( at_console, "%.0f %.0f : %.0f %.0f : %.0f %.0f : %.0f\n", pev->origin.x, pev->velocity.x, flDist, flSpeed, pev->angles.x, pev->avelocity.x, m_flForce ); @@ -693,8 +693,8 @@ void CApache::Flight( void ) // make rotor, engine sounds if( m_iSoundState == 0 ) { - EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, "apache/ap_rotor2.wav", 1.0, 0.3, 0, 110 ); - // EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, "apache/ap_whine1.wav", 0.5, 0.2, 0, 110 ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, "apache/ap_rotor2.wav", 1.0f, 0.3f, 0, 110 ); + // EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, "apache/ap_whine1.wav", 0.5f, 0.2f, 0, 110 ); m_iSoundState = SND_CHANGE_PITCH; // hack for going through level transitions } @@ -708,22 +708,22 @@ void CApache::Flight( void ) { float pitch = DotProduct( pev->velocity - pPlayer->pev->velocity, ( pPlayer->pev->origin - pev->origin ).Normalize() ); - pitch = (int)( 100 + pitch / 50.0 ); + pitch = (int)( 100.0f + pitch / 50.0f ); - if( pitch > 250 ) - pitch = 250; - if( pitch < 50 ) - pitch = 50; - if( pitch == 100 ) - pitch = 101; + if( pitch > 250.0f ) + pitch = 250.0f; + if( pitch < 50.0f ) + pitch = 50.0f; + if( pitch == 100.0f ) + pitch = 101.0f; - float flVol = ( m_flForce / 100.0 ) + .1; - if( flVol > 1.0 ) - flVol = 1.0; + /*float flVol = ( m_flForce / 100.0f ) + 0.1f; + if( flVol > 1.0f ) + flVol = 1.0f;*/ - EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, "apache/ap_rotor2.wav", 1.0, 0.3, SND_CHANGE_PITCH | SND_CHANGE_VOL, pitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, "apache/ap_rotor2.wav", 1.0f, 0.3f, SND_CHANGE_PITCH | SND_CHANGE_VOL, pitch ); } - // EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, "apache/ap_whine1.wav", flVol, 0.2, SND_CHANGE_PITCH | SND_CHANGE_VOL, pitch ); + // EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, "apache/ap_whine1.wav", flVol, 0.2f, SND_CHANGE_PITCH | SND_CHANGE_VOL, pitch ); // ALERT( at_console, "%.0f %.2f\n", pitch, flVol ); } @@ -731,49 +731,51 @@ void CApache::Flight( void ) void CApache::FireRocket( void ) { - static float side = 1.0; + static float side = 1.0f; if( m_iRockets <= 0 ) return; UTIL_MakeAimVectors( pev->angles ); - Vector vecSrc = pev->origin + 1.5 * ( gpGlobals->v_forward * 21 + gpGlobals->v_right * 70 * side + gpGlobals->v_up * -79 ); + Vector vecSrc = pev->origin + 1.5f * ( gpGlobals->v_forward * 21.0f + gpGlobals->v_right * 70.0f * side + gpGlobals->v_up * -79.0f ); switch( m_iRockets % 5 ) { case 0: - vecSrc = vecSrc + gpGlobals->v_right * 10; + vecSrc = vecSrc + gpGlobals->v_right * 10.0f; break; case 1: - vecSrc = vecSrc - gpGlobals->v_right * 10; + vecSrc = vecSrc - gpGlobals->v_right * 10.0f; break; case 2: - vecSrc = vecSrc + gpGlobals->v_up * 10; + vecSrc = vecSrc + gpGlobals->v_up * 10.0f; break; case 3: - vecSrc = vecSrc - gpGlobals->v_up * 10; + vecSrc = vecSrc - gpGlobals->v_up * 10.0f; break; case 4: break; } - MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSrc ); - WRITE_BYTE( TE_SMOKE ); - WRITE_COORD( vecSrc.x ); - WRITE_COORD( vecSrc.y ); - WRITE_COORD( vecSrc.z ); - WRITE_SHORT( g_sModelIndexSmoke ); - WRITE_BYTE( 20 ); // scale * 10 - WRITE_BYTE( 12 ); // framerate - MESSAGE_END(); - CBaseEntity *pRocket = CBaseEntity::Create( "hvr_rocket", vecSrc, pev->angles, edict() ); if( pRocket ) - pRocket->pev->velocity = pev->velocity + gpGlobals->v_forward * 100; + { + MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSrc ); + WRITE_BYTE( TE_SMOKE ); + WRITE_COORD( vecSrc.x ); + WRITE_COORD( vecSrc.y ); + WRITE_COORD( vecSrc.z ); + WRITE_SHORT( g_sModelIndexSmoke ); + WRITE_BYTE( 20 ); // scale * 10 + WRITE_BYTE( 12 ); // framerate + MESSAGE_END(); - m_iRockets--; + pRocket->pev->velocity = pev->velocity + gpGlobals->v_forward * 100.0f; - side = - side; + m_iRockets--; + + side = - side; + } } BOOL CApache::FireGun() @@ -794,23 +796,23 @@ BOOL CApache::FireGun() Vector angles = UTIL_VecToAngles( vecOut ); angles.x = -angles.x; - if( angles.y > 180 ) - angles.y = angles.y - 360; - if( angles.y < -180 ) - angles.y = angles.y + 360; - if( angles.x > 180 ) - angles.x = angles.x - 360; - if( angles.x < -180 ) - angles.x = angles.x + 360; + if( angles.y > 180.0f ) + angles.y = angles.y - 360.0f; + if( angles.y < -180.0f ) + angles.y = angles.y + 360.0f; + if( angles.x > 180.0f ) + angles.x = angles.x - 360.0f; + if( angles.x < -180.0f ) + angles.x = angles.x + 360.0f; if( angles.x > m_angGun.x ) - m_angGun.x = Q_min( angles.x, m_angGun.x + 12 ); + m_angGun.x = Q_min( angles.x, m_angGun.x + 12.0f ); if( angles.x < m_angGun.x ) - m_angGun.x = Q_max( angles.x, m_angGun.x - 12 ); + m_angGun.x = Q_max( angles.x, m_angGun.x - 12.0f ); if( angles.y > m_angGun.y ) - m_angGun.y = Q_min( angles.y, m_angGun.y + 12 ); + m_angGun.y = Q_min( angles.y, m_angGun.y + 12.0f ); if( angles.y < m_angGun.y ) - m_angGun.y = Q_max( angles.y, m_angGun.y - 12 ); + m_angGun.y = Q_max( angles.y, m_angGun.y - 12.0f ); m_angGun.y = SetBoneController( 0, m_angGun.y ); m_angGun.x = SetBoneController( 1, m_angGun.x ); @@ -819,11 +821,11 @@ BOOL CApache::FireGun() GetAttachment( 0, posBarrel, angBarrel ); Vector vecGun = ( posBarrel - posGun ).Normalize(); - if( DotProduct( vecGun, vecTarget ) > 0.98 ) + if( DotProduct( vecGun, vecTarget ) > 0.98f ) { #if 1 FireBullets( 1, posGun, vecGun, VECTOR_CONE_4DEGREES, 8192, BULLET_MONSTER_12MM, 1 ); - EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "turret/tu_fire1.wav", 1, 0.3 ); + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "turret/tu_fire1.wav", 1, 0.3f ); #else static float flNext; TraceResult tr; @@ -840,7 +842,7 @@ BOOL CApache::FireGun() if( flNext < gpGlobals->time ) { - flNext = gpGlobals->time + 0.5; + flNext = gpGlobals->time + 0.5f; m_pBeam->SetStartPos( tr.vecEndPos ); } #endif @@ -882,14 +884,14 @@ int CApache::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float if( bitsDamageType & DMG_BLAST ) { - flDamage *= 2; + flDamage *= 2.0f; } /* - if( ( bitsDamageType & DMG_BULLET ) && flDamage > 50 ) + if( ( bitsDamageType & DMG_BULLET ) && flDamage > 50.0f ) { // clip bullet damage at 50 - flDamage = 50; + flDamage = 50.0f; } */ @@ -910,13 +912,13 @@ void CApache::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir { // ALERT( at_console, "%.0f\n", flDamage ); AddMultiDamage( pevAttacker, this, flDamage, bitsDamageType ); - m_iDoSmokePuff = 3 + ( flDamage / 5.0 ); + m_iDoSmokePuff = 3.0f + ( flDamage / 5.0f ); } else { // do half damage in the body - // AddMultiDamage( pevAttacker, this, flDamage / 2.0, bitsDamageType ); - UTIL_Ricochet( ptr->vecEndPos, 2.0 ); + // AddMultiDamage( pevAttacker, this, flDamage / 2.0f, bitsDamageType ); + UTIL_Ricochet( ptr->vecEndPos, 2.0f ); } } @@ -961,9 +963,9 @@ void CApacheHVR::Spawn( void ) UTIL_MakeAimVectors( pev->angles ); m_vecForward = gpGlobals->v_forward; - pev->gravity = 0.5; + pev->gravity = 0.5f; - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; pev->dmg = 150; } @@ -972,7 +974,7 @@ void CApacheHVR::Precache( void ) { PRECACHE_MODEL( "models/HVR.mdl" ); m_iTrail = PRECACHE_MODEL( "sprites/smoke.spr" ); - PRECACHE_SOUND("weapons/rocket1.wav"); + PRECACHE_SOUND( "weapons/rocket1.wav" ); } void CApacheHVR::IgniteThink( void ) @@ -983,7 +985,7 @@ void CApacheHVR::IgniteThink( void ) pev->effects |= EF_LIGHT; // make rocket sound - EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/rocket1.wav", 1, 0.5 ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/rocket1.wav", 1, 0.5f ); // rocket trail MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); @@ -1000,13 +1002,13 @@ void CApacheHVR::IgniteThink( void ) // set to accelerate SetThink( &CApacheHVR::AccelerateThink ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } void CApacheHVR::AccelerateThink( void ) { // check world boundaries - if( pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096 ) + if( pev->origin.x < -4096.0f || pev->origin.x > 4096.0f || pev->origin.y < -4096.0f || pev->origin.y > 4096.0f || pev->origin.z < -4096.0f || pev->origin.z > 4096.0f ) { UTIL_Remove( this ); return; @@ -1014,14 +1016,14 @@ void CApacheHVR::AccelerateThink( void ) // accelerate float flSpeed = pev->velocity.Length(); - if( flSpeed < 1800 ) + if( flSpeed < 1800.0f ) { - pev->velocity = pev->velocity + m_vecForward * 200; + pev->velocity = pev->velocity + m_vecForward * 200.0f; } // re-aim pev->angles = UTIL_VecToAngles( pev->velocity ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } #endif diff --git a/dlls/barnacle.cpp b/dlls/barnacle.cpp index ecc1f5d4..5298bb32 100644 --- a/dlls/barnacle.cpp +++ b/dlls/barnacle.cpp @@ -57,11 +57,11 @@ public: // FIXME: need a custom barnacle model with non-generic hitgroup // otherwise we can apply to damage to tongue instead of body -#ifdef BARNACLE_FIX_VISIBILITY +#if BARNACLE_FIX_VISIBILITY void SetObjectCollisionBox( void ) { - pev->absmin = pev->origin + Vector( -16, -16, -m_flCachedLength ); - pev->absmax = pev->origin + Vector( 16, 16, 0 ); + pev->absmin = pev->origin + Vector( -16.0f, -16.0f, -m_flCachedLength ); + pev->absmax = pev->origin + Vector( 16.0f, 16.0f, 0.0f ); } #endif }; @@ -117,7 +117,7 @@ void CBarnacle::Spawn() Precache(); SET_MODEL( ENT( pev ), "models/barnacle.mdl" ); - UTIL_SetSize( pev, Vector( -16, -16, -32 ), Vector( 16, 16, 0 ) ); + UTIL_SetSize( pev, Vector( -16.0f, -16.0f, -32.0f ), Vector( 16.0f, 16.0f, 0.0f ) ); pev->solid = SOLID_SLIDEBOX; pev->movetype = MOVETYPE_NONE; @@ -125,20 +125,20 @@ void CBarnacle::Spawn() m_bloodColor = BLOOD_COLOR_RED; pev->effects = EF_INVLIGHT; // take light from the ceiling pev->health = 25; - m_flFieldOfView = 0.5;// indicates the width of this monster's forward view cone ( as a dotproduct result ) + m_flFieldOfView = 0.5f;// indicates the width of this monster's forward view cone ( as a dotproduct result ) m_MonsterState = MONSTERSTATE_NONE; - m_flKillVictimTime = 0; - m_flCachedLength = 32; // mins.z + m_flKillVictimTime = 0.0f; + m_flCachedLength = 32.0f; // mins.z m_cGibs = 0; m_fLiftingPrey = FALSE; - m_flTongueAdj = -100; + m_flTongueAdj = -100.0f; InitBoneControllers(); SetActivity( ACT_IDLE ); SetThink( &CBarnacle::BarnacleThink ); - pev->nextthink = gpGlobals->time + 0.5; + pev->nextthink = gpGlobals->time + 0.5f; UTIL_SetOrigin( pev, pev->origin ); } @@ -160,7 +160,7 @@ void CBarnacle::BarnacleThink( void ) CBaseEntity *pTouchEnt; CBaseMonster *pVictim; float flLength; -#ifdef BARNACLE_FIX_VISIBILITY +#if BARNACLE_FIX_VISIBILITY if( m_flCachedLength != ( m_flAltitude + m_flTongueAdj ) || ( pev->absmin.z != pev->origin.z + -m_flCachedLength ) ) { // recalc collision box here to avoid barnacle disappears bug @@ -168,7 +168,7 @@ void CBarnacle::BarnacleThink( void ) UTIL_SetOrigin( pev, pev->origin ); } #endif - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; if( m_hEnemy != 0 ) { @@ -197,8 +197,8 @@ void CBarnacle::BarnacleThink( void ) vecNewEnemyOrigin.y = pev->origin.y; // guess as to where their neck is - vecNewEnemyOrigin.x -= 6 * cos( m_hEnemy->pev->angles.y * M_PI / 180.0 ); - vecNewEnemyOrigin.y -= 6 * sin( m_hEnemy->pev->angles.y * M_PI / 180.0 ); + vecNewEnemyOrigin.x -= 6.0f * cos( m_hEnemy->pev->angles.y * M_PI_F / 180.0f ); + vecNewEnemyOrigin.y -= 6.0f * sin( m_hEnemy->pev->angles.y * M_PI_F / 180.0f ); m_flAltitude -= BARNACLE_PULL_SPEED; vecNewEnemyOrigin.z += BARNACLE_PULL_SPEED; @@ -212,7 +212,7 @@ void CBarnacle::BarnacleThink( void ) pVictim = m_hEnemy->MyMonsterPointer(); - m_flKillVictimTime = gpGlobals->time + 10;// now that the victim is in place, the killing bite will be administered in 10 seconds. + m_flKillVictimTime = gpGlobals->time + 10.0f;// now that the victim is in place, the killing bite will be administered in 10 seconds. if( pVictim ) { @@ -228,7 +228,7 @@ void CBarnacle::BarnacleThink( void ) // prey is lifted fully into feeding position and is dangling there. pVictim = m_hEnemy->MyMonsterPointer(); - if( m_flKillVictimTime != -1 && gpGlobals->time > m_flKillVictimTime ) + if( m_flKillVictimTime != -1.0f && gpGlobals->time > m_flKillVictimTime ) { // kill! if( pVictim ) @@ -265,7 +265,7 @@ void CBarnacle::BarnacleThink( void ) // barnacle has no prey right now, so just idle and check to see if anything is touching the tongue. // If idle and no nearby client, don't think so often if( FNullEnt( FIND_CLIENT_IN_PVS( edict() ) ) ) - pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 1, 1.5 ); // Stagger a bit to keep barnacles from thinking on the same frame + pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 1.0f, 1.5f ); // Stagger a bit to keep barnacles from thinking on the same frame if( m_fSequenceFinished ) { @@ -304,7 +304,7 @@ void CBarnacle::BarnacleThink( void ) EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "barnacle/bcl_alert2.wav", 1, ATTN_NORM ); SetSequenceByName( "attack1" ); - m_flTongueAdj = -20; + m_flTongueAdj = -20.0f; m_hEnemy = pTouchEnt; @@ -339,7 +339,7 @@ void CBarnacle::BarnacleThink( void ) // ALERT( at_console, "tounge %f\n", m_flAltitude + m_flTongueAdj ); SetBoneController( 0, -( m_flAltitude + m_flTongueAdj ) ); - StudioFrameAdvance( 0.1 ); + StudioFrameAdvance( 0.1f ); } //========================================================= @@ -377,9 +377,9 @@ void CBarnacle::Killed( entvars_t *pevAttacker, int iGib ) SetActivity( ACT_DIESIMPLE ); SetBoneController( 0, 0 ); - StudioFrameAdvance( 0.1 ); + StudioFrameAdvance( 0.1f ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; SetThink( &CBarnacle::WaitTillDead ); } @@ -387,9 +387,9 @@ void CBarnacle::Killed( entvars_t *pevAttacker, int iGib ) //========================================================= void CBarnacle::WaitTillDead( void ) { - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; - float flInterval = StudioFrameAdvance( 0.1 ); + float flInterval = StudioFrameAdvance( 0.1f ); DispatchAnimEvents( flInterval ); if( m_fSequenceFinished ) @@ -421,21 +421,21 @@ void CBarnacle::Precache() // to see if any entity is touching it. Also stores the length // of the trace in the int pointer provided. //========================================================= -#define BARNACLE_CHECK_SPACING 8 +#define BARNACLE_CHECK_SPACING 8.0f CBaseEntity *CBarnacle::TongueTouchEnt( float *pflLength ) { TraceResult tr; float length; // trace once to hit architecture and see if the tongue needs to change position. - UTIL_TraceLine( pev->origin, pev->origin - Vector ( 0, 0, 2048 ), ignore_monsters, ENT( pev ), &tr ); + UTIL_TraceLine( pev->origin, pev->origin - Vector ( 0.0f, 0.0f, 2048.0f ), ignore_monsters, ENT( pev ), &tr ); length = fabs( pev->origin.z - tr.vecEndPos.z ); if( pflLength ) { *pflLength = length; } - Vector delta = Vector( BARNACLE_CHECK_SPACING, BARNACLE_CHECK_SPACING, 0 ); + Vector delta = Vector( BARNACLE_CHECK_SPACING, BARNACLE_CHECK_SPACING, 0.0f ); Vector mins = pev->origin - delta; Vector maxs = pev->origin + delta; maxs.z = pev->origin.z; diff --git a/dlls/barney.cpp b/dlls/barney.cpp index fb027ab8..ac214786 100644 --- a/dlls/barney.cpp +++ b/dlls/barney.cpp @@ -267,7 +267,7 @@ void CBarney::AlertSound( void ) { if( FOkToSpeak() ) { - PlaySentence( "BA_ATTACK", RANDOM_FLOAT( 2.8, 3.2 ), VOL_NORM, ATTN_IDLE ); + PlaySentence( "BA_ATTACK", RANDOM_FLOAT( 2.8f, 3.2f ), VOL_NORM, ATTN_IDLE ); } } } @@ -306,22 +306,22 @@ void CBarney::SetYawSpeed( void ) //========================================================= BOOL CBarney::CheckRangeAttack1( float flDot, float flDist ) { - if( flDist <= 1024 && flDot >= 0.5 ) + if( flDist <= 1024.0f && flDot >= 0.5f ) { if( gpGlobals->time > m_checkAttackTime ) { TraceResult tr; - Vector shootOrigin = pev->origin + Vector( 0, 0, 55 ); + Vector shootOrigin = pev->origin + Vector( 0.0f, 0.0f, 55.0f ); CBaseEntity *pEnemy = m_hEnemy; Vector shootTarget = ( ( pEnemy->BodyTarget( shootOrigin ) - pEnemy->pev->origin ) + m_vecEnemyLKP ); UTIL_TraceLine( shootOrigin, shootTarget, dont_ignore_monsters, ENT( pev ), &tr ); - m_checkAttackTime = gpGlobals->time + 1; - if( tr.flFraction == 1.0 || ( tr.pHit != NULL && CBaseEntity::Instance( tr.pHit ) == pEnemy ) ) + m_checkAttackTime = gpGlobals->time + 1.0f; + if( tr.flFraction == 1.0f || ( tr.pHit != NULL && CBaseEntity::Instance( tr.pHit ) == pEnemy ) ) m_lastAttackCheck = TRUE; else m_lastAttackCheck = FALSE; - m_checkAttackTime = gpGlobals->time + 1.5; + m_checkAttackTime = gpGlobals->time + 1.5f; } return m_lastAttackCheck; } @@ -353,9 +353,9 @@ void CBarney::BarneyFirePistol( void ) pitchShift = 0; else pitchShift -= 5; - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "barney/ba_attack2.wav", 1, ATTN_NORM, 0, 100 + pitchShift ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "barney/ba_attack2.wav", 1.0f, ATTN_NORM, 0, 100 + pitchShift ); - CSoundEnt::InsertSound( bits_SOUND_COMBAT, pev->origin, 384, 0.3 ); + CSoundEnt::InsertSound( bits_SOUND_COMBAT, pev->origin, 384, 0.3f ); // UNDONE: Reload? m_cAmmoLoaded--;// take away a bullet! @@ -403,7 +403,7 @@ void CBarney::Spawn() pev->movetype = MOVETYPE_STEP; m_bloodColor = BLOOD_COLOR_RED; pev->health = gSkillData.barneyHealth; - pev->view_ofs = Vector ( 0, 0, 50 );// position of the eyes relative to monster's origin. + pev->view_ofs = Vector( 0.0f, 0.0f, 50.0f );// position of the eyes relative to monster's origin. m_flFieldOfView = VIEW_FIELD_WIDE; // NOTE: we need a wide field of view so npc will notice player and say hello m_MonsterState = MONSTERSTATE_NONE; @@ -477,15 +477,15 @@ void CBarney::TalkInit() static BOOL IsFacing( entvars_t *pevTest, const Vector &reference ) { Vector vecDir = reference - pevTest->origin; - vecDir.z = 0; + vecDir.z = 0.0f; vecDir = vecDir.Normalize(); Vector forward, angle; angle = pevTest->v_angle; - angle.x = 0; + angle.x = 0.0f; UTIL_MakeVectorsPrivate( angle, forward, NULL, NULL ); // He's facing me, he meant it - if( DotProduct( forward, vecDir ) > 0.96 ) // +/- 15 degrees or so + if( DotProduct( forward, vecDir ) > 0.96f ) // +/- 15 degrees or so { return TRUE; } @@ -541,18 +541,18 @@ void CBarney::PainSound( void ) if( gpGlobals->time < m_painTime ) return; - m_painTime = gpGlobals->time + RANDOM_FLOAT( 0.5, 0.75 ); + m_painTime = gpGlobals->time + RANDOM_FLOAT( 0.5f, 0.75f ); switch( RANDOM_LONG( 0, 2 ) ) { case 0: - EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "barney/ba_pain1.wav", 1, ATTN_NORM, 0, GetVoicePitch() ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "barney/ba_pain1.wav", 1.0f, ATTN_NORM, 0, GetVoicePitch() ); break; case 1: - EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "barney/ba_pain2.wav", 1, ATTN_NORM, 0, GetVoicePitch() ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "barney/ba_pain2.wav", 1.0f, ATTN_NORM, 0, GetVoicePitch() ); break; case 2: - EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "barney/ba_pain3.wav", 1, ATTN_NORM, 0, GetVoicePitch() ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "barney/ba_pain3.wav", 1.0f, ATTN_NORM, 0, GetVoicePitch() ); break; } } @@ -565,10 +565,10 @@ void CBarney::DeathSound( void ) switch( RANDOM_LONG( 0, 2 ) ) { case 0: - EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "barney/ba_die1.wav", 1, ATTN_NORM, 0, GetVoicePitch() ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "barney/ba_die1.wav", 1.0f, ATTN_NORM, 0, GetVoicePitch() ); break; case 1: - EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "barney/ba_die2.wav", 1, ATTN_NORM, 0, GetVoicePitch() ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "barney/ba_die2.wav", 1.0f, ATTN_NORM, 0, GetVoicePitch() ); break; case 2: EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "barney/ba_die3.wav", 1, ATTN_NORM, 0, GetVoicePitch() ); @@ -584,17 +584,17 @@ void CBarney::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir case HITGROUP_STOMACH: if (bitsDamageType & ( DMG_BULLET | DMG_SLASH | DMG_BLAST ) ) { - flDamage = flDamage / 2; + flDamage = flDamage * 0.5f; } break; case 10: if( bitsDamageType & ( DMG_BULLET | DMG_SLASH | DMG_CLUB ) ) { - flDamage -= 20; - if( flDamage <= 0 ) + flDamage -= 20.0f; + if( flDamage <= 0.0f ) { - UTIL_Ricochet( ptr->vecEndPos, 1.0 ); - flDamage = 0.01; + UTIL_Ricochet( ptr->vecEndPos, 1.0f ); + flDamage = 0.01f; } } diff --git a/dlls/basemonster.h b/dlls/basemonster.h index 696d3f39..2ed4f2cb 100644 --- a/dlls/basemonster.h +++ b/dlls/basemonster.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef BASEMONSTER_H +#if !defined(BASEMONSTER_H) #define BASEMONSTER_H // @@ -334,5 +334,7 @@ public: } CBaseEntity* DropItem( const char *pszItemName, const Vector &vecPos, const Vector &vecAng );// drop an item. + + float m_flLastYawTime; }; #endif // BASEMONSTER_H diff --git a/dlls/bigmomma.cpp b/dlls/bigmomma.cpp index 434d6134..62188740 100644 --- a/dlls/bigmomma.cpp +++ b/dlls/bigmomma.cpp @@ -12,7 +12,7 @@ * use or distribution of this code by or to any unlicensed person is illegal. * ****/ -#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD ) +#if !OEM_BUILD && !HLDEMO_BUILD //========================================================= // monster template @@ -150,8 +150,8 @@ IMPLEMENT_SAVERESTORE( CBMortar, CBaseEntity ) #define bits_COND_NODE_SEQUENCE ( bits_COND_SPECIAL1 ) // pev->netname contains the name of a sequence to play // Attack distance constants -#define BIG_ATTACKDIST 170 -#define BIG_MORTARDIST 800 +#define BIG_ATTACKDIST 170.0f +#define BIG_MORTARDIST 800.0f #define BIG_MAXCHILDREN 20 // Max # of live headcrab children #define bits_MEMORY_CHILDPAIR ( bits_MEMORY_CUSTOM1 ) @@ -255,8 +255,8 @@ public: if( m_crabTime < gpGlobals->time && m_crabCount < BIG_MAXCHILDREN ) { // Don't spawn crabs inside each other - Vector mins = pev->origin - Vector( 32, 32, 0 ); - Vector maxs = pev->origin + Vector( 32, 32, 0 ); + Vector mins = pev->origin - Vector( 32.0f, 32.0f, 0.0f ); + Vector maxs = pev->origin + Vector( 32.0f, 32.0f, 0.0f ); CBaseEntity *pList[2]; int count = UTIL_EntitiesInBox( pList, 2, mins, maxs, FL_MONSTER ); @@ -275,8 +275,8 @@ public: void SetObjectCollisionBox( void ) { - pev->absmin = pev->origin + Vector( -95, -95, 0 ); - pev->absmax = pev->origin + Vector( 95, 95, 190 ); + pev->absmin = pev->origin + Vector( -95.0f, -95.0f, 0.0f ); + pev->absmax = pev->origin + Vector( 95.0f, 95.0f, 190.0f ); } BOOL CheckMeleeAttack1( float flDot, float flDist ); // Slash @@ -418,6 +418,7 @@ void CBigMomma::SetYawSpeed( void ) break; default: ys = 90; + break; } pev->yaw_speed = ys; } @@ -440,9 +441,9 @@ void CBigMomma::HandleAnimEvent( MonsterEvent_t *pEvent ) UTIL_MakeVectorsPrivate( pev->angles, forward, right, NULL ); - Vector center = pev->origin + forward * 128; - Vector mins = center - Vector( 64, 64, 0 ); - Vector maxs = center + Vector( 64, 64, 64 ); + Vector center = pev->origin + forward * 128.0f; + Vector mins = center - Vector( 64.0f, 64.0f, 0.0f ); + Vector maxs = center + Vector( 64.0f, 64.0f, 64.0f ); CBaseEntity *pList[8]; int count = UTIL_EntitiesInBox( pList, 8, mins, maxs, FL_MONSTER | FL_CLIENT ); @@ -460,22 +461,22 @@ void CBigMomma::HandleAnimEvent( MonsterEvent_t *pEvent ) if( pHurt ) { pHurt->TakeDamage( pev, pev, gSkillData.bigmommaDmgSlash, DMG_CRUSH | DMG_SLASH ); - pHurt->pev->punchangle.x = 15; + pHurt->pev->punchangle.x = 15.0f; switch( pEvent->event ) { case BIG_AE_MELEE_ATTACKBR: - pHurt->pev->velocity = pHurt->pev->velocity + ( forward * 150 ) + Vector( 0, 0, 250 ) - ( right * 200 ); + pHurt->pev->velocity = pHurt->pev->velocity + ( forward * 150.0f ) + Vector( 0.0f, 0.0f, 250.0f ) - ( right * 200.0f ); break; case BIG_AE_MELEE_ATTACKBL: - pHurt->pev->velocity = pHurt->pev->velocity + ( forward * 150 ) + Vector( 0, 0, 250 ) + ( right * 200 ); + pHurt->pev->velocity = pHurt->pev->velocity + ( forward * 150.0f ) + Vector( 0.0f, 0.0f, 250.0f ) + ( right * 200.0f ); break; case BIG_AE_MELEE_ATTACK1: - pHurt->pev->velocity = pHurt->pev->velocity + ( forward * 220 ) + Vector( 0, 0, 200 ); + pHurt->pev->velocity = pHurt->pev->velocity + ( forward * 220.0f ) + Vector( 0.0f, 0.0f, 200.0f ); break; } pHurt->pev->flags &= ~FL_ONGROUND; - EMIT_SOUND_DYN( edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackHitSounds ), 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); + EMIT_SOUND_DYN( edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackHitSounds ), 1.0f, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); } } break; @@ -515,10 +516,10 @@ void CBigMomma::HandleAnimEvent( MonsterEvent_t *pEvent ) case BIG_AE_JUMP_FORWARD: ClearBits( pev->flags, FL_ONGROUND ); - UTIL_SetOrigin( pev, pev->origin + Vector( 0, 0, 1) );// take him off ground so engine doesn't instantly reset onground + UTIL_SetOrigin( pev, pev->origin + Vector( 0.0f, 0.0f, 1.0f ) );// take him off ground so engine doesn't instantly reset onground UTIL_MakeVectors( pev->angles ); - pev->velocity = gpGlobals->v_forward * 200 + gpGlobals->v_up * 500; + pev->velocity = gpGlobals->v_forward * 200.0f + gpGlobals->v_up * 500.0f; break; case BIG_AE_EARLY_TARGET: { @@ -541,11 +542,11 @@ void CBigMomma::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecD // didn't hit the sack? if( pev->dmgtime != gpGlobals->time || ( RANDOM_LONG( 0, 10 ) < 1 ) ) { - UTIL_Ricochet( ptr->vecEndPos, RANDOM_FLOAT( 1, 2) ); + UTIL_Ricochet( ptr->vecEndPos, RANDOM_FLOAT( 1.0f, 2.0f ) ); pev->dmgtime = gpGlobals->time; } - flDamage = 0.1;// don't hurt the monster much, but allow bits_COND_LIGHT_DAMAGE to be generated + flDamage = 0.1f;// don't hurt the monster much, but allow bits_COND_LIGHT_DAMAGE to be generated } else if( gpGlobals->time > m_painSoundTime ) { @@ -560,7 +561,7 @@ int CBigMomma::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, floa { // Don't take any acid damage -- BigMomma's mortar is acid if( bitsDamageType & DMG_ACID ) - flDamage = 0; + flDamage = 0.0f; if( !HasMemory( bits_MEMORY_PATH_FINISHED ) ) { @@ -584,20 +585,20 @@ void CBigMomma::LayHeadcrab( void ) // Is this the second crab in a pair? if( HasMemory( bits_MEMORY_CHILDPAIR ) ) { - m_crabTime = gpGlobals->time + RANDOM_FLOAT( 5, 10 ); + m_crabTime = gpGlobals->time + RANDOM_FLOAT( 5.0f, 10.0f ); Forget( bits_MEMORY_CHILDPAIR ); } else { - m_crabTime = gpGlobals->time + RANDOM_FLOAT( 0.5, 2.5 ); + m_crabTime = gpGlobals->time + RANDOM_FLOAT( 0.5f, 2.5f ); Remember( bits_MEMORY_CHILDPAIR ); } TraceResult tr; - UTIL_TraceLine( pev->origin, pev->origin - Vector( 0, 0, 100 ), ignore_monsters, edict(), &tr ); + UTIL_TraceLine( pev->origin, pev->origin - Vector( 0.0f, 0.0f, 100.0f ), ignore_monsters, edict(), &tr ); UTIL_DecalTrace( &tr, DECAL_MOMMABIRTH ); - EMIT_SOUND_DYN( edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pBirthSounds ), 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); + EMIT_SOUND_DYN( edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pBirthSounds ), 1.0f, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); m_crabCount++; } @@ -614,15 +615,15 @@ void CBigMomma::DeathNotice( entvars_t *pevChild ) void CBigMomma::LaunchMortar( void ) { - m_mortarTime = gpGlobals->time + RANDOM_FLOAT( 2, 15 ); + m_mortarTime = gpGlobals->time + RANDOM_FLOAT( 2.0f, 15.0f ); Vector startPos = pev->origin; - startPos.z += 180; + startPos.z += 180.0f; - EMIT_SOUND_DYN( edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pSackSounds ), 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); + EMIT_SOUND_DYN( edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pSackSounds ), 1.0f, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); CBMortar *pBomb = CBMortar::Shoot( edict(), startPos, pev->movedir ); - pBomb->pev->gravity = 1.0; - MortarSpray( startPos, Vector( 0, 0, 1 ), gSpitSprite, 24 ); + pBomb->pev->gravity = 1.0f; + MortarSpray( startPos, Vector( 0.0f, 0.0f, 1.0f ), gSpitSprite, 24 ); } //========================================================= @@ -633,14 +634,14 @@ void CBigMomma::Spawn() Precache(); SET_MODEL( ENT( pev ), "models/big_mom.mdl" ); - UTIL_SetSize( pev, Vector( -32, -32, 0 ), Vector( 32, 32, 64 ) ); + UTIL_SetSize( pev, Vector( -32.0f, -32.0f, 0.0f ), Vector( 32.0f, 32.0f, 64.0f ) ); pev->solid = SOLID_SLIDEBOX; pev->movetype = MOVETYPE_STEP; m_bloodColor = BLOOD_COLOR_GREEN; - pev->health = 150 * gSkillData.bigmommaHealthFactor; - pev->view_ofs = Vector( 0, 0, 128 );// position of the eyes relative to monster's origin. - m_flFieldOfView = 0.3;// indicates the width of this monster's forward view cone ( as a dotproduct result ) + pev->health = 150.0f * gSkillData.bigmommaHealthFactor; + pev->view_ofs = Vector( 0.0f, 0.0f, 128.0f );// position of the eyes relative to monster's origin. + m_flFieldOfView = 0.3f;// indicates the width of this monster's forward view cone ( as a dotproduct result ) m_MonsterState = MONSTERSTATE_NONE; MonsterInit(); @@ -732,7 +733,7 @@ void CBigMomma::NodeReach( void ) // Slash BOOL CBigMomma::CheckMeleeAttack1( float flDot, float flDist ) { - if( flDot >= 0.7 ) + if( flDot >= 0.7f ) { if( flDist <= BIG_ATTACKDIST ) return TRUE; @@ -756,8 +757,8 @@ BOOL CBigMomma::CheckRangeAttack1( float flDot, float flDist ) if( pEnemy ) { Vector startPos = pev->origin; - startPos.z += 180; - pev->movedir = VecCheckSplatToss( pev, startPos, pEnemy->BodyTarget( pev->origin ), RANDOM_FLOAT( 150, 500 ) ); + startPos.z += 180.0f; + pev->movedir = VecCheckSplatToss( pev, startPos, pEnemy->BodyTarget( pev->origin ), RANDOM_FLOAT( 150.0f, 500.0f ) ); if( pev->movedir != g_vecZero ) return TRUE; } @@ -893,7 +894,7 @@ void CBigMomma::StartTask( Task_t *pTask ) case TASK_NODE_DELAY: m_nodeTime = gpGlobals->time + pTask->flData; TaskComplete(); - ALERT( at_aiconsole, "BM: FAIL! Delay %.2f\n", pTask->flData ); + ALERT( at_aiconsole, "BM: FAIL! Delay %.2f\n", (double)pTask->flData ); break; case TASK_PROCESS_NODE: ALERT( at_aiconsole, "BM: Reached node %s\n", STRING( pev->netname ) ); @@ -930,11 +931,11 @@ void CBigMomma::StartTask( Task_t *pTask ) TaskComplete(); break; case TASK_WAIT_NODE: - m_flWait = gpGlobals->time + GetNodeDelay(); + m_flWaitFinished = gpGlobals->time + GetNodeDelay(); if( m_hTargetEnt->pev->spawnflags & SF_INFOBM_WAIT ) ALERT( at_aiconsole, "BM: Wait at node %s forever\n", STRING( pev->netname ) ); else - ALERT( at_aiconsole, "BM: Wait at node %s for %.2f\n", STRING( pev->netname ), GetNodeDelay() ); + ALERT( at_aiconsole, "BM: Wait at node %s for %.2f\n", STRING( pev->netname ), (double)GetNodeDelay() ); break; @@ -1006,8 +1007,10 @@ void CBigMomma::RunTask( Task_t *pTask ) return; if( gpGlobals->time > m_flWaitFinished ) + { TaskComplete(); - ALERT( at_aiconsole, "BM: The WAIT is over!\n" ); + ALERT( at_aiconsole, "BM: The WAIT is over!\n" ); + } break; case TASK_PLAY_NODE_PRESEQUENCE: case TASK_PLAY_NODE_SEQUENCE: @@ -1031,15 +1034,15 @@ Vector VecCheckSplatToss( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot Vector vecScale; Vector vecGrenadeVel; Vector vecTemp; - float flGravity = g_psv_gravity->value; + float flGravity = Q_max( g_psv_gravity->value, 0.1f ); // calculate the midpoint and apex of the 'triangle' - vecMidPoint = vecSpot1 + ( vecSpot2 - vecSpot1 ) * 0.5; - UTIL_TraceLine( vecMidPoint, vecMidPoint + Vector( 0, 0, maxHeight ), ignore_monsters, ENT( pev ), &tr ); + vecMidPoint = vecSpot1 + ( vecSpot2 - vecSpot1 ) * 0.5f; + UTIL_TraceLine( vecMidPoint, vecMidPoint + Vector( 0.0f, 0.0f, maxHeight ), ignore_monsters, ENT( pev ), &tr ); vecApex = tr.vecEndPos; UTIL_TraceLine( vecSpot1, vecApex, dont_ignore_monsters, ENT( pev ), &tr ); - if( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0f ) { // fail! return g_vecZero; @@ -1047,18 +1050,21 @@ Vector VecCheckSplatToss( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot // Don't worry about actually hitting the target, this won't hurt us! + // TODO: Need another way to calculate height because current calculation is completely wrong + // and there posible crash. + // How high should the grenade travel (subtract 15 so the grenade doesn't hit the ceiling)? - float height = vecApex.z - vecSpot1.z - 15; + float height = vecApex.z - vecSpot1.z - 15.0f; // How fast does the grenade need to travel to reach that height given gravity? - float speed = sqrt( 2 * flGravity * height ); + float speed = sqrt( 2.0f * flGravity * height ); // How much time does it take to get there? float time = speed / flGravity; vecGrenadeVel = vecSpot2 - vecSpot1; - vecGrenadeVel.z = 0; + vecGrenadeVel.z = 0.0f; // Travel half the distance to the target in that time (apex is at the midpoint) - vecGrenadeVel = vecGrenadeVel * ( 0.5 / time ); + vecGrenadeVel = vecGrenadeVel * ( 0.5f / time ); // Speed to offset gravity at the desired height vecGrenadeVel.z = speed; @@ -1099,26 +1105,26 @@ void CBMortar::Spawn( void ) SET_MODEL( ENT( pev ), "sprites/mommaspit.spr" ); pev->frame = 0; - pev->scale = 0.5; + pev->scale = 0.5f; UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) ); - m_maxFrame = (float) MODEL_FRAMES( pev->modelindex ) - 1; - pev->dmgtime = gpGlobals->time + 0.4; + m_maxFrame = MODEL_FRAMES( pev->modelindex ) - 1; + pev->dmgtime = gpGlobals->time + 0.4f; } void CBMortar::Animate( void ) { - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; if( gpGlobals->time > pev->dmgtime ) { - pev->dmgtime = gpGlobals->time + 0.2; + pev->dmgtime = gpGlobals->time + 0.2f; MortarSpray( pev->origin, -pev->velocity.Normalize(), gSpitSprite, 3 ); } if( pev->frame++ ) { - if ( pev->frame > m_maxFrame ) + if( pev->frame > m_maxFrame ) { pev->frame = 0; } @@ -1133,9 +1139,9 @@ CBMortar *CBMortar::Shoot( edict_t *pOwner, Vector vecStart, Vector vecVelocity UTIL_SetOrigin( pSpit->pev, vecStart ); pSpit->pev->velocity = vecVelocity; pSpit->pev->owner = pOwner; - pSpit->pev->scale = 2.5; + pSpit->pev->scale = 2.5f; pSpit->SetThink( &CBMortar::Animate ); - pSpit->pev->nextthink = gpGlobals->time + 0.1; + pSpit->pev->nextthink = gpGlobals->time + 0.1f; return pSpit; } @@ -1164,13 +1170,13 @@ void CBMortar::Touch( CBaseEntity *pOther ) { // make a splat on the wall - UTIL_TraceLine( pev->origin, pev->origin + pev->velocity * 10, dont_ignore_monsters, ENT( pev ), &tr ); + UTIL_TraceLine( pev->origin, pev->origin + pev->velocity * 10.0f, dont_ignore_monsters, ENT( pev ), &tr ); UTIL_DecalTrace( &tr, DECAL_MOMMASPLAT ); } else { tr.vecEndPos = pev->origin; - tr.vecPlaneNormal = -1 * pev->velocity.Normalize(); + tr.vecPlaneNormal = -1.0f * pev->velocity.Normalize(); } // make some flecks diff --git a/dlls/bmodels.cpp b/dlls/bmodels.cpp index fe56b6ac..a8b8f00f 100644 --- a/dlls/bmodels.cpp +++ b/dlls/bmodels.cpp @@ -42,7 +42,7 @@ extern DLL_GLOBAL Vector g_vecAttackDir; // Vector VecBModelOrigin( entvars_t* pevBModel ) { - return pevBModel->absmin + ( pevBModel->size * 0.5 ); + return pevBModel->absmin + ( pevBModel->size * 0.5f ); } // =================== FUNC_WALL ============================================== @@ -162,8 +162,8 @@ void CFuncConveyor::Spawn( void ) pev->skin = 0; // Don't want the engine thinking we've got special contents on this brush } - if( pev->speed == 0 ) - pev->speed = 100; + if( pev->speed == 0.0f ) + pev->speed = 100.0f; UpdateSpeed( pev->speed ); } @@ -172,7 +172,7 @@ void CFuncConveyor::Spawn( void ) void CFuncConveyor::UpdateSpeed( float speed ) { // Encode it as an integer with 4 fractional bits - int speedCode = (int)( fabs( speed ) * 16.0 ); + int speedCode = (int)( fabs( speed ) * 16.0f ); if( speed < 0 ) pev->rendercolor.x = 1; @@ -303,17 +303,17 @@ void CFuncRotating::KeyValue( KeyValueData* pkvd ) { if( FStrEq( pkvd->szKeyName, "fanfriction" ) ) { - m_flFanFriction = atof( pkvd->szValue ) / 100; + m_flFanFriction = atof( pkvd->szValue ) * 0.01f; pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "Volume" ) ) { - m_flVolume = atof( pkvd->szValue ) / 10.0; + m_flVolume = atof( pkvd->szValue ) * 0.1f; - if( m_flVolume > 1.0 ) - m_flVolume = 1.0; - if( m_flVolume < 0.0 ) - m_flVolume = 0.0; + if( m_flVolume > 1.0f ) + m_flVolume = 1.0f; + if( m_flVolume < 0.0f ) + m_flVolume = 0.0f; pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "spawnorigin" ) ) @@ -352,8 +352,8 @@ void CFuncRotating::Spawn() m_pitch = PITCH_NORM - 1; // maintain compatibility with previous maps - if( m_flVolume == 0.0 ) - m_flVolume = 1.0; + if( m_flVolume == 0.0f ) + m_flVolume = 1.0f; // if the designer didn't set a sound attenuation, default to one. m_flAttenuation = ATTN_NORM; @@ -372,21 +372,21 @@ void CFuncRotating::Spawn() } // prevent divide by zero if level designer forgets friction! - if( m_flFanFriction == 0 ) + if( m_flFanFriction == 0.0f ) { - m_flFanFriction = 1; + m_flFanFriction = 1.0f; } if( FBitSet( pev->spawnflags, SF_BRUSH_ROTATE_Z_AXIS ) ) - pev->movedir = Vector( 0, 0, 1 ); + pev->movedir = Vector( 0.0f, 0.0f, 1.0f ); else if( FBitSet( pev->spawnflags, SF_BRUSH_ROTATE_X_AXIS ) ) - pev->movedir = Vector( 1, 0, 0 ); + pev->movedir = Vector( 1.0f, 0.0f, 0.0f ); else - pev->movedir = Vector( 0, 1, 0 ); // y-axis + pev->movedir = Vector( 0.0f, 1.0f, 0.0f ); // y-axis // check for reverse rotation if( FBitSet( pev->spawnflags, SF_BRUSH_ROTATE_BACKWARDS ) ) - pev->movedir = pev->movedir * -1; + pev->movedir = pev->movedir * -1.0f; // some rotating objects like fake volumetric lights will not be solid. if( FBitSet( pev->spawnflags, SF_ROTATING_NOT_SOLID ) ) @@ -406,8 +406,8 @@ void CFuncRotating::Spawn() SetUse( &CFuncRotating::RotatingUse ); // did level designer forget to assign speed? - if( pev->speed <= 0 ) - pev->speed = 0; + if( pev->speed <= 0.0f ) + pev->speed = 0.0f; // Removed this per level designers request. -- JAY // if( pev->dmg == 0 ) @@ -417,7 +417,7 @@ void CFuncRotating::Spawn() if( FBitSet( pev->spawnflags, SF_BRUSH_ROTATE_INSTANT ) ) { SetThink( &CBaseEntity::SUB_CallUseToggle ); - pev->nextthink = pev->ltime + 1.5; // leave a magic delay for client to start up + pev->nextthink = pev->ltime + 1.5f; // leave a magic delay for client to start up } // can this brush inflict pain? if( FBitSet( pev->spawnflags, SF_BRUSH_HURT ) ) @@ -434,7 +434,7 @@ void CFuncRotating::Precache( void ) BOOL NullSound = FALSE; // set up fan sounds - if( !FStringNull( pev->message ) && strlen( szSoundFile ) > 0 ) + if( !FStringNull( pev->message ) && szSoundFile[0] != '\0' ) { // if a path is set for a wave, use it } @@ -476,7 +476,7 @@ void CFuncRotating::Precache( void ) // make sure we restart the sound. 1.5 sec delay is magic number. KDB SetThink( &CFuncRotating::SpinUp ); - pev->nextthink = pev->ltime + 1.5; + pev->nextthink = pev->ltime + 1.5f; } } @@ -527,7 +527,7 @@ void CFuncRotating::RampPitchVol( int fUp ) // calc volume and pitch as % of final vol and pitch fpct = vecCur / vecFinal; //if (fUp) - // fvol = m_flVolume * (0.5 + fpct/2.0); // spinup volume ramps up from 50% max vol + // fvol = m_flVolume * (0.5f + fpct/2.0f); // spinup volume ramps up from 50% max vol //else fvol = m_flVolume * fpct; // slowdown volume ramps down to 0 @@ -549,7 +549,7 @@ void CFuncRotating::SpinUp( void ) { Vector vecAVel;//rotational velocity - pev->nextthink = pev->ltime + 0.1; + pev->nextthink = pev->ltime + 0.1f; pev->avelocity = pev->avelocity + ( pev->movedir * ( pev->speed * m_flFanFriction ) ); vecAVel = pev->avelocity;// cache entity's rotational velocity @@ -580,23 +580,23 @@ void CFuncRotating::SpinDown( void ) Vector vecAVel;//rotational velocity vec_t vecdir; - pev->nextthink = pev->ltime + 0.1; + pev->nextthink = pev->ltime + 0.1f; pev->avelocity = pev->avelocity - ( pev->movedir * ( pev->speed * m_flFanFriction ) );//spin down slower than spinup vecAVel = pev->avelocity;// cache entity's rotational velocity - if( pev->movedir.x != 0 ) + if( pev->movedir.x != 0.0f ) vecdir = pev->movedir.x; - else if( pev->movedir.y != 0 ) + else if( pev->movedir.y != 0.0f ) vecdir = pev->movedir.y; else vecdir = pev->movedir.z; // if we've met or exceeded target speed, set target speed and stop thinking // (note: must check for movedir > 0 or < 0) - if( ( ( vecdir > 0 ) && ( vecAVel.x <= 0 && vecAVel.y <= 0 && vecAVel.z <= 0 ) ) || - ( ( vecdir < 0 ) && ( vecAVel.x >= 0 && vecAVel.y >= 0 && vecAVel.z >= 0 ) ) ) + if( ( ( vecdir > 0.0f ) && ( vecAVel.x <= 0.0f && vecAVel.y <= 0.0f && vecAVel.z <= 0.0f ) ) || + ( ( vecdir < 0.0f ) && ( vecAVel.x >= 0.0f && vecAVel.y >= 0.0f && vecAVel.z >= 0.0f ) ) ) { pev->avelocity = g_vecZero;// set speed in case we overshot @@ -615,7 +615,7 @@ void CFuncRotating::SpinDown( void ) void CFuncRotating::Rotate( void ) { - pev->nextthink = pev->ltime + 10; + pev->nextthink = pev->ltime + 10.0f; } //========================================================= @@ -633,15 +633,15 @@ void CFuncRotating::RotatingUse( CBaseEntity *pActivator, CBaseEntity *pCaller, //EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, STRING( pev->noiseStop ), // m_flVolume, m_flAttenuation, 0, m_pitch ); - pev->nextthink = pev->ltime + 0.1; + pev->nextthink = pev->ltime + 0.1f; } else// fan is not moving, so start it { SetThink( &CFuncRotating::SpinUp ); EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, STRING( pev->noiseRunning ), - 0.01, m_flAttenuation, 0, FANPITCHMIN ); + 0.01f, m_flAttenuation, 0, FANPITCHMIN ); - pev->nextthink = pev->ltime + 0.1; + pev->nextthink = pev->ltime + 0.1f; } } else if( !FBitSet( pev->spawnflags, SF_BRUSH_ACCDCC ) )//this is a normal start/stop brush. @@ -654,7 +654,7 @@ void CFuncRotating::RotatingUse( CBaseEntity *pActivator, CBaseEntity *pCaller, // EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, STRING( pev->noiseStop ), // m_flVolume, m_flAttenuation, 0, m_pitch ); - pev->nextthink = pev->ltime + 0.1; + pev->nextthink = pev->ltime + 0.1f; // pev->avelocity = g_vecZero; } else @@ -729,7 +729,7 @@ void CPendulum::KeyValue( KeyValueData *pkvd ) } else if( FStrEq( pkvd->szKeyName, "damp" ) ) { - m_damp = atof( pkvd->szValue ) * 0.001; + m_damp = atof( pkvd->szValue ) * 0.001f; pkvd->fHandled = TRUE; } else @@ -752,18 +752,18 @@ void CPendulum::Spawn( void ) if( m_distance == 0 ) return; - if( pev->speed == 0 ) - pev->speed = 100; + if( pev->speed == 0.0f ) + pev->speed = 100.0f; - m_accel = ( pev->speed * pev->speed ) / ( 2 * fabs( m_distance ) ); // Calculate constant acceleration from speed and distance + m_accel = ( pev->speed * pev->speed ) / ( 2.0f * fabs( m_distance ) ); // Calculate constant acceleration from speed and distance m_maxSpeed = pev->speed; m_start = pev->angles; - m_center = pev->angles + ( m_distance * 0.5 ) * pev->movedir; + m_center = pev->angles + ( m_distance * 0.5f ) * pev->movedir; if( FBitSet( pev->spawnflags, SF_BRUSH_ROTATE_INSTANT ) ) { SetThink( &CBaseEntity::SUB_CallUseToggle ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } pev->speed = 0; SetUse( &CPendulum::PendulumUse ); @@ -790,14 +790,14 @@ void CPendulum::PendulumUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_ } else { - pev->speed = 0; // Dead stop + pev->speed = 0.0f; // Dead stop SetThink( NULL ); pev->avelocity = g_vecZero; } } else { - pev->nextthink = pev->ltime + 0.1; // Start the pendulum moving + pev->nextthink = pev->ltime + 0.1f; // Start the pendulum moving m_time = gpGlobals->time; // Save time to calculate dt SetThink( &CPendulum::Swing ); m_dampSpeed = m_maxSpeed; @@ -807,7 +807,7 @@ void CPendulum::PendulumUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_ void CPendulum::Stop( void ) { pev->angles = m_start; - pev->speed = 0; + pev->speed = 0.0f; SetThink( NULL ); pev->avelocity = g_vecZero; } @@ -825,7 +825,7 @@ void CPendulum::Swing( void ) dt = gpGlobals->time - m_time; // How much time has passed? m_time = gpGlobals->time; // Remember the last time called - if( delta > 0 && m_accel > 0 ) + if( delta > 0.0f && m_accel > 0.0f ) pev->speed -= m_accel * dt; // Integrate velocity else pev->speed += m_accel * dt; @@ -838,12 +838,12 @@ void CPendulum::Swing( void ) pev->avelocity = pev->speed * pev->movedir; // Call this again - pev->nextthink = pev->ltime + 0.1; + pev->nextthink = pev->ltime + 0.1f; if( m_damp ) { m_dampSpeed -= m_damp * m_dampSpeed * dt; - if( m_dampSpeed < 30.0 ) + if( m_dampSpeed < 30.0f ) { pev->angles = m_center; pev->speed = 0; @@ -869,7 +869,7 @@ void CPendulum::Touch( CBaseEntity *pOther ) return; // calculate damage based on rotation speed - float damage = pev->dmg * pev->speed * 0.01; + float damage = pev->dmg * pev->speed * 0.01f; if( damage < 0 ) damage = -damage; diff --git a/dlls/bullsquid.cpp b/dlls/bullsquid.cpp index e48721c7..229f5885 100644 --- a/dlls/bullsquid.cpp +++ b/dlls/bullsquid.cpp @@ -27,7 +27,7 @@ #include "soundent.h" #include "game.h" -#define SQUID_SPRINT_DIST 256 // how close the squid has to get before starting to sprint and refusing to swerve +#define SQUID_SPRINT_DIST 256.0f // how close the squid has to get before starting to sprint and refusing to swerve int iSquidSpitSprite; @@ -91,16 +91,16 @@ void CSquidSpit::Spawn( void ) SET_MODEL( ENT( pev ), "sprites/bigspit.spr" ); pev->frame = 0; - pev->scale = 0.5; + pev->scale = 0.5f; UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) ); - m_maxFrame = (float)MODEL_FRAMES( pev->modelindex ) - 1; + m_maxFrame = MODEL_FRAMES( pev->modelindex ) - 1; } void CSquidSpit::Animate( void ) { - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; if( pev->frame++ ) { @@ -121,7 +121,7 @@ void CSquidSpit::Shoot( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity pSpit->pev->owner = ENT( pevOwner ); pSpit->SetThink( &CSquidSpit::Animate ); - pSpit->pev->nextthink = gpGlobals->time + 0.1; + pSpit->pev->nextthink = gpGlobals->time + 0.1f; } void CSquidSpit::Touch( CBaseEntity *pOther ) @@ -130,7 +130,7 @@ void CSquidSpit::Touch( CBaseEntity *pOther ) int iPitch; // splat sound - iPitch = RANDOM_FLOAT( 90, 110 ); + iPitch = RANDOM_FLOAT( 90.0f, 110.0f ); EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "bullchicken/bc_acid1.wav", 1, ATTN_NORM, 0, iPitch ); @@ -242,7 +242,7 @@ int CBullsquid::IgnoreConditions( void ) { int iIgnore = CBaseMonster::IgnoreConditions(); - if( gpGlobals->time - m_flLastHurtTime <= 20 ) + if( gpGlobals->time - m_flLastHurtTime <= 20.0f ) { // haven't been hurt in 20 seconds, so let the squid care about stink. iIgnore = bits_COND_SMELL | bits_COND_SMELL_FOOD; @@ -266,7 +266,7 @@ int CBullsquid::IgnoreConditions( void ) //========================================================= int CBullsquid::IRelationship( CBaseEntity *pTarget ) { - if( gpGlobals->time - m_flLastHurtTime < 5 && FClassnameIs( pTarget->pev, "monster_headcrab" ) ) + if( gpGlobals->time - m_flLastHurtTime < 5.0f && FClassnameIs( pTarget->pev, "monster_headcrab" ) ) { // if squid has been hurt in the last 5 seconds, and is getting relationship for a headcrab, // tell squid to disregard crab. @@ -287,7 +287,7 @@ int CBullsquid::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, flo // if the squid is running, has an enemy, was hurt by the enemy, hasn't been hurt in the last 3 seconds, and isn't too close to the enemy, // it will swerve. (whew). - if( m_hEnemy != 0 && IsMoving() && pevAttacker == m_hEnemy->pev && gpGlobals->time - m_flLastHurtTime > 3 ) + if( m_hEnemy != 0 && IsMoving() && pevAttacker == m_hEnemy->pev && gpGlobals->time - m_flLastHurtTime > 3.0f ) { flDist = ( pev->origin - m_hEnemy->pev->origin ).Length2D(); @@ -295,7 +295,7 @@ int CBullsquid::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, flo { flDist = ( pev->origin - m_Route[m_iRouteIndex].vecLocation ).Length2D();// reusing flDist. - if( FTriangulate( pev->origin, m_Route[m_iRouteIndex].vecLocation, flDist * 0.5, m_hEnemy, &vecApex ) ) + if( FTriangulate( pev->origin, m_Route[m_iRouteIndex].vecLocation, flDist * 0.5f, m_hEnemy, &vecApex ) ) { InsertWaypoint( vecApex, bits_MF_TO_DETOUR | bits_MF_DONT_SIMPLIFY ); } @@ -316,17 +316,17 @@ int CBullsquid::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, flo //========================================================= BOOL CBullsquid::CheckRangeAttack1( float flDot, float flDist ) { - if( IsMoving() && flDist >= 512 ) + if( IsMoving() && flDist >= 512.0f ) { // squid will far too far behind if he stops running to spit at this distance from the enemy. return FALSE; } - if( flDist > 64 && flDist <= 784 && flDot >= 0.5 && gpGlobals->time >= m_flNextSpitTime ) + if( flDist > 64.0f && flDist <= 784.0f && flDot >= 0.5f && gpGlobals->time >= m_flNextSpitTime ) { if( m_hEnemy != 0 ) { - if( fabs( pev->origin.z - m_hEnemy->pev->origin.z ) > 256 ) + if( fabs( pev->origin.z - m_hEnemy->pev->origin.z ) > 256.0f ) { // don't try to spit at someone up really high or down really low. return FALSE; @@ -336,12 +336,12 @@ BOOL CBullsquid::CheckRangeAttack1( float flDot, float flDist ) if( IsMoving() ) { // don't spit again for a long time, resume chasing enemy. - m_flNextSpitTime = gpGlobals->time + 5; + m_flNextSpitTime = gpGlobals->time + 5.0f; } else { // not moving, so spit again pretty soon. - m_flNextSpitTime = gpGlobals->time + 0.5; + m_flNextSpitTime = gpGlobals->time + 0.5f; } return TRUE; @@ -356,7 +356,7 @@ BOOL CBullsquid::CheckRangeAttack1( float flDot, float flDist ) //========================================================= BOOL CBullsquid::CheckMeleeAttack1( float flDot, float flDist ) { - if( m_hEnemy->pev->health <= gSkillData.bullsquidDmgWhip && flDist <= 85 && flDot >= 0.7 ) + if( m_hEnemy->pev->health <= gSkillData.bullsquidDmgWhip && flDist <= 85.0f && flDot >= 0.7f ) { return TRUE; } @@ -371,7 +371,7 @@ BOOL CBullsquid::CheckMeleeAttack1( float flDot, float flDist ) //========================================================= BOOL CBullsquid::CheckMeleeAttack2( float flDot, float flDist ) { - if( flDist <= 85 && flDot >= 0.7 && !HasConditions( bits_COND_CAN_MELEE_ATTACK1 ) ) // The player & bullsquid can be as much as their bboxes + if( flDist <= 85.0f && flDot >= 0.7f && !HasConditions( bits_COND_CAN_MELEE_ATTACK1 ) ) // The player & bullsquid can be as much as their bboxes { // apart (48 * sqrt(3)) and he can still attack (85 is a little more than 48*sqrt(3)) return TRUE; } @@ -504,7 +504,7 @@ void CBullsquid::SetYawSpeed( void ) ys = 0; - switch ( m_Activity ) + switch( m_Activity ) { case ACT_WALK: ys = 90; @@ -536,6 +536,9 @@ void CBullsquid::HandleAnimEvent( MonsterEvent_t *pEvent ) { case BSQUID_AE_SPIT: { + if( m_hEnemy == 0 ) + return; + Vector vecSpitOffset; Vector vecSpitDir; @@ -543,13 +546,13 @@ void CBullsquid::HandleAnimEvent( MonsterEvent_t *pEvent ) // !!!HACKHACK - the spot at which the spit originates (in front of the mouth) was measured in 3ds and hardcoded here. // we should be able to read the position of bones at runtime for this info. - vecSpitOffset = ( gpGlobals->v_right * 8 + gpGlobals->v_forward * 37 + gpGlobals->v_up * 23 ); + vecSpitOffset = ( gpGlobals->v_right * 8.0f + gpGlobals->v_forward * 37.0f + gpGlobals->v_up * 23.0f ); vecSpitOffset = ( pev->origin + vecSpitOffset ); vecSpitDir = ( ( m_hEnemy->pev->origin + m_hEnemy->pev->view_ofs ) - vecSpitOffset ).Normalize(); - vecSpitDir.x += RANDOM_FLOAT( -0.05, 0.05 ); - vecSpitDir.y += RANDOM_FLOAT( -0.05, 0.05 ); - vecSpitDir.z += RANDOM_FLOAT( -0.05, 0 ); + vecSpitDir.x += RANDOM_FLOAT( -0.05f, 0.05f ); + vecSpitDir.y += RANDOM_FLOAT( -0.05f, 0.05f ); + vecSpitDir.z += RANDOM_FLOAT( -0.05f, 0.0f ); // do stuff for this event. AttackSound(); @@ -569,7 +572,7 @@ void CBullsquid::HandleAnimEvent( MonsterEvent_t *pEvent ) WRITE_BYTE( 25 ); // noise ( client will divide by 100 ) MESSAGE_END(); - CSquidSpit::Shoot( pev, vecSpitOffset, vecSpitDir * 900 ); + CSquidSpit::Shoot( pev, vecSpitOffset, vecSpitDir * 900.0f ); } break; case BSQUID_AE_BITE: @@ -579,10 +582,10 @@ void CBullsquid::HandleAnimEvent( MonsterEvent_t *pEvent ) if( pHurt && ENTINDEX(pHurt->edict()) ) { - //pHurt->pev->punchangle.z = -15; - //pHurt->pev->punchangle.x = -45; - pHurt->pev->velocity = pHurt->pev->velocity - gpGlobals->v_forward * 100; - pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_up * 100; + //pHurt->pev->punchangle.z = -15.0f; + //pHurt->pev->punchangle.x = -45.0f; + pHurt->pev->velocity = pHurt->pev->velocity - gpGlobals->v_forward * 100.0f; + pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_up * 100.0f; } } break; @@ -592,10 +595,10 @@ void CBullsquid::HandleAnimEvent( MonsterEvent_t *pEvent ) if( pHurt && ENTINDEX(pHurt->edict()) ) { - pHurt->pev->punchangle.z = -20; - pHurt->pev->punchangle.x = 20; - pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_right * 200; - pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_up * 100; + pHurt->pev->punchangle.z = -20.0f; + pHurt->pev->punchangle.x = 20.0f; + pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_right * 200.0f; + pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_up * 100.0f; } } break; @@ -616,8 +619,8 @@ void CBullsquid::HandleAnimEvent( MonsterEvent_t *pEvent ) } // jump into air for 0.8 (24/30) seconds - //pev->velocity.z += ( 0.875 * flGravity ) * 0.5; - pev->velocity.z += ( 0.625 * flGravity ) * 0.5; + //pev->velocity.z += ( 0.875f * flGravity ) * 0.5f; + pev->velocity.z += ( 0.625f * flGravity ) * 0.5f; } break; case BSQUID_AE_THROW: @@ -630,14 +633,14 @@ void CBullsquid::HandleAnimEvent( MonsterEvent_t *pEvent ) if( pHurt && ENTINDEX(pHurt->edict()) ) { // croonchy bite sound - iPitch = RANDOM_FLOAT( 90, 110 ); + iPitch = RANDOM_FLOAT( 90.0f, 110.0f ); switch( RANDOM_LONG( 0, 1 ) ) { case 0: - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_bite2.wav", 1, ATTN_NORM, 0, iPitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_bite2.wav", 1.0f, ATTN_NORM, 0, iPitch ); break; case 1: - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_bite3.wav", 1, ATTN_NORM, 0, iPitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_bite3.wav", 1.0f, ATTN_NORM, 0, iPitch ); break; } @@ -646,12 +649,12 @@ void CBullsquid::HandleAnimEvent( MonsterEvent_t *pEvent ) //pHurt->pev->punchangle.y = RANDOM_LONG( 0, 89 ) - 45; // screeshake transforms the viewmodel as well as the viewangle. No problems with seeing the ends of the viewmodels. - UTIL_ScreenShake( pHurt->pev->origin, 25.0, 1.5, 0.7, 2 ); + UTIL_ScreenShake( pHurt->pev->origin, 25.0f, 1.5f, 0.7f, 2.0f ); if( pHurt->IsPlayer() ) { UTIL_MakeVectors( pev->angles ); - pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_forward * 300 + gpGlobals->v_up * 300; + pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_forward * 300.0f + gpGlobals->v_up * 300.0f; } } } @@ -669,14 +672,14 @@ void CBullsquid::Spawn() Precache(); SET_MODEL( ENT( pev ), "models/bullsquid.mdl" ); - UTIL_SetSize( pev, Vector( -32, -32, 0 ), Vector( 32, 32, 64 ) ); + UTIL_SetSize( pev, Vector( -32.0f, -32.0f, 0.0f ), Vector( 32.0f, 32.0f, 64.0f ) ); pev->solid = SOLID_SLIDEBOX; pev->movetype = MOVETYPE_STEP; m_bloodColor = BLOOD_COLOR_GREEN; pev->effects = 0; pev->health = gSkillData.bullsquidHealth; - m_flFieldOfView = 0.2;// indicates the width of this monster's forward view cone ( as a dotproduct result ) + m_flFieldOfView = 0.2f;// indicates the width of this monster's forward view cone ( as a dotproduct result ) m_MonsterState = MONSTERSTATE_NONE; m_fCanThreatDisplay = TRUE; @@ -789,7 +792,7 @@ void CBullsquid::RunAI( void ) // chasing enemy. Sprint for last bit if( ( pev->origin - m_hEnemy->pev->origin).Length2D() < SQUID_SPRINT_DIST ) { - pev->framerate = 1.25; + pev->framerate = 1.25f; } } } @@ -802,8 +805,8 @@ void CBullsquid::RunAI( void ) Task_t tlSquidRangeAttack1[] = { { TASK_STOP_MOVING, 0 }, - { TASK_FACE_IDEAL, (float)0 }, - { TASK_RANGE_ATTACK1, (float)0 }, + { TASK_FACE_IDEAL, 0.0f }, + { TASK_RANGE_ATTACK1, 0.0f }, { TASK_SET_ACTIVITY, (float)ACT_IDLE }, }; @@ -826,9 +829,9 @@ Schedule_t slSquidRangeAttack1[] = Task_t tlSquidChaseEnemy1[] = { { TASK_SET_FAIL_SCHEDULE, (float)SCHED_RANGE_ATTACK1 },// !!!OEM - this will stop nasty squid oscillation. - { TASK_GET_PATH_TO_ENEMY, (float)0 }, - { TASK_RUN_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_GET_PATH_TO_ENEMY, 0.0f }, + { TASK_RUN_PATH, 0.0f }, + { TASK_WAIT_FOR_MOVEMENT, 0.0f }, }; Schedule_t slSquidChaseEnemy[] = @@ -852,10 +855,10 @@ Schedule_t slSquidChaseEnemy[] = Task_t tlSquidHurtHop[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_SOUND_WAKE, (float)0 }, - { TASK_SQUID_HOPTURN, (float)0 }, - { TASK_FACE_ENEMY, (float)0 },// in case squid didn't turn all the way in the air. + { TASK_STOP_MOVING, 0.0f }, + { TASK_SOUND_WAKE, 0.0f }, + { TASK_SQUID_HOPTURN, 0.0f }, + { TASK_FACE_ENEMY, 0.0f },// in case squid didn't turn all the way in the air. }; Schedule_t slSquidHurtHop[] = @@ -871,10 +874,10 @@ Schedule_t slSquidHurtHop[] = Task_t tlSquidSeeCrab[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_SOUND_WAKE, (float)0 }, + { TASK_STOP_MOVING, 0.0f }, + { TASK_SOUND_WAKE, 0.0f }, { TASK_PLAY_SEQUENCE, (float)ACT_EXCITED }, - { TASK_FACE_ENEMY, (float)0 }, + { TASK_FACE_ENEMY, 0.0f }, }; Schedule_t slSquidSeeCrab[] = @@ -892,20 +895,20 @@ Schedule_t slSquidSeeCrab[] = // squid walks to something tasty and eats it. Task_t tlSquidEat[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_EAT, (float)10 },// this is in case the squid can't get to the food - { TASK_STORE_LASTPOSITION, (float)0 }, - { TASK_GET_PATH_TO_BESTSCENT, (float)0 }, - { TASK_WALK_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_STOP_MOVING, 0.0f }, + { TASK_EAT, 10.0f },// this is in case the squid can't get to the food + { TASK_STORE_LASTPOSITION, 0.0f }, + { TASK_GET_PATH_TO_BESTSCENT, 0.0f }, + { TASK_WALK_PATH, 0.0f }, + { TASK_WAIT_FOR_MOVEMENT, 0.0f }, { TASK_PLAY_SEQUENCE, (float)ACT_EAT }, { TASK_PLAY_SEQUENCE, (float)ACT_EAT }, { TASK_PLAY_SEQUENCE, (float)ACT_EAT }, - { TASK_EAT, (float)50 }, - { TASK_GET_PATH_TO_LASTPOSITION, (float)0 }, - { TASK_WALK_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_CLEAR_LASTPOSITION, (float)0 }, + { TASK_EAT, 50.0f }, + { TASK_GET_PATH_TO_LASTPOSITION, 0.0f }, + { TASK_WALK_PATH, 0.0f }, + { TASK_WAIT_FOR_MOVEMENT, 0.0f }, + { TASK_CLEAR_LASTPOSITION, 0.0f }, }; Schedule_t slSquidEat[] = @@ -928,21 +931,21 @@ Schedule_t slSquidEat[] = // the squid. This schedule plays a sniff animation before going to the source of food. Task_t tlSquidSniffAndEat[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_EAT, (float)10 },// this is in case the squid can't get to the food + { TASK_STOP_MOVING, 0.0f }, + { TASK_EAT, 10.0f },// this is in case the squid can't get to the food { TASK_PLAY_SEQUENCE, (float)ACT_DETECT_SCENT }, - { TASK_STORE_LASTPOSITION, (float)0 }, - { TASK_GET_PATH_TO_BESTSCENT, (float)0 }, - { TASK_WALK_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_STORE_LASTPOSITION, 0.0f }, + { TASK_GET_PATH_TO_BESTSCENT, 0.0f }, + { TASK_WALK_PATH, 0.0f }, + { TASK_WAIT_FOR_MOVEMENT, 0.0f }, { TASK_PLAY_SEQUENCE, (float)ACT_EAT }, { TASK_PLAY_SEQUENCE, (float)ACT_EAT }, { TASK_PLAY_SEQUENCE, (float)ACT_EAT }, - { TASK_EAT, (float)50 }, - { TASK_GET_PATH_TO_LASTPOSITION, (float)0 }, - { TASK_WALK_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_CLEAR_LASTPOSITION, (float)0 }, + { TASK_EAT, 50.0f }, + { TASK_GET_PATH_TO_LASTPOSITION, 0.0f }, + { TASK_WALK_PATH, 0.0f }, + { TASK_WAIT_FOR_MOVEMENT, 0.0f }, + { TASK_CLEAR_LASTPOSITION, 0.0f }, }; Schedule_t slSquidSniffAndEat[] = @@ -964,18 +967,18 @@ Schedule_t slSquidSniffAndEat[] = // squid does this to stinky things. Task_t tlSquidWallow[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_EAT, (float)10 },// this is in case the squid can't get to the stinkiness - { TASK_STORE_LASTPOSITION, (float)0 }, - { TASK_GET_PATH_TO_BESTSCENT, (float)0 }, - { TASK_WALK_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_STOP_MOVING, 0.0f }, + { TASK_EAT, 10.0f },// this is in case the squid can't get to the stinkiness + { TASK_STORE_LASTPOSITION, 0.0f }, + { TASK_GET_PATH_TO_BESTSCENT, 0.0f }, + { TASK_WALK_PATH, 0.0f }, + { TASK_WAIT_FOR_MOVEMENT, 0.0f }, { TASK_PLAY_SEQUENCE, (float)ACT_INSPECT_FLOOR }, - { TASK_EAT, (float)50 },// keeps squid from eating or sniffing anything else for a while. - { TASK_GET_PATH_TO_LASTPOSITION, (float)0 }, - { TASK_WALK_PATH, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_CLEAR_LASTPOSITION, (float)0 }, + { TASK_EAT, 50.0f },// keeps squid from eating or sniffing anything else for a while. + { TASK_GET_PATH_TO_LASTPOSITION, 0.0f }, + { TASK_WALK_PATH, 0.0f }, + { TASK_WAIT_FOR_MOVEMENT, 0.0f }, + { TASK_CLEAR_LASTPOSITION, 0.0f }, }; Schedule_t slSquidWallow[] = diff --git a/dlls/buttons.cpp b/dlls/buttons.cpp index 90bc42e5..9c7d5d39 100644 --- a/dlls/buttons.cpp +++ b/dlls/buttons.cpp @@ -57,7 +57,7 @@ TYPEDESCRIPTION CEnvGlobal::m_SaveData[] = DEFINE_FIELD( CEnvGlobal, m_initialstate, FIELD_INTEGER ), }; -IMPLEMENT_SAVERESTORE( CEnvGlobal, CBaseEntity ) +IMPLEMENT_SAVERESTORE( CEnvGlobal, CPointEntity ) LINK_ENTITY_TO_CLASS( env_global, CEnvGlobal ) @@ -130,7 +130,7 @@ TYPEDESCRIPTION CMultiSource::m_SaveData[] = DEFINE_FIELD( CMultiSource, m_globalstate, FIELD_STRING ), }; -IMPLEMENT_SAVERESTORE( CMultiSource, CBaseEntity ) +IMPLEMENT_SAVERESTORE( CMultiSource, CPointEntity ) LINK_ENTITY_TO_CLASS( multisource, CMultiSource ) @@ -163,7 +163,7 @@ void CMultiSource::Spawn() pev->solid = SOLID_NOT; pev->movetype = MOVETYPE_NONE; - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; pev->spawnflags |= SF_MULTI_INIT; // Until it's initialized SetThink( &CMultiSource::Register ); } @@ -476,7 +476,7 @@ void CBaseButton::Spawn() if( FBitSet( pev->spawnflags, SF_BUTTON_SPARK_IF_OFF ) )// this button should spark in OFF state { SetThink( &CBaseButton::ButtonSpark ); - pev->nextthink = gpGlobals->time + 0.5;// no hurry, make sure everything else spawns + pev->nextthink = gpGlobals->time + 0.5f;// no hurry, make sure everything else spawns } SetMovedir( pev ); @@ -485,29 +485,29 @@ void CBaseButton::Spawn() pev->solid = SOLID_BSP; SET_MODEL( ENT( pev ), STRING( pev->model ) ); - if( pev->speed == 0 ) - pev->speed = 40; + if( pev->speed == 0.0f ) + pev->speed = 40.0f; if( pev->health > 0 ) { pev->takedamage = DAMAGE_YES; } - if( m_flWait == 0 ) - m_flWait = 1; - if( m_flLip == 0 ) - m_flLip = 4; + if( m_flWait == 0.0f ) + m_flWait = 1.0f; + if( m_flLip == 0.0f ) + m_flLip = 4.0f; m_toggle_state = TS_AT_BOTTOM; m_vecPosition1 = pev->origin; // Subtract 2 from size because the engine expands bboxes by 1 in all directions making the size too big - m_vecPosition2 = m_vecPosition1 + ( pev->movedir * ( fabs( pev->movedir.x * ( pev->size.x - 2 ) ) + fabs( pev->movedir.y * ( pev->size.y - 2 ) ) + fabs( pev->movedir.z * ( pev->size.z - 2 ) ) - m_flLip ) ); + m_vecPosition2 = m_vecPosition1 + ( pev->movedir * ( fabs( pev->movedir.x * ( pev->size.x - 2.0f ) ) + fabs( pev->movedir.y * ( pev->size.y - 2.0f ) ) + fabs( pev->movedir.z * ( pev->size.z - 2.0f ) ) - m_flLip ) ); // Is this a non-moving button? - if( ( ( m_vecPosition2 - m_vecPosition1 ).Length() < 1 ) || ( pev->spawnflags & SF_BUTTON_DONTMOVE ) ) + if( ( ( m_vecPosition2 - m_vecPosition1 ).Length() < 1.0f ) || ( pev->spawnflags & SF_BUTTON_DONTMOVE ) ) m_vecPosition2 = m_vecPosition1; - m_fStayPushed = m_flWait == -1 ? TRUE : FALSE; + m_fStayPushed = m_flWait == -1.0f ? TRUE : FALSE; m_fRotating = FALSE; // if the button is flagged for USE button activation only, take away it's touch function and add a use function @@ -607,11 +607,11 @@ const char *ButtonSound( int sound ) // void DoSpark( entvars_t *pev, const Vector &location ) { - Vector tmp = location + pev->size * 0.5; + Vector tmp = location + pev->size * 0.5f; UTIL_Sparks( tmp ); - float flVolume = RANDOM_FLOAT( 0.25 , 0.75 ) * 0.4;//random volume range - switch( (int)( RANDOM_FLOAT( 0, 1 ) * 6 ) ) + float flVolume = RANDOM_FLOAT( 0.25f, 0.75f ) * 0.4f;//random volume range + switch( (int)( RANDOM_FLOAT( 0.0f, 1.0f ) * 6.0f ) ) { case 0: EMIT_SOUND( ENT( pev ), CHAN_VOICE, "buttons/spark1.wav", flVolume, ATTN_NORM ); @@ -637,9 +637,9 @@ void DoSpark( entvars_t *pev, const Vector &location ) void CBaseButton::ButtonSpark( void ) { SetThink( &CBaseButton::ButtonSpark ); - pev->nextthink = gpGlobals->time + 0.1 + RANDOM_FLOAT( 0, 1.5 );// spark again at random interval + pev->nextthink = pev->ltime + 0.1f + RANDOM_FLOAT( 0.0f, 1.5f );// spark again at random interval - DoSpark( pev, pev->mins ); + DoSpark( pev, pev->absmin ); } // @@ -657,7 +657,7 @@ void CBaseButton::ButtonUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_ { if( !m_fStayPushed && FBitSet( pev->spawnflags, SF_BUTTON_TOGGLE ) ) { - EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noise ), 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noise ), 1.0f, ATTN_NORM ); //SUB_UseTargets( m_eoActivator ); ButtonReturn(); @@ -694,7 +694,7 @@ CBaseButton::BUTTON_CODE CBaseButton::ButtonResponseToTouch( void ) void CBaseButton::ButtonTouch( CBaseEntity *pOther ) { // Ignore touches by anything but players - if( !FClassnameIs( pOther->pev, "player" ) ) + if( !pOther->IsPlayer() ) return; m_hActivator = pOther; @@ -795,7 +795,7 @@ void CBaseButton::ButtonReturn( void ) { ASSERT( m_toggle_state == TS_AT_TOP ); m_toggle_state = TS_GOING_DOWN; - + SetMoveDone( &CBaseButton::ButtonBackHome ); if( !m_fRotating ) LinearMove( m_vecPosition1, pev->speed ); @@ -852,7 +852,7 @@ void CBaseButton::ButtonBackHome( void ) if( FBitSet( pev->spawnflags, SF_BUTTON_SPARK_IF_OFF ) ) { SetThink( &CBaseButton::ButtonSpark ); - pev->nextthink = gpGlobals->time + 0.5;// no hurry. + pev->nextthink = gpGlobals->time + 0.5f;// no hurry. } } @@ -883,7 +883,7 @@ void CRotButton::Spawn( void ) // check for clockwise rotation if( FBitSet( pev->spawnflags, SF_DOOR_ROTATE_BACKWARDS ) ) - pev->movedir = pev->movedir * -1; + pev->movedir = pev->movedir * -1.0f; pev->movetype = MOVETYPE_PUSH; @@ -894,8 +894,8 @@ void CRotButton::Spawn( void ) SET_MODEL( ENT( pev ), STRING( pev->model ) ); - if( pev->speed == 0 ) - pev->speed = 40; + if( pev->speed == 0.0f ) + pev->speed = 40.0f; if( m_flWait == 0 ) m_flWait = 1; @@ -910,7 +910,7 @@ void CRotButton::Spawn( void ) m_vecAngle2 = pev->angles + pev->movedir * m_flMoveDistance; ASSERTSZ( m_vecAngle1 != m_vecAngle2, "rotating button start/end positions are equal" ); - m_fStayPushed = m_flWait == -1 ? TRUE : FALSE; + m_fStayPushed = m_flWait == -1.0f ? TRUE : FALSE; m_fRotating = TRUE; // if the button is flagged for USE button activation only, take away it's touch function and add a use function @@ -984,10 +984,10 @@ void CMomentaryRotButton::Spawn( void ) { CBaseToggle::AxisDir( pev ); - if( pev->speed == 0 ) - pev->speed = 100; + if( pev->speed == 0.0f ) + pev->speed = 100.0f; - if( m_flMoveDistance < 0 ) + if( m_flMoveDistance < 0.0f ) { m_start = pev->angles + pev->movedir * m_flMoveDistance; m_end = pev->angles; @@ -1087,14 +1087,14 @@ void CMomentaryRotButton::UpdateSelf( float value ) } m_lastUsed = 1; - pev->nextthink = pev->ltime + 0.1; - if( m_direction > 0 && value >= 1.0 ) + pev->nextthink = pev->ltime + 0.1f; + if( m_direction > 0 && value >= 1.0f ) { pev->avelocity = g_vecZero; pev->angles = m_end; return; } - else if( m_direction < 0 && value <= 0 ) + else if( m_direction < 0 && value <= 0.0f ) { pev->avelocity = g_vecZero; pev->angles = m_start; @@ -1106,9 +1106,9 @@ void CMomentaryRotButton::UpdateSelf( float value ) // HACKHACK -- If we're going slow, we'll get multiple player packets per frame, bump nexthink on each one to avoid stalling if( pev->nextthink < pev->ltime ) - pev->nextthink = pev->ltime + 0.1; + pev->nextthink = pev->ltime + 0.1f; else - pev->nextthink += 0.1; + pev->nextthink += 0.1f; pev->avelocity = m_direction * pev->speed * pev->movedir; SetThink( &CMomentaryRotButton::Off ); @@ -1140,7 +1140,7 @@ void CMomentaryRotButton::Off( void ) if( FBitSet( pev->spawnflags, SF_PENDULUM_AUTO_RETURN ) && m_returnSpeed > 0 ) { SetThink( &CMomentaryRotButton::Return ); - pev->nextthink = pev->ltime + 0.1; + pev->nextthink = pev->ltime + 0.1f; m_direction = -1; } else @@ -1152,23 +1152,23 @@ void CMomentaryRotButton::Return( void ) float value = CBaseToggle::AxisDelta( pev->spawnflags, pev->angles, m_start ) / m_flMoveDistance; UpdateAllButtons( value, 0 ); // This will end up calling UpdateSelfReturn() n times, but it still works right - if( value > 0 ) + if( value > 0.0f ) UpdateTarget( value ); } void CMomentaryRotButton::UpdateSelfReturn( float value ) { - if( value <= 0 ) + if( value <= 0.0f ) { pev->avelocity = g_vecZero; pev->angles = m_start; - pev->nextthink = -1; + pev->nextthink = -1.0f; SetThink( NULL ); } else { pev->avelocity = -m_returnSpeed * pev->movedir; - pev->nextthink = pev->ltime + 0.1; + pev->nextthink = pev->ltime + 0.1f; } } @@ -1221,10 +1221,10 @@ void CEnvSpark::Spawn( void ) else SetThink( &CEnvSpark::SparkThink ); - pev->nextthink = gpGlobals->time + 0.1 + RANDOM_FLOAT( 0, 1.5 ); + pev->nextthink = gpGlobals->time + 0.1f + RANDOM_FLOAT( 0.0f, 1.5f ); - if( m_flDelay <= 0 ) - m_flDelay = 1.5; + if( m_flDelay <= 0.0f ) + m_flDelay = 1.5f; Precache(); } @@ -1259,7 +1259,7 @@ void CEnvSpark::KeyValue( KeyValueData *pkvd ) void EXPORT CEnvSpark::SparkThink( void ) { - pev->nextthink = gpGlobals->time + 0.1 + RANDOM_FLOAT( 0, m_flDelay ); + pev->nextthink = gpGlobals->time + 0.1f + RANDOM_FLOAT( 0.0f, m_flDelay ); DoSpark( pev, pev->origin ); } @@ -1267,7 +1267,7 @@ void EXPORT CEnvSpark::SparkStart( CBaseEntity *pActivator, CBaseEntity *pCaller { SetUse( &CEnvSpark::SparkStop ); SetThink( &CEnvSpark::SparkThink ); - pev->nextthink = gpGlobals->time + 0.1 + RANDOM_FLOAT( 0, m_flDelay ); + pev->nextthink = gpGlobals->time + 0.1f + RANDOM_FLOAT( 0.0f, m_flDelay ); } void EXPORT CEnvSpark::SparkStop( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) @@ -1305,7 +1305,7 @@ void CButtonTarget::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE { if( !ShouldToggle( useType, (int)pev->frame ) ) return; - pev->frame = 1-pev->frame; + pev->frame = 1 - pev->frame; if( pev->frame ) SUB_UseTargets( pActivator, USE_ON, 0 ); else diff --git a/dlls/cbase.cpp b/dlls/cbase.cpp index e1448a7e..17317ac5 100644 --- a/dlls/cbase.cpp +++ b/dlls/cbase.cpp @@ -98,7 +98,7 @@ static DLL_FUNCTIONS gFunctionTable = static void SetObjectCollisionBox( entvars_t *pev ); -#ifndef _WIN32 +#if !_WIN32 extern "C" { #endif int GetEntityAPI( DLL_FUNCTIONS *pFunctionTable, int interfaceVersion ) @@ -125,7 +125,7 @@ int GetEntityAPI2( DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion ) return TRUE; } -#ifndef _WIN32 +#if !_WIN32 } #endif @@ -142,8 +142,8 @@ int DispatchSpawn( edict_t *pent ) if( pEntity ) { // Initialize these or entities who don't link to the world won't have anything in here - pEntity->pev->absmin = pEntity->pev->origin - Vector( 1, 1, 1 ); - pEntity->pev->absmax = pEntity->pev->origin + Vector( 1, 1, 1 ); + pEntity->pev->absmin = pEntity->pev->origin - Vector( 1.0f, 1.0f, 1.0f ); + pEntity->pev->absmax = pEntity->pev->origin + Vector( 1.0f, 1.0f, 1.0f ); pEntity->Spawn(); @@ -296,6 +296,8 @@ void DispatchSave( edict_t *pent, SAVERESTOREDATA *pSaveData ) { ENTITYTABLE *pTable = &pSaveData->pTable[pSaveData->currentIndex]; + gpGlobals->time = pSaveData->time; + if( pTable->pent != pent ) ALERT( at_error, "ENTITY TABLE OR INDEX IS WRONG!!!!\n" ); @@ -355,6 +357,9 @@ int DispatchRestore( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity Vector oldOffset; CRestore restoreHelper( pSaveData ); + + gpGlobals->time = pSaveData->time; + if( globalEntity ) { CRestore tmpRestore( pSaveData ); @@ -605,13 +610,13 @@ int CBaseEntity::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, fl // figure momentum add (don't let hurt brushes or other triggers move player) if( ( !FNullEnt( pevInflictor ) ) && (pev->movetype == MOVETYPE_WALK || pev->movetype == MOVETYPE_STEP ) && ( pevAttacker->solid != SOLID_TRIGGER ) ) { - Vector vecDir = pev->origin - ( pevInflictor->absmin + pevInflictor->absmax ) * 0.5; + Vector vecDir = pev->origin - ( pevInflictor->absmin + pevInflictor->absmax ) * 0.5f; vecDir = vecDir.Normalize(); - float flForce = flDamage * ( ( 32 * 32 * 72.0 ) / ( pev->size.x * pev->size.y * pev->size.z ) ) * 5; + float flForce = flDamage * ( ( 32.0f * 32.0f * 72.0f ) / ( pev->size.x * pev->size.y * pev->size.z ) ) * 5.0f; - if( flForce > 1000.0 ) - flForce = 1000.0; + if( flForce > 1000.0f ) + flForce = 1000.0f; pev->velocity = pev->velocity + vecDir * flForce; } @@ -755,7 +760,7 @@ void CBaseEntity::MakeDormant( void ) // Don't draw SetBits( pev->effects, EF_NODRAW ); // Don't think - pev->nextthink = 0; + pev->nextthink = 0.0f; // Relink UTIL_SetOrigin( pev, pev->origin ); } @@ -768,30 +773,30 @@ int CBaseEntity::IsDormant( void ) BOOL CBaseEntity::IsInWorld( void ) { // position - if( pev->origin.x >= 4096 ) + if( pev->origin.x >= 4096.0f ) return FALSE; - if( pev->origin.y >= 4096 ) + if( pev->origin.y >= 4096.0f ) return FALSE; - if( pev->origin.z >= 4096 ) + if( pev->origin.z >= 4096.0f ) return FALSE; - if( pev->origin.x <= -4096 ) + if( pev->origin.x <= -4096.0f ) return FALSE; - if( pev->origin.y <= -4096 ) + if( pev->origin.y <= -4096.0f ) return FALSE; - if( pev->origin.z <= -4096 ) + if( pev->origin.z <= -4096.0f ) return FALSE; // speed - if( pev->velocity.x >= 2000 ) + if( pev->velocity.x >= 2000.0f ) return FALSE; - if( pev->velocity.y >= 2000 ) + if( pev->velocity.y >= 2000.0f ) return FALSE; - if( pev->velocity.z >= 2000 ) + if( pev->velocity.z >= 2000.0f ) return FALSE; - if( pev->velocity.x <= -2000 ) + if( pev->velocity.x <= -2000.0f ) return FALSE; - if( pev->velocity.y <= -2000 ) + if( pev->velocity.y <= -2000.0f ) return FALSE; - if( pev->velocity.z <= -2000 ) + if( pev->velocity.z <= -2000.0f ) return FALSE; return TRUE; diff --git a/dlls/cbase.h b/dlls/cbase.h index 1c3c080f..8904fe45 100644 --- a/dlls/cbase.h +++ b/dlls/cbase.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef CBASE_H +#if !defined(CBASE_H) #define CBASE_H /* @@ -48,7 +48,7 @@ CBaseEntity #include "saverestore.h" #include "schedule.h" -#ifndef MONSTEREVENT_H +#if !defined(MONSTEREVENT_H) #include "monsterevent.h" #endif @@ -60,7 +60,6 @@ CBaseEntity extern "C" EXPORT int GetEntityAPI( DLL_FUNCTIONS *pFunctionTable, int interfaceVersion ); extern "C" EXPORT int GetEntityAPI2( DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion ); -extern "C" EXPORT int Server_GetPhysicsInterface( int iVersion, server_physics_api_t *pfuncsFromEngine, physics_interface_t *pFunctionTable ); extern int DispatchSpawn( edict_t *pent ); extern void DispatchKeyValue( edict_t *pentKeyvalue, KeyValueData *pkvd ); @@ -196,7 +195,7 @@ public: virtual BOOL IsAlive( void ) { return (pev->deadflag == DEAD_NO) && pev->health > 0; } virtual BOOL IsBSPModel( void ) { return pev->solid == SOLID_BSP || pev->movetype == MOVETYPE_PUSHSTEP; } virtual BOOL ReflectGauss( void ) { return ( IsBSPModel() && !pev->takedamage ); } - virtual BOOL HasTarget( string_t targetname ) { return FStrEq(STRING(targetname), STRING(pev->targetname) ); } + virtual BOOL HasTarget( string_t targetname ) { return FStrEq(STRING(targetname), STRING(pev->target) ); } virtual BOOL IsInWorld( void ); virtual BOOL IsPlayer( void ) { return FALSE; } virtual BOOL IsNetClient( void ) { return FALSE; } @@ -284,7 +283,7 @@ public: } // Ugly code to lookup all functions to make sure they are exported when set. -#ifdef _DEBUG +#if _DEBUG void FunctionCheck( void *pFunction, char *name ) { if( pFunction && !NAME_FOR_FUNCTION( pFunction ) ) @@ -363,12 +362,13 @@ public: // Normally it's illegal to cast a pointer to a member function of a derived class to a pointer to a // member function of a base class. static_cast is a sleezy way around that problem. -#ifdef _DEBUG +#if _DEBUG #define SetThink( a ) ThinkSet( static_cast (a), #a ) #define SetTouch( a ) TouchSet( static_cast (a), #a ) #define SetUse( a ) UseSet( static_cast (a), #a ) #define SetBlocked( a ) BlockedSet( static_cast (a), #a ) +#define ResetThink() SetThink(NULL) #else diff --git a/dlls/cdll_dll.h b/dlls/cdll_dll.h index 0aafafbd..4fe9e35a 100644 --- a/dlls/cdll_dll.h +++ b/dlls/cdll_dll.h @@ -17,7 +17,7 @@ // this file is included by both the game-dll and the client-dll, #pragma once -#ifndef CDLL_DLL_H +#if !defined(CDLL_DLL_H) #define CDLL_DLL_H #define MAX_WEAPONS 32 // ??? diff --git a/dlls/client.cpp b/dlls/client.cpp index 444e7b50..2d133ea3 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -69,11 +69,11 @@ void set_suicide_frame(entvars_t* pev) if (!FStrEq(STRING(pev->model), "models/player.mdl")) return; // allready gibbed -// pev->frame = $deatha11; - pev->solid = SOLID_NOT; - pev->movetype = MOVETYPE_TOSS; - pev->deadflag = DEAD_DEAD; - pev->nextthink = -1; + //pev->frame = $deatha11; + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_TOSS; + pev->deadflag = DEAD_DEAD; + pev->nextthink = -1.0f; } @@ -132,8 +132,10 @@ void ClientDisconnect( edict_t *pEntity ) char text[256] = ""; if( pEntity->v.netname ) - _snprintf( text, sizeof(text), "- %s has left the game\n", STRING( pEntity->v.netname ) ); - + { + _snprintf( text, sizeof(text) - 1, "- %s has left the game\n", STRING( pEntity->v.netname ) ); + text[sizeof(text) - 1] = '\0'; + } MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL ); WRITE_BYTE( ENTINDEX(pEntity) ); WRITE_STRING( text ); @@ -206,7 +208,7 @@ void ClientKill( edict_t *pEntity ) if ( pl->m_fNextSuicideTime > gpGlobals->time ) return; // prevent suiciding too ofter - pl->m_fNextSuicideTime = gpGlobals->time + 1; // don't let them suicide for 5 seconds after suiciding + pl->m_fNextSuicideTime = gpGlobals->time + 1.0f; // don't let them suicide for 5 seconds after suiciding // have the player kill themself pev->health = 0; @@ -230,8 +232,9 @@ void ClientPutInServer( edict_t *pEntity ) entvars_t *pev = &pEntity->v; - pPlayer = GetClassPtr((CBasePlayer *)pev); - pPlayer->SetCustomDecalFrames(-1); // Assume none; + pPlayer = GetClassPtr( (CBasePlayer *)pev ); + pPlayer->SetCustomDecalFrames( -1 ); // Assume none; + pPlayer->SetPrefsFromUserinfo( g_engfuncs.pfnGetInfoKeyBuffer( pEntity ) ); GGM_ClientPutinServer( pEntity, pPlayer ); @@ -248,7 +251,7 @@ void ClientPutInServer( edict_t *pEntity ) } -#ifndef NO_VOICEGAMEMGR +#if !NO_VOICEGAMEMGR #include "voice_gamemgr.h" extern CVoiceGameMgr g_VoiceGameMgr; #endif @@ -310,7 +313,7 @@ decodeError: uValueOut = '?'; bErrorOut = true; return nBytes; - +#if 0 decodeFinishedMaybeCESU8: // Do we have a full UTF-16 surrogate pair that's been UTF-8 encoded afterwards? // That is, do we have 0xD800-0xDBFF followed by 0xDC00-0xDFFF? If so, decode it all. @@ -321,6 +324,7 @@ decodeFinishedMaybeCESU8: uMinValue = 0x10000; } goto decodeFinished; +#endif } //----------------------------------------------------------------------------- @@ -357,7 +361,7 @@ void Host_Say( edict_t *pEntity, int teamonly ) { CBasePlayer *client; int j; - char *p, *pc; + char *p; //, *pc; char text[128]; char szTemp[256]; const char *cpSay = "say"; @@ -391,13 +395,15 @@ void Host_Say( edict_t *pEntity, int teamonly ) { if ( CMD_ARGC() >= 2 ) { - sprintf( szTemp, "%s %s", ( char * )pcmd, (char *)CMD_ARGS() ); + _snprintf( szTemp, sizeof(szTemp) - 1, "%s %s", (char *)pcmd, (char *)CMD_ARGS() ); } else { // Just a one word command, use the first word...sigh - sprintf( szTemp, "%s", ( char * )pcmd ); + strncpy( szTemp, (char *)pcmd, sizeof(szTemp) - 1 ); } + szTemp[sizeof(szTemp) - 1] = '\0'; + p = szTemp; } @@ -414,11 +420,12 @@ void Host_Say( edict_t *pEntity, int teamonly ) // turn on color set 2 (color on, no sound) if( player->IsObserver() && ( teamonly ) ) - sprintf( text, "%c(SPEC) %s: ", 2, STRING( pEntity->v.netname ) ); + _snprintf( text, sizeof(text) - 1, "%c(SPEC) %s: ", 2, STRING( pEntity->v.netname ) ); else if( teamonly ) - sprintf( text, "%c(TEAM) %s: ", 2, STRING( pEntity->v.netname ) ); + _snprintf( text, sizeof(text) - 1, "%c(TEAM) %s: ", 2, STRING( pEntity->v.netname ) ); else - sprintf( text, "%c%s: ", 2, STRING( pEntity->v.netname ) ); + _snprintf( text, sizeof(text) - 1, "%c%s: ", 2, STRING( pEntity->v.netname ) ); + text[sizeof(text) - 1] = '\0'; j = sizeof(text) - 2 - strlen(text); // -2 for /n and null terminator if ( (int)strlen(p) > j ) @@ -447,8 +454,10 @@ void Host_Say( edict_t *pEntity, int teamonly ) if ( !(client->IsNetClient()) ) // Not a client ? (should never be true) continue; + if( !( client->IsNetClient() ) ) // Not a client ? (should never be true) + continue; +#if !NO_VOICEGAMEMGR // can the receiver hear the sender? or has he muted him? -#ifndef NO_VOICEGAMEMGR if ( g_VoiceGameMgr.PlayerHasBlockedPlayer( client, player ) ) continue; #endif @@ -512,7 +521,7 @@ ClientCommand called each time a player uses a "cmd" command ============ */ -extern float g_flWeaponCheat; +extern cvar_t *g_enable_cheats; // Use CMD_ARGV, CMD_ARGV, and CMD_ARGC to get pointers the character string command. void ClientCommand( edict_t *pEntity ) @@ -541,7 +550,7 @@ void ClientCommand( edict_t *pEntity ) } else if ( FStrEq(pcmd, "give" ) ) { - if ( g_flWeaponCheat != 0.0) + if( g_enable_cheats->value != 0 ) { int iszItem = ALLOC_STRING( CMD_ARGV(1) ); // Make a copy of the classname GetClassPtr((CBasePlayer *)pev)->GiveNamedItem( STRING(iszItem) ); @@ -549,7 +558,7 @@ void ClientCommand( edict_t *pEntity ) } else if ( FStrEq(pcmd, "fire") ) { - if ( g_flWeaponCheat != 0.0) + if( g_enable_cheats->value != 0 ) { CBaseEntity *pPlayer = CBaseEntity::Instance(pEntity); if (CMD_ARGC() > 1) @@ -585,7 +594,7 @@ void ClientCommand( edict_t *pEntity ) } else if ( FStrEq(pcmd, "fov" ) ) { - if ( g_flWeaponCheat && CMD_ARGC() > 1) + if( g_enable_cheats->value != 0 && CMD_ARGC() > 1 ) { GetClassPtr((CBasePlayer *)pev)->m_iFOV = atoi( CMD_ARGV(1) ); } @@ -670,8 +679,8 @@ void ClientCommand( edict_t *pEntity ) // check the length of the command (prevents crash) // max total length is 192 ...and we're adding a string below ("Unknown command: %s\n") - strncpy( command, pcmd, 127 ); - command[127] = '\0'; + strncpy( command, pcmd, sizeof(command) - 1); + command[sizeof(command) - 1] = '\0'; // tell the user they entered an unknown command ClientPrint( &pEntity->v, HUD_PRINTCONSOLE, UTIL_VarArgs( "Unknown command: %s\n", command ) ); @@ -745,7 +754,8 @@ void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer ) if( gpGlobals->maxClients > 1 ) { char text[256]; - _snprintf( text, 256, "* %s changed name to %s\n", STRING( pEntity->v.netname ), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) ); + _snprintf( text, sizeof(text) - 1, "* %s changed name to %s\n", STRING( pEntity->v.netname ), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) ); + text[sizeof(text) - 1] = '\0'; MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL ); WRITE_BYTE( ENTINDEX( pEntity ) ); WRITE_STRING( text ); @@ -812,7 +822,7 @@ void ServerActivate( edict_t *pEdictList, int edictCount, int clientMax ) continue; // Clients aren't necessarily initialized until ClientPutInServer() - if ( i < clientMax || !pEdictList[i].pvPrivateData ) + if( (i > 0 && i <= clientMax) || !pEdictList[i].pvPrivateData ) continue; pClass = CBaseEntity::Instance( &pEdictList[i] ); @@ -914,7 +924,7 @@ void StartFrame( void ) g_ulFrameCount++; int oldBhopcap = g_bhopcap; - g_bhopcap = ( g_pGameRules->IsMultiplayer() && bhopcap.value != 0.0f ) ? 1 : 0; + g_bhopcap = ( g_pGameRules && g_pGameRules->IsMultiplayer() && bhopcap.value != 0.0f ) ? 1 : 0; if( g_bhopcap != oldBhopcap ) { MESSAGE_BEGIN( MSG_ALL, gmsgBhopcap, NULL ); @@ -1383,7 +1393,7 @@ int AddToFullPack( struct entity_state_s *state, int e, edict_t *ent, edict_t *h // // Round animtime to nearest millisecond - state->animtime = (int)(1000.0 * ent->v.animtime ) / 1000.0; + state->animtime = (int)( 1000.0f * ent->v.animtime ) / 1000.0f; memcpy( state->origin, ent->v.origin, 3 * sizeof( float ) ); memcpy( state->angles, ent->v.angles, 3 * sizeof( float ) ); @@ -1846,7 +1856,8 @@ void RegisterEncoders( void ) int GetWeaponData( struct edict_s *player, struct weapon_data_s *info ) { -#if defined( CLIENT_WEAPONS ) + memset( info, 0, MAX_WEAPONS * sizeof(weapon_data_t) ); +#if CLIENT_WEAPONS int i; weapon_data_t *item; entvars_t *pev = &player->v; @@ -1855,9 +1866,7 @@ int GetWeaponData( struct edict_s *player, struct weapon_data_s *info ) ItemInfo II; - memset( info, 0, 32 * sizeof( weapon_data_t ) ); - - if ( !pl ) + if( !pl ) return 1; // go through all of the weapons and make a list of the ones to pack @@ -1877,19 +1886,19 @@ int GetWeaponData( struct edict_s *player, struct weapon_data_s *info ) memset( &II, 0, sizeof( II ) ); gun->GetItemInfo( &II ); - if ( II.iId >= 0 && II.iId < 32 ) + if( II.iId >= 0 && II.iId < MAX_WEAPONS ) { item = &info[ II.iId ]; item->m_iId = II.iId; item->m_iClip = gun->m_iClip; - item->m_flTimeWeaponIdle = Q_max( gun->m_flTimeWeaponIdle, -0.001 ); - item->m_flNextPrimaryAttack = Q_max( gun->m_flNextPrimaryAttack, -0.001 ); - item->m_flNextSecondaryAttack = Q_max( gun->m_flNextSecondaryAttack, -0.001 ); + item->m_flTimeWeaponIdle = Q_max( gun->m_flTimeWeaponIdle, -0.001f ); + item->m_flNextPrimaryAttack = Q_max( gun->m_flNextPrimaryAttack, -0.001f ); + item->m_flNextSecondaryAttack = Q_max( gun->m_flNextSecondaryAttack, -0.001f ); item->m_fInReload = gun->m_fInReload; item->m_fInSpecialReload = gun->m_fInSpecialReload; - item->fuser1 = Q_max( gun->pev->fuser1, -0.001 ); + item->fuser1 = Q_max( gun->pev->fuser1, -0.001f ); item->fuser2 = gun->m_flStartThrow; item->fuser3 = gun->m_flReleaseThrow; item->iuser1 = gun->m_chargeReady; @@ -1903,8 +1912,6 @@ int GetWeaponData( struct edict_s *player, struct weapon_data_s *info ) } } } -#else - memset( info, 0, 32 * sizeof( weapon_data_t ) ); #endif return 1; } @@ -1977,8 +1984,8 @@ void UpdateClientData ( const struct edict_s *ent, int sendweapons, struct clien cd->iuser1 = pev->iuser1; cd->iuser2 = pev->iuser2; } -#if defined( CLIENT_WEAPONS ) - if ( sendweapons ) +#if CLIENT_WEAPONS + if( sendweapons ) { if( pl ) { @@ -2164,7 +2171,7 @@ One of the ENGINE_FORCE_UNMODIFIED files failed the consistency check for the sp int InconsistentFile( const edict_t *player, const char *filename, char *disconnect_message ) { // Server doesn't care? - if ( CVAR_GET_FLOAT( "mp_consistency" ) != 1 ) + if( CVAR_GET_FLOAT( "mp_consistency" ) != 1.0f ) return 0; // Default behavior is to kick the player diff --git a/dlls/client.h b/dlls/client.h index 6feaac1a..73bc0dc5 100644 --- a/dlls/client.h +++ b/dlls/client.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef CLIENT_H +#if !defined(CLIENT_H) #define CLIENT_H extern void respawn( entvars_t *pev, BOOL fCopyCorpse ); diff --git a/dlls/combat.cpp b/dlls/combat.cpp index 763ae989..11f63c55 100644 --- a/dlls/combat.cpp +++ b/dlls/combat.cpp @@ -30,6 +30,7 @@ #include "weapons.h" #include "func_break.h" #include "game.h" + extern DLL_GLOBAL Vector g_vecAttackDir; extern DLL_GLOBAL int g_iSkillLevel; @@ -48,8 +49,8 @@ void CGib::LimitVelocity( void ) // ceiling at 1500. The gib velocity equation is not bounded properly. Rather than tune it // in 3 separate places again, I'll just limit it here. - if( length > 1500.0 ) - pev->velocity = pev->velocity.Normalize() * 1500; // This should really be sv_maxvelocity * 0.75 or something + if( length > 1500.0f ) + pev->velocity = pev->velocity.Normalize() * 1500.0f; // This should really be sv_maxvelocity * 0.75 or something } @@ -72,9 +73,9 @@ void CGib::SpawnStickyGibs( entvars_t *pevVictim, Vector vecOrigin, int cGibs ) if( pevVictim ) { - pGib->pev->origin.x = vecOrigin.x + RANDOM_FLOAT( -3, 3 ); - pGib->pev->origin.y = vecOrigin.y + RANDOM_FLOAT( -3, 3 ); - pGib->pev->origin.z = vecOrigin.z + RANDOM_FLOAT( -3, 3 ); + pGib->pev->origin.x = vecOrigin.x + RANDOM_FLOAT( -3.0f, 3.0f ); + pGib->pev->origin.y = vecOrigin.y + RANDOM_FLOAT( -3.0f, 3.0f ); + pGib->pev->origin.z = vecOrigin.z + RANDOM_FLOAT( -3.0f, 3.0f ); /* pGib->pev->origin.x = pevVictim->absmin.x + pevVictim->size.x * ( RANDOM_FLOAT( 0, 1 ) ); @@ -83,32 +84,32 @@ void CGib::SpawnStickyGibs( entvars_t *pevVictim, Vector vecOrigin, int cGibs ) */ // make the gib fly away from the attack vector - pGib->pev->velocity = g_vecAttackDir * -1; + pGib->pev->velocity = g_vecAttackDir * -1.0f; // mix in some noise - pGib->pev->velocity.x += RANDOM_FLOAT( -0.15, 0.15 ); - pGib->pev->velocity.y += RANDOM_FLOAT( -0.15, 0.15 ); - pGib->pev->velocity.z += RANDOM_FLOAT( -0.15, 0.15 ); + pGib->pev->velocity.x += RANDOM_FLOAT( -0.15f, 0.15f ); + pGib->pev->velocity.y += RANDOM_FLOAT( -0.15f, 0.15f ); + pGib->pev->velocity.z += RANDOM_FLOAT( -0.15f, 0.15f ); - pGib->pev->velocity = pGib->pev->velocity * 900; + pGib->pev->velocity = pGib->pev->velocity * 900.0f; - pGib->pev->avelocity.x = RANDOM_FLOAT( 250, 400 ); - pGib->pev->avelocity.y = RANDOM_FLOAT( 250, 400 ); + pGib->pev->avelocity.x = RANDOM_FLOAT( 250.0f, 400.0f ); + pGib->pev->avelocity.y = RANDOM_FLOAT( 250.0f, 400.0f ); // copy owner's blood color pGib->m_bloodColor = ( CBaseEntity::Instance( pevVictim ) )->BloodColor(); if( pevVictim->health > -50 ) { - pGib->pev->velocity = pGib->pev->velocity * 0.7; + pGib->pev->velocity = pGib->pev->velocity * 0.7f; } else if( pevVictim->health > -200 ) { - pGib->pev->velocity = pGib->pev->velocity * 2; + pGib->pev->velocity = pGib->pev->velocity * 2.0f; } else { - pGib->pev->velocity = pGib->pev->velocity * 4; + pGib->pev->velocity = pGib->pev->velocity * 4.0f; } pGib->pev->movetype = MOVETYPE_TOSS; @@ -148,31 +149,31 @@ void CGib::SpawnHeadGib( entvars_t *pevVictim ) entvars_t *pevPlayer; pevPlayer = VARS( pentPlayer ); - pGib->pev->velocity = ( ( pevPlayer->origin + pevPlayer->view_ofs ) - pGib->pev->origin ).Normalize() * 300; - pGib->pev->velocity.z += 100; + pGib->pev->velocity = ( ( pevPlayer->origin + pevPlayer->view_ofs ) - pGib->pev->origin ).Normalize() * 300.0f; + pGib->pev->velocity.z += 100.0f; } else { - pGib->pev->velocity = Vector( RANDOM_FLOAT( -100, 100 ), RANDOM_FLOAT( -100, 100 ), RANDOM_FLOAT( 200, 300 ) ); + pGib->pev->velocity = Vector( RANDOM_FLOAT( -100.0f, 100.0f ), RANDOM_FLOAT( -100.0f, 100.0f ), RANDOM_FLOAT( 200.0f, 300.0f ) ); } - pGib->pev->avelocity.x = RANDOM_FLOAT( 100, 200 ); - pGib->pev->avelocity.y = RANDOM_FLOAT( 100, 300 ); + pGib->pev->avelocity.x = RANDOM_FLOAT( 100.0f, 200.0f ); + pGib->pev->avelocity.y = RANDOM_FLOAT( 100.0f, 300.0f ); // copy owner's blood color pGib->m_bloodColor = ( CBaseEntity::Instance( pevVictim ) )->BloodColor(); if( pevVictim->health > -50 ) { - pGib->pev->velocity = pGib->pev->velocity * 0.7; + pGib->pev->velocity = pGib->pev->velocity * 0.7f; } else if( pevVictim->health > -200 ) { - pGib->pev->velocity = pGib->pev->velocity * 2; + pGib->pev->velocity = pGib->pev->velocity * 2.0f; } else { - pGib->pev->velocity = pGib->pev->velocity * 4; + pGib->pev->velocity = pGib->pev->velocity * 4.0f; } } pGib->LimitVelocity(); @@ -210,37 +211,37 @@ void CGib::SpawnRandomGibs( entvars_t *pevVictim, int cGibs, int human ) if( pevVictim ) { // spawn the gib somewhere in the monster's bounding volume - pGib->pev->origin.x = pevVictim->absmin.x + pevVictim->size.x * (RANDOM_FLOAT ( 0 , 1 ) ); - pGib->pev->origin.y = pevVictim->absmin.y + pevVictim->size.y * (RANDOM_FLOAT ( 0 , 1 ) ); - pGib->pev->origin.z = pevVictim->absmin.z + pevVictim->size.z * (RANDOM_FLOAT ( 0 , 1 ) ) + 1; // absmin.z is in the floor because the engine subtracts 1 to enlarge the box + pGib->pev->origin.x = pevVictim->absmin.x + pevVictim->size.x * ( RANDOM_FLOAT( 0.0f, 1.0f ) ); + pGib->pev->origin.y = pevVictim->absmin.y + pevVictim->size.y * ( RANDOM_FLOAT( 0.0f, 1.0f ) ); + pGib->pev->origin.z = pevVictim->absmin.z + pevVictim->size.z * ( RANDOM_FLOAT( 0.0f, 1.0f ) ) + 1.0f; // absmin.z is in the floor because the engine subtracts 1 to enlarge the box // make the gib fly away from the attack vector - pGib->pev->velocity = g_vecAttackDir * -1; + pGib->pev->velocity = g_vecAttackDir * -1.0f; // mix in some noise - pGib->pev->velocity.x += RANDOM_FLOAT( -0.25, 0.25 ); - pGib->pev->velocity.y += RANDOM_FLOAT( -0.25, 0.25 ); - pGib->pev->velocity.z += RANDOM_FLOAT( -0.25, 0.25 ); + pGib->pev->velocity.x += RANDOM_FLOAT( -0.25f, 0.25f ); + pGib->pev->velocity.y += RANDOM_FLOAT( -0.25f, 0.25f ); + pGib->pev->velocity.z += RANDOM_FLOAT( -0.25f, 0.25f ); - pGib->pev->velocity = pGib->pev->velocity * RANDOM_FLOAT( 300, 400 ); + pGib->pev->velocity = pGib->pev->velocity * RANDOM_FLOAT( 300.0f, 400.0f ); - pGib->pev->avelocity.x = RANDOM_FLOAT( 100, 200 ); - pGib->pev->avelocity.y = RANDOM_FLOAT( 100, 300 ); + pGib->pev->avelocity.x = RANDOM_FLOAT( 100.0f, 200.0f ); + pGib->pev->avelocity.y = RANDOM_FLOAT( 100.0f, 300.0f ); // copy owner's blood color pGib->m_bloodColor = ( CBaseEntity::Instance( pevVictim ) )->BloodColor(); if( pevVictim->health > -50 ) { - pGib->pev->velocity = pGib->pev->velocity * 0.7; + pGib->pev->velocity = pGib->pev->velocity * 0.7f; } else if( pevVictim->health > -200 ) { - pGib->pev->velocity = pGib->pev->velocity * 2; + pGib->pev->velocity = pGib->pev->velocity * 2.0f; } else { - pGib->pev->velocity = pGib->pev->velocity * 4; + pGib->pev->velocity = pGib->pev->velocity * 4.0f; } pGib->pev->solid = SOLID_BBOX; @@ -374,7 +375,7 @@ Activity CBaseMonster::GetDeathActivity( void ) deathActivity = ACT_DIESIMPLE;// in case we can't find any special deaths to do. UTIL_MakeVectors( pev->angles ); - flDot = DotProduct( gpGlobals->v_forward, g_vecAttackDir * -1 ); + flDot = DotProduct( gpGlobals->v_forward, g_vecAttackDir * -1.0f ); switch( m_LastHitGroup ) { @@ -388,11 +389,11 @@ Activity CBaseMonster::GetDeathActivity( void ) case HITGROUP_GENERIC: // try to pick a death based on attack direction fTriedDirection = TRUE; - if( flDot > 0.3 ) + if( flDot > 0.3f ) { deathActivity = ACT_DIEFORWARD; } - else if( flDot <= -0.3 ) + else if( flDot <= -0.3f ) { deathActivity = ACT_DIEBACKWARD; } @@ -401,11 +402,11 @@ Activity CBaseMonster::GetDeathActivity( void ) // try to pick a death based on attack direction fTriedDirection = TRUE; - if( flDot > 0.3 ) + if( flDot > 0.3f ) { deathActivity = ACT_DIEFORWARD; } - else if( flDot <= -0.3 ) + else if( flDot <= -0.3f ) { deathActivity = ACT_DIEBACKWARD; } @@ -424,11 +425,11 @@ Activity CBaseMonster::GetDeathActivity( void ) else { // cannot perform the ideal region-specific death, so try a direction. - if( flDot > 0.3 ) + if( flDot > 0.3f ) { deathActivity = ACT_DIEFORWARD; } - else if( flDot <= -0.3 ) + else if( flDot <= -0.3f ) { deathActivity = ACT_DIEBACKWARD; } @@ -444,9 +445,9 @@ Activity CBaseMonster::GetDeathActivity( void ) if( deathActivity == ACT_DIEFORWARD ) { // make sure there's room to fall forward - UTIL_TraceHull( vecSrc, vecSrc + gpGlobals->v_forward * 64, dont_ignore_monsters, head_hull, edict(), &tr ); + UTIL_TraceHull( vecSrc, vecSrc + gpGlobals->v_forward * 64.0f, dont_ignore_monsters, head_hull, edict(), &tr ); - if( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0f ) { deathActivity = ACT_DIESIMPLE; } @@ -455,9 +456,9 @@ Activity CBaseMonster::GetDeathActivity( void ) if( deathActivity == ACT_DIEBACKWARD ) { // make sure there's room to fall backward - UTIL_TraceHull( vecSrc, vecSrc - gpGlobals->v_forward * 64, dont_ignore_monsters, head_hull, edict(), &tr ); + UTIL_TraceHull( vecSrc, vecSrc - gpGlobals->v_forward * 64.0f, dont_ignore_monsters, head_hull, edict(), &tr ); - if( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0f ) { deathActivity = ACT_DIESIMPLE; } @@ -473,12 +474,12 @@ Activity CBaseMonster::GetDeathActivity( void ) Activity CBaseMonster::GetSmallFlinchActivity( void ) { Activity flinchActivity; - BOOL fTriedDirection; + // BOOL fTriedDirection; //float flDot; - fTriedDirection = FALSE; + // fTriedDirection = FALSE; UTIL_MakeVectors( pev->angles ); - //flDot = DotProduct( gpGlobals->v_forward, g_vecAttackDir * -1 ); + //flDot = DotProduct( gpGlobals->v_forward, g_vecAttackDir * -1.0f ); switch( m_LastHitGroup ) { @@ -528,10 +529,16 @@ void CBaseMonster::BecomeDead( void ) // make the corpse fly away from the attack vector pev->movetype = MOVETYPE_TOSS; - //pev->flags &= ~FL_ONGROUND; - //pev->origin.z += 2; - //pev->velocity = g_vecAttackDir * -1; - //pev->velocity = pev->velocity * RANDOM_FLOAT( 300, 400 ); + if (corpsephysics.value && + // affect only dying monsters, not initially dead ones + m_IdealMonsterState == MONSTERSTATE_DEAD) + { + pev->flags &= ~FL_ONGROUND; + pev->origin.z += 2.0f; + pev->velocity = g_vecAttackDir * -1.0f; + pev->velocity = pev->velocity * RANDOM_FLOAT( 300.0f, 400.0f ); + } + } BOOL CBaseMonster::ShouldGibMonster( int iGib ) @@ -548,12 +555,12 @@ void CBaseMonster::CallGibMonster( void ) if( HasHumanGibs() ) { - if( CVAR_GET_FLOAT( "violence_hgibs" ) == 0 ) + if( CVAR_GET_FLOAT( "violence_hgibs" ) == 0.0f ) fade = TRUE; } else if( HasAlienGibs() ) { - if( CVAR_GET_FLOAT( "violence_agibs" ) == 0 ) + if( CVAR_GET_FLOAT( "violence_agibs" ) == 0.0f ) fade = TRUE; } @@ -681,7 +688,7 @@ void CBaseEntity::SUB_StartFadeOut( void ) pev->solid = SOLID_NOT; pev->avelocity = g_vecZero; - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; SetThink( &CBaseEntity::SUB_FadeOut ); } @@ -690,12 +697,12 @@ void CBaseEntity::SUB_FadeOut( void ) if( pev->renderamt > 7 ) { pev->renderamt -= 7; - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } else { pev->renderamt = 0; - pev->nextthink = gpGlobals->time + 0.2; + pev->nextthink = gpGlobals->time + 0.2f; SetThink( &CBaseEntity::SUB_Remove ); } } @@ -729,7 +736,7 @@ void CGib::WaitTillLand( void ) else { // wait and check again in another half second. - pev->nextthink = gpGlobals->time + 0.5; + pev->nextthink = gpGlobals->time + 0.5f; } } @@ -746,11 +753,11 @@ void CGib::BounceGibTouch( CBaseEntity *pOther ) if( pev->flags & FL_ONGROUND ) { - pev->velocity = pev->velocity * 0.9; - pev->angles.x = 0; - pev->angles.z = 0; - pev->avelocity.x = 0; - pev->avelocity.z = 0; + pev->velocity = pev->velocity * 0.9f; + pev->angles.x = 0.0f; + pev->angles.z = 0.0f; + pev->avelocity.x = 0.0f; + pev->avelocity.z = 0.0f; } else { @@ -772,8 +779,8 @@ void CGib::BounceGibTouch( CBaseEntity *pOther ) } if ( g_Language != LANGUAGE_GERMAN && m_cBloodDecals > 0 && m_bloodColor != DONT_BLEED ) { - vecSpot = pev->origin + Vector( 0, 0, 8 );//move up a bit, and trace down. - UTIL_TraceLine( vecSpot, vecSpot + Vector( 0, 0, -24 ), ignore_monsters, ENT( pev ), &tr ); + vecSpot = pev->origin + Vector( 0.0f, 0.0f, 8.0f );//move up a bit, and trace down. + UTIL_TraceLine( vecSpot, vecSpot + Vector( 0.0f, 0.0f, -24.0f ), ignore_monsters, ENT( pev ), &tr ); UTIL_BloodDecalTrace( &tr, m_bloodColor ); @@ -785,7 +792,7 @@ void CGib::BounceGibTouch( CBaseEntity *pOther ) float volume; float zvel = fabs( pev->velocity.z ); - volume = 0.8 * Q_min( 1.0, ( (float)zvel ) / 450.0 ); + volume = 0.8f * Q_min( 1.0f, zvel / 450.0f ); CBreakable::MaterialSoundRandom( edict(), (Materials)m_material, volume ); } @@ -800,8 +807,8 @@ void CGib::StickyGibTouch( CBaseEntity *pOther ) Vector vecSpot; TraceResult tr; - pev->nextthink = gpGlobals->time + 100; SetThink( &CBaseEntity::SUB_Remove ); + pev->nextthink = gpGlobals->time + 100.0f; if( !FClassnameIs( pOther->pev, "worldspawn" ) ) { @@ -809,11 +816,11 @@ void CGib::StickyGibTouch( CBaseEntity *pOther ) return; } - UTIL_TraceLine( pev->origin, pev->origin + pev->velocity * 32, ignore_monsters, ENT( pev ), &tr ); + UTIL_TraceLine( pev->origin, pev->origin + pev->velocity * 32.0f, ignore_monsters, ENT( pev ), &tr ); UTIL_BloodDecalTrace( &tr, m_bloodColor ); - pev->velocity = tr.vecPlaneNormal * -1; + pev->velocity = tr.vecPlaneNormal * -1.0f; pev->angles = UTIL_VecToAngles( pev->velocity ); pev->velocity = g_vecZero; pev->avelocity = g_vecZero; @@ -826,7 +833,7 @@ void CGib::StickyGibTouch( CBaseEntity *pOther ) void CGib::Spawn( const char *szGibModel ) { pev->movetype = MOVETYPE_BOUNCE; - pev->friction = 0.55; // deading the bounce a bit + pev->friction = 0.55f; // deading the bounce a bit // sometimes an entity inherits the edict from a former piece of glass, // and will spawn using the same render FX or rendermode! bad! @@ -839,8 +846,7 @@ void CGib::Spawn( const char *szGibModel ) SET_MODEL( ENT( pev ), szGibModel ); UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) ); - pev->nextthink = gpGlobals->time + 4; - + pev->nextthink = gpGlobals->time + 4.0f; m_lifeTime = cvar_gibtime.value; SetThink( &CGib::WaitTillLand ); @@ -1002,7 +1008,7 @@ int CBaseMonster::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, f } else { - m_vecEnemyLKP = pev->origin + ( g_vecAttackDir * 64 ); + m_vecEnemyLKP = pev->origin + ( g_vecAttackDir * 64.0f ); } MakeIdealYaw( m_vecEnemyLKP ); @@ -1010,12 +1016,12 @@ int CBaseMonster::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, f // add pain to the conditions // !!!HACKHACK - fudged for now. Do we want to have a virtual function to determine what is light and // heavy damage per monster class? - if( flDamage > 0 ) + if( flDamage > 0.0f ) { SetConditions( bits_COND_LIGHT_DAMAGE ); } - if( flDamage >= 20 ) + if( flDamage >= 20.0f ) { SetConditions( bits_COND_HEAVY_DAMAGE ); } @@ -1040,7 +1046,7 @@ int CBaseMonster::DeadTakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacke CBaseEntity *pInflictor = CBaseEntity::Instance( pevInflictor ); if( pInflictor ) { - vecDir = ( pInflictor->Center() - Vector ( 0, 0, 10 ) - Center() ).Normalize(); + vecDir = ( pInflictor->Center() - Vector ( 0.0f, 0.0f, 10.0f ) - Center() ).Normalize(); vecDir = g_vecAttackDir = vecDir.Normalize(); } } @@ -1048,8 +1054,8 @@ int CBaseMonster::DeadTakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacke #if 0// turn this back on when the bounding box issues are resolved. pev->flags &= ~FL_ONGROUND; - pev->origin.z += 1; - + pev->origin.z += 1.0f; + // let the damage scoot the corpse around a bit. if( !FNullEnt( pevInflictor ) && ( pevAttacker->solid != SOLID_TRIGGER ) ) { @@ -1066,7 +1072,7 @@ int CBaseMonster::DeadTakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacke return 0; } // Accumulate corpse gibbing damage, so you can gib with multiple hits - pev->health -= flDamage * 0.1; + pev->health -= flDamage * 0.1f; } return 1; @@ -1074,11 +1080,11 @@ int CBaseMonster::DeadTakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacke float CBaseMonster::DamageForce( float damage ) { - float force = damage * ( ( 32 * 32 * 72.0 ) / ( pev->size.x * pev->size.y * pev->size.z ) ) * 5; + float force = damage * ( ( 32.0f * 32.0f * 72.0f ) / ( pev->size.x * pev->size.y * pev->size.z ) ) * 5.0f; - if( force > 1000.0 ) + if( force > 1000.0f ) { - force = 1000.0; + force = 1000.0f; } return force; @@ -1098,11 +1104,11 @@ void RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacke if( flRadius ) falloff = flDamage / flRadius; else - falloff = 1.0; + falloff = 1.0f; int bInWater = ( UTIL_PointContents( vecSrc ) == CONTENTS_WATER ); - vecSrc.z += 1;// in case grenade is lying on the ground + vecSrc.z += 1.0f;// in case grenade is lying on the ground if( !pevAttacker ) pevAttacker = pevInflictor; @@ -1129,27 +1135,27 @@ void RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacke UTIL_TraceLine( vecSrc, vecSpot, dont_ignore_monsters, ENT( pevInflictor ), &tr ); - if( tr.flFraction == 1.0 || tr.pHit == pEntity->edict() ) + if( tr.flFraction == 1.0f || tr.pHit == pEntity->edict() ) { // the explosion can 'see' this entity, so hurt them! if( tr.fStartSolid ) { // if we're stuck inside them, fixup the position and distance tr.vecEndPos = vecSrc; - tr.flFraction = 0.0; + tr.flFraction = 0.0f; } // decrease damage for an ent that's farther from the bomb. flAdjustedDamage = ( vecSrc - tr.vecEndPos ).Length() * falloff; flAdjustedDamage = flDamage - flAdjustedDamage; - if( flAdjustedDamage < 0 ) + if( flAdjustedDamage < 0.0f ) { - flAdjustedDamage = 0; + flAdjustedDamage = 0.0f; } // ALERT( at_console, "hit %s\n", STRING( pEntity->pev->classname ) ); - if( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0f ) { ClearMultiDamage(); pEntity->TraceAttack( pevInflictor, flAdjustedDamage, ( tr.vecEndPos - vecSrc ).Normalize(), &tr, bitsDamageType ); @@ -1166,12 +1172,12 @@ void RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacke void CBaseMonster::RadiusDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ) { - ::RadiusDamage( pev->origin, pevInflictor, pevAttacker, flDamage, flDamage * 2.5, iClassIgnore, bitsDamageType ); + ::RadiusDamage( pev->origin, pevInflictor, pevAttacker, flDamage, flDamage * 2.5f, iClassIgnore, bitsDamageType ); } void CBaseMonster::RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ) { - ::RadiusDamage( vecSrc, pevInflictor, pevAttacker, flDamage, flDamage * 2.5, iClassIgnore, bitsDamageType ); + ::RadiusDamage( vecSrc, pevInflictor, pevAttacker, flDamage, flDamage * 2.5f, iClassIgnore, bitsDamageType ); } //========================================================= @@ -1192,7 +1198,7 @@ CBaseEntity* CBaseMonster::CheckTraceHullAttack( float flDist, int iDamage, int UTIL_MakeAimVectors( pev->angles ); Vector vecStart = pev->origin; - vecStart.z += pev->size.z * 0.5; + vecStart.z += pev->size.z * 0.5f; Vector vecEnd = vecStart + ( gpGlobals->v_forward * flDist ); UTIL_TraceHull( vecStart, vecEnd, dont_ignore_monsters, head_hull, ENT( pev ), &tr ); @@ -1294,7 +1300,7 @@ BOOL CBaseEntity::FVisible( CBaseEntity *pEntity ) UTIL_TraceLine( vecLookerOrigin, vecTargetOrigin, ignore_monsters, ignore_glass, ENT( pev )/*pentIgnore*/, &tr ); - if( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0f ) { return FALSE;// Line of sight is not established } @@ -1317,7 +1323,7 @@ BOOL CBaseEntity::FVisible( const Vector &vecOrigin ) UTIL_TraceLine( vecLookerOrigin, vecOrigin, ignore_monsters, ignore_glass, ENT( pev )/*pentIgnore*/, &tr ); - if( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0f ) { return FALSE;// Line of sight is not established } @@ -1334,7 +1340,7 @@ TraceAttack */ void CBaseEntity::TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) { - Vector vecOrigin = ptr->vecEndPos - vecDir * 4; + Vector vecOrigin = ptr->vecEndPos - vecDir * 4.0f; if( pev->takedamage ) { @@ -1356,7 +1362,7 @@ void CBaseEntity::TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vec //========================================================= void CBaseMonster::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ) { - Vector vecOrigin = ptr->vecEndPos - vecDir * 4; + Vector vecOrigin = ptr->vecEndPos - vecDir * 4.0f; ALERT( at_console, "%d\n", ptr->iHitgroup ); @@ -1442,8 +1448,8 @@ void CBaseEntity::FireBullets( ULONG cShots, Vector vecSrc, Vector vecDirShootin // get circular gaussian spread float x, y, z; do { - x = RANDOM_FLOAT( -0.5, 0.5 ) + RANDOM_FLOAT( -0.5, 0.5 ); - y = RANDOM_FLOAT( -0.5, 0.5 ) + RANDOM_FLOAT( -0.5, 0.5 ); + x = RANDOM_FLOAT( -0.5f, 0.5f ) + RANDOM_FLOAT( -0.5f, 0.5f ); + y = RANDOM_FLOAT( -0.5f, 0.5f ) + RANDOM_FLOAT( -0.5f, 0.5f ); z = x * x + y * y; } while (z > 1); @@ -1463,7 +1469,7 @@ void CBaseEntity::FireBullets( ULONG cShots, Vector vecSrc, Vector vecDirShootin if( IsPlayer() ) { // adjust tracer position for player - vecTracerSrc = vecSrc + Vector( 0, 0, -4 ) + gpGlobals->v_right * 2 + gpGlobals->v_forward * 16; + vecTracerSrc = vecSrc + Vector( 0.0f, 0.0f, -4.0f ) + gpGlobals->v_right * 2.0f + gpGlobals->v_forward * 16.0f; } else { @@ -1491,7 +1497,7 @@ void CBaseEntity::FireBullets( ULONG cShots, Vector vecSrc, Vector vecDirShootin } } // do damage, paint decals - if( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0f ) { CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit ); @@ -1538,7 +1544,7 @@ void CBaseEntity::FireBullets( ULONG cShots, Vector vecSrc, Vector vecDirShootin } } // make bullet trails - UTIL_BubbleTrail( vecSrc, tr.vecEndPos, (int)( ( flDistance * tr.flFraction ) / 64.0 ) ); + UTIL_BubbleTrail( vecSrc, tr.vecEndPos, (int)( ( flDistance * tr.flFraction ) / 64.0f ) ); } ApplyMultiDamage( pev, pevAttacker ); } @@ -1559,7 +1565,7 @@ Vector CBaseEntity::FireBulletsPlayer( ULONG cShots, Vector vecSrc, Vector vecDi Vector vecRight = gpGlobals->v_right; Vector vecUp = gpGlobals->v_up; float x = 0.0f, y = 0.0f; - float z; + //float z; if( pevAttacker == NULL ) pevAttacker = pev; // the default attacker is ourselves @@ -1571,8 +1577,8 @@ Vector CBaseEntity::FireBulletsPlayer( ULONG cShots, Vector vecSrc, Vector vecDi { //Use player's random seed. // get circular gaussian spread - x = UTIL_SharedRandomFloat( shared_rand + iShot, -0.5, 0.5 ) + UTIL_SharedRandomFloat( shared_rand + ( 1 + iShot ) , -0.5, 0.5 ); - y = UTIL_SharedRandomFloat( shared_rand + ( 2 + iShot ), -0.5, 0.5 ) + UTIL_SharedRandomFloat( shared_rand + ( 3 + iShot ), -0.5, 0.5 ); + x = UTIL_SharedRandomFloat( shared_rand + iShot, -0.5f, 0.5f ) + UTIL_SharedRandomFloat( shared_rand + ( 1 + iShot ) , -0.5f, 0.5f ); + y = UTIL_SharedRandomFloat( shared_rand + ( 2 + iShot ), -0.5f, 0.5f ) + UTIL_SharedRandomFloat( shared_rand + ( 3 + iShot ), -0.5f, 0.5f ); //z = x * x + y * y; Vector vecDir = vecDirShooting + @@ -1584,7 +1590,7 @@ Vector CBaseEntity::FireBulletsPlayer( ULONG cShots, Vector vecSrc, Vector vecDi UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, ENT( pev )/*pentIgnore*/, &tr ); // do damage, paint decals - if( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0f ) { CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit ); @@ -1624,7 +1630,7 @@ Vector CBaseEntity::FireBulletsPlayer( ULONG cShots, Vector vecSrc, Vector vecDi } } // make bullet trails - UTIL_BubbleTrail( vecSrc, tr.vecEndPos, (int)( ( flDistance * tr.flFraction ) / 64.0 ) ); + UTIL_BubbleTrail( vecSrc, tr.vecEndPos, (int)( ( flDistance * tr.flFraction ) / 64.0f ) ); } ApplyMultiDamage( pev, pevAttacker ); @@ -1664,33 +1670,33 @@ void CBaseEntity::TraceBleed( float flDamage, Vector vecDir, TraceResult *ptr, i } } */ - if( flDamage < 10 ) + if( flDamage < 10.0f ) { - flNoise = 0.1; + flNoise = 0.1f; cCount = 1; } - else if( flDamage < 25 ) + else if( flDamage < 25.0f ) { - flNoise = 0.2; + flNoise = 0.2f; cCount = 2; } else { - flNoise = 0.3; + flNoise = 0.3f; cCount = 4; } for( i = 0; i < cCount; i++ ) { - vecTraceDir = vecDir * -1;// trace in the opposite direction the shot came from (the direction the shot is going) + vecTraceDir = vecDir * -1.0f;// trace in the opposite direction the shot came from (the direction the shot is going) vecTraceDir.x += RANDOM_FLOAT( -flNoise, flNoise ); vecTraceDir.y += RANDOM_FLOAT( -flNoise, flNoise ); vecTraceDir.z += RANDOM_FLOAT( -flNoise, flNoise ); - UTIL_TraceLine( ptr->vecEndPos, ptr->vecEndPos + vecTraceDir * -172, ignore_monsters, ENT( pev ), &Bloodtr ); + UTIL_TraceLine( ptr->vecEndPos, ptr->vecEndPos + vecTraceDir * -172.0f, ignore_monsters, ENT( pev ), &Bloodtr ); - if( Bloodtr.flFraction != 1.0 ) + if( Bloodtr.flFraction != 1.0f ) { UTIL_BloodDecalTrace( &Bloodtr, BloodColor() ); } @@ -1728,7 +1734,7 @@ void CBaseMonster::MakeDamageBloodDecal( int cCount, float flNoise, TraceResult vecTraceDir.y += RANDOM_FLOAT( -flNoise, flNoise ); vecTraceDir.z += RANDOM_FLOAT( -flNoise, flNoise ); - UTIL_TraceLine( ptr->vecEndPos, ptr->vecEndPos + vecTraceDir * 172, ignore_monsters, ENT( pev ), &Bloodtr ); + UTIL_TraceLine( ptr->vecEndPos, ptr->vecEndPos + vecTraceDir * 172.0f, ignore_monsters, ENT( pev ), &Bloodtr ); /* MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); @@ -1743,7 +1749,7 @@ void CBaseMonster::MakeDamageBloodDecal( int cCount, float flNoise, TraceResult MESSAGE_END(); */ - if( Bloodtr.flFraction != 1.0 ) + if( Bloodtr.flFraction != 1.0f ) { UTIL_BloodDecalTrace( &Bloodtr, BloodColor() ); } diff --git a/dlls/compile.bat b/dlls/compile.bat index f97806a5..4eba92c7 100644 --- a/dlls/compile.bat +++ b/dlls/compile.bat @@ -108,12 +108,11 @@ set SOURCES=agrunt.cpp ^ xen.cpp ^ zombie.cpp ^ ../pm_shared/pm_debug.c ../pm_shared/pm_math.c ../pm_shared/pm_shared.c -set DEFINES=/DCLIENT_WEAPONS /Dsnprintf=_snprintf /DNO_VOICEGAMEMGR +set DEFINES=/DCLIENT_WEAPONS /Dsnprintf=_snprintf /DNO_VOICEGAMEMGR /DNDEBUG set LIBS=user32.lib set OUTNAME=hl.dll -set DEBUG=/debug -cl %DEFINES% %LIBS% %SOURCES% %INCLUDES% -o %OUTNAME% /link /dll /out:%OUTNAME% %DEBUG% /def:".\hl.def" +cl %DEFINES% %LIBS% %SOURCES% %INCLUDES% -o %OUTNAME% /link /dll /out:%OUTNAME% /release /def:".\hl.def" echo -- Compile done. Cleaning... diff --git a/dlls/controller.cpp b/dlls/controller.cpp index e1d57517..bfe3032e 100644 --- a/dlls/controller.cpp +++ b/dlls/controller.cpp @@ -12,7 +12,7 @@ * use or distribution of this code by or to any unlicensed person is illegal. * ****/ -#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD ) +#if !OEM_BUILD && !HLDEMO_BUILD //========================================================= // CONTROLLER @@ -190,9 +190,9 @@ void CController::Killed( entvars_t *pevAttacker, int iGib ) // shut off balls /* m_iBall[0] = 0; - m_iBallTime[0] = gpGlobals->time + 4.0; + m_iBallTime[0] = gpGlobals->time + 4.0f; m_iBall[1] = 0; - m_iBallTime[1] = gpGlobals->time + 4.0; + m_iBallTime[1] = gpGlobals->time + 4.0f; */ // fade balls @@ -281,9 +281,9 @@ void CController::HandleAnimEvent( MonsterEvent_t *pEvent ) MESSAGE_END(); m_iBall[0] = 192; - m_iBallTime[0] = gpGlobals->time + atoi( pEvent->options ) / 15.0; + m_iBallTime[0] = gpGlobals->time + atoi( pEvent->options ) / 15.0f; m_iBall[1] = 255; - m_iBallTime[1] = gpGlobals->time + atoi( pEvent->options ) / 15.0; + m_iBallTime[1] = gpGlobals->time + atoi( pEvent->options ) / 15.0f; } break; case CONTROLLER_AE_BALL_SHOOT: @@ -308,7 +308,7 @@ void CController::HandleAnimEvent( MonsterEvent_t *pEvent ) CBaseMonster *pBall = (CBaseMonster*)Create( "controller_head_ball", vecStart, pev->angles, edict() ); - pBall->pev->velocity = Vector( 0, 0, 32 ); + pBall->pev->velocity = Vector( 0.0f, 0.0f, 32.0f ); pBall->m_hEnemy = m_hEnemy; m_iBall[0] = 0; @@ -319,23 +319,23 @@ void CController::HandleAnimEvent( MonsterEvent_t *pEvent ) { AttackSound(); m_flShootTime = gpGlobals->time; - m_flShootEnd = m_flShootTime + atoi( pEvent->options ) / 15.0; + m_flShootEnd = m_flShootTime + atoi( pEvent->options ) / 15.0f; } break; case CONTROLLER_AE_POWERUP_FULL: { m_iBall[0] = 255; - m_iBallTime[0] = gpGlobals->time + atoi( pEvent->options ) / 15.0; + m_iBallTime[0] = gpGlobals->time + atoi( pEvent->options ) / 15.0f; m_iBall[1] = 255; - m_iBallTime[1] = gpGlobals->time + atoi( pEvent->options ) / 15.0; + m_iBallTime[1] = gpGlobals->time + atoi( pEvent->options ) / 15.0f; } break; case CONTROLLER_AE_POWERUP_HALF: { m_iBall[0] = 192; - m_iBallTime[0] = gpGlobals->time + atoi( pEvent->options ) / 15.0; + m_iBallTime[0] = gpGlobals->time + atoi( pEvent->options ) / 15.0f; m_iBall[1] = 192; - m_iBallTime[1] = gpGlobals->time + atoi( pEvent->options ) / 15.0; + m_iBallTime[1] = gpGlobals->time + atoi( pEvent->options ) / 15.0f; } break; default: @@ -352,14 +352,14 @@ void CController::Spawn() Precache(); SET_MODEL( ENT( pev ), "models/controller.mdl" ); - UTIL_SetSize( pev, Vector( -32, -32, 0 ), Vector( 32, 32, 64 ) ); + UTIL_SetSize( pev, Vector( -32.0f, -32.0f, 0.0f ), Vector( 32.0f, 32.0f, 64.0f ) ); pev->solid = SOLID_SLIDEBOX; pev->movetype = MOVETYPE_FLY; pev->flags |= FL_FLY; m_bloodColor = BLOOD_COLOR_GREEN; pev->health = gSkillData.controllerHealth; - pev->view_ofs = Vector( 0, 0, -2 );// position of the eyes relative to monster's origin. + pev->view_ofs = Vector( 0.0f, 0.0f, -2.0f );// position of the eyes relative to monster's origin. m_flFieldOfView = VIEW_FIELD_FULL;// indicates the width of this monster's forward view cone ( as a dotproduct result ) m_MonsterState = MONSTERSTATE_NONE; @@ -409,8 +409,8 @@ void CController::UpdateOnRemove() // Chase enemy schedule Task_t tlControllerChaseEnemy[] = { - { TASK_GET_PATH_TO_ENEMY, (float)128 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, + { TASK_GET_PATH_TO_ENEMY, 128.0f }, + { TASK_WAIT_FOR_MOVEMENT, 0.0f }, }; Schedule_t slControllerChaseEnemy[] = @@ -427,10 +427,10 @@ Schedule_t slControllerChaseEnemy[] = Task_t tlControllerStrafe[] = { - { TASK_WAIT, (float)0.2 }, - { TASK_GET_PATH_TO_ENEMY, (float)128 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_WAIT, (float)1 }, + { TASK_WAIT, 0.2f }, + { TASK_GET_PATH_TO_ENEMY, 128.0f }, + { TASK_WAIT_FOR_MOVEMENT, 0.0f }, + { TASK_WAIT, 1.0f }, }; Schedule_t slControllerStrafe[] = @@ -446,10 +446,10 @@ Schedule_t slControllerStrafe[] = Task_t tlControllerTakeCover[] = { - { TASK_WAIT, (float)0.2 }, - { TASK_FIND_COVER_FROM_ENEMY, (float)0 }, - { TASK_WAIT_FOR_MOVEMENT, (float)0 }, - { TASK_WAIT, (float)1 }, + { TASK_WAIT, 0.2f }, + { TASK_FIND_COVER_FROM_ENEMY, 0.0f }, + { TASK_WAIT_FOR_MOVEMENT, 0.0f }, + { TASK_WAIT, 1.0f }, }; Schedule_t slControllerTakeCover[] = @@ -504,7 +504,7 @@ void CController::StartTask( Task_t *pTask ) break; case TASK_GET_PATH_TO_ENEMY_LKP: { - if( BuildNearestRoute( m_vecEnemyLKP, pev->view_ofs, pTask->flData, (m_vecEnemyLKP - pev->origin).Length() + 1024 ) ) + if( BuildNearestRoute( m_vecEnemyLKP, pev->view_ofs, pTask->flData, (m_vecEnemyLKP - pev->origin).Length() + 1024.0f ) ) { TaskComplete(); } @@ -526,7 +526,7 @@ void CController::StartTask( Task_t *pTask ) return; } - if( BuildNearestRoute( pEnemy->pev->origin, pEnemy->pev->view_ofs, pTask->flData, ( pEnemy->pev->origin - pev->origin).Length() + 1024 ) ) + if( BuildNearestRoute( pEnemy->pev->origin, pEnemy->pev->view_ofs, pTask->flData, ( pEnemy->pev->origin - pev->origin).Length() + 1024.0f ) ) { TaskComplete(); } @@ -559,8 +559,8 @@ Vector Intersect( Vector vecSrc, Vector vecDst, Vector vecMove, float flSpeed ) } else { - t = b * b - 4 * a * c; - t = sqrt( t ) / ( 2.0 * a ); + t = b * b - 4.0f * a * c; + t = sqrt( t ) / ( 2.0f * a ); float t1 = -b +t; float t2 = -b -t; @@ -572,10 +572,10 @@ Vector Intersect( Vector vecSrc, Vector vecDst, Vector vecMove, float flSpeed ) // ALERT( at_console, "Intersect %f\n", t ); - if( t < 0.1 ) - t = 0.1; - if( t > 10.0 ) - t = 10.0; + if( t < 0.1f ) + t = 0.1f; + if( t > 10.0f ) + t = 10.0f; Vector vecHit = vecTo + vecMove * t; return vecHit.Normalize() * flSpeed; @@ -583,7 +583,7 @@ Vector Intersect( Vector vecSrc, Vector vecDst, Vector vecMove, float flSpeed ) int CController::LookupFloat() { - if( m_velocity.Length() < 32.0 ) + if( m_velocity.Length() < 32.0f ) { return LookupSequence( "up" ); } @@ -636,21 +636,21 @@ void CController::RunTask( Task_t *pTask ) { if( HasConditions( bits_COND_SEE_ENEMY ) ) { - m_vecEstVelocity = m_vecEstVelocity * 0.5 + m_hEnemy->pev->velocity * 0.5; + m_vecEstVelocity = m_vecEstVelocity * 0.5f + m_hEnemy->pev->velocity * 0.5f; } else { - m_vecEstVelocity = m_vecEstVelocity * 0.8; + m_vecEstVelocity = m_vecEstVelocity * 0.8f; } vecDir = Intersect( vecSrc, m_hEnemy->BodyTarget( pev->origin ), m_vecEstVelocity, gSkillData.controllerSpeedBall ); - float delta = 0.03490; // +-2 degree + float delta = 0.03490f; // +-2 degree vecDir = vecDir + Vector( RANDOM_FLOAT( -delta, delta ), RANDOM_FLOAT( -delta, delta ), RANDOM_FLOAT( -delta, delta ) ) * gSkillData.controllerSpeedBall; vecSrc = vecSrc + vecDir * ( gpGlobals->time - m_flShootTime ); CBaseMonster *pBall = (CBaseMonster*)Create( "controller_energy_ball", vecSrc, pev->angles, edict() ); pBall->pev->velocity = vecDir; } - m_flShootTime += 0.2; + m_flShootTime += 0.2f; } if( m_flShootTime > m_flShootEnd ) @@ -669,8 +669,11 @@ void CController::RunTask( Task_t *pTask ) case TASK_WAIT: case TASK_WAIT_FACE_ENEMY: case TASK_WAIT_PVS: - MakeIdealYaw( m_vecEnemyLKP ); - ChangeYaw( pev->yaw_speed ); + if (m_hEnemy != 0) + { + MakeIdealYaw( m_vecEnemyLKP ); + ChangeYaw( pev->yaw_speed ); + } if( m_fSequenceFinished ) { @@ -725,7 +728,7 @@ Schedule_t *CController::GetSchedule( void ) { case MONSTERSTATE_COMBAT: { - // Vector vecTmp = Intersect( Vector( 0, 0, 0 ), Vector( 100, 4, 7 ), Vector( 2, 10, -3 ), 20.0 ); + // Vector vecTmp = Intersect( Vector( 0, 0, 0 ), Vector( 100, 4, 7 ), Vector( 2, 10, -3 ), 20.0f ); // dead enemy if( HasConditions( bits_COND_LIGHT_DAMAGE ) ) @@ -777,7 +780,7 @@ Schedule_t *CController::GetScheduleOfType( int Type ) //========================================================= BOOL CController::CheckRangeAttack1( float flDot, float flDist ) { - if( flDot > 0.5 && flDist > 256 && flDist <= 2048 ) + if( flDot > 0.5f && flDist > 256.0f && flDist <= 2048.0f ) { return TRUE; } @@ -786,7 +789,7 @@ BOOL CController::CheckRangeAttack1( float flDot, float flDist ) BOOL CController::CheckRangeAttack2( float flDot, float flDist ) { - if( flDot > 0.5 && flDist > 64 && flDist <= 2048 ) + if( flDot > 0.5f && flDist > 64.0f && flDist <= 2048.0f ) { return TRUE; } @@ -805,10 +808,10 @@ void CController::SetActivity( Activity NewActivity ) switch( m_Activity ) { case ACT_WALK: - m_flGroundSpeed = 100; + m_flGroundSpeed = 100.0f; break; default: - m_flGroundSpeed = 100; + m_flGroundSpeed = 100.0f; break; } } @@ -831,14 +834,14 @@ void CController::RunAI( void ) m_pBall[i] = CSprite::SpriteCreate( "sprites/xspark4.spr", pev->origin, TRUE ); m_pBall[i]->SetTransparency( kRenderGlow, 255, 255, 255, 255, kRenderFxNoDissipation ); m_pBall[i]->SetAttachment( edict(), ( i + 3 ) ); - m_pBall[i]->SetScale( 1.0 ); + m_pBall[i]->SetScale( 1.0f ); } float t = m_iBallTime[i] - gpGlobals->time; - if( t > 0.1 ) - t = 0.1 / t; + if( t > 0.1f ) + t = 0.1f / t; else - t = 1.0; + t = 1.0f; m_iBallCurrent[i] += ( m_iBall[i] - m_iBallCurrent[i] ) * t; @@ -912,9 +915,9 @@ void CController::Move( float flInterval ) // to that entity for the CheckLocalMove and Triangulate functions. pTargetEnt = NULL; - if( m_flGroundSpeed == 0 ) + if( m_flGroundSpeed == 0.0f ) { - m_flGroundSpeed = 100; + m_flGroundSpeed = 100.0f; // TaskFail(); // return; } @@ -966,7 +969,8 @@ void CController::Move( float flInterval ) { DispatchBlocked( edict(), pBlocker->edict() ); } - if( pBlocker && m_moveWaitTime > 0 && pBlocker->IsMoving() && !pBlocker->IsPlayer() && (gpGlobals->time-m_flMoveWaitFinished) > 3.0 ) + + if( pBlocker && m_moveWaitTime > 0 && pBlocker->IsMoving() && !pBlocker->IsPlayer() && (gpGlobals->time-m_flMoveWaitFinished) > 3.0f ) { // Can we still move toward our target? if( flDist < m_flGroundSpeed ) @@ -992,7 +996,7 @@ void CController::Move( float flInterval ) if( m_moveWaitTime > 0 ) { FRefreshRoute(); - m_flMoveWaitFinished = gpGlobals->time + m_moveWaitTime * 0.5; + m_flMoveWaitFinished = gpGlobals->time + m_moveWaitTime * 0.5f; } else { @@ -1030,10 +1034,10 @@ void CController::Move( float flInterval ) Stop(); RouteClear(); } - } while( flMoveDist > 0 && flCheckDist > 0 ); + } while( flMoveDist > 0.0f && flCheckDist > 0.0f ); // cut corner? - if( flWaypointDist < 128 ) + if( flWaypointDist < 128.0f ) { if( m_movementGoal == MOVEGOAL_ENEMY ) RouteSimplify( m_hEnemy ); @@ -1041,19 +1045,19 @@ void CController::Move( float flInterval ) RouteSimplify( m_hTargetEnt ); FRefreshRoute(); - if( m_flGroundSpeed > 100 ) - m_flGroundSpeed -= 40; + if( m_flGroundSpeed > 100.0f ) + m_flGroundSpeed -= 40.0f; } else { - if( m_flGroundSpeed < 400 ) - m_flGroundSpeed += 10; + if( m_flGroundSpeed < 400.0f ) + m_flGroundSpeed += 10.0f; } } BOOL CController::ShouldAdvanceRoute( float flWaypointDist ) { - if( flWaypointDist <= 32 ) + if( flWaypointDist <= 32.0f ) { return TRUE; } @@ -1076,7 +1080,7 @@ int CController::CheckLocalMove( const Vector &vecStart, const Vector &vecEnd, C } // ALERT( at_console, "check %d %d %f\n", tr.fStartSolid, tr.fAllSolid, tr.flFraction ); - if( tr.fStartSolid || tr.flFraction < 1.0 ) + if( tr.fStartSolid || tr.flFraction < 1.0f ) { if( pTarget && pTarget->edict() == gpGlobals->trace_ent ) return LOCALMOVE_VALID; @@ -1096,7 +1100,7 @@ void CController::MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, fl // float flTotal = m_flGroundSpeed * pev->framerate * flInterval; // UTIL_MoveToOrigin ( ENT( pev ), m_Route[m_iRouteIndex].vecLocation, flTotal, MOVE_STRAFE ); - m_velocity = m_velocity * 0.8 + m_flGroundSpeed * vecDir * 0.2; + m_velocity = m_velocity * 0.8f + m_flGroundSpeed * vecDir * 0.2f; UTIL_MoveToOrigin( ENT( pev ), pev->origin + m_velocity, m_velocity.Length() * flInterval, MOVE_STRAFE ); } @@ -1133,7 +1137,7 @@ void CControllerHeadBall::Spawn( void ) pev->rendercolor.y = 255; pev->rendercolor.z = 255; pev->renderamt = 255; - pev->scale = 2.0; + pev->scale = 2.0f; UTIL_SetSize(pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) ); UTIL_SetOrigin( pev, pev->origin ); @@ -1143,7 +1147,7 @@ void CControllerHeadBall::Spawn( void ) m_vecIdeal = Vector( 0, 0, 0 ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; m_hOwner = Instance( pev->owner ); pev->dmgtime = gpGlobals->time; @@ -1158,7 +1162,7 @@ void CControllerHeadBall::Precache( void ) void CControllerHeadBall::HuntThink( void ) { - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; pev->renderamt -= 5; @@ -1219,12 +1223,12 @@ void CControllerHeadBall::HuntThink( void ) WRITE_BYTE( 10 ); // speed MESSAGE_END(); - UTIL_EmitAmbientSound( ENT( pev ), tr.vecEndPos, "weapons/electro4.wav", 0.5, ATTN_NORM, 0, RANDOM_LONG( 140, 160 ) ); + UTIL_EmitAmbientSound( ENT( pev ), tr.vecEndPos, "weapons/electro4.wav", 0.5f, ATTN_NORM, 0, RANDOM_LONG( 140, 160 ) ); - m_flNextAttack = gpGlobals->time + 3.0; + m_flNextAttack = gpGlobals->time + 3.0f; SetThink( &CControllerHeadBall::DieThink ); - pev->nextthink = gpGlobals->time + 0.3; + pev->nextthink = gpGlobals->time + 0.3f; } //Crawl(); @@ -1239,31 +1243,31 @@ void CControllerHeadBall::MovetoTarget( Vector vecTarget ) { // accelerate float flSpeed = m_vecIdeal.Length(); - if( flSpeed == 0 ) + if( flSpeed == 0.0f ) { m_vecIdeal = pev->velocity; flSpeed = m_vecIdeal.Length(); } - if( flSpeed > 400 ) + if( flSpeed > 400.0f ) { - m_vecIdeal = m_vecIdeal.Normalize() * 400; + m_vecIdeal = m_vecIdeal.Normalize() * 400.0f; } - m_vecIdeal = m_vecIdeal + ( vecTarget - pev->origin ).Normalize() * 100; + m_vecIdeal = m_vecIdeal + ( vecTarget - pev->origin ).Normalize() * 100.0f; pev->velocity = m_vecIdeal; } void CControllerHeadBall::Crawl( void ) { - Vector vecAim = Vector( RANDOM_FLOAT( -1, 1 ), RANDOM_FLOAT( -1, 1 ), RANDOM_FLOAT( -1, 1 ) ).Normalize(); - Vector vecPnt = pev->origin + pev->velocity * 0.3 + vecAim * 64; + Vector vecAim = Vector( RANDOM_FLOAT( -1.0f, 1.0f ), RANDOM_FLOAT( -1.0f, 1.0f ), RANDOM_FLOAT( -1.0f, 1.0f ) ).Normalize(); + Vector vecPnt = pev->origin + pev->velocity * 0.3f + vecAim * 64.0f; MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_BEAMENTPOINT ); WRITE_SHORT( entindex() ); - WRITE_COORD( vecPnt.x); - WRITE_COORD( vecPnt.y); - WRITE_COORD( vecPnt.z); + WRITE_COORD( vecPnt.x ); + WRITE_COORD( vecPnt.y ); + WRITE_COORD( vecPnt.z ); WRITE_SHORT( g_sModelIndexLaser ); WRITE_BYTE( 0 ); // frame start WRITE_BYTE( 10 ); // framerate @@ -1286,7 +1290,7 @@ void CControllerHeadBall::BounceTouch( CBaseEntity *pOther ) float n = -DotProduct( tr.vecPlaneNormal, vecDir ); - vecDir = 2.0 * tr.vecPlaneNormal * n + vecDir; + vecDir = 2.0f * tr.vecPlaneNormal * n + vecDir; m_vecIdeal = vecDir * m_vecIdeal.Length(); } @@ -1316,7 +1320,7 @@ void CControllerZapBall::Spawn( void ) pev->rendercolor.y = 255; pev->rendercolor.z = 255; pev->renderamt = 255; - pev->scale = 0.5; + pev->scale = 0.5f; UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) ); UTIL_SetOrigin( pev, pev->origin ); @@ -1326,7 +1330,7 @@ void CControllerZapBall::Spawn( void ) m_hOwner = Instance( pev->owner ); pev->dmgtime = gpGlobals->time; // keep track of when ball spawned - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } void CControllerZapBall::Precache( void ) @@ -1338,11 +1342,11 @@ void CControllerZapBall::Precache( void ) void CControllerZapBall::AnimateThink( void ) { - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; pev->frame = ( (int)pev->frame + 1 ) % 11; - if( gpGlobals->time - pev->dmgtime > 5 || pev->velocity.Length() < 10 ) + if( gpGlobals->time - pev->dmgtime > 5 || pev->velocity.Length() < 10.0f ) { SetTouch( NULL ); UTIL_Remove( this ); @@ -1367,10 +1371,10 @@ void CControllerZapBall::ExplodeTouch( CBaseEntity *pOther ) } ClearMultiDamage(); - pOther->TraceAttack(pevOwner, gSkillData.controllerDmgBall, pev->velocity.Normalize(), &tr, DMG_ENERGYBEAM ); + pOther->TraceAttack( pevOwner, gSkillData.controllerDmgBall, pev->velocity.Normalize(), &tr, DMG_ENERGYBEAM ); ApplyMultiDamage( pevOwner, pevOwner ); - UTIL_EmitAmbientSound( ENT( pev ), tr.vecEndPos, "weapons/electro4.wav", 0.3, ATTN_NORM, 0, RANDOM_LONG( 90, 99 ) ); + UTIL_EmitAmbientSound( ENT( pev ), tr.vecEndPos, "weapons/electro4.wav", 0.3f, ATTN_NORM, 0, RANDOM_LONG( 90, 99 ) ); } UTIL_Remove( this ); diff --git a/dlls/crossbow.cpp b/dlls/crossbow.cpp index b196457a..35554ebd 100644 --- a/dlls/crossbow.cpp +++ b/dlls/crossbow.cpp @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ -#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD ) +#if !OEM_BUILD && !HLDEMO_BUILD #include "extdll.h" #include "util.h" @@ -23,11 +23,11 @@ #include "player.h" #include "gamerules.h" -#ifndef CLIENT_DLL +#if !CLIENT_DLL #define BOLT_AIR_VELOCITY 2000 #define BOLT_WATER_VELOCITY 1000 -extern BOOL gPhysicsInterfaceInitialized; +extern BOOL g_fIsXash3D; // UNDONE: Save/restore this? Don't forget to set classname and LINK_ENTITY_TO_CLASS() // @@ -82,7 +82,7 @@ void CCrossbowBolt::Spawn() pev->movetype = MOVETYPE_FLY; pev->solid = SOLID_BBOX; - pev->gravity = 0.5; + pev->gravity = 0.5f; SET_MODEL( ENT( pev ), "models/crossbow_bolt.mdl" ); @@ -91,7 +91,7 @@ void CCrossbowBolt::Spawn() SetTouch( &CCrossbowBolt::BoltTouch ); SetThink( &CCrossbowBolt::BubbleThink ); - pev->nextthink = gpGlobals->time + 0.2; + pev->nextthink = gpGlobals->time + 0.2f; } void CCrossbowBolt::Precache() @@ -155,7 +155,7 @@ void CCrossbowBolt::BoltTouch( CBaseEntity *pOther ) } else { - EMIT_SOUND_DYN( ENT( pev ), CHAN_BODY, "weapons/xbow_hit1.wav", RANDOM_FLOAT( 0.95, 1.0 ), ATTN_NORM, 0, 98 + RANDOM_LONG( 0, 7 ) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_BODY, "weapons/xbow_hit1.wav", RANDOM_FLOAT( 0.95f, 1.0f ), ATTN_NORM, 0, 98 + RANDOM_LONG( 0, 7 ) ); SetThink( &CBaseEntity::SUB_Remove ); pev->nextthink = gpGlobals->time;// this will get changed below if the bolt is allowed to stick in what it hit. @@ -164,27 +164,28 @@ void CCrossbowBolt::BoltTouch( CBaseEntity *pOther ) { // if what we hit is static architecture, can stay around for a while. Vector vecDir = pev->velocity.Normalize(); - UTIL_SetOrigin( pev, pev->origin - vecDir * 12 ); + UTIL_SetOrigin( pev, pev->origin - vecDir * 12.0f ); pev->angles = UTIL_VecToAngles( vecDir ); //pev->solid = SOLID_NOT; pev->movetype = MOVETYPE_FLY; pev->velocity = Vector( 0, 0, 0 ); pev->avelocity.z = 0; pev->angles.z = RANDOM_LONG( 0, 360 ); - pev->nextthink = gpGlobals->time + 60.0; + pev->nextthink = gpGlobals->time + 60.0f; } else if( pOther->pev->movetype == MOVETYPE_PUSH || pOther->pev->movetype == MOVETYPE_PUSHSTEP ) { Vector vecDir = pev->velocity.Normalize(); - UTIL_SetOrigin( pev, pev->origin - vecDir * 12 ); + UTIL_SetOrigin( pev, pev->origin - vecDir * 12.0f ); pev->angles = UTIL_VecToAngles( vecDir ); pev->solid = SOLID_NOT; pev->velocity = Vector( 0, 0, 0 ); pev->avelocity.z = 0; pev->angles.z = RANDOM_LONG( 0, 360 ); - pev->nextthink = gpGlobals->time + 60.0; + pev->nextthink = gpGlobals->time + 60.0f; - if (gPhysicsInterfaceInitialized) { + if( g_fIsXash3D ) + { // g-cont. Setup movewith feature pev->movetype = MOVETYPE_COMPOUND; // set movewith type pev->aiment = ENT( pOther->pev ); // set parent @@ -200,18 +201,18 @@ void CCrossbowBolt::BoltTouch( CBaseEntity *pOther ) if( g_pGameRules->IsMultiplayer() ) { SetThink( &CCrossbowBolt::ExplodeThink ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } } void CCrossbowBolt::BubbleThink( void ) { - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; if( pev->waterlevel == 0 ) return; - UTIL_BubbleTrail( pev->origin - pev->velocity * 0.1, pev->origin, 1 ); + UTIL_BubbleTrail( pev->origin - pev->velocity * 0.1f, pev->origin, 1 ); } void CCrossbowBolt::ExplodeThink( void ) @@ -343,7 +344,7 @@ void CCrossbow::Holster( int skiplocal /* = 0 */ ) SecondaryAttack(); } - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5f; if( m_iClip ) SendWeaponAnim( CROSSBOW_HOLSTER1 ); else @@ -352,7 +353,7 @@ void CCrossbow::Holster( int skiplocal /* = 0 */ ) void CCrossbow::PrimaryAttack( void ) { -#ifdef CLIENT_DLL +#if CLIENT_DLL if( m_fInZoom && bIsMultiplayer() ) #else if( m_fInZoom && g_pGameRules->IsMultiplayer() ) @@ -368,7 +369,7 @@ void CCrossbow::PrimaryAttack( void ) // this function only gets called in multiplayer void CCrossbow::FireSniperBolt() { - m_flNextPrimaryAttack = GetNextAttackDelay( 0.75 ); + m_flNextPrimaryAttack = GetNextAttackDelay( 0.75f ); if( m_iClip == 0 ) { @@ -382,25 +383,25 @@ void CCrossbow::FireSniperBolt() m_iClip--; int flags; -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS flags = FEV_NOTHOST; #else flags = 0; #endif - PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usCrossbow2, 0.0, g_vecZero, g_vecZero, 0, 0, m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType], 0, 0 ); + PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usCrossbow2, 0.0f, g_vecZero, g_vecZero, 0, 0, m_iClip, 0, 0, 0 ); // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); Vector anglesAim = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle; UTIL_MakeVectors( anglesAim ); - Vector vecSrc = m_pPlayer->GetGunPosition() - gpGlobals->v_up * 2; + Vector vecSrc = m_pPlayer->GetGunPosition() - gpGlobals->v_up * 2.0f; Vector vecDir = gpGlobals->v_forward; UTIL_TraceLine( vecSrc, vecSrc + vecDir * 8192, dont_ignore_monsters, m_pPlayer->edict(), &tr ); -#ifndef CLIENT_DLL +#if !CLIENT_DLL if( tr.pHit->v.takedamage ) { ClearMultiDamage(); @@ -433,13 +434,13 @@ void CCrossbow::FireBolt() m_iClip--; int flags; -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS flags = FEV_NOTHOST; #else flags = 0; #endif - PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usCrossbow, 0.0, g_vecZero, g_vecZero, 0, 0, m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType], 0, 0 ); + PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usCrossbow, 0.0f, g_vecZero, g_vecZero, 0, 0, m_iClip, 0, 0, 0 ); // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); @@ -449,8 +450,8 @@ void CCrossbow::FireBolt() anglesAim.x = -anglesAim.x; -#ifndef CLIENT_DLL - Vector vecSrc = m_pPlayer->GetGunPosition() - gpGlobals->v_up * 2; +#if !CLIENT_DLL + Vector vecSrc = m_pPlayer->GetGunPosition() - gpGlobals->v_up * 2.0f; Vector vecDir = gpGlobals->v_forward; CCrossbowBolt *pBolt = CCrossbowBolt::BoltCreate(); @@ -468,21 +469,21 @@ void CCrossbow::FireBolt() pBolt->pev->velocity = vecDir * BOLT_AIR_VELOCITY; pBolt->pev->speed = BOLT_AIR_VELOCITY; } - pBolt->pev->avelocity.z = 10; + pBolt->pev->avelocity.z = 10.0f; #endif if( !m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) // HEV suit - indicate out of ammo condition m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 ); - m_flNextPrimaryAttack = GetNextAttackDelay( 0.75 ); + m_flNextPrimaryAttack = GetNextAttackDelay( 0.75f ); - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.75; + m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.75f; if( m_iClip != 0 ) - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5.0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5.0f; else - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.75; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.75f; } void CCrossbow::SecondaryAttack() @@ -498,8 +499,8 @@ void CCrossbow::SecondaryAttack() m_fInZoom = 1; } - pev->nextthink = UTIL_WeaponTimeBase() + 0.1; - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0; + pev->nextthink = UTIL_WeaponTimeBase() + 0.1f; + m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0f; } void CCrossbow::Reload( void ) @@ -512,9 +513,9 @@ void CCrossbow::Reload( void ) SecondaryAttack(); } - if( DefaultReload( CROSSBOW_MAX_CLIP, CROSSBOW_RELOAD, 4.5 ) ) + if( DefaultReload( CROSSBOW_MAX_CLIP, CROSSBOW_RELOAD, 4.5f ) ) { - EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/xbow_reload1.wav", RANDOM_FLOAT( 0.95, 1.0 ), ATTN_NORM, 0, 93 + RANDOM_LONG( 0, 0xF ) ); + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/xbow_reload1.wav", RANDOM_FLOAT( 0.95f, 1.0f ), ATTN_NORM, 0, 93 + RANDOM_LONG( 0, 0xF ) ); } } @@ -527,7 +528,7 @@ void CCrossbow::WeaponIdle( void ) if( m_flTimeWeaponIdle < UTIL_WeaponTimeBase() ) { float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 ); - if( flRand <= 0.75 ) + if( flRand <= 0.75f ) { if( m_iClip ) { @@ -544,12 +545,12 @@ void CCrossbow::WeaponIdle( void ) if( m_iClip ) { SendWeaponAnim( CROSSBOW_FIDGET1 ); - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 90.0 / 30.0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 90.0f / 30.0f; } else { SendWeaponAnim( CROSSBOW_FIDGET2 ); - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 80.0 / 30.0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 80.0f / 30.0f; } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); } diff --git a/dlls/crowbar.cpp b/dlls/crowbar.cpp index 8a0ba9a3..5342e7c2 100644 --- a/dlls/crowbar.cpp +++ b/dlls/crowbar.cpp @@ -37,7 +37,7 @@ enum crowbar_e CROWBAR_ATTACK2MISS, CROWBAR_ATTACK2HIT, CROWBAR_ATTACK3MISS, -#ifndef CROWBAR_IDLE_ANIM +#if !CROWBAR_IDLE_ANIM CROWBAR_ATTACK3HIT #else CROWBAR_ATTACK3HIT, @@ -105,7 +105,7 @@ BOOL CCrowbar::Deploy() void CCrowbar::Holster( int skiplocal /* = 0 */ ) { - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5f; SendWeaponAnim( CROWBAR_HOLSTER ); } @@ -120,9 +120,9 @@ void FindHullIntersection( const Vector &vecSrc, TraceResult &tr, float *mins, f distance = 1e6f; - vecHullEnd = vecSrc + ( ( vecHullEnd - vecSrc ) * 2 ); + vecHullEnd = vecSrc + ( ( vecHullEnd - vecSrc ) * 2.0f ); UTIL_TraceLine( vecSrc, vecHullEnd, dont_ignore_monsters, pEntity, &tmpTrace ); - if( tmpTrace.flFraction < 1.0 ) + if( tmpTrace.flFraction < 1.0f ) { tr = tmpTrace; return; @@ -139,7 +139,7 @@ void FindHullIntersection( const Vector &vecSrc, TraceResult &tr, float *mins, f vecEnd.z = vecHullEnd.z + minmaxs[k][2]; UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, pEntity, &tmpTrace ); - if( tmpTrace.flFraction < 1.0 ) + if( tmpTrace.flFraction < 1.0f ) { float thisDistance = ( tmpTrace.vecEndPos - vecSrc ).Length(); if( thisDistance < distance ) @@ -157,9 +157,9 @@ void CCrowbar::PrimaryAttack() { if( !Swing( 1 ) ) { -#ifndef CLIENT_DLL +#if !CLIENT_DLL SetThink( &CCrowbar::SwingAgain ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; #endif } } @@ -182,15 +182,15 @@ int CCrowbar::Swing( int fFirst ) UTIL_MakeVectors( m_pPlayer->pev->v_angle ); Vector vecSrc = m_pPlayer->GetGunPosition(); - Vector vecEnd = vecSrc + gpGlobals->v_forward * 32; + Vector vecEnd = vecSrc + gpGlobals->v_forward * 32.0f; UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, ENT( m_pPlayer->pev ), &tr ); -#ifndef CLIENT_DLL - if( tr.flFraction >= 1.0 ) +#if !CLIENT_DLL + if( tr.flFraction >= 1.0f ) { UTIL_TraceHull( vecSrc, vecEnd, dont_ignore_monsters, head_hull, ENT( m_pPlayer->pev ), &tr ); - if( tr.flFraction < 1.0 ) + if( tr.flFraction < 1.0f ) { // Calculate the point of intersection of the line (or hull) and the object we hit // This is and approximation of the "best" intersection @@ -204,17 +204,17 @@ int CCrowbar::Swing( int fFirst ) if( fFirst ) { PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usCrowbar, - 0.0, g_vecZero, g_vecZero, 0, 0, 0, + 0.0f, g_vecZero, g_vecZero, 0, 0, 0, 0, 0, 0 ); } - if( tr.flFraction >= 1.0 ) + if( tr.flFraction >= 1.0f ) { if( fFirst ) { // miss m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); -#ifdef CROWBAR_IDLE_ANIM +#if CROWBAR_IDLE_ANIM m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); #endif // player "shoot" animation @@ -239,13 +239,13 @@ int CCrowbar::Swing( int fFirst ) // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); -#ifndef CLIENT_DLL +#if !CLIENT_DLL // hit fDidHit = TRUE; CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit ); // play thwack, smack, or dong sound - float flVol = 1.0; + float flVol = 1.0f; int fHitWorld = TRUE; if( pEntity ) @@ -254,10 +254,10 @@ int CCrowbar::Swing( int fFirst ) // If building with the clientside weapon prediction system, // UTIL_WeaponTimeBase() is always 0 and m_flNextPrimaryAttack is >= -1.0f, thus making // m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase() always evaluate to false. -#ifdef CLIENT_WEAPONS - if( ( m_flNextPrimaryAttack + 1 == UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() ) +#if CLIENT_WEAPONS + if( ( m_flNextPrimaryAttack + 1.0f == UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() ) #else - if( ( m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() ) + if( ( m_flNextPrimaryAttack + 1.0f < UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() ) #endif { // first swing does full damage @@ -266,7 +266,7 @@ int CCrowbar::Swing( int fFirst ) else { // subsequent swings do half - pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgCrowbar / 2, gpGlobals->v_forward, &tr, DMG_CLUB ); + pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgCrowbar * 0.5f, gpGlobals->v_forward, &tr, DMG_CLUB ); } ApplyMultiDamage( m_pPlayer->pev, m_pPlayer->pev ); @@ -276,20 +276,27 @@ int CCrowbar::Swing( int fFirst ) switch( RANDOM_LONG( 0, 2 ) ) { case 0: - EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cbar_hitbod1.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cbar_hitbod1.wav", 1.0f, ATTN_NORM ); break; case 1: - EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cbar_hitbod2.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cbar_hitbod2.wav", 1.0f, ATTN_NORM ); break; case 2: - EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cbar_hitbod3.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cbar_hitbod3.wav", 1.0f, ATTN_NORM ); break; } + m_pPlayer->m_iWeaponVolume = CROWBAR_BODYHIT_VOLUME; + if( !pEntity->IsAlive() ) + { +#if CROWBAR_FIX_RAPID_CROWBAR + m_flNextPrimaryAttack = GetNextAttackDelay(0.25); +#endif return TRUE; + } else - flVol = 0.1; + flVol = 0.1f; fHitWorld = FALSE; } @@ -300,14 +307,14 @@ int CCrowbar::Swing( int fFirst ) if( fHitWorld ) { - float fvolbar = TEXTURETYPE_PlaySound( &tr, vecSrc, vecSrc + ( vecEnd - vecSrc ) * 2, BULLET_PLAYER_CROWBAR ); + float fvolbar = TEXTURETYPE_PlaySound( &tr, vecSrc, vecSrc + ( vecEnd - vecSrc ) * 2.0f, BULLET_PLAYER_CROWBAR ); if( g_pGameRules->IsMultiplayer() ) { // override the volume here, cause we don't play texture sounds in multiplayer, // and fvolbar is going to be 0 from the above call. - fvolbar = 1; + fvolbar = 1.0f; } // also play crowbar strike @@ -328,39 +335,43 @@ int CCrowbar::Swing( int fFirst ) m_pPlayer->m_iWeaponVolume = (int)( flVol * CROWBAR_WALLHIT_VOLUME ); SetThink( &CCrowbar::Smack ); - pev->nextthink = UTIL_WeaponTimeBase() + 0.2; + pev->nextthink = gpGlobals->time + 0.2f; +#endif +#if CROWBAR_DELAY_FIX + m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.25f; +#else + m_flNextPrimaryAttack = GetNextAttackDelay( 0.25f ); #endif - m_flNextPrimaryAttack = GetNextAttackDelay( 0.25 ); } -#ifdef CROWBAR_IDLE_ANIM +#if CROWBAR_IDLE_ANIM m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); #endif return fDidHit; } -#ifdef CROWBAR_IDLE_ANIM +#if CROWBAR_IDLE_ANIM void CCrowbar::WeaponIdle( void ) { if( m_flTimeWeaponIdle < UTIL_WeaponTimeBase() ) { int iAnim; float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 ); - if( flRand > 0.9 ) + if( flRand > 0.9f ) { iAnim = CROWBAR_IDLE2; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 160.0 / 30.0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 160.0f / 30.0f; } else { - if( flRand > 0.5 ) + if( flRand > 0.5f ) { iAnim = CROWBAR_IDLE; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 70.0 / 30.0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 70.0f / 25.0f; } else { iAnim = CROWBAR_IDLE3; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 160.0 / 30.0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 160.0f / 30.0f; } } SendWeaponAnim( iAnim ); diff --git a/dlls/decals.h b/dlls/decals.h index 5de54421..c5e67356 100644 --- a/dlls/decals.h +++ b/dlls/decals.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef DECALS_H +#if !defined(DECALS_H) #define DECALS_H // diff --git a/dlls/defaultai.h b/dlls/defaultai.h index 652d1085..9696169b 100644 --- a/dlls/defaultai.h +++ b/dlls/defaultai.h @@ -12,7 +12,7 @@ * use or distribution of this code by or to any unlicensed person is illegal. * ****/ -#ifndef DEFAULTAI_H +#if !defined(DEFAULTAI_H) #define DEFAULTAI_H //========================================================= diff --git a/dlls/doors.cpp b/dlls/doors.cpp index 17b7756a..9c4eab56 100644 --- a/dlls/doors.cpp +++ b/dlls/doors.cpp @@ -111,9 +111,9 @@ TYPEDESCRIPTION CBaseDoor::m_SaveData[] = IMPLEMENT_SAVERESTORE( CBaseDoor, CBaseToggle ) -#define DOOR_SENTENCEWAIT 6 -#define DOOR_SOUNDWAIT 3 -#define BUTTON_SOUNDWAIT 0.5 +#define DOOR_SENTENCEWAIT 6.0f +#define DOOR_SOUNDWAIT 3.0f +#define BUTTON_SOUNDWAIT 0.5f // play door or button locked or unlocked sounds. // pass in pointer to valid locksound struct. @@ -141,9 +141,9 @@ void PlayLockSounds( entvars_t *pev, locksound_t *pls, int flocked, int fbutton float fvol; if( fplaysound && fplaysentence ) - fvol = 0.25; + fvol = 0.25f; else - fvol = 1.0; + fvol = 1.0f; // if there is a locked sound, and we've debounced, play sound if( fplaysound ) @@ -160,7 +160,7 @@ void PlayLockSounds( entvars_t *pev, locksound_t *pls, int flocked, int fbutton int iprev = pls->iLockedSentence; pls->iLockedSentence = SENTENCEG_PlaySequentialSz( ENT( pev ), STRING( pls->sLockedSentence ), - 0.85, ATTN_NORM, 0, 100, pls->iLockedSentence, FALSE ); + 0.85f, ATTN_NORM, 0, 100, pls->iLockedSentence, FALSE ); pls->iUnlockedSentence = 0; // make sure we don't keep calling last sentence in list @@ -179,9 +179,9 @@ void PlayLockSounds( entvars_t *pev, locksound_t *pls, int flocked, int fbutton // if playing both sentence and sound, lower sound volume so we hear sentence if( fplaysound && fplaysentence ) - fvol = 0.25; + fvol = 0.25f; else - fvol = 1.0; + fvol = 1.0f; // play 'door unlocked' sound if set if( fplaysound ) @@ -196,7 +196,7 @@ void PlayLockSounds( entvars_t *pev, locksound_t *pls, int flocked, int fbutton int iprev = pls->iUnlockedSentence; pls->iUnlockedSentence = SENTENCEG_PlaySequentialSz( ENT( pev ), STRING( pls->sUnlockedSentence ), - 0.85, ATTN_NORM, 0, 100, pls->iUnlockedSentence, FALSE ); + 0.85f, ATTN_NORM, 0, 100, pls->iUnlockedSentence, FALSE ); pls->iLockedSentence = 0; // make sure we don't keep calling last sentence in list @@ -253,7 +253,7 @@ void CBaseDoor::KeyValue( KeyValueData *pkvd ) } else if( FStrEq( pkvd->szKeyName, "WaveHeight" ) ) { - pev->scale = atof( pkvd->szValue ) * ( 1.0 / 8.0 ); + pev->scale = atof( pkvd->szValue ) * ( 1.0f / 8.0f ); pkvd->fHandled = TRUE; } else @@ -315,13 +315,13 @@ void CBaseDoor::Spawn() UTIL_SetOrigin( pev, pev->origin ); SET_MODEL( ENT( pev ), STRING( pev->model ) ); - if( pev->speed == 0 ) - pev->speed = 100; + if( pev->speed == 0.0f ) + pev->speed = 100.0f; m_vecPosition1 = pev->origin; // Subtract 2 from size because the engine expands bboxes by 1 in all directions making the size too big - m_vecPosition2 = m_vecPosition1 + ( pev->movedir * ( fabs( pev->movedir.x * ( pev->size.x - 2 ) ) + fabs( pev->movedir.y * ( pev->size.y - 2 ) ) + fabs( pev->movedir.z * ( pev->size.z - 2 ) ) - m_flLip ) ); + m_vecPosition2 = m_vecPosition1 + ( pev->movedir * ( fabs( pev->movedir.x * ( pev->size.x - 2.0f ) ) + fabs( pev->movedir.y * ( pev->size.y - 2.0f ) ) + fabs( pev->movedir.z * ( pev->size.z - 2.0f ) ) - m_flLip ) ); ASSERTSZ( m_vecPosition1 != m_vecPosition2, "door start/end positions are equal" ); if( FBitSet( pev->spawnflags, SF_DOOR_START_OPEN ) ) { @@ -545,10 +545,8 @@ void CBaseDoor::Precache( void ) // void CBaseDoor::DoorTouch( CBaseEntity *pOther ) { - entvars_t *pevToucher = pOther->pev; - // Ignore touches by anything but players - if( !FClassnameIs( pevToucher, "player" ) ) + if( !pOther->IsPlayer() ) return; // If door has master, and it's not ready to trigger, @@ -569,7 +567,7 @@ void CBaseDoor::DoorTouch( CBaseEntity *pOther ) m_hActivator = pOther;// remember who activated the door - if( DoorActivate()) + if( DoorActivate() ) SetTouch( NULL ); // Temporarily disable the touch function, until movement is finished. } @@ -651,7 +649,7 @@ void CBaseDoor::DoorGoUp( void ) SetMoveDone( &CBaseDoor::DoorHitTop ); if( FClassnameIs( pev, "func_door_rotating" ) ) // !!! BUGBUG Triggered doors don't work with this yet { - float sign = 1.0; + float sign = 1.0f; if( m_hActivator != 0 ) { @@ -661,14 +659,14 @@ void CBaseDoor::DoorGoUp( void ) { Vector vec = pevActivator->origin - pev->origin; Vector angles = pevActivator->angles; - angles.x = 0; - angles.z = 0; + angles.x = 0.0f; + angles.z = 0.0f; UTIL_MakeVectors( angles ); - //Vector vnext = ( pevToucher->origin + ( pevToucher->velocity * 10 ) ) - pev->origin; + //Vector vnext = ( pevToucher->origin + ( pevToucher->velocity * 10.f ) ) - pev->origin; UTIL_MakeVectors( pevActivator->angles ); - Vector vnext = ( pevActivator->origin + ( gpGlobals->v_forward * 10 ) ) - pev->origin; - if( ( vec.x * vnext.y - vec.y * vnext.x ) < 0 ) - sign = -1.0; + Vector vnext = ( pevActivator->origin + ( gpGlobals->v_forward * 10.f ) ) - pev->origin; + if( ( vec.x * vnext.y - vec.y * vnext.x ) < 0.0f ) + sign = -1.0f; } } AngularMove( m_vecAngle2*sign, pev->speed ); @@ -685,7 +683,7 @@ void CBaseDoor::DoorHitTop( void ) if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) { STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ) ); - EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseArrived ), 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseArrived ), 1.0f, ATTN_NORM ); } ASSERT( m_toggle_state == TS_GOING_UP ); @@ -708,9 +706,9 @@ void CBaseDoor::DoorHitTop( void ) pev->nextthink = pev->ltime + m_flWait; SetThink( &CBaseDoor::DoorGoDown ); - if( m_flWait == -1 ) + if( m_flWait == -1.0f ) { - pev->nextthink = -1; + pev->nextthink = -1.0f; } } @@ -728,8 +726,8 @@ void CBaseDoor::DoorGoDown( void ) { if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) if( m_toggle_state != TS_GOING_UP && m_toggle_state != TS_GOING_DOWN ) - EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ), 1, ATTN_NORM ); -#ifdef DOOR_ASSERT + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ), 1.0f, ATTN_NORM ); +#if DOOR_ASSERT ASSERT( m_toggle_state == TS_AT_TOP ); #endif // DOOR_ASSERT m_toggle_state = TS_GOING_DOWN; @@ -749,7 +747,7 @@ void CBaseDoor::DoorHitBottom( void ) if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) { STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ) ); - EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseArrived ), 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseArrived ), 1.0f, ATTN_NORM ); } ASSERT( m_toggle_state == TS_GOING_DOWN ); @@ -792,7 +790,7 @@ void CBaseDoor::Blocked( CBaseEntity *pOther ) // if a door has a negative wait, it would never come back if blocked, // so let it just squash the object to death real fast - if( m_flWait >= 0 ) + if( m_flWait >= 0.0f ) { // BMod Start - Door sound fix. if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) @@ -825,7 +823,7 @@ void CBaseDoor::Blocked( CBaseEntity *pOther ) { pDoor = GetClassPtr( (CBaseDoor *)VARS( pentTarget ) ); - if( pDoor->m_flWait >= 0 ) + if( pDoor->m_flWait >= 0.0f ) { if( pDoor->pev->velocity == pev->velocity && pDoor->pev->avelocity == pev->velocity ) { @@ -913,8 +911,8 @@ void CRotDoor::Spawn( void ) // check for clockwise rotation if( FBitSet( pev->spawnflags, SF_DOOR_ROTATE_BACKWARDS ) ) - pev->movedir = pev->movedir * -1; - + pev->movedir = pev->movedir * -1.0f; + //m_flWait = 2; who the hell did this? (sjb) m_vecAngle1 = pev->angles; m_vecAngle2 = pev->angles + pev->movedir * m_flMoveDistance; @@ -930,8 +928,8 @@ void CRotDoor::Spawn( void ) UTIL_SetOrigin( pev, pev->origin ); SET_MODEL( ENT( pev ), STRING( pev->model ) ); - if( pev->speed == 0 ) - pev->speed = 100; + if( pev->speed == 0.0f ) + pev->speed = 100.0f; // DOOR_START_OPEN is to allow an entity to be lighted in the closed position // but spawn in the open position @@ -942,7 +940,7 @@ void CRotDoor::Spawn( void ) Vector vecSav = m_vecAngle1; m_vecAngle2 = m_vecAngle1; m_vecAngle1 = vecSav; - pev->movedir = pev->movedir * -1; + pev->movedir = pev->movedir * -1.0f; } m_toggle_state = TS_AT_BOTTOM; @@ -1005,14 +1003,14 @@ void CMomentaryDoor::Spawn( void ) UTIL_SetOrigin( pev, pev->origin ); SET_MODEL( ENT( pev ), STRING( pev->model ) ); - if( pev->speed == 0 ) - pev->speed = 100; - if( pev->dmg == 0 ) - pev->dmg = 2; + if( pev->speed == 0.0f ) + pev->speed = 100.0f; + if( pev->dmg == 0.0f ) + pev->dmg = 2.0f; m_vecPosition1 = pev->origin; // Subtract 2 from size because the engine expands bboxes by 1 in all directions making the size too big - m_vecPosition2 = m_vecPosition1 + ( pev->movedir * ( fabs( pev->movedir.x * ( pev->size.x - 2 ) ) + fabs( pev->movedir.y * ( pev->size.y - 2 ) ) + fabs( pev->movedir.z * ( pev->size.z - 2 ) ) - m_flLip ) ); + m_vecPosition2 = m_vecPosition1 + ( pev->movedir * ( fabs( pev->movedir.x * ( pev->size.x - 2.0f ) ) + fabs( pev->movedir.y * ( pev->size.y - 2.0f ) ) + fabs( pev->movedir.z * ( pev->size.z - 2.0f ) ) - m_flLip ) ); ASSERTSZ( m_vecPosition1 != m_vecPosition2, "door start/end positions are equal" ); if( FBitSet( pev->spawnflags, SF_DOOR_START_OPEN ) ) @@ -1136,23 +1134,23 @@ void CMomentaryDoor::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP if( useType != USE_SET ) // Momentary buttons will pass down a float in here return; - if( value > 1.0 ) - value = 1.0; - if( value < 0.0 ) - value = 0.0; + if( value > 1.0f ) + value = 1.0f; + if( value < 0.0f ) + value = 0.0f; Vector move = m_vecPosition1 + ( value * ( m_vecPosition2 - m_vecPosition1 ) ); Vector delta = move - pev->origin; - //float speed = delta.Length() * 10; - float speed = delta.Length() / 0.1; // move there in 0.1 sec + //float speed = delta.Length() * 10.0f; + float speed = delta.Length() / 0.1f; // move there in 0.1 sec if( speed != 0 ) { // This entity only thinks when it moves, so if it's thinking, it's in the process of moving // play the sound when it starts moving(not yet thinking) - if( pev->nextthink < pev->ltime || pev->nextthink == 0 ) - EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ), 1, ATTN_NORM ); + if( pev->nextthink < pev->ltime || pev->nextthink == 0.0f ) + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ), 1.0f, ATTN_NORM ); // If we already moving to designated point, return else if( move == m_vecFinalDest ) return; @@ -1165,13 +1163,13 @@ void CMomentaryDoor::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP void CMomentaryDoor::MomentaryMoveDone( void ) { SetThink(&CMomentaryDoor::StopMoveSound); - pev->nextthink = pev->ltime + 0.1; + pev->nextthink = pev->ltime + 0.1f; } void CMomentaryDoor::StopMoveSound() { STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ) ); - EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseArrived ), 1, ATTN_NORM ); - pev->nextthink = -1; + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseArrived ), 1.0f, ATTN_NORM ); + pev->nextthink = -1.0f; ResetThink(); } diff --git a/dlls/doors.h b/dlls/doors.h index fe2b5a85..35999886 100644 --- a/dlls/doors.h +++ b/dlls/doors.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef DOORS_H +#if !defined(DOORS_H) #define DOORS_H // doors diff --git a/dlls/effects.cpp b/dlls/effects.cpp index 65340f7c..c0cc101f 100644 --- a/dlls/effects.cpp +++ b/dlls/effects.cpp @@ -86,7 +86,7 @@ void CBubbling::Spawn( void ) if( !( pev->spawnflags & SF_BUBBLES_STARTOFF ) ) { SetThink( &CBubbling::FizzThink ); - pev->nextthink = gpGlobals->time + 2.0; + pev->nextthink = gpGlobals->time + 2.0f; m_state = 1; } else @@ -106,7 +106,7 @@ void CBubbling::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE use if( m_state ) { SetThink( &CBubbling::FizzThink ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } else { @@ -146,9 +146,9 @@ void CBubbling::FizzThink( void ) MESSAGE_END(); if( m_frequency > 19 ) - pev->nextthink = gpGlobals->time + 0.5; + pev->nextthink = gpGlobals->time + 0.5f; else - pev->nextthink = gpGlobals->time + 2.5 - ( 0.1 * m_frequency ); + pev->nextthink = gpGlobals->time + 2.5f - ( 0.1f * m_frequency ); } // -------------------------------------------------- @@ -175,13 +175,13 @@ void CBeam::Precache( void ) void CBeam::SetStartEntity( int entityIndex ) { - pev->sequence = ( entityIndex & 0x0FFF ) | ( ( pev->sequence & 0xF000 ) << 12 ); + pev->sequence = ( entityIndex & 0x0FFF ) | ( pev->sequence & 0xF000 ); pev->owner = g_engfuncs.pfnPEntityOfEntIndex( entityIndex ); } void CBeam::SetEndEntity( int entityIndex ) { - pev->skin = ( entityIndex & 0x0FFF ) | ( ( pev->skin & 0xF000 ) << 12 ); + pev->skin = ( entityIndex & 0x0FFF ) | ( pev->skin & 0xF000 ); pev->aiment = g_engfuncs.pfnPEntityOfEntIndex( entityIndex ); } @@ -454,7 +454,7 @@ void CLightning::Spawn( void ) if( pev->dmg > 0 ) { SetThink( &CLightning::DamageThink ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } if( pev->targetname ) { @@ -480,7 +480,7 @@ void CLightning::Spawn( void ) if( FStringNull( pev->targetname ) || FBitSet( pev->spawnflags, SF_BEAM_STARTON ) ) { SetThink( &CLightning::StrikeThink ); - pev->nextthink = gpGlobals->time + 1.0; + pev->nextthink = gpGlobals->time + 1.0f; } } } @@ -594,7 +594,7 @@ void CLightning::StrikeUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_T else { SetThink( &CLightning::StrikeThink ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } if( !FBitSet( pev->spawnflags, SF_BEAM_TOGGLE ) ) @@ -616,7 +616,7 @@ void CLightning::StrikeThink( void ) if( m_life != 0 ) { if( pev->spawnflags & SF_BEAM_RANDOM ) - pev->nextthink = gpGlobals->time + m_life + RANDOM_FLOAT( 0, m_restrike ); + pev->nextthink = gpGlobals->time + m_life + RANDOM_FLOAT( 0.0f, m_restrike ); else pev->nextthink = gpGlobals->time + m_life + m_restrike; } @@ -696,7 +696,7 @@ void CLightning::StrikeThink( void ) WRITE_SHORT( m_spriteTexture ); WRITE_BYTE( m_frameStart ); // framestart WRITE_BYTE( (int)pev->framerate ); // framerate - WRITE_BYTE( (int)( m_life * 10.0 ) ); // life + WRITE_BYTE( (int)( m_life * 10.0f ) ); // life WRITE_BYTE( m_boltWidth ); // width WRITE_BYTE( m_noiseAmplitude ); // noise WRITE_BYTE( (int)pev->rendercolor.x ); // r, g, b @@ -718,7 +718,7 @@ void CLightning::StrikeThink( void ) void CBeam::BeamDamage( TraceResult *ptr ) { RelinkBeam(); - if( ptr->flFraction != 1.0 && ptr->pHit != NULL ) + if( ptr->flFraction != 1.0f && ptr->pHit != NULL ) { CBaseEntity *pHit = CBaseEntity::Instance( ptr->pHit ); if( pHit ) @@ -738,7 +738,7 @@ void CBeam::BeamDamage( TraceResult *ptr ) void CLightning::DamageThink( void ) { - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; TraceResult tr; UTIL_TraceLine( GetStartPos(), GetEndPos(), dont_ignore_monsters, NULL, &tr ); BeamDamage( &tr ); @@ -758,7 +758,7 @@ void CLightning::Zap( const Vector &vecSrc, const Vector &vecDest ) WRITE_SHORT( m_spriteTexture ); WRITE_BYTE( m_frameStart ); // framestart WRITE_BYTE( (int)pev->framerate ); // framerate - WRITE_BYTE( (int)( m_life * 10.0) ); // life + WRITE_BYTE( (int)( m_life * 10.0f ) ); // life WRITE_BYTE( m_boltWidth ); // width WRITE_BYTE( m_noiseAmplitude ); // noise WRITE_BYTE( (int)pev->rendercolor.x ); // r, g, b @@ -793,32 +793,32 @@ void CLightning::RandomArea( void ) { Vector vecSrc = pev->origin; - Vector vecDir1 = Vector( RANDOM_FLOAT( -1.0, 1.0 ), RANDOM_FLOAT( -1.0, 1.0 ),RANDOM_FLOAT( -1.0, 1.0 ) ); + Vector vecDir1 = Vector( RANDOM_FLOAT( -1.0f, 1.0f ), RANDOM_FLOAT( -1.0f, 1.0f ),RANDOM_FLOAT( -1.0f, 1.0f ) ); vecDir1 = vecDir1.Normalize(); TraceResult tr1; UTIL_TraceLine( vecSrc, vecSrc + vecDir1 * m_radius, ignore_monsters, ENT( pev ), &tr1 ); - if( tr1.flFraction == 1.0 ) + if( tr1.flFraction == 1.0f ) continue; Vector vecDir2; do { - vecDir2 = Vector( RANDOM_FLOAT( -1.0, 1.0 ), RANDOM_FLOAT( -1.0, 1.0 ),RANDOM_FLOAT( -1.0, 1.0 ) ); - } while( DotProduct( vecDir1, vecDir2 ) > 0 ); + vecDir2 = Vector( RANDOM_FLOAT( -1.0f, 1.0f ), RANDOM_FLOAT( -1.0f, 1.0f ),RANDOM_FLOAT( -1.0f, 1.0f ) ); + } while( DotProduct( vecDir1, vecDir2 ) > 0.0f ); vecDir2 = vecDir2.Normalize(); TraceResult tr2; UTIL_TraceLine( vecSrc, vecSrc + vecDir2 * m_radius, ignore_monsters, ENT( pev ), &tr2 ); - if( tr2.flFraction == 1.0 ) + if( tr2.flFraction == 1.0f ) continue; - if( ( tr1.vecEndPos - tr2.vecEndPos ).Length() < m_radius * 0.1 ) + if( ( tr1.vecEndPos - tr2.vecEndPos ).Length() < m_radius * 0.1f ) continue; UTIL_TraceLine( tr1.vecEndPos, tr2.vecEndPos, ignore_monsters, ENT( pev ), &tr2 ); - if( tr2.flFraction != 1.0 ) + if( tr2.flFraction != 1.0f ) continue; Zap( tr1.vecEndPos, tr2.vecEndPos ); @@ -833,15 +833,15 @@ void CLightning::RandomPoint( Vector &vecSrc ) for( iLoops = 0; iLoops < 10; iLoops++ ) { - Vector vecDir1 = Vector( RANDOM_FLOAT( -1.0, 1.0 ), RANDOM_FLOAT( -1.0, 1.0 ),RANDOM_FLOAT( -1.0, 1.0 ) ); + Vector vecDir1 = Vector( RANDOM_FLOAT( -1.0f, 1.0f ), RANDOM_FLOAT( -1.0f, 1.0f ), RANDOM_FLOAT( -1.0f, 1.0f ) ); vecDir1 = vecDir1.Normalize(); TraceResult tr1; UTIL_TraceLine( vecSrc, vecSrc + vecDir1 * m_radius, ignore_monsters, ENT( pev ), &tr1 ); - if( ( tr1.vecEndPos - vecSrc ).Length() < m_radius * 0.1 ) + if( ( tr1.vecEndPos - vecSrc ).Length() < m_radius * 0.1f ) continue; - if( tr1.flFraction == 1.0 ) + if( tr1.flFraction == 1.0f ) continue; Zap( vecSrc, tr1.vecEndPos ); @@ -1067,7 +1067,7 @@ void CLaser::StrikeThink( void ) UTIL_TraceLine( pev->origin, m_firePosition, dont_ignore_monsters, NULL, &tr ); FireAtPoint( tr ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } class CGlow : public CPointEntity @@ -1105,8 +1105,8 @@ void CGlow::Spawn( void ) SET_MODEL( ENT( pev ), STRING( pev->model ) ); m_maxFrame = (float) MODEL_FRAMES( pev->modelindex ) - 1; - if( m_maxFrame > 1.0 && pev->framerate != 0 ) - pev->nextthink = gpGlobals->time + 0.1; + if( m_maxFrame > 1.0f && pev->framerate != 0 ) + pev->nextthink = gpGlobals->time + 0.1f; m_lastTime = gpGlobals->time; } @@ -1115,7 +1115,7 @@ void CGlow::Think( void ) { Animate( pev->framerate * ( gpGlobals->time - m_lastTime ) ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; m_lastTime = gpGlobals->time; } @@ -1198,7 +1198,7 @@ void CSprite::AnimateThink( void ) { Animate( pev->framerate * ( gpGlobals->time - m_lastTime ) ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; m_lastTime = gpGlobals->time; } @@ -1235,7 +1235,7 @@ void CSprite::ExpandThink( void ) } else { - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; m_lastTime = gpGlobals->time; } } @@ -1266,7 +1266,7 @@ void CSprite::TurnOff( void ) void CSprite::TurnOn( void ) { pev->effects = 0; - if( ( pev->framerate && m_maxFrame > 1.0 ) || ( pev->spawnflags & SF_SPRITE_ONCE ) ) + if( ( pev->framerate && m_maxFrame > 1.0f ) || ( pev->spawnflags & SF_SPRITE_ONCE ) ) { SetThink( &CSprite::AnimateThink ); pev->nextthink = gpGlobals->time; @@ -1423,9 +1423,9 @@ void CGibShooter::ShootThink( void ) vecShootDir = pev->movedir; - vecShootDir = vecShootDir + gpGlobals->v_right * RANDOM_FLOAT( -1, 1 ) * m_flVariance;; - vecShootDir = vecShootDir + gpGlobals->v_forward * RANDOM_FLOAT( -1, 1 ) * m_flVariance;; - vecShootDir = vecShootDir + gpGlobals->v_up * RANDOM_FLOAT( -1, 1 ) * m_flVariance;; + vecShootDir = vecShootDir + gpGlobals->v_right * RANDOM_FLOAT( -1.0f, 1.0f ) * m_flVariance;; + vecShootDir = vecShootDir + gpGlobals->v_forward * RANDOM_FLOAT( -1.0f, 1.0f ) * m_flVariance;; + vecShootDir = vecShootDir + gpGlobals->v_up * RANDOM_FLOAT( -1.0f, 1.0f ) * m_flVariance;; vecShootDir = vecShootDir.Normalize(); CGib *pGib = CreateGib(); @@ -1435,12 +1435,12 @@ void CGibShooter::ShootThink( void ) pGib->pev->origin = pev->origin; pGib->pev->velocity = vecShootDir * m_flGibVelocity; - pGib->pev->avelocity.x = RANDOM_FLOAT( 100, 200 ); - pGib->pev->avelocity.y = RANDOM_FLOAT( 100, 300 ); + pGib->pev->avelocity.x = RANDOM_FLOAT( 100.0f, 200.0f ); + pGib->pev->avelocity.y = RANDOM_FLOAT( 100.0f, 300.0f ); float thinkTime = pGib->pev->nextthink - gpGlobals->time; - pGib->m_lifeTime = ( m_flGibLife * RANDOM_FLOAT( 0.95, 1.05 ) ); // +/- 5% + pGib->m_lifeTime = ( m_flGibLife * RANDOM_FLOAT( 0.95f, 1.05f ) ); // +/- 5% if( pGib->m_lifeTime < thinkTime ) { pGib->pev->nextthink = gpGlobals->time + pGib->m_lifeTime; @@ -1585,7 +1585,7 @@ void CTestEffect::TestThink( void ) TraceResult tr; Vector vecSrc = pev->origin; - Vector vecDir = Vector( RANDOM_FLOAT( -1.0, 1.0 ), RANDOM_FLOAT( -1.0, 1.0 ),RANDOM_FLOAT( -1.0, 1.0 ) ); + Vector vecDir = Vector( RANDOM_FLOAT( -1.0f, 1.0f ), RANDOM_FLOAT( -1.0f, 1.0f ),RANDOM_FLOAT( -1.0f, 1.0f ) ); vecDir = vecDir.Normalize(); UTIL_TraceLine( vecSrc, vecSrc + vecDir * 128, ignore_monsters, ENT( pev ), &tr ); @@ -1599,7 +1599,7 @@ void CTestEffect::TestThink( void ) m_pBeam[m_iBeam] = pbeam; m_iBeam++; #if 0 - Vector vecMid = ( vecSrc + tr.vecEndPos ) * 0.5; + Vector vecMid = ( vecSrc + tr.vecEndPos ) * 0.5f; MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_DLIGHT ); WRITE_COORD( vecMid.x ); // X @@ -1615,15 +1615,15 @@ void CTestEffect::TestThink( void ) #endif } - if( t < 3.0 ) + if( t < 3.0f ) { for( i = 0; i < m_iBeam; i++ ) { - t = ( gpGlobals->time - m_flBeamTime[i] ) / ( 3 + m_flStartTime - m_flBeamTime[i] ); - m_pBeam[i]->SetBrightness( (int)( 255 * t ) ); + t = ( gpGlobals->time - m_flBeamTime[i] ) / ( 3.0f + m_flStartTime - m_flBeamTime[i] ); + m_pBeam[i]->SetBrightness( (int)( 255.0f * t ) ); // m_pBeam[i]->SetScrollRate( 20 * t ); } - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } else { @@ -1641,7 +1641,7 @@ void CTestEffect::TestThink( void ) void CTestEffect::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { SetThink( &CTestEffect::TestThink ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; m_flStartTime = gpGlobals->time; } @@ -1741,7 +1741,7 @@ Vector CBlood::BloodPosition( CBaseEntity *pActivator ) else pPlayer = g_engfuncs.pfnPEntityOfEntIndex( 1 ); if( pPlayer ) - return( pPlayer->v.origin + pPlayer->v.view_ofs ) + Vector( RANDOM_FLOAT( -10, 10 ), RANDOM_FLOAT( -10, 10 ), RANDOM_FLOAT( -10, 10 ) ); + return( pPlayer->v.origin + pPlayer->v.view_ofs ) + Vector( RANDOM_FLOAT( -10.0f, 10.0f ), RANDOM_FLOAT( -10.0f, 10.0f ), RANDOM_FLOAT( -10.0f, 10.0f ) ); } return pev->origin; @@ -1761,7 +1761,7 @@ void CBlood::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTyp TraceResult tr; UTIL_TraceLine( start, start + forward * BloodAmount() * 2, ignore_monsters, NULL, &tr ); - if( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0f ) UTIL_BloodDecalTrace( &tr, Color() ); } } @@ -2014,8 +2014,8 @@ void CMessage::Spawn( void ) pev->impulse = 0; // No volume, use normal - if( pev->scale <= 0 ) - pev->scale = 1.0; + if( pev->scale <= 0.0f ) + pev->scale = 1.0f; } void CMessage::Precache( void ) @@ -2213,7 +2213,7 @@ void CItemSoda::Spawn( void ) UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) ); SetThink( &CItemSoda::CanThink ); - pev->nextthink = gpGlobals->time + 0.5; + pev->nextthink = gpGlobals->time + 0.5f; } void CItemSoda::CanThink( void ) diff --git a/dlls/effects.h b/dlls/effects.h index 5dd55209..60e13952 100644 --- a/dlls/effects.h +++ b/dlls/effects.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef EFFECTS_H +#if !defined(EFFECTS_H) #define EFFECTS_H #define SF_BEAM_STARTON 0x0001 diff --git a/dlls/egon.cpp b/dlls/egon.cpp index 6f248309..d315e26f 100644 --- a/dlls/egon.cpp +++ b/dlls/egon.cpp @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ -#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD ) +#if !OEM_BUILD && !HLDEMO_BUILD #include "extdll.h" #include "util.h" @@ -32,8 +32,8 @@ #define EGON_SOUND_RUN "weapons/egon_run3.wav" #define EGON_SOUND_STARTUP "weapons/egon_windup2.wav" -#define EGON_SWITCH_NARROW_TIME 0.75 // Time it takes to switch fire modes -#define EGON_SWITCH_WIDE_TIME 1.5 +#define EGON_SWITCH_NARROW_TIME 0.75f // Time it takes to switch fire modes +#define EGON_SWITCH_WIDE_TIME 1.5f enum egon_e { EGON_IDLE1 = 0, @@ -105,7 +105,7 @@ int CEgon::AddToPlayer( CBasePlayer *pPlayer ) void CEgon::Holster( int skiplocal /* = 0 */ ) { - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5f; SendWeaponAnim( EGON_HOLSTER ); EndAttack(); @@ -178,7 +178,7 @@ void CEgon::Attack( void ) Vector vecSrc = m_pPlayer->GetGunPosition(); int flags; -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS flags = FEV_NOTHOST; #else flags = 0; @@ -190,20 +190,20 @@ void CEgon::Attack( void ) { if( !HasAmmo() ) { - m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.25; + m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.25f; PlayEmptySound( ); return; } m_flAmmoUseTime = gpGlobals->time;// start using ammo ASAP. - PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usEgonFire, 0.0, g_vecZero, g_vecZero, 0.0, 0.0, m_fireState, m_fireMode, 1, 0 ); + PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usEgonFire, 0.0f, g_vecZero, g_vecZero, 0.0f, 0.0f, 0, m_fireMode, 1, 0 ); m_shakeTime = 0; m_pPlayer->m_iWeaponVolume = EGON_PRIMARY_VOLUME; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.1; - pev->fuser1 = UTIL_WeaponTimeBase() + 2; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.1f; + pev->fuser1 = UTIL_WeaponTimeBase() + 2.0f; pev->dmgtime = gpGlobals->time + GetPulseInterval(); m_fireState = FIRE_CHARGE; @@ -216,14 +216,14 @@ void CEgon::Attack( void ) if( pev->fuser1 <= UTIL_WeaponTimeBase() ) { - PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usEgonFire, 0, g_vecZero, g_vecZero, 0.0, 0.0, m_fireState, m_fireMode, 0, 0 ); + PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usEgonFire, 0.0f, g_vecZero, g_vecZero, 0.0f, 0.0f, 0, m_fireMode, 0, 0 ); pev->fuser1 = 1000; } if( !HasAmmo() ) { EndAttack(); - m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0; + m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0f; } break; } @@ -238,12 +238,12 @@ void CEgon::PrimaryAttack( void ) void CEgon::Fire( const Vector &vecOrigSrc, const Vector &vecDir ) { - Vector vecDest = vecOrigSrc + vecDir * 2048; + Vector vecDest = vecOrigSrc + vecDir * 2048.0f; edict_t *pentIgnore; TraceResult tr; pentIgnore = m_pPlayer->edict(); - Vector tmpSrc = vecOrigSrc + gpGlobals->v_up * -8 + gpGlobals->v_right * 3; + Vector tmpSrc = vecOrigSrc + gpGlobals->v_up * -8.0f + gpGlobals->v_right * 3.0f; // ALERT( at_console, "." ); @@ -252,7 +252,7 @@ void CEgon::Fire( const Vector &vecOrigSrc, const Vector &vecDir ) if( tr.fAllSolid ) return; -#ifndef CLIENT_DLL +#if !CLIENT_DLL CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit ); if( pEntity == NULL ) @@ -275,7 +275,7 @@ void CEgon::Fire( const Vector &vecOrigSrc, const Vector &vecDir ) switch( m_fireMode ) { case FIRE_NARROW: -#ifndef CLIENT_DLL +#if !CLIENT_DLL if( pev->dmgtime < gpGlobals->time ) { // Narrow mode only does damage to the entity it hits @@ -292,7 +292,7 @@ void CEgon::Fire( const Vector &vecOrigSrc, const Vector &vecDir ) if( gpGlobals->time >= m_flAmmoUseTime ) { UseAmmo( 1 ); - m_flAmmoUseTime = gpGlobals->time + 0.1; + m_flAmmoUseTime = gpGlobals->time + 0.1f; } } else @@ -301,7 +301,7 @@ void CEgon::Fire( const Vector &vecOrigSrc, const Vector &vecDir ) if( gpGlobals->time >= m_flAmmoUseTime ) { UseAmmo( 1 ); - m_flAmmoUseTime = gpGlobals->time + 0.166; + m_flAmmoUseTime = gpGlobals->time + 0.166f; } } @@ -311,7 +311,7 @@ void CEgon::Fire( const Vector &vecOrigSrc, const Vector &vecDir ) timedist = ( pev->dmgtime - gpGlobals->time ) / GetPulseInterval(); break; case FIRE_WIDE: -#ifndef CLIENT_DLL +#if !CLIENT_DLL if( pev->dmgtime < gpGlobals->time ) { // wide mode does damage to the ent, and radius damage @@ -325,7 +325,7 @@ void CEgon::Fire( const Vector &vecOrigSrc, const Vector &vecDir ) if( g_pGameRules->IsMultiplayer() ) { // radius damage a little more potent in multiplayer. - ::RadiusDamage( tr.vecEndPos, pev, m_pPlayer->pev, gSkillData.plrDmgEgonWide/4, 128, CLASS_NONE, DMG_ENERGYBEAM | DMG_BLAST | DMG_ALWAYSGIB ); + ::RadiusDamage( tr.vecEndPos, pev, m_pPlayer->pev, gSkillData.plrDmgEgonWide * 0.25f, 128, CLASS_NONE, DMG_ENERGYBEAM | DMG_BLAST | DMG_ALWAYSGIB ); } if( !m_pPlayer->IsAlive() ) @@ -337,7 +337,7 @@ void CEgon::Fire( const Vector &vecOrigSrc, const Vector &vecDir ) if( gpGlobals->time >= m_flAmmoUseTime ) { UseAmmo( 1 ); - m_flAmmoUseTime = gpGlobals->time + 0.2; + m_flAmmoUseTime = gpGlobals->time + 0.2f; } } else @@ -346,15 +346,15 @@ void CEgon::Fire( const Vector &vecOrigSrc, const Vector &vecDir ) if( gpGlobals->time >= m_flAmmoUseTime ) { UseAmmo( 1 ); - m_flAmmoUseTime = gpGlobals->time + 0.1; + m_flAmmoUseTime = gpGlobals->time + 0.1f; } } pev->dmgtime = gpGlobals->time + GetDischargeInterval(); if( m_shakeTime < gpGlobals->time ) { - UTIL_ScreenShake( tr.vecEndPos, 5.0, 150.0, 0.75, 250.0 ); - m_shakeTime = gpGlobals->time + 1.5; + UTIL_ScreenShake( tr.vecEndPos, 5.0f, 150.0f, 0.75f, 250.0f ); + m_shakeTime = gpGlobals->time + 1.5f; } } #endif @@ -373,7 +373,7 @@ void CEgon::Fire( const Vector &vecOrigSrc, const Vector &vecDir ) void CEgon::UpdateEffect( const Vector &startPoint, const Vector &endPoint, float timeBlend ) { -#ifndef CLIENT_DLL +#if !CLIENT_DLL if( !m_pBeam ) { CreateEffect(); @@ -384,12 +384,12 @@ void CEgon::UpdateEffect( const Vector &startPoint, const Vector &endPoint, floa m_pBeam->SetWidth( (int)( 40 - ( timeBlend * 20 ) ) ); if( m_fireMode == FIRE_WIDE ) - m_pBeam->SetColor( (int)( 30 + ( 25 * timeBlend ) ), (int)( 30 + ( 30 * timeBlend ) ), (int)( 64 + 80 * fabs( sin( gpGlobals->time * 10 ) ) ) ); + m_pBeam->SetColor( (int)( 30 + ( 25 * timeBlend ) ), (int)( 30 + ( 30 * timeBlend ) ), (int)( 64 + 80 * fabs( sin( gpGlobals->time * 10.0f ) ) ) ); else - m_pBeam->SetColor( (int)( 60 + ( 25 * timeBlend ) ), (int)( 120 + ( 30 * timeBlend ) ), (int)( 64 + 80 * fabs( sin( gpGlobals->time *10 ) ) ) ); + m_pBeam->SetColor( (int)( 60 + ( 25 * timeBlend ) ), (int)( 120 + ( 30 * timeBlend ) ), (int)( 64 + 80 * fabs( sin( gpGlobals->time * 10.0f ) ) ) ); UTIL_SetOrigin( m_pSprite->pev, endPoint ); - m_pSprite->pev->frame += 8 * gpGlobals->frametime; + m_pSprite->pev->frame += 8.0f * gpGlobals->frametime; if( m_pSprite->pev->frame > m_pSprite->Frames() ) m_pSprite->pev->frame = 0; @@ -399,7 +399,7 @@ void CEgon::UpdateEffect( const Vector &startPoint, const Vector &endPoint, floa void CEgon::CreateEffect( void ) { -#ifndef CLIENT_DLL +#if !CLIENT_DLL DestroyEffect(); m_pBeam = CBeam::BeamCreate( EGON_BEAM_SPRITE, 40 ); @@ -445,7 +445,7 @@ void CEgon::CreateEffect( void ) void CEgon::DestroyEffect( void ) { -#ifndef CLIENT_DLL +#if !CLIENT_DLL if( m_pBeam ) { UTIL_Remove( m_pBeam ); @@ -480,17 +480,17 @@ void CEgon::WeaponIdle( void ) int iAnim; - float flRand = RANDOM_FLOAT( 0, 1 ); + float flRand = RANDOM_FLOAT( 0.0f, 1.0f ); - if( flRand <= 0.5 ) + if( flRand <= 0.5f ) { iAnim = EGON_IDLE1; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10.0f, 15.0f ); } else { iAnim = EGON_FIDGET1; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3.0f; } SendWeaponAnim( iAnim ); @@ -504,10 +504,10 @@ void CEgon::EndAttack( void ) if( m_fireState != FIRE_OFF ) //Checking the button just in case!. bMakeNoise = true; - PLAYBACK_EVENT_FULL( FEV_GLOBAL | FEV_RELIABLE, m_pPlayer->edict(), m_usEgonStop, 0, m_pPlayer->pev->origin, m_pPlayer->pev->angles, 0.0, 0.0, bMakeNoise, 0, 0, 0 ); + PLAYBACK_EVENT_FULL( FEV_GLOBAL | FEV_RELIABLE, m_pPlayer->edict(), m_usEgonStop, 0.0f, m_pPlayer->pev->origin, m_pPlayer->pev->angles, 0.0f, 0.0f, bMakeNoise, 0, 0, 0 ); - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0; - m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0f; + m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5f; m_fireState = FIRE_OFF; diff --git a/dlls/enginecallback.h b/dlls/enginecallback.h index aeaf3735..07a557b4 100644 --- a/dlls/enginecallback.h +++ b/dlls/enginecallback.h @@ -12,10 +12,9 @@ * without written permission from Valve LLC. * ****/ -#ifndef ENGINECALLBACK_H -#define ENGINECALLBACK_H - #pragma once +#if !defined(ENGINECALLBACK_H) +#define ENGINECALLBACK_H #include "event_flags.h" diff --git a/dlls/explode.cpp b/dlls/explode.cpp index f605dc02..a5815ddb 100644 --- a/dlls/explode.cpp +++ b/dlls/explode.cpp @@ -38,21 +38,21 @@ LINK_ENTITY_TO_CLASS( spark_shower, CShower ) void CShower::Spawn( void ) { - pev->velocity = RANDOM_FLOAT( 200, 300 ) * pev->angles; - pev->velocity.x += RANDOM_FLOAT( -100.f, 100.f ); - pev->velocity.y += RANDOM_FLOAT( -100.f, 100.f ); + pev->velocity = RANDOM_FLOAT( 200.0f, 300.0f ) * pev->angles; + pev->velocity.x += RANDOM_FLOAT( -100.0f, 100.0f ); + pev->velocity.y += RANDOM_FLOAT( -100.0f, 100.0f ); if( pev->velocity.z >= 0 ) - pev->velocity.z += 200; + pev->velocity.z += 200.0f; else - pev->velocity.z -= 200; + pev->velocity.z -= 200.0f; pev->movetype = MOVETYPE_BOUNCE; pev->gravity = 0.5; - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; pev->solid = SOLID_NOT; SET_MODEL( edict(), "models/grenade.mdl" ); // Need a model, just use the grenade, we don't draw it anyway UTIL_SetSize( pev, g_vecZero, g_vecZero ); pev->effects |= EF_NODRAW; - pev->speed = RANDOM_FLOAT( 0.5, 1.5 ); + pev->speed = RANDOM_FLOAT( 0.5f, 1.5f ); pev->angles = g_vecZero; } @@ -61,9 +61,9 @@ void CShower::Think( void ) { UTIL_Sparks( pev->origin ); - pev->speed -= 0.1; - if( pev->speed > 0 ) - pev->nextthink = gpGlobals->time + 0.1; + pev->speed -= 0.1f; + if( pev->speed > 0.0f ) + pev->nextthink = gpGlobals->time + 0.1f; else UTIL_Remove( this ); pev->flags &= ~FL_ONGROUND; @@ -72,12 +72,12 @@ void CShower::Think( void ) void CShower::Touch( CBaseEntity *pOther ) { if( pev->flags & FL_ONGROUND ) - pev->velocity = pev->velocity * 0.1; + pev->velocity = pev->velocity * 0.1f; else - pev->velocity = pev->velocity * 0.6; + pev->velocity = pev->velocity * 0.6f; - if( ( pev->velocity.x * pev->velocity.x + pev->velocity.y * pev->velocity.y ) < 10.0 ) - pev->speed = 0; + if( ( pev->velocity.x * pev->velocity.x + pev->velocity.y * pev->velocity.y ) < 10.0f ) + pev->speed = 0.0f; } class CEnvExplosion : public CBaseMonster @@ -130,17 +130,17 @@ void CEnvExplosion::Spawn( void ) */ float flSpriteScale; - flSpriteScale = ( m_iMagnitude - 50 ) * 0.6; + flSpriteScale = ( m_iMagnitude - 50 ) * 0.6f; /* - if( flSpriteScale > 50 ) + if( flSpriteScale > 50.0f ) { - flSpriteScale = 50; + flSpriteScale = 50.0f; } */ - if( flSpriteScale < 10 ) + if( flSpriteScale < 10.0f ) { - flSpriteScale = 10; + flSpriteScale = 10.0f; } m_spriteScale = (int)flSpriteScale; @@ -155,14 +155,14 @@ void CEnvExplosion::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE Vector vecSpot;// trace starts here! - vecSpot = pev->origin + Vector( 0, 0, 8 ); + vecSpot = pev->origin + Vector( 0.0f, 0.0f, 8.0f ); - UTIL_TraceLine( vecSpot, vecSpot + Vector( 0, 0, -40 ), ignore_monsters, ENT( pev ), &tr ); + UTIL_TraceLine( vecSpot, vecSpot + Vector( 0.0f, 0.0f, -40.0f ), ignore_monsters, ENT( pev ), &tr ); // Pull out of the wall a bit - if( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0f ) { - pev->origin = tr.vecEndPos + ( tr.vecPlaneNormal * ( m_iMagnitude - 24 ) * 0.6 ); + pev->origin = tr.vecEndPos + ( tr.vecPlaneNormal * ( m_iMagnitude - 24 ) * 0.6f ); } else { @@ -172,7 +172,7 @@ void CEnvExplosion::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE // draw decal if( !( pev->spawnflags & SF_ENVEXPLOSION_NODECAL ) ) { - if( RANDOM_FLOAT( 0, 1 ) < 0.5 ) + if( RANDOM_FLOAT( 0.0f, 1.0f ) < 0.5f ) { UTIL_DecalTrace( &tr, DECAL_SCORCH1 ); } @@ -217,7 +217,7 @@ void CEnvExplosion::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE } SetThink( &CEnvExplosion::Smoke ); - pev->nextthink = gpGlobals->time + 0.3; + pev->nextthink = gpGlobals->time + 0.3f; // draw sparks if( !( pev->spawnflags & SF_ENVEXPLOSION_NOSPARKS ) ) diff --git a/dlls/explode.h b/dlls/explode.h index 001d93ca..60638e63 100644 --- a/dlls/explode.h +++ b/dlls/explode.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef EXPLODE_H +#if !defined(EXPLODE_H) #define EXPLODE_H #define SF_ENVEXPLOSION_NODAMAGE ( 1 << 0 ) // when set, ENV_EXPLOSION will not actually inflict damage diff --git a/dlls/exportdef.h b/dlls/exportdef.h index 363d8d12..6de40543 100644 --- a/dlls/exportdef.h +++ b/dlls/exportdef.h @@ -1,8 +1,8 @@ #pragma once -#ifndef EXPORTDEF_H +#if !defined(EXPORTDEF_H) #define EXPORTDEF_H -#if defined _WIN32 || defined __CYGWIN__ - #ifdef __GNUC__ +#if _WIN32 || __CYGWIN__ + #if __GNUC__ #define EXPORT __attribute__ ((dllexport)) #else #define EXPORT __declspec(dllexport) // Note: actually gcc seems to also supports this syntax. diff --git a/dlls/extdll.h b/dlls/extdll.h index c86629f5..957e2954 100644 --- a/dlls/extdll.h +++ b/dlls/extdll.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef EXTDLL_H +#if !defined(EXTDLL_H) #define EXTDLL_H // @@ -21,12 +21,12 @@ // // Allow "DEBUG" in addition to default "_DEBUG" -#ifdef _DEBUG +#if _DEBUG #define DEBUG 1 #endif // Silence certain warnings -#ifdef _MSC_VER +#if _MSC_VER #pragma warning(disable : 4244) // int or float down-conversion #pragma warning(disable : 4305) // int or float data truncation #pragma warning(disable : 4201) // nameless struct/union @@ -35,38 +35,49 @@ #endif // Prevent tons of unused windows definitions -#ifdef _WIN32 +#if _WIN32 #define WIN32_LEAN_AND_MEAN #define NOWINRES #define NOSERVICE #define NOMCX #define NOIME #define HSPRITE HSPRITE_win32 -#include "windows.h" +#include #undef HSPRITE #else // _WIN32 -#ifndef FALSE +#if !defined(FALSE) #define FALSE 0 #endif -#ifndef TRUE +#if !defined(TRUE) #define TRUE (!FALSE) #endif +#include +#include typedef unsigned int ULONG; typedef unsigned char BYTE; typedef int BOOL; #define MAX_PATH PATH_MAX -#include -#include +#if !defined(PATH_MAX) +#define PATH_MAX 4096 +#endif #endif //_WIN32 // Misc C-runtime library headers -#include "stdio.h" -#include "stdlib.h" -#include "stddef.h" -#include "math.h" +#include +#include +#include +#if HAVE_CMATH +#include +#else +#include +#endif -#if defined(__LP64__) || defined(__LLP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) - #define XASH_64BIT +#if !defined(M_PI_F) +#define M_PI_F (float)M_PI +#endif + +#if __LP64__ || __LLP64__ || _WIN64 || (__x86_64__ && !__ILP32__) || _M_X64 || __ia64 || _M_IA64 || __aarch64__ || __powerpc64__ + #define XASH_64BIT 1 #endif // Header file containing definition of globalvars_t and entvars_t @@ -90,10 +101,10 @@ typedef float vec_t; // needed before including progdefs.h // Shared header between the client DLL and the game DLLs #include "cdll_dll.h" -#ifndef Q_min +#if !defined(Q_min) #define Q_min(a,b) (((a) < (b)) ? (a) : (b)) #endif -#ifndef Q_max +#if !defined(Q_max) #define Q_max(a,b) (((a) > (b)) ? (a) : (b)) #endif diff --git a/dlls/flyingmonster.cpp b/dlls/flyingmonster.cpp index c9822898..424f1dec 100644 --- a/dlls/flyingmonster.cpp +++ b/dlls/flyingmonster.cpp @@ -36,18 +36,18 @@ int CFlyingMonster::CheckLocalMove( const Vector &vecStart, const Vector &vecEnd TraceResult tr; - UTIL_TraceHull( vecStart + Vector( 0, 0, 32 ), vecEnd + Vector( 0, 0, 32 ), dont_ignore_monsters, large_hull, edict(), &tr ); + UTIL_TraceHull( vecStart + Vector( 0.0f, 0.0f, 32.0f ), vecEnd + Vector( 0.0f, 0.0f, 32.0f ), dont_ignore_monsters, large_hull, edict(), &tr ); // ALERT( at_console, "%.0f %.0f %.0f : ", vecStart.x, vecStart.y, vecStart.z ); // ALERT( at_console, "%.0f %.0f %.0f\n", vecEnd.x, vecEnd.y, vecEnd.z ); if( pflDist ) { - *pflDist = ( ( tr.vecEndPos - Vector( 0, 0, 32 ) ) - vecStart ).Length();// get the distance. + *pflDist = ( ( tr.vecEndPos - Vector( 0.0f, 0.0f, 32.0f ) ) - vecStart ).Length();// get the distance. } // ALERT( at_console, "check %d %d %f\n", tr.fStartSolid, tr.fAllSolid, tr.flFraction ); - if( tr.fStartSolid || tr.flFraction < 1.0 ) + if( tr.fStartSolid || tr.flFraction < 1.0f ) { if( pTarget && pTarget->edict() == gpGlobals->trace_ent ) return LOCALMOVE_VALID; @@ -78,8 +78,8 @@ void CFlyingMonster::Stop( void ) m_flightSpeed = 0; m_IdealActivity = stopped; } - pev->angles.z = 0; - pev->angles.x = 0; + pev->angles.z = 0.0f; + pev->angles.x = 0.0f; m_vecTravel = g_vecZero; } @@ -88,16 +88,16 @@ float CFlyingMonster::ChangeYaw( int speed ) if( pev->movetype == MOVETYPE_FLY ) { float diff = FlYawDiff(); - float target = 0; + float target = 0.0f; if( m_IdealActivity != GetStoppedActivity() ) { - if( diff < -20 ) - target = 90; - else if( diff > 20 ) - target = -90; + if( diff < -20.0f ) + target = 90.0f; + else if( diff > 20.0f ) + target = -90.0f; } - pev->angles.z = UTIL_Approach( target, pev->angles.z, 220.0 * gpGlobals->frametime ); + pev->angles.z = UTIL_Approach( target, pev->angles.z, 220.0f * gpGlobals->frametime ); } return CBaseMonster::ChangeYaw( speed ); } @@ -141,7 +141,7 @@ BOOL CFlyingMonster::ShouldAdvanceRoute( float flWaypointDist ) if( m_Route[m_iRouteIndex].iType & bits_MF_IS_GOAL ) flWaypointDist = ( m_Route[m_iRouteIndex].vecLocation - pev->origin ).Length(); - if( flWaypointDist <= 64 + ( m_flGroundSpeed * gpGlobals->frametime ) ) + if( flWaypointDist <= 64.0f + ( m_flGroundSpeed * gpGlobals->frametime ) ) return TRUE; return FALSE; @@ -151,7 +151,7 @@ void CFlyingMonster::MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, { if( pev->movetype == MOVETYPE_FLY ) { - if( gpGlobals->time - m_stopTime > 1.0 ) + if( gpGlobals->time - m_stopTime > 1.0f ) { if( m_IdealActivity != m_movementActivity ) { @@ -163,12 +163,12 @@ void CFlyingMonster::MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, if( m_IdealActivity != m_movementActivity ) { - m_flightSpeed = UTIL_Approach( 100, m_flightSpeed, 75 * gpGlobals->frametime ); + m_flightSpeed = UTIL_Approach( 100, m_flightSpeed, 75.0f * gpGlobals->frametime ); if( m_flightSpeed < 100 ) m_stopTime = gpGlobals->time; } else - m_flightSpeed = UTIL_Approach( 20, m_flightSpeed, 300 * gpGlobals->frametime ); + m_flightSpeed = UTIL_Approach( 20, m_flightSpeed, 300.0f * gpGlobals->frametime ); if( CheckLocalMove( pev->origin, vecMove, pTargetEnt, NULL ) ) { @@ -193,10 +193,10 @@ float CFlyingMonster::CeilingZ( const Vector &position ) Vector minUp = position; Vector maxUp = position; - maxUp.z += 4096.0; + maxUp.z += 4096.0f; UTIL_TraceLine( position, maxUp, ignore_monsters, NULL, &tr ); - if( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0f ) maxUp.z = tr.vecEndPos.z; if( ( pev->flags ) & FL_SWIM ) @@ -214,7 +214,7 @@ BOOL CFlyingMonster::ProbeZ( const Vector &position, const Vector &probe, float // SWIMING & !WATER // or FLYING & WATER // - *pFraction = 0.0; + *pFraction = 0.0f; return TRUE; // We hit a water boundary because we are where we don't belong. } int conProbe = UTIL_PointContents( probe ); @@ -223,7 +223,7 @@ BOOL CFlyingMonster::ProbeZ( const Vector &position, const Vector &probe, float // The probe is either entirely inside the water (for fish) or entirely // outside the water (for birds). // - *pFraction = 1.0; + *pFraction = 1.0f; return FALSE; } @@ -233,9 +233,9 @@ BOOL CFlyingMonster::ProbeZ( const Vector &position, const Vector &probe, float float minProbeLength = 0; float diff = maxProbeLength - minProbeLength; - while( diff > 1.0 ) + while( diff > 1.0f ) { - float midProbeLength = minProbeLength + diff / 2.0; + float midProbeLength = minProbeLength + diff / 2.0f; Vector midProbeVec = midProbeLength * ProbeUnit; if( UTIL_PointContents( position + midProbeVec ) == conPosition ) { @@ -257,11 +257,11 @@ float CFlyingMonster::FloorZ( const Vector &position ) TraceResult tr; Vector down = position; - down.z -= 2048; + down.z -= 2048.0f; UTIL_TraceLine( position, down, ignore_monsters, NULL, &tr ); - if( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0f ) return tr.vecEndPos.z; return down.z; diff --git a/dlls/flyingmonster.h b/dlls/flyingmonster.h index 31ff4e33..d043fa22 100644 --- a/dlls/flyingmonster.h +++ b/dlls/flyingmonster.h @@ -14,7 +14,7 @@ ****/ // Base class for flying monsters. This overrides the movement test & execution code from CBaseMonster #pragma once -#ifndef FLYINGMONSTER_H +#if !defined(FLYINGMONSTER_H) #define FLYINGMONSTER_H class CFlyingMonster : public CBaseMonster diff --git a/dlls/func_break.cpp b/dlls/func_break.cpp index 0cc3675f..0c5e0114 100644 --- a/dlls/func_break.cpp +++ b/dlls/func_break.cpp @@ -26,6 +26,7 @@ #include "func_break.h" #include "decals.h" #include "explode.h" +#include "game.h" extern DLL_GLOBAL Vector g_vecAttackDir; @@ -139,7 +140,7 @@ TYPEDESCRIPTION CBreakable::m_SaveData[] = // Explosion magnitude is stored in pev->impulse }; -IMPLEMENT_SAVERESTORE( CBreakable, CBaseEntity ) +IMPLEMENT_SAVERESTORE( CBreakable, CBaseDelay ) void CBreakable::Spawn( void ) { @@ -271,7 +272,7 @@ void CBreakable::MaterialSoundRandom( edict_t *pEdict, Materials soundMaterial, pSoundList = MaterialSoundList( soundMaterial, soundCount ); if( soundCount ) - EMIT_SOUND( pEdict, CHAN_BODY, pSoundList[RANDOM_LONG( 0, soundCount - 1 )], volume, 1.0 ); + EMIT_SOUND( pEdict, CHAN_BODY, pSoundList[RANDOM_LONG( 0, soundCount - 1 )], volume, 1.0f ); } void CBreakable::Precache( void ) @@ -432,7 +433,7 @@ void CBreakable::BreakTouch( CBaseEntity *pOther ) if( FBitSet( pev->spawnflags, SF_BREAK_TOUCH ) ) { // can be broken when run into - flDamage = pevToucher->velocity.Length() * 0.01; + flDamage = pevToucher->velocity.Length() * 0.01f; if( flDamage >= pev->health ) { @@ -453,10 +454,10 @@ void CBreakable::BreakTouch( CBaseEntity *pOther ) SetThink( &CBreakable::Die ); SetTouch( NULL ); - if( m_flDelay == 0 ) + if( m_flDelay == 0.0f ) { // !!!BUGBUG - why doesn't zero delay work? - m_flDelay = 0.1; + m_flDelay = 0.1f; } pev->nextthink = pev->ltime + m_flDelay; @@ -491,7 +492,7 @@ void CBreakable::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vec { UTIL_Sparks( ptr->vecEndPos ); - float flVolume = RANDOM_FLOAT( 0.7 , 1.0 );//random volume range + float flVolume = RANDOM_FLOAT( 0.7f, 1.0f );//random volume range switch( RANDOM_LONG( 0, 1 ) ) { case 0: @@ -504,7 +505,7 @@ void CBreakable::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vec } break; case matUnbreakableGlass: - UTIL_Ricochet( ptr->vecEndPos, RANDOM_FLOAT( 0.5, 1.5 ) ); + UTIL_Ricochet( ptr->vecEndPos, RANDOM_FLOAT( 0.5f, 1.5f ) ); break; default: break; @@ -527,7 +528,7 @@ int CBreakable::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, flo // (that is, no actual entity projectile was involved in the attack so use the shooter's origin). if( pevAttacker == pevInflictor ) { - vecTemp = pevInflictor->origin - ( pev->absmin + ( pev->size * 0.5 ) ); + vecTemp = pevInflictor->origin - ( pev->absmin + ( pev->size * 0.5f ) ); // if a client hit the breakable with a crowbar, and breakable is crowbar-sensitive, break it now. if( FBitSet ( pevAttacker->flags, FL_CLIENT ) && @@ -537,7 +538,7 @@ int CBreakable::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, flo else // an actual missile was involved. { - vecTemp = pevInflictor->origin - ( pev->absmin + ( pev->size * 0.5 ) ); + vecTemp = pevInflictor->origin - ( pev->absmin + ( pev->size * 0.5f ) ); } if( !IsBreakable() ) @@ -545,11 +546,11 @@ int CBreakable::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, flo // Breakables take double damage from the crowbar if( bitsDamageType & DMG_CLUB ) - flDamage *= 2; + flDamage *= 2.0f; // Boxes / glass / etc. don't take much poison damage, just the impact of the dart - consider that 10% if( bitsDamageType & DMG_POISON ) - flDamage *= 0.1; + flDamage *= 0.1f; // this global is still used for glass and other non-monster killables, along with decals. g_vecAttackDir = vecTemp.Normalize(); @@ -586,10 +587,10 @@ void CBreakable::Die( void ) // The more negative pev->health, the louder // the sound should be. - fvol = RANDOM_FLOAT( 0.85, 1.0 ) + ( fabs( pev->health ) / 100.0 ); + fvol = RANDOM_FLOAT( 0.85f, 1.0 ) + ( fabs( pev->health ) / 100.0f ); - if( fvol > 1.0 ) - fvol = 1.0; + if( fvol > 1.0f ) + fvol = 1.0f; switch( m_Material ) { @@ -667,7 +668,7 @@ void CBreakable::Die( void ) } if( m_Explosion == expDirected ) - vecVelocity = g_vecAttackDir * 200; + vecVelocity = g_vecAttackDir * 200.0f; else { vecVelocity.x = 0; @@ -675,7 +676,7 @@ void CBreakable::Die( void ) vecVelocity.z = 0; } - vecSpot = pev->origin + ( pev->mins + pev->maxs ) * 0.5; + vecSpot = pev->origin + ( pev->mins + pev->maxs ) * 0.5f; MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpot ); WRITE_BYTE( TE_BREAKMODEL ); @@ -710,11 +711,11 @@ void CBreakable::Die( void ) WRITE_BYTE( cFlag ); MESSAGE_END(); - float size = pev->size.x; + /*float size = pev->size.x; if( size < pev->size.y ) size = pev->size.y; if( size < pev->size.z ) - size = pev->size.z; + size = pev->size.z;*/ // !!! HACK This should work! // Build a box above the entity that looks like an 8 pixel high sheet @@ -744,7 +745,7 @@ void CBreakable::Die( void ) SUB_UseTargets( NULL, USE_TOGGLE, 0 ); SetThink( &CBaseEntity::SUB_Remove ); - pev->nextthink = pev->ltime + 0.1; + pev->nextthink = pev->ltime + 0.1f; if( m_iszSpawnObject ) CBaseEntity::Create( STRING( m_iszSpawnObject ), VecBModelOrigin( pev ), pev->angles, edict() ); @@ -838,7 +839,7 @@ void CPushable::Spawn( void ) UTIL_SetOrigin( pev, pev->origin ); // Multiply by area of the box's cross-section (assume 1000 units^3 standard volume) - pev->skin = (int)( ( pev->skin * ( pev->maxs.x - pev->mins.x ) * ( pev->maxs.y - pev->mins.y ) ) * 0.0005 ); + pev->skin = (int)( ( pev->skin * ( pev->maxs.x - pev->mins.x ) * ( pev->maxs.y - pev->mins.y ) ) * 0.0005f ); m_soundTime = 0; } @@ -862,11 +863,11 @@ void CPushable::KeyValue( KeyValueData *pkvd ) { case 0: // Point - UTIL_SetSize( pev, Vector( -8, -8, -8 ), Vector( 8, 8, 8 ) ); + UTIL_SetSize( pev, Vector( -8.0f, -8.0f, -8.0f ), Vector( 8.0f, 8.0f, 8.0f ) ); break; case 2: // Big Hull!?!? !!!BUGBUG Figure out what this hull really is - UTIL_SetSize( pev, VEC_DUCK_HULL_MIN*2, VEC_DUCK_HULL_MAX * 2 ); + UTIL_SetSize( pev, VEC_DUCK_HULL_MIN * 2.0f, VEC_DUCK_HULL_MAX * 2.0f ); break; case 3: // Player duck @@ -920,17 +921,29 @@ void CPushable::Move( CBaseEntity *pOther, int push ) { // Only push if floating if( pev->waterlevel > 0 ) - pev->velocity.z += pevToucher->velocity.z * 0.1; + pev->velocity.z += pevToucher->velocity.z * 0.1f; return; } - // g-cont. fix pushable acceleration bug (reverted as it used in mods) if( pOther->IsPlayer() ) { - // Don't push unless the player is pushing forward and NOT use (pull) - if( push && !( pevToucher->button & ( IN_FORWARD | IN_USE ) ) ) - return; + // g-cont. fix pushable acceleration bug (now implemented as cvar) + if (pushablemode.value == 1) + { + // Allow player push when moving right, left and back too + if ( push && !(pevToucher->button & (IN_FORWARD|IN_MOVERIGHT|IN_MOVELEFT|IN_BACK)) ) + return; + // Require player walking back when applying '+use' on pushable + if ( !push && !(pevToucher->button & (IN_BACK)) ) + return; + } + else + { + // Don't push unless the player is pushing forward and NOT use (pull) + if( push && !( pevToucher->button & ( IN_FORWARD | IN_USE ) ) ) + return; + } playerTouch = 1; } @@ -943,13 +956,20 @@ void CPushable::Move( CBaseEntity *pOther, int push ) if( pev->waterlevel < 1 ) return; else - factor = 0.1; + factor = 0.1f; } else - factor = 1; + factor = 1.0f; } else - factor = 0.25; + factor = 0.25f; + + // Spirit fix for pushable acceleration + if (pushablemode.value == 2) + { + if (!push) + factor *= 0.5f; + } pev->velocity.x += pevToucher->velocity.x * factor; pev->velocity.y += pevToucher->velocity.y * factor; @@ -964,15 +984,15 @@ void CPushable::Move( CBaseEntity *pOther, int push ) { pevToucher->velocity.x = pev->velocity.x; pevToucher->velocity.y = pev->velocity.y; - if( ( gpGlobals->time - m_soundTime ) > 0.7 ) + if( ( gpGlobals->time - m_soundTime ) > 0.7f ) { m_soundTime = gpGlobals->time; if( length > 0 && FBitSet( pev->flags,FL_ONGROUND ) ) { m_lastSound = RANDOM_LONG( 0, 2 ); - EMIT_SOUND( ENT( pev ), CHAN_WEAPON, m_soundNames[m_lastSound], 0.5, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, m_soundNames[m_lastSound], 0.5f, ATTN_NORM ); //SetThink( &StopSound ); - //pev->nextthink = pev->ltime + 0.1; + //pev->nextthink = pev->ltime + 0.1f; } else STOP_SOUND( ENT( pev ), CHAN_WEAPON, m_soundNames[m_lastSound] ); diff --git a/dlls/func_break.h b/dlls/func_break.h index eb027a0a..b1680795 100644 --- a/dlls/func_break.h +++ b/dlls/func_break.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef FUNC_BREAK_H +#if !defined(FUNC_BREAK_H) #define FUNC_BREAK_H typedef enum diff --git a/dlls/func_tank.cpp b/dlls/func_tank.cpp index 6cbcad61..b68f6ecf 100644 --- a/dlls/func_tank.cpp +++ b/dlls/func_tank.cpp @@ -66,7 +66,7 @@ public: virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } inline BOOL IsActive( void ) { return (pev->spawnflags & SF_TANK_ACTIVE)?TRUE:FALSE; } - inline void TankActivate( void ) { pev->spawnflags |= SF_TANK_ACTIVE; pev->nextthink = pev->ltime + 0.1; m_fireLast = 0; } + inline void TankActivate( void ) { pev->spawnflags |= SF_TANK_ACTIVE; pev->nextthink = pev->ltime + 0.1f; m_fireLast = 0; } inline void TankDeactivate( void ) { pev->spawnflags &= ~SF_TANK_ACTIVE; m_fireLast = 0; StopRotSound(); } inline BOOL CanFire( void ) { return (gpGlobals->time - m_lastSightTime) < m_persist; } BOOL InRange( float range ); @@ -185,7 +185,7 @@ void CFuncTank::Spawn( void ) m_pitchCenter = pev->angles.x; if( IsActive() ) - pev->nextthink = pev->ltime + 1.0; + pev->nextthink = pev->ltime + 1.0f; m_sightOrigin = BarrelPosition(); // Point at the end of the barrel @@ -363,7 +363,7 @@ BOOL CFuncTank::StartControl( CBasePlayer *pController ) m_pController->m_iHideHUD |= HIDEHUD_WEAPONS; m_vecControllerUsePos = m_pController->pev->origin; - pev->nextthink = pev->ltime + 0.1; + pev->nextthink = pev->ltime + 0.1f; return TRUE; } @@ -389,7 +389,7 @@ void CFuncTank::StopControl() m_pController = NULL; if( IsActive() ) - pev->nextthink = pev->ltime + 1.0; + pev->nextthink = pev->ltime + 1.0f; } // Called each frame by the player's ItemPostFrame @@ -405,7 +405,7 @@ void CFuncTank::ControllerPostFrame( void ) Vector vecForward; UTIL_MakeVectorsPrivate( pev->angles, vecForward, NULL, NULL ); - m_fireLast = gpGlobals->time - ( 1 / m_fireRate ) - 0.01; // to make sure the gun doesn't fire too many bullets + m_fireLast = gpGlobals->time - ( 1.0f / m_fireRate ) - 0.01f; // to make sure the gun doesn't fire too many bullets Fire( BarrelPosition(), vecForward, m_pController->pev ); @@ -413,7 +413,7 @@ void CFuncTank::ControllerPostFrame( void ) if( m_pController && m_pController->IsPlayer() ) ( (CBasePlayer *)m_pController )->m_iWeaponVolume = LOUD_GUN_VOLUME; - m_flNextAttack = gpGlobals->time + ( 1 / m_fireRate ); + m_flNextAttack = gpGlobals->time + ( 1.0f / m_fireRate ); } } ////////////// END NEW STUFF ////////////// @@ -491,19 +491,19 @@ void CFuncTank::TrackTarget( void ) // Tanks attempt to mirror the player's angles angles = m_pController->pev->v_angle; angles[0] = 0 - angles[0]; - pev->nextthink = pev->ltime + 0.05; + pev->nextthink = pev->ltime + 0.05f; } else { if( IsActive() ) - pev->nextthink = pev->ltime + 0.1; + pev->nextthink = pev->ltime + 0.1f; else return; if( FNullEnt( pPlayer ) ) { if( IsActive() ) - pev->nextthink = pev->ltime + 2; // Wait 2 secs + pev->nextthink = pev->ltime + 2.0f; // Wait 2 secs return; } pTarget = FindTarget( pPlayer ); @@ -520,7 +520,7 @@ void CFuncTank::TrackTarget( void ) UTIL_TraceLine( barrelEnd, targetPosition, dont_ignore_monsters, edict(), &tr ); - if( tr.flFraction == 1.0 || tr.pHit == pTarget ) + if( tr.flFraction == 1.0f || tr.pHit == pTarget ) { CBaseEntity *pInstance = CBaseEntity::Instance(pTarget); if( InRange( range ) && pInstance && pInstance->IsAlive() ) @@ -626,12 +626,14 @@ void CFuncTank::AdjustAnglesForBarrel( Vector &angles, float distance ) if( m_barrelPos.y ) { r2 = m_barrelPos.y * m_barrelPos.y; - angles.y += ( 180.0 / M_PI ) * atan2( m_barrelPos.y, sqrt( d2 - r2 ) ); + if( d2 > r2 ) + angles.y += ( 180.0f / M_PI_F ) * atan2( m_barrelPos.y, sqrt( d2 - r2 ) ); } if( m_barrelPos.z ) { r2 = m_barrelPos.z * m_barrelPos.z; - angles.x += ( 180.0 / M_PI ) * atan2( -m_barrelPos.z, sqrt( d2 - r2 ) ); + if( d2 > r2 ) + angles.x += ( 180.0f / M_PI_F ) * atan2( -m_barrelPos.z, sqrt( d2 - r2 ) ); } } } @@ -644,9 +646,9 @@ void CFuncTank::Fire( const Vector &barrelEnd, const Vector &forward, entvars_t if( m_iszSpriteSmoke ) { CSprite *pSprite = CSprite::SpriteCreate( STRING( m_iszSpriteSmoke ), barrelEnd, TRUE ); - pSprite->AnimateAndDie( RANDOM_FLOAT( 15.0, 20.0 ) ); + pSprite->AnimateAndDie( RANDOM_FLOAT( 15.0f, 20.0f ) ); pSprite->SetTransparency( kRenderTransAlpha, (int)pev->rendercolor.x, (int)pev->rendercolor.y, (int)pev->rendercolor.z, 255, kRenderFxNone ); - pSprite->pev->velocity.z = RANDOM_FLOAT( 40, 80 ); + pSprite->pev->velocity.z = RANDOM_FLOAT( 40.0f, 80.0f ); pSprite->SetScale( m_spriteScale ); } if( m_iszSpriteFlash ) @@ -657,7 +659,7 @@ void CFuncTank::Fire( const Vector &barrelEnd, const Vector &forward, entvars_t pSprite->SetScale( m_spriteScale ); // Hack Hack, make it stick around for at least 100 ms. - pSprite->pev->nextthink += 0.1; + pSprite->pev->nextthink += 0.1f; } SUB_UseTargets( this, USE_TOGGLE, 0 ); } @@ -670,8 +672,8 @@ void CFuncTank::TankTrace( const Vector &vecStart, const Vector &vecForward, con float x, y, z; do { - x = RANDOM_FLOAT( -0.5, 0.5 ) + RANDOM_FLOAT( -0.5, 0.5 ); - y = RANDOM_FLOAT( -0.5, 0.5 ) + RANDOM_FLOAT( -0.5, 0.5 ); + x = RANDOM_FLOAT( -0.5f, 0.5f ) + RANDOM_FLOAT( -0.5f, 0.5f ); + y = RANDOM_FLOAT( -0.5f, 0.5f ) + RANDOM_FLOAT( -0.5f, 0.5f ); z = x * x + y * y; } while( z > 1 ); Vector vecDir = vecForward + @@ -847,7 +849,7 @@ void CFuncTankLaser::Fire( const Vector &barrelEnd, const Vector &forward, entva m_laserTime = gpGlobals->time; m_pLaser->TurnOn(); - m_pLaser->pev->dmgtime = gpGlobals->time - 1.0; + m_pLaser->pev->dmgtime = gpGlobals->time - 1.0f; m_pLaser->FireAtPoint( tr ); m_pLaser->pev->nextthink = 0; } @@ -1014,7 +1016,7 @@ void CFuncTankControls::Spawn( void ) UTIL_SetSize( pev, pev->mins, pev->maxs ); UTIL_SetOrigin( pev, pev->origin ); - pev->nextthink = gpGlobals->time + 0.3; // After all the func_tank's have spawned + pev->nextthink = gpGlobals->time + 0.3f; // After all the func_tank's have spawned CBaseEntity::Spawn(); } diff --git a/dlls/game.cpp b/dlls/game.cpp index 96082fb5..e6653ee5 100644 --- a/dlls/game.cpp +++ b/dlls/game.cpp @@ -17,6 +17,8 @@ #include "util.h" #include "game.h" +BOOL g_fIsXash3D; + cvar_t displaysoundlist = {"displaysoundlist","0"}; // multiplayer server rules @@ -30,9 +32,13 @@ cvar_t timelimit = { "mp_timelimit","0", FCVAR_SERVER }; cvar_t friendlyfire = { "mp_friendlyfire","0", FCVAR_SERVER }; cvar_t falldamage = { "mp_falldamage","0", FCVAR_SERVER }; cvar_t weaponstay = { "mp_weaponstay","0", FCVAR_SERVER }; -cvar_t selfgauss = { "mp_selfgauss", "1", FCVAR_SERVER }; -cvar_t chargerfix = { "mp_chargerfix", "0", FCVAR_SERVER }; -cvar_t satchelfix = { "mp_satchelfix", "0", FCVAR_SERVER }; +cvar_t selfgauss = { "selfgauss", "1", FCVAR_SERVER }; +cvar_t chargerfix = { "chargerfix", "0", FCVAR_SERVER }; +cvar_t satchelfix = { "satchelfix", "0", FCVAR_SERVER }; +cvar_t explosionfix = { "explosionfix", "0", FCVAR_SERVER }; +cvar_t monsteryawspeedfix = { "monsteryawspeedfix", "1", FCVAR_SERVER }; +cvar_t corpsephysics = { "corpsephysics", "0", FCVAR_SERVER }; +cvar_t pushablemode = { "pushablemode", "0", FCVAR_SERVER }; cvar_t forcerespawn = { "mp_forcerespawn","1", FCVAR_SERVER }; cvar_t flashlight = { "mp_flashlight","0", FCVAR_SERVER }; cvar_t aimcrosshair = { "mp_autocrosshair","1", FCVAR_SERVER }; @@ -52,6 +58,9 @@ cvar_t mp_chattime = { "mp_chattime","10", FCVAR_SERVER }; cvar_t *g_psv_gravity = NULL; cvar_t *g_psv_aim = NULL; cvar_t *g_footsteps = NULL; +cvar_t *g_enable_cheats = NULL; + +cvar_t *g_psv_developer; //CVARS FOR SKILL LEVEL SETTINGS // Agrunt @@ -453,11 +462,17 @@ cvar_t sk_player_leg3 = { "sk_player_leg3","1" }; void GameDLLInit( void ) { // Register cvars here: + if( CVAR_GET_POINTER( "build" ) ) + g_fIsXash3D = TRUE; g_psv_gravity = CVAR_GET_POINTER( "sv_gravity" ); g_psv_aim = CVAR_GET_POINTER( "sv_aim" ); g_footsteps = CVAR_GET_POINTER( "mp_footsteps" ); + g_psv_developer = CVAR_GET_POINTER( "developer" ); + + g_enable_cheats = CVAR_GET_POINTER( "sv_cheats" ); + GGM_RegisterCVars(); COOP_RegisterCVars(); ENT_RegisterCVars(); @@ -478,6 +493,10 @@ void GameDLLInit( void ) CVAR_REGISTER( &selfgauss ); CVAR_REGISTER( &chargerfix ); CVAR_REGISTER( &satchelfix ); + CVAR_REGISTER( &explosionfix ); + CVAR_REGISTER( &monsteryawspeedfix ); + CVAR_REGISTER( &corpsephysics ); + CVAR_REGISTER( &pushablemode ); CVAR_REGISTER( &forcerespawn ); CVAR_REGISTER( &flashlight ); CVAR_REGISTER( &aimcrosshair ); @@ -491,6 +510,8 @@ void GameDLLInit( void ) CVAR_REGISTER( &mp_chattime ); + + // REGISTER CVARS FOR SKILL LEVEL STUFF // Agrunt CVAR_REGISTER( &sk_agrunt_health1 );// {"sk_agrunt_health1","0"}; diff --git a/dlls/game.h b/dlls/game.h index 864f8f7e..6001a4e6 100644 --- a/dlls/game.h +++ b/dlls/game.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef GAME_H +#if !defined(GAME_H) #define GAME_H extern void GameDLLInit( void ); @@ -30,6 +30,10 @@ extern cvar_t weaponstay; extern cvar_t selfgauss; extern cvar_t chargerfix; extern cvar_t satchelfix; +extern cvar_t explosionfix; +extern cvar_t monsteryawspeedfix; +extern cvar_t corpsephysics; +extern cvar_t pushablemode; extern cvar_t forcerespawn; extern cvar_t flashlight; extern cvar_t aimcrosshair; @@ -47,4 +51,7 @@ extern cvar_t allowmonsters; extern cvar_t *g_psv_gravity; extern cvar_t *g_psv_aim; extern cvar_t *g_footsteps; +extern cvar_t *g_enable_cheats; + +extern cvar_t *g_psv_developer; #endif // GAME_H diff --git a/dlls/gamerules.cpp b/dlls/gamerules.cpp index bc08dcca..56b29300 100644 --- a/dlls/gamerules.cpp +++ b/dlls/gamerules.cpp @@ -305,6 +305,11 @@ void CGameRules::RefreshSkillData ( void ) gSkillData.plrArm = GetSkillCvar( "sk_player_arm" ); } +void CGameRules::ClientUserInfoChanged( CBasePlayer *pPlayer, char *infobuffer ) +{ + pPlayer->SetPrefsFromUserinfo( infobuffer ); +} + //========================================================= // instantiate the proper game rules object //========================================================= diff --git a/dlls/gamerules.h b/dlls/gamerules.h index 04c6eea5..781ef447 100644 --- a/dlls/gamerules.h +++ b/dlls/gamerules.h @@ -16,7 +16,7 @@ // GameRules //========================================================= #pragma once -#ifndef GAMERULES_H +#if !defined(GAMERULES_H) #define GAMERULES_H //#include "weapons.h" //#include "items.h" @@ -98,7 +98,7 @@ public: virtual BOOL AllowAutoTargetCrosshair( void ) { return TRUE; }; virtual BOOL ClientCommand( CBasePlayer *pPlayer, const char *pcmd ) { return FALSE; }; // handles the user commands; returns TRUE if command handled properly - virtual void ClientUserInfoChanged( CBasePlayer *pPlayer, char *infobuffer ) {} // the player has changed userinfo; can change it now + virtual void ClientUserInfoChanged( CBasePlayer *pPlayer, char *infobuffer ); // the player has changed userinfo; can change it now // Client kills/scoring virtual int IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *pKilled ) = 0;// how many points do I award whoever kills this player? diff --git a/dlls/gargantua.cpp b/dlls/gargantua.cpp index f3155d7f..f99b4913 100644 --- a/dlls/gargantua.cpp +++ b/dlls/gargantua.cpp @@ -12,7 +12,7 @@ * use or distribution of this code by or to any unlicensed person is illegal. * ****/ -#ifndef OEM_BUILD +#if !OEM_BUILD //========================================================= // Gargantua @@ -34,7 +34,7 @@ //========================================================= // Gargantua Monster //========================================================= -const float GARG_ATTACKDIST = 80.0; +const float GARG_ATTACKDIST = 80.0f; // Garg animation events #define GARG_AE_SLASH_LEFT 1 @@ -43,7 +43,7 @@ const float GARG_ATTACKDIST = 80.0; #define GARG_AE_RIGHT_FOOT 4 #define GARG_AE_STOMP 5 #define GARG_AE_BREATHE 6 -#define STOMP_FRAMETIME 0.015 // gpGlobals->frametime +#define STOMP_FRAMETIME 0.015f // gpGlobals->frametime // Gargantua is immune to any damage but this #define GARG_DAMAGE (DMG_ENERGYBEAM|DMG_CRUSH|DMG_MORTAR|DMG_BLAST) @@ -114,16 +114,16 @@ void CStomp::Spawn( void ) pev->model = MAKE_STRING( GARG_STOMP_SPRITE_NAME ); pev->rendermode = kRenderTransTexture; pev->renderamt = 0; - EMIT_SOUND_DYN( edict(), CHAN_BODY, GARG_STOMP_BUZZ_SOUND, 1, ATTN_NORM, 0, PITCH_NORM * 0.55 ); + EMIT_SOUND_DYN( edict(), CHAN_BODY, GARG_STOMP_BUZZ_SOUND, 1, ATTN_NORM, 0, PITCH_NORM * 0.55f ); } -#define STOMP_INTERVAL 0.025 +#define STOMP_INTERVAL 0.025f void CStomp::Think( void ) { TraceResult tr; - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; // Do damage for this frame Vector vecStart = pev->origin; @@ -145,7 +145,7 @@ void CStomp::Think( void ) // Accelerate the effect pev->speed = pev->speed + ( STOMP_FRAMETIME ) * pev->framerate; - pev->framerate = pev->framerate + ( STOMP_FRAMETIME ) * 1500; + pev->framerate = pev->framerate + ( STOMP_FRAMETIME ) * 1500.0f; // Move and spawn trails while( gpGlobals->time - pev->dmgtime > STOMP_INTERVAL ) @@ -158,9 +158,9 @@ void CStomp::Think( void ) { UTIL_TraceLine( pev->origin, pev->origin - Vector( 0, 0, 500 ), ignore_monsters, edict(), &tr ); pSprite->pev->origin = tr.vecEndPos; - pSprite->pev->velocity = Vector( RANDOM_FLOAT( -200, 200 ), RANDOM_FLOAT( -200, 200 ), 175 ); - // pSprite->AnimateAndDie( RANDOM_FLOAT( 8.0, 12.0 ) ); - pSprite->pev->nextthink = gpGlobals->time + 0.3; + pSprite->pev->velocity = Vector( RANDOM_FLOAT( -200.0f, 200.0f ), RANDOM_FLOAT( -200.0f, 200.0f ), 175 ); + // pSprite->AnimateAndDie( RANDOM_FLOAT( 8.0f, 12.0f ) ); + pSprite->pev->nextthink = gpGlobals->time + 0.3f; pSprite->SetThink( &CBaseEntity::SUB_Remove ); pSprite->SetTransparency( kRenderTransAdd, 255, 255, 255, 255, kRenderFxFadeFast ); } @@ -471,10 +471,10 @@ void CGargantua::StompAttack( void ) UTIL_TraceLine( vecStart, vecEnd, ignore_monsters, edict(), &trace ); CStomp::StompCreate( vecStart, trace.vecEndPos, 0 ); UTIL_ScreenShake( pev->origin, 12.0, 100.0, 2.0, 1000 ); - EMIT_SOUND_DYN( edict(), CHAN_WEAPON, pStompSounds[RANDOM_LONG( 0, ARRAYSIZE( pStompSounds ) - 1 )], 1.0, ATTN_GARG, 0, PITCH_NORM + RANDOM_LONG( -10, 10 ) ); + EMIT_SOUND_DYN( edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pStompSounds ), 1.0, ATTN_GARG, 0, PITCH_NORM + RANDOM_LONG( -10, 10 ) ); UTIL_TraceLine( pev->origin, pev->origin - Vector(0,0,20), ignore_monsters, edict(), &trace ); - if( trace.flFraction < 1.0 ) + if( trace.flFraction < 1.0f ) UTIL_DecalTrace( &trace, DECAL_GARGSTOMP1 ); } @@ -559,9 +559,9 @@ void CGargantua::FlameUpdate( void ) UTIL_TraceLine( vecStart, vecEnd, dont_ignore_monsters, edict(), &trace ); m_pFlame[i]->SetStartPos( trace.vecEndPos ); - m_pFlame[i+2]->SetStartPos( ( vecStart * 0.6 ) + ( trace.vecEndPos * 0.4 ) ); + m_pFlame[i+2]->SetStartPos( ( vecStart * 0.6f ) + ( trace.vecEndPos * 0.4f ) ); - if( trace.flFraction != 1.0 && gpGlobals->time > m_streakTime ) + if( trace.flFraction != 1.0f && gpGlobals->time > m_streakTime ) { StreakSplash( trace.vecEndPos, trace.vecPlaneNormal, 6, 20, 50, 400 ); streaks = TRUE; @@ -577,7 +577,7 @@ void CGargantua::FlameUpdate( void ) WRITE_COORD( vecStart.x ); // origin WRITE_COORD( vecStart.y ); WRITE_COORD( vecStart.z ); - WRITE_COORD( RANDOM_FLOAT( 32, 48 ) ); // radius + WRITE_COORD( RANDOM_FLOAT( 32.0f, 48.0f ) ); // radius WRITE_BYTE( 255 ); // R WRITE_BYTE( 255 ); // G WRITE_BYTE( 255 ); // B @@ -597,7 +597,7 @@ void CGargantua::FlameDamage( Vector vecStart, Vector vecEnd, entvars_t *pevInfl float flAdjustedDamage; Vector vecSpot; - Vector vecMid = ( vecStart + vecEnd ) * 0.5; + Vector vecMid = ( vecStart + vecEnd ) * 0.5f; float searchRadius = ( vecStart - vecMid).Length(); @@ -627,15 +627,15 @@ void CGargantua::FlameDamage( Vector vecStart, Vector vecEnd, entvars_t *pevInfl UTIL_TraceLine( vecSrc, vecSpot, dont_ignore_monsters, ENT( pev ), &tr ); - if( tr.flFraction == 1.0 || tr.pHit == pEntity->edict() ) + if( tr.flFraction == 1.0f || tr.pHit == pEntity->edict() ) { // the explosion can 'see' this entity, so hurt them! // decrease damage for an ent that's farther from the flame. dist = ( vecSrc - tr.vecEndPos ).Length(); - if( dist > 64 ) + if( dist > 64.0f ) { - flAdjustedDamage = flDamage - ( dist - 64 ) * 0.4; + flAdjustedDamage = flDamage - ( dist - 64.0f ) * 0.4f; if( flAdjustedDamage <= 0 ) continue; } @@ -645,7 +645,7 @@ void CGargantua::FlameDamage( Vector vecStart, Vector vecEnd, entvars_t *pevInfl } // ALERT( at_console, "hit %s\n", STRING( pEntity->pev->classname ) ); - if( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0f ) { ClearMultiDamage(); pEntity->TraceAttack( pevInflictor, flAdjustedDamage, ( tr.vecEndPos - vecSrc ).Normalize(), &tr, bitsDamageType ); @@ -679,7 +679,7 @@ void CGargantua::PrescheduleThink( void ) { if( !HasConditions( bits_COND_SEE_ENEMY ) ) { - m_seeTime = gpGlobals->time + 5; + m_seeTime = gpGlobals->time + 5.0f; EyeOff(); } else @@ -759,8 +759,6 @@ void CGargantua::Spawn() //========================================================= void CGargantua::Precache() { - size_t i; - PRECACHE_MODEL( "models/garg.mdl" ); PRECACHE_MODEL( GARG_EYE_SPRITE_NAME ); PRECACHE_MODEL( GARG_BEAM_SPRITE_NAME ); @@ -769,38 +767,17 @@ void CGargantua::Precache() gGargGibModel = PRECACHE_MODEL( GARG_GIB_MODEL ); PRECACHE_SOUND( GARG_STOMP_BUZZ_SOUND ); - for( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) - PRECACHE_SOUND( pAttackHitSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pBeamAttackSounds ); i++ ) - PRECACHE_SOUND( pBeamAttackSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) - PRECACHE_SOUND( pAttackMissSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pRicSounds ); i++ ) - PRECACHE_SOUND( pRicSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pFootSounds ); i++ ) - PRECACHE_SOUND( pFootSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pIdleSounds ); i++ ) - PRECACHE_SOUND( pIdleSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) - PRECACHE_SOUND( pAlertSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) - PRECACHE_SOUND( pPainSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) - PRECACHE_SOUND( pAttackSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pStompSounds ); i++ ) - PRECACHE_SOUND( pStompSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pBreatheSounds ); i++ ) - PRECACHE_SOUND( pBreatheSounds[i] ); + PRECACHE_SOUND_ARRAY( pAttackHitSounds ); + PRECACHE_SOUND_ARRAY( pBeamAttackSounds ); + PRECACHE_SOUND_ARRAY( pAttackMissSounds ); + PRECACHE_SOUND_ARRAY( pRicSounds ); + PRECACHE_SOUND_ARRAY( pFootSounds ); + PRECACHE_SOUND_ARRAY( pIdleSounds ); + PRECACHE_SOUND_ARRAY( pAlertSounds ); + PRECACHE_SOUND_ARRAY( pPainSounds ); + PRECACHE_SOUND_ARRAY( pAttackSounds ); + PRECACHE_SOUND_ARRAY( pStompSounds ); + PRECACHE_SOUND_ARRAY( pBreatheSounds ); } void CGargantua::UpdateOnRemove() @@ -831,7 +808,7 @@ void CGargantua::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vec { if( m_painSoundTime < gpGlobals->time ) { - EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pPainSounds[RANDOM_LONG( 0, ARRAYSIZE( pPainSounds ) - 1 )], 1.0, ATTN_GARG, 0, PITCH_NORM ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, RANDOM_SOUND_ARRAY( pPainSounds ), 1.0, ATTN_GARG, 0, PITCH_NORM ); m_painSoundTime = gpGlobals->time + RANDOM_FLOAT( 2.5, 4 ); } } @@ -860,7 +837,7 @@ int CGargantua::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, flo if( IsAlive() ) { if( !( bitsDamageType & GARG_DAMAGE ) ) - flDamage *= 0.01; + flDamage *= 0.01f; if( bitsDamageType & DMG_BLAST ) SetConditions( bits_COND_LIGHT_DAMAGE ); } @@ -875,13 +852,13 @@ void CGargantua::DeathEffect( void ) Vector deathPos = pev->origin + gpGlobals->v_forward * 100; // Create a spiral of streaks - CSpiral::Create( deathPos, ( pev->absmax.z - pev->absmin.z ) * 0.6, 125, 1.5 ); + CSpiral::Create( deathPos, ( pev->absmax.z - pev->absmin.z ) * 0.6f, 125, 1.5 ); Vector position = pev->origin; position.z += 32; for( i = 0; i < 7; i+=2 ) { - SpawnExplosion( position, 70, ( i * 0.3 ), 60 + ( i * 20 ) ); + SpawnExplosion( position, 70, ( i * 0.3f ), 60 + ( i * 20 ) ); position.z += 15; } @@ -889,7 +866,7 @@ void CGargantua::DeathEffect( void ) pSmoker->pev->health = 1; // 1 smoke balls pSmoker->pev->scale = 46; // 4.6X normal size pSmoker->pev->dmg = 0; // 0 radial distribution - pSmoker->pev->nextthink = gpGlobals->time + 2.5; // Start in 2.5 seconds + pSmoker->pev->nextthink = gpGlobals->time + 2.5f; // Start in 2.5 seconds } void CGargantua::Killed( entvars_t *pevAttacker, int iGib ) @@ -909,7 +886,7 @@ BOOL CGargantua::CheckMeleeAttack1( float flDot, float flDist ) { //ALERT( at_aiconsole, "CheckMelee(%f, %f)\n", flDot, flDist ); - if( flDot >= 0.7 ) + if( flDot >= 0.7f ) { if( flDist <= GARG_ATTACKDIST ) return TRUE; @@ -924,7 +901,7 @@ BOOL CGargantua::CheckMeleeAttack2( float flDot, float flDist ) if( gpGlobals->time > m_flameTime ) { - if( flDot >= 0.8 && flDist > GARG_ATTACKDIST ) + if( flDot >= 0.8f && flDist > GARG_ATTACKDIST ) { if ( flDist <= GARG_FLAME_LENGTH ) return TRUE; @@ -946,7 +923,7 @@ BOOL CGargantua::CheckRangeAttack1( float flDot, float flDist ) { if( gpGlobals->time > m_seeTime ) { - if( flDot >= 0.7 && flDist > GARG_ATTACKDIST ) + if( flDot >= 0.7f && flDist > GARG_ATTACKDIST ) { return TRUE; } @@ -965,7 +942,7 @@ void CGargantua::HandleAnimEvent( MonsterEvent_t *pEvent ) case GARG_AE_SLASH_LEFT: { // HACKHACK!!! - CBaseEntity *pHurt = GargantuaCheckTraceHullAttack( GARG_ATTACKDIST + 10.0, gSkillData.gargantuaDmgSlash, DMG_SLASH ); + CBaseEntity *pHurt = GargantuaCheckTraceHullAttack( GARG_ATTACKDIST + 10.0f, gSkillData.gargantuaDmgSlash, DMG_SLASH ); if( pHurt ) { if( pHurt->pev->flags & ( FL_MONSTER | FL_CLIENT ) ) @@ -976,10 +953,10 @@ void CGargantua::HandleAnimEvent( MonsterEvent_t *pEvent ) //UTIL_MakeVectors( pev->angles ); // called by CheckTraceHullAttack pHurt->pev->velocity = pHurt->pev->velocity - gpGlobals->v_right * 100; } - EMIT_SOUND_DYN( edict(), CHAN_WEAPON, pAttackHitSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackHitSounds ) - 1 )], 1.0, ATTN_NORM, 0, 50 + RANDOM_LONG( 0, 15 ) ); + EMIT_SOUND_DYN( edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackHitSounds ), 1.0, ATTN_NORM, 0, 50 + RANDOM_LONG( 0, 15 ) ); } else // Play a random attack miss sound - EMIT_SOUND_DYN( edict(), CHAN_WEAPON, pAttackMissSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackMissSounds ) - 1 )], 1.0, ATTN_NORM, 0, 50 + RANDOM_LONG( 0, 15 ) ); + EMIT_SOUND_DYN( edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackMissSounds ), 1.0, ATTN_NORM, 0, 50 + RANDOM_LONG( 0, 15 ) ); Vector forward; UTIL_MakeVectorsPrivate( pev->angles, forward, NULL, NULL ); @@ -988,14 +965,14 @@ void CGargantua::HandleAnimEvent( MonsterEvent_t *pEvent ) case GARG_AE_RIGHT_FOOT: case GARG_AE_LEFT_FOOT: UTIL_ScreenShake( pev->origin, 4.0, 3.0, 1.0, 750 ); - EMIT_SOUND_DYN( edict(), CHAN_BODY, pFootSounds[RANDOM_LONG( 0, ARRAYSIZE( pFootSounds ) - 1 )], 1.0, ATTN_GARG, 0, PITCH_NORM + RANDOM_LONG( -10, 10 ) ); + EMIT_SOUND_DYN( edict(), CHAN_BODY, RANDOM_SOUND_ARRAY( pFootSounds ), 1.0, ATTN_GARG, 0, PITCH_NORM + RANDOM_LONG( -10, 10 ) ); break; case GARG_AE_STOMP: StompAttack(); - m_seeTime = gpGlobals->time + 12; + m_seeTime = gpGlobals->time + 12.0f; break; case GARG_AE_BREATHE: - EMIT_SOUND_DYN( edict(), CHAN_VOICE, pBreatheSounds[RANDOM_LONG( 0, ARRAYSIZE( pBreatheSounds ) - 1 )], 1.0, ATTN_GARG, 0, PITCH_NORM + RANDOM_LONG( -10, 10 ) ); + EMIT_SOUND_DYN( edict(), CHAN_VOICE, RANDOM_SOUND_ARRAY( pBreatheSounds ), 1.0, ATTN_GARG, 0, PITCH_NORM + RANDOM_LONG( -10, 10 ) ); break; default: CBaseMonster::HandleAnimEvent( pEvent ); @@ -1021,7 +998,7 @@ CBaseEntity* CGargantua::GargantuaCheckTraceHullAttack(float flDist, int iDamage UTIL_MakeVectors( pev->angles ); Vector vecStart = pev->origin; vecStart.z += 64; - Vector vecEnd = vecStart + ( gpGlobals->v_forward * flDist ) - ( gpGlobals->v_up * flDist * 0.3 ); + Vector vecEnd = vecStart + ( gpGlobals->v_forward * flDist ) - ( gpGlobals->v_up * flDist * 0.3f ); UTIL_TraceHull( vecStart, vecEnd, dont_ignore_monsters, head_hull, ENT( pev ), &tr ); @@ -1065,17 +1042,17 @@ void CGargantua::StartTask( Task_t *pTask ) case TASK_FLAME_SWEEP: FlameCreate(); m_flWaitFinished = gpGlobals->time + pTask->flData; - m_flameTime = gpGlobals->time + 6; + m_flameTime = gpGlobals->time + 6.0f; m_flameX = 0; m_flameY = 0; break; case TASK_SOUND_ATTACK: if( RANDOM_LONG( 0, 100 ) < 30 ) - EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pAttackSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackSounds ) - 1 )], 1.0, ATTN_GARG, 0, PITCH_NORM ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, RANDOM_SOUND_ARRAY( pAttackSounds ), 1.0, ATTN_GARG, 0, PITCH_NORM ); TaskComplete(); break; case TASK_DIE: - m_flWaitFinished = gpGlobals->time + 1.6; + m_flWaitFinished = gpGlobals->time + 1.6f; DeathEffect(); // FALL THROUGH default: @@ -1099,7 +1076,7 @@ void CGargantua::RunTask( Task_t *pTask ) pev->rendercolor.y = 0; pev->rendercolor.z = 0; StopAnimation(); - pev->nextthink = gpGlobals->time + 0.15; + pev->nextthink = gpGlobals->time + 0.15f; SetThink( &CBaseEntity::SUB_Remove ); int i; int parts = MODEL_FRAMES( gGargGibModel ); @@ -1118,7 +1095,7 @@ void CGargantua::RunTask( Task_t *pTask ) pGib->m_material = matNone; pGib->pev->origin = pev->origin; pGib->pev->velocity = UTIL_RandomBloodVector() * RANDOM_FLOAT( 300, 500 ); - pGib->pev->nextthink = gpGlobals->time + 1.25; + pGib->pev->nextthink = gpGlobals->time + 1.25f; pGib->SetThink( &CBaseEntity::SUB_FadeOut ); } MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin ); @@ -1194,10 +1171,10 @@ void CGargantua::RunTask( Task_t *pTask ) if( cancel ) { - m_flWaitFinished -= 0.5; - m_flameTime -= 0.5; + m_flWaitFinished -= 0.5f; + m_flameTime -= 0.5f; } - // FlameControls( angles.x + 2 * sin( gpGlobals->time * 8 ), angles.y + 28 * sin( gpGlobals->time * 8.5 ) ); + // FlameControls( angles.x + 2.0f * sin( gpGlobals->time * 8.0f ), angles.y + 28.0f * sin( gpGlobals->time * 8.5f ) ); FlameControls( angles.x, angles.y ); } break; @@ -1235,13 +1212,13 @@ void CSmoker::Think( void ) WRITE_COORD( pev->origin.y + RANDOM_FLOAT( -pev->dmg, pev->dmg ) ); WRITE_COORD( pev->origin.z); WRITE_SHORT( g_sModelIndexSmoke ); - WRITE_BYTE( RANDOM_LONG(pev->scale, pev->scale * 1.1 ) ); + WRITE_BYTE( RANDOM_LONG(pev->scale, pev->scale * 1.1f ) ); WRITE_BYTE( RANDOM_LONG( 8, 14 ) ); // framerate MESSAGE_END(); pev->health--; if( pev->health > 0 ) - pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 0.1, 0.2 ); + pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 0.1f, 0.2f ); else UTIL_Remove( this ); } @@ -1274,7 +1251,7 @@ CSpiral *CSpiral::Create( const Vector &origin, float height, float radius, floa return pSpiral; } -#define SPIRAL_INTERVAL 0.1 //025 +#define SPIRAL_INTERVAL 0.1f //025 void CSpiral::Think( void ) { @@ -1285,7 +1262,7 @@ void CSpiral::Think( void ) Vector position = pev->origin; Vector direction = Vector(0,0,1); - float fraction = 1.0 / pev->speed; + float fraction = 1.0f / pev->speed; float radius = ( pev->scale * pev->health ) * fraction; diff --git a/dlls/gauss.cpp b/dlls/gauss.cpp index 21377783..fb512757 100644 --- a/dlls/gauss.cpp +++ b/dlls/gauss.cpp @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ -#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD ) +#if !OEM_BUILD && !HLDEMO_BUILD #include "extdll.h" #include "util.h" @@ -46,19 +46,19 @@ LINK_ENTITY_TO_CLASS( weapon_gauss, CGauss ) float CGauss::GetFullChargeTime( void ) { -#ifdef CLIENT_DLL +#if CLIENT_DLL if( bIsMultiplayer() ) #else if( g_pGameRules->IsMultiplayer() ) #endif { - return 1.5; + return 1.5f; } - return 4; + return 4.0f; } -#ifdef CLIENT_DLL +#if CLIENT_DLL extern int g_irunninggausspred; #endif @@ -124,12 +124,6 @@ int CGauss::GetItemInfo( ItemInfo *p ) return 1; } -BOOL CGauss::IsUseable() -{ - // Currently charging, allow the player to fire it first. - Solokiller - return CBasePlayerWeapon::IsUseable() || m_fInAttack != 0; -} - BOOL CGauss::Deploy() { m_pPlayer->m_flPlayAftershock = 0.0; @@ -138,9 +132,9 @@ BOOL CGauss::Deploy() void CGauss::Holster( int skiplocal /* = 0 */ ) { - PLAYBACK_EVENT_FULL( FEV_RELIABLE | FEV_GLOBAL, m_pPlayer->edict(), m_usGaussFire, 0.01, m_pPlayer->pev->origin, m_pPlayer->pev->angles, 0.0, 0.0, 0, 0, 0, 1 ); + PLAYBACK_EVENT_FULL( FEV_RELIABLE | FEV_GLOBAL, m_pPlayer->edict(), m_usGaussFire, 0.01f, m_pPlayer->pev->origin, m_pPlayer->pev->angles, 0.0, 0.0, 0, 0, 0, 1 ); - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5f; SendWeaponAnim( GAUSS_HOLSTER ); m_fInAttack = 0; @@ -152,14 +146,14 @@ void CGauss::PrimaryAttack() if( m_pPlayer->pev->waterlevel == 3 ) { PlayEmptySound(); - m_flNextSecondaryAttack = m_flNextPrimaryAttack = GetNextAttackDelay( 0.15 ); + m_flNextSecondaryAttack = m_flNextPrimaryAttack = GetNextAttackDelay( 0.15f ); return; } if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] < 2 ) { PlayEmptySound(); - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5f; return; } @@ -170,8 +164,8 @@ void CGauss::PrimaryAttack() StartFire(); m_fInAttack = 0; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.2; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0f; + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.2f; } void CGauss::SecondaryAttack() @@ -190,7 +184,7 @@ void CGauss::SecondaryAttack() PlayEmptySound(); } - m_flNextSecondaryAttack = m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); + m_flNextSecondaryAttack = m_flNextPrimaryAttack = GetNextAttackDelay( 0.5f ); return; } @@ -199,7 +193,7 @@ void CGauss::SecondaryAttack() if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) { EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/357_cock1.wav", 0.8, ATTN_NORM ); - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5f; return; } @@ -213,11 +207,11 @@ void CGauss::SecondaryAttack() SendWeaponAnim( GAUSS_SPINUP ); m_fInAttack = 1; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5f; m_pPlayer->m_flStartCharge = gpGlobals->time; m_pPlayer->m_flAmmoStartCharge = UTIL_WeaponTimeBase() + GetFullChargeTime(); - PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usGaussSpin, 0.0, g_vecZero, g_vecZero, 0.0, 0.0, 110, 0, 0, 0 ); + PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usGaussSpin, 0.0f, g_vecZero, g_vecZero, 0.0f, 0.0f, 110, 0, 0, 0 ); m_iSoundState = SND_CHANGE_PITCH; } @@ -231,41 +225,35 @@ void CGauss::SecondaryAttack() } else { - // Moved to before the ammo burn. - // Because we drained 1 when m_InAttack == 0, then 1 again now before checking if we're out of ammo, - // this resuled in the player having -1 ammo, which in turn caused CanDeploy to think it could be deployed. - // This will need to be fixed further down the line by preventing negative ammo unless explicitly required (infinite ammo?), - // But this check will prevent the problem for now. - Solokiller - // TODO: investigate further. - if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) - { - // out of ammo! force the gun to fire - StartFire(); - m_fInAttack = 0; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1; - return; - } - // during the charging process, eat one bit of ammo every once in a while if( UTIL_WeaponTimeBase() >= m_pPlayer->m_flNextAmmoBurn && m_pPlayer->m_flNextAmmoBurn != 1000 ) { -#ifdef CLIENT_DLL +#if CLIENT_DLL if( bIsMultiplayer() ) #else if( g_pGameRules->IsMultiplayer() ) #endif { m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; - m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase() + 0.1; + m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase() + 0.1f; } else { m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; - m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase() + 0.3; + m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase() + 0.3f; } } + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) + { + // out of ammo! force the gun to fire + StartFire(); + m_fInAttack = 0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0f; + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1; + return; + } + if( UTIL_WeaponTimeBase() >= m_pPlayer->m_flAmmoStartCharge ) { // don't eat any more ammo after gun is fully charged. @@ -278,28 +266,36 @@ void CGauss::SecondaryAttack() // ALERT( at_console, "%d %d %d\n", m_fInAttack, m_iSoundState, pitch ); + const bool overcharge = m_pPlayer->m_flStartCharge < gpGlobals->time - 10.0f; + if( m_iSoundState == 0 ) ALERT( at_console, "sound state %d\n", m_iSoundState ); - PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usGaussSpin, 0.0, g_vecZero, g_vecZero, 0.0, 0.0, pitch, 0, ( m_iSoundState == SND_CHANGE_PITCH ) ? 1 : 0, 0 ); +#if GAUSS_OVERCHARGE_FIX + if (!overcharge) +#endif + PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usGaussSpin, 0.0f, g_vecZero, g_vecZero, 0.0f, 0.0f, pitch, 0, ( m_iSoundState == SND_CHANGE_PITCH ) ? 1 : 0, 0 ); m_iSoundState = SND_CHANGE_PITCH; // hack for going through level transitions m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_CHARGE_VOLUME; - // m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.1; - if( m_pPlayer->m_flStartCharge < gpGlobals->time - 10 ) + // m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.1f; + if( overcharge ) { // Player charged up too long. Zap him. - EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/electro4.wav", 1.0, ATTN_NORM, 0, 80 + RANDOM_LONG( 0, 0x3f ) ); - EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/electro6.wav", 1.0, ATTN_NORM, 0, 75 + RANDOM_LONG( 0, 0x3f ) ); +#if GAUSS_OVERCHARGE_FIX + PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usGaussSpin, 0.0, g_vecZero, g_vecZero, 0.0, 0.0, pitch, 0, 0, 1 ); +#endif + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/electro4.wav", 1.0f, ATTN_NORM, 0, 80 + RANDOM_LONG( 0, 0x3f ) ); + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/electro6.wav", 1.0f, ATTN_NORM, 0, 75 + RANDOM_LONG( 0, 0x3f ) ); m_fInAttack = 0; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0; -#ifndef CLIENT_DLL + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0f; + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0f; +#if !CLIENT_DLL m_pPlayer->TakeDamage( VARS( eoNullEntity ), VARS( eoNullEntity ), 50, DMG_SHOCK ); - UTIL_ScreenFade( m_pPlayer, Vector( 255, 128, 0 ), 2, 0.5, 128, FFADE_IN ); + UTIL_ScreenFade( m_pPlayer, Vector( 255, 128, 0 ), 2, 0.5f, 128, FFADE_IN ); #endif SendWeaponAnim( GAUSS_IDLE ); @@ -325,18 +321,18 @@ void CGauss::StartFire( void ) if( gpGlobals->time - m_pPlayer->m_flStartCharge > GetFullChargeTime() ) { - flDamage = 200; + flDamage = 200.0f; } else { - flDamage = 200 * ( ( gpGlobals->time - m_pPlayer->m_flStartCharge ) / GetFullChargeTime() ); + flDamage = 200.0f * ( ( gpGlobals->time - m_pPlayer->m_flStartCharge ) / GetFullChargeTime() ); } if( m_fPrimaryFire ) { // fixed damage on primary attack -#ifdef CLIENT_DLL - flDamage = 20; +#if CLIENT_DLL + flDamage = 20.0f; #else flDamage = gSkillData.plrDmgGauss; #endif @@ -345,12 +341,12 @@ void CGauss::StartFire( void ) if( m_fInAttack != 3 ) { //ALERT( at_console, "Time:%f Damage:%f\n", gpGlobals->time - m_pPlayer->m_flStartCharge, flDamage ); -#ifndef CLIENT_DLL +#if !CLIENT_DLL float flZVel = m_pPlayer->pev->velocity.z; if( !m_fPrimaryFire ) { - m_pPlayer->pev->velocity = m_pPlayer->pev->velocity - gpGlobals->v_forward * flDamage * 5; + m_pPlayer->pev->velocity = m_pPlayer->pev->velocity - gpGlobals->v_forward * flDamage * 5.0f; } if( !g_pGameRules->IsMultiplayer() ) @@ -364,7 +360,7 @@ void CGauss::StartFire( void ) } // time until aftershock 'static discharge' sound - m_pPlayer->m_flPlayAftershock = gpGlobals->time + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0.3, 0.8 ); + m_pPlayer->m_flPlayAftershock = gpGlobals->time + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0.3f, 0.8f ); Fire( vecSrc, vecAiming, flDamage ); } @@ -373,11 +369,11 @@ void CGauss::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage ) { m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_FIRE_VOLUME; TraceResult tr, beam_tr; -#ifndef CLIENT_DLL +#if !CLIENT_DLL Vector vecSrc = vecOrigSrc; - Vector vecDest = vecSrc + vecDir * 8192; + Vector vecDest = vecSrc + vecDir * 8192.0f; edict_t *pentIgnore; - float flMaxFrac = 1.0; + float flMaxFrac = 1.0f; int nTotal = 0; int fHasPunched = 0; int fFirstBeam = 1; @@ -389,13 +385,13 @@ void CGauss::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage ) g_irunninggausspred = true; #endif // The main firing event is sent unreliably so it won't be delayed. - PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usGaussFire, 0.0, m_pPlayer->pev->origin, m_pPlayer->pev->angles, flDamage, 0.0, 0, 0, m_fPrimaryFire ? 1 : 0, 0 ); + PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usGaussFire, 0.0f, m_pPlayer->pev->origin, m_pPlayer->pev->angles, flDamage, 0.0, 0, 0, m_fPrimaryFire ? 1 : 0, 0 ); // This reliable event is used to stop the spinning sound // It's delayed by a fraction of second to make sure it is delayed by 1 frame on the client // It's sent reliably anyway, which could lead to other delays - PLAYBACK_EVENT_FULL( FEV_NOTHOST | FEV_RELIABLE, m_pPlayer->edict(), m_usGaussFire, 0.01, m_pPlayer->pev->origin, m_pPlayer->pev->angles, 0.0, 0.0, 0, 0, 0, 1 ); + PLAYBACK_EVENT_FULL( FEV_NOTHOST | FEV_RELIABLE | FEV_GLOBAL, m_pPlayer->edict(), m_usGaussFire, 0.01f, m_pPlayer->pev->origin, m_pPlayer->pev->angles, 0.0, 0.0, 0, 0, 0, 1 ); /*ALERT( at_console, "%f %f %f\n%f %f %f\n", vecSrc.x, vecSrc.y, vecSrc.z, @@ -403,7 +399,7 @@ void CGauss::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage ) //ALERT( at_console, "%f %f\n", tr.flFraction, flMaxFrac ); -#ifndef CLIENT_DLL +#if !CLIENT_DLL while( flDamage > 10 && nMaxHits > 0 ) { nMaxHits--; @@ -442,7 +438,7 @@ void CGauss::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage ) n = -DotProduct( tr.vecPlaneNormal, vecDir ); - if( n < 0.5 ) // 60 degrees + if( n < 0.5f ) // 60 degrees { // ALERT( at_console, "reflect %f\n", n ); // reflect @@ -451,8 +447,8 @@ void CGauss::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage ) r = 2.0 * tr.vecPlaneNormal * n + vecDir; flMaxFrac = flMaxFrac - tr.flFraction; vecDir = r; - vecSrc = tr.vecEndPos + vecDir * 8; - vecDest = vecSrc + vecDir * 8192; + vecSrc = tr.vecEndPos + vecDir * 8.0f; + vecDest = vecSrc + vecDir * 8192.0f; // explode a bit m_pPlayer->RadiusDamage( tr.vecEndPos, pev, m_pPlayer->pev, flDamage * n, CLASS_NONE, DMG_BLAST ); @@ -460,8 +456,8 @@ void CGauss::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage ) nTotal += 34; // lose energy - if( n == 0 ) n = 0.1; - flDamage = flDamage * ( 1 - n ); + if( n == 0.0f ) n = 0.1f; + flDamage = flDamage * ( 1.0f - n ); } else { @@ -485,8 +481,8 @@ void CGauss::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage ) if( n < flDamage ) { - if( n == 0 ) - n = 1; + if( n == 0.0f ) + n = 1.0f; flDamage -= n; // ALERT( at_console, "punch %f\n", n ); @@ -498,16 +494,16 @@ void CGauss::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage ) if( g_pGameRules->IsMultiplayer() ) { - damage_radius = flDamage * 1.75; // Old code == 2.5 + damage_radius = flDamage * 1.75f; // Old code == 2.5 } else { - damage_radius = flDamage * 2.5; + damage_radius = flDamage * 2.5f; } ::RadiusDamage( beam_tr.vecEndPos + vecDir * 8, pev, m_pPlayer->pev, flDamage, damage_radius, CLASS_NONE, DMG_BLAST ); - CSoundEnt::InsertSound( bits_SOUND_COMBAT, pev->origin, NORMAL_EXPLOSION_VOLUME, 3.0 ); + CSoundEnt::InsertSound( bits_SOUND_COMBAT, pev->origin, NORMAL_EXPLOSION_VOLUME, 3.0f ); nTotal += 53; @@ -553,18 +549,18 @@ void CGauss::WeaponIdle( void ) switch( RANDOM_LONG( 0, 3 ) ) { case 0: - EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/electro4.wav", RANDOM_FLOAT( 0.7, 0.8 ), ATTN_NORM ); + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/electro4.wav", RANDOM_FLOAT( 0.7f, 0.8f ), ATTN_NORM ); break; case 1: - EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/electro5.wav", RANDOM_FLOAT( 0.7, 0.8 ), ATTN_NORM ); + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/electro5.wav", RANDOM_FLOAT( 0.7f, 0.8f ), ATTN_NORM ); break; case 2: - EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/electro6.wav", RANDOM_FLOAT( 0.7, 0.8 ), ATTN_NORM ); + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/electro6.wav", RANDOM_FLOAT( 0.7f, 0.8f ), ATTN_NORM ); break; case 3: break; // no sound } - m_pPlayer->m_flPlayAftershock = 0.0; + m_pPlayer->m_flPlayAftershock = 0.0f; } if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) @@ -574,32 +570,28 @@ void CGauss::WeaponIdle( void ) { StartFire(); m_fInAttack = 0; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0; - - // Need to set m_flNextPrimaryAttack so the weapon gets a chance to complete its secondary fire animation. - Solokiller - if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0f; } else { int iAnim; - float flRand = RANDOM_FLOAT( 0, 1 ); - if( flRand <= 0.5 ) + float flRand = RANDOM_FLOAT( 0.0f, 1.0f ); + if( flRand <= 0.5f ) { iAnim = GAUSS_IDLE; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10.0f, 15.0f ); } - else if( flRand <= 0.75 ) + else if( flRand <= 0.75f ) { iAnim = GAUSS_IDLE2; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10.0f, 15.0f ); } else { iAnim = GAUSS_FIDGET; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3.0f; } -#ifndef CLIENT_DLL +#if !CLIENT_DLL SendWeaponAnim( iAnim ); #endif } diff --git a/dlls/ggrenade.cpp b/dlls/ggrenade.cpp index 0ca516c4..5995fe53 100644 --- a/dlls/ggrenade.cpp +++ b/dlls/ggrenade.cpp @@ -26,6 +26,7 @@ #include "nodes.h" #include "soundent.h" #include "decals.h" +#include "game.h" //===================grenade @@ -57,9 +58,12 @@ void CGrenade::Explode( TraceResult *pTrace, int bitsDamageType ) pev->takedamage = DAMAGE_NO; // Pull out of the wall a bit - if( pTrace->flFraction != 1.0 ) + if( pTrace->flFraction != 1.0f ) { - pev->origin = pTrace->vecEndPos + ( pTrace->vecPlaneNormal * ( pev->dmg - 24 ) * 0.6 ); + if (explosionfix.value) + pev->origin = pTrace->vecEndPos + ( pTrace->vecPlaneNormal * 0.6f ); + else + pev->origin = pTrace->vecEndPos + ( pTrace->vecPlaneNormal * ( pev->dmg - 24 ) * 0.6f ); } int iContents = UTIL_PointContents( pev->origin ); @@ -77,7 +81,7 @@ void CGrenade::Explode( TraceResult *pTrace, int bitsDamageType ) { WRITE_SHORT( g_sModelIndexWExplosion ); } - WRITE_BYTE( ( pev->dmg - 50 ) * .60 ); // scale * 10 + WRITE_BYTE( ( pev->dmg - 50 ) * 0.6f ); // scale * 10 WRITE_BYTE( 15 ); // framerate WRITE_BYTE( TE_EXPLFLAG_NONE ); MESSAGE_END(); @@ -93,7 +97,7 @@ void CGrenade::Explode( TraceResult *pTrace, int bitsDamageType ) RadiusDamage( pev, pevOwner, pev->dmg, CLASS_NONE, bitsDamageType ); - if( RANDOM_FLOAT( 0, 1 ) < 0.5 ) + if( RANDOM_FLOAT( 0, 1 ) < 0.5f ) { UTIL_DecalTrace( pTrace, DECAL_SCORCH1 ); } @@ -120,7 +124,7 @@ void CGrenade::Explode( TraceResult *pTrace, int bitsDamageType ) pev->effects |= EF_NODRAW; SetThink( &CGrenade::Smoke ); pev->velocity = g_vecZero; - pev->nextthink = gpGlobals->time + 0.3; + pev->nextthink = gpGlobals->time + 0.3f; if( iContents != CONTENTS_WATER ) { @@ -144,7 +148,7 @@ void CGrenade::Smoke( void ) WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.z ); WRITE_SHORT( g_sModelIndexSmoke ); - WRITE_BYTE( (int)( ( pev->dmg - 50 ) * 0.80 ) ); // scale * 10 + WRITE_BYTE( (int)( ( pev->dmg - 50 ) * 0.8f ) ); // scale * 10 WRITE_BYTE( 12 ); // framerate MESSAGE_END(); } @@ -207,12 +211,12 @@ void CGrenade::DangerSoundThink( void ) return; } - CSoundEnt::InsertSound( bits_SOUND_DANGER, pev->origin + pev->velocity * 0.5, (int)pev->velocity.Length(), 0.2 ); - pev->nextthink = gpGlobals->time + 0.2; + CSoundEnt::InsertSound( bits_SOUND_DANGER, pev->origin + pev->velocity * 0.5f, (int)pev->velocity.Length(), 0.2 ); + pev->nextthink = gpGlobals->time + 0.2f; if( pev->waterlevel != 0 ) { - pev->velocity = pev->velocity * 0.5; + pev->velocity = pev->velocity * 0.5f; } } @@ -233,7 +237,7 @@ void CGrenade::BounceTouch( CBaseEntity *pOther ) pOther->TraceAttack( pevOwner, 1, gpGlobals->v_forward, &tr, DMG_CLUB ); ApplyMultiDamage( pev, pevOwner ); } - m_flNextAttack = gpGlobals->time + 1.0; // debounce + m_flNextAttack = gpGlobals->time + 1.0f; // debounce } Vector vecTestVelocity; @@ -243,7 +247,7 @@ void CGrenade::BounceTouch( CBaseEntity *pOther ) // or thrown very far tend to slow down too quickly for me to always catch just by testing velocity. // trimming the Z velocity a bit seems to help quite a bit. vecTestVelocity = pev->velocity; - vecTestVelocity.z *= 0.45; + vecTestVelocity.z *= 0.45f; if( !m_fRegisteredSound && vecTestVelocity.Length() <= 60 ) { @@ -253,14 +257,14 @@ void CGrenade::BounceTouch( CBaseEntity *pOther ) // go ahead and emit the danger sound. // register a radius louder than the explosion, so we make sure everyone gets out of the way - CSoundEnt::InsertSound( bits_SOUND_DANGER, pev->origin, (int)( pev->dmg / 0.4 ), 0.3 ); + CSoundEnt::InsertSound( bits_SOUND_DANGER, pev->origin, (int)( pev->dmg / 0.4f ), 0.3f ); m_fRegisteredSound = TRUE; } if( pev->flags & FL_ONGROUND ) { // add a bit of static friction - pev->velocity = pev->velocity * 0.8; + pev->velocity = pev->velocity * 0.8f; pev->sequence = RANDOM_LONG( 1, 1 ); } @@ -269,11 +273,11 @@ void CGrenade::BounceTouch( CBaseEntity *pOther ) // play bounce sound BounceSound(); } - pev->framerate = pev->velocity.Length() / 200.0; - if( pev->framerate > 1.0 ) - pev->framerate = 1; - else if( pev->framerate < 0.5 ) - pev->framerate = 0; + pev->framerate = pev->velocity.Length() / 200.0f; + if( pev->framerate > 1.0f ) + pev->framerate = 1.0f; + else if( pev->framerate < 0.5f ) + pev->framerate = 0.0f; } void CGrenade::SlideTouch( CBaseEntity *pOther ) @@ -286,7 +290,7 @@ void CGrenade::SlideTouch( CBaseEntity *pOther ) if( pev->flags & FL_ONGROUND ) { // add a bit of static friction - pev->velocity = pev->velocity * 0.95; + pev->velocity = pev->velocity * 0.95f; if( pev->velocity.x != 0 || pev->velocity.y != 0 ) { @@ -324,7 +328,7 @@ void CGrenade::TumbleThink( void ) } StudioFrameAdvance(); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; if( pev->dmgtime - 1 < gpGlobals->time ) { @@ -337,8 +341,8 @@ void CGrenade::TumbleThink( void ) } if( pev->waterlevel != 0 ) { - pev->velocity = pev->velocity * 0.5; - pev->framerate = 0.2; + pev->velocity = pev->velocity * 0.5f; + pev->framerate = 0.2f; } } @@ -399,21 +403,21 @@ CGrenade *CGrenade::ShootTimed( entvars_t *pevOwner, Vector vecStart, Vector vec pGrenade->pev->dmgtime = gpGlobals->time + time; pGrenade->SetThink( &CGrenade::TumbleThink ); - pGrenade->pev->nextthink = gpGlobals->time + 0.1; - if( time < 0.1 ) + pGrenade->pev->nextthink = gpGlobals->time + 0.1f; + if( time < 0.1f ) { pGrenade->pev->nextthink = gpGlobals->time; pGrenade->pev->velocity = Vector( 0, 0, 0 ); } pGrenade->pev->sequence = RANDOM_LONG( 3, 6 ); - pGrenade->pev->framerate = 1.0; + pGrenade->pev->framerate = 1.0f; // Tumble through the air // pGrenade->pev->avelocity.x = -400; - pGrenade->pev->gravity = 0.5; - pGrenade->pev->friction = 0.8; + pGrenade->pev->gravity = 0.5f; + pGrenade->pev->friction = 0.8f; SET_MODEL( ENT( pGrenade->pev ), "models/w_grenade.mdl" ); pGrenade->pev->dmg = 100; @@ -445,7 +449,7 @@ CGrenade *CGrenade::ShootSatchelCharge( entvars_t *pevOwner, Vector vecStart, Ve pGrenade->SetTouch( &CGrenade::SlideTouch ); pGrenade->pev->spawnflags = SF_DETONATE; - pGrenade->pev->friction = 0.9; + pGrenade->pev->friction = 0.9f; return pGrenade; } diff --git a/dlls/glock.cpp b/dlls/glock.cpp index 89dd189e..d9411d66 100644 --- a/dlls/glock.cpp +++ b/dlls/glock.cpp @@ -106,12 +106,12 @@ BOOL CGlock::Deploy() void CGlock::SecondaryAttack( void ) { - GlockFire( 0.1, 0.2, FALSE ); + GlockFire( 0.1f, 0.2f, FALSE ); } void CGlock::PrimaryAttack( void ) { - GlockFire( 0.01, 0.3, TRUE ); + GlockFire( 0.01f, 0.3f, TRUE ); } void CGlock::GlockFire( float flSpread, float flCycleTime, BOOL fUseAutoAim ) @@ -121,7 +121,7 @@ void CGlock::GlockFire( float flSpread, float flCycleTime, BOOL fUseAutoAim ) if( m_fFireOnEmpty ) { PlayEmptySound(); - m_flNextPrimaryAttack = GetNextAttackDelay( 0.2 ); + m_flNextPrimaryAttack = GetNextAttackDelay( 0.2f ); } return; @@ -132,7 +132,7 @@ void CGlock::GlockFire( float flSpread, float flCycleTime, BOOL fUseAutoAim ) m_pPlayer->pev->effects = (int)( m_pPlayer->pev->effects ) | EF_MUZZLEFLASH; int flags; -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS flags = FEV_NOTHOST; #else flags = 0; @@ -187,9 +187,9 @@ void CGlock::Reload( void ) int iResult; if( m_iClip == 0 ) - iResult = DefaultReload( GLOCK_MAX_CLIP, GLOCK_RELOAD, 1.5 ); + iResult = DefaultReload( GLOCK_MAX_CLIP, GLOCK_RELOAD, 1.5f ); else - iResult = DefaultReload( GLOCK_MAX_CLIP, GLOCK_RELOAD_NOT_EMPTY, 1.5 ); + iResult = DefaultReload( GLOCK_MAX_CLIP, GLOCK_RELOAD_NOT_EMPTY, 1.5f ); if( iResult ) { @@ -212,20 +212,20 @@ void CGlock::WeaponIdle( void ) int iAnim; float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0.0, 1.0 ); - if( flRand <= 0.3 + 0 * 0.75 ) + if( flRand <= 0.3f + 0 * 0.75f ) { iAnim = GLOCK_IDLE3; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 49.0 / 16; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 49.0f / 16.0f; } - else if( flRand <= 0.6 + 0 * 0.875 ) + else if( flRand <= 0.6f + 0 * 0.875f ) { iAnim = GLOCK_IDLE1; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 60.0 / 16.0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 60.0f / 16.0f; } else { iAnim = GLOCK_IDLE2; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 40.0 / 16.0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 40.0f / 16.0f; } SendWeaponAnim( iAnim, 1 ); } diff --git a/dlls/h_ai.cpp b/dlls/h_ai.cpp index d8a35547..0cc5d306 100644 --- a/dlls/h_ai.cpp +++ b/dlls/h_ai.cpp @@ -62,7 +62,7 @@ BOOL FBoxVisible( entvars_t *pevLooker, entvars_t *pevTarget, Vector &vecTargetO UTIL_TraceLine( vecLookerOrigin, vecTarget, ignore_monsters, ignore_glass, ENT( pevLooker )/*pentIgnore*/, &tr ); - if( tr.flFraction == 1.0 ) + if( tr.flFraction == 1.0f ) { vecTargetOrigin = vecTarget; return TRUE;// line of sight is valid. @@ -120,10 +120,10 @@ Vector VecCheckToss( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, fl float distance2 = vecMidPoint.z - vecSpot2.z; // How long will it take for the grenade to travel this distance - float time1 = sqrt( distance1 / ( 0.5 * flGravity ) ); - float time2 = sqrt( distance2 / ( 0.5 * flGravity ) ); + float time1 = sqrt( distance1 / ( 0.5f * flGravity ) ); + float time2 = sqrt( distance2 / ( 0.5f * flGravity ) ); - if( time1 < 0.1 ) + if( time1 < 0.1f ) { // too close return g_vecZero; @@ -139,7 +139,7 @@ Vector VecCheckToss( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, fl vecApex.z = vecMidPoint.z; UTIL_TraceLine( vecSpot1, vecApex, dont_ignore_monsters, ENT( pev ), &tr ); - if( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0f ) { // fail! return g_vecZero; @@ -147,7 +147,7 @@ Vector VecCheckToss( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, fl // UNDONE: either ignore monsters or change it to not care if we hit our enemy UTIL_TraceLine( vecSpot2, vecApex, ignore_monsters, ENT( pev ), &tr ); - if( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0f ) { // fail! return g_vecZero; @@ -168,24 +168,24 @@ Vector VecCheckThrow( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, f // throw at a constant time float time = vecGrenadeVel.Length() / flSpeed; - vecGrenadeVel = vecGrenadeVel * ( 1.0 / time ); + vecGrenadeVel = vecGrenadeVel * ( 1.0f / time ); // adjust upward toss to compensate for gravity loss - vecGrenadeVel.z += flGravity * time * 0.5; + vecGrenadeVel.z += flGravity * time * 0.5f; - Vector vecApex = vecSpot1 + ( vecSpot2 - vecSpot1 ) * 0.5; - vecApex.z += 0.5 * flGravity * ( time * 0.5 ) * ( time * 0.5 ); + Vector vecApex = vecSpot1 + ( vecSpot2 - vecSpot1 ) * 0.5f; + vecApex.z += 0.5f * flGravity * ( time * 0.5f ) * ( time * 0.5f ); TraceResult tr; UTIL_TraceLine( vecSpot1, vecApex, dont_ignore_monsters, ENT( pev ), &tr ); - if( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0f ) { // fail! return g_vecZero; } UTIL_TraceLine( vecSpot2, vecApex, ignore_monsters, ENT( pev ), &tr ); - if( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0f ) { // fail! return g_vecZero; diff --git a/dlls/h_battery.cpp b/dlls/h_battery.cpp index 357f0a87..54c1415a 100644 --- a/dlls/h_battery.cpp +++ b/dlls/h_battery.cpp @@ -60,7 +60,7 @@ TYPEDESCRIPTION CRecharge::m_SaveData[] = DEFINE_FIELD( CRecharge, m_flSoundTime, FIELD_TIME ), }; -IMPLEMENT_SAVERESTORE( CRecharge, CBaseEntity ) +IMPLEMENT_SAVERESTORE( CRecharge, CBaseToggle ) LINK_ENTITY_TO_CLASS( func_recharge, CRecharge ) @@ -106,8 +106,12 @@ void CRecharge::Precache() void CRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { + // Make sure that we have a caller + if( !pActivator ) + return; + // if it's not a player, ignore - if( !FClassnameIs( pActivator->pev, "player" ) ) + if( !pActivator->IsPlayer() ) return; // if there is no juice left, turn it off @@ -122,36 +126,29 @@ void CRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE use { if( m_flSoundTime <= gpGlobals->time ) { - m_flSoundTime = gpGlobals->time + 0.62; + m_flSoundTime = gpGlobals->time + 0.62f; EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/suitchargeno1.wav", 0.85, ATTN_NORM ); } return; } - pev->nextthink = pev->ltime + 0.25; + pev->nextthink = pev->ltime + 0.25f; SetThink( &CRecharge::Off ); // Time to recharge yet? if( m_flNextCharge >= gpGlobals->time ) return; - // Make sure that we have a caller - if( !pActivator ) - return; - m_hActivator = pActivator; - //only recharge the player - if( !m_hActivator->IsPlayer() ) - return; - // Play the on sound or the looping charging sound if( !m_iOn ) { m_iOn++; EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/suitchargeok1.wav", 0.85, ATTN_NORM ); - m_flSoundTime = 0.56 + gpGlobals->time; + m_flSoundTime = 0.56f + gpGlobals->time; } + if( ( m_iOn == 1 ) && ( m_flSoundTime <= gpGlobals->time ) ) { m_iOn++; @@ -169,7 +166,7 @@ void CRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE use } // govern the rate of charge - m_flNextCharge = gpGlobals->time + 0.1; + m_flNextCharge = gpGlobals->time + 0.1f; } void CRecharge::Recharge( void ) diff --git a/dlls/h_cine.cpp b/dlls/h_cine.cpp index bb07e02c..55e7a631 100644 --- a/dlls/h_cine.cpp +++ b/dlls/h_cine.cpp @@ -126,7 +126,7 @@ void CLegacyCineMonster :: CineSpawn( const char *szModel ) if ( FStringNull(pev->targetname) ) { SetThink( &CLegacyCineMonster::CineThink ); - pev->nextthink += 1.0; + pev->nextthink += 1.0f; } } @@ -167,7 +167,7 @@ void CLegacyCineMonster :: CineThink( void ) if (!pev->animtime) ResetSequenceInfo( ); - pev->nextthink = gpGlobals->time + 1.0; + pev->nextthink = gpGlobals->time + 1.0f; if (pev->spawnflags != 0 && m_fSequenceFinished) { @@ -196,14 +196,14 @@ void CCineBlood :: BloodGush ( void ) { Vector vecSplatDir; TraceResult tr; - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; - UTIL_MakeVectors(pev->angles); - if ( pev->health-- < 0 ) - REMOVE_ENTITY(ENT(pev)); + UTIL_MakeVectors( pev->angles ); + if( pev->health-- < 0 ) + REMOVE_ENTITY( ENT( pev ) ); // CHANGE_METHOD ( ENT(pev), em_think, SUB_Remove ); - if ( RANDOM_FLOAT ( 0 , 1 ) < 0.7 )// larger chance of globs + if ( RANDOM_FLOAT ( 0.0f, 1.0f ) < 0.7f )// larger chance of globs { UTIL_BloodDrips( pev->origin, UTIL_RandomBloodVector(), BLOOD_COLOR_RED, 10 ); } @@ -212,13 +212,13 @@ void CCineBlood :: BloodGush ( void ) UTIL_BloodStream( pev->origin, UTIL_RandomBloodVector(), BLOOD_COLOR_RED, RANDOM_LONG(50, 150) ); } - if ( RANDOM_FLOAT ( 0, 1 ) < 0.75 ) + if ( RANDOM_FLOAT ( 0, 1 ) < 0.75f ) { // decals the floor with blood. vecSplatDir = Vector ( 0 , 0 , -1 ); - vecSplatDir = vecSplatDir + (RANDOM_FLOAT(-1,1) * 0.6 * gpGlobals->v_right) + (RANDOM_FLOAT(-1,1) * 0.6 * gpGlobals->v_forward);// randomize a bit + vecSplatDir = vecSplatDir + (RANDOM_FLOAT(-1,1) * 0.6f * gpGlobals->v_right) + (RANDOM_FLOAT(-1,1) * 0.6f * gpGlobals->v_forward);// randomize a bit UTIL_TraceLine( pev->origin + Vector ( 0, 0 , 64) , pev->origin + vecSplatDir * 256, ignore_monsters, ENT(pev), &tr); - if ( tr.flFraction != 1.0 ) + if ( tr.flFraction != 1.0f ) { // Decal with a bloodsplat UTIL_BloodDecalTrace( &tr, BLOOD_COLOR_RED ); diff --git a/dlls/h_cycler.cpp b/dlls/h_cycler.cpp index 5daad4a2..49eff1d8 100644 --- a/dlls/h_cycler.cpp +++ b/dlls/h_cycler.cpp @@ -28,8 +28,8 @@ #include "weapons.h" #include "player.h" -#define TEMP_FOR_SCREEN_SHOTS -#ifdef TEMP_FOR_SCREEN_SHOTS //=================================================== +#define TEMP_FOR_SCREEN_SHOTS 1 +#if TEMP_FOR_SCREEN_SHOTS //=================================================== class CCycler : public CBaseMonster { @@ -96,7 +96,7 @@ void CCycler::GenericCyclerSpawn( const char *szModel, Vector vecMin, Vector vec { if( !szModel || !*szModel ) { - ALERT( at_error, "cycler at %.0f %.0f %0.f missing modelname", pev->origin.x, pev->origin.y, pev->origin.z ); + ALERT( at_error, "cycler at %.0f %.0f %0.f missing modelname", (double)pev->origin.x, (double)pev->origin.y, (double)pev->origin.z ); REMOVE_ENTITY( ENT( pev ) ); return; } @@ -125,7 +125,7 @@ void CCycler::Spawn() m_flFrameRate = 75; m_flGroundSpeed = 0; - pev->nextthink += 1.0; + pev->nextthink += 1.0f; ResetSequenceInfo(); @@ -145,7 +145,7 @@ void CCycler::Spawn() // void CCycler::Think( void ) { - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; if( m_animate ) { @@ -161,7 +161,7 @@ void CCycler::Think( void ) m_flLastEventCheck = gpGlobals->time; pev->frame = 0; if( !m_animate ) - pev->framerate = 0.0; // FIX: don't reset framerate + pev->framerate = 0.0f; // FIX: don't reset framerate } } @@ -172,9 +172,9 @@ void CCycler::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTy { m_animate = !m_animate; if( m_animate ) - pev->framerate = 1.0; + pev->framerate = 1.0f; else - pev->framerate = 0.0; + pev->framerate = 0.0f; } // @@ -189,7 +189,7 @@ int CCycler::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float ResetSequenceInfo(); - if( m_flFrameRate == 0.0 ) + if( m_flFrameRate == 0.0f ) { pev->sequence = 0; ResetSequenceInfo(); @@ -198,10 +198,10 @@ int CCycler::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float } else { - pev->framerate = 1.0; - StudioFrameAdvance( 0.1 ); + pev->framerate = 1.0f; + StudioFrameAdvance( 0.1f ); pev->framerate = 0; - ALERT( at_console, "sequence: %d, frame %.0f\n", pev->sequence, pev->frame ); + ALERT( at_console, "sequence: %d, frame %.0f\n", pev->sequence, (double)pev->frame ); } return 0; @@ -224,7 +224,7 @@ public: inline int ShouldAnimate( void ) { - return m_animate && m_maxFrame > 1.0; + return m_animate && m_maxFrame > 1.0f; } int m_animate; @@ -251,7 +251,7 @@ void CCyclerSprite::Spawn( void ) pev->effects = 0; pev->frame = 0; - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; m_animate = 1; m_lastTime = gpGlobals->time; @@ -266,7 +266,7 @@ void CCyclerSprite::Think( void ) if( ShouldAnimate() ) Animate( pev->framerate * ( gpGlobals->time - m_lastTime ) ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; m_lastTime = gpGlobals->time; } @@ -278,9 +278,9 @@ void CCyclerSprite::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE int CCyclerSprite::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { - if( m_maxFrame > 1.0 ) + if( m_maxFrame > 1.0f ) { - Animate( 1.0 ); + Animate( 1.0f ); } return 1; } @@ -327,7 +327,7 @@ void CWeaponCycler::Spawn() BOOL CWeaponCycler::Deploy() { m_pPlayer->pev->viewmodel = m_iszModel; - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0; + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0f; SendWeaponAnim( 0 ); m_iClip = 0; return TRUE; @@ -335,14 +335,14 @@ BOOL CWeaponCycler::Deploy() void CWeaponCycler::Holster( int skiplocal /* = 0 */ ) { - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5f; } void CWeaponCycler::PrimaryAttack() { SendWeaponAnim( pev->sequence ); - m_flNextPrimaryAttack = gpGlobals->time + 0.3; + m_flNextPrimaryAttack = gpGlobals->time + 0.3f; } void CWeaponCycler::SecondaryAttack( void ) @@ -356,14 +356,14 @@ void CWeaponCycler::SecondaryAttack( void ) GetSequenceInfo( pmodel, pev, &flFrameRate, &flGroundSpeed ); pev->modelindex = 0; - if( flFrameRate == 0.0 ) + if( flFrameRate == 0.0f ) { pev->sequence = 0; } SendWeaponAnim( pev->sequence ); - m_flNextSecondaryAttack = gpGlobals->time + 0.3; + m_flNextSecondaryAttack = gpGlobals->time + 0.3f; } // Flaming Wreakage @@ -397,7 +397,7 @@ void CWreckage::Spawn( void ) pev->effects = 0; pev->frame = 0; - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; if( pev->model ) { @@ -418,7 +418,7 @@ void CWreckage::Precache() void CWreckage::Think( void ) { StudioFrameAdvance(); - pev->nextthink = gpGlobals->time + 0.2; + pev->nextthink = gpGlobals->time + 0.2f; if( pev->dmgtime ) { diff --git a/dlls/h_export.cpp b/dlls/h_export.cpp index d0451906..0feb67c5 100644 --- a/dlls/h_export.cpp +++ b/dlls/h_export.cpp @@ -26,11 +26,10 @@ #include "cbase.h" // Holds engine functionality callbacks -enginefuncs_t g_engfuncs; -globalvars_t *gpGlobals; -server_physics_api_t g_physfuncs; +enginefuncs_t g_engfuncs; +globalvars_t *gpGlobals; -#ifdef _WIN32 +#if _WIN32 // Required DLL entry point BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) diff --git a/dlls/handgrenade.cpp b/dlls/handgrenade.cpp index c2bbd7f9..f9f360ec 100644 --- a/dlls/handgrenade.cpp +++ b/dlls/handgrenade.cpp @@ -43,7 +43,7 @@ void CHandGrenade::Spawn() m_iId = WEAPON_HANDGRENADE; SET_MODEL( ENT( pev ), "models/w_grenade.mdl" ); -#ifndef CLIENT_DLL +#if !CLIENT_DLL pev->dmg = gSkillData.plrDmgHandGrenade; #endif m_iDefaultAmmo = HANDGRENADE_DEFAULT_GIVE; @@ -89,7 +89,7 @@ BOOL CHandGrenade::CanHolster( void ) void CHandGrenade::Holster( int skiplocal /* = 0 */ ) { - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5f; if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { @@ -104,11 +104,11 @@ void CHandGrenade::Holster( int skiplocal /* = 0 */ ) if( m_flStartThrow ) { - m_flStartThrow = 0; - m_flReleaseThrow = 0; + m_flStartThrow = 0.0f; + m_flReleaseThrow = 0.0f; } - EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM ); + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "common/null.wav", 1.0f, ATTN_NORM ); } void CHandGrenade::PrimaryAttack() @@ -116,16 +116,16 @@ void CHandGrenade::PrimaryAttack() if( !m_flStartThrow && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] > 0 ) { m_flStartThrow = gpGlobals->time; - m_flReleaseThrow = 0; + m_flReleaseThrow = 0.0f; SendWeaponAnim( HANDGRENADE_PINPULL ); - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5f; } } void CHandGrenade::WeaponIdle( void ) { - if( m_flReleaseThrow == 0 && m_flStartThrow ) + if( m_flReleaseThrow == 0.0f && m_flStartThrow ) m_flReleaseThrow = gpGlobals->time; if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) @@ -135,33 +135,33 @@ void CHandGrenade::WeaponIdle( void ) { Vector angThrow = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle; - if( angThrow.x < 0 ) - angThrow.x = -10 + angThrow.x * ( ( 90 - 10 ) / 90.0 ); + if( angThrow.x < 0.0f ) + angThrow.x = -10.0f + angThrow.x * ( ( 90.0f - 10.0f ) / 90.0f ); else - angThrow.x = -10 + angThrow.x * ( ( 90 + 10 ) / 90.0 ); + angThrow.x = -10.0f + angThrow.x * ( ( 90.0f + 10.0f ) / 90.0f ); - float flVel = ( 90 - angThrow.x ) * 4; - if( flVel > 500 ) - flVel = 500; + float flVel = ( 90.0f - angThrow.x ) * 4.0f; + if( flVel > 500.0f ) + flVel = 500.0f; UTIL_MakeVectors( angThrow ); - Vector vecSrc = m_pPlayer->pev->origin + m_pPlayer->pev->view_ofs + gpGlobals->v_forward * 16; + Vector vecSrc = m_pPlayer->pev->origin + m_pPlayer->pev->view_ofs + gpGlobals->v_forward * 16.0f; Vector vecThrow = gpGlobals->v_forward * flVel + m_pPlayer->pev->velocity; // alway explode 3 seconds after the pin was pulled - float time = m_flStartThrow - gpGlobals->time + 3.0; - if( time < 0 ) - time = 0; + float time = m_flStartThrow - gpGlobals->time + 3.0f; + if( time < 0.0f ) + time = 0.0f; CGrenade::ShootTimed( m_pPlayer->pev, vecSrc, vecThrow, time ); - if( flVel < 500 ) + if( flVel < 500.0f ) { SendWeaponAnim( HANDGRENADE_THROW1 ); } - else if( flVel < 1000 ) + else if( flVel < 1000.0f ) { SendWeaponAnim( HANDGRENADE_THROW2 ); } @@ -173,10 +173,12 @@ void CHandGrenade::WeaponIdle( void ) // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); - m_flReleaseThrow = 0; - m_flStartThrow = 0; - m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; +#if !HANDGRENADE_DEPLOY_FIX + m_flReleaseThrow = 0.0f; +#endif + m_flStartThrow = 0.0f; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.5f ); + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5f; m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; @@ -185,14 +187,14 @@ void CHandGrenade::WeaponIdle( void ) // just threw last grenade // set attack times in the future, and weapon idle in the future so we can see the whole throw // animation, weapon idle will automatically retire the weapon for us. - m_flTimeWeaponIdle = m_flNextSecondaryAttack = m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 );// ensure that the animation can finish playing + m_flTimeWeaponIdle = m_flNextSecondaryAttack = m_flNextPrimaryAttack = GetNextAttackDelay( 0.5f );// ensure that the animation can finish playing } return; } - else if( m_flReleaseThrow > 0 ) + else if( m_flReleaseThrow > 0.0f ) { // we've finished the throw, restart. - m_flStartThrow = 0; + m_flStartThrow = 0.0f; if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { @@ -204,24 +206,24 @@ void CHandGrenade::WeaponIdle( void ) return; } - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); - m_flReleaseThrow = -1; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10.0f, 15.0f ); + m_flReleaseThrow = -1.0f; return; } if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { int iAnim; - float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 ); - if( flRand <= 0.75 ) + float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0.0f, 1.0f ); + if( flRand <= 0.75f ) { iAnim = HANDGRENADE_IDLE; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );// how long till we do this again. + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10.0f, 15.0f );// how long till we do this again. } else { iAnim = HANDGRENADE_FIDGET; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 75.0 / 30.0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 75.0f / 30.0f; } SendWeaponAnim( iAnim ); diff --git a/dlls/hassassin.cpp b/dlls/hassassin.cpp index f51ed4cb..36672d56 100644 --- a/dlls/hassassin.cpp +++ b/dlls/hassassin.cpp @@ -12,7 +12,7 @@ * use or distribution of this code by or to any unlicensed person is illegal. * ****/ -#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD ) +#if !OEM_BUILD && !HLDEMO_BUILD //========================================================= // hassassin - Human assassin, fast and stealthy @@ -193,15 +193,15 @@ void CHAssassin::Shoot( void ) Vector vecShootOrigin = GetGunPosition(); Vector vecShootDir = ShootAtEnemy( vecShootOrigin ); - if( m_flLastShot + 2 < gpGlobals->time ) + if( m_flLastShot + 2.0f < gpGlobals->time ) { - m_flDiviation = 0.10; + m_flDiviation = 0.10f; } else { - m_flDiviation -= 0.01; - if( m_flDiviation < 0.02 ) - m_flDiviation = 0.02; + m_flDiviation -= 0.01f; + if( m_flDiviation < 0.02f ) + m_flDiviation = 0.02f; } m_flLastShot = gpGlobals->time; @@ -214,10 +214,10 @@ void CHAssassin::Shoot( void ) switch( RANDOM_LONG( 0, 1 ) ) { case 0: - EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "weapons/pl_gun1.wav", RANDOM_FLOAT( 0.6, 0.8 ), ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "weapons/pl_gun1.wav", RANDOM_FLOAT( 0.6f, 0.8f ), ATTN_NORM ); break; case 1: - EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "weapons/pl_gun2.wav", RANDOM_FLOAT( 0.6, 0.8 ), ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "weapons/pl_gun2.wav", RANDOM_FLOAT( 0.6f, 0.8f ), ATTN_NORM ); break; } @@ -247,7 +247,7 @@ void CHAssassin::HandleAnimEvent( MonsterEvent_t *pEvent ) UTIL_MakeVectors( pev->angles ); CGrenade::ShootTimed( pev, pev->origin + gpGlobals->v_forward * 34 + Vector( 0, 0, 32 ), m_vecTossVelocity, 2.0 ); - m_flNextGrenadeCheck = gpGlobals->time + 6;// wait six seconds before even looking again to see if a grenade can be thrown. + m_flNextGrenadeCheck = gpGlobals->time + 6.0f;// wait six seconds before even looking again to see if a grenade can be thrown. m_fThrowGrenade = FALSE; // !!!LATER - when in a group, only try to throw grenade if ordered. } @@ -259,7 +259,7 @@ void CHAssassin::HandleAnimEvent( MonsterEvent_t *pEvent ) pev->movetype = MOVETYPE_TOSS; pev->flags &= ~FL_ONGROUND; pev->velocity = m_vecJumpVelocity; - m_flNextJump = gpGlobals->time + 3.0; + m_flNextJump = gpGlobals->time + 3.0f; } return; default: @@ -597,7 +597,7 @@ IMPLEMENT_CUSTOM_SCHEDULES( CHAssassin, CBaseMonster ) //========================================================= BOOL CHAssassin::CheckMeleeAttack1( float flDot, float flDist ) { - if( m_flNextJump < gpGlobals->time && ( flDist <= 128 || HasMemory( bits_MEMORY_BADJUMP ) ) && m_hEnemy != 0 ) + if( m_flNextJump < gpGlobals->time && ( flDist <= 128.0f || HasMemory( bits_MEMORY_BADJUMP ) ) && m_hEnemy != 0 ) { TraceResult tr; @@ -605,15 +605,15 @@ BOOL CHAssassin::CheckMeleeAttack1( float flDot, float flDist ) UTIL_TraceHull( pev->origin + Vector( 0, 0, 36 ), vecDest + Vector( 0, 0, 36 ), dont_ignore_monsters, human_hull, ENT( pev ), &tr ); - if( tr.fStartSolid || tr.flFraction < 1.0 ) + if( tr.fStartSolid || tr.flFraction < 1.0f ) { return FALSE; } float flGravity = g_psv_gravity->value; - float time = sqrt( 160 / ( 0.5 * flGravity ) ); - float speed = flGravity * time / 160; + float time = sqrt( 160.0f / ( 0.5f * flGravity ) ); + float speed = flGravity * time / 160.0f; m_vecJumpVelocity = ( vecDest - pev->origin ) * speed; return TRUE; diff --git a/dlls/headcrab.cpp b/dlls/headcrab.cpp index 60e03c10..dea97ebe 100644 --- a/dlls/headcrab.cpp +++ b/dlls/headcrab.cpp @@ -170,7 +170,7 @@ int CHeadCrab::Classify( void ) //========================================================= Vector CHeadCrab::Center( void ) { - return Vector( pev->origin.x, pev->origin.y, pev->origin.z + 6 ); + return Vector( pev->origin.x, pev->origin.y, pev->origin.z + 6.0f ); } Vector CHeadCrab::BodyTarget( const Vector &posSrc ) @@ -241,7 +241,7 @@ void CHeadCrab::HandleAnimEvent( MonsterEvent_t *pEvent ) // Scale the sideways velocity to get there at the right time vecJumpDir = m_hEnemy->pev->origin + m_hEnemy->pev->view_ofs - pev->origin; - vecJumpDir = vecJumpDir * ( 1.0 / time ); + vecJumpDir = vecJumpDir * ( 1.0f / time ); // Speed to offset gravity at the desired height vecJumpDir.z = speed; @@ -249,23 +249,23 @@ void CHeadCrab::HandleAnimEvent( MonsterEvent_t *pEvent ) // Don't jump too far/fast float distance = vecJumpDir.Length(); - if( distance > 650 ) + if( distance > 650.0f ) { - vecJumpDir = vecJumpDir * ( 650.0 / distance ); + vecJumpDir = vecJumpDir * ( 650.0f / distance ); } } else { // jump hop, don't care where - vecJumpDir = Vector( gpGlobals->v_forward.x, gpGlobals->v_forward.y, gpGlobals->v_up.z ) * 350; + vecJumpDir = Vector( gpGlobals->v_forward.x, gpGlobals->v_forward.y, gpGlobals->v_up.z ) * 350.0f; } - int iSound = RANDOM_LONG(0,2); + int iSound = RANDOM_LONG( 0, 2 ); if( iSound != 0 ) EMIT_SOUND_DYN( edict(), CHAN_VOICE, pAttackSounds[iSound], GetSoundVolue(), ATTN_IDLE, 0, GetVoicePitch() ); pev->velocity = vecJumpDir; - m_flNextAttack = gpGlobals->time + 2; + m_flNextAttack = gpGlobals->time + 2.0f; } break; default: @@ -370,7 +370,7 @@ void CHeadCrab::LeapTouch( CBaseEntity *pOther ) void CHeadCrab::PrescheduleThink( void ) { // make the crab coo a little bit in combat state - if( m_MonsterState == MONSTERSTATE_COMBAT && RANDOM_FLOAT( 0, 5 ) < 0.1 ) + if( m_MonsterState == MONSTERSTATE_COMBAT && RANDOM_FLOAT( 0, 5 ) < 0.1f ) { IdleSound(); } @@ -401,7 +401,7 @@ void CHeadCrab::StartTask( Task_t *pTask ) //========================================================= BOOL CHeadCrab::CheckRangeAttack1( float flDot, float flDist ) { - if( FBitSet( pev->flags, FL_ONGROUND ) && flDist <= 256 && flDot >= 0.65 ) + if( FBitSet( pev->flags, FL_ONGROUND ) && flDist <= 256 && flDot >= 0.65f ) { return TRUE; } @@ -416,7 +416,7 @@ BOOL CHeadCrab::CheckRangeAttack2( float flDot, float flDist ) return FALSE; // BUGBUG: Why is this code here? There is no ACT_RANGE_ATTACK2 animation. I've disabled it for now. #if 0 - if( FBitSet( pev->flags, FL_ONGROUND ) && flDist > 64 && flDist <= 256 && flDot >= 0.5 ) + if( FBitSet( pev->flags, FL_ONGROUND ) && flDist > 64 && flDist <= 256 && flDot >= 0.5f ) { return TRUE; } @@ -487,11 +487,11 @@ public: void Spawn( void ); void Precache( void ); void SetYawSpeed( void ); - float GetDamageAmount( void ) { return gSkillData.headcrabDmgBite * 0.3; } + float GetDamageAmount( void ) { return gSkillData.headcrabDmgBite * 0.3f; } BOOL CheckRangeAttack1( float flDot, float flDist ); Schedule_t *GetScheduleOfType ( int Type ); virtual int GetVoicePitch( void ) { return PITCH_NORM + RANDOM_LONG( 40, 50 ); } - virtual float GetSoundVolue( void ) { return 0.8; } + virtual float GetSoundVolue( void ) { return 0.8f; } }; LINK_ENTITY_TO_CLASS( monster_babycrab, CBabyCrab ) @@ -504,7 +504,7 @@ void CBabyCrab::Spawn( void ) pev->renderamt = 192; UTIL_SetSize( pev, Vector( -12, -12, 0 ), Vector( 12, 12, 24 ) ); - pev->health = gSkillData.headcrabHealth * 0.25; // less health than full grown + pev->health = gSkillData.headcrabHealth * 0.25f; // less health than full grown } void CBabyCrab::Precache( void ) @@ -526,7 +526,7 @@ BOOL CBabyCrab::CheckRangeAttack1( float flDot, float flDist ) return TRUE; // A little less accurate, but jump from closer - if( flDist <= 180 && flDot >= 0.55 ) + if( flDist <= 180.0f && flDot >= 0.55f ) return TRUE; } diff --git a/dlls/healthkit.cpp b/dlls/healthkit.cpp index e1744479..37e4624a 100644 --- a/dlls/healthkit.cpp +++ b/dlls/healthkit.cpp @@ -127,7 +127,7 @@ TYPEDESCRIPTION CWallHealth::m_SaveData[] = DEFINE_FIELD( CWallHealth, m_flSoundTime, FIELD_TIME ), }; -IMPLEMENT_SAVERESTORE( CWallHealth, CBaseEntity ) +IMPLEMENT_SAVERESTORE( CWallHealth, CBaseToggle ) LINK_ENTITY_TO_CLASS( func_healthcharger, CWallHealth ) @@ -192,13 +192,13 @@ void CWallHealth::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE u { if( m_flSoundTime <= gpGlobals->time ) { - m_flSoundTime = gpGlobals->time + 0.62; + m_flSoundTime = gpGlobals->time + 0.62f; EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/medshotno1.wav", 1.0, ATTN_NORM ); } return; } - pev->nextthink = pev->ltime + 0.25; + pev->nextthink = pev->ltime + 0.25f; SetThink( &CWallHealth::Off ); // Time to recharge yet? @@ -210,7 +210,7 @@ void CWallHealth::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE u { m_iOn++; EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/medshot4.wav", 1.0, ATTN_NORM ); - m_flSoundTime = 0.56 + gpGlobals->time; + m_flSoundTime = 0.56f + gpGlobals->time; } if( ( m_iOn == 1 ) && ( m_flSoundTime <= gpGlobals->time ) ) { @@ -225,7 +225,7 @@ void CWallHealth::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE u } // govern the rate of charge - m_flNextCharge = gpGlobals->time + 0.1; + m_flNextCharge = gpGlobals->time + 0.1f; } void CWallHealth::Recharge( void ) diff --git a/dlls/hgrunt.cpp b/dlls/hgrunt.cpp index 62c947f1..7f7e39e5 100644 --- a/dlls/hgrunt.cpp +++ b/dlls/hgrunt.cpp @@ -356,7 +356,7 @@ BOOL CHGrunt::FOkToSpeak( void ) //========================================================= void CHGrunt::JustSpoke( void ) { - CTalkMonster::g_talkWaitTime = gpGlobals->time + RANDOM_FLOAT( 1.5, 2.0 ); + CTalkMonster::g_talkWaitTime = gpGlobals->time + RANDOM_FLOAT( 1.5f, 2.0f ); m_iSentence = HGRUNT_SENT_NONE; } @@ -375,7 +375,7 @@ void CHGrunt::PrescheduleThink( void ) } else { - if( gpGlobals->time - MySquadLeader()->m_flLastEnemySightTime > 5 ) + if( gpGlobals->time - MySquadLeader()->m_flLastEnemySightTime > 5.0f ) { // been a while since we've seen the enemy MySquadLeader()->m_fEnemyEluded = TRUE; @@ -423,13 +423,13 @@ BOOL CHGrunt::CheckMeleeAttack1( float flDot, float flDist ) { return FALSE; } - } - if( flDist <= 64 && flDot >= 0.7 && - pEnemy->Classify() != CLASS_ALIEN_BIOWEAPON && - pEnemy->Classify() != CLASS_PLAYER_BIOWEAPON ) - { - return TRUE; + if( flDist <= 64.0f && flDot >= 0.7f && + pEnemy->Classify() != CLASS_ALIEN_BIOWEAPON && + pEnemy->Classify() != CLASS_PLAYER_BIOWEAPON ) + { + return TRUE; + } } return FALSE; } @@ -444,7 +444,7 @@ BOOL CHGrunt::CheckMeleeAttack1( float flDot, float flDist ) //========================================================= BOOL CHGrunt::CheckRangeAttack1( float flDot, float flDist ) { - if( !HasConditions( bits_COND_ENEMY_OCCLUDED ) && flDist <= 2048 && flDot >= 0.5 && NoFriendlyFire() ) + if( !HasConditions( bits_COND_ENEMY_OCCLUDED ) && flDist <= 2048.0f && flDot >= 0.5f && NoFriendlyFire() ) { TraceResult tr; @@ -459,7 +459,7 @@ BOOL CHGrunt::CheckRangeAttack1( float flDot, float flDist ) // verify that a bullet fired from the gun will hit the enemy before the world. UTIL_TraceLine( vecSrc, m_hEnemy->BodyTarget( vecSrc ), ignore_monsters, ignore_glass, ENT( pev ), &tr ); - if( tr.flFraction == 1.0 ) + if( tr.flFraction == 1.0f ) { return TRUE; } @@ -541,7 +541,7 @@ BOOL CHGrunt::CheckRangeAttack2( float flDot, float flDist ) } } - if( ( vecTarget - pev->origin ).Length2D() <= 256 ) + if( ( vecTarget - pev->origin ).Length2D() <= 256.0f ) { // crap, I don't want to blow myself up m_flNextGrenadeCheck = gpGlobals->time + 1; // one full second. @@ -567,7 +567,7 @@ BOOL CHGrunt::CheckRangeAttack2( float flDot, float flDist ) // don't throw m_fThrowGrenade = FALSE; // don't check again for a while. - m_flNextGrenadeCheck = gpGlobals->time + 1; // one full second. + m_flNextGrenadeCheck = gpGlobals->time + 1.0f; // one full second. } } else @@ -581,14 +581,14 @@ BOOL CHGrunt::CheckRangeAttack2( float flDot, float flDist ) // throw a hand grenade m_fThrowGrenade = TRUE; // don't check again for a while. - m_flNextGrenadeCheck = gpGlobals->time + 0.3; // 1/3 second. + m_flNextGrenadeCheck = gpGlobals->time + 0.3f; // 1/3 second. } else { // don't throw m_fThrowGrenade = FALSE; // don't check again for a while. - m_flNextGrenadeCheck = gpGlobals->time + 1; // one full second. + m_flNextGrenadeCheck = gpGlobals->time + 1.0f; // one full second. } } @@ -611,7 +611,7 @@ void CHGrunt::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir if( flDamage <= 0 ) { UTIL_Ricochet( ptr->vecEndPos, 1.0 ); - flDamage = 0.01; + flDamage = 0.01f; } } // it's head shot anyways @@ -752,7 +752,7 @@ CBaseEntity *CHGrunt::Kick( void ) UTIL_MakeVectors( pev->angles ); Vector vecStart = pev->origin; - vecStart.z += pev->size.z * 0.5; + vecStart.z += pev->size.z * 0.5f; Vector vecEnd = vecStart + ( gpGlobals->v_forward * 70 ); UTIL_TraceHull( vecStart, vecEnd, dont_ignore_monsters, head_hull, ENT( pev ), &tr ); @@ -895,9 +895,9 @@ void CHGrunt::HandleAnimEvent( MonsterEvent_t *pEvent ) CGrenade::ShootContact( pev, GetGunPosition(), m_vecTossVelocity ); m_fThrowGrenade = FALSE; if( g_iSkillLevel == SKILL_HARD ) - m_flNextGrenadeCheck = gpGlobals->time + RANDOM_FLOAT( 2, 5 );// wait a random amount of time before shooting again + m_flNextGrenadeCheck = gpGlobals->time + RANDOM_FLOAT( 2.0f, 5.0f );// wait a random amount of time before shooting again else - m_flNextGrenadeCheck = gpGlobals->time + 6;// wait six seconds before even looking again to see if a grenade can be thrown. + m_flNextGrenadeCheck = gpGlobals->time + 6.0f;// wait six seconds before even looking again to see if a grenade can be thrown. } break; case HGRUNT_AE_GREN_DROP: @@ -2392,7 +2392,7 @@ void CHGruntRepel::RepelUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_ pBeam->SetFlags( BEAM_FSOLID ); pBeam->SetColor( 255, 255, 255 ); pBeam->SetThink( &CBaseEntity::SUB_Remove ); - pBeam->pev->nextthink = gpGlobals->time + -4096.0 * tr.flFraction / pGrunt->pev->velocity.z + 0.5; + pBeam->pev->nextthink = gpGlobals->time + -4096.0f * tr.flFraction / pGrunt->pev->velocity.z + 0.5f; UTIL_Remove( this ); } diff --git a/dlls/hl.dsp b/dlls/hl.dsp deleted file mode 100644 index 7985e2e6..00000000 --- a/dlls/hl.dsp +++ /dev/null @@ -1,747 +0,0 @@ -# Microsoft Developer Studio Project File - Name="hl" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=hl - Win32 Release -!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 "hl.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 "hl.mak" CFG="hl - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "hl - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "hl - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "hl - Win32 Profile" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "hl - 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 "..\temp\dlls\!release" -# PROP Intermediate_Dir "..\temp\dlls\!release" -# PROP Ignore_Export_Lib 1 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /G5 /MT /W3 /O2 /I "..\dlls" /I "..\engine" /I "..\common" /I "..\pm_shared" /I "..\game_shared" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "QUIVER" /D "VOXEL" /D "QUAKE2" /D "VALVE_DLL" /D "CLIENT_WEAPONS" /Fr /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /dll /debug /machine:I386 /def:".\hl.def" -# SUBTRACT LINK32 /profile /map -# Begin Custom Build -TargetDir=\Xash3D\src_main\temp\dlls\!release -InputPath=\Xash3D\src_main\temp\dlls\!release\hl.dll -SOURCE="$(InputPath)" - -"D:\Xash3D\valve\dlls\hl.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - copy $(TargetDir)\hl.dll "D:\Xash3D\valve\dlls\hl.dll" - -# End Custom Build - -!ELSEIF "$(CFG)" == "hl - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir ".\hl___Win" -# PROP BASE Intermediate_Dir ".\hl___Win" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "..\temp\dlls\!debug" -# PROP Intermediate_Dir "..\temp\dlls\!debug" -# PROP Ignore_Export_Lib 1 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /G5 /MTd /W3 /Gm /ZI /Od /I "..\dlls" /I "..\engine" /I "..\common" /I "..\game_shared" /I "..\pm_shared" /I "..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "QUIVER" /D "VOXEL" /D "QUAKE2" /D "VALVE_DLL" /D "CLIENT_WEAPONS" /FR /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /i "..\engine" /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 -# ADD LINK32 user32.lib advapi32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /def:".\hl.def" -# SUBTRACT LINK32 /profile -# Begin Custom Build -TargetDir=\Xash3D\src_main\temp\dlls\!debug -InputPath=\Xash3D\src_main\temp\dlls\!debug\hl.dll -SOURCE="$(InputPath)" - -"D:\Xash3D\valve\dlls\hl.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - copy $(TargetDir)\hl.dll "D:\Xash3D\valve\dlls\hl.dll" - -# End Custom Build - -!ELSEIF "$(CFG)" == "hl - Win32 Profile" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir ".\hl___Win" -# PROP BASE Intermediate_Dir ".\hl___Win" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "..\temp\dlls\!profile" -# PROP Intermediate_Dir "..\temp\dlls\!profile" -# PROP Ignore_Export_Lib 1 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /G5 /MT /W3 /GX /Zi /O2 /I "..\engine" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "QUIVER" /D "VOXEL" /D "QUAKE2" /D "VALVE_DLL" /YX /c -# SUBTRACT BASE CPP /Fr -# ADD CPP /nologo /G5 /MT /W3 /Zi /O2 /I "..\dlls" /I "..\engine" /I "..\common" /I "..\pm_shared" /I "..\game_shared" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "QUIVER" /D "VOXEL" /D "QUAKE2" /D "VALVE_DLL" /D "CLIENT_WEAPONS" /YX /FD /c -# SUBTRACT CPP /Fr -# ADD BASE MTL /nologo /D "NDEBUG" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /dll /debug /machine:I386 /def:".\hl.def" -# SUBTRACT BASE LINK32 /profile -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /dll /profile /debug /machine:I386 /def:".\hl.def" -# Begin Custom Build -TargetDir=\Xash3D\src_main\temp\dlls\!profile -InputPath=\Xash3D\src_main\temp\dlls\!profile\hl.dll -SOURCE="$(InputPath)" - -"D:\Xash3D\valve\dlls\hl.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - copy $(TargetDir)\hl.dll "D:\Xash3D\valve\dlls\hl.dll" - -# End Custom Build - -!ENDIF - -# Begin Target - -# Name "hl - Win32 Release" -# Name "hl - Win32 Debug" -# Name "hl - Win32 Profile" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90" -# Begin Source File - -SOURCE=.\aflock.cpp -# End Source File -# Begin Source File - -SOURCE=.\agrunt.cpp -# End Source File -# Begin Source File - -SOURCE=.\airtank.cpp -# End Source File -# Begin Source File - -SOURCE=.\animating.cpp -# End Source File -# Begin Source File - -SOURCE=.\animation.cpp -# End Source File -# Begin Source File - -SOURCE=.\apache.cpp -# End Source File -# Begin Source File - -SOURCE=.\barnacle.cpp -# End Source File -# Begin Source File - -SOURCE=.\barney.cpp -# End Source File -# Begin Source File - -SOURCE=.\bigmomma.cpp -# End Source File -# Begin Source File - -SOURCE=.\bloater.cpp -# End Source File -# Begin Source File - -SOURCE=.\bmodels.cpp -# End Source File -# Begin Source File - -SOURCE=.\bullsquid.cpp -# End Source File -# Begin Source File - -SOURCE=.\buttons.cpp -# End Source File -# Begin Source File - -SOURCE=.\cbase.cpp -# End Source File -# Begin Source File - -SOURCE=.\client.cpp -# End Source File -# Begin Source File - -SOURCE=.\combat.cpp -# End Source File -# Begin Source File - -SOURCE=.\controller.cpp -# End Source File -# Begin Source File - -SOURCE=.\crossbow.cpp -# End Source File -# Begin Source File - -SOURCE=.\crowbar.cpp -# End Source File -# Begin Source File - -SOURCE=.\defaultai.cpp -# End Source File -# Begin Source File - -SOURCE=.\doors.cpp -# End Source File -# Begin Source File - -SOURCE=.\effects.cpp -# End Source File -# Begin Source File - -SOURCE=.\egon.cpp -# End Source File -# Begin Source File - -SOURCE=.\explode.cpp -# End Source File -# Begin Source File - -SOURCE=.\flyingmonster.cpp -# End Source File -# Begin Source File - -SOURCE=.\func_break.cpp -# End Source File -# Begin Source File - -SOURCE=.\func_tank.cpp -# End Source File -# Begin Source File - -SOURCE=.\game.cpp -# End Source File -# Begin Source File - -SOURCE=.\gamerules.cpp -# End Source File -# Begin Source File - -SOURCE=.\gargantua.cpp -# End Source File -# Begin Source File - -SOURCE=.\gauss.cpp -# End Source File -# Begin Source File - -SOURCE=.\genericmonster.cpp -# End Source File -# Begin Source File - -SOURCE=.\ggrenade.cpp -# End Source File -# Begin Source File - -SOURCE=.\globals.cpp -# End Source File -# Begin Source File - -SOURCE=.\glock.cpp -# End Source File -# Begin Source File - -SOURCE=.\gman.cpp -# End Source File -# Begin Source File - -SOURCE=.\h_ai.cpp -# End Source File -# Begin Source File - -SOURCE=.\h_battery.cpp -# End Source File -# Begin Source File - -SOURCE=.\h_cine.cpp -# End Source File -# Begin Source File - -SOURCE=.\h_cycler.cpp -# End Source File -# Begin Source File - -SOURCE=.\h_export.cpp -# End Source File -# Begin Source File - -SOURCE=.\handgrenade.cpp -# End Source File -# Begin Source File - -SOURCE=.\hassassin.cpp -# End Source File -# Begin Source File - -SOURCE=.\headcrab.cpp -# End Source File -# Begin Source File - -SOURCE=.\healthkit.cpp -# End Source File -# Begin Source File - -SOURCE=.\hgrunt.cpp -# End Source File -# Begin Source File - -SOURCE=.\hornet.cpp -# End Source File -# Begin Source File - -SOURCE=.\hornetgun.cpp -# End Source File -# Begin Source File - -SOURCE=.\houndeye.cpp -# End Source File -# Begin Source File - -SOURCE=.\ichthyosaur.cpp -# End Source File -# Begin Source File - -SOURCE=.\islave.cpp -# End Source File -# Begin Source File - -SOURCE=.\items.cpp -# End Source File -# Begin Source File - -SOURCE=.\leech.cpp -# End Source File -# Begin Source File - -SOURCE=.\lights.cpp -# End Source File -# Begin Source File - -SOURCE=.\maprules.cpp -# End Source File -# Begin Source File - -SOURCE=.\monstermaker.cpp -# End Source File -# Begin Source File - -SOURCE=.\monsters.cpp -# End Source File -# Begin Source File - -SOURCE=.\monsterstate.cpp -# End Source File -# Begin Source File - -SOURCE=.\mortar.cpp -# End Source File -# Begin Source File - -SOURCE=.\mp5.cpp -# End Source File -# Begin Source File - -SOURCE=.\multiplay_gamerules.cpp -# End Source File -# Begin Source File - -SOURCE=.\nihilanth.cpp -# End Source File -# Begin Source File - -SOURCE=.\nodes.cpp -# End Source File -# Begin Source File - -SOURCE=.\osprey.cpp -# End Source File -# Begin Source File - -SOURCE=.\pathcorner.cpp -# End Source File -# Begin Source File - -SOURCE=.\plane.cpp -# End Source File -# Begin Source File - -SOURCE=.\plats.cpp -# End Source File -# Begin Source File - -SOURCE=.\player.cpp -# End Source File -# Begin Source File - -SOURCE=..\pm_shared\pm_debug.c -# End Source File -# Begin Source File - -SOURCE=..\pm_shared\pm_math.c -# End Source File -# Begin Source File - -SOURCE=..\pm_shared\pm_shared.c -# End Source File -# Begin Source File - -SOURCE=.\python.cpp -# End Source File -# Begin Source File - -SOURCE=.\rat.cpp -# End Source File -# Begin Source File - -SOURCE=.\roach.cpp -# End Source File -# Begin Source File - -SOURCE=.\rpg.cpp -# End Source File -# Begin Source File - -SOURCE=.\satchel.cpp -# End Source File -# Begin Source File - -SOURCE=.\schedule.cpp -# End Source File -# Begin Source File - -SOURCE=.\scientist.cpp -# End Source File -# Begin Source File - -SOURCE=.\scripted.cpp -# End Source File -# Begin Source File - -SOURCE=.\shotgun.cpp -# End Source File -# Begin Source File - -SOURCE=.\singleplay_gamerules.cpp -# End Source File -# Begin Source File - -SOURCE=.\skill.cpp -# End Source File -# Begin Source File - -SOURCE=.\sound.cpp -# End Source File -# Begin Source File - -SOURCE=.\soundent.cpp -# End Source File -# Begin Source File - -SOURCE=.\spectator.cpp -# End Source File -# Begin Source File - -SOURCE=.\squadmonster.cpp -# End Source File -# Begin Source File - -SOURCE=.\squeakgrenade.cpp -# End Source File -# Begin Source File - -SOURCE=.\subs.cpp -# End Source File -# Begin Source File - -SOURCE=.\talkmonster.cpp -# End Source File -# Begin Source File - -SOURCE=.\teamplay_gamerules.cpp -# End Source File -# Begin Source File - -SOURCE=.\tempmonster.cpp -# End Source File -# Begin Source File - -SOURCE=.\tentacle.cpp -# End Source File -# Begin Source File - -SOURCE=.\triggers.cpp -# End Source File -# Begin Source File - -SOURCE=.\tripmine.cpp -# End Source File -# Begin Source File - -SOURCE=.\turret.cpp -# End Source File -# Begin Source File - -SOURCE=.\util.cpp -# End Source File -# Begin Source File - -SOURCE=..\game_shared\voice_gamemgr.cpp -# End Source File -# Begin Source File - -SOURCE=.\weapons.cpp -# End Source File -# Begin Source File - -SOURCE=.\world.cpp -# End Source File -# Begin Source File - -SOURCE=.\xen.cpp -# End Source File -# Begin Source File - -SOURCE=.\zombie.cpp -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd" -# Begin Source File - -SOURCE=.\activity.h -# End Source File -# Begin Source File - -SOURCE=.\activitymap.h -# End Source File -# Begin Source File - -SOURCE=.\animation.h -# End Source File -# Begin Source File - -SOURCE=.\basemonster.h -# End Source File -# Begin Source File - -SOURCE=.\cbase.h -# End Source File -# Begin Source File - -SOURCE=.\cdll_dll.h -# End Source File -# Begin Source File - -SOURCE=.\client.h -# End Source File -# Begin Source File - -SOURCE=.\decals.h -# End Source File -# Begin Source File - -SOURCE=.\defaultai.h -# End Source File -# Begin Source File - -SOURCE=.\doors.h -# End Source File -# Begin Source File - -SOURCE=.\effects.h -# End Source File -# Begin Source File - -SOURCE=..\engine\eiface.h -# End Source File -# Begin Source File - -SOURCE=.\enginecallback.h -# End Source File -# Begin Source File - -SOURCE=.\explode.h -# End Source File -# Begin Source File - -SOURCE=.\extdll.h -# End Source File -# Begin Source File - -SOURCE=.\flyingmonster.h -# End Source File -# Begin Source File - -SOURCE=.\func_break.h -# End Source File -# Begin Source File - -SOURCE=.\gamerules.h -# End Source File -# Begin Source File - -SOURCE=.\hornet.h -# End Source File -# Begin Source File - -SOURCE=.\items.h -# End Source File -# Begin Source File - -SOURCE=.\monsterevent.h -# End Source File -# Begin Source File - -SOURCE=.\monsters.h -# End Source File -# Begin Source File - -SOURCE=.\nodes.h -# End Source File -# Begin Source File - -SOURCE=.\plane.h -# End Source File -# Begin Source File - -SOURCE=.\player.h -# End Source File -# Begin Source File - -SOURCE=..\pm_shared\pm_debug.h -# End Source File -# Begin Source File - -SOURCE=..\pm_shared\pm_defs.h -# End Source File -# Begin Source File - -SOURCE=..\pm_shared\pm_info.h -# End Source File -# Begin Source File - -SOURCE=..\pm_shared\pm_materials.h -# End Source File -# Begin Source File - -SOURCE=..\pm_shared\pm_movevars.h -# End Source File -# Begin Source File - -SOURCE=..\pm_shared\pm_shared.h -# End Source File -# Begin Source File - -SOURCE=.\saverestore.h -# End Source File -# Begin Source File - -SOURCE=.\schedule.h -# End Source File -# Begin Source File - -SOURCE=.\scripted.h -# End Source File -# Begin Source File - -SOURCE=.\scriptevent.h -# End Source File -# Begin Source File - -SOURCE=.\skill.h -# End Source File -# Begin Source File - -SOURCE=.\soundent.h -# End Source File -# Begin Source File - -SOURCE=.\spectator.h -# End Source File -# Begin Source File - -SOURCE=.\squadmonster.h -# End Source File -# Begin Source File - -SOURCE=.\talkmonster.h -# End Source File -# Begin Source File - -SOURCE=.\teamplay_gamerules.h -# End Source File -# Begin Source File - -SOURCE=.\trains.h -# End Source File -# Begin Source File - -SOURCE=.\util.h -# End Source File -# Begin Source File - -SOURCE=.\vector.h -# End Source File -# Begin Source File - -SOURCE=.\weapons.h -# End Source File -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" -# End Group -# End Target -# End Project diff --git a/dlls/hornet.cpp b/dlls/hornet.cpp index 0827c00d..7e0f6f4d 100644 --- a/dlls/hornet.cpp +++ b/dlls/hornet.cpp @@ -70,14 +70,14 @@ void CHornet::Spawn( void ) if( g_pGameRules->IsMultiplayer() ) { // hornets don't live as long in multiplayer - m_flStopAttack = gpGlobals->time + 3.5; + m_flStopAttack = gpGlobals->time + 3.5f; } else { - m_flStopAttack = gpGlobals->time + 5.0; + m_flStopAttack = gpGlobals->time + 5.0f; } - m_flFieldOfView = 0.9; // +- 25 degrees + m_flFieldOfView = 0.9f; // +- 25 degrees if( RANDOM_LONG( 1, 5 ) <= 2 ) { @@ -96,9 +96,9 @@ void CHornet::Spawn( void ) SetTouch( &CHornet::DieTouch ); SetThink( &CHornet::StartTrack ); - edict_t *pSoundEnt = pev->owner; + /*edict_t *pSoundEnt = pev->owner; if( !pSoundEnt ) - pSoundEnt = edict(); + pSoundEnt = edict();*/ if( !FNullEnt( pev->owner ) && ( pev->owner->v.flags & FL_CLIENT ) ) { @@ -110,7 +110,7 @@ void CHornet::Spawn( void ) pev->dmg = gSkillData.monDmgHornet; } - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; ResetSequenceInfo(); } @@ -170,7 +170,7 @@ void CHornet::StartTrack( void ) SetTouch( &CHornet::TrackTouch ); SetThink( &CHornet::TrackTarget ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } //========================================================= @@ -183,7 +183,7 @@ void CHornet::StartDart( void ) SetTouch( &CHornet::DartTouch ); SetThink( &CBaseEntity::SUB_Remove ); - pev->nextthink = gpGlobals->time + 4; + pev->nextthink = gpGlobals->time + 4.0f; } void CHornet::IgniteTrail( void ) @@ -254,7 +254,7 @@ void CHornet::TrackTarget( void ) { SetTouch( NULL ); SetThink( &CBaseEntity::SUB_Remove ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; return; } @@ -272,12 +272,12 @@ void CHornet::TrackTarget( void ) } else { - m_vecEnemyLKP = m_vecEnemyLKP + pev->velocity * m_flFlySpeed * 0.1; + m_vecEnemyLKP = m_vecEnemyLKP + pev->velocity * m_flFlySpeed * 0.1f; } vecDirToEnemy = ( m_vecEnemyLKP - pev->origin ).Normalize(); - if( pev->velocity.Length() < 0.1 ) + if( pev->velocity.Length() < 0.1f ) vecFlightDir = vecDirToEnemy; else vecFlightDir = pev->velocity.Normalize(); @@ -285,7 +285,7 @@ void CHornet::TrackTarget( void ) // measure how far the turn is, the wider the turn, the slow we'll go this time. flDelta = DotProduct( vecFlightDir, vecDirToEnemy ); - if( flDelta < 0.5 ) + if( flDelta < 0.5f ) { // hafta turn wide again. play sound switch( RANDOM_LONG( 0, 2 ) ) @@ -305,7 +305,7 @@ void CHornet::TrackTarget( void ) if( flDelta <= 0 && m_iHornetType == HORNET_TYPE_RED ) { // no flying backwards, but we don't want to invert this, cause we'd go fast when we have to turn REAL far. - flDelta = 0.25; + flDelta = 0.25f; } pev->velocity = ( vecFlightDir + vecDirToEnemy ).Normalize(); @@ -313,20 +313,20 @@ void CHornet::TrackTarget( void ) if( pev->owner && ( pev->owner->v.flags & FL_MONSTER ) ) { // random pattern only applies to hornets fired by monsters, not players. - pev->velocity.x += RANDOM_FLOAT( -0.10, 0.10 );// scramble the flight dir a bit. - pev->velocity.y += RANDOM_FLOAT( -0.10, 0.10 ); - pev->velocity.z += RANDOM_FLOAT( -0.10, 0.10 ); + pev->velocity.x += RANDOM_FLOAT( -0.10f, 0.10f );// scramble the flight dir a bit. + pev->velocity.y += RANDOM_FLOAT( -0.10f, 0.10f ); + pev->velocity.z += RANDOM_FLOAT( -0.10f, 0.10f ); } switch( m_iHornetType ) { case HORNET_TYPE_RED: pev->velocity = pev->velocity * ( m_flFlySpeed * flDelta );// scale the dir by the ( speed * width of turn ) - pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 0.1, 0.3 ); + pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 0.1f, 0.3f ); break; case HORNET_TYPE_ORANGE: pev->velocity = pev->velocity * m_flFlySpeed;// do not have to slow down to turn. - pev->nextthink = gpGlobals->time + 0.1;// fixed think time + pev->nextthink = gpGlobals->time + 0.1f;// fixed think time break; } @@ -338,7 +338,7 @@ void CHornet::TrackTarget( void ) // (only in the single player game) if( m_hEnemy != 0 && !g_pGameRules->IsMultiplayer() ) { - if( flDelta >= 0.4 && ( pev->origin - m_vecEnemyLKP ).Length() <= 300 ) + if( flDelta >= 0.4f && ( pev->origin - m_vecEnemyLKP ).Length() <= 300 ) { MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin ); WRITE_BYTE( TE_SPRITE ); @@ -363,8 +363,8 @@ void CHornet::TrackTarget( void ) EMIT_SOUND( ENT( pev ), CHAN_VOICE, "hornet/ag_buzz3.wav", HORNET_BUZZ_VOLUME, ATTN_NORM ); break; } - pev->velocity = pev->velocity * 2; - pev->nextthink = gpGlobals->time + 1.0; + pev->velocity = pev->velocity * 2.0f; + pev->nextthink = gpGlobals->time + 1.0f; // don't attack again m_flStopAttack = gpGlobals->time; } @@ -389,10 +389,10 @@ void CHornet::TrackTouch( CBaseEntity *pOther ) pev->velocity = pev->velocity.Normalize(); - pev->velocity.x *= -1; - pev->velocity.y *= -1; + pev->velocity.x *= -1.0f; + pev->velocity.y *= -1.0f; - pev->origin = pev->origin + pev->velocity * 4; // bounce the hornet off a bit. + pev->origin = pev->origin + pev->velocity * 4.0f; // bounce the hornet off a bit. pev->velocity = pev->velocity * m_flFlySpeed; return; @@ -442,5 +442,5 @@ void CHornet::DieTouch( CBaseEntity *pOther ) pev->solid = SOLID_NOT; SetThink( &CBaseEntity::SUB_Remove ); - pev->nextthink = gpGlobals->time + 1;// stick around long enough for the sound to finish! + pev->nextthink = gpGlobals->time + 1.0f;// stick around long enough for the sound to finish! } diff --git a/dlls/hornet.h b/dlls/hornet.h index 1515b4cf..5366b3bc 100644 --- a/dlls/hornet.h +++ b/dlls/hornet.h @@ -16,7 +16,7 @@ // Hornets //========================================================= #pragma once -#ifndef HORNET_H +#if !defined(HORNET_H) #define HORNET_H //========================================================= // Hornet Defines diff --git a/dlls/hornetgun.cpp b/dlls/hornetgun.cpp index 909ba342..4223ddd6 100644 --- a/dlls/hornetgun.cpp +++ b/dlls/hornetgun.cpp @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ -#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD ) +#if !OEM_BUILD && !HLDEMO_BUILD #include "extdll.h" #include "util.h" @@ -74,7 +74,7 @@ int CHgun::AddToPlayer( CBasePlayer *pPlayer ) { if( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) { -#ifndef CLIENT_DLL +#if !CLIENT_DLL if( g_pGameRules->IsMultiplayer() ) { // in multiplayer, all hivehands come full. @@ -113,7 +113,7 @@ BOOL CHgun::Deploy() void CHgun::Holster( int skiplocal /* = 0 */ ) { - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5f; SendWeaponAnim( HGUN_DOWN ); //!!!HACKHACK - can't select hornetgun if it's empty! no way to get ammo for it, either. @@ -127,17 +127,17 @@ void CHgun::PrimaryAttack() { Reload(); - if(m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) { return; } -#ifndef CLIENT_DLL +#if !CLIENT_DLL UTIL_MakeVectors( m_pPlayer->pev->v_angle ); - CBaseEntity *pHornet = CBaseEntity::Create( "hornet", m_pPlayer->GetGunPosition( ) + gpGlobals->v_forward * 16 + gpGlobals->v_right * 8 + gpGlobals->v_up * -12, m_pPlayer->pev->v_angle, m_pPlayer->edict() ); - pHornet->pev->velocity = gpGlobals->v_forward * 300; + CBaseEntity *pHornet = CBaseEntity::Create( "hornet", m_pPlayer->GetGunPosition() + gpGlobals->v_forward * 16.0f + gpGlobals->v_right * 8.0f + gpGlobals->v_up * -12.0f, m_pPlayer->pev->v_angle, m_pPlayer->edict() ); + pHornet->pev->velocity = gpGlobals->v_forward * 300.0f; - m_flRechargeTime = gpGlobals->time + 0.5; + m_flRechargeTime = gpGlobals->time + 0.5f; #endif m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; @@ -145,21 +145,21 @@ void CHgun::PrimaryAttack() m_pPlayer->m_iWeaponFlash = DIM_GUN_FLASH; int flags; -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS flags = FEV_NOTHOST; #else flags = 0; #endif - PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usHornetFire, 0.0, g_vecZero, g_vecZero, 0.0, 0.0, FIREMODE_TRACK, 0, 0, 0 ); + PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usHornetFire, 0.0f, g_vecZero, g_vecZero, 0.0f, 0.0f, 0, 0, 0, 0 ); // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); - m_flNextPrimaryAttack = m_flNextPrimaryAttack + 0.25; + m_flNextPrimaryAttack = m_flNextPrimaryAttack + 0.25f; if( m_flNextPrimaryAttack < UTIL_WeaponTimeBase() ) { - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.25; + m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.25f; } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); @@ -175,63 +175,63 @@ void CHgun::SecondaryAttack( void ) } //Wouldn't be a bad idea to completely predict these, since they fly so fast... -#ifndef CLIENT_DLL +#if !CLIENT_DLL CBaseEntity *pHornet; Vector vecSrc; UTIL_MakeVectors( m_pPlayer->pev->v_angle ); - vecSrc = m_pPlayer->GetGunPosition() + gpGlobals->v_forward * 16 + gpGlobals->v_right * 8 + gpGlobals->v_up * -12; + vecSrc = m_pPlayer->GetGunPosition() + gpGlobals->v_forward * 16.0f + gpGlobals->v_right * 8.0f + gpGlobals->v_up * -12.0f; m_iFirePhase++; switch( m_iFirePhase ) { case 1: - vecSrc = vecSrc + gpGlobals->v_up * 8; + vecSrc = vecSrc + gpGlobals->v_up * 8.0f; break; case 2: - vecSrc = vecSrc + gpGlobals->v_up * 8; - vecSrc = vecSrc + gpGlobals->v_right * 8; + vecSrc = vecSrc + gpGlobals->v_up * 8.0f; + vecSrc = vecSrc + gpGlobals->v_right * 8.0f; break; case 3: - vecSrc = vecSrc + gpGlobals->v_right * 8; + vecSrc = vecSrc + gpGlobals->v_right * 8.0f; break; case 4: - vecSrc = vecSrc + gpGlobals->v_up * -8; - vecSrc = vecSrc + gpGlobals->v_right * 8; + vecSrc = vecSrc + gpGlobals->v_up * -8.0f; + vecSrc = vecSrc + gpGlobals->v_right * 8.0f; break; case 5: - vecSrc = vecSrc + gpGlobals->v_up * -8; + vecSrc = vecSrc + gpGlobals->v_up * -8.0f; break; case 6: - vecSrc = vecSrc + gpGlobals->v_up * -8; - vecSrc = vecSrc + gpGlobals->v_right * -8; + vecSrc = vecSrc + gpGlobals->v_up * -8.0f; + vecSrc = vecSrc + gpGlobals->v_right * -8.0f; break; case 7: - vecSrc = vecSrc + gpGlobals->v_right * -8; + vecSrc = vecSrc + gpGlobals->v_right * -8.0f; break; case 8: - vecSrc = vecSrc + gpGlobals->v_up * 8; - vecSrc = vecSrc + gpGlobals->v_right * -8; + vecSrc = vecSrc + gpGlobals->v_up * 8.0f; + vecSrc = vecSrc + gpGlobals->v_right * -8.0f; m_iFirePhase = 0; break; } pHornet = CBaseEntity::Create( "hornet", vecSrc, m_pPlayer->pev->v_angle, m_pPlayer->edict() ); - pHornet->pev->velocity = gpGlobals->v_forward * 1200; + pHornet->pev->velocity = gpGlobals->v_forward * 1200.0f; pHornet->pev->angles = UTIL_VecToAngles( pHornet->pev->velocity ); pHornet->SetThink( &CHornet::StartDart ); - m_flRechargeTime = gpGlobals->time + 0.5; + m_flRechargeTime = gpGlobals->time + 0.5f; #endif int flags; -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS flags = FEV_NOTHOST; #else flags = 0; #endif - PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usHornetFire, 0.0, g_vecZero, g_vecZero, 0.0, 0.0, FIREMODE_FAST, 0, 0, 0 ); + PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usHornetFire, 0.0f, g_vecZero, g_vecZero, 0.0f, 0.0f, 0, 0, 0, 0 ); m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME; @@ -240,8 +240,8 @@ void CHgun::SecondaryAttack( void ) // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); - m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.1; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); + m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.1f; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10.0f, 15.0f ); } void CHgun::Reload( void ) @@ -252,7 +252,7 @@ void CHgun::Reload( void ) while( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] < HORNET_MAX_CARRY && m_flRechargeTime < gpGlobals->time ) { m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]++; - m_flRechargeTime += 0.5; + m_flRechargeTime += 0.5f; } } @@ -264,21 +264,21 @@ void CHgun::WeaponIdle( void ) return; int iAnim; - float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 ); - if( flRand <= 0.75 ) + float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0.0f, 1.0f ); + if( flRand <= 0.75f ) { iAnim = HGUN_IDLE1; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 30.0 / 16 * ( 2 ); + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 30.0f / 16.0f * 2.0f; } - else if( flRand <= 0.875 ) + else if( flRand <= 0.875f ) { iAnim = HGUN_FIDGETSWAY; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 40.0 / 16.0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 40.0f / 16.0f; } else { iAnim = HGUN_FIDGETSHAKE; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 35.0 / 16.0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 35.0f / 16.0f; } SendWeaponAnim( iAnim ); } diff --git a/dlls/houndeye.cpp b/dlls/houndeye.cpp index 940b68ea..0333ca21 100644 --- a/dlls/houndeye.cpp +++ b/dlls/houndeye.cpp @@ -32,10 +32,10 @@ extern CGraph WorldGraph; // houndeye does 20 points of damage spread over a sphere 384 units in diameter, and each additional // squad member increases the BASE damage by 110%, per the spec. #define HOUNDEYE_MAX_SQUAD_SIZE 4 -#define HOUNDEYE_MAX_ATTACK_RADIUS 384 -#define HOUNDEYE_SQUAD_BONUS (float)1.1 +#define HOUNDEYE_MAX_ATTACK_RADIUS 384.0f +#define HOUNDEYE_SQUAD_BONUS 1.1f -#define HOUNDEYE_EYE_FRAMES 4 // how many different switchable maps for the eye +#define HOUNDEYE_EYE_FRAMES 3 // how many different switchable maps for the eye #define HOUNDEYE_SOUND_STARTLE_VOLUME 128 // how loud a sound has to be to badly scare a sleeping houndeye @@ -192,7 +192,7 @@ BOOL CHoundeye::FCanActiveIdle( void ) //========================================================= BOOL CHoundeye::CheckRangeAttack1( float flDot, float flDist ) { - if( flDist <= ( HOUNDEYE_MAX_ATTACK_RADIUS * 0.5 ) && flDot >= 0.3 ) + if( flDist <= ( HOUNDEYE_MAX_ATTACK_RADIUS * 0.5f ) && flDot >= 0.3f ) { return TRUE; } @@ -285,8 +285,8 @@ void CHoundeye::HandleAnimEvent( MonsterEvent_t *pEvent ) pev->flags &= ~FL_ONGROUND; - pev->velocity = gpGlobals->v_forward * -200; - pev->velocity.z += ( 0.6 * flGravity ) * 0.5; + pev->velocity = gpGlobals->v_forward * -200.0f; + pev->velocity.z += ( 0.6f * flGravity ) * 0.5f; break; } case HOUND_AE_THUMP: @@ -514,6 +514,7 @@ void CHoundeye::WriteBeamColor( void ) bBlue = 255; break; case 4: + case 5: bRed = 62; bGreen = 33; bBlue = 211; @@ -565,10 +566,10 @@ void CHoundeye::SonicAttack( void ) WRITE_BYTE( TE_BEAMCYLINDER ); WRITE_COORD( pev->origin.x ); WRITE_COORD( pev->origin.y ); - WRITE_COORD( pev->origin.z + 16 ); + WRITE_COORD( pev->origin.z + 16.0f ); WRITE_COORD( pev->origin.x ); WRITE_COORD( pev->origin.y ); - WRITE_COORD( pev->origin.z + 16 + HOUNDEYE_MAX_ATTACK_RADIUS / .2 ); // reach damage radius over .3 seconds + WRITE_COORD( pev->origin.z + 16.0f + HOUNDEYE_MAX_ATTACK_RADIUS / 0.2f ); // reach damage radius over .3 seconds WRITE_SHORT( m_iSpriteTexture ); WRITE_BYTE( 0 ); // startframe WRITE_BYTE( 0 ); // framerate @@ -586,10 +587,10 @@ void CHoundeye::SonicAttack( void ) WRITE_BYTE( TE_BEAMCYLINDER ); WRITE_COORD( pev->origin.x ); WRITE_COORD( pev->origin.y ); - WRITE_COORD( pev->origin.z + 16 ); + WRITE_COORD( pev->origin.z + 16.0f ); WRITE_COORD( pev->origin.x ); WRITE_COORD( pev->origin.y ); - WRITE_COORD( pev->origin.z + 16 + ( HOUNDEYE_MAX_ATTACK_RADIUS / 2 ) / .2 ); // reach damage radius over .3 seconds + WRITE_COORD( pev->origin.z + 16.0f + ( HOUNDEYE_MAX_ATTACK_RADIUS / 2.0f ) / 0.2f ); // reach damage radius over .3 seconds WRITE_SHORT( m_iSpriteTexture ); WRITE_BYTE( 0 ); // startframe WRITE_BYTE( 0 ); // framerate @@ -638,7 +639,7 @@ void CHoundeye::SonicAttack( void ) // if this entity is a client, and is not in full view, inflict half damage. We do this so that players still // take the residual damage if they don't totally leave the houndeye's effective radius. We restrict it to clients // so that monsters in other parts of the level don't take the damage and get pissed. - flAdjustedDamage *= 0.5; + flAdjustedDamage *= 0.5f; } else if( !FClassnameIs( pEntity->pev, "func_breakable" ) && !FClassnameIs( pEntity->pev, "func_pushable" ) ) { @@ -783,6 +784,11 @@ void CHoundeye::RunTask( Task_t *pTask ) { pev->skin++; } + + if( pev->skin == HOUNDEYE_EYE_FRAMES - 1 ) + { + TaskComplete(); + } break; } case TASK_HOUND_HOP_BACK: @@ -802,17 +808,17 @@ void CHoundeye::RunTask( Task_t *pTask ) float life; life = ( ( 255 - pev->frame ) / ( pev->framerate * m_flFrameRate ) ); - if( life < 0.1 ) - life = 0.1; + if( life < 0.1f ) + life = 0.1f; MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin ); WRITE_BYTE( TE_IMPLOSION ); WRITE_COORD( pev->origin.x ); WRITE_COORD( pev->origin.y ); - WRITE_COORD( pev->origin.z + 16 ); - WRITE_BYTE( 50 * life + 100 ); // radius - WRITE_BYTE( pev->frame / 25.0 ); // count - WRITE_BYTE( life * 10 ); // life + WRITE_COORD( pev->origin.z + 16.0f ); + WRITE_BYTE( 50.0f * life + 100.0f ); // radius + WRITE_BYTE( pev->frame / 25.0f ); // count + WRITE_BYTE( life * 10.0f ); // life MESSAGE_END(); if( m_fSequenceFinished ) @@ -836,7 +842,7 @@ void CHoundeye::RunTask( Task_t *pTask ) void CHoundeye::PrescheduleThink( void ) { // if the hound is mad and is running, make hunt noises. - if( m_MonsterState == MONSTERSTATE_COMBAT && m_Activity == ACT_RUN && RANDOM_FLOAT( 0, 1 ) < 0.2 ) + if( m_MonsterState == MONSTERSTATE_COMBAT && m_Activity == ACT_RUN && RANDOM_FLOAT( 0, 1 ) < 0.2f ) { WarnSound(); } @@ -882,8 +888,8 @@ void CHoundeye::PrescheduleThink( void ) //========================================================= Task_t tlHoundGuardPack[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_GUARD, (float)0 }, + { TASK_STOP_MOVING, 0.0f }, + { TASK_GUARD, 0.0f }, }; Schedule_t slHoundGuardPack[] = @@ -952,6 +958,7 @@ Task_t tlHoundSleep[] = { TASK_HOUND_FALL_ASLEEP, (float)0 }, { TASK_WAIT_RANDOM, (float)25 }, { TASK_HOUND_CLOSE_EYE, (float)0 }, + { TASK_WAIT_INDEFINITE, (float)0 }, //{ TASK_WAIT, (float)10 }, //{ TASK_WAIT_RANDOM, (float)10 }, }; @@ -1079,14 +1086,14 @@ Task_t tlHoundCombatFailPVS[] = { { TASK_STOP_MOVING, 0 }, { TASK_HOUND_THREAT_DISPLAY, 0 }, - { TASK_WAIT_FACE_ENEMY, (float)1 }, + { TASK_WAIT_FACE_ENEMY, 1.0f }, }; Schedule_t slHoundCombatFailPVS[] = { { tlHoundCombatFailPVS, - ARRAYSIZE ( tlHoundCombatFailPVS ), + ARRAYSIZE( tlHoundCombatFailPVS ), bits_COND_NEW_ENEMY | bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE, @@ -1260,13 +1267,13 @@ Schedule_t *CHoundeye::GetSchedule( void ) if( HasConditions( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE ) ) { - if( RANDOM_FLOAT( 0, 1 ) <= 0.4 ) + if( RANDOM_FLOAT( 0.0f, 1.0f ) <= 0.4f ) { TraceResult tr; UTIL_MakeVectors( pev->angles ); UTIL_TraceHull( pev->origin, pev->origin + gpGlobals->v_forward * -128, dont_ignore_monsters, head_hull, ENT( pev ), &tr ); - if( tr.flFraction == 1.0 ) + if( tr.flFraction == 1.0f ) { // it's clear behind, so the hound will jump return GetScheduleOfType( SCHED_HOUND_HOP_RETREAT ); diff --git a/dlls/ichthyosaur.cpp b/dlls/ichthyosaur.cpp index 53f57a27..0f9fbf5a 100644 --- a/dlls/ichthyosaur.cpp +++ b/dlls/ichthyosaur.cpp @@ -12,7 +12,7 @@ * use or distribution of this code by or to any unlicensed person is illegal. * ****/ -#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD ) +#if !OEM_BUILD && !HLDEMO_BUILD //========================================================= // icthyosaur - evin, satan fish monster @@ -32,7 +32,7 @@ #define SEARCH_RETRY 16 -#define ICHTHYOSAUR_SPEED 150 +#define ICHTHYOSAUR_SPEED 150.0f extern CGraph WorldGraph; @@ -328,7 +328,7 @@ int CIchthyosaur::Classify( void ) //========================================================= BOOL CIchthyosaur::CheckMeleeAttack1( float flDot, float flDist ) { - if( flDot >= 0.7 && m_flEnemyTouched > gpGlobals->time - 0.2 ) + if( flDot >= 0.7f && m_flEnemyTouched > gpGlobals->time - 0.2f ) { return TRUE; } @@ -366,7 +366,7 @@ void CIchthyosaur::CombatUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE //========================================================= BOOL CIchthyosaur::CheckRangeAttack1( float flDot, float flDist ) { - if( flDot > -0.7 && (m_bOnAttack || ( flDist <= 192 && m_idealDist <= 192 ) ) ) + if( flDot > -0.7f && (m_bOnAttack || ( flDist <= 192 && m_idealDist <= 192 ) ) ) { return TRUE; } @@ -420,22 +420,22 @@ void CIchthyosaur::HandleAnimEvent( MonsterEvent_t *pEvent ) { CBaseEntity *pHurt = m_hEnemy; - if( m_flEnemyTouched < gpGlobals->time - 0.2 && ( m_hEnemy->BodyTarget( pev->origin ) - pev->origin).Length() > ( 32 + 16 + 32 ) ) + if( m_flEnemyTouched < gpGlobals->time - 0.2f && ( m_hEnemy->BodyTarget( pev->origin ) - pev->origin).Length() > ( 32.0f + 16.0f + 32.0f ) ) break; Vector vecShootDir = ShootAtEnemy( pev->origin ); UTIL_MakeAimVectors( pev->angles ); - if( DotProduct( vecShootDir, gpGlobals->v_forward ) > 0.707 ) + if( DotProduct( vecShootDir, gpGlobals->v_forward ) > 0.707f ) { m_bOnAttack = TRUE; pHurt->pev->punchangle.z = -18; pHurt->pev->punchangle.x = 5; - pHurt->pev->velocity = pHurt->pev->velocity - gpGlobals->v_right * 300; + pHurt->pev->velocity = pHurt->pev->velocity - gpGlobals->v_right * 300.0f; if( pHurt->IsPlayer() ) { - pHurt->pev->angles.x += RANDOM_FLOAT( -35, 35 ); - pHurt->pev->angles.y += RANDOM_FLOAT( -90, 90 ); + pHurt->pev->angles.x += RANDOM_FLOAT( -35.0f, 35.0f ); + pHurt->pev->angles.y += RANDOM_FLOAT( -90.0f, 90.0f ); pHurt->pev->angles.z = 0; pHurt->pev->fixangle = TRUE; } @@ -454,7 +454,7 @@ void CIchthyosaur::HandleAnimEvent( MonsterEvent_t *pEvent ) if( bDidAttack ) { - Vector vecSrc = pev->origin + gpGlobals->v_forward * 32; + Vector vecSrc = pev->origin + gpGlobals->v_forward * 32.0f; UTIL_Bubbles( vecSrc - Vector( 8, 8, 8 ), vecSrc + Vector( 8, 8, 8 ), 16 ); } } @@ -478,7 +478,7 @@ void CIchthyosaur::Spawn() m_MonsterState = MONSTERSTATE_NONE; SetBits(pev->flags, FL_SWIM); SetFlyingSpeed( ICHTHYOSAUR_SPEED ); - SetFlyingMomentum( 2.5 ); // Set momentum constant + SetFlyingMomentum( 2.5f ); // Set momentum constant m_afCapability = bits_CAP_RANGE_ATTACK1 | bits_CAP_SWIM; @@ -634,9 +634,9 @@ void CIchthyosaur::RunTask( Task_t *pTask ) Vector vecSwim = CrossProduct( vecDelta, Vector( 0, 0, 1 ) ).Normalize(); if( DotProduct( vecSwim, m_SaveVelocity ) < 0 ) - vecSwim = vecSwim * -1.0; + vecSwim = vecSwim * -1.0f; - Vector vecPos = vecFrom + vecDelta * m_idealDist + vecSwim * 32; + Vector vecPos = vecFrom + vecDelta * m_idealDist + vecSwim * 32.0f; // ALERT( at_console, "vecPos %.0f %.0f %.0f\n", vecPos.x, vecPos.y, vecPos.z ); @@ -644,16 +644,16 @@ void CIchthyosaur::RunTask( Task_t *pTask ) UTIL_TraceHull( vecFrom, vecPos, ignore_monsters, large_hull, m_hEnemy->edict(), &tr ); - if( tr.flFraction > 0.5 ) + if( tr.flFraction > 0.5f ) vecPos = tr.vecEndPos; - m_SaveVelocity = m_SaveVelocity * 0.8 + 0.2 * ( vecPos - pev->origin ).Normalize() * m_flightSpeed; + m_SaveVelocity = m_SaveVelocity * 0.8f + 0.2f * ( vecPos - pev->origin ).Normalize() * m_flightSpeed; // ALERT( at_console, "m_SaveVelocity %.2f %.2f %.2f\n", m_SaveVelocity.x, m_SaveVelocity.y, m_SaveVelocity.z ); if( HasConditions( bits_COND_ENEMY_FACING_ME ) && m_hEnemy->FVisible( this ) ) { - m_flNextAlert -= 0.1; + m_flNextAlert -= 0.1f; if( m_idealDist < m_flMaxDist ) { @@ -670,12 +670,12 @@ void CIchthyosaur::RunTask( Task_t *pTask ) } if( m_flMinSpeed < m_flMaxSpeed ) { - m_flMinSpeed += 0.5; + m_flMinSpeed += 0.5f; } } else { - m_flNextAlert += 0.1; + m_flNextAlert += 0.1f; if( m_idealDist > 128 ) { @@ -690,7 +690,7 @@ void CIchthyosaur::RunTask( Task_t *pTask ) } else { - m_flNextAlert = gpGlobals->time + 0.2; + m_flNextAlert = gpGlobals->time + 0.2f; } if( m_flNextAlert < gpGlobals->time ) @@ -716,7 +716,7 @@ void CIchthyosaur::RunTask( Task_t *pTask ) break; case TASK_ICHTHYOSAUR_FLOAT: pev->angles.x = UTIL_ApproachAngle( 0, pev->angles.x, 20 ); - pev->velocity = pev->velocity * 0.8; + pev->velocity = pev->velocity * 0.8f; if( pev->waterlevel > 1 && pev->velocity.z < 64 ) { pev->velocity.z += 8; @@ -740,7 +740,7 @@ float CIchthyosaur::VectorToPitch( const Vector &vec ) pitch = 0; else { - pitch = (int) ( atan2( vec.z, sqrt( vec.x * vec.x + vec.y * vec.y ) ) * 180 / M_PI ); + pitch = (int) ( atan2( vec.z, sqrt( vec.x * vec.x + vec.y * vec.y ) ) * 180.0f / M_PI_F ); if( pitch < 0 ) pitch += 360; } @@ -793,7 +793,7 @@ float CIchthyosaur::ChangePitch( int speed ) else if( diff > 20 ) target = -45; } - pev->angles.x = UTIL_Approach(target, pev->angles.x, 220.0 * 0.1 ); + pev->angles.x = UTIL_Approach(target, pev->angles.x, 220.0f * 0.1f ); } return 0; } @@ -812,7 +812,7 @@ float CIchthyosaur::ChangeYaw( int speed ) else if( diff > 20 ) target = -20; } - pev->angles.z = UTIL_Approach( target, pev->angles.z, 220.0 * 0.1 ); + pev->angles.z = UTIL_Approach( target, pev->angles.z, 220.0f * 0.1f ); } return CFlyingMonster::ChangeYaw( speed ); } @@ -843,9 +843,9 @@ void CIchthyosaur::MonsterThink( void ) if( m_flBlink < gpGlobals->time ) { pev->skin = EYE_CLOSED; - if( m_flBlink + 0.2 < gpGlobals->time ) + if( m_flBlink + 0.2f < gpGlobals->time ) { - m_flBlink = gpGlobals->time + RANDOM_FLOAT( 3, 4 ); + m_flBlink = gpGlobals->time + RANDOM_FLOAT( 3.0f, 4.0f ); if( m_bOnAttack ) pev->skin = EYE_MAD; else @@ -873,7 +873,7 @@ void CIchthyosaur::Swim() if( FBitSet( pev->flags, FL_ONGROUND ) ) { - pev->angles.x = 0; + pev->angles.x = 0.0f; pev->angles.y += RANDOM_FLOAT( -45, 45 ); ClearBits( pev->flags, FL_ONGROUND ); @@ -894,15 +894,15 @@ void CIchthyosaur::Swim() if( m_IdealActivity == ACT_RUN ) SetActivity( ACT_WALK ); if( m_IdealActivity == ACT_WALK ) - pev->framerate = m_flightSpeed / 150.0; + pev->framerate = m_flightSpeed / 150.0f; // ALERT( at_console, "walk %.2f\n", pev->framerate ); } else { if( m_IdealActivity == ACT_WALK ) SetActivity( ACT_RUN ); - if( m_IdealActivity == ACT_RUN) - pev->framerate = m_flightSpeed / 150.0; + if( m_IdealActivity == ACT_RUN ) + pev->framerate = m_flightSpeed / 150.0f; // ALERT( at_console, "run %.2f\n", pev->framerate ); } /* @@ -935,10 +935,10 @@ void CIchthyosaur::Swim() // ALERT( at_console, "%f : %f\n", Angles.x, Forward.z ); float flDot = DotProduct( Forward, m_SaveVelocity ); - if( flDot > 0.5 ) + if( flDot > 0.5f ) pev->velocity = m_SaveVelocity = m_SaveVelocity * m_flightSpeed; else if( flDot > 0 ) - pev->velocity = m_SaveVelocity = m_SaveVelocity * m_flightSpeed * ( flDot + 0.5 ); + pev->velocity = m_SaveVelocity = m_SaveVelocity * m_flightSpeed * ( flDot + 0.5f ); else pev->velocity = m_SaveVelocity = m_SaveVelocity * 80; @@ -957,7 +957,7 @@ void CIchthyosaur::Swim() // if( Angles.x > 180 ) Angles.x = Angles.x - 360; - pev->angles.x = UTIL_Approach( Angles.x, pev->angles.x, 50 * 0.1 ); + pev->angles.x = UTIL_Approach( Angles.x, pev->angles.x, 50 * 0.1f ); if( pev->angles.x < -80 ) pev->angles.x = -80; if( pev->angles.x > 80 ) @@ -981,12 +981,12 @@ void CIchthyosaur::Swim() turn = Angles.y - pev->angles.y - 360; } - float speed = m_flightSpeed * 0.1; + float speed = m_flightSpeed * 0.1f; // ALERT( at_console, "speed %.0f %f\n", turn, speed ); if( fabs( turn ) > speed ) { - if( turn < 0.0 ) + if( turn < 0.0f ) { turn = -speed; } @@ -997,15 +997,15 @@ void CIchthyosaur::Swim() } pev->angles.y += turn; pev->angles.z -= turn; - pev->angles.y = fmod( ( pev->angles.y + 360.0 ), 360.0 ); + pev->angles.y = fmod( ( pev->angles.y + 360.0f ), 360.0f ); static float yaw_adj; - yaw_adj = yaw_adj * 0.8 + turn; + yaw_adj = yaw_adj * 0.8f + turn; // ALERT( at_console, "yaw %f : %f\n", turn, yaw_adj ); - SetBoneController( 0, -yaw_adj / 4.0 ); + SetBoneController( 0, -yaw_adj * 0.25f ); // Roll Smoothing // @@ -1022,7 +1022,7 @@ void CIchthyosaur::Swim() { turn = Angles.z - pev->angles.z - 360; } - speed = m_flightSpeed / 2 * 0.1; + speed = m_flightSpeed / 2 * 0.1f; if( fabs( turn ) < speed ) { @@ -1030,7 +1030,7 @@ void CIchthyosaur::Swim() } else { - if( turn < 0.0 ) + if( turn < 0.0f ) { pev->angles.z -= speed; } @@ -1058,12 +1058,12 @@ Vector CIchthyosaur::DoProbe( const Vector &Probe ) TraceResult tr; TRACE_MONSTER_HULL( edict(), pev->origin, Probe, dont_ignore_monsters, edict(), &tr ); - if( tr.fAllSolid || tr.flFraction < 0.99 ) + if( tr.fAllSolid || tr.flFraction < 0.99f ) { - if( tr.flFraction < 0.0 ) - tr.flFraction = 0.0; - if( tr.flFraction > 1.0 ) - tr.flFraction = 1.0; + if( tr.flFraction < 0.0f ) + tr.flFraction = 0.0f; + if( tr.flFraction > 1.0f ) + tr.flFraction = 1.0f; if( tr.flFraction < frac ) { frac = tr.flFraction; @@ -1080,7 +1080,7 @@ Vector CIchthyosaur::DoProbe( const Vector &Probe ) Vector SteeringVector = CrossProduct( NormalToProbeAndWallNormal, ProbeDir ); float SteeringForce = m_flightSpeed * ( 1 -frac ) * ( DotProduct( WallNormal.Normalize(), m_SaveVelocity.Normalize() ) ); - if( SteeringForce < 0.0 ) + if( SteeringForce < 0.0f ) { SteeringForce = -SteeringForce; } diff --git a/dlls/islave.cpp b/dlls/islave.cpp index b516c09b..577eda24 100644 --- a/dlls/islave.cpp +++ b/dlls/islave.cpp @@ -235,7 +235,7 @@ void CISlave::PainSound( void ) { if( RANDOM_LONG( 0, 2 ) == 0 ) { - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pPainSounds[RANDOM_LONG( 0, ARRAYSIZE( pPainSounds ) - 1 )], 1.0, ATTN_NORM, 0, m_voicePitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pPainSounds ), 1.0, ATTN_NORM, 0, m_voicePitch ); } } @@ -244,7 +244,7 @@ void CISlave::PainSound( void ) //========================================================= void CISlave::DeathSound( void ) { - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pDeathSounds[RANDOM_LONG( 0, ARRAYSIZE( pDeathSounds ) - 1 )], 1.0, ATTN_NORM, 0, m_voicePitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pDeathSounds ), 1.0, ATTN_NORM, 0, m_voicePitch ); } //========================================================= @@ -315,12 +315,12 @@ void CISlave::HandleAnimEvent( MonsterEvent_t *pEvent ) pHurt->pev->punchangle.x = 5; } // Play a random attack hit sound - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackHitSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackHitSounds ) - 1 )], 1.0, ATTN_NORM, 0, m_voicePitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackHitSounds ), 1.0, ATTN_NORM, 0, m_voicePitch ); } else { // Play a random attack miss sound - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackMissSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackMissSounds ) - 1 )], 1.0, ATTN_NORM, 0, m_voicePitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackMissSounds ), 1.0, ATTN_NORM, 0, m_voicePitch ); } } break; @@ -334,11 +334,11 @@ void CISlave::HandleAnimEvent( MonsterEvent_t *pEvent ) pHurt->pev->punchangle.z = -18; pHurt->pev->punchangle.x = 5; } - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackHitSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackHitSounds ) - 1 )], 1.0, ATTN_NORM, 0, m_voicePitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackHitSounds ), 1.0, ATTN_NORM, 0, m_voicePitch ); } else { - EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, pAttackMissSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackMissSounds ) - 1 )], 1.0, ATTN_NORM, 0, m_voicePitch ); + EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackMissSounds ), 1.0, ATTN_NORM, 0, m_voicePitch ); } } break; @@ -467,7 +467,7 @@ BOOL CISlave::CheckRangeAttack2( float flDot, float flDist ) TraceResult tr; UTIL_TraceLine( EyePosition(), pEntity->EyePosition(), ignore_monsters, ENT( pev ), &tr ); - if( tr.flFraction == 1.0 || tr.pHit == pEntity->edict() ) + if( tr.flFraction == 1.0f || tr.pHit == pEntity->edict() ) { if( pEntity->pev->deadflag == DEAD_DEAD ) { @@ -531,8 +531,6 @@ void CISlave::Spawn() //========================================================= void CISlave::Precache() { - size_t i; - PRECACHE_MODEL( "models/islave.mdl" ); PRECACHE_MODEL( "sprites/lgtning.spr" ); PRECACHE_SOUND( "debris/zap1.wav" ); @@ -543,17 +541,10 @@ void CISlave::Precache() PRECACHE_SOUND( "headcrab/hc_headbite.wav" ); PRECACHE_SOUND( "weapons/cbar_miss1.wav" ); - for( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) - PRECACHE_SOUND( pAttackHitSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) - PRECACHE_SOUND( pAttackMissSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) - PRECACHE_SOUND( pPainSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pDeathSounds ); i++ ) - PRECACHE_SOUND( pDeathSounds[i] ); + PRECACHE_SOUND_ARRAY( pAttackHitSounds ); + PRECACHE_SOUND_ARRAY( pAttackMissSounds ); + PRECACHE_SOUND_ARRAY( pPainSounds ); + PRECACHE_SOUND_ARRAY( pDeathSounds ); UTIL_PrecacheOther( "test_effect" ); } @@ -639,10 +630,13 @@ Schedule_t *CISlave::GetSchedule( void ) ASSERT( pSound != NULL ); - if( pSound && ( pSound->m_iType & bits_SOUND_DANGER ) ) - return GetScheduleOfType( SCHED_TAKE_COVER_FROM_BEST_SOUND ); - if( pSound->m_iType & bits_SOUND_COMBAT ) - m_afMemory |= bits_MEMORY_PROVOKED; + if( pSound ) + { + if( pSound->m_iType & bits_SOUND_DANGER ) + return GetScheduleOfType( SCHED_TAKE_COVER_FROM_BEST_SOUND ); + if( pSound->m_iType & bits_SOUND_COMBAT ) + m_afMemory |= bits_MEMORY_PROVOKED; + } } switch( m_MonsterState ) @@ -723,7 +717,7 @@ void CISlave::ArmBeam( int side ) } // Couldn't find anything close enough - if( flDist == 1.0 ) + if( flDist == 1.0f ) return; DecalGunshot( &tr, BULLET_PLAYER_CROWBAR ); diff --git a/dlls/items.cpp b/dlls/items.cpp index fc2ba2f3..3ee41304 100644 --- a/dlls/items.cpp +++ b/dlls/items.cpp @@ -99,7 +99,7 @@ void CItem::Spawn( void ) if( DROP_TO_FLOOR(ENT( pev ) ) == 0 ) { - ALERT(at_error, "Item %s fell out of level at %f,%f,%f\n", STRING( pev->classname ), pev->origin.x, pev->origin.y, pev->origin.z); + ALERT(at_error, "Item %s fell out of level at %f,%f,%f\n", STRING( pev->classname ), (double)pev->origin.x, (double)pev->origin.y, (double)pev->origin.z); UTIL_Remove( this ); return; } @@ -316,7 +316,7 @@ class CItemBattery : public CItem // Suit reports new power level // For some reason this wasn't working in release build -- round it. - pct = (int)( (float)( pPlayer->pev->armorvalue * 100.0 ) * ( 1.0 / MAX_NORMAL_BATTERY ) + 0.5 ); + pct = (int)( (float)( pPlayer->pev->armorvalue * 100.0f ) * ( 1.0f / MAX_NORMAL_BATTERY ) + 0.5f ); pct = ( pct / 5 ); if( pct > 0 ) pct--; diff --git a/dlls/items.h b/dlls/items.h index 18c38080..8d6434eb 100644 --- a/dlls/items.h +++ b/dlls/items.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef ITEMS_H +#if !defined(ITEMS_H) #define ITEMS_H class CItem : public CBaseEntity diff --git a/dlls/leech.cpp b/dlls/leech.cpp index 1d64eae1..fd912510 100644 --- a/dlls/leech.cpp +++ b/dlls/leech.cpp @@ -48,12 +48,12 @@ #define LEECH_ACCELERATE 10 #define LEECH_CHECK_DIST 45 -#define LEECH_SWIM_SPEED 50 -#define LEECH_SWIM_ACCEL 80 -#define LEECH_SWIM_DECEL 10 +#define LEECH_SWIM_SPEED 50.0f +#define LEECH_SWIM_ACCEL 80.0f +#define LEECH_SWIM_DECEL 10.0f #define LEECH_TURN_RATE 90 #define LEECH_SIZEX 10 -#define LEECH_FRAMETIME 0.1 +#define LEECH_FRAMETIME 0.1f #define DEBUG_BEAMS 0 @@ -209,16 +209,16 @@ void CLeech::RecalculateWaterlevel( void ) TraceResult tr; UTIL_TraceLine( pev->origin, vecTest, missile, edict(), &tr ); - if( tr.flFraction != 1.0 ) - m_bottom = tr.vecEndPos.z + 1; + if( tr.flFraction != 1.0f ) + m_bottom = tr.vecEndPos.z + 1.0f; else m_bottom = vecTest.z; m_top = UTIL_WaterLevel( pev->origin, pev->origin.z, pev->origin.z + 400 ) - 1; // Chop off 20% of the outside range - float newBottom = m_bottom * 0.8 + m_top * 0.2; - m_top = m_bottom * 0.2 + m_top * 0.8; + float newBottom = m_bottom * 0.8f + m_top * 0.2f; + m_top = m_bottom * 0.2f + m_top * 0.8f; m_bottom = newBottom; m_height = RANDOM_FLOAT( m_bottom, m_top ); m_waterTime = gpGlobals->time + RANDOM_FLOAT( 5, 7 ); @@ -259,27 +259,23 @@ void CLeech::AttackSound( void ) { if( gpGlobals->time > m_attackSoundTime ) { - EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pAttackSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackSounds ) - 1 )], 1.0, ATTN_NORM, 0, PITCH_NORM ); - m_attackSoundTime = gpGlobals->time + 0.5; + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, RANDOM_SOUND_ARRAY( pAttackSounds ), 1.0f, ATTN_NORM, 0, PITCH_NORM ); + m_attackSoundTime = gpGlobals->time + 0.5f; } } void CLeech::AlertSound( void ) { - EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pAlertSounds[RANDOM_LONG( 0, ARRAYSIZE( pAlertSounds ) - 1 )], 1.0, ATTN_NORM * 0.5, 0, PITCH_NORM ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, RANDOM_SOUND_ARRAY( pAlertSounds ), 1.0f, ATTN_NORM * 0.5f, 0, PITCH_NORM ); } void CLeech::Precache( void ) { - size_t i; - //PRECACHE_MODEL( "models/icky.mdl" ); PRECACHE_MODEL( "models/leech.mdl" ); - for( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) - PRECACHE_SOUND( pAttackSounds[i] ); - for( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) - PRECACHE_SOUND( pAlertSounds[i] ); + PRECACHE_SOUND_ARRAY( pAttackSounds ); + PRECACHE_SOUND_ARRAY( pAlertSounds ); } int CLeech::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) @@ -289,7 +285,7 @@ int CLeech::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float f // Nudge the leech away from the damage if( pevInflictor ) { - pev->velocity = ( pev->origin - pevInflictor->origin ).Normalize() * 25; + pev->velocity = ( pev->origin - pevInflictor->origin ).Normalize() * 25.0f; } return CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType ); @@ -315,7 +311,7 @@ void CLeech::HandleAnimEvent( MonsterEvent_t *pEvent ) dir = dir.Normalize(); face = face.Normalize(); - if( DotProduct( dir, face ) > 0.9 ) // Only take damage if the leech is facing the prey + if( DotProduct( dir, face ) > 0.9f ) // Only take damage if the leech is facing the prey pEnemy->TakeDamage( pev, pev, gSkillData.leechDmgBite, DMG_SLASH ); } m_stateTime -= 2; @@ -354,12 +350,12 @@ float CLeech::ObstacleDistance( CBaseEntity *pTarget ) if( tr.fStartSolid ) { - pev->speed = -LEECH_SWIM_SPEED * 0.5; + pev->speed = -LEECH_SWIM_SPEED * 0.5f; //ALERT( at_console, "Stuck from (%f %f %f) to (%f %f %f)\n", pev->oldorigin.x, pev->oldorigin.y, pev->oldorigin.z, pev->origin.x, pev->origin.y, pev->origin.z ); //UTIL_SetOrigin( pev, pev->oldorigin ); } - if( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0f ) { if( ( pTarget == NULL || tr.pHit != pTarget->edict() ) ) { @@ -377,16 +373,16 @@ float CLeech::ObstacleDistance( CBaseEntity *pTarget ) // extra wide checks vecTest = pev->origin + gpGlobals->v_right * LEECH_SIZEX * 2 + gpGlobals->v_forward * LEECH_CHECK_DIST; UTIL_TraceLine( pev->origin, vecTest, missile, edict(), &tr ); - if( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0f ) return tr.flFraction; vecTest = pev->origin - gpGlobals->v_right * LEECH_SIZEX * 2 + gpGlobals->v_forward * LEECH_CHECK_DIST; UTIL_TraceLine( pev->origin, vecTest, missile, edict(), &tr ); - if( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0f ) return tr.flFraction; // Didn't hit either side, so stop testing for another 0.5 - 1 seconds - m_sideTime = gpGlobals->time + RANDOM_FLOAT( 0.5, 1 ); + m_sideTime = gpGlobals->time + RANDOM_FLOAT( 0.5f, 1.0f ); } return 1.0; } @@ -408,7 +404,7 @@ void CLeech::DeadThink( void ) } } StudioFrameAdvance(); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; // Apply damage velocity, but keep out of the walls if( pev->velocity.x != 0 || pev->velocity.y != 0 ) @@ -416,11 +412,11 @@ void CLeech::DeadThink( void ) TraceResult tr; // Look 0.5 seconds ahead - UTIL_TraceLine( pev->origin, pev->origin + pev->velocity * 0.5, missile, edict(), &tr ); - if( tr.flFraction != 1.0 ) + UTIL_TraceLine( pev->origin, pev->origin + pev->velocity * 0.5f, missile, edict(), &tr ); + if( tr.flFraction != 1.0f ) { - pev->velocity.x = 0; - pev->velocity.y = 0; + pev->velocity.x = 0.0f; + pev->velocity.y = 0.0f; } } } @@ -428,15 +424,15 @@ void CLeech::DeadThink( void ) void CLeech::UpdateMotion( void ) { float flapspeed = ( pev->speed - m_flAccelerate ) / LEECH_ACCELERATE; - m_flAccelerate = m_flAccelerate * 0.8 + pev->speed * 0.2; + m_flAccelerate = m_flAccelerate * 0.8f + pev->speed * 0.2f; if( flapspeed < 0 ) flapspeed = -flapspeed; - flapspeed += 1.0; - if( flapspeed < 0.5 ) - flapspeed = 0.5; - if( flapspeed > 1.9 ) - flapspeed = 1.9; + flapspeed += 1.0f; + if( flapspeed < 0.5f ) + flapspeed = 0.5f; + if( flapspeed > 1.9f ) + flapspeed = 1.9f; pev->framerate = flapspeed; @@ -445,9 +441,9 @@ void CLeech::UpdateMotion( void ) else pev->avelocity.y = pev->ideal_yaw * m_obstacle; - if( pev->avelocity.y > 150 ) + if( pev->avelocity.y > 150.0f ) m_IdealActivity = ACT_TURN_LEFT; - else if( pev->avelocity.y < -150 ) + else if( pev->avelocity.y < -150.0f ) m_IdealActivity = ACT_TURN_RIGHT; else m_IdealActivity = ACT_SWIM; @@ -463,10 +459,10 @@ void CLeech::UpdateMotion( void ) else targetPitch = 0; - pev->angles.x = UTIL_Approach( targetPitch, pev->angles.x, 60 * LEECH_FRAMETIME ); + pev->angles.x = UTIL_Approach( targetPitch, pev->angles.x, 60.0f * LEECH_FRAMETIME ); // bank - pev->avelocity.z = -( pev->angles.z + ( pev->avelocity.y * 0.25 ) ); + pev->avelocity.z = -( pev->angles.z + ( pev->avelocity.y * 0.25f ) ); if( m_MonsterState == MONSTERSTATE_COMBAT && HasConditions( bits_COND_CAN_MELEE_ATTACK1 ) ) m_IdealActivity = ACT_MELEE_ATTACK1; @@ -479,11 +475,11 @@ void CLeech::UpdateMotion( void ) pev->velocity = g_vecZero; // Animation will intersect the floor if either of these is non-zero - pev->angles.z = 0; - pev->angles.x = 0; + pev->angles.z = 0.0f; + pev->angles.x = 0.0f; - if( pev->framerate < 1.0 ) - pev->framerate = 1.0; + if( pev->framerate < 1.0f ) + pev->framerate = 1.0f; } else if( pev->movetype == MOVETYPE_TOSS ) { @@ -505,11 +501,11 @@ void CLeech::UpdateMotion( void ) if( !m_pt ) m_pt = CBeam::BeamCreate( "sprites/laserbeam.spr", 5 ); m_pb->PointsInit( pev->origin, pev->origin + gpGlobals->v_forward * LEECH_CHECK_DIST ); - m_pt->PointsInit( pev->origin, pev->origin - gpGlobals->v_right * ( pev->avelocity.y * 0.25 ) ); + m_pt->PointsInit( pev->origin, pev->origin - gpGlobals->v_right * ( pev->avelocity.y * 0.25f ) ); if( m_fPathBlocked ) { float color = m_obstacle * 30; - if( m_obstacle == 1.0 ) + if( m_obstacle == 1.0f ) color = 0; if( color > 255 ) color = 255; @@ -532,12 +528,12 @@ void CLeech::SwimThink( void ) if( FNullEnt( FIND_CLIENT_IN_PVS( edict() ) ) ) { - pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 1, 1.5 ); + pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 1.0f, 1.5f ); pev->velocity = g_vecZero; return; } else - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; targetSpeed = LEECH_SWIM_SPEED; @@ -572,10 +568,10 @@ void CLeech::SwimThink( void ) targetYaw = UTIL_AngleDiff( targetYaw, UTIL_AngleMod( pev->angles.y ) ); - if( targetYaw < ( -LEECH_TURN_RATE * 0.75 ) ) - targetYaw = ( -LEECH_TURN_RATE * 0.75 ); - else if( targetYaw > ( LEECH_TURN_RATE * 0.75 ) ) - targetYaw = ( LEECH_TURN_RATE * 0.75 ); + if( targetYaw < ( -LEECH_TURN_RATE * 0.75f ) ) + targetYaw = ( -LEECH_TURN_RATE * 0.75f ); + else if( targetYaw > ( LEECH_TURN_RATE * 0.75f ) ) + targetYaw = ( LEECH_TURN_RATE * 0.75f ); else targetSpeed *= 2; } @@ -584,7 +580,7 @@ void CLeech::SwimThink( void ) if( m_zTime < gpGlobals->time ) { float newHeight = RANDOM_FLOAT( m_bottom, m_top ); - m_height = 0.5 * m_height + 0.5 * newHeight; + m_height = 0.5f * m_height + 0.5f * newHeight; m_zTime = gpGlobals->time + RANDOM_FLOAT( 1, 4 ); } if( RANDOM_LONG( 0, 100 ) < 10 ) @@ -602,11 +598,11 @@ void CLeech::SwimThink( void ) m_obstacle = ObstacleDistance( pTarget ); pev->oldorigin = pev->origin; - if( m_obstacle < 0.1 ) - m_obstacle = 0.1; + if( m_obstacle < 0.1f ) + m_obstacle = 0.1f; // is the way ahead clear? - if( m_obstacle == 1.0 ) + if( m_obstacle == 1.0f ) { // if the leech is turning, stop the trend. if( m_flTurning != 0 ) @@ -621,7 +617,7 @@ void CLeech::SwimThink( void ) } else { - m_obstacle = 1.0 / m_obstacle; + m_obstacle = 1.0f / m_obstacle; // IF we get this far in the function, the leader's path is blocked! m_fPathBlocked = TRUE; @@ -639,12 +635,12 @@ void CLeech::SwimThink( void ) // turn left, right or random depending on clearance ratio float delta = ( flRightSide - flLeftSide ); - if( delta > 0.1 || ( delta > -0.1 && RANDOM_LONG( 0, 100 ) < 50 ) ) + if( delta > 0.1f || ( delta > -0.1f && RANDOM_LONG( 0, 100 ) < 50 ) ) m_flTurning = -LEECH_TURN_RATE; else m_flTurning = LEECH_TURN_RATE; } - pev->speed = UTIL_Approach( -( LEECH_SWIM_SPEED * 0.5 ), pev->speed, LEECH_SWIM_DECEL * LEECH_FRAMETIME * m_obstacle ); + pev->speed = UTIL_Approach( -( LEECH_SWIM_SPEED * 0.5f ), pev->speed, LEECH_SWIM_DECEL * LEECH_FRAMETIME * m_obstacle ); pev->velocity = gpGlobals->v_forward * pev->speed; } pev->ideal_yaw = m_flTurning + targetYaw; diff --git a/dlls/lights.cpp b/dlls/lights.cpp index 13e6d3a9..9ff839c3 100644 --- a/dlls/lights.cpp +++ b/dlls/lights.cpp @@ -162,9 +162,9 @@ void CEnvLight::KeyValue( KeyValueData* pkvd ) } // simulate qrad direct, ambient,and gamma adjustments, as well as engine scaling - r = (int)( pow( r / 114.0, 0.6 ) * 264.0 ); - g = (int)( pow( g / 114.0, 0.6 ) * 264.0 ); - b = (int)( pow( b / 114.0, 0.6 ) * 264.0 ); + r = (int)( pow( r / 114.0f, 0.6f ) * 264.0f ); + g = (int)( pow( g / 114.0f, 0.6f ) * 264.0f ); + b = (int)( pow( b / 114.0f, 0.6f ) * 264.0f ); pkvd->fHandled = TRUE; sprintf( szColor, "%d", r ); @@ -185,11 +185,11 @@ void CEnvLight::Spawn( void ) char szVector[64]; UTIL_MakeAimVectors( pev->angles ); - sprintf( szVector, "%f", gpGlobals->v_forward.x ); + sprintf( szVector, "%f", (double)gpGlobals->v_forward.x ); CVAR_SET_STRING( "sv_skyvec_x", szVector ); - sprintf( szVector, "%f", gpGlobals->v_forward.y ); + sprintf( szVector, "%f", (double)gpGlobals->v_forward.y ); CVAR_SET_STRING( "sv_skyvec_y", szVector ); - sprintf( szVector, "%f", gpGlobals->v_forward.z ); + sprintf( szVector, "%f", (double)gpGlobals->v_forward.z ); CVAR_SET_STRING( "sv_skyvec_z", szVector ); CLight::Spawn(); diff --git a/dlls/maprules.h b/dlls/maprules.h index 70a88fb5..4990b0cf 100644 --- a/dlls/maprules.h +++ b/dlls/maprules.h @@ -12,8 +12,8 @@ * without written permission from Valve LLC. * ****/ - -#ifndef MAPRULES_H +#pragma once +#if !defined(MAPRULES_H) #define MAPRULES_H #endif //MAPRULES_H diff --git a/dlls/monsterevent.h b/dlls/monsterevent.h index ab54b687..b3ca4e87 100644 --- a/dlls/monsterevent.h +++ b/dlls/monsterevent.h @@ -12,8 +12,8 @@ * without written permission from Valve LLC. * ****/ - -#ifndef MONSTEREVENT_H +#pragma once +#if !defined(MONSTEREVENT_H) #define MONSTEREVENT_H typedef struct diff --git a/dlls/monsters.cpp b/dlls/monsters.cpp index eeeeede1..2b2681e2 100644 --- a/dlls/monsters.cpp +++ b/dlls/monsters.cpp @@ -33,6 +33,7 @@ #include "decals.h" #include "soundent.h" #include "gamerules.h" +#include "game.h" #define MONSTER_CUT_CORNER_DIST 8 // 8 means the monster's bounding box is contained without the box of the node in WC @@ -273,7 +274,8 @@ void CBaseMonster::Listen( void ) } //iSound = g_pSoundEnt->m_SoundPool[iSound].m_iNext; - iSound = pCurrentSound->m_iNext; + if( pCurrentSound ) + iSound = pCurrentSound->m_iNext; } } @@ -442,18 +444,21 @@ CSound *CBaseMonster::PBestSound( void ) { pSound = CSoundEnt::SoundPointerForIndex( iThisSound ); - if( pSound && pSound->FIsSound() ) + if( pSound ) { - flDist = ( pSound->m_vecOrigin - EarPosition() ).Length(); - - if( flDist < flBestDist ) + if( pSound->FIsSound() ) { - iBestSound = iThisSound; - flBestDist = flDist; - } - } + flDist = ( pSound->m_vecOrigin - EarPosition() ).Length(); - iThisSound = pSound->m_iNextAudible; + if( flDist < flBestDist ) + { + iBestSound = iThisSound; + flBestDist = flDist; + } + } + + iThisSound = pSound->m_iNextAudible; + } } if( iBestSound >= 0 ) { @@ -524,7 +529,7 @@ CSound *CBaseMonster::PBestScent( void ) //========================================================= void CBaseMonster::MonsterThink( void ) { - pev->nextthink = gpGlobals->time + 0.1;// keep monster thinking. + pev->nextthink = gpGlobals->time + 0.1f;// keep monster thinking. RunAI(); @@ -577,7 +582,8 @@ void CBaseMonster::MonsterThink( void ) //========================================================= void CBaseMonster::MonsterUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - m_IdealMonsterState = MONSTERSTATE_ALERT; + if (m_MonsterState == MONSTERSTATE_IDLE) + m_IdealMonsterState = MONSTERSTATE_ALERT; } //========================================================= @@ -734,7 +740,7 @@ BOOL CBaseMonster::MoveToNode( Activity movementAct, float waitTime, const Vecto return FRefreshRoute(); } -#ifdef _DEBUG +#if _DEBUG void DrawRoute( entvars_t *pev, WayPoint_t *m_Route, int m_iRouteIndex, int r, int g, int b ) { int i; @@ -861,10 +867,10 @@ void CBaseMonster::RouteSimplify( CBaseEntity *pTargetEnt ) Vector vecTest, vecSplit; // Halfway between this and next - vecTest = ( m_Route[m_iRouteIndex + i + 1].vecLocation + m_Route[m_iRouteIndex + i].vecLocation ) * 0.5; + vecTest = ( m_Route[m_iRouteIndex + i + 1].vecLocation + m_Route[m_iRouteIndex + i].vecLocation ) * 0.5f; // Halfway between this and previous - vecSplit = ( m_Route[m_iRouteIndex + i].vecLocation + vecStart ) * 0.5; + vecSplit = ( m_Route[m_iRouteIndex + i].vecLocation + vecStart ) * 0.5f; int iType = ( m_Route[m_iRouteIndex + i].iType | bits_MF_TO_DETOUR ) & ~bits_MF_NOT_TO_MASK; if( CheckLocalMove( vecStart, vecTest, pTargetEnt, NULL ) == LOCALMOVE_VALID ) @@ -938,7 +944,7 @@ BOOL CBaseMonster::FBecomeProne( void ) //========================================================= BOOL CBaseMonster::CheckRangeAttack1( float flDot, float flDist ) { - if( flDist > 64 && flDist <= 784 && flDot >= 0.5 ) + if( flDist > 64.0f && flDist <= 784.0f && flDot >= 0.5f ) { return TRUE; } @@ -950,7 +956,7 @@ BOOL CBaseMonster::CheckRangeAttack1( float flDot, float flDist ) //========================================================= BOOL CBaseMonster::CheckRangeAttack2( float flDot, float flDist ) { - if( flDist > 64 && flDist <= 512 && flDot >= 0.5 ) + if( flDist > 64.0f && flDist <= 512.0f && flDot >= 0.5f ) { return TRUE; } @@ -963,7 +969,7 @@ BOOL CBaseMonster::CheckRangeAttack2( float flDot, float flDist ) BOOL CBaseMonster::CheckMeleeAttack1( float flDot, float flDist ) { // Decent fix to keep folks from kicking/punching hornets and snarks is to check the onground flag(sjb) - if( flDist <= 64 && flDot >= 0.7 && m_hEnemy != 0 && FBitSet( m_hEnemy->pev->flags, FL_ONGROUND ) ) + if( flDist <= 64.0f && flDot >= 0.7f && m_hEnemy != 0 && FBitSet( m_hEnemy->pev->flags, FL_ONGROUND ) ) { return TRUE; } @@ -975,7 +981,7 @@ BOOL CBaseMonster::CheckMeleeAttack1( float flDot, float flDist ) //========================================================= BOOL CBaseMonster::CheckMeleeAttack2( float flDot, float flDist ) { - if( flDist <= 64 && flDot >= 0.7 ) + if( flDist <= 64.0f && flDot >= 0.7f ) { return TRUE; } @@ -1073,7 +1079,7 @@ int CBaseMonster::CheckEnemy( CBaseEntity *pEnemy ) // distance to enemy's origin flDistToEnemy = ( vecEnemyPos - pev->origin ).Length(); - vecEnemyPos.z += pEnemy->pev->size.z * 0.5; + vecEnemyPos.z += pEnemy->pev->size.z * 0.5f; // distance to enemy's head float flDistToEnemy2 = ( vecEnemyPos - pev->origin ).Length(); @@ -1110,7 +1116,7 @@ int CBaseMonster::CheckEnemy( CBaseEntity *pEnemy ) if( pEnemy->pev->velocity != Vector( 0, 0, 0 ) ) { // trail the enemy a bit - m_vecEnemyLKP = m_vecEnemyLKP - pEnemy->pev->velocity * RANDOM_FLOAT( -0.05, 0 ); + m_vecEnemyLKP = m_vecEnemyLKP - pEnemy->pev->velocity * RANDOM_FLOAT( -0.05f, 0.0f ); } else { @@ -1146,7 +1152,7 @@ int CBaseMonster::CheckEnemy( CBaseEntity *pEnemy ) if( m_Route[i].iType == ( bits_MF_IS_GOAL | bits_MF_TO_ENEMY ) ) { // UNDONE: Should we allow monsters to override this distance (80?) - if( ( m_Route[i].vecLocation - m_vecEnemyLKP ).Length() > 80 ) + if( ( m_Route[i].vecLocation - m_vecEnemyLKP ).Length() > 80.0f ) { // Refresh FRefreshRoute(); @@ -1368,7 +1374,7 @@ int CBaseMonster::CheckLocalMove( const Vector &vecStart, const Vector &vecEnd, { // The monster can move to a spot UNDER the target, but not to it. Don't try to triangulate, go directly to the node graph. // UNDONE: Magic # 64 -- this used to be pev->size.z but that won't work for small creatures like the headcrab - if( fabs( vecEnd.z - pev->origin.z ) > 64 ) + if( fabs( vecEnd.z - pev->origin.z ) > 64.0f ) { iReturn = LOCALMOVE_INVALID_DONT_TRIANGULATE; } @@ -1489,7 +1495,7 @@ void CBaseMonster::AdvanceRoute( float distance ) } else // At goal!!! { - if( distance < m_flGroundSpeed * 0.2 /* FIX */ ) + if( distance < m_flGroundSpeed * 0.2f /* FIX */ ) { MovementComplete(); } @@ -1623,13 +1629,13 @@ BOOL CBaseMonster::FTriangulate( const Vector &vecStart, const Vector &vecEnd, f // If the hull width is less than 24, use 24 because CheckLocalMove uses a min of // 24. sizeX = pev->size.x; - if( sizeX < 24.0 ) - sizeX = 24.0; - else if( sizeX > 48.0 ) - sizeX = 48.0; + if( sizeX < 24.0f ) + sizeX = 24.0f; + else if( sizeX > 48.0f ) + sizeX = 48.0f; sizeZ = pev->size.z; - //if( sizeZ < 24.0 ) - // sizeZ = 24.0; + //if( sizeZ < 24.0f ) + // sizeZ = 24.0f; vecForward = ( vecEnd - vecStart ).Normalize(); @@ -1867,7 +1873,7 @@ void CBaseMonster::Move( float flInterval ) DispatchBlocked( edict(), pBlocker->edict() ); } - if( pBlocker && m_moveWaitTime > 0 && pBlocker->IsMoving() && !pBlocker->IsPlayer() && ( gpGlobals->time-m_flMoveWaitFinished ) > 3.0 ) + if( pBlocker && m_moveWaitTime > 0 && pBlocker->IsMoving() && !pBlocker->IsPlayer() && ( gpGlobals->time-m_flMoveWaitFinished ) > 3.0f ) { // Can we still move toward our target? if( flDist < m_flGroundSpeed ) @@ -1902,10 +1908,10 @@ void CBaseMonster::Move( float flInterval ) else { // Don't get stuck - if( ( gpGlobals->time - m_flMoveWaitFinished ) < 0.2 ) + if( ( gpGlobals->time - m_flMoveWaitFinished ) < 0.2f ) Remember( bits_MEMORY_MOVE_FAILED ); - m_flMoveWaitFinished = gpGlobals->time + 0.1; + m_flMoveWaitFinished = gpGlobals->time + 0.1f; } } else @@ -1968,10 +1974,10 @@ void CBaseMonster::MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, f float flTotal = m_flGroundSpeed * pev->framerate * flInterval; float flStep; - while( flTotal > 0.001 ) + while( flTotal > 0.001f ) { // don't walk more than 16 units or stairs stop working - flStep = Q_min( 16.0, flTotal ); + flStep = Q_min( 16.0f, flTotal ); UTIL_MoveToOrigin( ENT( pev ), m_Route[m_iRouteIndex].vecLocation, flStep, MOVE_NORMAL ); flTotal -= flStep; } @@ -2019,15 +2025,17 @@ void CBaseMonster::MonsterInit( void ) m_hEnemy = NULL; - m_flDistTooFar = 1024.0; - m_flDistLook = 2048.0; + m_flDistTooFar = 1024.0f; + m_flDistLook = 2048.0f; // set eye position SetEyePosition(); SetThink( &CBaseMonster::MonsterInitThink ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; SetUse( &CBaseMonster::MonsterUse ); + + m_flLastYawTime = gpGlobals->time; } //========================================================= @@ -2072,10 +2080,9 @@ void CBaseMonster::StartMonster( void ) // Try to move the monster to make sure it's not stuck in a brush. if( !WALK_MOVE( ENT( pev ), 0, 0, WALKMOVE_NORMAL ) ) { -#ifdef _DEBUG ALERT( at_error, "Monster %s stuck in wall--level design error\n", STRING( pev->classname ) ); - pev->effects |= EF_BRIGHTFIELD; -#endif + if( g_psv_developer && g_psv_developer->value ) + pev->effects = EF_BRIGHTFIELD; } } else @@ -2130,7 +2137,7 @@ void CBaseMonster::StartMonster( void ) // Delay drop to floor to make sure each door in the level has had its chance to spawn // Spread think times so that they don't all happen at the same time (Carmack) SetThink( &CBaseMonster::CallMonsterThink ); - pev->nextthink += RANDOM_FLOAT( 0.1, 0.4 ); // spread think times. + pev->nextthink += RANDOM_FLOAT( 0.1f, 0.4f ); // spread think times. // Vit_amiN: fixed -- now it doesn't touch any scripted_sequence target if( !FStringNull( pev->targetname ) && !m_pCine )// wait until triggered @@ -2227,12 +2234,12 @@ BOOL CBaseMonster::FindCover( Vector vecThreat, Vector vecViewOffset, float flMi flMaxDist = 784; } - if( flMinDist > 0.5 * flMaxDist ) + if( flMinDist > 0.5f * flMaxDist ) { #if _DEBUG ALERT( at_console, "FindCover MinDist (%.0f) too close to MaxDist (%.0f)\n", flMinDist, flMaxDist ); #endif - flMinDist = 0.5 * flMaxDist; + flMinDist = 0.5f * flMaxDist; } if( !WorldGraph.m_fGraphPresent || !WorldGraph.m_fGraphPointersSet ) @@ -2277,7 +2284,7 @@ BOOL CBaseMonster::FindCover( Vector vecThreat, Vector vecViewOffset, float flMi UTIL_TraceLine( node.m_vecOrigin + vecViewOffset, vecLookersOffset, ignore_monsters, ignore_glass, ENT( pev ), &tr ); // if this node will block the threat's line of sight to me... - if( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0f ) { // ..and is also closer to me than the threat, or the same distance from myself and the threat the node is good. if( ( iMyNode == iThreatNode ) || WorldGraph.PathLength( iMyNode, nodeNumber, iMyHullIndex, m_afCapability ) <= WorldGraph.PathLength( iThreatNode, nodeNumber, iMyHullIndex, m_afCapability ) ) @@ -2331,12 +2338,12 @@ BOOL CBaseMonster::BuildNearestRoute( Vector vecThreat, Vector vecViewOffset, fl flMaxDist = 784; } - if( flMinDist > 0.5 * flMaxDist ) + if( flMinDist > 0.5f * flMaxDist ) { #if _DEBUG ALERT( at_console, "FindCover MinDist (%.0f) too close to MaxDist (%.0f)\n", flMinDist, flMaxDist ); #endif - flMinDist = 0.5 * flMaxDist; + flMinDist = 0.5f * flMaxDist; } if( !WorldGraph.m_fGraphPresent || !WorldGraph.m_fGraphPointersSet ) @@ -2375,12 +2382,12 @@ BOOL CBaseMonster::BuildNearestRoute( Vector vecThreat, Vector vecViewOffset, fl // can I see where I want to be from there? UTIL_TraceLine( node.m_vecOrigin + pev->view_ofs, vecLookersOffset, ignore_monsters, edict(), &tr ); - if( tr.flFraction == 1.0 ) + if( tr.flFraction == 1.0f ) { // try to actually get there if( BuildRoute( node.m_vecOrigin, bits_MF_TO_LOCATION, NULL ) ) { - flMaxDist = flDist; + // flMaxDist = flDist; m_vecMoveGoal = node.m_vecOrigin; return TRUE; // UNDONE: keep looking for something closer! } @@ -2510,7 +2517,17 @@ float CBaseMonster::ChangeYaw( int yawSpeed ) ideal = pev->ideal_yaw; if( current != ideal ) { - speed = (float)yawSpeed * gpGlobals->frametime * 10; + if( monsteryawspeedfix.value ) + { + float delta; + + delta = Q_min( gpGlobals->time - m_flLastYawTime, 0.25f ); + + speed = (float)yawSpeed * delta * 2; + } + else + speed = (float)yawSpeed * gpGlobals->frametime * 10; + move = ideal - current; if( ideal > current ) @@ -2554,6 +2571,8 @@ float CBaseMonster::ChangeYaw( int yawSpeed ) else move = 0; + m_flLastYawTime = gpGlobals->time; + return move; } @@ -2827,7 +2846,7 @@ int CBaseMonster::FindHintNode( void ) { UTIL_TraceLine( pev->origin + pev->view_ofs, node.m_vecOrigin + pev->view_ofs, ignore_monsters, ENT( pev ), &tr ); - if( tr.flFraction == 1.0 ) + if( tr.flFraction == 1.0f ) { WorldGraph.m_iLastActiveIdleSearch = nodeNumber + 1; // next monster that searches for hint nodes will start where we left off. return nodeNumber;// take it! @@ -2885,7 +2904,7 @@ void CBaseMonster::ReportAIState( void ) { ALERT( level, " Moving " ); if( m_flMoveWaitFinished > gpGlobals->time ) - ALERT( level, ": Stopped for %.2f. ", m_flMoveWaitFinished - gpGlobals->time ); + ALERT( level, ": Stopped for %.2f. ", (double)(m_flMoveWaitFinished - gpGlobals->time) ); else if( m_IdealActivity == GetStoppedActivity() ) ALERT( level, ": In stopped anim. " ); } @@ -2910,7 +2929,7 @@ void CBaseMonster::ReportAIState( void ) } ALERT( level, "\n" ); - ALERT( level, "Yaw speed:%3.1f,Health: %3.1f\n", pev->yaw_speed, pev->health ); + ALERT( level, "Yaw speed:%3.1f,Health: %3.1f\n", (double)pev->yaw_speed, (double)pev->health ); if( pev->spawnflags & SF_MONSTER_PRISONER ) ALERT( level, " PRISONER! " ); if( pev->spawnflags & SF_MONSTER_PREDISASTER ) @@ -3108,7 +3127,7 @@ BOOL CBaseMonster::FindLateralCover( const Vector &vecThreat, const Vector &vecV // it's faster to check the SightEnt's visibility to the potential spot than to check the local move, so we do that first. UTIL_TraceLine( vecThreat + vecViewOffset, vecLeftTest + pev->view_ofs, ignore_monsters, ignore_glass, ENT( pev )/*pentIgnore*/, &tr ); - if( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0f ) { if( FValidateCover( vecLeftTest ) && CheckLocalMove( pev->origin, vecLeftTest, NULL, NULL ) == LOCALMOVE_VALID ) { @@ -3122,7 +3141,7 @@ BOOL CBaseMonster::FindLateralCover( const Vector &vecThreat, const Vector &vecV // it's faster to check the SightEnt's visibility to the potential spot than to check the local move, so we do that first. UTIL_TraceLine( vecThreat + vecViewOffset, vecRightTest + pev->view_ofs, ignore_monsters, ignore_glass, ENT(pev)/*pentIgnore*/, &tr ); - if( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0f ) { if( FValidateCover( vecRightTest ) && CheckLocalMove( pev->origin, vecRightTest, NULL, NULL ) == LOCALMOVE_VALID ) { @@ -3158,7 +3177,7 @@ Vector CBaseMonster::ShootAtEnemy( const Vector &shootOrigin ) //========================================================= BOOL CBaseMonster::FacingIdeal( void ) { - if( fabs( FlYawDiff() ) <= 0.006 )//!!!BUGBUG - no magic numbers!!! + if( fabs( FlYawDiff() ) <= 0.006f )//!!!BUGBUG - no magic numbers!!! { return TRUE; } @@ -3211,7 +3230,7 @@ void CBaseMonster::CorpseFallThink( void ) UTIL_SetOrigin( pev, pev->origin );// link into world. } else - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } // Call after animation/pose is set up @@ -3236,7 +3255,7 @@ void CBaseMonster::MonsterInitDead( void ) // Setup health counters, etc. BecomeDead(); SetThink( &CBaseMonster::CorpseFallThink ); - pev->nextthink = gpGlobals->time + 0.5; + pev->nextthink = gpGlobals->time + 0.5f; } //========================================================= @@ -3291,7 +3310,7 @@ BOOL CBaseMonster::BBoxFlat( void ) { return FALSE; } - flLength = flLength2; + // flLength = flLength2; return TRUE; } diff --git a/dlls/monsters.h b/dlls/monsters.h index ba3cd984..03623973 100644 --- a/dlls/monsters.h +++ b/dlls/monsters.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef MONSTERS_H +#if !defined(MONSTERS_H) #include "skill.h" #define MONSTERS_H diff --git a/dlls/monsterstate.cpp b/dlls/monsterstate.cpp index cec29b79..a642873b 100644 --- a/dlls/monsterstate.cpp +++ b/dlls/monsterstate.cpp @@ -66,7 +66,7 @@ void CBaseMonster::RunAI( void ) // IDLE sound permitted in ALERT state is because monsters were silent in ALERT state. Only play IDLE sound in IDLE state // once we have sounds for that state. - if( ( m_MonsterState == MONSTERSTATE_IDLE || m_MonsterState == MONSTERSTATE_ALERT ) && RANDOM_LONG( 0, 99 ) == 0 && !( pev->flags & SF_MONSTER_GAG ) ) + if( ( m_MonsterState == MONSTERSTATE_IDLE || m_MonsterState == MONSTERSTATE_ALERT ) && RANDOM_LONG( 0, 99 ) == 0 && !( pev->spawnflags & SF_MONSTER_GAG ) ) { IdleSound(); } diff --git a/dlls/mp5.cpp b/dlls/mp5.cpp index 426f738a..2b2d07ab 100644 --- a/dlls/mp5.cpp +++ b/dlls/mp5.cpp @@ -126,14 +126,14 @@ void CMP5::PrimaryAttack() if( m_pPlayer->pev->waterlevel == 3 ) { PlayEmptySound(); - m_flNextPrimaryAttack = 0.15; + m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15f; return; } if( m_iClip <= 0 ) { PlayEmptySound(); - m_flNextPrimaryAttack = 0.15; + m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15f; return; } @@ -150,10 +150,10 @@ void CMP5::PrimaryAttack() Vector vecSrc = m_pPlayer->GetGunPosition(); Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES ); Vector vecDir; -#ifdef CLIENT_DLL - if( !bIsMultiplayer() ) +#if CLIENT_DLL + if( bIsMultiplayer() ) #else - if( !g_pGameRules->IsMultiplayer() ) + if( g_pGameRules->IsMultiplayer() ) #endif { // optimized multiplayer. Widened to make it easier to hit a moving player @@ -166,21 +166,21 @@ void CMP5::PrimaryAttack() } int flags; -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS flags = FEV_NOTHOST; #else flags = 0; #endif - PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usMP5, 0.0, g_vecZero, g_vecZero, vecDir.x, vecDir.y, 0, 0, 0, 0 ); + PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usMP5, 0.0f, g_vecZero, g_vecZero, vecDir.x, vecDir.y, 0, 0, 0, 0 ); if( !m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) // HEV suit - indicate out of ammo condition m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 ); - m_flNextPrimaryAttack = GetNextAttackDelay( 0.1 ); + m_flNextPrimaryAttack = GetNextAttackDelay( 0.1f ); if( m_flNextPrimaryAttack < UTIL_WeaponTimeBase() ) - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.1; + m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.1f; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); } @@ -191,7 +191,7 @@ void CMP5::SecondaryAttack( void ) if( m_pPlayer->pev->waterlevel == 3 ) { PlayEmptySound( ); - m_flNextPrimaryAttack = 0.15; + m_flNextPrimaryAttack = 0.15f; return; } @@ -205,7 +205,7 @@ void CMP5::SecondaryAttack( void ) m_pPlayer->m_iWeaponFlash = BRIGHT_GUN_FLASH; m_pPlayer->m_iExtraSoundTypes = bits_SOUND_DANGER; - m_pPlayer->m_flStopExtraSoundTime = UTIL_WeaponTimeBase() + 0.2; + m_pPlayer->m_flStopExtraSoundTime = UTIL_WeaponTimeBase() + 0.2f; m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType]--; @@ -216,20 +216,20 @@ void CMP5::SecondaryAttack( void ) // we don't add in player velocity anymore. CGrenade::ShootContact( m_pPlayer->pev, - m_pPlayer->pev->origin + m_pPlayer->pev->view_ofs + gpGlobals->v_forward * 16, - gpGlobals->v_forward * 800 ); + m_pPlayer->pev->origin + m_pPlayer->pev->view_ofs + gpGlobals->v_forward * 16.0f, + gpGlobals->v_forward * 800.0f ); int flags; -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS flags = FEV_NOTHOST; #else flags = 0; #endif PLAYBACK_EVENT( flags, m_pPlayer->edict(), m_usMP52 ); - m_flNextPrimaryAttack = GetNextAttackDelay( 1 ); - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5;// idle pretty soon after shooting. + m_flNextPrimaryAttack = GetNextAttackDelay( 1.0f ); + m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0f; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5.0f;// idle pretty soon after shooting. if( !m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType] ) // HEV suit - indicate out of ammo condition @@ -241,7 +241,7 @@ void CMP5::Reload( void ) if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == MP5_MAX_CLIP ) return; - DefaultReload( MP5_MAX_CLIP, MP5_RELOAD, 1.5 ); + DefaultReload( MP5_MAX_CLIP, MP5_RELOAD, 1.5f ); } void CMP5::WeaponIdle( void ) @@ -270,12 +270,6 @@ void CMP5::WeaponIdle( void ) m_flTimeWeaponIdle = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); // how long till we do this again. } -BOOL CMP5::IsUseable() -{ - //Can be used if the player has AR grenades. - Solokiller - return CBasePlayerWeapon::IsUseable() || m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType] > 0; -} - class CMP5AmmoClip : public CBasePlayerAmmo { void Spawn( void ) diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index e9b78716..c0a59e9e 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -26,7 +26,7 @@ #include "skill.h" #include "game.h" #include "items.h" -#ifndef NO_VOICEGAMEMGR +#if !NO_VOICEGAMEMGR #include "voice_gamemgr.h" #endif #include "hltv.h" @@ -42,7 +42,7 @@ extern int g_teamplay; float g_flIntermissionStartTime = 0; -#ifndef NO_VOICEGAMEMGR +#if !NO_VOICEGAMEMGR CVoiceGameMgr g_VoiceGameMgr; class CMultiplayGameMgrHelper : public IVoiceGameMgrHelper @@ -71,7 +71,7 @@ static CMultiplayGameMgrHelper g_GameMgrHelper; //********************************************************* CHalfLifeMultiplay::CHalfLifeMultiplay() { -#ifndef NO_VOICEGAMEMGR +#if !NO_VOICEGAMEMGR g_VoiceGameMgr.Init( &g_GameMgrHelper, gpGlobals->maxClients ); #endif RefreshSkillData(); @@ -123,7 +123,7 @@ void UTIL_CoopProcessMenu( CBasePlayer *pPlayer, int imenu ); BOOL CHalfLifeMultiplay::ClientCommand( CBasePlayer *pPlayer, const char *pcmd ) { -#ifndef NO_VOICEGAMEMGR +#if !NO_VOICEGAMEMGR if( g_VoiceGameMgr.ClientCommand( pPlayer, pcmd ) ) return TRUE; #endif @@ -196,7 +196,7 @@ extern cvar_t mp_chattime; //========================================================= void CHalfLifeMultiplay::Think( void ) { -#ifndef NO_VOICEGAMEMGR +#if !NO_VOICEGAMEMGR g_VoiceGameMgr.Update( gpGlobals->frametime ); #endif @@ -321,6 +321,17 @@ BOOL CHalfLifeMultiplay::FShouldSwitchWeapon( CBasePlayer *pPlayer, CBasePlayerI return TRUE; } + if( !pPlayer->m_iAutoWepSwitch ) + { + return FALSE; + } + + if( pPlayer->m_iAutoWepSwitch == 2 + && pPlayer->m_afButtonLast & ( IN_ATTACK | IN_ATTACK2 ) ) + { + return FALSE; + } + if( !pPlayer->m_pActiveItem->CanHolster() ) { // can't put away the active item. @@ -405,7 +416,7 @@ BOOL CHalfLifeMultiplay::GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerIte //========================================================= BOOL CHalfLifeMultiplay::ClientConnected( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128] ) { -#ifndef NO_VOICEGAMEMGR +#if !NO_VOICEGAMEMGR g_VoiceGameMgr.ClientConnected( pEntity ); #endif return TRUE; @@ -611,6 +622,11 @@ void CHalfLifeMultiplay::PlayerSpawn( CBasePlayer *pPlayer ) { BOOL addDefault = !mp_skipdefaults.value; CBaseEntity *pWeaponEntity = NULL; + int iOldAutoWepSwitch; + + iOldAutoWepSwitch = pPlayer->m_iAutoWepSwitch; + + pPlayer->m_iAutoWepSwitch = 1; if( GGM_PlayerSpawn( pPlayer ) ) return; @@ -650,6 +666,8 @@ void CHalfLifeMultiplay::PlayerSpawn( CBasePlayer *pPlayer ) { COOP_GiveDefaultWeapons( pPlayer ); } + + pPlayer->m_iAutoWepSwitch = iOldAutoWepSwitch; } //========================================================= @@ -766,12 +784,12 @@ void CHalfLifeMultiplay::DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, const char *tau = "tau_cannon"; const char *gluon = "gluon gun"; - if( pKiller->flags & FL_CLIENT ) + if( pevInflictor ) { - killer_index = ENTINDEX( ENT( pKiller ) ); - - if( pevInflictor ) + if( pKiller->flags & FL_CLIENT ) { + killer_index = ENTINDEX( ENT( pKiller ) ); + if( pevInflictor == pKiller ) { // If the inflictor is the killer, then it must be their current weapon doing the damage @@ -787,10 +805,10 @@ void CHalfLifeMultiplay::DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, killer_weapon_name = STRING( pevInflictor->classname ); // it's just that easy } } - } - else - { - killer_weapon_name = STRING( pevInflictor->classname ); + else + { + killer_weapon_name = STRING( pevInflictor->classname ); + } } // strip the monster_* or weapon_* from the inflictor's classname @@ -1414,7 +1432,8 @@ int ReloadMapCycleFile( const char *filename, mapcycle_t *cycle ) hasbuffer = 0; pFileList = COM_Parse( pFileList ); - if( strlen( com_token ) <= 0 ) + + if( com_token[0] == '\0' ) break; strcpy( szMap, com_token ); @@ -1423,7 +1442,8 @@ int ReloadMapCycleFile( const char *filename, mapcycle_t *cycle ) if( COM_TokenWaiting( pFileList ) ) { pFileList = COM_Parse( pFileList ); - if( strlen( com_token ) > 0 ) + + if( com_token[0] != '\0' ) { hasbuffer = 1; strcpy( szBuffer, com_token ); @@ -1579,7 +1599,8 @@ void ExtractCommandString( char *s, char *szCommand ) *o = 0; strcat( szCommand, pkey ); - if( strlen( value ) > 0 ) + + if( value[0] != '\0' ) { strcat( szCommand, " " ); strcat( szCommand, value ); @@ -1714,13 +1735,15 @@ void CHalfLifeMultiplay::ChangeLevel( void ) { ALERT( at_console, "PLAYER COUNT: min %i max %i current %i\n", minplayers, maxplayers, curplayers ); } - if( strlen( szRules ) > 0 ) + + if( szRules[0] != '\0' ) { ALERT( at_console, "RULES: %s\n", szRules ); } CHANGE_LEVEL( szNextMap, NULL ); - if( strlen( szCommands ) > 0 ) + + if( szCommands[0] != '\0' ) { SERVER_COMMAND( szCommands ); } diff --git a/dlls/nihilanth.cpp b/dlls/nihilanth.cpp index 1d072db4..951ee38c 100644 --- a/dlls/nihilanth.cpp +++ b/dlls/nihilanth.cpp @@ -12,7 +12,7 @@ * use or distribution of this code by or to any unlicensed person is illegal. * ****/ -#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD ) +#if !OEM_BUILD && !HLDEMO_BUILD #include "extdll.h" #include "util.h" @@ -298,7 +298,7 @@ void CNihilanth::Spawn( void ) InitBoneControllers(); SetThink( &CNihilanth::StartupThink ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; m_vecDesired = Vector( 1, 0, 0 ); m_posDesired = Vector( pev->origin.x, pev->origin.y, 512 ); @@ -391,13 +391,13 @@ void CNihilanth::DeathSound( void ) void CNihilanth::NullThink( void ) { StudioFrameAdvance(); - pev->nextthink = gpGlobals->time + 0.5; + pev->nextthink = gpGlobals->time + 0.5f; } void CNihilanth::StartupUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { SetThink( &CNihilanth::HuntThink ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; SetUse( &CNihilanth::CommandUse ); } @@ -429,7 +429,7 @@ void CNihilanth::StartupThink( void ) SetThink( &CNihilanth::HuntThink ); SetUse( &CNihilanth::CommandUse ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } void CNihilanth::Killed( entvars_t *pevAttacker, int iGib ) @@ -439,7 +439,7 @@ void CNihilanth::Killed( entvars_t *pevAttacker, int iGib ) void CNihilanth::DyingThink( void ) { - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; DispatchAnimEvents(); StudioFrameAdvance(); @@ -494,13 +494,13 @@ void CNihilanth::DyingThink( void ) do { vecDir = Vector( RANDOM_FLOAT( -1, 1 ), RANDOM_FLOAT( -1, 1 ), RANDOM_FLOAT( -1, 1 ) ); - } while( DotProduct( vecDir, vecDir ) > 1.0 ); + } while( DotProduct( vecDir, vecDir ) > 1.0f ); switch( RANDOM_LONG( 1, 4 ) ) { case 1: // head - vecDir.z = fabs( vecDir.z ) * 0.5; + vecDir.z = fabs( vecDir.z ) * 0.5f; vecDir = vecDir + 2 * gpGlobals->v_up; break; case 2: @@ -551,7 +551,7 @@ void CNihilanth::DyingThink( void ) GetAttachment( 0, vecSrc, vecAngles ); CNihilanthHVR *pEntity = (CNihilanthHVR *)Create( "nihilanth_energy_ball", vecSrc, pev->angles, edict() ); - pEntity->pev->velocity = Vector( RANDOM_FLOAT( -0.7, 0.7 ), RANDOM_FLOAT( -0.7, 0.7 ), 1.0 ) * 600.0; + pEntity->pev->velocity = Vector( RANDOM_FLOAT( -0.7f, 0.7f ), RANDOM_FLOAT( -0.7f, 0.7f ), 1.0f ) * 600.0f; pEntity->GreenBallInit(); return; @@ -619,7 +619,7 @@ void CNihilanth::ShootBalls( void ) vecDir = ( m_posTarget - pev->origin ).Normalize(); vecSrc = vecSrc + vecDir * ( gpGlobals->time - m_flShootTime ); pEntity = (CNihilanthHVR *)Create( "nihilanth_energy_ball", vecSrc, pev->angles, edict() ); - pEntity->pev->velocity = vecDir * 200.0; + pEntity->pev->velocity = vecDir * 200.0f; pEntity->ZapInit( m_hEnemy ); GetAttachment( 3, vecHand, vecAngle ); @@ -628,10 +628,10 @@ void CNihilanth::ShootBalls( void ) vecDir = ( m_posTarget - pev->origin ).Normalize(); vecSrc = vecSrc + vecDir * ( gpGlobals->time - m_flShootTime ); pEntity = (CNihilanthHVR *)Create( "nihilanth_energy_ball", vecSrc, pev->angles, edict() ); - pEntity->pev->velocity = vecDir * 200.0; + pEntity->pev->velocity = vecDir * 200.0f; pEntity->ZapInit( m_hEnemy ); } - m_flShootTime += 0.2; + m_flShootTime += 0.2f; } } } @@ -698,8 +698,8 @@ void CNihilanth::NextActivity() { m_pBall->SetTransparency( kRenderTransAdd, 255, 255, 255, 255, kRenderFxNoDissipation ); m_pBall->SetAttachment( edict(), 1 ); - m_pBall->SetScale( 4.0 ); - m_pBall->pev->framerate = 10.0; + m_pBall->SetScale( 4.0f ); + m_pBall->pev->framerate = 10.0f; m_pBall->TurnOn(); } } @@ -724,7 +724,7 @@ void CNihilanth::NextActivity() if( ( pev->health < gSkillData.nihilanthHealth / 2 || m_iActiveSpheres < N_SPHERES / 2 ) && m_hRecharger == 0 && m_iLevel <= 9 ) { - char szName[64]; + char szName[128]; CBaseEntity *pEnt = NULL; CBaseEntity *pRecharger = NULL; @@ -766,13 +766,13 @@ void CNihilanth::NextActivity() if( m_hRecharger != 0 ) { // at we at power up yet? - if( flDist < 128.0 ) + if( flDist < 128.0f ) { int iseq = LookupSequence( "recharge" ); if( iseq != pev->sequence ) { - char szText[64]; + char szText[128]; sprintf( szText, "%s%d", m_szDrawUse, m_iLevel ); FireTargets( szText, this, this, USE_ON, 1.0 ); @@ -808,7 +808,7 @@ void CNihilanth::NextActivity() { if( m_flLastSeen + 5 > gpGlobals->time && flDist < 256 && flDot > 0 ) { - if( m_irritation >= 2 && pev->health < gSkillData.nihilanthHealth / 2.0 ) + if( m_irritation >= 2 && pev->health < gSkillData.nihilanthHealth / 2.0f ) { pev->sequence = LookupSequence( "attack1_open" ); } @@ -820,7 +820,7 @@ void CNihilanth::NextActivity() } else { - char szText[64]; + char szText[128]; sprintf( szText, "%s%d", m_szTeleportTouch, m_iTeleport ); CBaseEntity *pTouch = UTIL_FindEntityByTargetname( NULL, szText ); @@ -848,7 +848,7 @@ void CNihilanth::NextActivity() void CNihilanth::HuntThink( void ) { - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; DispatchAnimEvents(); StudioFrameAdvance(); @@ -877,7 +877,7 @@ void CNihilanth::HuntThink( void ) pev->frame = 0; NextActivity(); ResetSequenceInfo(); - pev->framerate = 2.0 - 1.0 * ( pev->health / gSkillData.nihilanthHealth ); + pev->framerate = 2.0f - 1.0f * ( pev->health / gSkillData.nihilanthHealth ); } // look for current enemy @@ -885,7 +885,7 @@ void CNihilanth::HuntThink( void ) { if( FVisible( m_hEnemy ) ) { - if( m_flLastSeen < gpGlobals->time - 5 ) + if( m_flLastSeen < gpGlobals->time - 5.0f ) m_flPrevSeen = gpGlobals->time; m_flLastSeen = gpGlobals->time; m_posTarget = m_hEnemy->pev->origin; @@ -933,7 +933,7 @@ void CNihilanth::Flight( void ) m_avelocity.y -= 6; // 9 * ( 3.0 / 2.0 ); } } - m_avelocity.y *= 0.98; + m_avelocity.y *= 0.98f; // estimate where I'll be in two seconds Vector vecEst = pev->origin + m_velocity * 2.0 + gpGlobals->v_up * m_flForce * 20; @@ -944,20 +944,20 @@ void CNihilanth::Flight( void ) m_velocity.y += gpGlobals->v_up.y * m_flForce; m_velocity.z += gpGlobals->v_up.z * m_flForce; - float flSpeed = m_velocity.Length(); + /*float flSpeed = m_velocity.Length(); float flDir = DotProduct( Vector( gpGlobals->v_forward.x, gpGlobals->v_forward.y, 0 ), Vector( m_velocity.x, m_velocity.y, 0 ) ); if( flDir < 0 ) - flSpeed = -flSpeed; + flSpeed = -flSpeed;*/ //float flDist = DotProduct( m_posDesired - vecEst, gpGlobals->v_forward ); // sideways drag - m_velocity.x = m_velocity.x * ( 1.0 - fabs( gpGlobals->v_right.x ) * 0.05 ); - m_velocity.y = m_velocity.y * ( 1.0 - fabs( gpGlobals->v_right.y ) * 0.05 ); - m_velocity.z = m_velocity.z * ( 1.0 - fabs( gpGlobals->v_right.z ) * 0.05 ); + m_velocity.x = m_velocity.x * ( 1.0f - fabs( gpGlobals->v_right.x ) * 0.05f ); + m_velocity.y = m_velocity.y * ( 1.0f - fabs( gpGlobals->v_right.y ) * 0.05f ); + m_velocity.z = m_velocity.z * ( 1.0f - fabs( gpGlobals->v_right.z ) * 0.05f ); // general drag - m_velocity = m_velocity * 0.995; + m_velocity = m_velocity * 0.995f; // apply power to stay correct height if( m_flForce < 100 && vecEst.z < m_posDesired.z ) @@ -970,8 +970,8 @@ void CNihilanth::Flight( void ) m_flForce -= 10; } - UTIL_SetOrigin( pev, pev->origin + m_velocity * 0.1 ); - pev->angles = pev->angles + m_avelocity * 0.1; + UTIL_SetOrigin( pev, pev->origin + m_velocity * 0.1f ); + pev->angles = pev->angles + m_avelocity * 0.1f; // ALERT( at_console, "%5.0f %5.0f : %4.0f : %3.0f : %2.0f\n", m_posDesired.z, pev->origin.z, m_velocity.z, m_avelocity.y, m_flForce ); } @@ -1093,14 +1093,14 @@ void CNihilanth::HandleAnimEvent( MonsterEvent_t *pEvent ) MESSAGE_END(); m_flShootTime = gpGlobals->time; - m_flShootEnd = gpGlobals->time + 1.0; + m_flShootEnd = gpGlobals->time + 1.0f; } break; case 3: // prayer if( m_hEnemy != 0 ) { - char szText[32]; + char szText[128]; sprintf( szText, "%s%d", m_szTeleportTouch, m_iTeleport ); CBaseEntity *pTouch = UTIL_FindEntityByTargetname( NULL, szText ); @@ -1155,7 +1155,7 @@ void CNihilanth::HandleAnimEvent( MonsterEvent_t *pEvent ) MESSAGE_END(); m_flShootTime = gpGlobals->time; - m_flShootEnd = gpGlobals->time + 1.0; + m_flShootEnd = gpGlobals->time + 1.0f; } } break; @@ -1192,7 +1192,7 @@ void CNihilanth::HandleAnimEvent( MonsterEvent_t *pEvent ) Vector vecSrc, vecAngles; GetAttachment( 0, vecSrc, vecAngles ); CNihilanthHVR *pEntity = (CNihilanthHVR *)Create( "nihilanth_energy_ball", vecSrc, pev->angles, edict() ); - pEntity->pev->velocity = Vector( RANDOM_FLOAT( -0.7, 0.7 ), RANDOM_FLOAT( -0.7, 0.7 ), 1.0 ) * 600.0; + pEntity->pev->velocity = Vector( RANDOM_FLOAT( -0.7f, 0.7f ), RANDOM_FLOAT( -0.7f, 0.7f ), 1.0f ) * 600.0f; pEntity->GreenBallInit(); */ break; @@ -1299,7 +1299,7 @@ void CNihilanthHVR::Spawn( void ) pev->rendermode = kRenderTransAdd; pev->renderamt = 255; - pev->scale = 3.0; + pev->scale = 3.0f; } void CNihilanthHVR::Precache( void ) @@ -1328,7 +1328,7 @@ void CNihilanthHVR::CircleInit( CBaseEntity *pTarget ) pev->rendercolor.x = 255; pev->rendercolor.y = 224; pev->rendercolor.z = 192; - pev->scale = 2.0; + pev->scale = 2.0f; m_nFrames = 1; pev->renderamt = 255; @@ -1337,7 +1337,7 @@ void CNihilanthHVR::CircleInit( CBaseEntity *pTarget ) SetThink( &CNihilanthHVR::HoverThink ); SetTouch( &CNihilanthHVR::BounceTouch ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; m_hTargetEnt = pTarget; } @@ -1359,7 +1359,7 @@ CBaseEntity *CNihilanthHVR::RandomClassname( const char *szName ) void CNihilanthHVR::HoverThink( void ) { - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; if( m_hTargetEnt != 0 ) { @@ -1428,21 +1428,21 @@ void CNihilanthHVR::ZapInit( CBaseEntity *pEnemy ) pev->rendercolor.x = 255; pev->rendercolor.y = 255; pev->rendercolor.z = 255; - pev->scale = 2.0; + pev->scale = 2.0f; - pev->velocity = ( pEnemy->pev->origin - pev->origin ).Normalize() * 200; + pev->velocity = ( pEnemy->pev->origin - pev->origin ).Normalize() * 200.0f; m_hEnemy = pEnemy; SetThink( &CNihilanthHVR::ZapThink ); SetTouch( &CNihilanthHVR::ZapTouch ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; EMIT_SOUND_DYN( edict(), CHAN_WEAPON, "debris/zap4.wav", 1, ATTN_NORM, 0, 100 ); } void CNihilanthHVR::ZapThink( void ) { - pev->nextthink = gpGlobals->time + 0.05; + pev->nextthink = gpGlobals->time + 0.05f; // check world boundaries if( m_hEnemy == 0 || pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096 ) @@ -1454,7 +1454,7 @@ void CNihilanthHVR::ZapThink( void ) if( pev->velocity.Length() < 2000 ) { - pev->velocity = pev->velocity * 1.2; + pev->velocity = pev->velocity * 1.2f; } // MovetoTarget( m_hEnemy->Center() ); @@ -1496,7 +1496,7 @@ void CNihilanthHVR::ZapThink( void ) SetTouch( NULL ); UTIL_Remove( this ); - pev->nextthink = gpGlobals->time + 0.2; + pev->nextthink = gpGlobals->time + 0.2f; return; } @@ -1535,7 +1535,7 @@ void CNihilanthHVR::ZapTouch( CBaseEntity *pOther ) SetTouch( NULL ); UTIL_Remove( this ); - pev->nextthink = gpGlobals->time + 0.2; + pev->nextthink = gpGlobals->time + 0.2f; } void CNihilanthHVR::TeleportInit( CNihilanth *pOwner, CBaseEntity *pEnemy, CBaseEntity *pTarget, CBaseEntity *pTouch ) @@ -1546,7 +1546,7 @@ void CNihilanthHVR::TeleportInit( CNihilanth *pOwner, CBaseEntity *pEnemy, CBase pev->rendercolor.x = 255; pev->rendercolor.y = 255; pev->rendercolor.z = 255; - pev->velocity.z *= 0.2; + pev->velocity.z *= 0.2f; SET_MODEL( edict(), "sprites/exit1.spr" ); @@ -1557,7 +1557,7 @@ void CNihilanthHVR::TeleportInit( CNihilanth *pOwner, CBaseEntity *pEnemy, CBase SetThink( &CNihilanthHVR::TeleportThink ); SetTouch( &CNihilanthHVR::TeleportTouch ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; EMIT_SOUND_DYN( edict(), CHAN_WEAPON, "x/x_teleattack1.wav", 1, 0.2, 0, 100 ); } @@ -1570,7 +1570,7 @@ void CNihilanthHVR::GreenBallInit() pev->rendercolor.x = 255; pev->rendercolor.y = 255; pev->rendercolor.z = 255; - pev->scale = 1.0; + pev->scale = 1.0f; SET_MODEL( edict(), "sprites/exit1.spr" ); @@ -1579,7 +1579,7 @@ void CNihilanthHVR::GreenBallInit() void CNihilanthHVR::TeleportThink( void ) { - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; // check world boundaries if( m_hEnemy == 0 || !m_hEnemy->IsAlive() || pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096 ) @@ -1669,13 +1669,13 @@ void CNihilanthHVR::TeleportTouch( CBaseEntity *pOther ) void CNihilanthHVR::DissipateThink( void ) { - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; - if( pev->scale > 5.0 ) + if( pev->scale > 5.0f ) UTIL_Remove( this ); pev->renderamt -= 2; - pev->scale += 0.1; + pev->scale += 0.1f; if( m_hTargetEnt != 0 ) { @@ -1811,7 +1811,7 @@ void CNihilanthHVR::BounceTouch( CBaseEntity *pOther ) float n = -DotProduct( tr.vecPlaneNormal, vecDir ); - vecDir = 2.0 * tr.vecPlaneNormal * n + vecDir; + vecDir = 2.0f * tr.vecPlaneNormal * n + vecDir; m_vecIdeal = vecDir * m_vecIdeal.Length(); } diff --git a/dlls/nodes.cpp b/dlls/nodes.cpp index 6babe01d..42ff2404 100644 --- a/dlls/nodes.cpp +++ b/dlls/nodes.cpp @@ -42,7 +42,10 @@ CGraph WorldGraph; LINK_ENTITY_TO_CLASS( info_node, CNodeEnt ) LINK_ENTITY_TO_CLASS( info_node_air, CNodeEnt ) -#if !defined _WIN32 +#if __DOS__ +#include +#define CreateDirectoryA(p, n) mkdir(p) +#elif !_WIN32 #include #include #define CreateDirectoryA(p, n) mkdir(p, 0777) @@ -667,7 +670,7 @@ int CGraph::FindShortestPath( int *piPath, int iStart, int iDest, int iHull, int // for ( i = 0; i < m_cNodes; i++) { - m_pNodes[i].m_flClosestSoFar = -1.0; + m_pNodes[i].m_flClosestSoFar = -1.0f; } m_pNodes[iStart].m_flClosestSoFar = 0.0; @@ -709,8 +712,8 @@ int CGraph::FindShortestPath( int *piPath, int iStart, int iDest, int iHull, int } } float flOurDistance = flCurrentDistance + m_pLinkPool[m_pNodes[iCurrentNode].m_iFirstLink + i].m_flWeight; - if( m_pNodes[iVisitNode].m_flClosestSoFar < -0.5 - || flOurDistance < m_pNodes[iVisitNode].m_flClosestSoFar - 0.001 ) + if( m_pNodes[iVisitNode].m_flClosestSoFar < -0.5f + || flOurDistance < m_pNodes[iVisitNode].m_flClosestSoFar - 0.001f ) { m_pNodes[iVisitNode].m_flClosestSoFar = flOurDistance; m_pNodes[iVisitNode].m_iPreviousNode = iCurrentNode; @@ -719,7 +722,7 @@ int CGraph::FindShortestPath( int *piPath, int iStart, int iDest, int iHull, int } } } - if( m_pNodes[iDest].m_flClosestSoFar < -0.5 ) + if( m_pNodes[iDest].m_flClosestSoFar < -0.5f ) { // Destination is unreachable, no path found. return 0; @@ -837,7 +840,7 @@ void CGraph::CheckNode( Vector vecOrigin, int iNode ) // make sure that vecOrigin can trace to this node! UTIL_TraceLine( vecOrigin, m_pNodes[iNode].m_vecOriginPeek, ignore_monsters, 0, &tr ); - if( tr.flFraction == 1.0 ) + if( tr.flFraction == 1.0f ) { m_iNearest = iNode; m_flShortest = flDist; @@ -907,7 +910,7 @@ int CGraph::FindNearestNode( const Vector &vecOrigin, int afNodeTypes ) } m_iNearest = -1; - m_flShortest = 999999.0; // just a big number. + m_flShortest = 999999.0f; // just a big number. // If we can find a visible point, then let CalcBounds set the limits, but if // we have no visible point at all to start with, then don't restrict the limits. @@ -1276,7 +1279,7 @@ int CGraph::LinkVisibleNodes( CLink *pLinkPool, FILE *file, int *piBadNode ) if( tr.fStartSolid ) continue; - if( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0f ) { // trace hit a brush ent, trace backwards to make sure that this ent is the only thing in the way. pTraceEnt = tr.pHit;// store the ent that the trace hit, for comparison @@ -1442,14 +1445,14 @@ int CGraph::RejectInlineLinks( CLink *pLinkPool, FILE *file ) flDistToTestNode = vec2DirToTestNode.Length(); vec2DirToTestNode = vec2DirToTestNode.Normalize(); - if( DotProduct( vec2DirToCheckNode, vec2DirToTestNode ) >= 0.998 ) + if( DotProduct( vec2DirToCheckNode, vec2DirToTestNode ) >= 0.998f ) { // there's a chance that TestNode intersects the line to CheckNode. If so, we should disconnect the link to CheckNode. if( flDistToTestNode < flDistToCheckNode ) { if( file ) { - fprintf( file, "REJECTED NODE %3d through Node %3d, Dot = %8f\n", pLinkPool[pSrcNode->m_iFirstLink + j].m_iDestNode, pLinkPool[pSrcNode->m_iFirstLink + k].m_iDestNode, DotProduct( vec2DirToCheckNode, vec2DirToTestNode ) ); + fprintf( file, "REJECTED NODE %3d through Node %3d, Dot = %8f\n", pLinkPool[pSrcNode->m_iFirstLink + j].m_iDestNode, pLinkPool[pSrcNode->m_iFirstLink + k].m_iDestNode, (double)DotProduct( vec2DirToCheckNode, vec2DirToTestNode ) ); } pLinkPool[pSrcNode->m_iFirstLink + j] = pLinkPool[pSrcNode->m_iFirstLink + ( pSrcNode->m_cNumLinks - 1 )]; @@ -1516,7 +1519,7 @@ void CTestHull::Spawn( entvars_t *pevMasterNode ) else { SetThink( &CTestHull::DropDelay ); - pev->nextthink = gpGlobals->time + 1; + pev->nextthink = gpGlobals->time + 1.0f; } // Make this invisible @@ -1537,7 +1540,7 @@ void CTestHull::DropDelay( void ) SetThink( &CTestHull::CallBuildNodeGraph ); - pev->nextthink = gpGlobals->time + 1; + pev->nextthink = gpGlobals->time + 1.0f; } //========================================================= @@ -1623,7 +1626,7 @@ void CTestHull::ShowBadNode( void ) UTIL_ParticleEffect( pev->origin + gpGlobals->v_right * 64, g_vecZero, 255, 25 ); UTIL_ParticleEffect( pev->origin - gpGlobals->v_right * 64, g_vecZero, 255, 25 ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } extern BOOL gTouchDisabled; @@ -1737,7 +1740,7 @@ void CTestHull::BuildNodeGraph( void ) fprintf( file, "Location %4d,%4d,%4d\n",(int)WorldGraph.m_pNodes[i].m_vecOrigin.x, (int)WorldGraph.m_pNodes[i].m_vecOrigin.y, (int)WorldGraph.m_pNodes[i].m_vecOrigin.z ); fprintf( file, "HintType: %4d\n", WorldGraph.m_pNodes[i].m_sHintType ); fprintf( file, "HintActivity: %4d\n", WorldGraph.m_pNodes[i].m_sHintActivity ); - fprintf( file, "HintYaw: %4f\n", WorldGraph.m_pNodes[i].m_flHintYaw ); + fprintf( file, "HintYaw: %4f\n", (double)WorldGraph.m_pNodes[i].m_flHintYaw ); fprintf( file, "-------------------------------------------------------------------------------\n" ); } fprintf( file, "\n\n" ); @@ -1959,7 +1962,7 @@ void CTestHull::BuildNodeGraph( void ) TraceResult tr; UTIL_TraceHull( pSrcNode->m_vecOrigin + Vector( 0, 0, 32 ), pDestNode->m_vecOriginPeek + Vector( 0, 0, 32 ), ignore_monsters, large_hull, ENT( pev ), &tr ); - if( tr.fStartSolid || tr.flFraction < 1.0 ) + if( tr.fStartSolid || tr.flFraction < 1.0f ) { pTempPool[pSrcNode->m_iFirstLink + j].m_afLinkInfo &= ~bits_LINK_FLY_HULL; } @@ -2057,7 +2060,7 @@ void CTestHull::BuildNodeGraph( void ) fprintf( file, "\nAll Connections are Paired!\n" ); } -#ifdef _MSC_VER +#if _MSC_VER #define SIZET_FMT "%Iu" #else #define SIZET_FMT "%zu" @@ -2533,7 +2536,7 @@ int CGraph::FLoadGraph( const char *szMapName ) if( length < 0 ) goto ShortFile; memcpy( m_pHashLinks, pMemFile, sizeof(short) * m_nHashLinks ); - pMemFile += sizeof(short) * m_nHashLinks; + // pMemFile += sizeof(short) * m_nHashLinks; // Set the graph present flag, clear the pointers set flag // @@ -3517,7 +3520,7 @@ void CGraph::TestRoutingTables( void ) ALERT( at_aiconsole, "No link.\n" ); } } - if( fabs( flDistance1 - flDistance2 ) > 0.10 ) + if( fabs( flDistance1 - flDistance2 ) > 0.1f ) { #else if( cPathSize1 != cPathSize2 || memcmp( pMyPath, pMyPath2, sizeof(int) * cPathSize1 ) != 0 ) @@ -3641,7 +3644,7 @@ void CNodeViewer::Spawn() int start = 0; int end; do{ - end = m_nVisited; + // end = m_nVisited; // ALERT( at_console, "%d :", m_nVisited ); for( end = m_nVisited; start < end; start++ ) { diff --git a/dlls/nodes.h b/dlls/nodes.h index 4bc1ec1b..cb19aeb8 100644 --- a/dlls/nodes.h +++ b/dlls/nodes.h @@ -16,8 +16,8 @@ // nodes.h //========================================================= #pragma once -#ifndef NODES_H -#define NODES_H +#if !defined(NODES_H) +#define NODES_H //========================================================= // DEFINE //========================================================= @@ -106,7 +106,7 @@ typedef struct // CGraph //========================================================= #define _GRAPH_VERSION_RETAIL 16 // Retail Half-Life graph version. Don't increment this -#ifdef XASH_64BIT +#if XASH_64BIT #define _GRAPH_VERSION (16 * 10) #else #define _GRAPH_VERSION (16) // !!!increment this whenever graph/node/link classes change, to obsolesce older disk files. @@ -215,7 +215,7 @@ public: inline CNode &Node( int i ) { -#ifdef _DEBUG +#if _DEBUG if ( !m_pNodes || i < 0 || i > m_cNodes ) ALERT( at_error, "Bad Node!\n" ); #endif @@ -224,7 +224,7 @@ public: inline CLink &Link( int i ) { -#ifdef _DEBUG +#if _DEBUG if ( !m_pLinkPool || i < 0 || i > m_cLinks ) ALERT( at_error, "Bad link!\n" ); #endif diff --git a/dlls/nodes_compat.h b/dlls/nodes_compat.h index d73567e9..c190f11f 100644 --- a/dlls/nodes_compat.h +++ b/dlls/nodes_compat.h @@ -1,6 +1,6 @@ #pragma once -#ifndef NODES_32BIT_COMPAT +#if !defined(NODES_32BIT_COMPAT) #define NODES_32BIT_COMPAT //#include "nodes.h" diff --git a/dlls/observer.cpp b/dlls/observer.cpp index 22fa3818..79e1c9c1 100644 --- a/dlls/observer.cpp +++ b/dlls/observer.cpp @@ -103,7 +103,7 @@ void CBasePlayer::Observer_HandleButtons() else Observer_SetMode( OBS_CHASE_FREE ); // don't use OBS_CHASE_LOCKED anymore - m_flNextObserverInput = gpGlobals->time + 0.2; + m_flNextObserverInput = gpGlobals->time + 0.2f; } // Attack moves to the next player @@ -111,7 +111,7 @@ void CBasePlayer::Observer_HandleButtons() { Observer_FindNextPlayer( false ); - m_flNextObserverInput = gpGlobals->time + 0.2; + m_flNextObserverInput = gpGlobals->time + 0.2f; } // Attack2 moves to the prev player @@ -119,7 +119,7 @@ void CBasePlayer::Observer_HandleButtons() { Observer_FindNextPlayer( true ); - m_flNextObserverInput = gpGlobals->time + 0.2; + m_flNextObserverInput = gpGlobals->time + 0.2f; } } diff --git a/dlls/osprey.cpp b/dlls/osprey.cpp index 6a421645..055cddd2 100644 --- a/dlls/osprey.cpp +++ b/dlls/osprey.cpp @@ -170,7 +170,7 @@ void COsprey::Spawn( void ) if( !( pev->spawnflags & SF_WAITFORTRIGGER ) ) { - pev->nextthink = gpGlobals->time + 1.0; + pev->nextthink = gpGlobals->time + 1.0f; } m_pos2 = pev->origin; @@ -198,7 +198,7 @@ void COsprey::Precache( void ) void COsprey::CommandUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } void COsprey::FindAllThink( void ) @@ -223,7 +223,7 @@ void COsprey::FindAllThink( void ) return; } SetThink( &COsprey::FlyThink ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; m_startTime = gpGlobals->time; } @@ -238,8 +238,8 @@ void COsprey::DeployThink( void ) Vector vecSrc; TraceResult tr; - UTIL_TraceLine( pev->origin, pev->origin + Vector( 0, 0, -4096.0 ), ignore_monsters, ENT( pev ), &tr ); - CSoundEnt::InsertSound( bits_SOUND_DANGER, tr.vecEndPos, 400, 0.3 ); + UTIL_TraceLine( pev->origin, pev->origin + Vector( 0.0f, 0.0f, -4096.0f ), ignore_monsters, ENT( pev ), &tr ); + CSoundEnt::InsertSound( bits_SOUND_DANGER, tr.vecEndPos, 400, 0.3f ); vecSrc = pev->origin + vecForward * 32 + vecRight * 100 + vecUp * -96; m_hRepel[0] = MakeGrunt( vecSrc ); @@ -254,7 +254,7 @@ void COsprey::DeployThink( void ) m_hRepel[3] = MakeGrunt( vecSrc ); SetThink( &COsprey::HoverThink ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } BOOL COsprey::HasDead() @@ -279,7 +279,7 @@ CBaseMonster *COsprey::MakeGrunt( Vector vecSrc ) CBaseMonster *pGrunt; TraceResult tr; - UTIL_TraceLine( vecSrc, vecSrc + Vector( 0, 0, -4096.0 ), dont_ignore_monsters, ENT( pev ), &tr ); + UTIL_TraceLine( vecSrc, vecSrc + Vector( 0.0f, 0.0f, -4096.0f ), dont_ignore_monsters, ENT( pev ), &tr ); if( tr.pHit && Instance( tr.pHit )->pev->solid != SOLID_BSP ) return NULL; @@ -302,7 +302,7 @@ CBaseMonster *COsprey::MakeGrunt( Vector vecSrc ) pBeam->SetFlags( BEAM_FSOLID ); pBeam->SetColor( 255, 255, 255 ); pBeam->SetThink( &CBaseEntity::SUB_Remove ); - pBeam->pev->nextthink = gpGlobals->time + -4096.0 * tr.flFraction / pGrunt->pev->velocity.z + 0.5; + pBeam->pev->nextthink = gpGlobals->time + -4096.0f * tr.flFraction / pGrunt->pev->velocity.z + 0.5f; // ALERT( at_console, "%d at %.0f %.0f %.0f\n", i, m_vecOrigin[i].x, m_vecOrigin[i].y, m_vecOrigin[i].z ); pGrunt->m_vecLastPosition = m_vecOrigin[i]; @@ -331,7 +331,7 @@ void COsprey::HoverThink( void ) SetThink( &COsprey::FlyThink ); } - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; UTIL_MakeAimVectors( pev->angles ); ShowDamage(); } @@ -349,7 +349,7 @@ void COsprey::UpdateGoal() m_vel2 = gpGlobals->v_forward * m_pGoalEnt->pev->speed; m_startTime = m_startTime + m_dTime; - m_dTime = 2.0 * ( m_pos1 - m_pos2 ).Length() / ( m_vel1.Length() + m_pGoalEnt->pev->speed ); + m_dTime = 2.0f * ( m_pos1 - m_pos2 ).Length() / ( m_vel1.Length() + m_pGoalEnt->pev->speed ); if( m_ang1.y - m_ang2.y < -180 ) { @@ -374,7 +374,7 @@ void COsprey::UpdateGoal() void COsprey::FlyThink( void ) { StudioFrameAdvance(); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; if( m_pGoalEnt == NULL && !FStringNull( pev->target) )// this monster has a target { @@ -384,13 +384,18 @@ void COsprey::FlyThink( void ) if( gpGlobals->time > m_startTime + m_dTime ) { - if( m_pGoalEnt->pev->speed == 0 ) + if( m_pGoalEnt ) { - SetThink( &COsprey::DeployThink ); + if( m_pGoalEnt->pev->speed == 0 ) + { + SetThink( &COsprey::DeployThink ); + } + + do{ + m_pGoalEnt = CBaseEntity::Instance( FIND_ENTITY_BY_TARGETNAME( NULL, STRING( m_pGoalEnt->pev->target ) ) ); + } while( m_pGoalEnt && m_pGoalEnt->pev->speed < 400 && !HasDead() ); } - do{ - m_pGoalEnt = CBaseEntity::Instance( FIND_ENTITY_BY_TARGETNAME( NULL, STRING( m_pGoalEnt->pev->target ) ) ); - } while( m_pGoalEnt->pev->speed < 400 && !HasDead() ); + UpdateGoal(); } @@ -401,13 +406,13 @@ void COsprey::FlyThink( void ) void COsprey::Flight() { float t = ( gpGlobals->time - m_startTime ); - float scale = 1.0 / m_dTime; + float scale = 1.0f / m_dTime; - float f = UTIL_SplineFraction( t * scale, 1.0 ); + float f = UTIL_SplineFraction( t * scale, 1.0f ); - Vector pos = ( m_pos1 + m_vel1 * t ) * ( 1.0 - f ) + ( m_pos2 - m_vel2 * ( m_dTime - t ) ) * f; - Vector ang = ( m_ang1 ) * ( 1.0 - f ) + ( m_ang2 ) * f; - m_velocity = m_vel1 * ( 1.0 - f ) + m_vel2 * f; + Vector pos = ( m_pos1 + m_vel1 * t ) * ( 1.0f - f ) + ( m_pos2 - m_vel2 * ( m_dTime - t ) ) * f; + Vector ang = ( m_ang1 ) * ( 1.0f - f ) + ( m_ang2 ) * f; + m_velocity = m_vel1 * ( 1.0f - f ) + m_vel2 * f; UTIL_SetOrigin( pev, pos ); pev->angles = ang; @@ -416,18 +421,18 @@ void COsprey::Flight() // float flSpeed = DotProduct( gpGlobals->v_forward, pev->velocity ); - float m_flIdealtilt = ( 160 - flSpeed ) / 10.0; + float m_flIdealtilt = ( 160.0f - flSpeed ) / 10.0f; // ALERT( at_console, "%f %f\n", flSpeed, flIdealtilt ); if( m_flRotortilt < m_flIdealtilt ) { - m_flRotortilt += 0.5; + m_flRotortilt += 0.5f; if ( m_flRotortilt > 0 ) m_flRotortilt = 0; } if( m_flRotortilt > m_flIdealtilt ) { - m_flRotortilt -= 0.5; + m_flRotortilt -= 0.5f; if( m_flRotortilt < -90 ) m_flRotortilt = -90; } @@ -450,7 +455,7 @@ void COsprey::Flight() { float pitch = DotProduct( m_velocity - pPlayer->pev->velocity, ( pPlayer->pev->origin - pev->origin ).Normalize() ); - pitch = (int)( 100 + pitch / 75.0 ); + pitch = (int)( 100 + pitch / 75.0f ); if( pitch > 250 ) pitch = 250; @@ -474,7 +479,7 @@ void COsprey::Flight() void COsprey::HitTouch( CBaseEntity *pOther ) { - pev->nextthink = gpGlobals->time + 2.0; + pev->nextthink = gpGlobals->time + 2.0f; } /* @@ -496,7 +501,7 @@ int COsprey::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float void COsprey::Killed( entvars_t *pevAttacker, int iGib ) { pev->movetype = MOVETYPE_TOSS; - pev->gravity = 0.3; + pev->gravity = 0.3f; pev->velocity = m_velocity; pev->avelocity = Vector( RANDOM_FLOAT( -20, 20 ), 0, RANDOM_FLOAT( -50, 50 ) ); STOP_SOUND( ENT( pev ), CHAN_STATIC, "apache/ap_rotor4.wav" ); @@ -504,11 +509,11 @@ void COsprey::Killed( entvars_t *pevAttacker, int iGib ) UTIL_SetSize( pev, Vector( -32, -32, -64 ), Vector( 32, 32, 0 ) ); SetThink( &COsprey::DyingThink ); SetTouch( &COsprey::CrashTouch ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; pev->health = 0; pev->takedamage = DAMAGE_NO; - m_startTime = gpGlobals->time + 4.0; + m_startTime = gpGlobals->time + 4.0f; } void COsprey::CrashTouch( CBaseEntity *pOther ) @@ -526,9 +531,9 @@ void COsprey::CrashTouch( CBaseEntity *pOther ) void COsprey::DyingThink( void ) { StudioFrameAdvance(); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; - pev->avelocity = pev->avelocity * 1.02; + pev->avelocity = pev->avelocity * 1.02f; // still falling? if( m_startTime > gpGlobals->time ) @@ -536,14 +541,14 @@ void COsprey::DyingThink( void ) UTIL_MakeAimVectors( pev->angles ); ShowDamage(); - Vector vecSpot = pev->origin + pev->velocity * 0.2; + Vector vecSpot = pev->origin + pev->velocity * 0.2f; // random explosions MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpot ); WRITE_BYTE( TE_EXPLOSION ); // This just makes a dynamic light now - WRITE_COORD( vecSpot.x + RANDOM_FLOAT( -150, 150 ) ); - WRITE_COORD( vecSpot.y + RANDOM_FLOAT( -150, 150 ) ); - WRITE_COORD( vecSpot.z + RANDOM_FLOAT( -150, -50 ) ); + WRITE_COORD( vecSpot.x + RANDOM_FLOAT( -150.0f, 150.0f ) ); + WRITE_COORD( vecSpot.y + RANDOM_FLOAT( -150.0f, 150.0f ) ); + WRITE_COORD( vecSpot.z + RANDOM_FLOAT( -150.0f, -50.0f ) ); WRITE_SHORT( g_sModelIndexFireball ); WRITE_BYTE( RANDOM_LONG( 0, 29 ) + 30 ); // scale * 10 WRITE_BYTE( 12 ); // framerate @@ -553,15 +558,15 @@ void COsprey::DyingThink( void ) // lots of smoke MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpot ); WRITE_BYTE( TE_SMOKE ); - WRITE_COORD( vecSpot.x + RANDOM_FLOAT( -150, 150 ) ); - WRITE_COORD( vecSpot.y + RANDOM_FLOAT( -150, 150 ) ); - WRITE_COORD( vecSpot.z + RANDOM_FLOAT( -150, -50 ) ); + WRITE_COORD( vecSpot.x + RANDOM_FLOAT( -150.0f, 150.0f ) ); + WRITE_COORD( vecSpot.y + RANDOM_FLOAT( -150.0f, 150.0f ) ); + WRITE_COORD( vecSpot.z + RANDOM_FLOAT( -150.0f, -50.0f ) ); WRITE_SHORT( g_sModelIndexSmoke ); WRITE_BYTE( 100 ); // scale * 10 WRITE_BYTE( 10 ); // framerate MESSAGE_END(); - vecSpot = pev->origin + ( pev->mins + pev->maxs ) * 0.5; + vecSpot = pev->origin + ( pev->mins + pev->maxs ) * 0.5f; MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpot ); WRITE_BYTE( TE_BREAKMODEL); @@ -598,12 +603,12 @@ void COsprey::DyingThink( void ) // don't stop it we touch a entity pev->flags &= ~FL_ONGROUND; - pev->nextthink = gpGlobals->time + 0.2; + pev->nextthink = gpGlobals->time + 0.2f; return; } else { - Vector vecSpot = pev->origin + ( pev->mins + pev->maxs ) * 0.5; + Vector vecSpot = pev->origin + ( pev->mins + pev->maxs ) * 0.5f; /* MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); @@ -662,12 +667,12 @@ void COsprey::DyingThink( void ) WRITE_BYTE( 0 ); // speed MESSAGE_END(); - EMIT_SOUND( ENT( pev ), CHAN_STATIC, "weapons/mortarhit.wav", 1.0, 0.3 ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, "weapons/mortarhit.wav", 1.0, 0.3f ); RadiusDamage( pev->origin, pev, pev, 300, CLASS_NONE, DMG_BLAST ); // gibs - vecSpot = pev->origin + ( pev->mins + pev->maxs ) * 0.5; + vecSpot = pev->origin + ( pev->mins + pev->maxs ) * 0.5f; MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, vecSpot ); WRITE_BYTE( TE_BREAKMODEL); @@ -684,7 +689,7 @@ void COsprey::DyingThink( void ) // velocity WRITE_COORD( m_velocity.x ); WRITE_COORD( m_velocity.y ); - WRITE_COORD( fabs( m_velocity.z ) * 0.25 ); + WRITE_COORD( fabs( m_velocity.z ) * 0.25f ); // randomization WRITE_BYTE( 40 ); @@ -751,7 +756,7 @@ void COsprey::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir return; else m_flRightHealth -= flDamage; - m_iDoLeftSmokePuff = 3 + ( flDamage / 5.0 ); + m_iDoRightSmokePuff = 3 + ( flDamage / 5.0f ); } if( ptr->iHitgroup == 2 ) @@ -760,7 +765,7 @@ void COsprey::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir return; else m_flLeftHealth -= flDamage; - m_iDoRightSmokePuff = 3 + ( flDamage / 5.0 ); + m_iDoLeftSmokePuff = 3 + ( flDamage / 5.0f ); } // hit hard, hits cockpit, hits engines diff --git a/dlls/pathcorner.cpp b/dlls/pathcorner.cpp index bc999675..c563bf69 100644 --- a/dlls/pathcorner.cpp +++ b/dlls/pathcorner.cpp @@ -125,7 +125,7 @@ TYPEDESCRIPTION CPathTrack::m_SaveData[] = DEFINE_FIELD( CPathTrack, m_altName, FIELD_STRING ), }; -IMPLEMENT_SAVERESTORE( CPathTrack, CBaseEntity ) +IMPLEMENT_SAVERESTORE( CPathTrack, CPointEntity ) LINK_ENTITY_TO_CLASS( path_track, CPathTrack ) // diff --git a/dlls/plane.h b/dlls/plane.h index 912062f6..25d35d44 100644 --- a/dlls/plane.h +++ b/dlls/plane.h @@ -15,7 +15,7 @@ //========================================================= // Plane //========================================================= -#ifndef PLANE_H +#if !defined(PLANE_H) #define PLANE_H class CPlane diff --git a/dlls/plats.cpp b/dlls/plats.cpp index 39dab5d5..9c8bdedb 100644 --- a/dlls/plats.cpp +++ b/dlls/plats.cpp @@ -359,8 +359,7 @@ void CPlatTrigger::SpawnInsideTrigger( CFuncPlat *pPlatform ) void CPlatTrigger::Touch( CBaseEntity *pOther ) { // Ignore touches by non-players - entvars_t *pevToucher = pOther->pev; - if( !FClassnameIs( pevToucher, "player" ) ) + if( !pOther->IsPlayer() ) return; CFuncPlat *pPlatform = (CFuncPlat*)(CBaseEntity*)m_hPlatform; @@ -587,7 +586,7 @@ void CFuncPlatRot::RotMove( Vector &destAngle, float time ) Vector vecDestDelta = destAngle - pev->angles; // Travel time is so short, we're practically there already; so make it so. - if( time >= 0.1 ) + if( time >= 0.1f ) pev->avelocity = vecDestDelta / time; else { @@ -649,7 +648,7 @@ void CFuncTrain::Blocked( CBaseEntity *pOther ) if( gpGlobals->time < m_flActivateFinished ) return; - m_flActivateFinished = gpGlobals->time + 0.5; + m_flActivateFinished = gpGlobals->time + 0.5f; pOther->TakeDamage( pev, pev, pev->dmg, DMG_CRUSH ); } @@ -752,7 +751,7 @@ void CFuncTrain::Next( void ) { // don't copy speed from target if it is 0 (uninitialized) pev->speed = m_pevCurrentTarget->speed; - ALERT( at_aiconsole, "Train %s speed to %4.2f\n", STRING( pev->targetname ), pev->speed ); + ALERT( at_aiconsole, "Train %s speed to %4.2f\n", STRING( pev->targetname ), (double)pev->speed ); } m_pevCurrentTarget = pTarg->pev;// keep track of this since path corners change our target for us. @@ -762,7 +761,7 @@ void CFuncTrain::Next( void ) { // Path corner has indicated a teleport to the next corner. SetBits( pev->effects, EF_NOINTERP ); - UTIL_SetOrigin( pev, pTarg->pev->origin - ( pev->mins + pev->maxs ) * 0.5 ); + UTIL_SetOrigin( pev, pTarg->pev->origin - ( pev->mins + pev->maxs ) * 0.5f ); Wait(); // Get on with doing the next path corner. if( mp_coop.value ) pev->iuser1++; // Invalidate state for coop @@ -782,7 +781,7 @@ void CFuncTrain::Next( void ) ClearBits( pev->effects, EF_NOINTERP ); SetMoveDone( &CFuncTrain::Wait ); - LinearMove( pTarg->pev->origin - ( pev->mins + pev->maxs )* 0.5, pev->speed ); + LinearMove( pTarg->pev->origin - ( pev->mins + pev->maxs ) * 0.5f, pev->speed ); } } @@ -801,7 +800,7 @@ void CFuncTrain::Activate( void ) if( FStringNull( pev->targetname ) ) { // not triggered, so start immediately - pev->nextthink = pev->ltime + 0.1; + pev->nextthink = pev->ltime + 0.1f; SetThink( &CFuncTrain::Next ); } else @@ -845,7 +844,7 @@ void CFuncTrain::Spawn( void ) m_activated = FALSE; if( m_volume == 0 ) - m_volume = 0.85; + m_volume = 0.85f; } void CFuncTrain::Precache( void ) @@ -893,7 +892,7 @@ void CFuncTrain::OverrideReset( void ) else // Keep moving for 0.1 secs, then find path_corner again and restart { SetThink( &CFuncTrain::Next ); - pev->nextthink = pev->ltime + 0.1; + pev->nextthink = pev->ltime + 0.1f; } } } @@ -948,7 +947,7 @@ void CFuncTrackTrain::KeyValue( KeyValueData *pkvd ) else if( FStrEq( pkvd->szKeyName, "volume" ) ) { m_flVolume = (float)atoi( pkvd->szValue ); - m_flVolume *= 0.1; + m_flVolume *= 0.1f; pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "bank" ) ) @@ -987,7 +986,7 @@ void CFuncTrackTrain::Blocked( CBaseEntity *pOther ) else pevOther->velocity = ( pevOther->origin - pev->origin ).Normalize() * pev->dmg; - ALERT( at_aiconsole, "TRAIN(%s): Blocked by %s (dmg:%.2f)\n", STRING( pev->targetname ), STRING( pOther->pev->classname ), pev->dmg ); + ALERT( at_aiconsole, "TRAIN(%s): Blocked by %s (dmg:%.2f)\n", STRING( pev->targetname ), STRING( pOther->pev->classname ), (double)pev->dmg ); if( pev->dmg <= 0 ) return; // we can't hurt this thing, so we're not concerned with it @@ -1020,7 +1019,7 @@ void CFuncTrackTrain::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY { float delta = value; - delta = ( (int)( pev->speed * 4 ) / (int)m_speed )*0.25 + 0.25 * delta; + delta = ( (int)( pev->speed * 4 ) / (int)m_speed ) * 0.25f + 0.25f * delta; if( delta > 1 ) delta = 1; else if ( delta < -1 ) @@ -1032,7 +1031,7 @@ void CFuncTrackTrain::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY } pev->speed = m_speed * delta; Next(); - ALERT( at_aiconsole, "TRAIN(%s), speed to %.2f\n", STRING( pev->targetname ), pev->speed ); + ALERT( at_aiconsole, "TRAIN(%s), speed to %.2f\n", STRING( pev->targetname ), (double)pev->speed ); } } @@ -1110,13 +1109,13 @@ void CFuncTrackTrain::UpdateSound( void ) unsigned short us_encode; unsigned short us_sound = ( ( unsigned short )( m_sounds ) & 0x0007 ) << 12; - unsigned short us_pitch = ( ( unsigned short )( flpitch / 10.0 ) & 0x003f ) << 6; - unsigned short us_volume = ( ( unsigned short )( m_flVolume * 40.0 ) & 0x003f ); + unsigned short us_pitch = ( ( unsigned short )( flpitch / 10.0f ) & 0x003f ) << 6; + unsigned short us_volume = ( ( unsigned short )( m_flVolume * 40.0f ) & 0x003f ); us_encode = us_sound | us_pitch | us_volume; - PLAYBACK_EVENT_FULL( FEV_RELIABLE | FEV_UPDATE, edict(), m_usAdjustPitch, 0.0, - g_vecZero, g_vecZero, 0.0, 0.0, us_encode, 0, 0, 0 ); + PLAYBACK_EVENT_FULL( FEV_RELIABLE | FEV_UPDATE, edict(), m_usAdjustPitch, 0.0f, + g_vecZero, g_vecZero, 0.0f, 0.0f, us_encode, 0, 0, 0 ); } } @@ -1161,7 +1160,7 @@ void CFuncTrackTrain::Next( void ) Vector nextPos = pev->origin; nextPos.z -= m_height; - CPathTrack *pnext = m_ppath->LookAhead( &nextPos, pev->speed * 0.1, 1 ); + CPathTrack *pnext = m_ppath->LookAhead( &nextPos, pev->speed * 0.1f, 1 ); nextPos.z += m_height; pev->velocity = ( nextPos - pev->origin ) * 10; @@ -1235,7 +1234,7 @@ void CFuncTrackTrain::Next( void ) { // don't copy speed from target if it is 0 (uninitialized) pev->speed = pFire->pev->speed; - ALERT( at_aiconsole, "TrackTrain %s speed to %4.2f\n", STRING( pev->targetname ), pev->speed ); + ALERT( at_aiconsole, "TrackTrain %s speed to %4.2f\n", STRING( pev->targetname ), (double)pev->speed ); } } @@ -1374,7 +1373,7 @@ void CFuncTrackTrain::Find( void ) if( pev->spawnflags & SF_TRACKTRAIN_NOPITCH ) pev->angles.x = 0; UTIL_SetOrigin( pev, nextPos ); - NextThink( pev->ltime + 0.1, FALSE ); + NextThink( pev->ltime + 0.1f, FALSE ); SetThink( &CFuncTrackTrain::Next ); pev->speed = m_startSpeed; @@ -1423,14 +1422,14 @@ void CFuncTrackTrain::NearestPath( void ) if( pev->speed != 0 ) { - NextThink( pev->ltime + 0.1, FALSE ); + NextThink( pev->ltime + 0.1f, FALSE ); SetThink( &CFuncTrackTrain::Next ); } } void CFuncTrackTrain::OverrideReset( void ) { - NextThink( pev->ltime + 0.1, FALSE ); + NextThink( pev->ltime + 0.1f, FALSE ); SetThink( &CFuncTrackTrain::NearestPath ); } @@ -1489,7 +1488,7 @@ void CFuncTrackTrain::Spawn( void ) // start trains on the next frame, to make sure their targets have had // a chance to spawn/activate - NextThink( pev->ltime + 0.1, FALSE ); + NextThink( pev->ltime + 0.1f, FALSE ); SetThink( &CFuncTrackTrain::Find ); Precache(); } @@ -1498,8 +1497,8 @@ void CFuncTrackTrain::Precache( void ) { const char *pszSound; - if( m_flVolume == 0.0 ) - m_flVolume = 1.0; + if( m_flVolume == 0.0f ) + m_flVolume = 1.0f; switch( m_sounds ) { @@ -1693,7 +1692,7 @@ void CFuncTrackChange::Spawn( void ) } EnableUse(); - pev->nextthink = pev->ltime + 2.0; + pev->nextthink = pev->ltime + 2.0f; SetThink( &CFuncTrackChange::Find ); Precache(); } @@ -1740,7 +1739,7 @@ void CFuncTrackChange::KeyValue( KeyValueData *pkvd ) void CFuncTrackChange::OverrideReset( void ) { - pev->nextthink = pev->ltime + 1.0; + pev->nextthink = pev->ltime + 1.0f; SetThink( &CFuncTrackChange::Find ); } @@ -1766,7 +1765,7 @@ void CFuncTrackChange::Find( void ) ALERT( at_error, "Can't find train for track change! %s\n", STRING( m_trainName ) ); return; } - Vector center = ( pev->absmin + pev->absmax ) * 0.5; + Vector center = ( pev->absmin + pev->absmax ) * 0.5f; m_trackBottom = m_trackBottom->Nearest( center ); m_trackTop = m_trackTop->Nearest( center ); UpdateAutoTargets( m_toggle_state ); @@ -1776,7 +1775,7 @@ void CFuncTrackChange::Find( void ) else { ALERT( at_error, "Can't find train for track change! %s\n", STRING( m_trainName ) ); - target = FIND_ENTITY_BY_TARGETNAME( NULL, STRING( m_trainName ) ); + // target = FIND_ENTITY_BY_TARGETNAME( NULL, STRING( m_trainName ) ); } } else @@ -1833,7 +1832,7 @@ void CFuncTrackChange::UpdateTrain( Vector &dest ) local.z = DotProduct( offset, gpGlobals->v_up ); local = local - offset; - m_train->pev->velocity = pev->velocity + ( local * ( 1.0 / time ) ); + m_train->pev->velocity = pev->velocity + ( local * ( 1.0f / time ) ); } void CFuncTrackChange::GoDown( void ) @@ -2134,7 +2133,7 @@ void CGunTarget::Spawn( void ) if( pev->spawnflags & FGUNTARGET_START_ON ) { SetThink( &CGunTarget::Start ); - pev->nextthink = pev->ltime + 0.3; + pev->nextthink = pev->ltime + 0.3f; } } @@ -2147,7 +2146,7 @@ void CGunTarget::Activate( void ) if( pTarg ) { m_hTargetEnt = pTarg; - UTIL_SetOrigin( pev, pTarg->pev->origin - ( pev->mins + pev->maxs ) * 0.5 ); + UTIL_SetOrigin( pev, pTarg->pev->origin - ( pev->mins + pev->maxs ) * 0.5f ); } } @@ -2169,7 +2168,7 @@ void CGunTarget::Next( void ) return; } SetMoveDone( &CGunTarget::Wait ); - LinearMove( pTarget->pev->origin - ( pev->mins + pev->maxs ) * 0.5, pev->speed ); + LinearMove( pTarget->pev->origin - ( pev->mins + pev->maxs ) * 0.5f, pev->speed ); } void CGunTarget::Wait( void ) diff --git a/dlls/player.cpp b/dlls/player.cpp index 6932239a..2f0e601a 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -66,8 +66,8 @@ extern CGraph WorldGraph; #define TRAIN_FAST 0x04 #define TRAIN_BACK 0x05 -#define FLASH_DRAIN_TIME 1.2 //100 units/3 minutes -#define FLASH_CHARGE_TIME 0.2 // 100 units/20 seconds (seconds per unit) +#define FLASH_DRAIN_TIME 1.2f //100 units/3 minutes +#define FLASH_CHARGE_TIME 0.2f // 100 units/20 seconds (seconds per unit) // Global Savedata for player TYPEDESCRIPTION CBasePlayer::m_playerSaveData[] = @@ -242,11 +242,11 @@ void CBasePlayer::Pain( void ) { float flRndSound;//sound randomizer - flRndSound = RANDOM_FLOAT( 0, 1 ); + flRndSound = RANDOM_FLOAT( 0.0f, 1.0f ); - if( flRndSound <= 0.33 ) + if( flRndSound <= 0.33f ) EMIT_SOUND( ENT( pev ), CHAN_VOICE, "player/pl_pain5.wav", 1, ATTN_NORM ); - else if( flRndSound <= 0.66 ) + else if( flRndSound <= 0.66f ) EMIT_SOUND( ENT( pev ), CHAN_VOICE, "player/pl_pain6.wav", 1, ATTN_NORM ); else EMIT_SOUND( ENT( pev ), CHAN_VOICE, "player/pl_pain7.wav", 1, ATTN_NORM ); @@ -257,7 +257,7 @@ Vector VecVelocityForDamage( float flDamage ) Vector vec( RANDOM_FLOAT( -100, 100 ), RANDOM_FLOAT( -100, 100 ), RANDOM_FLOAT( 200, 300 ) ); if( flDamage > -50 ) - vec = vec * 0.7; + vec = vec * 0.7f; else if( flDamage > -200 ) vec = vec * 2; else @@ -314,15 +314,15 @@ int TrainSpeed( int iSpeed, int iMax ) fMax = (float)iMax; fSpeed = iSpeed; - fSpeed = fSpeed/fMax; + fSpeed = fSpeed / fMax; if( iSpeed < 0 ) iRet = TRAIN_BACK; - else if( iSpeed == 0 ) + else if( iSpeed == 0.0f ) iRet = TRAIN_NEUTRAL; - else if( fSpeed < 0.33 ) + else if( fSpeed < 0.33f ) iRet = TRAIN_SLOW; - else if( fSpeed < 0.66 ) + else if( fSpeed < 0.66f ) iRet = TRAIN_MEDIUM; else iRet = TRAIN_FAST; @@ -924,7 +924,7 @@ void CBasePlayer::Killed( entvars_t *pevAttacker, int iGib ) pev->angles.z = 0; SetThink( &CBasePlayer::PlayerDeathThink ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } // Set the activity based on an event or current state @@ -1201,23 +1201,26 @@ void CBasePlayer::WaterMove() } // make bubbles - air = (int)( pev->air_finished - gpGlobals->time ); - if( !RANDOM_LONG( 0, 0x1f ) && RANDOM_LONG( 0, AIRTIME - 1 ) >= air ) + if( pev->waterlevel == 3 ) { - switch( RANDOM_LONG( 0, 3 ) ) + air = (int)( pev->air_finished - gpGlobals->time ); + if( !RANDOM_LONG( 0, 0x1f ) && RANDOM_LONG( 0, AIRTIME - 1 ) >= air ) { - case 0: - EMIT_SOUND( ENT( pev ), CHAN_BODY, "player/pl_swim1.wav", 0.8, ATTN_NORM ); - break; - case 1: - EMIT_SOUND( ENT( pev ), CHAN_BODY, "player/pl_swim2.wav", 0.8, ATTN_NORM ); - break; - case 2: - EMIT_SOUND( ENT( pev ), CHAN_BODY, "player/pl_swim3.wav", 0.8, ATTN_NORM ); - break; - case 3: - EMIT_SOUND( ENT( pev ), CHAN_BODY, "player/pl_swim4.wav", 0.8, ATTN_NORM ); - break; + switch( RANDOM_LONG( 0, 3 ) ) + { + case 0: + EMIT_SOUND( ENT( pev ), CHAN_BODY, "player/pl_swim1.wav", 0.8, ATTN_NORM ); + break; + case 1: + EMIT_SOUND( ENT( pev ), CHAN_BODY, "player/pl_swim2.wav", 0.8, ATTN_NORM ); + break; + case 2: + EMIT_SOUND( ENT( pev ), CHAN_BODY, "player/pl_swim3.wav", 0.8, ATTN_NORM ); + break; + case 3: + EMIT_SOUND( ENT( pev ), CHAN_BODY, "player/pl_swim4.wav", 0.8, ATTN_NORM ); + break; + } } } @@ -1737,7 +1740,7 @@ void CBasePlayer::UpdateStatusBar() Vector vecEnd = vecSrc + ( gpGlobals->v_forward * MAX_ID_RANGE ); UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, edict(), &tr ); - if( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0f ) { if( !FNullEnt( tr.pHit ) ) { @@ -1755,7 +1758,7 @@ void CBasePlayer::UpdateStatusBar() newSBarState[SBAR_ID_TARGETARMOR] = (int)pEntity->pev->armorvalue; //No need to get it % based since 100 it's the max. } - m_flStatusBarDisappearDelay = gpGlobals->time + 1.0; + m_flStatusBarDisappearDelay = gpGlobals->time + 1.0f; } } else if( m_flStatusBarDisappearDelay > gpGlobals->time ) @@ -1884,7 +1887,7 @@ void CBasePlayer::PreThink( void ) UTIL_TraceLine( pev->origin, pev->origin + Vector( 0, 0, -38 ), ignore_monsters, ENT( pev ), &trainTrace ); // HACKHACK - Just look for the func_tracktrain classname - if( trainTrace.flFraction != 1.0 && trainTrace.pHit ) + if( trainTrace.flFraction != 1.0f && trainTrace.pHit ) pTrain = CBaseEntity::Instance( trainTrace.pHit ); if( !pTrain || !( pTrain->ObjectCaps() & FCAP_DIRECTIONAL_USE ) || !pTrain->OnControls( pev ) ) @@ -2085,7 +2088,7 @@ void CBasePlayer::CheckTimeBasedDamage() return; // only check for time based damage approx. every 2 seconds - if( fabs( gpGlobals->time - m_tbdPrev ) < 2.0 ) + if( fabs( gpGlobals->time - m_tbdPrev ) < 2.0f ) return; m_tbdPrev = gpGlobals->time; @@ -2239,7 +2242,7 @@ Things powered by the battery // if in range of radiation source, ping geiger counter -#define GEIGERDELAY 0.25 +#define GEIGERDELAY 0.25f void CBasePlayer::UpdateGeigerCounter( void ) { @@ -2276,8 +2279,8 @@ Play suit update if it's time ================ */ -#define SUITUPDATETIME 3.5 -#define SUITFIRSTUPDATETIME 0.1 +#define SUITUPDATETIME 3.5f +#define SUITFIRSTUPDATETIME 0.1f void CBasePlayer::CheckSuitUpdate() { @@ -2677,7 +2680,7 @@ pt_end: // Track button info so we can detect 'pressed' and 'released' buttons next frame m_afButtonLast = pev->button; -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS // Decay timers on weapons // go through all of the weapons and make a list of the ones to pack for( int i = 0; i < MAX_ITEM_TYPES; i++ ) @@ -2694,23 +2697,23 @@ pt_end: if( gun && gun->UseDecrement() ) { - gun->m_flNextPrimaryAttack = Q_max( gun->m_flNextPrimaryAttack - gpGlobals->frametime, -1.0 ); - gun->m_flNextSecondaryAttack = Q_max( gun->m_flNextSecondaryAttack - gpGlobals->frametime, -0.001 ); + gun->m_flNextPrimaryAttack = Q_max( gun->m_flNextPrimaryAttack - gpGlobals->frametime, -1.0f ); + gun->m_flNextSecondaryAttack = Q_max( gun->m_flNextSecondaryAttack - gpGlobals->frametime, -0.001f ); - if( gun->m_flTimeWeaponIdle != 1000 ) + if( gun->m_flTimeWeaponIdle != 1000.0f ) { - gun->m_flTimeWeaponIdle = Q_max( gun->m_flTimeWeaponIdle - gpGlobals->frametime, -0.001 ); + gun->m_flTimeWeaponIdle = Q_max( gun->m_flTimeWeaponIdle - gpGlobals->frametime, -0.001f ); } - if( gun->pev->fuser1 != 1000 ) + if( gun->pev->fuser1 != 1000.0f ) { - gun->pev->fuser1 = Q_max( gun->pev->fuser1 - gpGlobals->frametime, -0.001 ); + gun->pev->fuser1 = Q_max( gun->pev->fuser1 - gpGlobals->frametime, -0.001f ); } // Only decrement if not flagged as NO_DECREMENT - /*if( gun->m_flPumpTime != 1000 ) + /*if( gun->m_flPumpTime != 1000.0f ) { - gun->m_flPumpTime = Q_max( gun->m_flPumpTime - gpGlobals->frametime, -0.001 ); + gun->m_flPumpTime = Q_max( gun->m_flPumpTime - gpGlobals->frametime, -0.001f ); }*/ } @@ -2720,23 +2723,23 @@ pt_end: } m_flNextAttack -= gpGlobals->frametime; - if( m_flNextAttack < -0.001 ) - m_flNextAttack = -0.001; + if( m_flNextAttack < -0.001f ) + m_flNextAttack = -0.001f; - if( m_flNextAmmoBurn != 1000 ) + if( m_flNextAmmoBurn != 1000.0f ) { m_flNextAmmoBurn -= gpGlobals->frametime; - if( m_flNextAmmoBurn < -0.001 ) - m_flNextAmmoBurn = -0.001; + if( m_flNextAmmoBurn < -0.001f ) + m_flNextAmmoBurn = -0.001f; } - if( m_flAmmoStartCharge != 1000 ) + if( m_flAmmoStartCharge != 1000.0f ) { m_flAmmoStartCharge -= gpGlobals->frametime; - if( m_flAmmoStartCharge < -0.001 ) - m_flAmmoStartCharge = -0.001; + if( m_flAmmoStartCharge < -0.001f ) + m_flAmmoStartCharge = -0.001f; } #else return; @@ -2888,8 +2891,14 @@ edict_t *EntSelectSpawnPoint( CBaseEntity *pPlayer ) } #if 0 - // landmark may still exists when no spawn spot - if( FNullEnt( pSpot ) ) + // If startspot is set, (re)spawn there. + if( FStringNull( gpGlobals->startspot ) || (STRING( gpGlobals->startspot ) )[0] == '\0') + { + pSpot = UTIL_FindEntityByClassname( NULL, "info_player_start" ); + if( !FNullEnt( pSpot ) ) + goto ReturnSpot; + } + else { pSpot = UTIL_FindEntityByTargetname( NULL, STRING( gpGlobals->startspot ) ); @@ -2930,8 +2939,8 @@ void CBasePlayer::Spawn( void ) pev->deadflag = DEAD_NO; pev->dmg_take = 0; pev->dmg_save = 0; - pev->friction = 1.0; - pev->gravity = 1.0; + pev->friction = 1.0f; + pev->gravity = 1.0f; m_bitsHUDDamage = -1; m_bitsDamageType = 0; m_afPhysicsFlags = 0; @@ -2945,12 +2954,12 @@ void CBasePlayer::Spawn( void ) m_flNextDecalTime = 0;// let this player decal as soon as he spawns. - m_flgeigerDelay = gpGlobals->time + 2.0; // wait a few seconds until user-defined message registrations + m_flgeigerDelay = gpGlobals->time + 2.0f; // wait a few seconds until user-defined message registrations // are recieved by all clients m_flTimeStepSound = 0; m_iStepLeft = 0; - m_flFieldOfView = 0.5;// some monsters use this to determine whether or not the player is looking at them. + m_flFieldOfView = 0.5f;// some monsters use this to determine whether or not the player is looking at them. m_bloodColor = BLOOD_COLOR_RED; m_flNextAttack = UTIL_WeaponTimeBase(); @@ -3127,7 +3136,7 @@ int CBasePlayer::Restore( CRestore &restore ) RenewItems(); -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS // HACK: This variable is saved/restored in CBaseMonster as a time variable, but we're using it // as just a counter. Ideally, this needs its own variable that's saved as a plain float. // Barring that, we clear it out here instead of using the incorrect restored time value. @@ -3225,7 +3234,9 @@ void CBasePlayer::SelectItem( const char *pstr ) if( m_pActiveItem ) { + m_pActiveItem->pev->oldbuttons = 1; m_pActiveItem->Deploy(); + m_pActiveItem->pev->oldbuttons = 0; m_pActiveItem->UpdateItemInfo(); } } @@ -3251,7 +3262,11 @@ void CBasePlayer::SelectLastItem( void ) CBasePlayerItem *pTemp = m_pActiveItem; m_pActiveItem = m_pLastItem; m_pLastItem = pTemp; + + m_pActiveItem->pev->oldbuttons = 1; m_pActiveItem->Deploy(); + m_pActiveItem->pev->oldbuttons = 0; + m_pActiveItem->UpdateItemInfo(); } @@ -3306,7 +3321,7 @@ void CSprayCan::Spawn( entvars_t *pevOwner ) pev->owner = ENT( pevOwner ); pev->frame = 0; - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; EMIT_SOUND( ENT( pev ), CHAN_VOICE, "player/sprayer.wav", 1, ATTN_NORM ); } @@ -3345,7 +3360,7 @@ void CSprayCan::Think( void ) UTIL_Remove( this ); } - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } class CBloodSplat : public CBaseEntity @@ -3362,7 +3377,7 @@ void CBloodSplat::Spawn( entvars_t *pevOwner ) pev->owner = ENT( pevOwner ); SetThink( &CBloodSplat::Spray ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } void CBloodSplat::Spray( void ) @@ -3377,7 +3392,7 @@ void CBloodSplat::Spray( void ) UTIL_BloodDecalTrace( &tr, BLOOD_COLOR_RED ); } SetThink( &CBaseEntity::SUB_Remove ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } //============================================== @@ -3406,7 +3421,7 @@ CBaseEntity *FindEntityForward( CBaseEntity *pMe ) UTIL_MakeVectors( pMe->pev->v_angle ); UTIL_TraceLine( pMe->pev->origin + pMe->pev->view_ofs,pMe->pev->origin + pMe->pev->view_ofs + gpGlobals->v_forward * 8192,dont_ignore_monsters, pMe->edict(), &tr ); - if( tr.flFraction != 1.0 && !FNullEnt( tr.pHit ) ) + if( tr.flFraction != 1.0f && !FNullEnt( tr.pHit ) ) { CBaseEntity *pHit = CBaseEntity::Instance( tr.pHit ); return pHit; @@ -3485,7 +3500,7 @@ void CBasePlayer::ForceClientDllUpdate( void ) ImpulseCommands ============ */ -extern float g_flWeaponCheat; +extern cvar_t *g_enable_cheats; void CBasePlayer::ImpulseCommands() { @@ -3542,7 +3557,7 @@ void CBasePlayer::ImpulseCommands() UTIL_MakeVectors( pev->v_angle ); UTIL_TraceLine( pev->origin + pev->view_ofs, pev->origin + pev->view_ofs + gpGlobals->v_forward * 128, ignore_monsters, ENT( pev ), &tr ); - if( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0f ) { // line hit something, so paint a decal m_flNextDecalTime = gpGlobals->time + decalfrequency.value; @@ -3563,8 +3578,8 @@ void CBasePlayer::ImpulseCommands() //========================================================= void CBasePlayer::CheatImpulseCommands( int iImpulse ) { -#if !defined( HLDEMO_BUILD ) - if( g_flWeaponCheat == 0.0 ) +#if !HLDEMO_BUILD + if( g_enable_cheats->value == 0 ) { return; } @@ -3600,7 +3615,7 @@ void CBasePlayer::CheatImpulseCommands( int iImpulse ) GiveNamedItem( "ammo_ARgrenades" ); GiveNamedItem( "weapon_handgrenade" ); GiveNamedItem( "weapon_tripmine" ); -#ifndef OEM_BUILD +#if !OEM_BUILD GiveNamedItem( "weapon_357" ); GiveNamedItem( "ammo_357" ); GiveNamedItem( "weapon_crossbow" ); @@ -3713,7 +3728,7 @@ void CBasePlayer::CheatImpulseCommands( int iImpulse ) UTIL_MakeVectors( pev->v_angle ); UTIL_TraceLine( pev->origin + pev->view_ofs, pev->origin + pev->view_ofs + gpGlobals->v_forward * 128, ignore_monsters, ENT( pev ), &tr ); - if( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0f ) { // line hit something, so paint a decal CBloodSplat *pBlood = GetClassPtr( (CBloodSplat *)NULL ); @@ -3888,7 +3903,7 @@ Called every frame by the player PreThink */ void CBasePlayer::ItemPreFrame() { -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS if( m_flNextAttack > 0 ) #else if( gpGlobals->time < m_flNextAttack ) @@ -3918,7 +3933,7 @@ void CBasePlayer::ItemPostFrame() if( m_pTank != 0 ) return; -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS if( m_flNextAttack > 0 ) #else if( gpGlobals->time < m_flNextAttack ) @@ -4248,7 +4263,7 @@ void CBasePlayer::UpdateClientData( void ) if( m_flNextSBarUpdateTime < gpGlobals->time ) { UpdateStatusBar(); - m_flNextSBarUpdateTime = gpGlobals->time + 0.2; + m_flNextSBarUpdateTime = gpGlobals->time + 0.2f; } // Send the current bhopcap state. @@ -4304,6 +4319,18 @@ int CBasePlayer::Illumination( void ) return iIllum; } +void CBasePlayer::SetPrefsFromUserinfo( char *infobuffer ) +{ + const char *pszKeyVal; + + pszKeyVal = g_engfuncs.pfnInfoKeyValue( infobuffer, "cl_autowepswitch" ); + + if( pszKeyVal[0] != '\0' ) + m_iAutoWepSwitch = atoi( pszKeyVal ); + else + m_iAutoWepSwitch = 1; +} + void CBasePlayer::EnableControl( BOOL fControl ) { if( !fControl ) @@ -4339,7 +4366,7 @@ Vector CBasePlayer::GetAutoaimVector( float flDelta ) } Vector vecSrc = GetGunPosition(); - float flDist = 8192; + float flDist = 8192.0f; // always use non-sticky autoaim // UNDONE: use sever variable to chose! @@ -4382,11 +4409,11 @@ Vector CBasePlayer::GetAutoaimVector( float flDelta ) // UNDONE: use sever variable to chose! if( 0 || g_iSkillLevel == SKILL_EASY ) { - m_vecAutoAim = m_vecAutoAim * 0.67 + angles * 0.33; + m_vecAutoAim = m_vecAutoAim * 0.67f + angles * 0.33f; } else { - m_vecAutoAim = angles * 0.9; + m_vecAutoAim = angles * 0.9f; } // m_vecAutoAim = m_vecAutoAim * 0.99; @@ -4484,16 +4511,16 @@ Vector CBasePlayer::AutoaimDeflection( Vector &vecSrc, float flDist, float flDel if( DotProduct( dir, gpGlobals->v_forward ) < 0 ) continue; - dot = fabs( DotProduct( dir, gpGlobals->v_right ) ) + fabs( DotProduct( dir, gpGlobals->v_up ) ) * 0.5; + dot = fabs( DotProduct( dir, gpGlobals->v_right ) ) + fabs( DotProduct( dir, gpGlobals->v_up ) ) * 0.5f; // tweek for distance - dot *= 1.0 + 0.2 * ( ( center - vecSrc ).Length() / flDist ); + dot *= 1.0f + 0.2f * ( ( center - vecSrc ).Length() / flDist ); if( dot > bestdot ) continue; // to far to turn UTIL_TraceLine( vecSrc, center, dont_ignore_monsters, edict(), &tr ); - if( tr.flFraction != 1.0 && tr.pHit != pEdict ) + if( tr.flFraction != 1.0f && tr.pHit != pEdict ) { // ALERT( at_console, "hit %s, can't see %s\n", STRING( tr.pHit->v.classname ), STRING( pEdict->v.classname ) ); continue; @@ -4578,7 +4605,7 @@ void CBasePlayer::DropPlayerItem( char *pszItemName ) return; } - if( !strlen( pszItemName ) ) + if( pszItemName[0] == '\0' ) { // if this string has no length, the client didn't type a name! // assume player wants to drop the active item. @@ -4723,7 +4750,10 @@ BOOL CBasePlayer::SwitchWeapon( CBasePlayerItem *pWeapon ) } m_pActiveItem = pWeapon; + + pWeapon->pev->oldbuttons = 1; pWeapon->Deploy(); + pWeapon->pev->oldbuttons = 0; return TRUE; } @@ -4933,7 +4963,7 @@ void CInfoIntermission::Spawn( void ) pev->effects = EF_NODRAW; pev->v_angle = g_vecZero; - pev->nextthink = gpGlobals->time + 2;// let targets spawn! + pev->nextthink = gpGlobals->time + 2.0f;// let targets spawn! } void CInfoIntermission::Think( void ) diff --git a/dlls/player.h b/dlls/player.h index fb69c333..dfa440ad 100644 --- a/dlls/player.h +++ b/dlls/player.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef PLAYER_H +#if !defined(PLAYER_H) #define PLAYER_H #include "pm_materials.h" @@ -315,7 +315,7 @@ public: float m_flPlayAftershock; float m_flNextAmmoBurn;// while charging, when to absorb another unit of player's ammo? - //Player ID + // Player ID void InitStatusBar( void ); void UpdateStatusBar( void ); int m_izSBarState[SBAR_END]; @@ -324,8 +324,12 @@ public: char m_SbarString0[SBAR_STRING_SIZE]; char m_SbarString1[SBAR_STRING_SIZE]; + void SetPrefsFromUserinfo( char *infobuffer ); + float m_flNextChatTime; + int m_iAutoWepSwitch; + Vector m_vecLastViewAngles; bool m_bSentBhopcap; // If false, the player just joined and needs a bhopcap message. diff --git a/dlls/python.cpp b/dlls/python.cpp index 88aa34b5..567187c0 100644 --- a/dlls/python.cpp +++ b/dlls/python.cpp @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ -#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD ) +#if !OEM_BUILD && !HLDEMO_BUILD #include "extdll.h" #include "util.h" @@ -97,7 +97,7 @@ void CPython::Precache( void ) BOOL CPython::Deploy() { -#ifdef CLIENT_DLL +#if CLIENT_DLL if( bIsMultiplayer() ) #else if( g_pGameRules->IsMultiplayer() ) @@ -123,14 +123,14 @@ void CPython::Holster( int skiplocal /* = 0 */ ) SecondaryAttack(); } - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0f; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10.0f, 15.0f ); SendWeaponAnim( PYTHON_HOLSTER ); } void CPython::SecondaryAttack( void ) { -#ifdef CLIENT_DLL +#if CLIENT_DLL if( !bIsMultiplayer() ) #else if( !g_pGameRules->IsMultiplayer() ) @@ -150,7 +150,7 @@ void CPython::SecondaryAttack( void ) m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 40; } - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; + m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5f; } void CPython::PrimaryAttack() @@ -159,7 +159,7 @@ void CPython::PrimaryAttack() if( m_pPlayer->pev->waterlevel == 3 ) { PlayEmptySound(); - m_flNextPrimaryAttack = 0.15; + m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15f; return; } @@ -170,7 +170,7 @@ void CPython::PrimaryAttack() else { PlayEmptySound(); - m_flNextPrimaryAttack = 0.15; + m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15f; } return; @@ -195,7 +195,7 @@ void CPython::PrimaryAttack() vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, VECTOR_CONE_1DEGREES, 8192, BULLET_PLAYER_357, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed ); int flags; -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS flags = FEV_NOTHOST; #else flags = 0; @@ -206,8 +206,8 @@ void CPython::PrimaryAttack() // HEV suit - indicate out of ammo condition m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 ); - m_flNextPrimaryAttack = 0.75; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); + m_flNextPrimaryAttack = 0.75f; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10.0f, 15.0f ); } void CPython::Reload( void ) @@ -222,14 +222,14 @@ void CPython::Reload( void ) } int bUseScope = FALSE; -#ifdef CLIENT_DLL +#if CLIENT_DLL bUseScope = bIsMultiplayer(); #else bUseScope = g_pGameRules->IsMultiplayer(); #endif - if( DefaultReload( PYTHON_MAX_CLIP, PYTHON_RELOAD, 2.0, bUseScope ) ) + if( DefaultReload( PYTHON_MAX_CLIP, PYTHON_RELOAD, 2.0f, bUseScope ) ) { - m_flSoundDelay = 1.5; + m_flSoundDelay = 1.5f; } } @@ -242,8 +242,8 @@ void CPython::WeaponIdle( void ) // ALERT( at_console, "%.2f\n", gpGlobals->time - m_flSoundDelay ); if( m_flSoundDelay != 0 && m_flSoundDelay <= UTIL_WeaponTimeBase() ) { - EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/357_reload1.wav", RANDOM_FLOAT( 0.8, 0.9 ), ATTN_NORM ); - m_flSoundDelay = 0; + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/357_reload1.wav", RANDOM_FLOAT( 0.8f, 0.9f ), ATTN_NORM ); + m_flSoundDelay = 0.0f; } if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) @@ -251,29 +251,29 @@ void CPython::WeaponIdle( void ) int iAnim; float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0.0f, 1.0f ); - if( flRand <= 0.5 ) + if( flRand <= 0.5f ) { iAnim = PYTHON_IDLE1; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 70.0 / 30.0 ); + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 70.0f / 30.0f ); } - else if( flRand <= 0.7 ) + else if( flRand <= 0.7f ) { iAnim = PYTHON_IDLE2; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 60.0 / 30.0 ); + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 60.0f / 30.0f ); } - else if( flRand <= 0.9 ) + else if( flRand <= 0.9f ) { iAnim = PYTHON_IDLE3; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 88.0 / 30.0 ); + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 88.0f / 30.0f ); } else { iAnim = PYTHON_FIDGET; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 170.0 / 30.0 ); + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 170.0f / 30.0f ); } int bUseScope = FALSE; -#ifdef CLIENT_DLL +#if CLIENT_DLL bUseScope = bIsMultiplayer(); #else bUseScope = g_pGameRules->IsMultiplayer(); diff --git a/dlls/roach.cpp b/dlls/roach.cpp index 692b4beb..66e9702d 100644 --- a/dlls/roach.cpp +++ b/dlls/roach.cpp @@ -190,7 +190,7 @@ void CRoach::MonsterThink( void ) if( FNullEnt( FIND_CLIENT_IN_PVS( edict() ) ) ) pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 1, 1.5 ); else - pev->nextthink = gpGlobals->time + 0.1;// keep monster thinking + pev->nextthink = gpGlobals->time + 0.1f;// keep monster thinking float flInterval = StudioFrameAdvance(); // animate @@ -262,7 +262,7 @@ void CRoach::MonsterThink( void ) pSound = CSoundEnt::SoundPointerForIndex( m_iAudibleList ); // roach smells food and is just standing around. Go to food unless food isn't on same z-plane. - if( pSound && fabs( pSound->m_vecOrigin.z - pev->origin.z ) <= 3.0 ) + if( pSound && fabs( pSound->m_vecOrigin.z - pev->origin.z ) <= 3.0f ) { PickNewDest( ROACH_SMELL_FOOD ); SetActivity( ACT_WALK ); diff --git a/dlls/rpg.cpp b/dlls/rpg.cpp index 9171ce3a..98050d56 100644 --- a/dlls/rpg.cpp +++ b/dlls/rpg.cpp @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ -#if !defined( OEM_BUILD ) +#if !OEM_BUILD #include "extdll.h" #include "util.h" @@ -39,7 +39,7 @@ enum rpg_e LINK_ENTITY_TO_CLASS( weapon_rpg, CRpg ) -#ifndef CLIENT_DLL +#if !CLIENT_DLL LINK_ENTITY_TO_CLASS( laser_spot, CLaserSpot ) @@ -134,14 +134,14 @@ void CRpgRocket::Spawn( void ) SetThink( &CRpgRocket::IgniteThink ); SetTouch( &CGrenade::ExplodeTouch ); - pev->angles.x -= 30; + pev->angles.x -= 30.0f; UTIL_MakeVectors( pev->angles ); - pev->angles.x = -( pev->angles.x + 30 ); + pev->angles.x = -( pev->angles.x + 30.0f ); - pev->velocity = gpGlobals->v_forward * 250; - pev->gravity = 0.5; + pev->velocity = gpGlobals->v_forward * 250.0f; + pev->gravity = 0.5f; - pev->nextthink = gpGlobals->time + 0.4; + pev->nextthink = gpGlobals->time + 0.4f; pev->dmg = gSkillData.plrDmgRPG; } @@ -177,7 +177,7 @@ void CRpgRocket::IgniteThink( void ) pev->effects |= EF_LIGHT; // make rocket sound - EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/rocket1.wav", 1, 0.5 ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/rocket1.wav", 1, 0.5f ); // rocket trail MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); @@ -196,7 +196,7 @@ void CRpgRocket::IgniteThink( void ) // set to follow laser spot SetThink( &CRpgRocket::FollowThink ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } void CRpgRocket::FollowThink( void ) @@ -217,7 +217,7 @@ void CRpgRocket::FollowThink( void ) { UTIL_TraceLine( pev->origin, pOther->pev->origin, dont_ignore_monsters, ENT( pev ), &tr ); // ALERT( at_console, "%f\n", tr.flFraction ); - if( tr.flFraction >= 0.90 ) + if( tr.flFraction >= 0.9f ) { vecDir = pOther->pev->origin - pev->origin; flDist = vecDir.Length(); @@ -235,23 +235,23 @@ void CRpgRocket::FollowThink( void ) // this acceleration and turning math is totally wrong, but it seems to respond well so don't change it. float flSpeed = pev->velocity.Length(); - if( gpGlobals->time - m_flIgniteTime < 1.0 ) + if( gpGlobals->time - m_flIgniteTime < 1.0f ) { - pev->velocity = pev->velocity * 0.2 + vecTarget * ( flSpeed * 0.8 + 400 ); + pev->velocity = pev->velocity * 0.2f + vecTarget * ( flSpeed * 0.8f + 400.0f ); if( pev->waterlevel == 3 ) { // go slow underwater - if( pev->velocity.Length() > 300 ) + if( pev->velocity.Length() > 300.0f ) { - pev->velocity = pev->velocity.Normalize() * 300; + pev->velocity = pev->velocity.Normalize() * 300.0f; } - UTIL_BubbleTrail( pev->origin - pev->velocity * 0.1, pev->origin, 4 ); + UTIL_BubbleTrail( pev->origin - pev->velocity * 0.1f, pev->origin, 4 ); } else { - if( pev->velocity.Length() > 2000 ) + if( pev->velocity.Length() > 2000.0f ) { - pev->velocity = pev->velocity.Normalize() * 2000; + pev->velocity = pev->velocity.Normalize() * 2000.0f; } } } @@ -262,10 +262,10 @@ void CRpgRocket::FollowThink( void ) pev->effects = 0; STOP_SOUND( ENT( pev ), CHAN_VOICE, "weapons/rocket1.wav" ); } - pev->velocity = pev->velocity * 0.2 + vecTarget * flSpeed * 0.798; + pev->velocity = pev->velocity * 0.2f + vecTarget * flSpeed * 0.798f; /* // WHY??? - if( pev->waterlevel == 0 && pev->velocity.Length() < 1500 ) + if( pev->waterlevel == 0 && pev->velocity.Length() < 1500.0f ) { if( CRpg *pLauncher = (CRpg*)( (CBaseEntity*)( m_hLauncher ) ) ) { @@ -278,7 +278,7 @@ void CRpgRocket::FollowThink( void ) } // ALERT( at_console, "%.0f\n", flSpeed ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } #endif @@ -300,7 +300,7 @@ void CRpg::Reload( void ) // Set the next attack time into the future so that WeaponIdle will get called more often // than reload, allowing the RPG LTD to be updated - m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); + m_flNextPrimaryAttack = GetNextAttackDelay( 0.5f ); if( m_cActiveRockets && m_fSpotActive ) { @@ -309,11 +309,11 @@ void CRpg::Reload( void ) return; } -#ifndef CLIENT_DLL +#if !CLIENT_DLL if( m_pSpot && m_fSpotActive ) { - m_pSpot->Suspend( 2.1 ); - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 2.1; + m_pSpot->Suspend( 2.1f ); + m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 2.1f; } #endif @@ -332,7 +332,7 @@ void CRpg::Spawn() SET_MODEL( ENT( pev ), "models/w_rpg.mdl" ); m_fSpotActive = 1; -#ifdef CLIENT_DLL +#if CLIENT_DLL if( bIsMultiplayer() ) #else if( g_pGameRules->IsMultiplayer() ) @@ -420,11 +420,11 @@ void CRpg::Holster( int skiplocal /* = 0 */ ) { m_fInReload = FALSE;// cancel any reload in progress. - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5f; SendWeaponAnim( RPG_HOLSTER1 ); -#ifndef CLIENT_DLL +#if !CLIENT_DLL if( m_pSpot ) { m_pSpot->Killed( NULL, GIB_NEVER ); @@ -440,12 +440,12 @@ void CRpg::PrimaryAttack() m_pPlayer->m_iWeaponVolume = LOUD_GUN_VOLUME; m_pPlayer->m_iWeaponFlash = BRIGHT_GUN_FLASH; -#ifndef CLIENT_DLL +#if !CLIENT_DLL // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); UTIL_MakeVectors( m_pPlayer->pev->v_angle ); - Vector vecSrc = m_pPlayer->GetGunPosition() + gpGlobals->v_forward * 16 + gpGlobals->v_right * 8 + gpGlobals->v_up * -8; + Vector vecSrc = m_pPlayer->GetGunPosition() + gpGlobals->v_forward * 16.0f + gpGlobals->v_right * 8.0f + gpGlobals->v_up * -8.0f; CRpgRocket *pRocket = CRpgRocket::CreateRpgRocket( vecSrc, m_pPlayer->pev->v_angle, m_pPlayer, this ); @@ -457,7 +457,7 @@ void CRpg::PrimaryAttack() // Ken signed up for this as a global change (sjb) int flags; -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS flags = FEV_NOTHOST; #else flags = 0; @@ -466,15 +466,15 @@ void CRpg::PrimaryAttack() m_iClip--; - m_flNextPrimaryAttack = GetNextAttackDelay( 1.5 ); - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.5; + m_flNextPrimaryAttack = GetNextAttackDelay( 1.5f ); + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.5f; ResetEmptySound(); } else { PlayEmptySound(); - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.2; + m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.2f; } UpdateSpot(); } @@ -483,14 +483,14 @@ void CRpg::SecondaryAttack() { m_fSpotActive = !m_fSpotActive; -#ifndef CLIENT_DLL +#if !CLIENT_DLL if( !m_fSpotActive && m_pSpot ) { m_pSpot->Killed( NULL, GIB_NORMAL ); m_pSpot = NULL; } #endif - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.2; + m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.2f; } void CRpg::WeaponIdle( void ) @@ -505,15 +505,15 @@ void CRpg::WeaponIdle( void ) ResetEmptySound(); int iAnim; - float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 ); - if( flRand <= 0.75 || m_fSpotActive ) + float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0.0f, 1.0f ); + if( flRand <= 0.75f || m_fSpotActive ) { if( m_iClip == 0 ) iAnim = RPG_IDLE_UL; else iAnim = RPG_IDLE; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 90.0 / 15.0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 90.0f / 15.0f; } else { @@ -521,23 +521,29 @@ void CRpg::WeaponIdle( void ) iAnim = RPG_FIDGET_UL; else iAnim = RPG_FIDGET; - - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3.0; +#if WEAPONS_ANIMATION_TIMES_FIX + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 6.1f; +#else + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3.0f; +#endif } SendWeaponAnim( iAnim ); } else { - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0f; } } void CRpg::UpdateSpot( void ) { -#ifndef CLIENT_DLL +#if !CLIENT_DLL if( m_fSpotActive ) { + if (m_pPlayer->pev->viewmodel == 0) + return; + if( !m_pSpot ) { m_pSpot = CLaserSpot::CreateSpot(); @@ -548,7 +554,7 @@ void CRpg::UpdateSpot( void ) Vector vecAiming = gpGlobals->v_forward; TraceResult tr; - UTIL_TraceLine( vecSrc, vecSrc + vecAiming * 8192, dont_ignore_monsters, ENT( m_pPlayer->pev ), &tr ); + UTIL_TraceLine( vecSrc, vecSrc + vecAiming * 8192.0f, dont_ignore_monsters, ENT( m_pPlayer->pev ), &tr ); UTIL_SetOrigin( m_pSpot->pev, tr.vecEndPos ); } @@ -571,7 +577,7 @@ class CRpgAmmo : public CBasePlayerAmmo BOOL AddAmmo( CBaseEntity *pOther ) { int iGive; -#ifdef CLIENT_DLL +#if CLIENT_DLL if( bIsMultiplayer() ) #else if( g_pGameRules->IsMultiplayer() ) diff --git a/dlls/satchel.cpp b/dlls/satchel.cpp index dc8724bd..38ebec08 100644 --- a/dlls/satchel.cpp +++ b/dlls/satchel.cpp @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ -#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD ) +#if !OEM_BUILD && !HLDEMO_BUILD #include "extdll.h" #include "util.h" @@ -88,10 +88,10 @@ void CSatchelCharge::Spawn( void ) SetTouch( &CSatchelCharge::SatchelSlide ); SetUse( &CGrenade::DetonateUse ); SetThink( &CSatchelCharge::SatchelThink ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; - pev->gravity = 0.5; - pev->friction = 0.8; + pev->gravity = 0.5f; + pev->friction = 0.8f; pev->dmg = gSkillData.plrDmgSatchel; // ResetSequenceInfo(); @@ -113,14 +113,14 @@ void CSatchelCharge::SatchelSlide( CBaseEntity *pOther ) TraceResult tr; UTIL_TraceLine( pev->origin, pev->origin - Vector( 0, 0, 10 ), ignore_monsters, edict(), &tr ); - if( tr.flFraction < 1.0 ) + if( tr.flFraction < 1.0f ) { // add a bit of static friction pev->velocity = pev->velocity * 0.95; pev->avelocity = pev->avelocity * 0.9; // play sliding sound, volume based on velocity } - if( !( pev->flags & FL_ONGROUND ) && pev->velocity.Length2D() > 10 ) + if( !( pev->flags & FL_ONGROUND ) && pev->velocity.Length2D() > 10.0f ) { // Fix for a bug in engine: when object isn't moving, but its speed isn't 0 and on ground isn't set if( pev->origin != m_lastBounceOrigin ) @@ -135,7 +135,7 @@ void CSatchelCharge::SatchelThink( void ) { // There is no model animation so commented this out to prevent net traffic // StudioFrameAdvance(); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; if( !IsInWorld() ) { @@ -146,8 +146,8 @@ void CSatchelCharge::SatchelThink( void ) if( pev->waterlevel == 3 ) { pev->movetype = MOVETYPE_FLY; - pev->velocity = pev->velocity * 0.8; - pev->avelocity = pev->avelocity * 0.9; + pev->velocity = pev->velocity * 0.8f; + pev->avelocity = pev->avelocity * 0.9f; pev->velocity.z += 8; } else if( pev->waterlevel == 0 ) @@ -156,7 +156,7 @@ void CSatchelCharge::SatchelThink( void ) } else { - pev->velocity.z -= 8; + pev->velocity.z -= 8.0f; } } @@ -193,7 +193,7 @@ int CSatchel::AddDuplicate( CBasePlayerItem *pOriginal ) { CSatchel *pSatchel; -#ifdef CLIENT_DLL +#if CLIENT_DLL if( bIsMultiplayer() ) #else if( g_pGameRules->IsMultiplayer() ) @@ -292,20 +292,26 @@ BOOL CSatchel::CanDeploy( void ) BOOL CSatchel::Deploy() { - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0f; + BOOL result; if( m_chargeReady ) - return DefaultDeploy( "models/v_satchel_radio.mdl", "models/p_satchel_radio.mdl", SATCHEL_RADIO_DRAW, "hive" ); + result = DefaultDeploy( "models/v_satchel_radio.mdl", "models/p_satchel_radio.mdl", SATCHEL_RADIO_DRAW, "hive" ); else - return DefaultDeploy( "models/v_satchel.mdl", "models/p_satchel.mdl", SATCHEL_DRAW, "trip" ); + result = DefaultDeploy( "models/v_satchel.mdl", "models/p_satchel.mdl", SATCHEL_DRAW, "trip" ); - return TRUE; +#if WEAPONS_ANIMATION_TIMES_FIX + if ( result ) + { + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0f; + } +#endif + return result; } void CSatchel::Holster( int skiplocal /* = 0 */ ) { - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5f; if( m_chargeReady ) { @@ -315,7 +321,7 @@ void CSatchel::Holster( int skiplocal /* = 0 */ ) { SendWeaponAnim( SATCHEL_DROP ); } - EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM ); + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "common/null.wav", 1.0f, ATTN_NORM ); if( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] && m_chargeReady != SATCHEL_READY ) { @@ -353,9 +359,9 @@ void CSatchel::PrimaryAttack() } m_chargeReady = SATCHEL_RELOAD; - m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.5f ); + m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5f; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5f; break; } case SATCHEL_RELOAD: @@ -376,7 +382,7 @@ void CSatchel::Throw( void ) { if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { -#ifndef CLIENT_DLL +#if !CLIENT_DLL Vector vecSrc = m_pPlayer->pev->origin; Vector vecThrow = gpGlobals->v_forward * 274 + m_pPlayer->pev->velocity; @@ -400,8 +406,8 @@ void CSatchel::Throw( void ) m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; - m_flNextPrimaryAttack = GetNextAttackDelay( 1.0 ); - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; + m_flNextPrimaryAttack = GetNextAttackDelay( 1.0f ); + m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5f; } } @@ -430,7 +436,7 @@ void CSatchel::WeaponIdle( void ) return; } -#ifndef CLIENT_DLL +#if !CLIENT_DLL m_pPlayer->pev->viewmodel = MAKE_STRING( "models/v_satchel.mdl" ); m_pPlayer->pev->weaponmodel = MAKE_STRING( "models/p_satchel.mdl" ); #else @@ -441,8 +447,8 @@ void CSatchel::WeaponIdle( void ) // use tripmine animations strcpy( m_pPlayer->m_szAnimExtention, "trip" ); - m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.5f ); + m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5f; m_chargeReady = SATCHEL_IDLE; break; } diff --git a/dlls/saverestore.h b/dlls/saverestore.h index bd302394..a2b017d7 100644 --- a/dlls/saverestore.h +++ b/dlls/saverestore.h @@ -14,7 +14,7 @@ ****/ // Implementation in UTIL.CPP #pragma once -#ifndef SAVERESTORE_H +#if !defined(SAVERESTORE_H) #define SAVERESTORE_H class CBaseEntity; @@ -157,7 +157,7 @@ public: int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; -//#ifdef _DEBUG +//#if _DEBUG void DumpGlobals( void ); //#endif diff --git a/dlls/schedule.cpp b/dlls/schedule.cpp index 1db7dcb7..7abd05c8 100644 --- a/dlls/schedule.cpp +++ b/dlls/schedule.cpp @@ -181,7 +181,7 @@ BOOL CBaseMonster::FScheduleValid( void ) if( HasConditions( m_pSchedule->iInterruptMask | bits_COND_SCHEDULE_DONE | bits_COND_TASK_FAILED ) ) { -#ifdef DEBUG +#if DEBUG if( HasConditions( bits_COND_TASK_FAILED ) && m_failSchedule == SCHED_NONE ) { // fail! Send a visual indicator. @@ -414,7 +414,7 @@ void CBaseMonster::RunTask( Task_t *pTask ) distance = ( m_vecMoveGoal - pev->origin ).Length2D(); // Re-evaluate when you think your finished, or the target has moved too far - if( ( distance < pTask->flData ) || ( m_vecMoveGoal - m_hTargetEnt->pev->origin ).Length() > pTask->flData * 0.5 ) + if( ( distance < pTask->flData ) || ( m_vecMoveGoal - m_hTargetEnt->pev->origin ).Length() > pTask->flData * 0.5f ) { m_vecMoveGoal = m_hTargetEnt->pev->origin; distance = ( m_vecMoveGoal - pev->origin ).Length2D(); @@ -1378,7 +1378,7 @@ Schedule_t *CBaseMonster::GetSchedule( void ) if( HasConditions( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE ) ) { - if( fabs( FlYawDiff() ) < ( 1.0 - m_flFieldOfView ) * 60 ) // roughly in the correct direction + if( fabs( FlYawDiff() ) < ( 1.0f - m_flFieldOfView ) * 60.0f ) // roughly in the correct direction { return GetScheduleOfType( SCHED_TAKE_COVER_FROM_ORIGIN ); } diff --git a/dlls/schedule.h b/dlls/schedule.h index 6414ff15..f3b3101b 100644 --- a/dlls/schedule.h +++ b/dlls/schedule.h @@ -16,7 +16,7 @@ // Scheduling //========================================================= #pragma once -#ifndef SCHEDULE_H +#if !defined(SCHEDULE_H) #define SCHEDULE_H #define TASKSTATUS_NEW 0 // Just started diff --git a/dlls/scientist.cpp b/dlls/scientist.cpp index 47102d50..c3f95d47 100644 --- a/dlls/scientist.cpp +++ b/dlls/scientist.cpp @@ -136,7 +136,7 @@ IMPLEMENT_SAVERESTORE( CScientist, CTalkMonster ) Task_t tlFollow[] = { { TASK_SET_FAIL_SCHEDULE, (float)SCHED_CANT_FOLLOW }, // If you fail, bail out of follow - { TASK_MOVE_TO_TARGET_RANGE, (float)128 }, // Move within 128 of target ent (client) + { TASK_MOVE_TO_TARGET_RANGE, 128.0f }, // Move within 128 of target ent (client) //{ TASK_SET_SCHEDULE, (float)SCHED_TARGET_FACE }, }; @@ -158,7 +158,7 @@ Schedule_t slFollow[] = Task_t tlFollowScared[] = { { TASK_SET_FAIL_SCHEDULE, (float)SCHED_TARGET_CHASE },// If you fail, follow normally - { TASK_MOVE_TO_TARGET_RANGE_SCARED, (float)128 }, // Move within 128 of target ent (client) + { TASK_MOVE_TO_TARGET_RANGE_SCARED, 128.0f }, // Move within 128 of target ent (client) //{ TASK_SET_SCHEDULE, (float)SCHED_TARGET_FACE_SCARED }, }; @@ -178,7 +178,7 @@ Schedule_t slFollowScared[] = Task_t tlFaceTargetScared[] = { - { TASK_FACE_TARGET, (float)0 }, + { TASK_FACE_TARGET, 0.0f }, { TASK_SET_ACTIVITY, (float)ACT_CROUCHIDLE }, { TASK_SET_SCHEDULE, (float)SCHED_TARGET_CHASE_SCARED }, }; @@ -197,7 +197,7 @@ Schedule_t slFaceTargetScared[] = Task_t tlStopFollowing[] = { - { TASK_CANT_FOLLOW, (float)0 }, + { TASK_CANT_FOLLOW, 0.0f }, }; Schedule_t slStopFollowing[] = @@ -213,12 +213,12 @@ Schedule_t slStopFollowing[] = Task_t tlHeal[] = { - { TASK_MOVE_TO_TARGET_RANGE, (float)50 }, // Move within 60 of target ent (client) + { TASK_MOVE_TO_TARGET_RANGE, 50.0f }, // Move within 60 of target ent (client) { TASK_SET_FAIL_SCHEDULE, (float)SCHED_TARGET_CHASE }, // If you fail, catch up with that guy! (change this to put syringe away and then chase) - { TASK_FACE_IDEAL, (float)0 }, - { TASK_SAY_HEAL, (float)0 }, + { TASK_FACE_IDEAL, 0.0f }, + { TASK_SAY_HEAL, 0.0f }, { TASK_PLAY_SEQUENCE_FACE_TARGET, (float)ACT_ARM }, // Whip out the needle - { TASK_HEAL, (float)0 }, // Put it in the player + { TASK_HEAL, 0.0f }, // Put it in the player { TASK_PLAY_SEQUENCE_FACE_TARGET, (float)ACT_DISARM }, // Put away the needle }; @@ -235,8 +235,8 @@ Schedule_t slHeal[] = Task_t tlFaceTarget[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_FACE_TARGET, (float)0 }, + { TASK_STOP_MOVING, 0.0f }, + { TASK_FACE_TARGET, 0.0f }, { TASK_SET_ACTIVITY, (float)ACT_IDLE }, { TASK_SET_SCHEDULE, (float)SCHED_TARGET_CHASE }, }; @@ -257,9 +257,9 @@ Schedule_t slFaceTarget[] = Task_t tlSciPanic[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_SCREAM, (float)0 }, + { TASK_STOP_MOVING, 0.0f }, + { TASK_FACE_ENEMY, 0.0f }, + { TASK_SCREAM, 0.0f }, { TASK_PLAY_SEQUENCE_FACE_ENEMY, (float)ACT_EXCITED }, // This is really fear-stricken excitement { TASK_SET_ACTIVITY, (float)ACT_IDLE }, }; @@ -279,7 +279,7 @@ Task_t tlIdleSciStand[] = { { TASK_STOP_MOVING, 0 }, { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_WAIT, (float)2 }, // repick IDLESTAND every two seconds. + { TASK_WAIT, 2.0f }, // repick IDLESTAND every two seconds. { TASK_TLK_HEADRESET, (float)0 }, // reset head position }; @@ -310,10 +310,10 @@ Schedule_t slIdleSciStand[] = Task_t tlScientistCover[] = { { TASK_SET_FAIL_SCHEDULE, (float)SCHED_PANIC }, // If you fail, just panic! - { TASK_STOP_MOVING, (float)0 }, - { TASK_FIND_COVER_FROM_ENEMY, (float)0 }, - { TASK_RUN_PATH_SCARED, (float)0 }, - { TASK_TURN_LEFT, (float)179 }, + { TASK_STOP_MOVING, 0.0f }, + { TASK_FIND_COVER_FROM_ENEMY, 0.0f }, + { TASK_RUN_PATH_SCARED, 0.0f }, + { TASK_TURN_LEFT, 179.0f }, { TASK_SET_SCHEDULE, (float)SCHED_HIDE }, }; @@ -331,10 +331,10 @@ Schedule_t slScientistCover[] = Task_t tlScientistHide[] = { { TASK_SET_FAIL_SCHEDULE, (float)SCHED_PANIC }, // If you fail, just panic! - { TASK_STOP_MOVING, (float)0 }, + { TASK_STOP_MOVING, 0.0f }, { TASK_PLAY_SEQUENCE, (float)ACT_CROUCH }, { TASK_SET_ACTIVITY, (float)ACT_CROUCHIDLE }, // FIXME: This looks lame - { TASK_WAIT_RANDOM, (float)10.0 }, + { TASK_WAIT_RANDOM, 10.0f }, }; Schedule_t slScientistHide[] = @@ -356,12 +356,12 @@ Schedule_t slScientistHide[] = Task_t tlScientistStartle[] = { { TASK_SET_FAIL_SCHEDULE, (float)SCHED_PANIC }, // If you fail, just panic! - { TASK_RANDOM_SCREAM, (float)0.3 }, // Scream 30% of the time - { TASK_STOP_MOVING, (float)0 }, + { TASK_RANDOM_SCREAM, 0.3f }, // Scream 30% of the time + { TASK_STOP_MOVING, 0.0f }, { TASK_PLAY_SEQUENCE_FACE_ENEMY, (float)ACT_CROUCH }, - { TASK_RANDOM_SCREAM, (float)0.1 }, // Scream again 10% of the time + { TASK_RANDOM_SCREAM, 0.1f }, // Scream again 10% of the time { TASK_PLAY_SEQUENCE_FACE_ENEMY, (float)ACT_CROUCHIDLE }, - { TASK_WAIT_RANDOM, (float)1.0 }, + { TASK_WAIT_RANDOM, 1.0f }, }; Schedule_t slScientistStartle[] = @@ -381,9 +381,9 @@ Schedule_t slScientistStartle[] = Task_t tlFear[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_FACE_ENEMY, (float)0 }, - { TASK_SAY_FEAR, (float)0 }, + { TASK_STOP_MOVING, 0.0f }, + { TASK_FACE_ENEMY, 0.0f }, + { TASK_SAY_FEAR, 0.0f }, //{ TASK_PLAY_SEQUENCE, (float)ACT_FEAR_DISPLAY }, }; @@ -429,7 +429,7 @@ void CScientist::Scream( void ) { Talk( 10 ); m_hTalkTarget = m_hEnemy; - PlaySentence( "SC_SCREAM", RANDOM_FLOAT( 3, 6 ), VOL_NORM, ATTN_NORM ); + PlaySentence( "SC_SCREAM", RANDOM_FLOAT( 3.0f, 6.0f ), VOL_NORM, ATTN_NORM ); } } @@ -456,7 +456,7 @@ void CScientist::StartTask( Task_t *pTask ) TaskComplete(); break; case TASK_RANDOM_SCREAM: - if( RANDOM_FLOAT( 0, 1 ) < pTask->flData ) + if( RANDOM_FLOAT( 0.0f, 1.0f ) < pTask->flData ) Scream(); TaskComplete(); break; @@ -483,8 +483,10 @@ void CScientist::StartTask( Task_t *pTask ) break; case TASK_MOVE_TO_TARGET_RANGE_SCARED: { - if( ( m_hTargetEnt->pev->origin - pev->origin).Length() < 1 ) + if( ( m_hTargetEnt->pev->origin - pev->origin ).Length() < 1.0f ) + { TaskComplete(); + } else { m_vecMoveGoal = m_hTargetEnt->pev->origin; @@ -524,7 +526,7 @@ void CScientist::RunTask( Task_t *pTask ) distance = ( m_vecMoveGoal - pev->origin ).Length2D(); // Re-evaluate when you think your finished, or the target has moved too far - if( ( distance < pTask->flData ) || ( m_vecMoveGoal - m_hTargetEnt->pev->origin ).Length() > pTask->flData * 0.5 ) + if( ( distance < pTask->flData ) || ( m_vecMoveGoal - m_hTargetEnt->pev->origin ).Length() > pTask->flData * 0.5f ) { m_vecMoveGoal = m_hTargetEnt->pev->origin; distance = ( m_vecMoveGoal - pev->origin ).Length2D(); @@ -638,6 +640,13 @@ void CScientist::HandleAnimEvent( MonsterEvent_t *pEvent ) //========================================================= void CScientist::Spawn( void ) { + // We need to set it before precache so the right voice will be chosen + if( pev->body == -1 ) + { + // -1 chooses a random head + pev->body = RANDOM_LONG( 0, NUM_SCIENTIST_HEADS - 1 );// pick a head, any head + } + Precache(); SET_MODEL( ENT( pev ), "models/scientist.mdl" ); @@ -658,12 +667,6 @@ void CScientist::Spawn( void ) // White hands pev->skin = 0; - if( pev->body == -1 ) - { - // -1 chooses a random head - pev->body = RANDOM_LONG( 0, NUM_SCIENTIST_HEADS - 1 );// pick a head, any head - } - // Luther is black, make his hands black if( pev->body == HEAD_LUTHER ) pev->skin = 1; @@ -721,7 +724,7 @@ void CScientist::TalkInit() m_szGrp[TLK_MORTAL] = "SC_MORTAL"; // get voice for head - switch( pev->body % 3 ) + switch( pev->body % NUM_SCIENTIST_HEADS ) { default: case HEAD_GLASSES: @@ -762,6 +765,9 @@ int CScientist::ISoundMask( void ) { return bits_SOUND_WORLD | bits_SOUND_COMBAT | + bits_SOUND_CARCASS | + bits_SOUND_MEAT | + bits_SOUND_GARBAGE | bits_SOUND_DANGER | bits_SOUND_PLAYER; } @@ -774,7 +780,7 @@ void CScientist::PainSound( void ) if( gpGlobals->time < m_painTime ) return; - m_painTime = gpGlobals->time + RANDOM_FLOAT( 0.5, 0.75 ); + m_painTime = gpGlobals->time + RANDOM_FLOAT( 0.5f, 0.75f ); switch( RANDOM_LONG( 0, 4 ) ) { @@ -1050,7 +1056,7 @@ MONSTERSTATE CScientist::GetIdealState( void ) BOOL CScientist::CanHeal( void ) { - if( ( m_healTime > gpGlobals->time ) || ( m_hTargetEnt == 0 ) || ( m_hTargetEnt->pev->health > ( m_hTargetEnt->pev->max_health * 0.5 ) ) ) + if( ( m_healTime > gpGlobals->time ) || ( m_hTargetEnt == 0 ) || ( m_hTargetEnt->pev->health > ( m_hTargetEnt->pev->max_health * 0.5f ) ) ) return FALSE; return TRUE; @@ -1062,7 +1068,7 @@ void CScientist::Heal( void ) return; Vector target = m_hTargetEnt->pev->origin - pev->origin; - if( target.Length() > 100 ) + if( target.Length() > 100.0f ) return; m_hTargetEnt->TakeHealth( gSkillData.scientistHeal, DMG_GENERIC ); @@ -1241,7 +1247,7 @@ void CSittingScientist::Spawn() ResetSequenceInfo(); SetThink( &CSittingScientist::SittingThink ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; DROP_TO_FLOOR( ENT( pev ) ); } @@ -1369,13 +1375,13 @@ void CSittingScientist::SittingThink( void ) pev->frame = 0; SetBoneController( 0, m_headTurn ); } - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } // prepare sitting scientist to answer a question void CSittingScientist::SetAnswerQuestion( CTalkMonster *pSpeaker ) { - m_flResponseDelay = gpGlobals->time + RANDOM_FLOAT( 3, 4 ); + m_flResponseDelay = gpGlobals->time + RANDOM_FLOAT( 3.0f, 4.0f ); m_hTalkTarget = (CBaseMonster *)pSpeaker; } diff --git a/dlls/scripted.cpp b/dlls/scripted.cpp index 41638b39..da495f98 100644 --- a/dlls/scripted.cpp +++ b/dlls/scripted.cpp @@ -24,11 +24,11 @@ #include "cbase.h" #include "monsters.h" -#ifndef ANIMATION_H +#if !defined(ANIMATION_H) #include "animation.h" #endif -#ifndef SAVERESTORE_H +#if !defined(SAVERESTORE_H) #include "saverestore.h" #endif @@ -136,10 +136,10 @@ void CCineMonster::Spawn( void ) if( FStringNull( pev->targetname ) || !FStringNull( m_iszIdle ) ) { SetThink( &CCineMonster::CineThink ); - pev->nextthink = gpGlobals->time + 1.0; + pev->nextthink = gpGlobals->time + 1.0f; // Wait to be used? if( pev->targetname ) - m_startTime = gpGlobals->time + 1E6; + m_startTime = gpGlobals->time + (float)1E6; } if( pev->spawnflags & SF_SCRIPT_NOINTERRUPT ) m_interruptable = FALSE; @@ -185,7 +185,7 @@ void CCineMonster::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE if( pTarget->m_scriptState == SCRIPT_PLAYING ) return; - m_startTime = gpGlobals->time + 0.05; + m_startTime = gpGlobals->time + 0.05f; } else { @@ -356,7 +356,7 @@ void CCineMonster::PossessEntity( void ) pTarget->pev->effects |= EF_NOINTERP; pTarget->pev->angles.y = pev->angles.y; pTarget->m_scriptState = SCRIPT_WAIT; - m_startTime = gpGlobals->time + 1E6; + m_startTime = gpGlobals->time + (float)1E6; // UNDONE: Add a flag to do this so people can fixup physics after teleporting monsters // pTarget->pev->flags &= ~FL_ONGROUND; break; @@ -424,7 +424,7 @@ void CCineAI::PossessEntity( void ) pTarget->pev->effects |= EF_NOINTERP; pTarget->pev->angles.y = pev->angles.y; pTarget->m_scriptState = SCRIPT_WAIT; - m_startTime = gpGlobals->time + 1E6; + m_startTime = gpGlobals->time + (float)1E6; // UNDONE: Add a flag to do this so people can fixup physics after teleporting monsters pTarget->pev->flags &= ~FL_ONGROUND; break; @@ -466,7 +466,7 @@ void CCineMonster::CineThink( void ) { CancelScript(); ALERT( at_aiconsole, "script \"%s\" can't find monster \"%s\"\n", STRING( pev->targetname ), STRING( m_iszEntity ) ); - pev->nextthink = gpGlobals->time + 1.0; + pev->nextthink = gpGlobals->time + 1.0f; } } @@ -544,7 +544,7 @@ void CCineMonster::SequenceDone( CBaseMonster *pMonster ) if( !( pev->spawnflags & SF_SCRIPT_REPEATABLE ) ) { SetThink( &CBaseEntity::SUB_Remove ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } // This is done so that another sequence can take over the monster when triggered by the first @@ -664,7 +664,7 @@ void ScriptEntityCancel( edict_t *pentCine ) if( pTarget ) { // make sure their monster is actually playing a script - if( pTarget->m_MonsterState == MONSTERSTATE_SCRIPT ) + if( pTarget->m_MonsterState == MONSTERSTATE_SCRIPT || pTarget->m_IdealMonsterState == MONSTERSTATE_SCRIPT ) { // tell them do die pTarget->m_scriptState = CCineMonster::SCRIPT_CLEANUP; @@ -713,7 +713,7 @@ void CCineMonster::DelayStart( int state ) { pTarget->m_iDelay--; if( pTarget->m_iDelay <= 0 ) - pTarget->m_startTime = gpGlobals->time + 0.05; + pTarget->m_startTime = gpGlobals->time + 0.05f; } } pentCine = FIND_ENTITY_BY_TARGETNAME( pentCine, STRING( pev->targetname ) ); @@ -836,7 +836,7 @@ BOOL CBaseMonster::CineCleanup() // UNDONE: ugly hack. Don't move monster if they don't "seem" to move // this really needs to be done with the AX,AY,etc. flags, but that aren't consistantly // being set, so animations that really do move won't be caught. - if( ( oldOrigin - new_origin).Length2D() < 8.0 ) + if( ( oldOrigin - new_origin).Length2D() < 8.0f ) new_origin = oldOrigin; pev->origin.x = new_origin.x; @@ -974,7 +974,7 @@ void CScriptedSentence::KeyValue( KeyValueData *pkvd ) } else if( FStrEq( pkvd->szKeyName, "volume" ) ) { - m_flVolume = atof( pkvd->szValue ) * 0.1; + m_flVolume = atof( pkvd->szValue ) * 0.1f; pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "listener" ) ) @@ -1004,7 +1004,7 @@ void CScriptedSentence::Spawn( void ) if( !pev->targetname ) { SetThink( &CScriptedSentence::FindThink ); - pev->nextthink = gpGlobals->time + 1.0; + pev->nextthink = gpGlobals->time + 1.0f; } switch( pev->impulse ) @@ -1030,8 +1030,8 @@ void CScriptedSentence::Spawn( void ) pev->impulse = 0; // No volume, use normal - if( m_flVolume <= 0 ) - m_flVolume = 1.0; + if( m_flVolume <= 0.0f ) + m_flVolume = 1.0f; } void CScriptedSentence::FindThink( void ) @@ -1050,7 +1050,7 @@ void CScriptedSentence::FindThink( void ) else { //ALERT( at_console, "%s: can't find monster %s\n", STRING( m_iszSentence ), STRING( m_iszEntity ) ); - pev->nextthink = gpGlobals->time + m_flRepeat + 0.5; + pev->nextthink = gpGlobals->time + m_flRepeat + 0.5f; } } @@ -1058,7 +1058,7 @@ void CScriptedSentence::DelayThink( void ) { m_active = TRUE; if( !pev->targetname ) - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; SetThink( &CScriptedSentence::FindThink ); } @@ -1068,14 +1068,17 @@ BOOL CScriptedSentence::AcceptableSpeaker( CBaseMonster *pMonster ) { if( pev->spawnflags & SF_SENTENCE_FOLLOWERS ) { - if( pMonster->m_hTargetEnt == 0 || !FClassnameIs( pMonster->m_hTargetEnt->pev, "player" ) ) + if( pMonster->m_hTargetEnt == 0 || !pMonster->m_hTargetEnt->IsPlayer() ) return FALSE; } + BOOL override; + if( pev->spawnflags & SF_SENTENCE_INTERRUPT ) override = TRUE; else override = FALSE; + if( pMonster->CanPlaySentence( override ) ) return TRUE; } @@ -1143,7 +1146,7 @@ BOOL CScriptedSentence::StartSentence( CBaseMonster *pTarget ) } pTarget->PlayScriptedSentence( STRING( m_iszSentence ), m_flDuration, m_flVolume, m_flAttenuation, bConcurrent, pListener ); - ALERT( at_aiconsole, "Playing sentence %s (%.1f)\n", STRING( m_iszSentence ), m_flDuration ); + ALERT( at_aiconsole, "Playing sentence %s (%.1f)\n", STRING( m_iszSentence ), (double)m_flDuration ); SUB_UseTargets( NULL, USE_TOGGLE, 0 ); return TRUE; } @@ -1189,7 +1192,7 @@ void CFurniture::Spawn() pev->sequence = 0; pev->frame = 0; - //pev->nextthink += 1.0; + //pev->nextthink += 1.0f; //SetThink( &WalkMonsterDelay ); ResetSequenceInfo(); diff --git a/dlls/scripted.h b/dlls/scripted.h index 59b696f7..5666a082 100644 --- a/dlls/scripted.h +++ b/dlls/scripted.h @@ -13,10 +13,10 @@ * ****/ #pragma once -#ifndef SCRIPTED_H +#if !defined(SCRIPTED_H) #define SCRIPTED_H -#ifndef SCRIPTEVENT_H +#if !defined(SCRIPTEVENT_H) #include "scriptevent.h" #endif diff --git a/dlls/scriptevent.h b/dlls/scriptevent.h index 18436a26..179503d7 100644 --- a/dlls/scriptevent.h +++ b/dlls/scriptevent.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef SCRIPTEVENT_H +#if !defined(SCRIPTEVENT_H) #define SCRIPTEVENT_H #define SCRIPT_EVENT_DEAD 1000 // character is now dead diff --git a/dlls/shotgun.cpp b/dlls/shotgun.cpp index 03944087..7b263a21 100644 --- a/dlls/shotgun.cpp +++ b/dlls/shotgun.cpp @@ -119,7 +119,7 @@ void CShotgun::PrimaryAttack() if( m_pPlayer->pev->waterlevel == 3 ) { PlayEmptySound(); - m_flNextPrimaryAttack = GetNextAttackDelay( 0.15 ); + m_flNextPrimaryAttack = GetNextAttackDelay( 0.15f ); return; } @@ -137,7 +137,7 @@ void CShotgun::PrimaryAttack() m_iClip--; int flags; -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS flags = FEV_NOTHOST; #else flags = 0; @@ -152,7 +152,7 @@ void CShotgun::PrimaryAttack() Vector vecDir; -#ifdef CLIENT_DLL +#if CLIENT_DLL if( bIsMultiplayer() ) #else if( g_pGameRules->IsMultiplayer() ) @@ -173,14 +173,14 @@ void CShotgun::PrimaryAttack() m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 ); //if( m_iClip != 0 ) - m_flPumpTime = gpGlobals->time + 0.5; + m_flPumpTime = gpGlobals->time + 0.5f; - m_flNextPrimaryAttack = GetNextAttackDelay( 0.75 ); - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.75; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.75f ); + m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.75f; if( m_iClip != 0 ) - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5.0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5.0f; else - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.75; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.75f; m_fInSpecialReload = 0; } @@ -190,7 +190,7 @@ void CShotgun::SecondaryAttack( void ) if( m_pPlayer->pev->waterlevel == 3 ) { PlayEmptySound(); - m_flNextPrimaryAttack = GetNextAttackDelay( 0.15 ); + m_flNextPrimaryAttack = GetNextAttackDelay( 0.15f ); return; } @@ -207,7 +207,7 @@ void CShotgun::SecondaryAttack( void ) m_iClip -= 2; int flags; -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS flags = FEV_NOTHOST; #else flags = 0; @@ -222,7 +222,7 @@ void CShotgun::SecondaryAttack( void ) Vector vecDir; -#ifdef CLIENT_DLL +#if CLIENT_DLL if( bIsMultiplayer() ) #else if( g_pGameRules->IsMultiplayer() ) @@ -237,19 +237,19 @@ void CShotgun::SecondaryAttack( void ) vecDir = m_pPlayer->FireBulletsPlayer( 12, vecSrc, vecAiming, VECTOR_CONE_10DEGREES, 2048, BULLET_PLAYER_BUCKSHOT, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed ); } - PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usDoubleFire, 0.0, g_vecZero, g_vecZero, vecDir.x, vecDir.y, 0, 0, 0, 0 ); + PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usDoubleFire, 0.0f, g_vecZero, g_vecZero, vecDir.x, vecDir.y, 0, 0, 0, 0 ); if( !m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) // HEV suit - indicate out of ammo condition m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 ); //if( m_iClip != 0 ) - m_flPumpTime = gpGlobals->time + 0.95; + m_flPumpTime = gpGlobals->time + 0.95f; - m_flNextPrimaryAttack = GetNextAttackDelay( 1.5 ); - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.5; + m_flNextPrimaryAttack = GetNextAttackDelay( 1.5f ); + m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.5f; if( m_iClip != 0 ) - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 6.0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 6.0f; else m_flTimeWeaponIdle = 1.5; @@ -270,10 +270,10 @@ void CShotgun::Reload( void ) { SendWeaponAnim( SHOTGUN_START_RELOAD ); m_fInSpecialReload = 1; - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.6; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.6; - m_flNextPrimaryAttack = GetNextAttackDelay( 1.0 ); - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0; + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.6f; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.6f; + m_flNextPrimaryAttack = GetNextAttackDelay( 1.0f ); + m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0f; return; } else if( m_fInSpecialReload == 1 ) @@ -290,8 +290,8 @@ void CShotgun::Reload( void ) SendWeaponAnim( SHOTGUN_RELOAD ); - m_flNextReload = UTIL_WeaponTimeBase() + 0.5; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; + m_flNextReload = UTIL_WeaponTimeBase() + 0.5f; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5f; } else { @@ -302,7 +302,7 @@ void CShotgun::Reload( void ) } } -void CShotgun::WeaponTick() +void CShotgun::ItemPostFrame( void ) { if( m_flPumpTime && m_flPumpTime < gpGlobals->time ) { @@ -310,6 +310,8 @@ void CShotgun::WeaponTick() EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/scock1.wav", 1, ATTN_NORM, 0, 95 + RANDOM_LONG( 0, 0x1f ) ); m_flPumpTime = 0; } + + CBasePlayerWeapon::ItemPostFrame(); } void CShotgun::WeaponIdle( void ) @@ -338,27 +340,27 @@ void CShotgun::WeaponIdle( void ) // play cocking sound EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/scock1.wav", 1, ATTN_NORM, 0, 95 + RANDOM_LONG( 0, 0x1f ) ); m_fInSpecialReload = 0; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.5; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.5f; } } else { int iAnim; float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 ); - if( flRand <= 0.8 ) + if( flRand <= 0.8f ) { iAnim = SHOTGUN_IDLE_DEEP; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 60.0 / 12.0 );// * RANDOM_LONG( 2, 5 ); + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 60.0f / 12.0f );// * RANDOM_LONG( 2, 5 ); } - else if( flRand <= 0.95 ) + else if( flRand <= 0.95f ) { iAnim = SHOTGUN_IDLE; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 20.0 / 9.0 ); + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 20.0f / 9.0f ); } else { iAnim = SHOTGUN_IDLE4; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 20.0 / 9.0 ); + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 20.0f / 9.0f ); } SendWeaponAnim( iAnim ); } diff --git a/dlls/singleplay_gamerules.cpp b/dlls/singleplay_gamerules.cpp index 80953095..636461f7 100644 --- a/dlls/singleplay_gamerules.cpp +++ b/dlls/singleplay_gamerules.cpp @@ -75,6 +75,17 @@ BOOL CHalfLifeRules::FShouldSwitchWeapon( CBasePlayer *pPlayer, CBasePlayerItem return TRUE; } + if( !pPlayer->m_iAutoWepSwitch ) + { + return FALSE; + } + + if( pPlayer->m_iAutoWepSwitch == 2 + && pPlayer->m_afButtonLast & ( IN_ATTACK | IN_ATTACK2 ) ) + { + return FALSE; + } + if( !pPlayer->m_pActiveItem->CanHolster() ) { return FALSE; diff --git a/dlls/skill.h b/dlls/skill.h index 5244c923..1cb5b0c1 100644 --- a/dlls/skill.h +++ b/dlls/skill.h @@ -16,7 +16,7 @@ // skill.h - skill level concerns //========================================================= #pragma once -#ifndef SKILL_H +#if !defined(SKILL_H) #define SKILL_H struct skilldata_t diff --git a/dlls/sound.cpp b/dlls/sound.cpp index 119c7347..b317883b 100644 --- a/dlls/sound.cpp +++ b/dlls/sound.cpp @@ -185,10 +185,10 @@ void CAmbientGeneric::Spawn( void ) const char *szSoundFile = STRING( pev->message ); - if( FStringNull( pev->message ) || strlen( szSoundFile ) < 1 ) + if( FStringNull( pev->message ) || szSoundFile[0] == '\0' ) { - ALERT( at_error, "EMPTY AMBIENT AT: %f, %f, %f\n", pev->origin.x, pev->origin.y, pev->origin.z ); - pev->nextthink = gpGlobals->time + 0.1; + ALERT( at_error, "EMPTY AMBIENT AT: %f, %f, %f\n", (double)pev->origin.x, (double)pev->origin.y, (double)pev->origin.z ); + pev->nextthink = gpGlobals->time + 0.1f; SetThink( &CBaseEntity::SUB_Remove ); return; } @@ -200,7 +200,7 @@ void CAmbientGeneric::Spawn( void ) // start thinking yet. SetThink( &CAmbientGeneric::RampThink ); - pev->nextthink = 0; + pev->nextthink = 0.0f; // allow on/off switching via 'use' function. @@ -219,7 +219,7 @@ void CAmbientGeneric::Precache( void ) { const char *szSoundFile = STRING( pev->message ); - if( !FStringNull( pev->message ) && strlen( szSoundFile ) > 1 ) + if( !FStringNull( pev->message ) && szSoundFile[0] != '\0' ) { if( *szSoundFile != '!' ) PRECACHE_SOUND( szSoundFile ); @@ -237,9 +237,9 @@ void CAmbientGeneric::Precache( void ) if( m_fActive ) { UTIL_EmitAmbientSound( ENT( pev ), pev->origin, szSoundFile, - ( m_dpv.vol * 0.01 ), m_flAttenuation, SND_SPAWNING, m_dpv.pitch ); + ( m_dpv.vol * 0.01f ), m_flAttenuation, SND_SPAWNING, m_dpv.pitch ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } } @@ -281,7 +281,7 @@ void CAmbientGeneric::RampThink( void ) if( pitch < m_dpv.pitchstart ) { - pitch = m_dpv.pitchstart; + // pitch = m_dpv.pitchstart; m_dpv.spindown = 0; // done with ramp down // shut sound off @@ -325,7 +325,7 @@ void CAmbientGeneric::RampThink( void ) if( vol < m_dpv.volstart ) { - vol = m_dpv.volstart; + // vol = m_dpv.volstart; m_dpv.fadeout = 0; // done with ramp down // shut sound off @@ -434,11 +434,11 @@ void CAmbientGeneric::RampThink( void ) pitch = PITCH_NORM + 1; // don't send 'no pitch' ! UTIL_EmitAmbientSound( ENT( pev ), pev->origin, szSoundFile, - ( vol * 0.01 ), m_flAttenuation, flags, pitch ); + ( vol * 0.01f ), m_flAttenuation, flags, pitch ); } // update ramps at 5hz - pev->nextthink = gpGlobals->time + 0.2; + pev->nextthink = gpGlobals->time + 0.2f; return; } @@ -549,12 +549,12 @@ void CAmbientGeneric::ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, fraction = value; - if( fraction > 1.0 ) - fraction = 1.0; - if( fraction < 0.0 ) - fraction = 0.01; + if( fraction > 1.0f ) + fraction = 1.0f; + if( fraction < 0.0f ) + fraction = 0.01f; - m_dpv.pitch = (int)( fraction * 255 ); + m_dpv.pitch = (int)( fraction * 255.0f ); UTIL_EmitAmbientSound( ENT( pev ), pev->origin, szSoundFile, 0, 0, SND_CHANGE_PITCH, m_dpv.pitch ); return; @@ -585,7 +585,7 @@ void CAmbientGeneric::ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, if( m_dpv.pitchrun > 255 ) m_dpv.pitchrun = 255; - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } } else @@ -603,7 +603,7 @@ void CAmbientGeneric::ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, m_dpv.fadeout = m_dpv.fadeoutsav; m_dpv.fadein = 0; - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } else UTIL_EmitAmbientSound( ENT( pev ), pev->origin, szSoundFile, 0, 0, SND_STOP, 0 ); @@ -626,9 +626,9 @@ void CAmbientGeneric::ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, // init all ramp params for startup InitModulationParms(); - UTIL_EmitAmbientSound( ENT( pev ), pev->origin, szSoundFile, ( m_dpv.vol * 0.01 ), m_flAttenuation, 0, m_dpv.pitch ); + UTIL_EmitAmbientSound( ENT( pev ), pev->origin, szSoundFile, ( m_dpv.vol * 0.01f ), m_flAttenuation, 0, m_dpv.pitch ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } } @@ -826,7 +826,7 @@ TYPEDESCRIPTION CEnvSound::m_SaveData[] = DEFINE_FIELD( CEnvSound, m_flRoomtype, FIELD_FLOAT ), }; -IMPLEMENT_SAVERESTORE( CEnvSound, CBaseEntity ) +IMPLEMENT_SAVERESTORE( CEnvSound, CPointEntity ) void CEnvSound::KeyValue( KeyValueData *pkvd ) { @@ -963,10 +963,10 @@ void CEnvSound::Think( void ) // not in range. do nothing, fall through to think_fast... env_sound_Think_fast: - pev->nextthink = gpGlobals->time + 0.25; + pev->nextthink = gpGlobals->time + 0.25f; return; env_sound_Think_slow: - pev->nextthink = gpGlobals->time + 0.75; + pev->nextthink = gpGlobals->time + 0.75f; return; } @@ -978,7 +978,7 @@ env_sound_Think_slow: void CEnvSound::Spawn() { // spread think times - pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 0.0, 0.5 ); + pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 0.0f, 0.5f ); } // ==================== SENTENCE GROUPS, UTILITY FUNCTIONS ====================================== @@ -1289,9 +1289,9 @@ void SENTENCEG_Init() if( !buffer[j] ) continue; - if( gcallsentences > CVOXFILESENTENCEMAX ) + if( gcallsentences >= CVOXFILESENTENCEMAX ) { - ALERT( at_error, "Too many sentences in sentences.txt!\n" ); + ALERT( at_error, "Too many sentences in sentences.txt! >%d\n", gcallsentences ); break; } @@ -1408,7 +1408,7 @@ void EMIT_SOUND_SUIT( edict_t *entity, const char *sample ) if( RANDOM_LONG( 0, 1 ) ) pitch = RANDOM_LONG( 0, 6 ) + 98; - if( fvol > 0.05 ) + if( fvol > 0.05f ) EMIT_SOUND_DYN( entity, CHAN_STATIC, sample, fvol, ATTN_NORM, 0, pitch ); } @@ -1423,7 +1423,7 @@ void EMIT_GROUPID_SUIT( edict_t *entity, int isentenceg ) if( RANDOM_LONG( 0, 1 ) ) pitch = RANDOM_LONG( 0, 6 ) + 98; - if( fvol > 0.05 ) + if( fvol > 0.05f ) SENTENCEG_PlayRndI( entity, isentenceg, fvol, ATTN_NORM, 0, pitch ); } @@ -1438,7 +1438,7 @@ void EMIT_GROUPNAME_SUIT( edict_t *entity, const char *groupname ) if( RANDOM_LONG( 0, 1 ) ) pitch = RANDOM_LONG( 0, 6 ) + 98; - if( fvol > 0.05 ) + if( fvol > 0.05f ) SENTENCEG_PlayRndSz( entity, groupname, fvol, ATTN_NORM, 0, pitch ); } @@ -1531,7 +1531,7 @@ float TEXTURETYPE_PlaySound( TraceResult *ptr, Vector vecSrc, Vector vecEnd, in float fattn = ATTN_NORM; if( !g_pGameRules->PlayTextureSounds() ) - return 0.0; + return 0.0f; CBaseEntity *pEntity = CBaseEntity::Instance( ptr->pHit ); @@ -1580,44 +1580,44 @@ float TEXTURETYPE_PlaySound( TraceResult *ptr, Vector vecSrc, Vector vecEnd, in { default: case CHAR_TEX_CONCRETE: - fvol = 0.9; - fvolbar = 0.6; + fvol = 0.9f; + fvolbar = 0.6f; rgsz[0] = "player/pl_step1.wav"; rgsz[1] = "player/pl_step2.wav"; cnt = 2; break; case CHAR_TEX_METAL: - fvol = 0.9; - fvolbar = 0.3; + fvol = 0.9f; + fvolbar = 0.3f; rgsz[0] = "player/pl_metal1.wav"; rgsz[1] = "player/pl_metal2.wav"; cnt = 2; break; case CHAR_TEX_DIRT: - fvol = 0.9; - fvolbar = 0.1; + fvol = 0.9f; + fvolbar = 0.1f; rgsz[0] = "player/pl_dirt1.wav"; rgsz[1] = "player/pl_dirt2.wav"; rgsz[2] = "player/pl_dirt3.wav"; cnt = 3; break; case CHAR_TEX_VENT: - fvol = 0.5; - fvolbar = 0.3; + fvol = 0.5f; + fvolbar = 0.3f; rgsz[0] = "player/pl_duct1.wav"; rgsz[1] = "player/pl_duct1.wav"; cnt = 2; break; case CHAR_TEX_GRATE: - fvol = 0.9; - fvolbar = 0.5; + fvol = 0.9f; + fvolbar = 0.5f; rgsz[0] = "player/pl_grate1.wav"; rgsz[1] = "player/pl_grate4.wav"; cnt = 2; break; case CHAR_TEX_TILE: - fvol = 0.8; - fvolbar = 0.2; + fvol = 0.8f; + fvolbar = 0.2f; rgsz[0] = "player/pl_tile1.wav"; rgsz[1] = "player/pl_tile3.wav"; rgsz[2] = "player/pl_tile2.wav"; @@ -1625,8 +1625,8 @@ float TEXTURETYPE_PlaySound( TraceResult *ptr, Vector vecSrc, Vector vecEnd, in cnt = 4; break; case CHAR_TEX_SLOSH: - fvol = 0.9; - fvolbar = 0.0; + fvol = 0.9f; + fvolbar = 0.0f; rgsz[0] = "player/pl_slosh1.wav"; rgsz[1] = "player/pl_slosh3.wav"; rgsz[2] = "player/pl_slosh2.wav"; @@ -1634,8 +1634,8 @@ float TEXTURETYPE_PlaySound( TraceResult *ptr, Vector vecSrc, Vector vecEnd, in cnt = 4; break; case CHAR_TEX_WOOD: - fvol = 0.9; - fvolbar = 0.2; + fvol = 0.9f; + fvolbar = 0.2f; rgsz[0] = "debris/wood1.wav"; rgsz[1] = "debris/wood2.wav"; rgsz[2] = "debris/wood3.wav"; @@ -1643,8 +1643,8 @@ float TEXTURETYPE_PlaySound( TraceResult *ptr, Vector vecSrc, Vector vecEnd, in break; case CHAR_TEX_GLASS: case CHAR_TEX_COMPUTER: - fvol = 0.8; - fvolbar = 0.2; + fvol = 0.8f; + fvolbar = 0.2f; rgsz[0] = "debris/glass1.wav"; rgsz[1] = "debris/glass2.wav"; rgsz[2] = "debris/glass3.wav"; @@ -1652,12 +1652,12 @@ float TEXTURETYPE_PlaySound( TraceResult *ptr, Vector vecSrc, Vector vecEnd, in break; case CHAR_TEX_FLESH: if( iBulletType == BULLET_PLAYER_CROWBAR ) - return 0.0; // crowbar already makes this sound - fvol = 1.0; - fvolbar = 0.2; + return 0.0f; // crowbar already makes this sound + fvol = 1.0f; + fvolbar = 0.2f; rgsz[0] = "weapons/bullet_hit1.wav"; rgsz[1] = "weapons/bullet_hit2.wav"; - fattn = 1.0; + fattn = 1.0f; cnt = 2; break; } @@ -1666,17 +1666,17 @@ float TEXTURETYPE_PlaySound( TraceResult *ptr, Vector vecSrc, Vector vecEnd, in if( pEntity && FClassnameIs( pEntity->pev, "func_breakable" ) ) { // drop volumes, the object will already play a damaged sound - fvol /= 1.5; - fvolbar /= 2.0; + fvol /= 1.5f; + fvolbar /= 2.0f; } else if( chTextureType == CHAR_TEX_COMPUTER ) { // play random spark if computer - if( ptr->flFraction != 1.0 && RANDOM_LONG( 0, 1 ) ) + if( ptr->flFraction != 1.0f && RANDOM_LONG( 0, 1 ) ) { UTIL_Sparks( ptr->vecEndPos ); - float flVolume = RANDOM_FLOAT( 0.7, 1.0 );//random volume range + float flVolume = RANDOM_FLOAT( 0.7f, 1.0f );//random volume range switch( RANDOM_LONG( 0, 1 ) ) { case 0: @@ -1740,10 +1740,10 @@ void CSpeaker::Spawn( void ) { const char *szSoundFile = STRING( pev->message ); - if( !m_preset && ( FStringNull( pev->message ) || strlen( szSoundFile ) < 1 ) ) + if( !m_preset && ( FStringNull( pev->message ) || szSoundFile[0] == '\0' ) ) { - ALERT( at_error, "SPEAKER with no Level/Sentence! at: %f, %f, %f\n", pev->origin.x, pev->origin.y, pev->origin.z ); - pev->nextthink = gpGlobals->time + 0.1; + ALERT( at_error, "SPEAKER with no Level/Sentence! at: %f, %f, %f\n", (double)pev->origin.x, (double)pev->origin.y, (double)pev->origin.z ); + pev->nextthink = gpGlobals->time + 0.1f; SetThink( &CBaseEntity::SUB_Remove ); return; } @@ -1751,7 +1751,7 @@ void CSpeaker::Spawn( void ) pev->movetype = MOVETYPE_NONE; SetThink( &CSpeaker::SpeakerThink ); - pev->nextthink = 0.0; + pev->nextthink = 0.0f; // allow on/off switching via 'use' function. SetUse( &CSpeaker::ToggleUse ); @@ -1759,27 +1759,27 @@ void CSpeaker::Spawn( void ) Precache(); } -#define ANNOUNCE_MINUTES_MIN 0.25 -#define ANNOUNCE_MINUTES_MAX 2.25 +#define ANNOUNCE_MINUTES_MIN 0.25f +#define ANNOUNCE_MINUTES_MAX 2.25f void CSpeaker::Precache( void ) { if( !FBitSet( pev->spawnflags, SPEAKER_START_SILENT ) ) // set first announcement time for random n second - pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 5.0, 15.0 ); + pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 5.0f, 15.0f ); } void CSpeaker::SpeakerThink( void ) { - const char* szSoundFile = NULL; - float flvolume = pev->health * 0.1; - float flattenuation = 0.3; + const char* szSoundFile = ""; + float flvolume = pev->health * 0.1f; + float flattenuation = 0.3f; int flags = 0; int pitch = 100; // Wait for the talkmonster to finish first. if( gpGlobals->time <= CTalkMonster::g_talkWaitTime ) { - pev->nextthink = CTalkMonster::g_talkWaitTime + RANDOM_FLOAT( 5, 10 ); + pev->nextthink = CTalkMonster::g_talkWaitTime + RANDOM_FLOAT( 5.0f, 10.0f ); return; } @@ -1836,7 +1836,7 @@ void CSpeaker::SpeakerThink( void ) flvolume, flattenuation, flags, pitch ); // shut off and reset - pev->nextthink = 0.0; + pev->nextthink = 0.0f; } else { @@ -1845,9 +1845,9 @@ void CSpeaker::SpeakerThink( void ) ALERT( at_console, "Level Design Error!\nSPEAKER has bad sentence group name: %s\n",szSoundFile ); // set next announcement time for random 5 to 10 minute delay - pev->nextthink = gpGlobals->time + RANDOM_FLOAT( ANNOUNCE_MINUTES_MIN * 60.0, ANNOUNCE_MINUTES_MAX * 60.0 ); + pev->nextthink = gpGlobals->time + RANDOM_FLOAT( ANNOUNCE_MINUTES_MIN * 60.0f, ANNOUNCE_MINUTES_MAX * 60.0f ); - CTalkMonster::g_talkWaitTime = gpGlobals->time + 5; // time delay until it's ok to speak: used so that two NPCs don't talk at once + CTalkMonster::g_talkWaitTime = gpGlobals->time + 5.0f; // time delay until it's ok to speak: used so that two NPCs don't talk at once } return; @@ -1858,7 +1858,7 @@ void CSpeaker::SpeakerThink( void ) // void CSpeaker::ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - int fActive = ( pev->nextthink > 0.0 ); + int fActive = ( pev->nextthink > 0.0f ); // fActive is TRUE only if an announcement is pending @@ -1873,14 +1873,14 @@ void CSpeaker::ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP if( useType == USE_ON ) { // turn on announcements - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; return; } if( useType == USE_OFF ) { // turn off announcements - pev->nextthink = 0.0; + pev->nextthink = 0.0f; return; } @@ -1888,12 +1888,12 @@ void CSpeaker::ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP if( fActive ) { // turn off announcements - pev->nextthink = 0.0; + pev->nextthink = 0.0f; } else { // turn on announcements - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } } diff --git a/dlls/soundent.cpp b/dlls/soundent.cpp index 5e494b12..ed5e421a 100644 --- a/dlls/soundent.cpp +++ b/dlls/soundent.cpp @@ -82,7 +82,7 @@ void CSoundEnt::Spawn( void ) pev->solid = SOLID_NOT; Initialize(); - pev->nextthink = gpGlobals->time + 1; + pev->nextthink = gpGlobals->time + 1.0f; } //========================================================= @@ -95,7 +95,7 @@ void CSoundEnt::Think( void ) int iSound; int iPreviousSound; - pev->nextthink = gpGlobals->time + 0.3;// how often to check the sound list. + pev->nextthink = gpGlobals->time + 0.3f;// how often to check the sound list. iPreviousSound = SOUNDLIST_EMPTY; iSound = m_iActiveSound; @@ -367,7 +367,7 @@ int CSoundEnt::ClientSoundIndex( edict_t *pClient ) { int iReturn = ENTINDEX( pClient ) - 1; -#ifdef _DEBUG +#if _DEBUG if( iReturn < 0 || iReturn > gpGlobals->maxClients ) { ALERT( at_console, "** ClientSoundIndex returning a bogus value! **\n" ); diff --git a/dlls/soundent.h b/dlls/soundent.h index 88def506..9053e1fb 100644 --- a/dlls/soundent.h +++ b/dlls/soundent.h @@ -18,7 +18,7 @@ // lists. //========================================================= #pragma once -#ifndef SOUNDENT_H +#if !defined(SOUNDENT_H) #define SOUNDENT_H #define MAX_WORLD_SOUNDS 64 // maximum number of sounds handled by the world at one time. diff --git a/dlls/spectator.h b/dlls/spectator.h index c4e895c0..cf48c703 100644 --- a/dlls/spectator.h +++ b/dlls/spectator.h @@ -14,7 +14,7 @@ ****/ // Spectator.h #pragma once -#ifndef SPECTATOR_H +#if !defined(SPECTATOR_H) #define SPECTATOR_H class CBaseSpectator : public CBaseEntity diff --git a/dlls/squad.h b/dlls/squad.h index 2c79ee90..b6418cc1 100644 --- a/dlls/squad.h +++ b/dlls/squad.h @@ -8,7 +8,7 @@ // squad.h //========================================================= #pragma once -#ifndef SQUAD_H +#if !defined(SQUAD_H) #define SQUAD_H // these are special group roles that are assigned to members when the group is formed. diff --git a/dlls/squadmonster.cpp b/dlls/squadmonster.cpp index 3d476b50..d168d732 100644 --- a/dlls/squadmonster.cpp +++ b/dlls/squadmonster.cpp @@ -167,7 +167,7 @@ void CSquadMonster::SquadRemove( CSquadMonster *pRemove ) { for( int i = 0; i < MAX_SQUAD_MEMBERS - 1; i++ ) { - if( pSquadLeader->m_hSquadMember[i] == this ) + if( pSquadLeader->m_hSquadMember[i] == pRemove ) { pSquadLeader->m_hSquadMember[i] = NULL; break; @@ -256,7 +256,10 @@ void CSquadMonster::SquadMakeEnemy( CBaseEntity *pEnemy ) if( pMember ) { // reset members who aren't activly engaged in fighting - if( pMember->m_hEnemy != pEnemy && !pMember->HasConditions( bits_COND_SEE_ENEMY ) ) + if( pMember->m_hEnemy != pEnemy && !pMember->HasConditions( bits_COND_SEE_ENEMY ) + && ( pMember->m_pSchedule && (pMember->m_pSchedule->iInterruptMask & bits_COND_NEW_ENEMY) ) + // My enemy might be not an enemy for member of my squad, e.g. if I was provoked by player. + && pMember->IRelationship(pEnemy) >= R_DL ) { if( pMember->m_hEnemy != 0 ) { @@ -355,7 +358,7 @@ int CSquadMonster::SquadRecruit( int searchRadius, int maxMembers ) { TraceResult tr; UTIL_TraceLine( pev->origin + pev->view_ofs, pRecruit->pev->origin + pev->view_ofs, ignore_monsters, pRecruit->edict(), &tr );// try to hit recruit with a traceline. - if( tr.flFraction == 1.0 ) + if( tr.flFraction == 1.0f ) { if( !SquadAdd( pRecruit ) ) break; @@ -457,6 +460,7 @@ BOOL CSquadMonster::NoFriendlyFire( void ) Vector vecLeftSide; Vector vecRightSide; Vector v_left; + Vector v_dir; //!!!BUGBUG - to fix this, the planes must be aligned to where the monster will be firing its gun, not the direction it is facing!!! if( m_hEnemy != 0 ) @@ -471,9 +475,13 @@ BOOL CSquadMonster::NoFriendlyFire( void ) //UTIL_MakeVectors( pev->angles ); - vecLeftSide = pev->origin - ( gpGlobals->v_right * ( pev->size.x * 1.5 ) ); - vecRightSide = pev->origin + ( gpGlobals->v_right * ( pev->size.x * 1.5 ) ); - v_left = gpGlobals->v_right * -1; + // vecLeftSide = pev->origin - ( gpGlobals->v_right * ( pev->size.x * 1.5f ) ); + // vecRightSide = pev->origin + ( gpGlobals->v_right * ( pev->size.x * 1.5f ) ); + v_dir = gpGlobals->v_right * ( pev->size.x * 1.5f ); + vecLeftSide = pev->origin - v_dir; + vecRightSide = pev->origin + v_dir; + + v_left = gpGlobals->v_right * -1.0f; leftPlane.InitializePlane( gpGlobals->v_right, vecLeftSide ); rightPlane.InitializePlane( v_left, vecRightSide ); diff --git a/dlls/squadmonster.h b/dlls/squadmonster.h index e2c8a5b9..f6d3ed84 100644 --- a/dlls/squadmonster.h +++ b/dlls/squadmonster.h @@ -17,7 +17,7 @@ // form squads. //========================================================= #pragma once -#ifndef SQUADMONSTER_H +#if !defined(SQUADMONSTER_H) #define SQUADMONSTER_H #define SF_SQUADMONSTER_LEADER 32 diff --git a/dlls/squeakgrenade.cpp b/dlls/squeakgrenade.cpp index b6f881d4..f1d47c30 100644 --- a/dlls/squeakgrenade.cpp +++ b/dlls/squeakgrenade.cpp @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ -#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD ) +#if !OEM_BUILD && !HLDEMO_BUILD #include "extdll.h" #include "util.h" @@ -42,7 +42,7 @@ enum squeak_e SQUEAK_THROW }; -#ifndef CLIENT_DLL +#if !CLIENT_DLL class CSqueakGrenade : public CGrenade { void Spawn( void ); @@ -96,7 +96,7 @@ TYPEDESCRIPTION CSqueakGrenade::m_SaveData[] = IMPLEMENT_SAVERESTORE( CSqueakGrenade, CGrenade ) -#define SQUEEK_DETONATE_DELAY 15.0 +#define SQUEEK_DETONATE_DELAY 15.0f int CSqueakGrenade::Classify( void ) { @@ -129,25 +129,25 @@ void CSqueakGrenade::Spawn( void ) pev->solid = SOLID_BBOX; SET_MODEL( ENT( pev ), "models/w_squeak.mdl" ); - UTIL_SetSize( pev, Vector( -4, -4, 0 ), Vector( 4, 4, 8 ) ); + UTIL_SetSize( pev, Vector( -4.0f, -4.0f, 0.0f ), Vector( 4.0f, 4.0f, 8.0f ) ); UTIL_SetOrigin( pev, pev->origin ); SetTouch( &CSqueakGrenade::SuperBounceTouch ); SetThink( &CSqueakGrenade::HuntThink ); - pev->nextthink = gpGlobals->time + 0.1; - m_flNextHunt = gpGlobals->time + 1E6; + pev->nextthink = gpGlobals->time + 0.1f; + m_flNextHunt = gpGlobals->time + (float)1E6; pev->flags |= FL_MONSTER; pev->takedamage = DAMAGE_AIM; pev->health = gSkillData.snarkHealth; - pev->gravity = 0.5; - pev->friction = 0.5; + pev->gravity = 0.5f; + pev->friction = 0.5f; pev->dmg = gSkillData.snarkDmgPop; m_flDie = gpGlobals->time + SQUEEK_DETONATE_DELAY; - m_flFieldOfView = 0; // 180 degrees + m_flFieldOfView = 0.0f; // 180 degrees if( pev->owner ) m_hOwner = Instance( pev->owner ); @@ -175,7 +175,7 @@ void CSqueakGrenade::Killed( entvars_t *pevAttacker, int iGib ) pev->model = iStringNull;// make invisible SetThink( &CBaseEntity::SUB_Remove ); SetTouch( NULL ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; // since squeak grenades never leave a body behind, clear out their takedamage now. // Squeaks do a bit of radius damage when they pop, and that radius damage will @@ -183,9 +183,9 @@ void CSqueakGrenade::Killed( entvars_t *pevAttacker, int iGib ) pev->takedamage = DAMAGE_NO; // play squeek blast - EMIT_SOUND_DYN( ENT( pev ), CHAN_ITEM, "squeek/sqk_blast1.wav", 1, 0.5, 0, PITCH_NORM ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_ITEM, "squeek/sqk_blast1.wav", 1, 0.5f, 0, PITCH_NORM ); - CSoundEnt::InsertSound( bits_SOUND_COMBAT, pev->origin, SMALL_EXPLOSION_VOLUME, 3.0 ); + CSoundEnt::InsertSound( bits_SOUND_COMBAT, pev->origin, SMALL_EXPLOSION_VOLUME, 3.0f ); UTIL_BloodDrips( pev->origin, g_vecZero, BloodColor(), 80 ); @@ -203,7 +203,7 @@ void CSqueakGrenade::Killed( entvars_t *pevAttacker, int iGib ) void CSqueakGrenade::GibMonster( void ) { - EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "common/bodysplat.wav", 0.75, ATTN_NORM, 0, 200 ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "common/bodysplat.wav", 0.75f, ATTN_NORM, 0, 200 ); } void CSqueakGrenade::HuntThink( void ) @@ -218,7 +218,7 @@ void CSqueakGrenade::HuntThink( void ) } StudioFrameAdvance(); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; // explode when ready if( gpGlobals->time >= m_flDie ) @@ -236,8 +236,8 @@ void CSqueakGrenade::HuntThink( void ) { pev->movetype = MOVETYPE_FLY; } - pev->velocity = pev->velocity * 0.9; - pev->velocity.z += 8.0; + pev->velocity = pev->velocity * 0.9f; + pev->velocity.z += 8.0f; } else if( pev->movetype == MOVETYPE_FLY ) { @@ -248,7 +248,7 @@ void CSqueakGrenade::HuntThink( void ) if( m_flNextHunt > gpGlobals->time ) return; - m_flNextHunt = gpGlobals->time + 2.0; + m_flNextHunt = gpGlobals->time + 2.0f; //CBaseEntity *pOther = NULL; Vector vecDir; @@ -268,16 +268,16 @@ void CSqueakGrenade::HuntThink( void ) } // squeek if it's about time blow up - if( ( m_flDie - gpGlobals->time <= 0.5 ) && ( m_flDie - gpGlobals->time >= 0.3 ) ) + if( ( m_flDie - gpGlobals->time <= 0.5f ) && ( m_flDie - gpGlobals->time >= 0.3f ) ) { EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "squeek/sqk_die1.wav", 1, ATTN_NORM, 0, 100 + RANDOM_LONG( 0, 0x3F ) ); - CSoundEnt::InsertSound( bits_SOUND_COMBAT, pev->origin, 256, 0.25 ); + CSoundEnt::InsertSound( bits_SOUND_COMBAT, pev->origin, 256, 0.25f ); } // higher pitch as squeeker gets closer to detonation time - float flpitch = 155.0 - 60.0 * ( ( m_flDie - gpGlobals->time ) / SQUEEK_DETONATE_DELAY ); - if( flpitch < 100 ) - flpitch = 100; + /*float flpitch = 155.0f - 60.0f * ( ( m_flDie - gpGlobals->time ) / SQUEEK_DETONATE_DELAY ); + if( flpitch < 80.0f ) + flpitch = 80.0f;*/ if( m_hEnemy != 0 ) { @@ -288,16 +288,16 @@ void CSqueakGrenade::HuntThink( void ) } float flVel = pev->velocity.Length(); - float flAdj = 50.0 / ( flVel + 10.0 ); + float flAdj = 50.0f / ( flVel + 10.0f ); - if( flAdj > 1.2 ) - flAdj = 1.2; + if( flAdj > 1.2f ) + flAdj = 1.2f; // ALERT( at_console, "think : enemy\n"); // ALERT( at_console, "%.0f %.2f %.2f %.2f\n", flVel, m_vecTarget.x, m_vecTarget.y, m_vecTarget.z ); - pev->velocity = pev->velocity * flAdj + m_vecTarget * 300; + pev->velocity = pev->velocity * flAdj + m_vecTarget * 300.0f; } if( pev->flags & FL_ONGROUND ) @@ -313,7 +313,7 @@ void CSqueakGrenade::HuntThink( void ) } } - if( ( pev->origin - m_posPrev ).Length() < 1.0 ) + if( ( pev->origin - m_posPrev ).Length() < 1.0f ) { pev->velocity.x = RANDOM_FLOAT( -100, 100 ); pev->velocity.y = RANDOM_FLOAT( -100, 100 ); @@ -338,15 +338,15 @@ void CSqueakGrenade::SuperBounceTouch( CBaseEntity *pOther ) // at least until we've bounced once pev->owner = NULL; - pev->angles.x = 0; - pev->angles.z = 0; + pev->angles.x = 0.0f; + pev->angles.z = 0.0f; // avoid bouncing too much if( m_flNextHit > gpGlobals->time ) return; // higher pitch as squeeker gets closer to detonation time - flpitch = 155.0 - 60.0 * ( ( m_flDie - gpGlobals->time ) / SQUEEK_DETONATE_DELAY ); + flpitch = 155.0f - 60.0f * ( ( m_flDie - gpGlobals->time ) / SQUEEK_DETONATE_DELAY ); if( flpitch < 100 ) flpitch = 100; @@ -370,11 +370,11 @@ void CSqueakGrenade::SuperBounceTouch( CBaseEntity *pOther ) ApplyMultiDamage( pev, pev ); pev->dmg += gSkillData.snarkDmgPop; // add more explosion damage - // m_flDie += 2.0; // add more life + // m_flDie += 2.0f; // add more life // make bite sound - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "squeek/sqk_deploy1.wav", 1.0, ATTN_NORM, 0, (int)flpitch ); - m_flNextAttack = gpGlobals->time + 0.5; + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "squeek/sqk_deploy1.wav", 1.0f, ATTN_NORM, 0, (int)flpitch ); + m_flNextAttack = gpGlobals->time + 0.5f; } } else @@ -383,7 +383,7 @@ void CSqueakGrenade::SuperBounceTouch( CBaseEntity *pOther ) } } - m_flNextHit = gpGlobals->time + 0.1; + m_flNextHit = gpGlobals->time + 0.1f; m_flNextHunt = gpGlobals->time; if( g_pGameRules->IsMultiplayer() ) @@ -399,23 +399,23 @@ void CSqueakGrenade::SuperBounceTouch( CBaseEntity *pOther ) if( !( pev->flags & FL_ONGROUND ) ) { // play bounce sound - float flRndSound = RANDOM_FLOAT( 0, 1 ); + float flRndSound = RANDOM_FLOAT( 0.0f, 1.0f ); - if( flRndSound <= 0.33 ) + if( flRndSound <= 0.33f ) EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "squeek/sqk_hunt1.wav", 1, ATTN_NORM, 0, (int)flpitch ); - else if( flRndSound <= 0.66 ) + else if( flRndSound <= 0.66f ) EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "squeek/sqk_hunt2.wav", 1, ATTN_NORM, 0, (int)flpitch ); else EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "squeek/sqk_hunt3.wav", 1, ATTN_NORM, 0, (int)flpitch ); - CSoundEnt::InsertSound( bits_SOUND_COMBAT, pev->origin, 256, 0.25 ); + CSoundEnt::InsertSound( bits_SOUND_COMBAT, pev->origin, 256, 0.25f ); } else { // skittering sound - CSoundEnt::InsertSound( bits_SOUND_COMBAT, pev->origin, 100, 0.1 ); + CSoundEnt::InsertSound( bits_SOUND_COMBAT, pev->origin, 100, 0.1f ); } - m_flNextBounceSoundTime = gpGlobals->time + 0.5;// half second. + m_flNextBounceSoundTime = gpGlobals->time + 0.5f;// half second. } #endif @@ -433,7 +433,7 @@ void CSqueak::Spawn() pev->sequence = 1; pev->animtime = gpGlobals->time; - pev->framerate = 1.0; + pev->framerate = 1.0f; } void CSqueak::Precache( void ) @@ -468,21 +468,28 @@ int CSqueak::GetItemInfo( ItemInfo *p ) BOOL CSqueak::Deploy() { // play hunt sound - float flRndSound = RANDOM_FLOAT( 0, 1 ); + float flRndSound = RANDOM_FLOAT( 0.0f, 1.0f ); - if( flRndSound <= 0.5 ) + if( flRndSound <= 0.5f ) EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "squeek/sqk_hunt2.wav", 1, ATTN_NORM, 0, 100 ); else EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "squeek/sqk_hunt3.wav", 1, ATTN_NORM, 0, 100 ); m_pPlayer->m_iWeaponVolume = QUIET_GUN_VOLUME; - return DefaultDeploy( "models/v_squeak.mdl", "models/p_squeak.mdl", SQUEAK_UP, "squeak" ); + const BOOL result = DefaultDeploy( "models/v_squeak.mdl", "models/p_squeak.mdl", SQUEAK_UP, "squeak" ); +#if WEAPONS_ANIMATION_TIMES_FIX + if ( result ) + { + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.7f; + } +#endif + return result; } void CSqueak::Holster( int skiplocal /* = 0 */ ) { - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5f; if( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { @@ -492,7 +499,7 @@ void CSqueak::Holster( int skiplocal /* = 0 */ ) } SendWeaponAnim( SQUEAK_DOWN ); - EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM ); + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "common/null.wav", 1.0f, ATTN_NORM ); } void CSqueak::PrimaryAttack() @@ -512,28 +519,28 @@ void CSqueak::PrimaryAttack() } // find place to toss monster - UTIL_TraceLine( trace_origin + gpGlobals->v_forward * 20, trace_origin + gpGlobals->v_forward * 64, dont_ignore_monsters, NULL, &tr ); + UTIL_TraceLine( trace_origin + gpGlobals->v_forward * 20.0f, trace_origin + gpGlobals->v_forward * 64.0f, dont_ignore_monsters, NULL, &tr ); int flags; -#ifdef CLIENT_WEAPONS +#if CLIENT_WEAPONS flags = FEV_NOTHOST; #else flags = 0; #endif - PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usSnarkFire, 0.0, g_vecZero, g_vecZero, 0.0, 0.0, 0, 0, 0, 0 ); + PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usSnarkFire, 0.0f, g_vecZero, g_vecZero, 0.0f, 0.0f, 0, 0, 0, 0 ); - if( tr.fAllSolid == 0 && tr.fStartSolid == 0 && tr.flFraction > 0.25 ) + if( tr.fAllSolid == 0 && tr.fStartSolid == 0 && tr.flFraction > 0.25f ) { // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); -#ifndef CLIENT_DLL +#if !CLIENT_DLL CBaseEntity *pSqueak = CBaseEntity::Create( "monster_snark", tr.vecEndPos, m_pPlayer->pev->v_angle, m_pPlayer->edict() ); - pSqueak->pev->velocity = gpGlobals->v_forward * 200 + m_pPlayer->pev->velocity; + pSqueak->pev->velocity = gpGlobals->v_forward * 200.0f + m_pPlayer->pev->velocity; #endif // play hunt sound - float flRndSound = RANDOM_FLOAT( 0, 1 ); + float flRndSound = RANDOM_FLOAT( 0.0f, 1.0f ); - if( flRndSound <= 0.5 ) + if( flRndSound <= 0.5f ) EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "squeek/sqk_hunt2.wav", 1, ATTN_NORM, 0, 105 ); else EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "squeek/sqk_hunt3.wav", 1, ATTN_NORM, 0, 105 ); @@ -544,8 +551,8 @@ void CSqueak::PrimaryAttack() m_fJustThrown = 1; - m_flNextPrimaryAttack = GetNextAttackDelay( 0.3 ); - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.3f ); + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0f; } } } @@ -577,20 +584,20 @@ void CSqueak::WeaponIdle( void ) int iAnim; float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 ); - if( flRand <= 0.75 ) + if( flRand <= 0.75f ) { iAnim = SQUEAK_IDLE1; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 30.0 / 16 * (2); + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 30.0f / 16.0f * 2.0f; } - else if( flRand <= 0.875 ) + else if( flRand <= 0.875f ) { iAnim = SQUEAK_FIDGETFIT; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 70.0 / 16.0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 70.0f / 16.0f; } else { iAnim = SQUEAK_FIDGETNIP; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 80.0 / 16.0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 80.0f / 16.0f; } SendWeaponAnim( iAnim ); } diff --git a/dlls/subs.cpp b/dlls/subs.cpp index ff680279..7a1b724c 100644 --- a/dlls/subs.cpp +++ b/dlls/subs.cpp @@ -121,13 +121,6 @@ void CBaseEntity::UpdateOnRemove( void ) if( pev->globalname ) gGlobalState.EntitySetState( pev->globalname, GLOBAL_DEAD ); - - // tell owner ( if any ) that we're dead.This is mostly for MonsterMaker functionality. - //Killtarget didn't do this before, so the counter broke. - Solokiller - if( CBaseEntity* pOwner = pev->owner ? Instance( pev->owner ) : 0 ) - { - pOwner->DeathNotice( pev ); - } } // Convenient way to delay removing oneself @@ -251,7 +244,7 @@ void CBaseDelay::SUB_UseTargets( CBaseEntity *pActivator, USE_TYPE useType, floa // Save the useType pTemp->pev->button = (int)useType; pTemp->m_iszKillTarget = m_iszKillTarget; - pTemp->m_flDelay = 0; // prevent "recursion" + pTemp->m_flDelay = 0.0f; // prevent "recursion" pTemp->pev->target = pev->target; // HACKHACK @@ -421,13 +414,6 @@ void CBaseToggle::LinearMove( Vector vecDest, float flSpeed ) // divide vector length by speed to get time to reach dest float flTravelTime = vecDestDelta.Length() / flSpeed; - if( flTravelTime < 0.05 ) - { - UTIL_SetOrigin( pev, m_vecFinalDest ); - LinearMoveDone(); - return; - } - // set nextthink to trigger a call to LinearMoveDone when dest is reached pev->nextthink = pev->ltime + flTravelTime; SetThink( &CBaseToggle::LinearMoveDone ); @@ -461,7 +447,7 @@ void CBaseToggle::LinearMoveDone( void ) #else Vector delta = m_vecFinalDest - pev->origin; float error = delta.Length(); - if( error > 0.03125 ) + if( error > 0.03125f ) { LinearMove( m_vecFinalDest, 1000 ); return; diff --git a/dlls/talkmonster.cpp b/dlls/talkmonster.cpp index 9180f037..2b3ac14f 100644 --- a/dlls/talkmonster.cpp +++ b/dlls/talkmonster.cpp @@ -64,13 +64,13 @@ const char *CTalkMonster::m_szFriends[TLK_CFRIENDS] = Task_t tlIdleResponse[] = { { TASK_SET_ACTIVITY, (float)ACT_IDLE }, // Stop and listen - { TASK_WAIT, (float)0.5 }, // Wait until sure it's me they are talking to - { TASK_TLK_EYECONTACT, (float)0 }, // Wait until speaker is done - { TASK_TLK_RESPOND, (float)0 }, // Wait and then say my response - { TASK_TLK_IDEALYAW, (float)0 }, // look at who I'm talking to - { TASK_FACE_IDEAL, (float)0 }, + { TASK_WAIT, 0.5f }, // Wait until sure it's me they are talking to + { TASK_TLK_EYECONTACT, 0.0f }, // Wait until speaker is done + { TASK_TLK_RESPOND, 0.0f }, // Wait and then say my response + { TASK_TLK_IDEALYAW, 0.0f }, // look at who I'm talking to + { TASK_FACE_IDEAL, 0.0f }, { TASK_SET_ACTIVITY, (float)ACT_SIGNAL3 }, - { TASK_TLK_EYECONTACT, (float)0 }, // Wait until speaker is done + { TASK_TLK_EYECONTACT, 0.0f }, // Wait until speaker is done }; Schedule_t slIdleResponse[] = @@ -88,12 +88,12 @@ Schedule_t slIdleResponse[] = Task_t tlIdleSpeak[] = { - { TASK_TLK_SPEAK, (float)0 },// question or remark - { TASK_TLK_IDEALYAW, (float)0 },// look at who I'm talking to - { TASK_FACE_IDEAL, (float)0 }, + { TASK_TLK_SPEAK, 0.0f },// question or remark + { TASK_TLK_IDEALYAW, 0.0f },// look at who I'm talking to + { TASK_FACE_IDEAL, 0.0f }, { TASK_SET_ACTIVITY, (float)ACT_SIGNAL3 }, - { TASK_TLK_EYECONTACT, (float)0 }, - { TASK_WAIT_RANDOM, (float)0.5 }, + { TASK_TLK_EYECONTACT, 0.0f }, + { TASK_WAIT_RANDOM, 0.5f }, }; Schedule_t slIdleSpeak[] = @@ -113,9 +113,9 @@ Schedule_t slIdleSpeak[] = Task_t tlIdleSpeakWait[] = { { TASK_SET_ACTIVITY, (float)ACT_SIGNAL3 },// Stop and talk - { TASK_TLK_SPEAK, (float)0 },// question or remark - { TASK_TLK_EYECONTACT, (float)0 },// - { TASK_WAIT, (float)2 },// wait - used when sci is in 'use' mode to keep head turned + { TASK_TLK_SPEAK, 0.0f },// question or remark + { TASK_TLK_EYECONTACT, 0.0f },// + { TASK_WAIT, 2.0f },// wait - used when sci is in 'use' mode to keep head turned }; Schedule_t slIdleSpeakWait[] = @@ -135,18 +135,18 @@ Schedule_t slIdleSpeakWait[] = Task_t tlIdleHello[] = { { TASK_SET_ACTIVITY, (float)ACT_SIGNAL3 },// Stop and talk - { TASK_TLK_HELLO, (float)0 },// Try to say hello to player - { TASK_TLK_EYECONTACT, (float)0 }, - { TASK_WAIT, (float)0.5 },// wait a bit - { TASK_TLK_HELLO, (float)0 },// Try to say hello to player - { TASK_TLK_EYECONTACT, (float)0 }, - { TASK_WAIT, (float)0.5 },// wait a bit - { TASK_TLK_HELLO, (float)0 },// Try to say hello to player - { TASK_TLK_EYECONTACT, (float)0 }, - { TASK_WAIT, (float)0.5 },// wait a bit - { TASK_TLK_HELLO, (float)0 },// Try to say hello to player - { TASK_TLK_EYECONTACT, (float)0 }, - { TASK_WAIT, (float)0.5 },// wait a bit + { TASK_TLK_HELLO, 0.0f },// Try to say hello to player + { TASK_TLK_EYECONTACT, 0.0f }, + { TASK_WAIT, 0.5f },// wait a bit + { TASK_TLK_HELLO, 0.0f },// Try to say hello to player + { TASK_TLK_EYECONTACT, 0.0f }, + { TASK_WAIT, 0.5f },// wait a bit + { TASK_TLK_HELLO, 0.0f },// Try to say hello to player + { TASK_TLK_EYECONTACT, 0.0f }, + { TASK_WAIT, 0.5f },// wait a bit + { TASK_TLK_HELLO, 0.0f },// Try to say hello to player + { TASK_TLK_EYECONTACT, 0.0f }, + { TASK_WAIT, 0.5f },// wait a bit }; Schedule_t slIdleHello[] = @@ -167,8 +167,8 @@ Schedule_t slIdleHello[] = Task_t tlIdleStopShooting[] = { - { TASK_TLK_STOPSHOOTING, (float)0 },// tell player to stop shooting friend - // { TASK_TLK_EYECONTACT, (float)0 },// look at the player + { TASK_TLK_STOPSHOOTING, 0.0f },// tell player to stop shooting friend + // { TASK_TLK_EYECONTACT, 0.0f },// look at the player }; Schedule_t slIdleStopShooting[] = @@ -188,11 +188,11 @@ Schedule_t slIdleStopShooting[] = Task_t tlMoveAway[] = { { TASK_SET_FAIL_SCHEDULE, (float)SCHED_MOVE_AWAY_FAIL }, - { TASK_STORE_LASTPOSITION, (float)0 }, - { TASK_MOVE_AWAY_PATH, (float)100 }, - { TASK_WALK_PATH_FOR_UNITS, (float)100 }, - { TASK_STOP_MOVING, (float)0 }, - { TASK_FACE_PLAYER, (float)0.5 }, + { TASK_STORE_LASTPOSITION, 0.0f }, + { TASK_MOVE_AWAY_PATH, 100.0f }, + { TASK_WALK_PATH_FOR_UNITS, 100.0f }, + { TASK_STOP_MOVING, 0.0f }, + { TASK_FACE_PLAYER, 0.5f }, }; Schedule_t slMoveAway[] = @@ -208,8 +208,8 @@ Schedule_t slMoveAway[] = Task_t tlMoveAwayFail[] = { - { TASK_STOP_MOVING, (float)0 }, - { TASK_FACE_PLAYER, (float)0.5 }, + { TASK_STOP_MOVING, 0.0f }, + { TASK_FACE_PLAYER, 0.5f }, }; Schedule_t slMoveAwayFail[] = @@ -248,19 +248,19 @@ Task_t tlTlkIdleWatchClient[] = { { TASK_STOP_MOVING, 0 }, { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_TLK_LOOK_AT_CLIENT, (float)6 }, + { TASK_TLK_LOOK_AT_CLIENT, 6.0f }, }; Task_t tlTlkIdleWatchClientStare[] = { { TASK_STOP_MOVING, 0 }, { TASK_SET_ACTIVITY, (float)ACT_IDLE }, - { TASK_TLK_CLIENT_STARE, (float)6 }, - { TASK_TLK_STARE, (float)0 }, - { TASK_TLK_IDEALYAW, (float)0 },// look at who I'm talking to - { TASK_FACE_IDEAL, (float)0 }, + { TASK_TLK_CLIENT_STARE, 6.0f }, + { TASK_TLK_STARE, 0.0f }, + { TASK_TLK_IDEALYAW, 0.0f },// look at who I'm talking to + { TASK_FACE_IDEAL, 0.0f }, { TASK_SET_ACTIVITY, (float)ACT_SIGNAL3 }, - { TASK_TLK_EYECONTACT, (float)0 }, + { TASK_TLK_EYECONTACT, 0.0f }, }; Schedule_t slTlkIdleWatchClient[] = @@ -310,10 +310,10 @@ Schedule_t slTlkIdleWatchClient[] = Task_t tlTlkIdleEyecontact[] = { - { TASK_TLK_IDEALYAW, (float)0 },// look at who I'm talking to - { TASK_FACE_IDEAL, (float)0 }, + { TASK_TLK_IDEALYAW, 0.0f },// look at who I'm talking to + { TASK_FACE_IDEAL, 0.0f }, { TASK_SET_ACTIVITY, (float)ACT_SIGNAL3 }, - { TASK_TLK_EYECONTACT, (float)0 },// Wait until speaker is done + { TASK_TLK_EYECONTACT, 0.0f },// Wait until speaker is done }; Schedule_t slTlkIdleEyecontact[] = @@ -445,7 +445,7 @@ void CTalkMonster::StartTask( Task_t *pTask ) else if( FindCover( pev->origin, pev->view_ofs, 0, CoverRadius() ) ) { // then try for plain ole cover - m_flMoveWaitFinished = gpGlobals->time + 2; + m_flMoveWaitFinished = gpGlobals->time + 2.0f; TaskComplete(); } else @@ -494,18 +494,21 @@ void CTalkMonster::RunTask( Task_t *pTask ) if( pTask->iTask == TASK_TLK_CLIENT_STARE ) { - // fail out if the player looks away or moves away. - if( ( pPlayer->v.origin - pev->origin ).Length2D() > TLK_STARE_DIST ) + if( pPlayer ) { - // player moved away. - TaskFail(); - } + // fail out if the player looks away or moves away. + if( ( pPlayer->v.origin - pev->origin ).Length2D() > TLK_STARE_DIST ) + { + // player moved away. + TaskFail(); + } - UTIL_MakeVectors( pPlayer->v.angles ); - if( UTIL_DotPoints( pPlayer->v.origin, pev->origin, gpGlobals->v_forward ) < m_flFieldOfView ) - { - // player looked away - TaskFail(); + UTIL_MakeVectors( pPlayer->v.angles ); + if( UTIL_DotPoints( pPlayer->v.origin, pev->origin, gpGlobals->v_forward ) < m_flFieldOfView ) + { + // player looked away + TaskFail(); + } } } @@ -631,9 +634,9 @@ CBaseEntity *CTalkMonster::EnumFriends( CBaseEntity *pPrevious, int listNumber, UTIL_TraceLine( pev->origin, vecCheck, ignore_monsters, ENT( pev ), &tr ); } else - tr.flFraction = 1.0; + tr.flFraction = 1.0f; - if( tr.flFraction == 1.0 ) + if( tr.flFraction == 1.0f ) { return pFriend; } @@ -732,7 +735,7 @@ void CTalkMonster::HandleAnimEvent( MonsterEvent_t *pEvent ) // fall through... case SCRIPT_EVENT_SENTENCE: // Play a named sentence group ShutUpFriends(); - PlaySentence( pEvent->options, RANDOM_FLOAT( 2.8, 3.4 ), VOL_NORM, ATTN_IDLE ); + PlaySentence( pEvent->options, RANDOM_FLOAT( 2.8f, 3.4f ), VOL_NORM, ATTN_IDLE ); //ALERT( at_console, "script event speak\n" ); break; default: @@ -806,7 +809,7 @@ CBaseEntity *CTalkMonster::FindNearestFriend( BOOL fPlayer ) { UTIL_TraceLine( vecStart, vecCheck, ignore_monsters, ENT( pev ), &tr ); - if( tr.flFraction == 1.0 ) + if( tr.flFraction == 1.0f ) { // visible and in range, this is the new nearest scientist if( ( vecStart - vecCheck ).Length() < TALKRANGE_MIN ) @@ -841,10 +844,11 @@ void CTalkMonster::Touch( CBaseEntity *pOther ) // Heuristic for determining if the player is pushing me away float speed = fabs( pOther->pev->velocity.x ) + fabs( pOther->pev->velocity.y ); - if( speed > 50 ) + if( speed > 50.0f ) { SetConditions( bits_COND_CLIENT_PUSH ); - MakeIdealYaw( pOther->pev->origin ); + if ( m_MonsterState != MONSTERSTATE_SCRIPT ) + MakeIdealYaw( pOther->pev->origin ); } } } @@ -858,7 +862,7 @@ void CTalkMonster::IdleRespond( void ) //int pitch = GetVoicePitch(); // play response - PlaySentence( m_szGrp[TLK_ANSWER], RANDOM_FLOAT( 2.8, 3.2 ), VOL_NORM, ATTN_IDLE ); + PlaySentence( m_szGrp[TLK_ANSWER], RANDOM_FLOAT( 2.8f, 3.2f ), VOL_NORM, ATTN_IDLE ); } int CTalkMonster::FOkToSpeak( void ) @@ -939,9 +943,9 @@ int CTalkMonster::FIdleHello( void ) m_hTalkTarget = pPlayer; if( FBitSet(pev->spawnflags, SF_MONSTER_PREDISASTER ) ) - PlaySentence( m_szGrp[TLK_PHELLO], RANDOM_FLOAT( 3, 3.5 ), VOL_NORM, ATTN_IDLE ); + PlaySentence( m_szGrp[TLK_PHELLO], RANDOM_FLOAT( 3.0f, 3.5f ), VOL_NORM, ATTN_IDLE ); else - PlaySentence( m_szGrp[TLK_HELLO], RANDOM_FLOAT( 3, 3.5 ), VOL_NORM, ATTN_IDLE ); + PlaySentence( m_szGrp[TLK_HELLO], RANDOM_FLOAT( 3.0f, 3.5f ), VOL_NORM, ATTN_IDLE ); SetBits( m_bitsSaid, bit_saidHelloPlayer ); @@ -991,14 +995,14 @@ int CTalkMonster::FIdleSpeak( void ) szIdleGroup = m_szGrp[TLK_PIDLE]; szQuestionGroup = m_szGrp[TLK_PQUESTION]; // set global min delay for next conversation - duration = RANDOM_FLOAT( 4.8, 5.2 ); + duration = RANDOM_FLOAT( 4.8f, 5.2f ); } else { szIdleGroup = m_szGrp[TLK_IDLE]; szQuestionGroup = m_szGrp[TLK_QUESTION]; // set global min delay for next conversation - duration = RANDOM_FLOAT( 2.8, 3.2 ); + duration = RANDOM_FLOAT( 2.8f, 3.2f ); } //pitch = GetVoicePitch(); @@ -1105,7 +1109,7 @@ void CTalkMonster::PlaySentence( const char *pszSentence, float duration, float Talk( duration ); - CTalkMonster::g_talkWaitTime = gpGlobals->time + duration + 2.0; + CTalkMonster::g_talkWaitTime = gpGlobals->time + duration + 2.0f; if( pszSentence[0] == '!' ) EMIT_SOUND_DYN( edict(), CHAN_VOICE, pszSentence, volume, attenuation, 0, GetVoicePitch() ); else @@ -1124,7 +1128,7 @@ void CTalkMonster::Talk( float flDuration ) if( flDuration <= 0 ) { // no duration :( - m_flStopTalkTime = gpGlobals->time + 3; + m_flStopTalkTime = gpGlobals->time + 3.0f; } else { @@ -1186,20 +1190,20 @@ Schedule_t *CTalkMonster::GetScheduleOfType( int Type ) } // sustained light wounds? - if( !FBitSet( m_bitsSaid, bit_saidWoundLight ) && ( pev->health <= ( pev->max_health * 0.75 ) ) ) + if( !FBitSet( m_bitsSaid, bit_saidWoundLight ) && ( pev->health <= ( pev->max_health * 0.75f ) ) ) { //SENTENCEG_PlayRndSz( ENT( pev ), m_szGrp[TLK_WOUND], 1.0, ATTN_IDLE, 0, GetVoicePitch() ); - //CTalkMonster::g_talkWaitTime = gpGlobals->time + RANDOM_FLOAT( 2.8, 3.2 ); - PlaySentence( m_szGrp[TLK_WOUND], RANDOM_FLOAT( 2.8, 3.2 ), VOL_NORM, ATTN_IDLE ); + //CTalkMonster::g_talkWaitTime = gpGlobals->time + RANDOM_FLOAT( 2.8f, 3.2f ); + PlaySentence( m_szGrp[TLK_WOUND], RANDOM_FLOAT( 2.8f, 3.2f ), VOL_NORM, ATTN_IDLE ); SetBits( m_bitsSaid, bit_saidWoundLight ); return slIdleStand; } // sustained heavy wounds? - else if( !FBitSet( m_bitsSaid, bit_saidWoundHeavy ) && ( pev->health <= ( pev->max_health * 0.5 ) ) ) + else if( !FBitSet( m_bitsSaid, bit_saidWoundHeavy ) && ( pev->health <= ( pev->max_health * 0.5f ) ) ) { //SENTENCEG_PlayRndSz( ENT( pev ), m_szGrp[TLK_MORTAL], 1.0, ATTN_IDLE, 0, GetVoicePitch() ); - //CTalkMonster::g_talkWaitTime = gpGlobals->time + RANDOM_FLOAT( 2.8, 3.2 ); - PlaySentence( m_szGrp[TLK_MORTAL], RANDOM_FLOAT( 2.8, 3.2 ), VOL_NORM, ATTN_IDLE ); + //CTalkMonster::g_talkWaitTime = gpGlobals->time + RANDOM_FLOAT( 2.8f, 3.2f ); + PlaySentence( m_szGrp[TLK_MORTAL], RANDOM_FLOAT( 2.8f, 3.2f ), VOL_NORM, ATTN_IDLE ); SetBits( m_bitsSaid, bit_saidWoundHeavy ); return slIdleStand; } @@ -1289,8 +1293,8 @@ void CTalkMonster::TrySmellTalk( void ) // smelled something? if( !FBitSet( m_bitsSaid, bit_saidSmelled ) && HasConditions( bits_COND_SMELL ) ) { - PlaySentence( m_szGrp[TLK_SMELL], RANDOM_FLOAT( 2.8, 3.2 ), VOL_NORM, ATTN_IDLE ); - m_flLastSaidSmelled = gpGlobals->time + 60;// don't talk about the stinky for a while. + PlaySentence( m_szGrp[TLK_SMELL], RANDOM_FLOAT( 2.8f, 3.2f ), VOL_NORM, ATTN_IDLE ); + m_flLastSaidSmelled = gpGlobals->time + 60.0f;// don't talk about the stinky for a while. SetBits( m_bitsSaid, bit_saidSmelled ); } } @@ -1309,7 +1313,7 @@ void CTalkMonster::StopFollowing( BOOL clearSchedule ) { if( !( m_afMemory & bits_MEMORY_PROVOKED ) ) { - PlaySentence( m_szGrp[TLK_UNUSE], RANDOM_FLOAT( 2.8, 3.2 ), VOL_NORM, ATTN_IDLE ); + PlaySentence( m_szGrp[TLK_UNUSE], RANDOM_FLOAT( 2.8f, 3.2f ), VOL_NORM, ATTN_IDLE ); m_hTalkTarget = m_hTargetEnt; } @@ -1332,7 +1336,7 @@ void CTalkMonster::StartFollowing( CBaseEntity *pLeader ) m_IdealMonsterState = MONSTERSTATE_ALERT; m_hTargetEnt = pLeader; - PlaySentence( m_szGrp[TLK_USE], RANDOM_FLOAT( 2.8, 3.2 ), VOL_NORM, ATTN_IDLE ); + PlaySentence( m_szGrp[TLK_USE], RANDOM_FLOAT( 2.8f, 3.2f ), VOL_NORM, ATTN_IDLE ); m_hTalkTarget = m_hTargetEnt; ClearConditions( bits_COND_CLIENT_PUSH ); ClearSchedule(); diff --git a/dlls/talkmonster.h b/dlls/talkmonster.h index 36ac21a6..6a6e31ac 100644 --- a/dlls/talkmonster.h +++ b/dlls/talkmonster.h @@ -13,10 +13,10 @@ * ****/ #pragma once -#ifndef TALKMONSTER_H +#if !defined(TALKMONSTER_H) #define TALKMONSTER_H -#ifndef MONSTERS_H +#if !defined(MONSTERS_H) #include "monsters.h" #endif @@ -25,7 +25,7 @@ // Used for scientists and barneys //========================================================= -#define TALKRANGE_MIN 500.0 // don't talk to anyone farther away than this +#define TALKRANGE_MIN 500.0f // don't talk to anyone farther away than this #define TLK_STARE_DIST 128 // anyone closer than this and looking at me is probably staring at me. diff --git a/dlls/teamplay_gamerules.cpp b/dlls/teamplay_gamerules.cpp index 87b695e7..5c9a98d3 100644 --- a/dlls/teamplay_gamerules.cpp +++ b/dlls/teamplay_gamerules.cpp @@ -44,7 +44,8 @@ CHalfLifeTeamplay::CHalfLifeTeamplay() m_szTeamList[0] = 0; // Cache this because the team code doesn't want to deal with changing this in the middle of a game - strncpy( m_szTeamList, teamlist.string, TEAMPLAY_TEAMLISTLENGTH ); + strncpy( m_szTeamList, teamlist.string, TEAMPLAY_TEAMLISTLENGTH - 1 ); + m_szTeamList[TEAMPLAY_TEAMLISTLENGTH - 1] = '\0'; edict_t *pWorld = INDEXENT( 0 ); if( pWorld && pWorld->v.team ) @@ -52,14 +53,15 @@ CHalfLifeTeamplay::CHalfLifeTeamplay() if( teamoverride.value ) { const char *pTeamList = STRING( pWorld->v.team ); - if( pTeamList && strlen( pTeamList ) ) + if( pTeamList && pTeamList[0] != '\0' ) { - strncpy( m_szTeamList, pTeamList, TEAMPLAY_TEAMLISTLENGTH ); + strncpy( m_szTeamList, pTeamList, TEAMPLAY_TEAMLISTLENGTH - 1 ); + m_szTeamList[TEAMPLAY_TEAMLISTLENGTH - 1] = '\0'; } } } // Has the server set teams - if( strlen( m_szTeamList ) ) + if( m_szTeamList[0] != '\0' ) m_teamLimit = TRUE; else m_teamLimit = FALSE; @@ -69,7 +71,7 @@ CHalfLifeTeamplay::CHalfLifeTeamplay() extern cvar_t timeleft, fragsleft; -#ifndef NO_VOICEGAMEMGR +#if !NO_VOICEGAMEMGR #include "voice_gamemgr.h" extern CVoiceGameMgr g_VoiceGameMgr; #endif @@ -82,7 +84,7 @@ void CHalfLifeTeamplay::Think( void ) int frags_remaining = 0; int time_remaining = 0; -#ifndef NO_VOICEGAMEMGR +#if !NO_VOICEGAMEMGR g_VoiceGameMgr.Update(gpGlobals->frametime); #endif if( g_fGameOver ) // someone else quit the game already @@ -148,7 +150,7 @@ void CHalfLifeTeamplay::Think( void ) //========================================================= BOOL CHalfLifeTeamplay::ClientCommand( CBasePlayer *pPlayer, const char *pcmd ) { -#ifndef NO_VOICEGAMEMGR +#if !NO_VOICEGAMEMGR if( g_VoiceGameMgr.ClientCommand( pPlayer, pcmd ) ) return TRUE; #endif @@ -183,7 +185,8 @@ const char *CHalfLifeTeamplay::SetDefaultPlayerTeam( CBasePlayer *pPlayer ) { // copy out the team name from the model char *mdls = g_engfuncs.pfnInfoKeyValue( g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "model" ); - strncpy( pPlayer->m_szTeamName, mdls, TEAM_NAME_LENGTH ); + strncpy( pPlayer->m_szTeamName, mdls, TEAM_NAME_LENGTH - 1 ); + pPlayer->m_szTeamName[TEAM_NAME_LENGTH - 1] = '\0'; RecountTeams(); @@ -200,7 +203,8 @@ const char *CHalfLifeTeamplay::SetDefaultPlayerTeam( CBasePlayer *pPlayer ) { pTeamName = TeamWithFewestPlayers(); } - strncpy( pPlayer->m_szTeamName, pTeamName, TEAM_NAME_LENGTH ); + strncpy( pPlayer->m_szTeamName, pTeamName, TEAM_NAME_LENGTH - 1 ); + pPlayer->m_szTeamName[TEAM_NAME_LENGTH - 1] = '\0'; } return pPlayer->m_szTeamName; @@ -287,8 +291,10 @@ void CHalfLifeTeamplay::ChangePlayerTeam( CBasePlayer *pPlayer, const char *pTea // copy out the team name from the model if( pPlayer->m_szTeamName != pTeamName ) - strncpy( pPlayer->m_szTeamName, pTeamName, TEAM_NAME_LENGTH ); - + { + strncpy( pPlayer->m_szTeamName, pTeamName, TEAM_NAME_LENGTH - 1 ); + pPlayer->m_szTeamName[TEAM_NAME_LENGTH - 1] = '\0'; + } g_engfuncs.pfnSetClientKeyValue( clientIndex, g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "model", pPlayer->m_szTeamName ); g_engfuncs.pfnSetClientKeyValue( clientIndex, g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "team", pPlayer->m_szTeamName ); @@ -357,6 +363,8 @@ void CHalfLifeTeamplay::ClientUserInfoChanged( CBasePlayer *pPlayer, char *infob // recound stuff RecountTeams( TRUE ); + + pPlayer->SetPrefsFromUserinfo( infobuffer ); } extern int gmsgDeathMsg; @@ -601,7 +609,8 @@ void CHalfLifeTeamplay::RecountTeams( bool bResendInfo ) tm = num_teams; num_teams++; team_scores[tm] = 0; - strncpy( team_names[tm], pTeamName, MAX_TEAMNAME_LENGTH ); + strncpy( team_names[tm], pTeamName, MAX_TEAMNAME_LENGTH - 1 ); + team_names[tm][MAX_TEAMNAME_LENGTH - 1] = '\0'; } } diff --git a/dlls/teamplay_gamerules.h b/dlls/teamplay_gamerules.h index 12ed038f..f7c91de8 100644 --- a/dlls/teamplay_gamerules.h +++ b/dlls/teamplay_gamerules.h @@ -16,7 +16,7 @@ // teamplay_gamerules.h // #pragma once -#ifndef TEAMPLAY_GAMERULES_H +#if !defined(TEAMPLAY_GAMERULES_H) #define TEAMPLAY_GAMERULES_H #define MAX_TEAMNAME_LENGTH 16 diff --git a/dlls/tentacle.cpp b/dlls/tentacle.cpp index 44b8b45b..685540d5 100644 --- a/dlls/tentacle.cpp +++ b/dlls/tentacle.cpp @@ -12,7 +12,7 @@ * use or distribution of this code by or to any unlicensed person is illegal. * ****/ -#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD ) +#if !OEM_BUILD && !HLDEMO_BUILD /* @@ -261,7 +261,7 @@ void CTentacle::Spawn() SetTouch( &CTentacle::HitTouch ); SetUse( &CTentacle::CommandUse ); - pev->nextthink = gpGlobals->time + 0.2; + pev->nextthink = gpGlobals->time + 0.2f; ResetSequenceInfo(); m_iDir = 1; @@ -323,7 +323,7 @@ void CTentacle::KeyValue( KeyValueData *pkvd ) { if( FStrEq( pkvd->szKeyName, "sweeparc" ) ) { - m_flMaxYaw = atof( pkvd->szValue ) / 2.0; + m_flMaxYaw = atof( pkvd->szValue ) * 0.5f; pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "sound" ) ) @@ -426,7 +426,7 @@ void CTentacle::Test( void ) pev->sequence = TENTACLE_ANIM_Floor_Strike; pev->framerate = 0; StudioFrameAdvance(); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } // @@ -435,7 +435,7 @@ void CTentacle::Test( void ) void CTentacle::Cycle( void ) { // ALERT( at_console, "%s %.2f %d %d\n", STRING( pev->targetname ), pev->origin.z, m_MonsterState, m_IdealMonsterState ); - pev->nextthink = gpGlobals-> time + 0.1; + pev->nextthink = gpGlobals-> time + 0.1f; // ALERT( at_console, "%s %d %d %d %f %f\n", STRING( pev->targetname ), pev->sequence, m_iGoalAnim, m_iDir, pev->framerate, pev->health ); @@ -467,7 +467,7 @@ void CTentacle::Cycle( void ) if( pSound ) { Vector vecDir; - if( gpGlobals->time - m_flPrevSoundTime < 0.5 ) + if( gpGlobals->time - m_flPrevSoundTime < 0.5f ) { float dt = gpGlobals->time - m_flPrevSoundTime; vecDir = pSound->m_vecOrigin + ( pSound->m_vecOrigin - m_vecPrevSound ) / dt - pev->origin; @@ -506,7 +506,7 @@ void CTentacle::Cycle( void ) // UTIL_EmitAmbientSound( ENT( pev ), pev->origin + Vector( 0, 0, MyHeight() ), sound, 1.0, ATTN_NORM, 0, 100 ); } #endif - m_flSoundTime = gpGlobals->time + RANDOM_FLOAT( 5.0, 10.0 ); + m_flSoundTime = gpGlobals->time + RANDOM_FLOAT( 5.0f, 10.0f ); } // clip ideal_yaw @@ -644,8 +644,8 @@ void CTentacle::Cycle( void ) } ResetSequenceInfo(); - m_flFramerateAdj = RANDOM_FLOAT( -0.2, 0.2 ); - pev->framerate = m_iDir * 1.0 + m_flFramerateAdj; + m_flFramerateAdj = RANDOM_FLOAT( -0.2f, 0.2f ); + pev->framerate = m_iDir * 1.0f + m_flFramerateAdj; switch( pev->sequence ) { @@ -678,12 +678,12 @@ void CTentacle::Cycle( void ) // ALERT( at_console, "seq %d\n", pev->sequence ); } - if( m_flPrevSoundTime + 2.0 > gpGlobals->time ) + if( m_flPrevSoundTime + 2.0f > gpGlobals->time ) { // 1.5 normal speed if hears sounds - pev->framerate = m_iDir * 1.5 + m_flFramerateAdj; + pev->framerate = m_iDir * 1.5f + m_flFramerateAdj; } - else if( m_flPrevSoundTime + 5.0 > gpGlobals->time ) + else if( m_flPrevSoundTime + 5.0f > gpGlobals->time ) { // slowdown to normal pev->framerate = m_iDir + m_iDir * ( 5 - ( gpGlobals->time - m_flPrevSoundTime ) ) / 2 + m_flFramerateAdj; @@ -719,7 +719,7 @@ void CTentacle::CommandUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_T void CTentacle::DieThink( void ) { - pev->nextthink = gpGlobals-> time + 0.1; + pev->nextthink = gpGlobals-> time + 0.1f; DispatchAnimEvents(); StudioFrameAdvance(); @@ -778,7 +778,7 @@ void CTentacle::DieThink( void ) case TENTACLE_ANIM_Engine_Death1: case TENTACLE_ANIM_Engine_Death2: case TENTACLE_ANIM_Engine_Death3: - pev->framerate = RANDOM_FLOAT( m_iDir - 0.2, m_iDir + 0.2 ); + pev->framerate = RANDOM_FLOAT( m_iDir - 0.2f, m_iDir + 0.2f ); dy = 180; break; default: @@ -841,11 +841,11 @@ void CTentacle::HandleAnimEvent( MonsterEvent_t *pEvent ) case 6: // light tap { - Vector vecSrc = pev->origin + m_flTapRadius * Vector( cos( pev->angles.y * ( M_PI / 180.0 ) ), sin( pev->angles.y * ( M_PI / 180.0 ) ), 0.0 ); + Vector vecSrc = pev->origin + m_flTapRadius * Vector( cos( pev->angles.y * ( M_PI_F / 180.0f ) ), sin( pev->angles.y * ( M_PI_F / 180.0f ) ), 0.0f ); vecSrc.z += MyHeight(); - float flVol = RANDOM_FLOAT( 0.3, 0.5 ); + float flVol = RANDOM_FLOAT( 0.3f, 0.5f ); switch( m_iTapSound ) { @@ -929,7 +929,7 @@ void CTentacle::Start( void ) g_fSquirmSound = TRUE; } - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } void CTentacle::HitTouch( CBaseEntity *pOther ) @@ -961,7 +961,7 @@ void CTentacle::HitTouch( CBaseEntity *pOther ) return; // Huh? } - m_flHitTime = gpGlobals->time + 0.5; + m_flHitTime = gpGlobals->time + 0.5f; // ALERT( at_console, "%s : ", STRING( tr.pHit->v.classname ) ); diff --git a/dlls/trains.h b/dlls/trains.h index f740e2ea..046dbc24 100644 --- a/dlls/trains.h +++ b/dlls/trains.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef TRAINS_H +#if !defined(TRAINS_H) #define TRAINS_H // Tracktrain spawn flags diff --git a/dlls/triggers.cpp b/dlls/triggers.cpp index 053776a0..c9c428d3 100644 --- a/dlls/triggers.cpp +++ b/dlls/triggers.cpp @@ -167,7 +167,7 @@ void CAutoTrigger::Spawn( void ) void CAutoTrigger::Precache( void ) { - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } void CAutoTrigger::Think( void ) @@ -618,7 +618,7 @@ void CTriggerMonsterJump::Touch( CBaseEntity *pOther ) return; } - pevOther->origin.z += 1; + pevOther->origin.z += 1.0f; if( FBitSet( pevOther->flags, FL_ONGROUND ) ) { @@ -743,7 +743,7 @@ void CTargetCDAudio::Spawn( void ) pev->movetype = MOVETYPE_NONE; if( pev->scale > 0 ) - pev->nextthink = gpGlobals->time + 1.0; + pev->nextthink = gpGlobals->time + 1.0f; } void CTargetCDAudio::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) @@ -763,7 +763,7 @@ void CTargetCDAudio::Think( void ) if( !pClient ) return; - pev->nextthink = gpGlobals->time + 0.5; + pev->nextthink = gpGlobals->time + 0.5f; if( ( pClient->v.origin - pev->origin ).Length() <= pev->scale ) Play(); @@ -839,8 +839,8 @@ void CTriggerHurt::RadiationThink( void ) origin = pev->origin; view_ofs = pev->view_ofs; - pev->origin = ( pev->absmin + pev->absmax ) * 0.5; - pev->view_ofs = pev->view_ofs * 0.0; + pev->origin = ( pev->absmin + pev->absmax ) * 0.5f; + pev->view_ofs = pev->view_ofs * 0.0f; pentPlayer = FIND_CLIENT_IN_PVS( edict() ); @@ -855,8 +855,8 @@ void CTriggerHurt::RadiationThink( void ) pevTarget = VARS( pentPlayer ); // get range to player; - vecSpot1 = ( pev->absmin + pev->absmax ) * 0.5; - vecSpot2 = ( pevTarget->absmin + pevTarget->absmax ) * 0.5; + vecSpot1 = ( pev->absmin + pev->absmax ) * 0.5f; + vecSpot2 = ( pevTarget->absmin + pevTarget->absmax ) * 0.5f; vecRange = vecSpot1 - vecSpot2; flRange = vecRange.Length(); @@ -869,7 +869,7 @@ void CTriggerHurt::RadiationThink( void ) pPlayer->m_flgeigerRange = flRange; } - pev->nextthink = gpGlobals->time + 0.25; + pev->nextthink = gpGlobals->time + 0.25f; } // @@ -966,7 +966,7 @@ void CBaseTrigger::HurtTouch( CBaseEntity *pOther ) // while touching the trigger. Player continues taking damage for a while after // leaving the trigger - fldmg = pev->dmg * 0.5; // 0.5 seconds worth of damage, pev->dmg is damage/second + fldmg = pev->dmg * 0.5f; // 0.5 seconds worth of damage, pev->dmg is damage/second // JAY: Cut this because it wasn't fully realized. Damage is simpler now. #if 0 @@ -1006,7 +1006,7 @@ void CBaseTrigger::HurtTouch( CBaseEntity *pOther ) pev->pain_finished = gpGlobals->time; // Apply damage every half second - pev->dmgtime = gpGlobals->time + 0.5;// half second delay until this trigger can hurt toucher again + pev->dmgtime = gpGlobals->time + 0.5f;// half second delay until this trigger can hurt toucher again if( pev->target ) { @@ -1052,7 +1052,7 @@ LINK_ENTITY_TO_CLASS( trigger_multiple, CTriggerMultiple ) void CTriggerMultiple::Spawn( void ) { if( m_flWait == 0 ) - m_flWait = 0.2; + m_flWait = 0.2f; InitTrigger(); @@ -1138,7 +1138,7 @@ void CBaseTrigger::ActivateMultiTrigger( CBaseEntity *pActivator ) if( pev->nextthink > gpGlobals->time ) return; // still waiting for reset time - if( !UTIL_IsMasterTriggered( m_sMaster,pActivator ) ) + if( !UTIL_IsMasterTriggered( m_sMaster, pActivator ) ) return; if( FClassnameIs( pev, "trigger_secret" ) ) @@ -1173,7 +1173,7 @@ void CBaseTrigger::ActivateMultiTrigger( CBaseEntity *pActivator ) // we can't just remove (self) here, because this is a touch function // called while C code is looping through area links... SetTouch( NULL ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; SetThink( &CBaseEntity::SUB_Remove ); } } @@ -1205,7 +1205,7 @@ void CBaseTrigger::CounterUse( CBaseEntity *pActivator, CBaseEntity *pCaller, US BOOL fTellActivator = ( m_hActivator != 0 ) && - FClassnameIs( m_hActivator->pev, "player" ) && + m_hActivator->IsPlayer() && !FBitSet( pev->spawnflags, SPAWNFLAG_NOMESSAGE ); if( m_cTriggersLeft != 0 ) { @@ -1828,7 +1828,7 @@ void CChangeLevel::ChangeLevelNow( CBaseEntity *pActivator ) // void CChangeLevel::TouchChangeLevel( CBaseEntity *pOther ) { - if( !FClassnameIs( pOther->pev, "player" ) ) + if( !pOther->IsPlayer() ) return; m_coopData.fSkipSpawnCheck = false; @@ -2042,7 +2042,7 @@ void NextLevel( void ) if( pChange->pev->nextthink < gpGlobals->time ) { pChange->SetThink( &CChangeLevel::ExecuteChangeLevel ); - pChange->pev->nextthink = gpGlobals->time + 0.1; + pChange->pev->nextthink = gpGlobals->time + 0.1f; } } @@ -2781,13 +2781,13 @@ void CTriggerCamera::FollowTarget() if( dy > 180 ) dy = dy - 360; - pev->avelocity.x = dx * 40 * gpGlobals->frametime; - pev->avelocity.y = dy * 40 * gpGlobals->frametime; + pev->avelocity.x = dx * 40 * 0.01f; + pev->avelocity.y = dy * 40 * 0.01f; if( !( FBitSet( pev->spawnflags, SF_CAMERA_PLAYER_TAKECONTROL ) ) ) { - pev->velocity = pev->velocity * 0.8; - if( pev->velocity.Length() < 10.0 ) + pev->velocity = pev->velocity * 0.8f; + if( pev->velocity.Length() < 10.0f ) pev->velocity = g_vecZero; } diff --git a/dlls/tripmine.cpp b/dlls/tripmine.cpp index 6e8fc2fc..90379807 100644 --- a/dlls/tripmine.cpp +++ b/dlls/tripmine.cpp @@ -38,7 +38,7 @@ enum tripmine_e TRIPMINE_GROUND }; -#ifndef CLIENT_DLL +#if !CLIENT_DLL class CTripmineGrenade : public CGrenade { void Spawn( void ); @@ -82,7 +82,9 @@ TYPEDESCRIPTION CTripmineGrenade::m_SaveData[] = DEFINE_FIELD( CTripmineGrenade, m_vecEnd, FIELD_POSITION_VECTOR ), DEFINE_FIELD( CTripmineGrenade, m_flBeamLength, FIELD_FLOAT ), DEFINE_FIELD( CTripmineGrenade, m_hOwner, FIELD_EHANDLE ), +#if !TRIPMINE_BEAM_DUPLICATION_FIX DEFINE_FIELD( CTripmineGrenade, m_pBeam, FIELD_CLASSPTR ), +#endif DEFINE_FIELD( CTripmineGrenade, m_posOwner, FIELD_POSITION_VECTOR ), DEFINE_FIELD( CTripmineGrenade, m_angleOwner, FIELD_VECTOR ), DEFINE_FIELD( CTripmineGrenade, m_pRealOwner, FIELD_EDICT ), @@ -105,22 +107,22 @@ void CTripmineGrenade::Spawn( void ) ResetSequenceInfo(); pev->framerate = 0; - UTIL_SetSize( pev, Vector( -8, -8, -8 ), Vector( 8, 8, 8 ) ); + UTIL_SetSize( pev, Vector( -8.0f, -8.0f, -8.0f ), Vector( 8.0f, 8.0f, 8.0f ) ); UTIL_SetOrigin( pev, pev->origin ); if( pev->spawnflags & 1 ) { // power up quickly - m_flPowerUp = gpGlobals->time + 1.0; + m_flPowerUp = gpGlobals->time + 1.0f; } else { // power up in 2.5 seconds - m_flPowerUp = gpGlobals->time + 2.5; + m_flPowerUp = gpGlobals->time + 2.5f; } SetThink( &CTripmineGrenade::PowerupThink ); - pev->nextthink = gpGlobals->time + 0.2; + pev->nextthink = gpGlobals->time + 0.2f; pev->takedamage = DAMAGE_YES; pev->dmg = gSkillData.plrDmgTripmine; @@ -138,7 +140,7 @@ void CTripmineGrenade::Spawn( void ) UTIL_MakeAimVectors( pev->angles ); m_vecDir = gpGlobals->v_forward; - m_vecEnd = pev->origin + m_vecDir * 2048; + m_vecEnd = pev->origin + m_vecDir * 2048.0f; } void CTripmineGrenade::Precache( void ) @@ -163,7 +165,7 @@ void CTripmineGrenade::WarningThink( void ) // set to power up SetThink( &CTripmineGrenade::PowerupThink ); - pev->nextthink = gpGlobals->time + 1.0; + pev->nextthink = gpGlobals->time + 1.0f; } void CTripmineGrenade::PowerupThink( void ) @@ -175,15 +177,15 @@ void CTripmineGrenade::PowerupThink( void ) // find an owner edict_t *oldowner = pev->owner; pev->owner = NULL; - UTIL_TraceLine( pev->origin + m_vecDir * 8, pev->origin - m_vecDir * 32, dont_ignore_monsters, ENT( pev ), &tr ); + UTIL_TraceLine( pev->origin + m_vecDir * 8.0f, pev->origin - m_vecDir * 32.0f, dont_ignore_monsters, ENT( pev ), &tr ); if( tr.fStartSolid || ( oldowner && tr.pHit == oldowner ) ) { pev->owner = oldowner; - m_flPowerUp += 0.1; - pev->nextthink = gpGlobals->time + 0.1; + m_flPowerUp += 0.1f; + pev->nextthink = gpGlobals->time + 0.1f; return; } - if( tr.flFraction < 1.0 ) + if( tr.flFraction < 1.0f ) { pev->owner = tr.pHit; m_hOwner = CBaseEntity::Instance( pev->owner ); @@ -195,8 +197,8 @@ void CTripmineGrenade::PowerupThink( void ) STOP_SOUND( ENT( pev ), CHAN_VOICE, "weapons/mine_deploy.wav" ); STOP_SOUND( ENT( pev ), CHAN_BODY, "weapons/mine_charge.wav" ); SetThink( &CBaseEntity::SUB_Remove ); - pev->nextthink = gpGlobals->time + 0.1; - ALERT( at_console, "WARNING:Tripmine at %.0f, %.0f, %.0f removed\n", pev->origin.x, pev->origin.y, pev->origin.z ); + pev->nextthink = gpGlobals->time + 0.1f; + ALERT( at_console, "WARNING:Tripmine at %.0f, %.0f, %.0f removed\n", (double)pev->origin.x, (double)pev->origin.y, (double)pev->origin.z ); KillBeam(); return; } @@ -206,12 +208,12 @@ void CTripmineGrenade::PowerupThink( void ) // disable STOP_SOUND( ENT( pev ), CHAN_VOICE, "weapons/mine_deploy.wav" ); STOP_SOUND( ENT( pev ), CHAN_BODY, "weapons/mine_charge.wav" ); - CBaseEntity *pMine = Create( "weapon_tripmine", pev->origin + m_vecDir * 24, pev->angles ); + CBaseEntity *pMine = Create( "weapon_tripmine", pev->origin + m_vecDir * 24.0f, pev->angles ); pMine->pev->spawnflags |= SF_NORESPAWN; SetThink( &CBaseEntity::SUB_Remove ); KillBeam(); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; return; } // ALERT( at_console, "%d %.0f %.0f %0.f\n", pev->owner, m_pOwner->pev->origin.x, m_pOwner->pev->origin.y, m_pOwner->pev->origin.z ); @@ -227,7 +229,7 @@ void CTripmineGrenade::PowerupThink( void ) // play enabled sound EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "weapons/mine_activate.wav", 0.5, ATTN_NORM, 1, 75 ); } - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } void CTripmineGrenade::KillBeam( void ) @@ -251,11 +253,14 @@ void CTripmineGrenade::MakeBeam( void ) // set to follow laser spot SetThink( &CTripmineGrenade::BeamBreakThink ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; - Vector vecTmpEnd = pev->origin + m_vecDir * 2048 * m_flBeamLength; + Vector vecTmpEnd = pev->origin + m_vecDir * 2048.0f * m_flBeamLength; m_pBeam = CBeam::BeamCreate( g_pModelNameLaser, 10 ); +#if TRIPMINE_BEAM_DUPLICATION_FIX + m_pBeam->pev->spawnflags |= SF_BEAM_TEMPORARY; +#endif m_pBeam->PointEntInit( vecTmpEnd, entindex() ); m_pBeam->SetColor( 0, 214, 198 ); m_pBeam->SetScrollRate( 255 ); @@ -277,12 +282,26 @@ void CTripmineGrenade::BeamBreakThink( void ) // respawn detect. if( !m_pBeam ) { +#if TRIPMINE_BEAM_DUPLICATION_FIX + // Use the same trace parameters as the original trace above so the right entity is hit. + TraceResult tr2; + UTIL_TraceLine( pev->origin + m_vecDir * 8.0f, pev->origin - m_vecDir * 32.0f, dont_ignore_monsters, ENT( pev ), &tr2 ); +#endif MakeBeam(); +#if TRIPMINE_BEAM_DUPLICATION_FIX + if( tr2.pHit ) + { + // reset owner too + pev->owner = tr2.pHit; + m_hOwner = CBaseEntity::Instance( tr2.pHit ); + } +#else if( tr.pHit ) m_hOwner = CBaseEntity::Instance( tr.pHit ); // reset owner too +#endif } - if( fabs( m_flBeamLength - tr.flFraction ) > 0.001 ) + if( fabs( m_flBeamLength - tr.flFraction ) > 0.001f ) { bBlowup = 1; } @@ -308,7 +327,7 @@ void CTripmineGrenade::BeamBreakThink( void ) return; } - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } int CTripmineGrenade::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) @@ -316,9 +335,9 @@ int CTripmineGrenade::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacke if( gpGlobals->time < m_flPowerUp && flDamage < pev->health ) { // disable - // Create( "weapon_tripmine", pev->origin + m_vecDir * 24, pev->angles ); + // Create( "weapon_tripmine", pev->origin + m_vecDir * 24.0f, pev->angles ); SetThink( &CBaseEntity::SUB_Remove ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; KillBeam(); return FALSE; } @@ -336,16 +355,16 @@ void CTripmineGrenade::Killed( entvars_t *pevAttacker, int iGib ) } SetThink( &CTripmineGrenade::DelayDeathThink ); - pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 0.1, 0.3 ); + pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 0.1f, 0.3f ); - EMIT_SOUND( ENT( pev ), CHAN_BODY, "common/null.wav", 0.5, ATTN_NORM ); // shut off chargeup + EMIT_SOUND( ENT( pev ), CHAN_BODY, "common/null.wav", 0.5f, ATTN_NORM ); // shut off chargeup } void CTripmineGrenade::DelayDeathThink( void ) { KillBeam(); TraceResult tr; - UTIL_TraceLine( pev->origin + m_vecDir * 8, pev->origin - m_vecDir * 64, dont_ignore_monsters, ENT( pev ), &tr ); + UTIL_TraceLine( pev->origin + m_vecDir * 8, pev->origin - m_vecDir * 64.0f, dont_ignore_monsters, ENT( pev ), &tr ); Explode( &tr, DMG_BLAST ); } @@ -359,7 +378,12 @@ void CTripmine::Spawn() m_iId = WEAPON_TRIPMINE; SET_MODEL( ENT( pev ), "models/v_tripmine.mdl" ); pev->frame = 0; + +#ifdef CLIENT_DLL + pev->body = 0; +#else pev->body = 3; +#endif pev->sequence = TRIPMINE_GROUND; // ResetSequenceInfo(); pev->framerate = 0; @@ -368,13 +392,13 @@ void CTripmine::Spawn() m_iDefaultAmmo = TRIPMINE_DEFAULT_GIVE; -#ifdef CLIENT_DLL +#if CLIENT_DLL if( !bIsMultiplayer() ) #else if( !g_pGameRules->IsDeathmatch() ) #endif { - UTIL_SetSize( pev, Vector( -16, -16, 0 ), Vector( 16, 16, 28 ) ); + UTIL_SetSize( pev, Vector( -16.0f, -16.0f, 0.0f ), Vector( 16.0f, 16.0f, 28.0f ) ); } } @@ -412,7 +436,7 @@ BOOL CTripmine::Deploy() void CTripmine::Holster( int skiplocal /* = 0 */ ) { - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5f; if( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { @@ -422,7 +446,7 @@ void CTripmine::Holster( int skiplocal /* = 0 */ ) } SendWeaponAnim( TRIPMINE_HOLSTER ); - EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM ); + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "common/null.wav", 1.0f, ATTN_NORM ); } void CTripmine::PrimaryAttack( void ) @@ -436,24 +460,24 @@ void CTripmine::PrimaryAttack( void ) TraceResult tr; - UTIL_TraceLine( vecSrc, vecSrc + vecAiming * 128, dont_ignore_monsters, ENT( m_pPlayer->pev ), &tr ); + UTIL_TraceLine( vecSrc, vecSrc + vecAiming * 128.0f, dont_ignore_monsters, ENT( m_pPlayer->pev ), &tr ); int flags; -#ifdef CLIENT_WEAPONS +#if CLIENT_WEAPONS flags = FEV_NOTHOST; #else flags = 0; #endif - PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usTripFire, 0.0, g_vecZero, g_vecZero, 0.0, 0.0, 0, 0, 0, 0 ); + PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usTripFire, 0.0f, g_vecZero, g_vecZero, 0.0f, 0.0f, 0, 0, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] == 1, 0 ); - if( tr.flFraction < 1.0 ) + if( tr.flFraction < 1.0f ) { CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit ); if( pEntity && !( pEntity->pev->flags & FL_CONVEYOR ) ) { Vector angles = UTIL_VecToAngles( tr.vecPlaneNormal ); - CBaseEntity::Create( "monster_tripmine", tr.vecEndPos + tr.vecPlaneNormal * 8, angles, m_pPlayer->edict() ); + CBaseEntity::Create( "monster_tripmine", tr.vecEndPos + tr.vecPlaneNormal * 8.0f, angles, m_pPlayer->edict() ); m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; @@ -483,6 +507,8 @@ void CTripmine::PrimaryAttack( void ) void CTripmine::WeaponIdle( void ) { + pev->body = 0; + if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) return; @@ -498,20 +524,20 @@ void CTripmine::WeaponIdle( void ) int iAnim; float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 ); - if( flRand <= 0.25 ) + if( flRand <= 0.25f ) { iAnim = TRIPMINE_IDLE1; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 90.0 / 30.0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 90.0f / 30.0f; } - else if( flRand <= 0.75 ) + else if( flRand <= 0.75f ) { iAnim = TRIPMINE_IDLE2; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 60.0 / 30.0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 60.0f / 30.0f; } else { iAnim = TRIPMINE_FIDGET; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 100.0 / 30.0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 100.0f / 30.0f; } SendWeaponAnim( iAnim ); diff --git a/dlls/turret.cpp b/dlls/turret.cpp index 093b2032..556d7ede 100644 --- a/dlls/turret.cpp +++ b/dlls/turret.cpp @@ -316,7 +316,7 @@ void CTurret::Spawn() m_pEyeGlow->SetAttachment( edict(), 2 ); m_eyeBrightness = 0; - pev->nextthink = gpGlobals->time + 0.3; + pev->nextthink = gpGlobals->time + 0.3f; } void CTurret::Precache() @@ -331,9 +331,9 @@ void CMiniTurret::Spawn() Precache(); SET_MODEL( ENT( pev ), "models/miniturret.mdl" ); pev->health = gSkillData.miniturretHealth; - m_HackedGunPos = Vector( 0, 0, 12.75 ); + m_HackedGunPos = Vector( 0.0f, 0.0f, 12.75f ); m_flMaxSpin = 0; - pev->view_ofs.z = 12.75; + pev->view_ofs.z = 12.75f; CBaseTurret::Spawn(); m_iRetractHeight = 16; @@ -342,7 +342,7 @@ void CMiniTurret::Spawn() UTIL_SetSize( pev, Vector( -16, -16, -m_iRetractHeight ), Vector( 16, 16, m_iRetractHeight ) ); SetThink( &CBaseTurret::Initialize ); - pev->nextthink = gpGlobals->time + 0.3; + pev->nextthink = gpGlobals->time + 0.3f; } void CMiniTurret::Precache() @@ -385,7 +385,7 @@ void CBaseTurret::Initialize( void ) { m_flLastSight = gpGlobals->time + m_flMaxWait; SetThink( &CBaseTurret::AutoSearchThink ); - pev->nextthink = gpGlobals->time + .1; + pev->nextthink = gpGlobals->time + 0.1f; } else SetThink( &CBaseEntity::SUB_DoNothing ); @@ -399,7 +399,7 @@ void CBaseTurret::TurretUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_ if( m_iOn ) { m_hEnemy = NULL; - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; m_iAutoStart = FALSE;// switching off a turret disables autostart //!!!! this should spin down first!!BUGBUG @@ -407,7 +407,7 @@ void CBaseTurret::TurretUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_ } else { - pev->nextthink = gpGlobals->time + 0.1; // turn on delay + pev->nextthink = gpGlobals->time + 0.1f; // turn on delay // if the turret is flagged as an autoactivate turret, re-enable it's ability open self. if( pev->spawnflags & SF_MONSTER_TURRET_AUTOACTIVATE ) @@ -465,7 +465,7 @@ void CBaseTurret::ActiveThink( void ) int fAttack = 0; Vector vecDirToEnemy; - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; StudioFrameAdvance(); if( ( !m_iOn ) || ( m_hEnemy == 0 ) ) @@ -481,7 +481,7 @@ void CBaseTurret::ActiveThink( void ) { if( !m_flLastSight ) { - m_flLastSight = gpGlobals->time + 0.5; // continue-shooting timeout + m_flLastSight = gpGlobals->time + 0.5f; // continue-shooting timeout } else { @@ -510,7 +510,7 @@ void CBaseTurret::ActiveThink( void ) if( !fEnemyVisible || ( flDistToEnemy > TURRET_RANGE ) ) { if( !m_flLastSight ) - m_flLastSight = gpGlobals->time + 0.5; + m_flLastSight = gpGlobals->time + 0.5f; else { // Should we look for a new target? @@ -529,7 +529,7 @@ void CBaseTurret::ActiveThink( void ) m_vecLastSight = vecMidEnemy; } - UTIL_MakeAimVectors(m_vecCurAngles); + UTIL_MakeAimVectors( m_vecCurAngles ); /* ALERT( at_console, "%.0f %.0f : %.2f %.2f %.2f\n", @@ -541,7 +541,7 @@ void CBaseTurret::ActiveThink( void ) vecLOS = vecLOS.Normalize(); // Is the Gun looking at the target - if( DotProduct( vecLOS, gpGlobals->v_forward ) <= 0.866 ) // 30 degree slop + if( DotProduct( vecLOS, gpGlobals->v_forward ) <= 0.866f ) // 30 degree slop fAttack = FALSE; else fAttack = TRUE; @@ -642,7 +642,7 @@ void CMiniTurret::Shoot( Vector &vecSrc, Vector &vecDirToEnemy ) void CBaseTurret::Deploy( void ) { - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; StudioFrameAdvance(); if( pev->sequence != TURRET_ANIM_DEPLOY ) @@ -684,7 +684,7 @@ void CBaseTurret::Retire( void ) m_vecGoalAngles.x = 0; m_vecGoalAngles.y = m_flStartYaw; - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; StudioFrameAdvance(); @@ -713,7 +713,7 @@ void CBaseTurret::Retire( void ) if( m_iAutoStart ) { SetThink( &CBaseTurret::AutoSearchThink ); - pev->nextthink = gpGlobals->time + .1; + pev->nextthink = gpGlobals->time + 0.1f; } else SetThink( &CBaseEntity::SUB_DoNothing ); @@ -728,7 +728,7 @@ void CBaseTurret::Retire( void ) void CTurret::SpinUpCall( void ) { StudioFrameAdvance(); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; // Are we already spun up? If not start the two stage process. if( !m_iSpin ) @@ -738,15 +738,15 @@ void CTurret::SpinUpCall( void ) // for the first pass, spin up the the barrel if( !m_iStartSpin ) { - pev->nextthink = gpGlobals->time + 1.0; // spinup delay + pev->nextthink = gpGlobals->time + 1.0f; // spinup delay EMIT_SOUND( ENT( pev ), CHAN_BODY, "turret/tu_spinup.wav", TURRET_MACHINE_VOLUME, ATTN_NORM ); m_iStartSpin = 1; - pev->framerate = 0.1; + pev->framerate = 0.1f; } // after the barrel is spun up, turn on the hum - else if( pev->framerate >= 1.0 ) + else if( pev->framerate >= 1.0f ) { - pev->nextthink = gpGlobals->time + 0.1; // retarget delay + pev->nextthink = gpGlobals->time + 0.1f; // retarget delay EMIT_SOUND( ENT( pev ), CHAN_STATIC, "turret/tu_active2.wav", TURRET_MACHINE_VOLUME, ATTN_NORM ); SetThink( &CBaseTurret::ActiveThink ); m_iStartSpin = 0; @@ -754,7 +754,7 @@ void CTurret::SpinUpCall( void ) } else { - pev->framerate += 0.075; + pev->framerate += 0.075f; } } @@ -769,12 +769,12 @@ void CTurret::SpinDownCall( void ) if( m_iSpin ) { SetTurretAnim( TURRET_ANIM_SPIN ); - if( pev->framerate == 1.0 ) + if( pev->framerate == 1.0f ) { EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, "turret/tu_active2.wav", 0, 0, SND_STOP, 100 ); EMIT_SOUND( ENT( pev ), CHAN_ITEM, "turret/tu_spindown.wav", TURRET_MACHINE_VOLUME, ATTN_NORM ); } - pev->framerate -= 0.02; + pev->framerate -= 0.02f; if( pev->framerate <= 0 ) { pev->framerate = 0; @@ -830,7 +830,7 @@ void CBaseTurret::SearchThink( void ) // ensure rethink SetTurretAnim( TURRET_ANIM_SPIN ); StudioFrameAdvance(); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; if( m_flSpinUpTime == 0 && m_flMaxSpin ) m_flSpinUpTime = gpGlobals->time + m_flMaxSpin; @@ -875,7 +875,7 @@ void CBaseTurret::SearchThink( void ) } // generic hunt for new victims - m_vecGoalAngles.y = ( m_vecGoalAngles.y + 0.1 * m_fTurnRate ); + m_vecGoalAngles.y = ( m_vecGoalAngles.y + 0.1f * m_fTurnRate ); if( m_vecGoalAngles.y >= 360 ) m_vecGoalAngles.y -= 360; MoveTurret(); @@ -890,7 +890,7 @@ void CBaseTurret::AutoSearchThink( void ) { // ensure rethink StudioFrameAdvance(); - pev->nextthink = gpGlobals->time + 0.3; + pev->nextthink = gpGlobals->time + 0.3f; // If we have a target and we're still healthy if( m_hEnemy != 0 ) @@ -918,7 +918,7 @@ void CBaseTurret::TurretDeath( void ) //BOOL iActive = FALSE; StudioFrameAdvance(); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; if( pev->deadflag != DEAD_DEAD ) { @@ -926,9 +926,9 @@ void CBaseTurret::TurretDeath( void ) float flRndSound = RANDOM_FLOAT( 0, 1 ); - if( flRndSound <= 0.33 ) + if( flRndSound <= 0.33f ) EMIT_SOUND( ENT( pev ), CHAN_BODY, "turret/tu_die.wav", 1.0, ATTN_NORM ); - else if( flRndSound <= 0.66 ) + else if( flRndSound <= 0.66f ) EMIT_SOUND( ENT( pev ), CHAN_BODY, "turret/tu_die2.wav", 1.0, ATTN_NORM ); else EMIT_SOUND( ENT( pev ), CHAN_BODY, "turret/tu_die3.wav", 1.0, ATTN_NORM ); @@ -1006,7 +1006,7 @@ int CBaseTurret::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, fl return 0; if( !m_iOn ) - flDamage /= 10.0; + flDamage *= 0.1f; pev->health -= flDamage; if( pev->health <= 0 ) @@ -1020,7 +1020,7 @@ int CBaseTurret::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, fl SetUse( NULL ); SetThink( &CBaseTurret::TurretDeath ); SUB_UseTargets( this, USE_ON, 0 ); // wake up others - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; return 0; } @@ -1046,7 +1046,7 @@ int CBaseTurret::MoveTurret( void ) { float flDir = m_vecGoalAngles.x > m_vecCurAngles.x ? 1 : -1 ; - m_vecCurAngles.x += 0.1 * m_fTurnRate * flDir; + m_vecCurAngles.x += 0.1f * m_fTurnRate * flDir; // if we started below the goal, and now we're past, peg to goal if( flDir == 1 ) @@ -1093,14 +1093,14 @@ int CBaseTurret::MoveTurret( void ) m_fTurnRate += m_iBaseTurnRate; } - m_vecCurAngles.y += 0.1 * m_fTurnRate * flDir; + m_vecCurAngles.y += 0.1f * m_fTurnRate * flDir; if( m_vecCurAngles.y < 0 ) m_vecCurAngles.y += 360; else if( m_vecCurAngles.y >= 360 ) m_vecCurAngles.y -= 360; - if( flDist < ( 0.05 * m_iBaseTurnRate ) ) + if( flDist < ( 0.05f * m_iBaseTurnRate ) ) m_vecCurAngles.y = m_vecGoalAngles.y; //ALERT( at_console, "%.2f -> %.2f\n", m_vecCurAngles.y, y ); @@ -1150,6 +1150,9 @@ void CSentry::Precache() { CBaseTurret::Precache(); PRECACHE_MODEL( "models/sentry.mdl" ); + PRECACHE_SOUND( "weapons/hks1.wav" ); + PRECACHE_SOUND( "weapons/hks2.wav" ); + PRECACHE_SOUND( "weapons/hks3.wav" ); } void CSentry::Spawn() @@ -1170,7 +1173,7 @@ void CSentry::Spawn() SetTouch( &CSentry::SentryTouch ); SetThink( &CBaseTurret::Initialize ); - pev->nextthink = gpGlobals->time + 0.3; + pev->nextthink = gpGlobals->time + 0.3f; } void CSentry::Shoot( Vector &vecSrc, Vector &vecDirToEnemy ) @@ -1201,7 +1204,7 @@ int CSentry::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float { SetThink( &CBaseTurret::Deploy ); SetUse( NULL ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } pev->health -= flDamage; @@ -1216,7 +1219,7 @@ int CSentry::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float SetUse( NULL ); SetThink( &CSentry::SentryDeath ); SUB_UseTargets( this, USE_ON, 0 ); // wake up others - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; return 0; } @@ -1237,7 +1240,7 @@ void CSentry::SentryDeath( void ) //BOOL iActive = FALSE; StudioFrameAdvance(); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; if( pev->deadflag != DEAD_DEAD ) { @@ -1245,9 +1248,9 @@ void CSentry::SentryDeath( void ) float flRndSound = RANDOM_FLOAT( 0, 1 ); - if( flRndSound <= 0.33 ) + if( flRndSound <= 0.33f ) EMIT_SOUND( ENT( pev ), CHAN_BODY, "turret/tu_die.wav", 1.0, ATTN_NORM ); - else if( flRndSound <= 0.66 ) + else if( flRndSound <= 0.66f ) EMIT_SOUND( ENT( pev ), CHAN_BODY, "turret/tu_die2.wav", 1.0, ATTN_NORM ); else EMIT_SOUND( ENT( pev ), CHAN_BODY, "turret/tu_die3.wav", 1.0, ATTN_NORM ); diff --git a/dlls/util.cpp b/dlls/util.cpp index 88329f94..ee30f08f 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -33,8 +33,8 @@ float UTIL_WeaponTimeBase( void ) { -#if defined( CLIENT_WEAPONS ) - return 0.0; +#if CLIENT_WEAPONS + return 0.0f; #else return gpGlobals->time; #endif @@ -130,7 +130,7 @@ float UTIL_SharedRandomFloat( unsigned int seed, float low, float high ) tensixrand = U_Random() & 65535; - offset = (float)tensixrand / 65536.0; + offset = (float)tensixrand / 65536.0f; return ( low + offset * range ); } @@ -147,8 +147,8 @@ void UTIL_ParametricRocket( entvars_t *pev, Vector vecOrigin, Vector vecAngles, // Now compute how long it will take based on current velocity Vector vecTravel = pev->endpos - pev->startpos; - float travelTime = 0.0; - if( pev->velocity.Length() > 0 ) + float travelTime = 0.0f; + if( pev->velocity.Length() > 0.0f ) { travelTime = vecTravel.Length() / pev->velocity.Length(); } @@ -309,7 +309,7 @@ TYPEDESCRIPTION gEntvarsDescription[] = #define ENTVARS_COUNT ( sizeof(gEntvarsDescription) / sizeof(gEntvarsDescription[0]) ) -#ifdef DEBUG +#if DEBUG edict_t *DBG_EntOfVars( const entvars_t *pev ) { if( pev->pContainingEntity != NULL ) @@ -458,7 +458,7 @@ int UTIL_MonstersInSphere( CBaseEntity **pList, int listMax, const Vector ¢e // Use origin for X & Y since they are centered for all monsters // Now X - delta = center.x - pEdict->v.origin.x;//( pEdict->v.absmin.x + pEdict->v.absmax.x ) * 0.5; + delta = center.x - pEdict->v.origin.x;//( pEdict->v.absmin.x + pEdict->v.absmax.x ) * 0.5f; delta *= delta; if( delta > radiusSquared ) @@ -466,7 +466,7 @@ int UTIL_MonstersInSphere( CBaseEntity **pList, int listMax, const Vector ¢e distance = delta; // Now Y - delta = center.y - pEdict->v.origin.y;//( pEdict->v.absmin.y + pEdict->v.absmax.y )*0.5; + delta = center.y - pEdict->v.origin.y;//( pEdict->v.absmin.y + pEdict->v.absmax.y ) * 0.5f; delta *= delta; distance += delta; @@ -474,7 +474,7 @@ int UTIL_MonstersInSphere( CBaseEntity **pList, int listMax, const Vector ¢e continue; // Now Z - delta = center.z - ( pEdict->v.absmin.z + pEdict->v.absmax.z ) * 0.5; + delta = center.z - ( pEdict->v.absmin.z + pEdict->v.absmax.z ) * 0.5f; delta *= delta; distance += delta; @@ -1259,7 +1259,7 @@ void UTIL_DecalTrace( TraceResult *pTrace, int decalNumber ) if( index < 0 ) return; - if( pTrace->flFraction == 1.0 ) + if( pTrace->flFraction == 1.0f ) return; // Only decal BSP models @@ -1363,7 +1363,7 @@ void UTIL_PlayerDecalTrace( TraceResult *pTrace, int playernum, int decalNumber, else index = decalNumber; - if( pTrace->flFraction == 1.0 ) + if( pTrace->flFraction == 1.0f ) return; if( !mp_maxdecals.value ) // even do not send if decals disabled @@ -1427,7 +1427,7 @@ void UTIL_GunshotDecalTrace( TraceResult *pTrace, int decalNumber ) if( index < 0 ) return; - if( pTrace->flFraction == 1.0 ) + if( pTrace->flFraction == 1.0f ) return; if( mp_serverdistclip.value && mp_servercliptents.value ) @@ -1544,7 +1544,7 @@ void UTIL_Ricochet( const Vector &position, float scale ) WRITE_COORD( position.x ); WRITE_COORD( position.y ); WRITE_COORD( position.z ); - WRITE_BYTE( (int)( scale * 10 ) ); + WRITE_BYTE( (int)( scale * 10.0f ) ); MESSAGE_END(); } } @@ -1556,7 +1556,7 @@ void UTIL_Ricochet( const Vector &position, float scale ) WRITE_COORD( position.x ); WRITE_COORD( position.y ); WRITE_COORD( position.z ); - WRITE_BYTE( (int)( scale * 10 ) ); + WRITE_BYTE( (int)( scale * 10.0f ) ); MESSAGE_END(); } } @@ -1674,9 +1674,9 @@ float UTIL_WaterLevel( const Vector &position, float minz, float maxz ) return maxz; float diff = maxz - minz; - while( diff > 1.0 ) + while( diff > 1.0f ) { - midUp.z = minz + diff / 2.0; + midUp.z = minz + diff / 2.0f; if( UTIL_PointContents( midUp ) == CONTENTS_WATER ) { minz = midUp.z; @@ -1695,7 +1695,7 @@ extern DLL_GLOBAL short g_sModelIndexBubbles;// holds the index for the bubbles void UTIL_Bubbles( Vector mins, Vector maxs, int count ) { - Vector mid = ( mins + maxs ) * 0.5; + Vector mid = ( mins + maxs ) * 0.5f; float flHeight = UTIL_WaterLevel( mid, mid.z, mid.z + 1024 ); flHeight = flHeight - mins.z; @@ -1850,7 +1850,7 @@ static int gSizes[FIELD_TYPECOUNT] = sizeof(float) * 3, // FIELD_POSITION_VECTOR sizeof(void *), // FIELD_POINTER sizeof(int), // FIELD_INTEGER -#ifdef GNUC +#if GNUC sizeof(void *) * 2, // FIELD_FUNCTION #else sizeof(void *), // FIELD_FUNCTION @@ -1877,7 +1877,7 @@ static int gInputSizes[FIELD_TYPECOUNT] = sizeof(float) * 3, // FIELD_POSITION_VECTOR sizeof(void *), // FIELD_POINTER sizeof(int), // FIELD_INTEGER -#ifdef GNUC +#if GNUC sizeof(void *) * 2, // FIELD_FUNCTION #else sizeof(void *), // FIELD_FUNCTION @@ -1983,7 +1983,7 @@ void CSaveRestoreBuffer::BufferRewind( int size ) m_pdata->size -= size; } -#ifndef _WIN32 +#if !_WIN32 && !__WATCOMC__ extern "C" { unsigned _rotr( unsigned val, int shift ) { @@ -2094,7 +2094,7 @@ void CSave::WriteTime( const char *pname, const float *data, int count ) void CSave::WriteString( const char *pname, const char *pdata ) { -#ifdef TOKENIZE +#if TOKENIZE short token = (short)TokenHash( pdata ); WriteShort( pname, &token, 1 ); #else @@ -2105,7 +2105,7 @@ void CSave::WriteString( const char *pname, const char *pdata ) void CSave::WriteString( const char *pname, const int *stringId, int count ) { int i, size; -#ifdef TOKENIZE +#if TOKENIZE short token = (short)TokenHash( STRING( *stringId ) ); WriteShort( pname, &token, 1 ); #else @@ -2434,7 +2434,6 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou switch( pTest->fieldType ) { case FIELD_TIME: - memcpy( &timeData, pInputData, 4 ); // Re-base time variables timeData += time; @@ -2468,7 +2467,7 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou pString++; } pInputData = pString; - if( strlen( (char *)pInputData ) == 0 ) + if( ( (char *)pInputData )[0] == '\0' ) *( (string_t *)pOutputData ) = 0; else { @@ -2527,7 +2526,7 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou *( (EOFFSET *)pOutputData ) = 0; break; case FIELD_VECTOR: - #ifdef __VFP_FP__ + #if __VFP_FP__ memcpy( pOutputData, pInputData, sizeof( Vector ) ); #else ( (float *)pOutputData )[0] = ( (float *)pInputData )[0]; @@ -2536,7 +2535,7 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou #endif break; case FIELD_POSITION_VECTOR: - #ifdef __VFP_FP__ + #if __VFP_FP__ { Vector tmp; memcpy( &tmp, pInputData, sizeof( Vector ) ); @@ -2563,7 +2562,7 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou *( (void**)pOutputData ) = *(void **)pInputData; break; case FIELD_FUNCTION: - if( strlen( (char *)pInputData ) == 0 ) + if( ( (char *)pInputData )[0] == '\0' ) *( (void**)pOutputData ) = 0; else *( (void**)pOutputData ) = (void*)FUNCTION_FROM_NAME( (char *)pInputData ); @@ -2675,7 +2674,7 @@ char *CRestore::ReadNamedString( const char *pName ) HEADER header; BufferReadHeader( &header ); -#ifdef TOKENIZE +#if TOKENIZE return (char *)( m_pdata->pTokens[*(short *)header.pData] ); #else return (char *)header.pData; diff --git a/dlls/util.h b/dlls/util.h index c9067516..cf28e18d 100644 --- a/dlls/util.h +++ b/dlls/util.h @@ -13,23 +13,19 @@ * ****/ #pragma once -#ifndef UTIL_H +#if !defined(UTIL_H) #define UTIL_H // // Misc utility code // -#ifndef ACTIVITY_H +#if !defined(ACTIVITY_H) #include "activity.h" #endif -#ifndef ENGINECALLBACK_H +#if !defined(ENGINECALLBACK_H) #include "enginecallback.h" #endif -#ifndef PHYSCALLBACK_H -#include "physcallback.h" -#endif - #include #include inline void MESSAGE_BEGIN( int msg_dest, int msg_type, const float *pOrigin, entvars_t *ent ); // implementation later in this file @@ -38,7 +34,8 @@ extern globalvars_t *gpGlobals; // Use this instead of ALLOC_STRING on constant strings #define STRING(offset) (const char *)(gpGlobals->pStringBase + (int)offset) -#if !defined XASH_64BIT || defined(CLIENT_DLL) + +#if !XASH_64BIT || CLIENT_DLL #define MAKE_STRING(str) ((int)(long int)str - (int)(long int)STRING(0)) #else static inline int MAKE_STRING(const char *szValue) @@ -96,7 +93,7 @@ typedef int EOFFSET; typedef int BOOL; // In case this ever changes -#ifndef M_PI +#if !defined(M_PI) #define M_PI 3.14159265358979323846 #endif // Keeps clutter down a bit, when declaring external entity/global method prototypes @@ -107,7 +104,7 @@ typedef int BOOL; // The _declspec forces them to be exported by name so we can do a lookup with GetProcAddress() // The function is used to intialize / allocate the object for the entity -#if defined(CLIENT_DLL) +#if CLIENT_DLL #define LINK_ENTITY_TO_CLASS(mapClassName,DLLClassName) #else // CLIENT_DLL #define LINK_ENTITY_TO_CLASS(mapClassName,DLLClassName) extern "C" EXPORT void mapClassName( entvars_t *pev ); void mapClassName( entvars_t *pev ) { GetClassPtr( (DLLClassName *)pev ); } @@ -116,7 +113,7 @@ typedef int BOOL; // // Conversion among the three types of "entity", including identity-conversions. // -#ifdef DEBUG +#if DEBUG extern edict_t *DBG_EntOfVars(const entvars_t *pev); inline edict_t *ENT(const entvars_t *pev) { return DBG_EntOfVars(pev); } #else @@ -393,7 +390,7 @@ extern int BuildChangeList( LEVELLIST *pLevelList, int maxList ); // // How did I ever live without ASSERT? // -#ifdef DEBUG +#if DEBUG void DBG_AssertFunction(BOOL fExpr, const char* szExpr, const char* szFile, int szLine, const char* szMessage); #define ASSERT(f) DBG_AssertFunction(f, #f, __FILE__, __LINE__, NULL) #define ASSERTSZ(f, sz) DBG_AssertFunction(f, #f, __FILE__, __LINE__, sz) diff --git a/dlls/vector.h b/dlls/vector.h index 48c707b4..524cdfcf 100644 --- a/dlls/vector.h +++ b/dlls/vector.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef VECTOR_H +#if !defined(VECTOR_H) #define VECTOR_H //========================================================= diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index c21fda00..78da7daf 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -320,7 +320,7 @@ void W_Precache( void ) // 9mm ammo box UTIL_PrecacheOther( "ammo_9mmbox" ); -#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD ) +#if !OEM_BUILD && !HLDEMO_BUILD // python UTIL_PrecacheOtherWeapon( "weapon_357" ); UTIL_PrecacheOther( "ammo_357" ); @@ -342,13 +342,13 @@ void W_Precache( void ) #endif // tripmine UTIL_PrecacheOtherWeapon( "weapon_tripmine" ); -#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD ) +#if !OEM_BUILD && !HLDEMO_BUILD // satchel charge UTIL_PrecacheOtherWeapon( "weapon_satchel" ); #endif // hand grenade UTIL_PrecacheOtherWeapon("weapon_handgrenade"); -#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD ) +#if !OEM_BUILD && !HLDEMO_BUILD // squeak grenade UTIL_PrecacheOtherWeapon( "weapon_snark" ); @@ -413,7 +413,7 @@ IMPLEMENT_SAVERESTORE( CBasePlayerItem, CBaseAnimating ) TYPEDESCRIPTION CBasePlayerWeapon::m_SaveData[] = { -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS DEFINE_FIELD( CBasePlayerWeapon, m_flNextPrimaryAttack, FIELD_FLOAT ), DEFINE_FIELD( CBasePlayerWeapon, m_flNextSecondaryAttack, FIELD_FLOAT ), DEFINE_FIELD( CBasePlayerWeapon, m_flTimeWeaponIdle, FIELD_FLOAT ), @@ -452,7 +452,7 @@ void CBasePlayerItem::FallInit( void ) SetTouch( &CBasePlayerItem::DefaultTouch ); SetThink( &CBasePlayerItem::FallThink ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } //========================================================= @@ -464,7 +464,7 @@ void CBasePlayerItem::FallInit( void ) //========================================================= void CBasePlayerItem::FallThink( void ) { - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; if( pev->flags & FL_ONGROUND ) { @@ -680,7 +680,7 @@ void CBasePlayerItem::DefaultTouch( CBaseEntity *pOther ) BOOL CanAttack( float attack_time, float curtime, BOOL isPredicted ) { -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS if( !isPredicted ) #else if( 1 ) @@ -690,14 +690,12 @@ BOOL CanAttack( float attack_time, float curtime, BOOL isPredicted ) } else { - return ( attack_time <= 0.0 ) ? TRUE : FALSE; + return ( (static_cast(::floor(attack_time * 1000.0f)) * 1000.0f) <= 0.0f) ? TRUE : FALSE; } } void CBasePlayerWeapon::ItemPostFrame( void ) { - WeaponTick(); - if( ( m_fInReload ) && ( m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase() ) ) { // complete the reload. @@ -748,19 +746,19 @@ void CBasePlayerWeapon::ItemPostFrame( void ) // no fire buttons down m_fFireOnEmpty = FALSE; - if( !IsUseable() && m_flNextPrimaryAttack < ( UseDecrement() ? 0.0 : gpGlobals->time ) ) + if( !IsUseable() && m_flNextPrimaryAttack < ( UseDecrement() ? 0.0f : gpGlobals->time ) ) { // weapon isn't useable, switch. if( !( iFlags() & ITEM_FLAG_NOAUTOSWITCHEMPTY ) && g_pGameRules->GetNextBestWeapon( m_pPlayer, this ) ) { - m_flNextPrimaryAttack = ( UseDecrement() ? 0.0 : gpGlobals->time ) + 0.3; + m_flNextPrimaryAttack = ( UseDecrement() ? 0.0f : gpGlobals->time ) + 0.3f; return; } } else { // weapon is useable. Reload if empty and weapon has waited as long as it has to after firing - if( m_iClip == 0 && !(iFlags() & ITEM_FLAG_NOAUTORELOAD ) && m_flNextPrimaryAttack < ( UseDecrement() ? 0.0 : gpGlobals->time ) ) + if( m_iClip == 0 && !(iFlags() & ITEM_FLAG_NOAUTORELOAD ) && m_flNextPrimaryAttack < ( UseDecrement() ? 0.0f : gpGlobals->time ) ) { Reload(); return; @@ -800,14 +798,14 @@ void CBasePlayerItem::Drop( void ) { SetTouch( NULL ); SetThink( &CBaseEntity::SUB_Remove ); - pev->nextthink = gpGlobals->time + .1; + pev->nextthink = gpGlobals->time + 0.1f; } void CBasePlayerItem::Kill( void ) { SetTouch( NULL ); SetThink( &CBaseEntity::SUB_Remove ); - pev->nextthink = gpGlobals->time + .1; + pev->nextthink = gpGlobals->time + 0.1f; } void CBasePlayerItem::Holster( int skiplocal /* = 0 */ ) @@ -917,13 +915,13 @@ int CBasePlayerWeapon::UpdateClientData( CBasePlayer *pPlayer ) void CBasePlayerWeapon::SendWeaponAnim( int iAnim, int skiplocal, int body ) { if( UseDecrement() ) - skiplocal = 1; + skiplocal = !pev->oldbuttons; else skiplocal = 0; m_pPlayer->pev->weaponanim = iAnim; -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS if( skiplocal && ENGINE_CANSKIP( m_pPlayer->edict() ) ) return; #endif @@ -994,16 +992,38 @@ BOOL CBasePlayerWeapon::AddSecondaryAmmo( int iCount, char *szName, int iMax ) //========================================================= BOOL CBasePlayerWeapon::IsUseable( void ) { - if( m_iClip <= 0 ) + if( m_iClip > 0 ) { - if( m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] <= 0 && iMaxAmmo1() != -1 ) + return TRUE; + } + + // Player has unlimited ammo for this weapon or does not use magazines + if( iMaxAmmo1() == WEAPON_NOCLIP ) + { + return TRUE; + } + + if( m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] > 0 ) + { + return TRUE; + } + + if( pszAmmo2() ) + { + // Player has unlimited ammo for this weapon or does not use magazines + if( iMaxAmmo2() == WEAPON_NOCLIP ) { - // clip is empty (or nonexistant) and the player has no more ammo of this type. - return FALSE; + return TRUE; + } + + if( m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()] > 0 ) + { + return TRUE; } } - return TRUE; + // clip is empty (or nonexistant) and the player has no more ammo of this type. + return FALSE; } BOOL CBasePlayerWeapon::CanDeploy( void ) @@ -1047,8 +1067,8 @@ BOOL CBasePlayerWeapon::DefaultDeploy( const char *szViewModel, const char *szWe strcpy( m_pPlayer->m_szAnimExtention, szAnimExt ); SendWeaponAnim( iAnim, skiplocal, body ); - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5f; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0f; m_flLastFireTime = 0.0f; return TRUE; @@ -1071,7 +1091,7 @@ BOOL CBasePlayerWeapon::DefaultReload( int iClipSize, int iAnim, float fDelay, i m_fInReload = TRUE; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3.0f; return TRUE; } @@ -1236,7 +1256,7 @@ void CBasePlayerAmmo::DefaultTouch( CBaseEntity *pOther ) { SetTouch( NULL ); SetThink( &CBaseEntity::SUB_Remove ); - pev->nextthink = gpGlobals->time + .1; + pev->nextthink = gpGlobals->time + 0.1f; } } else if( gEvilImpulse101 ) @@ -1244,7 +1264,7 @@ void CBasePlayerAmmo::DefaultTouch( CBaseEntity *pOther ) // evil impulse 101 hack, kill always SetTouch( NULL ); SetThink( &CBaseEntity::SUB_Remove ); - pev->nextthink = gpGlobals->time + .1; + pev->nextthink = gpGlobals->time + 0.1f; } else { @@ -1269,13 +1289,13 @@ int CBasePlayerWeapon::ExtractAmmo( CBasePlayerWeapon *pWeapon ) { // blindly call with m_iDefaultAmmo. It's either going to be a value or zero. If it is zero, // we only get the ammo in the weapon's clip, which is what we want. - iReturn = pWeapon->AddPrimaryAmmo( m_iDefaultAmmo, (char *)pszAmmo1(), iMaxClip(), iMaxAmmo1() ); + iReturn |= pWeapon->AddPrimaryAmmo( m_iDefaultAmmo, (char *)pszAmmo1(), iMaxClip(), iMaxAmmo1() ); m_iDefaultAmmo = 0; } if( pszAmmo2() != NULL ) { - iReturn = pWeapon->AddSecondaryAmmo( 0, (char *)pszAmmo2(), iMaxAmmo2() ); + iReturn |= pWeapon->AddSecondaryAmmo( 0, (char *)pszAmmo2(), iMaxAmmo2() ); } return iReturn; @@ -1328,7 +1348,7 @@ void CBasePlayerWeapon::RetireWeapon( void ) //========================================================================= float CBasePlayerWeapon::GetNextAttackDelay( float delay ) { - if( m_flLastFireTime == 0 || m_flNextPrimaryAttack == -1 ) + if( m_flLastFireTime == 0 || m_flNextPrimaryAttack == -1.0f ) { // At this point, we are assuming that the client has stopped firing // and we are going to reset our book keeping variables. @@ -1426,7 +1446,7 @@ void CWeaponBox::Kill( void ) while( pWeapon ) { pWeapon->SetThink( &CBaseEntity::SUB_Remove ); - pWeapon->pev->nextthink = gpGlobals->time + 0.1; + pWeapon->pev->nextthink = gpGlobals->time + 0.1f; pWeapon = pWeapon->m_pNext; } } @@ -1724,8 +1744,8 @@ void CWeaponBox::SetObjectCollisionBox( void ) void CBasePlayerWeapon::PrintState( void ) { - ALERT( at_console, "primary: %f\n", m_flNextPrimaryAttack ); - ALERT( at_console, "idle : %f\n", m_flTimeWeaponIdle ); + ALERT( at_console, "primary: %f\n", (double)m_flNextPrimaryAttack ); + ALERT( at_console, "idle : %f\n", (double)m_flTimeWeaponIdle ); //ALERT( at_console, "nextrl : %f\n", m_flNextReload ); //ALERT( at_console, "nextpum: %f\n", m_flPumpTime ); @@ -1757,7 +1777,6 @@ TYPEDESCRIPTION CShotgun::m_SaveData[] = { DEFINE_FIELD( CShotgun, m_flNextReload, FIELD_TIME ), DEFINE_FIELD( CShotgun, m_fInSpecialReload, FIELD_INTEGER ), - DEFINE_FIELD( CShotgun, m_flNextReload, FIELD_TIME ), // DEFINE_FIELD( CShotgun, m_iShell, FIELD_INTEGER ), DEFINE_FIELD( CShotgun, m_flPumpTime, FIELD_TIME ), }; @@ -1792,6 +1811,7 @@ IMPLEMENT_SAVERESTORE( CEgon, CBasePlayerWeapon ) TYPEDESCRIPTION CHgun::m_SaveData[] = { DEFINE_FIELD( CHgun, m_flRechargeTime, FIELD_TIME ), + DEFINE_FIELD( CHgun, m_iFirePhase, FIELD_INTEGER ), }; IMPLEMENT_SAVERESTORE( CHgun, CBasePlayerWeapon ) diff --git a/dlls/weapons.h b/dlls/weapons.h index ebc8203a..32d0ece5 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef WEAPONS_H +#if !defined(WEAPONS_H) #define WEAPONS_H #include "effects.h" @@ -87,8 +87,6 @@ public: #define WEAPON_SUIT 31 // ????? -#define MAX_WEAPONS 32 - #define MAX_NORMAL_BATTERY 100 // weapon weight factors (for auto-switching) (-1 = noswitch) @@ -128,7 +126,6 @@ public: #define GLOCK_MAX_CLIP 17 #define PYTHON_MAX_CLIP 6 #define MP5_MAX_CLIP 50 -#define MP5_DEFAULT_AMMO 25 #define SHOTGUN_MAX_CLIP 8 #define CROSSBOW_MAX_CLIP 5 #define RPG_MAX_CLIP 1 @@ -144,7 +141,6 @@ public: #define GLOCK_DEFAULT_GIVE 17 #define PYTHON_DEFAULT_GIVE 6 #define MP5_DEFAULT_GIVE 25 -#define MP5_DEFAULT_AMMO 25 #define MP5_M203_DEFAULT_GIVE 0 #define SHOTGUN_DEFAULT_GIVE 12 #define CROSSBOW_DEFAULT_GIVE 5 @@ -331,7 +327,6 @@ public: virtual void PrimaryAttack( void ) { return; } // do "+ATTACK" virtual void SecondaryAttack( void ) { return; } // do "+ATTACK2" virtual void Reload( void ) { return; } // do "+RELOAD" - virtual void WeaponTick() {} // Always called at beginning of ItemPostFrame. - Solokiller virtual void WeaponIdle( void ) { return; } // called when no buttons pressed virtual int UpdateClientData( CBasePlayer *pPlayer ); // sends hud info to client dll, if things have changed virtual void RetireWeapon( void ); @@ -487,7 +482,7 @@ public: int ObjectCaps( void ) { return ( CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION ) | FCAP_DONT_SAVE; } }; -#ifdef CLIENT_DLL +#if CLIENT_DLL bool bIsMultiplayer ( void ); void LoadVModel ( const char *szViewModel, CBasePlayer *m_pPlayer ); #endif @@ -510,7 +505,7 @@ public: virtual BOOL UseDecrement( void ) { -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS return TRUE; #else return FALSE; @@ -539,7 +534,7 @@ public: int Swing( int fFirst ); BOOL Deploy( void ); void Holster( int skiplocal = 0 ); -#ifdef CROWBAR_IDLE_ANIM +#if CROWBAR_IDLE_ANIM void WeaponIdle(); #endif int m_iSwing; @@ -547,7 +542,7 @@ public: virtual BOOL UseDecrement( void ) { -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS return TRUE; #else return FALSE; @@ -577,7 +572,7 @@ public: virtual BOOL UseDecrement( void ) { -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS return TRUE; #else return FALSE; @@ -603,13 +598,12 @@ public: BOOL Deploy( void ); void Reload( void ); void WeaponIdle( void ); - BOOL IsUseable(); float m_flNextAnimTime; int m_iShell; virtual BOOL UseDecrement( void ) { -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS return TRUE; #else return FALSE; @@ -643,7 +637,7 @@ public: virtual BOOL UseDecrement( void ) { -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS return TRUE; #else return FALSE; @@ -659,7 +653,7 @@ private: class CShotgun : public CBasePlayerWeapon { public: -#ifndef CLIENT_DLL +#if !CLIENT_DLL int Save( CSave &save ); int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; @@ -674,15 +668,15 @@ public: void SecondaryAttack( void ); BOOL Deploy( ); void Reload( void ); - void WeaponTick(); void WeaponIdle( void ); + void ItemPostFrame( void ); int m_fInReload; float m_flNextReload; int m_iShell; virtual BOOL UseDecrement( void ) { -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS return TRUE; #else return FALSE; @@ -711,7 +705,7 @@ public: class CRpg : public CBasePlayerWeapon { public: -#ifndef CLIENT_DLL +#if !CLIENT_DLL int Save( CSave &save ); int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; @@ -740,7 +734,7 @@ public: virtual BOOL UseDecrement( void ) { -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS return TRUE; #else return FALSE; @@ -783,7 +777,7 @@ public: class CGauss : public CBasePlayerWeapon { public: -#ifndef CLIENT_DLL +#if !CLIENT_DLL int Save( CSave &save ); int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; @@ -793,7 +787,7 @@ public: int iItemSlot( void ) { return 4; } int GetItemInfo(ItemInfo *p); int AddToPlayer( CBasePlayer *pPlayer ); - BOOL IsUseable(); + BOOL Deploy( void ); void Holster( int skiplocal = 0 ); @@ -815,7 +809,7 @@ public: virtual BOOL UseDecrement( void ) { -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS return TRUE; #else return FALSE; @@ -830,7 +824,7 @@ private: class CEgon : public CBasePlayerWeapon { public: -#ifndef CLIENT_DLL +#if !CLIENT_DLL int Save( CSave &save ); int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; @@ -873,7 +867,7 @@ public: virtual BOOL UseDecrement( void ) { -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS return TRUE; #else return FALSE; @@ -883,7 +877,7 @@ public: unsigned short m_usEgonStop; private: -#ifndef CLIENT_DLL +#if !CLIENT_DLL float m_shootTime; #endif EGON_FIREMODE m_fireMode; @@ -896,7 +890,7 @@ private: class CHgun : public CBasePlayerWeapon { public: -#ifndef CLIENT_DLL +#if !CLIENT_DLL int Save( CSave &save ); int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; @@ -918,11 +912,11 @@ public: float m_flRechargeTime; - int m_iFirePhase;// don't save me. + int m_iFirePhase; virtual BOOL UseDecrement( void ) { -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS return TRUE; #else return FALSE; @@ -948,7 +942,7 @@ public: virtual BOOL UseDecrement( void ) { -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS return TRUE; #else return FALSE; @@ -959,7 +953,7 @@ public: class CSatchel : public CBasePlayerWeapon { public: -#ifndef CLIENT_DLL +#if !CLIENT_DLL int Save( CSave &save ); int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; @@ -982,7 +976,7 @@ public: virtual BOOL UseDecrement( void ) { -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS return TRUE; #else return FALSE; @@ -1011,7 +1005,7 @@ public: virtual BOOL UseDecrement( void ) { -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS return TRUE; #else return FALSE; @@ -1039,7 +1033,7 @@ public: virtual BOOL UseDecrement( void ) { -#if defined( CLIENT_WEAPONS ) +#if CLIENT_WEAPONS return TRUE; #else return FALSE; diff --git a/dlls/world.cpp b/dlls/world.cpp index 40da1a68..ec4676c8 100644 --- a/dlls/world.cpp +++ b/dlls/world.cpp @@ -160,7 +160,7 @@ void CDecal::TriggerDecal( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY MESSAGE_END(); SetThink( &CBaseEntity::SUB_Remove ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } void CDecal::StaticDecal( void ) @@ -293,7 +293,7 @@ globalentity_t *CGlobalState::Find( string_t globalname ) } // This is available all the time now on impulse 104, remove later -//#ifdef _DEBUG +//#if _DEBUG void CGlobalState::DumpGlobals( void ) { static const char *estates[] = { "Off", "On", "Dead" }; @@ -454,7 +454,6 @@ LINK_ENTITY_TO_CLASS( worldspawn, CWorld ) #define SF_WORLD_FORCETEAM 0x0004 // Force teams extern DLL_GLOBAL BOOL g_fGameOver; -float g_flWeaponCheat; void CWorld::Spawn( void ) { @@ -630,15 +629,15 @@ void CWorld::Precache( void ) pEntity->SetThink( &CBaseEntity::SUB_CallUseToggle ); pEntity->pev->message = pev->netname; pev->netname = 0; - pEntity->pev->nextthink = gpGlobals->time + 0.3; + pEntity->pev->nextthink = gpGlobals->time + 0.3f; pEntity->pev->spawnflags = SF_MESSAGE_ONCE; } } if( pev->spawnflags & SF_WORLD_DARK ) - CVAR_SET_FLOAT( "v_dark", 1.0 ); + CVAR_SET_FLOAT( "v_dark", 1.0f ); else - CVAR_SET_FLOAT( "v_dark", 0.0 ); + CVAR_SET_FLOAT( "v_dark", 0.0f ); pev->spawnflags &= ~SF_WORLD_DARK; // g-cont. don't apply fade after save\restore @@ -651,15 +650,12 @@ void CWorld::Precache( void ) if( pev->spawnflags & SF_WORLD_FORCETEAM ) { - CVAR_SET_FLOAT( "mp_defaultteam", 1 ); + CVAR_SET_FLOAT( "mp_defaultteam", 1.0f ); } else { - CVAR_SET_FLOAT( "mp_defaultteam", 0 ); + CVAR_SET_FLOAT( "mp_defaultteam", 0.0f ); } - - // g-cont. moved here so cheats will working on restore level - g_flWeaponCheat = CVAR_GET_FLOAT( "sv_cheats" ); // Is the impulse 101 command allowed? } // @@ -681,7 +677,7 @@ void CWorld::KeyValue( KeyValueData *pkvd ) else if( FStrEq(pkvd->szKeyName, "WaveHeight" ) ) { // Sent over net now. - pev->scale = atof( pkvd->szValue ) * ( 1.0 / 8.0 ); + pev->scale = atof( pkvd->szValue ) * ( 1.0f / 8.0f ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "MaxRange" ) ) @@ -893,3 +889,4 @@ int Server_GetPhysicsInterface( int iVersion, server_physics_api_t *pfuncsFromEn gPhysicsInterfaceInitialized = TRUE; return TRUE; } + diff --git a/dlls/wscript b/dlls/wscript index 05a7d002..33d37185 100644 --- a/dlls/wscript +++ b/dlls/wscript @@ -4,69 +4,164 @@ from waflib import Utils import os - + def options(opt): # stub return def configure(conf): - # stub - return + if conf.env.COMPILER_CC == 'msvc': + # hl.def removes MSVC function name decoration from GiveFnptrsToDll on Windows. + # Without this, the lookup for this function fails. + hlDefNode = conf.path.find_resource("./hl.def") + + if hlDefNode is not None: + conf.env.append_unique('LINKFLAGS', '/def:%s' % hlDefNode.abspath()) + else: + conf.fatal("Could not find hl.def") def build(bld): - defines = [] source = bld.path.parent.ant_glob([ 'pm_shared/*.c', ]) - + source += [ - 'agrunt.cpp', 'airtank.cpp', 'aflock.cpp', 'animating.cpp', 'animation.cpp', 'apache.cpp', - 'barnacle.cpp', 'barney.cpp', 'bigmomma.cpp', 'bloater.cpp', 'bmodels.cpp', 'bullsquid.cpp', 'buttons.cpp', - 'cbase.cpp', 'client.cpp', 'combat.cpp', 'controller.cpp', 'crossbow.cpp', 'crowbar.cpp', - 'defaultai.cpp', 'doors.cpp', - 'effects.cpp', 'egon.cpp', 'explode.cpp', - 'flyingmonster.cpp', 'func_break.cpp', 'func_tank.cpp', - 'game.cpp', 'gamerules.cpp', 'gargantua.cpp', 'gauss.cpp', 'genericmonster.cpp', 'ggrenade.cpp', 'globals.cpp', 'glock.cpp', 'gman.cpp', - 'h_ai.cpp', 'h_battery.cpp', 'h_cine.cpp', 'h_cycler.cpp', 'h_export.cpp', 'handgrenade.cpp', 'hassassin.cpp', 'headcrab.cpp', - 'healthkit.cpp', 'hgrunt.cpp', 'hornet.cpp', 'hornetgun.cpp', 'houndeye.cpp', - 'ichthyosaur.cpp', 'islave.cpp', 'items.cpp', - 'leech.cpp', 'lights.cpp', - 'maprules.cpp', 'monstermaker.cpp', 'monsters.cpp', 'monsterstate.cpp', 'mortar.cpp', 'mp5.cpp', 'multiplay_gamerules.cpp', - 'nihilanth.cpp', 'nodes.cpp', - 'observer.cpp', 'osprey.cpp', - 'pathcorner.cpp', 'plane.cpp', 'plats.cpp', 'player.cpp', 'playermonster.cpp', 'python.cpp', - 'rat.cpp', 'roach.cpp', 'rpg.cpp', - 'satchel.cpp', 'schedule.cpp', 'scientist.cpp', 'scripted.cpp', 'shotgun.cpp', 'singleplay_gamerules.cpp', 'skill.cpp', - 'sound.cpp', 'soundent.cpp', 'spectator.cpp', 'squadmonster.cpp', 'squeakgrenade.cpp', 'subs.cpp', - 'talkmonster.cpp', 'teamplay_gamerules.cpp', 'tempmonster.cpp', 'tentacle.cpp', - 'triggers.cpp', 'tripmine.cpp', 'turret.cpp', + 'agrunt.cpp', + 'airtank.cpp', + 'aflock.cpp', + 'animating.cpp', + 'animation.cpp', + 'apache.cpp', + 'barnacle.cpp', + 'barney.cpp', + 'bigmomma.cpp', + 'bloater.cpp', + 'bmodels.cpp', + 'bullsquid.cpp', + 'buttons.cpp', + 'cbase.cpp', + 'client.cpp', + 'combat.cpp', + 'controller.cpp', + 'crossbow.cpp', + 'crowbar.cpp', + 'defaultai.cpp', + 'doors.cpp', + 'effects.cpp', + 'egon.cpp', + 'explode.cpp', + 'flyingmonster.cpp', + 'func_break.cpp', + 'func_tank.cpp', + 'game.cpp', + 'gamerules.cpp', + 'gargantua.cpp', + 'gauss.cpp', + 'genericmonster.cpp', + 'ggrenade.cpp', + 'globals.cpp', + 'glock.cpp', + 'gman.cpp', + 'h_ai.cpp', + 'h_battery.cpp', + 'h_cine.cpp', + 'h_cycler.cpp', + 'h_export.cpp', + 'handgrenade.cpp', + 'hassassin.cpp', + 'headcrab.cpp', + 'healthkit.cpp', + 'hgrunt.cpp', + 'hornet.cpp', + 'hornetgun.cpp', + 'houndeye.cpp', + 'ichthyosaur.cpp', + 'islave.cpp', + 'items.cpp', + 'leech.cpp', + 'lights.cpp', + 'maprules.cpp', + 'monstermaker.cpp', + 'monsters.cpp', + 'monsterstate.cpp', + 'mortar.cpp', + 'mp5.cpp', + 'multiplay_gamerules.cpp', + 'nihilanth.cpp', + 'nodes.cpp', + 'observer.cpp', + 'osprey.cpp', + 'pathcorner.cpp', + 'plane.cpp', + 'plats.cpp', + 'player.cpp', + 'playermonster.cpp', + 'python.cpp', + 'rat.cpp', + 'roach.cpp', + 'rpg.cpp', + 'satchel.cpp', + 'schedule.cpp', + 'scientist.cpp', + 'scripted.cpp', + 'shotgun.cpp', + 'singleplay_gamerules.cpp', + 'skill.cpp', + 'sound.cpp', + 'soundent.cpp', + 'spectator.cpp', + 'squadmonster.cpp', + 'squeakgrenade.cpp', + 'subs.cpp', + 'talkmonster.cpp', + 'teamplay_gamerules.cpp', + 'tempmonster.cpp', + 'tentacle.cpp', + 'triggers.cpp', + 'tripmine.cpp', + 'turret.cpp', 'util.cpp', - 'weapons.cpp', 'world.cpp', 'xen.cpp', 'zombie.cpp'] - + 'weapons.cpp', + 'world.cpp', + 'xen.cpp', + 'zombie.cpp' + ] + + includes = [ + '.', + '../common', + '../engine', + '../pm_shared', + '../game_shared', + '../public' + ] + + defines = [] + if bld.env.VOICEMGR: source += bld.path.parent.ant_glob([ - 'game_shared/voice_gamemgr.cpp', + 'game_shared/voice_gamemgr.cpp', ]) else: defines += ['NO_VOICEGAMEMGR'] - includes = Utils.to_list('. wpn_shared ../common ../engine ../pm_shared ../game_shared ../public') - libs = [] - if bld.env.DEST_OS2 not in ['android']: + if bld.env.DEST_OS not in ['android', 'dos']: install_path = os.path.join(bld.env.GAMEDIR, bld.env.SERVER_DIR) else: install_path = bld.env.PREFIX bld.shlib( source = source, - target = 'server', + target = bld.env.SERVER_NAME + bld.env.POSTFIX, + name = 'server', features = 'c cxx', includes = includes, defines = defines, use = libs, install_path = install_path, subsystem = bld.env.MSVC_SUBSYSTEM, - idx = 2 + idx = bld.get_taskgen_count() ) + diff --git a/dlls/xen.cpp b/dlls/xen.cpp index fb7107a0..d0ab9990 100644 --- a/dlls/xen.cpp +++ b/dlls/xen.cpp @@ -94,10 +94,10 @@ void CXenPLight::Spawn( void ) UTIL_SetSize( pev, Vector( -80, -80, 0 ), Vector( 80, 80, 32 ) ); SetActivity( ACT_IDLE ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; pev->frame = RANDOM_FLOAT( 0, 255 ); - m_pGlow = CSprite::SpriteCreate( XEN_PLANT_GLOW_SPRITE, pev->origin + Vector(0,0,(pev->mins.z+pev->maxs.z)*0.5), FALSE ); + m_pGlow = CSprite::SpriteCreate( XEN_PLANT_GLOW_SPRITE, pev->origin + Vector( 0, 0, ( pev->mins.z + pev->maxs.z ) * 0.5f ), FALSE ); m_pGlow->SetTransparency( kRenderGlow, (int)pev->rendercolor.x, (int)pev->rendercolor.y, (int)pev->rendercolor.z, (int)pev->renderamt, (int)pev->renderfx ); m_pGlow->SetAttachment( edict(), 1 ); } @@ -111,7 +111,7 @@ void CXenPLight::Precache( void ) void CXenPLight::Think( void ) { StudioFrameAdvance(); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; switch( GetActivity() ) { @@ -187,19 +187,19 @@ void CXenHair::Spawn( void ) if( !( pev->spawnflags & SF_HAIR_SYNC ) ) { pev->frame = RANDOM_FLOAT( 0, 255 ); - pev->framerate = RANDOM_FLOAT( 0.7, 1.4 ); + pev->framerate = RANDOM_FLOAT( 0.7f, 1.4f ); } ResetSequenceInfo(); pev->solid = SOLID_NOT; pev->movetype = MOVETYPE_NONE; - pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 0.1, 0.4 ); // Load balance these a bit + pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 0.1f, 0.4f ); // Load balance these a bit } void CXenHair::Think( void ) { StudioFrameAdvance(); - pev->nextthink = gpGlobals->time + 0.5; + pev->nextthink = gpGlobals->time + 0.5f; } void CXenHair::Precache( void ) @@ -288,9 +288,9 @@ void CXenTree::Spawn( void ) UTIL_SetSize( pev, Vector( -30, -30, 0 ), Vector( 30, 30, 188 ) ); SetActivity( ACT_IDLE ); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; pev->frame = RANDOM_FLOAT( 0, 255 ); - pev->framerate = RANDOM_FLOAT( 0.7, 1.4 ); + pev->framerate = RANDOM_FLOAT( 0.7f, 1.4f ); Vector triggerPosition; UTIL_MakeVectorsPrivate( pev->angles, triggerPosition, NULL, NULL ); @@ -334,7 +334,7 @@ void CXenTree::Attack( void ) if( GetActivity() == ACT_IDLE ) { SetActivity( ACT_MELEE_ATTACK1 ); - pev->framerate = RANDOM_FLOAT( 1.0, 1.4 ); + pev->framerate = RANDOM_FLOAT( 1.0f, 1.4f ); EMIT_SOUND_ARRAY_DYN( CHAN_WEAPON, pAttackMissSounds ); } } @@ -380,7 +380,7 @@ void CXenTree::HandleAnimEvent( MonsterEvent_t *pEvent ) void CXenTree::Think( void ) { float flInterval = StudioFrameAdvance(); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; DispatchAnimEvents( flInterval ); switch( GetActivity() ) @@ -389,7 +389,7 @@ void CXenTree::Think( void ) if( m_fSequenceFinished ) { SetActivity( ACT_IDLE ); - pev->framerate = RANDOM_FLOAT( 0.6, 1.4 ); + pev->framerate = RANDOM_FLOAT( 0.6f, 1.4f ); } break; default: @@ -518,9 +518,9 @@ void CXenSpore :: Spawn( void ) //SetActivity( ACT_IDLE ); pev->sequence = 0; pev->frame = RANDOM_FLOAT( 0, 255 ); - pev->framerate = RANDOM_FLOAT( 0.7, 1.4 ); + pev->framerate = RANDOM_FLOAT( 0.7f, 1.4f ); ResetSequenceInfo(); - pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 0.1, 0.4 ); // Load balance these a bit + pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 0.1f, 0.4f ); // Load balance these a bit } const char *CXenSpore::pModelNames[] = @@ -542,7 +542,7 @@ void CXenSpore::Touch( CBaseEntity *pOther ) void CXenSpore::Think( void ) { StudioFrameAdvance(); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; #if 0 DispatchAnimEvents( flInterval ); diff --git a/dlls/zombie.cpp b/dlls/zombie.cpp index 96f032e6..b44dba38 100644 --- a/dlls/zombie.cpp +++ b/dlls/zombie.cpp @@ -136,11 +136,11 @@ int CZombie::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float // Take 30% damage from bullets if( bitsDamageType == DMG_BULLET ) { - Vector vecDir = pev->origin - (pevInflictor->absmin + pevInflictor->absmax) * 0.5; + Vector vecDir = pev->origin - ( pevInflictor->absmin + pevInflictor->absmax ) * 0.5f; vecDir = vecDir.Normalize(); float flForce = DamageForce( flDamage ); pev->velocity = pev->velocity + vecDir * flForce; - flDamage *= 0.3; + flDamage *= 0.3f; } // HACK HACK -- until we fix this. @@ -154,14 +154,14 @@ void CZombie::PainSound( void ) int pitch = 95 + RANDOM_LONG( 0, 9 ); if( RANDOM_LONG( 0, 5 ) < 2 ) - EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pPainSounds[RANDOM_LONG( 0, ARRAYSIZE( pPainSounds ) - 1 )], 1.0, ATTN_NORM, 0, pitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, RANDOM_SOUND_ARRAY( pPainSounds ), 1.0, ATTN_NORM, 0, pitch ); } void CZombie::AlertSound( void ) { int pitch = 95 + RANDOM_LONG( 0, 9 ); - EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pAlertSounds[ RANDOM_LONG( 0, ARRAYSIZE( pAlertSounds ) - 1 )], 1.0, ATTN_NORM, 0, pitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, RANDOM_SOUND_ARRAY( pAlertSounds ), 1.0, ATTN_NORM, 0, pitch ); } void CZombie::IdleSound( void ) @@ -169,7 +169,7 @@ void CZombie::IdleSound( void ) int pitch = 95 + RANDOM_LONG( 0, 9 ); // Play a random idle sound - EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pIdleSounds[RANDOM_LONG( 0, ARRAYSIZE( pIdleSounds ) -1 )], 1.0, ATTN_NORM, 0, pitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, RANDOM_SOUND_ARRAY( pIdleSounds ), 1.0, ATTN_NORM, 0, pitch ); } void CZombie::AttackSound( void ) @@ -177,7 +177,7 @@ void CZombie::AttackSound( void ) int pitch = 95 + RANDOM_LONG( 0, 9 ); // Play a random attack sound - EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pAttackSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackSounds ) - 1 )], 1.0, ATTN_NORM, 0, pitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, RANDOM_SOUND_ARRAY( pAttackSounds ), 1.0, ATTN_NORM, 0, pitch ); } //========================================================= @@ -202,10 +202,10 @@ void CZombie::HandleAnimEvent( MonsterEvent_t *pEvent ) pHurt->pev->velocity = pHurt->pev->velocity - gpGlobals->v_right * 100; } // Play a random attack hit sound - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackHitSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackHitSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5 , 5 ) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackHitSounds ), 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5 , 5 ) ); } else // Play a random attack miss sound - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackMissSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackMissSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackMissSounds ), 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); if( RANDOM_LONG( 0, 1 ) ) AttackSound(); @@ -224,10 +224,10 @@ void CZombie::HandleAnimEvent( MonsterEvent_t *pEvent ) pHurt->pev->punchangle.x = 5; pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_right * 100; } - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackHitSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackHitSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackHitSounds ), 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); } else - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackMissSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackMissSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackMissSounds ), 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); if( RANDOM_LONG( 0, 1 ) ) AttackSound(); @@ -244,10 +244,10 @@ void CZombie::HandleAnimEvent( MonsterEvent_t *pEvent ) pHurt->pev->punchangle.x = 5; pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_forward * -100; } - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackHitSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackHitSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackHitSounds ), 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); } else - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackMissSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackMissSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackMissSounds ), 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); if( RANDOM_LONG( 0, 1 ) ) AttackSound(); @@ -286,27 +286,14 @@ void CZombie::Spawn() //========================================================= void CZombie::Precache() { - size_t i; - PRECACHE_MODEL( "models/zombie.mdl" ); - for( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) - PRECACHE_SOUND( pAttackHitSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) - PRECACHE_SOUND( pAttackMissSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) - PRECACHE_SOUND( pAttackSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pIdleSounds ); i++ ) - PRECACHE_SOUND( pIdleSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) - PRECACHE_SOUND( pAlertSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) - PRECACHE_SOUND( pPainSounds[i] ); + PRECACHE_SOUND_ARRAY( pAttackHitSounds ); + PRECACHE_SOUND_ARRAY( pAttackMissSounds ); + PRECACHE_SOUND_ARRAY( pAttackSounds ); + PRECACHE_SOUND_ARRAY( pIdleSounds ); + PRECACHE_SOUND_ARRAY( pAlertSounds ); + PRECACHE_SOUND_ARRAY( pPainSounds ); } //========================================================= diff --git a/engine/cdll_exp.h b/engine/cdll_exp.h deleted file mode 100644 index e4c1f5d8..00000000 --- a/engine/cdll_exp.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -cdll_exp.h - exports for client -Copyright (C) 2013 Uncle Mike - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -*/ -#pragma once -#ifndef CDLL_EXP_H -#define CDLL_EXP_H - -// NOTE: ordering is important! -typedef struct cldll_func_s -{ - int (*pfnInitialize)( cl_enginefunc_t *pEnginefuncs, int iVersion ); - void (*pfnInit)( void ); - int (*pfnVidInit)( void ); - int (*pfnRedraw)( float flTime, int intermission ); - int (*pfnUpdateClientData)( client_data_t *cdata, float flTime ); - void (*pfnReset)( void ); - void (*pfnPlayerMove)( struct playermove_s *ppmove, int server ); - void (*pfnPlayerMoveInit)( struct playermove_s *ppmove ); - char (*pfnPlayerMoveTexture)( char *name ); - void (*IN_ActivateMouse)( void ); - void (*IN_DeactivateMouse)( void ); - void (*IN_MouseEvent)( int mstate ); - void (*IN_ClearStates)( void ); - void (*IN_Accumulate)( void ); - void (*CL_CreateMove)( float frametime, struct usercmd_s *cmd, int active ); - int (*CL_IsThirdPerson)( void ); - void (*CL_CameraOffset)( float *ofs ); - void *(*KB_Find)( const char *name ); - void (*CAM_Think)( void ); // camera stuff - void (*pfnCalcRefdef)( ref_params_t *pparams ); - int (*pfnAddEntity)( int type, cl_entity_t *ent, const char *modelname ); - void (*pfnCreateEntities)( void ); - void (*pfnDrawNormalTriangles)( void ); - void (*pfnDrawTransparentTriangles)( void ); - void (*pfnStudioEvent)( const struct mstudioevent_s *event, const cl_entity_t *entity ); - void (*pfnPostRunCmd)( struct local_state_s *from, struct local_state_s *to, usercmd_t *cmd, int runfuncs, double time, unsigned int random_seed ); - void (*pfnShutdown)( void ); - void (*pfnTxferLocalOverrides)( entity_state_t *state, const clientdata_t *client ); - void (*pfnProcessPlayerState)( entity_state_t *dst, const entity_state_t *src ); - void (*pfnTxferPredictionData)( entity_state_t *ps, const entity_state_t *pps, clientdata_t *pcd, const clientdata_t *ppcd, weapon_data_t *wd, const weapon_data_t *pwd ); - void (*pfnDemo_ReadBuffer)( int size, byte *buffer ); - int (*pfnConnectionlessPacket)( const struct netadr_s *net_from, const char *args, char *buffer, int *size ); - int (*pfnGetHullBounds)( int hullnumber, float *mins, float *maxs ); - void (*pfnFrame)( double time ); - int (*pfnKey_Event)( int eventcode, int keynum, const char *pszCurrentBinding ); - void (*pfnTempEntUpdate)( double frametime, double client_time, double cl_gravity, struct tempent_s **ppTempEntFree, struct tempent_s **ppTempEntActive, int ( *Callback_AddVisibleEntity )( cl_entity_t *pEntity ), void ( *Callback_TempEntPlaySound )( struct tempent_s *pTemp, float damp )); - cl_entity_t *(*pfnGetUserEntity)( int index ); - void (*pfnVoiceStatus)( int entindex, qboolean bTalking ); - void (*pfnDirectorMessage)( int iSize, void *pbuf ); - int (*pfnGetStudioModelInterface)( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio ); - void (*pfnChatInputPosition)( int *x, int *y ); - int (*pfnGetPlayerTeam)( int playerIndex ); - void *(*pfnGetClientFactory)( void ); - // Xash3D extension - int (*pfnGetRenderInterface)( int version, render_api_t *renderfuncs, render_interface_t *callback ); - void (*pfnClipMoveToEntity)( struct physent_s *pe, const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, struct pmtrace_s *tr ); -} cldll_func_t; - -#endif//CDLL_EXP_H diff --git a/engine/cdll_int.h b/engine/cdll_int.h index 8ab903b0..64620497 100644 --- a/engine/cdll_int.h +++ b/engine/cdll_int.h @@ -19,10 +19,10 @@ // JOHN: client dll interface declarations // #pragma once -#ifndef CDLL_INT_H +#if !defined(CDLL_INT_H) #define CDLL_INT_H -#ifdef __cplusplus +#if __cplusplus extern "C" { #endif @@ -303,11 +303,14 @@ typedef struct cl_enginefuncs_s int (*pfnGetAppID)( void ); cmdalias_t *(*pfnGetAliases)( void ); void (*pfnVguiWrap2_GetMouseDelta)( int *x, int *y ); + + // added in 2019 update, not documented yet + int (*pfnFilteredClientCmd)( const char *cmd ); } cl_enginefunc_t; #define CLDLL_INTERFACE_VERSION 7 -#ifdef __cplusplus +#if __cplusplus } #endif diff --git a/engine/custom.h b/engine/custom.h index 02aa2089..6bfd27c7 100644 --- a/engine/custom.h +++ b/engine/custom.h @@ -13,11 +13,13 @@ * ****/ #pragma once -#ifndef CUSTOM_H +#if !defined(CUSTOM_H) #define CUSTOM_H #include "const.h" +#define MAX_QPATH 64 // Must match value in quakedefs.h + ///////////////// // Customization // passed to pfnPlayerCustomization diff --git a/engine/customentity.h b/engine/customentity.h index f524ae79..fb4c1055 100644 --- a/engine/customentity.h +++ b/engine/customentity.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef CUSTOMENTITY_H +#if !defined(CUSTOMENTITY_H) #define CUSTOMENTITY_H // Custom Entities diff --git a/engine/edict.h b/engine/edict.h index 8584a0d9..beae7d7b 100644 --- a/engine/edict.h +++ b/engine/edict.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef EDICT_H +#if !defined(EDICT_H) #define EDICT_H #define MAX_ENT_LEAFS 48 diff --git a/engine/eiface.h b/engine/eiface.h index 6a5f86fc..2863319e 100644 --- a/engine/eiface.h +++ b/engine/eiface.h @@ -13,10 +13,10 @@ * ****/ #pragma once -#ifndef EIFACE_H +#if !defined(EIFACE_H) #define EIFACE_H -#ifdef HLDEMO_BUILD +#if HLDEMO_BUILD #define INTERFACE_VERSION 001 #else // !HLDEMO_BUILD, i.e., regular version of HL #define INTERFACE_VERSION 140 @@ -268,6 +268,9 @@ typedef struct enginefuncs_s void (*pfnQueryClientCvarValue)( const edict_t *player, const char *cvarName ); void (*pfnQueryClientCvarValue2)( const edict_t *player, const char *cvarName, int requestID ); int (*CheckParm)( char *parm, char **ppnext ); + + // added in 8279 + edict_t* (*pfnPEntityOfEntIndexAllEntities)( int iEntIndex ); } enginefuncs_t; // ONLY ADD NEW FUNCTIONS TO THE END OF THIS STRUCT. INTERFACE VERSION IS FROZEN AT 138 @@ -355,7 +358,7 @@ typedef enum _fieldtypes FIELD_TYPECOUNT // MUST BE LAST } FIELDTYPE; -#if !defined(offsetof) && !defined(__GNUC__) +#if !defined(offsetof) && !__GNUC__ #define offsetof(s,m) (size_t)&(((s *)0)->m) #endif @@ -380,7 +383,7 @@ typedef struct short flags; } TYPEDESCRIPTION; -#ifndef ARRAYSIZE +#if !defined(ARRAYSIZE) #define ARRAYSIZE(p) (sizeof(p)/sizeof(p[0])) #endif diff --git a/engine/engine.dsp b/engine/engine.dsp deleted file mode 100644 index b79d1bfe..00000000 --- a/engine/engine.dsp +++ /dev/null @@ -1,621 +0,0 @@ -# Microsoft Developer Studio Project File - Name="engine" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Application" 0x0101 - -CFG=engine - Win32 Release -!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 "engine.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 "engine.mak" CFG="engine - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "engine - Win32 Release" (based on "Win32 (x86) Application") -!MESSAGE "engine - Win32 Debug" (based on "Win32 (x86) Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "engine - 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 "..\temp\engine\!release" -# PROP Intermediate_Dir "..\temp\engine\!release" -# PROP Ignore_Export_Lib 1 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "./" /I "common" /I "common/imagelib" /I "common/soundlib" /I "server" /I "client" /I "client/vgui" /I "../common" /I "../game_shared" /I "../pm_shared" /I "../utils/vgui/include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c -# SUBTRACT CPP /Fr /YX -# ADD BASE MTL /nologo /D "NDEBUG" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /opt:nowin98 -# ADD LINK32 msvcrt.lib user32.lib gdi32.lib shell32.lib advapi32.lib winmm.lib mpeg.lib ../utils/vgui/lib/win32_vc6/vgui.lib /nologo /subsystem:windows /dll /pdb:none /machine:I386 /nodefaultlib:"libc" /out:"..\temp\engine\!release/xash.dll" /libpath:"./common/soundlib" /opt:nowin98 -# SUBTRACT LINK32 /debug /nodefaultlib -# Begin Custom Build -TargetDir=\Xash3D\src_main\temp\engine\!release -InputPath=\Xash3D\src_main\temp\engine\!release\xash.dll -SOURCE="$(InputPath)" - -"D:\Xash3D\xash.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - copy $(TargetDir)\xash.dll "D:\Xash3D\xash.dll" - -# End Custom Build - -!ELSEIF "$(CFG)" == "engine - 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 "..\temp\engine\!debug" -# PROP Intermediate_Dir "..\temp\engine\!debug" -# PROP Ignore_Export_Lib 1 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /MDd /W3 /Gm /Gi /GX /ZI /Od /I "./" /I "common" /I "common/imagelib" /I "common/soundlib" /I "server" /I "client" /I "client/vgui" /I "../common" /I "../game_shared" /I "../pm_shared" /I "../utils/vgui/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FAs /FR /FD /c -# SUBTRACT CPP /YX -# ADD BASE MTL /nologo /D "_DEBUG" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 -# ADD LINK32 msvcrtd.lib user32.lib gdi32.lib shell32.lib advapi32.lib winmm.lib mpeg_dbg.lib ../utils/vgui/lib/win32_vc6/vgui.lib /nologo /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libcd.lib" /out:"..\temp\engine\!debug/xash.dll" /pdbtype:sept /libpath:"./common/soundlib" -# SUBTRACT LINK32 /incremental:no /map /nodefaultlib -# Begin Custom Build -TargetDir=\Xash3D\src_main\temp\engine\!debug -InputPath=\Xash3D\src_main\temp\engine\!debug\xash.dll -SOURCE="$(InputPath)" - -"D:\Xash3D\xash.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - copy $(TargetDir)\xash.dll "D:\Xash3D\xash.dll" - -# End Custom Build - -!ENDIF - -# Begin Target - -# Name "engine - Win32 Release" -# Name "engine - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90" -# Begin Source File - -SOURCE=.\common\avikit.c -# End Source File -# Begin Source File - -SOURCE=.\common\build.c -# End Source File -# Begin Source File - -SOURCE=.\client\cl_cmds.c -# End Source File -# Begin Source File - -SOURCE=.\client\cl_demo.c -# End Source File -# Begin Source File - -SOURCE=.\client\cl_events.c -# End Source File -# Begin Source File - -SOURCE=.\client\cl_frame.c -# End Source File -# Begin Source File - -SOURCE=.\client\cl_game.c -# End Source File -# Begin Source File - -SOURCE=.\client\cl_main.c -# End Source File -# Begin Source File - -SOURCE=.\client\cl_menu.c -# End Source File -# Begin Source File - -SOURCE=.\client\cl_parse.c -# End Source File -# Begin Source File - -SOURCE=.\client\cl_pmove.c -# End Source File -# Begin Source File - -SOURCE=.\client\cl_remap.c -# End Source File -# Begin Source File - -SOURCE=.\client\cl_scrn.c -# End Source File -# Begin Source File - -SOURCE=.\client\cl_tent.c -# End Source File -# Begin Source File - -SOURCE=.\client\cl_video.c -# End Source File -# Begin Source File - -SOURCE=.\client\cl_view.c -# End Source File -# Begin Source File - -SOURCE=.\common\cmd.c -# End Source File -# Begin Source File - -SOURCE=.\common\common.c -# End Source File -# Begin Source File - -SOURCE=.\common\con_utils.c -# End Source File -# Begin Source File - -SOURCE=.\common\console.c -# End Source File -# Begin Source File - -SOURCE=.\common\crclib.c -# End Source File -# Begin Source File - -SOURCE=.\common\crtlib.c -# End Source File -# Begin Source File - -SOURCE=.\common\cvar.c -# End Source File -# Begin Source File - -SOURCE=.\common\filesystem.c -# End Source File -# Begin Source File - -SOURCE=.\common\gamma.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_backend.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_beams.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_cull.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_decals.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_draw.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_image.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_mirror.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_refrag.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_rlight.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_rmain.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_rmath.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_rmisc.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_rpart.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_rsurf.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_sprite.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_studio.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_vidnt.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_warp.c -# End Source File -# Begin Source File - -SOURCE=.\common\host.c -# End Source File -# Begin Source File - -SOURCE=.\common\hpak.c -# End Source File -# Begin Source File - -SOURCE=.\common\imagelib\img_bmp.c -# End Source File -# Begin Source File - -SOURCE=.\common\imagelib\img_dds.c -# End Source File -# Begin Source File - -SOURCE=.\common\imagelib\img_main.c -# End Source File -# Begin Source File - -SOURCE=.\common\imagelib\img_quant.c -# End Source File -# Begin Source File - -SOURCE=.\common\imagelib\img_tga.c -# End Source File -# Begin Source File - -SOURCE=.\common\imagelib\img_utils.c -# End Source File -# Begin Source File - -SOURCE=.\common\imagelib\img_wad.c -# End Source File -# Begin Source File - -SOURCE=.\common\infostring.c -# End Source File -# Begin Source File - -SOURCE=.\common\input.c -# End Source File -# Begin Source File - -SOURCE=.\common\keys.c -# End Source File -# Begin Source File - -SOURCE=.\common\library.c -# End Source File -# Begin Source File - -SOURCE=.\common\mathlib.c -# End Source File -# Begin Source File - -SOURCE=.\common\matrixlib.c -# End Source File -# Begin Source File - -SOURCE=.\common\mod_studio.c -# End Source File -# Begin Source File - -SOURCE=.\common\model.c -# End Source File -# Begin Source File - -SOURCE=.\common\net_buffer.c -# End Source File -# Begin Source File - -SOURCE=.\common\net_chan.c -# End Source File -# Begin Source File - -SOURCE=.\common\net_encode.c -# End Source File -# Begin Source File - -SOURCE=.\common\net_huff.c -# End Source File -# Begin Source File - -SOURCE=.\common\network.c -# End Source File -# Begin Source File - -SOURCE=.\common\pm_surface.c -# End Source File -# Begin Source File - -SOURCE=.\common\pm_trace.c -# End Source File -# Begin Source File - -SOURCE=.\common\random.c -# End Source File -# Begin Source File - -SOURCE=.\client\s_backend.c -# End Source File -# Begin Source File - -SOURCE=.\client\s_dsp.c -# End Source File -# Begin Source File - -SOURCE=.\client\s_load.c -# End Source File -# Begin Source File - -SOURCE=.\client\s_main.c -# End Source File -# Begin Source File - -SOURCE=.\client\s_mix.c -# End Source File -# Begin Source File - -SOURCE=.\client\s_mouth.c -# End Source File -# Begin Source File - -SOURCE=.\client\s_stream.c -# End Source File -# Begin Source File - -SOURCE=.\client\s_utils.c -# End Source File -# Begin Source File - -SOURCE=.\client\s_vox.c -# End Source File -# Begin Source File - -SOURCE=.\common\soundlib\snd_main.c -# End Source File -# Begin Source File - -SOURCE=.\common\soundlib\snd_mp3.c -# End Source File -# Begin Source File - -SOURCE=.\common\soundlib\snd_utils.c -# End Source File -# Begin Source File - -SOURCE=.\common\soundlib\snd_wav.c -# End Source File -# Begin Source File - -SOURCE=.\server\sv_client.c -# End Source File -# Begin Source File - -SOURCE=.\server\sv_cmds.c -# End Source File -# Begin Source File - -SOURCE=.\server\sv_custom.c -# End Source File -# Begin Source File - -SOURCE=.\server\sv_frame.c -# End Source File -# Begin Source File - -SOURCE=.\server\sv_game.c -# End Source File -# Begin Source File - -SOURCE=.\server\sv_init.c -# End Source File -# Begin Source File - -SOURCE=.\server\sv_main.c -# End Source File -# Begin Source File - -SOURCE=.\server\sv_move.c -# End Source File -# Begin Source File - -SOURCE=.\server\sv_phys.c -# End Source File -# Begin Source File - -SOURCE=.\server\sv_pmove.c -# End Source File -# Begin Source File - -SOURCE=.\server\sv_save.c -# End Source File -# Begin Source File - -SOURCE=.\server\sv_world.c -# End Source File -# Begin Source File - -SOURCE=.\common\sys_con.c -# End Source File -# Begin Source File - -SOURCE=.\common\sys_win.c -# End Source File -# Begin Source File - -SOURCE=.\common\titles.c -# End Source File -# Begin Source File - -SOURCE=.\client\vgui\vgui_clip.cpp -# End Source File -# Begin Source File - -SOURCE=.\client\vgui\vgui_draw.c -# End Source File -# Begin Source File - -SOURCE=.\client\vgui\vgui_font.cpp -# End Source File -# Begin Source File - -SOURCE=.\client\vgui\vgui_input.cpp -# End Source File -# Begin Source File - -SOURCE=.\client\vgui\vgui_int.cpp -# End Source File -# Begin Source File - -SOURCE=.\client\vgui\vgui_surf.cpp -# End Source File -# Begin Source File - -SOURCE=.\common\world.c -# End Source File -# Begin Source File - -SOURCE=.\common\zone.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd" -# Begin Source File - -SOURCE=.\client\cl_tent.h -# End Source File -# Begin Source File - -SOURCE=.\client\client.h -# End Source File -# Begin Source File - -SOURCE=.\common\common.h -# End Source File -# Begin Source File - -SOURCE=.\common\crtlib.h -# End Source File -# Begin Source File - -SOURCE=.\common\filesystem.h -# End Source File -# Begin Source File - -SOURCE=.\client\gl_export.h -# End Source File -# Begin Source File - -SOURCE=.\client\gl_local.h -# End Source File -# Begin Source File - -SOURCE=.\common\imagelib\imagelib.h -# End Source File -# Begin Source File - -SOURCE=.\common\library.h -# End Source File -# Begin Source File - -SOURCE=.\common\mathlib.h -# End Source File -# Begin Source File - -SOURCE=.\common\mod_local.h -# End Source File -# Begin Source File - -SOURCE=.\common\net_buffer.h -# End Source File -# Begin Source File - -SOURCE=.\common\net_encode.h -# End Source File -# Begin Source File - -SOURCE=.\common\protocol.h -# End Source File -# Begin Source File - -SOURCE=.\server\server.h -# End Source File -# Begin Source File - -SOURCE=.\client\sound.h -# End Source File -# Begin Source File - -SOURCE=.\common\soundlib\soundlib.h -# End Source File -# Begin Source File - -SOURCE=.\client\vgui\vgui_draw.h -# End Source File -# Begin Source File - -SOURCE=.\client\vgui\vgui_main.h -# End Source File -# Begin Source File - -SOURCE=.\client\vox.h -# End Source File -# Begin Source File - -SOURCE=.\common\world.h -# End Source File -# End Group -# End Target -# End Project diff --git a/engine/keydefs.h b/engine/keydefs.h index 5593d75a..82b799a8 100644 --- a/engine/keydefs.h +++ b/engine/keydefs.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef KEYDEFS_H +#if !defined(KEYDEFS_H) #define KEYDEFS_H // diff --git a/engine/menu_int.h b/engine/menu_int.h deleted file mode 100644 index d907bd87..00000000 --- a/engine/menu_int.h +++ /dev/null @@ -1,188 +0,0 @@ -/* -menu_int.h - interface between engine and menu -Copyright (C) 2010 Uncle Mike - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -*/ -#pragma once -#ifndef MENU_INT_H -#define MENU_INT_H - -#include "cvardef.h" -#include "gameinfo.h" -#include "wrect.h" - -typedef int HIMAGE; // handle to a graphic - -// flags for PIC_Load -#define PIC_NEAREST (1<<0) // disable texfilter -#define PIC_KEEP_RGBDATA (1<<1) // some images keep source -#define PIC_NOFLIP_TGA (1<<2) // Steam background completely ignore tga attribute 0x20 -#define PIC_KEEP_8BIT (1<<3) // keep original 8-bit image (if present) - -typedef struct ui_globalvars_s -{ - float time; // unclamped host.realtime - float frametime; - - int scrWidth; // actual values - int scrHeight; - - int maxClients; - int developer; - int demoplayback; - int demorecording; - char demoname[64]; // name of currently playing demo - char maptitle[64]; // title of active map -} ui_globalvars_t; - -typedef struct ui_enginefuncs_s -{ - // image handlers - HIMAGE (*pfnPIC_Load)( const char *szPicName, const byte *ucRawImage, long ulRawImageSize, long flags ); - void (*pfnPIC_Free)( const char *szPicName ); - int (*pfnPIC_Width)( HIMAGE hPic ); - int (*pfnPIC_Height)( HIMAGE hPic ); - void (*pfnPIC_Set)( HIMAGE hPic, int r, int g, int b, int a ); - void (*pfnPIC_Draw)( int x, int y, int width, int height, const wrect_t *prc ); - void (*pfnPIC_DrawHoles)( int x, int y, int width, int height, const wrect_t *prc ); - void (*pfnPIC_DrawTrans)( int x, int y, int width, int height, const wrect_t *prc ); - void (*pfnPIC_DrawAdditive)( int x, int y, int width, int height, const wrect_t *prc ); - void (*pfnPIC_EnableScissor)( int x, int y, int width, int height ); - void (*pfnPIC_DisableScissor)( void ); - - // screen handlers - void (*pfnFillRGBA)( int x, int y, int width, int height, int r, int g, int b, int a ); - - // cvar handlers - cvar_t* (*pfnRegisterVariable)( const char *szName, const char *szValue, int flags ); - float (*pfnGetCvarFloat)( const char *szName ); - char* (*pfnGetCvarString)( const char *szName ); - void (*pfnCvarSetString)( const char *szName, const char *szValue ); - void (*pfnCvarSetValue)( const char *szName, float flValue ); - - // command handlers - int (*pfnAddCommand)( const char *cmd_name, void (*function)(void) ); - void (*pfnClientCmd)( int execute_now, const char *szCmdString ); - void (*pfnDelCommand)( const char *cmd_name ); - int (*pfnCmdArgc)( void ); - char* (*pfnCmdArgv)( int argc ); - char* (*pfnCmd_Args)( void ); - - // debug messages (in-menu shows only notify) - void (*Con_Printf)( char *fmt, ... ); - void (*Con_DPrintf)( char *fmt, ... ); - void (*Con_NPrintf)( int pos, char *fmt, ... ); - void (*Con_NXPrintf)( struct con_nprint_s *info, char *fmt, ... ); - - // sound handlers - void (*pfnPlayLocalSound)( const char *szSound ); - - // cinematic handlers - void (*pfnDrawLogo)( const char *filename, float x, float y, float width, float height ); - int (*pfnGetLogoWidth)( void ); - int (*pfnGetLogoHeight)( void ); - float (*pfnGetLogoLength)( void ); // cinematic duration in seconds - - // text message system - void (*pfnDrawCharacter)( int x, int y, int width, int height, int ch, int ulRGBA, HIMAGE hFont ); - int (*pfnDrawConsoleString)( int x, int y, const char *string ); - void (*pfnDrawSetTextColor)( int r, int g, int b, int alpha ); - void (*pfnDrawConsoleStringLen)( const char *string, int *length, int *height ); - void (*pfnSetConsoleDefaultColor)( int r, int g, int b ); // color must came from colors.lst - - // custom rendering (for playermodel preview) - struct cl_entity_s* (*pfnGetPlayerModel)( void ); // for drawing playermodel previews - void (*pfnSetModel)( struct cl_entity_s *ed, const char *path ); - void (*pfnClearScene)( void ); - void (*pfnRenderScene)( const struct ref_params_s *fd ); - int (*CL_CreateVisibleEntity)( int type, struct cl_entity_s *ent ); - - // misc handlers - void (*pfnHostError)( const char *szFmt, ... ); - int (*pfnFileExists)( const char *filename, int gamedironly ); - void (*pfnGetGameDir)( char *szGetGameDir ); - - // gameinfo handlers - int (*pfnCreateMapsList)( int fRefresh ); - int (*pfnClientInGame)( void ); - void (*pfnClientJoin)( const struct netadr_s adr ); - - // parse txt files - byte* (*COM_LoadFile)( const char *filename, int *pLength ); - char* (*COM_ParseFile)( char *data, char *token ); - void (*COM_FreeFile)( void *buffer ); - - // keyfuncs - void (*pfnKeyClearStates)( void ); // call when menu open or close - void (*pfnSetKeyDest)( int dest ); - const char *(*pfnKeynumToString)( int keynum ); - const char *(*pfnKeyGetBinding)( int keynum ); - void (*pfnKeySetBinding)( int keynum, const char *binding ); - int (*pfnKeyIsDown)( int keynum ); - int (*pfnKeyGetOverstrikeMode)( void ); - void (*pfnKeySetOverstrikeMode)( int fActive ); - void *(*pfnKeyGetState)( const char *name ); // for mlook, klook etc - - // engine memory manager - void* (*pfnMemAlloc)( size_t cb, const char *filename, const int fileline ); - void (*pfnMemFree)( void *mem, const char *filename, const int fileline ); - - // collect info from engine - int (*pfnGetGameInfo)( GAMEINFO *pgameinfo ); - GAMEINFO **(*pfnGetGamesList)( int *numGames ); // collect info about all mods - char **(*pfnGetFilesList)( const char *pattern, int *numFiles, int gamedironly ); // find in files - int (*pfnGetSaveComment)( const char *savename, char *comment ); - int (*pfnGetDemoComment)( const char *demoname, char *comment ); - int (*pfnCheckGameDll)( void ); // returns false if hl.dll is missed or invalid - char *(*pfnGetClipboardData)( void ); - - // engine launcher - void (*pfnShellExecute)( const char *name, const char *args, int closeEngine ); - void (*pfnWriteServerConfig)( const char *name ); - void (*pfnChangeInstance)( const char *newInstance, const char *szFinalMessage ); - void (*pfnPlayBackgroundTrack)( const char *introName, const char *loopName ); - void (*pfnHostEndGame)( const char *szFinalMessage ); - - // menu interface is freezed at version 0.75 - // new functions starts here - float (*pfnRandomFloat)( float flLow, float flHigh ); - int (*pfnRandomLong)( int lLow, int lHigh ); - - void (*pfnSetCursor)( void *hCursor ); // change cursor - int (*pfnIsMapValid)( char *filename ); - void (*pfnProcessImage)( int texnum, float gamma, int topColor, int bottomColor ); - int (*pfnCompareFileTime)( char *filename1, char *filename2, int *iCompare ); -} ui_enginefuncs_t; - -typedef struct -{ - int (*pfnVidInit)( void ); - void (*pfnInit)( void ); - void (*pfnShutdown)( void ); - void (*pfnRedraw)( float flTime ); - void (*pfnKeyEvent)( int key, int down ); - void (*pfnMouseMove)( int x, int y ); - void (*pfnSetActiveMenu)( int active ); - void (*pfnAddServerToList)( struct netadr_s adr, const char *info ); - void (*pfnGetCursorPos)( int *pos_x, int *pos_y ); - void (*pfnSetCursorPos)( int pos_x, int pos_y ); - void (*pfnShowCursor)( int show ); - void (*pfnCharEvent)( int key ); - int (*pfnMouseInRect)( void ); // mouse entering\leave game window - int (*pfnIsVisible)( void ); - int (*pfnCreditsActive)( void ); // unused - void (*pfnFinalCredits)( void ); // show credits + game end -} UI_FUNCTIONS; - -typedef int (*MENUAPI)( UI_FUNCTIONS *pFunctionTable, ui_enginefuncs_t* engfuncs, ui_globalvars_t *pGlobals ); - -#endif//MENU_INT_H diff --git a/engine/mobility_int.h b/engine/mobility_int.h index d8b6120a..ef94f769 100644 --- a/engine/mobility_int.h +++ b/engine/mobility_int.h @@ -12,11 +12,10 @@ 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. */ - #pragma once -#ifndef MOBILITY_INT_H +#if !defined(MOBILITY_INT_H) #define MOBILITY_INT_H -#ifdef __cplusplus +#if __cplusplus extern "C" { #endif @@ -84,7 +83,7 @@ typedef struct mobile_engfuncs_s // returns 0 on no error otherwise error typedef int (*pfnMobilityInterface)( mobile_engfuncs_t *gMobileEngfuncs ); -#ifdef __cplusplus +#if __cplusplus } #endif #endif diff --git a/engine/physint.h b/engine/physint.h deleted file mode 100644 index 2b4ac8f7..00000000 --- a/engine/physint.h +++ /dev/null @@ -1,114 +0,0 @@ -/* -physint.h - Server Physics Interface -Copyright (C) 2011 Uncle Mike - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -*/ -#pragma once -#ifndef PHYSINT_H -#define PHYSINT_H - -#define SV_PHYSICS_INTERFACE_VERSION 6 - -#define STRUCT_FROM_LINK( l, t, m ) ((t *)((byte *)l - (int)&(((t *)0)->m))) -#define EDICT_FROM_AREA( l ) STRUCT_FROM_LINK( l, edict_t, area ) - -// values that can be returned with pfnServerState -#define SERVER_DEAD 0 -#define SERVER_LOADING 1 -#define SERVER_ACTIVE 2 - -typedef struct areanode_s -{ - int axis; // -1 = leaf node - float dist; - struct areanode_s *children[2]; - link_t trigger_edicts; - link_t solid_edicts; - link_t water_edicts; // func water -} areanode_t; - -typedef struct server_physics_api_s -{ - // unlink edict from old position and link onto new - void ( *pfnLinkEdict) ( edict_t *ent, qboolean touch_triggers ); - double ( *pfnGetServerTime )( void ); // unclamped - double ( *pfnGetFrameTime )( void ); // unclamped - void* ( *pfnGetModel )( int modelindex ); - areanode_t* ( *pfnGetHeadnode )( void ); // BSP tree for all physic entities - int ( *pfnServerState )( void ); - void ( *pfnHost_Error )( const char *error, ... ); // cause Host Error -// ONLY ADD NEW FUNCTIONS TO THE END OF THIS STRUCT. INTERFACE VERSION IS FROZEN AT 6 - struct triangleapi_s *pTriAPI; // draw coliisions etc. Only for local system - - // draw debug messages (must be called from DrawOrthoTriangles). Only for local system - int ( *pfnDrawConsoleString )( int x, int y, char *string ); - void ( *pfnDrawSetTextColor )( float r, float g, float b ); - void ( *pfnDrawConsoleStringLen )( const char *string, int *length, int *height ); - void ( *Con_NPrintf )( int pos, char *fmt, ... ); - void ( *Con_NXPrintf )( struct con_nprint_s *info, char *fmt, ... ); - const char *( *pfnGetLightStyle )( int style ); // read custom appreance for selected lightstyle - void ( *pfnUpdateFogSettings )( unsigned int packed_fog ); - char **(*pfnGetFilesList)( const char *pattern, int *numFiles, int gamedironly ); - struct msurface_s *(*pfnTraceSurface)( edict_t *pTextureEntity, const float *v1, const float *v2 ); - const byte *(*pfnGetTextureData)( unsigned int texnum ); - - // static allocations - void *(*pfnMemAlloc)( size_t cb, const char *filename, const int fileline ); - void (*pfnMemFree)( void *mem, const char *filename, const int fileline ); -} server_physics_api_t; - -// physic callbacks -typedef struct physics_interface_s -{ - int version; - // passed through pfnCreate (0 is attempt to create, -1 is reject) - int ( *SV_CreateEntity )( edict_t *pent, const char *szName ); - // run custom physics for each entity (return 0 to use built-in engine physic) - int ( *SV_PhysicsEntity )( edict_t *pEntity ); - // spawn entities with internal mod function e.g. for re-arrange spawn order (0 - use engine parser, 1 - use mod parser) - int ( *SV_LoadEntities )( const char *mapname, char *entities ); - // update conveyor belt for clients - void ( *SV_UpdatePlayerBaseVelocity )( edict_t *ent ); - // The game .dll should return 1 if save game should be allowed - int ( *SV_AllowSaveGame )( void ); -// ONLY ADD NEW FUNCTIONS TO THE END OF THIS STRUCT. INTERFACE VERSION IS FROZEN AT 6 - // override trigger area checking and touching - int ( *SV_TriggerTouch )( edict_t *pent, edict_t *trigger ); - // some engine features can be enabled only through this function - unsigned int ( *SV_CheckFeatures )( void ); - // used for draw debug collisions for custom physic engine etc - void ( *DrawDebugTriangles )( void ); - // used for draw debug overlay (textured) - void ( *DrawNormalTriangles )( void ); - // used for draw debug messages (2d mode) - void ( *DrawOrthoTriangles )( void ); - // tracing entities with SOLID_CUSTOM mode on a server (not used by pmove code) - void ( *ClipMoveToEntity)( edict_t *ent, const float *start, float *mins, float *maxs, const float *end, trace_t *trace ); - // tracing entities with SOLID_CUSTOM mode on a server (only used by pmove code) - void ( *ClipPMoveToEntity)( struct physent_s *pe, const float *start, float *mins, float *maxs, const float *end, struct pmtrace_s *tr ); - // called at end the frame of SV_Physics call - void ( *SV_EndFrame )( void ); - // called through save\restore process - void (*pfnCreateEntitiesInTransitionList)( SAVERESTOREDATA*, int levelMask ); - // called through save\restore process - void (*pfnCreateEntitiesInRestoreList)( SAVERESTOREDATA*, int createPlayers ); - // allocate custom string (e.g. using user implementation of stringtable, not engine strings) - string_t (*pfnAllocString)( const char *szValue ); - // make custom string (e.g. using user implementation of stringtable, not engine strings) - string_t (*pfnMakeString)( const char *szValue ); - // read custom string (e.g. using user implementation of stringtable, not engine strings) - const char* (*pfnGetString)( string_t iString ); - // helper for restore custom decals that have custom message (e.g. Paranoia) - int (*pfnRestoreDecal)( struct decallist_s *entry, edict_t *pEdict, qboolean adjacent ); -} physics_interface_t; - -#endif//PHYSINT_H diff --git a/engine/progdefs.h b/engine/progdefs.h index 31cfb3cb..d8dd62e6 100644 --- a/engine/progdefs.h +++ b/engine/progdefs.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef PROGDEFS_H +#if !defined(PROGDEFS_H) #define PROGDEFS_H typedef struct diff --git a/engine/shake.h b/engine/shake.h index a3e49324..8d4bbde5 100644 --- a/engine/shake.h +++ b/engine/shake.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef SHAKE_H +#if !defined(SHAKE_H) #define SHAKE_H // Screen / View effects diff --git a/engine/sprite.h b/engine/sprite.h index 4368c1ac..ee0c317b 100644 --- a/engine/sprite.h +++ b/engine/sprite.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef SPRITE_H +#if !defined(SPRITE_H) #define SPRITE_H /* diff --git a/engine/studio.h b/engine/studio.h index 88254c96..48be9d0a 100644 --- a/engine/studio.h +++ b/engine/studio.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef STUDIO_H +#if !defined(STUDIO_H) #define STUDIO_H /* @@ -201,7 +201,7 @@ typedef struct vec3_t bbmax; } mstudiobbox_t; -#ifndef CACHE_USER +#if !defined(CACHE_USER) #define CACHE_USER typedef struct cache_user_s { diff --git a/engine/warpsin.h b/engine/warpsin.h deleted file mode 100644 index e46b44d7..00000000 --- a/engine/warpsin.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -Copyright (C) 1997-2001 Id Software, Inc. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -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. - -*/ - - -0.000000, 0.098165, 0.196270, 0.294259, 0.392069, 0.489643, 0.586920, 0.683850, -0.780360, 0.876405, 0.971920, 1.066850, 1.161140, 1.254725, 1.347560, 1.439580, -1.530735, 1.620965, 1.710220, 1.798445, 1.885585, 1.971595, 2.056410, 2.139990, -2.222280, 2.303235, 2.382795, 2.460925, 2.537575, 2.612690, 2.686235, 2.758160, -2.828425, 2.896990, 2.963805, 3.028835, 3.092040, 3.153385, 3.212830, 3.270340, -3.325880, 3.379415, 3.430915, 3.480350, 3.527685, 3.572895, 3.615955, 3.656840, -3.695520, 3.731970, 3.766175, 3.798115, 3.827760, 3.855105, 3.880125, 3.902810, -3.923140, 3.941110, 3.956705, 3.969920, 3.980740, 3.989160, 3.995180, 3.998795, -4.000000, 3.998795, 3.995180, 3.989160, 3.980740, 3.969920, 3.956705, 3.941110, -3.923140, 3.902810, 3.880125, 3.855105, 3.827760, 3.798115, 3.766175, 3.731970, -3.695520, 3.656840, 3.615955, 3.572895, 3.527685, 3.480350, 3.430915, 3.379415, -3.325880, 3.270340, 3.212830, 3.153385, 3.092040, 3.028835, 2.963805, 2.896990, -2.828425, 2.758160, 2.686235, 2.612690, 2.537575, 2.460925, 2.382795, 2.303235, -2.222280, 2.139990, 2.056410, 1.971595, 1.885585, 1.798445, 1.710220, 1.620965, -1.530735, 1.439580, 1.347560, 1.254725, 1.161140, 1.066850, 0.971920, 0.876405, -0.780360, 0.683850, 0.586920, 0.489643, 0.392069, 0.294259, 0.196270, 0.098165, -0.000000, -0.098165, -0.196270, -0.294259, -0.392069, -0.489643, -0.586920, -0.683850, --0.780360, -0.876405, -0.971920, -1.066850, -1.161140, -1.254725, -1.347560, -1.439580, --1.530735, -1.620965, -1.710220, -1.798445, -1.885585, -1.971595, -2.056410, -2.139990, --2.222280, -2.303235, -2.382795, -2.460925, -2.537575, -2.612690, -2.686235, -2.758160, --2.828425, -2.896990, -2.963805, -3.028835, -3.092040, -3.153385, -3.212830, -3.270340, --3.325880, -3.379415, -3.430915, -3.480350, -3.527685, -3.572895, -3.615955, -3.656840, --3.695520, -3.731970, -3.766175, -3.798115, -3.827760, -3.855105, -3.880125, -3.902810, --3.923140, -3.941110, -3.956705, -3.969920, -3.980740, -3.989160, -3.995180, -3.998795, --4.000000, -3.998795, -3.995180, -3.989160, -3.980740, -3.969920, -3.956705, -3.941110, --3.923140, -3.902810, -3.880125, -3.855105, -3.827760, -3.798115, -3.766175, -3.731970, --3.695520, -3.656840, -3.615955, -3.572895, -3.527685, -3.480350, -3.430915, -3.379415, --3.325880, -3.270340, -3.212830, -3.153385, -3.092040, -3.028835, -2.963805, -2.896990, --2.828425, -2.758160, -2.686235, -2.612690, -2.537575, -2.460925, -2.382795, -2.303235, --2.222280, -2.139990, -2.056410, -1.971595, -1.885585, -1.798445, -1.710220, -1.620965, --1.530735, -1.439580, -1.347560, -1.254725, -1.161140, -1.066850, -0.971920, -0.876405, --0.780360, -0.683850, -0.586920, -0.489643, -0.392069, -0.294259, -0.196270, -0.098165, diff --git a/game_shared/bitvec.h b/game_shared/bitvec.h index b7f5343a..d77796fb 100644 --- a/game_shared/bitvec.h +++ b/game_shared/bitvec.h @@ -1,15 +1,11 @@ -//========= Copyright 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright � 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // // $NoKeywords: $ //============================================================================= - -#ifndef BITVEC_H +#if !defined(BITVEC_H) #define BITVEC_H -#ifdef _WIN32 -#pragma once -#endif #include #include @@ -158,3 +154,4 @@ inline void CBitVec::SetDWord( int i, unsigned long val ) m_DWords[i] = val; } #endif // BITVEC_H + diff --git a/game_shared/vgui_checkbutton2.cpp b/game_shared/vgui_checkbutton2.cpp index b998a41d..bb67f31a 100644 --- a/game_shared/vgui_checkbutton2.cpp +++ b/game_shared/vgui_checkbutton2.cpp @@ -10,57 +10,50 @@ #include "vgui_checkbutton2.h" #include "vgui_loadtga.h" - #define EXTRA_X 5 - using namespace vgui; - - CCheckButton2::CCheckButton2() : - m_Label(""), - m_pChecked(NULL), - m_pUnchecked(NULL), - m_pHandler(NULL), - m_CheckboxPanel(NULL) + m_Label( "" ), + m_pChecked( NULL ), + m_pUnchecked( NULL ), + m_pHandler( NULL ), + m_CheckboxPanel( NULL ) { m_bOwnImages = false; m_bChecked = false; m_pChecked = m_pUnchecked = NULL; m_bCheckboxLeft = true; - m_Label.setParent(this); - m_Label.setFgColor(255,255,255,0); - m_Label.setBgColor(0,0,0,255); // background is not drawn and foreground is white - m_Label.addInputSignal(this); + m_Label.setParent( this ); + m_Label.setFgColor( 255, 255, 255, 0 ); + m_Label.setBgColor( 0, 0, 0, 255 ); // background is not drawn and foreground is white + m_Label.addInputSignal( this ); - m_CheckboxPanel.setParent(this); - m_CheckboxPanel.addInputSignal(this); + m_CheckboxPanel.setParent( this ); + m_CheckboxPanel.addInputSignal( this ); - setPaintBackgroundEnabled(false); + setPaintBackgroundEnabled( false ); } - CCheckButton2::~CCheckButton2() { DeleteImages(); } - -void CCheckButton2::SetImages(char const *pChecked, char const *pUnchecked) +void CCheckButton2::SetImages( char const *pChecked, char const *pUnchecked ) { DeleteImages(); - - m_pChecked = vgui_LoadTGA(pChecked); - m_pUnchecked = vgui_LoadTGA(pUnchecked); + + m_pChecked = vgui_LoadTGA( pChecked ); + m_pUnchecked = vgui_LoadTGA( pUnchecked ); m_bOwnImages = true; SetupControls(); } - -void CCheckButton2::SetImages(Image *pChecked, Image *pUnchecked) +void CCheckButton2::SetImages( Image *pChecked, Image *pUnchecked ) { DeleteImages(); @@ -71,10 +64,9 @@ void CCheckButton2::SetImages(Image *pChecked, Image *pUnchecked) SetupControls(); } - void CCheckButton2::DeleteImages() { - if(m_bOwnImages) + if( m_bOwnImages ) { delete m_pChecked; delete m_pUnchecked; @@ -87,71 +79,62 @@ void CCheckButton2::DeleteImages() SetupControls(); } - -void CCheckButton2::SetCheckboxLeft(bool bLeftAlign) +void CCheckButton2::SetCheckboxLeft( bool bLeftAlign ) { m_bCheckboxLeft = bLeftAlign; SetupControls(); } - bool CCheckButton2::GetCheckboxLeft() { return m_bCheckboxLeft; } - -void CCheckButton2::SetText(char const *pText, ...) +void CCheckButton2::SetText( char const *pText, ... ) { char str[512]; - - va_list marker; - va_start(marker, pText); - _vsnprintf(str, sizeof(str), pText, marker); - va_end(marker); - m_Label.setText(str); + va_list marker; + va_start( marker, pText ); + _vsnprintf( str, sizeof( str ), pText, marker ); + va_end( marker ); + + m_Label.setText( str ); SetupControls(); } - -void CCheckButton2::SetTextColor(int r, int g, int b, int a) +void CCheckButton2::SetTextColor( int r, int g, int b, int a ) { - m_Label.setFgColor(r, g, b, a); + m_Label.setFgColor( r, g, b, a ); repaint(); } - -void CCheckButton2::SetHandler(ICheckButton2Handler *pHandler) +void CCheckButton2::SetHandler( ICheckButton2Handler *pHandler ) { m_pHandler = pHandler; } - bool CCheckButton2::IsChecked() { return m_bChecked; } - -void CCheckButton2::SetChecked(bool bChecked) +void CCheckButton2::SetChecked( bool bChecked ) { m_bChecked = bChecked; SetupControls(); } - -void CCheckButton2::internalMousePressed(MouseCode code) +void CCheckButton2::internalMousePressed( MouseCode code ) { m_bChecked = !m_bChecked; - if(m_pHandler) - m_pHandler->StateChanged(this); + if( m_pHandler ) + m_pHandler->StateChanged( this ); SetupControls(); } - void CCheckButton2::SetupControls() { // Initialize the checkbutton bitmap. @@ -161,37 +144,28 @@ void CCheckButton2::SetupControls() int controlSizes[2][2]; controlSizes[0][0] = controlSizes[0][1] = 0; - if(pBitmap) - pBitmap->getSize(controlSizes[0][0], controlSizes[0][1]); - - m_CheckboxPanel.setImage(pBitmap); - m_CheckboxPanel.setSize(controlSizes[0][0], controlSizes[0][1]); + if( pBitmap ) + pBitmap->getSize( controlSizes[0][0], controlSizes[0][1] ); + + m_CheckboxPanel.setImage( pBitmap ); + m_CheckboxPanel.setSize( controlSizes[0][0], controlSizes[0][1] ); - // Get the label's size. - m_Label.getSize(controlSizes[1][0], controlSizes[1][1]); - m_Label.setContentAlignment(Label::a_west); - + m_Label.getSize( controlSizes[1][0], controlSizes[1][1] ); + m_Label.setContentAlignment( Label::a_west ); // Position the controls. int iLeftControl = !m_bCheckboxLeft; int iBiggestY = controlSizes[0][1] > controlSizes[1][0] ? 0 : 1; - controls[iLeftControl]->setPos(0, (controlSizes[iBiggestY][1] - controlSizes[iLeftControl][1]) / 2); - controls[!iLeftControl]->setPos(controlSizes[iLeftControl][0] + EXTRA_X, (controlSizes[iBiggestY][1] - controlSizes[!iLeftControl][1]) / 2); + controls[iLeftControl]->setPos( 0, ( controlSizes[iBiggestY][1] - controlSizes[iLeftControl][1] ) / 2 ); + controls[!iLeftControl]->setPos( controlSizes[iLeftControl][0] + EXTRA_X, ( controlSizes[iBiggestY][1] - controlSizes[!iLeftControl][1]) / 2 ); - // Fit this control to the sizes of the subcontrols. - setSize(controlSizes[0][0] + controlSizes[1][0] + EXTRA_X, (controlSizes[0][1] > controlSizes[1][1]) ? controlSizes[0][1] : controlSizes[1][1]); + setSize(controlSizes[0][0] + controlSizes[1][0] + EXTRA_X, ( controlSizes[0][1] > controlSizes[1][1]) ? controlSizes[0][1] : controlSizes[1][1] ); repaint(); } - -void CCheckButton2::mousePressed(MouseCode code, Panel *panel) +void CCheckButton2::mousePressed( MouseCode code, Panel *panel ) { - internalMousePressed(code); + internalMousePressed( code ); } - - - - - diff --git a/game_shared/vgui_checkbutton2.h b/game_shared/vgui_checkbutton2.h index ef8f82ae..d04fc182 100644 --- a/game_shared/vgui_checkbutton2.h +++ b/game_shared/vgui_checkbutton2.h @@ -1,4 +1,4 @@ -//========= Copyright 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright � 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // @@ -11,26 +11,19 @@ #pragma once #endif - -#include "vgui_label.h" -#include "vgui_imagepanel.h" +#include "VGUI_Label.h" +#include "VGUI_ImagePanel.h" #include "vgui_defaultinputsignal.h" - namespace vgui { - - class CCheckButton2; - - class ICheckButton2Handler { public: - virtual void StateChanged(CCheckButton2 *pButton) = 0; + virtual void StateChanged( CCheckButton2 *pButton ) = 0; }; - // VGUI checkbox class. // - Provides access to the checkbox images. // - Provides an easy callback mechanism for state changes. @@ -38,47 +31,37 @@ public: class CCheckButton2 : public Panel, public CDefaultInputSignal { public: + CCheckButton2(); + ~CCheckButton2(); - CCheckButton2(); - ~CCheckButton2(); - // Initialize the button with these. - void SetImages(char const *pChecked, char const *pUnchecked); - void SetImages(Image *pChecked, Image *pUnchecked); // If you use this, the button will never delete the images. + void SetImages( char const *pChecked, char const *pUnchecked ); + void SetImages( Image *pChecked, Image *pUnchecked ); // If you use this, the button will never delete the images. void DeleteImages(); // The checkbox can be to the left or the right of the text (default is left). - void SetCheckboxLeft(bool bLeftAlign); + void SetCheckboxLeft( bool bLeftAlign ); bool GetCheckboxLeft(); - + // Set the label text. - void SetText(char const *pText, ...); - void SetTextColor(int r, int g, int b, int a); + void SetText( char const *pText, ... ); + void SetTextColor( int r, int g, int b, int a ); // You can register for change notification here. - void SetHandler(ICheckButton2Handler *pHandler); - + void SetHandler( ICheckButton2Handler *pHandler ); + // Get/set the check state. bool IsChecked(); - void SetChecked(bool bChecked); - - + void SetChecked( bool bChecked ); // Panel overrides. -public: - - virtual void internalMousePressed(MouseCode code); - + virtual void internalMousePressed( MouseCode code ); protected: - void SetupControls(); - // InputSignal overrides. -protected: - virtual void mousePressed(MouseCode code,Panel* panel); - + virtual void mousePressed( MouseCode code, Panel *panel ); public: ICheckButton2Handler *m_pHandler; @@ -93,9 +76,5 @@ public: bool m_bChecked; }; - - } - - #endif // VGUI_CHECKBUTTON2_H diff --git a/game_shared/vgui_defaultinputsignal.h b/game_shared/vgui_defaultinputsignal.h index 835d92b0..cd55b76c 100644 --- a/game_shared/vgui_defaultinputsignal.h +++ b/game_shared/vgui_defaultinputsignal.h @@ -1,4 +1,4 @@ -//========= Copyright 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright � 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // @@ -11,9 +11,7 @@ #pragma once #endif - -#include "vgui_inputsignal.h" - +#include "VGUI_InputSignal.h" namespace vgui { @@ -21,8 +19,8 @@ namespace vgui class CDefaultInputSignal : public vgui::InputSignal { public: - virtual void cursorMoved(int x,int y,Panel* panel) {} - virtual void cursorEntered(Panel* panel) {} + virtual void cursorMoved( int x, int y, Panel *panel ) {} + virtual void cursorEntered( Panel *panel ) {} virtual void cursorExited(Panel* panel) {} virtual void mousePressed(MouseCode code,Panel* panel) {} virtual void mouseDoublePressed(MouseCode code,Panel* panel) {} diff --git a/game_shared/vgui_grid.cpp b/game_shared/vgui_grid.cpp index 5a1af15e..f94e1cef 100644 --- a/game_shared/vgui_grid.cpp +++ b/game_shared/vgui_grid.cpp @@ -8,10 +8,8 @@ #include #include "vgui_grid.h" - using namespace vgui; - #define AssertCheck(expr, msg) \ if(!(expr))\ {\ @@ -19,12 +17,9 @@ using namespace vgui; return 0;\ } - - // ------------------------------------------------------------------------------ // // CGrid::CGridEntry. // ------------------------------------------------------------------------------ // - CGrid::CGridEntry::CGridEntry() { m_pPanel = NULL; @@ -35,47 +30,42 @@ CGrid::CGridEntry::~CGridEntry() { } - // ------------------------------------------------------------------------------ // // CGrid. // ------------------------------------------------------------------------------ // - CGrid::CGrid() { Clear(); } - CGrid::~CGrid() { Term(); } - -bool CGrid::SetDimensions(int xCols, int yRows) +bool CGrid::SetDimensions( int xCols, int yRows ) { Term(); m_GridEntries = new CGridEntry[xCols * yRows]; - m_Widths = new int[xCols*2 + yRows*2]; + m_Widths = new int[xCols * 2 + yRows * 2]; m_Heights = m_Widths + xCols; m_ColOffsets = m_Heights + yRows; m_RowOffsets = m_ColOffsets + xCols; - if(!m_GridEntries || !m_Widths) + if( !m_GridEntries || !m_Widths ) { Term(); return false; } - memset(m_Widths, 0, sizeof(int) * (xCols*2 + yRows*2)); + memset( m_Widths, 0, sizeof(int) * ( xCols * 2 + yRows * 2 ) ); m_xCols = xCols; m_yRows = yRows; return true; } - void CGrid::Term() { delete [] m_GridEntries; @@ -83,180 +73,164 @@ void CGrid::Term() Clear(); } - -Panel* CGrid::GetEntry(int x, int y) +Panel *CGrid::GetEntry( int x, int y ) { - return GridEntry(x, y)->m_pPanel; + return GridEntry( x, y )->m_pPanel; } - -bool CGrid::SetEntry(int x, int y, Panel *pPanel) +bool CGrid::SetEntry( int x, int y, Panel *pPanel ) { - CGridEntry *pEntry = GridEntry(x, y); - if(!pEntry) + CGridEntry *pEntry = GridEntry( x, y ); + if( !pEntry ) return false; - if(pEntry->m_pPanel) - pEntry->m_pPanel->setParent(NULL); + if( pEntry->m_pPanel ) + pEntry->m_pPanel->setParent( NULL ); pEntry->m_pPanel = pPanel; - if(pPanel) - pPanel->setParent(this); + if( pPanel ) + pPanel->setParent( this ); m_bDirty = true; return true; } - int CGrid::GetXSpacing() { return m_xSpacing; } - int CGrid::GetYSpacing() { return m_ySpacing; } - -void CGrid::SetSpacing(int xSpacing, int ySpacing) +void CGrid::SetSpacing( int xSpacing, int ySpacing ) { - if(xSpacing != m_xSpacing) + if( xSpacing != m_xSpacing ) { m_xSpacing = xSpacing; - CalcColOffsets(0); + CalcColOffsets( 0 ); m_bDirty = true; } - if(ySpacing != m_ySpacing) + if( ySpacing != m_ySpacing ) { m_ySpacing = ySpacing; - CalcRowOffsets(0); + CalcRowOffsets( 0 ); m_bDirty = true; } } - bool CGrid::SetColumnWidth(int iColumn, int width) { - AssertCheck(iColumn >= 0 && iColumn < m_xCols, "CGrid::SetColumnWidth : invalid location specified"); + AssertCheck( iColumn >= 0 && iColumn < m_xCols, "CGrid::SetColumnWidth : invalid location specified" ); m_Widths[iColumn] = width; - CalcColOffsets(iColumn+1); + CalcColOffsets( iColumn + 1 ); m_bDirty = true; return true; } - -bool CGrid::SetRowHeight(int iRow, int height) +bool CGrid::SetRowHeight( int iRow, int height ) { - AssertCheck(iRow >= 0 && iRow < m_yRows, "CGrid::SetColumnWidth : invalid location specified"); + AssertCheck( iRow >= 0 && iRow < m_yRows, "CGrid::SetColumnWidth : invalid location specified" ); m_Heights[iRow] = height; - CalcRowOffsets(iRow+1); + CalcRowOffsets( iRow + 1 ); m_bDirty = true; return true; } - -int CGrid::GetColumnWidth(int iColumn) +int CGrid::GetColumnWidth( int iColumn ) { - AssertCheck(iColumn >= 0 && iColumn < m_xCols, "CGrid::GetColumnWidth: invalid location specified"); + AssertCheck( iColumn >= 0 && iColumn < m_xCols, "CGrid::GetColumnWidth: invalid location specified" ); return m_Widths[iColumn]; } - -int CGrid::GetRowHeight(int iRow) +int CGrid::GetRowHeight( int iRow ) { - AssertCheck(iRow >= 0 && iRow < m_yRows, "CGrid::GetRowHeight: invalid location specified"); + AssertCheck( iRow >= 0 && iRow < m_yRows, "CGrid::GetRowHeight: invalid location specified" ); return m_Heights[iRow]; } - -int CGrid::CalcFitColumnWidth(int iColumn) +int CGrid::CalcFitColumnWidth( int iColumn ) { - AssertCheck(iColumn >= 0 && iColumn < m_xCols, "CGrid::CalcFitColumnWidth: invalid location specified"); + AssertCheck( iColumn >= 0 && iColumn < m_xCols, "CGrid::CalcFitColumnWidth: invalid location specified" ); int maxSize = 0; - for(int i=0; i < m_yRows; i++) + for( int i = 0; i < m_yRows; i++ ) { - Panel *pPanel = GridEntry(iColumn, i)->m_pPanel; - if(!pPanel) + Panel *pPanel = GridEntry( iColumn, i )->m_pPanel; + if( !pPanel ) continue; int w, h; - pPanel->getSize(w,h); - if(w > maxSize) + pPanel->getSize( w, h ); + if( w > maxSize ) maxSize = w; } return maxSize; } - -int CGrid::CalcFitRowHeight(int iRow) +int CGrid::CalcFitRowHeight( int iRow ) { - AssertCheck(iRow >= 0 && iRow < m_yRows, "CGrid::CalcFitRowHeight: invalid location specified"); + AssertCheck( iRow >= 0 && iRow < m_yRows, "CGrid::CalcFitRowHeight: invalid location specified" ); int maxSize = 0; - for(int i=0; i < m_xCols; i++) + for( int i = 0; i < m_xCols; i++ ) { - Panel *pPanel = GridEntry(i, iRow)->m_pPanel; - if(!pPanel) + Panel *pPanel = GridEntry( i, iRow )->m_pPanel; + if( !pPanel ) continue; int w, h; - pPanel->getSize(w,h); - if(h > maxSize) + pPanel->getSize( w, h ); + if( h > maxSize ) maxSize = h; } return maxSize; } - void CGrid::AutoSetRowHeights() { - for(int i=0; i < m_yRows; i++) - SetRowHeight(i, CalcFitRowHeight(i)); + for( int i = 0; i < m_yRows; i++ ) + SetRowHeight( i, CalcFitRowHeight( i ) ); } - -bool CGrid::GetEntryBox( - int col, int row, int &x, int &y, int &w, int &h) +bool CGrid::GetEntryBox( int col, int row, int &x, int &y, int &w, int &h ) { - AssertCheck(col >= 0 && col < m_xCols && row >= 0 && row < m_yRows, "CGrid::GetEntryBox: invalid location specified"); + AssertCheck( col >= 0 && col < m_xCols && row >= 0 && row < m_yRows, "CGrid::GetEntryBox: invalid location specified" ); x = m_ColOffsets[col]; w = m_Widths[col]; y = m_RowOffsets[row]; h = m_Heights[row]; - return true; + return true; } - -bool CGrid::CopyColumnWidths(CGrid *pOther) +bool CGrid::CopyColumnWidths( CGrid *pOther ) { - if(!pOther || pOther->m_xCols != m_xCols) + if( !pOther || pOther->m_xCols != m_xCols ) return false; - for(int i=0; i < m_xCols; i++) + for( int i = 0; i < m_xCols; i++ ) m_Widths[i] = pOther->m_Widths[i]; - CalcColOffsets(0); + CalcColOffsets( 0 ); m_bDirty = true; return true; } - void CGrid::RepositionContents() { - for(int x=0; x < m_xCols; x++) + for( int x = 0; x < m_xCols; x++ ) { - for(int y=0; y < m_yRows; y++) + for( int y=0; y < m_yRows; y++ ) { - Panel *pPanel = GridEntry(x,y)->m_pPanel; - if(!pPanel) + Panel *pPanel = GridEntry( x, y )->m_pPanel; + if( !pPanel ) continue; pPanel->setBounds( @@ -270,12 +244,11 @@ void CGrid::RepositionContents() m_bDirty = false; } - int CGrid::CalcDrawHeight() { - if(m_yRows > 0) + if( m_yRows > 0 ) { - return m_RowOffsets[m_yRows-1] + m_Heights[m_yRows - 1] + m_ySpacing; + return m_RowOffsets[m_yRows - 1] + m_Heights[m_yRows - 1] + m_ySpacing; } else { @@ -283,25 +256,24 @@ int CGrid::CalcDrawHeight() } } - void CGrid::paint() { - if(m_bDirty) + if( m_bDirty ) RepositionContents(); Panel::paint(); // walk the grid looking for underlined rows int x = 0, y = 0; - for (int row = 0; row < m_yRows; row++) + for( int row = 0; row < m_yRows; row++ ) { - CGridEntry *cell = GridEntry(0, row); + CGridEntry *cell = GridEntry( 0, row ); y += cell->m_pPanel->getTall() + m_ySpacing; - if (cell->m_bUnderline) + if( cell->m_bUnderline ) { - drawSetColor(cell->m_UnderlineColor[0], cell->m_UnderlineColor[1], cell->m_UnderlineColor[2], cell->m_UnderlineColor[3]); - drawFilledRect(0, y - (cell->m_iUnderlineOffset + 1), getWide(), y - cell->m_iUnderlineOffset); + drawSetColor( cell->m_UnderlineColor[0], cell->m_UnderlineColor[1], cell->m_UnderlineColor[2], cell->m_UnderlineColor[3] ); + drawFilledRect( 0, y - (cell->m_iUnderlineOffset + 1 ), getWide(), y - cell->m_iUnderlineOffset ); } } } @@ -314,11 +286,11 @@ void CGrid::paintBackground() //----------------------------------------------------------------------------- // Purpose: sets underline color for a particular row //----------------------------------------------------------------------------- -void CGrid::SetRowUnderline(int row, bool enabled, int offset, int r, int g, int b, int a) +void CGrid::SetRowUnderline( int row, bool enabled, int offset, int r, int g, int b, int a ) { - CGridEntry *cell = GridEntry(0, row); + CGridEntry *cell = GridEntry( 0, row ); cell->m_bUnderline = enabled; - if (enabled) + if( enabled ) { cell->m_iUnderlineOffset = offset; cell->m_UnderlineColor[0] = r; @@ -337,53 +309,51 @@ void CGrid::Clear() m_bDirty = false; } - CGrid::CGridEntry* CGrid::GridEntry(int x, int y) { - AssertCheck(x >= 0 && x < m_xCols && y >= 0 && y < m_yRows, "CGrid::GridEntry: invalid location specified"); - return &m_GridEntries[y*m_xCols + x]; + AssertCheck( x >= 0 && x < m_xCols && y >= 0 && y < m_yRows, "CGrid::GridEntry: invalid location specified" ); + return &m_GridEntries[y * m_xCols + x]; } - -void CGrid::CalcColOffsets(int iStart) +void CGrid::CalcColOffsets( int iStart ) { int cur = m_xSpacing; - if(iStart != 0) - cur += m_ColOffsets[iStart-1] + m_Widths[iStart-1]; + if( iStart != 0 ) + cur += m_ColOffsets[iStart - 1] + m_Widths[iStart - 1]; - for(int i=iStart; i < m_xCols; i++) + for( int i = iStart; i < m_xCols; i++ ) { m_ColOffsets[i] = cur; cur += m_Widths[i] + m_xSpacing; } } - -void CGrid::CalcRowOffsets(int iStart) +void CGrid::CalcRowOffsets( int iStart ) { int cur = m_ySpacing; - if(iStart != 0) - cur += m_RowOffsets[iStart-1]; + if( iStart != 0 ) + cur += m_RowOffsets[iStart - 1]; - for(int i=iStart; i < m_yRows; i++) + for( int i = iStart; i < m_yRows; i++ ) { m_RowOffsets[i] = cur; cur += m_Heights[i] + m_ySpacing; } } -bool CGrid::getCellAtPoint(int worldX, int worldY, int &row, int &col) +bool CGrid::getCellAtPoint( int worldX, int worldY, int &row, int &col ) { row = -1; col = -1; - for(int x=0; x < m_xCols; x++) + + for( int x = 0; x < m_xCols; x++ ) { - for(int y=0; y < m_yRows; y++) + for( int y = 0; y < m_yRows; y++ ) { - Panel *pPanel = GridEntry(x,y)->m_pPanel; - if (!pPanel) + Panel *pPanel = GridEntry( x, y )->m_pPanel; + if( !pPanel ) continue; - if (pPanel->isWithin(worldX, worldY)) + if( pPanel->isWithin( worldX, worldY ) ) { col = x; row = y; @@ -395,4 +365,3 @@ bool CGrid::getCellAtPoint(int worldX, int worldY, int &row, int &col) return false; } - diff --git a/game_shared/vgui_grid.h b/game_shared/vgui_grid.h index eaf8e1d7..0e45ac4a 100644 --- a/game_shared/vgui_grid.h +++ b/game_shared/vgui_grid.h @@ -4,27 +4,21 @@ // // $NoKeywords: $ //============================================================================= - +#pragma once #ifndef VGUI_GRID_H #define VGUI_GRID_H -#ifdef _WIN32 -#pragma once -#endif - - -#include "vgui_panel.h" +#include "VGUI_Panel.h" namespace vgui { - // The grid control simply manages a grid of panels. You can adjust column sizes and spacings and // configure and fill the panels however you want. // To use this control, call SetDimensions, SetSpacing and fill the controls. class CGrid : public Panel { public: - CGrid(); + CGrid(); virtual ~CGrid(); bool SetDimensions(int xCols, int yRows); // Set how many columns and rows in the grid. @@ -70,8 +64,6 @@ public: bool getCellAtPoint(int worldX, int worldY, int &row, int &col); // Panel overrides. -public: - virtual void paint(); virtual void paintBackground(); @@ -80,8 +72,8 @@ protected: class CGridEntry { public: - CGridEntry(); - ~CGridEntry(); + CGridEntry(); + ~CGridEntry(); Panel *m_pPanel; @@ -96,9 +88,6 @@ protected: void CalcColOffsets(int iStart); void CalcRowOffsets(int iStart); - -protected: - bool m_bDirty; // Set when controls will need to be repositioned. int m_xCols; @@ -112,11 +101,8 @@ protected: int *m_ColOffsets; int *m_RowOffsets; - CGridEntry *m_GridEntries; - + CGridEntry *m_GridEntries; }; - -}; - - +} #endif // VGUI_GRID_H + diff --git a/game_shared/vgui_helpers.cpp b/game_shared/vgui_helpers.cpp index c2694759..79c4e378 100644 --- a/game_shared/vgui_helpers.cpp +++ b/game_shared/vgui_helpers.cpp @@ -7,37 +7,36 @@ #include "vgui_helpers.h" - using namespace vgui; - -void AlignPanel(Panel *pChild, Panel *pParent, int alignment) +void AlignPanel( Panel *pChild, Panel *pParent, int alignment ) { int w, h, cw, ch; - pParent->getSize(w, h); - pChild->getSize(cw, ch); - int xCenter = (w - cw) / 2; - int yCenter = (h - ch) / 2; + pParent->getSize( w, h ); + pChild->getSize( cw, ch ); - if(alignment == Label::a_west) - pChild->setPos(0, yCenter); - else if(alignment == Label::a_northwest) - pChild->setPos(0,0); - else if(alignment == Label::a_north) - pChild->setPos(xCenter, 0); - else if(alignment == Label::a_northeast) - pChild->setPos(w - cw, 0); - else if(alignment == Label::a_east) - pChild->setPos(w - cw, yCenter); - else if(alignment == Label::a_southeast) - pChild->setPos(w - cw, h - ch); - else if(alignment == Label::a_south) - pChild->setPos(xCenter, h - ch); - else if(alignment == Label::a_southwest) - pChild->setPos(0, h - ch); - else if(alignment == Label::a_center) - pChild->setPos(xCenter, yCenter); + int xCenter = ( w - cw ) / 2; + int yCenter = ( h - ch ) / 2; + + if( alignment == Label::a_west ) + pChild->setPos( 0, yCenter ); + else if( alignment == Label::a_northwest ) + pChild->setPos( 0, 0 ); + else if( alignment == Label::a_north ) + pChild->setPos( xCenter, 0 ); + else if( alignment == Label::a_northeast ) + pChild->setPos( w - cw, 0 ); + else if( alignment == Label::a_east ) + pChild->setPos( w - cw, yCenter ); + else if( alignment == Label::a_southeast ) + pChild->setPos( w - cw, h - ch ); + else if( alignment == Label::a_south ) + pChild->setPos( xCenter, h - ch ); + else if( alignment == Label::a_southwest ) + pChild->setPos( 0, h - ch ); + else if( alignment == Label::a_center ) + pChild->setPos( xCenter, yCenter ); } diff --git a/game_shared/vgui_helpers.h b/game_shared/vgui_helpers.h index 09e82667..91c24343 100644 --- a/game_shared/vgui_helpers.h +++ b/game_shared/vgui_helpers.h @@ -4,28 +4,69 @@ // // $NoKeywords: $ //============================================================================= - +#pragma once #ifndef VGUI_HELPERS_H #define VGUI_HELPERS_H -#ifdef _WIN32 -#pragma once -#endif +#include "VGUI_Panel.h" +#include "VGUI_Label.h" -#include "vgui_panel.h" -#include "vgui_label.h" +inline int PanelTop( vgui::Panel *pPanel ) +{ + int x, y, w, h; + pPanel->getBounds( x, y, w, h ); -inline int PanelTop(vgui::Panel *pPanel) {int x,y,w,h; pPanel->getBounds(x,y,w,h); return y;} -inline int PanelLeft(vgui::Panel *pPanel) {int x,y,w,h; pPanel->getBounds(x,y,w,h); return x;} -inline int PanelRight(vgui::Panel *pPanel) {int x,y,w,h; pPanel->getBounds(x,y,w,h); return x+w;} -inline int PanelBottom(vgui::Panel *pPanel) {int x,y,w,h; pPanel->getBounds(x,y,w,h); return y+h;} -inline int PanelWidth(vgui::Panel *pPanel) {int x,y,w,h; pPanel->getBounds(x,y,w,h); return w;} -inline int PanelHeight(vgui::Panel *pPanel) {int x,y,w,h; pPanel->getBounds(x,y,w,h); return h;} + return y; +} + +inline int PanelLeft( vgui::Panel *pPanel ) +{ + int x, y, w, h; + + pPanel->getBounds( x, y, w, h ); + + return x; +} + +inline int PanelRight( vgui::Panel *pPanel ) +{ + int x, y, w, h; + + pPanel->getBounds( x, y, w, h ); + + return x + w; +} + +inline int PanelBottom( vgui::Panel *pPanel ) +{ + int x, y, w, h; + + pPanel->getBounds( x, y, w, h ); + + return y + h; +} + +inline int PanelWidth( vgui::Panel *pPanel ) +{ + int x, y, w, h; + + pPanel->getBounds( x, y, w, h ); + + return w; +} + +inline int PanelHeight( vgui::Panel *pPanel ) +{ + int x, y, w, h; + + pPanel->getBounds( x, y, w, h ); + + return h; +} // Places child at the requested position inside pParent. iAlignment is from Label::Alignment. -void AlignPanel(vgui::Panel *pChild, vgui::Panel *pParent, int alignment); - +void AlignPanel( vgui::Panel *pChild, vgui::Panel *pParent, int alignment ); #endif // VGUI_HELPERS_H diff --git a/game_shared/vgui_listbox.cpp b/game_shared/vgui_listbox.cpp index 6986d909..77b7689b 100644 --- a/game_shared/vgui_listbox.cpp +++ b/game_shared/vgui_listbox.cpp @@ -7,28 +7,25 @@ #include "vgui_listbox.h" - - using namespace vgui; - -CListBox::CListBox() : Panel(0, 0, 0, 0), - m_ItemsPanel(0,0,0,0), - m_ScrollBar(0, 0, 0, 0, true), - m_Slider(0, 0, 10, 40, true) +CListBox::CListBox() : Panel( 0, 0, 0, 0 ), + m_ItemsPanel( 0, 0, 0, 0 ), + m_ScrollBar( 0, 0, 0, 0, true ), + m_Slider( 0, 0, 10, 40, true ) { m_Signal.m_pListBox = this; - m_ItemsPanel.setParent(this); - m_ItemsPanel.setBgColor(0,0,0,255); - - m_Slider.setRangeWindow(50); - m_Slider.setRangeWindowEnabled(true); + m_ItemsPanel.setParent( this ); + m_ItemsPanel.setBgColor( 0, 0, 0, 255 ); - m_ScrollBar.setParent(this); - m_ScrollBar.addIntChangeSignal(&m_Signal); - m_ScrollBar.setSlider(&m_Slider); - m_ScrollBar.setButtonPressedScrollValue(1); + m_Slider.setRangeWindow( 50 ); + m_Slider.setRangeWindowEnabled( true ); + + m_ScrollBar.setParent( this ); + m_ScrollBar.addIntChangeSignal( &m_Signal ); + m_ScrollBar.setSlider( &m_Slider ); + m_ScrollBar.setButtonPressedScrollValue( 1 ); m_Items.m_pNext = m_Items.m_pPrev = &m_Items; m_ItemOffset = 0; @@ -51,40 +48,42 @@ void CListBox::Term() // Free the LBItems. LBItem *pNext; - for(LBItem *pItem=m_Items.m_pNext; pItem != &m_Items; pItem=pNext) + + for( LBItem *pItem =m_Items.m_pNext; pItem != &m_Items; pItem = pNext ) { - pItem->m_pPanel->setParent(NULL); // detach the panel from us + pItem->m_pPanel->setParent( NULL ); // detach the panel from us pNext = pItem->m_pNext; delete pItem; } m_Items.m_pPrev = m_Items.m_pNext = &m_Items; } -void CListBox::AddItem(Panel* panel) +void CListBox::AddItem( Panel *panel ) { // Add the item. LBItem *pItem = new LBItem; - if(!pItem) + if( !pItem ) return; pItem->m_pPanel = panel; - pItem->m_pPanel->setParent(&m_ItemsPanel); + pItem->m_pPanel->setParent( &m_ItemsPanel ); pItem->m_pPrev = m_Items.m_pPrev; pItem->m_pNext = &m_Items; pItem->m_pNext->m_pPrev = pItem->m_pPrev->m_pNext = pItem; - m_ScrollBar.setRange(0, GetScrollMax()); - m_Slider.setRangeWindow(50); - m_Slider.setRangeWindowEnabled(true); + m_ScrollBar.setRange( 0, GetScrollMax() ); + m_Slider.setRangeWindow( 50 ); + m_Slider.setRangeWindowEnabled( true ); InternalLayout(); } int CListBox::GetNumItems() { - int count=0; - for(LBItem *pItem=m_Items.m_pNext; pItem != &m_Items; pItem=pItem->m_pNext) + int count = 0; + + for( LBItem *pItem = m_Items.m_pNext; pItem != &m_Items; pItem = pItem->m_pNext ) ++count; return count; @@ -93,7 +92,9 @@ int CListBox::GetNumItems() int CListBox::GetItemWidth() { int wide, tall; - m_ItemsPanel.getSize(wide, tall); + + m_ItemsPanel.getSize( wide, tall ); + return wide; } @@ -102,29 +103,29 @@ int CListBox::GetScrollPos() return m_ItemOffset; } -void CListBox::SetScrollPos(int pos) +void CListBox::SetScrollPos( int pos ) { int maxItems = GetScrollMax(); - if(maxItems < 0) + if( maxItems < 0 ) return; - m_ItemOffset = (pos < 0) ? 0 : ((pos > maxItems) ? maxItems : pos); + m_ItemOffset = ( pos < 0 ) ? 0 : ( ( pos > maxItems ) ? maxItems : pos ); InternalLayout(); } -void CListBox::setPos(int x, int y) +void CListBox::setPos( int x, int y ) { - Panel::setPos(x, y); + Panel::setPos( x, y ); InternalLayout(); } -void CListBox::setSize(int wide,int tall) +void CListBox::setSize( int wide, int tall ) { - Panel::setSize(wide,tall); + Panel::setSize( wide, tall ); InternalLayout(); } -void CListBox::setPixelScroll(int value) +void CListBox::setPixelScroll( int value ) { m_ItemOffset = m_ScrollBar.getValue(); InternalLayout(); @@ -133,11 +134,11 @@ void CListBox::setPixelScroll(int value) void CListBox::InternalLayout() { int x, y, wide, tall; - getBounds(x, y, wide, tall); + getBounds( x, y, wide, tall ); // Reposition the main panel and the scrollbar. - m_ItemsPanel.setBounds(0, 0, wide-15, tall); - m_ScrollBar.setBounds(wide-15, 0, 15, tall); + m_ItemsPanel.setBounds( 0, 0, wide - 15, tall ); + m_ScrollBar.setBounds( wide - 15, 0, 15, tall ); bool bNeedScrollbar = false; @@ -145,31 +146,32 @@ void CListBox::InternalLayout() int curItem = 0; int curY = 0; int maxItem = GetScrollMax(); - for(LBItem *pItem=m_Items.m_pNext; pItem != &m_Items; pItem=pItem->m_pNext) + for( LBItem *pItem = m_Items.m_pNext; pItem != &m_Items; pItem = pItem->m_pNext ) { - if(curItem < m_ItemOffset) + if( curItem < m_ItemOffset ) { - pItem->m_pPanel->setVisible(false); + pItem->m_pPanel->setVisible( false ); bNeedScrollbar = true; } - else if (curItem >= maxItem) + else if( curItem >= maxItem ) { // item is past the end of the items we care about - pItem->m_pPanel->setVisible(false); + pItem->m_pPanel->setVisible( false ); } else { - pItem->m_pPanel->setVisible(true); + pItem->m_pPanel->setVisible( true ); int itemWidth, itemHeight; - pItem->m_pPanel->getSize(itemWidth, itemHeight); + + pItem->m_pPanel->getSize( itemWidth, itemHeight ); // Don't change the item's height but change its width to fit the listbox. - pItem->m_pPanel->setBounds(0, curY, wide, itemHeight); + pItem->m_pPanel->setBounds( 0, curY, wide, itemHeight ); curY += itemHeight; - if (curY > tall) + if( curY > tall ) { bNeedScrollbar = true; } @@ -178,7 +180,7 @@ void CListBox::InternalLayout() ++curItem; } - m_ScrollBar.setVisible(bNeedScrollbar); + m_ScrollBar.setVisible( bNeedScrollbar ); repaint(); } @@ -187,16 +189,16 @@ void CListBox::paintBackground() { } -void CListBox::SetScrollRange(int maxScroll) +void CListBox::SetScrollRange( int maxScroll ) { m_iScrollMax = maxScroll; - m_ScrollBar.setRange(0, maxScroll); + m_ScrollBar.setRange( 0, maxScroll ); InternalLayout(); } -int CListBox::GetScrollMax() +int CListBox::GetScrollMax() { - if (m_iScrollMax < 0) + if( m_iScrollMax < 0 ) { return GetNumItems() - 1; } @@ -204,4 +206,3 @@ int CListBox::GetScrollMax() return m_iScrollMax; } - diff --git a/game_shared/vgui_listbox.h b/game_shared/vgui_listbox.h index 7191f827..a97c780d 100644 --- a/game_shared/vgui_listbox.h +++ b/game_shared/vgui_listbox.h @@ -4,24 +4,18 @@ // // $NoKeywords: $ //============================================================================= - +#pragma once #ifndef VOICE_LISTBOX_H #define VOICE_LISTBOX_H -#ifdef _WIN32 -#pragma once -#endif - #include "VGUI_Panel.h" #include "VGUI_IntChangeSignal.h" -#include "VGUI_Slider2.h" -#include "VGUI_ScrollBar2.h" - +#include "vgui_slider2.h" +#include "vgui_scrollbar2.h" namespace vgui { - // Listbox class used by voice code. Based off of vgui's list panel but with some modifications: // - This listbox clips its child items to its rectangle. // - You can access things like the scrollbar and find out the item width. @@ -31,45 +25,39 @@ namespace vgui class CListBox : public Panel { public: - - CListBox(); - ~CListBox(); + CListBox(); + ~CListBox(); - void Init(); - void Term(); + void Init(); + void Term(); // Add an item to the listbox. This automatically sets the item's parent to the listbox // and resizes the item's width to fit within the listbox. - void AddItem(Panel *pPanel); + void AddItem( Panel *pPanel ); // Get the number of items currently in the listbox. - int GetNumItems(); + int GetNumItems(); // Get the width that listbox items will be set to (this changes if you resize the listbox). - int GetItemWidth(); + int GetItemWidth(); // Get/set the scrollbar position (position says which element is at the top of the listbox). - int GetScrollPos(); - void SetScrollPos(int pos); + int GetScrollPos(); + void SetScrollPos( int pos ); // sets the last item the listbox should scroll to // scroll to GetNumItems() if not set - void SetScrollRange(int maxScroll); + void SetScrollRange( int maxScroll ); // returns the maximum value the scrollbar can scroll to - int GetScrollMax(); + int GetScrollMax(); -// vgui overrides. -public: - - virtual void setPos(int x, int y); - virtual void setSize(int wide,int tall); - virtual void setPixelScroll(int value); + // vgui overrides. + virtual void setPos( int x, int y ); + virtual void setSize( int wide, int tall ); + virtual void setPixelScroll( int value ); virtual void paintBackground(); - - protected: - class LBItem { public: @@ -80,36 +68,29 @@ protected: class ListBoxSignal : public IntChangeSignal { public: - void intChanged(int value,Panel* panel) + void intChanged( int value, Panel *panel ) { - m_pListBox->setPixelScroll(-value); + m_pListBox->setPixelScroll( -value ); } vgui::CListBox *m_pListBox; }; - -protected: - - void InternalLayout(); - - -protected: + void InternalLayout(); // All the items.. - LBItem m_Items; + LBItem m_Items; - Panel m_ItemsPanel; + Panel m_ItemsPanel; - int m_ItemOffset; // where we're scrolled to - Slider2 m_Slider; - ScrollBar2 m_ScrollBar; + int m_ItemOffset; // where we're scrolled to + Slider2 m_Slider; + ScrollBar2 m_ScrollBar; ListBoxSignal m_Signal; - int m_iScrollMax; + int m_iScrollMax; }; } - - #endif // VOICE_LISTBOX_H + diff --git a/game_shared/vgui_loadtga.cpp b/game_shared/vgui_loadtga.cpp index 5c0d9189..bfd8ee7a 100644 --- a/game_shared/vgui_loadtga.cpp +++ b/game_shared/vgui_loadtga.cpp @@ -7,10 +7,9 @@ #include "../cl_dll/wrect.h" #include "../cl_dll/cl_dll.h" -#include "vgui.h" +#include "VGUI.h" #include "vgui_loadtga.h" -#include "vgui_inputstream.h" - +#include "VGUI_InputStream.h" // ---------------------------------------------------------------------- // // Helper class for loading tga files. @@ -18,76 +17,96 @@ class MemoryInputStream : public vgui::InputStream { public: - MemoryInputStream() - { - m_pData = NULL; - m_DataLen = m_ReadPos = 0; - } - - virtual void seekStart(bool& success) {m_ReadPos=0; success=true;} - virtual void seekRelative(int count,bool& success) {m_ReadPos+=count; success=true;} - virtual void seekEnd(bool& success) {m_ReadPos=m_DataLen; success=true;} - virtual int getAvailable(bool& success) {success=false; return 0;} // This is what vgui does for files... - - virtual uchar readUChar(bool& success) + MemoryInputStream() { - if(m_ReadPos>=0 && m_ReadPos= 0 && m_ReadPos < m_DataLen ) { - success=true; + success = true; uchar ret = m_pData[m_ReadPos]; ++m_ReadPos; return ret; } else { - success=false; + success = false; return 0; } } - virtual void readUChar(uchar* buf,int count,bool& success) + virtual void readUChar( uchar *buf, int count, bool &success ) { - for(int i=0; i < count; i++) - buf[i] = readUChar(success); + for( int i = 0; i < count; i++) + buf[i] = readUChar( success ); } - virtual void close(bool& success) + virtual void close( bool &success) { m_pData = NULL; m_DataLen = m_ReadPos = 0; } - uchar *m_pData; - int m_DataLen; - int m_ReadPos; + uchar *m_pData; + int m_DataLen; + int m_ReadPos; }; -vgui::BitmapTGA* vgui_LoadTGA(char const *pFilename) +vgui::BitmapTGA *vgui_LoadTGA( char const *pFilename ) { MemoryInputStream stream; - stream.m_pData = gEngfuncs.COM_LoadFile((char*)pFilename, 5, &stream.m_DataLen); - if(!stream.m_pData) + stream.m_pData = gEngfuncs.COM_LoadFile( (char*)pFilename, 5, &stream.m_DataLen ); + if( !stream.m_pData ) return NULL; stream.m_ReadPos = 0; - vgui::BitmapTGA *pRet = new vgui::BitmapTGA(&stream, true); - gEngfuncs.COM_FreeFile(stream.m_pData); - + vgui::BitmapTGA *pRet = new vgui::BitmapTGA( &stream, true ); + gEngfuncs.COM_FreeFile( stream.m_pData ); + return pRet; } -vgui::BitmapTGA* vgui_LoadTGANoInvertAlpha(char const *pFilename) +vgui::BitmapTGA *vgui_LoadTGANoInvertAlpha( char const *pFilename ) { MemoryInputStream stream; - - stream.m_pData = gEngfuncs.COM_LoadFile((char*)pFilename, 5, &stream.m_DataLen); - if(!stream.m_pData) + + stream.m_pData = gEngfuncs.COM_LoadFile( (char*)pFilename, 5, &stream.m_DataLen ); + if( !stream.m_pData ) return NULL; - + stream.m_ReadPos = 0; - vgui::BitmapTGA *pRet = new vgui::BitmapTGA(&stream, false); - gEngfuncs.COM_FreeFile(stream.m_pData); + vgui::BitmapTGA *pRet = new vgui::BitmapTGA( &stream, false ); + gEngfuncs.COM_FreeFile( stream.m_pData ); return pRet; } diff --git a/game_shared/vgui_loadtga.h b/game_shared/vgui_loadtga.h index 053d23ff..26505b18 100644 --- a/game_shared/vgui_loadtga.h +++ b/game_shared/vgui_loadtga.h @@ -4,19 +4,13 @@ // // $NoKeywords: $ //============================================================================= - +#pragma once #ifndef VGUI_LOADTGA_H #define VGUI_LOADTGA_H -#ifdef _WIN32 -#pragma once -#endif - - -#include "vgui_bitmaptga.h" - - -vgui::BitmapTGA* vgui_LoadTGA(char const *pFilename); -vgui::BitmapTGA* vgui_LoadTGANoInvertAlpha(char const *pFilename); +#include "VGUI_BitmapTGA.h" +vgui::BitmapTGA *vgui_LoadTGA( char const *pFilename ); +vgui::BitmapTGA *vgui_LoadTGANoInvertAlpha( char const *pFilename ); #endif // VGUI_LOADTGA_H + diff --git a/game_shared/vgui_scrollbar2.cpp b/game_shared/vgui_scrollbar2.cpp index 3f3194bc..805bb191 100644 --- a/game_shared/vgui_scrollbar2.cpp +++ b/game_shared/vgui_scrollbar2.cpp @@ -1,58 +1,56 @@ -//========= Copyright 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright � 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // // $NoKeywords: $ //============================================================================= - -#include "VGUI_ScrollBar2.h" -#include "VGUI_Slider2.h" +#include "vgui_scrollbar2.h" +#include "vgui_slider2.h" #include "vgui_loadtga.h" -#include -#include -#include -#include +#include +#include +#include +#include using namespace vgui; - namespace { class FooDefaultScrollBarIntChangeSignal : public IntChangeSignal { public: - FooDefaultScrollBarIntChangeSignal(ScrollBar2* scrollBar) + FooDefaultScrollBarIntChangeSignal( ScrollBar2 *scrollBar ) { - _scrollBar=scrollBar; + _scrollBar = scrollBar; } - virtual void intChanged(int value,Panel* panel) + + virtual void intChanged( int value, Panel *panel ) { _scrollBar->fireIntChangeSignal(); } protected: - ScrollBar2* _scrollBar; + ScrollBar2 *_scrollBar; }; class FooDefaultButtonSignal : public ActionSignal { public: - ScrollBar2* _scrollBar; - int _buttonIndex; -public: - FooDefaultButtonSignal(ScrollBar2* scrollBar,int buttonIndex) + ScrollBar2 *_scrollBar; + int _buttonIndex; + + FooDefaultButtonSignal( ScrollBar2 *scrollBar, int buttonIndex ) { - _scrollBar=scrollBar; - _buttonIndex=buttonIndex; + _scrollBar = scrollBar; + _buttonIndex = buttonIndex; } -public: - virtual void actionPerformed(Panel* panel) + + virtual void actionPerformed( Panel *panel ) { - _scrollBar->doButtonPressed(_buttonIndex); + _scrollBar->doButtonPressed( _buttonIndex ); } }; - } //----------------------------------------------------------------------------- @@ -65,32 +63,29 @@ private: LineBorder m_Border; public: - ScrollBarButton(const char *filename, int x, int y, int wide, int tall) : m_Border(Color(60, 60, 60, 0)), Button("", x, y, wide, tall) + ScrollBarButton( const char *filename, int x, int y, int wide, int tall ) : m_Border( Color( 60, 60, 60, 0 ) ), Button( "", x, y, wide, tall ) { - Image *image = vgui_LoadTGA(filename); - if (image) + Image *image = vgui_LoadTGA( filename ); + if( image ) { - image->setColor(Color(140, 140, 140, 0)); - setImage(image); + image->setColor( Color( 140, 140, 140, 0 ) ); + setImage( image ); } - setBorder(&m_Border); + setBorder( &m_Border ); } virtual void paintBackground() { - int wide,tall; - getPaintSize(wide,tall); + int wide, tall; + getPaintSize( wide, tall ); // fill the background - drawSetColor(0, 0, 0, 0); - drawFilledRect(0, 0, wide, tall); + drawSetColor( 0, 0, 0, 0 ); + drawFilledRect( 0, 0, wide, tall ); } }; - - - //----------------------------------------------------------------------------- // Purpose: Constructor // Input : x - @@ -99,68 +94,68 @@ public: // tall - // vertical - //----------------------------------------------------------------------------- -ScrollBar2::ScrollBar2(int x,int y,int wide,int tall,bool vertical) : Panel(x,y,wide,tall) +ScrollBar2::ScrollBar2( int x, int y, int wide, int tall, bool vertical ) : Panel( x, y, wide, tall ) { - _slider=null; - _button[0]=null; - _button[1]=null; + _slider = null; + _button[0] = null; + _button[1] = null; - if(vertical) + if( vertical ) { - setSlider(new Slider2(0,wide-1,wide,(tall-(wide*2))+2,true)); - setButton(new ScrollBarButton("gfx/vgui/arrowup.tga",0,0,wide,wide),0); - setButton(new ScrollBarButton("gfx/vgui/arrowdown.tga",0,tall-wide,wide,wide),1); + setSlider( new Slider2( 0, wide - 1, wide, ( tall - ( wide * 2 ) ) + 2, true ) ); + setButton( new ScrollBarButton( "gfx/vgui/arrowup.tga", 0, 0, wide, wide ), 0 ); + setButton( new ScrollBarButton( "gfx/vgui/arrowdown.tga", 0, tall - wide, wide, wide ), 1 ); } else { // untested code - setSlider(new Slider2(tall,0,wide-(tall*2),tall,false)); - setButton(new ScrollBarButton("gfx/vgui/320_arrowlt.tga",0,0,tall+1,tall+1),0); - setButton(new ScrollBarButton("gfx/vgui/320_arrowrt.tga",wide-tall,0,tall+1,tall+1),1); + setSlider( new Slider2( tall, 0, wide - ( tall * 2 ), tall, false ) ); + setButton( new ScrollBarButton( "gfx/vgui/320_arrowlt.tga", 0, 0, tall + 1, tall + 1 ), 0 ); + setButton( new ScrollBarButton( "gfx/vgui/320_arrowrt.tga", wide - tall, 0, tall + 1, tall + 1 ) , 1 ); } - setPaintBorderEnabled(true); - setPaintBackgroundEnabled(true); - setPaintEnabled(true); - setButtonPressedScrollValue(15); + setPaintBorderEnabled( true ); + setPaintBackgroundEnabled( true ); + setPaintEnabled( true ); + setButtonPressedScrollValue( 15 ); validate(); - } +} -void ScrollBar2::setSize(int wide,int tall) +void ScrollBar2::setSize( int wide, int tall ) { - Panel::setSize(wide,tall); + Panel::setSize( wide, tall ); - if(_slider==null) + if( _slider == null ) { return; } - if(_button[0]==null) + if( _button[0] == null ) { return; } - if(_button[1]==null) + if( _button[1] == null ) { return; } - getPaintSize(wide,tall); + getPaintSize( wide, tall ); - if(_slider->isVertical()) + if( _slider->isVertical() ) { - _slider->setBounds(0,wide,wide,tall-(wide*2)); - //_slider->setBounds(0,0,wide,tall); - _button[0]->setBounds(0,0,wide,wide); - _button[1]->setBounds(0,tall-wide,wide,wide); + _slider->setBounds( 0, wide, wide, tall - ( wide * 2 ) ); + // _slider->setBounds( 0, 0, wide, tall ); + _button[0]->setBounds( 0, 0, wide, wide ); + _button[1]->setBounds( 0, tall - wide, wide, wide ); } else { - _slider->setBounds(tall,0,wide-(tall*2),tall); - //_slider->setBounds(0,0,wide,tall); - _button[0]->setBounds(0,0,tall,tall); - _button[1]->setBounds((wide-tall),0,tall,tall); + _slider->setBounds( tall, 0, wide - ( tall * 2 ), tall ); + // _slider->setBounds( 0, 0, wide, tall ); + _button[0]->setBounds( 0, 0, tall, tall ); + _button[1]->setBounds( ( wide - tall ), 0, tall, tall); } } @@ -168,9 +163,9 @@ void ScrollBar2::performLayout() { } -void ScrollBar2::setValue(int value) +void ScrollBar2::setValue( int value ) { - _slider->setValue(value); + _slider->setValue( value ); } int ScrollBar2::getValue() @@ -178,22 +173,22 @@ int ScrollBar2::getValue() return _slider->getValue(); } -void ScrollBar2::addIntChangeSignal(IntChangeSignal* s) +void ScrollBar2::addIntChangeSignal( IntChangeSignal *s ) { - _intChangeSignalDar.putElement(s); - _slider->addIntChangeSignal(new FooDefaultScrollBarIntChangeSignal(this)); + _intChangeSignalDar.putElement( s ); + _slider->addIntChangeSignal( new FooDefaultScrollBarIntChangeSignal( this ) ); } -void ScrollBar2::setRange(int min,int max) +void ScrollBar2::setRange( int min, int max ) { - _slider->setRange(min,max); + _slider->setRange( min, max ); } void ScrollBar2::fireIntChangeSignal() { - for(int i=0;i<_intChangeSignalDar.getCount();i++) + for( int i = 0; i < _intChangeSignalDar.getCount(); i++ ) { - _intChangeSignalDar[i]->intChanged(_slider->getValue(),this); + _intChangeSignalDar[i]->intChanged( _slider->getValue(), this ); } } @@ -207,39 +202,41 @@ bool ScrollBar2::hasFullRange() return _slider->hasFullRange(); } -//LEAK: new and old slider will leak -void ScrollBar2::setButton(Button* button,int index) +// LEAK: new and old slider will leak +void ScrollBar2::setButton( Button *button, int index ) { - if(_button[index]!=null) + if( _button[index] != null ) { - removeChild(_button[index]); + removeChild( _button[index] ); } - _button[index]=button; - addChild(_button[index]); - _button[index]->addActionSignal(new FooDefaultButtonSignal(this,index)); + _button[index] = button; + addChild( _button[index] ); + + _button[index]->addActionSignal( new FooDefaultButtonSignal( this, index ) ); validate(); - //_button[index]->setVisible(false); + // _button[index]->setVisible( false ); } -Button* ScrollBar2::getButton(int index) +Button *ScrollBar2::getButton( int index ) { return _button[index]; } -//LEAK: new and old slider will leak -void ScrollBar2::setSlider(Slider2 *slider) +// LEAK: new and old slider will leak +void ScrollBar2::setSlider( Slider2 *slider ) { - if(_slider!=null) + if( _slider != null ) { - removeChild(_slider); + removeChild( _slider ); } - _slider=slider; - addChild(_slider); - _slider->addIntChangeSignal(new FooDefaultScrollBarIntChangeSignal(this)); + _slider = slider; + addChild( _slider ); + + _slider->addIntChangeSignal( new FooDefaultScrollBarIntChangeSignal( this ) ); validate(); } @@ -249,62 +246,62 @@ Slider2 *ScrollBar2::getSlider() return _slider; } -void ScrollBar2::doButtonPressed(int buttonIndex) +void ScrollBar2::doButtonPressed( int buttonIndex ) { - if(buttonIndex==0) + if( buttonIndex == 0 ) { - _slider->setValue(_slider->getValue()-_buttonPressedScrollValue); + _slider->setValue( _slider->getValue() - _buttonPressedScrollValue ); } else { - _slider->setValue(_slider->getValue()+_buttonPressedScrollValue); + _slider->setValue( _slider->getValue() + _buttonPressedScrollValue ); } - } -void ScrollBar2::setButtonPressedScrollValue(int value) +void ScrollBar2::setButtonPressedScrollValue( int value ) { - _buttonPressedScrollValue=value; + _buttonPressedScrollValue = value; } -void ScrollBar2::setRangeWindow(int rangeWindow) +void ScrollBar2::setRangeWindow( int rangeWindow ) { - _slider->setRangeWindow(rangeWindow); + _slider->setRangeWindow( rangeWindow ); } -void ScrollBar2::setRangeWindowEnabled(bool state) +void ScrollBar2::setRangeWindowEnabled( bool state ) { - _slider->setRangeWindowEnabled(state); + _slider->setRangeWindowEnabled( state ); } void ScrollBar2::validate() { - if(_slider!=null) + if( _slider != null ) { - int buttonOffset=0; + int buttonOffset = 0; - for(int i=0;i<2;i++) + for( int i = 0; i < 2; i++ ) { - if(_button[i]!=null) + if( _button[i] != null ) { - if(_button[i]->isVisible()) + if( _button[i]->isVisible() ) { - if(_slider->isVertical()) - { - buttonOffset+=_button[i]->getTall(); + if( _slider->isVertical() ) + { + buttonOffset += _button[i]->getTall(); } else { - buttonOffset+=_button[i]->getWide(); + buttonOffset += _button[i]->getWide(); } } } } - _slider->setButtonOffset(buttonOffset); + _slider->setButtonOffset( buttonOffset ); } - int wide,tall; - getSize(wide,tall); - setSize(wide,tall); + int wide, tall; + + getSize( wide, tall ); + setSize( wide, tall ); } diff --git a/game_shared/vgui_scrollbar2.h b/game_shared/vgui_scrollbar2.h index ad2d2d05..71cd965b 100644 --- a/game_shared/vgui_scrollbar2.h +++ b/game_shared/vgui_scrollbar2.h @@ -4,20 +4,16 @@ // // $NoKeywords: $ //============================================================================= - +#pragma once #ifndef VGUI_SCROLLBAR2_H #define VGUI_SCROLLBAR2_H -#ifdef _WIN32 -#pragma once -#endif -#include -#include -#include +#include +#include +#include namespace vgui { - class IntChangeSignal; class Button; class Slider2; @@ -28,35 +24,34 @@ class Slider2; class VGUIAPI ScrollBar2 : public Panel { public: - ScrollBar2(int x,int y,int wide,int tall,bool vertical); -public: - virtual void setValue(int value); - virtual int getValue(); - virtual void addIntChangeSignal(IntChangeSignal* s); - virtual void setRange(int min,int max); - virtual void setRangeWindow(int rangeWindow); - virtual void setRangeWindowEnabled(bool state); - virtual void setSize(int wide,int tall); - virtual bool isVertical(); - virtual bool hasFullRange(); - virtual void setButton(Button *button,int index); - virtual Button* getButton(int index); - virtual void setSlider(Slider2 *slider); - virtual Slider2 *getSlider(); - virtual void doButtonPressed(int buttonIndex); - virtual void setButtonPressedScrollValue(int value); - virtual void validate(); -public: //bullshit public - virtual void fireIntChangeSignal(); + ScrollBar2( int x, int y, int wide, int tall, bool vertical ); + + virtual void setValue( int value ); + virtual int getValue(); + virtual void addIntChangeSignal( IntChangeSignal *s ); + virtual void setRange(int min, int max ); + virtual void setRangeWindow( int rangeWindow ); + virtual void setRangeWindowEnabled( bool state ); + virtual void setSize( int wide, int tall ); + virtual bool isVertical(); + virtual bool hasFullRange(); + virtual void setButton( Button *button,int index ); + virtual Button *getButton( int index ); + virtual void setSlider( Slider2 *slider ); + virtual Slider2 *getSlider(); + virtual void doButtonPressed( int buttonIndex ); + virtual void setButtonPressedScrollValue( int value ); + virtual void validate(); + // bullshit public + virtual void fireIntChangeSignal(); protected: - virtual void performLayout(); -protected: - Button* _button[2]; - Slider2 *_slider; - Dar _intChangeSignalDar; - int _buttonPressedScrollValue; + virtual void performLayout(); + + Button *_button[2]; + Slider2 *_slider; + Dar _intChangeSignalDar; + int _buttonPressedScrollValue; }; - } - #endif // VGUI_SCROLLBAR2_H + diff --git a/game_shared/vgui_slider2.cpp b/game_shared/vgui_slider2.cpp index 801f5c00..d7e2c564 100644 --- a/game_shared/vgui_slider2.cpp +++ b/game_shared/vgui_slider2.cpp @@ -5,12 +5,12 @@ // $NoKeywords: $ //============================================================================= -#include "VGUI_Slider2.h" +#include "vgui_slider2.h" -#include -#include -#include -#include +#include +#include +#include +#include using namespace vgui; @@ -18,54 +18,57 @@ namespace { class FooDefaultSliderSignal : public InputSignal { -private: - Slider2* _slider; + Slider2 *_slider; public: - FooDefaultSliderSignal(Slider2* slider) + FooDefaultSliderSignal( Slider2 *slider ) { - _slider=slider; + _slider = slider; } -public: - void cursorMoved(int x,int y,Panel* panel) + + void cursorMoved( int x, int y, Panel *panel ) { - _slider->privateCursorMoved(x,y,panel); + _slider->privateCursorMoved( x, y, panel ); } - void cursorEntered(Panel* panel){} - void cursorExited(Panel* panel){} - void mouseDoublePressed(MouseCode code,Panel* panel){} - void mousePressed(MouseCode code,Panel* panel) + + void cursorEntered( Panel *panel ) {} + void cursorExited( Panel *panel ) {} + void mouseDoublePressed( MouseCode code, Panel *panel ) {} + + void mousePressed( MouseCode code, Panel *panel ) { - _slider->privateMousePressed(code,panel); + _slider->privateMousePressed( code, panel ); } - void mouseReleased(MouseCode code,Panel* panel) + + void mouseReleased( MouseCode code, Panel *panel ) { - _slider->privateMouseReleased(code,panel); + _slider->privateMouseReleased( code, panel ); } - void mouseWheeled(int delta,Panel* panel){} - void keyPressed(KeyCode code,Panel* panel){} - void keyTyped(KeyCode code,Panel* panel){} - void keyReleased(KeyCode code,Panel* panel){} - void keyFocusTicked(Panel* panel){} + + void mouseWheeled( int delta, Panel *panel ) {} + void keyPressed( KeyCode code, Panel *panel ) {} + void keyTyped( KeyCode code, Panel *panel ) {} + void keyReleased( KeyCode code, Panel *panel ) {} + void keyFocusTicked( Panel *panel ) {} }; } -Slider2::Slider2(int x,int y,int wide,int tall,bool vertical) : Panel(x,y,wide,tall) +Slider2::Slider2( int x, int y, int wide, int tall, bool vertical ) : Panel( x, y, wide, tall ) { - _vertical=vertical; - _dragging=false; - _value=0; - _range[0]=0; - _range[1]=299; - _rangeWindow=0; - _rangeWindowEnabled=false; - _buttonOffset=0; + _vertical = vertical; + _dragging = false; + _value = 0; + _range[0] = 0; + _range[1] = 299; + _rangeWindow = 0; + _rangeWindowEnabled = false; + _buttonOffset = 0; recomputeNobPosFromValue(); - addInputSignal(new FooDefaultSliderSignal(this)); + addInputSignal( new FooDefaultSliderSignal( this ) ); } -void Slider2::setSize(int wide,int tall) +void Slider2::setSize( int wide, int tall ) { - Panel::setSize(wide,tall); + Panel::setSize( wide, tall ); recomputeNobPosFromValue(); } @@ -74,24 +77,24 @@ bool Slider2::isVertical() return _vertical; } -void Slider2::setValue(int value) +void Slider2::setValue( int value ) { - int oldValue=_value; + int oldValue = _value; - if(value<_range[0]) + if( value < _range[0] ) { - value=_range[0]; + value = _range[0]; } - if(value>_range[1]) + if( value > _range[1] ) { value=_range[1]; } - _value=value; + _value = value; recomputeNobPosFromValue(); - if(_value!=oldValue) + if( _value != oldValue ) { fireIntChangeSignal(); } @@ -104,48 +107,48 @@ int Slider2::getValue() void Slider2::recomputeNobPosFromValue() { - int wide,tall; + int wide, tall; - getPaintSize(wide,tall); + getPaintSize( wide, tall ); - float fwide=(float)wide; - float ftall=(float)tall; - float frange=(float)(_range[1]-_range[0]); - float fvalue=(float)(_value-_range[0]); - float fper=fvalue/frange; - float frangewindow=(float)(_rangeWindow); + float fwide = (float)wide; + float ftall = (float)tall; + float frange = (float)(_range[1] - _range[0]); + float fvalue = (float)(_value - _range[0]); + float fper = fvalue / frange; + float frangewindow = (float)_rangeWindow; - if(frangewindow<0) + if( frangewindow < 0 ) { - frangewindow=0; + frangewindow = 0; } - if(!_rangeWindowEnabled) + if( !_rangeWindowEnabled ) { - frangewindow=frange; + frangewindow = frange; } - if ( frangewindow > 0 ) + if( frangewindow > 0 ) { - if(_vertical) + if( _vertical ) { float fnobsize=frangewindow; float freepixels = ftall - fnobsize; float firstpixel = freepixels * fper; - _nobPos[0]=(int)( firstpixel ); - _nobPos[1]=(int)( firstpixel + fnobsize ); + _nobPos[0] = (int)( firstpixel ); + _nobPos[1] = (int)( firstpixel + fnobsize ); - if(_nobPos[1]>tall) + if( _nobPos[1] > tall ) { - _nobPos[0]=tall-((int)fnobsize); - _nobPos[1]=tall; + _nobPos[0] = tall - ((int)fnobsize); + _nobPos[1] = tall; } } else { - float fnobsize=frangewindow; + float fnobsize = frangewindow; float freepixels = fwide - fnobsize; float firstpixel = freepixels * fper; @@ -153,10 +156,10 @@ void Slider2::recomputeNobPosFromValue() _nobPos[0]=(int)( firstpixel ); _nobPos[1]=(int)( firstpixel + fnobsize ); - if(_nobPos[1]>wide) + if( _nobPos[1] > wide ) { - _nobPos[0]=wide-((int)fnobsize); - _nobPos[1]=wide; + _nobPos[0] = wide - ((int)fnobsize); + _nobPos[1] = wide; } } } @@ -167,40 +170,41 @@ void Slider2::recomputeNobPosFromValue() void Slider2::recomputeValueFromNobPos() { int wide,tall; - getPaintSize(wide,tall); - float fwide=(float)wide; - float ftall=(float)tall; - float frange=(float)(_range[1]-_range[0]); - float fvalue=(float)(_value-_range[0]); - float fnob=(float)_nobPos[0]; - float frangewindow=(float)(_rangeWindow); + getPaintSize( wide, tall ); - if(frangewindow<0) + float fwide = (float)wide; + float ftall = (float)tall; + float frange = (float)(_range[1] - _range[0]); + float fvalue = (float)(_value - _range[0]); + float fnob = (float)_nobPos[0]; + float frangewindow = (float)(_rangeWindow); + + if( frangewindow < 0 ) { - frangewindow=0; + frangewindow = 0; } - if(!_rangeWindowEnabled) + if( !_rangeWindowEnabled ) { - frangewindow=frange; + frangewindow = frange; } - if ( frangewindow > 0 ) + if( frangewindow > 0 ) { - if(_vertical) + if( _vertical ) { - float fnobsize=frangewindow; - fvalue=frange*(fnob/(ftall-fnobsize)); + float fnobsize = frangewindow; + fvalue = frange * ( fnob / ( ftall - fnobsize ) ); } else { - float fnobsize=frangewindow; - fvalue=frange*(fnob/(fwide-fnobsize)); + float fnobsize = frangewindow; + fvalue = frange * ( fnob / ( fwide - fnobsize ) ); } } // Take care of rounding issues. - _value=(int)(fvalue+_range[0]+0.5); + _value = (int)( fvalue+_range[0] + 0.5 ); // Clamp final result _value = ( _value < _range[1] ) ? _value : _range[1]; @@ -208,27 +212,28 @@ void Slider2::recomputeValueFromNobPos() bool Slider2::hasFullRange() { - int wide,tall; - getPaintSize(wide,tall); + int wide, tall; - float fwide=(float)wide; - float ftall=(float)tall; - float frange=(float)(_range[1]-_range[0]); - float frangewindow=(float)(_rangeWindow); + getPaintSize( wide, tall ); - if(frangewindow<0) + float fwide = (float)wide; + float ftall = (float)tall; + float frange = (float)( _range[1] - _range[0] ); + float frangewindow = (float)( _rangeWindow ); + + if( frangewindow < 0 ) { - frangewindow=0; + frangewindow = 0; } - if(!_rangeWindowEnabled) + if( !_rangeWindowEnabled ) { - frangewindow=frange; + frangewindow = frange; } - if ( frangewindow > 0 ) + if( frangewindow > 0 ) { - if(_vertical) + if( _vertical ) { if( frangewindow <= ( ftall + _buttonOffset ) ) { @@ -247,126 +252,125 @@ bool Slider2::hasFullRange() return false; } -void Slider2::addIntChangeSignal(IntChangeSignal* s) +void Slider2::addIntChangeSignal( IntChangeSignal *s ) { _intChangeSignalDar.putElement(s); } void Slider2::fireIntChangeSignal() { - for(int i=0;i<_intChangeSignalDar.getCount();i++) + for( int i = 0; i < _intChangeSignalDar.getCount(); i++ ) { - _intChangeSignalDar[i]->intChanged(getValue(),this); + _intChangeSignalDar[i]->intChanged( getValue(), this ); } } void Slider2::paintBackground() { - int wide,tall; - getPaintSize(wide,tall); + int wide, tall; + getPaintSize( wide, tall ); - if (_vertical) + if( _vertical ) { // background behind slider - drawSetColor(40, 40, 40, 0); - drawFilledRect(0, 0, wide, tall); + drawSetColor( 40, 40, 40, 0 ); + drawFilledRect( 0, 0, wide, tall ); // slider front - drawSetColor(0, 0, 0, 0); - drawFilledRect(0,_nobPos[0],wide,_nobPos[1]); + drawSetColor( 0, 0, 0, 0 ); + drawFilledRect( 0, _nobPos[0], wide, _nobPos[1] ); // slider border - drawSetColor(60, 60, 60, 0); - drawFilledRect(0,_nobPos[0],wide,_nobPos[0]+1); // top - drawFilledRect(0,_nobPos[1],wide,_nobPos[1]+1); // bottom - drawFilledRect(0,_nobPos[0]+1,1,_nobPos[1]); // left - drawFilledRect(wide-1,_nobPos[0]+1,wide,_nobPos[1]); // right + drawSetColor( 60, 60, 60, 0 ); + drawFilledRect( 0, _nobPos[0], wide, _nobPos[0] + 1 ); // top + drawFilledRect( 0, _nobPos[1], wide, _nobPos[1] + 1 ); // bottom + drawFilledRect( 0, _nobPos[0] + 1, 1, _nobPos[1] ); // left + drawFilledRect( wide - 1, _nobPos[0] + 1, wide, _nobPos[1] ); // right } else { //!! doesn't work + drawSetColor( Scheme::sc_secondary3 ); + drawFilledRect( 0, 0, wide, tall ); - drawSetColor(Scheme::sc_secondary3); - drawFilledRect(0,0,wide,tall); + drawSetColor( Scheme::sc_black ); + drawOutlinedRect( 0, 0, wide, tall ); - drawSetColor(Scheme::sc_black); - drawOutlinedRect(0,0,wide,tall); - - drawSetColor(Scheme::sc_primary2); - drawFilledRect(_nobPos[0],0,_nobPos[1],tall); + drawSetColor( Scheme::sc_primary2 ); + drawFilledRect( _nobPos[0], 0, _nobPos[1], tall ); - drawSetColor(Scheme::sc_black); - drawOutlinedRect(_nobPos[0],0,_nobPos[1],tall); + drawSetColor( Scheme::sc_black ); + drawOutlinedRect( _nobPos[0], 0, _nobPos[1], tall ); } } -void Slider2::setRange(int min,int max) +void Slider2::setRange( int min, int max ) { - if(maxmax) + if( min > max ) { - min=max; + min = max; } - _range[0]=min; - _range[1]=max; + _range[0] = min; + _range[1] = max; } -void Slider2::getRange(int& min,int& max) +void Slider2::getRange( int &min, int &max ) { - min=_range[0]; - max=_range[1]; + min = _range[0]; + max = _range[1]; } -void Slider2::privateCursorMoved(int x,int y,Panel* panel) +void Slider2::privateCursorMoved( int x, int y, Panel *panel ) { - if(!_dragging) + if( !_dragging ) { return; } - getApp()->getCursorPos(x,y); - screenToLocal(x,y); + getApp()->getCursorPos( x, y ); + screenToLocal( x, y ); - int wide,tall; - getPaintSize(wide,tall); + int wide, tall; + getPaintSize( wide, tall); - if(_vertical) + if( _vertical ) { - _nobPos[0]=_nobDragStartPos[0]+(y-_dragStartPos[1]); - _nobPos[1]=_nobDragStartPos[1]+(y-_dragStartPos[1]); + _nobPos[0] = _nobDragStartPos[0] + ( y - _dragStartPos[1] ); + _nobPos[1] = _nobDragStartPos[1] + ( y - _dragStartPos[1] ); - if(_nobPos[1]>tall) + if( _nobPos[1] > tall ) { - _nobPos[0]=tall-(_nobPos[1]-_nobPos[0]); - _nobPos[1]=tall; + _nobPos[0] = tall - ( _nobPos[1] - _nobPos[0] ); + _nobPos[1] = tall; } - - if(_nobPos[0]<0) + + if( _nobPos[0] < 0 ) { - _nobPos[1]=_nobPos[1]-_nobPos[0]; - _nobPos[0]=0; + _nobPos[1] = _nobPos[1] - _nobPos[0]; + _nobPos[0] = 0; } } else { - _nobPos[0]=_nobDragStartPos[0]+(x-_dragStartPos[0]); - _nobPos[1]=_nobDragStartPos[1]+(x-_dragStartPos[0]); + _nobPos[0] = _nobDragStartPos[0] + ( x - _dragStartPos[0] ); + _nobPos[1] = _nobDragStartPos[1] + ( x - _dragStartPos[0] ); - if(_nobPos[1]>wide) + if( _nobPos[1] > wide ) { - _nobPos[0]=wide-(_nobPos[1]-_nobPos[0]); - _nobPos[1]=wide; + _nobPos[0] = wide - ( _nobPos[1] - _nobPos[0] ); + _nobPos[1] = wide; } - - if(_nobPos[0]<0) + + if( _nobPos[0] < 0 ) { - _nobPos[1]=_nobPos[1]-_nobPos[0]; - _nobPos[0]=0; + _nobPos[1] = _nobPos[1] - _nobPos[0]; + _nobPos[0] = 0; } } @@ -375,62 +379,61 @@ void Slider2::privateCursorMoved(int x,int y,Panel* panel) fireIntChangeSignal(); } -void Slider2::privateMousePressed(MouseCode code,Panel* panel) +void Slider2::privateMousePressed( MouseCode code, Panel *panel ) { int x,y; - getApp()->getCursorPos(x,y); - screenToLocal(x,y); + getApp()->getCursorPos( x, y ); + screenToLocal( x, y ); - if(_vertical) + if( _vertical ) { - if((y>=_nobPos[0])&&(y<_nobPos[1])) + if( ( y >= _nobPos[0] ) && ( y < _nobPos[1] ) ) { - _dragging=true; - getApp()->setMouseCapture(this); - _nobDragStartPos[0]=_nobPos[0]; - _nobDragStartPos[1]=_nobPos[1]; - _dragStartPos[0]=x; - _dragStartPos[1]=y; + _dragging = true; + getApp()->setMouseCapture( this ); + _nobDragStartPos[0] = _nobPos[0]; + _nobDragStartPos[1] = _nobPos[1]; + _dragStartPos[0] = x; + _dragStartPos[1] = y; } } else { - if((x>=_nobPos[0])&&(x<_nobPos[1])) + if( ( x >= _nobPos[0] ) && ( x < _nobPos[1] ) ) { - _dragging=true; - getApp()->setMouseCapture(this); - _nobDragStartPos[0]=_nobPos[0]; - _nobDragStartPos[1]=_nobPos[1]; - _dragStartPos[0]=x; - _dragStartPos[1]=y; + _dragging = true; + getApp()->setMouseCapture( this ); + _nobDragStartPos[0] = _nobPos[0]; + _nobDragStartPos[1] = _nobPos[1]; + _dragStartPos[0] = x; + _dragStartPos[1] = y; } } - } -void Slider2::privateMouseReleased(MouseCode code,Panel* panel) +void Slider2::privateMouseReleased( MouseCode code, Panel *panel ) { - _dragging=false; - getApp()->setMouseCapture(null); + _dragging = false; + getApp()->setMouseCapture( null ); } -void Slider2::getNobPos(int& min, int& max) +void Slider2::getNobPos( int &min, int &max ) { - min=_nobPos[0]; - max=_nobPos[1]; + min = _nobPos[0]; + max = _nobPos[1]; } -void Slider2::setRangeWindow(int rangeWindow) +void Slider2::setRangeWindow( int rangeWindow ) { _rangeWindow=rangeWindow; } -void Slider2::setRangeWindowEnabled(bool state) +void Slider2::setRangeWindowEnabled( bool state ) { _rangeWindowEnabled=state; } -void Slider2::setButtonOffset(int buttonOffset) +void Slider2::setButtonOffset( int buttonOffset ) { _buttonOffset=buttonOffset; -} \ No newline at end of file +} diff --git a/game_shared/vgui_slider2.h b/game_shared/vgui_slider2.h index 4edb87f2..9f9388c8 100644 --- a/game_shared/vgui_slider2.h +++ b/game_shared/vgui_slider2.h @@ -4,26 +4,21 @@ // // $NoKeywords: $ //============================================================================= - +#pragma once #ifndef VGUI_SLIDER2_H #define VGUI_SLIDER2_H -#ifdef _WIN32 -#pragma once -#endif -#include -#include -#include +#include +#include +#include namespace vgui { - enum MouseCode; class IntChangeSignal; class VGUIAPI Slider2 : public Panel { -private: bool _vertical; bool _dragging; int _nobPos[2]; @@ -36,32 +31,31 @@ private: bool _rangeWindowEnabled; int _buttonOffset; public: - Slider2(int x,int y,int wide,int tall,bool vertical); -public: - virtual void setValue(int value); + Slider2( int x, int y, int wide, int tall, bool vertical ); + + virtual void setValue( int value ); virtual int getValue(); virtual bool isVertical(); - virtual void addIntChangeSignal(IntChangeSignal* s); - virtual void setRange(int min,int max); - virtual void getRange(int& min,int& max); - virtual void setRangeWindow(int rangeWindow); - virtual void setRangeWindowEnabled(bool state); - virtual void setSize(int wide,int tall); - virtual void getNobPos(int& min, int& max); + virtual void addIntChangeSignal( IntChangeSignal *s ); + virtual void setRange( int min, int max ); + virtual void getRange( int &min, int &max ); + virtual void setRangeWindow( int rangeWindow ); + virtual void setRangeWindowEnabled( bool state ); + virtual void setSize( int wide, int tall ); + virtual void getNobPos( int &min, int &max ); virtual bool hasFullRange(); - virtual void setButtonOffset(int buttonOffset); + virtual void setButtonOffset( int buttonOffset ); private: virtual void recomputeNobPosFromValue(); virtual void recomputeValueFromNobPos(); -public: //bullshit public - virtual void privateCursorMoved(int x,int y,Panel* panel); - virtual void privateMousePressed(MouseCode code,Panel* panel); - virtual void privateMouseReleased(MouseCode code,Panel* panel); +public: // bullshit public + virtual void privateCursorMoved( int x, int y, Panel *panel ); + virtual void privateMousePressed( MouseCode code, Panel *panel ); + virtual void privateMouseReleased( MouseCode code, Panel *panel ); protected: - virtual void fireIntChangeSignal(); + virtual void fireIntChangeSignal(); virtual void paintBackground(); }; - } #endif // VGUI_SLIDER2_H diff --git a/game_shared/voice_banmgr.cpp b/game_shared/voice_banmgr.cpp index 915e854f..f8241bf3 100644 --- a/game_shared/voice_banmgr.cpp +++ b/game_shared/voice_banmgr.cpp @@ -9,79 +9,73 @@ #include #include "voice_banmgr.h" - #define BANMGR_FILEVERSION 1 char const *g_pBanMgrFilename = "voice_ban.dt"; - - // Hash a player ID to a byte. -unsigned char HashPlayerID(char const playerID[16]) +unsigned char HashPlayerID( char const playerID[16] ) { unsigned char curHash = 0; - for(int i=0; i < 16; i++) + for( int i = 0; i < 16; i++ ) curHash += (unsigned char)playerID[i]; return curHash; } - - CVoiceBanMgr::CVoiceBanMgr() { Clear(); } - CVoiceBanMgr::~CVoiceBanMgr() { Term(); } - -bool CVoiceBanMgr::Init(char const *pGameDir) +bool CVoiceBanMgr::Init( char const *pGameDir ) { Term(); char filename[512]; - _snprintf(filename, sizeof(filename), "%s/%s", pGameDir, g_pBanMgrFilename); + sprintf( filename, "%s/%s", pGameDir, g_pBanMgrFilename ); // Load in the squelch file. - FILE *fp = fopen(filename, "rb"); - if(fp) + FILE *fp = fopen( filename, "rb" ); + if( fp ) { int version; - fread(&version, 1, sizeof(version), fp); - if(version == BANMGR_FILEVERSION) + fread( &version, 1, sizeof(version), fp ); + if( version == BANMGR_FILEVERSION ) { - fseek(fp, 0, SEEK_END); - int nIDs = (ftell(fp) - sizeof(version)) / 16; - fseek(fp, sizeof(version), SEEK_SET); + fseek( fp, 0, SEEK_END ); + int nIDs = ( ftell( fp ) - sizeof(version) ) / 16; + fseek( fp, sizeof(version), SEEK_SET ); - for(int i=0; i < nIDs; i++) + for( int i = 0; i < nIDs; i++ ) { char playerID[16]; - fread(playerID, 1, 16, fp); - AddBannedPlayer(playerID); - } + + fread( playerID, 1, 16, fp ); + AddBannedPlayer( playerID ); + } } - fclose(fp); + fclose( fp ); } return true; } - void CVoiceBanMgr::Term() { // Free all the player structures. - for(int i=0; i < 256; i++) + for( int i = 0; i < 256; i++ ) { BannedPlayer *pListHead = &m_PlayerHash[i]; BannedPlayer *pNext; - for(BannedPlayer *pCur=pListHead->m_pNext; pCur != pListHead; pCur=pNext) + + for( BannedPlayer *pCur=pListHead->m_pNext; pCur != pListHead; pCur = pNext ) { pNext = pCur->m_pNext; delete pCur; @@ -91,53 +85,51 @@ void CVoiceBanMgr::Term() Clear(); } - void CVoiceBanMgr::SaveState(char const *pGameDir) { // Save the file out. char filename[512]; - _snprintf(filename, sizeof(filename), "%s/%s", pGameDir, g_pBanMgrFilename); - FILE *fp = fopen(filename, "wb"); - if(fp) + sprintf( filename, "%s/%s", pGameDir, g_pBanMgrFilename ); + + FILE *fp = fopen( filename, "wb" ); + if( fp ) { int version = BANMGR_FILEVERSION; - fwrite(&version, 1, sizeof(version), fp); + fwrite( &version, 1, sizeof(version), fp ); - for(int i=0; i < 256; i++) + for( int i = 0; i < 256; i++ ) { BannedPlayer *pListHead = &m_PlayerHash[i]; - for(BannedPlayer *pCur=pListHead->m_pNext; pCur != pListHead; pCur=pCur->m_pNext) + for( BannedPlayer *pCur = pListHead->m_pNext; pCur != pListHead; pCur = pCur->m_pNext ) { - fwrite(pCur->m_PlayerID, 1, 16, fp); + fwrite( pCur->m_PlayerID, 1, 16, fp ); } } - fclose(fp); + fclose( fp ); } } - -bool CVoiceBanMgr::GetPlayerBan(char const playerID[16]) +bool CVoiceBanMgr::GetPlayerBan( char const playerID[16] ) { - return !!InternalFindPlayerSquelch(playerID); + return !!InternalFindPlayerSquelch( playerID ); } - -void CVoiceBanMgr::SetPlayerBan(char const playerID[16], bool bSquelch) +void CVoiceBanMgr::SetPlayerBan( char const playerID[16], bool bSquelch ) { - if(bSquelch) + if( bSquelch ) { // Is this guy already squelched? - if(GetPlayerBan(playerID)) + if( GetPlayerBan( playerID ) ) return; - - AddBannedPlayer(playerID); + + AddBannedPlayer( playerID ); } else { - BannedPlayer *pPlayer = InternalFindPlayerSquelch(playerID); - if(pPlayer) + BannedPlayer *pPlayer = InternalFindPlayerSquelch( playerID ); + if( pPlayer ) { pPlayer->m_pPrev->m_pNext = pPlayer->m_pNext; pPlayer->m_pNext->m_pPrev = pPlayer->m_pPrev; @@ -146,52 +138,51 @@ void CVoiceBanMgr::SetPlayerBan(char const playerID[16], bool bSquelch) } } - -void CVoiceBanMgr::ForEachBannedPlayer(void (*callback)(char id[16])) +void CVoiceBanMgr::ForEachBannedPlayer(void (*callback)( char id[16] ) ) { - for(int i=0; i < 256; i++) + for( int i = 0; i < 256; i++ ) { - for(BannedPlayer *pCur=m_PlayerHash[i].m_pNext; pCur != &m_PlayerHash[i]; pCur=pCur->m_pNext) + for( BannedPlayer *pCur = m_PlayerHash[i].m_pNext; pCur != &m_PlayerHash[i]; pCur = pCur->m_pNext ) { - callback(pCur->m_PlayerID); + callback( pCur->m_PlayerID ); } } } - void CVoiceBanMgr::Clear() { // Tie off the hash table entries. - for(int i=0; i < 256; i++) + for( int i = 0; i < 256; i++ ) m_PlayerHash[i].m_pNext = m_PlayerHash[i].m_pPrev = &m_PlayerHash[i]; } - -CVoiceBanMgr::BannedPlayer* CVoiceBanMgr::InternalFindPlayerSquelch(char const playerID[16]) +CVoiceBanMgr::BannedPlayer *CVoiceBanMgr::InternalFindPlayerSquelch( char const playerID[16] ) { - int index = HashPlayerID(playerID); + int index = HashPlayerID( playerID ); + BannedPlayer *pListHead = &m_PlayerHash[index]; - for(BannedPlayer *pCur=pListHead->m_pNext; pCur != pListHead; pCur=pCur->m_pNext) + for( BannedPlayer *pCur = pListHead->m_pNext; pCur != pListHead; pCur=pCur->m_pNext ) { - if(memcmp(playerID, pCur->m_PlayerID, 16) == 0) + if( memcmp( playerID, pCur->m_PlayerID, 16 ) == 0 ) return pCur; } return NULL; } - -CVoiceBanMgr::BannedPlayer* CVoiceBanMgr::AddBannedPlayer(char const playerID[16]) +CVoiceBanMgr::BannedPlayer* CVoiceBanMgr::AddBannedPlayer( char const playerID[16] ) { BannedPlayer *pNew = new BannedPlayer; - if(!pNew) + if( !pNew ) return NULL; - int index = HashPlayerID(playerID); - memcpy(pNew->m_PlayerID, playerID, 16); + int index = HashPlayerID( playerID ); + + memcpy( pNew->m_PlayerID, playerID, 16 ); pNew->m_pNext = &m_PlayerHash[index]; pNew->m_pPrev = m_PlayerHash[index].m_pPrev; pNew->m_pPrev->m_pNext = pNew->m_pNext->m_pPrev = pNew; + return pNew; } diff --git a/game_shared/voice_banmgr.h b/game_shared/voice_banmgr.h index 610ad6cf..64c0c2bb 100644 --- a/game_shared/voice_banmgr.h +++ b/game_shared/voice_banmgr.h @@ -4,54 +4,43 @@ // // $NoKeywords: $ //============================================================================= - +#pragma once #ifndef VOICE_BANMGR_H #define VOICE_BANMGR_H -#ifdef _WIN32 -#pragma once -#endif - // This class manages the (persistent) list of squelched players. class CVoiceBanMgr { public: - - CVoiceBanMgr(); - ~CVoiceBanMgr(); + CVoiceBanMgr(); + ~CVoiceBanMgr(); // Init loads the list of squelched players from disk. - bool Init(char const *pGameDir); + bool Init( char const *pGameDir ); void Term(); // Saves the state into voice_squelch.dt. - void SaveState(char const *pGameDir); + void SaveState( char const *pGameDir ); - bool GetPlayerBan(char const playerID[16]); - void SetPlayerBan(char const playerID[16], bool bSquelch); + bool GetPlayerBan( char const playerID[16] ); + void SetPlayerBan( char const playerID[16], bool bSquelch ); // Call your callback for each banned player. - void ForEachBannedPlayer(void (*callback)(char id[16])); - + void ForEachBannedPlayer( void (*callback)( char id[16] ) ); protected: - class BannedPlayer { public: - char m_PlayerID[16]; + char m_PlayerID[16]; BannedPlayer *m_pPrev, *m_pNext; }; - void Clear(); - BannedPlayer* InternalFindPlayerSquelch(char const playerID[16]); - BannedPlayer* AddBannedPlayer(char const playerID[16]); - - -protected: + void Clear(); + BannedPlayer *InternalFindPlayerSquelch( char const playerID[16] ); + BannedPlayer *AddBannedPlayer( char const playerID[16] ); BannedPlayer m_PlayerHash[256]; }; - - #endif // VOICE_BANMGR_H + diff --git a/game_shared/voice_common.h b/game_shared/voice_common.h index 5517d8ee..c32011a3 100644 --- a/game_shared/voice_common.h +++ b/game_shared/voice_common.h @@ -4,21 +4,15 @@ // // $NoKeywords: $ //============================================================================= - +#pragma once #ifndef VOICE_COMMON_H #define VOICE_COMMON_H -#ifdef _WIN32 -#pragma once -#endif - #include "bitvec.h" - #define VOICE_MAX_PLAYERS 32 // (todo: this should just be set to MAX_CLIENTS). -#define VOICE_MAX_PLAYERS_DW ((VOICE_MAX_PLAYERS / 32) + !!(VOICE_MAX_PLAYERS & 31)) +#define VOICE_MAX_PLAYERS_DW ((VOICE_MAX_PLAYERS / 32) + !!(VOICE_MAX_PLAYERS & 31)) typedef CBitVec CPlayerBitVec; - - #endif // VOICE_COMMON_H + diff --git a/game_shared/voice_gamemgr.cpp b/game_shared/voice_gamemgr.cpp index 403d4320..086c715c 100644 --- a/game_shared/voice_gamemgr.cpp +++ b/game_shared/voice_gamemgr.cpp @@ -1,10 +1,11 @@ -//========= Copyright 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // -// Purpose: +// Purpose: // // $NoKeywords: $ //============================================================================= +#include "archtypes.h" // DAL #include "voice_gamemgr.h" #include #include @@ -13,8 +14,11 @@ #include "cbase.h" #include "player.h" + + #define UPDATE_INTERVAL 0.3 + // These are stored off as CVoiceGameMgr is created and deleted. CPlayerBitVec g_PlayerModEnable; // Set to 1 for each player if the player wants to use voice in this mod. // (If it's zero, then the server reports that the game rules are saying the @@ -32,24 +36,25 @@ cvar_t voice_serverdebug = {"voice_serverdebug", "0"}; // Set game rules to allow all clients to talk to each other. // Muted players still can't talk to each other. -cvar_t sv_alltalk = {"sv_alltalk", "0"}; +cvar_t sv_alltalk = {"sv_alltalk", "0", FCVAR_SERVER}; // ------------------------------------------------------------------------ // // Static helpers. // ------------------------------------------------------------------------ // + // Find a player with a case-insensitive name search. -static CBasePlayer* FindPlayerByName( const char *pTestName ) +static CBasePlayer* FindPlayerByName(const char *pTestName) { - for( int i = 1; i <= gpGlobals->maxClients; i++ ) + for(int i=1; i <= gpGlobals->maxClients; i++) { - edict_t *pEdict = g_engfuncs.pfnPEntityOfEntIndex( i ); - if( pEdict ) + edict_t *pEdict = g_engfuncs.pfnPEntityOfEntIndex(i); + if(pEdict) { - CBaseEntity *pEnt = CBaseEntity::Instance( pEdict ); - if( pEnt && pEnt->IsPlayer() ) - { - const char *pNetName = STRING( pEnt->pev->netname ); - if( stricmp( pNetName, pTestName ) == 0 ) + CBaseEntity *pEnt = CBaseEntity::Instance(pEdict); + if(pEnt && pEnt->IsPlayer()) + { + const char *pNetName = STRING(pEnt->pev->netname); + if(stricmp(pNetName, pTestName) == 0) { return (CBasePlayer*)pEnt; } @@ -75,30 +80,37 @@ static void VoiceServerDebug( char const *pFmt, ... ) ALERT( at_console, "%s", msg ); } + + // ------------------------------------------------------------------------ // // CVoiceGameMgr. // ------------------------------------------------------------------------ // + CVoiceGameMgr::CVoiceGameMgr() { m_UpdateInterval = 0; m_nMaxPlayers = 0; } + CVoiceGameMgr::~CVoiceGameMgr() { } -bool CVoiceGameMgr::Init( IVoiceGameMgrHelper *pHelper, int maxClients ) + +bool CVoiceGameMgr::Init( + IVoiceGameMgrHelper *pHelper, + int maxClients) { m_pHelper = pHelper; m_nMaxPlayers = VOICE_MAX_PLAYERS < maxClients ? VOICE_MAX_PLAYERS : maxClients; - g_engfuncs.pfnPrecacheModel( "sprites/voiceicon.spr" ); + g_engfuncs.pfnPrecacheModel("sprites/voiceicon.spr"); - m_msgPlayerVoiceMask = REG_USER_MSG( "VoiceMask", VOICE_MAX_PLAYERS_DW * 4 * 2 ); + m_msgPlayerVoiceMask = REG_USER_MSG( "VoiceMask", VOICE_MAX_PLAYERS_DW*4 * 2 ); m_msgRequestState = REG_USER_MSG( "ReqState", 0 ); // register voice_serverdebug if it hasn't been registered already - if( !CVAR_GET_POINTER( "voice_serverdebug" ) ) + if ( !CVAR_GET_POINTER( "voice_serverdebug" ) ) CVAR_REGISTER( &voice_serverdebug ); if( !CVAR_GET_POINTER( "sv_alltalk" ) ) @@ -107,70 +119,73 @@ bool CVoiceGameMgr::Init( IVoiceGameMgrHelper *pHelper, int maxClients ) return true; } -void CVoiceGameMgr::SetHelper( IVoiceGameMgrHelper *pHelper ) + +void CVoiceGameMgr::SetHelper(IVoiceGameMgrHelper *pHelper) { m_pHelper = pHelper; } -void CVoiceGameMgr::Update( double frametime ) + +void CVoiceGameMgr::Update(double frametime) { // Only update periodically. m_UpdateInterval += frametime; - if( m_UpdateInterval < UPDATE_INTERVAL ) + if(m_UpdateInterval < UPDATE_INTERVAL) return; UpdateMasks(); } -void CVoiceGameMgr::ClientConnected( edict_t *pEdict ) + +void CVoiceGameMgr::ClientConnected(edict_t *pEdict) { - int index = ENTINDEX( pEdict ) - 1; + int index = ENTINDEX(pEdict) - 1; // Clear out everything we use for deltas on this guy. g_bWantModEnable[index] = true; - g_SentGameRulesMasks[index].Init( 0 ); - g_SentBanMasks[index].Init( 0 ); + g_SentGameRulesMasks[index].Init(0); + g_SentBanMasks[index].Init(0); } // Called to determine if the Receiver has muted (blocked) the Sender // Returns true if the receiver has blocked the sender -bool CVoiceGameMgr::PlayerHasBlockedPlayer( CBasePlayer *pReceiver, CBasePlayer *pSender ) +bool CVoiceGameMgr::PlayerHasBlockedPlayer(CBasePlayer *pReceiver, CBasePlayer *pSender) { int iReceiverIndex, iSenderIndex; - if( !pReceiver || !pSender ) + if ( !pReceiver || !pSender ) return false; iReceiverIndex = pReceiver->entindex() - 1; - iSenderIndex = pSender->entindex() - 1; + iSenderIndex = pSender->entindex() - 1; - if( iReceiverIndex < 0 || iReceiverIndex >= m_nMaxPlayers || iSenderIndex < 0 || iSenderIndex >= m_nMaxPlayers ) + if ( iReceiverIndex < 0 || iReceiverIndex >= m_nMaxPlayers || iSenderIndex < 0 || iSenderIndex >= m_nMaxPlayers ) return false; return ( g_BanMasks[iReceiverIndex][iSenderIndex] ? true : false ); } -bool CVoiceGameMgr::ClientCommand( CBasePlayer *pPlayer, const char *cmd ) +bool CVoiceGameMgr::ClientCommand(CBasePlayer *pPlayer, const char *cmd) { int playerClientIndex = pPlayer->entindex() - 1; - if( playerClientIndex < 0 || playerClientIndex >= m_nMaxPlayers ) + if(playerClientIndex < 0 || playerClientIndex >= m_nMaxPlayers) { VoiceServerDebug( "CVoiceGameMgr::ClientCommand: cmd %s from invalid client (%d)\n", cmd, playerClientIndex ); return true; } - bool bBan = stricmp( cmd, "vban" ) == 0; - if( bBan && CMD_ARGC() >= 2 ) + bool bBan = stricmp(cmd, "vban") == 0; + if(bBan && CMD_ARGC() >= 2) { - for( int i = 1; i < CMD_ARGC(); i++ ) + for(int i=1; i < CMD_ARGC(); i++) { - unsigned long mask = 0; - sscanf( CMD_ARGV(i), "%lx", &mask ); + uint32 mask = 0; + sscanf(CMD_ARGV(i), "%x", &mask); - if( i <= VOICE_MAX_PLAYERS_DW ) + if(i <= VOICE_MAX_PLAYERS_DW) { VoiceServerDebug( "CVoiceGameMgr::ClientCommand: vban (0x%x) from %d\n", mask, playerClientIndex ); - g_BanMasks[playerClientIndex].SetDWord( i - 1, mask ); + g_BanMasks[playerClientIndex].SetDWord(i-1, mask); } else { @@ -179,15 +194,15 @@ bool CVoiceGameMgr::ClientCommand( CBasePlayer *pPlayer, const char *cmd ) } // Force it to update the masks now. - //UpdateMasks(); + // UpdateMasks(); return true; } - else if( stricmp( cmd, "VModEnable" ) == 0 && CMD_ARGC() >= 2 ) + else if(stricmp(cmd, "VModEnable") == 0 && CMD_ARGC() >= 2) { - VoiceServerDebug( "CVoiceGameMgr::ClientCommand: VModEnable (%d)\n", !!atoi( CMD_ARGV( 1 ) ) ); - g_PlayerModEnable[playerClientIndex] = !!atoi( CMD_ARGV( 1 ) ); + VoiceServerDebug( "CVoiceGameMgr::ClientCommand: VModEnable (%d)\n", !!atoi(CMD_ARGV(1)) ); + g_PlayerModEnable[playerClientIndex] = !!atoi(CMD_ARGV(1)); g_bWantModEnable[playerClientIndex] = false; - //UpdateMasks(); + // UpdateMasks(); return true; } else @@ -196,22 +211,23 @@ bool CVoiceGameMgr::ClientCommand( CBasePlayer *pPlayer, const char *cmd ) } } + void CVoiceGameMgr::UpdateMasks() { m_UpdateInterval = 0; - bool bAllTalk = !!g_engfuncs.pfnCVarGetFloat( "sv_alltalk" ); + bool bAllTalk = !!(sv_alltalk.value); - for( int iClient = 0; iClient < m_nMaxPlayers; iClient++ ) + for(int iClient=0; iClient < m_nMaxPlayers; iClient++) { - CBaseEntity *pEnt = UTIL_PlayerByIndex( iClient + 1 ); - if( !pEnt || !pEnt->IsPlayer() ) + CBaseEntity *pEnt = UTIL_PlayerByIndex(iClient+1); + if(!pEnt || !pEnt->IsPlayer()) continue; // Request the state of their "VModEnable" cvar. - if( g_bWantModEnable[iClient] ) + if(g_bWantModEnable[iClient]) { - MESSAGE_BEGIN( MSG_ONE, m_msgRequestState, NULL, pEnt->pev ); + MESSAGE_BEGIN(MSG_ONE, m_msgRequestState, NULL, pEnt->pev); MESSAGE_END(); } @@ -221,10 +237,10 @@ void CVoiceGameMgr::UpdateMasks() if( g_PlayerModEnable[iClient] ) { // Build a mask of who they can hear based on the game rules. - for( int iOtherClient = 0; iOtherClient < m_nMaxPlayers; iOtherClient++ ) + for(int iOtherClient=0; iOtherClient < m_nMaxPlayers; iOtherClient++) { - pEnt = UTIL_PlayerByIndex( iOtherClient + 1 ); - if( pEnt && pEnt->IsPlayer() && ( bAllTalk || m_pHelper->CanPlayerHearPlayer( pPlayer, (CBasePlayer*)pEnt ) ) ) + CBaseEntity *pEnt = UTIL_PlayerByIndex(iOtherClient+1); + if(pEnt && (bAllTalk || m_pHelper->CanPlayerHearPlayer(pPlayer, (CBasePlayer*)pEnt)) ) { gameRulesMask[iOtherClient] = true; } @@ -232,26 +248,27 @@ void CVoiceGameMgr::UpdateMasks() } // If this is different from what the client has, send an update. - if( gameRulesMask != g_SentGameRulesMasks[iClient] || g_BanMasks[iClient] != g_SentBanMasks[iClient] ) + if(gameRulesMask != g_SentGameRulesMasks[iClient] || + g_BanMasks[iClient] != g_SentBanMasks[iClient]) { g_SentGameRulesMasks[iClient] = gameRulesMask; g_SentBanMasks[iClient] = g_BanMasks[iClient]; - MESSAGE_BEGIN( MSG_ONE, m_msgPlayerVoiceMask, NULL, pPlayer->pev ); + MESSAGE_BEGIN(MSG_ONE, m_msgPlayerVoiceMask, NULL, pPlayer->pev); int dw; - for( dw = 0; dw < VOICE_MAX_PLAYERS_DW; dw++ ) + for(dw=0; dw < VOICE_MAX_PLAYERS_DW; dw++) { - WRITE_LONG( gameRulesMask.GetDWord( dw ) ); - WRITE_LONG( g_BanMasks[iClient].GetDWord( dw ) ); + WRITE_LONG(gameRulesMask.GetDWord(dw)); + WRITE_LONG(g_BanMasks[iClient].GetDWord(dw)); } MESSAGE_END(); } // Tell the engine. - for( int iOtherClient = 0; iOtherClient < m_nMaxPlayers; iOtherClient++ ) + for(int iOtherClient=0; iOtherClient < m_nMaxPlayers; iOtherClient++) { bool bCanHear = gameRulesMask[iOtherClient] && !g_BanMasks[iClient][iOtherClient]; - g_engfuncs.pfnVoice_SetClientListening( iClient + 1, iOtherClient + 1, bCanHear ); + g_engfuncs.pfnVoice_SetClientListening(iClient+1, iOtherClient+1, bCanHear); } } } diff --git a/game_shared/voice_gamemgr.h b/game_shared/voice_gamemgr.h index bc2d26a8..cdbb8815 100644 --- a/game_shared/voice_gamemgr.h +++ b/game_shared/voice_gamemgr.h @@ -1,67 +1,80 @@ -//========= Copyright 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright � 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // // $NoKeywords: $ //============================================================================= - +#pragma once #ifndef VOICE_GAMEMGR_H #define VOICE_GAMEMGR_H -#pragma once + +#ifdef _WIN32 +#endif + #include "voice_common.h" + class CGameRules; class CBasePlayer; + class IVoiceGameMgrHelper { public: - virtual ~IVoiceGameMgrHelper() {} + virtual ~IVoiceGameMgrHelper() {} // Called each frame to determine which players are allowed to hear each other. This overrides // whatever squelch settings players have. - virtual bool CanPlayerHearPlayer( CBasePlayer *pListener, CBasePlayer *pTalker ) = 0; + virtual bool CanPlayerHearPlayer(CBasePlayer *pListener, CBasePlayer *pTalker) = 0; }; + // CVoiceGameMgr manages which clients can hear which other clients. class CVoiceGameMgr { public: - CVoiceGameMgr(); - virtual ~CVoiceGameMgr(); + CVoiceGameMgr(); + virtual ~CVoiceGameMgr(); + + bool Init( + IVoiceGameMgrHelper *m_pHelper, + int maxClients + ); - bool Init( IVoiceGameMgrHelper *m_pHelper, int maxClients ); - - void SetHelper( IVoiceGameMgrHelper *pHelper ); + void SetHelper(IVoiceGameMgrHelper *pHelper); // Updates which players can hear which other players. // If gameplay mode is DM, then only players within the PVS can hear each other. // If gameplay mode is teamplay, then only players on the same team can hear each other. // Player masks are always applied. - void Update( double frametime ); + void Update(double frametime); // Called when a new client connects (unsquelches its entity for everyone). - void ClientConnected( struct edict_s *pEdict ); + void ClientConnected(struct edict_s *pEdict); // Called on ClientCommand. Checks for the squelch and unsquelch commands. // Returns true if it handled the command. - bool ClientCommand( CBasePlayer *pPlayer, const char *cmd ); + bool ClientCommand(CBasePlayer *pPlayer, const char *cmd); // Called to determine if the Receiver has muted (blocked) the Sender // Returns true if the receiver has blocked the sender - bool PlayerHasBlockedPlayer( CBasePlayer *pReceiver, CBasePlayer *pSender ); + bool PlayerHasBlockedPlayer(CBasePlayer *pReceiver, CBasePlayer *pSender); + private: + // Force it to update the client masks. - void UpdateMasks(); + void UpdateMasks(); -private: - int m_msgPlayerVoiceMask; - int m_msgRequestState; - IVoiceGameMgrHelper *m_pHelper; - int m_nMaxPlayers; - double m_UpdateInterval; // How long since the last update. + int m_msgPlayerVoiceMask; + int m_msgRequestState; + + IVoiceGameMgrHelper *m_pHelper; + int m_nMaxPlayers; + double m_UpdateInterval; // How long since the last update. }; + + #endif // VOICE_GAMEMGR_H diff --git a/game_shared/voice_status.cpp b/game_shared/voice_status.cpp index 57bc0f16..cbc81e81 100644 --- a/game_shared/voice_status.cpp +++ b/game_shared/voice_status.cpp @@ -6,34 +6,16 @@ //============================================================================= // There are hud.h's coming out of the woodwork so this ensures that we get the right one. -#if defined( DMC_BUILD ) - #include "../dmc/cl_dll/hud.h" - #include "../dmc/cl_dll/cl_util.h" -#elif defined( RICOCHET_BUILD ) - #include "../ricochet/cl_dll/hud.h" - #include "../ricochet/cl_dll/cl_util.h" -#else - #include "../cl_dll/hud.h" - #include "../cl_dll/cl_util.h" -#endif +#include "../cl_dll/hud.h" +#include "../cl_dll/cl_util.h" #include #include #include -#if defined( DMC_BUILD ) - #include "../dmc/cl_dll/parsemsg.h" - #include "../dmc/cl_dll/hud_servers.h" - #include "../dmc/cl_dll/demo.h" -#elif defined( RICOCHET_BUILD ) - #include "../ricochet/cl_dll/parsemsg.h" - #include "../ricochet/cl_dll/hud_servers.h" - #include "../ricochet/cl_dll/demo.h" -#else - #include "../cl_dll/parsemsg.h" - #include "../cl_dll/hud_servers.h" - #include "../cl_dll/demo.h" -#endif +#include "../cl_dll/parsemsg.h" +#include "../cl_dll/hud_servers.h" +#include "../cl_dll/demo.h" #include "demo_api.h" #include "voice_status.h" @@ -46,23 +28,16 @@ #include "vgui_helpers.h" #include "vgui_mousecode.h" - - using namespace vgui; - extern int cam_thirdperson; - #define VOICE_MODEL_INTERVAL 0.3 #define SCOREBOARD_BLINK_FREQUENCY 0.3 // How often to blink the scoreboard icons. #define SQUELCHOSCILLATE_PER_SECOND 2.0f - extern BitmapTGA *LoadTGA( const char* pImageName ); - - // ---------------------------------------------------------------------- // // The voice manager for the client. // ---------------------------------------------------------------------- // @@ -73,63 +48,60 @@ CVoiceStatus* GetClientVoiceMgr() return &g_VoiceStatus; } - - // ---------------------------------------------------------------------- // // CVoiceStatus. // ---------------------------------------------------------------------- // - static CVoiceStatus *g_pInternalVoiceStatus = NULL; -int __MsgFunc_VoiceMask(const char *pszName, int iSize, void *pbuf) +int __MsgFunc_VoiceMask( const char *pszName, int iSize, void *pbuf ) { - if(g_pInternalVoiceStatus) - g_pInternalVoiceStatus->HandleVoiceMaskMsg(iSize, pbuf); + if( g_pInternalVoiceStatus ) + g_pInternalVoiceStatus->HandleVoiceMaskMsg( iSize, pbuf ); return 1; } -int __MsgFunc_ReqState(const char *pszName, int iSize, void *pbuf) +int __MsgFunc_ReqState( const char *pszName, int iSize, void *pbuf ) { - if(g_pInternalVoiceStatus) - g_pInternalVoiceStatus->HandleReqStateMsg(iSize, pbuf); + if( g_pInternalVoiceStatus ) + g_pInternalVoiceStatus->HandleReqStateMsg( iSize, pbuf ); return 1; } - int g_BannedPlayerPrintCount; -void ForEachBannedPlayer(char id[16]) + +void ForEachBannedPlayer( char id[16] ) { char str[256]; - sprintf(str, "Ban %d: %2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x\n", + + sprintf( str, "Ban %d: %2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x\n", g_BannedPlayerPrintCount++, id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7], id[8], id[9], id[10], id[11], id[12], id[13], id[14], id[15] ); - strupr(str); + + strupr( str ); + gEngfuncs.pfnConsolePrint(str); } - void ShowBannedCallback() { - if(g_pInternalVoiceStatus) + if( g_pInternalVoiceStatus ) { g_BannedPlayerPrintCount = 0; gEngfuncs.pfnConsolePrint("------- BANNED PLAYERS -------\n"); - g_pInternalVoiceStatus->m_BanMgr.ForEachBannedPlayer(ForEachBannedPlayer); + g_pInternalVoiceStatus->m_BanMgr.ForEachBannedPlayer( ForEachBannedPlayer ); gEngfuncs.pfnConsolePrint("------------------------------\n"); } } - // ---------------------------------------------------------------------- // // CVoiceStatus. // ---------------------------------------------------------------------- // - CVoiceStatus::CVoiceStatus() { m_bBanMgrInitialized = false; @@ -142,84 +114,80 @@ CVoiceStatus::CVoiceStatus() m_pScoreboardSpeaking2 = NULL; m_pScoreboardSquelch = NULL; m_pScoreboardBanned = NULL; - + m_pLocalBitmap = NULL; m_pAckBitmap = NULL; m_bTalking = m_bServerAcked = false; - memset(m_pBanButtons, 0, sizeof(m_pBanButtons)); + memset( m_pBanButtons, 0, sizeof(m_pBanButtons) ); m_bServerModEnable = -1; m_pchGameDir = NULL; } - CVoiceStatus::~CVoiceStatus() { g_pInternalVoiceStatus = NULL; - - for(int i=0; i < MAX_VOICE_SPEAKERS; i++) + + for( int i = 0; i < MAX_VOICE_SPEAKERS; i++ ) { delete m_Labels[i].m_pLabel; m_Labels[i].m_pLabel = NULL; delete m_Labels[i].m_pIcon; m_Labels[i].m_pIcon = NULL; - + delete m_Labels[i].m_pBackground; m_Labels[i].m_pBackground = NULL; - } + } delete m_pLocalLabel; m_pLocalLabel = NULL; FreeBitmaps(); - if(m_pchGameDir) + if( m_pchGameDir ) { - if(m_bBanMgrInitialized) + if( m_bBanMgrInitialized ) { - m_BanMgr.SaveState(m_pchGameDir); + m_BanMgr.SaveState( m_pchGameDir ); } - free(m_pchGameDir); + free( m_pchGameDir ); } } - -int CVoiceStatus::Init( - IVoiceStatusHelper *pHelper, - Panel **pParentPanel) +int CVoiceStatus::Init( IVoiceStatusHelper *pHelper, Panel **pParentPanel ) { // Setup the voice_modenable cvar. - gEngfuncs.pfnRegisterVariable("voice_modenable", "1", FCVAR_ARCHIVE); + gEngfuncs.pfnRegisterVariable( "voice_modenable", "1", FCVAR_ARCHIVE ); - gEngfuncs.pfnRegisterVariable("voice_clientdebug", "0", 0); + gEngfuncs.pfnRegisterVariable( "voice_clientdebug", "0", 0 ); - gEngfuncs.pfnAddCommand("voice_showbanned", ShowBannedCallback); + gEngfuncs.pfnAddCommand( "voice_showbanned", ShowBannedCallback ); - if(gEngfuncs.pfnGetGameDirectory()) + if( gEngfuncs.pfnGetGameDirectory() ) { - m_BanMgr.Init(gEngfuncs.pfnGetGameDirectory()); + m_BanMgr.Init( gEngfuncs.pfnGetGameDirectory() ); m_bBanMgrInitialized = true; } - assert(!g_pInternalVoiceStatus); + assert( !g_pInternalVoiceStatus ); g_pInternalVoiceStatus = this; m_BlinkTimer = 0; m_VoiceHeadModel = NULL; - memset(m_Labels, 0, sizeof(m_Labels)); - - for(int i=0; i < MAX_VOICE_SPEAKERS; i++) + memset( m_Labels, 0, sizeof(m_Labels) ); + + for( int i = 0; i < MAX_VOICE_SPEAKERS; i++ ) { CVoiceLabel *pLabel = &m_Labels[i]; - pLabel->m_pBackground = new Label(""); + pLabel->m_pBackground = new Label( "" ); - if(pLabel->m_pLabel = new Label("")) + if( pLabel->m_pLabel = new Label( "" ) ) { pLabel->m_pLabel->setVisible( true ); pLabel->m_pLabel->setFont( Scheme::sf_primary2 ); @@ -237,92 +205,90 @@ int CVoiceStatus::Init( pLabel->m_clientindex = -1; } - m_pLocalLabel = new ImagePanel(NULL); + m_pLocalLabel = new ImagePanel( NULL ); m_bInSquelchMode = false; m_pHelper = pHelper; m_pParentPanel = pParentPanel; - gHUD.AddHudElem(this); + gHUD.AddHudElem( this ); m_iFlags = HUD_ACTIVE; - HOOK_MESSAGE(VoiceMask); - HOOK_MESSAGE(ReqState); + HOOK_MESSAGE( VoiceMask ); + HOOK_MESSAGE( ReqState ); // Cache the game directory for use when we shut down const char *pchGameDirT = gEngfuncs.pfnGetGameDirectory(); - m_pchGameDir = (char *)malloc(strlen(pchGameDirT) + 1); - strcpy(m_pchGameDir, pchGameDirT); + m_pchGameDir = (char *)malloc( strlen( pchGameDirT ) + 1 ); + strcpy( m_pchGameDir, pchGameDirT ); return 1; } - int CVoiceStatus::VidInit() { FreeBitmaps(); - - if( m_pLocalBitmap = vgui_LoadTGA("gfx/vgui/icntlk_pl.tga") ) + if( m_pLocalBitmap = vgui_LoadTGA( "gfx/vgui/icntlk_pl.tga" ) ) { - m_pLocalBitmap->setColor(Color(255,255,255,135)); + m_pLocalBitmap->setColor( Color( 255, 255, 255, 135 ) ); } - if( m_pAckBitmap = vgui_LoadTGA("gfx/vgui/icntlk_sv.tga") ) + if( m_pAckBitmap = vgui_LoadTGA( "gfx/vgui/icntlk_sv.tga" ) ) { - m_pAckBitmap->setColor(Color(255,255,255,135)); // Give just a tiny bit of translucency so software draws correctly. + m_pAckBitmap->setColor( Color( 255, 255, 255, 135 ) ); // Give just a tiny bit of translucency so software draws correctly. } m_pLocalLabel->setImage( m_pLocalBitmap ); m_pLocalLabel->setVisible( false ); + if( m_pSpeakerLabelIcon = vgui_LoadTGANoInvertAlpha( "gfx/vgui/speaker4.tga" ) ) + m_pSpeakerLabelIcon->setColor( Color( 255, 255, 255, 1 ) ); // Give just a tiny bit of translucency so software draws correctly. - if( m_pSpeakerLabelIcon = vgui_LoadTGANoInvertAlpha("gfx/vgui/speaker4.tga" ) ) - m_pSpeakerLabelIcon->setColor( Color(255,255,255,1) ); // Give just a tiny bit of translucency so software draws correctly. + if( m_pScoreboardNeverSpoken = vgui_LoadTGANoInvertAlpha( "gfx/vgui/640_speaker1.tga" ) ) + m_pScoreboardNeverSpoken->setColor( Color( 255, 255, 255, 1 ) ); // Give just a tiny bit of translucency so software draws correctly. - if (m_pScoreboardNeverSpoken = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_speaker1.tga")) - m_pScoreboardNeverSpoken->setColor(Color(255,255,255,1)); // Give just a tiny bit of translucency so software draws correctly. + if( m_pScoreboardNotSpeaking = vgui_LoadTGANoInvertAlpha( "gfx/vgui/640_speaker2.tga" ) ) + m_pScoreboardNotSpeaking->setColor( Color( 255, 255, 255, 1 ) ); // Give just a tiny bit of translucency so software draws correctly. - if(m_pScoreboardNotSpeaking = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_speaker2.tga")) - m_pScoreboardNotSpeaking->setColor(Color(255,255,255,1)); // Give just a tiny bit of translucency so software draws correctly. - - if(m_pScoreboardSpeaking = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_speaker3.tga")) - m_pScoreboardSpeaking->setColor(Color(255,255,255,1)); // Give just a tiny bit of translucency so software draws correctly. - - if(m_pScoreboardSpeaking2 = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_speaker4.tga")) - m_pScoreboardSpeaking2->setColor(Color(255,255,255,1)); // Give just a tiny bit of translucency so software draws correctly. - - if(m_pScoreboardSquelch = vgui_LoadTGA("gfx/vgui/icntlk_squelch.tga")) - m_pScoreboardSquelch->setColor(Color(255,255,255,1)); // Give just a tiny bit of translucency so software draws correctly. + if( m_pScoreboardSpeaking = vgui_LoadTGANoInvertAlpha( "gfx/vgui/640_speaker3.tga" ) ) + m_pScoreboardSpeaking->setColor( Color( 255, 255, 255, 1 ) ); // Give just a tiny bit of translucency so software draws correctly. - if(m_pScoreboardBanned = vgui_LoadTGA("gfx/vgui/640_voiceblocked.tga")) - m_pScoreboardBanned->setColor(Color(255,255,255,1)); // Give just a tiny bit of translucency so software draws correctly. + if( m_pScoreboardSpeaking2 = vgui_LoadTGANoInvertAlpha( "gfx/vgui/640_speaker4.tga" ) ) + m_pScoreboardSpeaking2->setColor( Color( 255, 255, 255, 1 ) ); // Give just a tiny bit of translucency so software draws correctly. + + if( m_pScoreboardSquelch = vgui_LoadTGA( "gfx/vgui/icntlk_squelch.tga" ) ) + m_pScoreboardSquelch->setColor( Color( 255, 255, 255, 1 ) ); // Give just a tiny bit of translucency so software draws correctly. + + if( m_pScoreboardBanned = vgui_LoadTGA( "gfx/vgui/640_voiceblocked.tga" ) ) + m_pScoreboardBanned->setColor( Color( 255, 255, 255, 1 ) ); // Give just a tiny bit of translucency so software draws correctly. // Figure out the voice head model height. m_VoiceHeadModelHeight = 45; - char *pFile = (char *)gEngfuncs.COM_LoadFile("scripts/voicemodel.txt", 5, NULL); - if(pFile) + char *pFile = (char *)gEngfuncs.COM_LoadFile( "scripts/voicemodel.txt", 5, NULL ); + if( pFile ) { char token[4096]; - gEngfuncs.COM_ParseFile(pFile, token); - if(token[0] >= '0' && token[0] <= '9') + + gEngfuncs.COM_ParseFile( pFile, token ); + if( token[0] >= '0' && token[0] <= '9' ) { - m_VoiceHeadModelHeight = (float)atof(token); + m_VoiceHeadModelHeight = (float)atof( token ); } - gEngfuncs.COM_FreeFile(pFile); + gEngfuncs.COM_FreeFile( pFile ); } - m_VoiceHeadModel = gEngfuncs.pfnSPR_Load("sprites/voiceicon.spr"); + m_VoiceHeadModel = gEngfuncs.pfnSPR_Load( "sprites/voiceicon.spr" ); + return TRUE; } - -void CVoiceStatus::Frame(double frametime) +void CVoiceStatus::Frame( double frametime ) { // check server banned players once per second - if(gEngfuncs.GetClientTime() - m_LastUpdateServerState > 1) + if( gEngfuncs.GetClientTime() - m_LastUpdateServerState > 1 ) { - UpdateServerState(false); + UpdateServerState( false ); } m_BlinkTimer += frametime; @@ -330,51 +296,50 @@ void CVoiceStatus::Frame(double frametime) // Update speaker labels. if( m_pHelper->CanShowSpeakerLabels() ) { - for( int i=0; i < MAX_VOICE_SPEAKERS; i++ ) + for( int i = 0; i < MAX_VOICE_SPEAKERS; i++ ) m_Labels[i].m_pBackground->setVisible( m_Labels[i].m_clientindex != -1 ); } else { - for( int i=0; i < MAX_VOICE_SPEAKERS; i++ ) + for( int i = 0; i < MAX_VOICE_SPEAKERS; i++ ) m_Labels[i].m_pBackground->setVisible( false ); } - for(int i=0; i < VOICE_MAX_PLAYERS; i++) + for( int i = 0; i < VOICE_MAX_PLAYERS; i++ ) UpdateBanButton(i); } - void CVoiceStatus::CreateEntities() { - if(!m_VoiceHeadModel) + if( !m_VoiceHeadModel ) return; cl_entity_t *localPlayer = gEngfuncs.GetLocalPlayer(); int iOutModel = 0; - for(int i=0; i < VOICE_MAX_PLAYERS; i++) + for( int i = 0; i < VOICE_MAX_PLAYERS; i++ ) { - if(!m_VoicePlayers[i]) + if( !m_VoicePlayers[i] ) continue; - - cl_entity_s *pClient = gEngfuncs.GetEntityByIndex(i+1); - + + cl_entity_s *pClient = gEngfuncs.GetEntityByIndex( i + 1 ); + // Don't show an icon if the player is not in our PVS. - if(!pClient || pClient->curstate.messagenum < localPlayer->curstate.messagenum) + if( !pClient || pClient->curstate.messagenum < localPlayer->curstate.messagenum ) continue; // Don't show an icon for dead or spectating players (ie: invisible entities). - if(pClient->curstate.effects & EF_NODRAW) + if( pClient->curstate.effects & EF_NODRAW ) continue; // Don't show an icon for the local player unless we're in thirdperson mode. - if(pClient == localPlayer && !cam_thirdperson) + if( pClient == localPlayer && !cam_thirdperson ) continue; cl_entity_s *pEnt = &m_VoiceHeadModels[iOutModel]; ++iOutModel; - memset(pEnt, 0, sizeof(*pEnt)); + memset( pEnt, 0, sizeof(*pEnt) ); pEnt->curstate.rendermode = kRenderTransAdd; pEnt->curstate.renderamt = 255; @@ -382,30 +347,30 @@ void CVoiceStatus::CreateEntities() pEnt->curstate.renderfx = kRenderFxNoDissipation; pEnt->curstate.framerate = 1; pEnt->curstate.frame = 0; - pEnt->model = (struct model_s*)gEngfuncs.GetSpritePointer(m_VoiceHeadModel); + pEnt->model = (struct model_s*)gEngfuncs.GetSpritePointer( m_VoiceHeadModel ); pEnt->angles[0] = pEnt->angles[1] = pEnt->angles[2] = 0; pEnt->curstate.scale = 0.5f; - + pEnt->origin[0] = pEnt->origin[1] = 0; pEnt->origin[2] = 45; - VectorAdd(pEnt->origin, pClient->origin, pEnt->origin); + VectorAdd( pEnt->origin, pClient->origin, pEnt->origin ); // Tell the engine. - gEngfuncs.CL_CreateVisibleEntity(ET_NORMAL, pEnt); + gEngfuncs.CL_CreateVisibleEntity( ET_NORMAL, pEnt ); } } - -void CVoiceStatus::UpdateSpeakerStatus(int entindex, qboolean bTalking) +void CVoiceStatus::UpdateSpeakerStatus( int entindex, qboolean bTalking ) { - if(!*m_pParentPanel) + if( !*m_pParentPanel ) return; if( gEngfuncs.pfnGetCvarFloat("voice_clientdebug") ) { char msg[256]; - _snprintf( msg, sizeof(msg), "CVoiceStatus::UpdateSpeakerStatus: ent %d talking = %d\n", entindex, bTalking ); + + sprintf( msg, "CVoiceStatus::UpdateSpeakerStatus: ent %d talking = %d\n", entindex, bTalking ); gEngfuncs.pfnConsolePrint( msg ); } @@ -423,30 +388,30 @@ void CVoiceStatus::UpdateSpeakerStatus(int entindex, qboolean bTalking) { m_bServerAcked = !!bTalking; } - else if(entindex >= 0 && entindex <= VOICE_MAX_PLAYERS) + else if( entindex >= 0 && entindex <= VOICE_MAX_PLAYERS ) { int iClient = entindex - 1; - if(iClient < 0) + if( iClient < 0 ) return; - CVoiceLabel *pLabel = FindVoiceLabel(iClient); - if(bTalking) + CVoiceLabel *pLabel = FindVoiceLabel( iClient ); + if( bTalking ) { m_VoicePlayers[iClient] = true; m_VoiceEnabledPlayers[iClient] = true; // If we don't have a label for this guy yet, then create one. - if(!pLabel) + if( !pLabel ) { - if(pLabel = GetFreeVoiceLabel()) + if( pLabel = GetFreeVoiceLabel() ) { // Get the name from the engine. - hud_player_info_t info; - memset(&info, 0, sizeof(info)); - GetPlayerInfo(entindex, &info); + hud_player_info_t info = {0}; + + GetPlayerInfo( entindex, &info ); char paddedName[512]; - _snprintf(paddedName, sizeof(paddedName), "%s ", info.name); + sprintf( paddedName, "%s ", info.name ); int color[3]; m_pHelper->GetPlayerTextColor( entindex, color ); @@ -474,9 +439,9 @@ void CVoiceStatus::UpdateSpeakerStatus(int entindex, qboolean bTalking) m_VoicePlayers[iClient] = false; // If we have a label for this guy, kill it. - if(pLabel) + if( pLabel ) { - pLabel->m_pBackground->setVisible(false); + pLabel->m_pBackground->setVisible( false ); pLabel->m_clientindex = -1; } } @@ -485,14 +450,13 @@ void CVoiceStatus::UpdateSpeakerStatus(int entindex, qboolean bTalking) RepositionLabels(); } - -void CVoiceStatus::UpdateServerState(bool bForce) +void CVoiceStatus::UpdateServerState( bool bForce ) { // Can't do anything when we're not in a level. char const *pLevelName = gEngfuncs.pfnGetLevelName(); if( pLevelName[0] == 0 ) { - if( gEngfuncs.pfnGetCvarFloat("voice_clientdebug") ) + if( gEngfuncs.pfnGetCvarFloat( "voice_clientdebug" ) ) { gEngfuncs.pfnConsolePrint( "CVoiceStatus::UpdateServerState: pLevelName[0]==0\n" ); } @@ -500,167 +464,177 @@ void CVoiceStatus::UpdateServerState(bool bForce) return; } - int bCVarModEnable = !!gEngfuncs.pfnGetCvarFloat("voice_modenable"); - if(bForce || m_bServerModEnable != bCVarModEnable) + int bCVarModEnable = !!gEngfuncs.pfnGetCvarFloat( "voice_modenable" ); + if( bForce || m_bServerModEnable != bCVarModEnable ) { m_bServerModEnable = bCVarModEnable; char str[256]; - _snprintf(str, sizeof(str), "VModEnable %d", m_bServerModEnable); - ServerCmd(str); - if(gEngfuncs.pfnGetCvarFloat("voice_clientdebug")) + sprintf( str, "VModEnable %d", m_bServerModEnable ); + ServerCmd( str ); + + if( gEngfuncs.pfnGetCvarFloat( "voice_clientdebug" ) ) { char msg[256]; - sprintf(msg, "CVoiceStatus::UpdateServerState: Sending '%s'\n", str); - gEngfuncs.pfnConsolePrint(msg); + + sprintf( msg, "CVoiceStatus::UpdateServerState: Sending '%s'\n", str ); + gEngfuncs.pfnConsolePrint( msg ); } } - char str[2048]; - sprintf(str, "vban"); + char str[2048] = "vban"; + bool bChange = false; - for(unsigned long dw=0; dw < VOICE_MAX_PLAYERS_DW; dw++) + for( unsigned long dw = 0; dw < VOICE_MAX_PLAYERS_DW; dw++ ) { unsigned long serverBanMask = 0; unsigned long banMask = 0; - for(unsigned long i=0; i < 32; i++) + + for( unsigned long i = 0; i < 32; i++ ) { char playerID[16]; - if(!gEngfuncs.GetPlayerUniqueID(i+1, playerID)) + + if( !gEngfuncs.GetPlayerUniqueID( i + 1, playerID ) ) continue; - if(m_BanMgr.GetPlayerBan(playerID)) + if( m_BanMgr.GetPlayerBan( playerID ) ) banMask |= 1 << i; - if(m_ServerBannedPlayers[dw*32 + i]) + if( m_ServerBannedPlayers[dw * 32 + i] ) serverBanMask |= 1 << i; } - if(serverBanMask != banMask) + if( serverBanMask != banMask ) bChange = true; // Ok, the server needs to be updated. char numStr[512]; + sprintf(numStr, " %x", banMask); + strcat(str, numStr); } - if(bChange || bForce) + if( bChange || bForce ) { - if(gEngfuncs.pfnGetCvarFloat("voice_clientdebug")) + if( gEngfuncs.pfnGetCvarFloat( "voice_clientdebug" ) ) { char msg[256]; - sprintf(msg, "CVoiceStatus::UpdateServerState: Sending '%s'\n", str); - gEngfuncs.pfnConsolePrint(msg); + + sprintf( msg, "CVoiceStatus::UpdateServerState: Sending '%s'\n", str ); + + gEngfuncs.pfnConsolePrint( msg ); } - gEngfuncs.pfnServerCmdUnreliable(str); // Tell the server.. + gEngfuncs.pfnServerCmdUnreliable( str ); // Tell the server.. } else { - if (gEngfuncs.pfnGetCvarFloat("voice_clientdebug")) + if( gEngfuncs.pfnGetCvarFloat( "voice_clientdebug" ) ) { gEngfuncs.pfnConsolePrint( "CVoiceStatus::UpdateServerState: no change\n" ); } } - + m_LastUpdateServerState = gEngfuncs.GetClientTime(); } -void CVoiceStatus::UpdateSpeakerImage(Label *pLabel, int iPlayer) +void CVoiceStatus::UpdateSpeakerImage( Label *pLabel, int iPlayer ) { - m_pBanButtons[iPlayer-1] = pLabel; - UpdateBanButton(iPlayer-1); + m_pBanButtons[iPlayer - 1] = pLabel; + UpdateBanButton(iPlayer - 1); } -void CVoiceStatus::UpdateBanButton(int iClient) +void CVoiceStatus::UpdateBanButton( int iClient ) { Label *pPanel = m_pBanButtons[iClient]; - if (!pPanel) + if( !pPanel ) return; char playerID[16]; extern bool HACK_GetPlayerUniqueID( int iPlayer, char playerID[16] ); - if(!HACK_GetPlayerUniqueID(iClient+1, playerID)) + + if( !HACK_GetPlayerUniqueID( iClient + 1, playerID ) ) return; // Figure out if it's blinking or not. - bool bBlink = fmod(m_BlinkTimer, SCOREBOARD_BLINK_FREQUENCY*2) < SCOREBOARD_BLINK_FREQUENCY; + bool bBlink = fmod( m_BlinkTimer, SCOREBOARD_BLINK_FREQUENCY * 2 ) < SCOREBOARD_BLINK_FREQUENCY; bool bTalking = !!m_VoicePlayers[iClient]; - bool bBanned = m_BanMgr.GetPlayerBan(playerID); + bool bBanned = m_BanMgr.GetPlayerBan( playerID ); bool bNeverSpoken = !m_VoiceEnabledPlayers[iClient]; // Get the appropriate image to display on the panel. - if (bBanned) + if( bBanned ) { - pPanel->setImage(m_pScoreboardBanned); + pPanel->setImage( m_pScoreboardBanned ); } - else if (bTalking) + else if( bTalking ) { - if (bBlink) + if( bBlink ) { - pPanel->setImage(m_pScoreboardSpeaking2); + pPanel->setImage( m_pScoreboardSpeaking2 ); } else { - pPanel->setImage(m_pScoreboardSpeaking); + pPanel->setImage( m_pScoreboardSpeaking ); } - pPanel->setFgColor(255, 170, 0, 1); + + pPanel->setFgColor( 255, 170, 0, 1 ); } - else if (bNeverSpoken) + else if( bNeverSpoken ) { - pPanel->setImage(m_pScoreboardNeverSpoken); - pPanel->setFgColor(100, 100, 100, 1); + pPanel->setImage( m_pScoreboardNeverSpoken ); + pPanel->setFgColor( 100, 100, 100, 1 ); } else { - pPanel->setImage(m_pScoreboardNotSpeaking); + pPanel->setImage( m_pScoreboardNotSpeaking ); } } - -void CVoiceStatus::HandleVoiceMaskMsg(int iSize, void *pbuf) +void CVoiceStatus::HandleVoiceMaskMsg( int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); unsigned long dw; - for(dw=0; dw < VOICE_MAX_PLAYERS_DW; dw++) - { - m_AudiblePlayers.SetDWord(dw, (unsigned long)READ_LONG()); - m_ServerBannedPlayers.SetDWord(dw, (unsigned long)READ_LONG()); - if(gEngfuncs.pfnGetCvarFloat("voice_clientdebug")) + for( dw = 0; dw < VOICE_MAX_PLAYERS_DW; dw++ ) + { + m_AudiblePlayers.SetDWord( dw, (unsigned long)READ_LONG() ); + m_ServerBannedPlayers.SetDWord( dw, (unsigned long)READ_LONG() ); + + if( gEngfuncs.pfnGetCvarFloat( "voice_clientdebug" ) ) { char str[256]; - gEngfuncs.pfnConsolePrint("CVoiceStatus::HandleVoiceMaskMsg\n"); - - sprintf(str, " - m_AudiblePlayers[%d] = %lu\n", dw, m_AudiblePlayers.GetDWord(dw)); - gEngfuncs.pfnConsolePrint(str); - - sprintf(str, " - m_ServerBannedPlayers[%d] = %lu\n", dw, m_ServerBannedPlayers.GetDWord(dw)); - gEngfuncs.pfnConsolePrint(str); + gEngfuncs.pfnConsolePrint( "CVoiceStatus::HandleVoiceMaskMsg\n" ); + + sprintf( str, " - m_AudiblePlayers[%d] = %lu\n", dw, m_AudiblePlayers.GetDWord( dw ) ); + gEngfuncs.pfnConsolePrint( str ); + + sprintf( str, " - m_ServerBannedPlayers[%d] = %lu\n", dw, m_ServerBannedPlayers.GetDWord( dw ) ); + gEngfuncs.pfnConsolePrint( str ); } } m_bServerModEnable = READ_BYTE(); } -void CVoiceStatus::HandleReqStateMsg(int iSize, void *pbuf) +void CVoiceStatus::HandleReqStateMsg( int iSize, void *pbuf ) { - if(gEngfuncs.pfnGetCvarFloat("voice_clientdebug")) + if( gEngfuncs.pfnGetCvarFloat( "voice_clientdebug" ) ) { - gEngfuncs.pfnConsolePrint("CVoiceStatus::HandleReqStateMsg\n"); + gEngfuncs.pfnConsolePrint( "CVoiceStatus::HandleReqStateMsg\n" ); } - UpdateServerState(true); + UpdateServerState( true ); } void CVoiceStatus::StartSquelchMode() { - if(m_bInSquelchMode) + if( m_bInSquelchMode ) return; m_bInSquelchMode = true; @@ -678,37 +652,35 @@ bool CVoiceStatus::IsInSquelchMode() return m_bInSquelchMode; } -CVoiceLabel* CVoiceStatus::FindVoiceLabel(int clientindex) +CVoiceLabel *CVoiceStatus::FindVoiceLabel( int clientindex ) { - for(int i=0; i < MAX_VOICE_SPEAKERS; i++) + for( int i = 0; i < MAX_VOICE_SPEAKERS; i++ ) { - if(m_Labels[i].m_clientindex == clientindex) + if( m_Labels[i].m_clientindex == clientindex ) return &m_Labels[i]; } return NULL; } - -CVoiceLabel* CVoiceStatus::GetFreeVoiceLabel() +CVoiceLabel *CVoiceStatus::GetFreeVoiceLabel() { - return FindVoiceLabel(-1); + return FindVoiceLabel( -1 ); } - void CVoiceStatus::RepositionLabels() { // find starting position to draw from, along right-hand side of screen int y = ScreenHeight / 2; - + int iconWide = 8, iconTall = 8; if( m_pSpeakerLabelIcon ) { m_pSpeakerLabelIcon->getSize( iconWide, iconTall ); } - + // Reposition active labels. - for(int i = 0; i < MAX_VOICE_SPEAKERS; i++) + for( int i = 0; i < MAX_VOICE_SPEAKERS; i++ ) { CVoiceLabel *pLabel = &m_Labels[i]; @@ -721,24 +693,25 @@ void CVoiceStatus::RepositionLabels() } int textWide, textTall; + pLabel->m_pLabel->getContentSize( textWide, textTall ); // Don't let it stretch too far across their screen. - if( textWide > (ScreenWidth*2)/3 ) - textWide = (ScreenWidth*2)/3; + if( textWide > ( ScreenWidth * 2 ) / 3 ) + textWide = ( ScreenWidth * 2 ) / 3; // Setup the background label to fit everything in. int border = 2; - int bgWide = textWide + iconWide + border*3; - int bgTall = max( textTall, iconTall ) + border*2; + int bgWide = textWide + iconWide + border * 3; + int bgTall = max( textTall, iconTall ) + border * 2; pLabel->m_pBackground->setBounds( ScreenWidth - bgWide - 8, y, bgWide, bgTall ); // Put the text at the left. - pLabel->m_pLabel->setBounds( border, (bgTall - textTall) / 2, textWide, textTall ); + pLabel->m_pLabel->setBounds( border, ( bgTall - textTall ) / 2, textWide, textTall ); // Put the icon at the right. int iconLeft = border + textWide + border; - int iconTop = (bgTall - iconTall) / 2; + int iconTop = ( bgTall - iconTall ) / 2; if( pLabel->m_pIcon ) { pLabel->m_pIcon->setImage( m_pSpeakerLabelIcon ); @@ -748,22 +721,23 @@ void CVoiceStatus::RepositionLabels() y += bgTall + 2; } - if( m_pLocalBitmap && m_pAckBitmap && m_pLocalLabel && (m_bTalking || m_bServerAcked) ) + if( m_pLocalBitmap && m_pAckBitmap && m_pLocalLabel && ( m_bTalking || m_bServerAcked ) ) { - m_pLocalLabel->setParent(*m_pParentPanel); + m_pLocalLabel->setParent( *m_pParentPanel ); m_pLocalLabel->setVisible( true ); - if( m_bServerAcked && !!gEngfuncs.pfnGetCvarFloat("voice_clientdebug") ) + if( m_bServerAcked && !!gEngfuncs.pfnGetCvarFloat( "voice_clientdebug" ) ) m_pLocalLabel->setImage( m_pAckBitmap ); else m_pLocalLabel->setImage( m_pLocalBitmap ); int sizeX, sizeY; - m_pLocalBitmap->getSize(sizeX, sizeY); + + m_pLocalBitmap->getSize( sizeX, sizeY ); int local_xPos = ScreenWidth - sizeX - 10; int local_yPos = m_pHelper->GetAckIconHeight() - sizeY; - + m_pLocalLabel->setPos( local_xPos, local_yPos ); } else @@ -772,7 +746,6 @@ void CVoiceStatus::RepositionLabels() } } - void CVoiceStatus::FreeBitmaps() { // Delete all the images we have loaded. @@ -804,16 +777,16 @@ void CVoiceStatus::FreeBitmaps() m_pScoreboardBanned = NULL; // Clear references to the images in panels. - for(int i=0; i < VOICE_MAX_PLAYERS; i++) + for( int i = 0; i < VOICE_MAX_PLAYERS; i++ ) { - if (m_pBanButtons[i]) + if( m_pBanButtons[i] ) { - m_pBanButtons[i]->setImage(NULL); + m_pBanButtons[i]->setImage( NULL ); } } - if(m_pLocalLabel) - m_pLocalLabel->setImage(NULL); + if( m_pLocalLabel ) + m_pLocalLabel->setImage( NULL ); } //----------------------------------------------------------------------------- @@ -821,13 +794,14 @@ void CVoiceStatus::FreeBitmaps() // Input : playerID - // Output : Returns true on success, false on failure. //----------------------------------------------------------------------------- -bool CVoiceStatus::IsPlayerBlocked(int iPlayer) +bool CVoiceStatus::IsPlayerBlocked( int iPlayer ) { char playerID[16]; - if (!gEngfuncs.GetPlayerUniqueID(iPlayer, playerID)) + + if( !gEngfuncs.GetPlayerUniqueID( iPlayer, playerID ) ) return false; - return m_BanMgr.GetPlayerBan(playerID); + return m_BanMgr.GetPlayerBan( playerID ); } //----------------------------------------------------------------------------- @@ -835,9 +809,9 @@ bool CVoiceStatus::IsPlayerBlocked(int iPlayer) // Input : playerID - // Output : Returns true on success, false on failure. //----------------------------------------------------------------------------- -bool CVoiceStatus::IsPlayerAudible(int iPlayer) +bool CVoiceStatus::IsPlayerAudible( int iPlayer ) { - return !!m_AudiblePlayers[iPlayer-1]; + return !!m_AudiblePlayers[iPlayer - 1]; } //----------------------------------------------------------------------------- @@ -845,30 +819,32 @@ bool CVoiceStatus::IsPlayerAudible(int iPlayer) // Input : playerID - // Output : Returns true on success, false on failure. //----------------------------------------------------------------------------- -void CVoiceStatus::SetPlayerBlockedState(int iPlayer, bool blocked) +void CVoiceStatus::SetPlayerBlockedState( int iPlayer, bool blocked ) { - if (gEngfuncs.pfnGetCvarFloat("voice_clientdebug")) + if( gEngfuncs.pfnGetCvarFloat( "voice_clientdebug" ) ) { gEngfuncs.pfnConsolePrint( "CVoiceStatus::SetPlayerBlockedState part 1\n" ); } char playerID[16]; - if (!gEngfuncs.GetPlayerUniqueID(iPlayer, playerID)) + + if( !gEngfuncs.GetPlayerUniqueID( iPlayer, playerID ) ) return; - if (gEngfuncs.pfnGetCvarFloat("voice_clientdebug")) + if( gEngfuncs.pfnGetCvarFloat( "voice_clientdebug" ) ) { gEngfuncs.pfnConsolePrint( "CVoiceStatus::SetPlayerBlockedState part 2\n" ); } // Squelch or (try to) unsquelch this player. - if (gEngfuncs.pfnGetCvarFloat("voice_clientdebug")) + if( gEngfuncs.pfnGetCvarFloat( "voice_clientdebug" ) ) { char str[256]; - sprintf(str, "CVoiceStatus::SetPlayerBlockedState: setting player %d ban to %d\n", iPlayer, !m_BanMgr.GetPlayerBan(playerID)); - gEngfuncs.pfnConsolePrint(str); + + sprintf( str, "CVoiceStatus::SetPlayerBlockedState: setting player %d ban to %d\n", iPlayer, !m_BanMgr.GetPlayerBan( playerID ) ); + gEngfuncs.pfnConsolePrint( str ); } m_BanMgr.SetPlayerBan( playerID, blocked ); - UpdateServerState(false); + UpdateServerState( false ); } diff --git a/game_shared/voice_status.h b/game_shared/voice_status.h index 509902e5..22bd864c 100644 --- a/game_shared/voice_status.h +++ b/game_shared/voice_status.h @@ -1,14 +1,11 @@ -//========= Copyright 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // // $NoKeywords: $ //============================================================================= - -#ifndef VOICE_STATUS_H +#if !defined(VOICE_STATUS_H) #define VOICE_STATUS_H -#pragma once - #include "VGUI_Label.h" #include "VGUI_LineBorder.h" @@ -22,17 +19,15 @@ #include "vgui_checkbutton2.h" #include "vgui_defaultinputsignal.h" - class CVoiceStatus; - class CVoiceLabel { public: - vgui::Label *m_pLabel; - vgui::Label *m_pBackground; + vgui::Label *m_pLabel; + vgui::Label *m_pBackground; vgui::ImagePanel *m_pIcon; // Voice icon next to player name. - int m_clientindex; // Client index of the speaker. -1 if this label isn't being used. + int m_clientindex; // Client index of the speaker. -1 if this label isn't being used. }; @@ -40,7 +35,7 @@ public: class IVoiceStatusHelper { public: - virtual ~IVoiceStatusHelper() {} + virtual ~IVoiceStatusHelper() {} // Get RGB color for voice status text about this player. virtual void GetPlayerTextColor(int entindex, int color[3]) = 0; @@ -49,7 +44,7 @@ public: virtual void UpdateCursorState() = 0; // Return the height above the bottom that the voice ack icons should be drawn at. - virtual int GetAckIconHeight() = 0; + virtual int GetAckIconHeight() = 0; // Return true if the voice manager is allowed to show speaker labels // (mods usually return false when the scoreboard is up). @@ -63,166 +58,148 @@ class VoiceImagePanel : public vgui::ImagePanel { virtual void paintBackground() { - if (_image!=null) + if( _image != null ) { vgui::Color col; - getFgColor(col); - _image->setColor(col); - _image->doPaint(this); + getFgColor( col ); + _image->setColor( col ); + _image->doPaint( this ); } } }; - class CVoiceStatus : public CHudBase, public vgui::CDefaultInputSignal { public: - CVoiceStatus(); + CVoiceStatus(); virtual ~CVoiceStatus(); -// CHudBase overrides. -public: + // CHudBase overrides. // Initialize the cl_dll's voice manager. - virtual int Init( - IVoiceStatusHelper *m_pHelper, - vgui::Panel **pParentPanel); - + virtual int Init( IVoiceStatusHelper *m_pHelper, vgui::Panel **pParentPanel ); + // ackPosition is the bottom position of where CVoiceStatus will draw the voice acknowledgement labels. - virtual int VidInit(); - - -public: + virtual int VidInit(); // Call from HUD_Frame each frame. - void Frame(double frametime); + void Frame( double frametime ); // Called when a player starts or stops talking. // entindex is -1 to represent the local client talking (before the data comes back from the server). // When the server acknowledges that the local client is talking, then entindex will be gEngfuncs.GetLocalPlayer(). // entindex is -2 to represent the local client's voice being acked by the server. - void UpdateSpeakerStatus(int entindex, qboolean bTalking); + void UpdateSpeakerStatus( int entindex, qboolean bTalking ); // sets the correct image in the label for the player - void UpdateSpeakerImage(vgui::Label *pLabel, int iPlayer); + void UpdateSpeakerImage( vgui::Label *pLabel, int iPlayer ); // Call from the HUD_CreateEntities function so it can add sprites above player heads. - void CreateEntities(); + void CreateEntities(); // Called when the server registers a change to who this client can hear. - void HandleVoiceMaskMsg(int iSize, void *pbuf); + void HandleVoiceMaskMsg( int iSize, void *pbuf ); // The server sends this message initially to tell the client to send their state. - void HandleReqStateMsg(int iSize, void *pbuf); + void HandleReqStateMsg( int iSize, void *pbuf ); - -// Squelch mode functions. -public: + // Squelch mode functions. // When you enter squelch mode, pass in - void StartSquelchMode(); - void StopSquelchMode(); - bool IsInSquelchMode(); + void StartSquelchMode(); + void StopSquelchMode(); + bool IsInSquelchMode(); // returns true if the target client has been banned // playerIndex is of range 1..maxplayers - bool IsPlayerBlocked(int iPlayerIndex); + bool IsPlayerBlocked( int iPlayerIndex ); // returns false if the player can't hear the other client due to game rules (eg. the other team) - bool IsPlayerAudible(int iPlayerIndex); + bool IsPlayerAudible( int iPlayerIndex ); // blocks the target client from being heard - void SetPlayerBlockedState(int iPlayerIndex, bool blocked); + void SetPlayerBlockedState( int iPlayerIndex, bool blocked ); -public: - - CVoiceLabel* FindVoiceLabel(int clientindex); // Find a CVoiceLabel representing the specified speaker. + CVoiceLabel *FindVoiceLabel( int clientindex ); // Find a CVoiceLabel representing the specified speaker. // Returns NULL if none. // entindex can be -1 if you want a currently-unused voice label. - CVoiceLabel* GetFreeVoiceLabel(); // Get an unused voice label. Returns NULL if none. + CVoiceLabel *GetFreeVoiceLabel(); // Get an unused voice label. Returns NULL if none. void RepositionLabels(); void FreeBitmaps(); - void UpdateServerState(bool bForce); + void UpdateServerState( bool bForce ); // Update the button artwork to reflect the client's current state. - void UpdateBanButton(int iClient); + void UpdateBanButton( int iClient ); + enum + { + MAX_VOICE_SPEAKERS = 7 + }; -public: + float m_LastUpdateServerState; // Last time we called this function. + int m_bServerModEnable; // What we've sent to the server about our "voice_modenable" cvar. - enum {MAX_VOICE_SPEAKERS=7}; - - float m_LastUpdateServerState; // Last time we called this function. - int m_bServerModEnable; // What we've sent to the server about our "voice_modenable" cvar. - - vgui::Panel **m_pParentPanel; - CPlayerBitVec m_VoicePlayers; // Who is currently talking. Indexed by client index. + vgui::Panel **m_pParentPanel; + CPlayerBitVec m_VoicePlayers; // Who is currently talking. Indexed by client index. // This is the gamerules-defined list of players that you can hear. It is based on what teams people are on // and is totally separate from the ban list. Indexed by client index. - CPlayerBitVec m_AudiblePlayers; + CPlayerBitVec m_AudiblePlayers; // Players who have spoken at least once in the game so far - CPlayerBitVec m_VoiceEnabledPlayers; + CPlayerBitVec m_VoiceEnabledPlayers; // This is who the server THINKS we have banned (it can become incorrect when a new player arrives on the server). // It is checked periodically, and the server is told to squelch or unsquelch the appropriate players. - CPlayerBitVec m_ServerBannedPlayers; + CPlayerBitVec m_ServerBannedPlayers; - cl_entity_s m_VoiceHeadModels[VOICE_MAX_PLAYERS]; // These aren't necessarily in the order of players. They are just - // a place for it to put data in during CreateEntities. + cl_entity_s m_VoiceHeadModels[VOICE_MAX_PLAYERS]; // These aren't necessarily in the order of players. They are just + // a place for it to put data in during CreateEntities. - IVoiceStatusHelper *m_pHelper; // Each mod provides an implementation of this. + IVoiceStatusHelper *m_pHelper; // Each mod provides an implementation of this. - // Scoreboard icons. - double m_BlinkTimer; // Blink scoreboard icons.. - vgui::BitmapTGA *m_pScoreboardNeverSpoken; - vgui::BitmapTGA *m_pScoreboardNotSpeaking; - vgui::BitmapTGA *m_pScoreboardSpeaking; - vgui::BitmapTGA *m_pScoreboardSpeaking2; - vgui::BitmapTGA *m_pScoreboardSquelch; - vgui::BitmapTGA *m_pScoreboardBanned; - - vgui::Label *m_pBanButtons[VOICE_MAX_PLAYERS]; // scoreboard buttons. + double m_BlinkTimer; // Blink scoreboard icons.. + vgui::BitmapTGA *m_pScoreboardNeverSpoken; + vgui::BitmapTGA *m_pScoreboardNotSpeaking; + vgui::BitmapTGA *m_pScoreboardSpeaking; + vgui::BitmapTGA *m_pScoreboardSpeaking2; + vgui::BitmapTGA *m_pScoreboardSquelch; + vgui::BitmapTGA *m_pScoreboardBanned; + + vgui::Label *m_pBanButtons[VOICE_MAX_PLAYERS]; // scoreboard buttons. // Squelch mode stuff. - bool m_bInSquelchMode; - - HSPRITE m_VoiceHeadModel; // Voice head model (goes above players who are speaking). - float m_VoiceHeadModelHeight; // Height above their head to place the model. + bool m_bInSquelchMode; - vgui::Image *m_pSpeakerLabelIcon; // Icon next to speaker labels. + HSPRITE m_VoiceHeadModel; // Voice head model (goes above players who are speaking). + float m_VoiceHeadModelHeight; // Height above their head to place the model. + + vgui::Image *m_pSpeakerLabelIcon; // Icon next to speaker labels. // Lower-right icons telling when the local player is talking.. - vgui::BitmapTGA *m_pLocalBitmap; // Represents the local client talking. - vgui::BitmapTGA *m_pAckBitmap; // Represents the server ack'ing the client talking. - vgui::ImagePanel *m_pLocalLabel; // Represents the local client talking. + vgui::BitmapTGA *m_pLocalBitmap; // Represents the local client talking. + vgui::BitmapTGA *m_pAckBitmap; // Represents the server ack'ing the client talking. + vgui::ImagePanel *m_pLocalLabel; // Represents the local client talking. - bool m_bTalking; // Set to true when the client thinks it's talking. - bool m_bServerAcked; // Set to true when the server knows the client is talking. + bool m_bTalking; // Set to true when the client thinks it's talking. + bool m_bServerAcked; // Set to true when the server knows the client is talking. -public: - - CVoiceBanMgr m_BanMgr; // Tracks which users we have squelched and don't want to hear. + CVoiceBanMgr m_BanMgr; // Tracks which users we have squelched and don't want to hear. -public: - - bool m_bBanMgrInitialized; + bool m_bBanMgrInitialized; // Labels telling who is speaking. - CVoiceLabel m_Labels[MAX_VOICE_SPEAKERS]; + CVoiceLabel m_Labels[MAX_VOICE_SPEAKERS]; // Cache the game directory for use when we shut down - char * m_pchGameDir; + char *m_pchGameDir; }; - -// Get the (global) voice manager. +// Get the (global) voice manager. CVoiceStatus* GetClientVoiceMgr(); - - #endif // VOICE_STATUS_H + diff --git a/game_shared/voice_vgui_tweakdlg.cpp b/game_shared/voice_vgui_tweakdlg.cpp index 07f02ad7..ea61f509 100644 --- a/game_shared/voice_vgui_tweakdlg.cpp +++ b/game_shared/voice_vgui_tweakdlg.cpp @@ -9,7 +9,6 @@ #include "../cl_dll/cl_util.h" #include "../cl_dll/vgui_teamfortressviewport.h" - #include "vgui_actionsignal.h" #include "voice_vgui_tweakdlg.h" #include "voice_vgui_tweakdlg.h" @@ -21,20 +20,18 @@ #include "vgui_checkbutton2.h" #include "vgui_helpers.h" - -#define ITEM_BORDER 40 // Border between text and scrollbars on left and right. +#define ITEM_BORDER 40 // Border between text and scrollbars on left and right. #define VOICETWEAK_TRANSPARENCY 150 - class TweakScroller { public: - TweakScroller(); - void Init(Panel *pParent, char *pText, int yPos); + TweakScroller(); + void Init( Panel *pParent, char *pText, int yPos ); // Get/set value. Values are 0-1. float GetValue(); - void SetValue(float val); + void SetValue( float val ); public: Label m_Label; @@ -46,48 +43,36 @@ public: class CVoiceVGUITweakDlg : public CMenuPanel, public ICheckButton2Handler { typedef CMenuPanel BaseClass; - public: - CVoiceVGUITweakDlg(); - ~CVoiceVGUITweakDlg(); + CVoiceVGUITweakDlg(); + ~CVoiceVGUITweakDlg(); -// CMenuPanel overrides. -public: + // CMenuPanel overrides. virtual void Open(); virtual void Close(); - -// ICheckButton2Handler overrides. -public: - + // ICheckButton2Handler overrides. virtual void StateChanged(CCheckButton2 *pButton); - - -// Panel overrides. -public: + // Panel overrides. virtual void paintBackground(); - private: + int m_DlgWidth; + int m_DlgHeight; - int m_DlgWidth; - int m_DlgHeight; + Label m_Label; - Label m_Label; - - IVoiceTweak *m_pVoiceTweak; // Engine voice tweak API. + IVoiceTweak *m_pVoiceTweak; // Engine voice tweak API. - TweakScroller m_MicVolume; - TweakScroller m_SpeakerVolume; + TweakScroller m_MicVolume; + TweakScroller m_SpeakerVolume; - CCheckButton2 m_VoiceModEnable; - - Button m_Button_OK; + CCheckButton2 m_VoiceModEnable; + + Button m_Button_OK; }; - - bool g_bTweakDlgOpen = false; bool IsTweakDlgOpen() @@ -95,107 +80,97 @@ bool IsTweakDlgOpen() return g_bTweakDlgOpen; } - - // ------------------------------------------------------------------------ // // Global functions. // ------------------------------------------------------------------------ // - static CVoiceVGUITweakDlg g_VoiceTweakDlg; -CMenuPanel* GetVoiceTweakDlg() + +CMenuPanel *GetVoiceTweakDlg() { return &g_VoiceTweakDlg; } - class CVoiceTweakOKButton : public ActionSignal { public: - virtual void actionPerformed(Panel *pPanel) + virtual void actionPerformed( Panel *pPanel ) { gViewPort->HideVGUIMenu(); } }; + CVoiceTweakOKButton g_OKButtonSignal; - - // ------------------------------------------------------------------------ // // TweakScroller // ------------------------------------------------------------------------ // - TweakScroller::TweakScroller() : - m_Label(""), - m_Scroll(0,0,0,0,false), - m_Slider(0,0,10,10,false) + m_Label( "" ), + m_Scroll( 0, 0, 0, 0, false ), + m_Slider( 0, 0, 10, 10, false ) { } - -void TweakScroller::Init(Panel *pParent, char *pText, int yPos) +void TweakScroller::Init( Panel *pParent, char *pText, int yPos ) { int parentWidth, parentHeight; - pParent->getSize(parentWidth, parentHeight); + + pParent->getSize( parentWidth, parentHeight ); // Setup the volume scroll bar. - m_Label.setParent(pParent); - m_Label.setFont(Scheme::sf_primary1); - m_Label.setContentAlignment(vgui::Label::a_northwest); - m_Label.setBgColor(0, 0, 0, 255); - m_Label.setFgColor(255,255,255,0); - m_Label.setPos(ITEM_BORDER, yPos); - m_Label.setSize(parentWidth/2-ITEM_BORDER, 20); - m_Label.setText(pText); - m_Label.setVisible(true); + m_Label.setParent( pParent ); + m_Label.setFont( Scheme::sf_primary1 ); + m_Label.setContentAlignment( vgui::Label::a_northwest ); + m_Label.setBgColor( 0, 0, 0, 255 ); + m_Label.setFgColor( 255, 255, 255, 0 ); + m_Label.setPos( ITEM_BORDER, yPos ); + m_Label.setSize( parentWidth / 2 - ITEM_BORDER, 20 ); + m_Label.setText( pText ); + m_Label.setVisible( true ); - m_Slider.setRangeWindow(10); - m_Slider.setRangeWindowEnabled(true); - - m_Scroll.setPos(parentWidth/2+ITEM_BORDER, yPos); - m_Scroll.setSize(parentWidth/2-ITEM_BORDER*2, 20); - m_Scroll.setSlider(&m_Slider); - m_Scroll.setParent(pParent); - m_Scroll.setRange(0, 100); - m_Scroll.setFgColor(255,255,255,0); - m_Scroll.setBgColor(255,255,255,0); + m_Slider.setRangeWindow( 10 ); + m_Slider.setRangeWindowEnabled( true ); + + m_Scroll.setPos( parentWidth / 2 + ITEM_BORDER, yPos ); + m_Scroll.setSize( parentWidth / 2 - ITEM_BORDER * 2, 20 ); + m_Scroll.setSlider( &m_Slider ); + m_Scroll.setParent( pParent ); + m_Scroll.setRange( 0, 100 ); + m_Scroll.setFgColor( 255, 255, 255, 0 ); + m_Scroll.setBgColor( 255, 255, 255, 0 ); } - float TweakScroller::GetValue() { return m_Scroll.getValue() / 100.0f; } - -void TweakScroller::SetValue(float val) +void TweakScroller::SetValue( float val ) { - m_Scroll.setValue((int)(val * 100.0f)); + m_Scroll.setValue( (int)( val * 100.0f ) ); } - // ------------------------------------------------------------------------ // // CVoiceVGUITweakDlg implementation. // ------------------------------------------------------------------------ // CVoiceVGUITweakDlg::CVoiceVGUITweakDlg() - : CMenuPanel(VOICETWEAK_TRANSPARENCY, false, 0, 0, 0, 0), - m_Button_OK("",0,0), - m_Label("") + : CMenuPanel( VOICETWEAK_TRANSPARENCY, false, 0, 0, 0, 0 ), + m_Button_OK( "", 0, 0 ), + m_Label( "" ) { m_pVoiceTweak = NULL; - m_Button_OK.addActionSignal(&g_OKButtonSignal); - m_Label.setBgColor(255,255,255,200); + m_Button_OK.addActionSignal( &g_OKButtonSignal ); + m_Label.setBgColor( 255, 255, 255, 200 ); } - CVoiceVGUITweakDlg::~CVoiceVGUITweakDlg() { } - void CVoiceVGUITweakDlg::Open() { - if(g_bTweakDlgOpen) + if( g_bTweakDlgOpen ) return; g_bTweakDlgOpen = true; @@ -209,46 +184,48 @@ void CVoiceVGUITweakDlg::Open() m_pVoiceTweak->StartVoiceTweakMode(); // Set our size. - setPos((ScreenWidth - m_DlgWidth) / 2, (ScreenHeight - m_DlgHeight) / 2); - setSize(m_DlgWidth, m_DlgHeight); + setPos( ( ScreenWidth - m_DlgWidth ) / 2, ( ScreenHeight - m_DlgHeight ) / 2 ); + setSize( m_DlgWidth, m_DlgHeight ); int curY = ITEM_BORDER; - m_MicVolume.Init(this, gHUD.m_TextMessage.BufferedLocaliseTextString("#Mic_Volume"), curY); - m_MicVolume.SetValue(m_pVoiceTweak->GetControlFloat(MicrophoneVolume)); - curY = PanelBottom(&m_MicVolume.m_Label); + m_MicVolume.Init( this, gHUD.m_TextMessage.BufferedLocaliseTextString( "#Mic_Volume" ), curY ); + m_MicVolume.SetValue( m_pVoiceTweak->GetControlFloat( MicrophoneVolume ) ); + curY = PanelBottom( &m_MicVolume.m_Label ); - m_SpeakerVolume.Init(this, gHUD.m_TextMessage.BufferedLocaliseTextString("#Speaker_Volume"), curY); - m_SpeakerVolume.SetValue(m_pVoiceTweak->GetControlFloat(OtherSpeakerScale)); - curY = PanelBottom(&m_SpeakerVolume.m_Label); + m_SpeakerVolume.Init( this, gHUD.m_TextMessage.BufferedLocaliseTextString( "#Speaker_Volume" ), curY ); + m_SpeakerVolume.SetValue( m_pVoiceTweak->GetControlFloat( OtherSpeakerScale ) ); + curY = PanelBottom( &m_SpeakerVolume.m_Label ); - m_VoiceModEnable.setParent(this); - m_VoiceModEnable.SetImages("gfx/vgui/checked.tga", "gfx/vgui/unchecked.tga"); - m_VoiceModEnable.SetText("Enable Voice In This Mod"); - m_VoiceModEnable.setPos(ITEM_BORDER, curY); - m_VoiceModEnable.SetCheckboxLeft(false); - m_VoiceModEnable.SetChecked(!!gEngfuncs.pfnGetCvarFloat("voice_modenable")); - m_VoiceModEnable.SetHandler(this); + m_VoiceModEnable.setParent( this ); + m_VoiceModEnable.SetImages( "gfx/vgui/checked.tga", "gfx/vgui/unchecked.tga" ); + m_VoiceModEnable.SetText( "Enable Voice In This Mod" ); + m_VoiceModEnable.setPos( ITEM_BORDER, curY ); + m_VoiceModEnable.SetCheckboxLeft( false ); + m_VoiceModEnable.SetChecked( !!gEngfuncs.pfnGetCvarFloat( "voice_modenable" ) ); + m_VoiceModEnable.SetHandler( this ); // Setup the OK button. int buttonWidth, buttonHeight; - m_Button_OK.setText(gHUD.m_TextMessage.BufferedLocaliseTextString("#Menu_OK")); - m_Button_OK.getSize(buttonWidth, buttonHeight); - m_Button_OK.setPos((m_DlgWidth - buttonWidth) / 2, m_DlgHeight - buttonHeight - 3); - m_Button_OK.setParent(this); + + m_Button_OK.setText( gHUD.m_TextMessage.BufferedLocaliseTextString( "#Menu_OK" ) ); + m_Button_OK.getSize( buttonWidth, buttonHeight ); + m_Button_OK.setPos(( m_DlgWidth - buttonWidth ) / 2, m_DlgHeight - buttonHeight - 3 ); + m_Button_OK.setParent( this ); // Put the label on the top. - m_Label.setBgColor(0, 0, 0, 255); - m_Label.setFgColor(255,255,255,0); - m_Label.setText(gHUD.m_TextMessage.BufferedLocaliseTextString("#Voice_Properties")); + m_Label.setBgColor( 0, 0, 0, 255 ); + m_Label.setFgColor( 255, 255, 255, 0 ); + m_Label.setText( gHUD.m_TextMessage.BufferedLocaliseTextString( "#Voice_Properties" ) ); + int labelWidth, labelHeight; - m_Label.getSize(labelWidth, labelHeight); - m_Label.setPos((m_DlgWidth - labelWidth) / 2, 5); - m_Label.setParent(this); + + m_Label.getSize( labelWidth, labelHeight ); + m_Label.setPos( ( m_DlgWidth - labelWidth ) / 2, 5 ); + m_Label.setParent( this ); BaseClass::Open(); } - void CVoiceVGUITweakDlg::Close() { m_pVoiceTweak->EndVoiceTweakMode(); @@ -257,33 +234,33 @@ void CVoiceVGUITweakDlg::Close() BaseClass::Close(); } - void CVoiceVGUITweakDlg::paintBackground() { BaseClass::paintBackground(); // Draw our border. - int w,h; - getSize(w,h); + int w, h; - drawSetColor(128,128,128,1); - drawOutlinedRect(0, 0, w, h); + getSize( w, h ); + + drawSetColor( 128, 128, 128, 1 ); + drawOutlinedRect( 0, 0, w, h ); float volume = m_MicVolume.GetValue(); - m_pVoiceTweak->SetControlFloat(MicrophoneVolume, volume); + m_pVoiceTweak->SetControlFloat( MicrophoneVolume, volume ); - m_pVoiceTweak->SetControlFloat(OtherSpeakerScale, m_SpeakerVolume.GetValue()); + m_pVoiceTweak->SetControlFloat( OtherSpeakerScale, m_SpeakerVolume.GetValue() ); } -void CVoiceVGUITweakDlg::StateChanged(CCheckButton2 *pButton) +void CVoiceVGUITweakDlg::StateChanged( CCheckButton2 *pButton ) { - if(pButton == &m_VoiceModEnable) + if( pButton == &m_VoiceModEnable ) { - if(pButton->IsChecked()) - gEngfuncs.pfnClientCmd("voice_modenable 1"); + if( pButton->IsChecked() ) + gEngfuncs.pfnClientCmd( "voice_modenable 1" ); else - gEngfuncs.pfnClientCmd("voice_modenable 0"); + gEngfuncs.pfnClientCmd( "voice_modenable 0" ); } } diff --git a/game_shared/voice_vgui_tweakdlg.h b/game_shared/voice_vgui_tweakdlg.h index deb83dc2..21af03ae 100644 --- a/game_shared/voice_vgui_tweakdlg.h +++ b/game_shared/voice_vgui_tweakdlg.h @@ -4,22 +4,17 @@ // // $NoKeywords: $ //============================================================================= - +#pragma once #ifndef VOICE_VGUI_TWEAKDLG_H #define VOICE_VGUI_TWEAKDLG_H -#ifdef _WIN32 -#pragma once -#endif - class CMenuPanel; - // Returns true if the tweak dialog is currently up. bool IsTweakDlgOpen(); // Returns a global instance of the tweak dialog. -CMenuPanel* GetVoiceTweakDlg(); - +CMenuPanel *GetVoiceTweakDlg(); #endif // VOICE_VGUI_TWEAKDLG_H + diff --git a/pm_shared/pm_debug.c b/pm_shared/pm_debug.c index 3b0879c7..d726e19a 100644 --- a/pm_shared/pm_debug.c +++ b/pm_shared/pm_debug.c @@ -12,8 +12,12 @@ * without written permission from Valve LLC. * ****/ - +#include #include "mathlib.h" +#if HAVE_TGMATH_H +#include +#endif + #include "const.h" #include "usercmd.h" #include "pm_defs.h" @@ -23,7 +27,7 @@ #include -#ifdef _MSC_VER +#if _MSC_VER #pragma warning(disable : 4244) #pragma warning(disable : 4305) #endif @@ -45,7 +49,7 @@ static int PM_boxpnt[6][4] = void PM_ShowClipBox( void ) { -#if defined( _DEBUG ) +#if _DEBUG vec3_t org; vec3_t offset = { 0, 0, 0 }; @@ -76,7 +80,7 @@ void PM_ShowClipBox( void ) // Show our BBOX in particles. PM_DrawBBox( pmove->player_mins[pmove->usehull], pmove->player_maxs[pmove->usehull], org, pmove->server ? 132 : 0, 0.1 ); - PM_ParticleLine( org, org, pmove->server ? 132 : 0, 0.1, 5.0 ); + PM_ParticleLine( org, org, pmove->server ? 132 : 0, 0.1f, 5.0f ); /* { int i; @@ -179,13 +183,13 @@ void PM_DrawPhysEntBBox(int num, int pcolor, float life) { vec3_t forward, right, up; - AngleVectorsTranspose(pe->angles, forward, right, up); - for (j = 0; j < 8; j++) + AngleVectorsTranspose( pe->angles, forward, right, up); + for( j = 0; j < 8; j++ ) { VectorCopy(p[j], tmp); - p[j][0] = DotProduct ( tmp, forward ); - p[j][1] = DotProduct ( tmp, right ); - p[j][2] = DotProduct ( tmp, up ); + p[j][0] = DotProduct( tmp, forward ); + p[j][1] = DotProduct( tmp, right ); + p[j][2] = DotProduct( tmp, up ); } } @@ -264,7 +268,7 @@ void PM_DrawBBox(vec3_t mins, vec3_t maxs, vec3_t origin, int pcolor, float life } -#ifndef DEDICATED +#if !DEDICATED /* ================ @@ -285,7 +289,7 @@ void PM_ViewEntity( void ) int i; pmtrace_t trace; int pcolor = 77; - float fup; + // float fup; #if 0 if ( !pm_showclip.value ) @@ -296,9 +300,9 @@ void PM_ViewEntity( void ) VectorCopy( pmove->origin, origin); - fup = 0.5*( pmove->player_mins[pmove->usehull][2] + pmove->player_maxs[pmove->usehull][2] ); + /*fup = 0.5f * ( pmove->player_mins[pmove->usehull][2] + pmove->player_maxs[pmove->usehull][2] ); fup += pmove->view_ofs[2]; - fup -= 4; + fup -= 4;*/ for (i = 0; i < 3; i++) { diff --git a/pm_shared/pm_debug.h b/pm_shared/pm_debug.h index 6c91d62e..2d7ba059 100644 --- a/pm_shared/pm_debug.h +++ b/pm_shared/pm_debug.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef PM_DEBUG_H +#if !defined(PM_DEBUG_H) #define PM_DEBUG_H void PM_ViewEntity( void ); diff --git a/pm_shared/pm_defs.h b/pm_shared/pm_defs.h index 82480806..5ef8c356 100644 --- a/pm_shared/pm_defs.h +++ b/pm_shared/pm_defs.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef PM_DEFS_H +#if !defined(PM_DEFS_H) #define PM_DEFS_H #define MAX_PHYSENTS 600 // Must have room for all entities in the world. @@ -194,7 +194,7 @@ typedef struct playermove_s int (*PM_PointContents)( float *p, int *truecontents /*filled in if this is non-null*/ ); int (*PM_TruePointContents)( float *p ); int (*PM_HullPointContents)( struct hull_s *hull, int num, float *p ); -#ifdef __MINGW32__ +#if __MINGW32__ pmtrace_t *(*PM_PlayerTrace_real)( pmtrace_t * retvalue, float *start, float *end, int traceFlags, int ignore_pe ); #else @@ -218,7 +218,7 @@ typedef struct playermove_s void (*PM_PlaySound)( int channel, const char *sample, float volume, float attenuation, int fFlags, int pitch ); const char *(*PM_TraceTexture)( int ground, float *vstart, float *vend ); void (*PM_PlaybackEventFull)( int flags, int clientindex, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); -#ifdef __MINGW32__ +#if __MINGW32__ pmtrace_t *(*PM_PlayerTraceEx_real) (pmtrace_t *retvalue, float *start, float *end, int traceFlags, int (*pfnIgnore)( physent_t *pe )); #else pmtrace_t (*PM_PlayerTraceEx) (float *start, float *end, int traceFlags, int (*pfnIgnore)( physent_t *pe )); @@ -228,7 +228,7 @@ typedef struct playermove_s struct msurface_s *(*PM_TraceSurface)( int ground, float *vstart, float *vend ); } playermove_t; -#ifdef __MINGW32__ +#if __MINGW32__ static pmtrace_t _pm_globalresult, _pm_globaltmp; static inline pmtrace_t PM_PlayerTrace_wrap( float *start, float *end, int traceFlags, int ignore_pe, playermove_t *pmove ) { diff --git a/pm_shared/pm_info.h b/pm_shared/pm_info.h index 9a971d53..2a13c14c 100644 --- a/pm_shared/pm_info.h +++ b/pm_shared/pm_info.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef PM_INFO_H +#if !defined(PM_INFO_H) #define PM_INFO_H #define MAX_PHYSINFO_STRING 256 diff --git a/pm_shared/pm_materials.h b/pm_shared/pm_materials.h index 9bc71b72..ad61e946 100644 --- a/pm_shared/pm_materials.h +++ b/pm_shared/pm_materials.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef PM_MATERIALS_H +#if !defined(PM_MATERIALS_H) #define PM_MATERIALS_H #define CBTEXTURENAMEMAX 13 // only load first n chars of name diff --git a/pm_shared/pm_math.c b/pm_shared/pm_math.c index 4bb4b93f..f10e8a59 100644 --- a/pm_shared/pm_math.c +++ b/pm_shared/pm_math.c @@ -13,10 +13,12 @@ * ****/ // pm_math.c -- math primitives - -#include "mathlib.h" -#include "const.h" #include +#include "mathlib.h" +#if HAVE_TGMATH_H +#include +#endif +#include "const.h" // up / down #define PITCH 0 @@ -25,16 +27,16 @@ // fall over #define ROLL 2 -#ifdef _MSC_VER +#if _MSC_VER #pragma warning(disable : 4244) #endif -vec3_t vec3_origin = { 0,0,0 }; +vec3_t vec3_origin = { 0, 0, 0 }; int nanmask = 255 << 23; float anglemod( float a ) { - a = ( 360.0 / 65536 ) * ( (int)( a * ( 65536 / 360.0 ) ) & 65535 ); + a = ( 360.0f / 65536.0f ) * ( (int)( a * ( 65536.0f / 360.0f ) ) & 65535 ); return a; } @@ -43,13 +45,13 @@ void AngleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up float angle; float sr, sp, sy, cr, cp, cy; - angle = angles[YAW] * ( M_PI * 2 / 360 ); + angle = angles[YAW] * ( M_PI_F * 2.0f / 360.0f ); sy = sin( angle ); cy = cos( angle ); - angle = angles[PITCH] * ( M_PI*2 / 360 ); + angle = angles[PITCH] * ( M_PI_F * 2.0f / 360.0f ); sp = sin( angle ); cp = cos( angle ); - angle = angles[ROLL] * ( M_PI*2 / 360 ); + angle = angles[ROLL] * ( M_PI_F * 2.0f / 360.0f ); sr = sin( angle ); cr = cos( angle ); @@ -78,13 +80,13 @@ void AngleVectorsTranspose( const vec3_t angles, vec3_t forward, vec3_t right, v float angle; float sr, sp, sy, cr, cp, cy; - angle = angles[YAW] * ( M_PI * 2 / 360 ); + angle = angles[YAW] * ( M_PI_F * 2.0f / 360.0f ); sy = sin( angle ); cy = cos( angle ); - angle = angles[PITCH] * ( M_PI * 2 / 360 ); + angle = angles[PITCH] * ( M_PI_F * 2.0f / 360.0f ); sp = sin( angle ); cp = cos( angle ); - angle = angles[ROLL] * ( M_PI * 2 / 360 ); + angle = angles[ROLL] * ( M_PI_F * 2.0f / 360.0f ); sr = sin( angle ); cr = cos( angle ); @@ -113,13 +115,13 @@ void AngleMatrix( const vec3_t angles, float (*matrix)[4] ) float angle; float sr, sp, sy, cr, cp, cy; - angle = angles[YAW] * ( M_PI * 2 / 360 ); + angle = angles[YAW] * ( M_PI_F * 2.0f / 360.0f ); sy = sin( angle ); cy = cos( angle ); - angle = angles[PITCH] * ( M_PI * 2 / 360 ); + angle = angles[PITCH] * ( M_PI_F * 2.0f / 360.0f ); sp = sin( angle ); cp = cos( angle ); - angle = angles[ROLL] * ( M_PI * 2 / 360 ); + angle = angles[ROLL] * ( M_PI_F * 2.0f / 360.0f ); sr = sin( angle ); cr = cos( angle ); @@ -133,9 +135,9 @@ void AngleMatrix( const vec3_t angles, float (*matrix)[4] ) matrix[0][2] = ( cr * sp * cy + -sr * -sy ); matrix[1][2] = ( cr * sp * sy + -sr * cy ); matrix[2][2] = cr * cp; - matrix[0][3] = 0.0; - matrix[1][3] = 0.0; - matrix[2][3] = 0.0; + matrix[0][3] = 0.0f; + matrix[1][3] = 0.0f; + matrix[2][3] = 0.0f; } void AngleIMatrix( const vec3_t angles, float matrix[3][4] ) @@ -143,13 +145,13 @@ void AngleIMatrix( const vec3_t angles, float matrix[3][4] ) float angle; float sr, sp, sy, cr, cp, cy; - angle = angles[YAW] * ( M_PI * 2 / 360 ); + angle = angles[YAW] * ( M_PI_F * 2.0f / 360.0f ); sy = sin( angle ); cy = cos( angle ); - angle = angles[PITCH] * ( M_PI * 2 / 360 ); + angle = angles[PITCH] * ( M_PI_F * 2.0f / 360.0f ); sp = sin( angle ); cp = cos( angle ); - angle = angles[ROLL] * ( M_PI * 2 / 360 ); + angle = angles[ROLL] * ( M_PI_F * 2.0f / 360.0f ); sr = sin( angle ); cr = cos( angle ); @@ -174,13 +176,13 @@ void NormalizeAngles( float *angles ) // Normalize angles for( i = 0; i < 3; i++ ) { - if( angles[i] > 180.0 ) + if( angles[i] > 180.0f ) { - angles[i] -= 360.0; + angles[i] -= 360.0f; } - else if( angles[i] < -180.0 ) + else if( angles[i] < -180.0f ) { - angles[i] += 360.0; + angles[i] += 360.0f; } } } @@ -209,13 +211,13 @@ void InterpolateAngles( float *start, float *end, float *output, float frac ) ang2 = end[i]; d = ang2 - ang1; - if( d > 180 ) + if( d > 180.0f ) { - d -= 360; + d -= 360.0f; } - else if( d < -180 ) + else if( d < -180.0f ) { - d += 360; + d += 360.0f; } output[i] = ang1 + d * frac; @@ -240,7 +242,7 @@ float AngleBetweenVectors( const vec3_t v1, const vec3_t v2 ) return 0.0f; angle = acos( DotProduct( v1, v2 ) / ( l1 * l2 ) ); - angle = ( angle * 180.0f ) / M_PI; + angle = ( angle * 180.0f ) / M_PI_F; return angle; } @@ -303,8 +305,6 @@ void CrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross ) cross[2] = v1[0] * v2[1] - v1[1] * v2[0]; } -double sqrt( double x ); - float Length( const vec3_t v ) { int i; @@ -333,7 +333,7 @@ float VectorNormalize( vec3_t v ) if( length ) { - ilength = 1 / length; + ilength = 1.0f / length; v[0] *= ilength; v[1] *= ilength; v[2] *= ilength; @@ -368,18 +368,18 @@ void VectorMatrix( vec3_t forward, vec3_t right, vec3_t up ) { vec3_t tmp; - if( forward[0] == 0 && forward[1] == 0 ) + if( forward[0] == 0.0f && forward[1] == 0.0f ) { - right[0] = 1; - right[1] = 0; - right[2] = 0; + right[0] = 1.0f; + right[1] = 0.0f; + right[2] = 0.0f; up[0] = -forward[2]; - up[1] = 0; - up[2] = 0; + up[1] = 0.0f; + up[2] = 0.0f; return; } - tmp[0] = 0; tmp[1] = 0; tmp[2] = 1.0; + tmp[0] = 0.0f; tmp[1] = 0.0f; tmp[2] = 1.0f; CrossProduct( forward, tmp, right ); VectorNormalize( right ); CrossProduct( right, forward, up ); @@ -390,27 +390,27 @@ void VectorAngles( const vec3_t forward, vec3_t angles ) { float tmp, yaw, pitch; - if( forward[1] == 0 && forward[0] == 0 ) + if( forward[1] == 0.0f && forward[0] == 0.0f ) { - yaw = 0; - if( forward[2] > 0 ) - pitch = 90; + yaw = 0.0f; + if( forward[2] > 0.0f ) + pitch = 90.0f; else - pitch = 270; + pitch = 270.0f; } else { - yaw = ( atan2( forward[1], forward[0] ) * 180 / M_PI ); - if( yaw < 0 ) - yaw += 360; + yaw = ( atan2( forward[1], forward[0] ) * 180.0f / M_PI_F ); + if( yaw < 0.0f ) + yaw += 360.0f; tmp = sqrt( forward[0] * forward[0] + forward[1] * forward[1] ); - pitch = ( atan2( forward[2], tmp ) * 180 / M_PI ); - if( pitch < 0 ) - pitch += 360; + pitch = ( atan2( forward[2], tmp ) * 180.0f / M_PI_F ); + if( pitch < 0.0f ) + pitch += 360.0f; } angles[0] = pitch; angles[1] = yaw; - angles[2] = 0; + angles[2] = 0.0f; } diff --git a/pm_shared/pm_shared.c b/pm_shared/pm_shared.c index 98246e3c..c07a1f52 100644 --- a/pm_shared/pm_shared.c +++ b/pm_shared/pm_shared.c @@ -14,25 +14,29 @@ ****/ #include +//#include // NULL +#include // sqrt +#include // strcpy +#include // atoi +#include // isspace #include "mathlib.h" +#if HAVE_TGMATH_H +#include +#endif + #include "const.h" #include "usercmd.h" #include "pm_defs.h" #include "pm_shared.h" #include "pm_movevars.h" #include "pm_debug.h" -//#include // NULL -#include // sqrt -#include // strcpy #ifdef stricmp #include // strncasecmp #endif -#include // atoi -#include // isspace int g_bhopcap = 1; -#ifdef CLIENT_DLL +#if CLIENT_DLL // Spectator Mode int iJumpSpectator; extern float vJumpOrigin[3]; @@ -41,14 +45,14 @@ extern float vJumpAngles[3]; static int pm_shared_initialized = 0; -#ifdef _MSC_VER +#if _MSC_VER #pragma warning( disable : 4305 ) #endif playermove_t *pmove = NULL; // Ducking time -#define TIME_TO_DUCK 0.4 +#define TIME_TO_DUCK 0.4f #define VEC_DUCK_HULL_MIN -18 #define VEC_DUCK_HULL_MAX 18 #define VEC_DUCK_VIEW 12 @@ -59,22 +63,10 @@ playermove_t *pmove = NULL; #define VEC_HULL_MIN -36 #define VEC_HULL_MAX 36 #define VEC_VIEW 28 -#define STOP_EPSILON 0.1 +#define STOP_EPSILON 0.1f #define CTEXTURESMAX 512 // max number of textures loaded -#define CBTEXTURENAMEMAX 13 // only load first n chars of name - -#define CHAR_TEX_CONCRETE 'C' // texture types -#define CHAR_TEX_METAL 'M' -#define CHAR_TEX_DIRT 'D' -#define CHAR_TEX_VENT 'V' -#define CHAR_TEX_GRATE 'G' -#define CHAR_TEX_TILE 'T' -#define CHAR_TEX_SLOSH 'S' -#define CHAR_TEX_WOOD 'W' -#define CHAR_TEX_COMPUTER 'P' -#define CHAR_TEX_GLASS 'Y' -#define CHAR_TEX_FLESH 'F' +#include "pm_materials.h" #define STEP_CONCRETE 0 // default step sound #define STEP_METAL 1 // metal floor @@ -94,10 +86,10 @@ playermove_t *pmove = NULL; #define PLAYER_LONGJUMP_SPEED 350 // how fast we longjump -#define PLAYER_DUCKING_MULTIPLIER 0.333 +#define PLAYER_DUCKING_MULTIPLIER 0.333f // double to float warning -#ifdef _MSC_VER +#if _MSC_VER #pragma warning(disable : 4244) #endif @@ -131,13 +123,26 @@ static char grgchTextureType[CTEXTURESMAX]; int g_onladder = 0; -#ifdef CLIENT_DLL +#if CLIENT_DLL #define materials_path "sound/materials.txt" #else #include "cvardef.h" extern cvar_t materials_txt; #define materials_path materials_txt.string #endif +static void PM_InitTrace( trace_t *trace, const vec3_t end ) +{ + memset( trace, 0, sizeof( *trace )); + VectorCopy( end, trace->endpos ); + trace->allsolid = true; + trace->fraction = 1.0f; +} + +static void PM_TraceModel( physent_t *pe, float *start, float *end, trace_t *trace ) +{ + PM_InitTrace( trace, end ); + pmove->PM_TraceModel(pe, start, end, trace); +} void PM_SwapTextures( int i, int j ) { @@ -297,7 +302,7 @@ void PM_PlayStepSound( int step, float fvol ) return; VectorCopy( pmove->velocity, hvel ); - hvel[2] = 0.0; + hvel[2] = 0.0f; if( pmove->multiplayer && ( !g_onladder && Length( hvel ) <= 220 ) ) return; @@ -607,7 +612,7 @@ void PM_UpdateStepSound( void ) // If we're on a ladder or on the ground, and we're moving fast enough, // play step sound. Also, if pmove->flTimeStepSound is zero, get the new // sound right away - we just started moving in new level. - if( ( fLadder || ( pmove->onground != -1 ) ) && ( Length( pmove->velocity ) > 0.0 ) && ( speed >= velwalk || !pmove->flTimeStepSound ) ) + if( ( fLadder || ( pmove->onground != -1 ) ) && ( Length( pmove->velocity ) > 0.0f ) && ( speed >= velwalk || !pmove->flTimeStepSound ) ) { fWalking = speed < velrun; @@ -617,26 +622,26 @@ void PM_UpdateStepSound( void ) height = pmove->player_maxs[pmove->usehull][2] - pmove->player_mins[pmove->usehull][2]; - knee[2] = pmove->origin[2] - 0.3 * height; - feet[2] = pmove->origin[2] - 0.5 * height; + knee[2] = pmove->origin[2] - 0.3f * height; + feet[2] = pmove->origin[2] - 0.5f * height; // find out what we're stepping in or on... if( fLadder ) { step = STEP_LADDER; - fvol = 0.35; + fvol = 0.35f; pmove->flTimeStepSound = 350; } else if( pmove->PM_PointContents( knee, NULL ) == CONTENTS_WATER ) { step = STEP_WADE; - fvol = 0.65; + fvol = 0.65f; pmove->flTimeStepSound = 600; } else if( pmove->PM_PointContents( feet, NULL ) == CONTENTS_WATER ) { step = STEP_SLOSH; - fvol = fWalking ? 0.2 : 0.5; + fvol = fWalking ? 0.2f : 0.5f; pmove->flTimeStepSound = fWalking ? 400 : 300; } else @@ -649,31 +654,31 @@ void PM_UpdateStepSound( void ) { default: case CHAR_TEX_CONCRETE: - fvol = fWalking ? 0.2 : 0.5; + fvol = fWalking ? 0.2f : 0.5f; pmove->flTimeStepSound = fWalking ? 400 : 300; break; case CHAR_TEX_METAL: - fvol = fWalking ? 0.2 : 0.5; + fvol = fWalking ? 0.2f : 0.5f; pmove->flTimeStepSound = fWalking ? 400 : 300; break; case CHAR_TEX_DIRT: - fvol = fWalking ? 0.25 : 0.55; + fvol = fWalking ? 0.25f : 0.55f; pmove->flTimeStepSound = fWalking ? 400 : 300; break; case CHAR_TEX_VENT: - fvol = fWalking ? 0.4 : 0.7; + fvol = fWalking ? 0.4f : 0.7f; pmove->flTimeStepSound = fWalking ? 400 : 300; break; case CHAR_TEX_GRATE: - fvol = fWalking ? 0.2 : 0.5; + fvol = fWalking ? 0.2f : 0.5f; pmove->flTimeStepSound = fWalking ? 400 : 300; break; case CHAR_TEX_TILE: - fvol = fWalking ? 0.2 : 0.5; + fvol = fWalking ? 0.2f : 0.5f; pmove->flTimeStepSound = fWalking ? 400 : 300; break; case CHAR_TEX_SLOSH: - fvol = fWalking ? 0.2 : 0.5; + fvol = fWalking ? 0.2f : 0.5f; pmove->flTimeStepSound = fWalking ? 400 : 300; break; } @@ -685,7 +690,7 @@ void PM_UpdateStepSound( void ) // 35% volume if ducking if( pmove->flags & FL_DUCKING ) { - fvol *= 0.35; + fvol *= 0.35f; } PM_PlayStepSound( step, fvol ); @@ -814,11 +819,11 @@ void PM_AddCorrectGravity() if( pmove->gravity ) ent_gravity = pmove->gravity; else - ent_gravity = 1.0; + ent_gravity = 1.0f; // Add gravity so they'll be in the correct position during movement // yes, this 0.5 looks wrong, but it's not. - pmove->velocity[2] -= ( ent_gravity * pmove->movevars->gravity * 0.5 * pmove->frametime ); + pmove->velocity[2] -= ( ent_gravity * pmove->movevars->gravity * 0.5f * pmove->frametime ); pmove->velocity[2] += pmove->basevelocity[2] * pmove->frametime; pmove->basevelocity[2] = 0; @@ -835,10 +840,10 @@ void PM_FixupGravityVelocity() if( pmove->gravity ) ent_gravity = pmove->gravity; else - ent_gravity = 1.0; + ent_gravity = 1.0f; // Get the correct velocity for the end of the dt - pmove->velocity[2] -= ( ent_gravity * pmove->movevars->gravity * pmove->frametime * 0.5 ); + pmove->velocity[2] -= ( ent_gravity * pmove->movevars->gravity * pmove->frametime * 0.5f ); PM_CheckVelocity(); } @@ -924,7 +929,7 @@ int PM_FlyMove( void ) // If the plane we hit has a high z component in the normal, then // it's probably a floor - if( trace.plane.normal[2] > 0.7 ) + if( trace.plane.normal[2] > 0.7f ) { blocked |= 1; // floor } @@ -959,14 +964,14 @@ int PM_FlyMove( void ) { for( i = 0; i < numplanes; i++ ) { - if( planes[i][2] > 0.7 ) + if( planes[i][2] > 0.7f ) { // floor or slope PM_ClipVelocity( original_velocity, planes[i], new_velocity, 1 ); VectorCopy( new_velocity, original_velocity ); } else - PM_ClipVelocity( original_velocity, planes[i], new_velocity, 1.0 + pmove->movevars->bounce * ( 1 - pmove->friction ) ); + PM_ClipVelocity( original_velocity, planes[i], new_velocity, 1.0f + pmove->movevars->bounce * ( 1 - pmove->friction ) ); } VectorCopy( new_velocity, pmove->velocity ); @@ -1215,8 +1220,9 @@ void PM_WalkMove() // If we are not on the ground any more then // use the original movement attempt - if( trace.plane.normal[2] < 0.7 ) + if( trace.plane.normal[2] < 0.7f ) goto usedown; + // If the trace ended up in empty space, copy the end // over to the origin. if( !trace.startsolid && !trace.allsolid ) @@ -1287,7 +1293,7 @@ void PM_Friction( void ) trace = pmove->PM_PlayerTrace( start, stop, PM_NORMAL, -1 ); - if( trace.fraction == 1.0 ) + if( trace.fraction == 1.0f ) friction = pmove->movevars->friction*pmove->movevars->edgefriction; else friction = pmove->movevars->friction; @@ -1401,7 +1407,7 @@ void PM_WaterMove( void ) wishspeed = pmove->maxspeed; } // Slow us down a bit. - wishspeed *= 0.8; + wishspeed *= 0.8f; VectorAdd( pmove->velocity, pmove->basevelocity, pmove->velocity ); @@ -1528,8 +1534,8 @@ qboolean PM_CheckWater() float heightover2; // Pick a spot just above the players feet. - point[0] = pmove->origin[0] + ( pmove->player_mins[pmove->usehull][0] + pmove->player_maxs[pmove->usehull][0] ) * 0.5; - point[1] = pmove->origin[1] + ( pmove->player_mins[pmove->usehull][1] + pmove->player_maxs[pmove->usehull][1] ) * 0.5; + point[0] = pmove->origin[0] + ( pmove->player_mins[pmove->usehull][0] + pmove->player_maxs[pmove->usehull][0] ) * 0.5f; + point[1] = pmove->origin[1] + ( pmove->player_mins[pmove->usehull][1] + pmove->player_maxs[pmove->usehull][1] ) * 0.5f; point[2] = pmove->origin[2] + pmove->player_mins[pmove->usehull][2] + 1; // Assume that we are not in water at all. @@ -1548,7 +1554,7 @@ qboolean PM_CheckWater() pmove->waterlevel = 1; height = ( pmove->player_mins[pmove->usehull][2] + pmove->player_maxs[pmove->usehull][2] ); - heightover2 = height * 0.5; + heightover2 = height * 0.5f; // Now check a point that is at the player hull midpoint. point[2] = pmove->origin[2] + heightover2; @@ -1623,7 +1629,7 @@ void PM_CatagorizePosition( void ) // Try and move down. tr = pmove->PM_PlayerTrace( pmove->origin, point, PM_NORMAL, -1 ); // If we hit a steep plane, we are not on ground - if( tr.plane.normal[2] < 0.7 ) + if( tr.plane.normal[2] < 0.7f ) pmove->onground = -1; // too steep else pmove->onground = tr.ent; // Otherwise, point to index of ent under us. @@ -1679,7 +1685,7 @@ try nudging slightly on all axis to allow for the cut precision of the net coordinates ================= */ -#define PM_CHECKSTUCK_MINTIME 0.05 // Don't check again too quickly. +#define PM_CHECKSTUCK_MINTIME 0.05f // Don't check again too quickly. int PM_CheckStuck( void ) { @@ -1765,8 +1771,8 @@ int PM_CheckStuck( void ) if( pmove->cmd.buttons & ( IN_JUMP | IN_DUCK | IN_ATTACK ) && ( pmove->physents[hitent].player != 0 ) ) { float x, y, z; - float xystep = 8.0; - float zstep = 18.0; + float xystep = 8.0f; + float zstep = 18.0f; float xyminmax = xystep; float zminmax = 4 * zstep; @@ -1818,7 +1824,7 @@ void PM_SpectatorMove( void ) if( pmove->iuser1 == OBS_ROAMING ) { -#ifdef CLIENT_DLL +#if CLIENT_DLL // jump only in roaming mode if( iJumpSpectator ) { @@ -1839,7 +1845,7 @@ void PM_SpectatorMove( void ) { drop = 0; - friction = pmove->movevars->friction * 1.5; // extra friction + friction = pmove->movevars->friction * 1.5f; // extra friction control = speed < pmove->movevars->stopspeed ? pmove->movevars->stopspeed : speed; drop += control * friction*pmove->frametime; @@ -2056,12 +2062,12 @@ void PM_Duck( void ) pmove->bInDuck = true; } - time = max( 0.0, ( 1.0 - (float)pmove->flDuckTime / 1000.0 ) ); + time = max( 0.0f, ( 1.0f - (float)pmove->flDuckTime / 1000.0f ) ); if( pmove->bInDuck ) { // Finish ducking immediately if duck time is over or not on ground - if( ( (float)pmove->flDuckTime / 1000.0 <= ( 1.0 - TIME_TO_DUCK ) ) || ( pmove->onground == -1 ) ) + if( ( (float)pmove->flDuckTime / 1000.0f <= ( 1.0f - TIME_TO_DUCK ) ) || ( pmove->onground == -1 ) ) { pmove->usehull = 1; pmove->view_ofs[2] = VEC_DUCK_VIEW; @@ -2087,7 +2093,7 @@ void PM_Duck( void ) float fMore = VEC_DUCK_HULL_MIN - VEC_HULL_MIN; // Calc parametric time - duckFraction = PM_SplineFraction( time, (1.0/TIME_TO_DUCK) ); + duckFraction = PM_SplineFraction( time, ( 1.0f / TIME_TO_DUCK ) ); pmove->view_ofs[2] = ( ( VEC_DUCK_VIEW - fMore ) * duckFraction ) + ( VEC_VIEW * ( 1 - duckFraction ) ); } } @@ -2128,8 +2134,8 @@ void PM_LadderMove( physent_t *pLadder ) onFloor = false; pmove->gravity = 0; - pmove->PM_TraceModel( pLadder, pmove->origin, ladderCenter, &trace ); - if( trace.fraction != 1.0 ) + PM_TraceModel(pLadder, pmove->origin, ladderCenter, &trace); + if( trace.fraction != 1.0f ) { float forward = 0, right = 0; vec3_t vpn, v_right; @@ -2274,7 +2280,7 @@ void PM_AddGravity() if( pmove->gravity ) ent_gravity = pmove->gravity; else - ent_gravity = 1.0; + ent_gravity = 1.0f; // Add gravity incorrectly pmove->velocity[2] -= ( ent_gravity * pmove->movevars->gravity * pmove->frametime ); @@ -2302,7 +2308,7 @@ pmtrace_t PM_PushEntity( vec3_t push ) VectorCopy( trace.endpos, pmove->origin ); // So we can run impact function afterwards. - if( trace.fraction < 1.0 && !trace.allsolid ) + if( trace.fraction < 1.0f && !trace.allsolid ) { PM_AddToTouched( trace, pmove->velocity ); } @@ -2369,16 +2375,16 @@ void PM_Physics_Toss() } if( pmove->movetype == MOVETYPE_BOUNCE ) - backoff = 2.0 - pmove->friction; + backoff = 2.0f - pmove->friction; else if( pmove->movetype == MOVETYPE_BOUNCEMISSILE ) - backoff = 2.0; + backoff = 2.0f; else - backoff = 1; + backoff = 1.0f; PM_ClipVelocity( pmove->velocity, trace.plane.normal, pmove->velocity, backoff ); // stop if on ground - if( trace.plane.normal[2] > 0.7 ) + if( trace.plane.normal[2] > 0.7f ) { float vel; vec3_t base; @@ -2402,7 +2408,7 @@ void PM_Physics_Toss() } else { - VectorScale( pmove->velocity, ( 1.0 - trace.fraction) * pmove->frametime * 0.9, move ); + VectorScale( pmove->velocity, ( 1.0f - trace.fraction) * pmove->frametime * 0.9f, move ); trace = PM_PushEntity( move ); } VectorSubtract( pmove->velocity, base, pmove->velocity ) @@ -2474,7 +2480,7 @@ void PM_PreventMegaBunnyJumping( void ) if( spd <= maxscaledspeed ) return; - fraction = ( maxscaledspeed / spd ) * 0.65; //Returns the modifier for the velocity + fraction = ( maxscaledspeed / spd ) * 0.65f; //Returns the modifier for the velocity VectorScale( pmove->velocity, fraction, pmove->velocity ); //Crop it down!. } @@ -2579,7 +2585,7 @@ void PM_Jump( void ) } else { - PM_PlayStepSound( PM_MapTextureTypeStepType( pmove->chtexturetype ), 1.0 ); + PM_PlayStepSound( PM_MapTextureTypeStepType( pmove->chtexturetype ), 1.0f ); } // See if user can super long jump? @@ -2598,19 +2604,19 @@ void PM_Jump( void ) for( i = 0; i < 2; i++ ) { - pmove->velocity[i] = pmove->forward[i] * PLAYER_LONGJUMP_SPEED * 1.6; + pmove->velocity[i] = pmove->forward[i] * PLAYER_LONGJUMP_SPEED * 1.6f; } - pmove->velocity[2] = sqrt( 2 * 800 * 56.0 ); + pmove->velocity[2] = sqrt( 2.0f * 800.0f * 56.0f ); } else { - pmove->velocity[2] = sqrt( 2 * 800 * 45.0 ); + pmove->velocity[2] = sqrt( 2.0f * 800.0f * 45.0f ); } } else { - pmove->velocity[2] = sqrt( 2 * 800 * 45.0 ); + pmove->velocity[2] = sqrt( 2.0f * 800.0f * 45.0f ); } // Decay it for simulation @@ -2658,7 +2664,7 @@ void PM_CheckWaterJump( void ) VectorNormalize( flatforward ); // Are we backing into water from steps or something? If so, don't pop forward - if( curspeed != 0.0 && ( DotProduct( flatvelocity, flatforward ) < 0.0 ) ) + if( curspeed != 0.0f && ( DotProduct( flatvelocity, flatforward ) < 0.0f ) ) return; VectorCopy( pmove->origin, vecStart ); @@ -2670,14 +2676,14 @@ void PM_CheckWaterJump( void ) savehull = pmove->usehull; pmove->usehull = 2; tr = pmove->PM_PlayerTrace( vecStart, vecEnd, PM_NORMAL, -1 ); - if( tr.fraction < 1.0 && fabs( tr.plane.normal[2] ) < 0.1f ) // Facing a near vertical wall? + if( tr.fraction < 1.0f && fabs( tr.plane.normal[2] ) < 0.1f ) // Facing a near vertical wall? { vecStart[2] += pmove->player_maxs[savehull][2] - WJ_HEIGHT; VectorMA( vecStart, 24, flatforward, vecEnd ); VectorMA( vec3_origin, -50, tr.plane.normal, pmove->movedir ); tr = pmove->PM_PlayerTrace( vecStart, vecEnd, PM_NORMAL, -1 ); - if( tr.fraction == 1.0 ) + if( tr.fraction == 1.0f ) { pmove->waterjumptime = 2000; pmove->velocity[2] = 225; @@ -2694,7 +2700,7 @@ void PM_CheckFalling( void ) { if( pmove->onground != -1 && !pmove->dead && pmove->flFallVelocity >= PLAYER_FALL_PUNCH_THRESHHOLD ) { - float fvol = 0.5; + float fvol = 0.5f; if( pmove->waterlevel > 0 ) { @@ -2712,7 +2718,7 @@ void PM_CheckFalling( void ) pmove->PM_PlaySound( CHAN_VOICE, "player/pl_fallpain3.wav", 1, ATTN_NORM, 0, PITCH_NORM ); // break; //} - fvol = 1.0; + fvol = 1.0f; } else if( pmove->flFallVelocity > PLAYER_MAX_SAFE_FALL_SPEED / 2 ) { @@ -2731,7 +2737,7 @@ void PM_CheckFalling( void ) fvol = 0; } - if( fvol > 0.0 ) + if( fvol > 0.0f ) { // Play landing step right away pmove->flTimeStepSound = 0; @@ -2742,7 +2748,7 @@ void PM_CheckFalling( void ) PM_PlayStepSound( PM_MapTextureTypeStepType( pmove->chtexturetype ), fvol ); // Knock the screen around a little bit, temporary effect - pmove->punchangle[2] = pmove->flFallVelocity * 0.013; // punch z axis + pmove->punchangle[2] = pmove->flFallVelocity * 0.013f; // punch z axis if( pmove->punchangle[0] > 8 ) { @@ -2832,8 +2838,8 @@ void PM_DropPunchAngle( vec3_t punchangle ) float len; len = VectorNormalize( punchangle ); - len -= ( 10.0 + len * 0.5 ) * pmove->frametime; - len = max( len, 0.0 ); + len -= ( 10.0f + len * 0.5f ) * pmove->frametime; + len = max( len, 0.0f ); VectorScale( punchangle, len, punchangle ); } @@ -2854,12 +2860,12 @@ void PM_CheckParamters( void ) spd = sqrt( spd ); maxspeed = pmove->clientmaxspeed; //atof( pmove->PM_Info_ValueForKey( pmove->physinfo, "maxspd" ) ); - if( maxspeed != 0.0 ) + if( maxspeed != 0.0f ) { pmove->maxspeed = min( maxspeed, pmove->maxspeed ); } - if( ( spd != 0.0 ) && ( spd > pmove->maxspeed ) ) + if( ( spd != 0.0f ) && ( spd > pmove->maxspeed ) ) { float fRatio = pmove->maxspeed / spd; pmove->cmd.forwardmove *= fRatio; @@ -2957,7 +2963,7 @@ void PM_PlayerMove( qboolean server ) pmove->numtouch = 0; // # of msec to apply movement - pmove->frametime = pmove->cmd.msec * 0.001; + pmove->frametime = pmove->cmd.msec * 0.001f; PM_ReduceTimers(); @@ -3139,7 +3145,7 @@ void PM_PlayerMove( qboolean server ) // we don't slow when standing still, relative to the conveyor. if( pmove->onground != -1 ) { - pmove->velocity[2] = 0.0; + pmove->velocity[2] = 0.0f; PM_Friction(); } @@ -3203,7 +3209,7 @@ void PM_CreateStuckTable( void ) // Little Moves. x = y = 0; // Z moves - for( z = -0.125; z <= 0.125; z += 0.125 ) + for( z = -0.125f; z <= 0.125f; z += 0.125f ) { rgv3tStuckTable[idx][0] = x; rgv3tStuckTable[idx][1] = y; @@ -3212,7 +3218,7 @@ void PM_CreateStuckTable( void ) } x = z = 0; // Y moves - for( y = -0.125; y <= 0.125; y += 0.125 ) + for( y = -0.125f; y <= 0.125f; y += 0.125f ) { rgv3tStuckTable[idx][0] = x; rgv3tStuckTable[idx][1] = y; @@ -3221,7 +3227,7 @@ void PM_CreateStuckTable( void ) } y = z = 0; // X moves - for( x = -0.125; x <= 0.125; x += 0.125 ) + for( x = -0.125f; x <= 0.125f; x += 0.125f ) { rgv3tStuckTable[idx][0] = x; rgv3tStuckTable[idx][1] = y; @@ -3230,11 +3236,11 @@ void PM_CreateStuckTable( void ) } // Remaining multi axis nudges. - for( x = - 0.125; x <= 0.125; x += 0.250 ) + for( x = - 0.125f; x <= 0.125f; x += 0.250f ) { - for( y = - 0.125; y <= 0.125; y += 0.250 ) + for( y = - 0.125f; y <= 0.125f; y += 0.250f ) { - for( z = - 0.125; z <= 0.125; z += 0.250 ) + for( z = - 0.125f; z <= 0.125f; z += 0.250f ) { rgv3tStuckTable[idx][0] = x; rgv3tStuckTable[idx][1] = y; @@ -3263,7 +3269,7 @@ void PM_CreateStuckTable( void ) x = z = 0; // Y moves - for( y = -2.0f ; y <= 2.0f ; y += 2.0 ) + for( y = -2.0f; y <= 2.0f; y += 2.0f ) { rgv3tStuckTable[idx][0] = x; rgv3tStuckTable[idx][1] = y; @@ -3272,7 +3278,7 @@ void PM_CreateStuckTable( void ) } y = z = 0; // X moves - for( x = -2.0f ; x <= 2.0f ; x += 2.0f ) + for( x = -2.0f; x <= 2.0f; x += 2.0f ) { rgv3tStuckTable[idx][0] = x; rgv3tStuckTable[idx][1] = y; @@ -3287,7 +3293,7 @@ void PM_CreateStuckTable( void ) for( x = -2.0f; x <= 2.0f; x += 2.0f ) { - for( y = -2.0f; y <= 2.0f; y += 2.0 ) + for( y = -2.0f; y <= 2.0f; y += 2.0f ) { rgv3tStuckTable[idx][0] = x; rgv3tStuckTable[idx][1] = y; diff --git a/pm_shared/pm_shared.h b/pm_shared/pm_shared.h index c315353b..7e64421f 100644 --- a/pm_shared/pm_shared.h +++ b/pm_shared/pm_shared.h @@ -13,7 +13,7 @@ * ****/ #pragma once -#ifndef PM_SHARED_H +#if !defined(PM_SHARED_H) #define PM_SHARED_H void PM_Init( struct playermove_s *ppmove ); diff --git a/public/build.h b/public/build.h new file mode 100644 index 00000000..4e4fe110 --- /dev/null +++ b/public/build.h @@ -0,0 +1,279 @@ +/* +build.h - compile-time build information + +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to +*/ +#pragma once +#ifndef BUILD_H +#define BUILD_H + +// All XASH_* macros set by this header are guaranteed to have positive value otherwise not defined + +// Any new define must be undefined at first +// You can generate #undef list below with this oneliner: +// $ cat build.h | sed 's/\t//g' | grep '^#define XASH' | awk '{ print $2 }' | sort | uniq | awk '{ print "#undef " $1 }' +// +// So in various buildscripts you can grep for ^#undef XASH and select only second word +// or in another oneliner: +// $ cat build.h | grep '^#undef XASH' | awk '{ print $2 }' + +#undef XASH_64BIT +#undef XASH_AMD64 +#undef XASH_ANDROID +#undef XASH_APPLE +#undef XASH_ARM +#undef XASH_ARM_HARDFP +#undef XASH_ARM_SOFTFP +#undef XASH_ARMv4 +#undef XASH_ARMv5 +#undef XASH_ARMv6 +#undef XASH_ARMv7 +#undef XASH_ARMv8 +#undef XASH_BIG_ENDIAN +#undef XASH_BSD +#undef XASH_DOS4GW +#undef XASH_E2K +#undef XASH_EMSCRIPTEN +#undef XASH_FREEBSD +#undef XASH_HAIKU +#undef XASH_IOS +#undef XASH_JS +#undef XASH_LINUX +#undef XASH_LITTLE_ENDIAN +#undef XASH_MINGW +#undef XASH_MIPS +#undef XASH_PPC +#undef XASH_MOBILE_PLATFORM +#undef XASH_MSVC +#undef XASH_NETBSD +#undef XASH_OPENBSD +#undef XASH_POSIX +#undef XASH_RISCV +#undef XASH_RISCV_DOUBLEFP +#undef XASH_RISCV_SINGLEFP +#undef XASH_RISCV_SOFTFP +#undef XASH_SERENITY +#undef XASH_WIN32 +#undef XASH_WIN64 +#undef XASH_X86 +#undef XASH_NSWITCH +#undef XASH_PSVITA + +//================================================================ +// +// OPERATING SYSTEM DEFINES +// +//================================================================ +#if defined(_WIN32) + #define XASH_WIN32 1 + #if defined(__MINGW32__) + #define XASH_MINGW 1 + #elif defined(_MSC_VER) + #define XASH_MSVC 1 + #endif + + #if defined(_WIN64) + #define XASH_WIN64 1 + #endif +#elif defined __SWITCH__ + #define XASH_NSWITCH 1 + #define XASH_LITTLE_ENDIAN 1 + #define XASH_POSIX 1 +#elif defined __vita__ + #define XASH_PSVITA 1 + #define XASH_LITTLE_ENDIAN 1 + #define XASH_POSIX 1 +#elif defined(__linux__) + #define XASH_LINUX 1 + #if defined(__ANDROID__) + #define XASH_ANDROID 1 + #endif // defined(__ANDROID__) + #define XASH_POSIX 1 +#elif defined(__APPLE__) + #include + #define XASH_APPLE 1 + #if TARGET_OS_IOS + #define XASH_IOS 1 + #endif // TARGET_OS_IOS + #define XASH_POSIX 1 +#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) + #define XASH_BSD 1 + #if defined(__FreeBSD__) + #define XASH_FREEBSD 1 + #elif defined(__NetBSD__) + #define XASH_NETBSD 1 + #elif defined(__OpenBSD__) + #define XASH_OPENBSD 1 + #endif + #define XASH_POSIX 1 +#elif defined __EMSCRIPTEN__ + #define XASH_EMSCRIPTEN 1 +#elif defined __WATCOMC__ && defined __DOS__ + #define XASH_DOS4GW 1 + #define XASH_LITTLE_ENDIAN 1 +#elif defined __HAIKU__ + #define XASH_HAIKU 1 + #define XASH_POSIX 1 +#elif defined __serenity__ + #define XASH_SERENITY 1 + #define XASH_POSIX 1 +#else +#error "Place your operating system name here! If this is a mistake, try to fix conditions above and report a bug" +#endif + +#if defined XASH_ANDROID || defined XASH_IOS || defined XASH_NSWITCH || defined XASH_PSVITA + #define XASH_MOBILE_PLATFORM 1 +#endif + +//================================================================ +// +// ENDIANNESS DEFINES +// +//================================================================ + +#if defined(XASH_FORCE_LITTLE_ENDIAN) && defined(XASH_FORCE_BIG_ENDIAN) + #error "Both XASH_FORCE_LITTLE_ENDIAN and XASH_FORCE_BIG_ENDIAN are defined" +#elif defined(XASH_FORCE_LITTLE_ENDIAN) + #define XASH_LITTLE_ENDIAN 1 +#elif defined(XASH_FORCE_BIG_ENDIAN) + #define XASH_BIG_ENDIAN 1 +#endif + +#if !defined(XASH_LITTLE_ENDIAN) && !defined(XASH_BIG_ENDIAN) + #if defined XASH_MSVC || __LITTLE_ENDIAN__ + //!!! Probably all WinNT installations runs in little endian + #define XASH_LITTLE_ENDIAN 1 + #elif __BIG_ENDIAN__ + #define XASH_BIG_ENDIAN 1 + #elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && defined(__ORDER_LITTLE_ENDIAN__) // some compilers define this + #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + #define XASH_BIG_ENDIAN 1 + #elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + #define XASH_LITTLE_ENDIAN 1 + #else + #error "Unknown endianness!" + #endif + #else + #include + #if __BYTE_ORDER == __BIG_ENDIAN + #define XASH_BIG_ENDIAN 1 + #elif __BYTE_ORDER == __LITTLE_ENDIAN + #define XASH_LITTLE_ENDIAN 1 + #else + #error "Unknown endianness!" + #endif + #endif // !XASH_WIN32 +#endif + +//================================================================ +// +// CPU ARCHITECTURE DEFINES +// +//================================================================ +#if defined(__x86_64__) || defined(_M_X64) + #define XASH_64BIT 1 + #define XASH_AMD64 1 +#elif defined(__i386__) || defined(_X86_) || defined(_M_IX86) + #define XASH_X86 1 +#elif defined __aarch64__ || defined _M_ARM64 + #define XASH_64BIT 1 + #define XASH_ARM 8 +#elif defined __arm__ || defined _M_ARM + #if __ARM_ARCH == 8 || __ARM_ARCH_8__ + #define XASH_ARM 8 + #elif __ARM_ARCH == 7 || __ARM_ARCH_7__ || defined _M_ARM // msvc can only armv7 in 32 bit + #define XASH_ARM 7 + #elif __ARM_ARCH == 6 || __ARM_ARCH_6__ || __ARM_ARCH_6J__ + #define XASH_ARM 6 + #elif __ARM_ARCH == 5 || __ARM_ARCH_5__ + #define XASH_ARM 5 + #elif __ARM_ARCH == 4 || __ARM_ARCH_4__ + #define XASH_ARM 4 + #else + #error "Unknown ARM" + #endif + + #if defined _M_ARM + #error "No WinMobile port yet! Need to determine which ARM float ABI msvc uses if applicable" + #endif + + #if defined __SOFTFP__ || __ARM_PCS_VFP == 0 + #define XASH_ARM_SOFTFP 1 + #else // __SOFTFP__ + #define XASH_ARM_HARDFP 1 + #endif // __SOFTFP__ +#elif defined __mips__ + #define XASH_MIPS 1 +#elif defined __powerpc__ + #define XASH_PPC 1 + #if defined __powerpc64__ + #define XASH_64BIT 1 + #endif +#elif defined __EMSCRIPTEN__ + #define XASH_JS 1 +#elif defined __e2k__ + #define XASH_64BIT 1 + #define XASH_E2K 1 +#elif defined __riscv + #define XASH_RISCV 1 + #if __riscv_xlen == 64 + #define XASH_64BIT 1 + #elif __riscv_xlen == 32 + // ... + #else + #error "Unknown RISC-V ABI" + #endif + + #if defined __riscv_float_abi_soft + #define XASH_RISCV_SOFTFP 1 + #elif defined __riscv_float_abi_single + #define XASH_RISCV_SINGLEFP 1 + #elif defined __riscv_float_abi_double + #define XASH_RISCV_DOUBLEFP 1 + #else + #error "Unknown RISC-V float ABI" + #endif +#else + #error "Place your architecture name here! If this is a mistake, try to fix conditions above and report a bug" +#endif + +#if defined(XASH_WAF_DETECTED_64BIT) && !defined(XASH_64BIT) + #define XASH_64BIT 1 +#endif + +#if XASH_ARM == 8 + #define XASH_ARMv8 1 +#elif XASH_ARM == 7 + #define XASH_ARMv7 1 +#elif XASH_ARM == 6 + #define XASH_ARMv6 1 +#elif XASH_ARM == 5 + #define XASH_ARMv5 1 +#elif XASH_ARM == 4 + #define XASH_ARMv4 1 +#endif + +#endif // BUILD_H diff --git a/scripts/waifulib/compiler_optimizations.py b/scripts/waifulib/compiler_optimizations.py new file mode 100644 index 00000000..688c6f55 --- /dev/null +++ b/scripts/waifulib/compiler_optimizations.py @@ -0,0 +1,179 @@ +# encoding: utf-8 +# compiler_optimizations.py -- main entry point for configuring C/C++ compilers +# Copyright (C) 2021 a1batross +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +try: from fwgslib import get_flags_by_type, get_flags_by_compiler +except: from waflib.extras.fwgslib import get_flags_by_type, get_flags_by_compiler +from waflib.Configure import conf +from waflib import Logs + +''' +Flags can be overriden and new types can be added +by importing this as normal Python module + +Example: +#!/usr/bin/env python +from waflib.extras import compiler_optimizations + +compiler_optimizations.VALID_BUILD_TYPES += 'gottagofast' +compiler_optimizations.CFLAGS['gottagofast'] = { + 'gcc': ['-Ogentoo'] +} +''' + +VALID_BUILD_TYPES = ['fastnative', 'fast', 'release', 'debug', 'sanitize', 'msan', 'none'] + +LINKFLAGS = { + 'common': { + 'msvc': ['/DEBUG'], # always create PDB, doesn't affect result binaries + 'gcc': ['-Wl,--no-undefined'], + 'owcc': ['-Wl,option stack=512k'] + }, + 'msan': { + 'clang': ['-fsanitize=memory', '-pthread'], + 'default': ['NO_MSAN_HERE'] + }, + 'sanitize': { + 'clang': ['-fsanitize=undefined', '-fsanitize=address', '-pthread'], + 'gcc': ['-fsanitize=undefined', '-fsanitize=address', '-pthread'], + 'msvc': ['/SAFESEH:NO'] + }, + 'debug': { + 'msvc': ['/INCREMENTAL', '/SAFESEH:NO'] + } +} + +CFLAGS = { + 'common': { + # disable thread-safe local static initialization for C++11 code, as it cause crashes on Windows XP + 'msvc': ['/D_USING_V110_SDK71_', '/FS', '/Zc:threadSafeInit-', '/MT', '/MP', '/Zc:__cplusplus'], + 'clang': ['-g', '-gdwarf-2', '-fvisibility=hidden', '-fno-threadsafe-statics'], + 'gcc': ['-g', '-fvisibility=hidden'], + 'owcc': ['-fno-short-enum', '-ffloat-store', '-g3'] + }, + 'fast': { + 'msvc': ['/O2', '/Oy', '/Zi'], + 'gcc': { + '3': ['-O3', '-fomit-frame-pointer'], + 'default': ['-Ofast', '-funsafe-math-optimizations', '-funsafe-loop-optimizations', '-fomit-frame-pointer'] + }, + 'clang': ['-Ofast'], + 'default': ['-O3'] + }, + 'fastnative': { + 'msvc': ['/O2', '/Oy', '/Zi'], + 'gcc': ['-Ofast', '-march=native', '-funsafe-math-optimizations', '-funsafe-loop-optimizations', '-fomit-frame-pointer'], + 'clang': ['-Ofast', '-march=native'], + 'default': ['-O3'] + }, + 'release': { + 'msvc': ['/O2', '/Zi'], + 'owcc': ['-O3', '-foptimize-sibling-calls', '-fomit-leaf-frame-pointer', '-fomit-frame-pointer', '-fschedule-insns', '-funsafe-math-optimizations', '-funroll-loops', '-frerun-optimizer', '-finline-functions', '-finline-limit=512', '-fguess-branch-probability', '-fno-strict-aliasing', '-floop-optimize'], + 'default': ['-O3'] + }, + 'debug': { + 'msvc': ['/Od', '/ZI'], + 'owcc': ['-O0', '-fno-omit-frame-pointer', '-funwind-tables', '-fno-omit-leaf-frame-pointer'], + 'default': ['-O0'] + }, + 'msan': { + 'clang': ['-O2', '-g', '-fno-omit-frame-pointer', '-fsanitize=memory', '-pthread'], + 'default': ['NO_MSAN_HERE'] + }, + 'sanitize': { + 'msvc': ['/Od', '/RTC1', '/Zi', '/fsanitize=address'], + 'gcc': ['-O0', '-fsanitize=undefined', '-fsanitize=address', '-pthread'], + 'clang': ['-O0', '-fsanitize=undefined', '-fsanitize=address', '-pthread'], + 'default': ['-O0'] + }, +} + +LTO_CFLAGS = { + 'msvc': ['/GL'], + 'gcc': ['-flto'], + 'clang': ['-flto'] +} + +LTO_LINKFLAGS = { + 'msvc': ['/LTCG'], + 'gcc': ['-flto'], + 'clang': ['-flto'] +} + +POLLY_CFLAGS = { + 'gcc': ['-fgraphite-identity'], + 'clang': ['-mllvm', '-polly'] + # msvc sosat :( +} + +def options(opt): + grp = opt.add_option_group('Compiler optimization options') + + grp.add_option('-T', '--build-type', action='store', dest='BUILD_TYPE', default=None, + help = 'build type: debug, release or none(custom flags)') + + grp.add_option('--enable-lto', action = 'store_true', dest = 'LTO', default = False, + help = 'enable Link Time Optimization if possible [default: %default]') + + grp.add_option('--enable-poly-opt', action = 'store_true', dest = 'POLLY', default = False, + help = 'enable polyhedral optimization if possible [default: %default]') + +def configure(conf): + conf.start_msg('Build type') + if conf.options.BUILD_TYPE == None: + conf.end_msg('not set', color='RED') + conf.fatal('Set a build type, for example "-T release"') + elif not conf.options.BUILD_TYPE in VALID_BUILD_TYPES: + conf.end_msg(conf.options.BUILD_TYPE, color='RED') + conf.fatal('Invalid build type. Valid are: %s' % ', '.join(VALID_BUILD_TYPES)) + conf.end_msg(conf.options.BUILD_TYPE) + + conf.msg('LTO build', 'yes' if conf.options.LTO else 'no') + conf.msg('PolyOpt build', 'yes' if conf.options.POLLY else 'no') + + # -march=native should not be used + if conf.options.BUILD_TYPE.startswith('fast'): + Logs.warn('WARNING: \'%s\' build type should not be used in release builds', conf.options.BUILD_TYPE) + + try: + conf.env.CC_VERSION[0] + except IndexError: + conf.env.CC_VERSION = (0,) + +@conf +def get_optimization_flags(conf): + '''Returns a list of compile flags, + depending on build type and options set by user + + NOTE: it doesn't filter out unsupported flags + + :returns: tuple of cflags and linkflags + ''' + linkflags = conf.get_flags_by_type(LINKFLAGS, conf.options.BUILD_TYPE, conf.env.COMPILER_CC, conf.env.CC_VERSION[0]) + + cflags = conf.get_flags_by_type(CFLAGS, conf.options.BUILD_TYPE, conf.env.COMPILER_CC, conf.env.CC_VERSION[0]) + + if conf.options.LTO: + linkflags+= conf.get_flags_by_compiler(LTO_LINKFLAGS, conf.env.COMPILER_CC) + cflags += conf.get_flags_by_compiler(LTO_CFLAGS, conf.env.COMPILER_CC) + + if conf.options.POLLY: + cflags += conf.get_flags_by_compiler(POLLY_CFLAGS, conf.env.COMPILER_CC) + + if conf.env.DEST_OS == 'nswitch' and conf.options.BUILD_TYPE == 'debug': + # enable remote debugger + cflags.append('-DNSWITCH_DEBUG') + elif conf.env.DEST_OS == 'psvita': + # this optimization is broken in vitasdk + cflags.append('-fno-optimize-sibling-calls') + + return cflags, linkflags diff --git a/scripts/waifulib/library_naming.py b/scripts/waifulib/library_naming.py new file mode 100644 index 00000000..b8985c92 --- /dev/null +++ b/scripts/waifulib/library_naming.py @@ -0,0 +1,176 @@ +#! /usr/bin/env python +# Copyright 2019 (C) a1batross + +from waflib import Configure, Errors, Utils + +# TODO: make generic +CHECK_SYMBOL_EXISTS_FRAGMENT = ''' +#include "build.h" + +int main(int argc, char** argv) +{ + (void)argv; +#ifndef %s + return ((int*)(&%s))[argc]; +#else + (void)argc; + return 0; +#endif +} +''' + +# generated(see comments in public/build.h) +# cat build.h | grep '^#undef XASH' | awk '{ print "'\''" $2 "'\''," }' +DEFINES = [ +'XASH_64BIT', +'XASH_AMD64', +'XASH_ANDROID', +'XASH_APPLE', +'XASH_ARM', +'XASH_ARM_HARDFP', +'XASH_ARM_SOFTFP', +'XASH_ARMv4', +'XASH_ARMv5', +'XASH_ARMv6', +'XASH_ARMv7', +'XASH_ARMv8', +'XASH_BIG_ENDIAN', +'XASH_BSD', +'XASH_DOS4GW', +'XASH_E2K', +'XASH_EMSCRIPTEN', +'XASH_FREEBSD', +'XASH_HAIKU', +'XASH_IOS', +'XASH_JS', +'XASH_LINUX', +'XASH_LITTLE_ENDIAN', +'XASH_MINGW', +'XASH_MIPS', +'XASH_PPC', +'XASH_MOBILE_PLATFORM', +'XASH_MSVC', +'XASH_NETBSD', +'XASH_OPENBSD', +'XASH_POSIX', +'XASH_RISCV', +'XASH_RISCV_DOUBLEFP', +'XASH_RISCV_SINGLEFP', +'XASH_RISCV_SOFTFP', +'XASH_SERENITY', +'XASH_WIN32', +'XASH_WIN64', +'XASH_X86', +'XASH_NSWITCH', +'XASH_PSVITA', +] + +def configure(conf): + conf.env.stash() + conf.start_msg('Determining library postfix') + tests = map(lambda x: { + 'fragment': CHECK_SYMBOL_EXISTS_FRAGMENT % (x, x), + 'includes': [conf.path.find_node('public/').abspath()], + 'define_name': x }, DEFINES ) + + conf.multicheck(*tests, msg = '', mandatory = False, quiet = True) + + # engine/common/build.c + if conf.env.XASH_ANDROID: + buildos = "android" + elif conf.env.XASH_WIN32 or conf.env.XASH_LINUX or conf.env.XASH_APPLE: + buildos = "" # no prefix for default OS + elif conf.env.XASH_FREEBSD: + buildos = "freebsd" + elif conf.env.XASH_NETBSD: + buildos = "netbsd" + elif conf.env.XASH_OPENBSD: + buildos = "openbsd" + elif conf.env.XASH_EMSCRIPTEN: + buildos = "emscripten" + elif conf.env.XASH_DOS4GW: + buildos = "dos4gw" # unused, just in case + elif conf.env.XASH_HAIKU: + buildos = "haiku" + elif conf.env.XASH_SERENITY: + buildos = "serenityos" + elif conf.env.XASH_NSWITCH: + buildos = "nswitch" + elif conf.env.XASH_PSVITA: + buildos = "psvita" + else: + conf.fatal("Place your operating system name in build.h and library_naming.py!\n" + "If this is a mistake, try to fix conditions above and report a bug") + + if conf.env.XASH_AMD64: + buildarch = "amd64" + elif conf.env.XASH_X86: + if conf.env.XASH_WIN32 or conf.env.XASH_LINUX or conf.env.XASH_APPLE: + buildarch = "" + else: + buildarch = "i386" + elif conf.env.XASH_ARM and conf.env.XASH_64BIT: + buildarch = "arm64" + elif conf.env.XASH_ARM: + buildarch = "armv" + if conf.env.XASH_ARMv8: + buildarch += "8_32" + elif conf.env.XASH_ARMv7: + buildarch += "7" + elif conf.env.XASH_ARMv6: + buildarch += "6" + elif conf.env.XASH_ARMv5: + buildarch += "5" + elif conf.env.XASH_ARMv4: + buildarch += "4" + else: + raise conf.fatal('Unknown ARM') + + if conf.env.XASH_ARM_HARDFP: + buildarch += "hf" + else: + buildarch += "l" + elif conf.env.XASH_MIPS: + buildarch = "mips" + if conf.env.XASH_64BIT: + buildarch += "64" + if conf.env.XASH_LITTLE_ENDIAN: + buildarch += "el" + elif conf.env.XASH_PPC: + buildarch = "powerpc" + if conf.env.XASH_64BIT: + buildarch += "64" + if conf.env.XASH_LITTLE_ENDIAN: + buildarch += "le" + elif conf.env.XASH_RISCV: + buildarch = "riscv" + if conf.env.XASH_64BIT: + buildarch += "64" + else: + buildarch += "32" + + if conf.env.XASH_RISCV_DOUBLEFP: + buildarch += "d" + elif conf.env.XASH_RISCV_SINGLEFP: + buildarch += "f" + elif conf.env.XASH_JS: + buildarch = "javascript" + elif conf.env.XASH_E2K: + buildarch = "e2k" + else: + raise conf.fatal("Place your architecture name in build.h and library_naming.py!\n" + "If this is a mistake, try to fix conditions above and report a bug") + + conf.env.revert() + + if buildos == 'android': + # force disable for Android, as Android ports aren't distributed in normal way and doesn't follow library naming + conf.env.POSTFIX = '' + elif buildos != '' and buildarch != '': + conf.env.POSTFIX = '_%s_%s' % (buildos,buildarch) + elif buildarch != '': + conf.env.POSTFIX = '_%s' % buildarch + else: + conf.env.POSTFIX = '' + + conf.end_msg(conf.env.POSTFIX) diff --git a/scripts/waifulib/strip_on_install.py b/scripts/waifulib/strip_on_install.py new file mode 100644 index 00000000..6522065d --- /dev/null +++ b/scripts/waifulib/strip_on_install.py @@ -0,0 +1,49 @@ +#! /usr/bin/env python +# Modified: Alibek Omarov +# Originally taken from Thomas Nagy's blogpost + +""" +Strip executables upon installation +""" + +import shutil, os +from waflib import Build, Utils, Context, Errors, Logs + +def options(opt): + grp = opt.option_groups['install/uninstall options'] + grp.add_option('--no-strip', dest='no_strip', action='store_true', default=False, + help='don\'t strip binaries. You must pass this flag to install command(default: False)') + +def configure(conf): + if conf.env.DEST_BINFMT in ['elf', 'mac-o']: + conf.find_program('strip', var='STRIP') + if not conf.env.STRIPFLAGS: + conf.env.STRIPFLAGS = os.environ['STRIPFLAGS'] if 'STRIPFLAGS' in os.environ else [] + +def copy_fun(self, src, tgt): + inst_copy_fun(self, src, tgt) + + if self.generator.bld.options.no_strip: + return + + if self.env.DEST_BINFMT not in ['elf', 'mac-o']: # don't strip unknown formats or PE + return + + if getattr(self.generator, 'link_task', None) and self.generator.link_task.outputs[0] in self.inputs: + cmd = self.env.STRIP + self.env.STRIPFLAGS + [tgt] + try: + self.generator.bld.cmd_and_log(cmd, output=Context.BOTH, quiet=Context.BOTH) + if not self.generator.bld.progress_bar: + c1 = Logs.colors.NORMAL + c2 = Logs.colors.CYAN + + f1 = os.path.getsize(src) + f2 = os.path.getsize(tgt) + + Logs.info('%s+ strip %s%s%s (%d bytes change)', c1, c2, tgt, c1, f2 - f1) + except Errors.WafError as e: + print(e.stdout, e.stderr) + +inst_copy_fun = Build.inst.copy_fun +Build.inst.copy_fun = copy_fun + diff --git a/scripts/waifulib/xcompile.py b/scripts/waifulib/xcompile.py index d6bb1a8b..08e90228 100644 --- a/scripts/waifulib/xcompile.py +++ b/scripts/waifulib/xcompile.py @@ -13,41 +13,51 @@ try: from fwgslib import get_flags_by_compiler except: from waflib.extras.fwgslib import get_flags_by_compiler -from waflib import Logs +from waflib import Logs, TaskGen +from waflib.Tools import c_config +from collections import OrderedDict import os import sys -# Output: -# CROSSCOMPILING -- set to true, if crosscompiling is enabled -# DEST_OS2 -- as some operating systems is built on top of another, it's better to not change DEST_OS, -# instead of this DEST_OS2 is defined with target value -# For example: android is built on top of linux and have many things in common, -# but it can't be considered as default GNU/Linux. -# Possible values: -# DEST_OS2 DEST_OS -# 'android' 'linux' +ANDROID_NDK_ENVVARS = ['ANDROID_NDK_HOME', 'ANDROID_NDK'] +ANDROID_NDK_SUPPORTED = [10, 19, 20, 23, 25] +ANDROID_NDK_HARDFP_MAX = 11 # latest version that supports hardfp +ANDROID_NDK_GCC_MAX = 17 # latest NDK that ships with GCC +ANDROID_NDK_UNIFIED_SYSROOT_MIN = 15 +ANDROID_NDK_SYSROOT_FLAG_MAX = 19 # latest NDK that need --sysroot flag +ANDROID_NDK_API_MIN = { 10: 3, 19: 16, 20: 16, 23: 16, 25: 19 } # minimal API level ndk revision supports -# This class does support ONLY r10e and r19c NDK +ANDROID_STPCPY_API_MIN = 21 # stpcpy() introduced in SDK 21 +ANDROID_64BIT_API_MIN = 21 # minimal API level that supports 64-bit targets + +NSWITCH_ENVVARS = ['DEVKITPRO'] + +PSVITA_ENVVARS = ['VITASDK'] + +# This class does support ONLY r10e and r19c/r20 NDK class Android: ctx = None # waf context arch = None toolchain = None api = None - toolchain_path = None ndk_home = None ndk_rev = 0 is_hardfloat = False clang = False - + def __init__(self, ctx, arch, toolchain, api): self.ctx = ctx - for i in ['ANDROID_NDK_HOME', 'ANDROID_NDK']: + self.api = api + self.toolchain = toolchain + self.arch = arch + + for i in ANDROID_NDK_ENVVARS: self.ndk_home = os.getenv(i) if self.ndk_home != None: break - - if not self.ndk_home: - conf.fatal('Set ANDROID_NDK_HOME environment variable pointing to the root of Android NDK!') + else: + ctx.fatal('Set %s environment variable pointing to the root of Android NDK!' % + ' or '.join(ANDROID_NDK_ENVVARS)) # TODO: this were added at some point of NDK development # but I don't know at which version @@ -61,37 +71,35 @@ class Android: if 'Pkg.Revision' in trimed_tokens: self.ndk_rev = int(trimed_tokens[1].split('.')[0]) + + if self.ndk_rev not in ANDROID_NDK_SUPPORTED: + ctx.fatal('Unknown NDK revision: %d' % (self.ndk_rev)) else: - self.ndk_rev = 10 + self.ndk_rev = ANDROID_NDK_SUPPORTED[0] - if self.ndk_rev not in [10, 19, 20]: - ctx.fatal('Unknown NDK revision: {}'.format(self.ndk_rev)) + if 'clang' in self.toolchain or self.ndk_rev > ANDROID_NDK_GCC_MAX: + self.clang = True - self.arch = arch if self.arch == 'armeabi-v7a-hard': - if self.ndk_rev <= 10: + if self.ndk_rev <= ANDROID_NDK_HARDFP_MAX: self.arch = 'armeabi-v7a' # Only armeabi-v7a have hard float ABI self.is_hardfloat = True else: - raise Exception('NDK does not support hardfloat ABI') + ctx.fatal('NDK does not support hardfloat ABI') - self.toolchain = toolchain + if self.api < ANDROID_NDK_API_MIN[self.ndk_rev]: + self.api = ANDROID_NDK_API_MIN[self.ndk_rev] + Logs.warn('API level automatically was set to %d due to NDK support' % self.api) - if self.ndk_rev >= 19 or 'clang' in self.toolchain: - self.clang = True + if self.is_arm64() or self.is_amd64() and self.api < ANDROID_64BIT_API_MIN: + self.api = ANDROID_64BIT_API_MIN + Logs.warn('API level for 64-bit target automatically was set to %d' % self.api) - if self.is_arm64() or self.is_amd64() and self.api < 21: - Logs.warn('API level for 64-bit target automatically was set to 21') - self.api = 21 - elif self.ndk_rev >= 19 and self.api < 16: - Logs.warn('API level automatically was set to 16 due to NDK support') - self.api = 16 - else: self.api = api - self.toolchain_path = self.gen_toolchain_path() - - # TODO: Crystax support? - # TODO: Support for everything else than linux-x86_64? - # TODO: Determine if I actually need to implement listed above + def is_host(self): + ''' + Checks if we using host compiler(implies clang) + ''' + return self.toolchain == 'host' def is_arm(self): ''' @@ -126,121 +134,382 @@ class Android: def is_hardfp(self): return self.is_hardfloat - def gen_toolchain_path(self): - path = 'toolchains' + def ndk_triplet(self, llvm_toolchain = False, toolchain_folder = False): + if self.is_x86(): + if toolchain_folder: + return 'x86' + else: + return 'i686-linux-android' + elif self.is_arm(): + if llvm_toolchain: + return 'armv7a-linux-androideabi' + else: + return 'arm-linux-androideabi' + elif self.is_amd64() and toolchain_folder: + return 'x86_64' + else: + return self.arch + '-linux-android' - if sys.platform.startswith('linux'): - toolchain_host = 'linux' + def apk_arch(self): + if self.is_arm64(): + return 'arm64-v8a' + return self.arch + + def gen_host_toolchain(self): + # With host toolchain we don't care about OS + # so just download NDK for Linux x86_64 + if 'HOST_TOOLCHAIN' in self.ctx.environ: + return self.ctx.environ['HOST_TOOLCHAIN'] + if self.is_host(): + return 'linux-x86_64' + + if sys.platform.startswith('win32') or sys.platform.startswith('cygwin'): + osname = 'windows' elif sys.platform.startswith('darwin'): - toolchain_host = 'darwin' - elif sys.platform.startswith('win32') or sys.platform.startswith('cygwin'): - toolchain_host = 'windows' - else: raise Exception('Unsupported by NDK host platform') + osname = 'darwin' + elif sys.platform.startswith('linux'): + osname = 'linux' + else: + self.ctx.fatal('Unsupported by NDK host platform') - toolchain_host += '-' + if sys.maxsize > 2**32: + arch = 'x86_64' + else: arch = 'x86' - # Assuming we are building on x86 - if sys.maxsize > 2**32: - toolchain_host += 'x86_64' - else: toolchain_host += 'x86' + return '%s-%s' % (osname, arch) + + def gen_gcc_toolchain_path(self): + path = 'toolchains' + toolchain_host = self.gen_host_toolchain() if self.is_clang(): - if self.ndk_rev < 19: - raise Exception('Clang is not supported for this NDK') - toolchain_folder = 'llvm' - - if self.is_x86(): - triplet = 'i686-linux-android{}-'.format(self.api) - elif self.is_arm(): - triplet = 'armv7a-linux-androideabi{}-'.format(self.api) - else: - triplet = self.arch + '-linux-android{}-'.format(self.api) else: - if self.is_x86() or self.is_amd64(): - toolchain_folder = self.arch + '-' + self.toolchain - elif self.is_arm(): - toolchain_folder = 'arm-linux-androideabi-' + self.toolchain + if self.is_host(): + toolchain = '4.9' else: - toolchain_folder = self.arch + '-linux-android-' + self.toolchain + toolchain = self.toolchain - if self.is_x86(): - triplet = 'i686-linux-android-' - elif self.is_arm(): - triplet = 'arm-linux-androideabi-' - else: - triplet = self.arch + '-linux-android-' + toolchain_folder = '%s-%s' % (self.ndk_triplet(toolchain_folder = True), toolchain) - return os.path.join(path, toolchain_folder, 'prebuilt', toolchain_host, 'bin', triplet) + return os.path.abspath(os.path.join(self.ndk_home, path, toolchain_folder, 'prebuilt', toolchain_host)) + + def gen_toolchain_path(self): + if self.is_clang(): + triplet = '%s%d-' % (self.ndk_triplet(llvm_toolchain = True), self.api) + else: + triplet = self.ndk_triplet() + '-' + return os.path.join(self.gen_gcc_toolchain_path(), 'bin', triplet) + + def gen_binutils_path(self): + if self.ndk_rev >= 23: + return os.path.join(self.gen_gcc_toolchain_path(), 'bin') + return os.path.join(self.gen_gcc_toolchain_path(), self.ndk_triplet(), 'bin') def cc(self): - return os.path.abspath(os.path.join(self.ndk_home, self.toolchain_path + ('clang' if self.is_clang() else 'gcc'))) + if self.is_host(): + s = 'clang' + environ = getattr(self.ctx, 'environ', os.environ) + + if 'CC' in environ: + s = environ['CC'] + + return '%s --target=%s%d' % (s, self.ndk_triplet(), self.api) + return self.gen_toolchain_path() + ('clang' if self.is_clang() else 'gcc') def cxx(self): - return os.path.abspath(os.path.join(self.ndk_home, self.toolchain_path + ('clang++' if self.is_clang() else 'g++'))) + if self.is_host(): + s = 'clang++' + environ = getattr(self.ctx, 'environ', os.environ) + + if 'CXX' in environ: + s = environ['CXX'] + + return '%s --target=%s%d' % (s, self.ndk_triplet(), self.api) + return self.gen_toolchain_path() + ('clang++' if self.is_clang() else 'g++') + + def strip(self): + if self.is_host(): + environ = getattr(self.ctx, 'environ', os.environ) + + if 'STRIP' in environ: + return environ['STRIP'] + return 'llvm-strip' + + if self.ndk_rev >= 23: + return os.path.join(self.gen_binutils_path(), 'llvm-strip') + return os.path.join(self.gen_binutils_path(), 'strip') def system_stl(self): # TODO: proper STL support return os.path.abspath(os.path.join(self.ndk_home, 'sources', 'cxx-stl', 'system', 'include')) + def libsysroot(self): + arch = self.arch + if self.is_arm(): + arch = 'arm' + elif self.is_arm64(): + arch = 'arm64' + path = 'platforms/android-%s/arch-%s' % (self.api, arch) + + return os.path.abspath(os.path.join(self.ndk_home, path)) + def sysroot(self): - if self.ndk_rev >= 19: + if self.ndk_rev >= ANDROID_NDK_UNIFIED_SYSROOT_MIN: return os.path.abspath(os.path.join(self.ndk_home, 'sysroot')) else: - arch = self.arch - if self.is_arm(): - arch = 'arm' - elif self.is_arm64(): - arch = 'arm64' - path = 'platforms/android-{}/arch-{}'.format(self.api, arch) + return self.libsysroot() - return os.path.abspath(os.path.join(self.ndk_home, path)) - - def cflags(self): + def cflags(self, cxx = False): cflags = [] - if self.ndk_rev < 20: - cflags = ['--sysroot={0}'.format(self.sysroot())] - cflags += ['-DANDROID', '-D__ANDROID__'] - cflags += ['-I{0}'.format(self.system_stl())] + + if self.ndk_rev <= ANDROID_NDK_SYSROOT_FLAG_MAX: + cflags += ['--sysroot=%s' % (self.sysroot())] + else: + if self.is_host(): + cflags += [ + '--sysroot=%s/sysroot' % (self.gen_gcc_toolchain_path()), + '-isystem', '%s/usr/include/' % (self.sysroot()) + ] + + cflags += ['-I%s' % (self.system_stl())] + if not self.is_clang(): + cflags += ['-DANDROID', '-D__ANDROID__'] + + if cxx and not self.is_clang() and self.toolchain not in ['4.8','4.9']: + cflags += ['-fno-sized-deallocation'] + + if self.is_clang(): + # stpcpy() isn't available in early Android versions + # disable it here so Clang won't use it + if self.api < ANDROID_STPCPY_API_MIN: + cflags += ['-fno-builtin-stpcpy'] + if self.is_arm(): if self.arch == 'armeabi-v7a': # ARMv7 support - cflags += ['-mthumb', '-mfpu=neon', '-mcpu=cortex-a9', '-DHAVE_EFFICIENT_UNALIGNED_ACCESS', '-DVECTORIZE_SINCOS'] - if not self.is_clang(): - cflags += [ '-mvectorize-with-neon-quad' ] - if self.is_hardfloat: - cflags += ['-D_NDK_MATH_NO_SOFTFP=1', '-mhard-float', '-mfloat-abi=hard', '-DLOAD_HARDFP', '-DSOFTFP_LINK'] + cflags += ['-mthumb', '-mfpu=neon', '-mcpu=cortex-a9'] + + if self.is_hardfp(): + cflags += ['-D_NDK_MATH_NO_SOFTFP=1', '-mfloat-abi=hard', '-DLOAD_HARDFP', '-DSOFTFP_LINK'] + + if self.is_host(): + # Clang builtin redefine w/ different calling convention bug + # NOTE: I did not added complex.h functions here, despite + # that NDK devs forgot to put __NDK_FPABI_MATH__ for complex + # math functions + # I personally don't need complex numbers support, but if you want it + # just run sed to patch header + for f in ['strtod', 'strtof', 'strtold']: + cflags += ['-fno-builtin-%s' % f] else: cflags += ['-mfloat-abi=softfp'] else: # ARMv5 support - cflags += ['-march=armv5te', '-mtune=xscale', '-msoft-float'] + cflags += ['-march=armv5te', '-msoft-float'] elif self.is_x86(): - cflags += ['-mtune=atom', '-march=atom', '-mssse3', '-mfpmath=sse', '-DVECTORIZE_SINCOS', '-DHAVE_EFFICIENT_UNALIGNED_ACCESS'] + cflags += ['-mtune=atom', '-march=atom', '-mssse3', '-mfpmath=sse'] return cflags # they go before object list def linkflags(self): linkflags = [] - if self.ndk_rev < 20: - linkflags = ['--sysroot={0}'.format(self.sysroot())] + if self.is_host(): + linkflags += ['--gcc-toolchain=%s' % self.gen_gcc_toolchain_path()] + + if self.ndk_rev <= ANDROID_NDK_SYSROOT_FLAG_MAX: + linkflags += ['--sysroot=%s' % (self.sysroot())] + elif self.is_host(): + linkflags += ['--sysroot=%s/sysroot' % (self.gen_gcc_toolchain_path())] + + if self.is_clang() or self.is_host(): + linkflags += ['-fuse-ld=lld'] + else: linkflags += ['-no-canonical-prefixes'] + + linkflags += ['-Wl,--hash-style=sysv', '-Wl,--no-undefined'] return linkflags def ldflags(self): - ldflags = ['-lgcc', '-no-canonical-prefixes'] + ldflags = [] + + if self.ndk_rev < 23: + ldflags += ['-lgcc'] + + if self.is_clang() or self.is_host(): + ldflags += ['-stdlib=libstdc++'] + else: ldflags += ['-no-canonical-prefixes'] + if self.is_arm(): if self.arch == 'armeabi-v7a': - ldflags += ['-march=armv7-a', '-Wl,--fix-cortex-a8', '-mthumb'] - if self.is_hardfloat: + ldflags += ['-march=armv7-a', '-mthumb'] + + if not self.is_clang() and not self.is_host(): # lld only + ldflags += ['-Wl,--fix-cortex-a8'] + + if self.is_hardfp(): ldflags += ['-Wl,--no-warn-mismatch', '-lm_hard'] else: ldflags += ['-march=armv5te'] return ldflags +class NintendoSwitch: + ctx = None # waf context + arch = "arm64" + dkp_dir = None + portlibs_dir = None + dka64_dir = None + libnx_dir = None + + def __init__(self, ctx): + self.ctx = ctx + + for i in NSWITCH_ENVVARS: + self.dkp_dir = os.getenv(i) + if self.dkp_dir != None: + break + else: + ctx.fatal('Set %s environment variable pointing to the DEVKITPRO home!' % + ' or '.join(NSWITCH_ENVVARS)) + + self.dkp_dir = os.path.abspath(self.dkp_dir) + + self.dka64_dir = os.path.join(self.dkp_dir, 'devkitA64') + if not os.path.exists(self.dka64_dir): + ctx.fatal('devkitA64 not found in `%s`. Install devkitA64!' % self.dka64_dir) + + self.libnx_dir = os.path.join(self.dkp_dir, 'libnx') + if not os.path.exists(self.libnx_dir): + ctx.fatal('libnx not found in `%s`. Install libnx!' % self.libnx_dir) + + self.portlibs_dir = os.path.join(self.dkp_dir, 'portlibs', 'switch') + if not os.path.exists(self.portlibs_dir): + ctx.fatal('No Switch libraries found in `%s`!' % self.portlibs_dir) + + def gen_toolchain_prefix(self): + return 'aarch64-none-elf-' + + def gen_gcc_toolchain_path(self): + return os.path.join(self.dka64_dir, 'bin', self.gen_toolchain_prefix()) + + def cc(self): + return self.gen_gcc_toolchain_path() + 'gcc' + + def cxx(self): + return self.gen_gcc_toolchain_path() + 'g++' + + def strip(self): + return self.gen_gcc_toolchain_path() + 'strip' + + def pkgconfig(self): + # counter-intuitively, this motherfucker is in $DEVKITPRO/portlibs/switch/bin + return os.path.join(self.portlibs_dir, 'bin', self.gen_toolchain_prefix() + 'pkg-config') + + def cflags(self, cxx = False): + cflags = [] + # arch flags + cflags += ['-D__SWITCH__', '-march=armv8-a+crc+crypto', '-mtune=cortex-a57', '-mtp=soft', '-ftls-model=local-exec', '-fPIE'] + # help the linker out + cflags += ['-ffunction-sections', '-fdata-sections'] + # base include dirs + cflags += ['-isystem %s/include' % self.libnx_dir, '-I%s/include' % self.portlibs_dir] + # the game wants GNU extensions + if cxx: + cflags += ['-std=gnu++17', '-D_GNU_SOURCE'] + else: + cflags += ['-std=gnu11', '-D_GNU_SOURCE'] + return cflags + + # they go before object list + def linkflags(self): + linkflags = ['-fPIE', '-specs=%s/switch.specs' % self.libnx_dir] + # libsolder only supports sysv hashes and we need to build everything with -rdynamic + linkflags += ['-Wl,--hash-style=sysv', '-rdynamic'] + # avoid pulling in and exposing mesa's internals, that crashes it for some god forsaken reason + linkflags += ['-Wl,--exclude-libs=libglapi.a', '-Wl,--exclude-libs=libdrm_nouveau.a'] + return linkflags + + def ldflags(self): + # NOTE: shared libraries should be built without standard libs, so that they could import their contents from the NRO, + # but executables, including the SDL2 sanity check, will generally require libstdc++ and libm, which we will add manually + ldflags = [] # ['-lm', '-lstdc++'] + return ldflags + +class PSVita: + ctx = None # waf context + arch ='armeabi-v7a-hard' + vitasdk_dir = None + + def __init__(self, ctx): + self.ctx = ctx + + for i in PSVITA_ENVVARS: + self.vitasdk_dir = os.getenv(i) + if self.vitasdk_dir != None: + break + else: + ctx.fatal('Set %s environment variable pointing to the VitaSDK directory!' % + ' or '.join(PSVITA_ENVVARS)) + + def gen_toolchain_prefix(self): + return 'arm-vita-eabi-' + + def gen_gcc_toolchain_path(self): + return os.path.join(self.vitasdk_dir, 'bin', self.gen_toolchain_prefix()) + + def cc(self): + return self.gen_gcc_toolchain_path() + 'gcc' + + def cxx(self): + return self.gen_gcc_toolchain_path() + 'g++' + + def strip(self): + return self.gen_gcc_toolchain_path() + 'strip' + + def ar(self): + return self.gen_gcc_toolchain_path() + 'ar' + + def pkgconfig(self): + return self.gen_gcc_toolchain_path() + 'pkg-config' + + def cflags(self, cxx = False): + cflags = [] + # arch flags + cflags += ['-D__vita__', '-mtune=cortex-a9', '-mfpu=neon'] + # necessary linker flags + cflags += ['-Wl,-q', '-Wl,-z,nocopyreloc'] + # this optimization is broken in vitasdk + cflags += ['-fno-optimize-sibling-calls'] + # disable some ARM bullshit + cflags += ['-fno-short-enums', '-Wno-attributes'] + # base include dir + cflags += ['-isystem %s/arm-vita-eabi/include' % self.vitasdk_dir] + # SDL include dir + cflags += ['-I%s/arm-vita-eabi/include/SDL2' % self.vitasdk_dir] + return cflags + + # they go before object list + def linkflags(self): + linkflags = ['-Wl,--hash-style=sysv', '-Wl,-q', '-Wl,-z,nocopyreloc', '-mtune=cortex-a9', '-mfpu=neon'] + # enforce no-short-enums again + linkflags += ['-Wl,-no-enum-size-warning', '-fno-short-enums'] + return linkflags + + def ldflags(self): + ldflags = [] + return ldflags + def options(opt): - android = opt.add_option_group('Android options') - android.add_option('--android', action='store', dest='ANDROID_OPTS', default=None, + xc = opt.add_option_group('Cross compile options') + xc.add_option('--android', action='store', dest='ANDROID_OPTS', default=None, help='enable building for android, format: --android=,,, example: --android=armeabi-v7a-hard,4.9,9') + xc.add_option('--enable-magx', action='store_true', dest='MAGX', default=False, + help='enable building for Motorola MAGX [default: %default]') + xc.add_option('--enable-msvc-wine', action='store_true', dest='MSVC_WINE', default=False, + help='enable building with MSVC using Wine [default: %default]') + xc.add_option('--nswitch', action='store_true', dest='NSWITCH', default = False, + help ='enable building for Nintendo Switch [default: %default]') + xc.add_option('--psvita', action='store_true', dest='PSVITA', default = False, + help ='enable building for PlayStation Vita [default: %default]') def configure(conf): if conf.options.ANDROID_OPTS: @@ -248,17 +517,17 @@ def configure(conf): if len(values) != 3: conf.fatal('Invalid --android paramater value!') - valid_archs = ['x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'armeabi-v7a-hard', 'aarch64', 'mipsel', 'mips64el'] + valid_archs = ['x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'armeabi-v7a-hard', 'aarch64'] if values[0] not in valid_archs: - conf.fatal('Unknown arch: {}. Supported: {}'.format(values[0], ', '.join(valid_archs))) + conf.fatal('Unknown arch: %s. Supported: %r' % (values[0], ', '.join(valid_archs))) - android = Android(conf, values[0], values[1], int(values[2])) - setattr(conf, 'android', android) + conf.android = android = Android(conf, values[0], values[1], int(values[2])) conf.environ['CC'] = android.cc() conf.environ['CXX'] = android.cxx() + conf.environ['STRIP'] = android.strip() conf.env.CFLAGS += android.cflags() - conf.env.CXXFLAGS += android.cflags() + conf.env.CXXFLAGS += android.cflags(True) conf.env.LINKFLAGS += android.linkflags() conf.env.LDFLAGS += android.ldflags() @@ -267,27 +536,88 @@ def configure(conf): conf.env.LIB_M = ['m_hard'] else: conf.env.LIB_M = ['m'] - conf.env.PREFIX = '/lib/{}'.format(android.arch) + conf.env.PREFIX = '/lib/%s' % android.apk_arch() - conf.msg('Selected Android NDK', '{}, version: {}'.format(android.ndk_home, android.ndk_rev)) + conf.msg('Selected Android NDK', '%s, version: %d' % (android.ndk_home, android.ndk_rev)) # no need to print C/C++ compiler, as it would be printed by compiler_c/cxx - conf.msg('... C/C++ flags', ' '.join(android.cflags()).replace(android.ndk_home, '$NDK')) - conf.msg('... link flags', ' '.join(android.linkflags()).replace(android.ndk_home, '$NDK')) - conf.msg('... ld flags', ' '.join(android.ldflags()).replace(android.ndk_home, '$NDK')) + conf.msg('... C/C++ flags', ' '.join(android.cflags()).replace(android.ndk_home, '$NDK/')) + conf.msg('... link flags', ' '.join(android.linkflags()).replace(android.ndk_home, '$NDK/')) + conf.msg('... ld flags', ' '.join(android.ldflags()).replace(android.ndk_home, '$NDK/')) + elif conf.options.MAGX: + # useless to change toolchain path, as toolchain meant to be placed in this path + toolchain_path = '/opt/toolchains/motomagx/arm-eabi2/lib/' + conf.env.INCLUDES_MAGX = [toolchain_path + i for i in ['ezx-z6/include', 'qt-2.3.8/include']] + conf.env.LIBPATH_MAGX = [toolchain_path + i for i in ['ezx-z6/lib', 'qt-2.3.8/lib']] + conf.env.LINKFLAGS_MAGX = ['-Wl,-rpath-link=' + i for i in conf.env.LIBPATH_MAGX] + elif conf.options.MSVC_WINE: + try: + toolchain_path = conf.environ['MSVC_WINE_PATH'] + except KeyError: + conf.fatal('Set MSVC_WINE_PATH environment variable to the MSVC toolchain root!') - # conf.env.ANDROID_OPTS = android - conf.env.DEST_OS2 = 'android' -# else: -# conf.load('compiler_c compiler_cxx') # Use host compiler :) + conf.environ['CC'] = conf.environ['CXX'] = os.path.join(toolchain_path, 'bin', conf.env.MSVC_TARGETS[0], 'cl') + conf.environ['LINK_CXX'] = os.path.join(toolchain_path, 'bin', conf.env.MSVC_TARGETS[0], 'link') + conf.environ['AR'] = os.path.join(toolchain_path, 'bin', conf.env.MSVC_TARGETS[0], 'lib') + conf.environ['WINRC'] = os.path.join(toolchain_path, 'bin', conf.env.MSVC_TARGETS[0], 'rc') + conf.env.DEST_OS = 'win32' + conf.env.DEST_CPU = conf.env.MSVC_TARGETS[0] + conf.env.COMPILER_CXX = conf.env.COMPILER_CC = 'msvc' + elif conf.options.NSWITCH: + conf.nswitch = nswitch = NintendoSwitch(conf) + conf.environ['CC'] = nswitch.cc() + conf.environ['CXX'] = nswitch.cxx() + conf.environ['STRIP'] = nswitch.strip() + conf.env.PKGCONFIG = nswitch.pkgconfig() + conf.env.CFLAGS += nswitch.cflags() + conf.env.CXXFLAGS += nswitch.cflags(True) + conf.env.LINKFLAGS += nswitch.linkflags() + conf.env.LDFLAGS += nswitch.ldflags() + conf.env.HAVE_M = True + conf.env.LIB_M = ['m'] + conf.env.DEST_OS = 'nswitch' + elif conf.options.PSVITA: + conf.psvita = psvita = PSVita(conf) + conf.environ['CC'] = psvita.cc() + conf.environ['CXX'] = psvita.cxx() + conf.environ['STRIP'] = psvita.strip() + conf.environ['AR'] = psvita.ar() + conf.env.PKGCONFIG = psvita.pkgconfig() + conf.env.CFLAGS += psvita.cflags() + conf.env.CXXFLAGS += psvita.cflags(True) + conf.env.LINKFLAGS += psvita.linkflags() + conf.env.LDFLAGS += psvita.ldflags() + conf.env.HAVE_M = True + conf.env.LIB_M = ['m'] + conf.env.VRTLD = ['vrtld'] + conf.env.DEST_OS = 'psvita' + + conf.env.MAGX = conf.options.MAGX + conf.env.MSVC_WINE = conf.options.MSVC_WINE + MACRO_TO_DESTOS = OrderedDict({ '__ANDROID__' : 'android', '__SWITCH__' : 'nswitch', '__vita__' : 'psvita' }) + for k in c_config.MACRO_TO_DESTOS: + MACRO_TO_DESTOS[k] = c_config.MACRO_TO_DESTOS[k] # ordering is important + c_config.MACRO_TO_DESTOS = MACRO_TO_DESTOS def post_compiler_cxx_configure(conf): + conf.msg('Target OS', conf.env.DEST_OS) + conf.msg('Target CPU', conf.env.DEST_CPU) + conf.msg('Target binfmt', conf.env.DEST_BINFMT) + if conf.options.ANDROID_OPTS: if conf.android.ndk_rev == 19: conf.env.CXXFLAGS_cxxshlib += ['-static-libstdc++'] conf.env.LDFLAGS_cxxshlib += ['-static-libstdc++'] + elif conf.options.MAGX: + for lib in ['qte-mt', 'ezxappbase', 'ezxpm', 'log_util']: + conf.check_cc(lib=lib, use='MAGX', uselib_store='MAGX') + return def post_compiler_c_configure(conf): + conf.msg('Target OS', conf.env.DEST_OS) + conf.msg('Target CPU', conf.env.DEST_CPU) + conf.msg('Target binfmt', conf.env.DEST_BINFMT) + return from waflib.Tools import compiler_cxx, compiler_c @@ -296,12 +626,35 @@ compiler_cxx_configure = getattr(compiler_cxx, 'configure') compiler_c_configure = getattr(compiler_c, 'configure') def patch_compiler_cxx_configure(conf): - compiler_cxx_configure(conf) + if not conf.env.MSVC_WINE: + compiler_cxx_configure(conf) + else: + conf.load('msvc', funs='no_autodetect') post_compiler_cxx_configure(conf) def patch_compiler_c_configure(conf): - compiler_c_configure(conf) + if not conf.env.MSVC_WINE: + compiler_c_configure(conf) + else: + conf.load('msvc', funs='no_autodetect') post_compiler_c_configure(conf) setattr(compiler_cxx, 'configure', patch_compiler_cxx_configure) setattr(compiler_c, 'configure', patch_compiler_c_configure) + +@TaskGen.feature('cshlib', 'cxxshlib', 'dshlib', 'fcshlib', 'vnum') +@TaskGen.after_method('apply_link', 'propagate_uselib_vars') +@TaskGen.before_method('apply_vnum') +def apply_android_soname(self): + """ + Enforce SONAME on Android + """ + if self.env.DEST_OS != 'android': + return + + setattr(self, 'vnum', None) # remove vnum, so SONAME would not be overwritten + link = self.link_task + node = link.outputs[0] + libname = node.name + v = self.env.SONAME_ST % libname + self.env.append_value('LINKFLAGS', v.split()) diff --git a/utils/false_vgui/include/VGUI.h b/utils/fake_vgui/include/VGUI.h similarity index 100% rename from utils/false_vgui/include/VGUI.h rename to utils/fake_vgui/include/VGUI.h diff --git a/utils/false_vgui/include/VGUI_App.h b/utils/fake_vgui/include/VGUI_App.h similarity index 100% rename from utils/false_vgui/include/VGUI_App.h rename to utils/fake_vgui/include/VGUI_App.h diff --git a/utils/false_vgui/include/VGUI_Color.h b/utils/fake_vgui/include/VGUI_Color.h similarity index 100% rename from utils/false_vgui/include/VGUI_Color.h rename to utils/fake_vgui/include/VGUI_Color.h diff --git a/utils/false_vgui/include/VGUI_Cursor.h b/utils/fake_vgui/include/VGUI_Cursor.h similarity index 100% rename from utils/false_vgui/include/VGUI_Cursor.h rename to utils/fake_vgui/include/VGUI_Cursor.h diff --git a/utils/false_vgui/include/VGUI_Dar.h b/utils/fake_vgui/include/VGUI_Dar.h similarity index 100% rename from utils/false_vgui/include/VGUI_Dar.h rename to utils/fake_vgui/include/VGUI_Dar.h diff --git a/utils/false_vgui/include/VGUI_KeyCode.h b/utils/fake_vgui/include/VGUI_KeyCode.h similarity index 100% rename from utils/false_vgui/include/VGUI_KeyCode.h rename to utils/fake_vgui/include/VGUI_KeyCode.h diff --git a/utils/false_vgui/include/VGUI_MouseCode.h b/utils/fake_vgui/include/VGUI_MouseCode.h similarity index 100% rename from utils/false_vgui/include/VGUI_MouseCode.h rename to utils/fake_vgui/include/VGUI_MouseCode.h diff --git a/utils/false_vgui/include/VGUI_Panel.h b/utils/fake_vgui/include/VGUI_Panel.h similarity index 100% rename from utils/false_vgui/include/VGUI_Panel.h rename to utils/fake_vgui/include/VGUI_Panel.h diff --git a/utils/false_vgui/include/VGUI_Scheme.h b/utils/fake_vgui/include/VGUI_Scheme.h similarity index 100% rename from utils/false_vgui/include/VGUI_Scheme.h rename to utils/fake_vgui/include/VGUI_Scheme.h diff --git a/vgui_support b/vgui_support new file mode 160000 index 00000000..99108598 --- /dev/null +++ b/vgui_support @@ -0,0 +1 @@ +Subproject commit 991085982209a1b8eefabae04d842004d4f4fe4f diff --git a/waf b/waf index b35987aa..919420c6 100755 --- a/waf +++ b/waf @@ -32,13 +32,13 @@ POSSIBILITY OF SUCH DAMAGE. import os, sys, inspect -VERSION="2.0.17" -REVISION="da8474e646911ac5657990d535080c54" -GIT="31da55afb92d9865019eb5193e874d1ffb86c522" +VERSION="2.0.22" +REVISION="9848c8ac89183c48b69d47e767462720" +GIT="3f8bb163290eb8fbfc3b26d61dd04aa5a6a29d4a" INSTALL='' -C1='#9' -C2='#3' -C3='#*' +C1='#=' +C2='#4' +C3='#/' cwd = os.getcwd() join = os.path.join @@ -140,6 +140,9 @@ def find_lib(): if name.endswith('waf-light'): w = test(base) if w: return w + for dir in sys.path: + if test(dir): + return dir err('waf-light requires waflib -> export WAFDIR=/folder') dirname = '%s-%s-%s' % (WAF, VERSION, REVISION) @@ -160,10 +163,13 @@ wafdir = find_lib() sys.path.insert(0, wafdir) if __name__ == '__main__': + from waflib import Context + Context.WAFNAME='waifu' + Context.WAIFUVERSION='1.1.0' sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), 'scripts', 'waifulib')) from waflib import Scripting Scripting.waf_entry_point(cwd, VERSION, wafdir) #==> -#BZh91AY&SYL79u  8X0EbQ\{*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#3oKmCamvueJwt]Sf:lݶq:}S۹NNݺ7}ۡ{;RR]#9טͬ@aحٽy_>gv|axoyzw#*Ogmoޏl{3w|#*#*#*#*6>=#*N{r#*ݻaݭw+Z57:٦Im݅8F#9CMw#*DT#*"DPTzRJnT׽z>wsK+w*ۮ"jO[ppwcT>Jzz$cg׾ٻ)nmfl&vNkuuE۞R {7ZۮVm=zǽXztn9EQk^E@^G(c:uJKk/y˙zv>-5΃'#* {Ghν{{'$})#994Aq0vf[5vNͶ뾷zd.o}]ә}uCَ=)ƎN8r #*7zu_w}FzKsH(%;5IBklvv6ɗKݹY{ݞzoy(W7Uv#*#*&#*h{{^w}}EOp[;nøşj=ù ٯZP}Po5zSkiTsڽWivo#*V{ wl)NwGk^غ ؅#Y˛X.+7e}zmMWJ[p^tSt^{;{={v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IݟCE[&QфAGNKbIC:~ݓRtm%G^1!l_.V1нcfٙHPwAGTjqGE#/ڥTDbj&BVX `u~MzE'w5ӈ '$Y7z=x1h#xG~YοPm4^l8{7v|l d`@B)0AO6@tww\@L4E1#4AUL)!@CT#/$USCQTL @B 2@ 4J!Ae *'yP5!d#/d?,Hu!с W죨,11P_+q x[&#/F Hɠk?kW!D,zR3Y#=6<\N7SS>h&T557EHSf#=1Ah ʹ|[Og~ǪaμC_3#4acz?+w6`k|'^!t2#4I0Ze&kAhm4܌Zp`LisT8v,9k]!㸎u5dcu牜m_a:#=;"3 vx;r+61SޛtL ̞i˓ ȸׄ]<z1#fM&]l̨dhjK2JW:lڝt94OHZJ8dx8'21 zX#4^% )F$f É$P;[G82P| یx:Yɡy|XC#={Y:F~dM]Jaa#/19RaHKe:N̛Z0$.JUhKjBo,ݱ"!hHNv|l#4*bF+mz60RE%S b8"cc#="l>]mF9μSi E 2MЩ%'$~4r@Э#׼k7nlxCX>_yQ$=5#4:܀v\@%{pi` (@M&C>ZqY89j0x '˲vBtHBkʂ#=jrfr#4?WU۔h$xD=` @ Bu=x#= P!JC (Pa9Nҕm+PILÚD3/E)%$W}d/Ϥ/SDu42DDQ#4!Q!CQ!_*4PDMl}n?t#4UzOq6!|Akmӏ_O^QgLs#=#4ּo=#5|3! L>NN1p:Ru8|FV9J;#/!-M-6t_):mKWF.7h8P^agTP 3hkʗ$DmGG⨊gU,#4L;qD 3BJ3% X5YB*9(:Y7#4C<9Uy_~ӫNqA܈zBAQM ĭʠ2:ݕ6O*@?HN?u(/!Q fBLL ,A;7ޗ_vCPO3CN#=EܑN$#^ #<== diff --git a/wscript b/wscript index ede9efa4..f125a186 100644 --- a/wscript +++ b/wscript @@ -3,38 +3,43 @@ # a1batross, mittorn, 2018 from __future__ import print_function -from waflib import Logs +from waflib import Logs, Context, Configure import sys import os -sys.path.append(os.path.realpath('scripts/waflib')) VERSION = '2.4' APPNAME = 'hlsdk-xash3d' top = '.' +Context.Context.line_just = 55 # should fit for everything on 80x26 + +@Configure.conf +def get_taskgen_count(self): + try: idx = self.tg_idx_count + except: idx = 0 # don't set tg_idx_count to not increase counter + return idx + def options(opt): grp = opt.add_option_group('Common options') - grp.add_option('-T', '--build-type', action='store', dest='BUILD_TYPE', default = None, - help = 'build type: debug, release or none(custom flags)') - grp.add_option('-8', '--64bits', action = 'store_true', dest = 'ALLOW64', default = False, - help = 'allow targetting 64-bit game dlls') + help = 'allow targetting 64-bit engine(Linux/Windows/OSX x86 only) [default: %default]') grp.add_option('--enable-voicemgr', action = 'store_true', dest = 'VOICEMGR', default = False, - help = 'enable voice manager') + help = 'enable voice manager [default: %default]') - grp.add_option('--enable-goldsrc-support', action = 'store_true', dest = 'GOLDSRC', default = False, - help = 'enable GoldSource engine support') + grp.add_option('--disable-goldsrc-support', action = 'store_false', dest = 'GOLDSRC', default = True, + help = 'disable GoldSource engine support [default: %default]') - opt.recurse('cl_dll dlls') + opt.load('compiler_optimizations subproject') - opt.load('xcompile compiler_cxx compiler_c') + opt.add_subproject(['cl_dll', 'dlls']) + + opt.load('xcompile compiler_cxx compiler_c clang_compilation_database strip_on_install msdev msvs') if sys.platform == 'win32': - opt.load('msvc msdev') + opt.load('msvc') opt.load('reconfigure') - def configure(conf): # Configuration conf.env.GAMEDIR = 'valve' @@ -43,20 +48,9 @@ def configure(conf): conf.env.SERVER_NAME = 'hl' conf.env.PREFIX = '' - conf.load('reconfigure') + conf.load('fwgslib reconfigure compiler_optimizations enforce_pic') - conf.start_msg('Build type') - if conf.options.BUILD_TYPE == None: - conf.end_msg('not set', color='RED') - conf.fatal('Please set a build type, for example "-T release"') - elif not conf.options.BUILD_TYPE in ['fast', 'release', 'debug', 'nooptimize', 'sanitize', 'none']: - conf.end_msg(conf.options.BUILD_TYPE, color='RED') - conf.fatal('Invalid build type. Valid are "debug", "release" or "none"') - conf.end_msg(conf.options.BUILD_TYPE) - - # -march=native should not be used - if conf.options.BUILD_TYPE == 'fast': - Logs.warn('WARNING: \'fast\' build type should not be used in release builds') + enforce_pic = True # modern defaults conf.env.VOICEMGR = conf.options.VOICEMGR conf.env.GOLDSRC = conf.options.GOLDSRC @@ -65,96 +59,157 @@ def configure(conf): # subsystem=bld.env.MSVC_SUBSYSTEM # TODO: wrapper around bld.stlib, bld.shlib and so on? conf.env.MSVC_SUBSYSTEM = 'WINDOWS,5.01' - conf.env.MSVC_TARGETS = ['x86'] # explicitly request x86 target for MSVC - if sys.platform == 'win32': - conf.load('msvc msdev') + conf.env.MSVC_TARGETS = ['x86' if not conf.options.ALLOW64 else 'x64'] + + # Load compilers early conf.load('xcompile compiler_c compiler_cxx') - if conf.env.DEST_OS2 == 'android': - conf.options.ALLOW64 = True - conf.options.GOLDSRC = False - conf.env.SERVER_NAME = 'server' # can't be any other name, until specified - - # print(conf.options.ALLOW64) - - conf.env.BIT32_MANDATORY = not conf.options.ALLOW64 - conf.env.BIT32_ALLOW64 = conf.options.ALLOW64 - conf.load('force_32bit') - - if conf.env.DEST_SIZEOF_VOID_P == 4: - Logs.info('NOTE: will build game dlls for 32-bit target') - else: - Logs.warn('WARNING: 64-bit game dlls may be unstable') - - linker_flags = { - 'common': { - 'msvc': ['/DEBUG'], # always create PDB, doesn't affect result binaries - 'gcc': ['-Wl,--no-undefined'] - }, - 'sanitize': { - 'gcc': ['-fsanitize=undefined', '-fsanitize=address'], - } - } - - compiler_c_cxx_flags = { - 'common': { - 'msvc': ['/D_USING_V110_SDK71_', '/Zi', '/FS'], - 'clang': ['-g', '-gdwarf-2'], - 'gcc': ['-g', '-Werror=implicit-function-declaration', '-fdiagnostics-color=always'] - }, - 'fast': { - 'msvc': ['/O2', '/Oy'], #todo: check /GL /LTCG - 'gcc': ['-Ofast', '-march=native', '-funsafe-math-optimizations', '-funsafe-loop-optimizations', '-fomit-frame-pointer'], - 'default': ['-O3'] - }, - 'release': { - 'msvc': ['/O2'], - 'default': ['-O3'] - }, - 'debug': { - 'msvc': ['/O1'], - 'gcc': ['-Og'], - 'default': ['-O1'] - }, - 'sanitize': { - 'msvc': ['/Od', '/RTC1'], - 'gcc': ['-Og', '-fsanitize=undefined', '-fsanitize=address'], - 'default': ['-O1'] - }, - 'nooptimize': { - 'msvc': ['/Od'], - 'default': ['-O0'] - } - } - - conf.env.append_unique('CFLAGS', conf.get_flags_by_type( - compiler_c_cxx_flags, conf.options.BUILD_TYPE, conf.env.COMPILER_CC)) - conf.env.append_unique('CXXFLAGS', conf.get_flags_by_type( - compiler_c_cxx_flags, conf.options.BUILD_TYPE, conf.env.COMPILER_CC)) - conf.env.append_unique('LINKFLAGS', conf.get_flags_by_type( - linker_flags, conf.options.BUILD_TYPE, conf.env.COMPILER_CC)) + # HACKHACK: override msvc DEST_CPU value by something that we understand + if conf.env.DEST_CPU == 'amd64': + conf.env.DEST_CPU = 'x86_64' if conf.env.COMPILER_CC == 'msvc': - conf.env.append_unique('DEFINES', ['_CRT_SECURE_NO_WARNINGS','_CRT_NONSTDC_NO_DEPRECATE']) + conf.load('msvc_pdb') + + conf.load('msvs msdev strip_on_install') + + if conf.env.DEST_OS == 'android': + conf.options.GOLDSRC = conf.env.GOLDSRC = False + conf.env.SERVER_NAME = 'server' # can't be any other name, until specified + elif conf.env.DEST_OS in ['nswitch', 'psvita']: + conf.options.GOLDSRC = conf.env.GOLDSRC = False + + if conf.env.MAGX: + enforce_pic = False + + conf.check_pic(enforce_pic) + + # We restrict 64-bit builds ONLY for Win/Linux/OSX running on Intel architecture + # Because compatibility with original GoldSrc + if conf.env.DEST_OS in ['win32', 'linux', 'darwin'] and conf.env.DEST_CPU in ['x86_64']: + conf.env.BIT32_ALLOW64 = conf.options.ALLOW64 + if not conf.env.BIT32_ALLOW64: + Logs.info('WARNING: will build engine for 32-bit target') else: - conf.env.append_unique('DEFINES', ['stricmp=strcasecmp','strnicmp=strncasecmp','_LINUX','LINUX','_snprintf=snprintf','_vsnprintf=vsnprintf']) - cflags = ['-fvisibility=hidden','-Wno-write-strings'] - conf.env.append_unique('CFLAGS', cflags) - conf.env.append_unique('CXXFLAGS', cflags + ['-Wno-invalid-offsetof', '-fno-rtti', '-fno-exceptions']) + conf.env.BIT32_ALLOW64 = True + conf.env.BIT32_MANDATORY = not conf.env.BIT32_ALLOW64 + conf.load('force_32bit library_naming') + + compiler_optional_flags = [ + '-fdiagnostics-color=always', + '-Werror=return-type', + '-Werror=parentheses', + '-Werror=vla', + '-Werror=tautological-compare', + '-Werror=duplicated-cond', + '-Werror=bool-compare', + '-Werror=bool-operation', + '-Wstrict-aliasing', + ] + + c_compiler_optional_flags = [ + '-Werror=implicit-function-declaration', + '-Werror=int-conversion', + '-Werror=implicit-int', + '-Werror=declaration-after-statement' + ] + + cflags, linkflags = conf.get_optimization_flags() + + # Here we don't differentiate C or C++ flags + if conf.options.LTO: + lto_cflags = { + 'msvc': ['/GL'], + 'gcc': ['-flto'], + 'clang': ['-flto'] + } + + lto_linkflags = { + 'msvc': ['/LTCG'], + 'gcc': ['-flto'], + 'clang': ['-flto'] + } + cflags += conf.get_flags_by_compiler(lto_cflags, conf.env.COMPILER_CC) + linkflags += conf.get_flags_by_compiler(lto_linkflags, conf.env.COMPILER_CC) + + if conf.options.POLLY: + polly_cflags = { + 'gcc': ['-fgraphite-identity'], + 'clang': ['-mllvm', '-polly'] + # msvc sosat :( + } + + cflags += conf.get_flags_by_compiler(polly_cflags, conf.env.COMPILER_CC) + + # And here C++ flags starts to be treated separately + cxxflags = list(cflags) + if conf.env.COMPILER_CC != 'msvc': + conf.check_cc(cflags=cflags, msg= 'Checking for required C flags') + conf.check_cxx(cxxflags=cflags, msg= 'Checking for required C++ flags') + + cflags += conf.filter_cflags(compiler_optional_flags + c_compiler_optional_flags, cflags) + cxxflags += conf.filter_cxxflags(compiler_optional_flags, cflags) + + # on the Switch and the PSVita, allow undefined symbols by default, + # which is needed for the dynamic loaders to work + # additionally, shared libs are linked without libc + if conf.env.DEST_OS == 'nswitch': + linkflags.remove('-Wl,--no-undefined') + conf.env.append_unique('LINKFLAGS_cshlib', ['-nostdlib', '-nostartfiles']) + conf.env.append_unique('LINKFLAGS_cxxshlib', ['-nostdlib', '-nostartfiles']) + elif conf.env.DEST_OS == 'psvita': + linkflags.remove('-Wl,--no-undefined') + conf.env.append_unique('CFLAGS_cshlib', ['-fPIC']) + conf.env.append_unique('CXXFLAGS_cxxshlib', ['-fPIC', '-fno-use-cxa-atexit']) + conf.env.append_unique('LINKFLAGS_cshlib', ['-nostdlib', '-Wl,--unresolved-symbols=ignore-all']) + conf.env.append_unique('LINKFLAGS_cxxshlib', ['-nostdlib', '-Wl,--unresolved-symbols=ignore-all']) + + conf.env.append_unique('CFLAGS', cflags) + conf.env.append_unique('CXXFLAGS', cxxflags) + conf.env.append_unique('LINKFLAGS', linkflags) + + # check if we can use C99 tgmath + if conf.check_cc(header_name='tgmath.h', mandatory=False): + tgmath_usable = conf.check_cc(fragment='''#include + int main(void){ return (int)sin(2.0f); }''', + msg='Checking if tgmath.h is usable', mandatory=False) + conf.define_cond('HAVE_TGMATH_H', tgmath_usable) + else: + conf.undefine('HAVE_TGMATH_H') + cmath_usable = conf.check_cxx(fragment='''#include + int main(void){ return (int)sqrt(2.0f); }''', + msg='Checking if cmath is usable', mandatory = False) + conf.define_cond('HAVE_CMATH', cmath_usable) + + if conf.env.COMPILER_CC == 'msvc': + conf.define('_CRT_SECURE_NO_WARNINGS', True) + conf.define('_CRT_NONSTDC_NO_DEPRECATE', True) + elif conf.env.COMPILER_CC == 'owcc': + pass + else: + conf.env.append_unique('DEFINES', ['stricmp=strcasecmp', 'strnicmp=strncasecmp', '_snprintf=snprintf', '_vsnprintf=vsnprintf', '_LINUX', 'LINUX']) + conf.env.append_unique('CXXFLAGS', ['-Wno-invalid-offsetof', '-fno-rtti', '-fno-exceptions']) # strip lib from pattern - if conf.env.DEST_OS in ['linux', 'darwin'] and conf.env.DEST_OS2 not in ['android']: + if conf.env.DEST_OS not in ['android']: if conf.env.cshlib_PATTERN.startswith('lib'): conf.env.cshlib_PATTERN = conf.env.cshlib_PATTERN[3:] if conf.env.cxxshlib_PATTERN.startswith('lib'): conf.env.cxxshlib_PATTERN = conf.env.cxxshlib_PATTERN[3:] - conf.env.append_unique('DEFINES', 'CLIENT_WEAPONS') + conf.define('BARNACLE_FIX_VISIBILITY', False) + conf.define('CLIENT_WEAPONS', True) + conf.define('CROWBAR_IDLE_ANIM', False) + conf.define('CROWBAR_DELAY_FIX', False) + conf.define('CROWBAR_FIX_RAPID_CROWBAR', False) + conf.define('GAUSS_OVERCHARGE_FIX', False) + conf.define('OEM_BUILD', False) + conf.define('HLDEMO_BUILD', False) - conf.recurse('cl_dll dlls') + conf.add_subproject(["cl_dll", "dlls"]) def build(bld): - bld.recurse('cl_dll dlls') - - - + bld.add_subproject(["cl_dll", "dlls"]) + + +