diff --git a/.gitignore b/.gitignore index 26362f60..a0bc5604 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,14 @@ *.a *.framework *.exe -build/ \ No newline at end of file +*.dll +*.pdb +build/ +CMakeLists.txt.user +cmake_install.cmake +*.orig +*.cbp +*.dsw +*.vsxproj +*.vsproj +*.sln diff --git a/.travis.yml b/.travis.yml index 9e165b81..f01abaeb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,10 +5,21 @@ compiler: os: - linux - osx -sudo: true +addons: + apt: + packages: + - gcc-multilib + - g++-multilib before_script: - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install gcc-multilib g++-multilib; fi + - curl http://libsdl.org/release/SDL2-devel-2.0.7-mingw.tar.gz | tar xzf - + - mv SDL2-2.0.7/i686-w64-mingw32/include/SDL2 cl_dll/ script: - mkdir -p build && cd build - - cmake ../ -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" -DUSE_VOICEMGR=0 && make -j3 && rm -rf * - - cmake ../ -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" -DUSE_VOICEMGR=1 && make -j3 && rm -rf * \ No newline at end of file + - cmake ../ -DCMAKE_C_FLAGS="-O2 -pipe -DNDEBUG -fvisibility=hidden -fomit-frame-pointer" -DCMAKE_CXX_FLAGS="-fno-exceptions -fno-rtti" -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined -Wl,--strip-all" -DGOLDSOURCE_SUPPORT=1 -DUSE_VOICEMGR=0 && make -j3 + - mkdir -p $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC/cl_dlls + - mkdir -p $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC/dlls + - cp cl_dll/client.* $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC/cl_dlls + - cp dlls/hl.* $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC/dlls + - tar -J -cf $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC.txz $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC + - curl --upload-file $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC.txz https://transfer.sh/$TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC.txz + diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c2d6822..918449e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,16 +21,29 @@ # cmake_minimum_required(VERSION 2.6.0) + +# Install custom module path +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") + +include(VSForceXPToolchain) # Force XP toolchain for Visual Studio + project (HLSDK-XASH3D) #-------------- # USER DEFINES \ ################\ +option(64BIT "Allow 64 Bit builds" OFF) option(USE_VGUI "Enable VGUI1. UNDONE" OFF) option(USE_VGUI2 "Enable VGUI2. UNDONE" 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) +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") #----------------- # MAIN BUILD CODE \ @@ -38,15 +51,40 @@ option(BUILD_SERVER "Build server dll" ON) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") -# Build 32-bit Xash on 64-bit, because Xash3D not support this -if(CMAKE_SIZEOF_VOID_P EQUAL 8) +if(CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT 64BIT) if(MSVC) - error("UNDONE: set 32 build flags") + error("UNDONE: set 32 build flags") else() - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") - set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32") endif() + set(CMAKE_SIZEOF_VOID_P 4) +endif() + +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) + message(STATUS "Building for 64 Bit") +else() + message(STATUS "Building for 32 Bit") +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") +endif() + +# add_compile_options for older cmake versions +if(${CMAKE_VERSION} VERSION_LESS "3.0.2") + macro(add_compile_options) + set(list_var "${ARGV}") + foreach(arg IN LISTS list_var) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${arg}") + endforeach() + endmacro() endif() if(BUILD_CLIENT) @@ -59,4 +97,4 @@ endif() if(NOT BUILD_SERVER AND NOT BUILD_CLIENT) error("Nothing to build") -endif() \ No newline at end of file +endif() diff --git a/README.md b/README.md index bb1cc675..be0a5fa8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Half-Life SDK for Xash3D [![Build Status](https://travis-ci.org/FWGS/hlsdk-xash3d.svg)](https://travis-ci.org/FWGS/hlsdk-xash3d) +# 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 Xash3D & GoldSource with some fixes. @@ -6,37 +6,144 @@ Half-Life SDK for Xash3D & GoldSource with some fixes. ### CMake as most universal way -``` -mkdir build && cd build -cmake ../ -``` + mkdir build && cd build + cmake ../ + make + +Crosscompiling using mingw: + + 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++" 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. See below, if CMake is not suitable for you: ### Windows +#### Using msvc + +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 + +These scripts also can be ran via wine: + + MSVCDir="z:\home\$USER\.wine\drive_c\Program Files\Microsoft Visual Studio" wine cmd /c compile.bat + +The libraries built this way are always GoldSource compatible. + +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. + +#### Using mingw + TODO ### Linux -TODO + (cd dlls && make) + (cd cl_dll && make) ### OS X -TODO +Nothing here. ### FreeBSD -``` - cd dlls - gmake CXX=clang++ CC=clang - cd ../cl_dll - gmake CXX=clang++ CC=clang -``` + (cd dlls && gmake CXX=clang++ CC=clang) + (cd cl_dll && gmake CXX=clang++ CC=clang) ### Android Just typical `ndk-build`. +TODO: describe what it is. +### Building GoldSource-compatible libraries + +To enable building the goldsource compatible client library add GOLDSOURCE_SUPPORT flag when calling cmake: + + cmake .. -DGOLDSOURCE_SUPPORT=ON + +or when using make without cmake: + + make GOLDSOURCE_SUPPORT=1 + +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. + +Note for **Windows**: it's not possible to create GoldSource compatible libraries using mingw, only msvc builds will work. + +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. + +#### Method 1: Statically build with c++ library + +This one is the most simple but has a drawback. + + cmake ../ -DGOLDSOURCE_SUPPORT=ON -DCMAKE_C_FLAGS="-static-libstdc++ -static-libgcc" + +The drawback is that the compiled libraries will be larger in size. + +#### Method 2: Build in Steam Runtime chroot + +This is the official way to build Steam compatible games for Linux. + +Clone https://github.com/ValveSoftware/steam-runtime and follow instructions https://github.com/ValveSoftware/steam-runtime#building-in-the-runtime + + sudo ./setup_chroot.sh --i386 + +Then use cmake and make as usual, but prepend the commands with `schroot --chroot steamrt_scout_i386 --`: + + mkdir build-in-steamrt && cd build-in-steamrt + schroot --chroot steamrt_scout_i386 -- cmake ../ -DGOLDSOURCE_SUPPORT=ON + schroot --chroot steamrt_scout_i386 -- make + +#### Method 3: Create your own chroot with older distro that includes g++ 4. + +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 debootstrap --arch=i386 jessie /var/chroot/jessie-debian-i386 # On Ubuntu type trusty instead of jessie + sudo chroot /var/chroot/jessie-debian-i386 + +Inside chroot install cmake, make, g++ and libsdl2-dev. Then exit the chroot. + +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): + +``` +[jessie] +type=directory +description=Debian jessie i386 +directory=/var/chroot/debian-jessie-i386/ +users=yourusername +groups=yourusername +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 --`: + + mkdir build-in-chroot && cd build-in-chroot + schroot --chroot jessie -- cmake ../ -DGOLDSOURCE_SUPPORT=ON + schroot --chroot jessie -- make + +#### 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 "$@" +``` + +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. diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..eb39ee2d --- /dev/null +++ b/appveyor.yml @@ -0,0 +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 + +build: + project: INSTALL.vcxproj + verbosity: normal + +configuration: + - Debug + +before_build: + - git submodule update --init --recursive + - cmake -G "%GENERATOR_NAME%" diff --git a/backup.bat b/backup.bat deleted file mode 100644 index 7e780aa8..00000000 --- a/backup.bat +++ /dev/null @@ -1,31 +0,0 @@ -@echo off -color 4F -echo XashXT Group 2006 (C) -echo Prepare source for backup -echo. - -if exist backup.log del /f /q backup.log -if not exist D:\!backup/ mkdir D:\!backup\ -echo Prepare OK! -echo Please wait: backup in progress -C:\Progra~1\WinRar\rar a -agMMMYYYY-DD D:\!backup\.rar -dh -m5 @backup.lst >>backup.log -if errorlevel 1 goto error -if errorlevel 0 goto ok -:ok -cls -echo Source was sucessfully backuped -echo and stored in folder "backup" -echo Press any key for exit. :-) -if exist backup.log del /f /q backup.log -exit -:error -echo ****************************** -echo ***********Error!************* -echo ****************************** -echo **See backup.log for details** -echo ****************************** -echo ****************************** -echo. -echo press any key for exit :-( -pause>nul -exit diff --git a/backup.lst b/backup.lst deleted file mode 100644 index 628de079..00000000 --- a/backup.lst +++ /dev/null @@ -1,36 +0,0 @@ -//======================================================================= -// Copyright XashXT Group 2007 © -// list with backup directories -//======================================================================= - -// global stuff -xash.dsw -debug.bat -backup.lst -backup.bat -release.bat -change.log -make_sdk.bat -xash_sdk.lst - -cl_dll\ -cl_dll\hl\ -common\ -dlls\ -game_shared\ -game_launch\ -engine\ -engine\client\ -engine\client\vgui\ -engine\server\ -engine\common\ -engine\common\imagelib\ -engine\common\soundlib\ -pm_shared\ -mainui\ -mainui\legacy -utils\ -utils\makefont\ -utils\vgui\ -utils\vgui\include\ -utils\vgui\lib\win32_vc6\ \ No newline at end of file diff --git a/cl_dll/Android.mk b/cl_dll/Android.mk index 2a15859b..4248d916 100755 --- a/cl_dll/Android.mk +++ b/cl_dll/Android.mk @@ -13,7 +13,6 @@ LOCAL_MODULE := client #else APP_PLATFORM := android-8 #endif -LOCAL_CONLYFLAGS += -std=c99 include $(XASH3D_CONFIG) @@ -25,32 +24,11 @@ LOCAL_CFLAGS += -DCLIENT_DLL=1 SRCS= SRCS_C= -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/hornetgun.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+=../dlls/glock.cpp -SRCS+=../dlls/poke646/bradnailer.cpp -SRCS+=../dlls/poke646/cmlwbr.cpp -SRCS+=../dlls/poke646/heaterpipe.cpp -SRCS+=../dlls/poke646/nailgun.cpp -SRCS+=../dlls/poke646/weapon_pipebomb.cpp -SRCS+=../dlls/poke646/xensquasher.cpp -SRCS+=../dlls/vendetta/par21.cpp #SRCS+=../game_shared/voice_banmgr.cpp #SRCS+=../game_shared/voice_status.cpp SRCS+=./ammo.cpp @@ -76,6 +54,8 @@ SRCS+=./hud_spectator.cpp SRCS+=./hud_update.cpp SRCS+=./in_camera.cpp SRCS+=./input.cpp +SRCS+=./input_goldsource.cpp +SRCS+=./input_mouse.cpp #SRCS+=./inputw32.cpp SRCS+=./menu.cpp SRCS+=./message.cpp @@ -99,8 +79,8 @@ SRCS+=./input_xash3d.cpp SRCS+=./scoreboard.cpp SRCS+=./MOTD.cpp -INCLUDES = -I../common -I. -I../game_shared -I../pm_shared -I../engine -I../dlls -DEFINES = -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w +INCLUDES = -I../common -I. -I../game_shared -I../pm_shared -I../engine -I../dlls -I../utils/false_vgui/include +DEFINES = -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w -D_snprintf=snprintf LOCAL_C_INCLUDES := $(LOCAL_PATH)/. \ $(LOCAL_PATH)/../common \ @@ -109,10 +89,17 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/. \ $(LOCAL_PATH)/../dlls \ $(LOCAL_PATH)/../pm_shared \ $(LOCAL_PATH)/poke646 \ - $(LOCAL_PATH)/../dlls/poke646 - + $(LOCAL_PATH)/../dlls/poke646 \ + $(LOCAL_PATH)/../utils/false_vgui/include LOCAL_CFLAGS += $(DEFINES) $(INCLUDES) +ifeq ($(GOLDSOURCE_SUPPORT),1) + DEFINES += -DGOLDSOURCE_SUPPORT + ifeq ($(shell uname -s),Linux) + LOCAL_LDLIBS += -ldl + endif +endif + LOCAL_SRC_FILES := $(SRCS) $(SRCS_C) include $(BUILD_SHARED_LIBRARY) diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index 5f16c9ea..5b032aec 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -25,31 +25,26 @@ project (CLDLL) set (CLDLL_LIBRARY client) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w") -set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") +add_definitions(-DCLIENT_DLL) -set (CLDLL_SOURCES - ../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 - ../dlls/poke646/bradnailer.cpp - ../dlls/poke646/cmlwbr.cpp - ../dlls/poke646/heaterpipe.cpp - ../dlls/poke646/nailgun.cpp - ../dlls/poke646/weapon_pipebomb.cpp - ../dlls/poke646/xensquasher.cpp - ../dlls/vendetta/par21.cpp +if(NOT MSVC) + add_compile_options(-fno-exceptions) # GCC/Clang flag + add_compile_options(-Wno-write-strings) # GCC/Clang flag + add_compile_options(-fvisibility=hidden) # GCC/Clang flag + add_definitions(-D_LINUX -DLINUX) # It seems enough for all non-Win32 systems + add_definitions(-Dstricmp=strcasecmp -Dstrnicmp=strncasecmp) + if(NOT MINGW) + add_definitions(-D_snprintf=snprintf -D_vsnprintf=vsnprintf) + endif() +else() + add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE) +endif() + +if (GOLDSOURCE_SUPPORT) + add_definitions(-DGOLDSOURCE_SUPPORT) +endif() + +set (CLDLL_SOURCES ev_hldm.cpp hl/hl_baseentity.cpp hl/hl_events.cpp @@ -77,7 +72,9 @@ set (CLDLL_SOURCES hud_update.cpp in_camera.cpp input.cpp -#SRCS+=./inputw32.cpp + input_goldsource.cpp + input_mouse.cpp + input_xash3d.cpp menu.cpp message.cpp overview.cpp @@ -96,10 +93,10 @@ set (CLDLL_SOURCES tri.cpp util.cpp view.cpp - input_xash3d.cpp scoreboard.cpp MOTD.cpp) -include_directories (. hl/ poke646 ../dlls ../dlls/poke646 ../dlls/wpn_shared ../common ../engine ../pm_shared ../game_shared ../public) + +include_directories (. hl/ poke646 ../dlls ../dlls/poke646 ../dlls/wpn_shared ../common ../engine ../pm_shared ../game_shared ../public ../utils/false_vgui/include) if(USE_VOICEMGR) #set(CLDLL_SOURCES @@ -109,7 +106,26 @@ if(USE_VOICEMGR) endif() add_library (${CLDLL_LIBRARY} SHARED ${CLDLL_SOURCES}) +if (GOLDSOURCE_SUPPORT) + target_link_libraries( ${CLDLL_LIBRARY} ${CMAKE_DL_LIBS} ) +endif() -set_target_properties (${CLDLL_SHARED} PROPERTIES +set_target_properties (${CLDLL_LIBRARY} PROPERTIES POSITION_INDEPENDENT_CODE 1) +if(APPLE OR WIN32 OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + set(CLDLL_NAME "client") + if(64BIT) + set(CLDLL_NAME "client64") + endif() + + set_target_properties(${CLDLL_LIBRARY} PROPERTIES + OUTPUT_NAME ${CLDLL_NAME} + PREFIX "") +endif() + +install( TARGETS ${CLDLL_LIBRARY} + DESTINATION "${GAMEDIR}/${CLIENT_INSTALL_DIR}/" + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE ) diff --git a/cl_dll/GameStudioModelRenderer.cpp b/cl_dll/GameStudioModelRenderer.cpp index c7211752..570b3375 100644 --- a/cl_dll/GameStudioModelRenderer.cpp +++ b/cl_dll/GameStudioModelRenderer.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/GameStudioModelRenderer.h b/cl_dll/GameStudioModelRenderer.h index 7d06f70f..0e424576 100644 --- a/cl_dll/GameStudioModelRenderer.h +++ b/cl_dll/GameStudioModelRenderer.h @@ -1,15 +1,13 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // // $NoKeywords: $ //============================================================================= +#pragma once #if !defined( GAMESTUDIOMODELRENDERER_H ) #define GAMESTUDIOMODELRENDERER_H -#if defined( _WIN32 ) -#pragma once -#endif /* ==================== @@ -23,4 +21,4 @@ public: CGameStudioModelRenderer( void ); }; -#endif // GAMESTUDIOMODELRENDERER_H \ No newline at end of file +#endif // GAMESTUDIOMODELRENDERER_H diff --git a/cl_dll/GameStudioModelRenderer_Sample.cpp b/cl_dll/GameStudioModelRenderer_Sample.cpp index d697d927..ee8e8f9c 100644 --- a/cl_dll/GameStudioModelRenderer_Sample.cpp +++ b/cl_dll/GameStudioModelRenderer_Sample.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/GameStudioModelRenderer_Sample.h b/cl_dll/GameStudioModelRenderer_Sample.h index c924ba3e..7a4d062d 100644 --- a/cl_dll/GameStudioModelRenderer_Sample.h +++ b/cl_dll/GameStudioModelRenderer_Sample.h @@ -1,15 +1,13 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // // $NoKeywords: $ //============================================================================= +#pragma once #if !defined( GAMESTUDIOMODELRENDERER_H ) #define GAMESTUDIOMODELRENDERER_H -#if defined( _WIN32 ) -#pragma once -#endif /* ==================== @@ -52,4 +50,4 @@ private: bool m_bLocal; }; -#endif // GAMESTUDIOMODELRENDERER_H \ No newline at end of file +#endif // GAMESTUDIOMODELRENDERER_H diff --git a/cl_dll/MOTD.cpp b/cl_dll/MOTD.cpp index 6ab3a161..179ae4a8 100644 --- a/cl_dll/MOTD.cpp +++ b/cl_dll/MOTD.cpp @@ -103,7 +103,7 @@ int CHudMOTD::Draw( float fTime ) // find where to start drawing the line if( ( ypos > ROW_RANGE_MIN ) && ( ypos + LINE_HEIGHT <= ypos_r + height ) ) - gHUD.DrawHudString( xpos, ypos, xmax, ch, 255, 180, 0 ); + DrawUtfString( xpos, ypos, xmax, ch, 255, 180, 0 ); ypos += LINE_HEIGHT; diff --git a/cl_dll/Makefile b/cl_dll/Makefile index 983b61c0..0ff4dadf 100644 --- a/cl_dll/Makefile +++ b/cl_dll/Makefile @@ -45,7 +45,8 @@ SRCS+=./hud_spectator.cpp SRCS+=./hud_update.cpp SRCS+=./in_camera.cpp SRCS+=./input.cpp -#SRCS+=./inputw32.cpp +SRCS+=./input_mouse.cpp +SRCS+=./input_goldsource.cpp SRCS+=./menu.cpp SRCS+=./message.cpp SRCS+=./overview.cpp @@ -66,15 +67,18 @@ 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 +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=$(LIBS) -ldl + LIBS += -ldl endif %.o : %.c @@ -83,7 +87,7 @@ endif %.o : %.cpp $(CXX) $(CFLAGS) $(INCLUDES) $(DEFINES) -fPIC -c $< -o $@ client.so : $(OBJS) - $(CXX) $(OBJS) -o client.so -shared -Wl,--no-undefined -fPIC $(LIBS) + $(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 b7c3c1c6..a9859244 100644 --- a/cl_dll/StudioModelRenderer.cpp +++ b/cl_dll/StudioModelRenderer.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/StudioModelRenderer.h b/cl_dll/StudioModelRenderer.h index 0a56b731..69d28a1e 100644 --- a/cl_dll/StudioModelRenderer.h +++ b/cl_dll/StudioModelRenderer.h @@ -1,15 +1,13 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // // $NoKeywords: $ //============================================================================= +#pragma once #if !defined ( STUDIOMODELRENDERER_H ) #define STUDIOMODELRENDERER_H -#if defined( _WIN32 ) -#pragma once -#endif /* ==================== diff --git a/cl_dll/ammo.cpp b/cl_dll/ammo.cpp index f6c815cf..0eb1cc92 100644 --- a/cl_dll/ammo.cpp +++ b/cl_dll/ammo.cpp @@ -305,6 +305,9 @@ void CHudAmmo::Reset( void ) gHR.Reset(); //VidInit(); + wrect_t nullrc = {0,}; + SetCrosshair( 0, nullrc, 0, 0, 0 ); // reset crosshair + m_pWeapon = NULL; // reset last weapon } int CHudAmmo::VidInit( void ) @@ -312,6 +315,7 @@ int CHudAmmo::VidInit( void ) // Load sprites for buckets (top row of weapon menu) m_HUD_bucket0 = gHUD.GetSpriteIndex( "bucket1" ); m_HUD_selection = gHUD.GetSpriteIndex( "selection" ); + m_HUD_stripe = gHUD.GetSpriteIndex( "stripe" ); ghsprBuckets = gHUD.GetSprite( m_HUD_bucket0 ); giBucketWidth = gHUD.GetSpriteRect( m_HUD_bucket0 ).right - gHUD.GetSpriteRect( m_HUD_bucket0 ).left; @@ -422,12 +426,6 @@ void WeaponsResource::SelectSlot( int iSlot, int fAdvance, int iDirection ) if( gHUD.m_fPlayerDead || gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL ) ) return; - if ( !( gHUD.m_iWeaponBits & ( 1 << ( WEAPON_SUIT ) ) ) ) - return; - - if( ! ( gHUD.m_iWeaponBits & ~( 1 << ( WEAPON_SUIT ) ) ) ) - return; - WEAPON *p = NULL; bool fastSwitch = CVAR_GET_FLOAT( "hud_fastswitch" ) != 0; @@ -484,7 +482,7 @@ int CHudAmmo::MsgFunc_AmmoX( const char *pszName, int iSize, void *pbuf ) BEGIN_READ( pbuf, iSize ); int iIndex = READ_BYTE(); - int iCount = READ_BYTE(); + int iCount = READ_SHORT(); gWR.SetAmmo( iIndex, abs( iCount ) ); @@ -495,7 +493,7 @@ int CHudAmmo::MsgFunc_AmmoPickup( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); int iIndex = READ_BYTE(); - int iCount = READ_BYTE(); + int iCount = READ_SHORT(); // Add ammo to the history gHR.AddToHistory( HISTSLOT_AMMO, iIndex, abs( iCount ) ); @@ -534,15 +532,18 @@ int CHudAmmo::MsgFunc_HideWeapon( const char *pszName, int iSize, void *pbuf ) if( gEngfuncs.IsSpectateOnly() ) return 1; + if( !( gHUD.m_iHideHUDDisplay & HIDEHUD_WEAPONS ) ) + gHUD.m_flScaleColorTime = gHUD.m_flTime + 2.0; + if( gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL ) ) { - static wrect_t nullrc; + wrect_t nullrc = {0,}; gpActiveSel = NULL; SetCrosshair( 0, nullrc, 0, 0, 0 ); } else { - if ( m_pWeapon ) + if( m_pWeapon ) SetCrosshair( m_pWeapon->hCrosshair, m_pWeapon->rcCrosshair, 255, 255, 255 ); } @@ -556,7 +557,7 @@ int CHudAmmo::MsgFunc_HideWeapon( const char *pszName, int iSize, void *pbuf ) // int CHudAmmo::MsgFunc_CurWeapon( const char *pszName, int iSize, void *pbuf ) { - static wrect_t nullrc; + wrect_t nullrc = {0,}; int fOnTarget = FALSE; BEGIN_READ( pbuf, iSize ); @@ -574,6 +575,8 @@ int CHudAmmo::MsgFunc_CurWeapon( const char *pszName, int iSize, void *pbuf ) if( iId < 1 ) { SetCrosshair( 0, nullrc, 0, 0, 0 ); + // Clear out the weapon so we don't keep drawing the last active weapon's ammo. - Solokiller + m_pWeapon = 0; return 0; } @@ -604,22 +607,24 @@ int CHudAmmo::MsgFunc_CurWeapon( const char *pszName, int iSize, void *pbuf ) m_pWeapon = pWeapon; - if( gHUD.m_iFOV >= 90 ) + if( !( gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL ) ) ) { - // normal crosshairs - if( fOnTarget && m_pWeapon->hAutoaim ) - SetCrosshair( m_pWeapon->hAutoaim, m_pWeapon->rcAutoaim, 255, 255, 255 ); + if( gHUD.m_iFOV >= 90 ) + { + // normal crosshairs + if( fOnTarget && m_pWeapon->hAutoaim ) + SetCrosshair( m_pWeapon->hAutoaim, m_pWeapon->rcAutoaim, 255, 255, 255 ); + else + SetCrosshair( m_pWeapon->hCrosshair, m_pWeapon->rcCrosshair, 255, 255, 255 ); + } else - SetCrosshair( m_pWeapon->hCrosshair, m_pWeapon->rcCrosshair, 255, 255, 255 ); - } - else - { - // zoomed crosshairs - if( fOnTarget && m_pWeapon->hZoomedAutoaim ) - SetCrosshair( m_pWeapon->hZoomedAutoaim, m_pWeapon->rcZoomedAutoaim, 255, 255, 255 ); - else - SetCrosshair( m_pWeapon->hZoomedCrosshair, m_pWeapon->rcZoomedCrosshair, 255, 255, 255 ); - + { + // zoomed crosshairs + if( fOnTarget && m_pWeapon->hZoomedAutoaim ) + SetCrosshair( m_pWeapon->hZoomedAutoaim, m_pWeapon->rcZoomedAutoaim, 255, 255, 255 ); + else + SetCrosshair( m_pWeapon->hZoomedCrosshair, m_pWeapon->rcZoomedCrosshair, 255, 255, 255 ); + } } m_fFade = 200.0f; //!!! @@ -826,9 +831,6 @@ int CHudAmmo::Draw( float flTime ) int a, x, y, r, g, b; int AmmoWidth; - if( !( gHUD.m_iWeaponBits & ( 1 << ( WEAPON_SUIT ) ) ) ) - return 1; - if( ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL ) ) ) return 1; @@ -854,7 +856,7 @@ int CHudAmmo::Draw( float flTime ) AmmoWidth = gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).right - gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).left; - a = (int) min( gHUD.m_flAlpha, max( MIN_ALPHA, m_fFade) ); + a = (int)max( MIN_ALPHA, m_fFade); if( m_fFade > 0 ) m_fFade -= ( gHUD.m_flTimeDelta * 20 ); @@ -864,7 +866,7 @@ int CHudAmmo::Draw( float flTime ) ScaleColors( r, g, b, a ); // Does this weapon have a clip? - y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2; + y = ScreenHeight - gHUD.m_iFontHeight - 10; // Does weapon have any ammo at all? if( m_pWeapon->iAmmoType > 0 ) @@ -874,40 +876,37 @@ int CHudAmmo::Draw( float flTime ) if( pw->iClip >= 0 ) { // room for the number and the '|' and the current ammo - x = ScreenWidth - ( 8 * AmmoWidth ) - iIconWidth; + int StripeWidth = gHUD.GetSpriteRect( m_HUD_stripe ).right - gHUD.GetSpriteRect( m_HUD_stripe ).left; + + x = ScreenWidth - ( 6 * AmmoWidth ) - iIconWidth - StripeWidth - 62; x = gHUD.DrawHudNumber( x, y, iFlags | DHN_3DIGITS, pw->iClip, r, g, b ); - - wrect_t rc; - rc.top = 0; - rc.left = 0; - rc.right = AmmoWidth; - rc.bottom = 100; - - int iBarWidth = AmmoWidth / 10; - - x += AmmoWidth / 2; + x += 16; UnpackRGB( r,g,b, RGB_YELLOWISH ); - // draw the | bar - FillRGBA( x, y, iBarWidth, gHUD.m_iFontHeight, r, g, b, a ); - - x += iBarWidth + AmmoWidth / 2; - // GL Seems to need this ScaleColors( r, g, b, a ); - x = gHUD.DrawHudNumber( x, y, iFlags | DHN_3DIGITS, gWR.CountAmmo( pw->iAmmoType ), r, g, b ); + + // draw the | bar + SPR_Set( gHUD.GetSprite( m_HUD_stripe ), r, g, b ); + SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect( m_HUD_stripe ) ); + + // GL Seems to need this + x = gHUD.DrawHudNumber( x + StripeWidth + 16, y, iFlags | DHN_3DIGITS, gWR.CountAmmo( pw->iAmmoType ), r, g, b ); + x += 10; } else { // SPR_Draw a bullets only line - x = ScreenWidth - 4 * AmmoWidth - iIconWidth; + x = ScreenWidth - 4 * AmmoWidth - iIconWidth - 10; x = gHUD.DrawHudNumber( x, y, iFlags | DHN_3DIGITS, gWR.CountAmmo( pw->iAmmoType ), r, g, b ); + x += 10; } // Draw the ammo Icon + // int iOffset = ( m_pWeapon->rcAmmo.bottom - m_pWeapon->rcAmmo.top ) / 8; SPR_Set( m_pWeapon->hAmmo, r, g, b ); - SPR_DrawAdditive( 0, x + iIconWidth / 4, y, &m_pWeapon->rcAmmo ); + SPR_DrawAdditive( 0, x, y + 1, &m_pWeapon->rcAmmo ); } // Does weapon have seconday ammo? @@ -924,7 +923,8 @@ int CHudAmmo::Draw( float flTime ) // Draw the ammo Icon SPR_Set( m_pWeapon->hAmmo2, r, g, b ); - SPR_DrawAdditive( 0, x + iIconWidth / 4, y, &m_pWeapon->rcAmmo2 ); + int iOffset = ( m_pWeapon->rcAmmo2.bottom - m_pWeapon->rcAmmo2.top ) / 8; + SPR_DrawAdditive( 0, x, y - iOffset, &m_pWeapon->rcAmmo2 ); } } return 1; @@ -942,7 +942,7 @@ int DrawBar( int x, int y, int width, int height, float f ) if( f > 1 ) f = 1; - if( f ) + if( f > 0 ) { int w = f * width; @@ -954,18 +954,19 @@ int DrawBar( int x, int y, int width, int height, float f ) r = 255 - g; b = 0; - ScaleColors( r, g, b, min( gHUD.m_flAlpha, 255 ) ); + //ScaleColors( r, g, b, min( gHUD.m_flAlpha, 255 ) ); - FillRGBA( x, y, w, height, r, g, b, min( gHUD.m_flAlpha, 255 ) ); + FillRGBA( x, y, w, height, 255 - g, g, 0, 255 ); x += w; width -= w; } else { - UnpackRGB( r, g, b, RGB_YELLOWISH ); + r=g=b=f; +// UnpackRGB( r, g, b, RGB_YELLOWISH ); } - FillRGBA( x, y, width, height, r, g, b, min( gHUD.m_flAlpha, 128 ) ); + FillRGBA( x, y, width, height, r, g, b, 64 ); return( x + width ); } @@ -1003,87 +1004,53 @@ int CHudAmmo::DrawWList( float flTime ) { int r, g, b, x, y, a, i; - if( !gpActiveSel ) - return 0; - - int iActiveSlot; - - if( gpActiveSel == (WEAPON *)1 ) - iActiveSlot = -1; // current slot has no weapons - else - iActiveSlot = gpActiveSel->iSlot; - x = 10; //!!! y = 10; //!!! - // Ensure that there are available choices in the active slot - if( iActiveSlot > 0 ) - { - if( !gWR.GetFirstPos( iActiveSlot ) ) - { - gpActiveSel = (WEAPON *)1; - iActiveSlot = -1; - } - } - // Draw top line for( i = 0; i < MAX_WEAPON_SLOTS; i++ ) { - int iHeight; - UnpackRGB( r, g, b, RGB_YELLOWISH ); - if( iActiveSlot == i ) - a = min( gHUD.m_flAlpha, 255 ); - else - a = min( gHUD.m_flAlpha, 192 ); - - ScaleColors( r, g, b, min( gHUD.m_flAlpha, 128 ) ); // 255 + ScaleColors( r, g, b, 100 ); // 255 SPR_Set( gHUD.GetSprite( m_HUD_bucket0 + i ), r, g, b ); - - // make active slot wide enough to accomodate gun pictures - if( i == iActiveSlot ) - { - WEAPON *p = gWR.GetFirstPos( iActiveSlot ); - if( p ) - iHeight = p->rcActive.bottom - p->rcActive.top; - else - iHeight = giBucketWidth; - } - else - iHeight = giBucketHeight; - SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect( m_HUD_bucket0 + i ) ); - y += iHeight + 5; + y += giBucketHeight + 4; } - a = min(gHUD.m_flAlpha, 128); //!!! + if( !gpActiveSel ) + return 0; + + if( gpActiveSel != (WEAPON *)1 ) + { + if( gpActiveSel->iSlot > 0 && !gWR.GetFirstPos( gpActiveSel->iSlot ) ) + { + gpActiveSel = (WEAPON *)1; + } + } y = 10; // Draw all of the buckets for( i = 0; i < MAX_WEAPON_SLOTS; i++ ) { - x = giBucketWidth + 15; + x = giBucketWidth + 14; - WEAPON *p = gWR.GetFirstPos( i ); - int iHeight = giBucketHeight; - if( p ) - iHeight = p->rcActive.bottom - p->rcActive.top; + WEAPON *p; // = gWR.GetFirstPos( i ); for( int iPos = 0; iPos < MAX_WEAPON_POSITIONS; iPos++ ) { p = gWR.GetWeaponSlot( i, iPos ); if( !p || !p->iId ) - continue; + continue; - UnpackRGB( r, g, b, RGB_YELLOWISH ); + UnpackRGB( r, g, b, RGB_WHITEISH ); // if active, then we must have ammo. if( gpActiveSel == p ) { - ScaleColors( r, g, b, min( gHUD.m_flAlpha, 192 ) ); + ScaleColors( r, g, b, 192 ); SPR_Set( p->hActive, r, g, b ); SPR_DrawAdditive( 0, x, y, &p->rcActive ); @@ -1092,21 +1059,21 @@ int CHudAmmo::DrawWList( float flTime ) { // Draw Weapon if Red if no ammo if( gWR.HasAmmo( p ) ) - ScaleColors( r, g, b, min( gHUD.m_flAlpha, 192 ) ); + ScaleColors( r, g, b, 192 ); else - ScaleColors( r, g, b, min( gHUD.m_flAlpha, 64 ) ); + ScaleColors( r, g, b, 96 ); SPR_Set( p->hInactive, r, g, b ); SPR_DrawAdditive( 0, x, y, &p->rcInactive ); } // Draw Ammo Bar - DrawAmmoBar( p, x + giABWidth/2, y, giABWidth, giABHeight ); + DrawAmmoBar( p, x + 1, y + 1, giABWidth, giABHeight ); - x += p->rcActive.right - p->rcActive.left + 5; + x += p->rcActive.right - p->rcActive.left + 4; } - y += iHeight + 5; + y += giBucketHeight + 4; } return 1; diff --git a/cl_dll/ammo.h b/cl_dll/ammo.h index 9134681c..57c08805 100644 --- a/cl_dll/ammo.h +++ b/cl_dll/ammo.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef __AMMO_H__ #define __AMMO_H__ diff --git a/cl_dll/ammo_secondary.cpp b/cl_dll/ammo_secondary.cpp index 474c6869..954ff211 100644 --- a/cl_dll/ammo_secondary.cpp +++ b/cl_dll/ammo_secondary.cpp @@ -61,7 +61,7 @@ int CHudAmmoSecondary::Draw( float flTime ) // draw secondary ammo icons above normal ammo readout int a, x, y, r, g, b, AmmoWidth; UnpackRGB( r, g, b, RGB_YELLOWISH ); - a = (int) max( min( gHUD.m_flAlpha, MIN_ALPHA ), m_fFade ); + a = (int) max( MIN_ALPHA, m_fFade ); if( m_fFade > 0 ) m_fFade -= ( gHUD.m_flTimeDelta * 20 ); // slowly lower alpha to fade out icons ScaleColors( r, g, b, a ); diff --git a/cl_dll/ammohistory.cpp b/cl_dll/ammohistory.cpp index aea573d5..4b1e6745 100644 --- a/cl_dll/ammohistory.cpp +++ b/cl_dll/ammohistory.cpp @@ -139,8 +139,10 @@ int HistoryResource::DrawAmmoHistory( float flTime ) SPR_DrawAdditive( 0, xpos, ypos, &rcPic ); } - // Draw the number - gHUD.DrawHudNumberString( xpos - 10, ypos, xpos - 100, rgAmmoHistory[i].iCount, r, g, b ); + // do not draw black console string + if( !( ( hud_textmode->value == 2 ) && ( scale < 200 ) ) ) + // Draw the number + gHUD.DrawHudNumberString( xpos - 10, ypos, xpos - 100, rgAmmoHistory[i].iCount, r, g, b ); } else if( rgAmmoHistory[i].type == HISTSLOT_WEAP ) { @@ -156,7 +158,7 @@ int HistoryResource::DrawAmmoHistory( float flTime ) UnpackRGB( r, g, b, RGB_REDISH ); // if the weapon doesn't have ammo, display it as red float scale = ( rgAmmoHistory[i].DisplayTime - flTime ) * 80; - ScaleColors( r, g, b, min( gHUD.m_flAlpha, min( scale, 255 ) ) ); + ScaleColors( r, g, b, min( scale, 255 ) ); int ypos = ScreenHeight - ( AMMO_PICKUP_PICK_HEIGHT + ( AMMO_PICKUP_GAP * i ) ); int xpos = ScreenWidth - ( weap->rcInactive.right - weap->rcInactive.left ); @@ -174,7 +176,7 @@ int HistoryResource::DrawAmmoHistory( float flTime ) UnpackRGB( r, g, b, RGB_YELLOWISH ); float scale = ( rgAmmoHistory[i].DisplayTime - flTime ) * 80; - ScaleColors( r, g, b, min( gHUD.m_flAlpha, min( scale, 255 ) ) ); + ScaleColors( r, g, b, min( scale, 255 ) ); int ypos = ScreenHeight - ( AMMO_PICKUP_PICK_HEIGHT + ( AMMO_PICKUP_GAP * i ) ); int xpos = ScreenWidth - ( rect.right - rect.left ) - 10; diff --git a/cl_dll/ammohistory.h b/cl_dll/ammohistory.h index f1063ae1..44edc916 100644 --- a/cl_dll/ammohistory.h +++ b/cl_dll/ammohistory.h @@ -15,6 +15,9 @@ // // ammohistory.h // +#pragma once +#ifndef AMMOHISTORY_H +#define AMMOHISTORY_H // this is the max number of items in each bucket #define MAX_WEAPON_POSITIONS MAX_WEAPON_SLOTS @@ -137,3 +140,4 @@ public: }; extern HistoryResource gHR; +#endif // AMMOHISTORY_H diff --git a/cl_dll/camera.h b/cl_dll/camera.h index 448b22ca..1ecb9563 100644 --- a/cl_dll/camera.h +++ b/cl_dll/camera.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // @@ -7,7 +7,7 @@ // Camera.h -- defines and such for a 3rd person camera // NOTE: must include quakedef.h first - +#pragma once #ifndef _CAMERA_H_ #define _CAMERA_H_ diff --git a/cl_dll/cdll_int.cpp b/cl_dll/cdll_int.cpp index 3504b09c..ca380222 100644 --- a/cl_dll/cdll_int.cpp +++ b/cl_dll/cdll_int.cpp @@ -21,6 +21,13 @@ #include "hud.h" #include "cl_util.h" #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 +#include "VGUI_Panel.h" +#include "VGUI_App.h" +#endif extern "C" { @@ -32,14 +39,20 @@ extern "C" cl_enginefunc_t gEngfuncs; CHud gHUD; mobile_engfuncs_t *gMobileEngfuncs = NULL; + +extern "C" int g_bhopcap; void InitInput( void ); void EV_HookEvents( void ); void IN_Commands( void ); -extern cvar_t *cl_upspeed; -extern cvar_t *cl_forwardspeed; -extern cvar_t *cl_backspeed; -extern cvar_t *cl_sidespeed; +int __MsgFunc_Bhopcap( const char *pszName, int iSize, void *pbuf ) +{ + BEGIN_READ( pbuf, iSize ); + + g_bhopcap = READ_BYTE(); + + return 1; +} /* ========================== @@ -81,18 +94,18 @@ int DLLEXPORT HUD_GetHullBounds( int hullnumber, float *mins, float *maxs ) switch( hullnumber ) { case 0: // Normal player - mins = Vector( -16, -16, -36 ); - maxs = Vector( 16, 16, 36 ); + Vector( -16, -16, -36 ).CopyToArray(mins); + Vector( 16, 16, 36 ).CopyToArray(maxs); iret = 1; break; case 1: // Crouched player - mins = Vector( -16, -16, -18 ); - maxs = Vector( 16, 16, 18 ); + Vector( -16, -16, -18 ).CopyToArray(mins); + Vector( 16, 16, 18 ).CopyToArray(maxs); iret = 1; break; case 2: // Point based hull - mins = Vector( 0, 0, 0 ); - maxs = Vector( 0, 0, 0 ); + Vector( 0, 0, 0 ).CopyToArray(mins); + Vector( 0, 0, 0 ).CopyToArray(maxs); iret = 1; break; } @@ -170,6 +183,46 @@ int *HUD_GetRect( void ) return extent; } +#ifdef USE_VGUI_FOR_GOLDSOURCE_SUPPORT +class TeamFortressViewport : public vgui::Panel +{ +public: + TeamFortressViewport(int x,int y,int wide,int tall); + void Initialize( void ); + + virtual void paintBackground(); + void *operator new( size_t stAllocateBlock ); +}; + +static TeamFortressViewport* gViewPort = NULL; + +TeamFortressViewport::TeamFortressViewport(int x, int y, int wide, int tall) : Panel(x, y, wide, tall) +{ + gViewPort = this; + Initialize(); +} + +void TeamFortressViewport::Initialize() +{ + //vgui::App::getInstance()->setCursorOveride( vgui::App::getInstance()->getScheme()->getCursor(vgui::Scheme::scu_none) ); +} + +void TeamFortressViewport::paintBackground() +{ +// int wide, tall; +// getParent()->getSize( wide, tall ); +// setSize( wide, tall ); + gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect()); +} + +void *TeamFortressViewport::operator new( size_t stAllocateBlock ) +{ + void *mem = ::operator new( stAllocateBlock ); + memset( mem, 0, stAllocateBlock ); + return mem; +} +#endif + /* ========================== HUD_VidInit @@ -184,14 +237,25 @@ int DLLEXPORT HUD_VidInit( void ) { gHUD.VidInit(); - // - // Fixup player speed. - // - cl_upspeed->value = - cl_forwardspeed->value = - cl_backspeed->value = - cl_sidespeed->value = 200; +#ifdef USE_VGUI_FOR_GOLDSOURCE_SUPPORT + vgui::Panel* root=(vgui::Panel*)gEngfuncs.VGui_GetPanel(); + if (root) { + gEngfuncs.Con_Printf( "Root VGUI panel exists\n" ); + root->setBgColor(128,128,0,0); + if (gViewPort != NULL) + { + gViewPort->Initialize(); + } + else + { + gViewPort = new TeamFortressViewport(0,0,root->getWide(),root->getTall()); + gViewPort->setParent(root); + } + } else { + gEngfuncs.Con_Printf( "Root VGUI panel does not exist\n" ); + } +#endif return 1; } @@ -209,6 +273,8 @@ void DLLEXPORT HUD_Init( void ) { InitInput(); gHUD.Init(); + + gEngfuncs.pfnHookUserMsg( "Bhopcap", __MsgFunc_Bhopcap ); } /* @@ -269,7 +335,13 @@ Called by engine every frame that client .dll is loaded */ void DLLEXPORT HUD_Frame( double time ) -{ gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect()); +{ +#ifdef USE_VGUI_FOR_GOLDSOURCE_SUPPORT + if (!gViewPort) + gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect()); +#else + gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect()); +#endif } /* @@ -304,3 +376,23 @@ void DLLEXPORT HUD_MobilityInterface( mobile_engfuncs_t *gpMobileEngfuncs ) return; gMobileEngfuncs = gpMobileEngfuncs; } + +bool HUD_MessageBox( const char *msg ) +{ + gEngfuncs.Con_Printf( msg ); // just in case + + if( IsXashFWGS() ) + { + gMobileEngfuncs->pfnSys_Warn( msg ); + return true; + } + + // TODO: Load SDL2 and call ShowSimpleMessageBox + + return false; +} + +bool IsXashFWGS() +{ + return gMobileEngfuncs != NULL; +} diff --git a/cl_dll/cl_dll.dsp b/cl_dll/cl_dll.dsp index 6864326b..17beb9ae 100644 --- a/cl_dll/cl_dll.dsp +++ b/cl_dll/cl_dll.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # 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 /MT /W3 /GX /O2 /I "..\utils\vgui\include" /I "..\engine" /I "..\common" /I "..\pm_shared" /I "..\dlls" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "CLIENT_DLL" /D "CLIENT_WEAPONS" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\utils\false_vgui\include" /I "..\engine" /I "..\common" /I "..\pm_shared" /I "..\dlls" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "CLIENT_DLL" /D "CLIENT_WEAPONS" /YX /FD /c # SUBTRACT CPP /Z # ADD BASE MTL /nologo /D "NDEBUG" /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 @@ -80,7 +80,7 @@ SOURCE="$(InputPath)" # PROP Ignore_Export_Lib 0 # 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 /GR /GX /ZI /Od /I "..\dlls" /I "..\common" /I "..\pm_shared" /I "..\engine" /I "..\utils\vgui\include" /I "..\game_shared" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "CLIENT_DLL" /D "CLIENT_WEAPONS" /FR /YX /FD /c +# ADD CPP /nologo /G5 /MTd /W3 /Gm /GR /GX /ZI /Od /I "..\dlls" /I "..\common" /I "..\pm_shared" /I "..\engine" /I "..\utils\false_vgui\include" /I "..\game_shared" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "CLIENT_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" @@ -300,7 +300,15 @@ SOURCE=.\input.cpp # End Source File # Begin Source File -SOURCE=.\inputw32.cpp +SOURCE=.\input_goldsource.cpp +# End Source File +# Begin Source File + +SOURCE=.\input_mouse.cpp +# End Source File +# Begin Source File + +SOURCE=.\input_xash3d.cpp # End Source File # Begin Source File @@ -513,6 +521,10 @@ SOURCE=.\in_defs.h # End Source File # Begin Source File +SOURCE=.\input_mouse.h +# End Source File +# Begin Source File + SOURCE=..\common\itrackeruser.h # End Source File # Begin Source File diff --git a/cl_dll/cl_dll.h b/cl_dll/cl_dll.h index fda4b812..6e1c4e69 100644 --- a/cl_dll/cl_dll.h +++ b/cl_dll/cl_dll.h @@ -25,6 +25,9 @@ // - Drawing the HUD graphics every frame // - Handling the custum HUD-update packets // +#pragma once +#ifndef CL_DLL_H +#define CL_DLL_H typedef unsigned char byte; typedef unsigned short word; typedef float vec_t; @@ -41,6 +44,11 @@ typedef int ( *pfnUserMsgHook )( const char *pszName, int iSize, void *pbuf ); #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 +#endif + extern cl_enginefunc_t gEngfuncs; #include "../engine/mobility_int.h" extern mobile_engfuncs_t *gMobileEngfuncs; +#endif diff --git a/cl_dll/cl_util.h b/cl_dll/cl_util.h index 84488050..0cb65f32 100644 --- a/cl_dll/cl_util.h +++ b/cl_dll/cl_util.h @@ -15,7 +15,8 @@ // // cl_util.h // - +#ifndef CL_UTIL_H +#define CL_UTIL_H #include "exportdef.h" #include "cvardef.h" @@ -94,8 +95,12 @@ inline void DrawSetTextColor( float r, float g, float b ) inline int SPR_Height( HSPRITE x, int f ) { return gEngfuncs.pfnSPR_Height(x, f); } inline int SPR_Width( HSPRITE x, int f ) { return gEngfuncs.pfnSPR_Width(x, f); } -inline client_textmessage_t *TextMessageGet( const char *pName ) { return gEngfuncs.pfnTextMessageGet( pName ); } -inline int TextMessageDrawChar( int x, int y, int number, int r, int g, int b ) +inline client_textmessage_t *TextMessageGet( const char *pName ) +{ + return gEngfuncs.pfnTextMessageGet( pName ); +} + +inline int TextMessageDrawChar( int x, int y, int number, int r, int g, int b ) { return gEngfuncs.pfnDrawCharacter( x, y, number, r, g, b ); } @@ -115,6 +120,8 @@ inline void GetConsoleStringSize( const char *string, int *width, int *height ) gEngfuncs.pfnDrawConsoleStringLen( (char*)string, width, height ); } +int DrawUtfString( int xpos, int ypos, int iMaxX, const char *szIt, int r, int g, int b ); + inline int ConsoleStringLen( const char *string ) { int _width = 0, _height = 0; @@ -138,7 +145,7 @@ inline void CenterPrint( const char *string ) #define GetPlayerInfo ( *gEngfuncs.pfnGetPlayerInfo ) // sound functions -inline void PlaySound( char *szSound, float vol ) { gEngfuncs.pfnPlaySoundByName( szSound, vol ); } +inline void PlaySound( const char *szSound, float vol ) { gEngfuncs.pfnPlaySoundByName( szSound, vol ); } inline void PlaySound( int iSound, float vol ) { gEngfuncs.pfnPlaySoundByIndex( iSound, vol ); } #define max(a, b) (((a) > (b)) ? (a) : (b)) @@ -173,3 +180,7 @@ inline void UnpackRGB( int &r, int &g, int &b, unsigned long ulRGB )\ } HSPRITE LoadSprite( const char *pszName ); + +bool HUD_MessageBox( const char *msg ); +bool IsXashFWGS(); +#endif diff --git a/cl_dll/com_weapons.cpp b/cl_dll/com_weapons.cpp index 4f539df9..5621149b 100644 --- a/cl_dll/com_weapons.cpp +++ b/cl_dll/com_weapons.cpp @@ -41,12 +41,12 @@ COM_Log Log debug messages to file ( appends ) ==================== */ -void COM_Log( char *pszFile, char *fmt, ... ) +void COM_Log( const char *pszFile, const char *fmt, ... ) { va_list argptr; char string[1024]; FILE *fp; - char *pfilename; + const char *pfilename; if( !pszFile ) { @@ -111,7 +111,7 @@ HUD_PlaySound Play a sound, if we are seeing this command for the first time ===================== */ -void HUD_PlaySound( char *sound, float volume ) +void HUD_PlaySound( const char *sound, float volume ) { if( !g_runfuncs || !g_finalstate ) return; @@ -268,12 +268,12 @@ stub functions for such things as precaching. So we don't have to modify weapon is compiled into both game and client .dlls. ====================== */ -int stub_PrecacheModel( char* s ) +int stub_PrecacheModel( const char* s ) { return 0; } -int stub_PrecacheSound( char* s ) +int stub_PrecacheSound( const char* s ) { return 0; } @@ -283,7 +283,7 @@ unsigned short stub_PrecacheEvent( int type, const char *s ) return 0; } -const char *stub_NameForFunction( unsigned long function ) +const char *stub_NameForFunction( void *function ) { return "func"; } diff --git a/cl_dll/com_weapons.h b/cl_dll/com_weapons.h index 7e1fdd77..efe06ad6 100644 --- a/cl_dll/com_weapons.h +++ b/cl_dll/com_weapons.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // @@ -7,11 +7,9 @@ // com_weapons.h // Shared weapons common function prototypes +#pragma once #if !defined( COM_WEAPONSH ) #define COM_WEAPONSH -#ifdef _WIN32 -#pragma once -#endif #include "hud_iface.h" @@ -20,7 +18,7 @@ extern "C" void _DLLEXPORT HUD_PostRunCmd( struct local_state_s *from, struct local_state_s *to, struct usercmd_s *cmd, int runfuncs, double time, unsigned int random_seed ); } -void COM_Log( char *pszFile, char *fmt, ... ); +void COM_Log( const char *pszFile, const char *fmt, ... ); int CL_IsDead( void ); float UTIL_SharedRandomFloat( unsigned int seed, float low, float high ); @@ -28,13 +26,13 @@ int UTIL_SharedRandomLong( unsigned int seed, int low, int high ); int HUD_GetWeaponAnim( void ); void HUD_SendWeaponAnim( int iAnim, int body, int force ); -void HUD_PlaySound( char *sound, float volume ); +void HUD_PlaySound( const char *sound, float volume ); void HUD_PlaybackEvent( int flags, const struct edict_s *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); void HUD_SetMaxSpeed( const struct edict_s *ed, float speed ); -int stub_PrecacheModel( char* s ); -int stub_PrecacheSound( char* s ); +int stub_PrecacheModel( const char* s ); +int stub_PrecacheSound( const char* s ); unsigned short stub_PrecacheEvent( int type, const char *s ); -const char *stub_NameForFunction( unsigned long function ); +const char *stub_NameForFunction( void *function ); void stub_SetModel( struct edict_s *e, const char *m ); extern cvar_t *cl_lw; diff --git a/cl_dll/compile.bat b/cl_dll/compile.bat new file mode 100644 index 00000000..9270d4bc --- /dev/null +++ b/cl_dll/compile.bat @@ -0,0 +1,84 @@ +@echo off +echo Setting environment for minimal Visual C++ 6 +set INCLUDE=%MSVCDir%\VC98\Include +set LIB=%MSVCDir%\VC98\Lib +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 SOURCES=../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^ + ev_hldm.cpp^ + hl/hl_baseentity.cpp^ + hl/hl_events.cpp^ + hl/hl_objects.cpp^ + hl/hl_weapons.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^ + ../pm_shared/pm_debug.c^ + ../pm_shared/pm_math.c^ + ../pm_shared/pm_shared.c^ + 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 +set DEFINES=/DCLIENT_DLL /DCLIENT_WEAPONS /Dsnprintf=_snprintf /DNO_VOICEGAMEMGR /DGOLDSOURCE_SUPPORT +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% + +echo -- Compile done. Cleaning... + +del *.obj *.exp *.lib *.ilk +echo -- Done. diff --git a/cl_dll/death.cpp b/cl_dll/death.cpp index 455dfd36..579fc255 100644 --- a/cl_dll/death.cpp +++ b/cl_dll/death.cpp @@ -187,7 +187,8 @@ int CHudDeathNotice::MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbu gHUD.m_Scoreboard.GetAllPlayersInfo(); // Get the Killer's name - char *killer_name = g_PlayerInfoList[killer].name; + const char *killer_name = ""; + killer_name = g_PlayerInfoList[killer].name; if( !killer_name ) { killer_name = ""; @@ -201,11 +202,11 @@ int CHudDeathNotice::MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbu } // Get the Victim's name - char *victim_name = NULL; + const char *victim_name = ""; // If victim is -1, the killer killed a specific, non-player object (like a sentrygun) - if ( ( (char)victim ) != -1 ) + if( ( (char)victim ) != -1 ) victim_name = g_PlayerInfoList[victim].name; - if ( !victim_name ) + if( !victim_name ) { victim_name = ""; rgDeathNoticeList[i].szVictim[0] = 0; @@ -218,7 +219,7 @@ int CHudDeathNotice::MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbu } // Is it a non-player object kill? - if ( ( (char)victim ) == -1 ) + if( ( (char)victim ) == -1 ) { rgDeathNoticeList[i].iNonPlayerKill = TRUE; @@ -227,10 +228,10 @@ int CHudDeathNotice::MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbu } else { - if ( killer == victim || killer == 0 ) + if( killer == victim || killer == 0 ) rgDeathNoticeList[i].iSuicide = TRUE; - if ( !strcmp( killedwith, "d_teammate" ) ) + if( !strcmp( killedwith, "d_teammate" ) ) rgDeathNoticeList[i].iTeamKill = TRUE; } @@ -285,7 +286,7 @@ int CHudDeathNotice::MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbu // replace the code names with the 'real' names if( !strcmp( killedwith + 2, "egon" ) ) strcpy( killedwith, "d_gluon gun" ); - if ( !strcmp( killedwith + 2, "gauss" ) ) + if( !strcmp( killedwith + 2, "gauss" ) ) strcpy( killedwith, "d_tau cannon" ); ConsolePrint( killedwith + 2 ); // skip over the "d_" part diff --git a/cl_dll/demo.h b/cl_dll/demo.h index a0a1b30e..3aaa3f21 100644 --- a/cl_dll/demo.h +++ b/cl_dll/demo.h @@ -1,13 +1,13 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // // $NoKeywords: $ //============================================================================= +#pragma once #if !defined( DEMOH ) #define DEMOH -#pragma once // Types of demo messages we can write/parse enum diff --git a/cl_dll/entity.cpp b/cl_dll/entity.cpp index 07bd0ff3..5c0bc4ec 100644 --- a/cl_dll/entity.cpp +++ b/cl_dll/entity.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // @@ -22,6 +22,7 @@ void Game_AddObjects( void ); +bool bDrawScope; extern vec3_t v_origin; int g_iAlive = 1; @@ -95,6 +96,7 @@ void DLLEXPORT HUD_TxferLocalOverrides( struct entity_state_s *state, const stru // Fire prevention state->iuser4 = client->iuser4; + bDrawScope = client->iuser4; } /* @@ -213,6 +215,7 @@ void DLLEXPORT HUD_TxferPredictionData( struct entity_state_s *ps, const struct // Fire prevention pcd->iuser4 = ppcd->iuser4; + bDrawScope = ppcd->iuser4; pcd->fuser2 = ppcd->fuser2; pcd->fuser3 = ppcd->fuser3; @@ -585,10 +588,10 @@ void DLLEXPORT HUD_TempEntUpdate ( static int gTempEntFrame = 0; int i; TEMPENTITY *pTemp, *pnext, *pprev; - float freq, gravity, gravitySlow, life, fastFreq; + float /*freq,*/ gravity, gravitySlow, life, fastFreq; // Nothing to simulate - if ( !*ppTempEntActive ) + if( !*ppTempEntActive ) return; // in order to have tents collide with players, we have to run the player prediction code so @@ -601,7 +604,7 @@ void DLLEXPORT HUD_TempEntUpdate ( gEngfuncs.pEventAPI->EV_PushPMStates(); // Now add in all of the players. - gEngfuncs.pEventAPI->EV_SetSolidPlayers( -1 ); + gEngfuncs.pEventAPI->EV_SetSolidPlayers( -1 ); // !!!BUGBUG -- This needs to be time based gTempEntFrame = ( gTempEntFrame + 1 ) & 31; @@ -623,7 +626,7 @@ void DLLEXPORT HUD_TempEntUpdate ( } pprev = NULL; - freq = client_time * 0.01; + //freq = client_time * 0.01; fastFreq = client_time * 5.5; gravity = -frametime * cl_gravity; gravitySlow = gravity * 0.5; @@ -709,12 +712,12 @@ void DLLEXPORT HUD_TempEntUpdate ( } else if( pTemp->flags & FTENT_SPIRAL ) { - float s, c; + /*float s, c; s = sin( pTemp->entity.baseline.origin[2] + fastFreq ); - c = cos( 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 + (int)(size_t)pTemp ); - pTemp->entity.origin[1] += pTemp->entity.baseline.origin[1] * frametime + 4 * sin( client_time * 30 + (int)(size_t)pTemp ); + 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; } else diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index 6e7f9b19..fdd31f33 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -38,7 +38,7 @@ extern engine_studio_api_t IEngineStudio; -static int tracerCount[32]; +static int g_tracerCount[32]; extern "C" char PM_FindTextureType( char *name ); @@ -50,34 +50,13 @@ extern cvar_t *cl_lw; extern "C" { // HLDM -void EV_FireGlock1( struct event_args_s *args ); -void EV_FireGlock2( struct event_args_s *args ); +//void EV_FireGlock1( struct event_args_s *args ); +//void EV_FireGlock2( struct event_args_s *args ); void EV_FireShotGunSingle( struct event_args_s *args ); -void EV_FireShotGunDouble( struct event_args_s *args ); -void EV_FireMP5( struct event_args_s *args ); -void EV_FireMP52( struct event_args_s *args ); -void EV_FirePython( struct event_args_s *args ); -void EV_FireGauss( struct event_args_s *args ); -void EV_SpinGauss( struct event_args_s *args ); -void EV_Crowbar( struct event_args_s *args ); -void EV_FireCrossbow( struct event_args_s *args ); -void EV_FireCrossbow2( struct event_args_s *args ); -void EV_FireRpg( struct event_args_s *args ); -void EV_EgonFire( struct event_args_s *args ); -void EV_EgonStop( struct event_args_s *args ); -void EV_HornetGunFire( struct event_args_s *args ); -void EV_TripmineFire( struct event_args_s *args ); -void EV_SnarkFire( struct event_args_s *args ); void EV_TrainPitchAdjust( struct event_args_s *args ); -void EV_HeaterPipe(struct event_args_s *args); -void EV_FireBradnailer(struct event_args_s *args); -void EV_FireNailgun(struct event_args_s *args); -void EV_FireCmlwbr(struct event_args_s *args); void EV_SpinXS(struct event_args_s *args); -void EV_FireXS(struct event_args_s *args); -void EV_Reload(struct event_args_s *args); void EV_FirePar21(struct event_args_s *args); void EV_M203(struct event_args_s *args); } @@ -104,7 +83,7 @@ float EV_HLDM_PlayTextureSound( int idx, pmtrace_t *ptr, float *vecSrc, float *v char chTextureType = CHAR_TEX_CONCRETE; float fvol; float fvolbar; - char *rgsz[4]; + const char *rgsz[4]; int cnt; float fattn = ATTN_NORM; int entity; @@ -233,16 +212,8 @@ float EV_HLDM_PlayTextureSound( int idx, pmtrace_t *ptr, float *vecSrc, float *v return 0.0; // crowbar already makes this sound fvol = 1.0; fvolbar = 0.2; - if( iBulletType == BULLET_PLAYER_NAIL ) - { - rgsz[0] = "weapons/brad_hit1.wav"; - rgsz[1] = "weapons/brad_hit2.wav"; - } - else - { - rgsz[0] = "weapons/bullet_hit1.wav"; - rgsz[1] = "weapons/bullet_hit2.wav"; - } + rgsz[0] = "weapons/bullet_hit1.wav"; + rgsz[1] = "weapons/bullet_hit2.wav"; fattn = 1.0; cnt = 2; break; @@ -334,12 +305,12 @@ void EV_HLDM_GunshotDecalTrace( pmtrace_t *pTrace, char *decalName ) TEMPENTITY* pSmoke = gEngfuncs.pEfxAPI->R_TempSprite( position, // position velocity, // velocity - gEngfuncs.pfnRandomFloat( 30, 35 ) / 100, // scale + gEngfuncs.pfnRandomFloat( 0.3f, 0.5f ), // scale modelindex, // model index kRenderNormal, // rendermode kRenderFxNoDissipation, // renderfx - gEngfuncs.pfnRandomFloat( 0.25, 0.5 ), // alpha - 0.01, // life + 0.5, // alpha + 0.3, // life FTENT_SPRCYCLE | FTENT_FADEOUT ); // flags if( pSmoke ) @@ -348,7 +319,7 @@ void EV_HLDM_GunshotDecalTrace( pmtrace_t *pTrace, char *decalName ) VectorAngles( velocity, angles ); pSmoke->flags |= FTENT_CLIENTCUSTOM; - pSmoke->entity.curstate.framerate = 4; + pSmoke->entity.curstate.framerate = 30; pSmoke->entity.baseline.vuser1 = angles; pSmoke->callback = EV_WallPuffCallback; } @@ -372,8 +343,6 @@ void EV_HLDM_DecalGunshot( pmtrace_t *pTrace, int iBulletType ) case BULLET_MONSTER_MP5: case BULLET_PLAYER_BUCKSHOT: case BULLET_PLAYER_357: - //case BULLET_PLAYER_NAIL: - case BULLET_PLAYER_PAR21: default: // smoke and decal EV_HLDM_GunshotDecalTrace( pTrace, EV_HLDM_DamageDecal( pe ) ); @@ -413,8 +382,6 @@ int EV_HLDM_CheckTracer( int idx, float *vecSrc, float *end, float *forward, flo switch( iBulletType ) { case BULLET_PLAYER_MP5: - case BULLET_PLAYER_NAIL: - case BULLET_PLAYER_PAR21: case BULLET_MONSTER_MP5: case BULLET_MONSTER_9MM: case BULLET_MONSTER_12MM: @@ -446,28 +413,16 @@ void EV_HLDM_FireBullets( int idx, float *forward, float *right, float *up, int vec3_t vecDir, vecEnd; float x, y, z; - //We randomize for the Shotgun. - if( iBulletType == BULLET_PLAYER_BUCKSHOT ) - { - do{ - x = gEngfuncs.pfnRandomFloat( -0.5, 0.5 ) + gEngfuncs.pfnRandomFloat( -0.5, 0.5 ); - y = gEngfuncs.pfnRandomFloat( -0.5, 0.5 ) + gEngfuncs.pfnRandomFloat( -0.5, 0.5 ); - z = x * x + y * y; - }while( z > 1 ); + do{ + x = gEngfuncs.pfnRandomFloat( -0.5, 0.5 ) + gEngfuncs.pfnRandomFloat( -0.5, 0.5 ); + y = gEngfuncs.pfnRandomFloat( -0.5, 0.5 ) + gEngfuncs.pfnRandomFloat( -0.5, 0.5 ); + z = x * x + y * y; + }while( z > 1 ); - for( i = 0 ; i < 3; i++ ) - { - vecDir[i] = vecDirShooting[i] + x * flSpreadX * right[i] + y * flSpreadY * up [i]; - vecEnd[i] = vecSrc[i] + flDistance * vecDir[i]; - } - }//But other guns already have their spread randomized in the synched spread. - else + for( i = 0 ; i < 3; i++ ) { - for( i = 0 ; i < 3; i++ ) - { - vecDir[i] = vecDirShooting[i] + flSpreadX * right[i] + flSpreadY * up [i]; - vecEnd[i] = vecSrc[i] + flDistance * vecDir[i]; - } + vecDir[i] = vecDirShooting[i] + x * flSpreadX * right[i] + y * flSpreadY * up [i]; + vecEnd[i] = vecSrc[i] + flDistance * vecDir[i]; } gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction( false, true ); @@ -507,20 +462,6 @@ void EV_HLDM_FireBullets( int idx, float *forward, float *right, float *up, int EV_HLDM_PlayTextureSound( idx, &tr, vecSrc, vecEnd, iBulletType ); EV_HLDM_DecalGunshot( &tr, iBulletType ); break; - case BULLET_PLAYER_NAIL: - if( !tracer ) - { - EV_HLDM_PlayTextureSound( idx, &tr, vecSrc, vecEnd, iBulletType ); - // EV_HLDM_DecalGunshot( &tr, iBulletType ); - } - break; - case BULLET_PLAYER_PAR21: - if( !tracer ) - { - EV_HLDM_PlayTextureSound( idx, &tr, vecSrc, vecEnd, iBulletType ); - EV_HLDM_DecalGunshot( &tr, iBulletType ); - } - break; } } @@ -531,7 +472,7 @@ void EV_HLDM_FireBullets( int idx, float *forward, float *right, float *up, int //====================== // GLOCK START //====================== -void EV_FireGlock1( event_args_t *args ) +/*void EV_FireGlock1( event_args_t *args ) { int idx; vec3_t origin; @@ -594,16 +535,17 @@ void EV_FireGlock2( event_args_t *args ) 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 + 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( GLOCK_SHOOT, 2 ); + gEngfuncs.pEventAPI->EV_WeaponAnimation( empty ? GLOCK_SHOOT_EMPTY : GLOCK_SHOOT, 2 ); V_PunchAxis( 0, -2.0 ); } @@ -618,8 +560,8 @@ void EV_FireGlock2( event_args_t *args ) VectorCopy( forward, vecAiming ); - EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_9MM, 0, &tracerCount[idx - 1], 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 ); +}*/ //====================== // GLOCK END //====================== @@ -627,10 +569,6 @@ void EV_FireGlock2( event_args_t *args ) //====================== // SHOTGUN START //====================== -void EV_FireShotGunDouble( event_args_t *args ) -{ -} - void EV_FireShotGunSingle( event_args_t *args ) { int idx; @@ -644,7 +582,7 @@ void EV_FireShotGunSingle( event_args_t *args ) vec3_t vecSrc, vecAiming; vec3_t vecSpread; vec3_t up, right, forward; - float flSpread = 0.01; + //float flSpread = 0.01; idx = args->entindex; VectorCopy( args->origin, origin ); @@ -661,7 +599,7 @@ void EV_FireShotGunSingle( event_args_t *args ) EV_MuzzleFlash(); gEngfuncs.pEventAPI->EV_WeaponAnimation( SHOTGUN_FIRE, 2 ); - V_PunchAxis( 0, -5.0 ); + V_PunchAxis( 0, -15.0 ); } EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 32, -12, 6 ); @@ -673,1034 +611,14 @@ void EV_FireShotGunSingle( event_args_t *args ) EV_GetGunPosition( args, vecSrc, origin ); VectorCopy( forward, vecAiming ); - if( gEngfuncs.GetMaxClients() > 1 ) - { - EV_HLDM_FireBullets( idx, forward, right, up, 4, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &tracerCount[idx - 1], 0.08716, 0.04362 ); - } - else - { - EV_HLDM_FireBullets( idx, forward, right, up, 6, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &tracerCount[idx - 1], 0.08716, 0.08716 ); - } + EV_HLDM_FireBullets( idx, forward, right, up, 12, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &g_tracerCount[idx - 1], 0.08716, 0.08716 ); } //====================== // SHOTGUN END //====================== -//====================== -// MP5 START -//====================== -void EV_FireMP5( 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 up, right, forward; - float flSpread = 0.01; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - VectorCopy( args->angles, angles ); - VectorCopy( args->velocity, velocity ); - - 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( MP5_FIRE1 + gEngfuncs.pfnRandomLong( 0, 2 ), 2 ); - - V_PunchAxis( 0, gEngfuncs.pfnRandomFloat( -2, 2 ) ); - } - - EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 20, -12, 4 ); - - EV_EjectBrass ( ShellOrigin, ShellVelocity, angles[YAW], shell, TE_BOUNCE_SHELL ); - - switch( gEngfuncs.pfnRandomLong( 0, 1 ) ) - { - case 0: - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/hks1.wav", 1, ATTN_NORM, 0, 94 + gEngfuncs.pfnRandomLong( 0, 0xf ) ); - break; - case 1: - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/hks2.wav", 1, ATTN_NORM, 0, 94 + gEngfuncs.pfnRandomLong( 0, 0xf ) ); - break; - } - - 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, &tracerCount[idx - 1], args->fparam1, args->fparam2 ); - } - else - { - EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_MP5, 2, &tracerCount[idx - 1], args->fparam1, args->fparam2 ); - } -} - -// We only predict the animation and sound -// The grenade is still launched from the server. -void EV_FireMP52( event_args_t *args ) -{ - int idx; - vec3_t origin; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - - if( EV_IsLocal( idx ) ) - { - gEngfuncs.pEventAPI->EV_WeaponAnimation( MP5_LAUNCH, 2 ); - V_PunchAxis( 0, -10 ); - } - - switch( gEngfuncs.pfnRandomLong( 0, 1 ) ) - { - case 0: - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/glauncher.wav", 1, ATTN_NORM, 0, 94 + gEngfuncs.pfnRandomLong( 0, 0xf ) ); - break; - case 1: - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/glauncher2.wav", 1, ATTN_NORM, 0, 94 + gEngfuncs.pfnRandomLong( 0, 0xf ) ); - break; - } -} -//====================== -// MP5 END -//====================== - -//====================== -// PHYTON START -// ( .357 ) -//====================== -void EV_FirePython( event_args_t *args ) -{ - int idx; - vec3_t origin; - vec3_t angles; - vec3_t velocity; - - vec3_t vecSrc, vecAiming; - vec3_t up, right, forward; - float flSpread = 0.01; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - VectorCopy( args->angles, angles ); - VectorCopy( args->velocity, velocity ); - - AngleVectors( angles, forward, right, up ); - - if( EV_IsLocal( idx ) ) - { - // Python uses different body in multiplayer versus single player - int multiplayer = gEngfuncs.GetMaxClients() == 1 ? 0 : 1; - - // Add muzzle flash to current weapon model - EV_MuzzleFlash(); - gEngfuncs.pEventAPI->EV_WeaponAnimation( PYTHON_FIRE1, multiplayer ? 1 : 0 ); - - V_PunchAxis( 0, -10.0 ); - } - - switch( gEngfuncs.pfnRandomLong( 0, 1 ) ) - { - case 0: - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/357_shot1.wav", gEngfuncs.pfnRandomFloat( 0.8, 0.9 ), ATTN_NORM, 0, PITCH_NORM ); - break; - case 1: - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/357_shot2.wav", gEngfuncs.pfnRandomFloat( 0.8, 0.9 ), ATTN_NORM, 0, PITCH_NORM ); - break; - } - - EV_GetGunPosition( args, vecSrc, origin ); - - VectorCopy( forward, vecAiming ); - - EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_357, 0, 0, args->fparam1, args->fparam2 ); -} -//====================== -// PHYTON END -// ( .357 ) -//====================== - -//====================== -// GAUSS START -//====================== #define SND_CHANGE_PITCH (1 << 7) // duplicated in protocol.h change sound pitch -void EV_SpinGauss( event_args_t *args ) -{ - int idx; - vec3_t origin; - vec3_t angles; - vec3_t velocity; - int iSoundState = 0; - - int pitch; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - VectorCopy( args->angles, angles ); - VectorCopy( args->velocity, velocity ); - - pitch = args->iparam1; - - iSoundState = args->bparam1 ? SND_CHANGE_PITCH : 0; - - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "ambience/pulsemachine.wav", 1.0, ATTN_NORM, iSoundState, pitch ); -} - -/* -============================== -EV_StopPreviousGauss - -============================== -*/ -void EV_StopPreviousGauss( int idx ) -{ - // Make sure we don't have a gauss spin event in the queue for this guy - gEngfuncs.pEventAPI->EV_KillEvents( idx, "events/gaussspin.sc" ); - gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_WEAPON, "ambience/pulsemachine.wav" ); -} - -extern float g_flApplyVel; - -void EV_FireGauss( event_args_t *args ) -{ - int idx; - vec3_t origin; - vec3_t angles; - vec3_t velocity; - float flDamage = args->fparam1; - int primaryfire = args->bparam1; - - int m_fPrimaryFire = args->bparam1; - int m_iWeaponVolume = GAUSS_PRIMARY_FIRE_VOLUME; - vec3_t vecSrc; - vec3_t vecDest; - edict_t *pentIgnore; - pmtrace_t tr, beam_tr; - float flMaxFrac = 1.0; - int nTotal = 0; - int fHasPunched = 0; - int fFirstBeam = 1; - int nMaxHits = 10; - physent_t *pEntity; - int m_iBeam, m_iGlow, m_iBalls; - vec3_t up, right, forward; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - VectorCopy( args->angles, angles ); - VectorCopy( args->velocity, velocity ); - - if( args->bparam2 ) - { - EV_StopPreviousGauss( idx ); - return; - } - - //Con_Printf( "Firing gauss with %f\n", flDamage ); - EV_GetGunPosition( args, vecSrc, origin ); - - m_iBeam = gEngfuncs.pEventAPI->EV_FindModelIndex( "sprites/smoke.spr" ); - m_iBalls = m_iGlow = gEngfuncs.pEventAPI->EV_FindModelIndex( "sprites/hotglow.spr" ); - - AngleVectors( angles, forward, right, up ); - - VectorMA( vecSrc, 8192, forward, vecDest ); - - if( EV_IsLocal( idx ) ) - { - V_PunchAxis( 0, -2.0 ); - gEngfuncs.pEventAPI->EV_WeaponAnimation( GAUSS_FIRE2, 2 ); - - 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 ) ); - - while( flDamage > 10 && nMaxHits > 0 ) - { - nMaxHits--; - - gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction( false, true ); - - // Store off the old count - gEngfuncs.pEventAPI->EV_PushPMStates(); - - // Now add in all of the players. - gEngfuncs.pEventAPI->EV_SetSolidPlayers( idx - 1 ); - - gEngfuncs.pEventAPI->EV_SetTraceHull( 2 ); - gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecDest, PM_STUDIO_BOX, -1, &tr ); - - gEngfuncs.pEventAPI->EV_PopPMStates(); - - if( tr.allsolid ) - break; - - if( fFirstBeam ) - { - if( EV_IsLocal( idx ) ) - { - // Add muzzle flash to current weapon model - EV_MuzzleFlash(); - } - fFirstBeam = 0; - - gEngfuncs.pEfxAPI->R_BeamEntPoint( - idx | 0x1000, - tr.endpos, - m_iBeam, - 0.1, - m_fPrimaryFire ? 1.0 : 2.5, - 0.0, - m_fPrimaryFire ? 128.0 : flDamage, - 0, - 0, - 0, - m_fPrimaryFire ? 255 : 255, - m_fPrimaryFire ? 128 : 255, - m_fPrimaryFire ? 0 : 255 - ); - } - else - { - 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, - 0, - 0, - m_fPrimaryFire ? 255 : 255, - m_fPrimaryFire ? 128 : 255, - m_fPrimaryFire ? 0 : 255 - ); - } - - pEntity = gEngfuncs.pEventAPI->EV_GetPhysent( tr.ent ); - if( pEntity == NULL ) - break; - - if( pEntity->solid == SOLID_BSP ) - { - float n; - - pentIgnore = NULL; - - n = -DotProduct( tr.plane.normal, forward ); - - if( n < 0.5 ) // 60 degrees - { - // ALERT( at_console, "reflect %f\n", n ); - // reflect - vec3_t r; - - VectorMA( forward, 2.0 * n, tr.plane.normal, r ); - - flMaxFrac = flMaxFrac - tr.fraction; - - VectorCopy( r, forward ); - - 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 ); - - 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, - 255, 100 ); - - // lose energy - if( n == 0 ) - { - n = 0.1; - } - - flDamage = flDamage * ( 1 - n ); - } - else - { - // 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 ); - - // limit it to one hole punch - if( fHasPunched ) - { - break; - } - fHasPunched = 1; - - // try punching through wall if secondary attack (primary is incapable of breaking through) - if( !m_fPrimaryFire ) - { - vec3_t start; - - VectorMA( tr.endpos, 8.0, forward, start ); - - // Store off the old count - gEngfuncs.pEventAPI->EV_PushPMStates(); - - // Now add in all of the players. - gEngfuncs.pEventAPI->EV_SetSolidPlayers ( idx - 1 ); - - gEngfuncs.pEventAPI->EV_SetTraceHull( 2 ); - gEngfuncs.pEventAPI->EV_PlayerTrace( start, vecDest, PM_STUDIO_BOX, -1, &beam_tr ); - - if( !beam_tr.allsolid ) - { - vec3_t delta; - - // trace backwards to find exit point - gEngfuncs.pEventAPI->EV_PlayerTrace( beam_tr.endpos, tr.endpos, PM_STUDIO_BOX, -1, &beam_tr ); - - VectorSubtract( beam_tr.endpos, tr.endpos, delta ); - - n = Length( delta ); - - if( n < flDamage ) - { - if( n == 0 ) - n = 1; - flDamage -= n; - - // absorption balls - { - 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, - 255, 100 ); - } - - //////////////////////////////////// WHAT TO DO HERE - // CSoundEnt::InsertSound( bits_SOUND_COMBAT, pev->origin, NORMAL_EXPLOSION_VOLUME, 3.0 ); - - 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 ); - - // 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, - 255, 40 ); - } - - VectorAdd( beam_tr.endpos, forward, vecSrc ); - } - } - else - { - flDamage = 0; - } - - gEngfuncs.pEventAPI->EV_PopPMStates(); - } - else - { - if( m_fPrimaryFire ) - { - // 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 ); - { - 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, - 255, 200 ); - } - } - - flDamage = 0; - } - } - } - else - { - VectorAdd( tr.endpos, forward, vecSrc ); - } - } -} -//====================== -// GAUSS END -//====================== - -//====================== -// CROWBAR START -//====================== -enum crowbar_e -{ - CROWBAR_IDLE = 0, - CROWBAR_DRAW, - CROWBAR_HOLSTER, - CROWBAR_ATTACK1HIT, - CROWBAR_ATTACK1MISS, - CROWBAR_ATTACK2MISS, - CROWBAR_ATTACK2HIT, - CROWBAR_ATTACK3MISS, - CROWBAR_ATTACK3HIT -}; - -int g_iSwing; - -//Only predict the miss sounds, hit sounds are still played -//server side, so players don't get the wrong idea. -void EV_Crowbar( event_args_t *args ) -{ - int idx; - vec3_t origin; - vec3_t angles; - vec3_t velocity; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - - //Play Swing sound - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/cbar_miss1.wav", 1, ATTN_NORM, 0, PITCH_NORM ); - - if( EV_IsLocal( idx ) ) - { - gEngfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK1MISS, 1 ); - - switch( (g_iSwing++) % 3 ) - { - case 0: - gEngfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK1MISS, 1 ); - break; - case 1: - gEngfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK2MISS, 1 ); - break; - case 2: - gEngfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK3MISS, 1 ); - break; - } - } -} -//====================== -// CROWBAR END -//====================== - -//====================== -// CROSSBOW START -//====================== -enum crossbow_e -{ - CROSSBOW_IDLE1 = 0, // full - CROSSBOW_IDLE2, // empty - CROSSBOW_FIDGET1, // full - CROSSBOW_FIDGET2, // empty - CROSSBOW_FIRE1, // full - CROSSBOW_FIRE2, // reload - CROSSBOW_FIRE3, // empty - CROSSBOW_RELOAD, // from empty - CROSSBOW_DRAW1, // full - CROSSBOW_DRAW2, // empty - CROSSBOW_HOLSTER1, // full - CROSSBOW_HOLSTER2 // empty -}; - -//===================== -// EV_BoltCallback -// This function is used to correct the origin and angles -// of the bolt, so it looks like it's stuck on the wall. -//===================== -void EV_BoltCallback( struct tempent_s *ent, float frametime, float currenttime ) -{ - ent->entity.origin = ent->entity.baseline.vuser1; - ent->entity.angles = ent->entity.baseline.vuser2; -} - -void EV_FireCrossbow2( event_args_t *args ) -{ - vec3_t vecSrc, vecEnd; - vec3_t up, right, forward; - pmtrace_t tr; - - int idx; - vec3_t origin; - vec3_t angles; - vec3_t velocity; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - VectorCopy( args->angles, angles ); - - VectorCopy( args->velocity, velocity ); - - AngleVectors( angles, forward, right, up ); - - EV_GetGunPosition( args, vecSrc, origin ); - - 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 ) ); - - 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 ); - } - - // Store off the old count - gEngfuncs.pEventAPI->EV_PushPMStates(); - - // Now add in all of the players. - gEngfuncs.pEventAPI->EV_SetSolidPlayers ( idx - 1 ); - gEngfuncs.pEventAPI->EV_SetTraceHull( 2 ); - gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecEnd, PM_STUDIO_BOX, -1, &tr ); - - //We hit something - if( tr.fraction < 1.0 ) - { - physent_t *pe = gEngfuncs.pEventAPI->EV_GetPhysent( tr.ent ); - - //Not the world, let's assume we hit something organic ( dog, cat, uncle joe, etc ). - if( pe->solid != SOLID_BSP ) - { - switch( gEngfuncs.pfnRandomLong( 0, 1 ) ) - { - case 0: - gEngfuncs.pEventAPI->EV_PlaySound( idx, tr.endpos, CHAN_BODY, "weapons/xbow_hitbod1.wav", 1, ATTN_NORM, 0, PITCH_NORM ); - break; - case 1: - gEngfuncs.pEventAPI->EV_PlaySound( idx, tr.endpos, CHAN_BODY, "weapons/xbow_hitbod2.wav", 1, ATTN_NORM, 0, PITCH_NORM ); - break; - } - } - //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 ); - - //Not underwater, do some sparks... - if( gEngfuncs.PM_PointContents( tr.endpos, NULL ) != CONTENTS_WATER ) - gEngfuncs.pEfxAPI->R_SparkShower( tr.endpos ); - - vec3_t vBoltAngles; - int iModelIndex = gEngfuncs.pEventAPI->EV_FindModelIndex( "models/crossbow_bolt.mdl" ); - - VectorAngles( forward, vBoltAngles ); - - TEMPENTITY *bolt = gEngfuncs.pEfxAPI->R_TempModel( tr.endpos - forward * 10, Vector( 0, 0, 0 ), vBoltAngles , 5, iModelIndex, TE_BOUNCE_NULL ); - - if( bolt ) - { - bolt->flags |= ( FTENT_CLIENTCUSTOM ); //So it calls the callback function. - bolt->entity.baseline.vuser1 = tr.endpos - forward * 10; // Pull out a little bit - bolt->entity.baseline.vuser2 = vBoltAngles; //Look forward! - bolt->callback = EV_BoltCallback; //So we can set the angles and origin back. (Stick the bolt to the wall) - } - } - } - - gEngfuncs.pEventAPI->EV_PopPMStates(); -} - -//TODO: Fully predict the fliying bolt. -void EV_FireCrossbow( event_args_t *args ) -{ - int idx; - vec3_t origin; - - idx = args->entindex; - 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 ) ); - - //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 ); - - V_PunchAxis( 0, -2.0 ); - } -} -//====================== -// CROSSBOW END -//====================== - -//====================== -// RPG START -//====================== -enum rpg_e -{ - RPG_IDLE = 0, - RPG_FIDGET, - RPG_RELOAD, // to reload - RPG_FIRE2, // to empty - RPG_HOLSTER1, // loaded - RPG_DRAW1, // loaded - RPG_HOLSTER2, // unloaded - RPG_DRAW_UL, // unloaded - RPG_IDLE_UL, // unloaded idle - RPG_FIDGET_UL // unloaded fidget -}; - -void EV_FireRpg( event_args_t *args ) -{ - int idx; - vec3_t origin; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/rocketfire1.wav", 0.9, ATTN_NORM, 0, PITCH_NORM ); - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_ITEM, "weapons/glauncher.wav", 0.7, ATTN_NORM, 0, PITCH_NORM ); - - //Only play the weapon anims if I shot it. - if( EV_IsLocal( idx ) ) - { - gEngfuncs.pEventAPI->EV_WeaponAnimation( RPG_FIRE2, 1 ); - - V_PunchAxis( 0, -5.0 ); - } -} -//====================== -// RPG END -//====================== - -//====================== -// EGON END -//====================== -enum egon_e -{ - EGON_IDLE1 = 0, - EGON_FIDGET1, - EGON_ALTFIREON, - EGON_ALTFIRECYCLE, - EGON_ALTFIREOFF, - EGON_FIRE1, - EGON_FIRE2, - EGON_FIRE3, - EGON_FIRE4, - EGON_DRAW, - EGON_HOLSTER -}; - -int g_fireAnims1[] = { EGON_FIRE1, EGON_FIRE2, EGON_FIRE3, EGON_FIRE4 }; -int g_fireAnims2[] = { EGON_ALTFIRECYCLE }; - -enum EGON_FIRESTATE -{ - FIRE_OFF, - FIRE_CHARGE -}; - -enum EGON_FIREMODE -{ - FIRE_NARROW, - FIRE_WIDE -}; - -#define EGON_PRIMARY_VOLUME 450 -#define EGON_BEAM_SPRITE "sprites/xbeam1.spr" -#define EGON_FLARE_SPRITE "sprites/XSpark1.spr" -#define EGON_SOUND_OFF "weapons/egon_off1.wav" -#define EGON_SOUND_RUN "weapons/egon_run3.wav" -#define EGON_SOUND_STARTUP "weapons/egon_windup2.wav" - -#define ARRAYSIZE(p) ( sizeof(p) /sizeof(p[0]) ) - -BEAM *pBeam; -BEAM *pBeam2; - -void EV_EgonFire( event_args_t *args ) -{ - int idx, iFireState, iFireMode; - vec3_t origin; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - iFireState = args->iparam1; - iFireMode = args->iparam2; - int iStartup = args->bparam1; - - if( iStartup ) - { - if( iFireMode == FIRE_WIDE ) - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, EGON_SOUND_STARTUP, 0.98, ATTN_NORM, 0, 125 ); - else - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, EGON_SOUND_STARTUP, 0.9, ATTN_NORM, 0, 100 ); - } - else - { - if( iFireMode == FIRE_WIDE ) - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_STATIC, EGON_SOUND_RUN, 0.98, ATTN_NORM, 0, 125 ); - else - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_STATIC, EGON_SOUND_RUN, 0.9, ATTN_NORM, 0, 100 ); - } - - //Only play the weapon anims if I shot it. - if( EV_IsLocal( idx ) ) - gEngfuncs.pEventAPI->EV_WeaponAnimation ( g_fireAnims1[gEngfuncs.pfnRandomLong( 0, 3 )], 1 ); - - if( iStartup == 1 && EV_IsLocal( idx ) && !pBeam && !pBeam2 && cl_lw->value ) //Adrian: Added the cl_lw check for those lital people that hate weapon prediction. - { - vec3_t vecSrc, vecEnd, angles, forward, right, up; - pmtrace_t tr; - - cl_entity_t *pl = gEngfuncs.GetEntityByIndex( idx ); - - if( pl ) - { - VectorCopy( gHUD.m_vecAngles, angles ); - - AngleVectors( angles, forward, right, up ); - - EV_GetGunPosition( args, vecSrc, pl->origin ); - - VectorMA( vecSrc, 2048, forward, vecEnd ); - - gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction( false, true ); - - // Store off the old count - gEngfuncs.pEventAPI->EV_PushPMStates(); - - // Now add in all of the players. - gEngfuncs.pEventAPI->EV_SetSolidPlayers( idx - 1 ); - - gEngfuncs.pEventAPI->EV_SetTraceHull( 2 ); - gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecEnd, PM_STUDIO_BOX, -1, &tr ); - - gEngfuncs.pEventAPI->EV_PopPMStates(); - - int iBeamModelIndex = gEngfuncs.pEventAPI->EV_FindModelIndex( EGON_BEAM_SPRITE ); - - float r = 50.0f; - float g = 50.0f; - float b = 125.0f; - - if( IEngineStudio.IsHardware() ) - { - r /= 100.0f; - g /= 100.0f; - } - - pBeam = gEngfuncs.pEfxAPI->R_BeamEntPoint( idx | 0x1000, tr.endpos, iBeamModelIndex, 99999, 3.5, 0.2, 0.7, 55, 0, 0, r, g, b ); - - if( pBeam ) - pBeam->flags |= ( FBEAM_SINENOISE ); - - pBeam2 = gEngfuncs.pEfxAPI->R_BeamEntPoint( idx | 0x1000, tr.endpos, iBeamModelIndex, 99999, 5.0, 0.08, 0.7, 25, 0, 0, r, g, b ); - } - } -} - -void EV_EgonStop( event_args_t *args ) -{ - int idx; - vec3_t origin; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - - gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_STATIC, EGON_SOUND_RUN ); - - if( args->iparam1 ) - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, EGON_SOUND_OFF, 0.98, ATTN_NORM, 0, 100 ); - - if( EV_IsLocal( idx ) ) - { - if( pBeam ) - { - pBeam->die = 0.0; - pBeam = NULL; - } - - if( pBeam2 ) - { - pBeam2->die = 0.0; - pBeam2 = NULL; - } - } -} -//====================== -// EGON END -//====================== - -//====================== -// HORNET START -//====================== -enum hgun_e -{ - HGUN_IDLE1 = 0, - HGUN_FIDGETSWAY, - HGUN_FIDGETSHAKE, - HGUN_DOWN, - HGUN_UP, - HGUN_SHOOT -}; - -void EV_HornetGunFire( event_args_t *args ) -{ - int idx, iFireMode; - vec3_t origin, angles, vecSrc, forward, right, up; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - VectorCopy( args->angles, angles ); - iFireMode = args->iparam1; - - //Only play the weapon anims if I shot it. - if( EV_IsLocal( idx ) ) - { - V_PunchAxis( 0, gEngfuncs.pfnRandomLong( 0, 2 ) ); - gEngfuncs.pEventAPI->EV_WeaponAnimation( HGUN_SHOOT, 1 ); - } - - switch( gEngfuncs.pfnRandomLong( 0 , 2 ) ) - { - case 0: - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "agrunt/ag_fire1.wav", 1, ATTN_NORM, 0, 100 ); - break; - case 1: - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "agrunt/ag_fire2.wav", 1, ATTN_NORM, 0, 100 ); - break; - case 2: - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "agrunt/ag_fire3.wav", 1, ATTN_NORM, 0, 100 ); - break; - } -} -//====================== -// HORNET END -//====================== - -//====================== -// TRIPMINE START -//====================== -enum tripmine_e -{ - TRIPMINE_IDLE1 = 0, - TRIPMINE_IDLE2, - TRIPMINE_ARM1, - TRIPMINE_ARM2, - TRIPMINE_FIDGET, - TRIPMINE_HOLSTER, - TRIPMINE_DRAW, - TRIPMINE_WORLD, - TRIPMINE_GROUND -}; - -//We only check if it's possible to put a trip mine -//and if it is, then we play the animation. Server still places it. -void EV_TripmineFire( event_args_t *args ) -{ - int idx; - vec3_t vecSrc, angles, view_ofs, forward; - pmtrace_t tr; - - idx = args->entindex; - VectorCopy( args->origin, vecSrc ); - VectorCopy( args->angles, angles ); - - AngleVectors( angles, forward, NULL, NULL ); - - if( !EV_IsLocal ( idx ) ) - return; - - // Grab predicted result for local player - gEngfuncs.pEventAPI->EV_LocalPlayerViewheight( view_ofs ); - - vecSrc = vecSrc + view_ofs; - - // Store off the old count - gEngfuncs.pEventAPI->EV_PushPMStates(); - - // 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 ); - - //Hit something solid - if( tr.fraction < 1.0 ) - gEngfuncs.pEventAPI->EV_WeaponAnimation ( TRIPMINE_DRAW, 0 ); - - gEngfuncs.pEventAPI->EV_PopPMStates(); -} -//====================== -// TRIPMINE END -//====================== - -//====================== -// SQUEAK START -//====================== -enum squeak_e -{ - SQUEAK_IDLE1 = 0, - SQUEAK_FIDGETFIT, - SQUEAK_FIDGETNIP, - SQUEAK_DOWN, - SQUEAK_UP, - SQUEAK_THROW -}; - -#define VEC_HULL_MIN Vector( -16, -16, -36 ) -#define VEC_DUCK_HULL_MIN Vector( -16, -16, -18 ) - -void EV_SnarkFire( event_args_t *args ) -{ - int idx; - vec3_t vecSrc, angles, view_ofs, forward; - pmtrace_t tr; - - idx = args->entindex; - VectorCopy( args->origin, vecSrc ); - VectorCopy( args->angles, angles ); - - AngleVectors( angles, forward, NULL, NULL ); - - if( !EV_IsLocal ( idx ) ) - return; - - if( args->ducking ) - vecSrc = vecSrc - ( VEC_HULL_MIN - VEC_DUCK_HULL_MIN ); - - // Store off the old count - gEngfuncs.pEventAPI->EV_PushPMStates(); - - // Now add in all of the players. - gEngfuncs.pEventAPI->EV_SetSolidPlayers( idx - 1 ); - gEngfuncs.pEventAPI->EV_SetTraceHull( 2 ); - 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 ) - gEngfuncs.pEventAPI->EV_WeaponAnimation( SQUEAK_THROW, 0 ); - - gEngfuncs.pEventAPI->EV_PopPMStates(); -} -//====================== -// SQUEAK END -//====================== - void EV_TrainPitchAdjust( event_args_t *args ) { int idx; @@ -1712,7 +630,7 @@ void EV_TrainPitchAdjust( event_args_t *args ) int pitch; int stop; - char sz[256]; + const char *pszSound; idx = args->entindex; @@ -1728,36 +646,35 @@ void EV_TrainPitchAdjust( event_args_t *args ) switch( noise ) { case 1: - strcpy( sz, "plats/ttrain1.wav" ); + pszSound = "plats/ttrain1.wav"; break; case 2: - strcpy( sz, "plats/ttrain2.wav" ); + pszSound = "plats/ttrain2.wav"; break; case 3: - strcpy( sz, "plats/ttrain3.wav" ); + pszSound = "plats/ttrain3.wav"; break; case 4: - strcpy( sz, "plats/ttrain4.wav"); + pszSound = "plats/ttrain4.wav"; break; case 5: - strcpy( sz, "plats/ttrain6.wav"); + pszSound = "plats/ttrain6.wav"; break; case 6: - strcpy( sz, "plats/ttrain7.wav"); + pszSound = "plats/ttrain7.wav"; break; default: // no sound - strcpy( sz, "" ); return; } if( stop ) { - gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_STATIC, sz ); + gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_STATIC, pszSound ); } else { - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_STATIC, sz, m_flVolume, ATTN_NORM, SND_CHANGE_PITCH, pitch ); + gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_STATIC, pszSound, m_flVolume, ATTN_NORM, SND_CHANGE_PITCH, pitch ); } } @@ -1766,227 +683,6 @@ int EV_TFC_IsAllyTeam( int iTeam1, int iTeam2 ) return 0; } -//====================== -// HEATERPIPE START -//====================== -enum heaterpipe_e -{ - HEATERPIPE_IDLE = 0, - HEATERPIPE_DRAW, - HEATERPIPE_HOLSTER, - HEATERPIPE_ATTACK1HIT, - HEATERPIPE_ATTACK1MISS, - HEATERPIPE_ATTACK2MISS, - HEATERPIPE_ATTACK2HIT, - HEATERPIPE_ATTACK3MISS, - HEATERPIPE_ATTACK3HIT, - HEATERPIPE_IDLE2, - HEATERPIPE_IDLE3, -}; - -//Only predict the miss sounds, hit sounds are still played -//server side, so players don't get the wrong idea. -void EV_HeaterPipe( event_args_t *args ) -{ - int idx; - vec3_t origin; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - - //Play Swing sound - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/pipe_miss.wav", 1, ATTN_NORM, 0, PITCH_NORM ); - - if( EV_IsLocal( idx ) ) - { - gEngfuncs.pEventAPI->EV_WeaponAnimation( HEATERPIPE_ATTACK1MISS, 1 ); - - switch( ( g_iSwing++ ) % 3 ) - { - case 0: - gEngfuncs.pEventAPI->EV_WeaponAnimation( HEATERPIPE_ATTACK1MISS, 1 ); - break; - case 1: - gEngfuncs.pEventAPI->EV_WeaponAnimation( HEATERPIPE_ATTACK2MISS, 1 ); - break; - case 2: - gEngfuncs.pEventAPI->EV_WeaponAnimation( HEATERPIPE_ATTACK3MISS, 1 ); - break; - } - } -} -//====================== -// HEATERPIPE END -//====================== - -//====================== -// BRADNAILER START -//====================== -enum bradnailer_e -{ - BRADNAILER_IDLE1 = 0, - BRADNAILER_IDLE2, - BRADNAILER_IDLE3, - BRADNAILER_SHOOT, - BRADNAILER_SHOOT_EMPTY, - BRADNAILER_RELOAD, - BRADNAILER_RELOAD_NOT_EMPTY, - BRADNAILER_DRAW, - BRADNAILER_HOLSTER, - BRADNAILER_ADD_SILENCER, - BRADNAILER_UPRIGHT_TO_TILT, - BRADNAILER_TILT_TO_UPRIGHT, - BRADNAILER_FASTSHOOT -}; - -void EV_FireBradnailer( event_args_t *args ) -{ - int idx; - vec3_t origin; - vec3_t angles; - vec3_t velocity; - int fastshoot = args->bparam1; - - vec3_t vecSrc, vecAiming; - vec3_t up, right, forward; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - VectorCopy( args->angles, angles ); - VectorCopy( args->velocity, velocity ); - - AngleVectors( angles, forward, right, up ); - - if( EV_IsLocal( idx ) ) - { - gEngfuncs.pEventAPI->EV_WeaponAnimation( fastshoot ? BRADNAILER_FASTSHOOT : BRADNAILER_SHOOT, 2 ); - - V_PunchAxis( 0, -2.0 ); - } - - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/bradnailer.wav", gEngfuncs.pfnRandomFloat( 0.92, 1.0 ), ATTN_NORM, 0, 98 + gEngfuncs.pfnRandomLong( 0, 3 ) ); - - EV_GetGunPosition( args, vecSrc, origin ); - - // Adjust tracer source. - if( fastshoot ) - { - vecSrc = vecSrc + forward * 4 + up * -4; - } - else - { - vecSrc = vecSrc + forward * 12 + right * 8 + up * -4; - } - - VectorCopy( forward, vecAiming ); - - EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_NAIL, 2, &tracerCount[idx - 1], args->fparam1, args->fparam2 ); -} - -//====================== -// BRADNAILER END -//====================== - -//====================== -// NAILGUN START -//====================== -enum nailgun_e -{ - NAILGUN_LONGIDLE = 0, - NAILGUN_IDLE1, - NAILGUN_LAUNCH, - NAILGUN_RELOAD, - NAILGUN_DEPLOY, - NAILGUN_FIRE1, - NAILGUN_FIRE2, - NAILGUN_FIRE3, - NAILGUN_DEPLOY_EMPTY, - NAILGUN_LONGIDLE_EMPTY, - NAILGUN_IDLE1_EMPTY -}; - -void EV_FireNailgun( event_args_t *args ) -{ - int idx; - vec3_t origin; - vec3_t angles; - vec3_t velocity; - - vec3_t vecSrc, vecAiming; - vec3_t up, right, forward; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - VectorCopy( args->angles, angles ); - VectorCopy( args->velocity, velocity ); - - AngleVectors( angles, forward, right, up ); - - if( EV_IsLocal( idx ) ) - { - gEngfuncs.pEventAPI->EV_WeaponAnimation( NAILGUN_FIRE1 + gEngfuncs.pfnRandomLong( 0, 2 ), 2 ); - - V_PunchAxis( 0, gEngfuncs.pfnRandomFloat( -2, 2 ) ); - } - - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/nailgun.wav", 1, ATTN_NORM, 0, 94 + gEngfuncs.pfnRandomLong( 0, 0xf ) ); - - EV_GetGunPosition( args, vecSrc, origin ); - - // Adjust tracer source. - vecSrc = vecSrc + forward * 8 + right * 16 + up * -16; - - VectorCopy( forward, vecAiming ); - - EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_NAIL, 1, &tracerCount[idx - 1], args->fparam1, args->fparam2 ); -} - -//====================== -// NAILGUN END -//====================== - -//====================== -// CMLWBR START -//====================== -enum cmlwbr_e -{ - CMLWBR_IDLE1 = 0, // drawn - CMLWBR_IDLE2, // undrawn - CMLWBR_FIDGET1, // drawn - CMLWBR_FIDGET2, // undrawn - CMLWBR_FIRE1, - CMLWBR_RELOAD, // drawn - CMLWBR_DRAWBACK, - CMLWBR_UNDRAW, - CMLWBR_DRAW1, // drawn - CMLWBR_DRAW2, // undrawn - CMLWBR_HOLSTER1, // drawn - CMLWBR_HOLSTER2 // undrawn -}; - -//TODO: Fully predict the fliying bolt. -void EV_FireCmlwbr( event_args_t *args ) -{ - int idx; - vec3_t origin; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/cmlwbr_fire.wav", 1, ATTN_NORM, 0, 93 + gEngfuncs.pfnRandomLong( 0, 0xF ) ); - - //Only play the weapon anims if I shot it. - if( EV_IsLocal( idx ) ) - { - gEngfuncs.pEventAPI->EV_WeaponAnimation( CMLWBR_FIRE1, 1 ); - - V_PunchAxis( 0, -2.0 ); - } -} -//====================== -// CMLWBR END -//====================== - //====================== // XENSQUASHER START //====================== @@ -2001,9 +697,18 @@ enum xensquasher_e XS_FIRE2, XS_HOLSTER, XS_DRAW, - XS_RELOAD + XS_RELOAD, }; +void EV_StopPreviousXS( int idx ) +{ + // Make sure we don't have a gauss spin event in the queue for this guy + gEngfuncs.pEventAPI->EV_KillEvents( idx, "events/xsspin.sc" ); + gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_WEAPON, "weapons/xs_windup.wav" ); + if( EV_IsLocal( idx ) ) + gEngfuncs.pEventAPI->EV_WeaponAnimation( XS_FIRE2, 2 ); +} + void EV_SpinXS( event_args_t *args ) { int idx; @@ -2015,55 +720,6 @@ void EV_SpinXS( event_args_t *args ) int pitch; idx = args->entindex; - VectorCopy( args->origin, origin ); - VectorCopy( args->angles, angles ); - VectorCopy( args->velocity, velocity ); - - pitch = args->iparam1; - - iSoundState = args->bparam1 ? SND_CHANGE_PITCH : 0; - - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/xs_windup.wav", 1.0, ATTN_NORM, iSoundState, pitch ); -} - -/* -============================== -EV_StopPreviousXS -============================== -*/ -void EV_StopPreviousXS( int idx ) -{ - // Make sure we don't have a gauss spin event in the queue for this guy - gEngfuncs.pEventAPI->EV_KillEvents( idx, "events/xsspin.sc" ); - gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_WEAPON, "weapons/xs_windup.wav" ); -} - -void EV_FireXS( event_args_t *args ) -{ - int idx; - vec3_t origin; - vec3_t angles; - vec3_t velocity; - float flDamage = args->fparam1; - int primaryfire = args->bparam1; - - int m_fPrimaryFire = args->bparam1; - int m_iWeaponVolume = GAUSS_PRIMARY_FIRE_VOLUME; - vec3_t vecSrc; - vec3_t vecDest; - pmtrace_t tr, beam_tr; - float flMaxFrac = 1.0; - int nTotal = 0; - int fHasPunched = 0; - int fFirstBeam = 1; - int nMaxHits = 10; - int m_iBeam, m_iGlow, m_iBalls; - vec3_t up, right, forward; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - VectorCopy( args->angles, angles ); - VectorCopy( args->velocity, velocity ); if( args->bparam2 ) { @@ -2071,51 +727,16 @@ void EV_FireXS( event_args_t *args ) return; } - //Con_Printf( "Firing gauss with %f\n", flDamage ); - EV_GetGunPosition( args, vecSrc, origin ); + VectorCopy( args->origin, origin ); + // VectorCopy( args->angles, angles ); + // VectorCopy( args->velocity, velocity ); - m_iBeam = gEngfuncs.pEventAPI->EV_FindModelIndex( "sprites/smoke.spr" ); - m_iBalls = m_iGlow = gEngfuncs.pEventAPI->EV_FindModelIndex( "sprites/hotglow.spr" ); + pitch = args->iparam1; - AngleVectors( angles, forward, right, up ); + iSoundState = args->bparam1 ? SND_CHANGE_PITCH : 0; - VectorMA( vecSrc, 8192, forward, vecDest ); - - if( EV_IsLocal( idx ) ) - { - V_PunchAxis( 0, -2.0 ); - gEngfuncs.pEventAPI->EV_WeaponAnimation( XS_FIRE2, 2 ); - - if( m_fPrimaryFire == false ) - g_flApplyVel = flDamage; - } - - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/xs_shot.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/xs_windup.wav", 1.0, ATTN_NORM, iSoundState, pitch ); } -//====================== -// XENSQUASHER END -//====================== - -//====================== -// RELOAD START -//====================== -void EV_Reload( event_args_t *args ) -{ - int idx; - - idx = args->entindex; - - if( EV_IsLocal( idx ) ) - { - int anim = args->iparam1; - int body = args->iparam2; - gEngfuncs.pEventAPI->EV_WeaponAnimation( anim, body ); - } -} - -//====================== -// RELOAD END -//====================== //====================== // PAR21 START @@ -2185,7 +806,7 @@ void EV_FirePar21( struct event_args_s *args ) EV_GetGunPosition( args, vecSrc, origin ); VectorCopy( forward, vecAiming ); - EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_PAR21, 2, &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 ); } void EV_M203( struct event_args_s *args ) @@ -2216,3 +837,4 @@ void EV_M203( struct event_args_s *args ) //====================== // PAR21 END //====================== + diff --git a/cl_dll/ev_hldm.h b/cl_dll/ev_hldm.h index b565cdd0..ae84a5ed 100644 --- a/cl_dll/ev_hldm.h +++ b/cl_dll/ev_hldm.h @@ -1,10 +1,11 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // // $NoKeywords: $ //============================================================================= +#pragma once #if !defined ( EV_HLDMH ) #define EV_HLDMH @@ -17,9 +18,6 @@ typedef enum BULLET_PLAYER_357, // python BULLET_PLAYER_BUCKSHOT, // shotgun BULLET_PLAYER_CROWBAR, // crowbar swipe - BULLET_PLAYER_NAIL, // nails - BULLET_PLAYER_XS, // xen squasher - BULLET_PLAYER_PAR21, // par21 BULLET_MONSTER_9MM, BULLET_MONSTER_MP5, BULLET_MONSTER_12MM diff --git a/cl_dll/events.cpp b/cl_dll/events.cpp index a51dd72f..f286d261 100644 --- a/cl_dll/events.cpp +++ b/cl_dll/events.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/eventscripts.h b/cl_dll/eventscripts.h index bb835474..c61bf300 100644 --- a/cl_dll/eventscripts.h +++ b/cl_dll/eventscripts.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // @@ -6,6 +6,7 @@ //============================================================================= // eventscripts.h +#pragma once #if !defined ( EVENTSCRIPTSH ) #define EVENTSCRIPTSH diff --git a/cl_dll/flashlight.cpp b/cl_dll/flashlight.cpp index 9fb51fa2..86cd3669 100644 --- a/cl_dll/flashlight.cpp +++ b/cl_dll/flashlight.cpp @@ -49,6 +49,8 @@ void CHudFlashlight::Reset( void ) { m_fFade = 0; m_fOn = 0; + m_iBat = 100; + m_flBat = 1.0; } int CHudFlashlight::VidInit( void ) @@ -91,5 +93,6 @@ int CHudFlashlight::MsgFunc_Flashlight( const char *pszName, int iSize, void *p int CHudFlashlight::Draw( float flTime ) { + gMobileEngfuncs->pfnTouchHideButtons( "flashlight", 1 ); return 1; } diff --git a/cl_dll/geiger.cpp b/cl_dll/geiger.cpp index 7ccaf1d3..097889b9 100644 --- a/cl_dll/geiger.cpp +++ b/cl_dll/geiger.cpp @@ -65,7 +65,7 @@ int CHudGeiger::Draw( float flTime ) { int pct; float flvol = 0.0f; - int rg[3]; + //int rg[3]; int i; if( m_iGeigerRange < 1000 && m_iGeigerRange > 0 ) @@ -79,61 +79,61 @@ int CHudGeiger::Draw( float flTime ) { pct = 2; flvol = 0.4; //Con_Printf( "range > 600\n" ); - rg[0] = 1; - rg[1] = 1; + //rg[0] = 1; + //rg[1] = 1; i = 2; } else if( m_iGeigerRange > 500 ) { pct = 4; flvol = 0.5; //Con_Printf( "range > 500\n" ); - rg[0] = 1; - rg[1] = 2; + //rg[0] = 1; + //rg[1] = 2; i = 2; } else if( m_iGeigerRange > 400 ) { pct = 8; flvol = 0.6; //Con_Printf( "range > 400\n" ); - rg[0] = 1; - rg[1] = 2; - rg[2] = 3; + //rg[0] = 1; + //rg[1] = 2; + //rg[2] = 3; i = 3; } else if( m_iGeigerRange > 300 ) { pct = 8; flvol = 0.7; //Con_Printf( "range > 300\n" ); - rg[0] = 2; - rg[1] = 3; - rg[2] = 4; + //rg[0] = 2; + //rg[1] = 3; + //rg[2] = 4; i = 3; } else if( m_iGeigerRange > 200 ) { pct = 28; flvol = 0.78; //Con_Printf( "range > 200\n" ); - rg[0] = 2; - rg[1] = 3; - rg[2] = 4; + //rg[0] = 2; + //rg[1] = 3; + //rg[2] = 4; i = 3; } else if( m_iGeigerRange > 150 ) { pct = 40; flvol = 0.80; //Con_Printf( "range > 150\n" ); - rg[0] = 3; - rg[1] = 4; - rg[2] = 5; + //rg[0] = 3; + //rg[1] = 4; + //rg[2] = 5; i = 3; } else if( m_iGeigerRange > 100 ) { pct = 60; flvol = 0.85; //Con_Printf( "range > 100\n" ); - rg[0] = 3; - rg[1] = 4; - rg[2] = 5; + //rg[0] = 3; + //rg[1] = 4; + //rg[2] = 5; i = 3; } else if( m_iGeigerRange > 75 ) @@ -141,29 +141,29 @@ int CHudGeiger::Draw( float flTime ) pct = 80; flvol = 0.9; //Con_Printf( "range > 75\n" ); //gflGeigerDelay = cl.time + GEIGERDELAY * 0.75; - rg[0] = 4; - rg[1] = 5; - rg[2] = 6; + //rg[0] = 4; + //rg[1] = 5; + //rg[2] = 6; i = 3; } else if( m_iGeigerRange > 50 ) { pct = 90; flvol = 0.95; //Con_Printf( "range > 50\n" ); - rg[0] = 5; - rg[1] = 6; + //rg[0] = 5; + //rg[1] = 6; i = 2; } else { pct = 95; flvol = 1.0; //Con_Printf( "range < 50\n" ); - rg[0] = 5; - rg[1] = 6; + //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.25; // UTIL_RandomFloat( 0.25, 0.5 ); if( ( rand() & 127 ) < pct || ( rand() & 127 ) < pct ) { diff --git a/cl_dll/health.cpp b/cl_dll/health.cpp index 9898d32c..12f788c2 100644 --- a/cl_dll/health.cpp +++ b/cl_dll/health.cpp @@ -156,25 +156,33 @@ 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; #else - if( m_iHealth > 25 ) + if( m_iHealth <= 0 ) + { + UnpackRGB( r, g, b, RGB_REDISH ); + } + else if( m_iHealth > 15 ) { UnpackRGB( r, g, b, RGB_YELLOWISH ); } else { UnpackRGB( r, g, b, RGB_YELLOWISH ); - g = b = 255 * fabs( sin( gEngfuncs.GetClientTime() * M_PI * 2.0f ) ); + float f = ( sin( ( 16 - gHUD.m_flTime ) * m_iHealth ) + 1.0 ) * 0.5; + r = (int)( r * f * 58.0f ); + g = (int)( g * f ); + b = (int)( b * f ); } #endif } @@ -197,44 +205,37 @@ int CHudHealth::Draw( float flTime ) m_fFade -= ( gHUD.m_flTimeDelta * 20 ); if( m_fFade <= 0 ) { - a = MIN_ALPHA; m_fFade = 0; } // Fade the health number back to dim - a = min( gHUD.m_flAlpha, MIN_ALPHA ) + ( m_fFade / FADE_TIME ) * 128; + a = MIN_ALPHA + ( m_fFade / FADE_TIME ) * 128; } else - a = min( gHUD.m_flAlpha, MIN_ALPHA ); + a = MIN_ALPHA; // If health is getting low, make it bright red if( m_iHealth <= 15 ) - a = 255; + a = 192; GetPainColor( r, g, b ); ScaleColors( r, g, b, a ); - // Only draw health if we have the suit. - if( gHUD.m_iWeaponBits & ( 1 << ( WEAPON_SUIT ) ) ) - { - HealthWidth = gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).right - gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).left; + wrect_t cross = gHUD.GetSpriteRect( m_HUD_cross ); - wrect_t cross = gHUD.GetSpriteRect( m_HUD_cross ); + int CrossWidth = cross.right - cross.left; + int CrossHeight = cross.bottom - cross.top; - int CrossWidth = cross.right - cross.left; - int CrossHeight = cross.bottom - cross.top; + x = 10; + y = ScreenHeight - CrossHeight - 10; - y = ScreenHeight - gHUD.m_iFontHeight / 2 - CrossHeight; - x = CrossWidth; + SPR_Set( gHUD.GetSprite( m_HUD_cross ), r, g, b ); + SPR_DrawAdditive( 0, 10, y, &cross ); - SPR_Set( gHUD.GetSprite( m_HUD_cross ), r, g, b ); - SPR_DrawAdditive( 0, x, y, &cross ); + x = CrossWidth + 20; + y = ScreenHeight - gHUD.m_iFontHeight - 10; - y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2; - x = CrossWidth * 2.0f + HealthWidth; - - x = gHUD.DrawHudNumber( x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iHealth, r, g, b ); - } + gHUD.DrawHudNumber( x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iHealth, r, g, b ); DrawDamage( flTime ); return DrawPain( flTime ); diff --git a/cl_dll/health.h b/cl_dll/health.h index 132b9cb4..62d7e0bc 100644 --- a/cl_dll/health.h +++ b/cl_dll/health.h @@ -12,6 +12,9 @@ * without written permission from Valve LLC. * ****/ +#pragma once +#ifndef HEALTH_H +#define HEALTH_H #define DMG_IMAGE_LIFE 2 // seconds that image is up @@ -122,3 +125,4 @@ private: void CalcDamageDirection( vec3_t vecFrom ); void UpdateTiles( float fTime, long bits ); }; +#endif // HEALTH_H diff --git a/cl_dll/hl/hl_baseentity.cpp b/cl_dll/hl/hl_baseentity.cpp index c36daf6d..38978f6a 100644 --- a/cl_dll/hl/hl_baseentity.cpp +++ b/cl_dll/hl/hl_baseentity.cpp @@ -54,7 +54,8 @@ int CBaseEntity::IsDormant( void ) { return 0; } BOOL CBaseEntity::IsInWorld( void ) { return TRUE; } int CBaseEntity::ShouldToggle( USE_TYPE useType, BOOL currentState ) { return 0; } int CBaseEntity::DamageDecal( int bitsDamageType ) { return -1; } -CBaseEntity *CBaseEntity::Create( char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner ) { return NULL; } +CBaseEntity *CBaseEntity::Create( const char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner ) { return NULL; } +void CBaseEntity::UpdateOnRemove( void ) { } void CBaseEntity::SUB_Remove( void ) { } // CBaseDelay Stubs @@ -146,7 +147,7 @@ int CBaseMonster::CheckEnemy( CBaseEntity *pEnemy ) { return 0; } void CBaseMonster::PushEnemy( CBaseEntity *pEnemy, Vector &vecLastKnownPos ) { } BOOL CBaseMonster::PopEnemy() { return FALSE; } void CBaseMonster::SetActivity( Activity NewActivity ) { } -void CBaseMonster::SetSequenceByName( char *szSequence ) { } +void CBaseMonster::SetSequenceByName( const char *szSequence ) { } int CBaseMonster::CheckLocalMove( const Vector &vecStart, const Vector &vecEnd, CBaseEntity *pTarget, float *pflDist ) { return 0; } float CBaseMonster::OpenDoorAndWait( entvars_t *pevDoor ) { return 0.0; } void CBaseMonster::AdvanceRoute( float distance ) { } @@ -214,7 +215,7 @@ void CBaseMonster::MonsterInitDead( void ) { } BOOL CBaseMonster::BBoxFlat( void ) { return TRUE; } BOOL CBaseMonster::GetEnemy( void ) { return FALSE; } void CBaseMonster::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) { } -CBaseEntity* CBaseMonster::DropItem( char *pszItemName, const Vector &vecPos, const Vector &vecAng ) { return NULL; } +CBaseEntity* CBaseMonster::DropItem( const char *pszItemName, const Vector &vecPos, const Vector &vecAng ) { return NULL; } BOOL CBaseMonster::ShouldFadeOnDeath( void ) { return FALSE; } void CBaseMonster::RadiusDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ) { } void CBaseMonster::RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ) { } @@ -258,8 +259,8 @@ void CBasePlayer::PreThink(void) { } void CBasePlayer::CheckTimeBasedDamage() { } void CBasePlayer::UpdateGeigerCounter( void ) { } void CBasePlayer::CheckSuitUpdate() { } -void CBasePlayer::SetSuitUpdate(char *name, int fgroup, int iNoRepeatTime) { } -void CBasePlayer::UpdatePlayerSound ( void ) { } +void CBasePlayer::SetSuitUpdate( const char *name, int fgroup, int iNoRepeatTime ) { } +void CBasePlayer::UpdatePlayerSound( void ) { } void CBasePlayer::PostThink() { } void CBasePlayer::Precache( void ) { } int CBasePlayer::Save( CSave &save ) { return 0; } @@ -276,7 +277,7 @@ void CBasePlayer::ForceClientDllUpdate( void ) { } void CBasePlayer::ImpulseCommands() { } void CBasePlayer::CheatImpulseCommands( int iImpulse ) { } int CBasePlayer::AddPlayerItem( CBasePlayerItem *pItem ) { return FALSE; } -int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem ) { return FALSE; } +int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem, bool bCallHoster ) { return FALSE; } void CBasePlayer::ItemPreFrame() { } void CBasePlayer::ItemPostFrame() { } int CBasePlayer::AmmoInventory( int iAmmoIndex ) { return -1; } @@ -298,13 +299,9 @@ BOOL CBasePlayer::HasPlayerItem( CBasePlayerItem *pCheckItem ) { return FALSE; } BOOL CBasePlayer::SwitchWeapon( CBasePlayerItem *pWeapon ) { return FALSE; } Vector CBasePlayer::GetGunPosition( void ) { return g_vecZero; } const char *CBasePlayer::TeamID( void ) { return ""; } -int CBasePlayer::GiveAmmo( int iCount, char *szName, int iMax ) { return 0; } +int CBasePlayer::GiveAmmo( int iCount, const char *szName, int iMax ) { return 0; } void CBasePlayer::AddPoints( int score, BOOL bAllowNegativeScore ) { } void CBasePlayer::AddPointsToTeam( int score, BOOL bAllowNegativeScore ) { } -void CBasePlayer::IncrementExertLevel( int amount ) { } -void CBasePlayer::DecrementExertLevel( int amount ) { } -void CBasePlayer::ShowPlayerHUD( BOOL bInstant ) {} -void CBasePlayer::HidePlayerHUD( BOOL bInstant ) {} void ClearMultiDamage( void ) { } void ApplyMultiDamage( entvars_t *pevInflictor, entvars_t *pevAttacker ) { } diff --git a/cl_dll/hl/hl_events.cpp b/cl_dll/hl/hl_events.cpp index 569da4d1..3bd9caec 100644 --- a/cl_dll/hl/hl_events.cpp +++ b/cl_dll/hl/hl_events.cpp @@ -20,34 +20,13 @@ extern "C" { // HLDM -void EV_FireGlock1( struct event_args_s *args ); -void EV_FireGlock2( struct event_args_s *args ); +//void EV_FireGlock1( struct event_args_s *args ); +//void EV_FireGlock2( struct event_args_s *args ); void EV_FireShotGunSingle( struct event_args_s *args ); -void EV_FireShotGunDouble( struct event_args_s *args ); -void EV_FireMP5( struct event_args_s *args ); -void EV_FireMP52( struct event_args_s *args ); -void EV_FirePython( struct event_args_s *args ); -void EV_FireGauss( struct event_args_s *args ); -void EV_SpinGauss( struct event_args_s *args ); -void EV_Crowbar( struct event_args_s *args ); -void EV_FireCrossbow( struct event_args_s *args ); -void EV_FireCrossbow2( struct event_args_s *args ); -void EV_FireRpg( struct event_args_s *args ); -void EV_EgonFire( struct event_args_s *args ); -void EV_EgonStop( struct event_args_s *args ); -void EV_HornetGunFire( struct event_args_s *args ); -void EV_TripmineFire( struct event_args_s *args ); -void EV_SnarkFire( struct event_args_s *args ); void EV_TrainPitchAdjust( struct event_args_s *args ); -void EV_HeaterPipe( struct event_args_s *args ); -void EV_FireBradnailer( struct event_args_s *args ); -void EV_FireNailgun( struct event_args_s *args ); -void EV_FireCmlwbr( struct event_args_s *args ); void EV_SpinXS( struct event_args_s *args ); -void EV_FireXS( struct event_args_s *args ); -void EV_Reload( struct event_args_s *args ); void EV_FirePar21( struct event_args_s *args ); void EV_M203( struct event_args_s *args ); } @@ -67,33 +46,11 @@ That was what we were going to do, but we ran out of time...oh well. */ void Game_HookEvents( void ) { - gEngfuncs.pfnHookEvent( "events/glock1.sc", EV_FireGlock1 ); - gEngfuncs.pfnHookEvent( "events/glock2.sc", EV_FireGlock2 ); + // gEngfuncs.pfnHookEvent( "events/glock1.sc", EV_FireGlock1 ); + // gEngfuncs.pfnHookEvent( "events/glock2.sc", EV_FireGlock2 ); gEngfuncs.pfnHookEvent( "events/shotgun1.sc", EV_FireShotGunSingle ); - gEngfuncs.pfnHookEvent( "events/shotgun2.sc", EV_FireShotGunDouble ); - gEngfuncs.pfnHookEvent( "events/mp5.sc", EV_FireMP5 ); - gEngfuncs.pfnHookEvent( "events/mp52.sc", EV_FireMP52 ); - gEngfuncs.pfnHookEvent( "events/python.sc", EV_FirePython ); - gEngfuncs.pfnHookEvent( "events/gauss.sc", EV_FireGauss ); - gEngfuncs.pfnHookEvent( "events/gaussspin.sc", EV_SpinGauss ); - gEngfuncs.pfnHookEvent( "events/train.sc", EV_TrainPitchAdjust ); - gEngfuncs.pfnHookEvent( "events/crowbar.sc", EV_Crowbar ); - gEngfuncs.pfnHookEvent( "events/crossbow1.sc", EV_FireCrossbow ); - gEngfuncs.pfnHookEvent( "events/crossbow2.sc", EV_FireCrossbow2 ); - gEngfuncs.pfnHookEvent( "events/rpg.sc", EV_FireRpg ); - gEngfuncs.pfnHookEvent( "events/egon_fire.sc", EV_EgonFire ); - gEngfuncs.pfnHookEvent( "events/egon_stop.sc", EV_EgonStop ); - gEngfuncs.pfnHookEvent( "events/firehornet.sc", EV_HornetGunFire ); - gEngfuncs.pfnHookEvent( "events/tripfire.sc", EV_TripmineFire ); - gEngfuncs.pfnHookEvent( "events/snarkfire.sc", EV_SnarkFire ); - - gEngfuncs.pfnHookEvent( "events/heaterpipe.sc", EV_HeaterPipe ); - gEngfuncs.pfnHookEvent( "events/bradnailer.sc", EV_FireBradnailer ); - gEngfuncs.pfnHookEvent( "events/nailgun.sc", EV_FireNailgun ); - gEngfuncs.pfnHookEvent( "events/cmlwbr.sc", EV_FireCmlwbr ); gEngfuncs.pfnHookEvent( "events/xsspin.sc", EV_SpinXS ); - gEngfuncs.pfnHookEvent( "events/xs.sc", EV_FireXS ); - gEngfuncs.pfnHookEvent( "events/reload.sc", EV_Reload ); gEngfuncs.pfnHookEvent( "events/par21.sc", EV_FirePar21 ); gEngfuncs.pfnHookEvent( "events/m203.sc", EV_M203 ); + gEngfuncs.pfnHookEvent( "events/train.sc", EV_TrainPitchAdjust ); } diff --git a/cl_dll/hl/hl_objects.cpp b/cl_dll/hl/hl_objects.cpp index b51ee693..dfeb4e1f 100644 --- a/cl_dll/hl/hl_objects.cpp +++ b/cl_dll/hl/hl_objects.cpp @@ -27,54 +27,10 @@ #include "entity_types.h" #include "r_efx.h" -extern BEAM *pBeam; -extern BEAM *pBeam2; void HUD_GetLastOrg( float *org ); void UpdateBeams( void ) { - vec3_t forward, vecSrc, vecEnd, origin, angles, right, up; - vec3_t view_ofs; - pmtrace_t tr; - cl_entity_t *pthisplayer = gEngfuncs.GetLocalPlayer(); - int idx = pthisplayer->index; - - // Get our exact viewangles from engine - gEngfuncs.GetViewAngles( (float *)angles ); - - // Determine our last predicted origin - HUD_GetLastOrg( (float *)&origin ); - - AngleVectors( angles, forward, right, up ); - - VectorCopy( origin, vecSrc ); - - VectorMA( vecSrc, 2048, forward, vecEnd ); - - gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction( false, true ); - - // Store off the old count - gEngfuncs.pEventAPI->EV_PushPMStates(); - - // Now add in all of the players. - gEngfuncs.pEventAPI->EV_SetSolidPlayers( idx - 1 ); - - gEngfuncs.pEventAPI->EV_SetTraceHull( 2 ); - gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecEnd, PM_STUDIO_BOX, -1, &tr ); - - gEngfuncs.pEventAPI->EV_PopPMStates(); - - 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. - } - - 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. - } } /* @@ -86,6 +42,4 @@ Add game specific, client-side objects here */ void Game_AddObjects( void ) { - if( pBeam && pBeam2 ) - UpdateBeams(); } diff --git a/cl_dll/hl/hl_weapons.cpp b/cl_dll/hl/hl_weapons.cpp index 745421a5..9cc6d62e 100644 --- a/cl_dll/hl/hl_weapons.cpp +++ b/cl_dll/hl/hl_weapons.cpp @@ -53,11 +53,6 @@ int g_irunninggausspred = 0; vec3_t previousorigin; // HLDM Weapon placeholder entities. -CHeaterPipe g_HeaterPipe; -CCmlwbr g_Cmlwbr; -CShotgun g_Shotgun; -CPipeBomb g_PipeBomb; -CPar21 g_Par21; /* ====================== AlertMessage @@ -65,7 +60,7 @@ AlertMessage Print debug messages to console ====================== */ -void AlertMessage( ALERT_TYPE atype, char *szFmt, ... ) +void AlertMessage( ALERT_TYPE atype, const char *szFmt, ... ) { va_list argptr; static char string[1024]; @@ -86,7 +81,7 @@ bool bIsMultiplayer( void ) } //Just loads a v_ model. -void LoadVModel( char *szViewModel, CBasePlayer *m_pPlayer ) +void LoadVModel( const char *szViewModel, CBasePlayer *m_pPlayer ) { gEngfuncs.CL_LoadModel( szViewModel, &m_pPlayer->pev->viewmodel ); } @@ -141,7 +136,7 @@ BOOL CBasePlayerWeapon::DefaultReload( int iClipSize, int iAnim, float fDelay, i if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) return FALSE; - int j = min( iClipSize - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ); + int j = Q_min( iClipSize - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ); if( j == 0 ) return FALSE; @@ -198,7 +193,7 @@ CBasePlayerWeapon::DefaultDeploy ===================== */ -BOOL CBasePlayerWeapon::DefaultDeploy( char *szViewModel, char *szWeaponModel, int iAnim, char *szAnimExt, int skiplocal, int body ) +BOOL CBasePlayerWeapon::DefaultDeploy( const char *szViewModel, const char *szWeaponModel, int iAnim, const char *szAnimExt, int skiplocal, int body ) { if( !CanDeploy() ) return FALSE; @@ -278,7 +273,7 @@ Only produces random numbers to match the server ones. */ Vector CBaseEntity::FireBulletsPlayer ( ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker, int shared_rand ) { - float x = 0, y = 0, z; + float x = 0.0f, y = 0.0f, z; for( ULONG iShot = 1; iShot <= cShots; iShot++ ) { @@ -550,27 +545,6 @@ void UTIL_ParticleLine( CBasePlayer *player, float *start, float *end, float lif gEngfuncs.pEfxAPI->R_ParticleLine( start, end, r, g, b, life ); } -/* -===================== -CBasePlayerWeapon::PrintState - -For debugging, print out state variables to log file -===================== -*/ -void CBasePlayerWeapon::PrintState( void ) -{ - COM_Log( "c:\\hl.log", "%.4f ", gpGlobals->time ); - COM_Log( "c:\\hl.log", "%.4f ", m_pPlayer->m_flNextAttack ); - COM_Log( "c:\\hl.log", "%.4f ", m_flNextPrimaryAttack ); - COM_Log( "c:\\hl.log", "%.4f ", m_flTimeWeaponIdle - gpGlobals->time ); - COM_Log( "c:\\hl.log", "%i ", m_iClip ); -} - -int RandomLong( int a, int b ) -{ - return gEngfuncs.pfnRandomLong( a, b ); -} - /* ===================== HUD_InitClientWeapons @@ -611,13 +585,6 @@ void HUD_InitClientWeapons( void ) // Allocate a slot for the local player HUD_PrepEntity( &player, NULL ); - - // Allocate slot(s) for each weapon that we are going to be predicting - HUD_PrepEntity( &g_HeaterPipe, &player ); - HUD_PrepEntity( &g_Shotgun, &player ); - HUD_PrepEntity( &g_Cmlwbr, &player ); - HUD_PrepEntity( &g_PipeBomb, &player ); - HUD_PrepEntity( &g_Par21, &player ); } /* @@ -679,24 +646,6 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm // Fill in data based on selected weapon // FIXME, make this a method in each weapon? where you pass in an entity_state_t *? - switch( from->client.m_iId ) - { - case WEAPON_HEATERPIPE: - pWeapon = &g_HeaterPipe; - break; - case WEAPON_SHOTGUN: - pWeapon = &g_Shotgun; - break; - case WEAPON_CMLWBR: - pWeapon = &g_Cmlwbr; - break; - case WEAPON_PIPEBOMB: - pWeapon = &g_PipeBomb; - break; - case WEAPON_PAR21: - pWeapon = &g_Par21; - break; - } // Store pointer to our destination entity_state_t so we can get our origin, etc. from it // for setting up events on the client @@ -741,11 +690,6 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm pCurrent->m_flNextSecondaryAttack = pfrom->m_flNextSecondaryAttack; pCurrent->m_flTimeWeaponIdle = pfrom->m_flTimeWeaponIdle; pCurrent->pev->fuser1 = pfrom->fuser1; - pCurrent->m_flStartThrow = pfrom->fuser2; - pCurrent->m_flReleaseThrow = pfrom->fuser3; - pCurrent->m_chargeReady = pfrom->iuser1; - pCurrent->m_fInAttack = pfrom->iuser2; - pCurrent->m_fireState = pfrom->iuser3; pCurrent->m_iSecondaryAmmoType = (int)from->client.vuser3[2]; pCurrent->m_iPrimaryAmmoType = (int)from->client.vuser4[0]; @@ -784,36 +728,12 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm player.m_flNextAmmoBurn = from->client.fuser2; player.m_flAmmoStartCharge = from->client.fuser3; - //Stores all our ammo info, so the client side weapons can use them. - player.ammo_9mm = (int)from->client.vuser1[0]; - player.ammo_357 = (int)from->client.vuser1[1]; - player.ammo_argrens = (int)from->client.vuser1[2]; - player.ammo_bolts = (int)from->client.ammo_nails; //is an int anyways... - player.ammo_buckshot = (int)from->client.ammo_shells; - player.ammo_uranium = (int)from->client.ammo_cells; - player.ammo_hornets = (int)from->client.vuser2[0]; - player.ammo_rockets = (int)from->client.ammo_rockets; - // Point to current weapon object if( from->client.m_iId ) { player.m_pActiveItem = g_pWpns[from->client.m_iId]; } - if( player.m_pActiveItem->m_iId == WEAPON_BRADNAILER || player.m_pActiveItem->m_iId == WEAPON_NAILGUN ) - { - player.ammo_nails = (int)from->client.vuser2[1]; - } - else if( player.m_pActiveItem->m_iId == WEAPON_XS ) - { - player.ammo_xencandy = (int)from->client.vuser2[1]; - } - else if( player.m_pActiveItem->m_iId == WEAPON_PAR21 ) - { - player.ammo_par21 = (int)from->client.vuser2[1]; - player.ammo_m203grens = (int)from->client.vuser2[2]; - } - // Don't go firing anything if we have died. // Or if we don't have a weapon model deployed if( ( player.pev->deadflag != ( DEAD_DISCARDBODY + 1 ) ) && @@ -865,31 +785,6 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm to->client.fuser3 = player.m_flAmmoStartCharge; to->client.maxspeed = player.pev->maxspeed; - //HL Weapons - to->client.vuser1[0] = player.ammo_9mm; - to->client.vuser1[1] = player.ammo_357; - to->client.vuser1[2] = player.ammo_argrens; - - to->client.ammo_nails = player.ammo_bolts; - to->client.ammo_shells = player.ammo_buckshot; - to->client.ammo_cells = player.ammo_uranium; - to->client.vuser2[0] = player.ammo_hornets; - to->client.ammo_rockets = player.ammo_rockets; - - if( player.m_pActiveItem->m_iId == WEAPON_BRADNAILER || player.m_pActiveItem->m_iId == WEAPON_NAILGUN ) - { - from->client.vuser2[1] = player.ammo_nails; - } - else if( player.m_pActiveItem->m_iId == WEAPON_XS ) - { - from->client.vuser2[1] = player.ammo_xencandy; - } - else if( player.m_pActiveItem->m_iId == WEAPON_PAR21 ) - { - from->client.vuser2[1] = player.ammo_par21; - from->client.vuser2[2] = player.ammo_m203grens; - } - // 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 ) ) @@ -920,11 +815,6 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm pto->m_flNextSecondaryAttack = pCurrent->m_flNextSecondaryAttack; pto->m_flTimeWeaponIdle = pCurrent->m_flTimeWeaponIdle; pto->fuser1 = pCurrent->pev->fuser1; - pto->fuser2 = pCurrent->m_flStartThrow; - pto->fuser3 = pCurrent->m_flReleaseThrow; - pto->iuser1 = pCurrent->m_chargeReady; - pto->iuser2 = pCurrent->m_fInAttack; - 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; diff --git a/cl_dll/hud.cpp b/cl_dll/hud.cpp index 696f436d..47c5c0d2 100644 --- a/cl_dll/hud.cpp +++ b/cl_dll/hud.cpp @@ -35,6 +35,7 @@ extern client_sprite_t *GetSpriteList( client_sprite_t *pList, const char *psz, extern cvar_t *sensitivity; cvar_t *cl_lw = NULL; +cvar_t *cl_viewbob = NULL; void ShutdownInput( void ); @@ -77,9 +78,26 @@ int __MsgFunc_GameMode( const char *pszName, int iSize, void *pbuf ) return gHUD.MsgFunc_GameMode( pszName, iSize, pbuf ); } -int __MsgFunc_StartUp( const char *pszName, int iSize, void *pbuf ) +int __MsgFunc_PlayMP3( const char *pszName, int iSize, void *pbuf ) { - return gHUD.MsgFunc_StartUp( pszName, iSize, pbuf ); + const char *pszSound; + char cmd[64], path[64]; + int loop; + + BEGIN_READ( pbuf, iSize ); + pszSound = READ_STRING(); + loop = READ_BYTE(); + + sprintf( path, "sound/%s", pszSound ); + if( !IsXashFWGS() && gEngfuncs.pfnGetCvarPointer( "gl_overbright" ) ) + { + sprintf( cmd, "mp3 play %s\n", path ); + gEngfuncs.pfnClientCmd( cmd ); + } + else + gEngfuncs.pfnPrimeMusicStream( path, loop ); + + return 1; } // TFFree Command Menu @@ -165,7 +183,7 @@ void CHud::Init( void ) HOOK_MESSAGE( ViewMode ); HOOK_MESSAGE( SetFOV ); HOOK_MESSAGE( Concuss ); - HOOK_MESSAGE( StartUp ); + HOOK_MESSAGE( PlayMP3 ); // TFFree CommandMenu HOOK_COMMAND( "+commandmenu", OpenCommandMenu ); @@ -194,14 +212,13 @@ void CHud::Init( void ) m_iLogo = 0; m_iFOV = 0; - m_flAlpha = 0; - m_flTargetAlpha = 0; CVAR_CREATE( "zoom_sensitivity_ratio", "1.2", 0 ); default_fov = CVAR_CREATE( "default_fov", "90", 0 ); m_pCvarStealMouse = CVAR_CREATE( "hud_capturemouse", "1", FCVAR_ARCHIVE ); m_pCvarDraw = CVAR_CREATE( "hud_draw", "1", FCVAR_ARCHIVE ); cl_lw = gEngfuncs.pfnGetCvarPointer( "cl_lw" ); + cl_viewbob = CVAR_CREATE( "cl_viewbob", "0", FCVAR_ARCHIVE ); m_pSpriteList = NULL; @@ -235,7 +252,6 @@ void CHud::Init( void ) m_AmmoSecondary.Init(); m_TextMessage.Init(); m_StatusIcons.Init(); - m_Scope.Init(); m_MOTD.Init(); m_Scoreboard.Init(); @@ -388,6 +404,18 @@ void CHud::VidInit( void ) // assumption: number_1, number_2, etc, are all listed and loaded sequentially m_HUD_number_0 = GetSpriteIndex( "number_0" ); + if( m_HUD_number_0 == -1 ) + { + const char *msg = "There is something wrong with your game data! Please, reinstall\n"; + + if( HUD_MessageBox( msg ) ) + { + gEngfuncs.pfnClientCmd( "quit\n" ); + } + + return; + } + m_iFontHeight = m_rgrcRects[m_HUD_number_0].bottom - m_rgrcRects[m_HUD_number_0].top; m_Ammo.VidInit(); @@ -405,7 +433,6 @@ void CHud::VidInit( void ) m_AmmoSecondary.VidInit(); m_TextMessage.VidInit(); m_StatusIcons.VidInit(); - m_Scope.VidInit(); m_Scoreboard.VidInit(); m_MOTD.VidInit(); } @@ -521,10 +548,6 @@ int CHud::MsgFunc_SetFOV( const char *pszName, int iSize, void *pbuf ) int newfov = READ_BYTE(); int def_fov = CVAR_GET_FLOAT( "default_fov" ); - //Weapon prediction already takes care of changing the fog. ( g_lastFOV ). - if( cl_lw && cl_lw->value ) - return 1; - g_lastFOV = newfov; if( newfov == 0 ) @@ -588,29 +611,3 @@ float CHud::GetSensitivity( void ) return m_flMouseSensitivity; } -int CHud::MsgFunc_StartUp( const char *pszName, int iSize, void *pbuf ) -{ - BEGIN_READ( pbuf, iSize ); - - // Target alpha - float alpha = READ_BYTE(); - - if( alpha < 0 ) - alpha = 0; - else if( alpha > 255 ) - alpha = 255; - - m_flTargetAlpha = alpha; - - // Start alpha - alpha = READ_BYTE(); - - if( alpha < 0 ) - alpha = 0; - else if( alpha > 255 ) - alpha = 255; - - m_flAlpha = alpha; - - return 1; -} diff --git a/cl_dll/hud.h b/cl_dll/hud.h index 5ec97208..284ff853 100644 --- a/cl_dll/hud.h +++ b/cl_dll/hud.h @@ -19,9 +19,12 @@ // // CHud handles the message, calculation, and drawing the HUD // - -#define RGB_YELLOWISH 0x00FFFFFF //255,255,255 -#define RGB_REDISH 0x00FF1010 //255,160,0 +#pragma once +#ifndef HUD_H +#define HUD_H +#define RGB_YELLOWISH 0x00C1CFCB //193,207,203 +#define RGB_WHITEISH 0x00FAFAFA //250,250,250 +#define RGB_REDISH 0x00FA0000 //250,0,0 #define RGB_GREENISH 0x0000A000 //0,160,0 #include "wrect.h" @@ -130,6 +133,7 @@ private: WEAPON *m_pWeapon; int m_HUD_bucket0; int m_HUD_selection; + int m_HUD_stripe; }; // @@ -228,7 +232,7 @@ public: 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 + int DrawPlayers( int xoffset, float listslot, int nameoffset = 0, const 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 ); @@ -480,7 +484,7 @@ public: int Init( void ); static char *LocaliseTextString( const char *msg, char *dst_buffer, int buffer_size ); static char *BufferedLocaliseTextString( const char *msg ); - char *LookupString( const char *msg_name, int *msg_dest = NULL ); + const char *LookupString( const char *msg_name, int *msg_dest = NULL ); int MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf ); }; @@ -541,8 +545,8 @@ public: //had to make these public so CHud could access them (to enable concussion icon) //could use a friend declaration instead... - void EnableIcon( char *pszIconName, unsigned char red, unsigned char green, unsigned char blue ); - void DisableIcon( char *pszIconName ); + void EnableIcon( const char *pszIconName, unsigned char red, unsigned char green, unsigned char blue ); + void DisableIcon( const char *pszIconName ); private: typedef struct @@ -559,15 +563,9 @@ private: // //----------------------------------------------------- // -class CHudScope : public CHudBase +class CHudScope { public: - int Init( void ); - int VidInit( void ); - int Draw( float flTime ); - void Reset( void ); - int MsgFunc_Scope( const char *pszName, int iSize, void *pbuf ); - int DrawScope( void ); private: @@ -593,6 +591,7 @@ public: HSPRITE m_hsprCursor; float m_flTime; // the current client time float m_fOldTime; // the time at which the HUD was last redrawn + float m_flScaleColorTime; double m_flTimeDelta; // the difference between flTime and fOldTime Vector m_vecOrigin; Vector m_vecAngles; @@ -606,11 +605,11 @@ public: int m_iFontHeight; int DrawHudNumber( int x, int y, int iFlags, int iNumber, int r, int g, int b ); - int DrawHudString( int x, int y, int iMaxX, char *szString, int r, int g, int b ); - int DrawHudStringReverse( int xpos, int ypos, int iMinX, char *szString, int r, int g, int b ); + int DrawHudString( int x, int y, int iMaxX, const char *szString, int r, int g, int b ); + int DrawHudStringReverse( int xpos, int ypos, int iMinX, const char *szString, int r, int g, int b ); int DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b ); int GetNumWidth( int iNumber, int iFlags ); - int DrawHudStringLen( char *szIt ); + int DrawHudStringLen( const char *szIt ); void DrawDarkRectangle( int x, int y, int wide, int tall ); private: @@ -671,7 +670,6 @@ public: void _cdecl MsgFunc_ViewMode( const char *pszName, int iSize, void *pbuf ); int _cdecl MsgFunc_SetFOV( const char *pszName, int iSize, void *pbuf ); int _cdecl MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf ); - int _cdecl MsgFunc_StartUp( const char *pszName, int iSize, void *pbuf ); // Screen information SCREENINFO m_scrinfo; @@ -688,11 +686,6 @@ public: void AddHudElem( CHudBase *p ); float GetSensitivity(); - - float m_flAlpha; - -private: - float m_flTargetAlpha; }; extern CHud gHUD; @@ -702,3 +695,4 @@ extern int g_iTeamNumber; extern int g_iUser1; extern int g_iUser2; extern int g_iUser3; +#endif diff --git a/cl_dll/hud_iface.h b/cl_dll/hud_iface.h index a7a05e7e..73464c83 100644 --- a/cl_dll/hud_iface.h +++ b/cl_dll/hud_iface.h @@ -1,13 +1,13 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // // $NoKeywords: $ //============================================================================= +#pragma once #if !defined( HUD_IFACEH ) #define HUD_IFACEH -#pragma once #include "exportdef.h" diff --git a/cl_dll/hud_msg.cpp b/cl_dll/hud_msg.cpp index 47f8bc92..75c1b50c 100644 --- a/cl_dll/hud_msg.cpp +++ b/cl_dll/hud_msg.cpp @@ -23,9 +23,7 @@ #define MAX_CLIENTS 32 -extern BEAM *pBeam; -extern BEAM *pBeam2; - +extern float g_lastFOV; // Vit_amiN /// USER-DEFINED SERVER MESSAGE HANDLERS int CHud::MsgFunc_ResetHUD( const char *pszName, int iSize, void *pbuf ) @@ -48,6 +46,10 @@ int CHud::MsgFunc_ResetHUD( const char *pszName, int iSize, void *pbuf ) // reset concussion effect m_iConcussionEffect = 0; + // Vit_amiN: reset the FOV + m_iFOV = 0; // default_fov + g_lastFOV = 0.0f; + return 1; } @@ -69,9 +71,6 @@ void CHud::MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf ) pList->p->InitHUDData(); pList = pList->pNext; } - - //Probably not a good place to put this. - pBeam = pBeam2 = NULL; } int CHud::MsgFunc_GameMode( const char *pszName, int iSize, void *pbuf ) @@ -107,10 +106,14 @@ int CHud::MsgFunc_Damage( const char *pszName, int iSize, void *pbuf ) int CHud::MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf ) { + int r, g, b; BEGIN_READ( pbuf, iSize ); m_iConcussionEffect = READ_BYTE(); if( m_iConcussionEffect ) - this->m_StatusIcons.EnableIcon( "dmg_concuss", 255, 160, 0 ); + { + UnpackRGB( r, g, b, RGB_YELLOWISH ); // Vit_amiN: fixed + this->m_StatusIcons.EnableIcon( "dmg_concuss", r, g, b ); + } else this->m_StatusIcons.DisableIcon( "dmg_concuss" ); return 1; diff --git a/cl_dll/hud_redraw.cpp b/cl_dll/hud_redraw.cpp index 170e6fdb..f63b6832 100644 --- a/cl_dll/hud_redraw.cpp +++ b/cl_dll/hud_redraw.cpp @@ -79,7 +79,6 @@ void CHud::Think( void ) } } -void HUD_DrawOrthoTriangles( void ); // Redraw // step through the local data, placing the appropriate graphics & text as appropriate @@ -95,6 +94,13 @@ int CHud::Redraw( float flTime, int intermission ) if( m_flTimeDelta < 0 ) m_flTimeDelta = 0; + 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 + } + if( m_flShotTime && m_flShotTime < flTime ) { gEngfuncs.pfnClientCmd( "snapshot\n" ); @@ -106,8 +112,6 @@ int CHud::Redraw( float flTime, int intermission ) // if no redrawing is necessary // return 0; - HUD_DrawOrthoTriangles(); - if( m_pCvarDraw->value ) { HUDLIST *pList = m_pHudList; @@ -173,23 +177,26 @@ int CHud::Redraw( float flTime, int intermission ) } */ - // - // Slowly increase HUD alpha value. - // - if( m_flAlpha != m_flTargetAlpha ) - { - if( m_flAlpha < m_flTargetAlpha ) - m_flAlpha = min( m_flAlpha + 2, m_flTargetAlpha ); - else if( m_flAlpha > m_flTargetAlpha ) - m_flAlpha = max( m_flAlpha - 8, m_flTargetAlpha ); - } - return 1; } void ScaleColors( int &r, int &g, int &b, int a ) { - float x = (float)a / 255; + float f = 1.0; + if( gHUD.m_flScaleColorTime != 0.0f ) + { + float flTimeDiff = gHUD.m_flScaleColorTime - gHUD.m_flTime; + if( flTimeDiff > 0.0f && flTimeDiff >= 1.0f ) + { + flTimeDiff = 1.0f; + } + else if( flTimeDiff <= 0.0f ) + { + flTimeDiff = 0.0f; + } + f = 1.0f - flTimeDiff; + } + float x = f * (float)a / 255; r = (int)( r * x ); g = (int)( g * x ); b = (int)( b * x ); @@ -207,7 +214,7 @@ const unsigned char colors[8][3] = {240, 180, 24} }; -int CHud::DrawHudString( int xpos, int ypos, int iMaxX, char *szIt, int r, int g, int b ) +int CHud::DrawHudString( int xpos, int ypos, int iMaxX, const char *szIt, int r, int g, int b ) { if( hud_textmode->value == 2 ) { @@ -241,7 +248,40 @@ int CHud::DrawHudString( int xpos, int ypos, int iMaxX, char *szIt, int r, int g return xpos; } -int CHud::DrawHudStringLen( char *szIt ) +int DrawUtfString( int xpos, int ypos, int iMaxX, const char *szIt, int r, int g, int b ) +{ + if (IsXashFWGS()) + { + // xash3d: reset unicode state + gEngfuncs.pfnVGUI2DrawCharacterAdditive( 0, 0, 0, 0, 0, 0, 0 ); + + // draw the string until we hit the null character or a newline character + for( ; *szIt != 0 && *szIt != '\n'; szIt++ ) + { + int w = gHUD.m_scrinfo.charWidths['M']; + if( xpos + w > iMaxX ) + return xpos; + if( ( *szIt == '^' ) && ( *( szIt + 1 ) >= '0') && ( *( szIt + 1 ) <= '7') ) + { + szIt++; + r = colors[*szIt - '0'][0]; + g = colors[*szIt - '0'][1]; + b = colors[*szIt - '0'][2]; + if( !*(++szIt) ) + return xpos; + } + int c = (unsigned int)(unsigned char)*szIt; + xpos += gEngfuncs.pfnVGUI2DrawCharacterAdditive( xpos, ypos, c, r, g, b, 0 ); + } + return xpos; + } + else + { + return gHUD.DrawHudString(xpos, ypos, iMaxX, szIt, r, g, b); + } +} + +int CHud::DrawHudStringLen( const char *szIt ) { int l = 0; for( ; *szIt != 0 && *szIt != '\n'; szIt++ ) @@ -259,10 +299,10 @@ int CHud::DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r } // draws a string from right to left (right-aligned) -int CHud::DrawHudStringReverse( int xpos, int ypos, int iMinX, char *szString, int r, int g, int b ) +int CHud::DrawHudStringReverse( int xpos, int ypos, int iMinX, const char *szString, int r, int g, int b ) { // find the end of the string - for( char *szIt = szString; *szIt != 0; szIt++ ) + for( const char *szIt = szString; *szIt != 0; szIt++ ) xpos -= gHUD.m_scrinfo.charWidths[(unsigned char)*szIt]; if( xpos < iMinX ) xpos = iMinX; diff --git a/cl_dll/hud_servers.cpp b/cl_dll/hud_servers.cpp index 67973c75..fa6d5585 100644 --- a/cl_dll/hud_servers.cpp +++ b/cl_dll/hud_servers.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/hud_servers.h b/cl_dll/hud_servers.h index 33fb72a5..5e886560 100644 --- a/cl_dll/hud_servers.h +++ b/cl_dll/hud_servers.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/hud_servers_priv.h b/cl_dll/hud_servers_priv.h index d26b3655..72590c2f 100644 --- a/cl_dll/hud_servers_priv.h +++ b/cl_dll/hud_servers_priv.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/hud_spectator.cpp b/cl_dll/hud_spectator.cpp index ff6eb8ff..edb743ba 100644 --- a/cl_dll/hud_spectator.cpp +++ b/cl_dll/hud_spectator.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // @@ -175,13 +175,13 @@ void UTIL_StringToVector( float * pVector, const char *pString ) } } -int UTIL_FindEntityInMap( char * name, float * origin, float * angle ) +int UTIL_FindEntityInMap( const char *name, float *origin, float *angle ) { int n, found = 0; char keyname[256]; char token[2048]; - cl_entity_t * pEnt = gEngfuncs.GetEntityByIndex( 0 ); // get world model + cl_entity_t *pEnt = gEngfuncs.GetEntityByIndex( 0 ); // get world model if( !pEnt ) return 0; @@ -189,7 +189,7 @@ int UTIL_FindEntityInMap( char * name, float * origin, float * angle ) if( !pEnt->model ) return 0; - char * data = pEnt->model->entities; + char *data = pEnt->model->entities; while( data ) { @@ -1374,12 +1374,12 @@ void CHudSpectator::DeathMessage( int victim ) AddOverviewEntityToList(m_hsprPlayerDead, pl, gEngfuncs.GetClientTime() + 2.0f ); } -bool CHudSpectator::AddOverviewEntityToList(HSPRITE sprite, cl_entity_t *ent, double killTime) +bool CHudSpectator::AddOverviewEntityToList( HSPRITE sprite, cl_entity_t *ent, double killTime ) { for( int i = 0; i < MAX_OVERVIEW_ENTITIES; i++ ) { // find empty entity slot - if( m_OverviewEntities[i].entity == NULL) + if( m_OverviewEntities[i].entity == NULL ) { m_OverviewEntities[i].entity = ent; m_OverviewEntities[i].hSprite = sprite; diff --git a/cl_dll/hud_spectator.h b/cl_dll/hud_spectator.h index f60353db..9b3391e2 100644 --- a/cl_dll/hud_spectator.h +++ b/cl_dll/hud_spectator.h @@ -1,13 +1,13 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // // $NoKeywords: $ //============================================================================= -#ifndef SPECTATOR_H -#define SPECTATOR_H #pragma once +#ifndef HUD_SPECTATOR_H +#define HUD_SPECTATOR_H #include "cl_entity.h" @@ -64,11 +64,11 @@ public: void CheckOverviewEntities(); void DrawOverview(); void DrawOverviewEntities(); - void GetMapPosition( float * returnvec ); + void GetMapPosition( float *returnvec ); void DrawOverviewLayer(); void LoadMapSprites(); bool ParseOverviewFile(); - bool IsActivePlayer( cl_entity_t * ent ); + bool IsActivePlayer( cl_entity_t *ent ); void SetModes( int iMainMode, int iInsetMode ); void HandleButtonsDown( int ButtonPressed ); void HandleButtonsUp( int ButtonPressed ); diff --git a/cl_dll/in_camera.cpp b/cl_dll/in_camera.cpp index 92051afe..12ad41f4 100644 --- a/cl_dll/in_camera.cpp +++ b/cl_dll/in_camera.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/in_defs.h b/cl_dll/in_defs.h index 037c7cc6..b4c51730 100644 --- a/cl_dll/in_defs.h +++ b/cl_dll/in_defs.h @@ -1,13 +1,13 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // // $NoKeywords: $ //============================================================================= +#pragma once #if !defined( IN_DEFSH ) #define IN_DEFSH -#pragma once // up / down #define PITCH 0 diff --git a/cl_dll/input.cpp b/cl_dll/input.cpp index fd1ef7da..0abd542b 100644 --- a/cl_dll/input.cpp +++ b/cl_dll/input.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/input_goldsource.cpp b/cl_dll/input_goldsource.cpp new file mode 100644 index 00000000..c45841cb --- /dev/null +++ b/cl_dll/input_goldsource.cpp @@ -0,0 +1,1607 @@ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +// in_win.c -- windows 95 mouse and joystick code +// 02/21/97 JCB Added extended DirectInput code to support external controllers. + +#include "input_mouse.h" + +#ifdef SUPPORT_GOLDSOURCE_INPUT + +#include "hud.h" +#include "cl_util.h" +#include "camera.h" +#include "kbutton.h" +#include "cvardef.h" +#include "const.h" +#include "camera.h" +#include "in_defs.h" +#include "keydefs.h" +#include "view.h" + +#ifndef _WIN32 +#define USE_SDL2 +#endif + +#ifdef USE_SDL2 +#define ARRAYSIZE(p) ( sizeof(p) /sizeof(p[0]) ) +#include +#include +#include +int (*pfnSDL_SetRelativeMouseMode)(SDL_bool); +Uint32 (*pfnSDL_GetRelativeMouseState)(int* x, int* y); +int (*pfnSDL_NumJoysticks)(void); +SDL_bool (*pfnSDL_IsGameController)(int); +SDL_GameController* (*pfnSDL_GameControllerOpen)(int); +Sint16 (*pfnSDL_GameControllerGetAxis)(SDL_GameController*, SDL_GameControllerAxis); +Uint8 (*pfnSDL_GameControllerGetButton)(SDL_GameController*, SDL_GameControllerButton); +void (*pfnSDL_JoystickUpdate)(void); +const char* (*pfnSDL_GameControllerName)(SDL_GameController*); + +int safe_pfnSDL_SetRelativeMouseMode(SDL_bool mode) +{ + if (pfnSDL_SetRelativeMouseMode) + return pfnSDL_SetRelativeMouseMode(mode); + return -1; +} +Uint32 safe_pfnSDL_GetRelativeMouseState(int* x, int* y) +{ + if (pfnSDL_GetRelativeMouseState) + return pfnSDL_GetRelativeMouseState(x, y); + return 0; +} +int safe_pfnSDL_NumJoysticks() +{ + if (pfnSDL_NumJoysticks) + return pfnSDL_NumJoysticks(); + return -1; +} +SDL_bool safe_pfnSDL_IsGameController(int joystick_index) +{ + if (pfnSDL_IsGameController) + return pfnSDL_IsGameController(joystick_index); + return SDL_FALSE; +} +SDL_GameController* safe_pfnSDL_GameControllerOpen(int joystick_index) +{ + if (pfnSDL_GameControllerOpen) + return pfnSDL_GameControllerOpen(joystick_index); + return NULL; +} +Sint16 safe_pfnSDL_GameControllerGetAxis(SDL_GameController* gamecontroller, SDL_GameControllerAxis axis) +{ + if (pfnSDL_GameControllerGetAxis) + return pfnSDL_GameControllerGetAxis(gamecontroller, axis); + return 0; +} +Uint8 safe_pfnSDL_GameControllerGetButton(SDL_GameController* gamecontroller, SDL_GameControllerButton button) +{ + if (pfnSDL_GameControllerGetButton) + return pfnSDL_GameControllerGetButton(gamecontroller, button); + return 0; +} +void safe_pfnSDL_JoystickUpdate() +{ + if (pfnSDL_JoystickUpdate) + pfnSDL_JoystickUpdate(); +} +const char* safe_pfnSDL_GameControllerName(SDL_GameController* gamecontroller) +{ + if (pfnSDL_GameControllerName) + return pfnSDL_GameControllerName(gamecontroller); + return NULL; +} + +struct SDLFunction +{ + void** ppfnFunc; + const char* name; +}; +static SDLFunction sdlFunctions[] = { + {(void**)&pfnSDL_SetRelativeMouseMode, "SDL_SetRelativeMouseMode"}, + {(void**)&pfnSDL_GetRelativeMouseState, "SDL_GetRelativeMouseState"}, + {(void**)&pfnSDL_NumJoysticks, "SDL_NumJoysticks"}, + {(void**)&pfnSDL_IsGameController, "SDL_IsGameController"}, + {(void**)&pfnSDL_GameControllerOpen, "SDL_GameControllerOpen"}, + {(void**)&pfnSDL_GameControllerGetAxis, "SDL_GameControllerGetAxis"}, + {(void**)&pfnSDL_GameControllerGetButton, "SDL_GameControllerGetButton"}, + {(void**)&pfnSDL_JoystickUpdate, "SDL_JoystickUpdate"}, + {(void**)&pfnSDL_GameControllerName, "SDL_GameControllerName"} +}; +#endif + +#ifdef _WIN32 +#include +#else +typedef unsigned int DWORD; +#endif + +#define MOUSE_BUTTON_COUNT 5 + +// use IN_SetVisibleMouse to set: +int iVisibleMouse = 0; + +extern cl_enginefunc_t gEngfuncs; + +extern int iMouseInUse; + +extern kbutton_t in_strafe; +extern kbutton_t in_mlook; +extern kbutton_t in_speed; +extern kbutton_t in_jlook; + +extern cvar_t *m_pitch; +extern cvar_t *m_yaw; +extern cvar_t *m_forward; +extern cvar_t *m_side; + +extern cvar_t *lookstrafe; +extern cvar_t *lookspring; +extern cvar_t *cl_pitchdown; +extern cvar_t *cl_pitchup; +extern cvar_t *cl_yawspeed; +extern cvar_t *cl_sidespeed; +extern cvar_t *cl_forwardspeed; +extern cvar_t *cl_pitchspeed; +extern cvar_t *cl_movespeedkey; + +#ifdef _WIN32 +static double s_flRawInputUpdateTime = 0.0f; +static bool m_bRawInput = false; +static bool m_bMouseThread = false; +bool isMouseRelative = false; +#endif + +#ifdef _WIN32 +#include "progdefs.h" +extern globalvars_t *gpGlobals; +#endif + +extern Vector dead_viewangles; + +void V_StopPitchDrift( void ) +{ + +} + +// mouse variables +cvar_t *m_filter; +extern cvar_t *sensitivity; + +// Custom mouse acceleration (0 disable, 1 to enable, 2 enable with separate yaw/pitch rescale) +static cvar_t *m_customaccel; +//Formula: mousesensitivity = ( rawmousedelta^m_customaccel_exponent ) * m_customaccel_scale + sensitivity +// If mode is 2, then x and y sensitivity are scaled by m_pitch and m_yaw respectively. +// Custom mouse acceleration value. +static cvar_t *m_customaccel_scale; +//Max mouse move scale factor, 0 for no limit +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 threaded mouse is enabled then the time to sleep between polls +static cvar_t *m_mousethread_sleep; +#endif + +float mouse_x, mouse_y; + +static int restore_spi; +static int originalmouseparms[3], newmouseparms[3] = {0, 0, 1}; +static int mouseactive = 0; +static int mouseparmsvalid; +static int mouseshowtoggle = 1; + +// joystick defines and variables +// where should defines be moved? +#define JOY_ABSOLUTE_AXIS 0x00000000 // control like a joystick +#define JOY_RELATIVE_AXIS 0x00000010 // control like a mouse, spinner, trackball +#define JOY_MAX_AXES 6 // X, Y, Z, R, U, V +#define JOY_AXIS_X 0 +#define JOY_AXIS_Y 1 +#define JOY_AXIS_Z 2 +#define JOY_AXIS_R 3 +#define JOY_AXIS_U 4 +#define JOY_AXIS_V 5 + +enum _ControlList +{ + AxisNada = 0, + AxisForward, + AxisLook, + AxisSide, + AxisTurn +}; + +#if !defined(USE_SDL2) && defined(_WIN32) +DWORD dwAxisFlags[JOY_MAX_AXES] = +{ + JOY_RETURNX, + JOY_RETURNY, + JOY_RETURNZ, + JOY_RETURNR, + JOY_RETURNU, + JOY_RETURNV +}; +#endif + +DWORD dwAxisMap[ JOY_MAX_AXES ]; +DWORD dwControlMap[ JOY_MAX_AXES ]; +#if defined(USE_SDL2) +int pdwRawValue[ JOY_MAX_AXES ]; +#elif defined(_WIN32) +PDWORD pdwRawValue[ JOY_MAX_AXES ]; +#endif +DWORD joy_oldbuttonstate, joy_oldpovstate; + +int joy_id; +DWORD joy_numbuttons; + +#ifdef USE_SDL2 +SDL_GameController *s_pJoystick = NULL; +#elif defined(_WIN32) +DWORD joy_flags; +static JOYINFOEX ji; +#endif + +// none of these cvars are saved over a session +// this means that advanced controller configuration needs to be executed +// each time. this avoids any problems with getting back to a default usage +// or when changing from one controller to another. this way at least something +// works. +extern cvar_t *in_joystick; +cvar_t *joy_name; +cvar_t *joy_advanced; +cvar_t *joy_advaxisx; +cvar_t *joy_advaxisy; +cvar_t *joy_advaxisz; +cvar_t *joy_advaxisr; +cvar_t *joy_advaxisu; +cvar_t *joy_advaxisv; +cvar_t *joy_forwardthreshold; +cvar_t *joy_sidethreshold; +cvar_t *joy_pitchthreshold; +cvar_t *joy_yawthreshold; +cvar_t *joy_forwardsensitivity; +cvar_t *joy_sidesensitivity; +cvar_t *joy_pitchsensitivity; +cvar_t *joy_yawsensitivity; +cvar_t *joy_wwhack1; +cvar_t *joy_wwhack2; + +int joy_avail, joy_advancedinit, joy_haspov; + +#ifdef _WIN32 +unsigned int s_hMouseThreadId = 0; +HANDLE s_hMouseThread = 0; +HANDLE s_hMouseQuitEvent = 0; +HANDLE s_hMouseThreadActiveLock = 0; +#endif + +/* +=========== +Force_CenterView_f +=========== +*/ +void Force_CenterView_f (void) +{ + vec3_t viewangles; + + if (!iMouseInUse) + { + gEngfuncs.GetViewAngles( (float *)viewangles ); + viewangles[PITCH] = 0; + gEngfuncs.SetViewAngles( (float *)viewangles ); + } +} + +#ifdef _WIN32 + +LONG mouseThreadActive = 0; +LONG mouseThreadCenterX = 0; +LONG mouseThreadCenterY = 0; +LONG mouseThreadDeltaX = 0; +LONG mouseThreadDeltaY = 0; +LONG mouseThreadSleep = 0; + +bool MouseThread_ActiveLock_Enter( void ) +{ + if(!m_bMouseThread) + return true; + + return WAIT_OBJECT_0 == WaitForSingleObject( s_hMouseThreadActiveLock, INFINITE); +} + +void MouseThread_ActiveLock_Exit( void ) +{ + if(!m_bMouseThread) + return; + + SetEvent( s_hMouseThreadActiveLock ); +} + +unsigned __stdcall MouseThread_Function( void * pArg ) +{ + while ( true ) + { + DWORD sleepVal = (DWORD)InterlockedExchangeAdd(&mouseThreadSleep, 0); + if(0 > sleepVal) sleepVal = 0; + else if(1000 < sleepVal) sleepVal = 1000; + if(WAIT_OBJECT_0 == WaitForSingleObject( s_hMouseQuitEvent, sleepVal)) + { + break; + } + + if( MouseThread_ActiveLock_Enter() ) + { + if ( InterlockedExchangeAdd(&mouseThreadActive, 0) ) + { + POINT mouse_pos; + POINT center_pos; + + center_pos.x = InterlockedExchangeAdd(&mouseThreadCenterX, 0); + center_pos.y = InterlockedExchangeAdd(&mouseThreadCenterY, 0); + GetCursorPos(&mouse_pos); + + mouse_pos.x -= center_pos.x; + mouse_pos.y -= center_pos.y; + + if(mouse_pos.x || mouse_pos.y) SetCursorPos( center_pos.x, center_pos.y ); + + InterlockedExchangeAdd(&mouseThreadDeltaX, mouse_pos.x); + InterlockedExchangeAdd(&mouseThreadDeltaY, mouse_pos.y); + } + + MouseThread_ActiveLock_Exit(); + } + } + + return 0; +} + +/// Updates mouseThreadActive using the global variables mouseactive, iVisibleMouse and m_bRawInput. Should be called after any of these is changed. +/// Has to be interlocked manually by programmer! Use MouseThread_ActiveLock_Enter and MouseThread_ActiveLock_Exit. +void UpdateMouseThreadActive(void) +{ + InterlockedExchange(&mouseThreadActive, mouseactive && !iVisibleMouse && !m_bRawInput); +} + +#endif + +void IN_SetMouseMode(bool enable) +{ + static bool currentMouseMode = false; + + if(enable == currentMouseMode) + return; + + if(enable) + { +#ifdef _WIN32 + if (mouseparmsvalid) + restore_spi = SystemParametersInfo (SPI_SETMOUSE, 0, newmouseparms, 0); + + m_bRawInput = CVAR_GET_FLOAT( "m_rawinput" ) != 0; + if(m_bRawInput) + { +#ifdef USE_SDL2 + safe_pfnSDL_SetRelativeMouseMode(SDL_TRUE); +#endif + isMouseRelative = true; + } +#else + safe_pfnSDL_SetRelativeMouseMode(SDL_TRUE); +#endif + + currentMouseMode = true; + } + else + { +#ifdef _WIN32 + if(isMouseRelative) + { +#ifdef USE_SDL2 + safe_pfnSDL_SetRelativeMouseMode(SDL_FALSE); +#endif + isMouseRelative = false; + } + + if (restore_spi) + SystemParametersInfo (SPI_SETMOUSE, 0, originalmouseparms, 0); +#else + safe_pfnSDL_SetRelativeMouseMode(SDL_FALSE); +#endif + + currentMouseMode = false; + } +} + +void IN_SetVisibleMouse(bool visible) +{ +#ifdef _WIN32 + bool lockEntered = MouseThread_ActiveLock_Enter(); +#endif + + iVisibleMouse = visible; + + IN_SetMouseMode(!visible); + +#ifdef _WIN32 + UpdateMouseThreadActive(); + if(lockEntered) MouseThread_ActiveLock_Exit(); +#endif +} + +void IN_ResetMouse( void ); + +/* +=========== +IN_ActivateMouse +=========== +*/ +void GoldSourceInput::IN_ActivateMouse (void) +{ + if (mouseinitialized) + { +#ifdef _WIN32 + bool lockEntered = MouseThread_ActiveLock_Enter(); +#endif + + IN_SetMouseMode(true); + + mouseactive = 1; + +#ifdef _WIN32 + UpdateMouseThreadActive(); + if(lockEntered) MouseThread_ActiveLock_Exit(); +#endif + + // now is a good time to reset mouse positon: + IN_ResetMouse(); + } +} + + +/* +=========== +IN_DeactivateMouse +=========== +*/ +void GoldSourceInput::IN_DeactivateMouse (void) +{ + if (mouseinitialized) + { +#ifdef _WIN32 + bool lockEntered = MouseThread_ActiveLock_Enter(); +#endif + + IN_SetMouseMode(false); + + mouseactive = 0; + +#ifdef _WIN32 + UpdateMouseThreadActive(); + if(lockEntered) MouseThread_ActiveLock_Exit(); +#endif + } +} + +/* +=========== +IN_StartupMouse +=========== +*/ +void GoldSourceInput::IN_StartupMouse (void) +{ + if ( gEngfuncs.CheckParm ("-nomouse", NULL ) ) + return; + + mouseinitialized = 1; +#ifdef _WIN32 + mouseparmsvalid = SystemParametersInfo (SPI_GETMOUSE, 0, originalmouseparms, 0); + + if (mouseparmsvalid) + { + if ( gEngfuncs.CheckParm ("-noforcemspd", NULL ) ) + newmouseparms[2] = originalmouseparms[2]; + + if ( gEngfuncs.CheckParm ("-noforcemaccel", NULL ) ) + { + newmouseparms[0] = originalmouseparms[0]; + newmouseparms[1] = originalmouseparms[1]; + } + + if ( gEngfuncs.CheckParm ("-noforcemparms", NULL ) ) + { + newmouseparms[0] = originalmouseparms[0]; + newmouseparms[1] = originalmouseparms[1]; + newmouseparms[2] = originalmouseparms[2]; + } + } +#endif + + mouse_buttons = MOUSE_BUTTON_COUNT; +} + +/* +=========== +IN_Shutdown +=========== +*/ +void GoldSourceInput::IN_Shutdown (void) +{ + IN_DeactivateMouse (); + +#ifdef _WIN32 + if ( s_hMouseQuitEvent ) + { + SetEvent( s_hMouseQuitEvent ); + } + + if ( s_hMouseThread ) + { + if(WAIT_OBJECT_0 != WaitForSingleObject( s_hMouseThread, 5000 )) + { + TerminateThread( s_hMouseThread, 0 ); + } + CloseHandle( s_hMouseThread ); + s_hMouseThread = (HANDLE)0; + } + + if ( s_hMouseQuitEvent ) + { + CloseHandle( s_hMouseQuitEvent ); + s_hMouseQuitEvent = (HANDLE)0; + } + + if( s_hMouseThreadActiveLock ) + { + CloseHandle( s_hMouseThreadActiveLock ); + s_hMouseThreadActiveLock = (HANDLE)0; + } +#endif + +#ifdef USE_SDL2 + for (int j=0; jvalue; + + // Using special accleration values + if ( m_customaccel->value != 0 ) + { + float raw_mouse_movement_distance = sqrt( mx * mx + my * my ); + float acceleration_scale = m_customaccel_scale->value; + float accelerated_sensitivity_max = m_customaccel_max->value; + float accelerated_sensitivity_exponent = m_customaccel_exponent->value; + float accelerated_sensitivity = ( (float)pow( raw_mouse_movement_distance, accelerated_sensitivity_exponent ) * acceleration_scale + mouse_senstivity ); + + if ( accelerated_sensitivity_max > 0.0001f && + accelerated_sensitivity > accelerated_sensitivity_max ) + { + accelerated_sensitivity = accelerated_sensitivity_max; + } + + *x *= accelerated_sensitivity; + *y *= accelerated_sensitivity; + + // Further re-scale by yaw and pitch magnitude if user requests alternate mode 2 + // This means that they will need to up their value for m_customaccel_scale greatly (>40x) since m_pitch/yaw default + // to 0.022 + if ( m_customaccel->value == 2 ) + { + *x *= m_yaw->value; + *y *= m_pitch->value; + } + } + else + { + // Just apply the default + *x *= mouse_senstivity; + *y *= mouse_senstivity; + } +} + +void GoldSourceInput::IN_GetMouseDelta( int *pOutX, int *pOutY) +{ + bool active = mouseactive && !iVisibleMouse; + int mx, my; + + if(active) + { + int deltaX, deltaY; +#ifdef _WIN32 + if ( !m_bRawInput ) + { + if ( m_bMouseThread ) + { + // update mouseThreadSleep: + InterlockedExchange(&mouseThreadSleep, (LONG)m_mousethread_sleep->value); + + bool lockEntered = MouseThread_ActiveLock_Enter(); + + current_pos.x = InterlockedExchange( &mouseThreadDeltaX, 0 ); + current_pos.y = InterlockedExchange( &mouseThreadDeltaY, 0 ); + + if(lockEntered) MouseThread_ActiveLock_Exit(); + } + else + { + GetCursorPos (¤t_pos); + } + } + else +#endif + { +#ifdef USE_SDL2 + safe_pfnSDL_GetRelativeMouseState( &deltaX, &deltaY ); + current_pos.x = deltaX; + current_pos.y = deltaY; +#else + GetCursorPos (¤t_pos); + deltaX = current_pos.x - gEngfuncs.GetWindowCenterX(); + deltaY = current_pos.y - gEngfuncs.GetWindowCenterY(); +#endif + } + +#ifdef _WIN32 + if ( !m_bRawInput ) + { + if ( m_bMouseThread ) + { + mx = current_pos.x; + my = current_pos.y; + } + else + { + mx = current_pos.x - gEngfuncs.GetWindowCenterX() + mx_accum; + my = current_pos.y - gEngfuncs.GetWindowCenterY() + my_accum; + } + } + else +#endif + { + mx = deltaX + mx_accum; + my = deltaY + my_accum; + } + + mx_accum = 0; + my_accum = 0; + + // reset mouse position if required, so there is room to move: +#ifdef _WIN32 + // do not reset if mousethread would do it: + if ( m_bRawInput || !m_bMouseThread ) +#else + if(true) +#endif + IN_ResetMouse(); + +#ifdef _WIN32 + // update m_bRawInput occasionally: + if ( gpGlobals && gpGlobals->time - s_flRawInputUpdateTime > 1.0f ) + { + s_flRawInputUpdateTime = gpGlobals->time; + + bool lockEntered = MouseThread_ActiveLock_Enter(); + + m_bRawInput = CVAR_GET_FLOAT( "m_rawinput" ) != 0; + + if(m_bRawInput && !isMouseRelative) + { +#ifdef USE_SDL2 + safe_pfnSDL_SetRelativeMouseMode(SDL_TRUE); +#endif + isMouseRelative = true; + } + else if(!m_bRawInput && isMouseRelative) + { +#ifdef USE_SDL2 + safe_pfnSDL_SetRelativeMouseMode(SDL_FALSE); +#endif + isMouseRelative = false; + } + + UpdateMouseThreadActive(); + if(lockEntered) MouseThread_ActiveLock_Exit(); + } +#endif + } + else + { + mx = my = 0; + } + + if(pOutX) *pOutX = mx; + if(pOutY) *pOutY = my; +} + +/* +=========== +IN_MouseMove +=========== +*/ +void GoldSourceInput::IN_MouseMove ( float frametime, usercmd_t *cmd) +{ + int mx, my; + vec3_t viewangles; + + gEngfuncs.GetViewAngles( (float *)viewangles ); + + if ( in_mlook.state & 1) + { + V_StopPitchDrift (); + } + + //jjb - this disbles normal mouse control if the user is trying to + // move the camera, or if the mouse cursor is visible or if we're in intermission + if ( !iMouseInUse && !gHUD.m_iIntermission && !iVisibleMouse ) + { + IN_GetMouseDelta( &mx, &my ); + + if (m_filter && m_filter->value) + { + mouse_x = (mx + old_mouse_x) * 0.5; + mouse_y = (my + old_mouse_y) * 0.5; + } + else + { + mouse_x = mx; + mouse_y = my; + } + + old_mouse_x = mx; + old_mouse_y = my; + + // Apply custom mouse scaling/acceleration + IN_ScaleMouse( &mouse_x, &mouse_y ); + + // add mouse X/Y movement to cmd + if ( (in_strafe.state & 1) || (lookstrafe->value && (in_mlook.state & 1) )) + cmd->sidemove += m_side->value * mouse_x; + else + viewangles[YAW] -= m_yaw->value * mouse_x; + + if ( (in_mlook.state & 1) && !(in_strafe.state & 1)) + { + viewangles[PITCH] += m_pitch->value * mouse_y; + if (viewangles[PITCH] > cl_pitchdown->value) + viewangles[PITCH] = cl_pitchdown->value; + if (viewangles[PITCH] < -cl_pitchup->value) + viewangles[PITCH] = -cl_pitchup->value; + } + else + { + if ((in_strafe.state & 1) && gEngfuncs.IsNoClipping() ) + { + cmd->upmove -= m_forward->value * mouse_y; + } + else + { + cmd->forwardmove -= m_forward->value * mouse_y; + } + } + } + + gEngfuncs.SetViewAngles( (float *)viewangles ); + +/* +//#define TRACE_TEST +#if defined( TRACE_TEST ) + { + int mx, my; + void V_Move( int mx, int my ); + IN_GetMousePos( &mx, &my ); + V_Move( mx, my ); + } +#endif +*/ +} + +/* +=========== +IN_Accumulate +=========== +*/ +void GoldSourceInput::IN_Accumulate (void) +{ + //only accumulate mouse if we are not moving the camera with the mouse + if ( !iMouseInUse && !iVisibleMouse) + { + if (mouseactive) + { +#ifdef _WIN32 + if ( !m_bRawInput ) + { + if ( !m_bMouseThread ) + { + GetCursorPos (¤t_pos); + + mx_accum += current_pos.x - gEngfuncs.GetWindowCenterX(); + my_accum += current_pos.y - gEngfuncs.GetWindowCenterY(); + } + } + else +#endif + { +#ifdef USE_SDL2 + int deltaX, deltaY; + safe_pfnSDL_GetRelativeMouseState( &deltaX, &deltaY ); + mx_accum += deltaX; + my_accum += deltaY; +#else + GetCursorPos (¤t_pos); + + mx_accum += current_pos.x - gEngfuncs.GetWindowCenterX(); + my_accum += current_pos.y - gEngfuncs.GetWindowCenterY(); +#endif + } + + // force the mouse to the center, so there's room to move +#ifdef _WIN32 + // do not reset if mousethread would do it: + if ( m_bRawInput || !m_bMouseThread ) +#else + if(true) +#endif + IN_ResetMouse(); + + } + } + +} + +/* +=================== +IN_ClearStates +=================== +*/ +void GoldSourceInput::IN_ClearStates (void) +{ + if ( !mouseactive ) + return; + + mx_accum = 0; + my_accum = 0; + mouse_oldbuttonstate = 0; +} + +/* +=============== +IN_StartupJoystick +=============== +*/ +void IN_StartupJoystick (void) +{ + // abort startup if user requests no joystick + if ( gEngfuncs.CheckParm ("-nojoy", NULL ) ) + return; + + // assume no joystick + joy_avail = 0; +#ifdef USE_SDL2 + int nJoysticks = safe_pfnSDL_NumJoysticks(); + if ( nJoysticks > 0 ) + { + for ( int i = 0; i < nJoysticks; i++ ) + { + if ( safe_pfnSDL_IsGameController( i ) ) + { + s_pJoystick = safe_pfnSDL_GameControllerOpen( i ); + if ( s_pJoystick ) + { + //save the joystick's number of buttons and POV status + joy_numbuttons = SDL_CONTROLLER_BUTTON_MAX; + joy_haspov = 0; + + // old button and POV states default to no buttons pressed + joy_oldbuttonstate = joy_oldpovstate = 0; + + // mark the joystick as available and advanced initialization not completed + // this is needed as cvars are not available during initialization + gEngfuncs.Con_Printf ("joystick found\n\n", safe_pfnSDL_GameControllerName(s_pJoystick)); + joy_avail = 1; + joy_advancedinit = 0; + break; + } + } + } + } + else + { + gEngfuncs.Con_DPrintf ("joystick not found -- driver not present\n\n"); + } +#elif defined(_WIN32) + int numdevs; + JOYCAPS jc; + MMRESULT mmr; + // verify joystick driver is present + if ((numdevs = joyGetNumDevs ()) == 0) + { + gEngfuncs.Con_DPrintf ("joystick not found -- driver not present\n\n"); + return; + } + + // cycle through the joystick ids for the first valid one + for (joy_id=0 ; joy_idvalue == 0.0) + { + // default joystick initialization + // 2 axes only with joystick control + dwAxisMap[JOY_AXIS_X] = AxisTurn; + // dwControlMap[JOY_AXIS_X] = JOY_ABSOLUTE_AXIS; + dwAxisMap[JOY_AXIS_Y] = AxisForward; + // dwControlMap[JOY_AXIS_Y] = JOY_ABSOLUTE_AXIS; + } + else + { + if ( strcmp ( joy_name->string, "joystick") != 0 ) + { + // notify user of advanced controller + gEngfuncs.Con_Printf ("\n%s configured\n\n", joy_name->string); + } + + // advanced initialization here + // data supplied by user via joy_axisn cvars + dwTemp = (DWORD) joy_advaxisx->value; + dwAxisMap[JOY_AXIS_X] = dwTemp & 0x0000000f; + dwControlMap[JOY_AXIS_X] = dwTemp & JOY_RELATIVE_AXIS; + dwTemp = (DWORD) joy_advaxisy->value; + dwAxisMap[JOY_AXIS_Y] = dwTemp & 0x0000000f; + dwControlMap[JOY_AXIS_Y] = dwTemp & JOY_RELATIVE_AXIS; + dwTemp = (DWORD) joy_advaxisz->value; + dwAxisMap[JOY_AXIS_Z] = dwTemp & 0x0000000f; + dwControlMap[JOY_AXIS_Z] = dwTemp & JOY_RELATIVE_AXIS; + dwTemp = (DWORD) joy_advaxisr->value; + dwAxisMap[JOY_AXIS_R] = dwTemp & 0x0000000f; + dwControlMap[JOY_AXIS_R] = dwTemp & JOY_RELATIVE_AXIS; + dwTemp = (DWORD) joy_advaxisu->value; + dwAxisMap[JOY_AXIS_U] = dwTemp & 0x0000000f; + dwControlMap[JOY_AXIS_U] = dwTemp & JOY_RELATIVE_AXIS; + dwTemp = (DWORD) joy_advaxisv->value; + dwAxisMap[JOY_AXIS_V] = dwTemp & 0x0000000f; + dwControlMap[JOY_AXIS_V] = dwTemp & JOY_RELATIVE_AXIS; + } + +#if !defined(USE_SDL2) && defined(_WIN32) + // compute the axes to collect from DirectInput + joy_flags = JOY_RETURNCENTERED | JOY_RETURNBUTTONS | JOY_RETURNPOV; + for (i = 0; i < JOY_MAX_AXES; i++) + { + if (dwAxisMap[i] != AxisNada) + { + joy_flags |= dwAxisFlags[i]; + } + } +#endif +} + + +/* +=========== +IN_Commands +=========== +*/ +void GoldSourceInput::IN_Commands (void) +{ + int i, key_index; + + if (!joy_avail) + { + return; + } + + DWORD buttonstate, povstate; + + // loop through the joystick buttons + // key a joystick event or auxillary event for higher number buttons for each state change +#ifdef USE_SDL2 + buttonstate = 0; + for ( i = 0; i < SDL_CONTROLLER_BUTTON_MAX; i++ ) + { + if ( safe_pfnSDL_GameControllerGetButton( s_pJoystick, (SDL_GameControllerButton)i ) ) + { + buttonstate |= 1<value != 0.0) + { + ji.dwUpos += 100; + } + return 1; + } + else + { + // read error occurred + // turning off the joystick seems too harsh for 1 read error,\ + // but what should be done? + // Con_Printf ("IN_ReadJoystick: no response\n"); + // joy_avail = 0; + return 0; + } +#else + return 0; +#endif +} + + +/* +=========== +IN_JoyMove +=========== +*/ +void IN_JoyMove ( float frametime, usercmd_t *cmd ) +{ + float speed, aspeed; + float fAxisValue, fTemp; + int i; + vec3_t viewangles; + + gEngfuncs.GetViewAngles( (float *)viewangles ); + + + // complete initialization if first time in + // this is needed as cvars are not available at initialization time + if( joy_advancedinit != 1 ) + { + Joy_AdvancedUpdate_f(); + joy_advancedinit = 1; + } + + // verify joystick is available and that the user wants to use it + if (!joy_avail || !in_joystick->value) + { + return; + } + + // collect the joystick data, if possible + if (IN_ReadJoystick () != 1) + { + return; + } + + if (in_speed.state & 1) + speed = cl_movespeedkey->value; + else + speed = 1; + + aspeed = speed * frametime; + + // loop through the axes + for (i = 0; i < JOY_MAX_AXES; i++) + { + // get the floating point zero-centered, potentially-inverted data for the current axis +#ifdef USE_SDL2 + fAxisValue = (float)pdwRawValue[i]; +#elif defined(_WIN32) + fAxisValue = (float) *pdwRawValue[i]; + fAxisValue -= 32768.0; +#endif + + if (joy_wwhack2->value != 0.0) + { + if (dwAxisMap[i] == AxisTurn) + { + // this is a special formula for the Logitech WingMan Warrior + // y=ax^b; where a = 300 and b = 1.3 + // also x values are in increments of 800 (so this is factored out) + // then bounds check result to level out excessively high spin rates + fTemp = 300.0 * pow(fabs(fAxisValue) / 800.0, 1.3); + if (fTemp > 14000.0) + fTemp = 14000.0; + // restore direction information + fAxisValue = (fAxisValue > 0.0) ? fTemp : -fTemp; + } + } + + // convert range from -32768..32767 to -1..1 + fAxisValue /= 32768.0; + + switch (dwAxisMap[i]) + { + case AxisForward: + if ((joy_advanced->value == 0.0) && (in_jlook.state & 1)) + { + // user wants forward control to become look control + if (fabs(fAxisValue) > joy_pitchthreshold->value) + { + // if mouse invert is on, invert the joystick pitch value + // only absolute control support here (joy_advanced is 0) + if (m_pitch->value < 0.0) + { + viewangles[PITCH] -= (fAxisValue * joy_pitchsensitivity->value) * aspeed * cl_pitchspeed->value; + } + else + { + viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity->value) * aspeed * cl_pitchspeed->value; + } + V_StopPitchDrift(); + } + else + { + // no pitch movement + // disable pitch return-to-center unless requested by user + // *** this code can be removed when the lookspring bug is fixed + // *** the bug always has the lookspring feature on + if(lookspring->value == 0.0) + { + V_StopPitchDrift(); + } + } + } + else + { + // user wants forward control to be forward control + if (fabs(fAxisValue) > joy_forwardthreshold->value) + { + cmd->forwardmove += (fAxisValue * joy_forwardsensitivity->value) * speed * cl_forwardspeed->value; + } + } + break; + + case AxisSide: + if (fabs(fAxisValue) > joy_sidethreshold->value) + { + cmd->sidemove += (fAxisValue * joy_sidesensitivity->value) * speed * cl_sidespeed->value; + } + break; + + case AxisTurn: + if ((in_strafe.state & 1) || (lookstrafe->value && (in_jlook.state & 1))) + { + // user wants turn control to become side control + if (fabs(fAxisValue) > joy_sidethreshold->value) + { + cmd->sidemove -= (fAxisValue * joy_sidesensitivity->value) * speed * cl_sidespeed->value; + } + } + else + { + // user wants turn control to be turn control + if (fabs(fAxisValue) > joy_yawthreshold->value) + { + if(dwControlMap[i] == JOY_ABSOLUTE_AXIS) + { + viewangles[YAW] += (fAxisValue * joy_yawsensitivity->value) * aspeed * cl_yawspeed->value; + } + else + { + viewangles[YAW] += (fAxisValue * joy_yawsensitivity->value) * speed * 180.0; + } + + } + } + break; + + case AxisLook: + if (in_jlook.state & 1) + { + if (fabs(fAxisValue) > joy_pitchthreshold->value) + { + // pitch movement detected and pitch movement desired by user + if(dwControlMap[i] == JOY_ABSOLUTE_AXIS) + { + viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity->value) * aspeed * cl_pitchspeed->value; + } + else + { + viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity->value) * speed * 180.0; + } + V_StopPitchDrift(); + } + else + { + // no pitch movement + // disable pitch return-to-center unless requested by user + // *** this code can be removed when the lookspring bug is fixed + // *** the bug always has the lookspring feature on + if( lookspring->value == 0.0 ) + { + V_StopPitchDrift(); + } + } + } + break; + + default: + break; + } + } + + // bounds check pitch + if (viewangles[PITCH] > cl_pitchdown->value) + viewangles[PITCH] = cl_pitchdown->value; + if (viewangles[PITCH] < -cl_pitchup->value) + viewangles[PITCH] = -cl_pitchup->value; + + gEngfuncs.SetViewAngles( (float *)viewangles ); +} + +/* +=========== +IN_Move +=========== +*/ +void GoldSourceInput::IN_Move ( float frametime, usercmd_t *cmd) +{ + if ( !iMouseInUse && mouseactive ) + { + IN_MouseMove ( frametime, cmd); + } + + IN_JoyMove ( frametime, cmd); +} + +/* +=========== +IN_Init +=========== +*/ +void GoldSourceInput::IN_Init (void) +{ + m_filter = gEngfuncs.pfnRegisterVariable ( "m_filter","0", FCVAR_ARCHIVE ); + sensitivity = gEngfuncs.pfnRegisterVariable ( "sensitivity","3", FCVAR_ARCHIVE ); // user mouse sensitivity setting. + + in_joystick = gEngfuncs.pfnRegisterVariable ( "joystick","0", FCVAR_ARCHIVE ); + joy_name = gEngfuncs.pfnRegisterVariable ( "joyname", "joystick", 0 ); + joy_advanced = gEngfuncs.pfnRegisterVariable ( "joyadvanced", "0", 0 ); + joy_advaxisx = gEngfuncs.pfnRegisterVariable ( "joyadvaxisx", "0", 0 ); + joy_advaxisy = gEngfuncs.pfnRegisterVariable ( "joyadvaxisy", "0", 0 ); + joy_advaxisz = gEngfuncs.pfnRegisterVariable ( "joyadvaxisz", "0", 0 ); + joy_advaxisr = gEngfuncs.pfnRegisterVariable ( "joyadvaxisr", "0", 0 ); + joy_advaxisu = gEngfuncs.pfnRegisterVariable ( "joyadvaxisu", "0", 0 ); + joy_advaxisv = gEngfuncs.pfnRegisterVariable ( "joyadvaxisv", "0", 0 ); + joy_forwardthreshold = gEngfuncs.pfnRegisterVariable ( "joyforwardthreshold", "0.15", 0 ); + joy_sidethreshold = gEngfuncs.pfnRegisterVariable ( "joysidethreshold", "0.15", 0 ); + joy_pitchthreshold = gEngfuncs.pfnRegisterVariable ( "joypitchthreshold", "0.15", 0 ); + joy_yawthreshold = gEngfuncs.pfnRegisterVariable ( "joyyawthreshold", "0.15", 0 ); + joy_forwardsensitivity = gEngfuncs.pfnRegisterVariable ( "joyforwardsensitivity", "-1.0", 0 ); + joy_sidesensitivity = gEngfuncs.pfnRegisterVariable ( "joysidesensitivity", "-1.0", 0 ); + joy_pitchsensitivity = gEngfuncs.pfnRegisterVariable ( "joypitchsensitivity", "1.0", 0 ); + joy_yawsensitivity = gEngfuncs.pfnRegisterVariable ( "joyyawsensitivity", "-1.0", 0 ); + joy_wwhack1 = gEngfuncs.pfnRegisterVariable ( "joywwhack1", "0.0", 0 ); + joy_wwhack2 = gEngfuncs.pfnRegisterVariable ( "joywwhack2", "0.0", 0 ); + + m_customaccel = gEngfuncs.pfnRegisterVariable ( "m_customaccel", "0", FCVAR_ARCHIVE ); + m_customaccel_scale = gEngfuncs.pfnRegisterVariable ( "m_customaccel_scale", "0.04", FCVAR_ARCHIVE ); + 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; + m_bMouseThread = gEngfuncs.CheckParm ("-mousethread", NULL ) != NULL; + m_mousethread_sleep = gEngfuncs.pfnRegisterVariable ( "m_mousethread_sleep", "1", FCVAR_ARCHIVE ); // default to less than 1000 Hz + + m_bMouseThread = m_bMouseThread && NULL != m_mousethread_sleep; + + if (m_bMouseThread) + { + // init mouseThreadSleep: +#if 0 // _beginthreadex is not defined on VS 6? + InterlockedExchange(&mouseThreadSleep, (LONG)m_mousethread_sleep->value); + + s_hMouseQuitEvent = CreateEvent( NULL, FALSE, FALSE, NULL ); + s_hMouseThreadActiveLock = CreateEvent( NULL, FALSE, TRUE, NULL ); + if ( s_hMouseQuitEvent && s_hMouseThreadActiveLock) + { + s_hMouseThread = (HANDLE)_beginthreadex( NULL, 0, MouseThread_Function, NULL, 0, &s_hMouseThreadId ); + } + + m_bMouseThread = NULL != s_hMouseThread; +#else + m_bMouseThread = 0; +#endif + + // at this early stage this won't print anything: + // gEngfuncs.Con_DPrintf ("Mouse thread %s.\n", m_bMouseThread ? "initalized" : "failed to initalize"); + } +#endif + +#ifdef USE_SDL2 +#ifdef __APPLE__ +#define SDL2_FULL_LIBNAME "libsdl2-2.0.0.dylib" +#else +#define SDL2_FULL_LIBNAME "libSDL2-2.0.so.0" +#endif + sdl2Lib = dlopen(SDL2_FULL_LIBNAME, RTLD_NOW|RTLD_LOCAL); + if (sdl2Lib) { + for (int j=0; jIN_ClientMoveEvent(forwardmove, sidemove); +} + +extern "C" void DLLEXPORT IN_ClientLookEvent( float relyaw, float relpitch ) +{ + currentInput->IN_ClientLookEvent(relyaw, relpitch); +} + +void IN_Move( float frametime, usercmd_t *cmd ) +{ + currentInput->IN_Move(frametime, cmd); +} + +extern "C" void DLLEXPORT IN_MouseEvent( int mstate ) +{ + currentInput->IN_MouseEvent(mstate); +} + +extern "C" void DLLEXPORT IN_ClearStates( void ) +{ + currentInput->IN_ClearStates(); +} + +extern "C" void DLLEXPORT IN_ActivateMouse( void ) +{ + currentInput->IN_ActivateMouse(); +} + +extern "C" void DLLEXPORT IN_DeactivateMouse( void ) +{ + currentInput->IN_DeactivateMouse(); +} + +extern "C" void DLLEXPORT IN_Accumulate( void ) +{ + currentInput->IN_Accumulate(); +} + +void IN_Commands( void ) +{ + currentInput->IN_Commands(); +} + +void IN_Shutdown( void ) +{ + currentInput->IN_Shutdown(); +} + +void IN_Init( void ) +{ +#ifdef SUPPORT_GOLDSOURCE_INPUT + if (IsXashFWGS()) { + gEngfuncs.Con_Printf( "FWGS Xash3D input is in use\n" ); + currentInput = &fwgsInput; + } else { + gEngfuncs.Con_Printf( "GoldSource input is in use\n" ); + currentInput = &goldSourceInput; + } +#else + currentInput = &fwgsInput; +#endif + currentInput->IN_Init(); +} diff --git a/cl_dll/input_mouse.h b/cl_dll/input_mouse.h new file mode 100644 index 00000000..c13b7fa2 --- /dev/null +++ b/cl_dll/input_mouse.h @@ -0,0 +1,79 @@ +#pragma once +#ifndef INPUT_MOUSE_H +#define INPUT_MOUSE_H +#include "cl_dll.h" +#include "usercmd.h" +#include "in_defs.h" + +class AbstractInput +{ +public: + virtual void IN_ClientMoveEvent( float forwardmove, float sidemove ) = 0; + virtual void IN_ClientLookEvent( float relyaw, float relpitch ) = 0; + virtual void IN_Move( float frametime, usercmd_t *cmd ) = 0; + virtual void IN_MouseEvent( int mstate ) = 0; + virtual void IN_ClearStates( void ) = 0; + virtual void IN_ActivateMouse( void ) = 0; + virtual void IN_DeactivateMouse( void ) = 0; + virtual void IN_Accumulate( void ) = 0; + virtual void IN_Commands( void ) = 0; + virtual void IN_Shutdown( void ) = 0; + virtual void IN_Init( void ) = 0; +}; + +class FWGSInput : public AbstractInput +{ +public: + virtual void IN_ClientMoveEvent( float forwardmove, float sidemove ); + virtual void IN_ClientLookEvent( float relyaw, float relpitch ); + virtual void IN_Move( float frametime, usercmd_t *cmd ); + virtual void IN_MouseEvent( int mstate ); + virtual void IN_ClearStates( void ); + virtual void IN_ActivateMouse( void ); + virtual void IN_DeactivateMouse( void ); + virtual void IN_Accumulate( void ); + virtual void IN_Commands( void ); + virtual void IN_Shutdown( void ); + virtual void IN_Init( void ); + +protected: + float ac_forwardmove; + float ac_sidemove; + int ac_movecount; + float rel_yaw; + float rel_pitch; +}; + +// 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 +class GoldSourceInput : public AbstractInput +{ +public: + virtual void IN_ClientMoveEvent( float forwardmove, float sidemove ) {} + virtual void IN_ClientLookEvent( float relyaw, float relpitch ) {} + virtual void IN_Move( float frametime, usercmd_t *cmd ); + virtual void IN_MouseEvent( int mstate ); + virtual void IN_ClearStates( void ); + virtual void IN_ActivateMouse( void ); + virtual void IN_DeactivateMouse( void ); + virtual void IN_Accumulate( void ); + virtual void IN_Commands( void ); + virtual void IN_Shutdown( void ); + virtual void IN_Init( void ); + +protected: + void IN_GetMouseDelta( int *pOutX, int *pOutY); + void IN_MouseMove ( float frametime, usercmd_t *cmd); + void IN_StartupMouse (void); + + int mouse_buttons; + int mouse_oldbuttonstate; + POINT current_pos; + int old_mouse_x, old_mouse_y, mx_accum, my_accum; + int mouseinitialized; + void* sdl2Lib; +}; +#endif + +#endif diff --git a/cl_dll/input_xash3d.cpp b/cl_dll/input_xash3d.cpp index 63cdfbeb..2ff572ee 100644 --- a/cl_dll/input_xash3d.cpp +++ b/cl_dll/input_xash3d.cpp @@ -3,14 +3,9 @@ #include "cvardef.h" #include "kbutton.h" #include "keydefs.h" -cvar_t *sensitivity; -cvar_t *in_joystick; -#define PITCH 0 -#define YAW 1 -#define ROLL 2 - -extern "C" void DLLEXPORT IN_ClientMoveEvent( float forwardmove, float sidemove ); -extern "C" void DLLEXPORT IN_ClientLookEvent( float relyaw, float relpitch ); +#include "input_mouse.h" +extern cvar_t *sensitivity; +extern cvar_t *in_joystick; extern kbutton_t in_strafe; extern kbutton_t in_mlook; @@ -37,12 +32,6 @@ extern cvar_t *cl_movespeedkey; cvar_t *cl_laddermode; -float ac_forwardmove; -float ac_sidemove; -int ac_movecount; -float rel_yaw; -float rel_pitch; - #define F 1U<<0 // Forward #define B 1U<<1 // Back #define L 1U<<2 // Left @@ -55,7 +44,7 @@ float rel_pitch; #define IMPULSE_UP 4 int CL_IsDead( void ); -Vector dead_viewangles(0, 0, 0); +extern Vector dead_viewangles; void IN_ToggleButtons( float forwardmove, float sidemove ) { @@ -135,7 +124,7 @@ void IN_ToggleButtons( float forwardmove, float sidemove ) } } -void IN_ClientMoveEvent( float forwardmove, float sidemove ) +void FWGSInput::IN_ClientMoveEvent( float forwardmove, float sidemove ) { //gEngfuncs.Con_Printf("IN_MoveEvent\n"); @@ -144,14 +133,14 @@ void IN_ClientMoveEvent( float forwardmove, float sidemove ) ac_movecount++; } -void IN_ClientLookEvent( float relyaw, float relpitch ) +void FWGSInput::IN_ClientLookEvent( float relyaw, float relpitch ) { rel_yaw += relyaw; rel_pitch += relpitch; } // Rotate camera and add move values to usercmd -void IN_Move( float frametime, usercmd_t *cmd ) +void FWGSInput::IN_Move( float frametime, usercmd_t *cmd ) { Vector viewangles; bool fLadder = false; @@ -235,7 +224,7 @@ void IN_Move( float frametime, usercmd_t *cmd ) ac_movecount = 0; } -extern "C" void DLLEXPORT IN_MouseEvent( int mstate ) +void FWGSInput::IN_MouseEvent( int mstate ) { static int mouse_oldbuttonstate; // perform button actions @@ -257,37 +246,37 @@ extern "C" void DLLEXPORT IN_MouseEvent( int mstate ) // Stubs -extern "C" void DLLEXPORT IN_ClearStates( void ) +void FWGSInput::IN_ClearStates( void ) { //gEngfuncs.Con_Printf( "IN_ClearStates\n" ); } -extern "C" void DLLEXPORT IN_ActivateMouse( void ) +void FWGSInput::IN_ActivateMouse( void ) { //gEngfuncs.Con_Printf( "IN_ActivateMouse\n" ); } -extern "C" void DLLEXPORT IN_DeactivateMouse( void ) +void FWGSInput::IN_DeactivateMouse( void ) { //gEngfuncs.Con_Printf( "IN_DeactivateMouse\n" ); } -extern "C" void DLLEXPORT IN_Accumulate( void ) +void FWGSInput::IN_Accumulate( void ) { //gEngfuncs.Con_Printf( "IN_Accumulate\n" ); } -void IN_Commands( void ) +void FWGSInput::IN_Commands( void ) { //gEngfuncs.Con_Printf( "IN_Commands\n" ); } -void IN_Shutdown( void ) +void FWGSInput::IN_Shutdown( void ) { } // Register cvars and reset data -void IN_Init( void ) +void FWGSInput::IN_Init( void ) { sensitivity = gEngfuncs.pfnRegisterVariable( "sensitivity", "3", FCVAR_ARCHIVE ); in_joystick = gEngfuncs.pfnRegisterVariable( "joystick", "0", FCVAR_ARCHIVE ); diff --git a/cl_dll/inputw32.cpp b/cl_dll/inputw32.cpp deleted file mode 100644 index 5c8210fa..00000000 --- a/cl_dll/inputw32.cpp +++ /dev/null @@ -1,901 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -// in_win.c -- windows 95 mouse and joystick code -// 02/21/97 JCB Added extended DirectInput code to support external controllers. - -#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 "../engine/keydefs.h" -//#include "view.h" -#include "windows.h" - -#define MOUSE_BUTTON_COUNT 5 - -// Set this to 1 to show mouse cursor. Experimental -int g_iVisibleMouse = 0; - -extern "C" -{ - void DLLEXPORT IN_ActivateMouse( void ); - void DLLEXPORT IN_DeactivateMouse( void ); - void DLLEXPORT IN_MouseEvent( int mstate ); - void DLLEXPORT IN_Accumulate( void ); - void DLLEXPORT IN_ClearStates( void ); -} - -extern cl_enginefunc_t gEngfuncs; - -extern int iMouseInUse; - -extern kbutton_t in_strafe; -extern kbutton_t in_mlook; -extern kbutton_t in_speed; -extern kbutton_t in_jlook; - -extern cvar_t *m_pitch; -extern cvar_t *m_yaw; -extern cvar_t *m_forward; -extern cvar_t *m_side; - -extern cvar_t *lookstrafe; -extern cvar_t *lookspring; -extern cvar_t *cl_pitchdown; -extern cvar_t *cl_pitchup; -extern cvar_t *cl_yawspeed; -extern cvar_t *cl_sidespeed; -extern cvar_t *cl_forwardspeed; -extern cvar_t *cl_pitchspeed; -extern cvar_t *cl_movespeedkey; - -// mouse variables -cvar_t *m_filter; -cvar_t *sensitivity; - -int mouse_buttons; -int mouse_oldbuttonstate; -POINT current_pos; -int mouse_x, mouse_y, old_mouse_x, old_mouse_y, mx_accum, my_accum; - -static int restore_spi; -static int originalmouseparms[3], newmouseparms[3] = {0, 0, 1}; -static int mouseactive; -int mouseinitialized; -static int mouseparmsvalid; -static int mouseshowtoggle = 1; - -// joystick defines and variables -// where should defines be moved? -#define JOY_ABSOLUTE_AXIS 0x00000000 // control like a joystick -#define JOY_RELATIVE_AXIS 0x00000010 // control like a mouse, spinner, trackball -#define JOY_MAX_AXES 6 // X, Y, Z, R, U, V -#define JOY_AXIS_X 0 -#define JOY_AXIS_Y 1 -#define JOY_AXIS_Z 2 -#define JOY_AXIS_R 3 -#define JOY_AXIS_U 4 -#define JOY_AXIS_V 5 - -enum _ControlList -{ - AxisNada = 0, - AxisForward, - AxisLook, - AxisSide, - AxisTurn -}; - -DWORD dwAxisFlags[JOY_MAX_AXES] = -{ - JOY_RETURNX, - JOY_RETURNY, - JOY_RETURNZ, - JOY_RETURNR, - JOY_RETURNU, - JOY_RETURNV -}; - -DWORD dwAxisMap[JOY_MAX_AXES]; -DWORD dwControlMap[JOY_MAX_AXES]; -PDWORD pdwRawValue[JOY_MAX_AXES]; - -// none of these cvars are saved over a session -// this means that advanced controller configuration needs to be executed -// each time. this avoids any problems with getting back to a default usage -// or when changing from one controller to another. this way at least something -// works. -cvar_t *in_joystick; -cvar_t *joy_name; -cvar_t *joy_advanced; -cvar_t *joy_advaxisx; -cvar_t *joy_advaxisy; -cvar_t *joy_advaxisz; -cvar_t *joy_advaxisr; -cvar_t *joy_advaxisu; -cvar_t *joy_advaxisv; -cvar_t *joy_forwardthreshold; -cvar_t *joy_sidethreshold; -cvar_t *joy_pitchthreshold; -cvar_t *joy_yawthreshold; -cvar_t *joy_forwardsensitivity; -cvar_t *joy_sidesensitivity; -cvar_t *joy_pitchsensitivity; -cvar_t *joy_yawsensitivity; -cvar_t *joy_wwhack1; -cvar_t *joy_wwhack2; - -int joy_avail, joy_advancedinit, joy_haspov; -DWORD joy_oldbuttonstate, joy_oldpovstate; - -int joy_id; -DWORD joy_flags; -DWORD joy_numbuttons; - -static JOYINFOEX ji; - -/* -=========== -Force_CenterView_f -=========== -*/ -void Force_CenterView_f( void ) -{ - vec3_t viewangles; - - if( !iMouseInUse ) - { - gEngfuncs.GetViewAngles( (float *)viewangles ); - viewangles[PITCH] = 0; - gEngfuncs.SetViewAngles( (float *)viewangles ); - } -} - -/* -=========== -IN_ActivateMouse -=========== -*/ -void DLLEXPORT IN_ActivateMouse( void ) -{ - if( mouseinitialized ) - { - if( mouseparmsvalid ) - restore_spi = SystemParametersInfo( SPI_SETMOUSE, 0, newmouseparms, 0 ); - mouseactive = 1; - } -} - -/* -=========== -IN_DeactivateMouse -=========== -*/ -void DLLEXPORT IN_DeactivateMouse( void ) -{ - if( mouseinitialized ) - { - if( restore_spi ) - SystemParametersInfo( SPI_SETMOUSE, 0, originalmouseparms, 0 ); - mouseactive = 0; - } -} - -/* -=========== -IN_StartupMouse -=========== -*/ -void IN_StartupMouse( void ) -{ - if( gEngfuncs.CheckParm( "-nomouse", NULL ) ) - return; - - mouseinitialized = 1; - mouseparmsvalid = SystemParametersInfo( SPI_GETMOUSE, 0, originalmouseparms, 0 ); - - if( mouseparmsvalid ) - { - if( gEngfuncs.CheckParm( "-noforcemspd", NULL ) ) - newmouseparms[2] = originalmouseparms[2]; - - if( gEngfuncs.CheckParm( "-noforcemaccel", NULL ) ) - { - newmouseparms[0] = originalmouseparms[0]; - newmouseparms[1] = originalmouseparms[1]; - } - - if( gEngfuncs.CheckParm( "-noforcemparms", NULL ) ) - { - newmouseparms[0] = originalmouseparms[0]; - newmouseparms[1] = originalmouseparms[1]; - newmouseparms[2] = originalmouseparms[2]; - } - } - - mouse_buttons = MOUSE_BUTTON_COUNT; -} - -/* -=========== -IN_Shutdown -=========== -*/ -void IN_Shutdown( void ) -{ - IN_DeactivateMouse (); -} - -/* -=========== -IN_GetMousePos - -Ask for mouse position from engine -=========== -*/ -void IN_GetMousePos( int *mx, int *my ) -{ - gEngfuncs.GetMousePosition( mx, my ); -} - -/* -=========== -IN_ResetMouse - -FIXME: Call through to engine? -=========== -*/ -void IN_ResetMouse( void ) -{ - SetCursorPos ( gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY() ); -} - -/* -=========== -IN_MouseEvent -=========== -*/ -void DLLEXPORT IN_MouseEvent( int mstate ) -{ - int i; - - if( iMouseInUse || g_iVisibleMouse ) - return; - - // perform button actions - for( i = 0; i < mouse_buttons; i++ ) - { - if( ( mstate & ( 1 << i ) ) && - !( mouse_oldbuttonstate & ( 1 << i ) ) ) - { - gEngfuncs.Key_Event( K_MOUSE1 + i, 1 ); - } - - if( !( mstate & ( 1 << i ) ) && - ( mouse_oldbuttonstate & ( 1 << i ) ) ) - { - gEngfuncs.Key_Event( K_MOUSE1 + i, 0 ); - } - } - - mouse_oldbuttonstate = mstate; -} - -/* -=========== -IN_MouseMove -=========== -*/ -void IN_MouseMove( float frametime, usercmd_t *cmd ) -{ - int mx, my; - vec3_t viewangles; - - gEngfuncs.GetViewAngles( (float *)viewangles ); - - //jjb - this disbles normal mouse control if the user is trying to - // move the camera, or if the mouse cursor is visible or if we're in intermission - if( !iMouseInUse && !g_iVisibleMouse && !gHUD.m_iIntermission ) - { - GetCursorPos( ¤t_pos ); - - mx = current_pos.x - gEngfuncs.GetWindowCenterX() + mx_accum; - my = current_pos.y - gEngfuncs.GetWindowCenterY() + my_accum; - - mx_accum = 0; - my_accum = 0; - - if( m_filter->value ) - { - mouse_x = ( mx + old_mouse_x ) * 0.5; - mouse_y = ( my + old_mouse_y ) * 0.5; - } - else - { - mouse_x = mx; - mouse_y = my; - } - - old_mouse_x = mx; - old_mouse_y = my; - - if( gHUD.GetSensitivity() != 0 ) - { - mouse_x *= gHUD.GetSensitivity(); - mouse_y *= gHUD.GetSensitivity(); - } - else - { - mouse_x *= sensitivity->value; - mouse_y *= sensitivity->value; - } - - // add mouse X/Y movement to cmd - if( ( in_strafe.state & 1 ) || ( lookstrafe->value && ( in_mlook.state & 1 ) ) ) - cmd->sidemove += m_side->value * mouse_x; - else - viewangles[YAW] -= m_yaw->value * mouse_x; - - if( ( in_mlook.state & 1 ) && !( in_strafe.state & 1 ) ) - { - viewangles[PITCH] += m_pitch->value * mouse_y; - if( viewangles[PITCH] > cl_pitchdown->value ) - viewangles[PITCH] = cl_pitchdown->value; - if( viewangles[PITCH] < -cl_pitchup->value ) - viewangles[PITCH] = -cl_pitchup->value; - } - else - { - if( ( in_strafe.state & 1 ) && gEngfuncs.IsNoClipping() ) - { - cmd->upmove -= m_forward->value * mouse_y; - } - else - { - cmd->forwardmove -= m_forward->value * mouse_y; - } - } - - // if the mouse has moved, force it to the center, so there's room to move - if( mx || my ) - { - IN_ResetMouse(); - } - } - - gEngfuncs.SetViewAngles( (float *)viewangles ); - -/* -//#define TRACE_TEST -#if defined( TRACE_TEST ) - { - int mx, my; - void V_Move( int mx, int my ); - IN_GetMousePos( &mx, &my ); - V_Move( mx, my ); - } -#endif -*/ -} - -/* -=========== -IN_Accumulate -=========== -*/ -void DLLEXPORT IN_Accumulate( void ) -{ - //only accumulate mouse if we are not moving the camera with the mouse - if( !iMouseInUse && !g_iVisibleMouse ) - { - if( mouseactive ) - { - GetCursorPos( ¤t_pos ); - - mx_accum += current_pos.x - gEngfuncs.GetWindowCenterX(); - my_accum += current_pos.y - gEngfuncs.GetWindowCenterY(); - - // force the mouse to the center, so there's room to move - IN_ResetMouse(); - } - } -} - -/* -=================== -IN_ClearStates -=================== -*/ -void DLLEXPORT IN_ClearStates( void ) -{ - if( !mouseactive ) - return; - - mx_accum = 0; - my_accum = 0; - mouse_oldbuttonstate = 0; -} - -/* -=============== -IN_StartupJoystick -=============== -*/ -void IN_StartupJoystick( void ) -{ - int numdevs; - JOYCAPS jc; - MMRESULT mmr; - - // assume no joystick - joy_avail = 0; - - // abort startup if user requests no joystick - if( gEngfuncs.CheckParm( "-nojoy", NULL ) ) - return; - - // verify joystick driver is present - if( ( numdevs = joyGetNumDevs() ) == 0 ) - { - gEngfuncs.Con_DPrintf( "joystick not found -- driver not present\n\n" ); - return; - } - - // cycle through the joystick ids for the first valid one - for( joy_id = 0; joy_id < numdevs; joy_id++ ) - { - memset( &ji, 0, sizeof(ji) ); - ji.dwSize = sizeof(ji); - ji.dwFlags = JOY_RETURNCENTERED; - - if( ( mmr = joyGetPosEx( joy_id, &ji ) ) == JOYERR_NOERROR ) - break; - } - - // abort startup if we didn't find a valid joystick - if( mmr != JOYERR_NOERROR ) - { - gEngfuncs.Con_DPrintf( "joystick not found -- no valid joysticks (%x)\n\n", mmr ); - return; - } - - // get the capabilities of the selected joystick - // abort startup if command fails - memset( &jc, 0, sizeof(jc) ); - if( ( mmr = joyGetDevCaps( joy_id, &jc, sizeof(jc) ) ) != JOYERR_NOERROR ) - { - gEngfuncs.Con_DPrintf( "joystick not found -- invalid joystick capabilities (%x)\n\n", mmr ); - return; - } - - // save the joystick's number of buttons and POV status - joy_numbuttons = jc.wNumButtons; - joy_haspov = jc.wCaps & JOYCAPS_HASPOV; - - // old button and POV states default to no buttons pressed - joy_oldbuttonstate = joy_oldpovstate = 0; - - // mark the joystick as available and advanced initialization not completed - // this is needed as cvars are not available during initialization - gEngfuncs.Con_Printf( "joystick found\n\n", mmr ); - joy_avail = 1; - joy_advancedinit = 0; -} - -/* -=========== -RawValuePointer -=========== -*/ -PDWORD RawValuePointer( int axis ) -{ - switch( axis ) - { - case JOY_AXIS_X: - return &ji.dwXpos; - case JOY_AXIS_Y: - return &ji.dwYpos; - case JOY_AXIS_Z: - return &ji.dwZpos; - case JOY_AXIS_R: - return &ji.dwRpos; - case JOY_AXIS_U: - return &ji.dwUpos; - case JOY_AXIS_V: - return &ji.dwVpos; - } - // FIX: need to do some kind of error - return &ji.dwXpos; -} - -/* -=========== -Joy_AdvancedUpdate_f -=========== -*/ -void Joy_AdvancedUpdate_f( void ) -{ - // called once by IN_ReadJoystick and by user whenever an update is needed - // cvars are now available - int i; - DWORD dwTemp; - - // initialize all the maps - for( i = 0; i < JOY_MAX_AXES; i++ ) - { - dwAxisMap[i] = AxisNada; - dwControlMap[i] = JOY_ABSOLUTE_AXIS; - pdwRawValue[i] = RawValuePointer(i); - } - - if( joy_advanced->value == 0.0 ) - { - // default joystick initialization - // 2 axes only with joystick control - dwAxisMap[JOY_AXIS_X] = AxisTurn; - // dwControlMap[JOY_AXIS_X] = JOY_ABSOLUTE_AXIS; - dwAxisMap[JOY_AXIS_Y] = AxisForward; - // dwControlMap[JOY_AXIS_Y] = JOY_ABSOLUTE_AXIS; - } - else - { - if( strcmp( joy_name->string, "joystick" ) != 0 ) - { - // notify user of advanced controller - gEngfuncs.Con_Printf( "\n%s configured\n\n", joy_name->string ); - } - - // advanced initialization here - // data supplied by user via joy_axisn cvars - dwTemp = (DWORD)joy_advaxisx->value; - dwAxisMap[JOY_AXIS_X] = dwTemp & 0x0000000f; - dwControlMap[JOY_AXIS_X] = dwTemp & JOY_RELATIVE_AXIS; - dwTemp = (DWORD)joy_advaxisy->value; - dwAxisMap[JOY_AXIS_Y] = dwTemp & 0x0000000f; - dwControlMap[JOY_AXIS_Y] = dwTemp & JOY_RELATIVE_AXIS; - dwTemp = (DWORD)joy_advaxisz->value; - dwAxisMap[JOY_AXIS_Z] = dwTemp & 0x0000000f; - dwControlMap[JOY_AXIS_Z] = dwTemp & JOY_RELATIVE_AXIS; - dwTemp = (DWORD)joy_advaxisr->value; - dwAxisMap[JOY_AXIS_R] = dwTemp & 0x0000000f; - dwControlMap[JOY_AXIS_R] = dwTemp & JOY_RELATIVE_AXIS; - dwTemp = (DWORD)joy_advaxisu->value; - dwAxisMap[JOY_AXIS_U] = dwTemp & 0x0000000f; - dwControlMap[JOY_AXIS_U] = dwTemp & JOY_RELATIVE_AXIS; - dwTemp = (DWORD)joy_advaxisv->value; - dwAxisMap[JOY_AXIS_V] = dwTemp & 0x0000000f; - dwControlMap[JOY_AXIS_V] = dwTemp & JOY_RELATIVE_AXIS; - } - - // compute the axes to collect from DirectInput - joy_flags = JOY_RETURNCENTERED | JOY_RETURNBUTTONS | JOY_RETURNPOV; - for( i = 0; i < JOY_MAX_AXES; i++ ) - { - if( dwAxisMap[i] != AxisNada ) - { - joy_flags |= dwAxisFlags[i]; - } - } -} - -/* -=========== -IN_Commands -=========== -*/ -void IN_Commands( void ) -{ - int i, key_index; - DWORD buttonstate, povstate; - - if( !joy_avail ) - { - return; - } - - // loop through the joystick buttons - // key a joystick event or auxillary event for higher number buttons for each state change - buttonstate = ji.dwButtons; - for( i = 0; i < (int)joy_numbuttons; i++ ) - { - if( ( buttonstate & ( 1 << i ) ) && !( joy_oldbuttonstate & ( 1 << i ) ) ) - { - key_index = ( i < 4 ) ? K_JOY1 : K_AUX1; - gEngfuncs.Key_Event( key_index + i, 1 ); - } - - if( !( buttonstate & ( 1 << i ) ) && ( joy_oldbuttonstate & ( 1 << i ) ) ) - { - key_index = ( i < 4 ) ? K_JOY1 : K_AUX1; - gEngfuncs.Key_Event( key_index + i, 0 ); - } - } - joy_oldbuttonstate = buttonstate; - - if( joy_haspov ) - { - // convert POV information into 4 bits of state information - // this avoids any potential problems related to moving from one - // direction to another without going through the center position - povstate = 0; - if( ji.dwPOV != JOY_POVCENTERED ) - { - if( ji.dwPOV == JOY_POVFORWARD ) - povstate |= 0x01; - if( ji.dwPOV == JOY_POVRIGHT ) - povstate |= 0x02; - if( ji.dwPOV == JOY_POVBACKWARD ) - povstate |= 0x04; - if( ji.dwPOV == JOY_POVLEFT ) - povstate |= 0x08; - } - // determine which bits have changed and key an auxillary event for each change - for( i = 0; i < 4; i++ ) - { - if( ( povstate & ( 1 << i ) ) && !( joy_oldpovstate & ( 1 << i ) ) ) - { - gEngfuncs.Key_Event( K_AUX29 + i, 1 ); - } - - if( !( povstate & ( 1 << i ) ) && ( joy_oldpovstate & ( 1 << i ) ) ) - { - gEngfuncs.Key_Event( K_AUX29 + i, 0 ); - } - } - joy_oldpovstate = povstate; - } -} - -/* -=============== -IN_ReadJoystick -=============== -*/ -int IN_ReadJoystick( void ) -{ - memset( &ji, 0, sizeof(ji) ); - ji.dwSize = sizeof(ji); - ji.dwFlags = joy_flags; - - if( joyGetPosEx( joy_id, &ji ) == JOYERR_NOERROR ) - { - // this is a hack -- there is a bug in the Logitech WingMan Warrior DirectInput Driver - // rather than having 32768 be the zero point, they have the zero point at 32668 - // go figure -- anyway, now we get the full resolution out of the device - if( joy_wwhack1->value != 0.0 ) - { - ji.dwUpos += 100; - } - return 1; - } - else - { - // read error occurred - // turning off the joystick seems too harsh for 1 read error,\ - // but what should be done? - // Con_Printf( "IN_ReadJoystick: no response\n" ); - // joy_avail = 0; - return 0; - } -} - -/* -=========== -IN_JoyMove -=========== -*/ -void IN_JoyMove( float frametime, usercmd_t *cmd ) -{ - float speed, aspeed; - float fAxisValue, fTemp; - int i; - vec3_t viewangles; - - gEngfuncs.GetViewAngles( (float *)viewangles ); - - // complete initialization if first time in - // this is needed as cvars are not available at initialization time - if( joy_advancedinit != 1 ) - { - Joy_AdvancedUpdate_f(); - joy_advancedinit = 1; - } - - // verify joystick is available and that the user wants to use it - if( !joy_avail || !in_joystick->value ) - { - return; - } - - // collect the joystick data, if possible - if( IN_ReadJoystick () != 1 ) - { - return; - } - - if( in_speed.state & 1 ) - speed = cl_movespeedkey->value; - else - speed = 1; - - aspeed = speed * frametime; - - // loop through the axes - for( i = 0; i < JOY_MAX_AXES; i++ ) - { - // get the floating point zero-centered, potentially-inverted data for the current axis - fAxisValue = (float) *pdwRawValue[i]; - // move centerpoint to zero - fAxisValue -= 32768.0; - - if( joy_wwhack2->value != 0.0 ) - { - if( dwAxisMap[i] == AxisTurn ) - { - // this is a special formula for the Logitech WingMan Warrior - // y=ax^b; where a = 300 and b = 1.3 - // also x values are in increments of 800 (so this is factored out) - // then bounds check result to level out excessively high spin rates - fTemp = 300.0 * pow( abs( fAxisValue ) / 800.0, 1.3 ); - if( fTemp > 14000.0 ) - fTemp = 14000.0; - // restore direction information - fAxisValue = ( fAxisValue > 0.0 ) ? fTemp : -fTemp; - } - } - - // convert range from -32768..32767 to -1..1 - fAxisValue /= 32768.0; - - switch( dwAxisMap[i] ) - { - case AxisForward: - if( ( joy_advanced->value == 0.0 ) && ( in_jlook.state & 1 ) ) - { - // user wants forward control to become look control - if( fabs( fAxisValue ) > joy_pitchthreshold->value ) - { - // if mouse invert is on, invert the joystick pitch value - // only absolute control support here (joy_advanced is 0) - if( m_pitch->value < 0.0 ) - { - viewangles[PITCH] -= ( fAxisValue * joy_pitchsensitivity->value ) * aspeed * cl_pitchspeed->value; - } - else - { - viewangles[PITCH] += ( fAxisValue * joy_pitchsensitivity->value ) * aspeed * cl_pitchspeed->value; - } - } - } - else - { - // user wants forward control to be forward control - if( fabs( fAxisValue ) > joy_forwardthreshold->value ) - { - cmd->forwardmove += ( fAxisValue * joy_forwardsensitivity->value ) * speed * cl_forwardspeed->value; - } - } - break; - case AxisSide: - if( fabs( fAxisValue ) > joy_sidethreshold->value ) - { - cmd->sidemove += ( fAxisValue * joy_sidesensitivity->value ) * speed * cl_sidespeed->value; - } - break; - case AxisTurn: - if( ( in_strafe.state & 1 ) || ( lookstrafe->value && ( in_jlook.state & 1 ) ) ) - { - // user wants turn control to become side control - if( fabs( fAxisValue ) > joy_sidethreshold->value ) - { - cmd->sidemove -= ( fAxisValue * joy_sidesensitivity->value ) * speed * cl_sidespeed->value; - } - } - else - { - // user wants turn control to be turn control - if( fabs( fAxisValue ) > joy_yawthreshold->value ) - { - if( dwControlMap[i] == JOY_ABSOLUTE_AXIS ) - { - viewangles[YAW] += ( fAxisValue * joy_yawsensitivity->value ) * aspeed * cl_yawspeed->value; - } - else - { - viewangles[YAW] += ( fAxisValue * joy_yawsensitivity->value ) * speed * 180.0; - } - } - } - break; - case AxisLook: - if( in_jlook.state & 1 ) - { - if( fabs( fAxisValue ) > joy_pitchthreshold->value ) - { - // pitch movement detected and pitch movement desired by user - if( dwControlMap[i] == JOY_ABSOLUTE_AXIS ) - { - viewangles[PITCH] += ( fAxisValue * joy_pitchsensitivity->value ) * aspeed * cl_pitchspeed->value; - } - else - { - viewangles[PITCH] += ( fAxisValue * joy_pitchsensitivity->value ) * speed * 180.0; - } - } - } - break; - default: - break; - } - } - - // bounds check pitch - if( viewangles[PITCH] > cl_pitchdown->value ) - viewangles[PITCH] = cl_pitchdown->value; - if( viewangles[PITCH] < -cl_pitchup->value ) - viewangles[PITCH] = -cl_pitchup->value; - - gEngfuncs.SetViewAngles( (float *)viewangles ); -} - -/* -=========== -IN_Move -=========== -*/ -void IN_Move( float frametime, usercmd_t *cmd ) -{ - if( !iMouseInUse && mouseactive ) - { - IN_MouseMove( frametime, cmd ); - } - - IN_JoyMove( frametime, cmd ); -} - -/* -=========== -IN_Init -=========== -*/ -void IN_Init( void ) -{ - m_filter = gEngfuncs.pfnRegisterVariable( "m_filter","0", FCVAR_ARCHIVE ); - sensitivity = gEngfuncs.pfnRegisterVariable( "sensitivity","3", FCVAR_ARCHIVE ); // user mouse sensitivity setting. - - in_joystick = gEngfuncs.pfnRegisterVariable( "joystick","0", FCVAR_ARCHIVE ); - joy_name = gEngfuncs.pfnRegisterVariable( "joyname", "joystick", 0 ); - joy_advanced = gEngfuncs.pfnRegisterVariable( "joyadvanced", "0", 0 ); - joy_advaxisx = gEngfuncs.pfnRegisterVariable( "joyadvaxisx", "0", 0 ); - joy_advaxisy = gEngfuncs.pfnRegisterVariable( "joyadvaxisy", "0", 0 ); - joy_advaxisz = gEngfuncs.pfnRegisterVariable( "joyadvaxisz", "0", 0 ); - joy_advaxisr = gEngfuncs.pfnRegisterVariable( "joyadvaxisr", "0", 0 ); - joy_advaxisu = gEngfuncs.pfnRegisterVariable( "joyadvaxisu", "0", 0 ); - joy_advaxisv = gEngfuncs.pfnRegisterVariable( "joyadvaxisv", "0", 0 ); - joy_forwardthreshold = gEngfuncs.pfnRegisterVariable( "joyforwardthreshold", "0.15", 0 ); - joy_sidethreshold = gEngfuncs.pfnRegisterVariable( "joysidethreshold", "0.15", 0 ); - joy_pitchthreshold = gEngfuncs.pfnRegisterVariable( "joypitchthreshold", "0.15", 0 ); - joy_yawthreshold = gEngfuncs.pfnRegisterVariable( "joyyawthreshold", "0.15", 0 ); - joy_forwardsensitivity = gEngfuncs.pfnRegisterVariable( "joyforwardsensitivity", "-1.0", 0 ); - joy_sidesensitivity = gEngfuncs.pfnRegisterVariable( "joysidesensitivity", "-1.0", 0 ); - joy_pitchsensitivity = gEngfuncs.pfnRegisterVariable( "joypitchsensitivity", "1.0", 0 ); - joy_yawsensitivity = gEngfuncs.pfnRegisterVariable( "joyyawsensitivity", "-1.0", 0 ); - joy_wwhack1 = gEngfuncs.pfnRegisterVariable( "joywwhack1", "0.0", 0 ); - joy_wwhack2 = gEngfuncs.pfnRegisterVariable( "joywwhack2", "0.0", 0 ); - - gEngfuncs.pfnAddCommand ("force_centerview", Force_CenterView_f); - gEngfuncs.pfnAddCommand ("joyadvancedupdate", Joy_AdvancedUpdate_f); - - IN_StartupMouse (); - IN_StartupJoystick (); -} diff --git a/cl_dll/kbutton.h b/cl_dll/kbutton.h index 29accdf5..4c7c7ae8 100644 --- a/cl_dll/kbutton.h +++ b/cl_dll/kbutton.h @@ -1,13 +1,12 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // // $NoKeywords: $ //============================================================================= - +#pragma once #if !defined( KBUTTONH ) #define KBUTTONH -#pragma once typedef struct kbutton_s { diff --git a/cl_dll/menu.cpp b/cl_dll/menu.cpp index 5f710a33..fc24b917 100644 --- a/cl_dll/menu.cpp +++ b/cl_dll/menu.cpp @@ -83,7 +83,7 @@ int CHudMenu::Draw( float flTime ) int nlc = 0; for( i = 0; i < MAX_MENU_STRING && g_szMenuString[i] != '\0'; i++ ) { - if ( g_szMenuString[i] == '\n' ) + if( g_szMenuString[i] == '\n' ) nlc++; } @@ -153,19 +153,21 @@ int CHudMenu::MsgFunc_ShowMenu( const char *pszName, int iSize, void *pbuf ) else { // append to the current menu string - strncat( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING - strlen( g_szPrelocalisedMenuString ) ); + strncat( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING - strlen( g_szPrelocalisedMenuString ) - 1 ); } g_szPrelocalisedMenuString[MAX_MENU_STRING - 1] = 0; // ensure null termination (strncat/strncpy does not) if( !NeedMore ) { // we have the whole string, so we can localise it now - strcpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString( g_szPrelocalisedMenuString ) ); + strncpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString( g_szPrelocalisedMenuString ), MAX_MENU_STRING ); + g_szMenuString[MAX_MENU_STRING - 1] = '\0'; // Swap in characters if( KB_ConvertString( g_szMenuString, &temp ) ) { - strcpy( g_szMenuString, temp ); + strncpy( g_szMenuString, temp, MAX_MENU_STRING ); + g_szMenuString[MAX_MENU_STRING - 1] = '\0'; free( temp ); } } diff --git a/cl_dll/message.cpp b/cl_dll/message.cpp index 5d52d413..ff8d97bf 100644 --- a/cl_dll/message.cpp +++ b/cl_dll/message.cpp @@ -29,7 +29,7 @@ DECLARE_MESSAGE( m_Message, GameTitle ) // 1 Global client_textmessage_t for custom messages that aren't in the titles.txt client_textmessage_t g_pCustomMessage; -char *g_pCustomName = "Custom"; +const char *g_pCustomName = "Custom"; char g_pCustomText[1024]; int CHudMessage::Init( void ) @@ -260,7 +260,7 @@ void CHudMessage::MessageDrawScan( client_textmessage_t *pMessage, float time ) width = 0; } else - width += gHUD.m_scrinfo.charWidths[*pText]; + width += gHUD.m_scrinfo.charWidths[(unsigned char)*pText]; pText++; length++; } @@ -310,7 +310,7 @@ int CHudMessage::Draw( float fTime ) { int i, drawn; client_textmessage_t *pMessage; - float endTime = 0; + float endTime = 0.0f; drawn = 0; diff --git a/cl_dll/overview.cpp b/cl_dll/overview.cpp index 881812f7..81f028e2 100644 --- a/cl_dll/overview.cpp +++ b/cl_dll/overview.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/overview.h b/cl_dll/overview.h index 6748760b..c1675e98 100644 --- a/cl_dll/overview.h +++ b/cl_dll/overview.h @@ -1,13 +1,13 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // // $NoKeywords: $ //============================================================================= +#pragma once #ifndef OVERVIEW_H #define OVERVIEW_H -#pragma once //----------------------------------------------------------------------------- // Purpose: Handles the drawing of the top-down map and all the things on it diff --git a/cl_dll/parsemsg.h b/cl_dll/parsemsg.h index 0e6bd2a3..05efefc3 100644 --- a/cl_dll/parsemsg.h +++ b/cl_dll/parsemsg.h @@ -15,6 +15,9 @@ // // parsemsg.h // +#pragma once +#ifndef PARSEMSG_H +#define PARSEMSG_H #define ASSERT( x ) @@ -30,6 +33,7 @@ float READ_COORD( void ); float READ_ANGLE( void ); float READ_HIRESANGLE( void ); +#endif // PARSEMSG_H diff --git a/cl_dll/poke646/scope.cpp b/cl_dll/poke646/scope.cpp index 9f9cea6c..7ce5b209 100644 --- a/cl_dll/poke646/scope.cpp +++ b/cl_dll/poke646/scope.cpp @@ -26,63 +26,15 @@ #include "pm_shared.h" #include "pm_defs.h" #include "pmtrace.h" - +extern bool bDrawScope; extern vec3_t v_origin; // last view origin extern vec3_t v_angles; // last view angle extern vec3_t v_cl_angles; // last client/mouse angle extern vec3_t v_sim_org; // last sim origin -DECLARE_MESSAGE(m_Scope, Scope) - -int CHudScope::Init(void) +int CHudScope::DrawScope() { - HOOK_MESSAGE(Scope); - - m_iFlags = 0; - - gHUD.AddHudElem(this); - return 1; -} - -void CHudScope::Reset(void) -{ - -} - -int CHudScope::VidInit(void) -{ - m_hSprite = SPR_Load("sprites/scopeborder.spr"); - - return 1; -} - -int CHudScope::MsgFunc_Scope(const char *pszName, int iSize, void *pbuf) -{ - // TODO: update local health data - BEGIN_READ(pbuf, iSize); - int fOn = READ_BYTE(); - - if (fOn) - { - m_iFlags |= HUD_ACTIVE; - } - else - { - m_iFlags &= ~HUD_ACTIVE; - } - - return 1; -} - - -int CHudScope::Draw(float flTime) -{ - return 1; -} - -int CHudScope::DrawScope(void) -{ - if (!(m_iFlags & HUD_ACTIVE)) + if( !bDrawScope ) return 1; if (!m_hSprite) @@ -341,4 +293,4 @@ int CHudScope::DrawScope(void) // gEngfuncs.Con_Printf("CMLWBR trace distance: %.3f\n", meters); return 1; -} \ No newline at end of file +} diff --git a/cl_dll/scoreboard.cpp b/cl_dll/scoreboard.cpp index 2e0722f9..5d52787c 100644 --- a/cl_dll/scoreboard.cpp +++ b/cl_dll/scoreboard.cpp @@ -26,6 +26,7 @@ #include #include +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 @@ -59,6 +60,7 @@ int CHudScoreboard::Init( void ) InitHUDData(); + cl_scoreboard_bg = CVAR_CREATE( "cl_scoreboard_bg", "1", FCVAR_ARCHIVE ); cl_showpacketloss = CVAR_CREATE( "cl_showpacketloss", "0", FCVAR_ARCHIVE ); return 1; @@ -92,6 +94,7 @@ We have a minimum width of 1-320 - we could have the field widths scale with it? // relative to the side of the scoreboard #define NAME_RANGE_MIN 20 #define NAME_RANGE_MAX 145 +#define NAME_RANGE_MODIFIER 120 #define KILLS_RANGE_MIN 130 #define KILLS_RANGE_MAX 170 #define DIVIDER_POS 180 @@ -126,11 +129,11 @@ int CHudScoreboard::Draw( float fTime ) if( cl_showpacketloss && cl_showpacketloss->value && ( ScreenWidth >= 400 ) ) { can_show_packetloss = 1; - SCOREBOARD_WIDTH = 400; + SCOREBOARD_WIDTH = ( ScreenWidth >= 520 ) ? ( 400 - NAME_RANGE_MODIFIER ) : 400; } else { - SCOREBOARD_WIDTH = 320; + SCOREBOARD_WIDTH = ( ScreenWidth >= 440 ) ? ( 320 - NAME_RANGE_MODIFIER ) : 320; } // just sort the list on the fly @@ -144,25 +147,33 @@ int CHudScoreboard::Draw( float fTime ) FAR_RIGHT = can_show_packetloss ? PL_RANGE_MAX : PING_RANGE_MAX; FAR_RIGHT += 5; - gHUD.DrawDarkRectangle( xpos - 5, ypos - 5, FAR_RIGHT, ROW_RANGE_MAX ); + + if( ( ScreenWidth >= 440 && !can_show_packetloss ) || ( ScreenWidth >= 520 && can_show_packetloss ) ) + { + xpos -= NAME_RANGE_MODIFIER; + FAR_RIGHT += NAME_RANGE_MODIFIER; + } + + if( cl_scoreboard_bg && cl_scoreboard_bg->value ) + gHUD.DrawDarkRectangle( xpos - 5, ypos - 5, FAR_RIGHT, ROW_RANGE_MAX ); if( !gHUD.m_Teamplay ) - gHUD.DrawHudString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, "Player", 255, 140, 0 ); + DrawUtfString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, "Player", 255, 140, 0 ); else - gHUD.DrawHudString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, "Teams", 255, 140, 0 ); + DrawUtfString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, "Teams", 255, 140, 0 ); gHUD.DrawHudStringReverse( KILLS_RANGE_MAX + xpos_rel, ypos, 0, "kills", 255, 140, 0 ); - gHUD.DrawHudString( DIVIDER_POS + xpos_rel, ypos, ScreenWidth, "/", 255, 140, 0 ); - gHUD.DrawHudString( DEATHS_RANGE_MIN + xpos_rel + 5, ypos, ScreenWidth, "deaths", 255, 140, 0 ); - gHUD.DrawHudString( PING_RANGE_MAX + xpos_rel - 35, ypos, ScreenWidth, "latency", 255, 140, 0 ); + DrawUtfString( DIVIDER_POS + xpos_rel, ypos, ScreenWidth, "/", 255, 140, 0 ); + DrawUtfString( DEATHS_RANGE_MIN + xpos_rel + 5, ypos, ScreenWidth, "deaths", 255, 140, 0 ); + DrawUtfString( PING_RANGE_MAX + xpos_rel - 35, ypos, ScreenWidth, "latency", 255, 140, 0 ); if( can_show_packetloss ) { - gHUD.DrawHudString( PL_RANGE_MAX + xpos_rel - 35, ypos, ScreenWidth, "pkt loss", 255, 140, 0 ); + DrawUtfString( PL_RANGE_MAX + xpos_rel - 35, ypos, ScreenWidth, "pkt loss", 255, 140, 0 ); } list_slot += 1.2; ypos = ROW_RANGE_MIN + ( list_slot * ROW_GAP ); - xpos = NAME_RANGE_MIN + xpos_rel; + // 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; @@ -263,16 +274,22 @@ int CHudScoreboard::Draw( float fTime ) break; xpos = NAME_RANGE_MIN + xpos_rel; + + if( ( ScreenWidth >= 440 && !can_show_packetloss ) || ( ScreenWidth >= 520 && can_show_packetloss ) ) + { + xpos -= NAME_RANGE_MODIFIER; + } + int r = 255, g = 225, b = 55; // draw the stuff kinda yellowish if( team_info->ownteam ) // if it is their team, draw the background different color { // overlay the background in blue, then draw the score text over it - FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 0, 0, 255, 70 ); + FillRGBA( xpos - 5, ypos, FAR_RIGHT, ROW_GAP, 0, 0, 255, 70 ); } // draw their name (left to right) - gHUD.DrawHudString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, team_info->name, r, g, b ); + DrawUtfString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, team_info->name, r, g, b ); // draw kills (right to left) xpos = KILLS_RANGE_MAX + xpos_rel; @@ -280,7 +297,7 @@ int CHudScoreboard::Draw( float fTime ) // draw divider xpos = DIVIDER_POS + xpos_rel; - gHUD.DrawHudString( xpos, ypos, xpos + 20, "/", r, g, b ); + DrawUtfString( xpos, ypos, xpos + 20, "/", r, g, b ); // draw deaths xpos = DEATHS_RANGE_MAX + xpos_rel; @@ -300,7 +317,7 @@ int CHudScoreboard::Draw( float fTime ) xpos = ( ( PL_RANGE_MAX - PL_RANGE_MIN ) / 2) + PL_RANGE_MIN + xpos_rel + 25; sprintf( buf, " %d", team_info->packetloss ); - gHUD.DrawHudString( xpos, ypos, xpos+50, buf, r, g, b ); + DrawUtfString( xpos, ypos, xpos+50, buf, r, g, b ); } team_info->already_drawn = TRUE; // set the already_drawn to be TRUE, so this team won't get drawn again @@ -320,7 +337,7 @@ int CHudScoreboard::Draw( float fTime ) extern float *GetClientColor( int client ); // returns the ypos where it finishes drawing -int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, char *team ) +int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, const char *team ) { int can_show_packetloss = 0; int FAR_RIGHT; @@ -339,6 +356,11 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, FAR_RIGHT = can_show_packetloss ? PL_RANGE_MAX : PING_RANGE_MAX; FAR_RIGHT += 5; + if( ( ScreenWidth >= 440 && !can_show_packetloss ) || ( ScreenWidth >= 520 && can_show_packetloss ) ) + { + FAR_RIGHT += NAME_RANGE_MODIFIER; + } + // draw the players, in order, and restricted to team if set while( 1 ) { @@ -377,6 +399,12 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, break; int xpos = NAME_RANGE_MIN + xpos_rel; + + if( ( ScreenWidth >= 440 && !can_show_packetloss ) || ( ScreenWidth >= 520 && can_show_packetloss ) ) + { + xpos -= NAME_RANGE_MODIFIER; + } + int r = 255, g = 255, b = 255; float *colors = GetClientColor( best_player ); r *= colors[0], g *= colors[1], b *= colors[2]; @@ -385,22 +413,22 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, if( pl_info->thisplayer ) { // green is the suicide color? i wish this could do grey... - FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 80, 155, 0, 70 ); + FillRGBA( xpos - 5, ypos, FAR_RIGHT, ROW_GAP, 80, 155, 0, 70 ); } else { // Highlight the killers name - overlay the background in red, then draw the score text over it - FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 255, 0, 0, ( (float)15 * (float)( m_fLastKillTime - gHUD.m_flTime ) ) ); + FillRGBA( xpos - 5, ypos, FAR_RIGHT, ROW_GAP, 255, 0, 0, ( (float)15 * (float)( m_fLastKillTime - gHUD.m_flTime ) ) ); } } else if( pl_info->thisplayer ) // if it is their name, draw it a different color { // overlay the background in blue, then draw the score text over it - FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 0, 0, 255, 70 ); + FillRGBA( xpos - 5, ypos, FAR_RIGHT, ROW_GAP, 0, 0, 255, 70 ); } // draw their name (left to right) - gHUD.DrawHudString( xpos + nameoffset, ypos, NAME_RANGE_MAX + xpos_rel, pl_info->name, r, g, b ); + DrawUtfString( xpos + nameoffset, ypos, NAME_RANGE_MAX + xpos_rel, pl_info->name, r, g, b ); // draw kills (right to left) xpos = KILLS_RANGE_MAX + xpos_rel; @@ -408,7 +436,7 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, // draw divider xpos = DIVIDER_POS + xpos_rel; - gHUD.DrawHudString( xpos, ypos, xpos + 20, "/", r, g, b ); + DrawUtfString( xpos, ypos, xpos + 20, "/", r, g, b ); // draw deaths xpos = DEATHS_RANGE_MAX + xpos_rel; @@ -435,7 +463,7 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, xpos = ( ( PL_RANGE_MAX - PL_RANGE_MIN ) / 2 ) + PL_RANGE_MIN + xpos_rel + 25; - gHUD.DrawHudString( xpos, ypos, xpos+50, buf, r, g, b ); + DrawUtfString( xpos, ypos, xpos+50, buf, r, g, b ); } pl_info->name = NULL; // set the name to be NULL, so this client won't get drawn again diff --git a/cl_dll/status_icons.cpp b/cl_dll/status_icons.cpp index c960d5ef..4b2d9726 100644 --- a/cl_dll/status_icons.cpp +++ b/cl_dll/status_icons.cpp @@ -104,7 +104,7 @@ int CHudStatusIcons::MsgFunc_StatusIcon( const char *pszName, int iSize, void *p } // add the icon to the icon list, and set it's drawing color -void CHudStatusIcons::EnableIcon( char *pszIconName, unsigned char red, unsigned char green, unsigned char blue ) +void CHudStatusIcons::EnableIcon( const char *pszIconName, unsigned char red, unsigned char green, unsigned char blue ) { int i; @@ -149,7 +149,7 @@ void CHudStatusIcons::EnableIcon( char *pszIconName, unsigned char red, unsigned } } -void CHudStatusIcons::DisableIcon( char *pszIconName ) +void CHudStatusIcons::DisableIcon( const char *pszIconName ) { // find the sprite is in the current list for( int i = 0; i < MAX_ICONSPRITES; i++ ) diff --git a/cl_dll/studio_util.cpp b/cl_dll/studio_util.cpp index a5eb39f1..6e488dcb 100644 --- a/cl_dll/studio_util.cpp +++ b/cl_dll/studio_util.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/studio_util.h b/cl_dll/studio_util.h index 963dcda7..83de704c 100644 --- a/cl_dll/studio_util.h +++ b/cl_dll/studio_util.h @@ -1,15 +1,13 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // // $NoKeywords: $ //============================================================================= +#pragma once #if !defined( STUDIO_UTIL_H ) #define STUDIO_UTIL_H -#if defined( WIN32 ) -#pragma once -#endif #ifndef M_PI #define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h diff --git a/cl_dll/text_message.cpp b/cl_dll/text_message.cpp index af62a915..512623dd 100644 --- a/cl_dll/text_message.cpp +++ b/cl_dll/text_message.cpp @@ -45,14 +45,15 @@ int CHudTextMessage::Init( void ) char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, int buffer_size ) { char *dst = dst_buffer; - for( char *src = (char*)msg; *src != 0 && buffer_size > 0; buffer_size-- ) + for( char *src = (char*)msg; *src != 0 && ( buffer_size - 1 ) > 0; buffer_size-- ) { if( *src == '#' ) { // cut msg name out of string static char word_buf[255]; char *wdst = word_buf, *word_start = src; - for( ++src; ( *src >= 'A' && *src <= 'z' ) || ( *src >= '0' && *src <= '9' ); wdst++, src++ ) + int wordbuf_size = (int)sizeof(word_buf); + for( ++src; ( ( *src >= 'A' && *src <= 'z' ) || ( *src >= '0' && *src <= '9' ) ) && ( wordbuf_size - 1 ) > 0; wdst++, src++, wordbuf_size-- ) { *wdst = *src; } @@ -69,21 +70,20 @@ char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, in } // copy string into message over the msg name - for( char *wsrc = (char*)clmsg->pMessage; *wsrc != 0; wsrc++, dst++ ) + for( char *wsrc = (char*)clmsg->pMessage; *wsrc != 0 && ( buffer_size - 1 ) > 0; wsrc++, dst++, buffer_size-- ) { *dst = *wsrc; } - *dst = 0; + buffer_size++; } else { *dst = *src; dst++, src++; - *dst = 0; } } - dst_buffer[buffer_size - 1] = 0; // ensure null termination + *dst = 0; // ensure null termination return dst_buffer; } @@ -91,12 +91,12 @@ char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, in char *CHudTextMessage::BufferedLocaliseTextString( const char *msg ) { static char dst_buffer[1024]; - LocaliseTextString( msg, dst_buffer, 1024 ); + LocaliseTextString( msg, dst_buffer, sizeof(dst_buffer) ); return dst_buffer; } // Simplified version of LocaliseTextString; assumes string is only one word -char *CHudTextMessage::LookupString( const char *msg, int *msg_dest ) +const char *CHudTextMessage::LookupString( const char *msg, int *msg_dest ) { if( !msg ) return ""; @@ -108,7 +108,7 @@ char *CHudTextMessage::LookupString( const char *msg, int *msg_dest ) client_textmessage_t *clmsg = TextMessageGet( msg + 1 ); if( !clmsg || !(clmsg->pMessage) ) - return (char*)msg; // lookup failed, so return the original string + return msg; // lookup failed, so return the original string if( msg_dest ) { @@ -118,12 +118,12 @@ char *CHudTextMessage::LookupString( const char *msg, int *msg_dest ) *msg_dest = -clmsg->effect; } - return (char*)clmsg->pMessage; + return clmsg->pMessage; } else { // nothing special about this message, so just return the same string - return (char*)msg; + return msg; } } @@ -162,42 +162,39 @@ int CHudTextMessage::MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf int msg_dest = READ_BYTE(); - static char szBuf[6][128]; - char *msg_text = LookupString( READ_STRING(), &msg_dest ); - msg_text = strcpy( szBuf[0], msg_text ); +#define MSG_BUF_SIZE 128 + char szBuf[6][MSG_BUF_SIZE]; + + strncpy( szBuf[0], LookupString( READ_STRING(), &msg_dest ), MSG_BUF_SIZE - 1 ); + szBuf[0][MSG_BUF_SIZE - 1] = '\0'; + + for( int i = 1; i <= 4; i++ ) + { + // keep reading strings and using C format strings for subsituting the strings into the localised text string + strncpy( szBuf[i], LookupString( READ_STRING() ), MSG_BUF_SIZE - 1 ); + szBuf[i][MSG_BUF_SIZE - 1] = '\0'; + StripEndNewlineFromString( szBuf[i] ); // these strings are meant for subsitution into the main strings, so cull the automatic end newlines + } - // keep reading strings and using C format strings for subsituting the strings into the localised text string - char *sstr1 = LookupString( READ_STRING() ); - sstr1 = strcpy( szBuf[1], sstr1 ); - StripEndNewlineFromString( sstr1 ); // these strings are meant for subsitution into the main strings, so cull the automatic end newlines - char *sstr2 = LookupString( READ_STRING() ); - sstr2 = strcpy( szBuf[2], sstr2 ); - StripEndNewlineFromString( sstr2 ); - char *sstr3 = LookupString( READ_STRING() ); - sstr3 = strcpy( szBuf[3], sstr3 ); - StripEndNewlineFromString( sstr3 ); - char *sstr4 = LookupString( READ_STRING() ); - sstr4 = strcpy( szBuf[4], sstr4 ); - StripEndNewlineFromString( sstr4 ); char *psz = szBuf[5]; switch( msg_dest ) { case HUD_PRINTCENTER: - sprintf( psz, msg_text, sstr1, sstr2, sstr3, sstr4 ); + _snprintf( psz, MSG_BUF_SIZE, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); CenterPrint( ConvertCRtoNL( psz ) ); break; case HUD_PRINTNOTIFY: psz[0] = 1; // mark this message to go into the notify buffer - sprintf( psz + 1, msg_text, sstr1, sstr2, sstr3, sstr4 ); + _snprintf( psz + 1, MSG_BUF_SIZE - 1, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); ConsolePrint( ConvertCRtoNL( psz ) ); break; case HUD_PRINTTALK: - sprintf( psz, msg_text, sstr1, sstr2, sstr3, sstr4 ); - gHUD.m_SayText.SayTextPrint( ConvertCRtoNL( psz ), 128 ); + _snprintf( psz, MSG_BUF_SIZE, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); + gHUD.m_SayText.SayTextPrint( ConvertCRtoNL( psz ), MSG_BUF_SIZE ); break; case HUD_PRINTCONSOLE: - sprintf( psz, msg_text, sstr1, sstr2, sstr3, sstr4 ); + _snprintf( psz, MSG_BUF_SIZE, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); ConsolePrint( ConvertCRtoNL( psz ) ); break; } diff --git a/cl_dll/tri.cpp b/cl_dll/tri.cpp index fabbe4b5..7c111432 100644 --- a/cl_dll/tri.cpp +++ b/cl_dll/tri.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // @@ -112,19 +112,9 @@ Render any triangles with transparent rendermode needs here */ void DLLEXPORT HUD_DrawTransparentTriangles( void ) { + gHUD.m_Scope.DrawScope(); #if defined( TEST_IT ) // Draw_Triangles(); #endif } -/* -================= -HUD_DrawOrthoTriangles -Orthogonal Triangles -- (relative to resolution, -smackdab on the screen) add them here -================= -*/ -void HUD_DrawOrthoTriangles( void ) -{ - gHUD.m_Scope.DrawScope(); -} diff --git a/cl_dll/util_vector.h b/cl_dll/util_vector.h index ff5f9a91..477d97be 100644 --- a/cl_dll/util_vector.h +++ b/cl_dll/util_vector.h @@ -15,6 +15,9 @@ // Vector.h // A subset of the extdll.h in the project HL Entity DLL // +#pragma once +#ifndef UTIL_VECTOR_H +#define UTIL_VECTOR_H // Misc C-runtime library headers #include "stdio.h" @@ -23,7 +26,7 @@ // Header file containing definition of globalvars_t and entvars_t typedef unsigned int func_t; // -typedef unsigned int string_t; // from engine's pr_comp.h; +typedef int string_t; // from engine's pr_comp.h; typedef float vec_t; // needed before including progdefs.h //========================================================= @@ -124,3 +127,4 @@ inline float DotProduct( const Vector& a, const Vector& b) { return( a.x * b.x + inline Vector CrossProduct(const Vector& a, const Vector& b) { return Vector( a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x ); } #define vec3_t Vector +#endif // UTIL_VECTOR_H diff --git a/cl_dll/view.cpp b/cl_dll/view.cpp index f5c9475d..a577a671 100644 --- a/cl_dll/view.cpp +++ b/cl_dll/view.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // @@ -26,6 +26,7 @@ #include "shake.h" #include "hltv.h" +extern bool bDrawScope; // Spectator Mode extern "C" { @@ -78,6 +79,7 @@ extern cvar_t *cl_forwardspeed; extern cvar_t *chase_active; extern cvar_t *scr_ofsx, *scr_ofsy, *scr_ofsz; extern cvar_t *cl_vsmoothing; +extern cvar_t *cl_viewbob; extern Vector dead_viewangles; #define CAM_MODE_RELAX 1 @@ -90,7 +92,7 @@ float v_cameraFocusAngle = 35.0f; int v_cameraMode = CAM_MODE_FOCUS; qboolean v_resetCamera = 1; -vec3_t ev_punchangle; +vec3_t g_ev_punchangle; cvar_t *scr_ofsx; cvar_t *scr_ofsy; @@ -351,11 +353,11 @@ V_CalcIntermissionRefdef */ void V_CalcIntermissionRefdef( struct ref_params_s *pparams ) { - cl_entity_t *ent, *view; + cl_entity_t /**ent,*/ *view; float old; // ent is the player model ( visible when out of body ) - ent = gEngfuncs.GetLocalPlayer(); + //ent = gEngfuncs.GetLocalPlayer(); // view is the weapon model (only visible from inside body ) view = gEngfuncs.GetViewModel(); @@ -527,7 +529,7 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams ) V_AddIdle( pparams ); // offsets - if ( pparams->health <= 0 ) + if( pparams->health <= 0 ) { VectorCopy( dead_viewangles, angles ); } @@ -598,6 +600,9 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams ) view->angles[ROLL] -= bob * 1; view->angles[PITCH] -= bob * 0.3; + if( cl_viewbob && cl_viewbob->value ) + VectorCopy( view->angles, view->curstate.angles ); + // 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). @@ -626,9 +631,9 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams ) VectorAdd( pparams->viewangles, pparams->punchangle, pparams->viewangles ); // Include client side punch, too - VectorAdd( pparams->viewangles, (float *)&ev_punchangle, pparams->viewangles ); + VectorAdd( pparams->viewangles, (float *)&g_ev_punchangle, pparams->viewangles ); - V_DropPunchAngle( pparams->frametime, (float *)&ev_punchangle ); + V_DropPunchAngle( pparams->frametime, (float *)&g_ev_punchangle ); // smooth out stair step ups #if 1 @@ -758,6 +763,7 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams ) // Store off overridden viewangles v_angles = pparams->viewangles; + bDrawScope = 0; } } @@ -1307,7 +1313,7 @@ void V_GetMapChasePosition( int target, float *cl_angles, float *origin, float * int V_FindViewModelByWeaponModel( int weaponindex ) { - static char *modelmap[][2] = + static const char *modelmap[][2] = { { "models/p_bradnailer.mdl", "models/v_bradnailer.mdl" }, { "models/p_cmlwbr.mdl", "models/v_cmlwbr.mdl" }, @@ -1321,7 +1327,7 @@ int V_FindViewModelByWeaponModel( int weaponindex ) { NULL, NULL } }; - struct model_s * weaponModel = IEngineStudio.GetModelByIndex( weaponindex ); + struct model_s *weaponModel = IEngineStudio.GetModelByIndex( weaponindex ); if( weaponModel ) { @@ -1569,7 +1575,7 @@ Client side punch effect */ void V_PunchAxis( int axis, float punch ) { - ev_punchangle[axis] = punch; + g_ev_punchangle[axis] = punch; } /* diff --git a/cl_dll/view.h b/cl_dll/view.h index c0aa0e8f..6ca818d5 100644 --- a/cl_dll/view.h +++ b/cl_dll/view.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cmake/VSForceXPToolchain.cmake b/cmake/VSForceXPToolchain.cmake new file mode 100644 index 00000000..e78fb0a2 --- /dev/null +++ b/cmake/VSForceXPToolchain.cmake @@ -0,0 +1,29 @@ +if(WIN32) + # Windows XP compatible platform toolset. Must be set before project(), + # otherwise change of CMAKE_*_TOOLSET will take no effect. + # We get VS version from the generator name because neither MSVC* nor other + # variables that describe the compiler aren't available before project(). + if ("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([0-9]+)") + if(${CMAKE_MATCH_1} LESS 11) + # Nothing. Older VS does support XP by default. + elseif(${CMAKE_MATCH_1} EQUAL 11) + # Visual Studio 11 2012 + set(CMAKE_GENERATOR_TOOLSET "v110_xp" CACHE STRING "CMAKE_GENERATOR_TOOLSET" FORCE) + set(CMAK_VS_PLATFORM_TOOLSET "v110_xp" CACHE STRING "CMAKE_VS_PLATFORM_TOOLSET" FORCE) + elseif (${CMAKE_MATCH_1} EQUAL 12) + # Visual Studio 12 2013 + set(CMAKE_GENERATOR_TOOLSET "v120_xp" CACHE STRING "CMAKE_GENERATOR_TOOLSET" FORCE) + set(CMAKE_VS_PLATFORM_TOOLSET "v120_xp" CACHE STRING "CMAKE_VS_PLATFORM_TOOLSET" FORCE) + elseif (${CMAKE_MATCH_1} EQUAL 14) + # Visual Studio 14 2015 + set(CMAKE_GENERATOR_TOOLSET "v140_xp" CACHE STRING "CMAKE_GENERATOR_TOOLSET" FORCE) + set(CMAKE_VS_PLATFORM_TOOLSET "v140_xp" CACHE STRING "CMAKE_VS_PLATFORM_TOOLSET" FORCE) + elseif (${CMAKE_MATCH_1} EQUAL 15) + # Visual Studio 15 2017 + set(CMAKE_GENERATOR_TOOLSET "v141_xp" CACHE STRING "CMAKE_GENERATOR_TOOLSET" FORCE) + set(CMAKE_VS_PLATFORM_TOOLSET "v141_xp" CACHE STRING "CMAKE_VS_PLATFORM_TOOLSET" FORCE) + else() + message(WARNING "WARNING: You maybe building without Windows XP compability. See which toolchain version Visual Studio provides, and say cmake to use it: cmake -G \"Visual Studio XX\" -T \"vXXX_xp\"") + endif() + endif() +endif() diff --git a/common/beamdef.h b/common/beamdef.h index 3b8c553a..f254428c 100644 --- a/common/beamdef.h +++ b/common/beamdef.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef BEAMDEF_H #define BEAMDEF_H @@ -57,4 +57,4 @@ struct beam_s struct particle_s *particles; }; -#endif//BEAMDEF_H \ No newline at end of file +#endif//BEAMDEF_H diff --git a/common/bspfile.h b/common/bspfile.h index 809e2fd0..079e1b21 100644 --- a/common/bspfile.h +++ b/common/bspfile.h @@ -12,7 +12,7 @@ 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 diff --git a/common/cl_entity.h b/common/cl_entity.h index 02f84e35..c003ce30 100644 --- a/common/cl_entity.h +++ b/common/cl_entity.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef CL_ENTITY_H #define CL_ENTITY_H @@ -102,4 +102,4 @@ struct cl_entity_s colorVec cvFloorColor; }; -#endif//CL_ENTITY_H \ No newline at end of file +#endif//CL_ENTITY_H diff --git a/common/com_model.h b/common/com_model.h index 709f23d9..abc8e8e6 100644 --- a/common/com_model.h +++ b/common/com_model.h @@ -12,7 +12,7 @@ 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 COM_MODEL_H #define COM_MODEL_H @@ -410,4 +410,4 @@ typedef struct mspriteframedesc_t frames[1]; } msprite_t; -#endif//COM_MODEL_H \ No newline at end of file +#endif//COM_MODEL_H diff --git a/common/con_nprint.h b/common/con_nprint.h index 5d87c760..615a1850 100644 --- a/common/con_nprint.h +++ b/common/con_nprint.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef CON_NPRINT_H #define CON_NPRINT_H @@ -22,4 +23,4 @@ typedef struct con_nprint_s float color[3]; // RGB colors ( 0.0 -> 1.0 scale ) } con_nprint_t; -#endif//CON_NPRINT_H \ No newline at end of file +#endif//CON_NPRINT_H diff --git a/common/const.h b/common/const.h index b885e44e..fa0f33e6 100644 --- a/common/const.h +++ b/common/const.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef CONST_H #define CONST_H // @@ -110,7 +111,9 @@ #define EF_NOINTERP 32 // don't interpolate the next frame #define EF_LIGHT 64 // rocket flare glow sprite #define EF_NODRAW 128 // don't draw entity - +#define EF_NIGHTVISION 256 // player nightvision +#define EF_SNIPERLASER 512 // sniper laser effect +#define EF_FIBERCAMERA 1024 // fiber camera #define EF_NOREFLECT (1<<24) // Entity won't reflecting in mirrors @@ -531,6 +534,7 @@ #define TEFIRE_FLAG_LOOP 4 // if set, sprite plays at 15 fps, otherwise plays at whatever rate stretches the animation over the sprite's duration. #define TEFIRE_FLAG_ALPHA 8 // if set, sprite is rendered alpha blended at 50% else, opaque #define TEFIRE_FLAG_PLANAR 16 // if set, all fire sprites have same initial Z instead of randomly filling a cube. +#define TEFIRE_FLAG_ADDITIVE 32 // if set, sprite is rendered non-opaque with additive #define TE_PLAYERATTACHMENT 124 // attaches a TENT to a player (this is a high-priority tent) // byte (entity index of player) @@ -621,8 +625,9 @@ #define CHAN_BODY 4 #define CHAN_STREAM 5 // allocate stream channel from the static or dynamic area #define CHAN_STATIC 6 // allocate channel from the static area -#define CHAN_NETWORKVOICE_BASE 7 // voice data coming across the network +#define CHAN_NETWORKVOICE_BASE 7 // voice data coming across the network #define CHAN_NETWORKVOICE_END 500 // network voice data reserves slots (CHAN_NETWORKVOICE_BASE through CHAN_NETWORKVOICE_END). +#define CHAN_BOT 501 // channel used for bot chatter. // attenuation values #define ATTN_NONE 0 @@ -724,11 +729,12 @@ enum kRenderFxDeadPlayer, // kRenderAmt is the player index kRenderFxExplode, // Scale up really big! kRenderFxGlowShell, // Glowing Shell - kRenderFxClampMinScale // Keep this sprite from getting very small (SPRITES only!) + kRenderFxClampMinScale, // Keep this sprite from getting very small (SPRITES only!) + kRenderFxLightMultiplier //CTM !!!CZERO added to tell the studiorender that the value in iuser2 is a lightmultiplier }; typedef unsigned int func_t; -typedef unsigned int string_t; +typedef int string_t; typedef unsigned char byte; typedef unsigned short word; diff --git a/common/cvardef.h b/common/cvardef.h index f822cc7a..f461c329 100644 --- a/common/cvardef.h +++ b/common/cvardef.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef CVARDEF_H #define CVARDEF_H @@ -24,14 +25,15 @@ #define FCVAR_SPONLY (1<<6) // This cvar cannot be changed by clients connected to a multiplayer server. #define FCVAR_PRINTABLEONLY (1<<7) // This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ). #define FCVAR_UNLOGGED (1<<8) // If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log +#define FCVAR_NOEXTRAWHITEPACE (1<<9) // strip trailing/leading white space from this cvar typedef struct cvar_s { - char *name; - char *string; + const char *name; + const char *string; int flags; float value; struct cvar_s *next; } cvar_t; -#endif//CVARDEF_H \ No newline at end of file +#endif//CVARDEF_H diff --git a/common/demo_api.h b/common/demo_api.h index fa89bbef..1a678b60 100644 --- a/common/demo_api.h +++ b/common/demo_api.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef DEMO_API_H #define DEMO_API_H @@ -24,4 +24,4 @@ typedef struct demo_api_s void (*WriteBuffer)( int size, unsigned char *buffer ); } demo_api_t; -#endif//DEMO_API_H \ No newline at end of file +#endif//DEMO_API_H diff --git a/common/dlight.h b/common/dlight.h index b139d582..ecb01445 100644 --- a/common/dlight.h +++ b/common/dlight.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef DLIGHT_H #define DLIGHT_H @@ -28,4 +28,4 @@ typedef struct dlight_s qboolean dark; // subtracts light instead of adding } dlight_t; -#endif//DLIGHT_H \ No newline at end of file +#endif//DLIGHT_H diff --git a/common/entity_state.h b/common/entity_state.h index ef5448f1..2ffd70dc 100644 --- a/common/entity_state.h +++ b/common/entity_state.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef ENTITY_STATE_H #define ENTITY_STATE_H @@ -183,4 +184,4 @@ typedef struct local_state_s weapon_data_t weapondata[64]; } local_state_t; -#endif//ENTITY_STATE_H \ No newline at end of file +#endif//ENTITY_STATE_H diff --git a/common/entity_types.h b/common/entity_types.h index 25a8fce9..f5754fea 100644 --- a/common/entity_types.h +++ b/common/entity_types.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef ENTITY_TYPES_H #define ENTITY_TYPES_H @@ -22,4 +22,4 @@ #define ET_BEAM 3 #define ET_FRAGMENTED 4 // BMODEL or SPRITE that was split across BSP nodes -#endif//ENTITY_TYPES_H \ No newline at end of file +#endif//ENTITY_TYPES_H diff --git a/common/event_api.h b/common/event_api.h index a7ff71b2..86c5fbe9 100644 --- a/common/event_api.h +++ b/common/event_api.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef EVENT_API_H #define EVENT_API_H @@ -51,4 +51,4 @@ typedef struct event_api_s struct msurface_s *( *EV_TraceSurface )( int ground, float *vstart, float *vend ); } event_api_t; -#endif//EVENT_API_H \ No newline at end of file +#endif//EVENT_API_H diff --git a/common/event_args.h b/common/event_args.h index d85906cc..4cf63741 100644 --- a/common/event_args.h +++ b/common/event_args.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef EVENT_ARGS_H #define EVENT_ARGS_H @@ -44,4 +45,4 @@ typedef struct event_args_s int bparam2; } event_args_t; -#endif//EVENT_ARGS_H \ No newline at end of file +#endif//EVENT_ARGS_H diff --git a/common/event_flags.h b/common/event_flags.h index 3c1d8fb3..a2d5f3b7 100644 --- a/common/event_flags.h +++ b/common/event_flags.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef EVENT_FLAGS_H #define EVENT_FLAGS_H @@ -42,4 +42,4 @@ // Only issue event client side ( from shared code ) #define FEV_CLIENT (1<<6) -#endif//EVENT_FLAGS_H \ No newline at end of file +#endif//EVENT_FLAGS_H diff --git a/common/gameinfo.h b/common/gameinfo.h index 511b3718..ab5f649c 100644 --- a/common/gameinfo.h +++ b/common/gameinfo.h @@ -12,7 +12,7 @@ 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 @@ -46,4 +46,4 @@ typedef struct int gamemode; } GAMEINFO; -#endif//GAMEINFO_H \ No newline at end of file +#endif//GAMEINFO_H diff --git a/common/hltv.h b/common/hltv.h index 79251910..e64dd30b 100644 --- a/common/hltv.h +++ b/common/hltv.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef HLTV_H #define HLTV_H @@ -56,4 +56,4 @@ #define MAX_DIRECTOR_CMD_PARAMETERS 4 #define MAX_DIRECTOR_CMD_STRING 128 -#endif//HLTV_H \ No newline at end of file +#endif//HLTV_H diff --git a/common/ivoicetweak.h b/common/ivoicetweak.h index 541a63fa..96879beb 100644 --- a/common/ivoicetweak.h +++ b/common/ivoicetweak.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef IVOICETWEAK_H #define IVOICETWEAK_H @@ -37,4 +37,4 @@ typedef struct IVoiceTweak_s int (*GetSpeakingVolume)( void ); } IVoiceTweak; -#endif//IVOICETWEAK_H \ No newline at end of file +#endif//IVOICETWEAK_H diff --git a/common/lightstyle.h b/common/lightstyle.h index 8b42edac..a12702f4 100644 --- a/common/lightstyle.h +++ b/common/lightstyle.h @@ -12,7 +12,7 @@ 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 @@ -26,4 +26,4 @@ typedef struct 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 \ No newline at end of file +#endif//LIGHTSTYLE_H diff --git a/common/mathlib.h b/common/mathlib.h index fadb97fb..6bcf76eb 100644 --- a/common/mathlib.h +++ b/common/mathlib.h @@ -13,12 +13,19 @@ * ****/ // mathlib.h - +#pragma once +#ifndef MATHLIB_H +#define MATHLIB_H #include typedef float vec_t; typedef vec_t vec2_t[2]; + +#ifndef 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 @@ -93,3 +100,4 @@ float anglemod(float a); ) \ : \ BoxOnPlaneSide( (emins), (emaxs), (p))) +#endif // MATHLIB_H diff --git a/common/net_api.h b/common/net_api.h index 00831394..da18fc30 100644 --- a/common/net_api.h +++ b/common/net_api.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef NET_API_H #define NET_API_H @@ -94,4 +94,4 @@ typedef struct net_api_s void (*SetValueForKey)( char *s, const char *key, const char *value, int maxsize ); } net_api_t; -#endif//NET_APIH \ No newline at end of file +#endif // NET_APIH diff --git a/common/netadr.h b/common/netadr.h index dfeea8b0..0d70a22b 100644 --- a/common/netadr.h +++ b/common/netadr.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef NETADR_H #define NETADR_H @@ -34,4 +34,4 @@ typedef struct netadr_s unsigned short port; } netadr_t; -#endif//NETADR_H \ No newline at end of file +#endif//NETADR_H diff --git a/common/particledef.h b/common/particledef.h index 3f2ead66..15c95feb 100644 --- a/common/particledef.h +++ b/common/particledef.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef PARTICLEDEF_H #define PARTICLEDEF_H @@ -51,4 +51,4 @@ typedef struct particle_s unsigned char context; } particle_t; -#endif//PARTICLEDEF_H \ No newline at end of file +#endif//PARTICLEDEF_H diff --git a/common/pmtrace.h b/common/pmtrace.h index 6394de56..d5dd1453 100644 --- a/common/pmtrace.h +++ b/common/pmtrace.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef PM_TRACE_H #define PM_TRACE_H @@ -38,4 +38,4 @@ struct pmtrace_s int hitgroup; }; -#endif//PM_TRACE_H \ No newline at end of file +#endif//PM_TRACE_H diff --git a/common/qfont.h b/common/qfont.h index 06408572..beb36ff9 100644 --- a/common/qfont.h +++ b/common/qfont.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef QFONT_H #define QFONT_H @@ -35,4 +35,4 @@ typedef struct qfont_s byte data[4]; } qfont_t; -#endif//QFONT_H \ No newline at end of file +#endif//QFONT_H diff --git a/common/r_efx.h b/common/r_efx.h index fc27bef7..1a55aa0b 100644 --- a/common/r_efx.h +++ b/common/r_efx.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef R_EFX_H #define R_EFX_H @@ -192,4 +192,4 @@ struct efx_api_s void (*R_FireCustomDecal)( int textureIndex, int entity, int modelIndex, float *position, int flags, float scale ); }; -#endif//R_EFX_H \ No newline at end of file +#endif//R_EFX_H diff --git a/common/r_studioint.h b/common/r_studioint.h index 00384a16..b17e826f 100644 --- a/common/r_studioint.h +++ b/common/r_studioint.h @@ -12,8 +12,7 @@ * without written permission from Valve LLC. * ****/ - - +#pragma once #ifndef R_STUDIOINT_H #define R_STUDIOINT_H @@ -151,4 +150,4 @@ typedef struct sv_blending_interface_s const edict_t *pEdict ); } sv_blending_interface_t; -#endif//R_STUDIOINT_H \ No newline at end of file +#endif//R_STUDIOINT_H diff --git a/common/ref_params.h b/common/ref_params.h index 0458c4f4..61527eca 100644 --- a/common/ref_params.h +++ b/common/ref_params.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef REF_PARAMS_H #define REF_PARAMS_H @@ -87,4 +87,4 @@ typedef struct ref_overview_s float flZoom; } ref_overview_t; -#endif//REF_PARAMS_H \ No newline at end of file +#endif//REF_PARAMS_H diff --git a/common/render_api.h b/common/render_api.h index 7a9fcffe..03973f27 100644 --- a/common/render_api.h +++ b/common/render_api.h @@ -12,7 +12,7 @@ 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 @@ -258,4 +258,4 @@ typedef struct render_interface_s void (*Mod_ProcessUserData)( struct model_s *mod, qboolean create, const byte *buffer ); } render_interface_t; -#endif//RENDER_API_H \ No newline at end of file +#endif//RENDER_API_H diff --git a/common/screenfade.h b/common/screenfade.h index 730f729e..1611f914 100644 --- a/common/screenfade.h +++ b/common/screenfade.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef SCREENFADE_H #define SCREENFADE_H @@ -26,4 +26,4 @@ typedef struct screenfade_s int fadeFlags; // Fading flags } screenfade_t; -#endif//SCREENFADE_H \ No newline at end of file +#endif//SCREENFADE_H diff --git a/common/studio_event.h b/common/studio_event.h index 29ea1f90..cf21e82a 100644 --- a/common/studio_event.h +++ b/common/studio_event.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef STUDIO_EVENT_H #define STUDIO_EVENT_H @@ -24,4 +24,4 @@ typedef struct mstudioevent_s char options[64]; } mstudioevent_t; -#endif//STUDIO_EVENT_H \ No newline at end of file +#endif//STUDIO_EVENT_H diff --git a/common/triangleapi.h b/common/triangleapi.h index f2e9a309..49dc919f 100644 --- a/common/triangleapi.h +++ b/common/triangleapi.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef TRIANGLEAPI_H #define TRIANGLEAPI_H diff --git a/common/usercmd.h b/common/usercmd.h index 96e3c91b..538c60a6 100644 --- a/common/usercmd.h +++ b/common/usercmd.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef USERCMD_H #define USERCMD_H @@ -36,4 +36,4 @@ typedef struct usercmd_s vec3_t impact_position; } usercmd_t; -#endif//USERCMD_H \ No newline at end of file +#endif//USERCMD_H diff --git a/common/wadfile.h b/common/wadfile.h index 38a08032..84ffbb2d 100644 --- a/common/wadfile.h +++ b/common/wadfile.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef WADFILE_H #define WADFILE_H @@ -76,4 +76,4 @@ typedef struct mip_s unsigned int offsets[4]; // four mip maps stored } mip_t; -#endif//WADFILE_H \ No newline at end of file +#endif//WADFILE_H diff --git a/common/weaponinfo.h b/common/weaponinfo.h index ae78c645..b94857b6 100644 --- a/common/weaponinfo.h +++ b/common/weaponinfo.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef WEAPONINFO_H #define WEAPONINFO_H @@ -47,4 +47,4 @@ typedef struct weapon_data_s float fuser4; } weapon_data_t; -#endif//WEAPONINFO_H \ No newline at end of file +#endif//WEAPONINFO_H diff --git a/common/wrect.h b/common/wrect.h index 8dd2ba2f..51e84d88 100644 --- a/common/wrect.h +++ b/common/wrect.h @@ -12,7 +12,7 @@ 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 @@ -21,4 +21,4 @@ typedef struct wrect_s int left, right, top, bottom; } wrect_t; -#endif//WRECT_H \ No newline at end of file +#endif//WRECT_H diff --git a/debug.bat b/debug.bat deleted file mode 100644 index eb702325..00000000 --- a/debug.bat +++ /dev/null @@ -1,42 +0,0 @@ -@echo off - -set MSDEV=BuildConsole -set CONFIG=/ShowTime /ShowAgent /nologo /cfg= -set MSDEV=msdev -set CONFIG=/make -set build_type=debug -set BUILD_ERROR= -call vcvars32 - -%MSDEV% engine/engine.dsp %CONFIG%"engine - Win32 Debug" %build_target% -if errorlevel 1 set BUILD_ERROR=1 - -%MSDEV% mainui/mainui.dsp %CONFIG%"mainui - Win32 Debug" %build_target% -if errorlevel 1 set BUILD_ERROR=1 - -if "%BUILD_ERROR%"=="" goto build_ok - -echo ********************* -echo ********************* -echo *** Build Errors! *** -echo ********************* -echo ********************* -echo press any key to exit -echo ********************* -pause>nul -goto done - - -@rem -@rem Successful build -@rem -:build_ok - -rem //delete log files -if exist engine\engine.plg del /f /q engine\engine.plg -if exist mainui\mainui.plg del /f /q mainui\mainui.plg - -echo -echo Build succeeded! -echo -:done \ No newline at end of file diff --git a/dlls/Android.mk b/dlls/Android.mk index 60e5f86e..4fd5de6e 100644 --- a/dlls/Android.mk +++ b/dlls/Android.mk @@ -14,9 +14,9 @@ LOCAL_MODULE_FILENAME = libserver_hardfp endif LOCAL_CFLAGS += -D_LINUX -DCLIENT_WEAPONS -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf \ - -fno-exceptions -DNO_VOICEGAMEMGR -w + -fno-exceptions -DNO_VOICEGAMEMGR -DCROWBAR_IDLE_ANIM -w -LOCAL_CPPFLAGS := $(LOCAL_CFLAGS) -frtti +LOCAL_CPPFLAGS := $(LOCAL_CFLAGS) LOCAL_C_INCLUDES := $(SDL_PATH)/include \ $(LOCAL_PATH)/. \ @@ -56,9 +56,11 @@ LOCAL_SRC_FILES := agrunt.cpp airtank.cpp \ func_tank.cpp \ game.cpp \ gamerules.cpp \ + gauss.cpp \ gargantua.cpp \ genericmonster.cpp \ ggrenade.cpp \ + glock.cpp \ globals.cpp \ gman.cpp \ h_ai.cpp \ @@ -85,11 +87,13 @@ LOCAL_SRC_FILES := agrunt.cpp airtank.cpp \ multiplay_gamerules.cpp \ nihilanth.cpp \ nodes.cpp \ + observer.cpp \ osprey.cpp \ pathcorner.cpp \ plane.cpp \ plats.cpp \ player.cpp \ + playermonster.cpp \ rat.cpp \ roach.cpp \ rpg.cpp \ @@ -121,18 +125,12 @@ LOCAL_SRC_FILES := agrunt.cpp airtank.cpp \ ../pm_shared/pm_debug.c \ ../pm_shared/pm_math.c \ ../pm_shared/pm_shared.c \ - poke646/bradnailer.cpp \ - poke646/cmlwbr.cpp \ poke646/firetrail.cpp \ poke646/genericmodel.cpp \ - poke646/heaterpipe.cpp \ + poke646/mp3.cpp \ poke646/nail.cpp \ - poke646/nailgun.cpp \ - poke646/pipebomb.cpp \ poke646/robocop.cpp \ - poke646/weapon_pipebomb.cpp \ - poke646/xenspit.cpp \ - poke646/xensquasher.cpp \ + poke646/xsbeam.cpp \ vendetta/par21.cpp # ../game_shared/voice_gamemgr.cpp diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index 7f30b853..78848449 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -25,10 +25,19 @@ project (SVDLL) set (SVDLL_LIBRARY server) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LINUX -DCLIENT_WEAPONS -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf -fno-exceptions -w") -set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") +add_definitions(-DCROWBAR_IDLE_ANIM) -set (SVDLL_SOURCES +if(NOT MSVC) + add_compile_options(-fno-exceptions) # GCC/Clang flag + add_compile_options(-Wno-invalid-offsetof) # GCC/Clang flag + add_compile_options(-fvisibility=hidden) # GCC/Clang flag + add_definitions(-D_LINUX) # It seems enough for all non-Win32 systems + add_definitions(-Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf ) +else() + add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE) +endif() + +set (SVDLL_SOURCES agrunt.cpp airtank.cpp aflock.cpp @@ -59,11 +68,11 @@ set (SVDLL_SOURCES game.cpp gamerules.cpp gargantua.cpp -# gauss.cpp + gauss.cpp genericmonster.cpp ggrenade.cpp globals.cpp -# glock.cpp + glock.cpp gman.cpp h_ai.cpp h_battery.cpp @@ -88,16 +97,18 @@ set (SVDLL_SOURCES monsters.cpp monsterstate.cpp mortar.cpp -# mp5.cpp + mp5.cpp multiplay_gamerules.cpp nihilanth.cpp nodes.cpp + observer.cpp osprey.cpp pathcorner.cpp plane.cpp plats.cpp player.cpp # python.cpp + playermonster.cpp rat.cpp roach.cpp rpg.cpp @@ -129,21 +140,15 @@ set (SVDLL_SOURCES ../pm_shared/pm_debug.c ../pm_shared/pm_math.c ../pm_shared/pm_shared.c - poke646/bradnailer.cpp - poke646/cmlwbr.cpp poke646/firetrail.cpp poke646/genericmodel.cpp - poke646/heaterpipe.cpp + poke646/mp3.cpp poke646/nail.cpp - poke646/nailgun.cpp - poke646/pipebomb.cpp poke646/robocop.cpp - poke646/weapon_pipebomb.cpp - poke646/xenspit.cpp - poke646/xensquasher.cpp + poke646/xsbeam.cpp vendetta/par21.cpp ) - + include_directories (. wpn_shared poke646 ../common ../engine ../pm_shared ../game_shared ../public) if(USE_VOICEMGR) @@ -156,6 +161,22 @@ endif() add_library (${SVDLL_LIBRARY} SHARED ${SVDLL_SOURCES}) -set_target_properties (${SVDLL_SHARED} PROPERTIES +set_target_properties (${SVDLL_LIBRARY} PROPERTIES POSITION_INDEPENDENT_CODE 1) +if(APPLE OR WIN32 OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + 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() + +install( TARGETS ${SVDLL_LIBRARY} + DESTINATION "${GAMEDIR}/${SERVER_INSTALL_DIR}/" + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE) diff --git a/dlls/Makefile b/dlls/Makefile index c75731d5..3599b9c7 100644 --- a/dlls/Makefile +++ b/dlls/Makefile @@ -129,11 +129,13 @@ OBJ = \ $(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 \ diff --git a/dlls/activity.h b/dlls/activity.h index 58b2d8cd..90d85a08 100644 --- a/dlls/activity.h +++ b/dlls/activity.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef ACTIVITY_H #define ACTIVITY_H @@ -99,7 +99,7 @@ typedef enum { typedef struct { int type; - char *name; + const char *name; } activity_map_t; extern activity_map_t activity_map[]; diff --git a/dlls/activitymap.h b/dlls/activitymap.h index 92cadae7..b5f789f9 100644 --- a/dlls/activitymap.h +++ b/dlls/activitymap.h @@ -12,7 +12,9 @@ * without written permission from Valve LLC. * ****/ - +#pragma once +#ifndef ACTIVITYMAP_H +#define ACTIVITYMAP_H #define _A( a ) { a, #a } activity_map_t activity_map[] = @@ -93,5 +95,6 @@ _A( ACT_FLINCH_LEFTARM ), _A( ACT_FLINCH_RIGHTARM ), _A( ACT_FLINCH_LEFTLEG ), _A( ACT_FLINCH_RIGHTLEG ), -0, NULL +{ 0, NULL } }; +#endif // ACTIVITYMAP_H diff --git a/dlls/aflock.cpp b/dlls/aflock.cpp index 1e317632..d50a8165 100644 --- a/dlls/aflock.cpp +++ b/dlls/aflock.cpp @@ -567,7 +567,6 @@ void CFlockingFlyer::FlockLeaderThink( void ) TraceResult tr; Vector vecDist;// used for general measurements Vector vecDir;// used for general measurements - int cProcessed = 0;// keep track of how many other boids we've processed float flLeftSide; float flRightSide; @@ -840,11 +839,11 @@ void CFlockingFlyer::SquadRemove( CFlockingFlyer *pRemove ) { CFlockingFlyer *pLeader = m_pSquadNext; - // copy the enemy LKP to the new leader - pLeader->m_vecEnemyLKP = m_vecEnemyLKP; - if( pLeader ) { + // copy the enemy LKP to the new leader + pLeader->m_vecEnemyLKP = m_vecEnemyLKP; + CFlockingFlyer *pList = pLeader; while( pList ) diff --git a/dlls/agrunt.cpp b/dlls/agrunt.cpp index 97804f68..cb47ac65 100644 --- a/dlls/agrunt.cpp +++ b/dlls/agrunt.cpp @@ -608,30 +608,30 @@ void CAGrunt::Spawn() //========================================================= void CAGrunt::Precache() { - int i; + size_t i; PRECACHE_MODEL( "models/agrunt.mdl" ); for( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackHitSounds[i] ); + PRECACHE_SOUND( pAttackHitSounds[i] ); for( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackMissSounds[i] ); + PRECACHE_SOUND( pAttackMissSounds[i] ); for( i = 0; i < ARRAYSIZE( pIdleSounds ); i++ ) - PRECACHE_SOUND( (char *)pIdleSounds[i] ); + PRECACHE_SOUND( pIdleSounds[i] ); for( i = 0; i < ARRAYSIZE( pDieSounds ); i++ ) - PRECACHE_SOUND( (char *)pDieSounds[i] ); + PRECACHE_SOUND( pDieSounds[i] ); for( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) - PRECACHE_SOUND( (char *)pPainSounds[i] ); + PRECACHE_SOUND( pPainSounds[i] ); for( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackSounds[i] ); + PRECACHE_SOUND( pAttackSounds[i] ); for( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) - PRECACHE_SOUND( (char *)pAlertSounds[i] ); + PRECACHE_SOUND( pAlertSounds[i] ); PRECACHE_SOUND( "hassault/hw_shoot1.wav" ); @@ -909,7 +909,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 != NULL ) + if( HasConditions( bits_COND_SEE_ENEMY ) && flDist <= AGRUNT_MELEE_DIST && flDot >= 0.6 && m_hEnemy != 0 ) { return TRUE; } @@ -1160,7 +1160,7 @@ Schedule_t *CAGrunt::GetScheduleOfType( int Type ) case SCHED_FAIL: // no fail schedule specified, so pick a good generic one. { - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { // I have an enemy // !!!LATER - what if this enemy is really far away and i'm chasing him? diff --git a/dlls/animation.cpp b/dlls/animation.cpp index 86cb78ae..f84ec380 100644 --- a/dlls/animation.cpp +++ b/dlls/animation.cpp @@ -208,7 +208,7 @@ void SequencePrecache( void *pmodel, const char *pSequenceName ) ALERT( at_error, "Bad sound event %d in sequence %s :: %s (sound is \"%s\")\n", pevent[i].event, pstudiohdr->name, pSequenceName, pevent[i].options ); } - PRECACHE_SOUND( (char *)( gpGlobals->pStringBase + ALLOC_STRING( pevent[i].options ) ) ); + PRECACHE_SOUND( gpGlobals->pStringBase + ALLOC_STRING( pevent[i].options ) ); } } } @@ -268,8 +268,6 @@ int GetAnimationEvent( void *pmodel, entvars_t *pev, MonsterEvent_t *pMonsterEve if( !pstudiohdr || pev->sequence >= pstudiohdr->numseq || !pMonsterEvent ) return 0; - int events = 0; - mstudioseqdesc_t *pseqdesc; mstudioevent_t *pevent; @@ -351,7 +349,7 @@ float SetController( void *pmodel, entvars_t *pev, int iController, float flValu } } - int setting = 255 * ( flValue - pbonecontroller->start ) / ( pbonecontroller->end - pbonecontroller->start ); + int setting = (int)( 255 * ( flValue - pbonecontroller->start ) / ( pbonecontroller->end - pbonecontroller->start ) ); if( setting < 0 ) setting = 0; @@ -393,7 +391,7 @@ float SetBlending( void *pmodel, entvars_t *pev, int iBlender, float flValue ) } } - int setting = 255 * ( flValue - pseqdesc->blendstart[iBlender] ) / ( pseqdesc->blendend[iBlender] - pseqdesc->blendstart[iBlender] ); + int setting = (int)( 255 * ( flValue - pseqdesc->blendstart[iBlender] ) / ( pseqdesc->blendend[iBlender] - pseqdesc->blendstart[iBlender] ) ); if( setting < 0 ) setting = 0; diff --git a/dlls/animation.h b/dlls/animation.h index 384c1e98..6def910c 100644 --- a/dlls/animation.h +++ b/dlls/animation.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef ANIMATION_H #define ANIMATION_H diff --git a/dlls/apache.cpp b/dlls/apache.cpp index b64a8bae..b3cfcf87 100644 --- a/dlls/apache.cpp +++ b/dlls/apache.cpp @@ -458,7 +458,7 @@ void CApache::HuntThink( void ) if( m_flGoalSpeed < 800 ) m_flGoalSpeed += 5; - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { // ALERT( at_console, "%s\n", STRING( m_hEnemy->pev->classname ) ); if( FVisible( m_hEnemy ) ) @@ -552,7 +552,7 @@ void CApache::HuntThink( void ) { if( m_flLastSeen + 60 > gpGlobals->time ) { - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { // make sure it's a good shot if( DotProduct( m_vecTarget, vecEst ) > .965 ) @@ -732,7 +732,6 @@ void CApache::Flight( void ) void CApache::FireRocket( void ) { static float side = 1.0; - static int count; if( m_iRockets <= 0 ) return; @@ -805,13 +804,13 @@ BOOL CApache::FireGun() angles.x = angles.x + 360; if( angles.x > m_angGun.x ) - m_angGun.x = min( angles.x, m_angGun.x + 12 ); + m_angGun.x = Q_min( angles.x, m_angGun.x + 12 ); if( angles.x < m_angGun.x ) - m_angGun.x = max( angles.x, m_angGun.x - 12 ); + m_angGun.x = Q_max( angles.x, m_angGun.x - 12 ); if( angles.y > m_angGun.y ) - m_angGun.y = min( angles.y, m_angGun.y + 12 ); + m_angGun.y = Q_min( angles.y, m_angGun.y + 12 ); if( angles.y < m_angGun.y ) - m_angGun.y = max( angles.y, m_angGun.y - 12 ); + m_angGun.y = Q_max( angles.y, m_angGun.y - 12 ); m_angGun.y = SetBoneController( 0, m_angGun.y ); m_angGun.x = SetBoneController( 1, m_angGun.x ); diff --git a/dlls/barnacle.cpp b/dlls/barnacle.cpp index c6e8c7dc..3e10baf4 100644 --- a/dlls/barnacle.cpp +++ b/dlls/barnacle.cpp @@ -170,7 +170,7 @@ void CBarnacle::BarnacleThink( void ) #endif pev->nextthink = gpGlobals->time + 0.1; - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { // barnacle has prey. if( !m_hEnemy->IsAlive() ) @@ -183,7 +183,7 @@ void CBarnacle::BarnacleThink( void ) if( m_fLiftingPrey ) { - if( m_hEnemy != NULL && m_hEnemy->pev->deadflag != DEAD_NO ) + if( m_hEnemy != 0 && m_hEnemy->pev->deadflag != DEAD_NO ) { // crap, someone killed the prey on the way up. m_hEnemy = NULL; @@ -352,7 +352,7 @@ void CBarnacle::Killed( entvars_t *pevAttacker, int iGib ) pev->solid = SOLID_NOT; pev->takedamage = DAMAGE_NO; - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { pVictim = m_hEnemy->MyMonsterPointer(); diff --git a/dlls/barney.cpp b/dlls/barney.cpp index b1c97090..329528bf 100644 --- a/dlls/barney.cpp +++ b/dlls/barney.cpp @@ -221,7 +221,7 @@ void CBarney::RunTask( Task_t *pTask ) switch( pTask->iTask ) { case TASK_RANGE_ATTACK1: - if( m_hEnemy != NULL && ( m_hEnemy->IsPlayer() ) ) + if( m_hEnemy != 0 && ( m_hEnemy->IsPlayer() ) ) { pev->framerate = 1.5; } @@ -262,7 +262,7 @@ int CBarney::Classify( void ) //========================================================= void CBarney::AlertSound( void ) { - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { if( FOkToSpeak() ) { @@ -504,7 +504,7 @@ int CBarney::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float // This is a heurstic to determine if the player intended to harm me // If I have an enemy, we can't establish intent (may just be crossfire) - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { // If the player was facing directly at me, or I'm already suspicious, get mad if( ( m_afMemory & bits_MEMORY_SUSPICIOUS ) || IsFacing( pevAttacker, pev->origin ) ) @@ -616,7 +616,7 @@ void CBarney::Killed( entvars_t *pevAttacker, int iGib ) GetAttachment( 0, vecGunPos, vecGunAngles ); - CBaseEntity *pGun = DropItem( "weapon_9mmhandgun", vecGunPos, vecGunAngles ); + DropItem( "weapon_bradnailer", vecGunPos, vecGunAngles ); } SetUse( NULL ); @@ -633,7 +633,7 @@ Schedule_t *CBarney::GetScheduleOfType( int Type ) switch( Type ) { case SCHED_ARM_WEAPON: - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { // face enemy, then draw. return slBarneyEnemyDraw; @@ -721,7 +721,7 @@ Schedule_t *CBarney::GetSchedule( void ) return GetScheduleOfType( SCHED_SMALL_FLINCH ); } - if( m_hEnemy == NULL && IsFollowing() ) + if( m_hEnemy == 0 && IsFollowing() ) { if( !m_hTargetEnt->IsAlive() ) { @@ -783,10 +783,10 @@ public: void KeyValue( KeyValueData *pkvd ); int m_iPose;// which sequence to display -- temporary, don't need to save - static char *m_szPoses[3]; + static const char *m_szPoses[3]; }; -char *CDeadBarney::m_szPoses[] = { "lying_on_back", "lying_on_side", "lying_on_stomach" }; +const char *CDeadBarney::m_szPoses[] = { "lying_on_back", "lying_on_side", "lying_on_stomach" }; void CDeadBarney::KeyValue( KeyValueData *pkvd ) { diff --git a/dlls/basemonster.h b/dlls/basemonster.h index ad05fccf..2234aaf9 100644 --- a/dlls/basemonster.h +++ b/dlls/basemonster.h @@ -12,7 +12,7 @@ * use or distribution of this code by or to any unlicensed person is illegal. * ****/ - +#pragma once #ifndef BASEMONSTER_H #define BASEMONSTER_H @@ -195,7 +195,7 @@ public: Task_t *GetTask( void ); virtual MONSTERSTATE GetIdealState( void ); virtual void SetActivity( Activity NewActivity ); - void SetSequenceByName( char *szSequence ); + void SetSequenceByName( const char *szSequence ); void SetState( MONSTERSTATE State ); virtual void ReportAIState( void ); @@ -327,6 +327,6 @@ public: BOOL ExitScriptedSequence(); BOOL CineCleanup(); - CBaseEntity* DropItem ( char *pszItemName, const Vector &vecPos, const Vector &vecAng );// drop an item. + CBaseEntity* DropItem( const char *pszItemName, const Vector &vecPos, const Vector &vecAng );// drop an item. }; #endif // BASEMONSTER_H diff --git a/dlls/bigmomma.cpp b/dlls/bigmomma.cpp index 59f6cae2..434d6134 100644 --- a/dlls/bigmomma.cpp +++ b/dlls/bigmomma.cpp @@ -49,7 +49,7 @@ public: virtual int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; - int m_preSequence; + string_t m_preSequence; }; LINK_ENTITY_TO_CLASS( info_bigmomma, CInfoBM ) @@ -411,7 +411,7 @@ void CBigMomma::SetYawSpeed( void ) { int ys; - switch ( m_Activity ) + switch( m_Activity ) { case ACT_IDLE: ys = 100; @@ -677,7 +677,7 @@ void CBigMomma::Precache() void CBigMomma::Activate( void ) { - if( m_hTargetEnt == NULL ) + if( m_hTargetEnt == 0 ) Remember( bits_MEMORY_ADVANCE_NODE ); // Start 'er up } @@ -985,7 +985,7 @@ void CBigMomma::RunTask( Task_t *pTask ) { float distance; - if( m_hTargetEnt == NULL ) + if( m_hTargetEnt == 0 ) TaskFail(); else { @@ -1002,7 +1002,7 @@ void CBigMomma::RunTask( Task_t *pTask ) } break; case TASK_WAIT_NODE: - if( m_hTargetEnt != NULL && ( m_hTargetEnt->pev->spawnflags & SF_INFOBM_WAIT ) ) + if( m_hTargetEnt != 0 && ( m_hTargetEnt->pev->spawnflags & SF_INFOBM_WAIT ) ) return; if( gpGlobals->time > m_flWaitFinished ) @@ -1056,7 +1056,6 @@ Vector VecCheckSplatToss( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot float time = speed / flGravity; vecGrenadeVel = vecSpot2 - vecSpot1; vecGrenadeVel.z = 0; - float distance = vecGrenadeVel.Length(); // Travel half the distance to the target in that time (apex is at the midpoint) vecGrenadeVel = vecGrenadeVel * ( 0.5 / time ); diff --git a/dlls/bmodels.cpp b/dlls/bmodels.cpp index ee676679..fe56b6ac 100644 --- a/dlls/bmodels.cpp +++ b/dlls/bmodels.cpp @@ -210,7 +210,7 @@ void CFuncIllusionary::KeyValue( KeyValueData *pkvd ) { if( FStrEq( pkvd->szKeyName, "skin" ) )//skin is used for content type { - pev->skin = atof( pkvd->szValue ); + pev->skin = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else @@ -402,7 +402,7 @@ void CFuncRotating::Spawn() } UTIL_SetOrigin( pev, pev->origin ); - SET_MODEL( ENT(pev), STRING(pev->model) ); + SET_MODEL( ENT( pev ), STRING( pev->model ) ); SetUse( &CFuncRotating::RotatingUse ); // did level designer forget to assign speed? @@ -430,15 +430,13 @@ void CFuncRotating::Spawn() void CFuncRotating::Precache( void ) { - char* szSoundFile = (char*)STRING( pev->message ); + const char* szSoundFile = STRING( pev->message ); + BOOL NullSound = FALSE; // set up fan sounds if( !FStringNull( pev->message ) && strlen( szSoundFile ) > 0 ) { // if a path is set for a wave, use it - PRECACHE_SOUND( szSoundFile ); - - pev->noiseRunning = ALLOC_STRING( szSoundFile ); } else { @@ -446,42 +444,32 @@ void CFuncRotating::Precache( void ) switch( m_sounds ) { case 1: - PRECACHE_SOUND( "fans/fan1.wav" ); - pev->noiseRunning = ALLOC_STRING( "fans/fan1.wav" ); + szSoundFile = "fans/fan1.wav"; break; case 2: - PRECACHE_SOUND( "fans/fan2.wav" ); - pev->noiseRunning = ALLOC_STRING( "fans/fan2.wav" ); + szSoundFile = "fans/fan2.wav"; break; case 3: - PRECACHE_SOUND( "fans/fan3.wav" ); - pev->noiseRunning = ALLOC_STRING( "fans/fan3.wav" ); + szSoundFile = "fans/fan3.wav"; break; case 4: - PRECACHE_SOUND( "fans/fan4.wav" ); - pev->noiseRunning = ALLOC_STRING( "fans/fan4.wav" ); + szSoundFile = "fans/fan4.wav"; break; case 5: - PRECACHE_SOUND( "fans/fan5.wav" ); - pev->noiseRunning = ALLOC_STRING( "fans/fan5.wav" ); + szSoundFile = "fans/fan5.wav"; break; case 0: default: - if( !FStringNull( pev->message ) && strlen( szSoundFile ) > 0 ) - { - PRECACHE_SOUND( szSoundFile ); - - pev->noiseRunning = ALLOC_STRING( szSoundFile ); - break; - } - else - { - pev->noiseRunning = ALLOC_STRING( "common/null.wav" ); - break; - } + szSoundFile = "common/null.wav"; + NullSound = TRUE; + break; } } + if( !NullSound ) + PRECACHE_SOUND( szSoundFile ); + pev->noiseRunning = MAKE_STRING( szSoundFile ); + if( pev->avelocity != g_vecZero ) { // if fan was spinning, and we went through transition or save/restore, @@ -550,7 +538,7 @@ void CFuncRotating::RampPitchVol( int fUp ) pitch = PITCH_NORM - 1; // change the fan's vol and pitch - EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char *)STRING( pev->noiseRunning ), + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, STRING( pev->noiseRunning ), fvol, m_flAttenuation, SND_CHANGE_PITCH | SND_CHANGE_VOL, pitch ); } @@ -572,7 +560,7 @@ void CFuncRotating::SpinUp( void ) fabs( vecAVel.z ) >= fabs( pev->movedir.z * pev->speed ) ) { pev->avelocity = pev->movedir * pev->speed;// set speed in case we overshot - EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char *)STRING( pev->noiseRunning ), + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, STRING( pev->noiseRunning ), m_flVolume, m_flAttenuation, SND_CHANGE_PITCH | SND_CHANGE_VOL, FANPITCHMAX ); SetThink( &CFuncRotating::Rotate ); @@ -613,8 +601,8 @@ void CFuncRotating::SpinDown( void ) pev->avelocity = g_vecZero;// set speed in case we overshot // stop sound, we're done - EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char *)STRING( pev->noiseRunning /* Stop */ ), - 0, 0, SND_STOP, m_pitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, STRING( pev->noiseRunning /* Stop */ ), + 0, 0, SND_STOP, (int)m_pitch ); SetThink( &CFuncRotating::Rotate ); Rotate(); @@ -642,7 +630,7 @@ void CFuncRotating::RotatingUse( CBaseEntity *pActivator, CBaseEntity *pCaller, if( pev->avelocity != g_vecZero ) { SetThink( &CFuncRotating::SpinDown ); - //EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, (char *)STRING( pev->noiseStop ), + //EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, STRING( pev->noiseStop ), // m_flVolume, m_flAttenuation, 0, m_pitch ); pev->nextthink = pev->ltime + 0.1; @@ -650,7 +638,7 @@ void CFuncRotating::RotatingUse( CBaseEntity *pActivator, CBaseEntity *pCaller, else// fan is not moving, so start it { SetThink( &CFuncRotating::SpinUp ); - EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char *)STRING( pev->noiseRunning ), + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, STRING( pev->noiseRunning ), 0.01, m_flAttenuation, 0, FANPITCHMIN ); pev->nextthink = pev->ltime + 0.1; @@ -663,7 +651,7 @@ void CFuncRotating::RotatingUse( CBaseEntity *pActivator, CBaseEntity *pCaller, // play stopping sound here SetThink( &CFuncRotating::SpinDown ); - // EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, (char *)STRING( pev->noiseStop ), + // EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, STRING( pev->noiseStop ), // m_flVolume, m_flAttenuation, 0, m_pitch ); pev->nextthink = pev->ltime + 0.1; @@ -671,7 +659,7 @@ void CFuncRotating::RotatingUse( CBaseEntity *pActivator, CBaseEntity *pCaller, } else { - EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char *)STRING( pev->noiseRunning ), + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, STRING( pev->noiseRunning ), m_flVolume, m_flAttenuation, 0, FANPITCHMAX ); pev->avelocity = pev->movedir * pev->speed; diff --git a/dlls/bullsquid.cpp b/dlls/bullsquid.cpp index 18026b43..af3ab88a 100644 --- a/dlls/bullsquid.cpp +++ b/dlls/bullsquid.cpp @@ -248,7 +248,7 @@ int CBullsquid::IgnoreConditions( void ) iIgnore = bits_COND_SMELL | bits_COND_SMELL_FOOD; } - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { if( FClassnameIs( m_hEnemy->pev, "monster_headcrab" ) ) { @@ -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 != NULL && IsMoving() && pevAttacker == m_hEnemy->pev && gpGlobals->time - m_flLastHurtTime > 3 ) + if( m_hEnemy != 0 && IsMoving() && pevAttacker == m_hEnemy->pev && gpGlobals->time - m_flLastHurtTime > 3 ) { flDist = ( pev->origin - m_hEnemy->pev->origin ).Length2D(); @@ -324,7 +324,7 @@ BOOL CBullsquid::CheckRangeAttack1( float flDot, float flDist ) if( flDist > 64 && flDist <= 784 && flDot >= 0.5 && gpGlobals->time >= m_flNextSpitTime ) { - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { if( fabs( pev->origin.z - m_hEnemy->pev->origin.z ) > 256 ) { @@ -383,7 +383,7 @@ BOOL CBullsquid::CheckMeleeAttack2( float flDot, float flDist ) //========================================================= BOOL CBullsquid::FValidateHintType( short sHint ) { - int i; + size_t i; static short sSquidHints[] = { @@ -784,7 +784,7 @@ void CBullsquid::RunAI( void ) pev->skin = 1; } - if( m_hEnemy != NULL && m_Activity == ACT_RUN ) + if( m_hEnemy != 0 && m_Activity == ACT_RUN ) { // chasing enemy. Sprint for last bit if( ( pev->origin - m_hEnemy->pev->origin).Length2D() < SQUID_SPRINT_DIST ) @@ -1247,7 +1247,7 @@ MONSTERSTATE CBullsquid::GetIdealState( void ) COMBAT goes to ALERT upon death of enemy */ { - if( m_hEnemy != NULL && ( iConditions & bits_COND_LIGHT_DAMAGE || iConditions & bits_COND_HEAVY_DAMAGE ) && FClassnameIs( m_hEnemy->pev, "monster_headcrab" ) ) + if( m_hEnemy != 0 && ( iConditions & bits_COND_LIGHT_DAMAGE || iConditions & bits_COND_HEAVY_DAMAGE ) && FClassnameIs( m_hEnemy->pev, "monster_headcrab" ) ) { // if the squid has a headcrab enemy and something hurts it, it's going to forget about the crab for a while. m_hEnemy = NULL; diff --git a/dlls/buttons.cpp b/dlls/buttons.cpp index 7b050add..90bc42e5 100644 --- a/dlls/buttons.cpp +++ b/dlls/buttons.cpp @@ -275,7 +275,7 @@ IMPLEMENT_SAVERESTORE( CBaseButton, CBaseToggle ) void CBaseButton::Precache( void ) { - char *pszSound; + const char *pszSound; if( FBitSet( pev->spawnflags, SF_BUTTON_SPARK_IF_OFF ) )// this button should spark in OFF state { @@ -292,14 +292,14 @@ void CBaseButton::Precache( void ) { pszSound = ButtonSound( (int)m_bLockedSound ); PRECACHE_SOUND( pszSound ); - m_ls.sLockedSound = ALLOC_STRING( pszSound ); + m_ls.sLockedSound = MAKE_STRING( pszSound ); } if( m_bUnlockedSound ) { pszSound = ButtonSound( (int)m_bUnlockedSound ); PRECACHE_SOUND( pszSound ); - m_ls.sUnlockedSound = ALLOC_STRING( pszSound ); + m_ls.sUnlockedSound = MAKE_STRING( pszSound ); } // get sentence group names, for doors which are directly 'touched' to open @@ -343,25 +343,25 @@ void CBaseButton::Precache( void ) m_ls.sUnlockedSentence = MAKE_STRING( "EA" ); break; case 2: // security door - m_ls.sUnlockedSentence = MAKE_STRING("ED"); + m_ls.sUnlockedSentence = MAKE_STRING( "ED" ); break; case 3: // blast door - m_ls.sUnlockedSentence = MAKE_STRING("EF"); + m_ls.sUnlockedSentence = MAKE_STRING( "EF" ); break; case 4: // fire door - m_ls.sUnlockedSentence = MAKE_STRING("EFIRE"); + m_ls.sUnlockedSentence = MAKE_STRING( "EFIRE" ); break; case 5: // chemical door - m_ls.sUnlockedSentence = MAKE_STRING("ECHEM"); + m_ls.sUnlockedSentence = MAKE_STRING( "ECHEM" ); break; case 6: // radiation door - m_ls.sUnlockedSentence = MAKE_STRING("ERAD"); + m_ls.sUnlockedSentence = MAKE_STRING( "ERAD" ); break; case 7: // gen containment - m_ls.sUnlockedSentence = MAKE_STRING("ECON"); + m_ls.sUnlockedSentence = MAKE_STRING( "ECON" ); break; case 8: // maintenance door - m_ls.sUnlockedSentence = MAKE_STRING("EH"); + m_ls.sUnlockedSentence = MAKE_STRING( "EH" ); break; default: m_ls.sUnlockedSentence = 0; @@ -381,22 +381,22 @@ void CBaseButton::KeyValue( KeyValueData *pkvd ) } else if( FStrEq( pkvd->szKeyName, "locked_sound" ) ) { - m_bLockedSound = atof( pkvd->szValue ); + m_bLockedSound = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "locked_sentence" ) ) { - m_bLockedSentence = atof( pkvd->szValue ); + m_bLockedSentence = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "unlocked_sound" ) ) { - m_bUnlockedSound = atof( pkvd->szValue ); + m_bUnlockedSound = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "unlocked_sentence" ) ) { - m_bUnlockedSentence = atof( pkvd->szValue ); + m_bUnlockedSentence = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "sounds" ) ) @@ -421,12 +421,12 @@ int CBaseButton::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, fl SetTouch( NULL ); m_hActivator = CBaseEntity::Instance( pevAttacker ); - if( m_hActivator == NULL ) + if( m_hActivator == 0 ) return 0; if( code == BUTTON_RETURN ) { - EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noise ), 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noise ), 1, ATTN_NORM ); // Toggle buttons fire when they get back to their "home" position if( !( pev->spawnflags & SF_BUTTON_TOGGLE ) ) @@ -461,7 +461,7 @@ LINK_ENTITY_TO_CLASS( func_button, CBaseButton ) void CBaseButton::Spawn() { - char *pszSound; + const char *pszSound; //---------------------------------------------------- //determine sounds for buttons @@ -469,7 +469,7 @@ void CBaseButton::Spawn() //---------------------------------------------------- pszSound = ButtonSound( m_sounds ); PRECACHE_SOUND( pszSound ); - pev->noise = ALLOC_STRING( pszSound ); + pev->noise = MAKE_STRING( pszSound ); Precache(); @@ -525,9 +525,9 @@ void CBaseButton::Spawn() // Button sound table. // Also used by CBaseDoor to get 'touched' door lock/unlock sounds -char *ButtonSound( int sound ) +const char *ButtonSound( int sound ) { - char *pszSound; + const char *pszSound; switch( sound ) { @@ -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, (char*)STRING( pev->noise ), 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noise ), 1, ATTN_NORM ); //SUB_UseTargets( m_eoActivator ); ButtonReturn(); @@ -716,7 +716,7 @@ void CBaseButton::ButtonTouch( CBaseEntity *pOther ) if( code == BUTTON_RETURN ) { - EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noise ), 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noise ), 1, ATTN_NORM ); SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 ); ButtonReturn(); } @@ -729,7 +729,7 @@ void CBaseButton::ButtonTouch( CBaseEntity *pOther ) // void CBaseButton::ButtonActivate() { - EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noise ), 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noise ), 1, ATTN_NORM ); if( !UTIL_IsMasterTriggered( m_sMaster, m_hActivator ) ) { @@ -815,7 +815,7 @@ void CBaseButton::ButtonBackHome( void ) if( FBitSet( pev->spawnflags, SF_BUTTON_TOGGLE ) ) { - //EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noise ), 1, ATTN_NORM ); + //EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noise ), 1, ATTN_NORM ); SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 ); } @@ -869,14 +869,14 @@ LINK_ENTITY_TO_CLASS( func_rot_button, CRotButton ) void CRotButton::Spawn( void ) { - char *pszSound; + const char *pszSound; //---------------------------------------------------- //determine sounds for buttons //a sound of 0 should not make a sound //---------------------------------------------------- pszSound = ButtonSound( m_sounds ); PRECACHE_SOUND( pszSound ); - pev->noise = ALLOC_STRING( pszSound ); + pev->noise = MAKE_STRING( pszSound ); // set the axis of rotation CBaseToggle::AxisDir( pev ); @@ -1010,9 +1010,9 @@ void CMomentaryRotButton::Spawn( void ) UTIL_SetOrigin( pev, pev->origin ); SET_MODEL( ENT( pev ), STRING( pev->model ) ); - char *pszSound = ButtonSound( m_sounds ); + const char *pszSound = ButtonSound( m_sounds ); PRECACHE_SOUND( pszSound ); - pev->noise = ALLOC_STRING( pszSound ); + pev->noise = MAKE_STRING( pszSound ); m_lastUsed = 0; } @@ -1034,7 +1034,7 @@ void CMomentaryRotButton::KeyValue( KeyValueData *pkvd ) void CMomentaryRotButton::PlaySound( void ) { - EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noise ), 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noise ), 1, ATTN_NORM ); } // BUGBUG: This design causes a latentcy. When the button is retriggered, the first impulse @@ -1045,7 +1045,11 @@ void CMomentaryRotButton::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, US pev->ideal_yaw = CBaseToggle::AxisDelta( pev->spawnflags, pev->angles, m_start ) / m_flMoveDistance; UpdateAllButtons( pev->ideal_yaw, 1 ); - UpdateTarget( pev->ideal_yaw ); + + // Calculate destination angle and use it to predict value, this prevents sending target in wrong direction on retriggering + Vector dest = pev->angles + pev->avelocity * ( pev->nextthink - pev->ltime ); + float value1 = CBaseToggle::AxisDelta( pev->spawnflags, dest, m_start ) / m_flMoveDistance; + UpdateTarget( value1 ); } void CMomentaryRotButton::UpdateAllButtons( float value, int start ) diff --git a/dlls/cbase.cpp b/dlls/cbase.cpp index 62b4eaa1..8750bddf 100644 --- a/dlls/cbase.cpp +++ b/dlls/cbase.cpp @@ -26,7 +26,7 @@ void EntvarsKeyvalue( entvars_t *pev, KeyValueData *pkvd ); extern "C" void PM_Move ( struct playermove_s *ppmove, int server ); extern "C" void PM_Init ( struct playermove_s *ppmove ); -extern "C" char PM_FindTextureType( char *name ); +extern "C" char PM_FindTextureType( const char *name ); extern Vector VecBModelOrigin( entvars_t* pevBModel ); extern DLL_GLOBAL Vector g_vecAttackDir; @@ -441,9 +441,16 @@ edict_t *EHANDLE::Get( void ) edict_t *EHANDLE::Set( edict_t *pent ) { - m_pent = pent; - if( pent ) - m_serialnumber = m_pent->serialnumber; + if( pent ) + { + m_pent = pent; + m_serialnumber = m_pent->serialnumber; + } + else + { + m_pent = NULL; + m_serialnumber = 0; + } return pent; } @@ -511,7 +518,7 @@ int CBaseEntity::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, fl // (that is, no actual entity projectile was involved in the attack so use the shooter's origin). if( pevAttacker == pevInflictor ) { - vecTemp = pevInflictor->origin - VecBModelOrigin( pev ); + vecTemp = pevAttacker->origin - VecBModelOrigin( pev ); } else // an actual missile was involved. @@ -598,7 +605,7 @@ int CBaseEntity::Restore( CRestore &restore ) mins = pev->mins; // Set model is about to destroy these maxs = pev->maxs; - PRECACHE_MODEL( (char *)STRING( pev->model ) ); + PRECACHE_MODEL( STRING( pev->model ) ); SET_MODEL( ENT( pev ), STRING( pev->model ) ); UTIL_SetSize( pev, mins, maxs ); // Reset them } @@ -739,7 +746,7 @@ int CBaseEntity::DamageDecal( int bitsDamageType ) // NOTE: szName must be a pointer to constant memory, e.g. "monster_class" because the entity // will keep a pointer to it after this call. -CBaseEntity *CBaseEntity::Create( char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner ) +CBaseEntity *CBaseEntity::Create( const char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner ) { edict_t *pent; CBaseEntity *pEntity; diff --git a/dlls/cbase.h b/dlls/cbase.h index c84dea91..779e30e0 100644 --- a/dlls/cbase.h +++ b/dlls/cbase.h @@ -12,6 +12,9 @@ * without written permission from Valve LLC. * ****/ +#pragma once +#ifndef CBASE_H +#define CBASE_H /* Class Hierachy @@ -177,7 +180,7 @@ public: virtual void AddPointsToTeam( int score, BOOL bAllowNegativeScore ) {} virtual BOOL AddPlayerItem( CBasePlayerItem *pItem ) { return 0; } virtual BOOL RemovePlayerItem( CBasePlayerItem *pItem ) { return 0; } - virtual int GiveAmmo( int iAmount, char *szName, int iMax ) { return -1; }; + virtual int GiveAmmo( int iAmount, const char *szName, int iMax ) { return -1; }; virtual float GetDelay( void ) { return 0; } virtual int IsMoving( void ) { return pev->velocity != g_vecZero; } virtual void OverrideReset( void ) {} @@ -229,7 +232,7 @@ public: }; #endif - void UpdateOnRemove( void ); + virtual void UpdateOnRemove( void ); // common member functions void EXPORT SUB_Remove( void ); @@ -280,8 +283,8 @@ public: #ifdef _DEBUG void FunctionCheck( void *pFunction, char *name ) { - if( pFunction && !NAME_FOR_FUNCTION( (unsigned long)( pFunction ) ) ) - ALERT( at_error, "No EXPORT: %s:%s (%08lx)\n", STRING( pev->classname ), name, (unsigned long)pFunction ); + if( pFunction && !NAME_FOR_FUNCTION( pFunction ) ) + ALERT( at_error, "No EXPORT: %s:%s (%08lx)\n", STRING( pev->classname ), name, (size_t)pFunction ); } BASEPTR ThinkSet( BASEPTR func, char *name ) @@ -314,7 +317,7 @@ public: // used by monsters that are created by the MonsterMaker virtual void UpdateOwner( void ) { return; }; - static CBaseEntity *Create( char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner = NULL ); + static CBaseEntity *Create( const char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner = NULL ); virtual BOOL FBecomeProne( void ) {return FALSE;}; edict_t *edict() { return ENT( pev ); }; @@ -330,30 +333,6 @@ public: virtual BOOL FVisible( CBaseEntity *pEntity ); virtual BOOL FVisible( const Vector &vecOrigin ); - - //We use this variables to store each ammo count. - int ammo_9mm; - int ammo_357; - int ammo_bolts; - int ammo_buckshot; - int ammo_rockets; - int ammo_uranium; - int ammo_hornets; - int ammo_argrens; - int ammo_nails; - int ammo_xencandy; - int ammo_par21; - int ammo_m203grens; - - //Special stuff for grenades and satchels. - float m_flStartThrow; - float m_flReleaseThrow; - int m_chargeReady; - int m_fInAttack; - - enum EGON_FIRESTATE { FIRE_OFF, FIRE_CHARGE }; - int m_fireState; - int m_thrownByPlayer; }; // Ugly technique to override base member functions @@ -442,7 +421,7 @@ class CBaseDelay : public CBaseEntity { public: float m_flDelay; - int m_iszKillTarget; + string_t m_iszKillTarget; virtual void KeyValue( KeyValueData *pkvd ); virtual int Save( CSave &save ); @@ -661,8 +640,7 @@ class CSound; #include "basemonster.h" - -char *ButtonSound( int sound ); // get string of button sound number +const char *ButtonSound( int sound ); // get string of button sound number // // Generic Button @@ -787,3 +765,4 @@ public: void Precache( void ); void KeyValue( KeyValueData *pkvd ); }; +#endif diff --git a/dlls/cdll_dll.h b/dlls/cdll_dll.h index c960a6ac..0aafafbd 100644 --- a/dlls/cdll_dll.h +++ b/dlls/cdll_dll.h @@ -16,7 +16,7 @@ // cdll_dll.h // this file is included by both the game-dll and the client-dll, - +#pragma once #ifndef CDLL_DLL_H #define CDLL_DLL_H diff --git a/dlls/client.cpp b/dlls/client.cpp index 56bd8ff3..f488408e 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -38,6 +38,7 @@ #include "weaponinfo.h" #include "usercmd.h" #include "netadr.h" +#include "pm_shared.h" extern DLL_GLOBAL ULONG g_ulModelIndexPlayer; extern DLL_GLOBAL BOOL g_fGameOver; @@ -47,9 +48,15 @@ extern DLL_GLOBAL ULONG g_ulFrameCount; extern void CopyToBodyQue( entvars_t* pev ); extern int giPrecacheGrunt; extern int gmsgSayText; +extern int gmsgBhopcap; + +extern cvar_t allow_spectators; extern int g_teamplay; +extern cvar_t bhopcap; +extern "C" int g_bhopcap; + void LinkUserMessages( void ); /* @@ -101,25 +108,24 @@ 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), "- %s has left the game\n", STRING( pEntity->v.netname ) ); MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL ); WRITE_BYTE( ENTINDEX( pEntity ) ); WRITE_STRING( text ); MESSAGE_END(); - CSound *pSound; - pSound = CSoundEnt::SoundPointerForIndex( CSoundEnt::ClientSoundIndex( pEntity ) ); + CSound *pSound = CSoundEnt::SoundPointerForIndex( CSoundEnt::ClientSoundIndex( pEntity ) ); + + // since this client isn't around to think anymore, reset their sound. + if( pSound ) { - // since this client isn't around to think anymore, reset their sound. - if( pSound ) - { - pSound->Reset(); - } + pSound->Reset(); } // since the edict doesn't get deleted, fix it so it doesn't interfere. pEntity->v.takedamage = DAMAGE_NO;// don't attract autoaim pEntity->v.solid = SOLID_NOT;// nonsolid + pEntity->v.effects = 0;// clear any effects UTIL_SetOrigin( &pEntity->v, pEntity->v.origin ); g_pGameRules->ClientDisconnected( pEntity ); @@ -198,12 +204,104 @@ void ClientPutInServer( edict_t *pEntity ) pPlayer->pev->iuser1 = 0; pPlayer->pev->iuser2 = 0; + pPlayer->pev->iuser4 = 0; } #ifndef NO_VOICEGAMEMGR #include "voice_gamemgr.h" extern CVoiceGameMgr g_VoiceGameMgr; #endif + +//----------------------------------------------------------------------------- +// Purpose: determine if a uchar32 represents a valid Unicode code point +//----------------------------------------------------------------------------- +bool Q_IsValidUChar32( unsigned int uVal ) +{ + // Values > 0x10FFFF are explicitly invalid; ditto for UTF-16 surrogate halves, + // values ending in FFFE or FFFF, or values in the 0x00FDD0-0x00FDEF reserved range + return ( ( uVal - 0x0u ) < 0x110000u ) && ( (uVal - 0x00D800u) > 0x7FFu ) && ( (uVal & 0xFFFFu) < 0xFFFEu ) && ( ( uVal - 0x00FDD0u ) > 0x1Fu ); +} + +// Decode one character from a UTF-8 encoded string. Treats 6-byte CESU-8 sequences +// as a single character, as if they were a correctly-encoded 4-byte UTF-8 sequence. +int Q_UTF8ToUChar32( const char *pUTF8_, unsigned int &uValueOut, bool &bErrorOut ) +{ + const unsigned char *pUTF8 = (const unsigned char*)pUTF8_; + + int nBytes = 1; + unsigned int uValue = pUTF8[0]; + unsigned int uMinValue = 0; + + // 0....... single byte + if( uValue < 0x80 ) + goto decodeFinishedNoCheck; + + // Expecting at least a two-byte sequence with 0xC0 <= first <= 0xF7 (110...... and 11110...) + if( ( uValue - 0xC0u ) > 0x37u || ( pUTF8[1] & 0xC0 ) != 0x80 ) + goto decodeError; + + uValue = ( uValue << 6 ) - ( 0xC0 << 6 ) + pUTF8[1] - 0x80; + nBytes = 2; + uMinValue = 0x80; + + // 110..... two-byte lead byte + if( !( uValue & ( 0x20 << 6 ) ) ) + goto decodeFinished; + + // Expecting at least a three-byte sequence + if( ( pUTF8[2] & 0xC0 ) != 0x80 ) + goto decodeError; + + uValue = ( uValue << 6 ) - ( 0x20 << 12 ) + pUTF8[2] - 0x80; + nBytes = 3; + uMinValue = 0x800; + + // 1110.... three-byte lead byte +decodeFinished: + if( uValue >= uMinValue && Q_IsValidUChar32( uValue ) ) + { +decodeFinishedNoCheck: + uValueOut = uValue; + bErrorOut = false; + return nBytes; + } +decodeError: + uValueOut = '?'; + bErrorOut = true; + return nBytes; + +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. + if( ( uValue - 0xD800u ) < 0x400u && pUTF8[3] == 0xED && (unsigned char)( pUTF8[4] - 0xB0 ) < 0x10 && ( pUTF8[5] & 0xC0 ) == 0x80 ) + { + uValue = 0x10000 + ( ( uValue - 0xD800u ) << 10 ) + ( (unsigned char)( pUTF8[4] - 0xB0 ) << 6 ) + pUTF8[5] - 0x80; + nBytes = 6; + uMinValue = 0x10000; + } + goto decodeFinished; +} + +//----------------------------------------------------------------------------- +// Purpose: Returns true if UTF-8 string contains invalid sequences. +//----------------------------------------------------------------------------- +bool Q_UnicodeValidate( const char *pUTF8 ) +{ + bool bError = false; + while( *pUTF8 ) + { + unsigned int uVal; + // Our UTF-8 decoder silently fixes up 6-byte CESU-8 (improperly re-encoded UTF-16) sequences. + // However, these are technically not valid UTF-8. So if we eat 6 bytes at once, it's an error. + int nCharSize = Q_UTF8ToUChar32( pUTF8, uVal, bError ); + if( bError || nCharSize == 6 ) + return false; + pUTF8 += nCharSize; + } + return true; +} + + //// HOST_SAY // String comes in as // say blah blah blah @@ -259,26 +357,19 @@ void Host_Say( edict_t *pEntity, int teamonly ) } // remove quotes if present - if( *p == '"' ) + if( p && *p == '"' ) { p++; p[strlen( p ) - 1] = 0; } - // make sure the text has content - for( pc = p; pc != NULL && *pc != 0; pc++ ) - { - if( !isspace( *pc ) ) - { - pc = NULL; // we've found an alphanumeric character, so text is valid - break; - } - } - if( pc != NULL ) + if( !p || !p[0] || !Q_UnicodeValidate ( p ) ) return; // no character found, so say nothing // turn on color set 2 (color on, no sound) - if( teamonly ) + if( player->IsObserver() && ( teamonly ) ) + sprintf( text, "%c(SPEC) %s: ", 2, STRING( pEntity->v.netname ) ); + else if( teamonly ) sprintf( text, "%c(TEAM) %s: ", 2, STRING( pEntity->v.netname ) ); else sprintf( text, "%c%s: ", 2, STRING( pEntity->v.netname ) ); @@ -313,9 +404,14 @@ void Host_Say( edict_t *pEntity, int teamonly ) if( g_VoiceGameMgr.PlayerHasBlockedPlayer( client, player ) ) continue; #endif - if( teamonly && g_pGameRules->PlayerRelationship( client, CBaseEntity::Instance( pEntity ) ) != GR_TEAMMATE ) + if( !player->IsObserver() && teamonly && g_pGameRules->PlayerRelationship( client, CBaseEntity::Instance( pEntity ) ) != GR_TEAMMATE ) continue; + // Spectators can only talk to other specs + if( player->IsObserver() && teamonly ) + if ( !client->IsObserver() ) + continue; + MESSAGE_BEGIN( MSG_ONE, gmsgSayText, NULL, client->pev ); WRITE_BYTE( ENTINDEX( pEntity ) ); WRITE_STRING( text ); @@ -331,7 +427,7 @@ void Host_Say( edict_t *pEntity, int teamonly ) // echo to server console g_engfuncs.pfnServerPrint( text ); - char *temp; + const char *temp; if( teamonly ) temp = "say_team"; else @@ -459,17 +555,55 @@ void ClientCommand( edict_t *pEntity ) { GetClassPtr( (CBasePlayer *)pev )->SelectLastItem(); } - else if( FStrEq( pcmd, "spectate" ) && ( pev->flags & FL_PROXY ) ) // added for proxy support + else if( FStrEq( pcmd, "spectate" ) ) // clients wants to become a spectator { - CBasePlayer * pPlayer = GetClassPtr( (CBasePlayer *)pev ); + CBasePlayer *pPlayer = GetClassPtr( (CBasePlayer *)pev ); + if( !pPlayer->IsObserver() ) + { + // always allow proxies to become a spectator + if( ( pev->flags & FL_PROXY ) || allow_spectators.value ) + { + edict_t *pentSpawnSpot = g_pGameRules->GetPlayerSpawnSpot( pPlayer ); + pPlayer->StartObserver( pev->origin, VARS( pentSpawnSpot )->angles ); - edict_t *pentSpawnSpot = g_pGameRules->GetPlayerSpawnSpot( pPlayer ); - pPlayer->StartObserver( pev->origin, VARS( pentSpawnSpot )->angles ); + // notify other clients of player switching to spectator mode + UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs( "%s switched to spectator mode\n", + ( pev->netname && ( STRING( pev->netname ) )[0] != 0 ) ? STRING( pev->netname ) : "unconnected" ) ); + } + else + ClientPrint( pev, HUD_PRINTCONSOLE, "Spectator mode is disabled.\n" ); + } + else + { + pPlayer->StopObserver(); + + // notify other clients of player left spectators + UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs( "%s has left spectator mode\n", + ( pev->netname && ( STRING( pev->netname ) )[0] != 0 ) ? STRING( pev->netname ) : "unconnected" ) ); + } } - /*else if( g_pGameRules->ClientCommand( GetClassPtr( (CBasePlayer *)pev ), pcmd ) ) + else if( FStrEq( pcmd, "specmode" ) ) // new spectator mode + { + CBasePlayer *pPlayer = GetClassPtr( (CBasePlayer *)pev ); + + if( pPlayer->IsObserver() ) + pPlayer->Observer_SetMode( atoi( CMD_ARGV( 1 ) ) ); + } + else if( FStrEq( pcmd, "closemenus" ) ) + { + // just ignore it + } + else if( FStrEq( pcmd, "follownext" ) ) // follow next player + { + CBasePlayer *pPlayer = GetClassPtr( (CBasePlayer *)pev ); + + if( pPlayer->IsObserver() ) + pPlayer->Observer_FindNextPlayer( atoi( CMD_ARGV( 1 ) ) ? true : false ); + } + else if( g_pGameRules->ClientCommand( GetClassPtr( (CBasePlayer *)pev ), pcmd ) ) { // MenuSelect returns true only if the command is properly handled, so don't print a warning - }*/ + } else if( FStrEq( pcmd, "VModEnable" ) ) { // clear 'Unknown command: VModEnable' in singleplayer @@ -506,7 +640,7 @@ void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer ) return; // msg everyone if someone changes their name, and it isn't the first time (changing no name to current name) - if( pEntity->v.netname && STRING( pEntity->v.netname )[0] != 0 && !FStrEq( STRING( pEntity->v.netname ), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) ) ) + if( pEntity->v.netname && ( STRING( pEntity->v.netname ) )[0] != 0 && !FStrEq( STRING( pEntity->v.netname ), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) ) ) { char sName[256]; char *pName = g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ); @@ -524,12 +658,17 @@ void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer ) // Set the name g_engfuncs.pfnSetClientKeyValue( ENTINDEX( pEntity ), infobuffer, "name", sName ); - char text[256]; - snprintf( text, 256, "* %s changed name to %s\n", STRING( pEntity->v.netname ), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) ); - MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL ); - WRITE_BYTE( ENTINDEX( pEntity ) ); - WRITE_STRING( text ); - MESSAGE_END(); + 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" ) ); + MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL ); + WRITE_BYTE( ENTINDEX( pEntity ) ); + WRITE_STRING( text ); + MESSAGE_END(); + } + + SET_CLIENT_MAX_SPEED( pEntity, PLAYER_MAX_SPEED ); // team match? if( g_teamplay ) @@ -621,7 +760,6 @@ void PlayerPreThink( edict_t *pEntity ) { //ALERT( at_console, "PreThink( %g, frametime %g )\n", gpGlobals->time, gpGlobals->frametime ); - entvars_t *pev = &pEntity->v; CBasePlayer *pPlayer = (CBasePlayer *)GET_PRIVATE( pEntity ); if( pPlayer ) @@ -639,7 +777,6 @@ void PlayerPostThink( edict_t *pEntity ) { //ALERT( at_console, "PostThink( %g, frametime %g )\n", gpGlobals->time, gpGlobals->frametime ); - entvars_t *pev = &pEntity->v; CBasePlayer *pPlayer = (CBasePlayer *)GET_PRIVATE( pEntity ); if( pPlayer ) @@ -674,8 +811,16 @@ void StartFrame( void ) gpGlobals->teamplay = teamplay.value; g_ulFrameCount++; -} + int oldBhopcap = g_bhopcap; + g_bhopcap = ( g_pGameRules->IsMultiplayer() && bhopcap.value != 0.0f ) ? 1 : 0; + if( g_bhopcap != oldBhopcap ) + { + MESSAGE_BEGIN( MSG_ALL, gmsgBhopcap, NULL ); + WRITE_BYTE( g_bhopcap ); + MESSAGE_END(); + } +} void ClientPrecache( void ) { @@ -787,8 +932,6 @@ void ClientPrecache( void ) if( giPrecacheGrunt ) UTIL_PrecacheOther( "monster_human_grunt" ); - - PRECACHE_SOUND("player/breathe2.wav"); } /* @@ -803,7 +946,7 @@ const char *GetGameDescription() if( g_pGameRules ) // this function may be called before the world has spawned, and the game rules initialized return g_pGameRules->GetGameDescription(); else - return "Half-Life"; + return "Poke646"; } /* @@ -829,7 +972,6 @@ animation right now. */ void PlayerCustomization( edict_t *pEntity, customization_t *pCust ) { - entvars_t *pev = &pEntity->v; CBasePlayer *pPlayer = (CBasePlayer *)GET_PRIVATE( pEntity ); if( !pPlayer ) @@ -869,7 +1011,6 @@ A spectator has joined the game */ void SpectatorConnect( edict_t *pEntity ) { - entvars_t *pev = &pEntity->v; CBaseSpectator *pPlayer = (CBaseSpectator *)GET_PRIVATE( pEntity ); if( pPlayer ) @@ -885,7 +1026,6 @@ A spectator has left the game */ void SpectatorDisconnect( edict_t *pEntity ) { - entvars_t *pev = &pEntity->v; CBaseSpectator *pPlayer = (CBaseSpectator *)GET_PRIVATE( pEntity ); if( pPlayer ) @@ -901,7 +1041,6 @@ A spectator has sent a usercmd */ void SpectatorThink( edict_t *pEntity ) { - entvars_t *pev = &pEntity->v; CBaseSpectator *pPlayer = (CBaseSpectator *)GET_PRIVATE( pEntity ); if( pPlayer ) @@ -985,7 +1124,7 @@ int AddToFullPack( struct entity_state_s *state, int e, edict_t *ent, edict_t *h int i; // don't send if flagged for NODRAW and it's not the host getting the message - if( ( ent->v.effects == EF_NODRAW ) && ( ent != host ) ) + if( ( ent->v.effects & EF_NODRAW ) && ( ent != host ) ) return 0; // Ignore ents without valid / visible models @@ -1114,11 +1253,11 @@ int AddToFullPack( struct entity_state_s *state, int e, edict_t *ent, edict_t *h } state->rendermode = ent->v.rendermode; - state->renderamt = ent->v.renderamt; + state->renderamt = (int)ent->v.renderamt; state->renderfx = ent->v.renderfx; - state->rendercolor.r = ent->v.rendercolor.x; - state->rendercolor.g = ent->v.rendercolor.y; - state->rendercolor.b = ent->v.rendercolor.z; + state->rendercolor.r = (byte)ent->v.rendercolor.x; + state->rendercolor.g = (byte)ent->v.rendercolor.y; + state->rendercolor.b = (byte)ent->v.rendercolor.z; state->aiment = 0; if( ent->v.aiment ) @@ -1165,7 +1304,7 @@ int AddToFullPack( struct entity_state_s *state, int e, edict_t *ent, edict_t *h //state->team = ent->v.team; state->usehull = ( ent->v.flags & FL_DUCKING ) ? 1 : 0; - state->health = ent->v.health; + state->health = (int)ent->v.health; } return 1; @@ -1520,12 +1659,12 @@ int GetWeaponData( struct edict_s *player, struct weapon_data_s *info ) item->m_iId = II.iId; item->m_iClip = gun->m_iClip; - item->m_flTimeWeaponIdle = max( gun->m_flTimeWeaponIdle, -0.001 ); - item->m_flNextPrimaryAttack = max( gun->m_flNextPrimaryAttack, -0.001 ); - item->m_flNextSecondaryAttack = max( gun->m_flNextSecondaryAttack, -0.001 ); + 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_fInReload = gun->m_fInReload; item->m_fInSpecialReload = gun->m_fInSpecialReload; - item->fuser1 = max( gun->pev->fuser1, -0.001 ); + item->fuser1 = Q_max( gun->pev->fuser1, -0.001 ); item->fuser2 = gun->m_flStartThrow; item->fuser3 = gun->m_flReleaseThrow; item->iuser1 = gun->m_chargeReady; @@ -1555,41 +1694,69 @@ engine sets cd to 0 before calling. */ void UpdateClientData( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ) { - cd->flags = ent->v.flags; - cd->health = ent->v.health; + if( !ent || !ent->pvPrivateData ) + return; + entvars_t *pev = (entvars_t *)&ent->v; + CBasePlayer *pl = (CBasePlayer *)( CBasePlayer::Instance( pev ) ); + entvars_t *pevOrg = NULL; - cd->viewmodel = MODEL_INDEX( STRING( ent->v.viewmodel ) ); + // if user is spectating different player in First person, override some vars + if( pl && pl->pev->iuser1 == OBS_IN_EYE ) + { + if( pl->m_hObserverTarget ) + { + pevOrg = pev; + pev = pl->m_hObserverTarget->pev; + pl = (CBasePlayer *)(CBasePlayer::Instance( pev ) ); + } + } - cd->waterlevel = ent->v.waterlevel; - cd->watertype = ent->v.watertype; - cd->weapons = ent->v.weapons; + cd->flags = pev->flags; + cd->health = pev->health; + + cd->viewmodel = MODEL_INDEX( STRING( pev->viewmodel ) ); + + cd->waterlevel = pev->waterlevel; + cd->watertype = pev->watertype; + cd->weapons = pev->weapons; // Vectors - cd->origin = ent->v.origin; - cd->velocity = ent->v.velocity; - cd->view_ofs = ent->v.view_ofs; - cd->punchangle = ent->v.punchangle; + cd->origin = pev->origin; + cd->velocity = pev->velocity; + cd->view_ofs = pev->view_ofs; + cd->punchangle = pev->punchangle; - cd->bInDuck = ent->v.bInDuck; - cd->flTimeStepSound = ent->v.flTimeStepSound; - cd->flDuckTime = ent->v.flDuckTime; - cd->flSwimTime = ent->v.flSwimTime; - cd->waterjumptime = ent->v.teleport_time; + cd->bInDuck = pev->bInDuck; + cd->flTimeStepSound = pev->flTimeStepSound; + cd->flDuckTime = pev->flDuckTime; + cd->flSwimTime = pev->flSwimTime; + cd->waterjumptime = pev->teleport_time; strcpy( cd->physinfo, ENGINE_GETPHYSINFO( ent ) ); - cd->maxspeed = ent->v.maxspeed; - cd->fov = ent->v.fov; - cd->weaponanim = ent->v.weaponanim; + cd->maxspeed = pev->maxspeed; + cd->fov = pev->fov; + cd->weaponanim = pev->weaponanim; - cd->pushmsec = ent->v.pushmsec; + cd->pushmsec = pev->pushmsec; + // Spectator mode + if( pevOrg != NULL ) + { + // don't use spec vars from chased player + cd->iuser1 = pevOrg->iuser1; + cd->iuser2 = pevOrg->iuser2; + cd->iuser4 = pevOrg->iuser4; + } + else + { + cd->iuser1 = pev->iuser1; + cd->iuser2 = pev->iuser2; + cd->iuser4 = pev->iuser4; + } #if defined( CLIENT_WEAPONS ) if( sendweapons ) { - entvars_t *pev = (entvars_t *)&ent->v; - CBasePlayer *pl = (CBasePlayer *)CBasePlayer::Instance( pev ); - if( pl ) { cd->m_flNextAttack = pl->m_flNextAttack; @@ -1695,7 +1862,7 @@ ConnectionlessPacket int 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 @@ -1720,18 +1887,18 @@ int GetHullBounds( int hullnumber, float *mins, float *maxs ) switch( hullnumber ) { case 0: // Normal player - mins = VEC_HULL_MIN; - maxs = VEC_HULL_MAX; + VEC_HULL_MIN.CopyToArray(mins); + VEC_HULL_MAX.CopyToArray(maxs); iret = 1; break; case 1: // Crouched player - mins = VEC_DUCK_HULL_MIN; - maxs = VEC_DUCK_HULL_MAX; + VEC_DUCK_HULL_MIN.CopyToArray(mins); + VEC_DUCK_HULL_MAX.CopyToArray(maxs); iret = 1; break; case 2: // Point based hull - mins = Vector( 0, 0, 0 ); - maxs = Vector( 0, 0, 0 ); + Vector( 0, 0, 0 ).CopyToArray(mins); + Vector( 0, 0, 0 ).CopyToArray(maxs); iret = 1; break; } @@ -1749,10 +1916,10 @@ to be created during play ( e.g., grenades, ammo packs, projectiles, corpses, et */ void CreateInstancedBaselines( void ) { - int iret = 0; + /*int iret = 0; entity_state_t state; - memset( &state, 0, sizeof(state) ); + memset( &state, 0, sizeof(state) );*/ // Create any additional baselines here for things like grendates, etc. // iret = ENGINE_INSTANCE_BASELINE( pc->pev->classname, &state ); diff --git a/dlls/client.h b/dlls/client.h index 6728151b..6feaac1a 100644 --- a/dlls/client.h +++ b/dlls/client.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef CLIENT_H #define CLIENT_H diff --git a/dlls/combat.cpp b/dlls/combat.cpp index f0f39d04..0a271ee1 100644 --- a/dlls/combat.cpp +++ b/dlls/combat.cpp @@ -460,11 +460,11 @@ Activity CBaseMonster::GetSmallFlinchActivity( void ) { Activity flinchActivity; BOOL fTriedDirection; - float flDot; + //float flDot; fTriedDirection = FALSE; UTIL_MakeVectors( pev->angles ); - flDot = DotProduct( gpGlobals->v_forward, g_vecAttackDir * -1 ); + //flDot = DotProduct( gpGlobals->v_forward, g_vecAttackDir * -1 ); switch( m_LastHitGroup ) { @@ -576,8 +576,8 @@ Killed */ void CBaseMonster::Killed( entvars_t *pevAttacker, int iGib ) { - unsigned int cCount = 0; - BOOL fDone = FALSE; + //unsigned int cCount = 0; + //BOOL fDone = FALSE; if( HasMemory( bits_MEMORY_KILLED ) ) { @@ -727,7 +727,7 @@ void CGib::BounceGibTouch( CBaseEntity *pOther ) float volume; float zvel = fabs( pev->velocity.z ); - volume = 0.8 * min( 1.0, ( (float)zvel ) / 450.0 ); + volume = 0.8 * Q_min( 1.0, ( (float)zvel ) / 450.0 ); CBreakable::MaterialSoundRandom( edict(), (Materials)m_material, volume ); } @@ -920,7 +920,7 @@ int CBaseMonster::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, f // enemy's last known position is somewhere down the vector that the attack came from. if( pevInflictor ) { - if( m_hEnemy == NULL || pevInflictor == m_hEnemy->pev || !HasConditions( bits_COND_SEE_ENEMY ) ) + if( m_hEnemy == 0 || pevInflictor == m_hEnemy->pev || !HasConditions( bits_COND_SEE_ENEMY ) ) { m_vecEnemyLKP = pevInflictor->origin; } @@ -1463,7 +1463,7 @@ void CBaseEntity::FireBullets( ULONG cShots, Vector vecSrc, Vector vecDirShootin } } // make bullet trails - UTIL_BubbleTrail( vecSrc, tr.vecEndPos, ( flDistance * tr.flFraction ) / 64.0 ); + UTIL_BubbleTrail( vecSrc, tr.vecEndPos, (int)( ( flDistance * tr.flFraction ) / 64.0 ) ); } ApplyMultiDamage( pev, pevAttacker ); } @@ -1483,7 +1483,8 @@ Vector CBaseEntity::FireBulletsPlayer( ULONG cShots, Vector vecSrc, Vector vecDi TraceResult tr; Vector vecRight = gpGlobals->v_right; Vector vecUp = gpGlobals->v_up; - float x, y, z; + float x = 0.0f, y = 0.0f; + float z; if( pevAttacker == NULL ) pevAttacker = pev; // the default attacker is ourselves @@ -1497,7 +1498,7 @@ Vector CBaseEntity::FireBulletsPlayer( ULONG cShots, Vector vecSrc, Vector vecDi // 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; + //z = x * x + y * y; Vector vecDir = vecDirShooting + x * vecSpread.x * vecRight + @@ -1523,10 +1524,10 @@ Vector CBaseEntity::FireBulletsPlayer( ULONG cShots, Vector vecSrc, Vector vecDi { default: case BULLET_PLAYER_9MM: - pEntity->TraceAttack( pevAttacker, gSkillData.plrDmg9MM, vecDir, &tr, DMG_BULLET ); + pEntity->TraceAttack( pevAttacker, gSkillData.plrDmg9MM, vecDir, &tr, DMG_NEVERGIB ); break; case BULLET_PLAYER_MP5: - pEntity->TraceAttack( pevAttacker, gSkillData.plrDmgMP5, vecDir, &tr, DMG_BULLET ); + pEntity->TraceAttack( pevAttacker, gSkillData.plrDmgMP5, vecDir, &tr, DMG_NEVERGIB ); break; case BULLET_PLAYER_BUCKSHOT: // make distance based! @@ -1544,17 +1545,11 @@ Vector CBaseEntity::FireBulletsPlayer( ULONG cShots, Vector vecSrc, Vector vecDi UTIL_DecalTrace( &tr, DECAL_GLASSBREAK1 + RANDOM_LONG( 0, 2 ) ); } - break; - case BULLET_PLAYER_NAIL: - pEntity->TraceAttack( pevAttacker, 0, vecDir, &tr, DMG_BULLET ); - break; - case BULLET_PLAYER_PAR21: - pEntity->TraceAttack( pevAttacker, gSkillData.plrDmgPar21, vecDir, &tr, DMG_BULLET ); break; } } // make bullet trails - UTIL_BubbleTrail( vecSrc, tr.vecEndPos, ( flDistance * tr.flFraction ) / 64.0 ); + UTIL_BubbleTrail( vecSrc, tr.vecEndPos, (int)( ( flDistance * tr.flFraction ) / 64.0 ) ); } ApplyMultiDamage( pev, pevAttacker ); diff --git a/dlls/compile.bat b/dlls/compile.bat new file mode 100644 index 00000000..53c4511b --- /dev/null +++ b/dlls/compile.bat @@ -0,0 +1,121 @@ +@echo off +echo Setting environment for minimal Visual C++ 6 +set INCLUDE=%MSVCDir%\VC98\Include +set LIB=%MSVCDir%\VC98\Lib +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 +set SOURCES=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^ + ../pm_shared/pm_debug.c ../pm_shared/pm_math.c ../pm_shared/pm_shared.c +set DEFINES=/DCLIENT_WEAPONS /Dsnprintf=_snprintf /DNO_VOICEGAMEMGR +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" + +echo -- Compile done. Cleaning... + +del *.obj *.exp *.lib *.ilk +echo -- Done. diff --git a/dlls/controller.cpp b/dlls/controller.cpp index 3d56325f..e1d57517 100644 --- a/dlls/controller.cpp +++ b/dlls/controller.cpp @@ -47,6 +47,7 @@ public: void Spawn( void ); void Precache( void ); + void UpdateOnRemove(); void SetYawSpeed( void ); int Classify( void ); void HandleAnimEvent( MonsterEvent_t *pEvent ); @@ -384,6 +385,23 @@ void CController::Precache() UTIL_PrecacheOther( "controller_head_ball" ); } +void CController::UpdateOnRemove() +{ + CBaseEntity::UpdateOnRemove(); + + if( m_pBall[0] ) + { + UTIL_Remove( m_pBall[0] ); + m_pBall[0] = 0; + } + + if( m_pBall[1] ) + { + UTIL_Remove( m_pBall[1] ); + m_pBall[1] = 0; + } +} + //========================================================= // AI Schedules Specific to this monster //========================================================= @@ -614,7 +632,7 @@ void CController::RunTask( Task_t *pTask ) Vector vecSrc = vecHand + pev->velocity * ( m_flShootTime - gpGlobals->time ); Vector vecDir; - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { if( HasConditions( bits_COND_SEE_ENEMY ) ) { @@ -707,7 +725,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.0 ); // dead enemy if( HasConditions( bits_COND_LIGHT_DAMAGE ) ) @@ -1095,7 +1113,6 @@ class CControllerHeadBall : public CBaseMonster void EXPORT BounceTouch( CBaseEntity *pOther ); void MovetoTarget( Vector vecTarget ); void Crawl( void ); - int m_iTrail; int m_flNextAttack; Vector m_vecIdeal; EHANDLE m_hOwner; @@ -1160,7 +1177,7 @@ void CControllerHeadBall::HuntThink( void ) MESSAGE_END(); // check world boundaries - if( gpGlobals->time - pev->dmgtime > 5 || pev->renderamt < 64 || m_hEnemy == NULL || m_hOwner == NULL || 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( gpGlobals->time - pev->dmgtime > 5 || pev->renderamt < 64 || m_hEnemy == 0 || m_hOwner == 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 ) { SetTouch( NULL ); UTIL_Remove( this ); @@ -1340,7 +1357,7 @@ void CControllerZapBall::ExplodeTouch( CBaseEntity *pOther ) entvars_t *pevOwner; - if( m_hOwner != NULL ) + if( m_hOwner != 0 ) { pevOwner = m_hOwner->pev; } diff --git a/dlls/crossbow.cpp b/dlls/crossbow.cpp index 77ac9d41..a8c4c641 100644 --- a/dlls/crossbow.cpp +++ b/dlls/crossbow.cpp @@ -22,9 +22,34 @@ #include "nodes.h" #include "player.h" #include "gamerules.h" -#include "crossbow.h" +#include "shake.h" #ifndef CLIENT_DLL +#define BOLT_AIR_VELOCITY 2000 +#define BOLT_WATER_VELOCITY 1000 + +extern BOOL gPhysicsInterfaceInitialized; + +// UNDONE: Save/restore this? Don't forget to set classname and LINK_ENTITY_TO_CLASS() +// +// OVERLOADS SOME ENTVARS: +// +// speed - the ideal magnitude of my velocity +class CCrossbowBolt : public CBaseEntity +{ + void Spawn( void ); + void Precache( void ); + int Classify( void ); + void EXPORT BubbleThink( void ); + void EXPORT BoltTouch( CBaseEntity *pOther ); + void EXPORT ExplodeThink( void ); + + int m_iTrail; + +public: + static CCrossbowBolt *BoltCreate( void ); +}; + LINK_ENTITY_TO_CLASS( crossbow_bolt, CCrossbowBolt ) CCrossbowBolt *CCrossbowBolt::BoltCreate( void ) @@ -48,7 +73,7 @@ void CCrossbowBolt::Spawn() SET_MODEL( ENT( pev ), "models/crossbow_bolt.mdl" ); UTIL_SetOrigin( pev, pev->origin ); - UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) ); + UTIL_SetSize( pev, g_vecZero, g_vecZero ); SetTouch( &CCrossbowBolt::BoltTouch ); SetThink( &CCrossbowBolt::BubbleThink ); @@ -97,7 +122,7 @@ void CCrossbowBolt::BoltTouch( CBaseEntity *pOther ) ApplyMultiDamage( pev, pevOwner ); - pev->velocity = Vector( 0, 0, 0 ); + pev->velocity = g_vecZero; // play body "thwack" sound switch( RANDOM_LONG( 0, 1 ) ) { @@ -129,7 +154,7 @@ void CCrossbowBolt::BoltTouch( CBaseEntity *pOther ) pev->angles = UTIL_VecToAngles( vecDir ); pev->solid = SOLID_NOT; pev->movetype = MOVETYPE_FLY; - pev->velocity = Vector( 0, 0, 0 ); + pev->velocity = g_vecZero; pev->avelocity.z = 0; pev->angles.z = RANDOM_LONG( 0, 360 ); pev->nextthink = gpGlobals->time + 10.0; @@ -140,7 +165,7 @@ void CCrossbowBolt::BoltTouch( CBaseEntity *pOther ) UTIL_SetOrigin( pev, pev->origin - vecDir * 12 ); pev->angles = UTIL_VecToAngles( vecDir ); pev->solid = SOLID_NOT; - pev->velocity = Vector( 0, 0, 0 ); + pev->velocity = g_vecZero; pev->avelocity.z = 0; pev->angles.z = RANDOM_LONG( 0, 360 ); pev->nextthink = gpGlobals->time + 10.0; @@ -215,4 +240,294 @@ void CCrossbowBolt::ExplodeThink( void ) UTIL_Remove( this ); } #endif + +enum crossbow_e +{ + CROSSBOW_IDLE1 = 0, // full + CROSSBOW_IDLE2, // empty + CROSSBOW_FIDGET1, // full + CROSSBOW_FIDGET2, // empty + CROSSBOW_FIRE1, // full + CROSSBOW_RELOAD, // reload + CROSSBOW_DRAWBACK, // empty + CROSSBOW_UNDRAW, // from empty + CROSSBOW_DRAW1, // full + CROSSBOW_DRAW2, // empty + CROSSBOW_HOLSTER1, // full + CROSSBOW_HOLSTER2 // empty +}; + +LINK_ENTITY_TO_CLASS( weapon_cmlwbr, CCrossbow ) + +void CCrossbow::Spawn() +{ + Precache(); + m_iId = WEAPON_CROSSBOW; + SET_MODEL( ENT( pev ), "models/w_crossbow.mdl" ); + + m_iDefaultAmmo = CROSSBOW_DEFAULT_GIVE; + + FallInit();// get ready to fall down. +} + +int CCrossbow::AddToPlayer( CBasePlayer *pPlayer ) +{ + if( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) + { + MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev ); + WRITE_BYTE( m_iId ); + MESSAGE_END(); + return TRUE; + } + return FALSE; +} + +void CCrossbow::Precache( void ) +{ + PRECACHE_MODEL( "models/w_crossbow.mdl" ); + PRECACHE_MODEL( "models/v_cmlwbr.mdl" ); + PRECACHE_MODEL( "models/p_crossbow.mdl" ); + + PRECACHE_SOUND( "weapons/cmlwbr_fire.wav" ); + PRECACHE_SOUND( "weapons/cmlwbr_reload.wav" ); + PRECACHE_SOUND( "weapons/cmlwbr_drawback.wav" ); + PRECACHE_SOUND( "weapons/cmlwbr_undraw.wav" ); + PRECACHE_SOUND( "weapons/cmlwbr_zoom.wav" ); + + UTIL_PrecacheOther( "crossbow_bolt" ); +} + +int CCrossbow::GetItemInfo( ItemInfo *p ) +{ + p->pszName = STRING( pev->classname ); + p->pszAmmo1 = "bolts"; + p->iMaxAmmo1 = BOLT_MAX_CARRY; + p->pszAmmo2 = NULL; + p->iMaxAmmo2 = -1; + p->iMaxClip = CROSSBOW_MAX_CLIP; + p->iSlot = 3; + p->iPosition = 1; + p->iId = WEAPON_CROSSBOW; + p->iFlags = 0; + p->iWeight = CROSSBOW_WEIGHT; + return 1; +} + +BOOL CCrossbow::Deploy() +{ + return DefaultDeploy( "models/v_cmlwbr.mdl", "models/p_crossbow.mdl", m_iClip ? CROSSBOW_DRAW1 : CROSSBOW_DRAW2 , "bow" ); +} + +void CCrossbow::Holster( int skiplocal /* = 0 */ ) +{ + m_fInReload = FALSE;// cancel any reload in progress. + + if( m_fInZoom ) + { + ZoomOut(); + } + + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; + SendWeaponAnim( m_iClip ? CROSSBOW_HOLSTER1 : CROSSBOW_HOLSTER2 ); +} + +void CCrossbow::PrimaryAttack( void ) +{ + if( m_pPlayer->pev->waterlevel == 3 ) + { + PlayEmptySound(); + m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.2f; + return; + } + + FireBolt(); +} + +void CCrossbow::FireBolt() +{ + TraceResult tr; + + if( m_iClip == 0 || !m_fInAttack ) + { + PlayEmptySound(); + return; + } + + m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME; + + m_iClip--; + + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cmlwbr_fire.wav", RANDOM_FLOAT( 0.95, 1.0 ), ATTN_NORM, 0, 93 + RANDOM_LONG( 0, 0xF ) ); + SendWeaponAnim( CROSSBOW_FIRE1 ); + + // player "shoot" animation + m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); + + Vector anglesAim = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle; + UTIL_MakeVectors( anglesAim ); + + anglesAim.x = -anglesAim.x; + +#ifndef CLIENT_DLL + Vector vecSrc = m_pPlayer->GetGunPosition() - gpGlobals->v_up * 2; + Vector vecDir = gpGlobals->v_forward; + + CCrossbowBolt *pBolt = CCrossbowBolt::BoltCreate(); + pBolt->pev->origin = vecSrc; + pBolt->pev->angles = anglesAim; + pBolt->pev->owner = m_pPlayer->edict(); + + if( m_pPlayer->pev->waterlevel == 3 ) + { + pBolt->pev->velocity = vecDir * BOLT_WATER_VELOCITY; + pBolt->pev->speed = BOLT_WATER_VELOCITY; + } + else + { + pBolt->pev->velocity = vecDir * BOLT_AIR_VELOCITY; + pBolt->pev->speed = BOLT_AIR_VELOCITY; + } + pBolt->pev->avelocity.z = 10; +#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 = UTIL_WeaponTimeBase() + 0.75f; + m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.2f; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.1f; + + m_pPlayer->pev->punchangle.x -= 2.0f; +} + +void CCrossbow::ZoomOut() +{ + m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 0; // 0 means reset to default fov + m_fInZoom = 0; + m_pPlayer->pev->iuser4 = m_fInZoom; + m_pPlayer->pev->viewmodel = MAKE_STRING( "models/v_cmlwbr.mdl" ); + UTIL_ScreenFade( m_pPlayer, g_vecZero, 0.2, 0.1, 255, FFADE_IN ); +} + +void CCrossbow::SecondaryAttack() +{ + if( m_fInZoom == 2 ) + { + ZoomOut(); + m_flNextPrimaryAttack = m_flNextSecondaryAttack = m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.7; + } + else + { + m_pPlayer->m_iFOV = m_pPlayer->pev->fov = 20 * ( 2 - m_fInZoom ); + ++m_fInZoom; + m_pPlayer->pev->iuser4 = m_fInZoom; + m_pPlayer->pev->viewmodel = 0; + UTIL_ScreenFade( m_pPlayer, g_vecZero, 0.1, 0.1, 255, FFADE_IN ); + m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; + } + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cmlwbr_zoom.wav", RANDOM_FLOAT( 0.95, 1.0 ), ATTN_NORM, 0, 93 + RANDOM_LONG( 0, 0xF ) ); +} + +void CCrossbow::ToggleDrawn() +{ + SetThink( NULL ); + m_fInAttack = ( m_fInAttack == 0 ); + if( m_fInSpecialReload ) + { + m_fInSpecialReload = 0; + Reload(); + } +} + +void CCrossbow::Reload( void ) +{ + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == CROSSBOW_MAX_CLIP ) + return; + + if( m_fInZoom != 0 ) + { + ZoomOut(); + } + + if( m_fInAttack ) + { + if(!m_fInSpecialReload ) + { + SetThink( &CCrossbow::ToggleDrawn ); + pev->nextthink = gpGlobals->time + 1.4f; + SendWeaponAnim( CROSSBOW_UNDRAW ); + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cmlwbr_undraw.wav", RANDOM_FLOAT( 0.95, 1.0 ), ATTN_NORM, 0, 93 + RANDOM_LONG( 0, 0xF ) ); + m_fInSpecialReload = 1; + } + return; + } + + if( DefaultReload( CROSSBOW_MAX_CLIP, CROSSBOW_RELOAD, 4.5f ) ) + { + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cmlwbr_reload.wav", RANDOM_FLOAT( 0.95, 1.0 ), ATTN_NORM, 0, 93 + RANDOM_LONG( 0, 0xF ) ); + } + m_flNextPrimaryAttack = m_flNextSecondaryAttack = m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 4.5f; +} + +void CCrossbow::WeaponIdle( void ) +{ + m_pPlayer->GetAutoaimVector( AUTOAIM_2DEGREES ); // get the autoaim vector but ignore it; used for autoaim crosshair in DM + + ResetEmptySound(); + + if( m_flTimeWeaponIdle < UTIL_WeaponTimeBase() ) + { + int iAnim; + if( m_fInAttack || !m_iClip ) + { + float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 ); + if( flRand <= 0.75 || m_fInZoom ) + { + iAnim = m_fInAttack ? CROSSBOW_IDLE1 : CROSSBOW_IDLE2; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3.1f; + } + else + { + iAnim = m_fInAttack ? CROSSBOW_FIDGET1 : CROSSBOW_FIDGET2; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.8f; + } + } + else + { + iAnim = CROSSBOW_DRAWBACK; + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cmlwbr_drawback.wav", RANDOM_FLOAT( 0.9, 1.0 ), ATTN_NORM, 0, 93 + RANDOM_LONG( 0, 0xF ) ); + m_flNextSecondaryAttack = m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.3f; + SetThink( &CCrossbow::ToggleDrawn ); + pev->nextthink = gpGlobals->time + 1.2f; + } + SendWeaponAnim( iAnim ); + } +} + +class CCrossbowAmmo : public CBasePlayerAmmo +{ + void Spawn( void ) + { + Precache(); + SET_MODEL( ENT( pev ), "models/w_crossbow_clip.mdl" ); + CBasePlayerAmmo::Spawn(); + } + void Precache( void ) + { + PRECACHE_MODEL( "models/w_crossbow_clip.mdl" ); + PRECACHE_SOUND( "items/9mmclip1.wav" ); + } + BOOL AddAmmo( CBaseEntity *pOther ) + { + if( pOther->GiveAmmo( AMMO_CROSSBOWCLIP_GIVE, "bolts", BOLT_MAX_CARRY ) != -1 ) + { + EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM ); + return TRUE; + } + return FALSE; + } +}; + +LINK_ENTITY_TO_CLASS( ammo_bolts, CCrossbowAmmo ) #endif diff --git a/dlls/crossbow.h b/dlls/crossbow.h deleted file mode 100644 index 682a554d..00000000 --- a/dlls/crossbow.h +++ /dev/null @@ -1,46 +0,0 @@ -/*** -* -* Copyright (c) 1996-2001, 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. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef CROSSBOW_H -#define CROSSBOW_H - -#ifdef _WIN32 -#pragma once -#endif - -#define BOLT_AIR_VELOCITY 2000 -#define BOLT_WATER_VELOCITY 1000 - -extern BOOL gPhysicsInterfaceInitialized; -// UNDONE: Save/restore this? Don't forget to set classname and LINK_ENTITY_TO_CLASS() -// -// OVERLOADS SOME ENTVARS: -// -// speed - the ideal magnitude of my velocity -class CCrossbowBolt : public CBaseEntity -{ - void Spawn(void); - void Precache(void); - int Classify(void); - void EXPORT BubbleThink(void); - void EXPORT BoltTouch(CBaseEntity *pOther); - void EXPORT ExplodeThink(void); - - int m_iTrail; - -public: - static CCrossbowBolt *BoltCreate(void); -}; - -#endif // CROSSBOW_H diff --git a/dlls/crowbar.cpp b/dlls/crowbar.cpp index 94f0066b..b5c08cee 100644 --- a/dlls/crowbar.cpp +++ b/dlls/crowbar.cpp @@ -25,9 +25,9 @@ #define CROWBAR_BODYHIT_VOLUME 128 #define CROWBAR_WALLHIT_VOLUME 512 -LINK_ENTITY_TO_CLASS( weapon_crowbar, CCrowbar ) +LINK_ENTITY_TO_CLASS( weapon_heaterpipe, CCrowbar ) -enum gauss_e +enum crowbar_e { CROWBAR_IDLE = 0, CROWBAR_DRAW, @@ -37,15 +37,20 @@ enum gauss_e CROWBAR_ATTACK2MISS, CROWBAR_ATTACK2HIT, CROWBAR_ATTACK3MISS, +#ifndef CROWBAR_IDLE_ANIM CROWBAR_ATTACK3HIT +#else + CROWBAR_ATTACK3HIT, + CROWBAR_IDLE2, + CROWBAR_IDLE3 +#endif }; - -void CCrowbar::Spawn( ) +void CCrowbar::Spawn() { Precache(); m_iId = WEAPON_CROWBAR; - SET_MODEL( ENT( pev ), "models/w_crowbar.mdl" ); + SET_MODEL( ENT( pev ), "models/w_heaterpipe.mdl" ); m_iClip = -1; FallInit();// get ready to fall down. @@ -53,17 +58,16 @@ void CCrowbar::Spawn( ) void CCrowbar::Precache( void ) { - PRECACHE_MODEL( "models/v_crowbar.mdl" ); - PRECACHE_MODEL( "models/w_crowbar.mdl" ); - PRECACHE_MODEL( "models/p_crowbar.mdl" ); - PRECACHE_SOUND( "weapons/cbar_hit1.wav" ); - PRECACHE_SOUND( "weapons/cbar_hit2.wav" ); + PRECACHE_MODEL( "models/v_heaterpipe.mdl" ); + PRECACHE_MODEL( "models/w_heaterpipe.mdl" ); + PRECACHE_MODEL( "models/p_heaterpipe.mdl" ); + PRECACHE_SOUND( "weapons/pipe_hit1.wav" ); + PRECACHE_SOUND( "weapons/pipe_hit2.wav" ); PRECACHE_SOUND( "weapons/cbar_hitbod1.wav" ); PRECACHE_SOUND( "weapons/cbar_hitbod2.wav" ); PRECACHE_SOUND( "weapons/cbar_hitbod3.wav" ); - PRECACHE_SOUND( "weapons/cbar_miss1.wav" ); - - m_usCrowbar = PRECACHE_EVENT( 1, "events/crowbar.sc" ); + PRECACHE_SOUND( "weapons/pipe_miss.wav" ); + PRECACHE_SOUND( "player/pl_breathe.wav" ); } int CCrowbar::GetItemInfo( ItemInfo *p ) @@ -76,14 +80,26 @@ int CCrowbar::GetItemInfo( ItemInfo *p ) p->iMaxClip = WEAPON_NOCLIP; p->iSlot = 0; p->iPosition = 0; - p->iId = WEAPON_CROWBAR; + p->iId = m_iId = WEAPON_CROWBAR; p->iWeight = CROWBAR_WEIGHT; return 1; } +int CCrowbar::AddToPlayer( CBasePlayer *pPlayer ) +{ + if( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) + { + MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev ); + WRITE_BYTE( m_iId ); + MESSAGE_END(); + return TRUE; + } + return FALSE; +} + BOOL CCrowbar::Deploy() { - return DefaultDeploy( "models/v_crowbar.mdl", "models/p_crowbar.mdl", CROWBAR_DRAW, "crowbar" ); + return DefaultDeploy( "models/v_heaterpipe.mdl", "models/p_heaterpipe.mdl", CROWBAR_DRAW, "crowbar" ); } void CCrowbar::Holster( int skiplocal /* = 0 */ ) @@ -138,11 +154,14 @@ void FindHullIntersection( const Vector &vecSrc, TraceResult &tr, float *mins, f void CCrowbar::PrimaryAttack() { - if( !Swing( 1 ) ) + if( m_flNextPrimaryAttack + 1 <= UTIL_WeaponTimeBase() ) { - SetThink( &CCrowbar::SwingAgain ); - pev->nextthink = gpGlobals->time + 0.1; + m_iSwing = Q_max( 0, m_iSwing - static_cast( ( UTIL_WeaponTimeBase() - m_flNextPrimaryAttack ) * 5.0f ) ); } + + Swing(); + + ++m_iSwing; } void CCrowbar::Smack() @@ -150,16 +169,10 @@ void CCrowbar::Smack() DecalGunshot( &m_trHit, BULLET_PLAYER_CROWBAR ); } -void CCrowbar::SwingAgain( void ) +void CCrowbar::Swing() { - Swing( 0 ); -} - -int CCrowbar::Swing( int fFirst ) -{ - int fDidHit = FALSE; - TraceResult tr; + float flVol; UTIL_MakeVectors( m_pPlayer->pev->v_angle ); Vector vecSrc = m_pPlayer->GetGunPosition(); @@ -182,24 +195,39 @@ int CCrowbar::Swing( int fFirst ) } } #endif - PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usCrowbar, - 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, 0, - 0.0, 0, 0.0 ); + if( m_iSwing > 4 && m_flNextBreathSoundTime <= UTIL_WeaponTimeBase() ) + { + flVol = Q_min( 1.0f, static_cast( m_iSwing - 3 ) * 0.2 ); + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_BODY, "player/pl_breathe.wav", flVol, ATTN_NORM ); + m_flNextBreathSoundTime = UTIL_WeaponTimeBase() + 1.2f; + } if( tr.flFraction >= 1.0 ) { - if( fFirst ) + // miss + switch( ( m_iSwing++ ) % 3 ) { - // miss - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; - - // player "shoot" animation - m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); + case 0: + SendWeaponAnim( CROWBAR_ATTACK1MISS ); + break; + case 1: + SendWeaponAnim( CROWBAR_ATTACK2MISS ); + break; + case 2: + SendWeaponAnim( CROWBAR_ATTACK3MISS ); + break; } + m_flNextPrimaryAttack = ( static_cast( m_iSwing ) * 0.03f ) + UTIL_WeaponTimeBase() + 0.5f; + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/pipe_miss.wav", 1, ATTN_NORM, 0, 94 + RANDOM_LONG( 0, 0xF ) ); +#ifdef CROWBAR_IDLE_ANIM + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); +#endif + // player "shoot" animation + m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); } else { - switch( ( ( m_iSwing++ ) % 2 ) + 1 ) + switch( ( m_iSwing++ ) % 3 ) { case 0: SendWeaponAnim( CROWBAR_ATTACK1HIT ); @@ -217,29 +245,23 @@ int CCrowbar::Swing( int fFirst ) #ifndef CLIENT_DLL // hit - fDidHit = TRUE; CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit ); - ClearMultiDamage(); - - if( ( m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() ) - { - // first swing does full damage - pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgCrowbar, gpGlobals->v_forward, &tr, DMG_CLUB ); - } - else - { - // subsequent swings do half - pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgCrowbar / 2, gpGlobals->v_forward, &tr, DMG_CLUB ); - } - ApplyMultiDamage( m_pPlayer->pev, m_pPlayer->pev ); - // play thwack, smack, or dong sound - float flVol = 1.0; + flVol = 1.0; int fHitWorld = TRUE; + m_flNextPrimaryAttack = ( static_cast( m_iSwing ) * 0.03f ) + UTIL_WeaponTimeBase() + 0.3f; + if( pEntity ) { + ClearMultiDamage(); + + float flDmg = Q_max( 1.0f, gSkillData.plrDmgCrowbar - ( static_cast( m_iSwing ) * 0.5f ) ); + pEntity->TraceAttack( m_pPlayer->pev, flDmg, gpGlobals->v_forward, &tr, DMG_CLUB ); + + ApplyMultiDamage( m_pPlayer->pev, m_pPlayer->pev ); + if( pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE ) { // play thwack or smack sound @@ -257,7 +279,7 @@ int CCrowbar::Swing( int fFirst ) } m_pPlayer->m_iWeaponVolume = CROWBAR_BODYHIT_VOLUME; if( !pEntity->IsAlive() ) - return TRUE; + return; else flVol = 0.1; @@ -284,10 +306,10 @@ int CCrowbar::Swing( int fFirst ) switch( RANDOM_LONG( 0, 1 ) ) { case 0: - EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cbar_hit1.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG( 0, 3 ) ); + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/pipe_hit1.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG( 0, 3 ) ); break; case 1: - EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cbar_hit2.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG( 0, 3 ) ); + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/pipe_hit2.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG( 0, 3 ) ); break; } @@ -295,12 +317,43 @@ int CCrowbar::Swing( int fFirst ) m_trHit = tr; } - m_pPlayer->m_iWeaponVolume = flVol * CROWBAR_WALLHIT_VOLUME; -#endif - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.25; + m_pPlayer->m_iWeaponVolume = (int)( flVol * CROWBAR_WALLHIT_VOLUME ); SetThink( &CCrowbar::Smack ); - pev->nextthink = UTIL_WeaponTimeBase() + 0.2; + pev->nextthink = UTIL_WeaponTimeBase() + 0.1f; +#endif } - return fDidHit; +#ifdef CROWBAR_IDLE_ANIM + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); +#endif } + +#ifdef 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 ) + { + iAnim = CROWBAR_IDLE2; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 160.0 / 30.0; + } + else + { + if( flRand > 0.5 ) + { + iAnim = CROWBAR_IDLE; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 70.0 / 30.0; + } + else + { + iAnim = CROWBAR_IDLE3; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 160.0 / 30.0; + } + } + SendWeaponAnim( iAnim ); + } +} +#endif diff --git a/dlls/decals.h b/dlls/decals.h index ce5a2b53..5de54421 100644 --- a/dlls/decals.h +++ b/dlls/decals.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef DECALS_H #define DECALS_H @@ -66,7 +67,7 @@ enum decal_e typedef struct { - char *name; + const char *name; int index; } DLL_DECALLIST; diff --git a/dlls/doors.cpp b/dlls/doors.cpp index f9219d02..c4c390e9 100644 --- a/dlls/doors.cpp +++ b/dlls/doors.cpp @@ -22,6 +22,8 @@ #include "util.h" #include "cbase.h" #include "doors.h" +#include "game.h" +#include "weapons.h" extern void SetMovedir( entvars_t *ev ); @@ -71,8 +73,6 @@ public: BYTE m_bLockedSentence; BYTE m_bUnlockedSound; BYTE m_bUnlockedSentence; - BOOL m_bIsEndBossDoor; - int m_iNumTimesItWasOpen; }; TYPEDESCRIPTION CBaseDoor::m_SaveData[] = @@ -85,9 +85,6 @@ TYPEDESCRIPTION CBaseDoor::m_SaveData[] = DEFINE_FIELD( CBaseDoor, m_bLockedSentence, FIELD_CHARACTER ), DEFINE_FIELD( CBaseDoor, m_bUnlockedSound, FIELD_CHARACTER ), DEFINE_FIELD( CBaseDoor, m_bUnlockedSentence, FIELD_CHARACTER ), - - DEFINE_FIELD( CBaseDoor, m_bIsEndBossDoor, FIELD_BOOLEAN ), - DEFINE_FIELD( CBaseDoor, m_iNumTimesItWasOpen, FIELD_INTEGER ), }; IMPLEMENT_SAVERESTORE( CBaseDoor, CBaseToggle ) @@ -130,7 +127,7 @@ void PlayLockSounds( entvars_t *pev, locksound_t *pls, int flocked, int fbutton if( fplaysound ) { // play 'door locked' sound - EMIT_SOUND( ENT( pev ), CHAN_ITEM, (char*)STRING( pls->sLockedSound ), fvol, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_ITEM, STRING( pls->sLockedSound ), fvol, ATTN_NORM ); pls->flwaitSound = gpGlobals->time + flsoundwait; } @@ -167,7 +164,7 @@ void PlayLockSounds( entvars_t *pev, locksound_t *pls, int flocked, int fbutton // play 'door unlocked' sound if set if( fplaysound ) { - EMIT_SOUND( ENT( pev ), CHAN_ITEM, (char*)STRING( pls->sUnlockedSound ), fvol, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_ITEM, STRING( pls->sUnlockedSound ), fvol, ATTN_NORM ); pls->flwaitSound = gpGlobals->time + flsoundwait; } @@ -194,42 +191,42 @@ void CBaseDoor::KeyValue( KeyValueData *pkvd ) { if( FStrEq( pkvd->szKeyName, "skin" ) )//skin is used for content type { - pev->skin = atof( pkvd->szValue ); + pev->skin = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "movesnd" ) ) { - m_bMoveSnd = atof( pkvd->szValue ); + m_bMoveSnd = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "stopsnd" ) ) { - m_bStopSnd = atof( pkvd->szValue ); + m_bStopSnd = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "healthvalue" ) ) { - m_bHealthValue = atof( pkvd->szValue ); + m_bHealthValue = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "locked_sound" ) ) { - m_bLockedSound = atof( pkvd->szValue ); + m_bLockedSound = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "locked_sentence" ) ) { - m_bLockedSentence = atof( pkvd->szValue ); + m_bLockedSentence = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "unlocked_sound" ) ) { - m_bUnlockedSound = atof( pkvd->szValue ); + m_bUnlockedSound = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "unlocked_sentence" ) ) { - m_bUnlockedSentence = atof( pkvd->szValue ); + m_bUnlockedSentence = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "WaveHeight" ) ) @@ -321,18 +318,6 @@ void CBaseDoor::Spawn() } else // touchable button SetTouch( &CBaseDoor::DoorTouch ); - - m_bIsEndBossDoor = FALSE; - m_iNumTimesItWasOpen = 0; - - if( FStrEq( STRING( gpGlobals->mapname ), "pv_asl02" ) && FStrEq( STRING( pev->targetname ), "robogate" ) ) - { - m_bIsEndBossDoor = TRUE; - } - else - { - m_bIsEndBossDoor = FALSE; - } } void CBaseDoor::SetToggleState( int state ) @@ -345,115 +330,105 @@ void CBaseDoor::SetToggleState( int state ) void CBaseDoor::Precache( void ) { - char *pszSound; + const char *pszSound; + BOOL NullSound = FALSE; // set the door's "in-motion" sound switch( m_bMoveSnd ) { - case 0: - pev->noiseMoving = ALLOC_STRING( "common/null.wav" ); - break; case 1: - PRECACHE_SOUND( "doors/doormove1.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove1.wav" ); + pszSound = "doors/doormove1.wav"; break; case 2: - PRECACHE_SOUND( "doors/doormove2.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove2.wav" ); + pszSound = "doors/doormove2.wav"; break; case 3: - PRECACHE_SOUND( "doors/doormove3.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove3.wav" ); + pszSound = "doors/doormove3.wav"; break; case 4: - PRECACHE_SOUND( "doors/doormove4.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove4.wav" ); + pszSound = "doors/doormove4.wav"; break; case 5: - PRECACHE_SOUND( "doors/doormove5.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove5.wav" ); + pszSound = "doors/doormove5.wav"; break; case 6: - PRECACHE_SOUND( "doors/doormove6.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove6.wav" ); + pszSound = "doors/doormove6.wav"; break; case 7: - PRECACHE_SOUND( "doors/doormove7.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove7.wav" ); + pszSound = "doors/doormove7.wav"; break; case 8: - PRECACHE_SOUND( "doors/doormove8.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove8.wav" ); + pszSound = "doors/doormove8.wav"; break; case 9: - PRECACHE_SOUND( "doors/doormove9.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove9.wav" ); + pszSound = "doors/doormove9.wav"; break; case 10: - PRECACHE_SOUND( "doors/doormove10.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove10.wav" ); + pszSound = "doors/doormove10.wav"; break; + case 0: default: - pev->noiseMoving = ALLOC_STRING( "common/null.wav" ); + pszSound = "common/null.wav"; + NullSound = TRUE; break; } + if( !NullSound ) + PRECACHE_SOUND( pszSound ); + pev->noiseMoving = MAKE_STRING( pszSound ); + NullSound = FALSE; + // set the door's 'reached destination' stop sound switch( m_bStopSnd ) { - case 0: - pev->noiseArrived = ALLOC_STRING( "common/null.wav" ); - break; case 1: - PRECACHE_SOUND( "doors/doorstop1.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop1.wav" ); + pszSound = "doors/doorstop1.wav"; break; case 2: - PRECACHE_SOUND( "doors/doorstop2.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop2.wav" ); + pszSound = "doors/doorstop2.wav"; break; case 3: - PRECACHE_SOUND( "doors/doorstop3.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop3.wav" ); + pszSound = "doors/doorstop3.wav"; break; case 4: - PRECACHE_SOUND( "doors/doorstop4.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop4.wav" ); + pszSound = "doors/doorstop4.wav"; break; case 5: - PRECACHE_SOUND( "doors/doorstop5.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop5.wav" ); + pszSound = "doors/doorstop5.wav"; break; case 6: - PRECACHE_SOUND( "doors/doorstop6.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop6.wav"); + pszSound = "doors/doorstop6.wav"; break; case 7: - PRECACHE_SOUND( "doors/doorstop7.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop7.wav" ); + pszSound = "doors/doorstop7.wav"; break; case 8: - PRECACHE_SOUND( "doors/doorstop8.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop8.wav" ); + pszSound = "doors/doorstop8.wav"; break; + case 0: default: - pev->noiseArrived = ALLOC_STRING( "common/null.wav" ); + pszSound = "common/null.wav"; + NullSound = TRUE; break; } + if( !NullSound ) + PRECACHE_SOUND( pszSound ); + pev->noiseArrived = MAKE_STRING( pszSound ); + // get door button sounds, for doors which are directly 'touched' to open if( m_bLockedSound ) { pszSound = ButtonSound( (int)m_bLockedSound ); PRECACHE_SOUND( pszSound ); - m_ls.sLockedSound = ALLOC_STRING( pszSound ); + m_ls.sLockedSound = MAKE_STRING( pszSound ); } if( m_bUnlockedSound ) { pszSound = ButtonSound( (int)m_bUnlockedSound ); PRECACHE_SOUND( pszSound ); - m_ls.sUnlockedSound = ALLOC_STRING( pszSound ); + m_ls.sUnlockedSound = MAKE_STRING( pszSound ); } // get sentence group names, for doors which are directly 'touched' to open @@ -461,39 +436,39 @@ void CBaseDoor::Precache( void ) { case 1: // access denied - m_ls.sLockedSentence = ALLOC_STRING( "NA" ); + m_ls.sLockedSentence = MAKE_STRING( "NA" ); break; case 2: // security lockout - m_ls.sLockedSentence = ALLOC_STRING( "ND" ); + m_ls.sLockedSentence = MAKE_STRING( "ND" ); break; case 3: // blast door - m_ls.sLockedSentence = ALLOC_STRING( "NF" ); + m_ls.sLockedSentence = MAKE_STRING( "NF" ); break; case 4: // fire door - m_ls.sLockedSentence = ALLOC_STRING( "NFIRE" ); + m_ls.sLockedSentence = MAKE_STRING( "NFIRE" ); break; case 5: // chemical door - m_ls.sLockedSentence = ALLOC_STRING( "NCHEM" ); + m_ls.sLockedSentence = MAKE_STRING( "NCHEM" ); break; case 6: // radiation door - m_ls.sLockedSentence = ALLOC_STRING( "NRAD" ); + m_ls.sLockedSentence = MAKE_STRING( "NRAD" ); break; case 7: // gen containment - m_ls.sLockedSentence = ALLOC_STRING( "NCON" ); + m_ls.sLockedSentence = MAKE_STRING( "NCON" ); break; case 8: // maintenance door - m_ls.sLockedSentence = ALLOC_STRING( "NH" ); + m_ls.sLockedSentence = MAKE_STRING( "NH" ); break; case 9: // broken door - m_ls.sLockedSentence = ALLOC_STRING( "NG" ); + m_ls.sLockedSentence = MAKE_STRING( "NG" ); break; default: m_ls.sLockedSentence = 0; @@ -504,35 +479,35 @@ void CBaseDoor::Precache( void ) { case 1: // access granted - m_ls.sUnlockedSentence = ALLOC_STRING( "EA" ); + m_ls.sUnlockedSentence = MAKE_STRING( "EA" ); break; case 2: // security door - m_ls.sUnlockedSentence = ALLOC_STRING( "ED" ); + m_ls.sUnlockedSentence = MAKE_STRING( "ED" ); break; case 3: // blast door - m_ls.sUnlockedSentence = ALLOC_STRING( "EF" ); + m_ls.sUnlockedSentence = MAKE_STRING( "EF" ); break; case 4: // fire door - m_ls.sUnlockedSentence = ALLOC_STRING( "EFIRE" ); + m_ls.sUnlockedSentence = MAKE_STRING( "EFIRE" ); break; case 5: // chemical door - m_ls.sUnlockedSentence = ALLOC_STRING( "ECHEM" ); + m_ls.sUnlockedSentence = MAKE_STRING( "ECHEM" ); break; case 6: // radiation door - m_ls.sUnlockedSentence = ALLOC_STRING( "ERAD" ); + m_ls.sUnlockedSentence = MAKE_STRING( "ERAD" ); break; case 7: // gen containment - m_ls.sUnlockedSentence = ALLOC_STRING( "ECON" ); + m_ls.sUnlockedSentence = MAKE_STRING( "ECON" ); break; case 8: // maintenance door - m_ls.sUnlockedSentence = ALLOC_STRING( "EH" ); + m_ls.sUnlockedSentence = MAKE_STRING( "EH" ); break; default: m_ls.sUnlockedSentence = 0; @@ -598,7 +573,7 @@ int CBaseDoor::DoorActivate() else { // door should open - if( m_hActivator != NULL && m_hActivator->IsPlayer() ) + if( m_hActivator != 0 && m_hActivator->IsPlayer() ) { // give health if player opened the door (medikit) //VARS( m_eoActivator )->health += m_bHealthValue; @@ -631,7 +606,7 @@ void CBaseDoor::DoorGoUp( void ) // filter them out and leave a client stuck with looping door sounds! 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, (char*)STRING( pev->noiseMoving ), 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ), 1, ATTN_NORM ); m_toggle_state = TS_GOING_UP; @@ -640,7 +615,7 @@ void CBaseDoor::DoorGoUp( void ) { float sign = 1.0; - if( m_hActivator != NULL ) + if( m_hActivator != 0 ) { pevActivator = m_hActivator->pev; @@ -671,48 +646,29 @@ void CBaseDoor::DoorHitTop( void ) { if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) { - STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ) ); - EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseArrived ), 1, ATTN_NORM ); + STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ) ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseArrived ), 1, ATTN_NORM ); } ASSERT( m_toggle_state == TS_GOING_UP ); m_toggle_state = TS_AT_TOP; - m_iNumTimesItWasOpen++; - - if( m_bIsEndBossDoor ) + // toggle-doors don't come down automatically, they wait for refire. + if( FBitSet( pev->spawnflags, SF_DOOR_NO_AUTO_RETURN ) ) { - if( m_iNumTimesItWasOpen < 2 ) - { - // In flWait seconds, DoorGoDown will fire, unless wait is -1, then door stays open - pev->nextthink = pev->ltime + 1; - SetThink( &CBaseDoor::DoorGoDown ); - } - else - { - m_flWait = -1; - pev->nextthink = -1; - } + // Re-instate touch method, movement is complete + if( !FBitSet( pev->spawnflags, SF_DOOR_USE_ONLY ) ) + SetTouch( &CBaseDoor::DoorTouch ); } else { - // toggle-doors don't come down automatically, they wait for refire. - if( FBitSet( pev->spawnflags, SF_DOOR_NO_AUTO_RETURN ) ) - { - // Re-instate touch method, movement is complete - if( !FBitSet( pev->spawnflags, SF_DOOR_USE_ONLY ) ) - SetTouch( &CBaseDoor::DoorTouch ); - } - else - { - // In flWait seconds, DoorGoDown will fire, unless wait is -1, then door stays open - pev->nextthink = pev->ltime + m_flWait; - SetThink( &CBaseDoor::DoorGoDown ); + // In flWait seconds, DoorGoDown will fire, unless wait is -1, then door stays open + pev->nextthink = pev->ltime + m_flWait; + SetThink( &CBaseDoor::DoorGoDown ); - if( m_flWait == -1 ) - { - pev->nextthink = -1; - } + if( m_flWait == -1 ) + { + pev->nextthink = -1; } } @@ -730,7 +686,7 @@ 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, (char*)STRING( pev->noiseMoving ), 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ), 1, ATTN_NORM ); #ifdef DOOR_ASSERT ASSERT( m_toggle_state == TS_AT_TOP ); #endif // DOOR_ASSERT @@ -750,8 +706,8 @@ void CBaseDoor::DoorHitBottom( void ) { if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) { - STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ) ); - EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseArrived ), 1, ATTN_NORM ); + STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ) ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseArrived ), 1, ATTN_NORM ); } ASSERT( m_toggle_state == TS_GOING_DOWN ); @@ -782,10 +738,22 @@ void CBaseDoor::Blocked( CBaseEntity *pOther ) if( pev->dmg ) pOther->TakeDamage( pev, pev, pev->dmg, DMG_CRUSH ); + if( satchelfix.value ) + { + // Detonate satchels + if( !strcmp( "monster_satchel", STRING( pOther->pev->classname ) ) ) + ( (CPipebomb*)pOther )->Use( this, this, USE_ON, 0 ); + } + // 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 ) { + // BMod Start - Door sound fix. + if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) + STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ) ); + // BMod End + if( m_toggle_state == TS_GOING_DOWN ) { DoorGoUp(); @@ -799,7 +767,7 @@ void CBaseDoor::Blocked( CBaseEntity *pOther ) // Block all door pieces with the same targetname here. if( !FStringNull( pev->targetname ) ) { - for(;;) + for( ; ; ) { pentTarget = FIND_ENTITY_BY_TARGETNAME( pentTarget, STRING( pev->targetname ) ); @@ -831,7 +799,7 @@ void CBaseDoor::Blocked( CBaseEntity *pOther ) } } if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) - STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ) ); + STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ) ); if( pDoor->m_toggle_state == TS_GOING_DOWN ) pDoor->DoorGoUp(); @@ -1011,94 +979,88 @@ void CMomentaryDoor::Spawn( void ) Precache(); } - + void CMomentaryDoor::Precache( void ) { + const char *pszSound; + BOOL NullSound = FALSE; + // set the door's "in-motion" sound switch( m_bMoveSnd ) { - case 0: - pev->noiseMoving = ALLOC_STRING( "common/null.wav" ); - break; case 1: - PRECACHE_SOUND( "doors/doormove1.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove1.wav" ); + pszSound = "doors/doormove1.wav"; break; case 2: - PRECACHE_SOUND( "doors/doormove2.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove2.wav" ); + pszSound = "doors/doormove2.wav"; break; case 3: - PRECACHE_SOUND( "doors/doormove3.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove3.wav" ); + pszSound = "doors/doormove3.wav"; break; case 4: - PRECACHE_SOUND( "doors/doormove4.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove4.wav" ); + pszSound = "doors/doormove4.wav"; break; case 5: - PRECACHE_SOUND( "doors/doormove5.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove5.wav" ); + pszSound = "doors/doormove5.wav"; break; case 6: - PRECACHE_SOUND( "doors/doormove6.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove6.wav" ); + pszSound = "doors/doormove6.wav"; break; case 7: - PRECACHE_SOUND( "doors/doormove7.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove7.wav" ); + pszSound = "doors/doormove7.wav"; break; case 8: - PRECACHE_SOUND( "doors/doormove8.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove8.wav" ); + pszSound = "doors/doormove8.wav"; break; + case 0: default: - pev->noiseMoving = ALLOC_STRING( "common/null.wav" ); + pszSound = "common/null.wav"; + NullSound = TRUE; break; } + if( !NullSound ) + PRECACHE_SOUND( pszSound ); + pev->noiseMoving = MAKE_STRING( pszSound ); + NullSound = FALSE; + // set the door's 'reached destination' stop sound switch( m_bStopSnd ) { - case 0: - pev->noiseArrived = ALLOC_STRING( "common/null.wav" ); - break; case 1: - PRECACHE_SOUND( "doors/doorstop1.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop1.wav" ); + pszSound = "doors/doorstop1.wav"; break; case 2: - PRECACHE_SOUND( "doors/doorstop2.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop2.wav" ); + pszSound = "doors/doorstop2.wav"; break; case 3: - PRECACHE_SOUND( "doors/doorstop3.wav" ); - pev->noiseArrived = ALLOC_STRING("doors/doorstop3.wav"); + pszSound = "doors/doorstop3.wav"; break; case 4: - PRECACHE_SOUND( "doors/doorstop4.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop4.wav" ); + pszSound = "doors/doorstop4.wav"; break; case 5: - PRECACHE_SOUND( "doors/doorstop5.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop5.wav" ); + pszSound = "doors/doorstop5.wav"; break; case 6: - PRECACHE_SOUND( "doors/doorstop6.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop6.wav" ); + pszSound = "doors/doorstop6.wav"; break; case 7: - PRECACHE_SOUND( "doors/doorstop7.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop7.wav" ); + pszSound = "doors/doorstop7.wav"; break; case 8: - PRECACHE_SOUND( "doors/doorstop8.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop8.wav" ); + pszSound = "doors/doorstop8.wav"; break; + case 0: default: - pev->noiseArrived = ALLOC_STRING( "common/null.wav" ); + pszSound = "common/null.wav"; + NullSound = TRUE; break; } + + if( !NullSound ) + PRECACHE_SOUND( pszSound ); + pev->noiseArrived = MAKE_STRING( pszSound ); } void CMomentaryDoor::KeyValue( KeyValueData *pkvd ) @@ -1106,7 +1068,7 @@ void CMomentaryDoor::KeyValue( KeyValueData *pkvd ) if( FStrEq( pkvd->szKeyName, "movesnd" ) ) { - m_bMoveSnd = atof( pkvd->szValue ); + m_bMoveSnd = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "stopsnd" ) ) @@ -1136,23 +1098,26 @@ void CMomentaryDoor::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP Vector move = m_vecPosition1 + ( value * ( m_vecPosition2 - m_vecPosition1 ) ); Vector delta = move - pev->origin; - float speed = delta.Length() * 10; + //float speed = delta.Length() * 10; + float speed = delta.Length() / 0.1; // 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 + // play the sound when it starts moving(not yet thinking) if( pev->nextthink < pev->ltime || pev->nextthink == 0 ) - EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ), 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ), 1, ATTN_NORM ); + // If we already moving to designated point, return + else if( move == m_vecFinalDest ) + return; LinearMove( move, speed ); SetMoveDone( &CMomentaryDoor::MomentaryMoveDone ); } - } void CMomentaryDoor::MomentaryMoveDone( void ) { - STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ) ); - EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseArrived ), 1, ATTN_NORM ); + STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ) ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseArrived ), 1, ATTN_NORM ); } diff --git a/dlls/doors.h b/dlls/doors.h index 7e89b497..fe2b5a85 100644 --- a/dlls/doors.h +++ b/dlls/doors.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef DOORS_H #define DOORS_H diff --git a/dlls/effects.cpp b/dlls/effects.cpp index cb8e5829..df590618 100644 --- a/dlls/effects.cpp +++ b/dlls/effects.cpp @@ -75,7 +75,7 @@ void CBubbling::Spawn( void ) pev->solid = SOLID_NOT; // Remove model & collisions pev->renderamt = 0; // The engine won't draw this model if this is set to 0 and blending is on pev->rendermode = kRenderTransTexture; - int speed = pev->speed > 0 ? pev->speed : -pev->speed; + int speed = fabs( pev->speed ); // HACKHACK!!! - Speed in rendercolor pev->rendercolor.x = speed >> 8; @@ -229,7 +229,7 @@ void CBeam::BeamInit( const char *pSpriteName, int width ) SetFrame( 0 ); SetScrollRate( 0 ); pev->model = MAKE_STRING( pSpriteName ); - SetTexture( PRECACHE_MODEL( (char *)pSpriteName ) ); + SetTexture( PRECACHE_MODEL( pSpriteName ) ); SetWidth( width ); pev->skin = 0; pev->sequence = 0; @@ -280,12 +280,12 @@ void CBeam::RelinkBeam( void ) { const Vector &startPos = GetStartPos(), &endPos = GetEndPos(); - pev->mins.x = min( startPos.x, endPos.x ); - pev->mins.y = min( startPos.y, endPos.y ); - pev->mins.z = min( startPos.z, endPos.z ); - pev->maxs.x = max( startPos.x, endPos.x ); - pev->maxs.y = max( startPos.y, endPos.y ); - pev->maxs.z = max( startPos.z, endPos.z ); + pev->mins.x = Q_min( startPos.x, endPos.x ); + pev->mins.y = Q_min( startPos.y, endPos.y ); + pev->mins.z = Q_min( startPos.z, endPos.z ); + pev->maxs.x = Q_max( startPos.x, endPos.x ); + pev->maxs.y = Q_max( startPos.y, endPos.y ); + pev->maxs.z = Q_max( startPos.z, endPos.z ); pev->mins = pev->mins - pev->origin; pev->maxs = pev->maxs - pev->origin; @@ -380,8 +380,8 @@ public: void BeamUpdateVars( void ); int m_active; - int m_iszStartEntity; - int m_iszEndEntity; + string_t m_iszStartEntity; + string_t m_iszEndEntity; float m_life; int m_boltWidth; int m_noiseAmplitude; @@ -389,7 +389,7 @@ public: int m_speed; float m_restrike; int m_spriteTexture; - int m_iszSpriteName; + string_t m_iszSpriteName; int m_frameStart; float m_radius; @@ -486,7 +486,7 @@ void CLightning::Spawn( void ) void CLightning::Precache( void ) { - m_spriteTexture = PRECACHE_MODEL( (char *)STRING( m_iszSpriteName ) ); + m_spriteTexture = PRECACHE_MODEL( STRING( m_iszSpriteName ) ); CBeam::Precache(); } @@ -701,7 +701,7 @@ void CLightning::StrikeThink( void ) WRITE_BYTE( (int)pev->rendercolor.x ); // r, g, b WRITE_BYTE( (int)pev->rendercolor.y ); // r, g, b WRITE_BYTE( (int)pev->rendercolor.z ); // r, g, b - WRITE_BYTE( pev->renderamt ); // brightness + WRITE_BYTE( (int)pev->renderamt ); // brightness WRITE_BYTE( m_speed ); // speed MESSAGE_END(); DoSparks( pStart->pev->origin, pEnd->pev->origin ); @@ -763,7 +763,7 @@ void CLightning::Zap( const Vector &vecSrc, const Vector &vecDest ) WRITE_BYTE( (int)pev->rendercolor.x ); // r, g, b WRITE_BYTE( (int)pev->rendercolor.y ); // r, g, b WRITE_BYTE( (int)pev->rendercolor.z ); // r, g, b - WRITE_BYTE( pev->renderamt ); // brightness + WRITE_BYTE( (int)pev->renderamt ); // brightness WRITE_BYTE( m_speed ); // speed MESSAGE_END(); #else @@ -944,7 +944,7 @@ void CLaser::Spawn( void ) m_pSprite = NULL; if( m_pSprite ) - m_pSprite->SetTransparency( kRenderGlow, pev->rendercolor.x, pev->rendercolor.y, pev->rendercolor.z, pev->renderamt, pev->renderfx ); + m_pSprite->SetTransparency( kRenderGlow, (int)pev->rendercolor.x, (int)pev->rendercolor.y, (int)pev->rendercolor.z, (int)pev->renderamt, (int)pev->renderfx ); if( pev->targetname && !( pev->spawnflags & SF_BEAM_STARTON ) ) TurnOff(); @@ -954,9 +954,9 @@ void CLaser::Spawn( void ) void CLaser::Precache( void ) { - pev->modelindex = PRECACHE_MODEL( (char *)STRING( pev->model ) ); + pev->modelindex = PRECACHE_MODEL( STRING( pev->model ) ); if( m_iszSpriteName ) - PRECACHE_MODEL( (char *)STRING( m_iszSpriteName ) ); + PRECACHE_MODEL( STRING( m_iszSpriteName ) ); } void CLaser::KeyValue( KeyValueData *pkvd ) @@ -1100,7 +1100,7 @@ void CGlow::Spawn( void ) pev->effects = 0; pev->frame = 0; - PRECACHE_MODEL( (char *)STRING( pev->model ) ); + PRECACHE_MODEL( STRING( pev->model ) ); SET_MODEL( ENT( pev ), STRING( pev->model ) ); m_maxFrame = (float) MODEL_FRAMES( pev->modelindex ) - 1; @@ -1160,7 +1160,7 @@ void CSprite::Spawn( void ) void CSprite::Precache( void ) { - PRECACHE_MODEL( (char *)STRING( pev->model ) ); + PRECACHE_MODEL( STRING( pev->model ) ); // Reset attachment after save/restore if( pev->aiment ) @@ -1515,7 +1515,7 @@ void CEnvShooter::KeyValue( KeyValueData *pkvd ) void CEnvShooter::Precache( void ) { - m_iGibModelIndex = PRECACHE_MODEL( (char *)STRING( pev->model ) ); + m_iGibModelIndex = PRECACHE_MODEL( STRING( pev->model ) ); CBreakable::MaterialSoundPrecache( (Materials)m_iGibMaterial ); } @@ -1619,7 +1619,7 @@ void CTestEffect::TestThink( void ) for( i = 0; i < m_iBeam; i++ ) { t = ( gpGlobals->time - m_flBeamTime[i] ) / ( 3 + m_flStartTime - m_flBeamTime[i] ); - m_pBeam[i]->SetBrightness( 255 * t ); + m_pBeam[i]->SetBrightness( (int)( 255 * t ) ); // m_pBeam[i]->SetScrollRate( 20 * t ); } pev->nextthink = gpGlobals->time + 0.1; @@ -1749,9 +1749,9 @@ Vector CBlood::BloodPosition( CBaseEntity *pActivator ) void CBlood::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { if( pev->spawnflags & SF_BLOOD_STREAM ) - UTIL_BloodStream( BloodPosition( pActivator ), Direction(), ( Color() == BLOOD_COLOR_RED ) ? 70 : Color(), BloodAmount() ); + UTIL_BloodStream( BloodPosition( pActivator ), Direction(), ( Color() == BLOOD_COLOR_RED ) ? 70 : Color(), (int)BloodAmount() ); else - UTIL_BloodDrips( BloodPosition( pActivator ), Direction(), Color(), BloodAmount() ); + UTIL_BloodDrips( BloodPosition( pActivator ), Direction(), Color(), (int)BloodAmount() ); if( pev->spawnflags & SF_BLOOD_DECAL ) { @@ -1947,12 +1947,12 @@ void CFade::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType { if( pActivator->IsNetClient() ) { - UTIL_ScreenFade( pActivator, pev->rendercolor, Duration(), HoldTime(), pev->renderamt, fadeFlags ); + UTIL_ScreenFade( pActivator, pev->rendercolor, Duration(), HoldTime(), (int)pev->renderamt, fadeFlags ); } } else { - UTIL_ScreenFadeAll( pev->rendercolor, Duration(), HoldTime(), pev->renderamt, fadeFlags ); + UTIL_ScreenFadeAll( pev->rendercolor, Duration(), HoldTime(), (int)pev->renderamt, fadeFlags ); } SUB_UseTargets( this, USE_TOGGLE, 0 ); } @@ -2005,7 +2005,7 @@ void CMessage::Spawn( void ) void CMessage::Precache( void ) { if( pev->noise ) - PRECACHE_SOUND( (char *)STRING( pev->noise ) ); + PRECACHE_SOUND( STRING( pev->noise ) ); } void CMessage::KeyValue( KeyValueData *pkvd ) @@ -2040,16 +2040,15 @@ void CMessage::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useT if( pActivator && pActivator->IsPlayer() ) pPlayer = pActivator; else - { pPlayer = CBaseEntity::Instance( g_engfuncs.pfnPEntityOfEntIndex( 1 ) ); - } + if( pPlayer ) UTIL_ShowMessage( STRING( pev->message ), pPlayer ); } + if( pev->noise ) - { EMIT_SOUND( edict(), CHAN_BODY, STRING( pev->noise ), pev->scale, pev->speed ); - } + if( pev->spawnflags & SF_MESSAGE_ONCE ) UTIL_Remove( this ); @@ -2071,7 +2070,7 @@ public: void CEnvFunnel::Precache( void ) { - m_iSprite = PRECACHE_MODEL ( "sprites/flare6.spr" ); + m_iSprite = PRECACHE_MODEL( "sprites/flare6.spr" ); } LINK_ENTITY_TO_CLASS( env_funnel, CEnvFunnel ) @@ -2182,6 +2181,8 @@ public: void CItemSoda::Precache( void ) { + PRECACHE_MODEL( "models/can.mdl" ); + PRECACHE_SOUND( "weapons/g_bounce3.wav" ); } LINK_ENTITY_TO_CLASS( item_sodacan, CItemSoda ) diff --git a/dlls/effects.h b/dlls/effects.h index 031b8273..5dd55209 100644 --- a/dlls/effects.h +++ b/dlls/effects.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef EFFECTS_H #define EFFECTS_H @@ -238,7 +239,7 @@ public: inline int GetWidth( void ) { - return pev->scale; + return (int)pev->scale; } inline int GetNoise( void ) @@ -255,17 +256,17 @@ public: inline int GetBrightness( void ) { - return pev->renderamt; + return (int)pev->renderamt; } inline int GetFrame( void ) { - return pev->frame; + return (int)pev->frame; } inline int GetScrollRate( void ) { - return pev->animtime; + return (int)pev->animtime; } // Call after you change start/end positions @@ -321,7 +322,7 @@ public: static TYPEDESCRIPTION m_SaveData[]; CSprite *m_pSprite; - int m_iszSpriteName; + string_t m_iszSpriteName; Vector m_firePosition; }; #endif //EFFECTS_H diff --git a/dlls/egon.cpp b/dlls/egon.cpp index 433704ce..b83c9086 100644 --- a/dlls/egon.cpp +++ b/dlls/egon.cpp @@ -143,7 +143,7 @@ float CEgon::GetDischargeInterval( void ) BOOL CEgon::HasAmmo( void ) { - if( m_pPlayer->ammo_uranium <= 0 ) + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) return FALSE; return TRUE; @@ -270,7 +270,7 @@ void CEgon::Fire( const Vector &vecOrigSrc, const Vector &vecDir ) } } #endif - float timedist; + float timedist = 0.0f; switch( m_fireMode ) { @@ -380,13 +380,13 @@ void CEgon::UpdateEffect( const Vector &startPoint, const Vector &endPoint, floa } m_pBeam->SetStartPos( endPoint ); - m_pBeam->SetBrightness( 255 - ( timeBlend * 180 ) ); - m_pBeam->SetWidth( 40 - ( timeBlend * 20 ) ); + m_pBeam->SetBrightness( (int)( 255 - ( timeBlend * 180 )) ); + m_pBeam->SetWidth( (int)( 40 - ( timeBlend * 20 ) ) ); if( m_fireMode == FIRE_WIDE ) - m_pBeam->SetColor( 30 + ( 25 * timeBlend ), 30 + ( 30 * timeBlend ), 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 ) ) ) ); else - m_pBeam->SetColor( 60 + ( 25 * timeBlend ), 120 + ( 30 * timeBlend ), 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 ) ) ) ); UTIL_SetOrigin( m_pSprite->pev, endPoint ); m_pSprite->pev->frame += 8 * gpGlobals->frametime; diff --git a/dlls/enginecallback.h b/dlls/enginecallback.h index 1c5ec1b2..a7e6a584 100644 --- a/dlls/enginecallback.h +++ b/dlls/enginecallback.h @@ -14,10 +14,14 @@ ****/ #ifndef ENGINECALLBACK_H #define ENGINECALLBACK_H + #pragma once #include "event_flags.h" +// Fix warning in MSVC8 +#undef SERVER_EXECUTE + // Must be provided by user of this code extern enginefuncs_t g_engfuncs; @@ -156,5 +160,6 @@ inline void *GET_PRIVATE( edict_t *pent ) #define ENGINE_FORCE_UNMODIFIED ( *g_engfuncs.pfnForceUnmodified ) #define PLAYER_CNX_STATS ( *g_engfuncs.pfnGetPlayerStats ) +#define SET_CLIENT_MAX_SPEED ( *g_engfuncs.pfnSetClientMaxspeed ) #endif //ENGINECALLBACK_H diff --git a/dlls/explode.h b/dlls/explode.h index d9745db5..162a61b3 100644 --- a/dlls/explode.h +++ b/dlls/explode.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef EXPLODE_H #define EXPLODE_H @@ -28,4 +29,4 @@ extern DLL_GLOBAL short g_sModelIndexSmoke; extern DLL_GLOBAL short g_sModelIndexShockwave; extern void ExplosionCreate( const Vector ¢er, const Vector &angles, edict_t *pOwner, int magnitude, BOOL doDamage ); -#endif //EXPLODE_H +#endif // EXPLODE_H diff --git a/dlls/exportdef.h b/dlls/exportdef.h index 995613ff..363d8d12 100644 --- a/dlls/exportdef.h +++ b/dlls/exportdef.h @@ -1,3 +1,4 @@ +#pragma once #ifndef EXPORTDEF_H #define EXPORTDEF_H #if defined _WIN32 || defined __CYGWIN__ diff --git a/dlls/extdll.h b/dlls/extdll.h index cbc7ebb9..d6ea4888 100644 --- a/dlls/extdll.h +++ b/dlls/extdll.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef EXTDLL_H #define EXTDLL_H @@ -25,11 +26,13 @@ #endif // Silence certain warnings +#ifdef _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 #pragma warning(disable : 4514) // unreferenced inline function removed #pragma warning(disable : 4100) // unreferenced formal parameter +#endif // Prevent tons of unused windows definitions #ifdef _WIN32 @@ -42,9 +45,13 @@ #include "windows.h" #undef HSPRITE #else // _WIN32 +#ifndef FALSE #define FALSE 0 +#endif +#ifndef TRUE #define TRUE (!FALSE) -typedef unsigned long ULONG; +#endif +typedef unsigned int ULONG; typedef unsigned char BYTE; typedef int BOOL; #define MAX_PATH PATH_MAX @@ -57,9 +64,13 @@ typedef int BOOL; #include "stdlib.h" #include "math.h" +#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 +#endif + // Header file containing definition of globalvars_t and entvars_t typedef unsigned int func_t; -typedef unsigned int string_t; // from engine's pr_comp.h; +typedef int string_t; // from engine's pr_comp.h; typedef float vec_t; // needed before including progdefs.h // Vector class @@ -78,11 +89,11 @@ typedef float vec_t; // needed before including progdefs.h // Shared header between the client DLL and the game DLLs #include "cdll_dll.h" -#ifndef min -#define min(a,b) (((a) < (b)) ? (a) : (b)) +#ifndef Q_min +#define Q_min(a,b) (((a) < (b)) ? (a) : (b)) #endif -#ifndef max -#define max(a,b) (((a) > (b)) ? (a) : (b)) +#ifndef Q_max +#define Q_max(a,b) (((a) > (b)) ? (a) : (b)) #endif #endif //EXTDLL_H diff --git a/dlls/flyingmonster.h b/dlls/flyingmonster.h index 4dd87fb4..31ff4e33 100644 --- a/dlls/flyingmonster.h +++ b/dlls/flyingmonster.h @@ -13,7 +13,7 @@ * ****/ // Base class for flying monsters. This overrides the movement test & execution code from CBaseMonster - +#pragma once #ifndef FLYINGMONSTER_H #define FLYINGMONSTER_H diff --git a/dlls/func_break.cpp b/dlls/func_break.cpp index 105add3c..f88b6096 100644 --- a/dlls/func_break.cpp +++ b/dlls/func_break.cpp @@ -104,7 +104,7 @@ void CBreakable::KeyValue( KeyValueData* pkvd ) else if( FStrEq( pkvd->szKeyName, "spawnobject" ) ) { int object = atoi( pkvd->szValue ); - if( object > 0 && object < ARRAYSIZE( pSpawnObjects ) ) + if( object > 0 && object < (int)ARRAYSIZE( pSpawnObjects ) ) m_iszSpawnObject = MAKE_STRING( pSpawnObjects[object] ); pkvd->fHandled = TRUE; } @@ -259,7 +259,7 @@ void CBreakable::MaterialSoundPrecache( Materials precacheMaterial ) for( i = 0; i < soundCount; i++ ) { - PRECACHE_SOUND( (char *)pSoundList[i] ); + PRECACHE_SOUND( pSoundList[i] ); } } @@ -340,11 +340,11 @@ void CBreakable::Precache( void ) if( m_iszGibModel ) pGibName = STRING( m_iszGibModel ); - m_idShard = PRECACHE_MODEL( (char *)pGibName ); + m_idShard = PRECACHE_MODEL( pGibName ); // Precache the spawn item's data if( m_iszSpawnObject ) - UTIL_PrecacheOther( (char *)STRING( m_iszSpawnObject ) ); + UTIL_PrecacheOther( STRING( m_iszSpawnObject ) ); } // play shard sound when func_breakable takes damage. @@ -353,7 +353,7 @@ void CBreakable::DamageSound( void ) { int pitch; float fvol; - char *rgpsz[6]; + const char *rgpsz[6]; int i = 0; int material = m_Material; @@ -574,7 +574,6 @@ void CBreakable::Die( void ) { Vector vecSpot;// shard origin Vector vecVelocity;// shard velocity - CBaseEntity *pEntity = NULL; char cFlag = 0; int pitch; float fvol; @@ -747,7 +746,7 @@ void CBreakable::Die( void ) SetThink( &CBaseEntity::SUB_Remove ); pev->nextthink = pev->ltime + 0.1; if( m_iszSpawnObject ) - CBaseEntity::Create( (char *)STRING( m_iszSpawnObject ), VecBModelOrigin( pev ), pev->angles, edict() ); + CBaseEntity::Create( STRING( m_iszSpawnObject ), VecBModelOrigin( pev ), pev->angles, edict() ); if( Explodable() ) { @@ -794,7 +793,7 @@ public: static TYPEDESCRIPTION m_SaveData[]; - static char *m_soundNames[3]; + static const char *m_soundNames[3]; int m_lastSound; // no need to save/restore, just keeps the same sound from playing twice in a row float m_maxSpeed; float m_soundTime; @@ -810,7 +809,7 @@ IMPLEMENT_SAVERESTORE( CPushable, CBreakable ) LINK_ENTITY_TO_CLASS( func_pushable, CPushable ) -char *CPushable::m_soundNames[3] = +const char *CPushable::m_soundNames[3] = { "debris/pushbox1.wav", "debris/pushbox2.wav", @@ -839,7 +838,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 = ( 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.0005 ); m_soundTime = 0; } @@ -882,7 +881,7 @@ void CPushable::KeyValue( KeyValueData *pkvd ) } else if( FStrEq( pkvd->szKeyName, "buoyancy" ) ) { - pev->skin = atof( pkvd->szValue ); + pev->skin = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else diff --git a/dlls/func_break.h b/dlls/func_break.h index ab5dda41..89c9f54e 100644 --- a/dlls/func_break.h +++ b/dlls/func_break.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef FUNC_BREAK_H #define FUNC_BREAK_H @@ -84,7 +85,7 @@ public: Explosions m_Explosion; int m_idShard; float m_angle; - int m_iszGibModel; - int m_iszSpawnObject; + string_t m_iszGibModel; + string_t m_iszSpawnObject; }; #endif // FUNC_BREAK_H diff --git a/dlls/func_tank.cpp b/dlls/func_tank.cpp index eab9e621..cbc7f5b1 100644 --- a/dlls/func_tank.cpp +++ b/dlls/func_tank.cpp @@ -93,6 +93,7 @@ public: BOOL StartControl( CBasePlayer* pController ); void StopControl( void ); void ControllerPostFrame( void ); + virtual void StopFire( void ){} protected: CBasePlayer* m_pController; @@ -119,14 +120,15 @@ protected: Vector m_barrelPos; // Length of the freakin barrel float m_spriteScale; // Scale of any sprites we shoot - int m_iszSpriteSmoke; - int m_iszSpriteFlash; + string_t m_iszSpriteSmoke; + string_t m_iszSpriteFlash; TANKBULLET m_bulletType; // Bullet type int m_iBulletDamage; // 0 means use Bullet type's default damage Vector m_sightOrigin; // Last sight of target int m_spread; // firing spread - int m_iszMaster; // Master entity (game_team_master or multisource) + string_t m_iszMaster; // Master entity (game_team_master or multisource) + int m_iControllerHUDFlags; }; TYPEDESCRIPTION CFuncTank::m_SaveData[] = @@ -157,6 +159,7 @@ TYPEDESCRIPTION CFuncTank::m_SaveData[] = DEFINE_FIELD( CFuncTank, m_flNextAttack, FIELD_TIME ), DEFINE_FIELD( CFuncTank, m_iBulletDamage, FIELD_INTEGER ), DEFINE_FIELD( CFuncTank, m_iszMaster, FIELD_STRING ), + DEFINE_FIELD( CFuncTank, m_iControllerHUDFlags, FIELD_INTEGER ), }; IMPLEMENT_SAVERESTORE( CFuncTank, CBaseEntity ) @@ -190,7 +193,7 @@ void CFuncTank::Spawn( void ) if( m_fireRate <= 0 ) m_fireRate = 1; - if( m_spread > MAX_FIRING_SPREADS ) + if( m_spread > (int)MAX_FIRING_SPREADS ) m_spread = 0; pev->oldorigin = pev->origin; @@ -199,13 +202,13 @@ void CFuncTank::Spawn( void ) void CFuncTank::Precache( void ) { if( m_iszSpriteSmoke ) - PRECACHE_MODEL( (char *)STRING( m_iszSpriteSmoke ) ); + PRECACHE_MODEL( STRING( m_iszSpriteSmoke ) ); if( m_iszSpriteFlash ) - PRECACHE_MODEL( (char *)STRING( m_iszSpriteFlash ) ); + PRECACHE_MODEL( STRING( m_iszSpriteFlash ) ); if( pev->noise ) - PRECACHE_SOUND( (char *)STRING( pev->noise ) ); + PRECACHE_SOUND( STRING( pev->noise ) ); } void CFuncTank::KeyValue( KeyValueData *pkvd ) @@ -328,7 +331,7 @@ BOOL CFuncTank::OnControls( entvars_t *pevTest ) if( !( pev->spawnflags & SF_TANK_CANCONTROL ) ) return FALSE; - Vector offset = pevTest->origin - pev->origin; + //Vector offset = pevTest->origin - pev->origin; if( ( m_vecControllerUsePos - pevTest->origin ).Length() < 30 ) return TRUE; @@ -351,6 +354,7 @@ BOOL CFuncTank::StartControl( CBasePlayer *pController ) ALERT( at_console, "using TANK!\n"); m_pController = pController; + m_pController->m_pTank = this; if( m_pController->m_pActiveItem ) { m_pController->m_pActiveItem->Holster(); @@ -358,6 +362,7 @@ BOOL CFuncTank::StartControl( CBasePlayer *pController ) m_pController->pev->viewmodel = 0; } + m_iControllerHUDFlags = m_pController->m_iHideHUD; m_pController->m_iHideHUD |= HIDEHUD_WEAPONS; m_vecControllerUsePos = m_pController->pev->origin; @@ -368,6 +373,8 @@ BOOL CFuncTank::StartControl( CBasePlayer *pController ) void CFuncTank::StopControl() { + StopFire(); + // TODO: bring back the controllers current weapon if( !m_pController ) return; @@ -377,9 +384,11 @@ void CFuncTank::StopControl() ALERT( at_console, "stopped using TANK\n"); - m_pController->m_iHideHUD &= ~HIDEHUD_WEAPONS; + m_pController->m_iHideHUD = m_iControllerHUDFlags; pev->nextthink = 0; + + m_pController->m_pTank = NULL; m_pController = NULL; if( IsActive() ) @@ -426,7 +435,6 @@ void CFuncTank::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE use } else if( !m_pController && useType != USE_OFF ) { - ( (CBasePlayer*)pActivator )->m_pTank = this; StartControl( (CBasePlayer*)pActivator ); } else @@ -476,9 +484,9 @@ void CFuncTank::TrackTarget( void ) { TraceResult tr; edict_t *pPlayer = FIND_CLIENT_IN_PVS( edict() ); - BOOL updateTime = FALSE, lineOfSight; + BOOL updateTime = FALSE; Vector angles, direction, targetPosition, barrelEnd; - edict_t *pTarget; + edict_t *pTarget = NULL; // Get a position to aim for if( m_pController ) @@ -515,12 +523,8 @@ void CFuncTank::TrackTarget( void ) UTIL_TraceLine( barrelEnd, targetPosition, dont_ignore_monsters, edict(), &tr ); - lineOfSight = FALSE; - // No line of sight, don't track if( tr.flFraction == 1.0 || tr.pHit == pTarget ) { - lineOfSight = TRUE; - CBaseEntity *pInstance = CBaseEntity::Instance(pTarget); if( InRange( range ) && pInstance && pInstance->IsAlive() ) { @@ -644,7 +648,7 @@ void CFuncTank::Fire( const Vector &barrelEnd, const Vector &forward, entvars_t { CSprite *pSprite = CSprite::SpriteCreate( STRING( m_iszSpriteSmoke ), barrelEnd, TRUE ); pSprite->AnimateAndDie( RANDOM_FLOAT( 15.0, 20.0 ) ); - pSprite->SetTransparency( kRenderTransAlpha, pev->rendercolor.x, pev->rendercolor.y, pev->rendercolor.z, 255, kRenderFxNone ); + 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->SetScale( m_spriteScale ); } @@ -687,13 +691,13 @@ void CFuncTank::StartRotSound( void ) if( !pev->noise || ( pev->spawnflags & SF_TANK_SOUNDON ) ) return; pev->spawnflags |= SF_TANK_SOUNDON; - EMIT_SOUND( edict(), CHAN_STATIC, (char*)STRING( pev->noise ), 0.85, ATTN_NORM ); + EMIT_SOUND( edict(), CHAN_STATIC, STRING( pev->noise ), 0.85, ATTN_NORM ); } void CFuncTank::StopRotSound( void ) { if( pev->spawnflags & SF_TANK_SOUNDON ) - STOP_SOUND( edict(), CHAN_STATIC, (char*)STRING( pev->noise ) ); + STOP_SOUND( edict(), CHAN_STATIC, STRING( pev->noise ) ); pev->spawnflags &= ~SF_TANK_SOUNDON; } @@ -714,7 +718,7 @@ void CFuncTankGun::Fire( const Vector &barrelEnd, const Vector &forward, entvars // FireBullets needs gpGlobals->v_up, etc. UTIL_MakeAimVectors( pev->angles ); - int bulletCount = ( gpGlobals->time - m_fireLast ) * m_fireRate; + int bulletCount = (int)( ( gpGlobals->time - m_fireLast ) * m_fireRate ); if( bulletCount > 0 ) { for( i = 0; i < bulletCount; i++ ) @@ -754,6 +758,7 @@ public: virtual int Save( CSave &save ); virtual int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; + virtual void StopFire( void ); private: CLaser *m_pLaser; @@ -835,7 +840,7 @@ void CFuncTankLaser::Fire( const Vector &barrelEnd, const Vector &forward, entva // TankTrace needs gpGlobals->v_up, etc. UTIL_MakeAimVectors( pev->angles ); - int bulletCount = ( gpGlobals->time - m_fireLast ) * m_fireRate; + int bulletCount = (int)( ( gpGlobals->time - m_fireLast ) * m_fireRate ); if( bulletCount ) { for( i = 0; i < bulletCount; i++ ) @@ -858,6 +863,12 @@ void CFuncTankLaser::Fire( const Vector &barrelEnd, const Vector &forward, entva } } +void CFuncTankLaser::StopFire( void ) +{ + if( m_pLaser ) + m_pLaser->TurnOff(); +} + class CFuncTankRocket : public CFuncTank { public: @@ -879,12 +890,12 @@ void CFuncTankRocket::Fire( const Vector &barrelEnd, const Vector &forward, entv if( m_fireLast != 0 ) { - int bulletCount = ( gpGlobals->time - m_fireLast ) * m_fireRate; + int bulletCount = (int)( ( gpGlobals->time - m_fireLast ) * m_fireRate ); if( bulletCount > 0 ) { for( i = 0; i < bulletCount; i++ ) { - CBaseEntity *pRocket = CBaseEntity::Create( "rpg_rocket", barrelEnd, pev->angles, edict() ); + CBaseEntity::Create( "rpg_rocket", barrelEnd, pev->angles, edict() ); } CFuncTank::Fire( barrelEnd, forward, pev ); } @@ -917,7 +928,7 @@ void CFuncTankMortar::Fire( const Vector &barrelEnd, const Vector &forward, entv { if( m_fireLast != 0 ) { - int bulletCount = ( gpGlobals->time - m_fireLast ) * m_fireRate; + int bulletCount = (int)( ( gpGlobals->time - m_fireLast ) * m_fireRate ); // Only create 1 explosion if( bulletCount > 0 ) { diff --git a/dlls/game.cpp b/dlls/game.cpp index b31f4657..5ab739f4 100644 --- a/dlls/game.cpp +++ b/dlls/game.cpp @@ -25,11 +25,13 @@ cvar_t timeleft = { "mp_timeleft","0" , FCVAR_SERVER | FCVAR_UNLOGGED }; // " // multiplayer server rules cvar_t teamplay = { "mp_teamplay","0", FCVAR_SERVER }; -cvar_t fraglimit = {"mp_fraglimit","0", FCVAR_SERVER }; +cvar_t fraglimit = { "mp_fraglimit","0", FCVAR_SERVER }; 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 satchelfix = { "mp_satchelfix", "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 }; @@ -38,6 +40,9 @@ cvar_t teamlist = { "mp_teamlist","hgrunt;scientist", FCVAR_SERVER }; cvar_t teamoverride = { "mp_teamoverride","1" }; cvar_t defaultteam = { "mp_defaultteam","0" }; cvar_t allowmonsters = { "mp_allowmonsters","0", FCVAR_SERVER }; +cvar_t bhopcap = { "mp_bhopcap", "1", FCVAR_SERVER }; + +cvar_t allow_spectators = { "allow_spectators", "0", FCVAR_SERVER }; // 0 prevents players from being spectators cvar_t mp_chattime = { "mp_chattime","10", FCVAR_SERVER }; @@ -456,16 +461,6 @@ cvar_t sk_player_leg1 = { "sk_player_leg1","1" }; cvar_t sk_player_leg2 = { "sk_player_leg2","1" }; cvar_t sk_player_leg3 = { "sk_player_leg3","1" }; -// Nails -cvar_t sk_plr_nail1 = { "sk_plr_nail1", "0" }; -cvar_t sk_plr_nail2 = { "sk_plr_nail2", "0" }; -cvar_t sk_plr_nail3 = { "sk_plr_nail3", "0" }; - -// Par21 Round -cvar_t sk_plr_par21_bullet1 = { "sk_plr_par21_bullet1", "0" }; -cvar_t sk_plr_par21_bullet2 = { "sk_plr_par21_bullet2", "0" }; -cvar_t sk_plr_par21_bullet3 = { "sk_plr_par21_bullet3", "0" }; - // END Cvars for Skill Level settings // Register your console variables here @@ -479,6 +474,7 @@ void GameDLLInit( void ) g_footsteps = CVAR_GET_POINTER( "mp_footsteps" ); CVAR_REGISTER( &displaysoundlist ); + CVAR_REGISTER( &allow_spectators ); CVAR_REGISTER( &teamplay ); CVAR_REGISTER( &fraglimit ); @@ -490,6 +486,8 @@ void GameDLLInit( void ) CVAR_REGISTER( &friendlyfire ); CVAR_REGISTER( &falldamage ); CVAR_REGISTER( &weaponstay ); + CVAR_REGISTER( &selfgauss ); + CVAR_REGISTER( &satchelfix ); CVAR_REGISTER( &forcerespawn ); CVAR_REGISTER( &flashlight ); CVAR_REGISTER( &aimcrosshair ); @@ -498,6 +496,7 @@ void GameDLLInit( void ) CVAR_REGISTER( &teamoverride ); CVAR_REGISTER( &defaultteam ); CVAR_REGISTER( &allowmonsters ); + CVAR_REGISTER( &bhopcap ); CVAR_REGISTER( &mp_chattime ); @@ -891,18 +890,10 @@ void GameDLLInit( void ) CVAR_REGISTER( &sk_player_leg2 ); CVAR_REGISTER( &sk_player_leg3 ); - // Nails - CVAR_REGISTER( &sk_plr_nail1 ); - CVAR_REGISTER( &sk_plr_nail2 ); - CVAR_REGISTER( &sk_plr_nail3 ); - - // Par21 Round - CVAR_REGISTER( &sk_plr_par21_bullet1 ); - CVAR_REGISTER( &sk_plr_par21_bullet2 ); - CVAR_REGISTER( &sk_plr_par21_bullet3 ); - // END REGISTER CVARS FOR SKILL LEVEL STUFF SERVER_COMMAND( "exec skill.cfg\n" ); + + SOUNDTRACKLIST_Init(); } diff --git a/dlls/game.h b/dlls/game.h index 925010f3..0dc5ba87 100644 --- a/dlls/game.h +++ b/dlls/game.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef GAME_H #define GAME_H @@ -27,6 +27,8 @@ extern cvar_t timelimit; extern cvar_t friendlyfire; extern cvar_t falldamage; extern cvar_t weaponstay; +extern cvar_t selfgauss; +extern cvar_t satchelfix; extern cvar_t forcerespawn; extern cvar_t flashlight; extern cvar_t aimcrosshair; diff --git a/dlls/gamerules.cpp b/dlls/gamerules.cpp index 3db845e0..cd42c5ea 100644 --- a/dlls/gamerules.cpp +++ b/dlls/gamerules.cpp @@ -307,12 +307,6 @@ void CGameRules::RefreshSkillData ( void ) gSkillData.plrStomach = GetSkillCvar( "sk_player_stomach" ); gSkillData.plrLeg = GetSkillCvar( "sk_player_leg" ); gSkillData.plrArm = GetSkillCvar( "sk_player_arm" ); - - // Nails - gSkillData.plrDmgNail = GetSkillCvar( "sk_plr_nail" ); - - // Par21 - gSkillData.plrDmgPar21 = GetSkillCvar( "sk_9mmAR_bullet" ); } //========================================================= diff --git a/dlls/gamerules.h b/dlls/gamerules.h index 6ad470d0..e34414cd 100644 --- a/dlls/gamerules.h +++ b/dlls/gamerules.h @@ -15,7 +15,9 @@ //========================================================= // GameRules //========================================================= - +#pragma once +#ifndef GAMERULES_H +#define GAMERULES_H //#include "weapons.h" //#include "items.h" class CBasePlayerItem; @@ -74,7 +76,7 @@ public: virtual BOOL IsDeathmatch( void ) = 0;//is this a deathmatch game? virtual BOOL IsTeamplay( void ) { return FALSE; };// is this deathmatch game being played with team rules? virtual BOOL IsCoOp( void ) = 0;// is this a coop game? - virtual const char *GetGameDescription( void ) { return "Half-Life"; } // this is the game name that gets seen in the server browser + virtual const char *GetGameDescription( void ) { return "Poke646"; } // this is the game name that gets seen in the server browser // Client connection/disconnection virtual BOOL ClientConnected( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128] ) = 0;// a client just connected to the server (player hasn't spawned yet) @@ -361,3 +363,4 @@ protected: }; extern DLL_GLOBAL CGameRules *g_pGameRules; +#endif // GAMERULES_H diff --git a/dlls/gargantua.cpp b/dlls/gargantua.cpp index 6c65b06f..f3155d7f 100644 --- a/dlls/gargantua.cpp +++ b/dlls/gargantua.cpp @@ -200,6 +200,7 @@ class CGargantua : public CBaseMonster public: void Spawn( void ); void Precache( void ); + void UpdateOnRemove(); void SetYawSpeed( void ); int Classify( void ); int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); @@ -538,7 +539,6 @@ void CGargantua::FlameControls( float angleX, float angleY ) void CGargantua::FlameUpdate( void ) { int i; - static float offset[2] = { 60, -60 }; TraceResult trace; Vector vecStart, angleGun; BOOL streaks = FALSE; @@ -759,7 +759,7 @@ void CGargantua::Spawn() //========================================================= void CGargantua::Precache() { - int i; + size_t i; PRECACHE_MODEL( "models/garg.mdl" ); PRECACHE_MODEL( GARG_EYE_SPRITE_NAME ); @@ -770,39 +770,52 @@ void CGargantua::Precache() PRECACHE_SOUND( GARG_STOMP_BUZZ_SOUND ); for( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackHitSounds[i] ); + PRECACHE_SOUND( pAttackHitSounds[i] ); for( i = 0; i < ARRAYSIZE( pBeamAttackSounds ); i++ ) - PRECACHE_SOUND( (char *)pBeamAttackSounds[i] ); + PRECACHE_SOUND( pBeamAttackSounds[i] ); for( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackMissSounds[i] ); + PRECACHE_SOUND( pAttackMissSounds[i] ); for( i = 0; i < ARRAYSIZE( pRicSounds ); i++ ) - PRECACHE_SOUND( (char *)pRicSounds[i] ); + PRECACHE_SOUND( pRicSounds[i] ); for( i = 0; i < ARRAYSIZE( pFootSounds ); i++ ) - PRECACHE_SOUND( (char *)pFootSounds[i] ); + PRECACHE_SOUND( pFootSounds[i] ); for( i = 0; i < ARRAYSIZE( pIdleSounds ); i++ ) - PRECACHE_SOUND( (char *)pIdleSounds[i] ); + PRECACHE_SOUND( pIdleSounds[i] ); for( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) - PRECACHE_SOUND((char *)pAlertSounds[i]); + PRECACHE_SOUND( pAlertSounds[i] ); for( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) - PRECACHE_SOUND( (char *)pPainSounds[i] ); + PRECACHE_SOUND( pPainSounds[i] ); for( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackSounds[i] ); + PRECACHE_SOUND( pAttackSounds[i] ); for( i = 0; i < ARRAYSIZE( pStompSounds ); i++ ) - PRECACHE_SOUND( (char *)pStompSounds[i] ); + PRECACHE_SOUND( pStompSounds[i] ); for( i = 0; i < ARRAYSIZE( pBreatheSounds ); i++ ) - PRECACHE_SOUND( (char *)pBreatheSounds[i] ); + PRECACHE_SOUND( pBreatheSounds[i] ); } +void CGargantua::UpdateOnRemove() +{ + CBaseEntity::UpdateOnRemove(); + + if( m_pEyeGlow ) + { + UTIL_Remove( m_pEyeGlow ); + m_pEyeGlow = 0; + } + + FlameDestroy(); +} + void CGargantua::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ) { ALERT( at_aiconsole, "CGargantua::TraceAttack\n" ); diff --git a/dlls/gauss.cpp b/dlls/gauss.cpp index 14aac39b..34a514b6 100644 --- a/dlls/gauss.cpp +++ b/dlls/gauss.cpp @@ -24,26 +24,29 @@ #include "soundent.h" #include "shake.h" #include "gamerules.h" +#include "game.h" +#include "xsbeam.h" -#define GAUSS_PRIMARY_CHARGE_VOLUME 256// how loud gauss is while charging -#define GAUSS_PRIMARY_FIRE_VOLUME 450// how loud gauss is when discharged +#define XS_PRIMARY_CHARGE_VOLUME 256// how loud xen squasher is while charging +#define XS_PRIMARY_FIRE_VOLUME 450// how loud xen squasher is when discharged -enum gauss_e +enum xs_e { - GAUSS_IDLE = 0, - GAUSS_IDLE2, - GAUSS_FIDGET, - GAUSS_SPINUP, - GAUSS_SPIN, - GAUSS_FIRE, - GAUSS_FIRE2, - GAUSS_HOLSTER, - GAUSS_DRAW + XS_IDLE = 0, + XS_IDLE2, + XS_FIDGET, + XS_SPINUP, + XS_SPIN, + XS_FIRE, + XS_FIRE2, + XS_HOLSTER, + XS_DRAW, + XS_RELOAD }; -LINK_ENTITY_TO_CLASS( weapon_gauss, CGauss ) +LINK_ENTITY_TO_CLASS( weapon_xs, CXS ) -float CGauss::GetFullChargeTime( void ) +float CXS::GetFullChargeTime( void ) { #ifdef CLIENT_DLL if( bIsMultiplayer() ) @@ -57,44 +60,42 @@ float CGauss::GetFullChargeTime( void ) return 4; } -#ifdef CLIENT_DLL -extern int g_irunninggausspred; -#endif -void CGauss::Spawn() +void CXS::Spawn() { Precache(); - m_iId = WEAPON_GAUSS; - SET_MODEL( ENT( pev ), "models/w_gauss.mdl" ); + m_iId = WEAPON_XS; + SET_MODEL( ENT( pev ), "models/w_xs.mdl" ); - m_iDefaultAmmo = GAUSS_DEFAULT_GIVE; + m_iDefaultAmmo = XS_DEFAULT_GIVE; FallInit();// get ready to fall down. + pev->sequence = 0; + pev->animtime = gpGlobals->time; + pev->framerate = 1; } -void CGauss::Precache( void ) +void CXS::Precache( void ) { - PRECACHE_MODEL( "models/w_gauss.mdl" ); - PRECACHE_MODEL( "models/v_gauss.mdl" ); + PRECACHE_MODEL( "models/w_xs.mdl" ); + PRECACHE_MODEL( "models/v_xs.mdl" ); PRECACHE_MODEL( "models/p_gauss.mdl" ); PRECACHE_SOUND( "items/9mmclip1.wav" ); - PRECACHE_SOUND( "weapons/gauss2.wav" ); - PRECACHE_SOUND( "weapons/electro4.wav" ); - PRECACHE_SOUND( "weapons/electro5.wav" ); - PRECACHE_SOUND( "weapons/electro6.wav" ); - PRECACHE_SOUND( "ambience/pulsemachine.wav" ); + PRECACHE_SOUND( "weapons/xs_shot.wav" ); + PRECACHE_SOUND( "weapons/xs_moan1.wav" ); + PRECACHE_SOUND( "weapons/xs_moan2.wav" ); + PRECACHE_SOUND( "weapons/xs_moan3.wav" ); + PRECACHE_SOUND( "weapons/xs_windup.wav" ); + PRECACHE_SOUND( "weapons/xs_reload.wav" ); - m_iGlow = PRECACHE_MODEL( "sprites/hotglow.spr" ); - m_iBalls = PRECACHE_MODEL( "sprites/hotglow.spr" ); - m_iBeam = PRECACHE_MODEL( "sprites/smoke.spr" ); + m_usXSSpin = PRECACHE_EVENT( 1, "events/xsspin.sc" ); - m_usGaussFire = PRECACHE_EVENT( 1, "events/gauss.sc" ); - m_usGaussSpin = PRECACHE_EVENT( 1, "events/gaussspin.sc" ); + UTIL_PrecacheOther( "xs_beam" ); } -int CGauss::AddToPlayer( CBasePlayer *pPlayer ) +int CXS::AddToPlayer( CBasePlayer *pPlayer ) { if( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) { @@ -106,76 +107,80 @@ int CGauss::AddToPlayer( CBasePlayer *pPlayer ) return FALSE; } -int CGauss::GetItemInfo( ItemInfo *p ) +int CXS::GetItemInfo( ItemInfo *p ) { p->pszName = STRING( pev->classname ); p->pszAmmo1 = "uranium"; p->iMaxAmmo1 = URANIUM_MAX_CARRY; p->pszAmmo2 = NULL; p->iMaxAmmo2 = -1; - p->iMaxClip = WEAPON_NOCLIP; + p->iMaxClip = XS_MAX_CLIP; p->iSlot = 3; - p->iPosition = 1; - p->iId = m_iId = WEAPON_GAUSS; + p->iPosition = 0; + p->iId = m_iId = WEAPON_XS; p->iFlags = 0; - p->iWeight = GAUSS_WEIGHT; + p->iWeight = XS_WEIGHT; return 1; } -BOOL CGauss::Deploy() +BOOL CXS::IsUseable() { - m_pPlayer->m_flPlayAftershock = 0.0; - return DefaultDeploy( "models/v_gauss.mdl", "models/p_gauss.mdl", GAUSS_DRAW, "gauss" ); + // Currently charging, allow the player to fire it first. - Solokiller + return CBasePlayerWeapon::IsUseable() || m_fInAttack != 0; } -void CGauss::Holster( int skiplocal /* = 0 */ ) +BOOL CXS::Deploy() { - PLAYBACK_EVENT_FULL( FEV_RELIABLE | FEV_GLOBAL, m_pPlayer->edict(), m_usGaussFire, 0.01, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, 0.0, 0.0, 0, 0, 0, 1 ); + return DefaultDeploy( "models/v_xs.mdl", "models/p_gauss.mdl", XS_DRAW, "gauss" ); +} +void CXS::Holster( int skiplocal /* = 0 */ ) +{ m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; - SendWeaponAnim( GAUSS_HOLSTER ); + SendWeaponAnim( XS_HOLSTER ); m_fInAttack = 0; + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM ); } -void CGauss::PrimaryAttack() +void CXS::PrimaryAttack() { // don't fire underwater if( m_pPlayer->pev->waterlevel == 3 ) { PlayEmptySound(); - m_flNextSecondaryAttack = m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15; + m_flNextSecondaryAttack = m_flNextPrimaryAttack = GetNextAttackDelay( 0.15 ); return; } - if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] < 2 ) + if( m_iClip <= 0 ) { PlayEmptySound(); m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; return; } - m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_FIRE_VOLUME; + m_pPlayer->m_iWeaponVolume = XS_PRIMARY_FIRE_VOLUME; m_fPrimaryFire = TRUE; - m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= 2; + --m_iClip; StartFire(); m_fInAttack = 0; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.2; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.2; + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.4; } -void CGauss::SecondaryAttack() +void CXS::SecondaryAttack() { // don't fire underwater if( m_pPlayer->pev->waterlevel == 3 ) { if( m_fInAttack != 0 ) { - EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/electro4.wav", 1.0, ATTN_NORM, 0, 80 + RANDOM_LONG( 0, 0x3f ) ); - SendWeaponAnim( GAUSS_IDLE ); + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/xs_moan1.wav", 1.0, ATTN_NORM, 0, 80 + RANDOM_LONG( 0, 0x3f ) ); + SendWeaponAnim( XS_IDLE ); m_fInAttack = 0; } else @@ -183,13 +188,13 @@ void CGauss::SecondaryAttack() PlayEmptySound(); } - m_flNextSecondaryAttack = m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; + m_flNextSecondaryAttack = m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); return; } if( m_fInAttack == 0 ) { - if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) + if( m_iClip <= 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; @@ -198,19 +203,19 @@ void CGauss::SecondaryAttack() m_fPrimaryFire = FALSE; - m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;// take one ammo just to start the spin + --m_iClip;// take one ammo just to start the spin m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase(); // spin up - m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_CHARGE_VOLUME; + m_pPlayer->m_iWeaponVolume = XS_PRIMARY_CHARGE_VOLUME; - SendWeaponAnim( GAUSS_SPINUP ); + SendWeaponAnim( XS_SPINUP ); m_fInAttack = 1; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; 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, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 110, 0, 0, 0 ); + PLAYBACK_EVENT_FULL( 0, m_pPlayer->edict(), m_usXSSpin, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 110, 0, 0, 0 ); m_iSoundState = SND_CHANGE_PITCH; } @@ -218,12 +223,28 @@ void CGauss::SecondaryAttack() { if( m_flTimeWeaponIdle < UTIL_WeaponTimeBase() ) { - SendWeaponAnim( GAUSS_SPIN ); + SendWeaponAnim( XS_SPIN ); m_fInAttack = 2; } } 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_iClip <= 0 ) + { + // out of ammo! force the gun to fire + StartFire(); + m_fInAttack = 0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.2; + 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 ) { @@ -233,33 +254,23 @@ void CGauss::SecondaryAttack() if( g_pGameRules->IsMultiplayer() ) #endif { - m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; + --m_iClip; m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase() + 0.1; } else { - m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; + --m_iClip; m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase() + 0.3; } } - 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; - } - if( UTIL_WeaponTimeBase() >= m_pPlayer->m_flAmmoStartCharge ) { // don't eat any more ammo after gun is fully charged. m_pPlayer->m_flNextAmmoBurn = 1000; } - int pitch = ( gpGlobals->time - m_pPlayer->m_flStartCharge ) * ( 150 / GetFullChargeTime() ) + 100; + int pitch = (int)( ( gpGlobals->time - m_pPlayer->m_flStartCharge ) * ( 150 / GetFullChargeTime() ) + 100 ); if( pitch > 250 ) pitch = 250; @@ -268,27 +279,27 @@ void CGauss::SecondaryAttack() 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, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, pitch, 0, ( m_iSoundState == SND_CHANGE_PITCH ) ? 1 : 0, 0 ); + PLAYBACK_EVENT_FULL( 0, m_pPlayer->edict(), m_usXSSpin, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 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_pPlayer->m_iWeaponVolume = XS_PRIMARY_CHARGE_VOLUME; // m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.1; if( m_pPlayer->m_flStartCharge < gpGlobals->time - 10 ) { // 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 ) ); + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/xs_moan1.wav", 1.0, ATTN_NORM, 0, 80 + RANDOM_LONG( 0, 0x3f ) ); + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/xs_moan3.wav", 1.0, ATTN_NORM, 0, 75 + RANDOM_LONG( 0, 0x3f ) ); m_fInAttack = 0; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.2; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0; #ifndef 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 ); + m_pPlayer->TakeDamage( VARS( eoNullEntity ), VARS( eoNullEntity ), 50, DMG_POISON ); + UTIL_ScreenFade( m_pPlayer, Vector( 192, 224, 0 ), 2, 0.5, 128, FFADE_IN ); #endif - SendWeaponAnim( GAUSS_IDLE ); + SendWeaponAnim( XS_IDLE ); // Player may have been killed and this weapon dropped, don't execute any more code after this! return; @@ -302,13 +313,13 @@ void CGauss::SecondaryAttack() // of weaponidle() and make its own function then to try to // merge this into Fire(), which has some identical variable names //========================================================= -void CGauss::StartFire( void ) +void CXS::StartFire( void ) { float flDamage; UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle ); Vector vecAiming = gpGlobals->v_forward; - Vector vecSrc = m_pPlayer->GetGunPosition(); // + gpGlobals->v_up * -8 + gpGlobals->v_right * 8; + Vector vecSrc = m_pPlayer->GetGunPosition() + gpGlobals->v_forward * 20 + gpGlobals->v_up * -6 + gpGlobals->v_right * 3; if( gpGlobals->time - m_pPlayer->m_flStartCharge > GetFullChargeTime() ) { @@ -342,7 +353,7 @@ void CGauss::StartFire( void ) if( !g_pGameRules->IsMultiplayer() ) { - // in deathmatch, gauss can pop you up into the air. Not in single play. + // in deathmatch, xen squasher can pop you up into the air. Not in single play. m_pPlayer->pev->velocity.z = flZVel; } #endif @@ -356,178 +367,41 @@ void CGauss::StartFire( void ) Fire( vecSrc, vecAiming, flDamage ); } -void CGauss::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage ) +void CXS::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage ) { - m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_FIRE_VOLUME; + m_pPlayer->m_iWeaponVolume = XS_PRIMARY_FIRE_VOLUME; - Vector vecSrc = vecOrigSrc; - Vector vecDest = vecSrc + vecDir * 8192; - edict_t *pentIgnore; - TraceResult tr, beam_tr; - float flMaxFrac = 1.0; - int nTotal = 0; - int fHasPunched = 0; - int fFirstBeam = 1; - int nMaxHits = 10; + CXSBeam *pXSBeam = CXSBeam::CXSBeamCreate( flDamage ); - pentIgnore = ENT( m_pPlayer->pev ); + pXSBeam->pev->origin = vecOrigSrc; + pXSBeam->m_vecOldOrigin = vecOrigSrc; + pXSBeam->pev->angles = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle; + pXSBeam->pev->velocity = vecDir * 1250.0f; + pXSBeam->pev->owner = m_pPlayer->edict(); + pXSBeam->Init(); -#ifdef CLIENT_DLL - if( m_fPrimaryFire == false ) - 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, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, flDamage, 0.0, 0, 0, m_fPrimaryFire ? 1 : 0, 0 ); + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/xs_shot.wav", flDamage * 0.0025 + 0.5, ATTN_NORM, 0, 85 + RANDOM_LONG( 0, 16 ) ); // 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_RELIABLE, m_pPlayer->edict(), m_usXSSpin, 0.01, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, 0.0, 0.0, 0, 0, 0, 1 ); - PLAYBACK_EVENT_FULL( FEV_NOTHOST | FEV_RELIABLE, m_pPlayer->edict(), m_usGaussFire, 0.01, (float *)&m_pPlayer->pev->origin, (float *)&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, - vecDest.x, vecDest.y, vecDest.z );*/ - - //ALERT( at_console, "%f %f\n", tr.flFraction, flMaxFrac ); - -#ifndef CLIENT_DLL - while( flDamage > 10 && nMaxHits > 0 ) - { - nMaxHits--; - - // ALERT( at_console, "." ); - UTIL_TraceLine( vecSrc, vecDest, dont_ignore_monsters, pentIgnore, &tr ); - - if( tr.fAllSolid ) - break; - - CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit ); - - if( pEntity == NULL ) - break; - - if( fFirstBeam ) - { - m_pPlayer->pev->effects |= EF_MUZZLEFLASH; - fFirstBeam = 0; - - nTotal += 26; - } - - if( pEntity->pev->takedamage ) - { - ClearMultiDamage(); - pEntity->TraceAttack( m_pPlayer->pev, flDamage, vecDir, &tr, DMG_BULLET ); - ApplyMultiDamage( m_pPlayer->pev, m_pPlayer->pev ); - } - - if( pEntity->ReflectGauss() ) - { - float n; - - pentIgnore = NULL; - - n = -DotProduct( tr.vecPlaneNormal, vecDir ); - - if( n < 0.5 ) // 60 degrees - { - // ALERT( at_console, "reflect %f\n", n ); - // reflect - Vector r; - - r = 2.0 * tr.vecPlaneNormal * n + vecDir; - flMaxFrac = flMaxFrac - tr.flFraction; - vecDir = r; - vecSrc = tr.vecEndPos + vecDir * 8; - vecDest = vecSrc + vecDir * 8192; - - // explode a bit - m_pPlayer->RadiusDamage( tr.vecEndPos, pev, m_pPlayer->pev, flDamage * n, CLASS_NONE, DMG_BLAST ); - - nTotal += 34; - - // lose energy - if( n == 0 ) n = 0.1; - flDamage = flDamage * ( 1 - n ); - } - else - { - nTotal += 13; - - // limit it to one hole punch - if( fHasPunched ) - break; - fHasPunched = 1; - - // try punching through wall if secondary attack (primary is incapable of breaking through) - if( !m_fPrimaryFire ) - { - UTIL_TraceLine( tr.vecEndPos + vecDir * 8, vecDest, dont_ignore_monsters, pentIgnore, &beam_tr ); - if( !beam_tr.fAllSolid ) - { - // trace backwards to find exit point - UTIL_TraceLine( beam_tr.vecEndPos, tr.vecEndPos, dont_ignore_monsters, pentIgnore, &beam_tr ); - - n = ( beam_tr.vecEndPos - tr.vecEndPos ).Length(); - - if( n < flDamage ) - { - if( n == 0 ) - n = 1; - flDamage -= n; - - // ALERT( at_console, "punch %f\n", n ); - nTotal += 21; - - // exit blast damage - //m_pPlayer->RadiusDamage( beam_tr.vecEndPos + vecDir * 8, pev, m_pPlayer->pev, flDamage, CLASS_NONE, DMG_BLAST ); - float damage_radius; - - if( g_pGameRules->IsMultiplayer() ) - { - damage_radius = flDamage * 1.75; // Old code == 2.5 - } - else - { - damage_radius = flDamage * 2.5; - } - - ::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 ); - - nTotal += 53; - - vecSrc = beam_tr.vecEndPos + vecDir; - } - } - else - { - //ALERT( at_console, "blocked %f\n", n ); - flDamage = 0; - } - } - else - { - //ALERT( at_console, "blocked solid\n" ); - - flDamage = 0; - } - - } - } - else - { - vecSrc = tr.vecEndPos + vecDir; - pentIgnore = ENT( pEntity->pev ); - } - } -#endif - // ALERT( at_console, "%d bytes\n", nTotal ); + pev->effects |= EF_MUZZLEFLASH; } -void CGauss::WeaponIdle( void ) +void CXS::Reload() +{ + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == XS_MAX_CLIP ) + return; + + if( !m_fInAttack && DefaultReload( XS_MAX_CLIP, XS_RELOAD, 3.5 ) ) + { + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/xs_reload.wav", 0.8, ATTN_NORM, 0, ATTN_NORM ); + } +} + +void CXS::WeaponIdle( void ) { ResetEmptySound(); @@ -537,13 +411,13 @@ 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/xs_moan1.wav", RANDOM_FLOAT( 0.7, 0.8 ), 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/xs_moan2.wav", RANDOM_FLOAT( 0.7, 0.8 ), 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/xs_moan3.wav", RANDOM_FLOAT( 0.7, 0.8 ), ATTN_NORM ); break; case 3: break; // no sound @@ -558,7 +432,11 @@ void CGauss::WeaponIdle( void ) { StartFire(); m_fInAttack = 0; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.2; + + // Need to set m_flNextPrimaryAttack so the weapon gets a chance to complete its secondary fire animation. - Solokiller + if( m_iClip <= 0 ) + m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; } else { @@ -566,37 +444,60 @@ void CGauss::WeaponIdle( void ) float flRand = RANDOM_FLOAT( 0, 1 ); if( flRand <= 0.5 ) { - iAnim = GAUSS_IDLE; + iAnim = XS_IDLE; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); } else if( flRand <= 0.75 ) { - iAnim = GAUSS_IDLE2; + iAnim = XS_IDLE2; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); } else { - iAnim = GAUSS_FIDGET; + iAnim = XS_FIDGET; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3; } -#ifndef CLIENT_DLL SendWeaponAnim( iAnim ); -#endif } } -class CGaussAmmo : public CBasePlayerAmmo +class CXSAmmo : public CBasePlayerAmmo { + void EXPORT FallThink() + { + pev->nextthink = gpGlobals->time + 0.1; + + if( pev->flags & FL_ONGROUND ) + { + // clatter if we have an owner (i.e., dropped by someone) + // don't clatter if the gun is waiting to respawn (if it's waiting, it is invisible!) + if( !FNullEnt( pev->owner ) ) + { + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "items/weapondrop1.wav", 1, ATTN_NORM, 0, 100 ); + } + + // lie flat + pev->angles.x = 0; + pev->angles.z = 0; + + UTIL_SetOrigin( pev, pev->origin );// link into world. + SetThink( NULL ); + } + } void Spawn( void ) { Precache(); - SET_MODEL( ENT( pev ), "models/w_gaussammo.mdl" ); + SET_MODEL( ENT( pev ), "models/w_xencandy.mdl" ); CBasePlayerAmmo::Spawn(); + + SetThink( &CXSAmmo::FallThink ); + pev->nextthink = gpGlobals->time + 0.1; } void Precache( void ) { - PRECACHE_MODEL( "models/w_gaussammo.mdl" ); + PRECACHE_MODEL( "models/w_xencandy.mdl" ); PRECACHE_SOUND( "items/9mmclip1.wav" ); + PRECACHE_SOUND( "items/weapondrop1.wav" ); } BOOL AddAmmo( CBaseEntity *pOther ) { @@ -609,5 +510,5 @@ class CGaussAmmo : public CBasePlayerAmmo } }; -LINK_ENTITY_TO_CLASS( ammo_gaussclip, CGaussAmmo ) +LINK_ENTITY_TO_CLASS( ammo_xencandy, CXSAmmo ) #endif diff --git a/dlls/genericmonster.cpp b/dlls/genericmonster.cpp index c40bb802..3cc0acc6 100644 --- a/dlls/genericmonster.cpp +++ b/dlls/genericmonster.cpp @@ -88,7 +88,7 @@ void CGenericMonster::HandleAnimEvent( MonsterEvent_t *pEvent ) //========================================================= int CGenericMonster::ISoundMask( void ) { - return NULL; + return 0; } //========================================================= @@ -131,7 +131,7 @@ void CGenericMonster::Spawn() //========================================================= void CGenericMonster::Precache() { - PRECACHE_MODEL( (char *)STRING( pev->model ) ); + PRECACHE_MODEL( STRING( pev->model ) ); } //========================================================= diff --git a/dlls/ggrenade.cpp b/dlls/ggrenade.cpp index 15e94504..4f9a37e0 100644 --- a/dlls/ggrenade.cpp +++ b/dlls/ggrenade.cpp @@ -49,41 +49,14 @@ void CGrenade::Explode( Vector vecSrc, Vector vecAim ) // UNDONE: temporary scorching for PreAlpha - find a less sleazy permenant solution. void CGrenade::Explode( TraceResult *pTrace, int bitsDamageType ) { - float flRndSound;// sound randomizer + // float flRndSound;// sound randomizer pev->model = iStringNull;//invisible pev->solid = SOLID_NOT;// intangible pev->takedamage = DAMAGE_NO; - if( FClassnameIs( pev, "monster_pipebomb" ) ) - { - int trailCount = RANDOM_LONG( 1, 4 ); - for( int i = 0; i < trailCount; i++ ) - Create( "fire_trail", pev->origin, pTrace->vecPlaneNormal, NULL ); - - // blast circles - MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin ); - WRITE_BYTE( TE_BEAMCYLINDER ); - WRITE_COORD( pev->origin.x ); - WRITE_COORD( pev->origin.y ); - WRITE_COORD( pev->origin.z + 16 ); - WRITE_COORD( pev->origin.x ); - WRITE_COORD( pev->origin.y ); - WRITE_COORD( pev->origin.z + 16 + 384 ); // reach damage radius over .3 seconds - WRITE_SHORT( g_sModelIndexShockwave ); - WRITE_BYTE( 0 ); // startframe - WRITE_BYTE( 0 ); // framerate - WRITE_BYTE( 3 ); // life - WRITE_BYTE( 16 ); // width - WRITE_BYTE( 0 ); // noise - WRITE_BYTE( 255 ); // r - WRITE_BYTE( 255 ); // g - WRITE_BYTE( 255 ); // b - WRITE_BYTE( 255 ); //brightness - WRITE_BYTE( 0 ); // speed - MESSAGE_END(); - } + Vector vecOldOrigin = pev->origin; // Pull out of the wall a bit if( pTrace->flFraction != 1.0 ) @@ -111,6 +84,35 @@ void CGrenade::Explode( TraceResult *pTrace, int bitsDamageType ) WRITE_BYTE( TE_EXPLFLAG_NONE ); MESSAGE_END(); + if( FClassnameIs( pev, "monster_satchel" ) && iContents != CONTENTS_WATER ) + { + // blast circles + MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin ); + WRITE_BYTE( TE_BEAMCYLINDER ); + WRITE_COORD( vecOldOrigin.x ); + WRITE_COORD( vecOldOrigin.y ); + WRITE_COORD( vecOldOrigin.z + 16 ); + WRITE_COORD( vecOldOrigin.x ); + WRITE_COORD( vecOldOrigin.y ); + WRITE_COORD( vecOldOrigin.z + 700 ); // reach damage radius over .3 seconds + WRITE_SHORT( static_cast( this )->m_iTrail ); + WRITE_BYTE( 0 ); // startframe + WRITE_BYTE( 10 ); // framerate + WRITE_BYTE( 2 ); // life + WRITE_BYTE( 16 ); // width + WRITE_BYTE( 0 ); // noise + WRITE_BYTE( 255 ); // r + WRITE_BYTE( 255 ); // g + WRITE_BYTE( 255 ); // b + WRITE_BYTE( 128 ); //brightness + WRITE_BYTE( 0 ); // speed + MESSAGE_END(); + + int trailCount = RANDOM_LONG( 2, 4 ); + for( int i = 0; i < trailCount; i++ ) + Create( "fire_trail", pev->origin, pTrace->vecPlaneNormal, NULL ); + } + CSoundEnt::InsertSound( bits_SOUND_COMBAT, pev->origin, NORMAL_EXPLOSION_VOLUME, 3.0 ); entvars_t *pevOwner; if( pev->owner ) @@ -131,7 +133,7 @@ void CGrenade::Explode( TraceResult *pTrace, int bitsDamageType ) UTIL_DecalTrace( pTrace, DECAL_SCORCH2 ); } - flRndSound = RANDOM_FLOAT( 0, 1 ); + //flRndSound = RANDOM_FLOAT( 0, 1 ); switch( RANDOM_LONG( 0, 2 ) ) { @@ -173,8 +175,8 @@ void CGrenade::Smoke( void ) WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.z ); WRITE_SHORT( g_sModelIndexSmoke ); - WRITE_BYTE( ( pev->dmg - 50 ) * 0.80 ); // scale * 10 - WRITE_BYTE( 12 ); // framerate + WRITE_BYTE( (int)( ( pev->dmg - 50 ) * 0.80 ) ); // scale * 10 + WRITE_BYTE( 12 ); // framerate MESSAGE_END(); } UTIL_Remove( this ); @@ -194,7 +196,7 @@ void CGrenade::DetonateUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_T void CGrenade::PreDetonate( void ) { - CSoundEnt::InsertSound ( bits_SOUND_DANGER, pev->origin, 400, 0.3 ); + CSoundEnt::InsertSound( bits_SOUND_DANGER, pev->origin, 400, 0.3 ); SetThink( &CGrenade::Detonate ); pev->nextthink = gpGlobals->time + 1; @@ -236,7 +238,7 @@ void CGrenade::DangerSoundThink( void ) return; } - CSoundEnt::InsertSound ( bits_SOUND_DANGER, pev->origin + pev->velocity * 0.5, pev->velocity.Length(), 0.2 ); + CSoundEnt::InsertSound( bits_SOUND_DANGER, pev->origin + pev->velocity * 0.5, (int)pev->velocity.Length(), 0.2 ); pev->nextthink = gpGlobals->time + 0.2; if( pev->waterlevel != 0 ) @@ -282,7 +284,7 @@ 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, pev->dmg / 0.4, 0.3 ); + CSoundEnt::InsertSound( bits_SOUND_DANGER, pev->origin, (int)( pev->dmg / 0.4 ), 0.3 ); m_fRegisteredSound = TRUE; } diff --git a/dlls/glock.cpp b/dlls/glock.cpp index 1f4517e7..c70d8e40 100644 --- a/dlls/glock.cpp +++ b/dlls/glock.cpp @@ -20,6 +20,7 @@ #include "weapons.h" #include "nodes.h" #include "player.h" +#include "nail.h" enum glock_e { @@ -32,19 +33,22 @@ enum glock_e GLOCK_RELOAD_NOT_EMPTY, GLOCK_DRAW, GLOCK_HOLSTER, - GLOCK_ADD_SILENCER + GLOCK_ADD_SILENCER, + GLOCK_UPRIGHT_TO_TILT, + GLOCK_TILT_TO_UPRIGHT, + GLOCK_FASTSHOOT }; -LINK_ENTITY_TO_CLASS( weapon_glock, CGlock ) -LINK_ENTITY_TO_CLASS( weapon_9mmhandgun, CGlock ) +LINK_ENTITY_TO_CLASS( weapon_bradnailer, CGlock ) void CGlock::Spawn() { - pev->classname = MAKE_STRING( "weapon_9mmhandgun" ); // hack to allow for old names + // pev->classname = MAKE_STRING( "weapon_9mmhandgun" ); // hack to allow for old names Precache(); m_iId = WEAPON_GLOCK; - SET_MODEL( ENT( pev ), "models/w_9mmhandgun.mdl" ); + SET_MODEL( ENT( pev ), "models/w_bradnailer.mdl" ); + m_fInAttack = 0; m_iDefaultAmmo = GLOCK_DEFAULT_GIVE; FallInit();// get ready to fall down. @@ -52,21 +56,14 @@ void CGlock::Spawn() void CGlock::Precache( void ) { - PRECACHE_MODEL( "models/v_9mmhandgun.mdl" ); - PRECACHE_MODEL( "models/w_9mmhandgun.mdl" ); - PRECACHE_MODEL( "models/p_9mmhandgun.mdl" ); - - m_iShell = PRECACHE_MODEL( "models/shell.mdl" );// brass shell - + PRECACHE_MODEL( "models/v_bradnailer.mdl" ); + PRECACHE_MODEL( "models/w_bradnailer.mdl" ); + PRECACHE_MODEL( "models/p_bradnailer.mdl" ); PRECACHE_SOUND( "items/9mmclip1.wav" ); PRECACHE_SOUND( "items/9mmclip2.wav" ); + PRECACHE_SOUND( "weapons/bradnailer.wav" ); - PRECACHE_SOUND( "weapons/pl_gun1.wav" );//silenced handgun - PRECACHE_SOUND( "weapons/pl_gun2.wav" );//silenced handgun - PRECACHE_SOUND( "weapons/pl_gun3.wav" );//handgun - - m_usFireGlock1 = PRECACHE_EVENT( 1, "events/glock1.sc" ); - m_usFireGlock2 = PRECACHE_EVENT( 1, "events/glock2.sc" ); + // UTIL_PrecacheOther( "nailgun_nail" ); } int CGlock::GetItemInfo( ItemInfo *p ) @@ -86,116 +83,185 @@ int CGlock::GetItemInfo( ItemInfo *p ) return 1; } +int CGlock::AddToPlayer( CBasePlayer *pPlayer ) +{ + if( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) + { + MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev ); + WRITE_BYTE( m_iId ); + MESSAGE_END(); + return TRUE; + } + return FALSE; +} + BOOL CGlock::Deploy() { // pev->body = 1; - return DefaultDeploy( "models/v_9mmhandgun.mdl", "models/p_9mmhandgun.mdl", GLOCK_DRAW, "onehanded", /*UseDecrement() ? 1 : 0*/ 0 ); + return DefaultDeploy( "models/v_bradnailer.mdl", "models/p_bradnailer.mdl", GLOCK_DRAW, "onehanded", /*UseDecrement() ? 1 : 0*/ 0 ); } void CGlock::SecondaryAttack( void ) { - GlockFire( 0.1, 0.2, FALSE ); + GlockFire( 0.2, FALSE ); } void CGlock::PrimaryAttack( void ) { - GlockFire( 0.01, 0.3, TRUE ); + GlockFire( 0.3, TRUE ); } -void CGlock::GlockFire( float flSpread, float flCycleTime, BOOL fUseAutoAim ) +void CGlock::GlockFire( float flCycleTime, BOOL fUseAutoAim ) { + // don't fire underwater + if( m_pPlayer->pev->waterlevel == 3 ) + { + PlayEmptySound(); + m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15; + return; + } + if( m_iClip <= 0 ) { if( m_fFireOnEmpty ) { PlayEmptySound(); - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.2; + m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15; } - return; } + if( fUseAutoAim ) + { + if( m_fInAttack ) + { + SendWeaponAnim( GLOCK_TILT_TO_UPRIGHT ); + m_fInAttack = 0; + m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.3f; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); + return; + } + + SendWeaponAnim( GLOCK_SHOOT ); + } + else + { + if( !m_fInAttack ) + { + SendWeaponAnim( GLOCK_UPRIGHT_TO_TILT ); + m_fInAttack = 1; + m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.3f; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0f; + return; + } + + SendWeaponAnim( GLOCK_FASTSHOOT ); + } m_iClip--; - m_pPlayer->pev->effects = (int)( m_pPlayer->pev->effects ) | EF_MUZZLEFLASH; + m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME; + + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/bradnailer.wav", 1.0, ATTN_NORM, 0, 98 + RANDOM_LONG( 0, 3 ) ); + + // m_pPlayer->pev->effects = (int)( m_pPlayer->pev->effects ) | EF_MUZZLEFLASH; - int flags; -#if defined( CLIENT_WEAPONS ) - flags = FEV_NOTHOST; -#else - flags = 0; -#endif // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); - // silenced - if( pev->body == 1 ) - { - m_pPlayer->m_iWeaponVolume = QUIET_GUN_VOLUME; - m_pPlayer->m_iWeaponFlash = DIM_GUN_FLASH; - } - else - { - // non-silenced - m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME; - m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH; - } + Vector vecAngles = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle; + UTIL_MakeVectors( vecAngles ); - Vector vecSrc = m_pPlayer->GetGunPosition(); - Vector vecAiming; + vecAngles.x = -vecAngles.x; + Vector vecSrc = m_pPlayer->GetGunPosition() - gpGlobals->v_up * 3; + float flSpread; if( fUseAutoAim ) { - vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES ); + vecSrc = vecSrc + gpGlobals->v_up + gpGlobals->v_right * 2; + flSpread = 0.008732f; } else { - vecAiming = gpGlobals->v_forward; + flSpread = 0.06976f; } - Vector vecDir; - vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, Vector( flSpread, flSpread, flSpread ), 8192, BULLET_PLAYER_9MM, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed ); + float x, y; + 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 ); + } + while( x * x + y * y > 1.0f ); - PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), fUseAutoAim ? m_usFireGlock1 : m_usFireGlock2, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, ( m_iClip == 0 ) ? 1 : 0, 0 ); + Vector vecSpread = x * flSpread * gpGlobals->v_up + y * flSpread * gpGlobals->v_right + gpGlobals->v_forward; + Vector vecDest = vecSrc + vecSpread * 2048.0f; - m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + flCycleTime; + UTIL_MakeTracer( vecSrc, vecDest ); - if( !m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) - // HEV suit - indicate out of ammo condition - m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 ); + CNailGunNail *pNail = CNailGunNail::NailCreate( TRUE ); + pNail->pev->origin = vecSrc; + pNail->pev->angles = vecAngles; + pNail->pev->owner = m_pPlayer->edict(); + pNail->pev->velocity = vecSpread * 1600.0f; + pNail->pev->speed = 1600.0f; + pNail->pev->avelocity.z = 10; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); + m_flNextPrimaryAttack = m_flNextSecondaryAttack = GetNextAttackDelay( flCycleTime ); + + if( m_fInAttack ) + { + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0f; + } + else + { + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); + } + + m_pPlayer->pev->punchangle.x -= 2.0f; } void CGlock::Reload( void ) { - if( m_pPlayer->ammo_9mm <= 0 ) - return; + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == GLOCK_MAX_CLIP ) + return; - int iResult; + if( m_fInAttack ) + { + if( !m_fInSpecialReload ) + { + SendWeaponAnim( GLOCK_TILT_TO_UPRIGHT ); - if( m_iClip == 0 ) - iResult = DefaultReload( 17, GLOCK_RELOAD, 1.5 ); - else - iResult = DefaultReload( 17, GLOCK_RELOAD_NOT_EMPTY, 1.5 ); - - if( iResult ) + SetThink( &CGlock::ReloadWait ); + pev->nextthink = gpGlobals->time + 0.4; + m_fInSpecialReload = 1; + } + } + else if( DefaultReload( GLOCK_MAX_CLIP, m_iClip ? GLOCK_RELOAD : GLOCK_RELOAD_NOT_EMPTY, 2.3 ) ) { m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); } } +void CGlock::ReloadWait() +{ + m_fInAttack = m_fInSpecialReload = 0; + SetThink( NULL ); + Reload(); +} + void CGlock::WeaponIdle( void ) { ResetEmptySound(); - m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES ); - if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) return; - // only idle if the slid isn't back - if( m_iClip != 0 ) + if( m_fInAttack ) + { + m_fInAttack = 0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.4f; + SendWeaponAnim( GLOCK_TILT_TO_UPRIGHT ); + } + else { int iAnim; float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0.0, 1.0 ); @@ -224,13 +290,13 @@ class CGlockAmmo : public CBasePlayerAmmo void Spawn( void ) { Precache(); - SET_MODEL( ENT( pev ), "models/w_9mmclip.mdl" ); + SET_MODEL( ENT( pev ), "models/w_nailclip.mdl" ); CBasePlayerAmmo::Spawn(); } void Precache( void ) { - PRECACHE_MODEL( "models/w_9mmclip.mdl" ); + PRECACHE_MODEL( "models/w_nailclip.mdl" ); PRECACHE_SOUND( "items/9mmclip1.wav" ); } @@ -245,5 +311,4 @@ class CGlockAmmo : public CBasePlayerAmmo } }; -LINK_ENTITY_TO_CLASS( ammo_glockclip, CGlockAmmo ) -LINK_ENTITY_TO_CLASS( ammo_9mmclip, CGlockAmmo ) +LINK_ENTITY_TO_CLASS( ammo_nailclip, CGlockAmmo ) diff --git a/dlls/gman.cpp b/dlls/gman.cpp index bdfb60d4..377755f6 100644 --- a/dlls/gman.cpp +++ b/dlls/gman.cpp @@ -109,7 +109,7 @@ void CGMan::HandleAnimEvent( MonsterEvent_t *pEvent ) //========================================================= int CGMan::ISoundMask( void ) { - return NULL; + return 0; } //========================================================= @@ -149,7 +149,7 @@ void CGMan::StartTask( Task_t *pTask ) switch( pTask->iTask ) { case TASK_WAIT: - if( m_hPlayer == NULL ) + if( m_hPlayer == 0 ) { m_hPlayer = UTIL_FindEntityByClassname( NULL, "player" ); } @@ -164,7 +164,7 @@ void CGMan::RunTask( Task_t *pTask ) { case TASK_WAIT: // look at who I'm talking to - if( m_flTalkTime > gpGlobals->time && m_hTalkTarget != NULL ) + if( m_flTalkTime > gpGlobals->time && m_hTalkTarget != 0 ) { float yaw = VecToYaw( m_hTalkTarget->pev->origin - pev->origin ) - pev->angles.y; @@ -177,7 +177,7 @@ void CGMan::RunTask( Task_t *pTask ) SetBoneController( 0, yaw ); } // look at player, but only if playing a "safe" idle animation - else if( m_hPlayer != NULL && pev->sequence == 0 ) + else if( m_hPlayer != 0 && pev->sequence == 0 ) { float yaw = VecToYaw( m_hPlayer->pev->origin - pev->origin ) - pev->angles.y; diff --git a/dlls/h_battery.cpp b/dlls/h_battery.cpp index fdb7c645..976a5733 100644 --- a/dlls/h_battery.cpp +++ b/dlls/h_battery.cpp @@ -91,7 +91,7 @@ void CRecharge::Spawn() UTIL_SetOrigin( pev, pev->origin ); // set size and link into world UTIL_SetSize( pev, pev->mins, pev->maxs ); SET_MODEL( ENT( pev ), STRING( pev->model ) ); - m_iJuice = gSkillData.suitchargerCapacity; + m_iJuice = (int)gSkillData.suitchargerCapacity; pev->frame = 0; } @@ -172,7 +172,7 @@ void CRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE use void CRecharge::Recharge( void ) { - m_iJuice = gSkillData.suitchargerCapacity; + m_iJuice = (int)gSkillData.suitchargerCapacity; pev->frame = 0; SetThink( &CBaseEntity::SUB_DoNothing ); } @@ -185,7 +185,7 @@ void CRecharge::Off( void ) m_iOn = 0; - if( ( !m_iJuice ) && ( ( m_iReactivate = g_pGameRules->FlHEVChargerRechargeTime() ) > 0 ) ) + if( ( !m_iJuice ) && ( ( m_iReactivate = (int)g_pGameRules->FlHEVChargerRechargeTime() ) > 0 ) ) { pev->nextthink = pev->ltime + m_iReactivate; SetThink( &CRecharge::Recharge ); diff --git a/dlls/h_cine.cpp b/dlls/h_cine.cpp index fc503171..bb07e02c 100644 --- a/dlls/h_cine.cpp +++ b/dlls/h_cine.cpp @@ -31,7 +31,7 @@ class CLegacyCineMonster : public CBaseMonster { public: - void CineSpawn( char *szModel ); + void CineSpawn( const char *szModel ); void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void EXPORT CineThink( void ); void Pain( void ); @@ -103,7 +103,7 @@ LINK_ENTITY_TO_CLASS( monster_cine3_barney, CCine3Barney ) // ********** Scientist SPAWN ********** // -void CLegacyCineMonster :: CineSpawn( char *szModel ) +void CLegacyCineMonster :: CineSpawn( const char *szModel ) { PRECACHE_MODEL(szModel); SET_MODEL(ENT(pev), szModel); diff --git a/dlls/h_cycler.cpp b/dlls/h_cycler.cpp index d685ac36..5daad4a2 100644 --- a/dlls/h_cycler.cpp +++ b/dlls/h_cycler.cpp @@ -34,7 +34,7 @@ class CCycler : public CBaseMonster { public: - void GenericCyclerSpawn(char *szModel, Vector vecMin, Vector vecMax); + void GenericCyclerSpawn( const char *szModel, Vector vecMin, Vector vecMax ); virtual int ObjectCaps( void ) { return ( CBaseEntity::ObjectCaps() | FCAP_IMPULSE_USE ); } int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ); void Spawn( void ); @@ -67,7 +67,7 @@ class CGenericCycler : public CCycler public: void Spawn( void ) { - GenericCyclerSpawn( (char *)STRING( pev->model ), Vector( -16, -16, 0 ), Vector( 16, 16, 72 ) ); + GenericCyclerSpawn( STRING( pev->model ), Vector( -16, -16, 0 ), Vector( 16, 16, 72 ) ); } }; @@ -92,7 +92,7 @@ void CCyclerProbe::Spawn( void ) } // Cycler member functions -void CCycler::GenericCyclerSpawn( char *szModel, Vector vecMin, Vector vecMax ) +void CCycler::GenericCyclerSpawn( const char *szModel, Vector vecMin, Vector vecMax ) { if( !szModel || !*szModel ) { @@ -255,7 +255,7 @@ void CCyclerSprite::Spawn( void ) m_animate = 1; m_lastTime = gpGlobals->time; - PRECACHE_MODEL( (char *)STRING( pev->model ) ); + PRECACHE_MODEL( STRING( pev->model ) ); SET_MODEL( ENT( pev ), STRING( pev->model ) ); m_maxFrame = (float)MODEL_FRAMES( pev->modelindex ) - 1; @@ -314,7 +314,7 @@ void CWeaponCycler::Spawn() pev->solid = SOLID_SLIDEBOX; pev->movetype = MOVETYPE_NONE; - PRECACHE_MODEL( (char *)STRING( pev->model ) ); + PRECACHE_MODEL( STRING( pev->model ) ); SET_MODEL( ENT( pev ), STRING( pev->model ) ); m_iszModel = pev->model; m_iModel = pev->modelindex; @@ -401,18 +401,18 @@ void CWreckage::Spawn( void ) if( pev->model ) { - PRECACHE_MODEL( (char *)STRING( pev->model ) ); + PRECACHE_MODEL( STRING( pev->model ) ); SET_MODEL( ENT( pev ), STRING( pev->model ) ); } // pev->scale = 5.0; - m_flStartTime = gpGlobals->time; + m_flStartTime = (int)gpGlobals->time; } void CWreckage::Precache() { if( pev->model ) - PRECACHE_MODEL( (char *)STRING( pev->model ) ); + PRECACHE_MODEL( STRING( pev->model ) ); } void CWreckage::Think( void ) diff --git a/dlls/handgrenade.cpp b/dlls/handgrenade.cpp index 063b2886..c2bbd7f9 100644 --- a/dlls/handgrenade.cpp +++ b/dlls/handgrenade.cpp @@ -99,8 +99,13 @@ void CHandGrenade::Holster( int skiplocal /* = 0 */ ) { // no more grenades! m_pPlayer->pev->weapons &= ~( 1 << WEAPON_HANDGRENADE ); - SetThink( &CBasePlayerItem::DestroyItem ); - pev->nextthink = gpGlobals->time + 0.1; + DestroyItem(); + } + + if( m_flStartThrow ) + { + m_flStartThrow = 0; + m_flReleaseThrow = 0; } EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM ); @@ -170,7 +175,7 @@ void CHandGrenade::WeaponIdle( void ) m_flReleaseThrow = 0; m_flStartThrow = 0; - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; @@ -180,7 +185,7 @@ 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 = UTIL_WeaponTimeBase() + 0.5;// ensure that the animation can finish playing + m_flTimeWeaponIdle = m_flNextSecondaryAttack = m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 );// ensure that the animation can finish playing } return; } diff --git a/dlls/hassassin.cpp b/dlls/hassassin.cpp index 5aac1e53..f51ed4cb 100644 --- a/dlls/hassassin.cpp +++ b/dlls/hassassin.cpp @@ -185,7 +185,7 @@ void CHAssassin::SetYawSpeed( void ) //========================================================= void CHAssassin::Shoot( void ) { - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { return; } @@ -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 != NULL ) + if( m_flNextJump < gpGlobals->time && ( flDist <= 128 || HasMemory( bits_MEMORY_BADJUMP ) ) && m_hEnemy != 0 ) { TraceResult tr; @@ -687,7 +687,7 @@ void CHAssassin::RunAI( void ) // always visible if moving // always visible is not on hard - if( g_iSkillLevel != SKILL_HARD || m_hEnemy == NULL || pev->deadflag != DEAD_NO || m_Activity == ACT_RUN || m_Activity == ACT_WALK || !( pev->flags & FL_ONGROUND ) ) + if( g_iSkillLevel != SKILL_HARD || m_hEnemy == 0 || pev->deadflag != DEAD_NO || m_Activity == ACT_RUN || m_Activity == ACT_WALK || !( pev->flags & FL_ONGROUND ) ) m_iTargetRanderamt = 255; else m_iTargetRanderamt = 20; @@ -699,12 +699,12 @@ void CHAssassin::RunAI( void ) EMIT_SOUND( ENT( pev ), CHAN_BODY, "debris/beamstart1.wav", 0.2, ATTN_NORM ); } - pev->renderamt = max( pev->renderamt - 50, m_iTargetRanderamt ); + pev->renderamt = Q_max( pev->renderamt - 50, m_iTargetRanderamt ); pev->rendermode = kRenderTransTexture; } else if( pev->renderamt < m_iTargetRanderamt ) { - pev->renderamt = min( pev->renderamt + 50, m_iTargetRanderamt ); + pev->renderamt = Q_min( pev->renderamt + 50, m_iTargetRanderamt ); if( pev->renderamt == 255 ) pev->rendermode = kRenderNormal; } diff --git a/dlls/headcrab.cpp b/dlls/headcrab.cpp index d84a692e..60e03c10 100644 --- a/dlls/headcrab.cpp +++ b/dlls/headcrab.cpp @@ -226,7 +226,7 @@ void CHeadCrab::HandleAnimEvent( MonsterEvent_t *pEvent ) UTIL_MakeVectors( pev->angles ); Vector vecJumpDir; - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { float gravity = g_psv_gravity->value; if( gravity <= 1 ) @@ -538,7 +538,7 @@ Schedule_t *CBabyCrab::GetScheduleOfType( int Type ) switch( Type ) { case SCHED_FAIL: // If you fail, try to jump! - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) return slHCRangeAttack1Fast; break; case SCHED_RANGE_ATTACK1: diff --git a/dlls/healthkit.cpp b/dlls/healthkit.cpp index df0e1f98..c5b794f8 100644 --- a/dlls/healthkit.cpp +++ b/dlls/healthkit.cpp @@ -159,7 +159,7 @@ void CWallHealth::Spawn() UTIL_SetOrigin( pev, pev->origin ); // set size and link into world UTIL_SetSize( pev, pev->mins, pev->maxs ); SET_MODEL( ENT( pev ), STRING( pev->model ) ); - m_iJuice = gSkillData.healthchargerCapacity; + m_iJuice = (int)gSkillData.healthchargerCapacity; pev->frame = 0; } @@ -230,7 +230,7 @@ void CWallHealth::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE u void CWallHealth::Recharge( void ) { EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/medshot4.wav", 1.0, ATTN_NORM ); - m_iJuice = gSkillData.healthchargerCapacity; + m_iJuice = (int)gSkillData.healthchargerCapacity; pev->frame = 0; SetThink( &CBaseEntity::SUB_DoNothing ); } @@ -243,7 +243,7 @@ void CWallHealth::Off( void ) m_iOn = 0; - if( ( !m_iJuice ) && ( ( m_iReactivate = g_pGameRules->FlHealthChargerRechargeTime() ) > 0 ) ) + if( ( !m_iJuice ) && ( ( m_iReactivate = (int)g_pGameRules->FlHealthChargerRechargeTime() ) > 0 ) ) { pev->nextthink = pev->ltime + m_iReactivate; SetThink( &CWallHealth::Recharge ); diff --git a/dlls/hgrunt.cpp b/dlls/hgrunt.cpp index ab9eeb17..f9cd348a 100644 --- a/dlls/hgrunt.cpp +++ b/dlls/hgrunt.cpp @@ -217,7 +217,7 @@ const char *CHGrunt::pGruntSentences[] = "HG_TAUNT", // say rude things }; -enum +typedef enum { HGRUNT_SENT_NONE = -1, HGRUNT_SENT_GREN = 0, @@ -363,7 +363,7 @@ void CHGrunt::JustSpoke( void ) //========================================================= void CHGrunt::PrescheduleThink( void ) { - if( InSquad() && m_hEnemy != NULL ) + if( InSquad() && m_hEnemy != 0 ) { if( HasConditions( bits_COND_SEE_ENEMY ) ) { @@ -410,9 +410,9 @@ BOOL CHGrunt::FCanCheckAttacks( void ) //========================================================= BOOL CHGrunt::CheckMeleeAttack1( float flDot, float flDist ) { - CBaseMonster *pEnemy; + CBaseMonster *pEnemy = 0; - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { pEnemy = m_hEnemy->MyMonsterPointer(); @@ -784,7 +784,7 @@ Vector CHGrunt::GetGunPosition() //========================================================= void CHGrunt::Shoot( void ) { - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { return; } @@ -811,7 +811,7 @@ void CHGrunt::Shoot( void ) //========================================================= void CHGrunt::Shotgun( void ) { - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { return; } @@ -949,6 +949,7 @@ void CHGrunt::HandleAnimEvent( MonsterEvent_t *pEvent ) } } + break; default: CSquadMonster::HandleAnimEvent( pEvent ); break; @@ -983,6 +984,33 @@ void CHGrunt::Spawn() m_HackedGunPos = Vector( 0, 0, 55 ); + if( pev->body ) + { + switch( pev->body ) + { + case 1: + SetBodygroup( HEAD_GROUP, HEAD_GRUNT ); + break; + case 2: + SetBodygroup( HEAD_GROUP, HEAD_COMMANDER ); + break; + case 3: + SetBodygroup( HEAD_GROUP, HEAD_SHOTGUN ); + break; + case 4: + SetBodygroup( HEAD_GROUP, HEAD_M203 ); + break; + default: + break; + } + } + else + { + SetBodygroup( HEAD_GROUP, RANDOM_LONG( HEAD_COMMANDER, HEAD_M203) ); + } + + pev->skin = 0; + if( pev->weapons == 0 ) { // initialize to original values @@ -991,6 +1019,9 @@ void CHGrunt::Spawn() // pev->weapons = HGRUNT_9MMAR | HGRUNT_GRENADELAUNCHER; } + if( FBitSet( pev->weapons, HGRUNT_GRENADELAUNCHER ) ) + ClearBits( pev->weapons, HGRUNT_GRENADELAUNCHER ); + if( FBitSet( pev->weapons, HGRUNT_SHOTGUN ) ) { SetBodygroup( GUN_GROUP, GUN_SHOTGUN ); @@ -1809,7 +1840,7 @@ IMPLEMENT_CUSTOM_SCHEDULES( CHGrunt, CSquadMonster ) void CHGrunt::SetActivity( Activity NewActivity ) { int iSequence = ACTIVITY_NOT_AVAILABLE; - void *pmodel = GET_MODEL_PTR( ENT( pev ) ); + //void *pmodel = GET_MODEL_PTR( ENT( pev ) ); switch( NewActivity ) { @@ -2007,10 +2038,10 @@ Schedule_t *CHGrunt::GetSchedule( void ) // before he starts pluggin away. if( FOkToSpeak() )// && RANDOM_LONG( 0, 1 ) ) { - if( ( m_hEnemy != NULL ) && m_hEnemy->IsPlayer() ) + if( ( m_hEnemy != 0 ) && m_hEnemy->IsPlayer() ) // player SENTENCEG_PlayRndSz( ENT( pev ), "HG_ALERT", HGRUNT_SENTENCE_VOLUME, GRUNT_ATTN, 0, m_voicePitch ); - else if( ( m_hEnemy != NULL ) && + else if( ( m_hEnemy != 0 ) && ( m_hEnemy->Classify() != CLASS_PLAYER_ALLY ) && ( m_hEnemy->Classify() != CLASS_HUMAN_PASSIVE ) && ( m_hEnemy->Classify() != CLASS_MACHINE ) ) @@ -2047,7 +2078,7 @@ Schedule_t *CHGrunt::GetSchedule( void ) // 10% chance of flinch. int iPercent = RANDOM_LONG( 0, 99 ); - if( iPercent <= 90 && m_hEnemy != NULL ) + if( iPercent <= 90 && m_hEnemy != 0 ) { // only try to take cover if we actually have an enemy! @@ -2283,7 +2314,7 @@ Schedule_t *CHGrunt::GetScheduleOfType( int Type ) } case SCHED_FAIL: { - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { // grunt has an enemy, so pick a different default fail schedule most likely to help recover. return &slGruntCombatFail[0]; @@ -2383,10 +2414,10 @@ public: void KeyValue( KeyValueData *pkvd ); int m_iPose;// which sequence to display -- temporary, don't need to save - static char *m_szPoses[3]; + static const char *m_szPoses[3]; }; -char *CDeadHGrunt::m_szPoses[] = { "deadstomach", "deadside", "deadsitting" }; +const char *CDeadHGrunt::m_szPoses[] = { "deadstomach", "deadside", "deadsitting" }; void CDeadHGrunt::KeyValue( KeyValueData *pkvd ) { @@ -2424,5 +2455,38 @@ void CDeadHGrunt::Spawn( void ) // Corpses have less health pev->health = 8; + // map old bodies onto new bodies + switch( pev->body ) + { + case 0: + // Grunt with Gun + pev->body = 0; + pev->skin = 0; + SetBodygroup( HEAD_GROUP, HEAD_COMMANDER ); + SetBodygroup( GUN_GROUP, GUN_MP5 ); + break; + case 1: + // Commander with Gun + pev->body = 0; + pev->skin = 0; + SetBodygroup( HEAD_GROUP, HEAD_GRUNT ); + SetBodygroup( GUN_GROUP, GUN_MP5 ); + break; + case 2: + // Grunt no Gun + pev->body = 0; + pev->skin = 0; + SetBodygroup( HEAD_GROUP, HEAD_COMMANDER ); + SetBodygroup( GUN_GROUP, GUN_NONE ); + break; + case 3: + // Commander no Gun + pev->body = 0; + pev->skin = 0; + SetBodygroup( HEAD_GROUP, HEAD_GRUNT ); + SetBodygroup( GUN_GROUP, GUN_NONE ); + break; + } + MonsterInitDead(); } diff --git a/dlls/hornet.cpp b/dlls/hornet.cpp index 1e7025a0..758ba7e9 100644 --- a/dlls/hornet.cpp +++ b/dlls/hornet.cpp @@ -258,14 +258,14 @@ void CHornet::TrackTarget( void ) } // UNDONE: The player pointer should come back after returning from another level - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { // enemy is dead. Look( 512 ); m_hEnemy = BestVisibleEnemy(); } - if( m_hEnemy != NULL && FVisible( m_hEnemy ) ) + if( m_hEnemy != 0 && FVisible( m_hEnemy ) ) { m_vecEnemyLKP = m_hEnemy->BodyTarget( pev->origin ); } @@ -335,7 +335,7 @@ void CHornet::TrackTarget( void ) // if hornet is close to the enemy, jet in a straight line for a half second. // (only in the single player game) - if( m_hEnemy != NULL && !g_pGameRules->IsMultiplayer() ) + if( m_hEnemy != 0 && !g_pGameRules->IsMultiplayer() ) { if( flDelta >= 0.4 && ( pev->origin - m_vecEnemyLKP ).Length() <= 300 ) { @@ -407,7 +407,7 @@ void CHornet::DartTouch( CBaseEntity *pOther ) void CHornet::DieTouch( CBaseEntity *pOther ) { - if( pOther && pOther->pev->takedamage ) + if( pOther && pOther->pev->takedamage && pev->owner ) { // do the damage switch( RANDOM_LONG( 0, 2 ) ) diff --git a/dlls/hornet.h b/dlls/hornet.h index dc78fc40..f0f0d366 100644 --- a/dlls/hornet.h +++ b/dlls/hornet.h @@ -15,7 +15,9 @@ //========================================================= // Hornets //========================================================= - +#pragma once +#ifndef HORNET_H +#define HORNET_H //========================================================= // Hornet Defines //========================================================= @@ -55,3 +57,4 @@ public: int m_iHornetType; float m_flFlySpeed; }; +#endif // HORNET_H diff --git a/dlls/houndeye.cpp b/dlls/houndeye.cpp index f35b0740..cedee258 100644 --- a/dlls/houndeye.cpp +++ b/dlls/houndeye.cpp @@ -137,7 +137,7 @@ int CHoundeye::Classify( void ) //========================================================= BOOL CHoundeye::FValidateHintType( short sHint ) { - int i; + size_t i; static short sHoundHints[] = { diff --git a/dlls/ichthyosaur.cpp b/dlls/ichthyosaur.cpp index cbc86d50..53f57a27 100644 --- a/dlls/ichthyosaur.cpp +++ b/dlls/ichthyosaur.cpp @@ -416,7 +416,7 @@ void CIchthyosaur::HandleAnimEvent( MonsterEvent_t *pEvent ) case ICHTHYOSAUR_AE_SHAKE_RIGHT: case ICHTHYOSAUR_AE_SHAKE_LEFT: { - if( m_hEnemy != NULL && FVisible( m_hEnemy ) ) + if( m_hEnemy != 0 && FVisible( m_hEnemy ) ) { CBaseEntity *pHurt = m_hEnemy; @@ -622,7 +622,7 @@ void CIchthyosaur::RunTask( Task_t *pTask ) switch( pTask->iTask ) { case TASK_ICHTHYOSAUR_CIRCLE_ENEMY: - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { TaskComplete(); } @@ -864,7 +864,7 @@ void CIchthyosaur::Stop( void ) void CIchthyosaur::Swim() { - int retValue = 0; + //int retValue = 0; Vector start = pev->origin; @@ -1072,7 +1072,7 @@ Vector CIchthyosaur::DoProbe( const Vector &Probe ) } } - if( bBumpedSomething && ( m_hEnemy == NULL || tr.pHit != m_hEnemy->edict() ) ) + if( bBumpedSomething && ( m_hEnemy == 0 || tr.pHit != m_hEnemy->edict() ) ) { Vector ProbeDir = Probe - pev->origin; diff --git a/dlls/islave.cpp b/dlls/islave.cpp index cfb1df1b..b516c09b 100644 --- a/dlls/islave.cpp +++ b/dlls/islave.cpp @@ -44,6 +44,7 @@ class CISlave : public CSquadMonster public: void Spawn( void ); void Precache( void ); + void UpdateOnRemove(); void SetYawSpeed( void ); int ISoundMask( void ); int Classify( void ); @@ -51,7 +52,7 @@ public: void HandleAnimEvent( MonsterEvent_t *pEvent ); BOOL CheckRangeAttack1( float flDot, float flDist ); BOOL CheckRangeAttack2( float flDot, float flDist ); - void CallForHelp( char *szClassname, float flDist, EHANDLE hEnemy, Vector &vecLocation ); + void CallForHelp( const char *szClassname, float flDist, EHANDLE hEnemy, Vector &vecLocation ); void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ); int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ); @@ -155,7 +156,7 @@ int CISlave::IRelationship( CBaseEntity *pTarget ) return CBaseMonster::IRelationship( pTarget ); } -void CISlave::CallForHelp( char *szClassname, float flDist, EHANDLE hEnemy, Vector &vecLocation ) +void CISlave::CallForHelp( const char *szClassname, float flDist, EHANDLE hEnemy, Vector &vecLocation ) { // ALERT( at_aiconsole, "help " ); @@ -185,7 +186,7 @@ void CISlave::CallForHelp( char *szClassname, float flDist, EHANDLE hEnemy, Vect //========================================================= void CISlave::AlertSound( void ) { - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { SENTENCEG_PlayRndSz( ENT( pev ), "SLV_ALERT", 0.85, ATTN_NORM, 0, m_voicePitch ); @@ -365,7 +366,7 @@ void CISlave::HandleAnimEvent( MonsterEvent_t *pEvent ) WRITE_BYTE( 0 ); // decay * 0.1 MESSAGE_END(); } - if( m_hDead != NULL ) + if( m_hDead != 0 ) { WackBeam( -1, m_hDead ); WackBeam( 1, m_hDead ); @@ -385,7 +386,7 @@ void CISlave::HandleAnimEvent( MonsterEvent_t *pEvent ) { ClearBeams(); - if( m_hDead != NULL ) + if( m_hDead != 0 ) { Vector vecDest = m_hDead->pev->origin + Vector( 0, 0, 38 ); TraceResult trace; @@ -394,7 +395,7 @@ void CISlave::HandleAnimEvent( MonsterEvent_t *pEvent ) if( !trace.fStartSolid ) { CBaseEntity *pNew = Create( "monster_alien_slave", m_hDead->pev->origin, m_hDead->pev->angles ); - CBaseMonster *pNewMonster = pNew->MyMonsterPointer( ); + //CBaseMonster *pNewMonster = pNew->MyMonsterPointer(); pNew->pev->spawnflags |= 1; WackBeam( -1, pNew ); WackBeam( 1, pNew ); @@ -484,7 +485,7 @@ BOOL CISlave::CheckRangeAttack2( float flDot, float flDist ) } } } - if( m_hDead != NULL ) + if( m_hDead != 0 ) return TRUE; else return FALSE; @@ -530,7 +531,7 @@ void CISlave::Spawn() //========================================================= void CISlave::Precache() { - int i; + size_t i; PRECACHE_MODEL( "models/islave.mdl" ); PRECACHE_MODEL( "sprites/lgtning.spr" ); @@ -543,20 +544,27 @@ void CISlave::Precache() PRECACHE_SOUND( "weapons/cbar_miss1.wav" ); for( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackHitSounds[i] ); + PRECACHE_SOUND( pAttackHitSounds[i] ); for( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackMissSounds[i] ); + PRECACHE_SOUND( pAttackMissSounds[i] ); for( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) - PRECACHE_SOUND((char *)pPainSounds[i] ); + PRECACHE_SOUND( pPainSounds[i] ); for( i = 0; i < ARRAYSIZE( pDeathSounds ); i++ ) - PRECACHE_SOUND( (char *)pDeathSounds[i] ); + PRECACHE_SOUND( pDeathSounds[i] ); UTIL_PrecacheOther( "test_effect" ); } +void CISlave::UpdateOnRemove() +{ + CBaseEntity::UpdateOnRemove(); + + ClearBeams(); +} + //========================================================= // TakeDamage - get provoked when injured //========================================================= @@ -756,8 +764,8 @@ void CISlave::BeamGlow() //========================================================= void CISlave::WackBeam( int side, CBaseEntity *pEntity ) { - Vector vecDest; - float flDist = 1.0; + //Vector vecDest; + //float flDist = 1.0; if( m_iBeams >= ISLAVE_MAX_BEAMS ) return; diff --git a/dlls/items.cpp b/dlls/items.cpp index f1e2f44c..45edeb5e 100644 --- a/dlls/items.cpp +++ b/dlls/items.cpp @@ -30,7 +30,6 @@ #include "gamerules.h" extern int gmsgItemPickup; -extern int gmsgStartUp; class CWorldItem : public CBaseEntity { @@ -167,6 +166,7 @@ void CItem::Materialize( void ) } SetTouch( &CItem::ItemTouch ); + SetThink( NULL ); } #define SF_SUIT_SHORTLOGON 0x0001 @@ -188,10 +188,10 @@ class CItemSuit : public CItem if( pPlayer->pev->weapons & ( 1<ShowPlayerHUD(); + if( pev->spawnflags & SF_SUIT_SHORTLOGON ) + EMIT_SOUND_SUIT( pPlayer->edict(), "!HEV_A0" ); // short version of suit logon, + else + EMIT_SOUND_SUIT( pPlayer->edict(), "!HEV_AAx" ); // long version of suit logon pPlayer->pev->weapons |= ( 1 << WEAPON_SUIT ); return TRUE; @@ -227,7 +227,7 @@ class CItemBattery : public CItem char szcharge[64]; pPlayer->pev->armorvalue += gSkillData.batteryCapacity; - pPlayer->pev->armorvalue = min( pPlayer->pev->armorvalue, MAX_NORMAL_BATTERY ); + pPlayer->pev->armorvalue = Q_min( pPlayer->pev->armorvalue, MAX_NORMAL_BATTERY ); EMIT_SOUND( pPlayer->edict(), CHAN_ITEM, "items/gunpickup2.wav", 1, ATTN_NORM ); diff --git a/dlls/items.h b/dlls/items.h index 2c31f801..060678c8 100644 --- a/dlls/items.h +++ b/dlls/items.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef ITEMS_H #define ITEMS_H diff --git a/dlls/leech.cpp b/dlls/leech.cpp index ea524aaa..1d64eae1 100644 --- a/dlls/leech.cpp +++ b/dlls/leech.cpp @@ -271,15 +271,15 @@ void CLeech::AlertSound( void ) void CLeech::Precache( void ) { - int i; + size_t i; //PRECACHE_MODEL( "models/icky.mdl" ); PRECACHE_MODEL( "models/leech.mdl" ); for( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackSounds[i] ); + PRECACHE_SOUND( pAttackSounds[i] ); for( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) - PRECACHE_SOUND( (char *)pAlertSounds[i] ); + PRECACHE_SOUND( pAlertSounds[i] ); } int CLeech::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) diff --git a/dlls/lights.cpp b/dlls/lights.cpp index 2a8b0683..13e6d3a9 100644 --- a/dlls/lights.cpp +++ b/dlls/lights.cpp @@ -38,7 +38,7 @@ public: private: int m_iStyle; - int m_iszPattern; + string_t m_iszPattern; }; LINK_ENTITY_TO_CLASS( light, CLight ) @@ -99,7 +99,7 @@ void CLight::Spawn( void ) if( FBitSet( pev->spawnflags, SF_LIGHT_START_OFF ) ) LIGHT_STYLE( m_iStyle, "a" ); else if( m_iszPattern ) - LIGHT_STYLE( m_iStyle, (char *)STRING( m_iszPattern ) ); + LIGHT_STYLE( m_iStyle, STRING( m_iszPattern ) ); else LIGHT_STYLE( m_iStyle, "m" ); } @@ -115,7 +115,7 @@ void CLight::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTyp if( FBitSet( pev->spawnflags, SF_LIGHT_START_OFF ) ) { if( m_iszPattern ) - LIGHT_STYLE( m_iStyle, (char *)STRING( m_iszPattern ) ); + LIGHT_STYLE( m_iStyle, STRING( m_iszPattern ) ); else LIGHT_STYLE( m_iStyle, "m" ); ClearBits( pev->spawnflags, SF_LIGHT_START_OFF ); @@ -155,15 +155,16 @@ void CEnvLight::KeyValue( KeyValueData* pkvd ) } else if( j == 4 ) { - r = r * ( v / 255.0 ); - g = g * ( v / 255.0 ); - b = b * ( v / 255.0 ); + float vf = v / 255.0f; + r *= vf; + g *= vf; + b *= vf; } // simulate qrad direct, ambient,and gamma adjustments, as well as engine scaling - r = pow( r / 114.0, 0.6 ) * 264; - g = pow( g / 114.0, 0.6 ) * 264; - b = pow( b / 114.0, 0.6 ) * 264; + 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 ); pkvd->fHandled = TRUE; sprintf( szColor, "%d", r ); diff --git a/dlls/maprules.cpp b/dlls/maprules.cpp index 3eea7486..519f7d2a 100644 --- a/dlls/maprules.cpp +++ b/dlls/maprules.cpp @@ -64,9 +64,9 @@ void CRuleEntity::Spawn( void ) void CRuleEntity::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "master")) + if( FStrEq(pkvd->szKeyName, "master" ) ) { - SetMaster( ALLOC_STRING(pkvd->szValue) ); + SetMaster( ALLOC_STRING( pkvd->szValue ) ); pkvd->fHandled = TRUE; } else @@ -75,9 +75,9 @@ void CRuleEntity::KeyValue( KeyValueData *pkvd ) BOOL CRuleEntity::CanFireForActivator( CBaseEntity *pActivator ) { - if ( m_iszMaster ) + if( m_iszMaster ) { - if ( UTIL_IsMasterTriggered( m_iszMaster, pActivator ) ) + if( UTIL_IsMasterTriggered( m_iszMaster, pActivator ) ) return TRUE; else return FALSE; @@ -135,7 +135,7 @@ public: void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void KeyValue( KeyValueData *pkvd ); - inline int Points( void ) { return pev->frags; } + inline int Points( void ) { return (int)pev->frags; } inline BOOL AllowNegativeScore( void ) { return pev->spawnflags & SF_SCORE_NEGATIVE; } inline BOOL AwardToTeam( void ) { return pev->spawnflags & SF_SCORE_TEAM; } @@ -153,9 +153,9 @@ void CGameScore::Spawn( void ) void CGameScore::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "points")) + if( FStrEq( pkvd->szKeyName, "points" ) ) { - SetPoints( atoi(pkvd->szValue) ); + SetPoints( atoi( pkvd->szValue ) ); pkvd->fHandled = TRUE; } else @@ -164,13 +164,13 @@ void CGameScore::KeyValue( KeyValueData *pkvd ) void CGameScore::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !CanFireForActivator( pActivator ) ) + if( !CanFireForActivator( pActivator ) ) return; // Only players can use this - if ( pActivator->IsPlayer() ) + if( pActivator->IsPlayer() ) { - if ( AwardToTeam() ) + if( AwardToTeam() ) { pActivator->AddPointsToTeam( Points(), AllowNegativeScore() ); } @@ -194,7 +194,7 @@ LINK_ENTITY_TO_CLASS( game_end, CGameEnd ) void CGameEnd::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !CanFireForActivator( pActivator ) ) + if( !CanFireForActivator( pActivator ) ) return; g_pGameRules->EndMultiplayerGame(); @@ -239,27 +239,27 @@ IMPLEMENT_SAVERESTORE( CGameText, CRulePointEntity ) void CGameText::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "channel")) + if( FStrEq( pkvd->szKeyName, "channel" ) ) { m_textParms.channel = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "x")) + else if( FStrEq( pkvd->szKeyName, "x" ) ) { m_textParms.x = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "y")) + else if( FStrEq(pkvd->szKeyName, "y" ) ) { m_textParms.y = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "effect")) + else if( FStrEq( pkvd->szKeyName, "effect" ) ) { m_textParms.effect = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "color")) + else if( FStrEq( pkvd->szKeyName, "color" ) ) { int color[4]; UTIL_StringToIntArray( color, 4, pkvd->szValue ); @@ -269,7 +269,7 @@ void CGameText::KeyValue( KeyValueData *pkvd ) m_textParms.a1 = color[3]; pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "color2")) + else if( FStrEq( pkvd->szKeyName, "color2" ) ) { int color[4]; UTIL_StringToIntArray( color, 4, pkvd->szValue ); @@ -279,22 +279,22 @@ void CGameText::KeyValue( KeyValueData *pkvd ) m_textParms.a2 = color[3]; pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "fadein")) + else if( FStrEq( pkvd->szKeyName, "fadein" ) ) { m_textParms.fadeinTime = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "fadeout")) + else if( FStrEq( pkvd->szKeyName, "fadeout" ) ) { m_textParms.fadeoutTime = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "holdtime")) + else if( FStrEq( pkvd->szKeyName, "holdtime" ) ) { m_textParms.holdTime = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "fxtime")) + else if( FStrEq(pkvd->szKeyName, "fxtime" ) ) { m_textParms.fxTime = atof( pkvd->szValue ); pkvd->fHandled = TRUE; @@ -305,16 +305,16 @@ void CGameText::KeyValue( KeyValueData *pkvd ) void CGameText::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !CanFireForActivator( pActivator ) ) + if( !CanFireForActivator( pActivator ) ) return; - if ( MessageToAll() ) + if( MessageToAll() ) { UTIL_HudMessageAll( m_textParms, MessageGet() ); } else { - if ( pActivator->IsNetClient() ) + if( pActivator->IsNetClient() ) { UTIL_HudMessage( pActivator, m_textParms, MessageGet() ); } @@ -356,12 +356,12 @@ LINK_ENTITY_TO_CLASS( game_team_master, CGameTeamMaster ) void CGameTeamMaster::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "teamindex")) + if( FStrEq( pkvd->szKeyName, "teamindex" ) ) { m_teamIndex = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "triggerstate")) + else if( FStrEq( pkvd->szKeyName, "triggerstate" ) ) { int type = atoi( pkvd->szValue ); switch( type ) @@ -384,12 +384,12 @@ void CGameTeamMaster::KeyValue( KeyValueData *pkvd ) void CGameTeamMaster::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !CanFireForActivator( pActivator ) ) + if( !CanFireForActivator( pActivator ) ) return; - if ( useType == USE_SET ) + if( useType == USE_SET ) { - if ( value < 0 ) + if( value < 0 ) { m_teamIndex = -1; } @@ -400,10 +400,10 @@ void CGameTeamMaster::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY return; } - if ( TeamMatch( pActivator ) ) + if( TeamMatch( pActivator ) ) { SUB_UseTargets( pActivator, triggerType, value ); - if ( RemoveOnFire() ) + if( RemoveOnFire() ) UTIL_Remove( this ); } } @@ -415,7 +415,7 @@ BOOL CGameTeamMaster::IsTriggered( CBaseEntity *pActivator ) const char *CGameTeamMaster::TeamID( void ) { - if ( m_teamIndex < 0 ) // Currently set to "no team" + if( m_teamIndex < 0 ) // Currently set to "no team" return ""; return g_pGameRules->GetIndexedTeamName( m_teamIndex ); // UNDONE: Fill this in with the team from the "teamlist" @@ -423,10 +423,10 @@ const char *CGameTeamMaster::TeamID( void ) BOOL CGameTeamMaster::TeamMatch( CBaseEntity *pActivator ) { - if ( m_teamIndex < 0 && AnyTeam() ) + if( m_teamIndex < 0 && AnyTeam() ) return TRUE; - if ( !pActivator ) + if( !pActivator ) return FALSE; return UTIL_TeamsMatch( pActivator->TeamID(), TeamID() ); @@ -443,7 +443,7 @@ BOOL CGameTeamMaster::TeamMatch( CBaseEntity *pActivator ) class CGameTeamSet : public CRulePointEntity { public: - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); inline BOOL RemoveOnFire( void ) { return (pev->spawnflags & SF_TEAMSET_FIREONCE) ? TRUE : FALSE; } inline BOOL ShouldClearTeam( void ) { return (pev->spawnflags & SF_TEAMSET_CLEARTEAM) ? TRUE : FALSE; } @@ -454,10 +454,10 @@ LINK_ENTITY_TO_CLASS( game_team_set, CGameTeamSet ) void CGameTeamSet::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !CanFireForActivator( pActivator ) ) + if( !CanFireForActivator( pActivator ) ) return; - if ( ShouldClearTeam() ) + if( ShouldClearTeam() ) { SUB_UseTargets( pActivator, USE_SET, -1 ); } @@ -466,7 +466,7 @@ void CGameTeamSet::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE SUB_UseTargets( pActivator, USE_SET, 0 ); } - if ( RemoveOnFire() ) + if( RemoveOnFire() ) { UTIL_Remove( this ); } @@ -506,22 +506,22 @@ IMPLEMENT_SAVERESTORE( CGamePlayerZone, CRuleBrushEntity ) void CGamePlayerZone::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "intarget")) + if( FStrEq(pkvd->szKeyName, "intarget" ) ) { m_iszInTarget = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "outtarget")) + else if( FStrEq( pkvd->szKeyName, "outtarget" ) ) { m_iszOutTarget = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "incount")) + else if( FStrEq( pkvd->szKeyName, "incount" ) ) { m_iszInCount = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "outcount")) + else if( FStrEq( pkvd->szKeyName, "outcount" ) ) { m_iszOutCount = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; @@ -535,12 +535,12 @@ void CGamePlayerZone::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY int playersInCount = 0; int playersOutCount = 0; - if ( !CanFireForActivator( pActivator ) ) + if( !CanFireForActivator( pActivator ) ) return; CBaseEntity *pPlayer = NULL; - for ( int i = 1; i <= gpGlobals->maxClients; i++ ) + for( int i = 1; i <= gpGlobals->maxClients; i++ ) { pPlayer = UTIL_PlayerByIndex( i ); if ( pPlayer ) @@ -549,40 +549,40 @@ void CGamePlayerZone::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY int hullNumber; hullNumber = human_hull; - if ( pPlayer->pev->flags & FL_DUCKING ) + if( pPlayer->pev->flags & FL_DUCKING ) { hullNumber = head_hull; } UTIL_TraceModel( pPlayer->pev->origin, pPlayer->pev->origin, hullNumber, edict(), &trace ); - if ( trace.fStartSolid ) + if( trace.fStartSolid ) { playersInCount++; - if ( m_iszInTarget ) + if( m_iszInTarget ) { - FireTargets( STRING(m_iszInTarget), pPlayer, pActivator, useType, value ); + FireTargets( STRING( m_iszInTarget ), pPlayer, pActivator, useType, value ); } } else { playersOutCount++; - if ( m_iszOutTarget ) + if( m_iszOutTarget ) { - FireTargets( STRING(m_iszOutTarget), pPlayer, pActivator, useType, value ); + FireTargets( STRING( m_iszOutTarget ), pPlayer, pActivator, useType, value ); } } } } - if ( m_iszInCount ) + if( m_iszInCount ) { - FireTargets( STRING(m_iszInCount), pActivator, this, USE_SET, playersInCount ); + FireTargets( STRING( m_iszInCount ), pActivator, this, USE_SET, playersInCount ); } - if ( m_iszOutCount ) + if( m_iszOutCount ) { - FireTargets( STRING(m_iszOutCount), pActivator, this, USE_SET, playersOutCount ); + FireTargets( STRING( m_iszOutCount ), pActivator, this, USE_SET, playersOutCount ); } } @@ -605,12 +605,12 @@ LINK_ENTITY_TO_CLASS( game_player_hurt, CGamePlayerHurt ) void CGamePlayerHurt::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !CanFireForActivator( pActivator ) ) + if( !CanFireForActivator( pActivator ) ) return; - if ( pActivator->IsPlayer() ) + if( pActivator->IsPlayer() ) { - if ( pev->dmg < 0 ) + if( pev->dmg < 0 ) pActivator->TakeHealth( -pev->dmg, DMG_GENERIC ); else pActivator->TakeDamage( pev, pev, pev->dmg, DMG_GENERIC ); @@ -618,7 +618,7 @@ void CGamePlayerHurt::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY SUB_UseTargets( pActivator, useType, value ); - if ( RemoveOnFire() ) + if( RemoveOnFire() ) { UTIL_Remove( this ); } @@ -643,8 +643,8 @@ public: inline void CountUp( void ) { pev->frags++; } inline void CountDown( void ) { pev->frags--; } inline void ResetCount( void ) { pev->frags = pev->dmg; } - inline int CountValue( void ) { return pev->frags; } - inline int LimitValue( void ) { return pev->health; } + inline int CountValue( void ) { return (int)pev->frags; } + inline int LimitValue( void ) { return (int)pev->health; } inline BOOL HitLimit( void ) { return CountValue() == LimitValue(); } @@ -665,7 +665,7 @@ void CGameCounter::Spawn( void ) void CGameCounter::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !CanFireForActivator( pActivator ) ) + if( !CanFireForActivator( pActivator ) ) return; switch( useType ) @@ -681,16 +681,16 @@ void CGameCounter::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE SetCountValue( (int)value ); break; } - - if ( HitLimit() ) + + if( HitLimit() ) { SUB_UseTargets( pActivator, USE_TOGGLE, 0 ); - if ( RemoveOnFire() ) + if( RemoveOnFire() ) { UTIL_Remove( this ); } - - if ( ResetOnFire() ) + + if( ResetOnFire() ) { ResetCount(); } @@ -716,12 +716,12 @@ LINK_ENTITY_TO_CLASS( game_counter_set, CGameCounterSet ) void CGameCounterSet::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !CanFireForActivator( pActivator ) ) + if( !CanFireForActivator( pActivator ) ) return; SUB_UseTargets( pActivator, USE_SET, pev->frags ); - if ( RemoveOnFire() ) + if( RemoveOnFire() ) { UTIL_Remove( this ); } @@ -756,19 +756,19 @@ void CGamePlayerEquip::KeyValue( KeyValueData *pkvd ) { CRulePointEntity::KeyValue( pkvd ); - if ( !pkvd->fHandled ) + if( !pkvd->fHandled ) { - for ( int i = 0; i < MAX_EQUIP; i++ ) + for( int i = 0; i < MAX_EQUIP; i++ ) { - if ( !m_weaponNames[i] ) + if( !m_weaponNames[i] ) { char tmp[128]; UTIL_StripToken( pkvd->szKeyName, tmp ); - m_weaponNames[i] = ALLOC_STRING(tmp); - m_weaponCount[i] = atoi(pkvd->szValue); - m_weaponCount[i] = max(1,m_weaponCount[i]); + m_weaponNames[i] = ALLOC_STRING( tmp ); + m_weaponCount[i] = atoi( pkvd->szValue ); + m_weaponCount[i] = Q_max( 1, m_weaponCount[i] ); pkvd->fHandled = TRUE; break; } @@ -778,10 +778,10 @@ void CGamePlayerEquip::KeyValue( KeyValueData *pkvd ) void CGamePlayerEquip::Touch( CBaseEntity *pOther ) { - if ( !CanFireForActivator( pOther ) ) + if( !CanFireForActivator( pOther ) ) return; - if ( UseOnly() ) + if( UseOnly() ) return; EquipPlayer( pOther ); @@ -791,21 +791,21 @@ void CGamePlayerEquip::EquipPlayer( CBaseEntity *pEntity ) { CBasePlayer *pPlayer = NULL; - if ( pEntity->IsPlayer() ) + if( pEntity->IsPlayer() ) { pPlayer = (CBasePlayer *)pEntity; } - if ( !pPlayer ) + if( !pPlayer ) return; - for ( int i = 0; i < MAX_EQUIP; i++ ) + for( int i = 0; i < MAX_EQUIP; i++ ) { - if ( !m_weaponNames[i] ) + if( !m_weaponNames[i] ) break; - for ( int j = 0; j < m_weaponCount[i]; j++ ) + for( int j = 0; j < m_weaponCount[i]; j++ ) { - pPlayer->GiveNamedItem( STRING(m_weaponNames[i]) ); + pPlayer->GiveNamedItem( STRING( m_weaponNames[i] ) ); } } } @@ -844,9 +844,9 @@ const char *CGamePlayerTeam::TargetTeamName( const char *pszTargetName ) { CBaseEntity *pTeamEntity = NULL; - while ((pTeamEntity = UTIL_FindEntityByTargetname( pTeamEntity, pszTargetName )) != NULL) + while( ( pTeamEntity = UTIL_FindEntityByTargetname( pTeamEntity, pszTargetName ) ) != NULL ) { - if ( FClassnameIs( pTeamEntity->pev, "game_team_master" ) ) + if( FClassnameIs( pTeamEntity->pev, "game_team_master" ) ) return pTeamEntity->TeamID(); } @@ -855,10 +855,10 @@ const char *CGamePlayerTeam::TargetTeamName( const char *pszTargetName ) void CGamePlayerTeam::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !CanFireForActivator( pActivator ) ) + if( !CanFireForActivator( pActivator ) ) return; - if ( pActivator->IsPlayer() ) + if( pActivator->IsPlayer() ) { const char *pszTargetTeam = TargetTeamName( STRING(pev->target) ); if ( pszTargetTeam ) @@ -868,7 +868,7 @@ void CGamePlayerTeam::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY } } - if ( RemoveOnFire() ) + if( RemoveOnFire() ) { UTIL_Remove( this ); } diff --git a/dlls/monsters.cpp b/dlls/monsters.cpp index d034abd6..953d1a69 100644 --- a/dlls/monsters.cpp +++ b/dlls/monsters.cpp @@ -133,7 +133,7 @@ int CBaseMonster::Restore( CRestore &restore ) m_Activity = ACT_RESET; // If we don't have an enemy, clear conditions like see enemy, etc. - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) m_afConditions = 0; return status; @@ -334,12 +334,10 @@ void CBaseMonster::Look( int iDistance ) { if( pev->spawnflags & SF_MONSTER_WAIT_TILL_SEEN ) { - CBaseMonster *pClient; - - pClient = pSightEnt->MyMonsterPointer(); + CBaseMonster *pClient = pSightEnt->MyMonsterPointer(); // don't link this client in the list if the monster is wait till seen and the player isn't facing the monster - if( pSightEnt && !pClient->FInViewCone( this ) ) + if( pClient && !pClient->FInViewCone( this ) ) { // we're not in the player's view cone. continue; @@ -672,7 +670,7 @@ BOOL CBaseMonster::FRefreshRoute( void ) returnCode = BuildRoute( m_vecMoveGoal, bits_MF_TO_LOCATION, NULL ); break; case MOVEGOAL_TARGETENT: - if( m_hTargetEnt != NULL ) + if( m_hTargetEnt != 0 ) { returnCode = BuildRoute( m_hTargetEnt->pev->origin, bits_MF_TO_TARGETENT, m_hTargetEnt ); } @@ -954,7 +952,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 != NULL && FBitSet( m_hEnemy->pev->flags, FL_ONGROUND ) ) + if( flDist <= 64 && flDot >= 0.7 && m_hEnemy != 0 && FBitSet( m_hEnemy->pev->flags, FL_ONGROUND ) ) { return TRUE; } @@ -1165,7 +1163,7 @@ void CBaseMonster::PushEnemy( CBaseEntity *pEnemy, Vector &vecLastKnownPos ) { if( m_hOldEnemy[i] == pEnemy ) return; - if( m_hOldEnemy[i] == NULL ) // someone died, reuse their slot + if( m_hOldEnemy[i] == 0 ) // someone died, reuse their slot break; } if( i >= MAX_OLD_ENEMIES ) @@ -1183,7 +1181,7 @@ BOOL CBaseMonster::PopEnemy() // UNDONE: blah, this is bad, we should use a stack but I'm too lazy to code one. for( int i = MAX_OLD_ENEMIES - 1; i >= 0; i-- ) { - if( m_hOldEnemy[i] != NULL ) + if( m_hOldEnemy[i] != 0 ) { if( m_hOldEnemy[i]->IsAlive()) // cheat and know when they die { @@ -1240,7 +1238,7 @@ void CBaseMonster::SetActivity( Activity NewActivity ) //========================================================= // SetSequenceByName //========================================================= -void CBaseMonster::SetSequenceByName( char *szSequence ) +void CBaseMonster::SetSequenceByName( const char *szSequence ) { int iSequence; @@ -1961,7 +1959,7 @@ void CBaseMonster::MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, f while( flTotal > 0.001 ) { // don't walk more than 16 units or stairs stop working - flStep = min( 16.0, flTotal ); + flStep = Q_min( 16.0, flTotal ); UTIL_MoveToOrigin( ENT( pev ), m_Route[m_iRouteIndex].vecLocation, flStep, MOVE_NORMAL ); flTotal -= flStep; } @@ -2120,7 +2118,8 @@ void CBaseMonster::StartMonster( void ) SetThink( &CBaseMonster::CallMonsterThink ); pev->nextthink += RANDOM_FLOAT( 0.1, 0.4 ); // spread think times. - if( !FStringNull( pev->targetname ) )// wait until triggered + // Vit_amiN: fixed -- now it doesn't touch any scripted_sequence target + if( !FStringNull( pev->targetname ) && !m_pCine )// wait until triggered { SetState( MONSTERSTATE_IDLE ); // UNDONE: Some scripted sequence monsters don't have an idle? @@ -2863,7 +2862,7 @@ void CBaseMonster::ReportAIState( void ) else ALERT( level, "No Schedule, " ); - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) ALERT( level, "\nEnemy is %s", STRING( m_hEnemy->pev->classname ) ); else ALERT( level, "No enemy" ); @@ -2950,7 +2949,7 @@ BOOL CBaseMonster::FCheckAITrigger( void ) switch( m_iTriggerCondition ) { case AITRIGGER_SEEPLAYER_ANGRY_AT_PLAYER: - if( m_hEnemy != NULL && m_hEnemy->IsPlayer() && HasConditions( bits_COND_SEE_ENEMY ) ) + if( m_hEnemy != 0 && m_hEnemy->IsPlayer() && HasConditions( bits_COND_SEE_ENEMY ) ) { fFireTarget = TRUE; } @@ -3321,7 +3320,7 @@ BOOL CBaseMonster::GetEnemy( void ) } // remember old enemies - if( m_hEnemy == NULL && PopEnemy() ) + if( m_hEnemy == 0 && PopEnemy() ) { if( m_pSchedule ) { @@ -3332,7 +3331,7 @@ BOOL CBaseMonster::GetEnemy( void ) } } - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { // monster has an enemy. return TRUE; @@ -3344,7 +3343,7 @@ BOOL CBaseMonster::GetEnemy( void ) //========================================================= // DropItem - dead monster drops named item //========================================================= -CBaseEntity *CBaseMonster::DropItem( char *pszItemName, const Vector &vecPos, const Vector &vecAng ) +CBaseEntity *CBaseMonster::DropItem( const char *pszItemName, const Vector &vecPos, const Vector &vecAng ) { if( !pszItemName ) { @@ -3359,6 +3358,9 @@ CBaseEntity *CBaseMonster::DropItem( char *pszItemName, const Vector &vecPos, co // do we want this behavior to be default?! (sjb) pItem->pev->velocity = pev->velocity; pItem->pev->avelocity = Vector( 0, RANDOM_FLOAT( 0, 100 ), 0 ); + + // Dropped items should never respawn (unless this rule changes in the future). - Solokiller + pItem->pev->spawnflags |= SF_NORESPAWN; return pItem; } else diff --git a/dlls/monsters.h b/dlls/monsters.h index 6f2df294..4aeca3a9 100644 --- a/dlls/monsters.h +++ b/dlls/monsters.h @@ -12,6 +12,7 @@ * use or distribution of this code by or to any unlicensed person is illegal. * ****/ +#pragma once #ifndef MONSTERS_H #include "skill.h" #define MONSTERS_H diff --git a/dlls/monsterstate.cpp b/dlls/monsterstate.cpp index f29664dc..cec29b79 100644 --- a/dlls/monsterstate.cpp +++ b/dlls/monsterstate.cpp @@ -42,7 +42,7 @@ void CBaseMonster::SetState( MONSTERSTATE State ) // Drop enemy pointers when going to idle case MONSTERSTATE_IDLE: - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { m_hEnemy = NULL;// not allowed to have an enemy anymore. ALERT( at_aiconsole, "Stripped\n" ); @@ -92,7 +92,7 @@ void CBaseMonster::RunAI( void ) } // do these calculations if monster has an enemy. - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { CheckEnemy( m_hEnemy ); } @@ -198,7 +198,7 @@ MONSTERSTATE CBaseMonster::GetIdealState( void ) COMBAT goes to ALERT upon death of enemy */ { - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { m_IdealMonsterState = MONSTERSTATE_ALERT; // pev->effects = EF_BRIGHTFIELD; diff --git a/dlls/mortar.cpp b/dlls/mortar.cpp index 33a7d2da..e8c7bef3 100644 --- a/dlls/mortar.cpp +++ b/dlls/mortar.cpp @@ -45,8 +45,8 @@ public: void EXPORT FieldUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - int m_iszXController; - int m_iszYController; + string_t m_iszXController; + string_t m_iszYController; float m_flSpread; float m_flDelay; int m_iCount; @@ -197,6 +197,7 @@ public: void EXPORT MortarExplode( void ); int m_spriteTexture; + int m_blastwave; }; LINK_ENTITY_TO_CLASS( monster_mortar, CMortar ) @@ -217,6 +218,7 @@ void CMortar::Spawn() void CMortar::Precache() { m_spriteTexture = PRECACHE_MODEL( "sprites/lgtning.spr" ); + m_blastwave = PRECACHE_MODEL( "sprites/xbeam3.spr" ); } void CMortar::MortarExplode( void ) @@ -245,7 +247,7 @@ void CMortar::MortarExplode( void ) MESSAGE_END(); #endif -#if 0 +#if 1 // blast circle MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_BEAMTORUS ); @@ -255,7 +257,7 @@ void CMortar::MortarExplode( void ) WRITE_COORD( pev->origin.x ); WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.z + 32 + pev->dmg * 2 / .2 ); // reach damage radius over .3 seconds - WRITE_SHORT( m_spriteTexture ); + WRITE_SHORT( m_blastwave ); WRITE_BYTE( 0 ); // startframe WRITE_BYTE( 0 ); // framerate WRITE_BYTE( 2 ); // life diff --git a/dlls/mp5.cpp b/dlls/mp5.cpp index 7d05d5e1..4226a825 100644 --- a/dlls/mp5.cpp +++ b/dlls/mp5.cpp @@ -22,6 +22,7 @@ #include "player.h" #include "soundent.h" #include "gamerules.h" +#include "nail.h" enum mp5_e { @@ -32,24 +33,20 @@ enum mp5_e MP5_DEPLOY, MP5_FIRE1, MP5_FIRE2, - MP5_FIRE3 + MP5_FIRE3, + MP5_DEPLOY_EMPTY, + MP5_LONGIDLE_EMPTY, + MP5_IDLE1_EMPTY }; -LINK_ENTITY_TO_CLASS( weapon_mp5, CMP5 ) -LINK_ENTITY_TO_CLASS( weapon_9mmAR, CMP5 ) +LINK_ENTITY_TO_CLASS( weapon_nailgun, CMP5 ) //========================================================= //========================================================= -int CMP5::SecondaryAmmoIndex( void ) -{ - return m_iSecondaryAmmoType; -} - void CMP5::Spawn() { - pev->classname = MAKE_STRING( "weapon_9mmAR" ); // hack to allow for old names Precache(); - SET_MODEL( ENT( pev ), "models/w_9mmAR.mdl" ); + SET_MODEL( ENT( pev ), "models/w_nailgun.mdl" ); m_iId = WEAPON_MP5; m_iDefaultAmmo = MP5_DEFAULT_GIVE; @@ -59,31 +56,19 @@ void CMP5::Spawn() void CMP5::Precache( void ) { - PRECACHE_MODEL( "models/v_9mmAR.mdl" ); - PRECACHE_MODEL( "models/w_9mmAR.mdl" ); - PRECACHE_MODEL( "models/p_9mmAR.mdl" ); + PRECACHE_MODEL( "models/v_nailgun.mdl" ); + PRECACHE_MODEL( "models/w_nailgun.mdl" ); + PRECACHE_MODEL( "models/p_nailgun.mdl" ); - m_iShell = PRECACHE_MODEL( "models/shell.mdl" );// brass shellTE_MODEL - - PRECACHE_MODEL( "models/grenade.mdl" ); // grenade - - PRECACHE_MODEL( "models/w_9mmARclip.mdl" ); + PRECACHE_MODEL( "models/w_nailround.mdl" ); PRECACHE_SOUND( "items/9mmclip1.wav" ); PRECACHE_SOUND( "items/clipinsert1.wav" ); PRECACHE_SOUND( "items/cliprelease1.wav" ); - PRECACHE_SOUND( "weapons/hks1.wav" );// H to the K - PRECACHE_SOUND( "weapons/hks2.wav" );// H to the K - PRECACHE_SOUND( "weapons/hks3.wav" );// H to the K + PRECACHE_SOUND( "weapons/nailgun.wav" ); - PRECACHE_SOUND( "weapons/glauncher.wav" ); - PRECACHE_SOUND( "weapons/glauncher2.wav" ); - - PRECACHE_SOUND( "weapons/357_cock1.wav" ); - - m_usMP5 = PRECACHE_EVENT( 1, "events/mp5.sc" ); - m_usMP52 = PRECACHE_EVENT( 1, "events/mp52.sc" ); + UTIL_PrecacheOther( "nailgun_nail" ); } int CMP5::GetItemInfo( ItemInfo *p ) @@ -91,11 +76,11 @@ int CMP5::GetItemInfo( ItemInfo *p ) p->pszName = STRING( pev->classname ); p->pszAmmo1 = "9mm"; p->iMaxAmmo1 = _9MM_MAX_CARRY; - p->pszAmmo2 = "ARgrenades"; - p->iMaxAmmo2 = M203_GRENADE_MAX_CARRY; + p->pszAmmo2 = NULL; + p->iMaxAmmo2 = -1; p->iMaxClip = MP5_MAX_CLIP; - p->iSlot = 2; - p->iPosition = 0; + p->iSlot = 1; + p->iPosition = 1; p->iFlags = 0; p->iId = m_iId = WEAPON_MP5; p->iWeight = MP5_WEIGHT; @@ -117,7 +102,7 @@ int CMP5::AddToPlayer( CBasePlayer *pPlayer ) BOOL CMP5::Deploy() { - return DefaultDeploy( "models/v_9mmAR.mdl", "models/p_9mmAR.mdl", MP5_DEPLOY, "mp5" ); + return DefaultDeploy( "models/v_nailgun.mdl", "models/p_nailgun.mdl", m_iClip ? MP5_DEPLOY : MP5_DEPLOY_EMPTY, "mp5" ); } void CMP5::PrimaryAttack() @@ -126,119 +111,67 @@ void CMP5::PrimaryAttack() if( m_pPlayer->pev->waterlevel == 3 ) { PlayEmptySound(); - m_flNextPrimaryAttack = 0.15; + m_flNextPrimaryAttack = 0.3; return; } if( m_iClip <= 0 ) { PlayEmptySound(); - m_flNextPrimaryAttack = 0.15; + m_flNextPrimaryAttack = 0.3; return; } m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME; - m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH; m_iClip--; - m_pPlayer->pev->effects = (int)( m_pPlayer->pev->effects ) | EF_MUZZLEFLASH; + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/nailgun.wav", 1.0, ATTN_NORM, 0, 94 + RANDOM_LONG( 0, 15 ) ); + + SendWeaponAnim( MP5_FIRE1 + RANDOM_LONG( 0, 2 ) ); + + // m_pPlayer->pev->effects = (int)( m_pPlayer->pev->effects ) | EF_MUZZLEFLASH; // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); - Vector vecSrc = m_pPlayer->GetGunPosition(); - Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES ); - Vector vecDir; -#ifdef CLIENT_DLL - if( !bIsMultiplayer() ) -#else - if( !g_pGameRules->IsMultiplayer() ) -#endif - { - // optimized multiplayer. Widened to make it easier to hit a moving player - vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, VECTOR_CONE_6DEGREES, 8192, BULLET_PLAYER_MP5, 2, 0, m_pPlayer->pev, m_pPlayer->random_seed ); - } - else - { - // single player spread - vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, VECTOR_CONE_3DEGREES, 8192, BULLET_PLAYER_MP5, 2, 0, m_pPlayer->pev, m_pPlayer->random_seed ); + Vector vecAngles = m_pPlayer->pev->punchangle + m_pPlayer->pev->v_angle; + UTIL_MakeVectors( vecAngles ); + vecAngles.x = -vecAngles.x; + + Vector vecSrc = m_pPlayer->GetGunPosition() - gpGlobals->v_up * 3 + gpGlobals->v_right * 3; + float flSpread = 0.0349; + + float x, y; + 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 ); } + while( x * x + y * y > 1.0f ); - int flags; -#if defined( CLIENT_WEAPONS ) - flags = FEV_NOTHOST; -#else - flags = 0; -#endif - PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usMP5, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, 0, 0 ); + Vector vecSpread = x * flSpread * gpGlobals->v_up + y * flSpread * gpGlobals->v_right + gpGlobals->v_forward; + Vector vecDest = vecSrc + vecSpread * 2048.0f; - if( !m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) - // HEV suit - indicate out of ammo condition - m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 ); + UTIL_MakeTracer( vecSrc, vecDest ); - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.1; - - if( m_flNextPrimaryAttack < UTIL_WeaponTimeBase() ) - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.1; + CNailGunNail *pNail = CNailGunNail::NailCreate( FALSE ); + pNail->pev->origin = vecSrc; + pNail->pev->angles = vecAngles; + pNail->pev->owner = m_pPlayer->edict(); + pNail->pev->velocity = vecSpread * 1600.0f; + pNail->pev->speed = 1600.0f; + pNail->pev->avelocity.z = 30; + m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.1f; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); -} - -void CMP5::SecondaryAttack( void ) -{ - // don't fire underwater - if( m_pPlayer->pev->waterlevel == 3 ) - { - PlayEmptySound( ); - m_flNextPrimaryAttack = 0.15; - return; - } - - if( m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType] == 0 ) - { - PlayEmptySound(); - return; - } - - m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME; - 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_rgAmmo[m_iSecondaryAmmoType]--; - - // player "shoot" animation - m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); - - UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle ); - - // 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 ); - - int flags; -#if defined( CLIENT_WEAPONS ) - flags = FEV_NOTHOST; -#else - flags = 0; -#endif - PLAYBACK_EVENT( flags, m_pPlayer->edict(), m_usMP52 ); - - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1; - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5;// idle pretty soon after shooting. - - if( !m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType] ) - // HEV suit - indicate out of ammo condition - m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 ); + if( !m_iClip ) + SendWeaponAnim( MP5_LONGIDLE_EMPTY ); + m_pPlayer->pev->punchangle.x -= 1.0f; } void CMP5::Reload( void ) { - if( m_pPlayer->ammo_9mm <= 0 ) + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == MP5_MAX_CLIP ) return; DefaultReload( MP5_MAX_CLIP, MP5_RELOAD, 1.5 ); @@ -248,8 +181,6 @@ void CMP5::WeaponIdle( void ) { ResetEmptySound(); - m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES ); - if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) return; @@ -257,11 +188,11 @@ void CMP5::WeaponIdle( void ) switch( RANDOM_LONG( 0, 1 ) ) { case 0: - iAnim = MP5_LONGIDLE; + iAnim = m_iClip ? MP5_LONGIDLE : MP5_LONGIDLE_EMPTY; break; default: case 1: - iAnim = MP5_IDLE1; + iAnim = m_iClip ? MP5_IDLE1 : MP5_IDLE1_EMPTY; break; } @@ -275,12 +206,12 @@ class CMP5AmmoClip : public CBasePlayerAmmo void Spawn( void ) { Precache(); - SET_MODEL( ENT( pev ), "models/w_9mmARclip.mdl" ); + SET_MODEL( ENT( pev ), "models/w_nailround.mdl" ); CBasePlayerAmmo::Spawn(); } void Precache( void ) { - PRECACHE_MODEL( "models/w_9mmARclip.mdl" ); + PRECACHE_MODEL( "models/w_nailround.mdl" ); PRECACHE_SOUND( "items/9mmclip1.wav" ); } BOOL AddAmmo( CBaseEntity *pOther ) @@ -294,59 +225,4 @@ class CMP5AmmoClip : public CBasePlayerAmmo } }; -LINK_ENTITY_TO_CLASS( ammo_mp5clip, CMP5AmmoClip ) -LINK_ENTITY_TO_CLASS( ammo_9mmAR, CMP5AmmoClip ) - -class CMP5Chainammo : public CBasePlayerAmmo -{ - void Spawn( void ) - { - Precache(); - SET_MODEL( ENT( pev ), "models/w_chainammo.mdl" ); - CBasePlayerAmmo::Spawn(); - } - void Precache( void ) - { - PRECACHE_MODEL( "models/w_chainammo.mdl" ); - PRECACHE_SOUND( "items/9mmclip1.wav" ); - } - BOOL AddAmmo( CBaseEntity *pOther ) - { - int bResult = ( pOther->GiveAmmo( AMMO_CHAINBOX_GIVE, "9mm", _9MM_MAX_CARRY ) != -1 ); - if( bResult ) - { - EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM ); - } - return bResult; - } -}; - -LINK_ENTITY_TO_CLASS( ammo_9mmbox, CMP5Chainammo ) - -class CMP5AmmoGrenade : public CBasePlayerAmmo -{ - void Spawn( void ) - { - Precache(); - SET_MODEL( ENT( pev ), "models/w_ARgrenade.mdl" ); - CBasePlayerAmmo::Spawn(); - } - void Precache( void ) - { - PRECACHE_MODEL( "models/w_ARgrenade.mdl" ); - PRECACHE_SOUND( "items/9mmclip1.wav" ); - } - BOOL AddAmmo( CBaseEntity *pOther ) - { - int bResult = ( pOther->GiveAmmo( AMMO_M203BOX_GIVE, "ARgrenades", M203_GRENADE_MAX_CARRY ) != -1 ); - - if( bResult ) - { - EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM ); - } - return bResult; - } -}; - -LINK_ENTITY_TO_CLASS( ammo_mp5grenades, CMP5AmmoGrenade ) -LINK_ENTITY_TO_CLASS( ammo_ARgrenades, CMP5AmmoGrenade ) +LINK_ENTITY_TO_CLASS( ammo_nailround, CMP5AmmoClip ) diff --git a/dlls/mpstubb.cpp b/dlls/mpstubb.cpp index 703a4dba..12b3a82f 100644 --- a/dlls/mpstubb.cpp +++ b/dlls/mpstubb.cpp @@ -230,7 +230,7 @@ CBaseEntity *CBaseMonster::BestVisibleEnemy( void ) // currently think is the best visible enemy. No need to do // a distance check, just get mad at this one for now. iBestRelationship = IRelationship( pNextEnt ); - iNearest = ( pNextEnt->pev->origin - pev->origin ).Length(); + (int)iNearest = ( pNextEnt->pev->origin - pev->origin ).Length(); pReturn = pNextEnt; } else if( IRelationship( pNextEnt ) == iBestRelationship ) @@ -238,7 +238,7 @@ CBaseEntity *CBaseMonster::BestVisibleEnemy( void ) // this entity is disliked just as much as the entity that // we currently think is the best visible enemy, so we only // get mad at it if it is closer. - iDist = ( pNextEnt->pev->origin - pev->origin ).Length(); + (int)iDist = ( pNextEnt->pev->origin - pev->origin ).Length(); if( iDist <= iNearest ) { diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index 929c2bf6..73f422e2 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -92,7 +92,7 @@ CHalfLifeMultiplay::CHalfLifeMultiplay() if( IS_DEDICATED_SERVER() ) { // dedicated server - char *servercfgfile = (char *)CVAR_GET_STRING( "servercfgfile" ); + /*const char *servercfgfile = CVAR_GET_STRING( "servercfgfile" ); if( servercfgfile && servercfgfile[0] ) { @@ -102,11 +102,13 @@ CHalfLifeMultiplay::CHalfLifeMultiplay() sprintf( szCommand, "exec %s\n", servercfgfile ); SERVER_COMMAND( szCommand ); } + */ + // this code has been moved into engine, to only run server.cfg once } else { // listen server - char *lservercfgfile = (char *)CVAR_GET_STRING( "lservercfgfile" ); + const char *lservercfgfile = CVAR_GET_STRING( "lservercfgfile" ); if( lservercfgfile && lservercfgfile[0] ) { @@ -254,7 +256,7 @@ void CHalfLifeMultiplay::Think( void ) if( pPlayer ) { - remain = flFragLimit - pPlayer->pev->frags; + remain = (int)( flFragLimit - pPlayer->pev->frags ); if( remain < bestfrags ) { bestfrags = remain; @@ -298,7 +300,7 @@ BOOL CHalfLifeMultiplay::IsDeathmatch( void ) //========================================================= BOOL CHalfLifeMultiplay::IsCoOp( void ) { - return gpGlobals->coop; + return gpGlobals->coop ? TRUE : FALSE; } //========================================================= @@ -404,7 +406,8 @@ BOOL CHalfLifeMultiplay::ClientConnected( edict_t *pEntity, const char *pszName, #ifndef NO_VOICEGAMEMGR g_VoiceGameMgr.ClientConnected( pEntity ); #endif - return TRUE; + ALERT( at_error, "Sorry, there's no multiplayer mode in Poke646!\n" ); + return FALSE; } extern int gmsgSayText; @@ -421,7 +424,7 @@ void CHalfLifeMultiplay::InitHUD( CBasePlayer *pl ) { // notify other clients of player joining the game UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs( "%s has joined the game\n", - ( pl->pev->netname && STRING( pl->pev->netname )[0] != 0 ) ? STRING( pl->pev->netname ) : "unconnected" ) ); + ( pl->pev->netname && ( STRING( pl->pev->netname ) )[0] != 0 ) ? STRING( pl->pev->netname ) : "unconnected" ) ); // team match? if( g_teamplay ) @@ -465,7 +468,7 @@ void CHalfLifeMultiplay::InitHUD( CBasePlayer *pl ) { MESSAGE_BEGIN( MSG_ONE, gmsgScoreInfo, NULL, pl->edict() ); WRITE_BYTE( i ); // client number - WRITE_SHORT( plr->pev->frags ); + WRITE_SHORT( (int)plr->pev->frags ); WRITE_SHORT( plr->m_iDeaths ); WRITE_SHORT( 0 ); WRITE_SHORT( GetTeamIndex( plr->m_szTeamName ) + 1 ); @@ -650,7 +653,7 @@ void CHalfLifeMultiplay::PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, // killed scores MESSAGE_BEGIN( MSG_ALL, gmsgScoreInfo ); WRITE_BYTE( ENTINDEX(pVictim->edict()) ); - WRITE_SHORT( pVictim->pev->frags ); + WRITE_SHORT( (int)pVictim->pev->frags ); WRITE_SHORT( pVictim->m_iDeaths ); WRITE_SHORT( 0 ); WRITE_SHORT( GetTeamIndex( pVictim->m_szTeamName ) + 1 ); @@ -664,7 +667,7 @@ void CHalfLifeMultiplay::PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, MESSAGE_BEGIN( MSG_ALL, gmsgScoreInfo ); WRITE_BYTE( ENTINDEX( PK->edict() ) ); - WRITE_SHORT( PK->pev->frags ); + WRITE_SHORT( (int)PK->pev->frags ); WRITE_SHORT( PK->m_iDeaths ); WRITE_SHORT( 0 ); WRITE_SHORT( GetTeamIndex( PK->m_szTeamName ) + 1 ); @@ -673,12 +676,6 @@ void CHalfLifeMultiplay::PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, // let the killer paint another decal as soon as he'd like. PK->m_flNextDecalTime = gpGlobals->time; } -#ifndef HLDEMO_BUILD - if( pVictim->HasNamedPlayerItem( "weapon_satchel" ) ) - { - DeactivateSatchels( pVictim ); - } -#endif } //========================================================= @@ -687,14 +684,14 @@ void CHalfLifeMultiplay::PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, void CHalfLifeMultiplay::DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pevInflictor ) { // Work out what killed the player, and send a message to all clients about it - CBaseEntity *Killer = CBaseEntity::Instance( pKiller ); + CBaseEntity::Instance( pKiller ); const char *killer_weapon_name = "world"; // by default, the player is killed by the world int killer_index = 0; // Hack to fix name change - char *tau = "tau_cannon"; - char *gluon = "gluon gun"; + const char *tau = "tau_cannon"; + const char *gluon = "gluon gun"; if( pKiller->flags & FL_CLIENT ) { @@ -1218,7 +1215,7 @@ COM_Parse Parse a token out of a string ============== */ -char *COM_Parse( char *data ) +const char *COM_Parse( const char *data ) { int c; int len; @@ -1294,9 +1291,9 @@ COM_TokenWaiting Returns 1 if additional data is waiting to be processed on this line ============== */ -int COM_TokenWaiting( char *buffer ) +int COM_TokenWaiting( const char *buffer ) { - char *p; + const char *p; p = buffer; while( *p && *p!='\n') @@ -1317,12 +1314,12 @@ ReloadMapCycleFile Parses mapcycle.txt file into mapcycle_t structure ============== */ -int ReloadMapCycleFile( char *filename, mapcycle_t *cycle ) +int ReloadMapCycleFile( const char *filename, mapcycle_t *cycle ) { char szMap[32]; int length; - char *pFileList; - char *aFileList = pFileList = (char*)LOAD_FILE_FOR_ME( filename, &length ); + const char *pFileList; + const char *aFileList = pFileList = (const char *)LOAD_FILE_FOR_ME( filename, &length ); int hasbuffer; mapcycle_item_s *item, *newlist = NULL, *next; @@ -1372,15 +1369,15 @@ int ReloadMapCycleFile( char *filename, mapcycle_t *cycle ) if( s && s[0] ) { item->minplayers = atoi( s ); - item->minplayers = max( item->minplayers, 0 ); - item->minplayers = min( item->minplayers, gpGlobals->maxClients ); + item->minplayers = Q_max( item->minplayers, 0 ); + item->minplayers = Q_min( item->minplayers, gpGlobals->maxClients ); } s = g_engfuncs.pfnInfoKeyValue( szBuffer, "maxplayers" ); if( s && s[0] ) { item->maxplayers = atoi( s ); - item->maxplayers = max( item->maxplayers, 0 ); - item->maxplayers = min( item->maxplayers, gpGlobals->maxClients ); + item->maxplayers = Q_max( item->maxplayers, 0 ); + item->maxplayers = Q_min( item->maxplayers, gpGlobals->maxClients ); } // Remove keys @@ -1400,7 +1397,7 @@ int ReloadMapCycleFile( char *filename, mapcycle_t *cycle ) } } - FREE_FILE( aFileList ); + FREE_FILE( (void*)aFileList ); } // Fixup circular list pointer @@ -1536,7 +1533,7 @@ void CHalfLifeMultiplay::ChangeLevel( void ) BOOL do_cycle = TRUE; // find the map to change to - char *mapcfile = (char*)CVAR_GET_STRING( "mapcyclefile" ); + const char *mapcfile = CVAR_GET_STRING( "mapcyclefile" ); ASSERT( mapcfile != NULL ); szCommands[0] = '\0'; @@ -1655,7 +1652,7 @@ void CHalfLifeMultiplay::SendMOTDToClient( edict_t *client ) // read from the MOTD.txt file int length, char_count = 0; char *pFileList; - char *aFileList = pFileList = (char*)LOAD_FILE_FOR_ME( (char *)CVAR_GET_STRING( "motdfile" ), &length ); + char *aFileList = pFileList = (char*)LOAD_FILE_FOR_ME( CVAR_GET_STRING( "motdfile" ), &length ); // send the server name MESSAGE_BEGIN( MSG_ONE, gmsgServerName, NULL, client ); @@ -1691,5 +1688,5 @@ void CHalfLifeMultiplay::SendMOTDToClient( edict_t *client ) MESSAGE_END(); } - FREE_FILE( aFileList ); + FREE_FILE( (void*)aFileList ); } diff --git a/dlls/nihilanth.cpp b/dlls/nihilanth.cpp index 58317b3c..1d072db4 100644 --- a/dlls/nihilanth.cpp +++ b/dlls/nihilanth.cpp @@ -34,6 +34,7 @@ public: void Spawn( void ); void Precache( void ); + void UpdateOnRemove(); int Classify( void ) { return CLASS_ALIEN_MILITARY; }; int BloodColor( void ) { return BLOOD_COLOR_YELLOW; } void Killed( entvars_t *pevAttacker, int iGib ); @@ -345,6 +346,26 @@ void CNihilanth::Precache( void ) PRECACHE_SOUND( "debris/beamstart7.wav" ); } +void CNihilanth::UpdateOnRemove() +{ + CBaseEntity::UpdateOnRemove(); + + if( m_pBall ) + { + UTIL_Remove( m_pBall ); + m_pBall = 0; + } + + for( int i = 0; i < N_SPHERES; i++ ) + { + if( CBaseEntity* pSphere = (CBaseEntity *)m_hSphere[i] ) + { + UTIL_Remove( pSphere ); + m_hSphere[i] = 0; + } + } +} + void CNihilanth::PainSound( void ) { if( m_flNextPainSound > gpGlobals->time ) @@ -457,7 +478,7 @@ void CNihilanth::DyingThink( void ) { if( m_pBall->pev->renderamt > 0 ) { - m_pBall->pev->renderamt = max( 0, m_pBall->pev->renderamt - 2 ); + m_pBall->pev->renderamt = Q_max( 0, m_pBall->pev->renderamt - 2 ); } else { @@ -587,7 +608,7 @@ void CNihilanth::ShootBalls( void ) while( m_flShootTime < m_flShootEnd && m_flShootTime < gpGlobals->time ) { - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { Vector vecSrc, vecDir; CNihilanthHVR *pEntity; @@ -621,14 +642,14 @@ void CNihilanth::MakeFriend( Vector vecStart ) for( i = 0; i < 3; i++ ) { - if( m_hFriend[i] != NULL && !m_hFriend[i]->IsAlive() ) + if( m_hFriend[i] != 0 && !m_hFriend[i]->IsAlive() ) { if( pev->rendermode == kRenderNormal ) // don't do it if they are already fading m_hFriend[i]->MyMonsterPointer()->FadeMonster(); m_hFriend[i] = NULL; } - if( m_hFriend[i] == NULL ) + if( m_hFriend[i] == 0 ) { if( RANDOM_LONG( 0, 1 ) == 0 ) { @@ -654,7 +675,7 @@ void CNihilanth::MakeFriend( Vector vecStart ) m_hFriend[i] = Create( "monster_alien_slave", node.m_vecOrigin, pev->angles ); } } - if( m_hFriend[i] != NULL ) + if( m_hFriend[i] != 0 ) { EMIT_SOUND( m_hFriend[i]->edict(), CHAN_WEAPON, "debris/beamstart7.wav", 1.0, ATTN_NORM ); } @@ -701,7 +722,7 @@ void CNihilanth::NextActivity() } } - if( ( pev->health < gSkillData.nihilanthHealth / 2 || m_iActiveSpheres < N_SPHERES / 2 ) && m_hRecharger == NULL && m_iLevel <= 9 ) + if( ( pev->health < gSkillData.nihilanthHealth / 2 || m_iActiveSpheres < N_SPHERES / 2 ) && m_hRecharger == 0 && m_iLevel <= 9 ) { char szName[64]; @@ -742,7 +763,7 @@ void CNihilanth::NextActivity() float flDist = ( m_posDesired - pev->origin ).Length(); float flDot = DotProduct( m_vecDesired, gpGlobals->v_forward ); - if( m_hRecharger != NULL ) + if( m_hRecharger != 0 ) { // at we at power up yet? if( flDist < 128.0 ) @@ -767,23 +788,23 @@ void CNihilanth::NextActivity() return; } - if( m_hEnemy != NULL && !m_hEnemy->IsAlive() ) + if( m_hEnemy != 0 && !m_hEnemy->IsAlive() ) { - m_hEnemy = NULL; + m_hEnemy = 0; } if( m_flLastSeen + 15 < gpGlobals->time ) { - m_hEnemy = NULL; + m_hEnemy = 0; } - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { Look( 4096 ); m_hEnemy = BestVisibleEnemy(); } - if( m_hEnemy != NULL && m_irritation != 0 ) + if( m_hEnemy != 0 && m_irritation != 0 ) { if( m_flLastSeen + 5 > gpGlobals->time && flDist < 256 && flDot > 0 ) { @@ -860,7 +881,7 @@ void CNihilanth::HuntThink( void ) } // look for current enemy - if( m_hEnemy != NULL && m_hRecharger == NULL ) + if( m_hEnemy != 0 && m_hRecharger == 0 ) { if( FVisible( m_hEnemy ) ) { @@ -874,7 +895,7 @@ void CNihilanth::HuntThink( void ) } else { - m_flAdj = min( m_flAdj + 10, 1000 ); + m_flAdj = Q_min( m_flAdj + 10, 1000 ); } } @@ -928,7 +949,7 @@ void CNihilanth::Flight( void ) if( flDir < 0 ) flSpeed = -flSpeed; - float flDist = DotProduct( m_posDesired - vecEst, gpGlobals->v_forward ); + //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 ); @@ -959,7 +980,7 @@ BOOL CNihilanth::AbsorbSphere( void ) { for( int i = 0; i < N_SPHERES; i++ ) { - if( m_hSphere[i] != NULL ) + if( m_hSphere[i] != 0 ) { CNihilanthHVR *pSphere = (CNihilanthHVR *)( (CBaseEntity *)m_hSphere[i] ); pSphere->AbsorbInit(); @@ -978,7 +999,7 @@ BOOL CNihilanth::EmitSphere( void ) for( int i = 0; i < N_SPHERES; i++ ) { - if( m_hSphere[i] != NULL ) + if( m_hSphere[i] != 0 ) { m_iActiveSpheres++; } @@ -1007,10 +1028,10 @@ void CNihilanth::TargetSphere( USE_TYPE useType, float value ) for( i = 0; i < N_SPHERES; i++ ) { - if( m_hSphere[i] != NULL ) + if( m_hSphere[i] != 0 ) { pSphere = m_hSphere[i]->MyMonsterPointer(); - if( pSphere->m_hEnemy == NULL ) + if( pSphere->m_hEnemy == 0 ) break; } } @@ -1036,7 +1057,7 @@ void CNihilanth::HandleAnimEvent( MonsterEvent_t *pEvent ) break; case 2: // zen - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { if( RANDOM_LONG( 0, 4 ) == 0 ) EMIT_SOUND( edict(), CHAN_VOICE, RANDOM_SOUND_ARRAY( pAttackSounds ), 1.0, 0.2 ); @@ -1077,7 +1098,7 @@ void CNihilanth::HandleAnimEvent( MonsterEvent_t *pEvent ) break; case 3: // prayer - if (m_hEnemy != NULL) + if( m_hEnemy != 0 ) { char szText[32]; @@ -1141,7 +1162,7 @@ void CNihilanth::HandleAnimEvent( MonsterEvent_t *pEvent ) case 4: // get a sphere { - if( m_hRecharger != NULL ) + if( m_hRecharger != 0 ) { if( !EmitSphere() ) { @@ -1157,7 +1178,7 @@ void CNihilanth::HandleAnimEvent( MonsterEvent_t *pEvent ) } break; case 6: - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { Vector vecSrc, vecAngles; GetAttachment( 2, vecSrc, vecAngles ); @@ -1185,8 +1206,22 @@ void CNihilanth::CommandUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_ case USE_OFF: { CBaseEntity *pTouch = UTIL_FindEntityByTargetname( NULL, m_szDeadTouch ); - if( pTouch && m_hEnemy != NULL ) - pTouch->Touch( m_hEnemy ); + if( pTouch ) + { + if( m_hEnemy != 0 ) + { + pTouch->Touch( m_hEnemy ); + } + // if the player is using "notarget", the ending sequence won't fire unless we catch it here + else + { + CBaseEntity *pEntity = UTIL_FindEntityByClassname( NULL, "player" ); + if( pEntity != NULL && pEntity->IsAlive() ) + { + pTouch->Touch( pEntity ); + } + } + } } break; case USE_ON: @@ -1326,7 +1361,7 @@ void CNihilanthHVR::HoverThink( void ) { pev->nextthink = gpGlobals->time + 0.1; - if( m_hTargetEnt != NULL ) + if( m_hTargetEnt != 0 ) { CircleTarget( m_hTargetEnt->pev->origin + Vector( 0, 0, 16 * N_SCALE ) ); } @@ -1410,7 +1445,7 @@ void CNihilanthHVR::ZapThink( void ) pev->nextthink = gpGlobals->time + 0.05; // check world boundaries - if( m_hEnemy == NULL || 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( 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 ) { SetTouch( NULL ); UTIL_Remove( this ); @@ -1547,7 +1582,7 @@ void CNihilanthHVR::TeleportThink( void ) pev->nextthink = gpGlobals->time + 0.1; // check world boundaries - if( m_hEnemy == NULL || !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 ) + 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 ) { STOP_SOUND( edict(), CHAN_WEAPON, "x/x_teleattack1.wav" ); UTIL_Remove( this ); @@ -1559,10 +1594,10 @@ void CNihilanthHVR::TeleportThink( void ) STOP_SOUND( edict(), CHAN_WEAPON, "x/x_teleattack1.wav" ); UTIL_Remove( this ); - if( m_hTargetEnt != NULL ) + if( m_hTargetEnt != 0 ) m_hTargetEnt->Use( m_hEnemy, m_hEnemy, USE_ON, 1.0 ); - if( m_hTouch != NULL && m_hEnemy != NULL ) + if( m_hTouch != 0 && m_hEnemy != 0 ) m_hTouch->Touch( m_hEnemy ); } else @@ -1616,10 +1651,10 @@ void CNihilanthHVR::TeleportTouch( CBaseEntity *pOther ) if( pOther == pEnemy ) { - if( m_hTargetEnt != NULL ) + if( m_hTargetEnt != 0 ) m_hTargetEnt->Use( pEnemy, pEnemy, USE_ON, 1.0 ); - if( m_hTouch != NULL && pEnemy != NULL ) + if( m_hTouch != 0 && pEnemy != NULL ) m_hTouch->Touch( pEnemy ); } else @@ -1642,7 +1677,7 @@ void CNihilanthHVR::DissipateThink( void ) pev->renderamt -= 2; pev->scale += 0.1; - if( m_hTargetEnt != NULL ) + if( m_hTargetEnt != 0 ) { CircleTarget( m_hTargetEnt->pev->origin + Vector( 0, 0, 4096 ) ); } diff --git a/dlls/nodes.cpp b/dlls/nodes.cpp index a97b6a80..04705638 100644 --- a/dlls/nodes.cpp +++ b/dlls/nodes.cpp @@ -214,7 +214,7 @@ entvars_t *CGraph::LinkEntForLink( CLink *pLink, CNode *pNode ) //========================================================= int CGraph::HandleLinkEnt( int iNode, entvars_t *pevLinkEnt, int afCapMask, NODEQUERY queryType ) { - edict_t *pentWorld; + //edict_t *pentWorld; CBaseEntity *pDoor; TraceResult tr; @@ -230,7 +230,7 @@ int CGraph::HandleLinkEnt( int iNode, entvars_t *pevLinkEnt, int afCapMask, NODE ALERT( at_aiconsole, "dead path ent!\n" ); return TRUE; } - pentWorld = NULL; + //pentWorld = NULL; // func_door if( FClassnameIs( pevLinkEnt, "func_door" ) || FClassnameIs( pevLinkEnt, "func_door_rotating" ) ) @@ -586,7 +586,7 @@ int CGraph::FindShortestPath( int *piPath, int iStart, int iDest, int iHull, int int iVisitNode; int iCurrentNode; int iNumPathNodes; - int iHullMask; + int iHullMask = 0; if( !m_fGraphPresent || !m_fGraphPointersSet ) { @@ -793,12 +793,12 @@ void inline CalcBounds( int &Lower, int &Upper, int Goal, int Best ) int Temp = 2 * Goal - Best; if( Best > Goal ) { - Lower = max( 0, Temp ); + Lower = Q_max( 0, Temp ); Upper = Best; } else { - Upper = min( 255, Temp ); + Upper = Q_min( 255, Temp ); Lower = Best; } } @@ -962,7 +962,7 @@ int CGraph::FindNearestNode( const Vector &vecOrigin, int afNodeTypes ) } } - for( i = max( m_minY, halfY + 1 ); i <= m_maxY; i++ ) + for( i = Q_max( m_minY, halfY + 1 ); i <= m_maxY; i++ ) { for( j = m_RangeStart[1][i]; j <= m_RangeEnd[1][i]; j++ ) { @@ -987,7 +987,7 @@ int CGraph::FindNearestNode( const Vector &vecOrigin, int afNodeTypes ) } } - for( i = min( m_maxZ, halfZ ); i >= m_minZ; i-- ) + for( i = Q_min( m_maxZ, halfZ ); i >= m_minZ; i-- ) { for( j = m_RangeStart[2][i]; j <= m_RangeEnd[2][i]; j++ ) { @@ -1012,7 +1012,7 @@ int CGraph::FindNearestNode( const Vector &vecOrigin, int afNodeTypes ) } } - for( i = max( m_minX, halfX + 1 ); i <= m_maxX; i++ ) + for( i = Q_max( m_minX, halfX + 1 ); i <= m_maxX; i++ ) { for( j = m_RangeStart[0][i]; j <= m_RangeEnd[0][i]; j++ ) { @@ -1034,7 +1034,7 @@ int CGraph::FindNearestNode( const Vector &vecOrigin, int afNodeTypes ) } } - for( i = min( m_maxY, halfY ); i >= m_minY; i-- ) + for( i = Q_min( m_maxY, halfY ); i >= m_minY; i-- ) { for( j = m_RangeStart[1][i]; j <= m_RangeEnd[1][i]; j++ ) { @@ -1055,7 +1055,7 @@ int CGraph::FindNearestNode( const Vector &vecOrigin, int afNodeTypes ) } } - for( i = max( m_minZ, halfZ + 1 ); i <= m_maxZ; i++ ) + for( i = Q_max( m_minZ, halfZ + 1 ); i <= m_maxZ; i++ ) { for( j = m_RangeStart[2][i]; j <= m_RangeEnd[2][i]; j++ ) { @@ -1665,10 +1665,10 @@ void CTestHull::BuildNodeGraph( void ) int iBadNode;// this is the node that caused graph generation to fail - int cMaxInitialLinks = 0; - int cMaxValidLinks = 0; + //int cMaxInitialLinks = 0; + //int cMaxValidLinks = 0; - int iPoolIndex = 0; + //int iPoolIndex = 0; int cPoolLinks;// number of links in the pool. Vector vecDirToCheckNode; @@ -2058,11 +2058,16 @@ void CTestHull::BuildNodeGraph( void ) fprintf( file, "\nAll Connections are Paired!\n" ); } +#ifdef _MSC_VER +#define SIZET_FMT "%Iu" +#else +#define SIZET_FMT "%zu" +#endif fprintf( file, "-------------------------------------------------------------------------------\n" ); fprintf( file, "\n\n-------------------------------------------------------------------------------\n" ); fprintf( file, "Total Number of Connections in Pool: %d\n", cPoolLinks ); fprintf( file, "-------------------------------------------------------------------------------\n" ); - fprintf( file, "Connection Pool: %d bytes\n", sizeof(CLink) * cPoolLinks ); + fprintf( file, "Connection Pool: " SIZET_FMT " bytes\n", sizeof(CLink) * cPoolLinks ); fprintf( file, "-------------------------------------------------------------------------------\n" ); ALERT( at_aiconsole, "%d Nodes, %d Connections\n", WorldGraph.m_cNodes, cPoolLinks ); @@ -2103,7 +2108,7 @@ void CTestHull::BuildNodeGraph( void ) WorldGraph.ComputeStaticRoutingTables(); // save the node graph for this level - WorldGraph.FSaveGraph( (char *)STRING( gpGlobals->mapname ) ); + WorldGraph.FSaveGraph( STRING( gpGlobals->mapname ) ); ALERT( at_console, "Done.\n" ); } @@ -2358,7 +2363,7 @@ void CQueuePriority::Heap_SiftUp( void ) // will be loaded. If file cannot be loaded, the node tree // will be created and saved to disk. //========================================================= -int CGraph::FLoadGraph( char *szMapName ) +int CGraph::FLoadGraph( const char *szMapName ) { char szFilename[MAX_PATH]; int iVersion; @@ -2537,7 +2542,7 @@ NoMemory: // CGraph - FSaveGraph - It's not rocket science. // this WILL overwrite existing files. //========================================================= -int CGraph::FSaveGraph( char *szMapName ) +int CGraph::FSaveGraph( const char *szMapName ) { int iVersion = GRAPH_VERSION; char szFilename[MAX_PATH]; @@ -2669,7 +2674,7 @@ int CGraph::FSetGraphPointers( void ) // though. ( I now suspect that we are getting GMT back from // these functions and must compensate for local time ) (sjb) //========================================================= -int CGraph::CheckNODFile( char *szMapName ) +int CGraph::CheckNODFile( const char *szMapName ) { int retValue; diff --git a/dlls/nodes.h b/dlls/nodes.h index 27b890ed..52b715e5 100644 --- a/dlls/nodes.h +++ b/dlls/nodes.h @@ -15,7 +15,9 @@ //========================================================= // nodes.h //========================================================= - +#pragma once +#ifndef NODES_H +#define NODES_H //========================================================= // DEFINE //========================================================= @@ -103,7 +105,11 @@ typedef struct //========================================================= // CGraph //========================================================= +#ifdef XASH_64BIT +#define GRAPH_VERSION (int)16 * 10 +#else #define GRAPH_VERSION (int)16// !!!increment this whever graph/node/link classes change, to obsolesce older disk files. +#endif class CGraph { @@ -177,9 +183,9 @@ public: void InitGraph( void ); int AllocNodes ( void ); - int CheckNODFile(char *szMapName); - int FLoadGraph(char *szMapName); - int FSaveGraph(char *szMapName); + int CheckNODFile(const char *szMapName); + int FLoadGraph(const char *szMapName); + int FSaveGraph(const char *szMapName); int FSetGraphPointers(void); void CheckNode(Vector vecOrigin, int iNode); @@ -370,3 +376,4 @@ enum }; extern CGraph WorldGraph; +#endif // NODES_H diff --git a/dlls/observer.cpp b/dlls/observer.cpp new file mode 100644 index 00000000..22fa3818 --- /dev/null +++ b/dlls/observer.cpp @@ -0,0 +1,291 @@ +//=========== (C) Copyright 1999 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: Functionality for the observer chase camera +// +// $Workfile: $ +// $Date: $ +// +//----------------------------------------------------------------------------- +// $Log: $ +// +// $NoKeywords: $ +//============================================================================= +#include "extdll.h" +#include "util.h" +#include "cbase.h" +#include "player.h" +#include "weapons.h" +#include "pm_shared.h" + +extern int gmsgCurWeapon; +extern int gmsgSetFOV; +extern int gmsgTeamInfo; + +extern int g_teamplay; + +// Find the next client in the game for this player to spectate +void CBasePlayer::Observer_FindNextPlayer( bool bReverse ) +{ + // 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. + int iStart; + if( m_hObserverTarget ) + iStart = ENTINDEX( m_hObserverTarget->edict() ); + else + iStart = ENTINDEX( edict() ); + int iCurrent = iStart; + m_hObserverTarget = 0; + int iDir = bReverse ? -1 : 1; + + do + { + iCurrent += iDir; + + // Loop through the clients + if( iCurrent > gpGlobals->maxClients ) + iCurrent = 1; + if( iCurrent < 1 ) + iCurrent = gpGlobals->maxClients; + + CBaseEntity *pEnt = UTIL_PlayerByIndex( iCurrent ); + if( !pEnt ) + continue; + if( pEnt == this ) + continue; + // Don't spec observers or players who haven't picked a class yet + if( ( (CBasePlayer*)pEnt )->IsObserver() || ( pEnt->pev->effects & EF_NODRAW ) ) + continue; + + // MOD AUTHORS: Add checks on target here. + m_hObserverTarget = pEnt; + break; + }while( iCurrent != iStart ); + + // Did we find a target? + if( m_hObserverTarget ) + { + // Move to the target + UTIL_SetOrigin( pev, m_hObserverTarget->pev->origin ); + + // ALERT( at_console, "Now Tracking %s\n", STRING( m_hObserverTarget->pev->netname ) ); + + // Store the target in pev so the physics DLL can get to it + if( pev->iuser1 != OBS_ROAMING ) + pev->iuser2 = ENTINDEX( m_hObserverTarget->edict() ); + } +} + +// Handle buttons in observer mode +void CBasePlayer::Observer_HandleButtons() +{ + // Slow down mouse clicks + if( m_flNextObserverInput > gpGlobals->time ) + return; + + // Jump changes from modes: Chase to Roaming + if( m_afButtonPressed & IN_JUMP ) + { + if( pev->iuser1 == OBS_CHASE_LOCKED ) + Observer_SetMode( OBS_CHASE_FREE ); + else if( pev->iuser1 == OBS_CHASE_FREE ) + Observer_SetMode( OBS_IN_EYE ); + else if( pev->iuser1 == OBS_IN_EYE ) + Observer_SetMode( OBS_ROAMING ); + else if( pev->iuser1 == OBS_ROAMING ) + Observer_SetMode( OBS_MAP_FREE ); + else if( pev->iuser1 == OBS_MAP_FREE ) + Observer_SetMode( OBS_MAP_CHASE ); + else + Observer_SetMode( OBS_CHASE_FREE ); // don't use OBS_CHASE_LOCKED anymore + + m_flNextObserverInput = gpGlobals->time + 0.2; + } + + // Attack moves to the next player + if ( m_afButtonPressed & IN_ATTACK )//&& pev->iuser1 != OBS_ROAMING ) + { + Observer_FindNextPlayer( false ); + + m_flNextObserverInput = gpGlobals->time + 0.2; + } + + // Attack2 moves to the prev player + if ( m_afButtonPressed & IN_ATTACK2)// && pev->iuser1 != OBS_ROAMING ) + { + Observer_FindNextPlayer( true ); + + m_flNextObserverInput = gpGlobals->time + 0.2; + } +} + +void CBasePlayer::Observer_CheckTarget() +{ + if( pev->iuser1 == OBS_ROAMING ) + return; + + // try to find a traget if we have no current one + if( m_hObserverTarget == 0 ) + { + Observer_FindNextPlayer( false ); + + if( m_hObserverTarget == 0 ) + { + // no target found at all + + int lastMode = pev->iuser1; + + Observer_SetMode( OBS_ROAMING ); + + m_iObserverLastMode = lastMode; // don't overwrite users lastmode + + return; // we still have np target return + } + } + + CBasePlayer* target = (CBasePlayer*)( UTIL_PlayerByIndex( ENTINDEX( m_hObserverTarget->edict() ) ) ); + + if( !target ) + { + Observer_FindNextPlayer( false ); + return; + } + + // check taget + if( target->pev->deadflag == DEAD_DEAD ) + { + if( ( target->m_fDeadTime + 2.0f ) < gpGlobals->time ) + { + // 3 secs after death change target + Observer_FindNextPlayer( false ); + return; + } + } +} + +void CBasePlayer::Observer_CheckProperties() +{ + // try to find a traget if we have no current one + if( pev->iuser1 == OBS_IN_EYE && m_hObserverTarget != 0 ) + { + CBasePlayer* target = (CBasePlayer*)( UTIL_PlayerByIndex( ENTINDEX( m_hObserverTarget->edict() ) ) ); + + if( !target ) + return; + + int weapon = ( target->m_pActiveItem != NULL ) ? target->m_pActiveItem->m_iId : 0; + // use fov of tracked client + if( m_iFOV != target->m_iFOV || m_iObserverWeapon != weapon ) + { + m_iFOV = target->m_iFOV; + m_iClientFOV = m_iFOV; + // write fov before wepon data, so zoomed crosshair is set correctly + MESSAGE_BEGIN( MSG_ONE, gmsgSetFOV, NULL, pev ); + WRITE_BYTE( m_iFOV ); + MESSAGE_END(); + + m_iObserverWeapon = weapon; + //send weapon update + MESSAGE_BEGIN( MSG_ONE, gmsgCurWeapon, NULL, pev ); + WRITE_BYTE( 1 ); // 1 = current weapon, not on target + WRITE_BYTE( m_iObserverWeapon ); + WRITE_BYTE( 0 ); // clip + MESSAGE_END(); + } + } + else + { + m_iFOV = 90; + + if( m_iObserverWeapon != 0 ) + { + m_iObserverWeapon = 0; + + MESSAGE_BEGIN( MSG_ONE, gmsgCurWeapon, NULL, pev ); + WRITE_BYTE( 1 ); // 1 = current weapon + WRITE_BYTE( m_iObserverWeapon ); + WRITE_BYTE( 0 ); // clip + MESSAGE_END(); + } + } +} + +// Attempt to change the observer mode +void CBasePlayer::Observer_SetMode( int iMode ) +{ + + // Just abort if we're changing to the mode we're already in + if( iMode == pev->iuser1 ) + return; + + // is valid mode ? + if( iMode < OBS_CHASE_LOCKED || iMode > OBS_MAP_CHASE ) + iMode = OBS_IN_EYE; // now it is + // verify observer target again + if( m_hObserverTarget != 0 ) + { + CBaseEntity *pEnt = m_hObserverTarget; + + if( ( pEnt == this ) || ( pEnt == NULL ) ) + m_hObserverTarget = 0; + else if( ( (CBasePlayer*)pEnt )->IsObserver() || ( pEnt->pev->effects & EF_NODRAW ) ) + m_hObserverTarget = 0; + } + + // set spectator mode + pev->iuser1 = iMode; + + // if we are not roaming, we need a valid target to track + if( ( iMode != OBS_ROAMING ) && ( m_hObserverTarget == 0 ) ) + { + Observer_FindNextPlayer( false ); + + // if we didn't find a valid target switch to roaming + if( m_hObserverTarget == 0 ) + { + ClientPrint( pev, HUD_PRINTCENTER, "#Spec_NoTarget" ); + pev->iuser1 = OBS_ROAMING; + } + } + + // set target if not roaming + if( pev->iuser1 == OBS_ROAMING ) + { + pev->iuser2 = 0; + } + else + pev->iuser2 = ENTINDEX( m_hObserverTarget->edict() ); + + pev->iuser3 = 0; // clear second target from death cam + + // print spepctaor mode on client screen + + char modemsg[16]; + sprintf( modemsg,"#Spec_Mode%i", pev->iuser1 ); + ClientPrint( pev, HUD_PRINTCENTER, modemsg ); + + m_iObserverLastMode = iMode; +} + +void CBasePlayer::StopObserver() +{ + // Turn off spectator + pev->iuser1 = pev->iuser2 = 0; + m_iHideHUD = 0; + + GetClassPtr( (CBasePlayer *)pev )->Spawn(); + pev->nextthink = -1; + + // Update Team Status + MESSAGE_BEGIN( MSG_ALL, gmsgTeamInfo ); + WRITE_BYTE( ENTINDEX( edict() ) ); // index number of primary entity + if( g_teamplay ) + WRITE_STRING( TeamID() ); + else + WRITE_STRING( "Players" ); + MESSAGE_END(); +} diff --git a/dlls/osprey.cpp b/dlls/osprey.cpp index 95088d2b..6a421645 100644 --- a/dlls/osprey.cpp +++ b/dlls/osprey.cpp @@ -261,7 +261,7 @@ BOOL COsprey::HasDead() { for( int i = 0; i < m_iUnits; i++ ) { - if( m_hGrunt[i] == NULL || !m_hGrunt[i]->IsAlive() ) + if( m_hGrunt[i] == 0 || !m_hGrunt[i]->IsAlive() ) { return TRUE; } @@ -285,9 +285,9 @@ CBaseMonster *COsprey::MakeGrunt( Vector vecSrc ) for( int i = 0; i < m_iUnits; i++ ) { - if( m_hGrunt[i] == NULL || !m_hGrunt[i]->IsAlive() ) + if( m_hGrunt[i] == 0 || !m_hGrunt[i]->IsAlive() ) { - if( m_hGrunt[i] != NULL && m_hGrunt[i]->pev->rendermode == kRenderNormal ) + if( m_hGrunt[i] != 0 && m_hGrunt[i]->pev->rendermode == kRenderNormal ) { m_hGrunt[i]->SUB_StartFadeOut(); } @@ -319,7 +319,7 @@ void COsprey::HoverThink( void ) int i; for( i = 0; i < 4; i++ ) { - if( m_hRepel[i] != NULL && m_hRepel[i]->pev->health > 0 && !( m_hRepel[i]->pev->flags & FL_ONGROUND ) ) + if( m_hRepel[i] != 0 && m_hRepel[i]->pev->health > 0 && !( m_hRepel[i]->pev->flags & FL_ONGROUND ) ) { break; } diff --git a/dlls/physcallback.h b/dlls/physcallback.h index 1db276e0..fd68936c 100644 --- a/dlls/physcallback.h +++ b/dlls/physcallback.h @@ -12,9 +12,9 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef PHYSCALLBACK_H #define PHYSCALLBACK_H -#pragma once #include "physint.h" diff --git a/dlls/plane.h b/dlls/plane.h index 35a17611..912062f6 100644 --- a/dlls/plane.h +++ b/dlls/plane.h @@ -12,12 +12,12 @@ * without written permission from Valve LLC. * ****/ -#ifndef PLANE_H -#define PLANE_H - //========================================================= // Plane //========================================================= +#ifndef PLANE_H +#define PLANE_H + class CPlane { public: diff --git a/dlls/plats.cpp b/dlls/plats.cpp index 93fb22fe..b3e1c683 100644 --- a/dlls/plats.cpp +++ b/dlls/plats.cpp @@ -82,12 +82,12 @@ void CBasePlatTrain::KeyValue( KeyValueData *pkvd ) } else if( FStrEq( pkvd->szKeyName, "movesnd" ) ) { - m_bMoveSnd = atof( pkvd->szValue ); + m_bMoveSnd = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "stopsnd" ) ) { - m_bStopSnd = atof( pkvd->szValue ); + m_bStopSnd = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "volume" ) ) @@ -104,111 +104,100 @@ void CBasePlatTrain::KeyValue( KeyValueData *pkvd ) void CBasePlatTrain::Precache( void ) { + const char *pszSound; + BOOL NullSound = FALSE; + // set the plat's "in-motion" sound switch( m_bMoveSnd ) { - case 0: - pev->noiseMoving = MAKE_STRING( "common/null.wav" ); - break; case 1: - PRECACHE_SOUND( "plats/bigmove1.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/bigmove1.wav" ); + pszSound = "plats/bigmove1.wav"; break; case 2: - PRECACHE_SOUND( "plats/bigmove2.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/bigmove2.wav" ); + pszSound = "plats/bigmove2.wav"; break; case 3: - PRECACHE_SOUND( "plats/elevmove1.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/elevmove1.wav" ); + pszSound = "plats/elevmove1.wav"; break; case 4: - PRECACHE_SOUND( "plats/elevmove2.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/elevmove2.wav" ); + pszSound = "plats/elevmove2.wav"; break; case 5: - PRECACHE_SOUND( "plats/elevmove3.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/elevmove3.wav" ); + pszSound = "plats/elevmove3.wav"; break; case 6: - PRECACHE_SOUND( "plats/freightmove1.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/freightmove1.wav" ); + pszSound = "plats/freightmove1.wav"; break; case 7: - PRECACHE_SOUND( "plats/freightmove2.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/freightmove2.wav" ); + pszSound = "plats/freightmove2.wav"; break; case 8: - PRECACHE_SOUND( "plats/heavymove1.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/heavymove1.wav" ); + pszSound = "plats/heavymove1.wav"; break; case 9: - PRECACHE_SOUND( "plats/rackmove1.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/rackmove1.wav" ); + pszSound = "plats/rackmove1.wav"; break; case 10: - PRECACHE_SOUND( "plats/railmove1.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/railmove1.wav" ); + pszSound = "plats/railmove1.wav"; break; case 11: - PRECACHE_SOUND( "plats/squeekmove1.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/squeekmove1.wav" ); + pszSound = "plats/squeekmove1.wav"; break; case 12: - PRECACHE_SOUND( "plats/talkmove1.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/talkmove1.wav" ); + pszSound = "plats/talkmove1.wav"; break; case 13: - PRECACHE_SOUND( "plats/talkmove2.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/talkmove2.wav" ); + pszSound = "plats/talkmove2.wav"; break; + case 0: default: - pev->noiseMoving = MAKE_STRING( "common/null.wav" ); + pszSound = "common/null.wav"; + NullSound = TRUE; break; } + if( !NullSound ) + PRECACHE_SOUND( pszSound ); + pev->noiseMoving = MAKE_STRING( pszSound ); + NullSound = FALSE; + // set the plat's 'reached destination' stop sound switch( m_bStopSnd ) { - case 0: - pev->noiseArrived = MAKE_STRING( "common/null.wav" ); - break; case 1: - PRECACHE_SOUND( "plats/bigstop1.wav" ); - pev->noiseArrived = MAKE_STRING( "plats/bigstop1.wav" ); + pszSound = "plats/bigstop1.wav"; break; case 2: - PRECACHE_SOUND( "plats/bigstop2.wav" ); - pev->noiseArrived = MAKE_STRING( "plats/bigstop2.wav" ); + pszSound = "plats/bigstop2.wav"; break; case 3: - PRECACHE_SOUND( "plats/freightstop1.wav" ); - pev->noiseArrived = MAKE_STRING( "plats/freightstop1.wav" ); + pszSound = "plats/freightstop1.wav"; break; case 4: - PRECACHE_SOUND( "plats/heavystop2.wav" ); - pev->noiseArrived = MAKE_STRING( "plats/heavystop2.wav" ); + pszSound = "plats/heavystop2.wav"; break; case 5: - PRECACHE_SOUND( "plats/rackstop1.wav" ); - pev->noiseArrived = MAKE_STRING( "plats/rackstop1.wav" ); + pszSound = "plats/rackstop1.wav"; break; case 6: - PRECACHE_SOUND( "plats/railstop1.wav" ); - pev->noiseArrived = MAKE_STRING( "plats/railstop1.wav" ); + pszSound = "plats/railstop1.wav"; break; case 7: - PRECACHE_SOUND( "plats/squeekstop1.wav" ); - pev->noiseArrived = MAKE_STRING( "plats/squeekstop1.wav" ); + pszSound = "plats/squeekstop1.wav"; break; case 8: - PRECACHE_SOUND( "plats/talkstop1.wav" ); - pev->noiseArrived = MAKE_STRING( "plats/talkstop1.wav" ); + pszSound = "plats/talkstop1.wav"; break; + case 0: default: - pev->noiseArrived = MAKE_STRING( "common/null.wav" ); + pszSound = "common/null.wav"; + NullSound = TRUE; break; } + + if( !NullSound ) + PRECACHE_SOUND( pszSound ); + pev->noiseArrived = MAKE_STRING( pszSound ); } // @@ -248,7 +237,7 @@ public: virtual int ObjectCaps( void ) { return (CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | FCAP_DONT_SAVE; } void SpawnInsideTrigger( CFuncPlat *pPlatform ); void Touch( CBaseEntity *pOther ); - CFuncPlat *m_pPlatform; + EHANDLE m_hPlatform; }; /*QUAKED func_plat (0 .5 .8) ? PLAT_LOW_TRIGGER @@ -340,24 +329,24 @@ static void PlatSpawnInsideTrigger( entvars_t *pevPlatform ) // void CPlatTrigger::SpawnInsideTrigger( CFuncPlat *pPlatform ) { - m_pPlatform = pPlatform; + m_hPlatform = pPlatform; // Create trigger entity, "point" it at the owning platform, give it a touch method pev->solid = SOLID_TRIGGER; pev->movetype = MOVETYPE_NONE; pev->origin = pPlatform->pev->origin; // Establish the trigger field's size - Vector vecTMin = m_pPlatform->pev->mins + Vector( 25, 25, 0 ); - Vector vecTMax = m_pPlatform->pev->maxs + Vector( 25, 25, 8 ); - vecTMin.z = vecTMax.z - ( m_pPlatform->m_vecPosition1.z - m_pPlatform->m_vecPosition2.z + 8 ); - if( m_pPlatform->pev->size.x <= 50 ) + Vector vecTMin = pPlatform->pev->mins + Vector( 25, 25, 0 ); + Vector vecTMax = pPlatform->pev->maxs + Vector( 25, 25, 8 ); + vecTMin.z = vecTMax.z - ( pPlatform->m_vecPosition1.z - pPlatform->m_vecPosition2.z + 8 ); + if( pPlatform->pev->size.x <= 50 ) { - vecTMin.x = ( m_pPlatform->pev->mins.x + m_pPlatform->pev->maxs.x ) / 2; + vecTMin.x = ( pPlatform->pev->mins.x + pPlatform->pev->maxs.x ) / 2; vecTMax.x = vecTMin.x + 1; } - if( m_pPlatform->pev->size.y <= 50 ) + if( pPlatform->pev->size.y <= 50 ) { - vecTMin.y = ( m_pPlatform->pev->mins.y + m_pPlatform->pev->maxs.y ) / 2; + vecTMin.y = ( pPlatform->pev->mins.y + pPlatform->pev->maxs.y ) / 2; vecTMax.y = vecTMin.y + 1; } UTIL_SetSize( pev, vecTMin, vecTMax ); @@ -373,15 +362,24 @@ void CPlatTrigger::Touch( CBaseEntity *pOther ) if( !FClassnameIs( pevToucher, "player" ) ) return; + CFuncPlat *pPlatform = (CFuncPlat*)(CBaseEntity*)m_hPlatform; + + if( !pPlatform ) + { + // The target platform has been removed, remove myself as well. - Solokiller + UTIL_Remove( this ); + return; + } + // Ignore touches by corpses if( !pOther->IsAlive() ) return; // Make linked platform go up/down. - if( m_pPlatform->m_toggle_state == TS_AT_BOTTOM ) - m_pPlatform->GoUp(); - else if( m_pPlatform->m_toggle_state == TS_AT_TOP ) - m_pPlatform->pev->nextthink = m_pPlatform->pev->ltime + 1;// delay going down + if( pPlatform->m_toggle_state == TS_AT_BOTTOM ) + pPlatform->GoUp(); + else if( pPlatform->m_toggle_state == TS_AT_TOP ) + pPlatform->pev->nextthink = pPlatform->pev->ltime + 1;// delay going down } // @@ -418,7 +416,7 @@ void CFuncPlat::PlatUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE void CFuncPlat::GoDown( void ) { if( pev->noiseMovement ) - EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMovement ), m_volume, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMovement ), m_volume, ATTN_NORM ); ASSERT( m_toggle_state == TS_AT_TOP || m_toggle_state == TS_GOING_UP ); m_toggle_state = TS_GOING_DOWN; @@ -427,15 +425,15 @@ void CFuncPlat::GoDown( void ) } // -// Platform has hit bottom. Stops and waits forever. +// Platform has hit bottom. Stops and waits forever. // void CFuncPlat::HitBottom( void ) { if( pev->noiseMovement ) - STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMovement ) ); + STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMovement ) ); if( pev->noiseStopMoving ) - EMIT_SOUND( ENT( pev ), CHAN_WEAPON, (char*)STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); ASSERT( m_toggle_state == TS_GOING_DOWN ); m_toggle_state = TS_AT_BOTTOM; @@ -447,7 +445,7 @@ void CFuncPlat::HitBottom( void ) void CFuncPlat::GoUp( void ) { if( pev->noiseMovement ) - EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMovement ), m_volume, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMovement ), m_volume, ATTN_NORM ); ASSERT( m_toggle_state == TS_AT_BOTTOM || m_toggle_state == TS_GOING_DOWN ); m_toggle_state = TS_GOING_UP; @@ -456,15 +454,15 @@ void CFuncPlat::GoUp( void ) } // -// Platform has hit top. Pauses, then starts back down again. +// Platform has hit top. Pauses, then starts back down again. // void CFuncPlat::HitTop( void ) { if( pev->noiseMovement ) - STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMovement ) ); + STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMovement ) ); if( pev->noiseStopMoving ) - EMIT_SOUND( ENT( pev ), CHAN_WEAPON, (char*)STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); ASSERT( m_toggle_state == TS_GOING_UP ); m_toggle_state = TS_AT_TOP; @@ -484,7 +482,7 @@ void CFuncPlat::Blocked( CBaseEntity *pOther ) pOther->TakeDamage( pev, pev, 1, DMG_CRUSH ); if( pev->noiseMovement ) - STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMovement ) ); + STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMovement ) ); // Send the platform back where it came from ASSERT( m_toggle_state == TS_GOING_UP || m_toggle_state == TS_GOING_DOWN ); @@ -554,7 +552,7 @@ void CFuncPlatRot::GoDown( void ) } // -// Platform has hit bottom. Stops and waits forever. +// Platform has hit bottom. Stops and waits forever. // void CFuncPlatRot::HitBottom( void ) { @@ -573,7 +571,7 @@ void CFuncPlatRot::GoUp( void ) } // -// Platform has hit top. Pauses, then starts back down again. +// Platform has hit top. Pauses, then starts back down again. // void CFuncPlatRot::HitTop( void ) { @@ -672,7 +670,7 @@ void CFuncTrain::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE us pev->nextthink = 0; pev->velocity = g_vecZero; if( pev->noiseStopMoving ) - EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); } } @@ -693,9 +691,9 @@ void CFuncTrain::Wait( void ) // clear the sound channel. if( pev->noiseMovement ) - STOP_SOUND( edict(), CHAN_STATIC, (char*)STRING( pev->noiseMovement ) ); + STOP_SOUND( edict(), CHAN_STATIC, STRING( pev->noiseMovement ) ); if( pev->noiseStopMoving ) - EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); pev->nextthink = 0; return; } @@ -706,9 +704,9 @@ void CFuncTrain::Wait( void ) // -1 wait will wait forever! pev->nextthink = pev->ltime + m_flWait; if( pev->noiseMovement ) - STOP_SOUND( edict(), CHAN_STATIC, (char*)STRING( pev->noiseMovement ) ); + STOP_SOUND( edict(), CHAN_STATIC, STRING( pev->noiseMovement ) ); if( pev->noiseStopMoving ) - EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); SetThink( &CFuncTrain::Next ); } else @@ -730,10 +728,10 @@ void CFuncTrain::Next( void ) if( !pTarg ) { if( pev->noiseMovement ) - STOP_SOUND( edict(), CHAN_STATIC, (char*)STRING( pev->noiseMovement ) ); + STOP_SOUND( edict(), CHAN_STATIC, STRING( pev->noiseMovement ) ); // Play stop sound if( pev->noiseStopMoving ) - EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); return; } @@ -743,21 +741,21 @@ void CFuncTrain::Next( void ) pev->target = pTarg->pev->target; m_flWait = pTarg->GetDelay(); - if ( m_pevCurrentTarget && m_pevCurrentTarget->speed != 0 ) + if( m_pevCurrentTarget && m_pevCurrentTarget->speed != 0 ) { // 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 ), pev->speed ); } m_pevCurrentTarget = pTarg->pev;// keep track of this since path corners change our target for us. pev->enemy = pTarg->edict();//hack - if(FBitSet(m_pevCurrentTarget->spawnflags, SF_CORNER_TELEPORT)) + if( FBitSet( m_pevCurrentTarget->spawnflags, SF_CORNER_TELEPORT ) ) { // 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); + SetBits( pev->effects, EF_NOINTERP ); + UTIL_SetOrigin( pev, pTarg->pev->origin - ( pev->mins + pev->maxs ) * 0.5 ); Wait(); // Get on with doing the next path corner. } else @@ -767,13 +765,15 @@ void CFuncTrain::Next( void ) // CHANGED this from CHAN_VOICE to CHAN_STATIC around OEM beta time because trains should // use CHAN_STATIC for their movement sounds to prevent sound field problems. // this is not a hack or temporary fix, this is how things should be. (sjb). - if ( pev->noiseMovement ) - STOP_SOUND( edict(), CHAN_STATIC, (char*)STRING(pev->noiseMovement) ); - if ( pev->noiseMovement ) - EMIT_SOUND (ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMovement), m_volume, ATTN_NORM); - ClearBits(pev->effects, EF_NOINTERP); + if( pev->noiseMovement ) + { + STOP_SOUND( edict(), CHAN_STATIC, STRING( pev->noiseMovement ) ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMovement ), m_volume, ATTN_NORM ); + } + + 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.5, pev->speed ); } } @@ -853,8 +853,8 @@ void CFuncTrain::Precache( void ) case 1: PRECACHE_SOUND( "plats/train2.wav" ); PRECACHE_SOUND( "plats/train1.wav" ); - pev->noise = MAKE_STRING("plats/train2.wav" ); - pev->noise1 = MAKE_STRING("plats/train1.wav" ); + pev->noise = MAKE_STRING( "plats/train2.wav" ); + pev->noise1 = MAKE_STRING( "plats/train1.wav" ); break; case 2: PRECACHE_SOUND( "plats/platmove1.wav" ); @@ -1061,7 +1061,7 @@ void CFuncTrackTrain::StopSound( void ) PLAYBACK_EVENT_FULL( FEV_RELIABLE | FEV_UPDATE, edict(), m_usAdjustPitch, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, us_encode, 0, 1, 0 ); /* - STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noise ) ); + STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noise ) ); */ EMIT_SOUND_DYN( ENT( pev ), CHAN_ITEM, "plats/ttrain_brake1.wav", m_flVolume, ATTN_NORM, 0, 100 ); } @@ -1085,14 +1085,14 @@ void CFuncTrackTrain::UpdateSound( void ) { // play startup sound for train EMIT_SOUND_DYN( ENT( pev ), CHAN_ITEM, "plats/ttrain_start1.wav", m_flVolume, ATTN_NORM, 0, 100 ); - EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noise ), m_flVolume, ATTN_NORM, 0, (int)flpitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, STRING( pev->noise ), m_flVolume, ATTN_NORM, 0, (int)flpitch ); m_soundPlaying = 1; } else { /* // update pitch - EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noise ), m_flVolume, ATTN_NORM, SND_CHANGE_PITCH, (int)flpitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, STRING( pev->noise ), m_flVolume, ATTN_NORM, SND_CHANGE_PITCH, (int)flpitch ); */ // volume 0.0 - 1.0 - 6 bits // m_sounds 3 bits @@ -1322,7 +1322,7 @@ BOOL CFuncTrackTrain::OnControls( entvars_t *pevTest ) void CFuncTrackTrain::Find( void ) { - m_ppath = CPathTrack::Instance(FIND_ENTITY_BY_TARGETNAME( NULL, STRING( pev->target ) ) ); + m_ppath = CPathTrack::Instance( FIND_ENTITY_BY_TARGETNAME( NULL, STRING( pev->target ) ) ); if( !m_ppath ) return; @@ -1437,7 +1437,7 @@ void CFuncTrackTrain::Spawn( void ) pev->speed = 0; pev->velocity = g_vecZero; pev->avelocity = g_vecZero; - pev->impulse = m_speed; + pev->impulse = (int)m_speed; m_dir = 1; @@ -1471,6 +1471,8 @@ void CFuncTrackTrain::Spawn( void ) void CFuncTrackTrain::Precache( void ) { + const char *pszSound; + if( m_flVolume == 0.0 ) m_flVolume = 1.0; @@ -1478,34 +1480,36 @@ void CFuncTrackTrain::Precache( void ) { default: // no sound - pev->noise = 0; + pszSound = NULL; break; case 1: - PRECACHE_SOUND( "plats/ttrain1.wav" ); - pev->noise = MAKE_STRING("plats/ttrain1.wav" ); + pszSound = "plats/ttrain1.wav"; break; case 2: - PRECACHE_SOUND( "plats/ttrain2.wav" ); - pev->noise = MAKE_STRING( "plats/ttrain2.wav" ); + pszSound = "plats/ttrain2.wav"; break; case 3: - PRECACHE_SOUND( "plats/ttrain3.wav" ); - pev->noise = MAKE_STRING( "plats/ttrain3.wav" ); + pszSound = "plats/ttrain3.wav"; break; case 4: - PRECACHE_SOUND( "plats/ttrain4.wav" ); - pev->noise = MAKE_STRING( "plats/ttrain4.wav" ); + pszSound = "plats/ttrain4.wav"; break; case 5: - PRECACHE_SOUND( "plats/ttrain6.wav" ); - pev->noise = MAKE_STRING( "plats/ttrain6.wav" ); + pszSound = "plats/ttrain6.wav"; break; case 6: - PRECACHE_SOUND( "plats/ttrain7.wav" ); - pev->noise = MAKE_STRING( "plats/ttrain7.wav" ); + pszSound = "plats/ttrain7.wav"; break; } + if( pszSound ) + { + PRECACHE_SOUND( pszSound ); + pev->noise = MAKE_STRING( pszSound ); + } + else + pev->noise = 0; + PRECACHE_SOUND( "plats/ttrain_brake1.wav" ); PRECACHE_SOUND( "plats/ttrain_start1.wav" ); @@ -1615,9 +1619,9 @@ public: CFuncTrackTrain *m_train; - int m_trackTopName; - int m_trackBottomName; - int m_trainName; + string_t m_trackTopName; + string_t m_trackBottomName; + string_t m_trainName; TRAIN_CODE m_code; int m_targetState; int m_use; @@ -2212,7 +2216,7 @@ void CGunTarget::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE us { pev->takedamage = DAMAGE_AIM; m_hTargetEnt = GetNextTarget(); - if( m_hTargetEnt == NULL ) + if( m_hTargetEnt == 0 ) return; pev->health = pev->max_health; Next(); diff --git a/dlls/player.cpp b/dlls/player.cpp index e3311a90..4a45674b 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -34,6 +34,7 @@ #include "decals.h" #include "gamerules.h" #include "game.h" +#include "pm_shared.h" #include "hltv.h" // #define DUCKFIX @@ -44,6 +45,8 @@ extern DLL_GLOBAL BOOL g_fDrawLines; int gEvilImpulse101; extern DLL_GLOBAL int g_iSkillLevel, gDisplayTitle; +extern "C" int g_bhopcap; + BOOL gInitHUD = TRUE; extern void CopyToBodyQue( entvars_t *pev); @@ -116,23 +119,6 @@ TYPEDESCRIPTION CBasePlayer::m_playerSaveData[] = DEFINE_FIELD( CBasePlayer, m_iHideHUD, FIELD_INTEGER ), DEFINE_FIELD( CBasePlayer, m_iFOV, FIELD_INTEGER ), - // Music - DEFINE_FIELD( CBasePlayer, m_bSong01_Played, FIELD_BOOLEAN ), - DEFINE_FIELD( CBasePlayer, m_bSong02_Played, FIELD_BOOLEAN ), - DEFINE_FIELD( CBasePlayer, m_bSong03_Played, FIELD_BOOLEAN ), - DEFINE_FIELD( CBasePlayer, m_bSong04_Played, FIELD_BOOLEAN ), - DEFINE_FIELD( CBasePlayer, m_bSong05_Played, FIELD_BOOLEAN ), - DEFINE_FIELD( CBasePlayer, m_bSong06_Played, FIELD_BOOLEAN ), - DEFINE_FIELD( CBasePlayer, m_flMusicCheckWait, FIELD_TIME ), - - // Player exert. - DEFINE_FIELD( CBasePlayer, m_iExertLevel, FIELD_INTEGER ), - DEFINE_FIELD( CBasePlayer, m_flExertRate, FIELD_FLOAT ), - DEFINE_FIELD( CBasePlayer, m_flExertUpdateStart, FIELD_TIME ), - - DEFINE_FIELD( CBasePlayer, m_fHudVisible, FIELD_BOOLEAN ), - DEFINE_FIELD( CBasePlayer, m_fUpdateHudVisibility, FIELD_BOOLEAN ), - //DEFINE_FIELD( CBasePlayer, m_fDeadTime, FIELD_FLOAT ), // only used in multiplayer games //DEFINE_FIELD( CBasePlayer, m_fGameHUDInitialized, FIELD_INTEGER ), // only used in multiplayer games //DEFINE_FIELD( CBasePlayer, m_flStopExtraSoundTime, FIELD_TIME ), @@ -197,13 +183,12 @@ int gmsgSetFOV = 0; int gmsgShowMenu = 0; int gmsgGeigerRange = 0; int gmsgTeamNames = 0; +int gmsgBhopcap = 0; +int gmsgPlayMP3 = 0; int gmsgStatusText = 0; int gmsgStatusValue = 0; -int gmsgStartUp = 0; -int gmsgScope = 0; - void LinkUserMessages( void ) { // Already taken care of? @@ -221,7 +206,8 @@ void LinkUserMessages( void ) gmsgDamage = REG_USER_MSG( "Damage", 12 ); gmsgBattery = REG_USER_MSG( "Battery", 2); gmsgTrain = REG_USER_MSG( "Train", 1 ); - gmsgHudText = REG_USER_MSG( "HudText", -1 ); + //gmsgHudText = REG_USER_MSG( "HudTextPro", -1 ); + gmsgHudText = REG_USER_MSG( "HudText", -1 ); // we don't use the message but 3rd party addons may! gmsgSayText = REG_USER_MSG( "SayText", -1 ); gmsgTextMsg = REG_USER_MSG( "TextMsg", -1 ); gmsgWeaponList = REG_USER_MSG( "WeaponList", -1 ); @@ -235,7 +221,7 @@ void LinkUserMessages( void ) gmsgGameMode = REG_USER_MSG( "GameMode", 1 ); gmsgMOTD = REG_USER_MSG( "MOTD", -1 ); gmsgServerName = REG_USER_MSG( "ServerName", -1 ); - gmsgAmmoPickup = REG_USER_MSG( "AmmoPickup", 2 ); + gmsgAmmoPickup = REG_USER_MSG( "AmmoPickup", 3 ); gmsgWeapPickup = REG_USER_MSG( "WeapPickup", 1 ); gmsgItemPickup = REG_USER_MSG( "ItemPickup", -1 ); gmsgHideWeapon = REG_USER_MSG( "HideWeapon", 1 ); @@ -243,14 +229,14 @@ void LinkUserMessages( void ) gmsgShowMenu = REG_USER_MSG( "ShowMenu", -1 ); gmsgShake = REG_USER_MSG( "ScreenShake", sizeof(ScreenShake) ); gmsgFade = REG_USER_MSG( "ScreenFade", sizeof(ScreenFade) ); - gmsgAmmoX = REG_USER_MSG( "AmmoX", 2 ); + gmsgAmmoX = REG_USER_MSG( "AmmoX", 3 ); + gmsgPlayMP3 = REG_USER_MSG( "PlayMP3", -1 ); gmsgTeamNames = REG_USER_MSG( "TeamNames", -1 ); gmsgStatusText = REG_USER_MSG( "StatusText", -1 ); gmsgStatusValue = REG_USER_MSG( "StatusValue", 3 ); - gmsgStartUp = REG_USER_MSG( "StartUp", 2 ); - gmsgScope = REG_USER_MSG( "Scope", 1 ); + gmsgBhopcap = REG_USER_MSG( "Bhopcap", 1 ); } LINK_ENTITY_TO_CLASS( player, CBasePlayer ) @@ -477,10 +463,10 @@ int CBasePlayer::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, fl } // keep track of amount of damage last sustained - m_lastDamageAmount = flDamage; + m_lastDamageAmount = (int)flDamage; // Armor. - if( pev->armorvalue && !( bitsDamageType & ( DMG_FALL | DMG_DROWN ) ) )// armor doesn't protect against fall or drown damage! + if( !( pev->flags & FL_GODMODE ) && pev->armorvalue && !( bitsDamageType & ( DMG_FALL | DMG_DROWN ) ) )// armor doesn't protect against fall or drown damage! { float flNew = flDamage * flRatio; @@ -680,8 +666,8 @@ void CBasePlayer::PackDeadPlayerItems( void ) int iWeaponRules; int iAmmoRules; int i; - CBasePlayerWeapon *rgpPackWeapons[20] = {0};// 20 hardcoded for now. How to determine exactly how many weapons we have? - int iPackAmmo[MAX_AMMO_SLOTS + 1]; + CBasePlayerWeapon *rgpPackWeapons[MAX_WEAPONS] = {0,}; + int iPackAmmo[MAX_AMMO_SLOTS]; int iPW = 0;// index into packweapons array int iPA = 0;// index into packammo array @@ -689,7 +675,7 @@ void CBasePlayer::PackDeadPlayerItems( void ) // get the game rules iWeaponRules = g_pGameRules->DeadPlayerWeapons( this ); - iAmmoRules = g_pGameRules->DeadPlayerAmmo( this ); + iAmmoRules = g_pGameRules->DeadPlayerAmmo( this ); if( iWeaponRules == GR_PLR_DROP_GUN_NO && iAmmoRules == GR_PLR_DROP_AMMO_NO ) { @@ -699,14 +685,14 @@ void CBasePlayer::PackDeadPlayerItems( void ) } // go through all of the weapons and make a list of the ones to pack - for( i = 0; i < MAX_ITEM_TYPES; i++ ) + for( i = 0; i < MAX_ITEM_TYPES && iPW < MAX_WEAPONS; i++ ) { if( m_rgpPlayerItems[i] ) { // there's a weapon here. Should I pack it? CBasePlayerItem *pPlayerItem = m_rgpPlayerItems[i]; - while( pPlayerItem ) + while( pPlayerItem && iPW < MAX_WEAPONS ) { switch( iWeaponRules ) { @@ -796,6 +782,9 @@ void CBasePlayer::PackDeadPlayerItems( void ) void CBasePlayer::RemoveAllItems( BOOL removeSuit ) { + int i; + CBasePlayerItem *pPendingItem; + if( m_pActiveItem ) { ResetAutoaim(); @@ -805,18 +794,21 @@ void CBasePlayer::RemoveAllItems( BOOL removeSuit ) m_pLastItem = NULL; - int i; - CBasePlayerItem *pPendingItem; + if( m_pTank != 0 ) + m_pTank->Use( this, this, USE_OFF, 0 ); + + m_iTrain = TRAIN_NEW; // turn off train + for( i = 0; i < MAX_ITEM_TYPES; i++ ) { m_pActiveItem = m_rgpPlayerItems[i]; + m_rgpPlayerItems[i] = NULL; while( m_pActiveItem ) { pPendingItem = m_pActiveItem->m_pNext; m_pActiveItem->Drop(); m_pActiveItem = pPendingItem; } - m_rgpPlayerItems[i] = NULL; } m_pActiveItem = NULL; @@ -824,17 +816,21 @@ void CBasePlayer::RemoveAllItems( BOOL removeSuit ) pev->weaponmodel = 0; if( removeSuit ) - { pev->weapons = 0; - - HidePlayerHUD(); - } else pev->weapons &= ~WEAPON_ALLWEAPONS; + m_iHideHUD |= HIDEHUD_WEAPONS; + + // Turn off flashlight + ClearBits( pev->effects, EF_DIMLIGHT ); + for( i = 0; i < MAX_AMMO_SLOTS; i++ ) m_rgAmmo[i] = 0; + if( satchelfix.value ) + DeactivatePipebombs( this ); + UpdateClientData(); // send Selected Weapon Message to our client @@ -863,11 +859,8 @@ void CBasePlayer::Killed( entvars_t *pevAttacker, int iGib ) g_pGameRules->PlayerKilled( this, pevAttacker, g_pevLastInflictor ); - if( m_pTank != NULL ) - { + if( m_pTank != 0 ) m_pTank->Use( this, this, USE_OFF, 0 ); - m_pTank = NULL; - } // this client isn't going to be thinking for a while, so reset the sound until they respawn pSound = CSoundEnt::SoundPointerForIndex( CSoundEnt::ClientSoundIndex( edict() ) ); @@ -1100,30 +1093,7 @@ void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim ) } /* -=========== -TabulateAmmo -This function is used to find and store -all the ammo we have into the ammo vars. ============ -*/ -void CBasePlayer::TabulateAmmo() -{ - ammo_9mm = AmmoInventory( GetAmmoIndex( "9mm" ) ); - ammo_357 = AmmoInventory( GetAmmoIndex( "357" ) ); - ammo_argrens = AmmoInventory( GetAmmoIndex( "ARgrenades" ) ); - ammo_bolts = AmmoInventory( GetAmmoIndex( "bolts" ) ); - ammo_buckshot = AmmoInventory( GetAmmoIndex( "buckshot" ) ); - ammo_rockets = AmmoInventory( GetAmmoIndex( "rockets" ) ); - ammo_uranium = AmmoInventory( GetAmmoIndex( "uranium" ) ); - ammo_hornets = AmmoInventory( GetAmmoIndex( "Hornets" ) ); - ammo_nails = AmmoInventory( GetAmmoIndex( "nails" ) ); - ammo_xencandy = AmmoInventory( GetAmmoIndex( "xencandy" ) ); - ammo_par21 = AmmoInventory( GetAmmoIndex( "par21" ) ); - ammo_m203grens = AmmoInventory( GetAmmoIndex( "M203grenades" ) ); -} - -/* -=========== WaterMove ============ */ @@ -1192,7 +1162,7 @@ void CBasePlayer::WaterMove() // track drowning damage, give it back when // player finally takes a breath - m_idrowndmg += pev->dmg; + m_idrowndmg += (int)pev->dmg; } } else @@ -1325,6 +1295,9 @@ void CBasePlayer::PlayerDeathThink( void ) StartDeathCam(); } + if( pev->iuser1 ) // player is in spectator mode + return; + // wait for any button down, or mp_forcerespawn is set and the respawn time is up if( !fAnyButtonDown && !( g_pGameRules->IsMultiplayer() && forcerespawn.value > 0 && ( gpGlobals->time > ( m_fDeadTime + 5 ) ) ) ) return; @@ -1373,7 +1346,9 @@ void CBasePlayer::StartDeathCam( void ) } CopyToBodyQue( pev ); - StartObserver( pSpot->v.origin, pSpot->v.v_angle ); + + UTIL_SetOrigin( pev, pSpot->v.origin ); + pev->angles = pev->v_angle = pSpot->v.v_angle; } else { @@ -1381,23 +1356,86 @@ void CBasePlayer::StartDeathCam( void ) TraceResult tr; CopyToBodyQue( pev ); UTIL_TraceLine( pev->origin, pev->origin + Vector( 0, 0, 128 ), ignore_monsters, edict(), &tr ); - StartObserver( tr.vecEndPos, UTIL_VecToAngles( tr.vecEndPos - pev->origin ) ); - return; + + UTIL_SetOrigin( pev, tr.vecEndPos ); + pev->angles = pev->v_angle = UTIL_VecToAngles( tr.vecEndPos - pev->origin ); } + + // start death cam + m_afPhysicsFlags |= PFLAG_OBSERVER; + pev->view_ofs = g_vecZero; + pev->fixangle = TRUE; + pev->solid = SOLID_NOT; + pev->takedamage = DAMAGE_NO; + pev->movetype = MOVETYPE_NONE; + pev->modelindex = 0; } void CBasePlayer::StartObserver( Vector vecPosition, Vector vecViewAngle ) { - m_afPhysicsFlags |= PFLAG_OBSERVER; + // clear any clientside entities attached to this player + MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin ); + WRITE_BYTE( TE_KILLPLAYERATTACHMENTS ); + WRITE_BYTE( (BYTE)entindex() ); + MESSAGE_END(); + // Holster weapon immediately, to allow it to cleanup + if( m_pActiveItem ) + m_pActiveItem->Holster(); + + if( m_pTank != 0 ) + m_pTank->Use( this, this, USE_OFF, 0 ); + + // clear out the suit message cache so we don't keep chattering + SetSuitUpdate( NULL, FALSE, 0 ); + + // Tell Ammo Hud that the player is dead + MESSAGE_BEGIN( MSG_ONE, gmsgCurWeapon, NULL, pev ); + WRITE_BYTE( 0 ); + WRITE_BYTE( 0XFF ); + WRITE_BYTE( 0xFF ); + MESSAGE_END(); + + // reset FOV + m_iFOV = m_iClientFOV = 0; + pev->fov = m_iFOV; + MESSAGE_BEGIN( MSG_ONE, gmsgSetFOV, NULL, pev ); + WRITE_BYTE( 0 ); + MESSAGE_END(); + + // Setup flags + m_iHideHUD = ( HIDEHUD_HEALTH | HIDEHUD_FLASHLIGHT | HIDEHUD_WEAPONS ); + m_afPhysicsFlags |= PFLAG_OBSERVER; + pev->effects = EF_NODRAW; pev->view_ofs = g_vecZero; pev->angles = pev->v_angle = vecViewAngle; pev->fixangle = TRUE; pev->solid = SOLID_NOT; pev->takedamage = DAMAGE_NO; pev->movetype = MOVETYPE_NONE; - pev->modelindex = 0; + ClearBits( m_afPhysicsFlags, PFLAG_DUCKING ); + ClearBits( pev->flags, FL_DUCKING ); + pev->deadflag = DEAD_RESPAWNABLE; + pev->health = 1; + + // Clear out the status bar + m_fInitHUD = TRUE; + + pev->team = 0; + MESSAGE_BEGIN( MSG_ALL, gmsgTeamInfo ); + WRITE_BYTE( ENTINDEX(edict()) ); + WRITE_STRING( "" ); + MESSAGE_END(); + + // Remove all the player's stuff + RemoveAllItems( FALSE ); + + // Move them to the new position UTIL_SetOrigin( pev, vecPosition ); + + // Find a player to watch + m_flNextObserverInput = 0; + Observer_SetMode( m_iObserverLastMode ); } // @@ -1407,6 +1445,9 @@ void CBasePlayer::StartObserver( Vector vecPosition, Vector vecViewAngle ) void CBasePlayer::PlayerUse( void ) { + if( IsObserver() ) + return; + // Was use pressed or released? if( !( ( pev->button | m_afButtonPressed | m_afButtonReleased) & IN_USE ) ) return; @@ -1414,12 +1455,11 @@ void CBasePlayer::PlayerUse( void ) // Hit Use on a train? if( m_afButtonPressed & IN_USE ) { - if( m_pTank != NULL ) + if( m_pTank != 0 ) { // Stop controlling the tank // TODO: Send HUD Update m_pTank->Use( this, this, USE_OFF, 0 ); - m_pTank = NULL; return; } else @@ -1437,7 +1477,7 @@ void CBasePlayer::PlayerUse( void ) if( pTrain && !( pev->button & IN_JUMP ) && FBitSet( pev->flags, FL_ONGROUND ) && (pTrain->ObjectCaps() & FCAP_DIRECTIONAL_USE ) && pTrain->OnControls( pev ) ) { m_afPhysicsFlags |= PFLAG_ONTRAIN; - m_iTrain = TrainSpeed( pTrain->pev->speed, pTrain->pev->impulse ); + m_iTrain = TrainSpeed( (int)pTrain->pev->speed, pTrain->pev->impulse ); m_iTrain |= TRAIN_NEW; EMIT_SOUND( ENT( pev ), CHAN_ITEM, "plats/train_use1.wav", 0.8, ATTN_NORM ); return; @@ -1608,7 +1648,7 @@ void CBasePlayer::AddPoints( int score, BOOL bAllowNegativeScore ) if( -score > pev->frags ) // Will this go negative? { - score = -pev->frags; // Sum will be 0 + score = (int)( -pev->frags ); // Sum will be 0 } } } @@ -1617,7 +1657,7 @@ void CBasePlayer::AddPoints( int score, BOOL bAllowNegativeScore ) MESSAGE_BEGIN( MSG_ALL, gmsgScoreInfo ); WRITE_BYTE( ENTINDEX( edict() ) ); - WRITE_SHORT( pev->frags ); + WRITE_SHORT( (int)pev->frags ); WRITE_SHORT( m_iDeaths ); WRITE_SHORT( 0 ); WRITE_SHORT( g_pGameRules->GetTeamIndex( m_szTeamName ) + 1 ); @@ -1679,8 +1719,8 @@ void CBasePlayer::UpdateStatusBar() // allies and medics get to see the targets health if( g_pGameRules->PlayerRelationship( this, pEntity ) == GR_TEAMMATE ) { - newSBarState[SBAR_ID_TARGETHEALTH] = 100 * ( pEntity->pev->health / pEntity->pev->max_health ); - newSBarState[SBAR_ID_TARGETARMOR] = pEntity->pev->armorvalue; //No need to get it % based since 100 it's the max. + newSBarState[SBAR_ID_TARGETHEALTH] = (int)( 100 * ( pEntity->pev->health / pEntity->pev->max_health ) ); + 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; @@ -1775,6 +1815,16 @@ void CBasePlayer::PreThink( void ) CheckSuitUpdate(); + // Observer Button Handling + if( IsObserver() ) + { + Observer_HandleButtons(); + Observer_CheckTarget(); + Observer_CheckProperties(); + pev->impulse = 0; + return; + } + if( pev->deadflag >= DEAD_DYING ) { PlayerDeathThink(); @@ -1793,6 +1843,7 @@ void CBasePlayer::PreThink( void ) { CBaseEntity *pTrain = CBaseEntity::Instance( pev->groundentity ); float vel; + int iGearId; // Vit_amiN: keeps the train control HUD in sync if( !pTrain ) { @@ -1833,10 +1884,12 @@ void CBasePlayer::PreThink( void ) pTrain->Use( this, this, USE_SET, (float)vel ); } - if( vel ) + iGearId = TrainSpeed( pTrain->pev->speed, pTrain->pev->impulse ); + + if( iGearId != ( m_iTrain & 0x0F ) ) // Vit_amiN: speed changed { - m_iTrain = TrainSpeed( pTrain->pev->speed, pTrain->pev->impulse ); - m_iTrain |= TRAIN_ACTIVE|TRAIN_NEW; + m_iTrain = iGearId; + m_iTrain |= TRAIN_ACTIVE | TRAIN_NEW; } } else if( m_iTrain & TRAIN_ACTIVE ) @@ -1867,55 +1920,6 @@ void CBasePlayer::PreThink( void ) { pev->velocity = g_vecZero; } - - // Only try to play music if wait time has elapsed. - if( m_flMusicCheckWait <= gpGlobals->time ) - { - if( !m_bSong01_Played ) - { - if( FStrEq( STRING( gpGlobals->mapname ), "pv_intro" ) ) - { - CLIENT_COMMAND( edict(), "play sound/mp3/int.mp3\n" ); - m_bSong01_Played = TRUE; - } - } - if( !m_bSong02_Played ) - { - if( FStrEq( STRING( gpGlobals->mapname ), "pv_orl01" ) ) - { - CLIENT_COMMAND( edict(), "play sound/mp3/orl.mp3\n" ); - m_bSong02_Played = TRUE; - } - } - if( !m_bSong03_Played ) - { - if( FStrEq( STRING( gpGlobals->mapname ), "pv_ntc01" ) ) - { - CLIENT_COMMAND( edict(), "play sound/mp3/ntc.mp3\n" ); - m_bSong03_Played = TRUE; - } - } - if( !m_bSong04_Played ) - { - if( FStrEq( STRING( gpGlobals->mapname ), "pv_ntc05" ) ) - { - CLIENT_COMMAND( edict(), "play sound/mp3/asl.mp3\n" ); - m_bSong04_Played = TRUE; - } - } - if( !m_bSong05_Played ) - { - if( FStrEq( STRING( gpGlobals->mapname ), "pv_outro" ) ) - { - CLIENT_COMMAND( edict(), "play sound/mp3/out.mp3\n" ); - m_bSong05_Played = TRUE; - } - } - if( !m_bSong06_Played ) - { - m_bSong06_Played = TRUE; - } - } } /* Time based Damage works as follows: 1) There are several types of timebased damage: @@ -1995,7 +1999,7 @@ void CBasePlayer::CheckTimeBasedDamage() int i; BYTE bDuration = 0; - static float gtbdPrev = 0.0; + //static float gtbdPrev = 0.0; if( !( m_bitsDamageType & DMG_TIMEBASED ) ) return; @@ -2034,7 +2038,7 @@ void CBasePlayer::CheckTimeBasedDamage() // after the player has been drowning and finally takes a breath if( m_idrowndmg > m_idrownrestored ) { - int idif = min( m_idrowndmg - m_idrownrestored, 10 ); + int idif = Q_min( m_idrowndmg - m_idrownrestored, 10 ); TakeHealth( idif, DMG_GENERIC ); m_idrownrestored += idif; @@ -2256,7 +2260,7 @@ void CBasePlayer::CheckSuitUpdate() // seconds, then we won't repeat playback of this word or sentence // for at least that number of seconds. -void CBasePlayer::SetSuitUpdate( char *name, int fgroup, int iNoRepeatTime ) +void CBasePlayer::SetSuitUpdate( const char *name, int fgroup, int iNoRepeatTime ) { } @@ -2302,7 +2306,7 @@ void CBasePlayer::UpdatePlayerSound( void ) // is louder than his body/movement, use the weapon volume, else, use the body volume. if( FBitSet( pev->flags, FL_ONGROUND ) ) { - iBodyVolume = pev->velocity.Length(); + iBodyVolume = (int)pev->velocity.Length(); // clamp the noise that can be made by the body, in case a push trigger, // weapon recoil, or anything shoves the player abnormally fast. @@ -2335,7 +2339,7 @@ void CBasePlayer::UpdatePlayerSound( void ) } // decay weapon volume over time so bits_SOUND_COMBAT stays set for a while - m_iWeaponVolume -= 250 * gpGlobals->frametime; + m_iWeaponVolume -= (int)( 250 * gpGlobals->frametime ); if( m_iWeaponVolume < 0 ) { iVolume = 0; @@ -2353,7 +2357,7 @@ void CBasePlayer::UpdatePlayerSound( void ) } else if( iVolume > m_iTargetVolume ) { - iVolume -= 250 * gpGlobals->frametime; + iVolume -= (int)( 250 * gpGlobals->frametime ); if( iVolume < m_iTargetVolume ) { @@ -2382,7 +2386,7 @@ void CBasePlayer::UpdatePlayerSound( void ) } // keep track of virtual muzzle flash - m_iWeaponFlash -= 256 * gpGlobals->frametime; + m_iWeaponFlash -= (int)( 256 * gpGlobals->frametime ); if( m_iWeaponFlash < 0 ) m_iWeaponFlash = 0; @@ -2404,7 +2408,7 @@ void CBasePlayer::PostThink() goto pt_end; // Handle Tank controlling - if( m_pTank != NULL ) + if( m_pTank != 0 ) { // if they've moved too far from the gun, or selected a weapon, unuse the gun if( m_pTank->OnControls( pev ) && !pev->weaponmodel ) @@ -2415,7 +2419,6 @@ void CBasePlayer::PostThink() { // they've moved off the platform m_pTank->Use( this, this, USE_OFF, 0 ); - m_pTank = NULL; } } @@ -2468,7 +2471,7 @@ void CBasePlayer::PostThink() { if( m_flFallVelocity > 64 && !g_pGameRules->IsMultiplayer() ) { - CSoundEnt::InsertSound( bits_SOUND_PLAYER, pev->origin, m_flFallVelocity, 0.2 ); + CSoundEnt::InsertSound( bits_SOUND_PLAYER, pev->origin, (int)m_flFallVelocity, 0.2 ); // ALERT( at_console, "fall %f\n", m_flFallVelocity ); } m_flFallVelocity = 0; @@ -2489,13 +2492,15 @@ void CBasePlayer::PostThink() CheckPowerups( pev ); UpdatePlayerSound(); - - UpdateExertLevel(); +pt_end: + if( pev->deadflag == DEAD_NO ) + m_vecLastViewAngles = pev->angles; + else + pev->angles = m_vecLastViewAngles; // Track button info so we can detect 'pressed' and 'released' buttons next frame m_afButtonLast = pev->button; -pt_end: #if defined( CLIENT_WEAPONS ) // Decay timers on weapons // go through all of the weapons and make a list of the ones to pack @@ -2513,23 +2518,23 @@ pt_end: if( gun && gun->UseDecrement() ) { - gun->m_flNextPrimaryAttack = max( gun->m_flNextPrimaryAttack - gpGlobals->frametime, -1.0 ); - gun->m_flNextSecondaryAttack = max( gun->m_flNextSecondaryAttack - gpGlobals->frametime, -0.001 ); + gun->m_flNextPrimaryAttack = Q_max( gun->m_flNextPrimaryAttack - gpGlobals->frametime, -1.0 ); + gun->m_flNextSecondaryAttack = Q_max( gun->m_flNextSecondaryAttack - gpGlobals->frametime, -0.001 ); if( gun->m_flTimeWeaponIdle != 1000 ) { - gun->m_flTimeWeaponIdle = max( gun->m_flTimeWeaponIdle - gpGlobals->frametime, -0.001 ); + gun->m_flTimeWeaponIdle = Q_max( gun->m_flTimeWeaponIdle - gpGlobals->frametime, -0.001 ); } if( gun->pev->fuser1 != 1000 ) { - gun->pev->fuser1 = max( gun->pev->fuser1 - gpGlobals->frametime, -0.001 ); + gun->pev->fuser1 = Q_max( gun->pev->fuser1 - gpGlobals->frametime, -0.001 ); } // Only decrement if not flagged as NO_DECREMENT /*if( gun->m_flPumpTime != 1000 ) { - gun->m_flPumpTime = max( gun->m_flPumpTime - gpGlobals->frametime, -0.001 ); + gun->m_flPumpTime = Q_max( gun->m_flPumpTime - gpGlobals->frametime, -0.001 ); }*/ } @@ -2708,6 +2713,7 @@ void CBasePlayer::Spawn( void ) g_engfuncs.pfnSetPhysicsKeyValue( edict(), "slj", "0" ); g_engfuncs.pfnSetPhysicsKeyValue( edict(), "hl", "1" ); + SET_CLIENT_MAX_SPEED( edict(), PLAYER_MAX_SPEED ); pev->fov = m_iFOV = 0;// init field of view. m_iClientFOV = -1; // make sure fov reset is sent @@ -2772,17 +2778,6 @@ void CBasePlayer::Spawn( void ) m_flNextChatTime = gpGlobals->time; - m_bSong01_Played = - m_bSong02_Played = - m_bSong03_Played = - m_bSong04_Played = - m_bSong05_Played = - m_bSong06_Played = FALSE; - - m_fHudVisible = FALSE; - m_fUpdateHudVisibility = FALSE; - m_flMusicCheckWait = gpGlobals->time + 0.1f; // Give a bit of time before attempting to use MP3 player. - g_pGameRules->PlayerSpawn( this ); } @@ -2829,6 +2824,8 @@ void CBasePlayer::Precache( void ) if( gInitHUD ) m_fInitHUD = TRUE; + + pev->fov = m_iFOV; // Vit_amiN: restore the FOV on level change or map/saved game load } int CBasePlayer::Save( CSave &save ) @@ -2906,9 +2903,6 @@ int CBasePlayer::Restore( CRestore &restore ) // Barring that, we clear it out here instead of using the incorrect restored time value. m_flNextAttack = UTIL_WeaponTimeBase(); #endif - m_fUpdateHudVisibility = TRUE; - - m_flMusicCheckWait = gpGlobals->time + 0.5f; return status; } @@ -3115,7 +3109,7 @@ void CSprayCan::Think( void ) } else { - UTIL_PlayerDecalTrace( &tr, playernum, pev->frame, TRUE ); + UTIL_PlayerDecalTrace( &tr, playernum, (int)pev->frame, TRUE ); // Just painted last custom frame. if( pev->frame++ >= ( nFrames - 1 ) ) UTIL_Remove( this ); @@ -3240,10 +3234,16 @@ void CBasePlayer::ForceClientDllUpdate( void ) { m_iClientHealth = -1; m_iClientBattery = -1; + m_iClientHideHUD = -1; // Vit_amiN: forcing to update + m_iClientFOV = -1; // Vit_amiN: force client weapons to be sent m_iTrain |= TRAIN_NEW; // Force new train message. m_fWeapon = FALSE; // Force weapon send m_fKnownItem = FALSE; // Force weaponinit messages. m_fInitHUD = TRUE; // Force HUD gmsgResetHUD message + m_bSentBhopcap = true; // a1ba: Update bhopcap state + memset( m_rgAmmoLast, 0, sizeof( m_rgAmmoLast )); // a1ba: Force update AmmoX + + // Now force all the necessary messages // to be sent. @@ -3349,18 +3349,21 @@ void CBasePlayer::CheatImpulseCommands( int iImpulse ) break; case 101: gEvilImpulse101 = TRUE; - GiveNamedItem( "item_suit" ); GiveNamedItem( "weapon_heaterpipe" ); + GiveNamedItem( "weapon_bradnailer" ); + GiveNamedItem( "ammo_nailclip" ); + GiveNamedItem( "weapon_nailgun" ); + GiveNamedItem( "ammo_nailround" ); GiveNamedItem( "weapon_shotgun" ); GiveNamedItem( "ammo_buckshot" ); GiveNamedItem( "weapon_cmlwbr" ); GiveNamedItem( "ammo_bolts" ); + GiveNamedItem( "weapon_xs" ); + GiveNamedItem( "ammo_xencandy" ); GiveNamedItem( "weapon_pipebomb" ); GiveNamedItem( "weapon_par21" ); GiveNamedItem( "ammo_par21_clip" ); GiveNamedItem( "ammo_par21_grenade" ); - GiveNamedItem( "ammo_m203grenade" ); - gEvilImpulse101 = FALSE; break; case 102: @@ -3520,6 +3523,8 @@ int CBasePlayer::AddPlayerItem( CBasePlayerItem *pItem ) g_pGameRules->PlayerGotWeapon( this, pItem ); pItem->CheckRespawn(); + m_iHideHUD &= ~HIDEHUD_WEAPONS; + pItem->m_pNext = m_rgpPlayerItems[pItem->iItemSlot()]; m_rgpPlayerItems[pItem->iItemSlot()] = pItem; @@ -3539,19 +3544,23 @@ int CBasePlayer::AddPlayerItem( CBasePlayerItem *pItem ) return FALSE; } -int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem ) +int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem, bool bCallHolster ) { + pItem->pev->nextthink = 0;// crowbar may be trying to swing again, etc. + pItem->SetThink( NULL ); + if( m_pActiveItem == pItem ) { ResetAutoaim(); - pItem->Holster(); - pItem->pev->nextthink = 0;// crowbar may be trying to swing again, etc. - pItem->SetThink( NULL ); + if( bCallHolster ) + pItem->Holster(); m_pActiveItem = NULL; pev->viewmodel = 0; pev->weaponmodel = 0; } - else if( m_pLastItem == pItem ) + + // In some cases an item can be both the active and last item, like for instance dropping all weapons and only having an exhaustible weapon left. - Solokiller + if( m_pLastItem == pItem ) m_pLastItem = NULL; CBasePlayerItem *pPrev = m_rgpPlayerItems[pItem->iItemSlot()]; @@ -3579,7 +3588,7 @@ int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem ) // // Returns the unique ID for the ammo, or -1 if error // -int CBasePlayer::GiveAmmo( int iCount, char *szName, int iMax ) +int CBasePlayer::GiveAmmo( int iCount, const char *szName, int iMax ) { if( !szName ) { @@ -3600,7 +3609,7 @@ int CBasePlayer::GiveAmmo( int iCount, char *szName, int iMax ) if( i < 0 || i >= MAX_AMMO_SLOTS ) return -1; - int iAdd = min( iCount, iMax - m_rgAmmo[i] ); + int iAdd = Q_min( iCount, iMax - m_rgAmmo[i] ); if( iAdd < 1 ) return i; @@ -3611,12 +3620,10 @@ int CBasePlayer::GiveAmmo( int iCount, char *szName, int iMax ) // Send the message that ammo has been picked up MESSAGE_BEGIN( MSG_ONE, gmsgAmmoPickup, NULL, pev ); WRITE_BYTE( GetAmmoIndex( szName ) ); // ammo ID - WRITE_BYTE( iAdd ); // amount + WRITE_SHORT( iAdd ); // amount MESSAGE_END(); } - TabulateAmmo(); - return i; } @@ -3653,10 +3660,10 @@ Called every frame by the player PostThink */ void CBasePlayer::ItemPostFrame() { - static int fInSelect = FALSE; + //static int fInSelect = FALSE; // check if the player is using a tank - if( m_pTank != NULL ) + if( m_pTank != 0 ) return; #if defined( CLIENT_WEAPONS ) @@ -3721,7 +3728,7 @@ void CBasePlayer::SendAmmoUpdate( void ) // send "Ammo" update message MESSAGE_BEGIN( MSG_ONE, gmsgAmmoX, NULL, pev ); WRITE_BYTE( i ); - WRITE_BYTE( max( min( m_rgAmmo[i], 254 ), 0 ) ); // clamp the value to one byte + WRITE_SHORT( Q_max( m_rgAmmo[i], 0 ) ); // clamp the value to 2 bytes MESSAGE_END(); } } @@ -3756,6 +3763,9 @@ void CBasePlayer::UpdateClientData( void ) g_pGameRules->InitHUD( this ); m_fGameHUDInitialized = TRUE; + + m_iObserverLastMode = OBS_ROAMING; + if( g_pGameRules->IsMultiplayer() ) { FireTargets( "game_playerjoin", this, this, USE_TOGGLE, 0 ); @@ -3764,59 +3774,20 @@ void CBasePlayer::UpdateClientData( void ) FireTargets( "game_playerspawn", this, this, USE_TOGGLE, 0 ); + // Send flashlight status + MESSAGE_BEGIN( MSG_ONE, gmsgFlashlight, NULL, pev ); + WRITE_BYTE( FlashlightIsOn() ? 1 : 0 ); + WRITE_BYTE( m_iFlashBattery ); + MESSAGE_END(); + + // Vit_amiN: the geiger state could run out of sync, too + MESSAGE_BEGIN( MSG_ONE, gmsgGeigerRange, NULL, pev ); + WRITE_BYTE( 0 ); + MESSAGE_END(); + InitStatusBar(); } - // - // Poke646 & Vendetta - Give suit to toggle hud on map po_aud01 or po_orl01 - // - if( !( pev->weapons & ( 1 << WEAPON_SUIT ) ) ) - { - if( FStrEq( STRING( gpGlobals->mapname ), "pv_orl01" ) ) - { - pev->weapons |= ( 1 << WEAPON_SUIT ); - - // - // Make HUD completely transparent and slowly increase it's alpha. - // - ShowPlayerHUD(); - } - } - - // Update HUD visibility. - if( m_fUpdateHudVisibility ) - { - // If player is frozen, tell client to hide HUD, - // if visible. - if( ( pev->flags & FL_FROZEN ) && m_fHudVisible ) - { - if( pev->weapons & ( 1 << WEAPON_SUIT ) ) - { - HidePlayerHUD(); - } - } - // If player is not frozen, tell client to show HUD, - // if not visible. - else if( !( pev->flags & FL_FROZEN ) && !m_fHudVisible ) - { - if( pev->weapons & ( 1 << WEAPON_SUIT ) ) - { - ShowPlayerHUD(); - } - } - else - { - if( pev->weapons & ( 1 << WEAPON_SUIT ) ) - { - m_fHudVisible = FALSE; - - ShowPlayerHUD( TRUE ); - } - } - - m_fUpdateHudVisibility = FALSE; - } - if( m_iHideHUD != m_iClientHideHUD ) { MESSAGE_BEGIN( MSG_ONE, gmsgHideWeapon, NULL, pev ); @@ -3847,19 +3818,21 @@ void CBasePlayer::UpdateClientData( void ) if( pev->health != m_iClientHealth ) { #define clamp( val, min, max ) ( ((val) > (max)) ? (max) : ( ((val) < (min)) ? (min) : (val) ) ) - int iHealth = max( pev->health, 0 ); // make sure that no negative health values are sent + int iHealth = clamp( pev->health, 0, 255 ); // make sure that no negative health values are sent + if( pev->health > 0.0f && pev->health <= 1.0f ) + iHealth = 1; // send "health" update message MESSAGE_BEGIN( MSG_ONE, gmsgHealth, NULL, pev ); WRITE_BYTE( iHealth ); MESSAGE_END(); - m_iClientHealth = pev->health; + m_iClientHealth = (int)pev->health; } - if( pev->armorvalue != m_iClientBattery ) + if( (int)pev->armorvalue != m_iClientBattery ) { - m_iClientBattery = pev->armorvalue; + m_iClientBattery = (int)pev->armorvalue; ASSERT( gmsgBattery > 0 ); @@ -3887,8 +3860,8 @@ void CBasePlayer::UpdateClientData( void ) int visibleDamageBits = m_bitsDamageType & DMG_SHOWNHUD; MESSAGE_BEGIN( MSG_ONE, gmsgDamage, NULL, pev ); - WRITE_BYTE( pev->dmg_save ); - WRITE_BYTE( pev->dmg_take ); + WRITE_BYTE( (int)pev->dmg_save ); + WRITE_BYTE( (int)pev->dmg_take ); WRITE_LONG( visibleDamageBits ); WRITE_COORD( damageOrigin.x ); WRITE_COORD( damageOrigin.y ); @@ -4014,6 +3987,15 @@ void CBasePlayer::UpdateClientData( void ) UpdateStatusBar(); m_flNextSBarUpdateTime = gpGlobals->time + 0.2; } + + // Send the current bhopcap state. + if( !m_bSentBhopcap ) + { + m_bSentBhopcap = true; + MESSAGE_BEGIN( MSG_ONE, gmsgBhopcap, NULL, pev ); + WRITE_BYTE( g_bhopcap ); + MESSAGE_END(); + } } //========================================================= @@ -4153,8 +4135,8 @@ Vector CBasePlayer::GetAutoaimVector( float flDelta ) { SET_CROSSHAIRANGLE( edict(), -m_vecAutoAim.x, m_vecAutoAim.y ); - m_lastx = m_vecAutoAim.x; - m_lasty = m_vecAutoAim.y; + m_lastx = (int)m_vecAutoAim.x; + m_lasty = (int)m_vecAutoAim.y; } } @@ -4376,7 +4358,8 @@ void CBasePlayer::DropPlayerItem( char *pszItemName ) // item we want to drop and hit a BREAK; pWeapon is the item. if( pWeapon ) { - g_pGameRules->GetNextBestWeapon( this, pWeapon ); + if( !g_pGameRules->GetNextBestWeapon( this, pWeapon ) ) + return; // can't drop the item they asked for, may be our last item or something we can't holster UTIL_MakeVectors( pev->angles ); @@ -4459,6 +4442,27 @@ BOOL CBasePlayer::HasNamedPlayerItem( const char *pszItemName ) return FALSE; } +CBasePlayerItem *CBasePlayer::GiveNamedPlayerItem( const char *pszItemName ) +{ + CBasePlayerItem *pItem; + int i; + + for( i = 0; i < MAX_ITEM_TYPES; i++ ) + { + pItem = m_rgpPlayerItems[i]; + + while( pItem ) + { + if( !strcmp( pszItemName, STRING( pItem->pev->classname ) ) ) + { + return pItem; + } + pItem = pItem->m_pNext; + } + } + + return 0; +} //========================================================= // //========================================================= @@ -4482,82 +4486,6 @@ BOOL CBasePlayer::SwitchWeapon( CBasePlayerItem *pWeapon ) return TRUE; } -void CBasePlayer::IncrementExertLevel( int amount ) -{ - m_iExertLevel += min( amount, PLAYER_EXERT_LEVEL_MAX - m_iExertLevel ); -} - -void CBasePlayer::DecrementExertLevel( int amount ) -{ - m_iExertLevel -= min( amount, m_iExertLevel ); -} - -void CBasePlayer::SetExertLevel( int level ) -{ - m_iExertLevel = clamp( level, PLAYER_EXERT_LEVEL_MIN, PLAYER_EXERT_LEVEL_MAX ); -} - -int CBasePlayer::GetExertLevel( void ) const -{ - return m_iExertLevel; -} - -void CBasePlayer::UpdateExertLevel( void ) -{ - if( m_iExertLevel > PLAYER_EXERT_LEVEL_MIN ) - { - // Slowly decrease exert level. - if( ( gpGlobals->time - m_flExertUpdateStart ) > m_flExertRate ) - { - float temp = (float)m_iExertLevel * 0.0625f; - - if( temp < 1 ) - temp = 1; - - m_iExertLevel -= min( m_iExertLevel, temp ); - - m_flExertRate = PLAYER_EXERT_RATE; - m_flExertUpdateStart = gpGlobals->time; - } - } - -#ifndef CLIENT_DLL - // ALERT( at_console, "Player exert level: %d\n", m_iExertLevel ); -#endif -} - -void CBasePlayer::ShowPlayerHUD( BOOL bInstant ) -{ - if( m_fHudVisible ) - return; - - m_fHudVisible = TRUE; - - MESSAGE_BEGIN( MSG_ONE, gmsgStartUp, NULL, pev ); - WRITE_BYTE( 255 ); // Target alpha - if( bInstant ) - WRITE_BYTE( 255 ); // Startup alpha - else - WRITE_BYTE( 0 ); // Startup alpha - MESSAGE_END(); -} - -void CBasePlayer::HidePlayerHUD( BOOL bInstant ) -{ - if( !m_fHudVisible ) - return; - - m_fHudVisible = FALSE; - - MESSAGE_BEGIN( MSG_ONE, gmsgStartUp, NULL, pev ); - WRITE_BYTE( 0 ); // Target alpha - if( bInstant ) - WRITE_BYTE( 0 ); // Startup alpha - else - WRITE_BYTE( 255 ); // Startup alpha - MESSAGE_END(); -} - //========================================================= // Dead HEV suit prop //========================================================= @@ -4573,10 +4501,10 @@ public: void KeyValue( KeyValueData *pkvd ); int m_iPose;// which sequence to display -- temporary, don't need to save - static char *m_szPoses[4]; + static const char *m_szPoses[4]; }; -char *CDeadHEV::m_szPoses[] = +const char *CDeadHEV::m_szPoses[] = { "deadback", "deadsitting", @@ -4650,7 +4578,7 @@ void CStripWeapons::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE } if( pPlayer ) - pPlayer->RemoveAllItems( TRUE ); + pPlayer->RemoveAllItems( FALSE ); } class CRevertSaved : public CPointEntity @@ -4718,7 +4646,7 @@ void CRevertSaved::KeyValue( KeyValueData *pkvd ) void CRevertSaved::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - UTIL_ScreenFadeAll( pev->rendercolor, Duration(), HoldTime(), pev->renderamt, FFADE_OUT ); + UTIL_ScreenFadeAll( pev->rendercolor, Duration(), HoldTime(), (int)pev->renderamt, FFADE_OUT ); pev->nextthink = gpGlobals->time + MessageTime(); SetThink( &CRevertSaved::MessageThink ); } diff --git a/dlls/player.h b/dlls/player.h index 4d4c3f1f..476863be 100644 --- a/dlls/player.h +++ b/dlls/player.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef PLAYER_H #define PLAYER_H @@ -22,6 +23,7 @@ #define DAMAGE_FOR_FALL_SPEED (float) 100 / ( PLAYER_FATAL_FALL_SPEED - PLAYER_MAX_SAFE_FALL_SPEED )// damage per unit per second. #define PLAYER_MIN_BOUNCE_SPEED 200 #define PLAYER_FALL_PUNCH_THRESHHOLD (float)350 // won't punch player's screen/make scrape noise unless player falling at least this fast. +#define PLAYER_MAX_SPEED 220 // // Player PHYSICS FLAGS bits @@ -60,18 +62,6 @@ #define TEAM_NAME_LENGTH 16 -// -// Player exert. -// - -#define PLAYER_EXERT_LEVEL_MIN 0 -#define PLAYER_EXERT_LEVEL_MAX 50 -#define PLAYER_EXERT_RATE 0.2f - -#define PLAYER_BREATHE_LEVEL 5 -#define PLAYER_BREATHE_VOLUME_MAX 2.0f -#define PLAYER_BREATHE_SOUND "player/breathe2.wav" - typedef enum { PLAYER_IDLE, @@ -98,6 +88,18 @@ enum sbar_data class CBasePlayer : public CBaseMonster { public: + // Spectator camera + void Observer_FindNextPlayer( bool bReverse ); + void Observer_HandleButtons(); + void Observer_SetMode( int iMode ); + void Observer_CheckTarget(); + void Observer_CheckProperties(); + EHANDLE m_hObserverTarget; + float m_flNextObserverInput; + int m_iObserverWeapon; // weapon of current tracked target + int m_iObserverLastMode;// last used observer mode + int IsObserver() { return pev->iuser1; }; + int random_seed; // See that is shared between client & server for shared weapons code int m_iPlayerSound;// the index of the sound list slot reserved for this player @@ -255,14 +257,16 @@ public: void StartDeathCam( void ); void StartObserver( Vector vecPosition, Vector vecViewAngle ); + void StopObserver(); void AddPoints( int score, BOOL bAllowNegativeScore ); void AddPointsToTeam( int score, BOOL bAllowNegativeScore ); BOOL AddPlayerItem( CBasePlayerItem *pItem ); - BOOL RemovePlayerItem( CBasePlayerItem *pItem ); + BOOL RemovePlayerItem( CBasePlayerItem *pItem, bool bCallHoster ); void DropPlayerItem ( char *pszItemName ); BOOL HasPlayerItem( CBasePlayerItem *pCheckItem ); BOOL HasNamedPlayerItem( const char *pszItemName ); + CBasePlayerItem *GiveNamedPlayerItem( const char *pszItemName ); BOOL HasWeapons( void );// do I have ANY weapons? void SelectPrevItem( int iItem ); void SelectNextItem( int iItem ); @@ -273,7 +277,7 @@ public: void GiveNamedItem( const char *szName ); void EnableControl(BOOL fControl); - int GiveAmmo( int iAmount, char *szName, int iMax ); + int GiveAmmo( int iAmount, const char *szName, int iMax ); void SendAmmoUpdate(void); void WaterMove( void ); @@ -281,7 +285,7 @@ public: void PlayerUse( void ); void CheckSuitUpdate(); - void SetSuitUpdate(char *name, int fgroup, int iNoRepeat); + void SetSuitUpdate( const char *name, int fgroup, int iNoRepeat ); void UpdateGeigerCounter( void ); void CheckTimeBasedDamage( void ); @@ -303,7 +307,7 @@ public: void SetCustomDecalFrames( int nFrames ); int GetCustomDecalFrames( void ); - void TabulateAmmo( void ); + Vector m_vecLastViewAngles; float m_flStartCharge; float m_flAmmoStartCharge; @@ -313,43 +317,15 @@ public: //Player ID void InitStatusBar( void ); void UpdateStatusBar( void ); - int m_izSBarState[ SBAR_END ]; + int m_izSBarState[SBAR_END]; float m_flNextSBarUpdateTime; float m_flStatusBarDisappearDelay; - char m_SbarString0[ SBAR_STRING_SIZE ]; - char m_SbarString1[ SBAR_STRING_SIZE ]; + char m_SbarString0[SBAR_STRING_SIZE]; + char m_SbarString1[SBAR_STRING_SIZE]; float m_flNextChatTime; - // Music - BOOL m_bSong01_Played; - BOOL m_bSong02_Played; - BOOL m_bSong03_Played; - BOOL m_bSong04_Played; - BOOL m_bSong05_Played; - BOOL m_bSong06_Played; - float m_flMusicCheckWait; - - // - // Exert - // - void IncrementExertLevel( int amount ); - void DecrementExertLevel( int amount ); - void SetExertLevel( int level ); - int GetExertLevel( void ) const; - - void UpdateExertLevel( void ); - - int m_iExertLevel; - float m_flExertRate; - float m_flExertUpdateStart; - - // HUD visibility - void ShowPlayerHUD( BOOL bInstant = FALSE ); - void HidePlayerHUD( BOOL bInstant = FALSE ); - - BOOL m_fHudVisible; - BOOL m_fUpdateHudVisibility; + bool m_bSentBhopcap; // If false, the player just joined and needs a bhopcap message. }; #define AUTOAIM_2DEGREES 0.0348994967025 @@ -357,7 +333,7 @@ public: #define AUTOAIM_8DEGREES 0.1391731009601 #define AUTOAIM_10DEGREES 0.1736481776669 -extern int gmsgHudText; +extern int gmsgHudText; extern BOOL gInitHUD; #endif // PLAYER_H diff --git a/dlls/playermonster.cpp b/dlls/playermonster.cpp index cd3484ab..092e7dca 100644 --- a/dlls/playermonster.cpp +++ b/dlls/playermonster.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: New version of the slider bar // @@ -82,7 +82,7 @@ void CPlayerMonster :: HandleAnimEvent( MonsterEvent_t *pEvent ) //========================================================= int CPlayerMonster::ISoundMask( void ) { - return NULL; + return 0; } //========================================================= diff --git a/dlls/poke646/bradnailer.cpp b/dlls/poke646/bradnailer.cpp deleted file mode 100644 index 86164231..00000000 --- a/dlls/poke646/bradnailer.cpp +++ /dev/null @@ -1,326 +0,0 @@ -/*** -* -* Copyright (c) 1996-2001, 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. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -#include "extdll.h" -#include "util.h" -#include "cbase.h" -#include "monsters.h" -#include "weapons.h" -#include "nodes.h" -#include "player.h" -#include "nail.h" - -enum bradnailer_e { - BRADNAILER_IDLE1 = 0, - BRADNAILER_IDLE2, - BRADNAILER_IDLE3, - BRADNAILER_SHOOT, - BRADNAILER_SHOOT_EMPTY, - BRADNAILER_RELOAD, - BRADNAILER_RELOAD_NOT_EMPTY, - BRADNAILER_DRAW, - BRADNAILER_HOLSTER, - BRADNAILER_ADD_SILENCER, - BRADNAILER_UPRIGHT_TO_TILT, - BRADNAILER_TILT_TO_UPRIGHT, - BRADNAILER_FASTSHOOT, -}; - -LINK_ENTITY_TO_CLASS(weapon_bradnailer, CBradnailer); - -void CBradnailer::Spawn() -{ - Precache(); - m_iId = WEAPON_BRADNAILER; - SET_MODEL(ENT(pev), "models/w_bradnailer.mdl"); - - m_iDefaultAmmo = BRADNAILER_DEFAULT_GIVE; - - FallInit();// get ready to fall down. -} - - -void CBradnailer::Precache(void) -{ - PRECACHE_MODEL("models/v_bradnailer.mdl"); - PRECACHE_MODEL("models/w_bradnailer.mdl"); - PRECACHE_MODEL("models/p_bradnailer.mdl"); - - m_iShell = PRECACHE_MODEL("models/shell.mdl");// brass shell - - PRECACHE_SOUND("items/9mmclip1.wav"); - PRECACHE_SOUND("items/9mmclip2.wav"); - - PRECACHE_SOUND("weapons/bradnailer.wav"); - - m_usFireBradnailer = PRECACHE_EVENT(1, "events/bradnailer.sc"); - m_usReload = PRECACHE_EVENT(1, "events/reload.sc"); - - UTIL_PrecacheOther( "nail" ); -} - -int CBradnailer::GetItemInfo(ItemInfo *p) -{ - p->pszName = STRING(pev->classname); - p->pszAmmo1 = "nails"; - p->iMaxAmmo1 = NAILS_MAX_CARRY; - p->pszAmmo2 = NULL; - p->iMaxAmmo2 = -1; - p->iMaxClip = BRADNAILER_MAX_CLIP; - p->iSlot = 1; - p->iPosition = 0; - p->iFlags = 0; - p->iId = m_iId = WEAPON_BRADNAILER; - p->iWeight = BRADNAILER_WEIGHT; - - return 1; -} - -BOOL CBradnailer::Deploy() -{ - return DefaultDeploy("models/v_bradnailer.mdl", "models/p_bradnailer.mdl", BRADNAILER_DRAW, "bradnailer", 0); -} - -BOOL CBradnailer::CanHolster(void) -{ - return (m_fInAttack == 0); -} - -void CBradnailer::Holster(int skiplocal /*= 0*/) -{ - m_fInReload = FALSE;// cancel any reload in progress. - - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; - SendWeaponAnim(BRADNAILER_HOLSTER); - - m_fInAttack = 0; -} - -void CBradnailer::SecondaryAttack(void) -{ - if (m_iClip <= 0) - { - Reload(); - m_flNextSecondaryAttack = 0.15f; - return; - } - - if (m_flNextSecondaryAttack > UTIL_WeaponTimeBase()) - return; - - if (m_fInAttack == 0) - { -#ifndef CLIENT_DLL - //ALERT(at_console, "BRADNAILER_UPRIGHT_TO_TILT\n" ); -#endif - - SendWeaponAnim(BRADNAILER_UPRIGHT_TO_TILT, UseDecrement()); - - m_fInAttack = 1; - - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.7; - m_flNextSecondaryAttack = GetNextAttackDelay(0.7); - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 2.0; - return; - } - else if (m_fInAttack == 1) - { - if (m_flTimeWeaponIdle < UTIL_WeaponTimeBase()) - { -#ifndef CLIENT_DLL - //ALERT(at_console, "Fire\n"); -#endif - Fire(0.05, 0.2, FALSE, TRUE); - - m_fInAttack = 1; - - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.2f; - m_flNextPrimaryAttack = GetNextAttackDelay(0.5); - } - } -} - -void CBradnailer::PrimaryAttack(void) -{ - if (m_fInAttack != 0) - { - m_flNextPrimaryAttack = GetNextAttackDelay(0.5); - return; - } - - if (m_iClip <= 0) - { - Reload(); - m_flNextPrimaryAttack = 0.15f; - return; - } - - Fire(0.01f, 0.3f, TRUE, FALSE); - - m_flNextPrimaryAttack = m_flNextSecondaryAttack = GetNextAttackDelay(0.3f); - - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat(m_pPlayer->random_seed, 10, 15); -} - -void CBradnailer::Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim, BOOL fFastShoot) -{ - m_iClip--; - - m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH; - - int flags; - -#if defined( CLIENT_WEAPONS ) - flags = FEV_NOTHOST; -#else - flags = 0; -#endif - - // player "shoot" animation - m_pPlayer->SetAnimation(PLAYER_ATTACK1); - - m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME; - m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH; - - Vector anglesAim = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle; - UTIL_MakeVectors(anglesAim); - - anglesAim.x = -anglesAim.x; - // Vector vecSrc = m_pPlayer->GetGunPosition() - gpGlobals->v_up * 2; - Vector vecSrc; - Vector vecAiming; - - if (fFastShoot) - { - vecSrc = m_pPlayer->GetGunPosition() + gpGlobals->v_forward * 2 + gpGlobals->v_up * -2; - } - else - { - vecSrc = m_pPlayer->GetGunPosition() + gpGlobals->v_forward * 8 + gpGlobals->v_right * 3 + gpGlobals->v_up * -2; - } - - if (fUseAutoAim) - { - vecAiming = m_pPlayer->GetAutoaimVector(AUTOAIM_10DEGREES); - } - else - { - vecAiming = gpGlobals->v_forward; - } - - Vector vecDir; - vecDir = m_pPlayer->FireBulletsPlayer(1, vecSrc, vecAiming, Vector(flSpread, flSpread, flSpread), 8192, BULLET_PLAYER_NAIL, 2, 0, m_pPlayer->pev, m_pPlayer->random_seed); - - PLAYBACK_EVENT_FULL(0, m_pPlayer->edict(), m_usFireBradnailer, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, fFastShoot, 0); - -#ifndef CLIENT_DLL - - CNail *pNail = CNail::NailCreate(); - pNail->pev->origin = vecSrc; - pNail->pev->angles = anglesAim; - pNail->pev->owner = m_pPlayer->edict(); - - if (m_pPlayer->pev->waterlevel == 3) - { - pNail->pev->velocity = vecAiming * NAIL_WATER_VELOCITY; - pNail->pev->speed = NAIL_WATER_VELOCITY; - } - else - { - pNail->pev->velocity = vecAiming * NAIL_AIR_VELOCITY; - pNail->pev->speed = NAIL_AIR_VELOCITY; - } - pNail->pev->avelocity.z = 10; -#endif - -} - - -void CBradnailer::Reload(void) -{ - if (m_fInAttack != 0) - return; - - if (m_flNextPrimaryAttack > UTIL_WeaponTimeBase()) - return; - - if (m_pPlayer->ammo_nails <= 0) - return; - - int iAnim = (m_iClip == 0) ? BRADNAILER_RELOAD : BRADNAILER_RELOAD_NOT_EMPTY; - - int iResult = DefaultReload(BRADNAILER_MAX_CLIP, iAnim, 2.3); - - if (iResult) - { - m_fInAttack = 0; - - PLAYBACK_EVENT_FULL(0, m_pPlayer->edict(), m_usReload, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, iAnim, 0, 0, 0); - } -} - -BOOL CBradnailer::ShouldWeaponIdle(void) -{ - return (m_iClip == 0) || ((m_fInAttack != 0) && (m_pPlayer->pev->button & IN_ATTACK)); -} - -void CBradnailer::WeaponIdle(void) -{ - ResetEmptySound(); - - m_pPlayer->GetAutoaimVector(AUTOAIM_10DEGREES); - - if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase()) - return; - - if (m_fInAttack != 0) - { -#ifndef CLIENT_DLL - //ALERT(at_console, "BRADNAILER_TILT_TO_UPRIGHT\n"); -#endif - - SendWeaponAnim(BRADNAILER_TILT_TO_UPRIGHT, UseDecrement()); - - m_fInAttack = 0; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5f; - m_flNextPrimaryAttack = m_flNextSecondaryAttack = GetNextAttackDelay(0.5f); - } - else - { - // only idle if the slid isn't back - if (m_iClip != 0) - { - int iAnim; - float flRand = UTIL_SharedRandomFloat(m_pPlayer->random_seed, 0.0, 1.0); - - if (flRand <= 0.3 + 0 * 0.75) - { - iAnim = BRADNAILER_IDLE3; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 49.0 / 16; - } - else if (flRand <= 0.6 + 0 * 0.875) - { - iAnim = BRADNAILER_IDLE1; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 60.0 / 16.0; - } - else - { - iAnim = BRADNAILER_IDLE2; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 40.0 / 16.0; - } - SendWeaponAnim(iAnim, 1); - } - } -} diff --git a/dlls/poke646/cmlwbr.cpp b/dlls/poke646/cmlwbr.cpp deleted file mode 100644 index 84cb4ec9..00000000 --- a/dlls/poke646/cmlwbr.cpp +++ /dev/null @@ -1,456 +0,0 @@ -/*** -* -* Copyright (c) 1996-2001, 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. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -#include "extdll.h" -#include "util.h" -#include "cbase.h" -#include "monsters.h" -#include "weapons.h" -#include "nodes.h" -#include "player.h" -#include "shake.h" -#include "gamerules.h" -#include "crossbow.h" - -extern int gmsgScope; - -enum cmlwbr_e { - CMLWBR_IDLE1 = 0, // drawn - CMLWBR_IDLE2, // undrawn - CMLWBR_FIDGET1, // drawn - CMLWBR_FIDGET2, // undrawn - CMLWBR_FIRE1, - CMLWBR_RELOAD, // drawn - CMLWBR_DRAWBACK, - CMLWBR_UNDRAW, - CMLWBR_DRAW1, // drawn - CMLWBR_DRAW2, // undrawn - CMLWBR_HOLSTER1, // drawn - CMLWBR_HOLSTER2, // undrawn -}; - -LINK_ENTITY_TO_CLASS(weapon_cmlwbr, CCmlwbr); - -void CCmlwbr::Spawn() -{ - Precache(); - m_iId = WEAPON_CMLWBR; - SET_MODEL(ENT(pev), "models/w_crossbow.mdl"); - - m_iDefaultAmmo = CMLWBR_DEFAULT_GIVE; - - SetDrawn( FALSE ); - - m_fInSpecialReload = 0; - - FallInit();// get ready to fall down. -} - -int CCmlwbr::AddToPlayer(CBasePlayer *pPlayer) -{ - if (CBasePlayerWeapon::AddToPlayer(pPlayer)) - { - MESSAGE_BEGIN(MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev); - WRITE_BYTE(m_iId); - MESSAGE_END(); - return TRUE; - } - return FALSE; -} - -void CCmlwbr::Precache(void) -{ - PRECACHE_MODEL("models/w_crossbow.mdl"); - PRECACHE_MODEL("models/v_cmlwbr.mdl"); - PRECACHE_MODEL("models/p_cmlwbr.mdl"); - - PRECACHE_SOUND("weapons/cmlwbr_drawback.wav"); - PRECACHE_SOUND("weapons/cmlwbr_fire.wav"); - PRECACHE_SOUND("weapons/cmlwbr_reload.wav"); - PRECACHE_SOUND("weapons/cmlwbr_undraw.wav"); - PRECACHE_SOUND("weapons/cmlwbr_zoom.wav"); - - PRECACHE_SOUND("weapons/xbow_fire1.wav"); - PRECACHE_SOUND("weapons/xbow_reload1.wav"); - - UTIL_PrecacheOther("crossbow_bolt"); - - m_usReload = PRECACHE_EVENT(1, "events/reload.sc"); - m_usCmlwbr = PRECACHE_EVENT(1, "events/cmlwbr.sc"); -} - - -int CCmlwbr::GetItemInfo(ItemInfo *p) -{ - p->pszName = STRING(pev->classname); - p->pszAmmo1 = "bolts"; - p->iMaxAmmo1 = BOLT_MAX_CARRY; - p->pszAmmo2 = NULL; - p->iMaxAmmo2 = -1; - p->iMaxClip = CMLWBR_MAX_CLIP; - p->iSlot = 3; - p->iPosition = 0; - p->iId = WEAPON_CMLWBR; - p->iFlags = 0; - p->iWeight = CMLWBR_WEIGHT; - return 1; -} - - -BOOL CCmlwbr::Deploy() -{ - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.6f; - - if (IsDrawn()) - return DefaultDeploy("models/v_cmlwbr.mdl", "models/p_cmlwbr.mdl", CMLWBR_DRAW1, "bow"); - - return DefaultDeploy("models/v_cmlwbr.mdl", "models/p_cmlwbr.mdl", CMLWBR_DRAW2, "bow"); -} - -void CCmlwbr::Holster(int skiplocal /* = 0 */) -{ - m_fInReload = FALSE;// cancel any reload in progress. - - if (m_fInZoom) - { - ZoomOut(); - } - - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; - - if (IsDrawn()) - SendWeaponAnim(CMLWBR_HOLSTER1); - else - SendWeaponAnim(CMLWBR_HOLSTER2); - - m_fInSpecialReload = 0; - - STOP_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cmlwbr_reload.wav"); - STOP_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cmlwbr_zoom.wav"); - STOP_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cmlwbr_drawback.wav"); - STOP_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cmlwbr_undraw.wav"); -} - -void CCmlwbr::PrimaryAttack(void) -{ - if (!IsDrawn() || (m_fInSpecialReload != 0)) - return; - - FireBolt(); -} - -void CCmlwbr::FireBolt() -{ -#ifndef CLIENT_DLL - //ALERT(at_console, "FireBolt\n"); -#endif - - TraceResult tr; - - if (m_iClip == 0) - { - PlayEmptySound(); - return; - } - - m_pPlayer->m_iWeaponVolume = QUIET_GUN_VOLUME; - - m_iClip--; - - int flags; -#if defined( CLIENT_WEAPONS ) - flags = FEV_NOTHOST; -#else - flags = 0; -#endif - - PLAYBACK_EVENT_FULL(0, m_pPlayer->edict(), m_usCmlwbr, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType], 0, 0); - - // player "shoot" animation - m_pPlayer->SetAnimation(PLAYER_ATTACK1); - - Vector anglesAim = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle; - UTIL_MakeVectors(anglesAim); - - anglesAim.x = -anglesAim.x; - Vector vecSrc = m_pPlayer->GetGunPosition() - gpGlobals->v_up * 2; - Vector vecDir = gpGlobals->v_forward; - -#ifndef CLIENT_DLL - CCrossbowBolt *pBolt = CCrossbowBolt::BoltCreate(); - pBolt->pev->origin = vecSrc; - pBolt->pev->angles = anglesAim; - pBolt->pev->owner = m_pPlayer->edict(); - - if (m_pPlayer->pev->waterlevel == 3) - { - pBolt->pev->velocity = vecDir * BOLT_WATER_VELOCITY; - pBolt->pev->speed = BOLT_WATER_VELOCITY; - } - else - { - pBolt->pev->velocity = vecDir * BOLT_AIR_VELOCITY; - pBolt->pev->speed = BOLT_AIR_VELOCITY; - } - pBolt->pev->avelocity.z = 10; -#endif - - m_flNextPrimaryAttack = m_flNextSecondaryAttack = GetNextAttackDelay(0.6f); - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5f; - - // Undraw. - SetDrawn(FALSE); -} - - -void CCmlwbr::SecondaryAttack() -{ - if (!IsDrawn() || (m_fInSpecialReload != 0)) - return; - - ToggleZoom(); - - pev->nextthink = UTIL_WeaponTimeBase() + 0.1; - // m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0; - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; -} - - -void CCmlwbr::Reload(void) -{ - if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == CMLWBR_MAX_CLIP) - return; - - // don't reload until recoil is done - if (m_flNextPrimaryAttack > UTIL_WeaponTimeBase()) - return; - -#ifndef CLIENT_DLL - //ALERT(at_console, "RELOAD\n"); -#endif - - if (m_pPlayer->pev->fov != 0) - { - ZoomOut(); - } - - if (m_fInAttack != 0) - { - m_fInSpecialReload = 1; - } - - if (m_fInSpecialReload == 0) - { - Undraw(); - - m_fInSpecialReload = 1; - } - else if (m_fInSpecialReload == 1) - { - if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase()) - return; - - DoReload(); - - m_fInSpecialReload = 0; - } -} - - -void CCmlwbr::WeaponIdle(void) -{ - m_pPlayer->GetAutoaimVector(AUTOAIM_2DEGREES); // get the autoaim vector but ignore it; used for autoaim crosshair in DM - - ResetEmptySound(); - - if (m_flTimeWeaponIdle < UTIL_WeaponTimeBase()) - { - if (m_iClip == 0 && m_fInSpecialReload == 0 && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]) - { - Reload(); - } - else - { - if (m_fInSpecialReload != 0 && m_iClip != CMLWBR_MAX_CLIP) - { - Reload(); - } - else if(!IsDrawn()) - { - DrawBack(); - } - else - { - int iAnim; - float flRand = UTIL_SharedRandomFloat(m_pPlayer->random_seed, 0, 1); - if (flRand <= 0.75) - { - if (m_iClip) - { - iAnim = CMLWBR_IDLE1; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 93.0 / 30.0; - } - else - { - iAnim = CMLWBR_IDLE2; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 93.0 / 30.0; - } - } - else - { - if (m_iClip) - { - iAnim = CMLWBR_FIDGET1; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 90.0 / 30.0; - } - else - { - iAnim = CMLWBR_FIDGET2; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 80.0 / 30.0; - } - } - SendWeaponAnim(iAnim, UseDecrement()); - } - } - } -} - -BOOL CCmlwbr::ShouldWeaponIdle(void) -{ - return (!IsDrawn() || m_fInSpecialReload != 0); -} - -BOOL CCmlwbr::IsDrawn(void) -{ - return (m_fInAttack == 0); -} - -void CCmlwbr::SetDrawn(BOOL bDrawn) -{ - m_fInAttack = (bDrawn) ? 0 : 1; -} - - -void CCmlwbr::ToggleZoom(void) -{ - if (m_pPlayer->pev->fov == 0) - { - ZoomIn(50); - } - else if (m_pPlayer->pev->fov == 50) - { - ZoomIn(25); - } - else - { - ZoomOut(); - } -} - -void CCmlwbr::ZoomIn(int iFOV) -{ - m_pPlayer->pev->fov = m_pPlayer->m_iFOV = iFOV; - - m_fInZoom = 1; - - EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cmlwbr_zoom.wav", VOL_NORM, ATTN_NORM); - -#ifndef CLIENT_DLL - MESSAGE_BEGIN(MSG_ONE, gmsgScope, NULL, m_pPlayer->pev); - WRITE_BYTE(1); - MESSAGE_END(); - - UTIL_ScreenFade(m_pPlayer, Vector(0, 0, 0), 0.1, 0.1, 255, FFADE_IN | FFADE_OUT); -#endif -} - -void CCmlwbr::ZoomOut(void) -{ - m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 0; - - m_fInZoom = 0; - - EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cmlwbr_zoom.wav", VOL_NORM, ATTN_NORM); - -#ifndef CLIENT_DLL - MESSAGE_BEGIN(MSG_ONE, gmsgScope, NULL, m_pPlayer->pev); - WRITE_BYTE(0); - MESSAGE_END(); -#endif -} - -void CCmlwbr::DoReload() -{ - if (DefaultReload(CMLWBR_MAX_CLIP, CMLWBR_RELOAD, 4.7)) // 4.7 - { - EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cmlwbr_reload.wav", RANDOM_FLOAT(0.95, 1.0), ATTN_NORM, 0, 93 + RANDOM_LONG(0, 0xF)); - } - - SetDrawn(FALSE); - - m_flNextPrimaryAttack = GetNextAttackDelay(6.0); - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 4.8; -} - -void CCmlwbr::DrawBack(void) -{ - SendWeaponAnim(CMLWBR_DRAWBACK); - - EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cmlwbr_drawback.wav", RANDOM_FLOAT(0.95, 1.0), ATTN_NORM, 0, 93 + RANDOM_LONG(0, 0xF)); - - SetDrawn(TRUE); - - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.3; - m_flNextPrimaryAttack = m_flNextSecondaryAttack = GetNextAttackDelay(1.3); -} - -void CCmlwbr::Undraw() -{ - SendWeaponAnim(CMLWBR_UNDRAW); - - EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cmlwbr_undraw.wav", RANDOM_FLOAT(0.95, 1.0), ATTN_NORM, 0, 93 + RANDOM_LONG(0, 0xF)); - - SetDrawn(FALSE); - - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.4; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.4; - m_flNextPrimaryAttack = GetNextAttackDelay(1.4); - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 7.4; -} - -class CCmlwbrAmmo : public CBasePlayerAmmo -{ - void Spawn(void) - { - Precache(); - SET_MODEL(ENT(pev), "models/w_crossbow_clip.mdl"); - CBasePlayerAmmo::Spawn(); - } - void Precache(void) - { - PRECACHE_MODEL("models/w_crossbow_clip.mdl"); - PRECACHE_SOUND("items/9mmclip1.wav"); - } - BOOL AddAmmo(CBaseEntity *pOther) - { - if (pOther->GiveAmmo(AMMO_CMLWBRCLIP_GIVE, "bolts", BOLT_MAX_CARRY) != -1) - { - EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM); - return TRUE; - } - return FALSE; - } -}; -LINK_ENTITY_TO_CLASS(ammo_bolts, CCmlwbrAmmo); diff --git a/dlls/poke646/firetrail.cpp b/dlls/poke646/firetrail.cpp index e274df11..b87d1848 100644 --- a/dlls/poke646/firetrail.cpp +++ b/dlls/poke646/firetrail.cpp @@ -23,23 +23,47 @@ // Fire Trail class CFireTrail : public CBaseEntity { +public: void Spawn(void); void Think(void); void Touch(CBaseEntity *pOther); int ObjectCaps(void) { return FCAP_DONT_SAVE; } + + int Save( CSave &save ); + int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; +private: + int m_spriteScale; // what's the exact fireball sprite scale? }; -LINK_ENTITY_TO_CLASS(fire_trail, CFireTrail); +LINK_ENTITY_TO_CLASS( fire_trail, CFireTrail ); -void CFireTrail::Spawn(void) +TYPEDESCRIPTION CFireTrail::m_SaveData[] = { - 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); - if (pev->velocity.z >= 0) + DEFINE_FIELD( CFireTrail, m_spriteScale, FIELD_INTEGER ), +}; + +IMPLEMENT_SAVERESTORE( CFireTrail, CBaseEntity ) + +void CFireTrail::Spawn( void ) +{ + pev->velocity = RANDOM_FLOAT(100.0f, 150.0f) * pev->angles; + if( RANDOM_LONG( 0, 1 ) ) + pev->velocity.x += RANDOM_FLOAT(-300.f, -100.f); + else + pev->velocity.x += RANDOM_FLOAT(100.f, 300.f); + + if( RANDOM_LONG( 0, 1 ) ) + pev->velocity.y += RANDOM_FLOAT(-300.f, -100.f); + else + pev->velocity.y += RANDOM_FLOAT(100.f, 300.f); + + if( pev->velocity.z >= 0 ) pev->velocity.z += 200; else pev->velocity.z -= 200; + + m_spriteScale = RANDOM_LONG( 7, 13 ); pev->movetype = MOVETYPE_BOUNCE; pev->gravity = 0.5; pev->nextthink = gpGlobals->time + 0.1; @@ -53,14 +77,18 @@ void CFireTrail::Spawn(void) pev->angles = g_vecZero; } - void CFireTrail::Think(void) { - CSprite* pSprite = CSprite::SpriteCreate("sprites/zerogxplode.spr", pev->origin, TRUE); - pSprite->AnimateAndDie(RANDOM_FLOAT(15.0f, 20.0f)); - pSprite->SetTransparency( kRenderTransAdd, 255, 255, 255, 192, kRenderFxNoDissipation ); - pSprite->SetScale(pev->speed); - pSprite->pev->frame = pSprite->Frames() - ((max(0, pev->speed - (0.1 * pSprite->pev->framerate)) * pSprite->Frames()) / pev->maxspeed); + MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin ); + WRITE_BYTE( TE_EXPLOSION); + WRITE_COORD( pev->origin.x ); + WRITE_COORD( pev->origin.y ); + WRITE_COORD( pev->origin.z ); + WRITE_SHORT( g_sModelIndexFireball ); + WRITE_BYTE( (BYTE)( m_spriteScale * pev->speed ) ); // scale * 10 + WRITE_BYTE( 15 ); // framerate + WRITE_BYTE( TE_EXPLFLAG_NOSOUND ); + MESSAGE_END(); pev->speed -= 0.1; if (pev->speed > 0) @@ -80,4 +108,4 @@ void CFireTrail::Touch(CBaseEntity *pOther) if ((pev->velocity.x*pev->velocity.x + pev->velocity.y*pev->velocity.y) < 10.0) pev->speed = 0; -} \ No newline at end of file +} diff --git a/dlls/poke646/genericmodel.cpp b/dlls/poke646/genericmodel.cpp index e737474d..30deef70 100644 --- a/dlls/poke646/genericmodel.cpp +++ b/dlls/poke646/genericmodel.cpp @@ -21,6 +21,8 @@ #include "weapons.h" #include "player.h" +#define SF_MODEL_ANIMATE 1 + class CGenericModel : public CBaseAnimating { public: @@ -29,8 +31,6 @@ public: void Precache(void); void KeyValue(KeyValueData* pkvd); - void EXPORT IdleThink(void); - virtual int Save(CSave &save); virtual int Restore(CRestore &restore); static TYPEDESCRIPTION m_SaveData[]; @@ -50,74 +50,34 @@ IMPLEMENT_SAVERESTORE(CGenericModel, CBaseAnimating); void CGenericModel::KeyValue(KeyValueData* pkvd) { // UNDONE_WC: explicitly ignoring these fields, but they shouldn't be in the map file! - if (FStrEq(pkvd->szKeyName, "sequencename")) + if( FStrEq( pkvd->szKeyName, "sequencename" ) ) { - m_iszSequence = ALLOC_STRING(pkvd->szValue); + m_iszSequence = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } else CBaseDelay::KeyValue(pkvd); } -void CGenericModel::Spawn(void) +void CGenericModel::Spawn() { Precache(); pev->solid = SOLID_NOT; pev->movetype = MOVETYPE_NONE; - pev->takedamage = DAMAGE_NO; SET_MODEL( ENT(pev), STRING(pev->model) ); - UTIL_SetSize( pev, Vector(0, 0, 0), Vector(0, 0, 0) ); + UTIL_SetSize( pev, g_vecZero, g_vecZero ); - if (!FStringNull(m_iszSequence)) + if( FBitSet( pev->spawnflags, SF_MODEL_ANIMATE ) ) { - pev->sequence = LookupSequence(STRING(m_iszSequence)); - - if (pev->sequence < 0) - { - ALERT(at_warning, "Generic model %s: Unknown sequence named: %s\n", STRING(pev->model), STRING(m_iszSequence)); - pev->sequence = 0; - } + pev->sequence = LookupSequence( STRING( m_iszSequence ) ); + pev->animtime = gpGlobals->time; + pev->framerate = 1.0f; } - else - { - pev->sequence = 0; - } - - pev->frame = 0; - pev->framerate = 1.0f; - - SetThink(&CGenericModel::IdleThink); - SetTouch(NULL); - SetUse(NULL); - - pev->nextthink = gpGlobals->time + 0.1; } -void CGenericModel::Precache(void) +void CGenericModel::Precache() { - PRECACHE_MODEL((char*)STRING(pev->model)); + PRECACHE_MODEL( STRING( pev->model ) ); } - -void CGenericModel::IdleThink(void) -{ - float flInterval = StudioFrameAdvance(); - - pev->nextthink = gpGlobals->time + 0.5; - - DispatchAnimEvents(flInterval); - - if (m_fSequenceFinished) - { - if (m_fSequenceLoops) - { - pev->frame = 0; - ResetSequenceInfo(); - } - else - { - SetThink( NULL ); - } - } -} \ No newline at end of file diff --git a/dlls/poke646/heaterpipe.cpp b/dlls/poke646/heaterpipe.cpp deleted file mode 100644 index ff2bce96..00000000 --- a/dlls/poke646/heaterpipe.cpp +++ /dev/null @@ -1,313 +0,0 @@ -/*** -* -* Copyright (c) 1996-2001, 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. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -#include "extdll.h" -#include "util.h" -#include "cbase.h" -#include "monsters.h" -#include "weapons.h" -#include "nodes.h" -#include "player.h" -#include "gamerules.h" - - -#define HEATERPIPE_BODYHIT_VOLUME 128 -#define HEATERPIPE_WALLHIT_VOLUME 512 - -#define HEATERPIPE_FIRE_RATE_MIN 0.5f -#define HEATERPIPE_FIRE_RATE_MAX 2.0f - -#define HEATERPIPE_FIRE_RATE_RATIO 0.75f - -void FindHullIntersection(const Vector &vecSrc, TraceResult &tr, float *mins, float *maxs, edict_t *pEntity); - -LINK_ENTITY_TO_CLASS(weapon_heaterpipe, CHeaterPipe); - - -enum heaterpipe_e { - HEATERPIPE_IDLE = 0, - HEATERPIPE_DRAW, - HEATERPIPE_HOLSTER, - HEATERPIPE_ATTACK1HIT, - HEATERPIPE_ATTACK1MISS, - HEATERPIPE_ATTACK2MISS, - HEATERPIPE_ATTACK2HIT, - HEATERPIPE_ATTACK3MISS, - HEATERPIPE_ATTACK3HIT, - HEATERPIPE_IDLE2, - HEATERPIPE_IDLE3, -}; - - -void CHeaterPipe::Spawn() -{ - Precache(); - m_iId = WEAPON_HEATERPIPE; - SET_MODEL(ENT(pev), "models/w_heaterpipe.mdl"); - m_iClip = -1; - - FallInit();// get ready to fall down. -} - - -void CHeaterPipe::Precache(void) -{ - PRECACHE_MODEL("models/v_heaterpipe.mdl"); - PRECACHE_MODEL("models/w_heaterpipe.mdl"); - PRECACHE_MODEL("models/p_heaterpipe.mdl"); - PRECACHE_SOUND("weapons/pipe_hit1.wav"); - PRECACHE_SOUND("weapons/pipe_hit2.wav"); - PRECACHE_SOUND("weapons/cbar_hitbod1.wav"); - PRECACHE_SOUND("weapons/cbar_hitbod2.wav"); - PRECACHE_SOUND("weapons/cbar_hitbod3.wav"); - PRECACHE_SOUND("weapons/pipe_miss.wav"); - - m_usHeaterPipe = PRECACHE_EVENT(1, "events/heaterpipe.sc"); -} - -int CHeaterPipe::GetItemInfo(ItemInfo *p) -{ - p->pszName = STRING(pev->classname); - p->pszAmmo1 = NULL; - p->iMaxAmmo1 = -1; - p->pszAmmo2 = NULL; - p->iMaxAmmo2 = -1; - p->iMaxClip = WEAPON_NOCLIP; - p->iSlot = 0; - p->iPosition = 1; - p->iId = WEAPON_HEATERPIPE; - p->iWeight = HEATERPIPE_WEIGHT; - return 1; -} - - - -BOOL CHeaterPipe::Deploy() -{ - return DefaultDeploy("models/v_heaterpipe.mdl", "models/p_heaterpipe.mdl", HEATERPIPE_DRAW, "heaterpipe"); -} - -void CHeaterPipe::Holster(int skiplocal /* = 0 */) -{ - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; - SendWeaponAnim(HEATERPIPE_HOLSTER); - - STOP_SOUND(ENT(pev), CHAN_ITEM, "player/breathe2.wav"); -} - -void CHeaterPipe::PrimaryAttack() -{ - if (!Swing(1)) - { - SetThink(&CHeaterPipe::SwingAgain); - pev->nextthink = gpGlobals->time + 0.1; - } -} - - -void CHeaterPipe::Smack() -{ - DecalGunshot(&m_trHit, BULLET_PLAYER_CROWBAR); -} - - -void CHeaterPipe::SwingAgain(void) -{ - Swing(0); -} - - -void CHeaterPipe::WeaponIdle(void) -{ - STOP_SOUND(ENT(pev), CHAN_ITEM, "player/breathe2.wav"); -} - -int CHeaterPipe::Swing(int fFirst) -{ - int fDidHit = FALSE; - - TraceResult tr; - - UTIL_MakeVectors(m_pPlayer->pev->v_angle); - Vector vecSrc = m_pPlayer->GetGunPosition(); - Vector vecEnd = vecSrc + gpGlobals->v_forward * 32; - - UTIL_TraceLine(vecSrc, vecEnd, dont_ignore_monsters, ENT(m_pPlayer->pev), &tr); - -#ifndef CLIENT_DLL - if (tr.flFraction >= 1.0) - { - UTIL_TraceHull(vecSrc, vecEnd, dont_ignore_monsters, head_hull, ENT(m_pPlayer->pev), &tr); - if (tr.flFraction < 1.0) - { - // Calculate the point of intersection of the line (or hull) and the object we hit - // This is and approximation of the "best" intersection - CBaseEntity *pHit = CBaseEntity::Instance(tr.pHit); - if (!pHit || pHit->IsBSPModel()) - FindHullIntersection(vecSrc, tr, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX, m_pPlayer->edict()); - vecEnd = tr.vecEndPos; // This is the point on the actual surface (the hull could have hit space) - } - } -#endif - - if (m_pPlayer->m_iExertLevel < PLAYER_EXERT_LEVEL_MAX) - { - m_pPlayer->m_iExertLevel++; - } - - if (m_pPlayer->m_iExertLevel > PLAYER_BREATHE_LEVEL) - { - EMIT_SOUND(ENT(pev), CHAN_ITEM, PLAYER_BREATHE_SOUND, PLAYER_BREATHE_VOLUME_MAX, ATTN_NORM); - } - - float flNextAttackTime = HEATERPIPE_FIRE_RATE_MIN; - - if (m_pPlayer->m_iExertLevel >= 4) - { - float flMinFireRate = HEATERPIPE_FIRE_RATE_MIN; - float flLongestFireRate = HEATERPIPE_FIRE_RATE_MAX - flMinFireRate; - flNextAttackTime = flNextAttackTime + (((m_pPlayer->m_iExertLevel - 4) * flLongestFireRate) / (PLAYER_EXERT_LEVEL_MAX - 4)); - } - - m_pPlayer->m_flExertUpdateStart = gpGlobals->time; - m_pPlayer->m_flExertRate = flNextAttackTime; - -#ifndef CLIENT_DLL - // ALERT(at_console, "HeaterPipe fire rate: %f\n", flNextAttackTime); -#endif - - - if (tr.flFraction >= 1.0) - { - PLAYBACK_EVENT_FULL(FEV_NOTHOST, m_pPlayer->edict(), m_usHeaterPipe, - 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, 0, - 0.0, 0, 0.0); - - if (fFirst) - { - // miss - m_flNextPrimaryAttack = GetNextAttackDelay(flNextAttackTime); - - // player "shoot" animation - m_pPlayer->SetAnimation(PLAYER_ATTACK1); - } - } - else - { - switch (((m_iSwing++) % 3)) - { - case 0: - SendWeaponAnim(HEATERPIPE_ATTACK1HIT, 0); break; - case 1: - SendWeaponAnim(HEATERPIPE_ATTACK2HIT, 0); break; - case 2: - SendWeaponAnim(HEATERPIPE_ATTACK3HIT, 0); break; - } - - // player "shoot" animation - m_pPlayer->SetAnimation(PLAYER_ATTACK1); - -#ifndef CLIENT_DLL - - // hit - fDidHit = TRUE; - CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit); - - ClearMultiDamage(); - - if ((m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase()) || g_pGameRules->IsMultiplayer()) - { - // first swing does full damage - pEntity->TraceAttack(m_pPlayer->pev, gSkillData.plrDmgCrowbar, gpGlobals->v_forward, &tr, DMG_CLUB); - } - else - { - // subsequent swings do half - pEntity->TraceAttack(m_pPlayer->pev, gSkillData.plrDmgCrowbar / 2, gpGlobals->v_forward, &tr, DMG_CLUB); - } - ApplyMultiDamage(m_pPlayer->pev, m_pPlayer->pev); - - // play thwack, smack, or dong sound - float flVol = 1.0; - int fHitWorld = TRUE; - - if (pEntity) - { - if (pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE) - { - // play thwack or smack sound - switch (RANDOM_LONG(0, 2)) - { - case 0: - EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_hitbod1.wav", 1, ATTN_NORM); break; - case 1: - EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_hitbod2.wav", 1, ATTN_NORM); break; - case 2: - EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_hitbod3.wav", 1, ATTN_NORM); break; - } - m_pPlayer->m_iWeaponVolume = HEATERPIPE_BODYHIT_VOLUME; - if (!pEntity->IsAlive()) - return TRUE; - else - flVol = 0.1; - - fHitWorld = FALSE; - } - } - - // play texture hit sound - // UNDONE: Calculate the correct point of intersection when we hit with the hull instead of the line - - if (fHitWorld) - { - float fvolbar = TEXTURETYPE_PlaySound(&tr, vecSrc, vecSrc + (vecEnd - vecSrc) * 2, 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; - } - - // also play crowbar strike - switch (RANDOM_LONG(0, 1)) - { - case 0: - EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/pipe_hit1.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG(0, 3)); - break; - case 1: - EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/pipe_hit2.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG(0, 3)); - break; - } - - // delay the decal a bit - m_trHit = tr; - } - - m_pPlayer->m_iWeaponVolume = flVol * HEATERPIPE_WALLHIT_VOLUME; -#endif - m_flNextPrimaryAttack = GetNextAttackDelay(flNextAttackTime * HEATERPIPE_FIRE_RATE_RATIO); - - SetThink(&CHeaterPipe::Smack); - pev->nextthink = UTIL_WeaponTimeBase() + 0.2; - - - } - return fDidHit; -} - - - diff --git a/dlls/poke646/mp3.cpp b/dlls/poke646/mp3.cpp new file mode 100644 index 00000000..9806ff5f --- /dev/null +++ b/dlls/poke646/mp3.cpp @@ -0,0 +1,98 @@ +/*** +* +* Copyright (c) 1996-2001, 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. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ + +#include "extdll.h" +#include "util.h" +#include "cbase.h" +#include "player.h" +#include "gamerules.h" +#include "mp3.h" + +extern int gmsgPlayMP3; +#define SF_AMBIENTMP3_LOOP 1 + +LINK_ENTITY_TO_CLASS( ambient_mp3, CAmbientMP3 ) + +CAmbientMP3 *CAmbientMP3::AmbientMP3Create( const char *pszSound ) +{ + // Create a new entity with CCrossbowBolt private data + CAmbientMP3 *pMPlayer = GetClassPtr( (CAmbientMP3 *)NULL ); + pMPlayer->pev->classname = MAKE_STRING( "ambient_mp3" ); + pMPlayer->pev->message = MAKE_STRING( pszSound ); + pMPlayer->Spawn(); + + return pMPlayer; +} + +void CAmbientMP3::Spawn( void ) +{ + if( pev->message && strlen( STRING( pev->message ) ) >= 1 ) + { + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_NONE; + SetUse( &CAmbientMP3::ToggleUse ); + } + else + { + ALERT( at_console, "ambient_mp3 without soundfile at: %f, %f, %f, removing self...\n", pev->origin.x, pev->origin.y, pev->origin.z ); + UTIL_Remove( this ); + } +} + +void CAmbientMP3::ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +{ + edict_t *pClient; + const char *pszSound; + int i; + BOOL loop; + + loop = pev->spawnflags & SF_AMBIENTMP3_LOOP; + pszSound = STRING( pev->message ); + + if( FStrEq( pszSound, "#po_soundtrack#" ) ) + { + pszSound = 0; + + for( i = 0; i < g_soundtrackCount; i++ ) + { + if( FStrEq( g_soundtracklist[i].mapname, STRING( gpGlobals->mapname ) ) ) + { + pszSound = g_soundtracklist[i].soundfile; + loop = g_soundtracklist[i].loop; + break; + } + } + } + + if( !pszSound ) + { + UTIL_Remove( this ); + return; + } + + // manually find the single player. + pClient = g_engfuncs.pfnPEntityOfEntIndex( 1 ); + + if( pClient ) + { + MESSAGE_BEGIN( MSG_ONE, gmsgPlayMP3, NULL, pClient ); + WRITE_STRING( pszSound ); + WRITE_BYTE( loop ); + MESSAGE_END(); + } + + UTIL_Remove( this ); +} + diff --git a/dlls/poke646/mp3.h b/dlls/poke646/mp3.h new file mode 100644 index 00000000..df2aec0b --- /dev/null +++ b/dlls/poke646/mp3.h @@ -0,0 +1,7 @@ +class CAmbientMP3 : public CPointEntity +{ +public: + static CAmbientMP3 *AmbientMP3Create( const char *pszSound ); + void Spawn( void ); + void EXPORT ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); +}; diff --git a/dlls/poke646/nail.cpp b/dlls/poke646/nail.cpp index c134bbbd..6be1dc54 100644 --- a/dlls/poke646/nail.cpp +++ b/dlls/poke646/nail.cpp @@ -25,109 +25,116 @@ #include "nail.h" -LINK_ENTITY_TO_CLASS(nail, CNail); +LINK_ENTITY_TO_CLASS( nailgun_nail, CNailGunNail ) -CNail *CNail::NailCreate(void) +CNailGunNail *CNailGunNail::NailCreate( BOOL bIsBradnailer ) { // Create a new entity with CCrossbowBolt private data - CNail *pBolt = GetClassPtr((CNail *)NULL); - pBolt->pev->classname = MAKE_STRING("nail"); - pBolt->Spawn(); - - return pBolt; + CNailGunNail *pNail = GetClassPtr((CNailGunNail *)NULL); + pNail->pev->classname = MAKE_STRING("nailgun_nail"); + pNail->m_bIsBradnailer = bIsBradnailer; + pNail->Spawn(); + + return pNail; } -void CNail::Spawn() +void CNailGunNail::Spawn() { Precache(); pev->movetype = MOVETYPE_FLY; pev->solid = SOLID_BBOX; - pev->gravity = 0.0; + pev->gravity = 0.5; SET_MODEL(ENT(pev), "models/nail.mdl"); UTIL_SetOrigin(pev, pev->origin); - UTIL_SetSize(pev, Vector(0, 0, 0), Vector(0, 0, 0)); + UTIL_SetSize(pev, g_vecZero, g_vecZero); - SetTouch(&CNail::NailTouch); - SetThink(&CNail::NailThink); + SetTouch(&CNailGunNail::NailTouch); + SetThink(&CNailGunNail::BubbleThink); pev->nextthink = gpGlobals->time + 0.2; } -void CNail::Precache() +void CNailGunNail::Precache() { PRECACHE_MODEL("models/nail.mdl"); PRECACHE_SOUND("weapons/brad_hit1.wav"); PRECACHE_SOUND("weapons/brad_hit2.wav"); } -int CNail::Classify(void) +int CNailGunNail::Classify() { return CLASS_NONE; } -void CNail::NailTouch(CBaseEntity *pOther) +void CNailGunNail::NailTouch( CBaseEntity *pOther ) { - SetTouch(NULL); - SetThink(NULL); + SetTouch( NULL ); + SetThink( NULL ); - if (pOther->pev->takedamage) + if( pOther->pev->takedamage ) { TraceResult tr = UTIL_GetGlobalTrace(); - entvars_t *pevOwner; - - pevOwner = VARS(pev->owner); + entvars_t *pevOwner = VARS( pev->owner ); // UNDONE: this needs to call TraceAttack instead ClearMultiDamage(); - pOther->TraceAttack(pevOwner, gSkillData.plrDmgNail, pev->velocity.Normalize(), &tr, DMG_NEVERGIB); + pOther->TraceAttack( pevOwner, m_bIsBradnailer ? gSkillData.plrDmg9MM : gSkillData.plrDmgMP5, pev->velocity.Normalize(), &tr, DMG_NEVERGIB ); - ApplyMultiDamage(pev, pevOwner); + ApplyMultiDamage( pev, pevOwner ); - pev->velocity = Vector(0, 0, 0); + pev->velocity = g_vecZero; // play body "thwack" sound - switch (RANDOM_LONG(0, 1)) + switch( RANDOM_LONG( 0, 1 ) ) { case 0: - EMIT_SOUND(ENT(pev), CHAN_BODY, "weapons/brad_hit1.wav", 1, ATTN_NORM); break; + EMIT_SOUND( ENT( pev ), CHAN_BODY, "weapons/brad_hit1.wav", 1, ATTN_NORM ); + break; case 1: - EMIT_SOUND(ENT(pev), CHAN_BODY, "weapons/brad_hit2.wav", 1, ATTN_NORM); break; + if( m_bIsBradnailer ) + EMIT_SOUND( ENT( pev ), CHAN_BODY, "weapons/brad_hit2.wav", 1, ATTN_NORM ); + break; } - Killed(pev, GIB_NEVER); + Killed( pev, GIB_NEVER ); } else { - EMIT_SOUND_DYN(ENT(pev), CHAN_BODY, "weapons/brad_hit1.wav", RANDOM_FLOAT(0.95, 1.0), ATTN_NORM, 0, 98 + RANDOM_LONG(0, 7)); + // EMIT_SOUND_DYN(ENT(pev), CHAN_BODY, "weapons/brad_hit1.wav", RANDOM_FLOAT(0.95, 1.0), ATTN_NORM, 0, 98 + RANDOM_LONG(0, 7)); - SetThink(&CNail::SUB_Remove); + SetThink( &CBaseEntity::SUB_Remove ); pev->nextthink = gpGlobals->time;// this will get changed below if the bolt is allowed to stick in what it hit. - if (FClassnameIs(pOther->pev, "worldspawn")) + if( FClassnameIs( pOther->pev, "worldspawn" ) ) { // 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); - pev->angles = UTIL_VecToAngles(vecDir); + UTIL_SetOrigin( pev, pev->origin - vecDir * RANDOM_LONG( 6, 10 ) ); + pev->angles = UTIL_VecToAngles( vecDir ); pev->solid = SOLID_NOT; pev->movetype = MOVETYPE_FLY; - pev->velocity = Vector(0, 0, 0); + pev->velocity = g_vecZero; pev->avelocity.z = 0; - pev->angles.z = RANDOM_LONG(0, 360); - pev->nextthink = gpGlobals->time + 10.0; + pev->angles.z = RANDOM_LONG( 0, 360 ); + pev->nextthink = gpGlobals->time + 2.0; } - /*if (UTIL_PointContents(pev->origin) != CONTENTS_WATER) + if( UTIL_PointContents( pev->origin ) != CONTENTS_WATER && RANDOM_LONG( 0, 4 ) == 4 ) { - UTIL_Sparks(pev->origin); - }*/ + UTIL_Sparks( pev->origin ); + } } } -void CNail::NailThink(void) +void CNailGunNail::BubbleThink() { pev->nextthink = gpGlobals->time + 0.1; -} \ No newline at end of file + + if( pev->waterlevel == 0 ) + return; + + UTIL_BubbleTrail( pev->origin - pev->velocity * 0.1, pev->origin, 1 ); +} diff --git a/dlls/poke646/nail.h b/dlls/poke646/nail.h index 0a30cbec..23c30631 100644 --- a/dlls/poke646/nail.h +++ b/dlls/poke646/nail.h @@ -22,16 +22,18 @@ //========================================================= // Nail projectile //========================================================= -class CNail : public CBaseEntity +class CNailGunNail : public CBaseEntity { - void Spawn(void); - void Precache(void); - int Classify(void); - void EXPORT NailThink(void); - void EXPORT NailTouch(CBaseEntity *pOther); - public: - static CNail *NailCreate(void); + void Spawn(); + void Precache(); + int Classify(); + void EXPORT NailTouch( CBaseEntity *pOther ); + void EXPORT BubbleThink(); + static CNailGunNail *NailCreate( BOOL bIsBradnailer ); + +private: + BOOL m_bIsBradnailer; }; -#endif // NAIL_H \ No newline at end of file +#endif // NAIL_H diff --git a/dlls/poke646/nailgun.cpp b/dlls/poke646/nailgun.cpp deleted file mode 100644 index bb49587a..00000000 --- a/dlls/poke646/nailgun.cpp +++ /dev/null @@ -1,290 +0,0 @@ -/*** -* -* Copyright (c) 1996-2001, 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. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -#include "extdll.h" -#include "util.h" -#include "cbase.h" -#include "monsters.h" -#include "weapons.h" -#include "nodes.h" -#include "player.h" -#include "soundent.h" -#include "gamerules.h" -#include "nail.h" - -enum nailgun_e -{ - NAILGUN_LONGIDLE = 0, - NAILGUN_IDLE1, - NAILGUN_LAUNCH, - NAILGUN_RELOAD, - NAILGUN_DEPLOY, - NAILGUN_FIRE1, - NAILGUN_FIRE2, - NAILGUN_FIRE3, - NAILGUN_DEPLOY_EMPTY, - NAILGUN_LONGIDLE_EMPTY, - NAILGUN_IDLE1_EMPTY, -}; - - -LINK_ENTITY_TO_CLASS(weapon_nailgun, CNailgun); - -void CNailgun::Spawn() -{ - Precache(); - SET_MODEL(ENT(pev), "models/w_nailgun.mdl"); - m_iId = WEAPON_NAILGUN; - - m_iDefaultAmmo = NAILGUN_DEFAULT_GIVE; - - FallInit();// get ready to fall down. -} - - -void CNailgun::Precache(void) -{ - PRECACHE_MODEL("models/v_nailgun.mdl"); - PRECACHE_MODEL("models/w_nailgun.mdl"); - PRECACHE_MODEL("models/p_nailgun.mdl"); - - m_iShell = PRECACHE_MODEL("models/shell.mdl");// brass shellTE_MODEL - - PRECACHE_MODEL("models/w_nailclip.mdl"); - PRECACHE_MODEL("models/w_nailround.mdl"); - PRECACHE_SOUND("items/9mmclip1.wav"); - - PRECACHE_SOUND("items/clipinsert1.wav"); - PRECACHE_SOUND("items/cliprelease1.wav"); - - PRECACHE_SOUND("weapons/nailgun.wav"); - - PRECACHE_SOUND("weapons/357_cock1.wav"); - - m_usNailgun = PRECACHE_EVENT(1, "events/nailgun.sc"); - m_usReload = PRECACHE_EVENT(1, "events/reload.sc"); - - UTIL_PrecacheOther( "nail" ); -} - -int CNailgun::GetItemInfo(ItemInfo *p) -{ - p->pszName = STRING(pev->classname); - p->pszAmmo1 = "nails"; - p->iMaxAmmo1 = NAILS_MAX_CARRY; - p->pszAmmo2 = NULL; - p->iMaxAmmo2 = -1; - p->iMaxClip = NAILGUN_MAX_CLIP; - p->iSlot = 1; - p->iPosition = 1; - p->iFlags = 1; - p->iId = m_iId = WEAPON_NAILGUN; - p->iWeight = NAILGUN_WEIGHT; - - return 1; -} - -int CNailgun::AddToPlayer(CBasePlayer *pPlayer) -{ - if (CBasePlayerWeapon::AddToPlayer(pPlayer)) - { - MESSAGE_BEGIN(MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev); - WRITE_BYTE(m_iId); - MESSAGE_END(); - return TRUE; - } - return FALSE; -} - -BOOL CNailgun::Deploy() -{ - int iAnim; - if (m_iClip == 0) - iAnim = NAILGUN_DEPLOY_EMPTY; - else - iAnim = NAILGUN_DEPLOY; - - return DefaultDeploy("models/v_nailgun.mdl", "models/p_nailgun.mdl", iAnim, "nailgun"); -} - - -void CNailgun::PrimaryAttack() -{ - // don't fire underwater - if (m_pPlayer->pev->waterlevel == 3) - { - PlayEmptySound(); - m_flNextPrimaryAttack = 0.15; - return; - } - - if (m_iClip <= 0) - { - PlayEmptySound(); - m_flNextPrimaryAttack = 0.15; - return; - } - - m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME; - m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH; - - m_iClip--; - - - m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH; - - // player "shoot" animation - m_pPlayer->SetAnimation(PLAYER_ATTACK1); - - Vector anglesAim = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle; - UTIL_MakeVectors(anglesAim); - - anglesAim.x = -anglesAim.x; - Vector vecSrc = m_pPlayer->GetGunPosition() + gpGlobals->v_forward * 8 + gpGlobals->v_right * 4 + gpGlobals->v_up * -4; - Vector vecAiming = gpGlobals->v_forward; - - Vector vecDir; - vecDir = m_pPlayer->FireBulletsPlayer(1, vecSrc, vecAiming, VECTOR_CONE_3DEGREES, 8192, BULLET_PLAYER_NAIL, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed); - - int flags; -#if defined( CLIENT_WEAPONS ) - flags = FEV_NOTHOST; -#else - flags = 0; -#endif - - PLAYBACK_EVENT_FULL(flags, m_pPlayer->edict(), m_usNailgun, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, 0, 0); - -#ifndef CLIENT_DLL - CNail *pNail = CNail::NailCreate(); - pNail->pev->origin = vecSrc; - pNail->pev->angles = anglesAim; - pNail->pev->owner = m_pPlayer->edict(); - - if (m_pPlayer->pev->waterlevel == 3) - { - pNail->pev->velocity = vecAiming * NAIL_WATER_VELOCITY; - pNail->pev->speed = NAIL_WATER_VELOCITY; - } - else - { - pNail->pev->velocity = vecAiming * NAIL_AIR_VELOCITY; - pNail->pev->speed = NAIL_AIR_VELOCITY; - } - pNail->pev->avelocity.z = 10; -#endif - - m_flNextPrimaryAttack = GetNextAttackDelay(0.1); - - if (m_flNextPrimaryAttack < UTIL_WeaponTimeBase()) - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.1; - - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat(m_pPlayer->random_seed, 10, 15); -} - -void CNailgun::Reload(void) -{ - if (m_pPlayer->ammo_nails <= 0) - return; - - int iAnim = NAILGUN_RELOAD; - int iResult = DefaultReload(NAILGUN_MAX_CLIP, iAnim, 1.6); - - if (iResult) - { - PLAYBACK_EVENT_FULL(0, m_pPlayer->edict(), m_usReload, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, iAnim, 0, 0, 0); - } -} - - -void CNailgun::WeaponIdle(void) -{ - ResetEmptySound(); - - m_pPlayer->GetAutoaimVector(AUTOAIM_5DEGREES); - - if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase()) - return; - - int iAnim; - switch (RANDOM_LONG(0, 1)) - { - case 0: - iAnim = (m_iClip == 0) ? NAILGUN_LONGIDLE_EMPTY : NAILGUN_LONGIDLE; - break; - - default: - case 1: - iAnim = (m_iClip == 0) ? NAILGUN_IDLE1_EMPTY : NAILGUN_IDLE1; - break; - } - - SendWeaponAnim(iAnim); - - m_flTimeWeaponIdle = UTIL_SharedRandomFloat(m_pPlayer->random_seed, 10, 15); // how long till we do this again. -} - - - -class CNailAmmoClip : public CBasePlayerAmmo -{ - void Spawn(void) - { - Precache(); - SET_MODEL(ENT(pev), "models/w_nailclip.mdl"); - CBasePlayerAmmo::Spawn(); - } - void Precache(void) - { - PRECACHE_MODEL("models/w_nailclip.mdl"); - PRECACHE_SOUND("items/9mmclip1.wav"); - } - BOOL AddAmmo(CBaseEntity *pOther) - { - int bResult = (pOther->GiveAmmo(AMMO_NAILCLIP_GIVE, "nails", NAILS_MAX_CARRY) != -1); - if (bResult) - { - EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM); - } - return bResult; - } -}; -LINK_ENTITY_TO_CLASS(ammo_nailclip, CNailAmmoClip); - - -class CNailAmmoRound : public CBasePlayerAmmo -{ - void Spawn(void) - { - Precache(); - SET_MODEL(ENT(pev), "models/w_nailround.mdl"); - CBasePlayerAmmo::Spawn(); - } - void Precache(void) - { - PRECACHE_MODEL("models/w_nailround.mdl"); - PRECACHE_SOUND("items/9mmclip1.wav"); - } - BOOL AddAmmo(CBaseEntity *pOther) - { - int bResult = (pOther->GiveAmmo(AMMO_NAILROUND_GIVE, "nails", NAILS_MAX_CARRY) != -1); - if (bResult) - { - EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM); - } - return bResult; - } -}; -LINK_ENTITY_TO_CLASS(ammo_nailround, CNailAmmoRound); \ No newline at end of file diff --git a/dlls/poke646/pipebomb.cpp b/dlls/poke646/pipebomb.cpp deleted file mode 100644 index 2a723ff4..00000000 --- a/dlls/poke646/pipebomb.cpp +++ /dev/null @@ -1,227 +0,0 @@ -/*** -* -* Copyright (c) 1996-2001, 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. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -#include "extdll.h" -#include "util.h" -#include "cbase.h" -#include "monsters.h" -#include "weapons.h" -#include "nodes.h" -#include "player.h" -#include "gamerules.h" -#include "pipebomb.h" - -LINK_ENTITY_TO_CLASS(monster_pipebomb, CPipeBombGrenade); - - -TYPEDESCRIPTION CPipeBombGrenade::m_SaveData[] = -{ - DEFINE_FIELD(CPipeBombGrenade, m_hOwner, FIELD_EHANDLE), - DEFINE_FIELD(CPipeBombGrenade, m_thrownByPlayer, FIELD_INTEGER), -}; - -IMPLEMENT_SAVERESTORE(CPipeBombGrenade, CGrenade); - -//========================================================= -// Deactivate - do whatever it is we do to an orphaned -// satchel when we don't want it in the world anymore. -//========================================================= -void CPipeBombGrenade::Deactivate(void) -{ - pev->solid = SOLID_NOT; - UTIL_Remove(this); -} - - -void CPipeBombGrenade::Spawn(void) -{ - Precache(); - // motor - pev->movetype = MOVETYPE_BOUNCE; - pev->solid = SOLID_BBOX; - - SET_MODEL(ENT(pev), "models/w_pipebomb.mdl"); - //UTIL_SetSize(pev, Vector( -16, -16, -4), Vector(16, 16, 32)); // Old box -- size of headcrab monsters/players get blocked by this - UTIL_SetSize(pev, Vector(-4, -4, -4), Vector(4, 4, 4)); // Uses point-sized, and can be stepped over - UTIL_SetOrigin(pev, pev->origin); - - SetTouch(&CPipeBombGrenade::BombSlide); - SetUse(&CPipeBombGrenade::DetonateUse); - SetThink(&CPipeBombGrenade::BombThink); - pev->nextthink = gpGlobals->time + 0.1; - - pev->gravity = 0.5; - pev->friction = 0.8; - - pev->dmg = gSkillData.plrDmgSatchel; - // ResetSequenceInfo( ); - pev->sequence = 1; -} - - -void CPipeBombGrenade::BombSlide(CBaseEntity *pOther) -{ - entvars_t *pevOther = pOther->pev; - - // don't hit the guy that launched this grenade - if (pOther->edict() == pev->owner) - return; - - // pev->avelocity = Vector (300, 300, 300); - pev->gravity = 1;// normal gravity now - - // HACKHACK - On ground isn't always set, so look for ground underneath - TraceResult tr; - UTIL_TraceLine(pev->origin, pev->origin - Vector(0, 0, 10), ignore_monsters, edict(), &tr); - - if (tr.flFraction < 1.0) - { - // 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) - { - BounceSound(); - } - StudioFrameAdvance(); -} - - -void CPipeBombGrenade::BombThink(void) -{ - StudioFrameAdvance(); - pev->nextthink = gpGlobals->time + 0.1; - - if (!IsInWorld()) - { - UTIL_Remove(this); - return; - } - - if (pev->waterlevel == 3) - { - pev->movetype = MOVETYPE_FLY; - pev->velocity = pev->velocity * 0.8; - pev->avelocity = pev->avelocity * 0.9; - pev->velocity.z += 8; - } - else if (pev->waterlevel == 0) - { - pev->movetype = MOVETYPE_BOUNCE; - } - else - { - pev->velocity.z -= 8; - } - if ((pev->flags & FL_ONGROUND) && pev->velocity.Length() <= 1) - { - if (pev->owner != NULL) - { - m_hOwner = CBaseEntity::Instance(pev->owner); - pev->owner = NULL; - } - - SetThink(NULL); - SetTouch(&CPipeBombGrenade::PickupTouch); - } -} - -void CPipeBombGrenade::Precache(void) -{ - PRECACHE_MODEL("models/w_pipebomb.mdl"); - PRECACHE_SOUND("weapons/pb_bounce1.wav"); - PRECACHE_SOUND("weapons/pb_bounce2.wav"); - PRECACHE_SOUND("weapons/pb_bounce3.wav"); -} - -void CPipeBombGrenade::BounceSound(void) -{ - switch (RANDOM_LONG(0, 2)) - { - case 0: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/pb_bounce1.wav", 1, ATTN_NORM); break; - case 1: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/pb_bounce2.wav", 1, ATTN_NORM); break; - case 2: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/pb_bounce3.wav", 1, ATTN_NORM); break; - } -} - -void CPipeBombGrenade::PickupTouch(CBaseEntity* pOther) -{ - if (pOther != m_hOwner || !pOther->IsPlayer()) - return; - - CBasePlayer* pPlayer = (CBasePlayer*)pOther; - - - CPipeBomb *pSatchel = (CPipeBomb*)Create("weapon_pipebomb", pPlayer->pev->origin, pPlayer->pev->angles); - if (pSatchel) - { - BOOL found = FALSE; - CBasePlayerItem* pItem = NULL; - for (int i = 0; i < MAX_ITEM_TYPES && !found; i++) - { - pItem = pPlayer->m_rgpPlayerItems[i]; - - while (pItem) - { - if (pItem->m_iId == WEAPON_PIPEBOMB) - { - ((CPipeBomb*)pItem)->m_chargeReady = 2; - ((CPipeBomb*)pItem)->WeaponIdle(); - found = TRUE; - break; - } - - pItem = pItem->m_pNext; - } - } - } - - SetThink(&CPipeBombGrenade::SUB_Remove); - SetTouch(NULL); - pev->nextthink = gpGlobals->time; - - //ALERT(at_console, "Pickup touch.\n"); -} - -//========================================================= -// DeactivateSatchels - removes all satchels owned by -// the provided player. Should only be used upon death. -// -// Made this global on purpose. -//========================================================= -void DeactivatePipebombs(CBasePlayer *pOwner) -{ - edict_t *pFind; - - pFind = FIND_ENTITY_BY_CLASSNAME(NULL, "monster_pipebomb"); - - while (!FNullEnt(pFind)) - { - CBaseEntity *pEnt = CBaseEntity::Instance(pFind); - CPipeBombGrenade *pPipebomb = (CPipeBombGrenade *)pEnt; - - if (pPipebomb) - { - if (pPipebomb->pev->owner == pOwner->edict()) - { - pPipebomb->Deactivate(); - } - } - - pFind = FIND_ENTITY_BY_CLASSNAME(pFind, "monster_pipebomb"); - } -} \ No newline at end of file diff --git a/dlls/poke646/robocop.cpp b/dlls/poke646/robocop.cpp index 8c9d0fd7..3a495442 100644 --- a/dlls/poke646/robocop.cpp +++ b/dlls/poke646/robocop.cpp @@ -25,10 +25,9 @@ #include "explode.h" #define ROBOCOP_EYE_SPRITE_NAME "sprites/gargeye1.spr" -#define ROBOCOP_EYE_BEAM_NAME "sprites/laserbeam.spr" -#define ROBOCOP_EYE_SPOT_NAME "sprites/glow02.spr" +#define ROBOCOP_EYE_BEAM_NAME "sprites/smoke.spr" +#define ROBOCOP_EYE_SPOT_NAME "sprites/gargeye1.spr" -#define ROBOCOP_MAX_SHOCKWAVE_RADIUS 384 #define ROBOCOP_MAX_MORTAR_RADIUS 256 #define ROBOCOP_MORTAR_CHARGE_TIME 2.0f @@ -40,8 +39,13 @@ #define ROBOCOP_RANGE_ATTACK_DIST 512 #define ROBOCOP_MAX_CHASE_DIST 1024 -#define ROBOCOP_DEATH_DURATION 10.0f +#define ROBOCOP_DEATH_DURATION 2.1f +#define ROBOCOP_GIB_MODEL "models/metalplategibs.mdl" +// Robocop is immune to any damage but this +#define ROBOCOP_DAMAGE (DMG_ENERGYBEAM|DMG_CRUSH|DMG_MORTAR|DMG_BLAST) + +void SpawnExplosion( Vector center, float randomRange, float time, int magnitude ); // AI Nodes for RoboCop class CInfoRCNode : public CPointEntity @@ -197,7 +201,10 @@ public: void ScheduleChange(void); BOOL ShouldGibMonster(int iGib) { return FALSE; } void Killed(entvars_t *pevAttacker, int iGib); + void UpdateOnRemove(); + void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ); + int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); Schedule_t *GetSchedule(void); Schedule_t *GetScheduleOfType(int Type); void StartTask(Task_t *pTask); @@ -241,7 +248,7 @@ public: void SetupNodes(float flRadius); int m_iSpriteTexture; - + int m_iRobocopGibModel; CSprite* m_pEyeGlow; // Glow around the eyes int m_eyeBrightness; // Brightness target @@ -263,8 +270,6 @@ public: int m_lastsector; float m_flNextSparkTime; - - static const char* pSparkSounds[]; }; void CreateRoboCopNodes(CRoboCop* pOwner); @@ -296,16 +301,6 @@ TYPEDESCRIPTION CRoboCop::m_SaveData[] = IMPLEMENT_SAVERESTORE(CRoboCop, CBaseMonster); -const char* CRoboCop::pSparkSounds[] = -{ - "buttons/spark1.wav", - "buttons/spark2.wav", - "buttons/spark3.wav", - "buttons/spark4.wav", - "buttons/spark5.wav", - "buttons/spark6.wav", -}; - //========================================================= // AI Schedules Specific to this monster //========================================================= @@ -399,13 +394,16 @@ void CRoboCop::SetYawSpeed(void) { int ys; - ys = 120; - -#if 0 - switch (m_Activity) + switch( m_Activity ) { + case ACT_TURN_LEFT: + case ACT_TURN_RIGHT: + ys = 180; + break; + default: + ys = 90; + break; } -#endif pev->yaw_speed = ys; } @@ -420,11 +418,8 @@ void CRoboCop::HandleAnimEvent(MonsterEvent_t *pEvent) { case ROBOCOP_AE_RIGHT_FOOT: case ROBOCOP_AE_LEFT_FOOT: - switch (RANDOM_LONG(0, 1)) - { - case 0: EMIT_SOUND_DYN(ENT(pev), CHAN_BODY, "robocop/rc_step1.wav", 1, ATTN_NORM, 0, 70); break; - case 1: EMIT_SOUND_DYN(ENT(pev), CHAN_BODY, "robocop/rc_step2.wav", 1, ATTN_NORM, 0, 70); break; - } + UTIL_ScreenShake( pev->origin, 4.0, 3.0, 1.0, 250.0 ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_BODY, RANDOM_LONG( 0, 1 ) ? "robocop/rc_step2.wav" : "robocop/rc_step1.wav", 1, ATTN_NORM, 0, PITCH_NORM + RANDOM_LONG( -10, 10 ) ); break; case ROBOCOP_AE_FIST: @@ -490,14 +485,16 @@ void CRoboCop::Precache() PRECACHE_SOUND("robocop/rc_laser.wav"); PRECACHE_SOUND("robocop/rc_step1.wav"); PRECACHE_SOUND("robocop/rc_step2.wav"); - - PRECACHE_SOUND_ARRAY(pSparkSounds); + PRECACHE_SOUND("ambience/sparks.wav"); PRECACHE_MODEL(ROBOCOP_EYE_SPRITE_NAME); PRECACHE_MODEL(ROBOCOP_EYE_BEAM_NAME); - PRECACHE_MODEL(ROBOCOP_EYE_SPOT_NAME); + // PRECACHE_MODEL(ROBOCOP_EYE_SPOT_NAME); - m_iSpriteTexture = PRECACHE_MODEL("sprites/shockwave.spr"); + m_iSpriteTexture = PRECACHE_MODEL("sprites/xbeam3.spr"); + m_iRobocopGibModel = PRECACHE_MODEL( ROBOCOP_GIB_MODEL ); + + UTIL_PrecacheOther( "monster_mortar" ); } //========================================================= @@ -513,6 +510,37 @@ void CRoboCop::MonsterThink(void) m_flGroundSpeed = 200; } +void CRoboCop::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ) +{ + bitsDamageType &= ROBOCOP_DAMAGE; + + if( IsAlive() && !FBitSet( bitsDamageType, ROBOCOP_DAMAGE ) ) + { + if( pev->dmgtime != gpGlobals->time || (RANDOM_LONG( 0, 100 ) < 20 ) ) + { + UTIL_Ricochet( ptr->vecEndPos, RANDOM_FLOAT( 0.5, 1.5 ) ); + pev->dmgtime = gpGlobals->time; + } + + flDamage = 0; + } + + CBaseMonster::TraceAttack( pevAttacker, flDamage, vecDir, ptr, bitsDamageType ); +} + +int CRoboCop::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) +{ + if( IsAlive() ) + { + if( !FBitSet( bitsDamageType, ROBOCOP_DAMAGE ) ) + flDamage *= 0.01; + if( bitsDamageType & DMG_BLAST ) + SetConditions( bits_COND_LIGHT_DAMAGE ); + } + + return CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType ); +} + //========================================================= // FCanCheckAttacks - this is overridden for alien grunts // because they can use their smart weapons against unseen @@ -536,7 +564,7 @@ BOOL CRoboCop::FCanCheckAttacks(void) //========================================================= BOOL CRoboCop::CheckMeleeAttack1(float flDot, float flDist) { - if (flDist <= ROBOCOP_MELEE_ATTACK_DIST) + if( flDot >= 0.8f && flDist < gSkillData.robocopSWRadius ) { return TRUE; } @@ -550,7 +578,13 @@ BOOL CRoboCop::CheckMeleeAttack1(float flDot, float flDist) //========================================================= BOOL CRoboCop::CheckRangeAttack1(float flDot, float flDist) { - return FALSE; + if (m_flNextMortarAttack > gpGlobals->time) + return FALSE; + + if (flDot >= 0.8f && flDist > gSkillData.robocopSWRadius && flDist < 4096.0f && !HasConditions(bits_COND_CAN_MELEE_ATTACK1)) + { + return TRUE; + } } //========================================================= @@ -579,7 +613,19 @@ void CRoboCop::Killed(entvars_t *pevAttacker, int iGib) CBaseMonster::Killed(pevAttacker, GIB_NEVER); } +void CRoboCop::UpdateOnRemove() +{ + CBaseEntity::UpdateOnRemove(); + EyeOff(); + DestroyEffects(); + + if (m_pTemp) + { + UTIL_Remove(m_pTemp); + m_pTemp = NULL; + } +} void CRoboCop::PrescheduleThink(void) { CBaseMonster::PrescheduleThink(); @@ -632,11 +678,19 @@ Schedule_t* CRoboCop::GetSchedule() return GetScheduleOfType(SCHED_MELEE_ATTACK1); } + // laser attack. + if (HasConditions(bits_COND_CAN_RANGE_ATTACK1)) + { + return GetScheduleOfType(SCHED_RANGE_ATTACK1); + } + return GetScheduleOfType(SCHED_CHASE_ENEMY); } // Wander or simply walk. return GetScheduleOfType(SCHED_STANDOFF); + default: + break; } return CBaseMonster::GetSchedule(); @@ -740,11 +794,11 @@ void CRoboCop::StartTask(Task_t *pTask) case TASK_DIE: m_flWaitFinished = gpGlobals->time + ROBOCOP_DEATH_DURATION; - m_flNextSparkTime = gpGlobals->time + RANDOM_FLOAT(0, 0.5f); + m_flNextSparkTime = gpGlobals->time + 0.3f; + pev->renderamt = 19; pev->renderfx = kRenderFxGlowShell; - pev->rendercolor = Vector(64, 64, 255); - CBaseMonster::StartTask(pTask); - break; + pev->rendercolor = Vector(67, 85, 255); + pev->health = 0; default: CBaseMonster::StartTask(pTask); break; @@ -855,57 +909,60 @@ void CRoboCop::RunTask(Task_t *pTask) case TASK_DIE: if (m_flWaitFinished > gpGlobals->time) { - if (gpGlobals->time > m_flNextSparkTime) + if( pev->frame >= 255.0f ) { - float flRemainingWaitTime = m_flWaitFinished - gpGlobals->time; - float flRemainingProp = flRemainingWaitTime / ROBOCOP_DEATH_DURATION; + EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "common/null.wav", 1.0, ATTN_NORM, 0, 100); + MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin ); + WRITE_BYTE( TE_BREAKMODEL ); - if (flRemainingProp < 0) - flRemainingProp = 0; + // position + WRITE_COORD( pev->origin.x ); + WRITE_COORD( pev->origin.y ); + WRITE_COORD( pev->origin.z ); - Vector vSparkPos = pev->origin; - Vector forward, right, up; + // size + WRITE_COORD( 200 ); + WRITE_COORD( 200 ); + WRITE_COORD( 128 ); - Vector angles = pev->angles; - angles.x = 0; + // velocity + WRITE_COORD( 0 ); + WRITE_COORD( 0 ); + WRITE_COORD( 0 ); - UTIL_MakeVectors(angles); + // randomization + WRITE_BYTE( 200 ); - forward = gpGlobals->v_forward; - right = gpGlobals->v_right; - up = gpGlobals->v_up; + // Model + WRITE_SHORT( m_iRobocopGibModel ); //model id# - float halfHeight = pev->view_ofs.z * 0.5f; - float halfWidth = 32; + // # of shards + WRITE_BYTE( 20 ); - float flMinHeight = 4; - float flMaxHeight = flMinHeight + flRemainingProp * pev->view_ofs.z; + // duration + WRITE_BYTE( 20 );// 3.0 seconds - float flCenterZ = (flMinHeight + flMaxHeight) / 2; + // flags + WRITE_BYTE( BREAK_FLESH ); + MESSAGE_END(); - vSparkPos = vSparkPos + forward * ((1 - flRemainingProp) * 180); - vSparkPos = vSparkPos + right * halfWidth * (RANDOM_LONG(-1, 1) + RANDOM_FLOAT(0, 1)); - vSparkPos = vSparkPos + up * (flCenterZ + RANDOM_LONG(-1, 1) * RANDOM_FLOAT(0, 1)); + SpawnExplosion( pev->origin, 70, 0, 150 ); - UTIL_Sparks(vSparkPos); + int trailCount = RANDOM_LONG( 2, 4 ); + for( int i = 0; i < trailCount; i++ ) + Create( "fire_trail", pev->origin, Vector( 0, 0, 1 ), NULL ); - EMIT_SOUND_DYN(ENT(pev), CHAN_BODY, RANDOM_SOUND_ARRAY(pSparkSounds), 1.0, 0.6, 0, RANDOM_LONG(95, 105)); - - m_flNextSparkTime = gpGlobals->time + RANDOM_FLOAT(0.3f, 0.5f); + SetBodygroup( 0, 1 ); + return; } } - else + if (gpGlobals->time > m_flNextSparkTime) { - pev->renderfx = kRenderFxNone; - pev->rendercolor.x = - pev->rendercolor.y = - pev->rendercolor.z = 255; - - m_flNextSparkTime = 0; - - CBaseMonster::RunTask(pTask); + Create( "spark_shower", pev->origin, Vector( 0, 0, 1 ), NULL ); + EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "ambience/sparks.wav", 1.0, ATTN_NORM, 0, 100); + m_flNextSparkTime = gpGlobals->time + 0.3f; + return; } - break; default: CBaseMonster::RunTask(pTask); break; @@ -920,58 +977,56 @@ void CRoboCop::SonicAttack(void) { float flAdjustedDamage; float flDist; + Vector vecDist; + int i, r, g, b; - EMIT_SOUND(ENT(pev), CHAN_WEAPON, "robocop/rc_fist.wav", 1, ATTN_NORM); + UTIL_MakeVectors( pev->angles ); + Vector vecSrc = pev->origin + 12 * gpGlobals->v_right + 95 * gpGlobals->v_forward; - // blast circles - MESSAGE_BEGIN(MSG_PAS, SVC_TEMPENTITY, pev->origin); - WRITE_BYTE(TE_BEAMCYLINDER); - WRITE_COORD(pev->origin.x); - WRITE_COORD(pev->origin.y); - WRITE_COORD(pev->origin.z + 16); - WRITE_COORD(pev->origin.x); - WRITE_COORD(pev->origin.y); - WRITE_COORD(pev->origin.z + 16 + ROBOCOP_MAX_SHOCKWAVE_RADIUS / .2); // reach damage radius over .3 seconds - WRITE_SHORT(m_iSpriteTexture); - WRITE_BYTE(0); // startframe - WRITE_BYTE(0); // framerate - WRITE_BYTE(2); // life - WRITE_BYTE(16); // width - WRITE_BYTE(0); // noise - WRITE_BYTE(62); // r - WRITE_BYTE(33); // g - WRITE_BYTE(211); // b - WRITE_BYTE(255); //brightness - WRITE_BYTE(0); // speed - MESSAGE_END(); - - MESSAGE_BEGIN(MSG_PAS, SVC_TEMPENTITY, pev->origin); - WRITE_BYTE(TE_BEAMCYLINDER); - WRITE_COORD(pev->origin.x); - WRITE_COORD(pev->origin.y); - WRITE_COORD(pev->origin.z + 16); - WRITE_COORD(pev->origin.x); - WRITE_COORD(pev->origin.y); - WRITE_COORD(pev->origin.z + 16 + (ROBOCOP_MAX_SHOCKWAVE_RADIUS / 2) / .2); // reach damage radius over .3 seconds - WRITE_SHORT(m_iSpriteTexture); - WRITE_BYTE(0); // startframe - WRITE_BYTE(0); // framerate - WRITE_BYTE(2); // life - WRITE_BYTE(16); // width - WRITE_BYTE(0); // noise - WRITE_BYTE(62); // r - WRITE_BYTE(33); // g - WRITE_BYTE(211); // b - WRITE_BYTE(255); //brightness - WRITE_BYTE(0); // speed - MESSAGE_END(); + for( i = 0; i < 3; i++ ) + { + switch( i ) + { + case 0: + r = 101, g = 133, b = 221; + break; + case 1: + r = 67, g = 85, b = 255; + break; + case 2: + r = 62, g = 33, b = 211; + break; + } + + // blast circles + MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin ); + WRITE_BYTE( TE_BEAMCYLINDER ); + WRITE_COORD( vecSrc.x ); + WRITE_COORD( vecSrc.y ); + WRITE_COORD( vecSrc.z + 16 ); + WRITE_COORD( vecSrc.x ); + WRITE_COORD( vecSrc.y ); + WRITE_COORD( vecSrc.z + gSkillData.robocopSWRadius / ( ( i + 1 ) * .2 ) ); // reach damage radius over .3 seconds + WRITE_SHORT( m_iSpriteTexture ); + WRITE_BYTE( 0 ); // startframe + WRITE_BYTE( 10 ); // framerate + WRITE_BYTE( i + 2 ); // life + WRITE_BYTE( 32 ); // width + WRITE_BYTE( 0 ); // noise + WRITE_BYTE( r ); // r + WRITE_BYTE( g ); // g + WRITE_BYTE( b ); // b + WRITE_BYTE( 255 ); //brightness + WRITE_BYTE( 0 ); // speed + MESSAGE_END(); + } // Shake the screen. UTIL_ScreenShake(pev->origin, 12.0, 100.0, 2.0, 1000); CBaseEntity *pEntity = NULL; // iterate on all entities in the vicinity. - while ((pEntity = UTIL_FindEntityInSphere(pEntity, pev->origin, ROBOCOP_MAX_SHOCKWAVE_RADIUS)) != NULL) + while ((pEntity = UTIL_FindEntityInSphere(pEntity, pev->origin, gSkillData.robocopSWRadius)) != NULL) { if ( pEntity->pev->takedamage != DAMAGE_NO ) { @@ -982,12 +1037,10 @@ void CRoboCop::SonicAttack(void) // This means that you must get out of the houndeye's attack range entirely to avoid damage. // Calculate full damage first - // solo - flAdjustedDamage = gSkillData.robocopDmgFist; + vecDist = pEntity->Center() - vecSrc; + flDist = Q_max( 0, gSkillData.robocopSWRadius - vecDist.Length() ); - flDist = (pEntity->Center() - pev->origin).Length(); - - flAdjustedDamage -= (flDist / ROBOCOP_MAX_SHOCKWAVE_RADIUS) * flAdjustedDamage; + flDist = flDist / gSkillData.robocopSWRadius; if (!FVisible(pEntity)) { @@ -996,24 +1049,35 @@ void CRoboCop::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; + flDist *= 0.5; } else if (!FClassnameIs(pEntity->pev, "func_breakable") && !FClassnameIs(pEntity->pev, "func_pushable")) { // do not hurt nonclients through walls, but allow damage to be done to breakables - flAdjustedDamage = 0; + flDist = 0; } } + flAdjustedDamage = gSkillData.robocopDmgFist * flDist; //ALERT ( at_aiconsole, "Damage: %f\n", flAdjustedDamage ); if (flAdjustedDamage > 0) { - pEntity->TakeDamage(pev, pev, flAdjustedDamage, DMG_SONIC | DMG_ALWAYSGIB); + pEntity->TakeDamage(pev, pev, flAdjustedDamage, DMG_SONIC); + } + if( pEntity->IsPlayer() ) + { + vecDist = vecDist.Normalize(); + vecDist.x = vecDist.x * flDist * 600.0f; + vecDist.y = vecDist.y * flDist * 600.0f; + vecDist.z = flDist * 450.0f; + pEntity->pev->velocity = vecDist + pEntity->pev->velocity; + pEntity->pev->punchangle.x = 5; } } } } + EMIT_SOUND_DYN( edict(), CHAN_WEAPON, "robocop/rc_fist.wav", 1.0, ATTN_NORM, 0, PITCH_NORM + RANDOM_LONG( -10, 10 ) ); } @@ -1022,110 +1086,9 @@ void CRoboCop::SonicAttack(void) //========================================================= void CRoboCop::MortarAttack(Vector vecSrc) { - float flAdjustedDamage; - float flDist; - - - // blast circles - MESSAGE_BEGIN(MSG_PAS, SVC_TEMPENTITY, vecSrc); - WRITE_BYTE(TE_BEAMCYLINDER); - WRITE_COORD(vecSrc.x); - WRITE_COORD(vecSrc.y); - WRITE_COORD(vecSrc.z + 16); - WRITE_COORD(vecSrc.x); - WRITE_COORD(vecSrc.y); - WRITE_COORD(vecSrc.z + 16 + ROBOCOP_MAX_MORTAR_RADIUS / .2); // reach damage radius over .3 seconds - WRITE_SHORT(m_iSpriteTexture); - WRITE_BYTE(0); // startframe - WRITE_BYTE(0); // framerate - WRITE_BYTE(2); // life - WRITE_BYTE(12); // width // 16 - WRITE_BYTE(0); // noise - WRITE_BYTE(255); // r - WRITE_BYTE(128); // g - WRITE_BYTE(64); // b - WRITE_BYTE(255); //brightness - WRITE_BYTE(0); // speed - MESSAGE_END(); - - MESSAGE_BEGIN(MSG_PAS, SVC_TEMPENTITY, pev->origin); - WRITE_BYTE(TE_BEAMCYLINDER); - WRITE_COORD(vecSrc.x); - WRITE_COORD(vecSrc.y); - WRITE_COORD(vecSrc.z + 16); - WRITE_COORD(vecSrc.x); - WRITE_COORD(vecSrc.y); - WRITE_COORD(vecSrc.z + 16 + (ROBOCOP_MAX_MORTAR_RADIUS / 2) / .2); // reach damage radius over .3 seconds - WRITE_SHORT(m_iSpriteTexture); - WRITE_BYTE(0); // startframe - WRITE_BYTE(0); // framerate - WRITE_BYTE(2); // life - WRITE_BYTE(12); // width // 16 - WRITE_BYTE(0); // noise - WRITE_BYTE(255); // r - WRITE_BYTE(128); // g - WRITE_BYTE(64); // b - WRITE_BYTE(255); //brightness - WRITE_BYTE(0); // speed - MESSAGE_END(); - - // Explosion - MESSAGE_BEGIN(MSG_PAS, SVC_TEMPENTITY, vecSrc); - WRITE_BYTE( TE_EXPLOSION ); // This makes a dynamic light and the explosion sprites/sound - WRITE_COORD(vecSrc.x); // Send to PAS because of the sound - WRITE_COORD(vecSrc.y); - WRITE_COORD(vecSrc.z); - WRITE_SHORT( g_sModelIndexFireball ); - WRITE_BYTE( 50 ); // scale * 10 - WRITE_BYTE( 15 ); // framerate - WRITE_BYTE(TE_EXPLFLAG_NONE | TE_EXPLFLAG_NODLIGHTS); - MESSAGE_END(); - - CBaseEntity *pEntity = NULL; - // iterate on all entities in the vicinity. - while ((pEntity = UTIL_FindEntityInSphere(pEntity, vecSrc, ROBOCOP_MAX_MORTAR_RADIUS)) != NULL) - { - if (pEntity->pev->takedamage != DAMAGE_NO) - { - // Robocop does not take damage from it's own attacks. - if (pEntity != this) - { - // houndeyes do FULL damage if the ent in question is visible. Half damage otherwise. - // This means that you must get out of the houndeye's attack range entirely to avoid damage. - // Calculate full damage first - - // solo - flAdjustedDamage = 20;// gSkillData.robocopDmgMortar; - - flDist = (pEntity->Center() - vecSrc).Length(); - - flAdjustedDamage -= (flDist / ROBOCOP_MAX_MORTAR_RADIUS) * flAdjustedDamage; - - if (!FVisible(pEntity)) - { - if (pEntity->IsPlayer()) - { - // 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; - } - else if (!FClassnameIs(pEntity->pev, "func_breakable") && !FClassnameIs(pEntity->pev, "func_pushable")) - { - // do not hurt nonclients through walls, but allow damage to be done to breakables - flAdjustedDamage = 0; - } - } - - //ALERT ( at_aiconsole, "Damage: %f\n", flAdjustedDamage ); - - if (flAdjustedDamage > 0) - { - pEntity->TakeDamage(pev, pev, flAdjustedDamage, DMG_SONIC | DMG_ALWAYSGIB); - } - } - } - } + CBaseEntity *pMortar = Create( "monster_mortar", vecSrc, g_vecZero, 0 ); + pMortar->pev->nextthink = gpGlobals->time + 0.1; + pMortar->pev->dmg = gSkillData.robocopDmgMortar; } void CRoboCop::StartMortarAttack(void) @@ -1212,7 +1175,7 @@ BOOL CRoboCop::IsEnemyReachable(CBaseEntity* pEnemy) void CRoboCop::CreateEyeGlow(void) { m_pEyeGlow = CSprite::SpriteCreate(ROBOCOP_EYE_SPRITE_NAME, pev->origin, FALSE); - m_pEyeGlow->SetTransparency(kRenderGlow, 255, 255, 255, 0, kRenderFxNoDissipation); + m_pEyeGlow->SetTransparency(kRenderTransAdd, 255, 255, 255, 0, kRenderFxNoDissipation); m_pEyeGlow->SetAttachment(edict(), 1); m_pEyeGlow->SetScale(0.5f); } @@ -1225,7 +1188,7 @@ void CRoboCop::DestroyEyeGlow(void) void CRoboCop::CreateBeam(void) { - m_pBeam = CBeam::BeamCreate(ROBOCOP_EYE_BEAM_NAME, 20); + m_pBeam = CBeam::BeamCreate(ROBOCOP_EYE_BEAM_NAME, 30); m_pBeam->PointEntInit(pev->origin, entindex()); m_pBeam->SetEndAttachment(1); m_pBeam->SetBrightness(0); @@ -1241,8 +1204,8 @@ void CRoboCop::DestroyBeam(void) void CRoboCop::CreateSpot(void) { m_pBeamSpot = CSprite::SpriteCreate(ROBOCOP_EYE_SPOT_NAME, pev->origin, FALSE); - m_pBeamSpot->SetTransparency(kRenderGlow, 255, 0, 0, 0, kRenderFxNoDissipation); - m_pBeamSpot->SetScale(0.15f); + m_pBeamSpot->SetTransparency(kRenderTransAdd, 255, 255, 255, 0, kRenderFxNoDissipation); + m_pBeamSpot->SetScale(0.30f); } void CRoboCop::DestroySpot(void) @@ -1308,7 +1271,7 @@ void CRoboCop::EyeUpdate(void) if (m_pEyeGlow) { - m_pEyeGlow->pev->renderamt = UTIL_Approach(m_eyeBrightness, m_pEyeGlow->pev->renderamt, 26); + m_pEyeGlow->pev->renderamt = UTIL_Approach(m_eyeBrightness, m_pEyeGlow->pev->renderamt, 30); if (m_pEyeGlow->pev->renderamt == 0) m_pEyeGlow->pev->effects |= EF_NODRAW; else @@ -1353,7 +1316,7 @@ void CRoboCop::BeamUpdate(void) if (m_pBeamSpot) { - m_pBeamSpot->pev->renderamt = UTIL_Approach(min(m_beamBrightness + 25, 255), m_pBeamSpot->pev->renderamt, 60); + m_pBeamSpot->pev->renderamt = UTIL_Approach(Q_min(m_beamBrightness + 25, 255), m_pBeamSpot->pev->renderamt, 60); if (m_pBeamSpot->pev->renderamt == 0) m_pBeamSpot->pev->effects |= EF_NODRAW; else diff --git a/dlls/poke646/weapon_pipebomb.cpp b/dlls/poke646/weapon_pipebomb.cpp deleted file mode 100644 index c621535e..00000000 --- a/dlls/poke646/weapon_pipebomb.cpp +++ /dev/null @@ -1,310 +0,0 @@ -/*** -* -* Copyright (c) 1996-2001, 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. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -#include "extdll.h" -#include "util.h" -#include "cbase.h" -#include "monsters.h" -#include "weapons.h" -#include "nodes.h" -#include "player.h" -#include "gamerules.h" -#include "pipebomb.h" - - -enum pipebomb_e { - PIPEBOMB_IDLE1 = 0, - PIPEBOMB_FIDGET1, - PIPEBOMB_DRAW, - PIPEBOMB_DROP -}; - -enum pipebomb_watch_e { - PIPEBOMB_WATCH_IDLE1 = 0, - PIPEBOMB_WATCH_FIDGET1, - PIPEBOMB_WATCH_DRAW, - PIPEBOMB_WATCH_FIRE, - PIPEBOMB_WATCH_HOLSTER -}; - - -LINK_ENTITY_TO_CLASS(weapon_pipebomb, CPipeBomb); - - -//========================================================= -//========================================================= -int CPipeBomb::AddToPlayer(CBasePlayer *pPlayer) -{ - int bResult = CBasePlayerItem::AddToPlayer(pPlayer); - - pPlayer->pev->weapons |= (1 << m_iId); - m_chargeReady = 0;// this satchel charge weapon now forgets that any satchels are deployed by it. - - if (bResult) - { - return AddWeapon(); - } - return FALSE; -} - -void CPipeBomb::Spawn() -{ - Precache(); - m_iId = WEAPON_PIPEBOMB; - SET_MODEL(ENT(pev), "models/w_pipebomb.mdl"); - - m_iDefaultAmmo = PIPEBOMB_DEFAULT_GIVE; - - FallInit();// get ready to fall down. -} - - -void CPipeBomb::Precache(void) -{ - PRECACHE_MODEL("models/v_pipebomb.mdl"); - PRECACHE_MODEL("models/v_pipebomb_watch.mdl"); - PRECACHE_MODEL("models/w_pipebomb.mdl"); - PRECACHE_MODEL("models/p_pipebomb.mdl"); - PRECACHE_MODEL("models/p_pipebomb_watch.mdl"); - - UTIL_PrecacheOther("monster_pipebomb"); - - m_usReload = PRECACHE_EVENT(1, "events/reload.sc"); -} - - -int CPipeBomb::GetItemInfo(ItemInfo *p) -{ - p->pszName = STRING(pev->classname); - p->pszAmmo1 = "Pipe Bombs"; - p->iMaxAmmo1 = PIPEBOMB_MAX_CARRY; - p->pszAmmo2 = NULL; - p->iMaxAmmo2 = -1; - p->iMaxClip = WEAPON_NOCLIP; - p->iSlot = 4; - p->iPosition = 0; - p->iFlags = ITEM_FLAG_SELECTONEMPTY | ITEM_FLAG_LIMITINWORLD | ITEM_FLAG_EXHAUSTIBLE; - p->iId = m_iId = WEAPON_PIPEBOMB; - p->iWeight = PIPEBOMB_WEIGHT; - - return 1; -} - - -BOOL CPipeBomb::Deploy() -{ - - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat(m_pPlayer->random_seed, 10, 15); - - if (m_chargeReady) - return DefaultDeploy("models/v_pipebomb_watch.mdl", "models/p_pipebomb_watch.mdl", PIPEBOMB_WATCH_DRAW, "hive"); - else - return DefaultDeploy("models/v_pipebomb.mdl", "models/p_pipebomb.mdl", PIPEBOMB_DRAW, "trip"); - - - return TRUE; -} - - -void CPipeBomb::Holster(int skiplocal /* = 0 */) -{ - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; - - if (m_chargeReady) - { - SendWeaponAnim(PIPEBOMB_WATCH_HOLSTER); - } - else - { - SendWeaponAnim(PIPEBOMB_DROP); - } - - EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM); - - if (!m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] && !m_chargeReady) - { - m_pPlayer->pev->weapons &= ~(1 << WEAPON_PIPEBOMB); - SetThink(&CPipeBomb::DestroyItem); - pev->nextthink = gpGlobals->time + 0.1; - } -} - - - -void CPipeBomb::PrimaryAttack() -{ - switch (m_chargeReady) - { - case 0: - { - Throw(); - } - break; - case 1: - { - SendWeaponAnim(PIPEBOMB_WATCH_FIRE); - - edict_t *pPlayer = m_pPlayer->edict(); - - CBaseEntity *pSatchel = NULL; - - while ((pSatchel = UTIL_FindEntityInSphere(pSatchel, m_pPlayer->pev->origin, 4096)) != NULL) - { - if (FClassnameIs(pSatchel->pev, "monster_pipebomb")) - { - if ( pSatchel->pev->owner == pPlayer || pSatchel->m_thrownByPlayer == 1) - { - pSatchel->Use(m_pPlayer, m_pPlayer, USE_ON, 0); - m_chargeReady = 2; - } - } - } - - m_chargeReady = 2; - m_flNextPrimaryAttack = GetNextAttackDelay(0.5); - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; - break; - } - - case 2: - // we're reloading, don't allow fire - { - } - break; - } -} - - -void CPipeBomb::SecondaryAttack(void) -{ - if (m_chargeReady != 2) - { - Throw(); - } -} - - -void CPipeBomb::Redraw(void) -{ -#ifndef CLIENT_DLL - m_pPlayer->pev->viewmodel = MAKE_STRING("models/v_pipebomb.mdl"); - m_pPlayer->pev->weaponmodel = MAKE_STRING("models/p_pipebomb.mdl"); -#else - LoadVModel("models/v_pipebomb.mdl", m_pPlayer); -#endif - - // SendWeaponAnim(PIPEBOMB_DRAW, 0); - PLAYBACK_EVENT_FULL(0, m_pPlayer->edict(), m_usReload, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, PIPEBOMB_DRAW, 0, 0, 0); - - // use tripmine animations - strcpy(m_pPlayer->m_szAnimExtention, "trip"); - - m_flNextPrimaryAttack = GetNextAttackDelay(0.5); - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; - m_chargeReady = 0; -} - -void CPipeBomb::Throw(void) -{ - if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]) - { - Vector vecSrc = m_pPlayer->pev->origin; - - Vector vecThrow = gpGlobals->v_forward * 274 + m_pPlayer->pev->velocity; - -#ifndef CLIENT_DLL - CBaseEntity *pSatchel = Create("monster_pipebomb", vecSrc, Vector(0, 0, 0), m_pPlayer->edict()); - pSatchel->pev->velocity = vecThrow; - pSatchel->pev->avelocity.y = 400; - pSatchel->m_thrownByPlayer = 1; - - m_pPlayer->pev->viewmodel = MAKE_STRING("models/v_pipebomb_watch.mdl"); - m_pPlayer->pev->weaponmodel = MAKE_STRING("models/p_pipebomb_watch.mdl"); -#else - LoadVModel("models/v_pipebomb_watch.mdl", m_pPlayer); -#endif - - // SendWeaponAnim(PIPEBOMB_WATCH_DRAW); - PLAYBACK_EVENT_FULL(0, m_pPlayer->edict(), m_usReload, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, PIPEBOMB_WATCH_DRAW, 0, 0, 0); - - // player "shoot" animation - m_pPlayer->SetAnimation(PLAYER_ATTACK1); - - m_chargeReady = 1; - - m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; - - m_flNextPrimaryAttack = GetNextAttackDelay(1.0); - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; - } -} - -BOOL CPipeBomb::ShouldWeaponIdle(void) -{ - return FALSE; -} - -void CPipeBomb::WeaponIdle(void) -{ - if (m_chargeReady == 2) - { - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() - 0.1; - } - - if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase()) - return; - - switch (m_chargeReady) - { - case 0: - SendWeaponAnim(PIPEBOMB_FIDGET1); - // use tripmine animations - strcpy(m_pPlayer->m_szAnimExtention, "trip"); - break; - case 1: - SendWeaponAnim(PIPEBOMB_WATCH_FIDGET1); - // use hivehand animations - strcpy(m_pPlayer->m_szAnimExtention, "hive"); - break; - case 2: - if (!m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]) - { - m_chargeReady = 0; - RetireWeapon(); - return; - } - -#ifndef CLIENT_DLL - m_pPlayer->pev->viewmodel = MAKE_STRING("models/v_pipebomb.mdl"); - m_pPlayer->pev->weaponmodel = MAKE_STRING("models/p_pipebomb.mdl"); -#else - LoadVModel("models/v_pipebomb.mdl", m_pPlayer); -#endif - - // SendWeaponAnim(PIPEBOMB_DRAW, 0); - PLAYBACK_EVENT_FULL(0, m_pPlayer->edict(), m_usReload, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, PIPEBOMB_DRAW, 0, 0, 0); - - // use tripmine animations - strcpy(m_pPlayer->m_szAnimExtention, "trip"); - - m_flNextPrimaryAttack = GetNextAttackDelay(0.5); - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; - m_chargeReady = 0; - break; - } - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat(m_pPlayer->random_seed, 10, 15);// how long till we do this again. -} \ No newline at end of file diff --git a/dlls/poke646/xenspit.cpp b/dlls/poke646/xenspit.cpp deleted file mode 100644 index b38d433d..00000000 --- a/dlls/poke646/xenspit.cpp +++ /dev/null @@ -1,351 +0,0 @@ -/*** -* -* Copyright (c) 1996-2001, 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. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - - -#include "extdll.h" -#include "util.h" -#include "cbase.h" -#include "monsters.h" -#include "weapons.h" -#include "schedule.h" -#include "nodes.h" -#include "effects.h" -#include "decals.h" -#include "soundent.h" -#include "game.h" -#include "xenspit.h" - -LINK_ENTITY_TO_CLASS(xensmallspit, CXenSmallSpit); - -TYPEDESCRIPTION CXenSmallSpit::m_SaveData[] = -{ - DEFINE_FIELD(CXenSmallSpit, m_iTrail, FIELD_INTEGER), - DEFINE_FIELD(CXenSmallSpit, m_flCycle, FIELD_FLOAT), - DEFINE_FIELD(CXenSmallSpit, m_pBeam, FIELD_CLASSPTR), - DEFINE_FIELD(CXenSmallSpit, m_vecOldVelocity, FIELD_VECTOR), -}; - -IMPLEMENT_SAVERESTORE(CXenSmallSpit, CBaseEntity); - -void CXenSmallSpit::Spawn(void) -{ - Precache(); - - pev->movetype = MOVETYPE_FLY; - pev->classname = MAKE_STRING("xensmallspit"); - - pev->solid = SOLID_BBOX; - pev->rendermode = kRenderTransAdd; - pev->renderamt = 255; - - SET_MODEL(ENT(pev), "sprites/hotglow.spr"); - pev->frame = 0; - pev->scale = 0.5; - pev->gravity = 0; - pev->dmg = gSkillData.plrDmgGauss; - - UTIL_SetSize(pev, Vector(0, 0, 0), Vector(0, 0, 0)); - - // trail - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); - WRITE_BYTE( TE_BEAMFOLLOW ); - WRITE_SHORT( entindex() ); // entity - WRITE_SHORT( m_iTrail ); // model - WRITE_BYTE( 10 ); // life - WRITE_BYTE( 4 ); // width - WRITE_BYTE( 161 ); // r, g, b - WRITE_BYTE( 188 ); // r, g, b - WRITE_BYTE( 0 ); // r, g, b - WRITE_BYTE( 128 ); // brightness - - MESSAGE_END(); - - m_pBeam = NULL; - m_pParent = NULL; -} - -void CXenSmallSpit::Precache() -{ - PRECACHE_MODEL("sprites/hotglow.spr"); - - m_iTrail = PRECACHE_MODEL("sprites/laserbeam.spr"); - - PRECACHE_MODEL("sprites/laserbeam.spr"); -} - -CXenSmallSpit* CXenSmallSpit::ShootStraight(entvars_t *pevOwner, Vector vecStart, Vector vecAngles, Vector vecVelocity) -{ - CXenSmallSpit *pSpit = GetClassPtr((CXenSmallSpit *)NULL); - pSpit->Spawn(); - - UTIL_SetOrigin(pSpit->pev, vecStart); - pSpit->pev->angles = vecAngles; - pSpit->pev->velocity = vecVelocity; - pSpit->pev->owner = ENT(pevOwner); - pSpit->m_vecOldVelocity = vecVelocity; - - pSpit->m_flCycle = 0.0f; - pSpit->m_pParent = NULL; - - pSpit->SetThink(&CXenSmallSpit::StraightThink); - pSpit->pev->nextthink = gpGlobals->time + 0.01; - - return pSpit; -} - -CXenSmallSpit* CXenSmallSpit::ShootCycle(entvars_t *pevOwner, Vector vecStart, Vector vecAngles, Vector vecVelocity, CBaseEntity* pParent, float flCycle) -{ - CXenSmallSpit *pSpit = GetClassPtr((CXenSmallSpit *)NULL); - pSpit->Spawn(); - - UTIL_SetOrigin(pSpit->pev, vecStart); - pSpit->pev->angles = vecAngles; - pSpit->pev->velocity = vecVelocity; - pSpit->pev->owner = ENT(pevOwner); - pSpit->m_vecOldVelocity = vecVelocity; - - pSpit->m_flCycle = flCycle; - pSpit->m_pParent = pParent; - - pSpit->SetThink(&CXenSmallSpit::CycleThink); - pSpit->pev->nextthink = gpGlobals->time + 0.01; - - return pSpit; -} - -void CXenSmallSpit::Touch(CBaseEntity *pOther) -{ - if (m_pParent != NULL) - return; - - if (FClassnameIs(pOther->pev, STRING(pev->classname))) - return; - - // ALERT(at_console, " CXenSmallSpit::Touch START\n"); - - TraceResult tr; - - RadiusDamage(pev->origin, pev, pev, pev->dmg, 80, CLASS_NONE, DMG_POISON | DMG_ALWAYSGIB); - - if (!pOther->pev->takedamage) - { - // make a splat on the wall - UTIL_TraceLine(pev->origin, pev->origin + pev->velocity * 10, dont_ignore_monsters, ENT(pev), &tr); - UTIL_DecalTrace(&tr, DECAL_SMALLSCORCH1 + RANDOM_LONG(0, 2)); - } - - if (m_pBeam) - { - UTIL_Remove(m_pBeam); - m_pBeam = NULL; - } - - // light. - MESSAGE_BEGIN(MSG_PVS, SVC_TEMPENTITY, pev->origin); - WRITE_BYTE(TE_DLIGHT); - WRITE_COORD(pev->origin.x); // X - WRITE_COORD(pev->origin.y); // Y - WRITE_COORD(pev->origin.z); // Z - WRITE_BYTE(8); // radius * 0.1 - WRITE_BYTE(161); // r - WRITE_BYTE(188); // g - WRITE_BYTE(0); // b - WRITE_BYTE(10); // time * 10 - WRITE_BYTE(2); // decay * 0.1 - MESSAGE_END(); - - m_pParent = NULL; - - SetThink(&CXenSmallSpit::SUB_Remove); - SetTouch(NULL); - pev->nextthink = gpGlobals->time; - - // ALERT(at_console, " CXenSmallSpit::Touch END\n"); -} - -void CXenSmallSpit::StraightThink(void) -{ - pev->nextthink = gpGlobals->time + 0.01f; - - m_flCycle += 0.02f; - - if (m_flCycle >= 1) - m_flCycle = 0; - - pev->velocity.z = m_vecOldVelocity.z + sin(m_flCycle * 2 * M_PI) * 16; -} - -void CXenSmallSpit::CycleThink(void) -{ - pev->nextthink = gpGlobals->time + 0.01f; - - m_flCycle += 0.02f; - - if (m_flCycle >= 1) - m_flCycle = 0; -} - - - - - -LINK_ENTITY_TO_CLASS(xenlargespit, CXenLargeSpit); - -TYPEDESCRIPTION CXenLargeSpit::m_SaveData[] = -{ - DEFINE_FIELD(CXenLargeSpit, m_iChildCount, FIELD_INTEGER), - DEFINE_ARRAY(CXenLargeSpit, m_pChildren, FIELD_CLASSPTR, XENSPIT_MAX_PROJECTILES), -}; - -IMPLEMENT_SAVERESTORE(CXenLargeSpit, CBaseEntity); - - -void CXenLargeSpit::Spawn(void) -{ - Precache(); - - pev->movetype = MOVETYPE_FLY; - pev->classname = MAKE_STRING("xenlargespit"); - - pev->solid = SOLID_BBOX; - pev->rendermode = kRenderTransAdd; - pev->renderamt = 255; - - SET_MODEL(ENT(pev), "sprites/glow02.spr"); - pev->frame = 0; - pev->scale = 0.5; - pev->gravity = 0; - pev->dmg = gSkillData.plrDmgGauss; - - pev->renderamt = 0; - - UTIL_SetSize(pev, Vector(0, 0, 0), Vector(0, 0, 0)); - - for (int i = 0; i < XENSPIT_MAX_PROJECTILES; i++) - m_pChildren[i] = NULL; -} - -void CXenLargeSpit::Precache() -{ - PRECACHE_MODEL("sprites/glow02.spr"); -} - -CXenLargeSpit* CXenLargeSpit::Shoot(entvars_t *pevOwner, Vector vecStart, Vector vecAngles, Vector vecVelocity) -{ - CXenLargeSpit *pSpit = GetClassPtr((CXenLargeSpit *)NULL); - pSpit->Spawn(); - - UTIL_SetOrigin(pSpit->pev, vecStart); - pSpit->pev->angles = vecAngles; - pSpit->pev->velocity = vecVelocity; - pSpit->pev->owner = ENT(pevOwner); - - pSpit->SetThink(&CXenLargeSpit::CycleThink); - pSpit->pev->nextthink = gpGlobals->time + 0.01; - - return pSpit; -} - -void CXenLargeSpit::Touch(CBaseEntity *pOther) -{ - // ALERT(at_console, " CXenLargeSpit::Touch START\n"); - - float damage = max(pev->dmg, pev->dmg * m_iChildCount); - - RadiusDamage(pev->origin, pev, pev, damage, 110, CLASS_NONE, DMG_POISON | DMG_ALWAYSGIB); - - TraceResult tr; - - if (!pOther->pev->takedamage) - { - // make a splat on the wall - UTIL_TraceLine(pev->origin, pev->origin + pev->velocity * 10, dont_ignore_monsters, ENT(pev), &tr); - UTIL_DecalTrace(&tr, DECAL_SMALLSCORCH1 + RANDOM_LONG(0, 2)); - } - - for (int i = 0; i < m_iChildCount; i++) - { - if (m_pChildren[i]) - { - UTIL_Remove(m_pChildren[i]); - m_pChildren[i] = NULL; - } - } - - m_iChildCount = 0; - - // light. - MESSAGE_BEGIN(MSG_PVS, SVC_TEMPENTITY, pev->origin); - WRITE_BYTE(TE_DLIGHT); - WRITE_COORD(pev->origin.x); // X - WRITE_COORD(pev->origin.y); // Y - WRITE_COORD(pev->origin.z); // Z - WRITE_BYTE(12); // radius * 0.1 - WRITE_BYTE(161); // r - WRITE_BYTE(188); // g - WRITE_BYTE(0); // b - WRITE_BYTE(10); // time * 10 - WRITE_BYTE(2); // decay * 0.1 - MESSAGE_END(); - - SetThink(&CXenLargeSpit::SUB_Remove); - SetTouch(NULL); - pev->nextthink = gpGlobals->time + 0.1f; - - // ALERT(at_console, " CXenLargeSpit::Touch START\n"); -} - -void CXenLargeSpit::CycleThink(void) -{ - pev->nextthink = gpGlobals->time + 0.1f; - - Vector src, forward, right, up, cross; - - forward = pev->velocity.Normalize(); - - Vector horizontal = Vector(pev->velocity.x, pev->velocity.y, 0).Normalize(); - Vector direction = forward; - - float flDot = DotProduct(direction, horizontal); - if (flDot < 0.5) - cross = Vector(1, 0, 0); - else - cross = Vector(0, 0, 1); - - right = CrossProduct(direction, cross); - up = CrossProduct(right, direction); - - for (int i = 0; i < m_iChildCount; i++) - { - CXenSmallSpit* pSpit = (CXenSmallSpit*)m_pChildren[i]; - if (pSpit) - { - float cs, sn, dist; - cs = cos(pSpit->m_flCycle * 2 * M_PI); - sn = sin(pSpit->m_flCycle * 2 * M_PI); - dist = max(2, 2 * m_iChildCount); - - // ALERT(at_console, "cs: %.2f. sn: %.2f\n", cs, sn); - - Vector target = (right * cs * dist) + (up * sn * dist); - - src = pev->origin + target * -2; - pSpit->pev->origin = src; - pSpit->pev->velocity = pev->velocity; - } - } -} - - diff --git a/dlls/poke646/xenspit.h b/dlls/poke646/xenspit.h deleted file mode 100644 index 06d22ed0..00000000 --- a/dlls/poke646/xenspit.h +++ /dev/null @@ -1,71 +0,0 @@ -/*** -* -* Copyright (c) 1996-2001, 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. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -#ifndef XENSPIT_H -#define XENSPIT_H - -#ifdef _WIN32 -#pragma once -#endif - -#define XENSPIT_MAX_PROJECTILES 4 - -class CXenLargeSpit : public CBaseEntity -{ -public: - void Spawn(void); - void Precache(void); - - static CXenLargeSpit* Shoot(entvars_t *pevOwner, Vector vecStart, Vector vecAngles, Vector vecVelocity); - void Touch(CBaseEntity *pOther); - void EXPORT CycleThink(void); - - virtual int Save(CSave &save); - virtual int Restore(CRestore &restore); - static TYPEDESCRIPTION m_SaveData[]; - - CBaseEntity* m_pChildren[XENSPIT_MAX_PROJECTILES]; - int m_iChildCount; -}; - - -class CXenSmallSpit : public CBaseEntity -{ -public: - void Spawn(void); - void Precache(void); - - static CXenSmallSpit* ShootStraight(entvars_t *pevOwner, Vector vecStart, Vector vecAngles, Vector vecVelocity); - static CXenSmallSpit* ShootCycle(entvars_t *pevOwner, Vector vecStart, Vector vecAngles, Vector vecVelocity, CBaseEntity* pParent, float flCycle = 0.0f); - void Touch(CBaseEntity *pOther); - void EXPORT CycleThink(void); - void EXPORT StraightThink(void); - - virtual int Save(CSave &save); - virtual int Restore(CRestore &restore); - static TYPEDESCRIPTION m_SaveData[]; - - int m_iTrail; - float m_flCycle; - Vector m_vecOldVelocity; - - CBaseEntity* m_pParent; - - CBeam* m_pBeam; -}; - - - -#endif // XENSPIT_H \ No newline at end of file diff --git a/dlls/poke646/xensquasher.cpp b/dlls/poke646/xensquasher.cpp index 99ba5084..4b051717 100644 --- a/dlls/poke646/xensquasher.cpp +++ b/dlls/poke646/xensquasher.cpp @@ -39,7 +39,7 @@ enum xensquasher_e { XS_FIRE2, XS_HOLSTER, XS_DRAW, - XS_RELOAD, + XS_RELOAD }; LINK_ENTITY_TO_CLASS(weapon_xs, CXenSquasher); @@ -81,18 +81,11 @@ void CXenSquasher::Precache(void) PRECACHE_SOUND("weapons/xs_shot.wav"); PRECACHE_SOUND("weapons/xs_windup.wav"); - m_iGlow = PRECACHE_MODEL("sprites/hotglow.spr"); - m_iBalls = PRECACHE_MODEL("sprites/hotglow.spr"); - m_iBeam = PRECACHE_MODEL("sprites/smoke.spr"); - - m_usXSFire = PRECACHE_EVENT(1, "events/xs.sc"); m_usXSSpin = PRECACHE_EVENT(1, "events/xsspin.sc"); - m_usReload = PRECACHE_EVENT(1, "events/reload.sc"); PRECACHE_MODEL("sprites/glow02.spr"); - UTIL_PrecacheOther("xensmallspit"); - UTIL_PrecacheOther("xenlargespit"); + UTIL_PrecacheOther("xs_beam"); } int CXenSquasher::AddToPlayer(CBasePlayer *pPlayer) @@ -168,7 +161,7 @@ void CXenSquasher::PrimaryAttack() StartFire(); m_fInAttack = 0; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; + m_flTimeWeaponIdle = gpGlobals->time + 1.0; // m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.2; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.45; } @@ -205,24 +198,24 @@ void CXenSquasher::SecondaryAttack() m_fPrimaryFire = FALSE; m_iClip--;// take one ammo just to start the spin - m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase(); + m_pPlayer->m_flNextAmmoBurn = gpGlobals->time; // spin up m_pPlayer->m_iWeaponVolume = XS_PRIMARY_CHARGE_VOLUME; SendWeaponAnim(XS_SPINUP); m_fInAttack = 1; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; + m_flTimeWeaponIdle = gpGlobals->time + 0.5; m_pPlayer->m_flStartCharge = gpGlobals->time; - m_pPlayer->m_flAmmoStartCharge = UTIL_WeaponTimeBase() + GetFullChargeTime(); + m_pPlayer->m_flAmmoStartCharge = gpGlobals->time + GetFullChargeTime(); - PLAYBACK_EVENT_FULL(FEV_NOTHOST, m_pPlayer->edict(), m_usXSSpin, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 110, 0, 0, 0); + PLAYBACK_EVENT_FULL(0, m_pPlayer->edict(), m_usXSSpin, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 110, 0, 0, 0); m_iSoundState = SND_CHANGE_PITCH; } else if (m_fInAttack == 1) { - if (m_flTimeWeaponIdle < UTIL_WeaponTimeBase()) + if (m_flTimeWeaponIdle < gpGlobals->time) { SendWeaponAnim(XS_SPIN); m_fInAttack = 2; @@ -231,10 +224,10 @@ void CXenSquasher::SecondaryAttack() else { // 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) + if (gpGlobals->time >= m_pPlayer->m_flNextAmmoBurn && m_pPlayer->m_flNextAmmoBurn != 1000) { m_iClip--; - m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase() + 0.3; + m_pPlayer->m_flNextAmmoBurn = gpGlobals->time + 0.3; } if (m_iClip <= 0) @@ -242,12 +235,12 @@ void CXenSquasher::SecondaryAttack() // out of ammo! force the gun to fire StartFire(); m_fInAttack = 0; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; + m_flTimeWeaponIdle = gpGlobals->time + 1.0; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1; return; } - if (UTIL_WeaponTimeBase() >= m_pPlayer->m_flAmmoStartCharge) + if (gpGlobals->time >= m_pPlayer->m_flAmmoStartCharge) { // don't eat any more ammo after gun is fully charged. m_pPlayer->m_flNextAmmoBurn = 1000; @@ -262,7 +255,7 @@ void CXenSquasher::SecondaryAttack() if (m_iSoundState == 0) ALERT(at_console, "sound state %d\n", m_iSoundState); - PLAYBACK_EVENT_FULL(FEV_NOTHOST, m_pPlayer->edict(), m_usXSSpin, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, pitch, 0, (m_iSoundState == SND_CHANGE_PITCH) ? 1 : 0, 0); + PLAYBACK_EVENT_FULL(0, m_pPlayer->edict(), m_usXSSpin, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, pitch, 0, (m_iSoundState == SND_CHANGE_PITCH) ? 1 : 0, 0); m_iSoundState = SND_CHANGE_PITCH; // hack for going through level transitions @@ -276,7 +269,7 @@ void CXenSquasher::SecondaryAttack() EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/xs_moan3.wav", 1.0, ATTN_NORM, 0, 75 + RANDOM_LONG(0, 0x3f)); m_fInAttack = 0; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; + m_flTimeWeaponIdle = gpGlobals->time + 1.0; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0; #ifndef CLIENT_DLL @@ -376,13 +369,13 @@ void CXenSquasher::Fire(Vector vecOrigSrc, Vector vecDir, float flDamage) // The main firing event is sent unreliably so it won't be delayed. - PLAYBACK_EVENT_FULL(FEV_NOTHOST, m_pPlayer->edict(), m_usXSFire, 0.0, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, flDamage, 0.0, 0, 0, m_fPrimaryFire ? 1 : 0, 0); + PLAYBACK_EVENT_FULL(0, m_pPlayer->edict(), m_usXSFire, 0.0, (float *)&m_pPlayer->pev->origin, (float *)&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_usXSFire, 0.01, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, 0.0, 0.0, 0, 0, 0, 1); + PLAYBACK_EVENT_FULL(0 | FEV_RELIABLE, m_pPlayer->edict(), m_usXSFire, 0.01, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, 0.0, 0.0, 0, 0, 0, 1); /*ALERT( at_console, "%f %f %f\n%f %f %f\n", @@ -406,7 +399,7 @@ void CXenSquasher::Fire(Vector vecOrigSrc, Vector vecDir, float flDamage) pLargeSpit->pev->velocity = gpGlobals->v_forward * 800; pLargeSpit->pev->scale = 0.2f; - int iNumProjectiles = max(1, flDamage * XENSPIT_MAX_PROJECTILES / 200); + int iNumProjectiles = Q_max(1, flDamage * XENSPIT_MAX_PROJECTILES / 200); float cycle = 0; float cycleGap = 1.0f / (float)iNumProjectiles; @@ -463,14 +456,14 @@ void CXenSquasher::WeaponIdle(void) m_pPlayer->m_flPlayAftershock = 0.0; } - if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase()) + if (m_flTimeWeaponIdle > gpGlobals->time) return; if (m_fInAttack != 0) { StartFire(); m_fInAttack = 0; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0; + m_flTimeWeaponIdle = gpGlobals->time + 2.0; } else { @@ -479,20 +472,20 @@ void CXenSquasher::WeaponIdle(void) if (flRand <= 0.5) { iAnim = XS_IDLE; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + (63.0f / 15.0f); + m_flTimeWeaponIdle = gpGlobals->time + (63.0f / 15.0f); } else if (flRand <= 0.75) { iAnim = XS_IDLE2; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + (63.0f / 15.0f); + m_flTimeWeaponIdle = gpGlobals->time + (63.0f / 15.0f); } else { iAnim = XS_FIDGET; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + (93.0f / 30.0f); + m_flTimeWeaponIdle = gpGlobals->time + (93.0f / 30.0f); } - return; + //return; SendWeaponAnim(iAnim); } diff --git a/dlls/poke646/xsbeam.cpp b/dlls/poke646/xsbeam.cpp new file mode 100644 index 00000000..0a5d2ce8 --- /dev/null +++ b/dlls/poke646/xsbeam.cpp @@ -0,0 +1,213 @@ +/*** +* +* Copyright (c) 1996-2001, 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. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ + + +#include "extdll.h" +#include "util.h" +#include "cbase.h" +#include "monsters.h" +#include "weapons.h" +#include "schedule.h" +#include "nodes.h" +#include "effects.h" +#include "decals.h" +#include "soundent.h" +#include "game.h" +#include "xsbeam.h" + +LINK_ENTITY_TO_CLASS( xs_beam, CXSBeam ) + +TYPEDESCRIPTION CXSBeam::m_SaveData[] = +{ + DEFINE_FIELD( CXSBeam, m_iTrail, FIELD_INTEGER ), + DEFINE_FIELD( CXSBeam, m_iBeamCount, FIELD_INTEGER ), + DEFINE_FIELD( CXSBeam, m_flDeflectionDist, FIELD_FLOAT ), + DEFINE_FIELD( CXSBeam, m_flDmg, FIELD_FLOAT ), + DEFINE_ARRAY( CXSBeam, m_flDeflectionDot, FIELD_FLOAT, XENSQUASHER_MAX_BEAMS ), + DEFINE_FIELD( CXSBeam, m_vecOldOrigin, FIELD_VECTOR ), + DEFINE_ARRAY( CXSBeam, m_pBeam, FIELD_CLASSPTR, XENSQUASHER_MAX_BEAMS ), +}; + +IMPLEMENT_SAVERESTORE( CXSBeam, CBaseEntity ) + +void CXSBeam::Spawn() +{ + Precache(); + + pev->movetype = MOVETYPE_FLY; + pev->solid = SOLID_BBOX; + pev->gravity = 0.5f; + + SET_MODEL( ENT( pev ), "models/grenade.mdl" ); + + pev->effects |= EF_NODRAW; + + UTIL_SetSize( pev, g_vecZero, g_vecZero ); + + if( m_flDmg >= 150.0f ) + { + m_flDeflectionDist = 22.0f; + } + else if( m_flDmg >= 100.0f ) + { + m_flDeflectionDist = 17.0f; + } + else if( m_flDmg >= 50.0f ) + { + m_flDeflectionDist = 10.0f; + } + else + { + m_flDeflectionDist = 5.0f; + } + + SetTouch( &CXSBeam::BeamTouch ); + SetThink( &CXSBeam::FlyThink ); + pev->nextthink = gpGlobals->time + 0.01f; +} + +void CXSBeam::Precache() +{ + PRECACHE_MODEL( "sprites/hotglow.spr" ); + m_iTrail = PRECACHE_MODEL( "sprites/smoke.spr" ); +} + +CXSBeam* CXSBeam::CXSBeamCreate( float flDamage ) +{ + CXSBeam *pBeam = GetClassPtr( (CXSBeam *)NULL ); + pBeam->pev->classname = MAKE_STRING( "xs_beam" ); + pBeam->m_flDmg = flDamage; + pBeam->m_iBeamCount = Q_min( static_cast( ( flDamage + 50.0f ) * 0.02f ), XENSQUASHER_MAX_BEAMS ); + pBeam->Spawn(); + + return pBeam; +} + +void CXSBeam::Init() +{ + int i; + for( i = 0; i < m_iBeamCount; i++ ) + { + m_pBeam[i] = CSprite::SpriteCreate( "sprites/hotglow.spr", pev->origin, FALSE ); + if( m_pBeam[i] ) + { + m_pBeam[i]->pev->scale = 0.5; + m_pBeam[i]->SetTransparency( kRenderGlow, 255, 255, 255, 255, kRenderFxFadeFast ); + UTIL_SetOrigin( m_pBeam[i]->pev, pev->origin ); + + m_pBeam[i]->pev->spawnflags |= SF_SPRITE_TEMPORARY; + + // rocket trail + MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY, pev->origin ); + WRITE_BYTE( TE_BEAMFOLLOW ); + WRITE_SHORT( m_pBeam[i]->entindex() ); // entity + WRITE_SHORT( m_iTrail ); // model + WRITE_BYTE( 5 ); // life + WRITE_BYTE( 4 ); // width + WRITE_BYTE( 192 ); // r + WRITE_BYTE( 224 ); // g + WRITE_BYTE( 0 ); // b + WRITE_BYTE( 192 ); // brightness + MESSAGE_END(); + } + } + + if( m_iBeamCount == 3 ) + { + m_flDeflectionDot[0] = 0.0f; + m_flDeflectionDot[1] = 0.33f; + m_flDeflectionDot[2] = 0.66f; + } + else + { + m_flDeflectionDot[0] = 0.25f; + m_flDeflectionDot[1] = 0.75f; + m_flDeflectionDot[2] = 0.0f; + m_flDeflectionDot[3] = 0.5f; + } +} + +void CXSBeam::BeamTouch( CBaseEntity *pOther ) +{ + SetTouch( NULL ); + SetThink( NULL ); + + TraceResult tr = UTIL_GetGlobalTrace(); + + UTIL_DecalTrace( &tr, DECAL_SMALLSCORCH1 + RANDOM_LONG( 0, 2 ) ); + + float flRadius = m_flDmg * 0.08 + 8; + + MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin ); + WRITE_BYTE( TE_DLIGHT ); + WRITE_COORD( pev->origin.x ); // X + WRITE_COORD( pev->origin.y ); // Y + WRITE_COORD( pev->origin.z ); // Z + WRITE_BYTE( flRadius ); // radius * 0.1 + WRITE_BYTE( 192 ); // r + WRITE_BYTE( 224 ); // g + WRITE_BYTE( 0 ); // b + WRITE_BYTE( flRadius * 2.5f ); // time * 10 + WRITE_BYTE( 4 ); // decay * 0.1 + MESSAGE_END(); + + RadiusDamage( pev->origin, pev, pev, m_flDmg, 10 * flRadius, CLASS_NONE, DMG_POISON | DMG_ALWAYSGIB ); + + for( ; m_iBeamCount > 1; --m_iBeamCount ) + { + UTIL_Remove( m_pBeam[m_iBeamCount - 1] ); + } + + if( FClassnameIs( pOther->pev, "worldspawn" ) ) + { + m_pBeam[0]->pev->origin = tr.vecEndPos; + + float flQuarterRadius = flRadius / 4.0f; + m_pBeam[0]->Expand(0, 255.0f / flQuarterRadius ); + + SetThink( &CXSBeam::RemoveThink ); + pev->nextthink = gpGlobals->time + flQuarterRadius; + } + else + { + UTIL_Remove( m_pBeam[0] ); + Killed( pev, GIB_NEVER ); + } +} + +void CXSBeam::FlyThink() +{ + int i; + float flCenter; + + UTIL_MakeVectors( pev->angles ); + + flCenter = ( pev->origin - m_vecOldOrigin ).Length() * 0.01f; + + for( i = 0; i < m_iBeamCount; i++ ) + { + float flDist = m_flDeflectionDot[i] * 360.0f * ( M_PI / 180.0f ) + flCenter; + Vector vecSin = sin( flDist ) * m_flDeflectionDist * gpGlobals->v_up; + Vector vecCos = cos( flDist ) * m_flDeflectionDist * gpGlobals->v_right; + m_pBeam[i]->pev->origin = pev->origin + vecSin + vecCos; + } + pev->nextthink = gpGlobals->time + 0.05f; +} + +void CXSBeam::RemoveThink() +{ + SetThink( NULL ); + Killed( pev, GIB_NEVER ); +} diff --git a/dlls/poke646/pipebomb.h b/dlls/poke646/xsbeam.h similarity index 50% rename from dlls/poke646/pipebomb.h rename to dlls/poke646/xsbeam.h index 6a16cafd..fc79d7ac 100644 --- a/dlls/poke646/pipebomb.h +++ b/dlls/poke646/xsbeam.h @@ -12,35 +12,34 @@ * without written permission from Valve LLC. * ****/ - -#ifndef PIPEBOMBGRENADE_H -#define PIPEBOMBGRENADE_H - -#ifdef _WIN32 #pragma once -#endif +#ifndef XSBEAM_H +#define XSBEAM_H -class CPipeBombGrenade : public CGrenade +#define XENSQUASHER_MAX_BEAMS 4 + +class CXSBeam : public CBaseEntity { public: + void Spawn(); + void Precache(); - void Spawn(void); - void Precache(void); - void BounceSound(void); + static CXSBeam* CXSBeamCreate( float flDamage ); + void Init(); + void EXPORT BeamTouch(CBaseEntity *pOther); + void EXPORT FlyThink(); + void EXPORT RemoveThink(); - void EXPORT BombSlide(CBaseEntity *pOther); - void EXPORT BombThink(void); - void EXPORT PickupTouch(CBaseEntity* pOther); - - virtual int Save(CSave &save); - virtual int Restore(CRestore &restore); + int Save(CSave &save); + int Restore(CRestore &restore); static TYPEDESCRIPTION m_SaveData[]; - - EHANDLE m_hOwner; - -public: - void Deactivate(void); + int m_iTrail; + int m_iBeamCount; + float m_flDmg; + float m_flDeflectionDist; + float m_flDeflectionDot[XENSQUASHER_MAX_BEAMS]; + Vector m_vecOldOrigin; + CSprite *m_pBeam[XENSQUASHER_MAX_BEAMS]; }; - -#endif // PIPEBOMBGRENADE_H \ No newline at end of file +#endif // XSBEAM_H diff --git a/dlls/prop.cpp b/dlls/prop.cpp index c6c4017e..7f7dba48 100644 --- a/dlls/prop.cpp +++ b/dlls/prop.cpp @@ -248,7 +248,7 @@ void CProp::MaterialSoundPrecache( Materials precacheMaterial ) for( i = 0; i < soundCount; i++ ) { - PRECACHE_SOUND( (char *)pSoundList[i] ); + PRECACHE_SOUND( pSoundList[i] ); } } @@ -327,8 +327,8 @@ void CProp::Precache( void ) if( m_iszGibModel ) pGibName = STRING( m_iszGibModel ); - m_idShard = PRECACHE_MODEL( (char *)pGibName ); - PRECACHE_MODEL( (char *)STRING( pev->model ) ); + m_idShard = PRECACHE_MODEL( pGibName ); + PRECACHE_MODEL( STRING( pev->model ) ); } void CProp::DamageSound( void ) diff --git a/dlls/python.cpp b/dlls/python.cpp index 7bb71325..90606c50 100644 --- a/dlls/python.cpp +++ b/dlls/python.cpp @@ -169,7 +169,7 @@ void CPython::PrimaryAttack() Reload(); else { - EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/357_cock1.wav", 0.8, ATTN_NORM ); + PlayEmptySound(); m_flNextPrimaryAttack = 0.15; } @@ -212,7 +212,7 @@ void CPython::PrimaryAttack() void CPython::Reload( void ) { - if( m_pPlayer->ammo_357 <= 0 ) + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == PYTHON_MAX_CLIP ) return; if( m_pPlayer->pev->fov != 0 ) @@ -227,7 +227,7 @@ void CPython::Reload( void ) #else bUseScope = g_pGameRules->IsMultiplayer(); #endif - if( DefaultReload( 6, PYTHON_RELOAD, 2.0, bUseScope ) ) + if( DefaultReload( PYTHON_MAX_CLIP, PYTHON_RELOAD, 2.0, bUseScope ) ) { m_flSoundDelay = 1.5; } diff --git a/dlls/rpg.cpp b/dlls/rpg.cpp index 057fcbd5..f5530cff 100644 --- a/dlls/rpg.cpp +++ b/dlls/rpg.cpp @@ -93,8 +93,8 @@ CRpgRocket *CRpgRocket::CreateRpgRocket( Vector vecOrigin, Vector vecAngles, CBa pRocket->pev->angles = vecAngles; pRocket->Spawn(); pRocket->SetTouch( &CRpgRocket::RocketTouch ); - pRocket->m_pLauncher = pLauncher;// remember what RPG fired me. - pRocket->m_pLauncher->m_cActiveRockets++;// register this missile as active for the launcher + pRocket->m_hLauncher = pLauncher;// remember what RPG fired me. + pLauncher->m_cActiveRockets++;// register this missile as active for the launcher pRocket->pev->owner = pOwner->edict(); return pRocket; @@ -134,10 +134,10 @@ void CRpgRocket::Spawn( void ) //========================================================= void CRpgRocket::RocketTouch( CBaseEntity *pOther ) { - if( m_pLauncher ) + if( CRpg* pLauncher = (CRpg*)( (CBaseEntity*)( m_hLauncher ) ) ) { // my launcher is still around, tell it I'm dead. - m_pLauncher->m_cActiveRockets--; + pLauncher->m_cActiveRockets--; } STOP_SOUND( edict(), CHAN_VOICE, "weapons/rocket1.wav" ); @@ -249,6 +249,11 @@ void CRpgRocket::FollowThink( void ) pev->velocity = pev->velocity * 0.2 + vecTarget * flSpeed * 0.798; if( pev->waterlevel == 0 && pev->velocity.Length() < 1500 ) { + if( CRpg *pLauncher = (CRpg*)( (CBaseEntity*)( m_hLauncher ) ) ) + { + // my launcher is still around, tell it I'm dead. + pLauncher->m_cActiveRockets--; + } Detonate(); } } diff --git a/dlls/satchel.cpp b/dlls/satchel.cpp index 48ec5b9a..4cc4ad6a 100644 --- a/dlls/satchel.cpp +++ b/dlls/satchel.cpp @@ -23,6 +23,13 @@ #include "player.h" #include "gamerules.h" +enum satchel_state +{ + SATCHEL_IDLE = 0, + SATCHEL_READY, + SATCHEL_RELOAD +}; + enum satchel_e { SATCHEL_IDLE1 = 0, @@ -40,66 +47,77 @@ enum satchel_radio_e SATCHEL_RADIO_HOLSTER }; -class CSatchelCharge : public CGrenade -{ - void Spawn( void ); - void Precache( void ); - void BounceSound( void ); - - void EXPORT SatchelSlide( CBaseEntity *pOther ); - void EXPORT SatchelThink( void ); - -public: - void Deactivate( void ); -}; - -LINK_ENTITY_TO_CLASS( monster_satchel, CSatchelCharge ) +LINK_ENTITY_TO_CLASS( monster_satchel, CPipebombCharge ) //========================================================= // Deactivate - do whatever it is we do to an orphaned // satchel when we don't want it in the world anymore. //========================================================= -void CSatchelCharge::Deactivate( void ) +void CPipebombCharge::Deactivate( void ) { pev->solid = SOLID_NOT; UTIL_Remove( this ); } -void CSatchelCharge::Spawn( void ) +void CPipebombCharge::PipebombUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +{ + pev->owner = m_hOwner->edict(); + + SetThink( &CGrenade::Detonate ); + pev->nextthink = gpGlobals->time; +} + +void CPipebombCharge::Spawn( void ) { Precache(); // motor pev->movetype = MOVETYPE_BOUNCE; pev->solid = SOLID_BBOX; - SET_MODEL( ENT( pev ), "models/w_satchel.mdl" ); + SET_MODEL( ENT( pev ), "models/w_pipebomb.mdl" ); //UTIL_SetSize( pev, Vector( -16, -16, -4 ), Vector( 16, 16, 32 ) ); // Old box -- size of headcrab monsters/players get blocked by this UTIL_SetSize( pev, Vector( -4, -4, -4 ), Vector( 4, 4, 4 ) ); // Uses point-sized, and can be stepped over UTIL_SetOrigin( pev, pev->origin ); - SetTouch( &CSatchelCharge::SatchelSlide ); - SetUse( &CGrenade::DetonateUse ); - SetThink( &CSatchelCharge::SatchelThink ); + SetTouch( &CPipebombCharge::PipebombSlide ); + SetUse( &CPipebombCharge::PipebombUse ); + SetThink( &CPipebombCharge::PipebombThink ); pev->nextthink = gpGlobals->time + 0.1; pev->gravity = 0.5; - pev->friction = 0.8; + pev->friction = 0.5; pev->dmg = gSkillData.plrDmgSatchel; // ResetSequenceInfo(); pev->sequence = 1; + m_flDropTime = gpGlobals->time; } -void CSatchelCharge::SatchelSlide( CBaseEntity *pOther ) +void CPipebombCharge::PipebombSlide( CBaseEntity *pOther ) { - entvars_t *pevOther = pOther->pev; + //entvars_t *pevOther = pOther->pev; // don't hit the guy that launched this grenade - if( pOther->edict() == pev->owner ) - return; + if( pOther->edict() == m_hOwner->edict() ) + { + if( pev->velocity.Length2D() < 10.0f + && m_flDropTime + 0.5f <= gpGlobals->time + && pOther->GiveAmmo( SATCHEL_DEFAULT_GIVE, "Satchel Charge", SATCHEL_MAX_CARRY ) != -1 ) + { + CBasePlayer *pPlayer = static_cast( pOther ); + EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM ); + + UTIL_Remove( this ); + + CPipebomb *pPipebomb = static_cast( pPlayer->GiveNamedPlayerItem( "weapon_pipebomb" ) ); + if( pPipebomb ) + pPipebomb->PipebombReload(); + } + return; + } // pev->avelocity = Vector( 300, 300, 300 ); - pev->gravity = 1;// normal gravity now + pev->gravity = 0.7f;// normal gravity now // HACKHACK - On ground isn't always set, so look for ground underneath TraceResult tr; @@ -108,22 +126,30 @@ void CSatchelCharge::SatchelSlide( CBaseEntity *pOther ) if( tr.flFraction < 1.0 ) { // add a bit of static friction - pev->velocity = pev->velocity * 0.95; + pev->velocity = pev->velocity * 0.7; pev->avelocity = pev->avelocity * 0.9; // play sliding sound, volume based on velocity } if( !( pev->flags & FL_ONGROUND ) && pev->velocity.Length2D() > 10 ) { + // 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 ) BounceSound(); } - StudioFrameAdvance(); + m_lastBounceOrigin = pev->origin; + // There is no model animation so commented this out to prevent net traffic + // StudioFrameAdvance(); } -void CSatchelCharge::SatchelThink( void ) +void CPipebombCharge::PipebombThink( void ) { - StudioFrameAdvance(); + // There is no model animation so commented this out to prevent net traffic + // StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; + if( pev->owner && m_flDropTime + 0.5f <= gpGlobals->time ) + pev->owner = 0; + if( !IsInWorld() ) { UTIL_Remove( this ); @@ -147,38 +173,38 @@ void CSatchelCharge::SatchelThink( void ) } } -void CSatchelCharge::Precache( void ) +void CPipebombCharge::Precache( void ) { - PRECACHE_MODEL( "models/grenade.mdl" ); - PRECACHE_SOUND( "weapons/g_bounce1.wav" ); - PRECACHE_SOUND( "weapons/g_bounce2.wav" ); - PRECACHE_SOUND( "weapons/g_bounce3.wav" ); + PRECACHE_SOUND( "weapons/pb_bounce1.wav" ); + PRECACHE_SOUND( "weapons/pb_bounce2.wav" ); + PRECACHE_SOUND( "weapons/pb_bounce3.wav" ); + m_iTrail = PRECACHE_MODEL( "sprites/white.spr" ); } -void CSatchelCharge::BounceSound( void ) +void CPipebombCharge::BounceSound( void ) { switch( RANDOM_LONG( 0, 2 ) ) { case 0: - EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/g_bounce1.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/pb_bounce1.wav", 1, ATTN_NORM ); break; case 1: - EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/g_bounce2.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/pb_bounce2.wav", 1, ATTN_NORM ); break; case 2: - EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/g_bounce3.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/pb_bounce3.wav", 1, ATTN_NORM ); break; } } -LINK_ENTITY_TO_CLASS( weapon_satchel, CSatchel ) +LINK_ENTITY_TO_CLASS( weapon_pipebomb, CPipebomb ) //========================================================= // CALLED THROUGH the newly-touched weapon's instance. The existing player weapon is pOriginal //========================================================= -int CSatchel::AddDuplicate( CBasePlayerItem *pOriginal ) +int CPipebomb::AddDuplicate( CBasePlayerItem *pOriginal ) { - CSatchel *pSatchel; + CPipebomb *pPipebomb; #ifdef CLIENT_DLL if( bIsMultiplayer() ) @@ -186,9 +212,9 @@ int CSatchel::AddDuplicate( CBasePlayerItem *pOriginal ) if( g_pGameRules->IsMultiplayer() ) #endif { - pSatchel = (CSatchel *)pOriginal; + pPipebomb = (CPipebomb *)pOriginal; - if( pSatchel->m_chargeReady != 0 ) + if( pPipebomb->m_chargeReady != SATCHEL_IDLE ) { // player has some satchels deployed. Refuse to add more. return FALSE; @@ -200,12 +226,12 @@ int CSatchel::AddDuplicate( CBasePlayerItem *pOriginal ) //========================================================= //========================================================= -int CSatchel::AddToPlayer( CBasePlayer *pPlayer ) +int CPipebomb::AddToPlayer( CBasePlayer *pPlayer ) { int bResult = CBasePlayerItem::AddToPlayer( pPlayer ); pPlayer->pev->weapons |= ( 1 << m_iId ); - m_chargeReady = 0;// this satchel charge weapon now forgets that any satchels are deployed by it. + m_chargeReady = SATCHEL_IDLE;// this satchel charge weapon now forgets that any satchels are deployed by it. if( bResult ) { @@ -214,29 +240,29 @@ int CSatchel::AddToPlayer( CBasePlayer *pPlayer ) return FALSE; } -void CSatchel::Spawn() +void CPipebomb::Spawn() { Precache(); m_iId = WEAPON_SATCHEL; - SET_MODEL( ENT( pev ), "models/w_satchel.mdl" ); + SET_MODEL( ENT( pev ), "models/w_pipebomb.mdl" ); m_iDefaultAmmo = SATCHEL_DEFAULT_GIVE; - + FallInit();// get ready to fall down. } -void CSatchel::Precache( void ) +void CPipebomb::Precache( void ) { - PRECACHE_MODEL( "models/v_satchel.mdl" ); - PRECACHE_MODEL( "models/v_satchel_radio.mdl" ); - PRECACHE_MODEL( "models/w_satchel.mdl" ); - PRECACHE_MODEL( "models/p_satchel.mdl" ); - PRECACHE_MODEL( "models/p_satchel_radio.mdl" ); + PRECACHE_MODEL( "models/v_pipebomb.mdl" ); + PRECACHE_MODEL( "models/v_pipebomb_watch.mdl" ); + PRECACHE_MODEL( "models/w_pipebomb.mdl" ); + PRECACHE_MODEL( "models/p_pipebomb.mdl" ); + PRECACHE_MODEL( "models/p_pipebomb_watch.mdl" ); UTIL_PrecacheOther( "monster_satchel" ); } -int CSatchel::GetItemInfo( ItemInfo *p ) +int CPipebomb::GetItemInfo( ItemInfo *p ) { p->pszName = STRING( pev->classname ); p->pszAmmo1 = "Satchel Charge"; @@ -245,7 +271,7 @@ int CSatchel::GetItemInfo( ItemInfo *p ) p->iMaxAmmo2 = -1; p->iMaxClip = WEAPON_NOCLIP; p->iSlot = 4; - p->iPosition = 1; + p->iPosition = 0; p->iFlags = ITEM_FLAG_SELECTONEMPTY | ITEM_FLAG_LIMITINWORLD | ITEM_FLAG_EXHAUSTIBLE; p->iId = m_iId = WEAPON_SATCHEL; p->iWeight = SATCHEL_WEIGHT; @@ -255,7 +281,12 @@ int CSatchel::GetItemInfo( ItemInfo *p ) //========================================================= //========================================================= -BOOL CSatchel::IsUseable( void ) +BOOL CPipebomb::IsUseable( void ) +{ + return CanDeploy(); +} + +BOOL CPipebomb::CanDeploy( void ) { if( m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] > 0 ) { @@ -263,7 +294,7 @@ BOOL CSatchel::IsUseable( void ) return TRUE; } - if( m_chargeReady != 0 ) + if( m_chargeReady ) { // player isn't carrying any satchels, but has some out return TRUE; @@ -272,37 +303,20 @@ BOOL CSatchel::IsUseable( void ) return FALSE; } -BOOL CSatchel::CanDeploy( void ) -{ - if( m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] > 0 ) - { - // player is carrying some satchels - return TRUE; - } - - if( m_chargeReady != 0 ) - { - // player isn't carrying any satchels, but has some out - return TRUE; - } - - return FALSE; -} - -BOOL CSatchel::Deploy() +BOOL CPipebomb::Deploy() { m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); if( m_chargeReady ) - return DefaultDeploy( "models/v_satchel_radio.mdl", "models/p_satchel_radio.mdl", SATCHEL_RADIO_DRAW, "hive" ); + return DefaultDeploy( "models/w_pipebomb_watch.mdl", "models/p_pipebomb_watch.mdl", SATCHEL_RADIO_DRAW, "hive" ); else - return DefaultDeploy( "models/v_satchel.mdl", "models/p_satchel.mdl", SATCHEL_DRAW, "trip" ); + return DefaultDeploy( "models/v_pipebomb.mdl", "models/w_pipebomb.mdl", SATCHEL_DRAW, "trip" ); return TRUE; } -void CSatchel::Holster( int skiplocal /* = 0 */ ) +void CPipebomb::Holster( int skiplocal /* = 0 */ ) { m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; @@ -316,80 +330,81 @@ void CSatchel::Holster( int skiplocal /* = 0 */ ) } EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM ); - if( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] && !m_chargeReady ) + if( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] && m_chargeReady != SATCHEL_READY ) { m_pPlayer->pev->weapons &= ~( 1 << WEAPON_SATCHEL ); - SetThink( &CBasePlayerItem::DestroyItem ); - pev->nextthink = gpGlobals->time + 0.1; + DestroyItem(); } } -void CSatchel::PrimaryAttack() +void CPipebomb::PrimaryAttack() { switch( m_chargeReady ) { - case 0: + case SATCHEL_IDLE: { - Throw(); + Throw(); } break; - case 1: + case SATCHEL_READY: { - SendWeaponAnim( SATCHEL_RADIO_FIRE ); + SendWeaponAnim( SATCHEL_RADIO_FIRE ); - edict_t *pPlayer = m_pPlayer->edict(); + edict_t *pPlayer = m_pPlayer->edict(); - CBaseEntity *pSatchel = NULL; + CBaseEntity *pEnt = NULL; - while( ( pSatchel = UTIL_FindEntityInSphere( pSatchel, m_pPlayer->pev->origin, 4096 ) ) != NULL ) - { - if( FClassnameIs( pSatchel->pev, "monster_satchel" ) ) + while( ( pEnt = UTIL_FindEntityInSphere( pEnt, m_pPlayer->pev->origin, 4096 ) ) != NULL ) { - if( pSatchel->pev->owner == pPlayer ) + if( FClassnameIs( pEnt->pev, "monster_satchel" ) ) { - pSatchel->Use( m_pPlayer, m_pPlayer, USE_ON, 0 ); - m_chargeReady = 2; + CPipebombCharge *pPipebomb = (CPipebombCharge *)pEnt; + if( pPipebomb->m_hOwner->edict() == pPlayer ) + { + pPipebomb->Use( m_pPlayer, m_pPlayer, USE_ON, 0 ); + } } } - } - m_chargeReady = 2; - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; - break; + m_chargeReady = SATCHEL_RELOAD; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); + m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; + break; } - case 2: + case SATCHEL_RELOAD: // we're reloading, don't allow fire break; } } -void CSatchel::SecondaryAttack( void ) +void CPipebomb::SecondaryAttack( void ) { - if( m_chargeReady != 2 ) + if( m_chargeReady != SATCHEL_RELOAD ) { Throw(); } } -void CSatchel::Throw( void ) +void CPipebomb::Throw( void ) { if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { +#ifndef CLIENT_DLL Vector vecSrc = m_pPlayer->pev->origin; Vector vecThrow = gpGlobals->v_forward * 274 + m_pPlayer->pev->velocity; -#ifndef CLIENT_DLL - CBaseEntity *pSatchel = Create( "monster_satchel", vecSrc, Vector( 0, 0, 0 ), m_pPlayer->edict() ); - pSatchel->pev->velocity = vecThrow; - pSatchel->pev->avelocity.y = 400; + CPipebombCharge *pPipebomb = (CPipebombCharge *)Create( "monster_satchel", vecSrc, g_vecZero, m_pPlayer->edict() ); + pPipebomb->pev->velocity = vecThrow; + pPipebomb->pev->avelocity.y = 400; + pPipebomb->m_hOwner = m_pPlayer; + pPipebomb->pev->owner = pPipebomb->m_hOwner->edict(); - m_pPlayer->pev->viewmodel = MAKE_STRING( "models/v_satchel_radio.mdl" ); - m_pPlayer->pev->weaponmodel = MAKE_STRING( "models/p_satchel_radio.mdl" ); + m_pPlayer->pev->viewmodel = MAKE_STRING( "models/v_pipebomb_watch.mdl" ); + m_pPlayer->pev->weaponmodel = MAKE_STRING( "models/p_pipebomb_watch.mdl" ); #else - LoadVModel( "models/v_satchel_radio.mdl", m_pPlayer ); + LoadVModel( "models/v_pipebomb_watch.mdl", m_pPlayer ); #endif SendWeaponAnim( SATCHEL_RADIO_DRAW ); @@ -397,33 +412,33 @@ void CSatchel::Throw( void ) // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); - m_chargeReady = 1; - + m_chargeReady = SATCHEL_READY; + m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1.0; + m_flNextPrimaryAttack = GetNextAttackDelay( 1.0 ); m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; } } -void CSatchel::WeaponIdle( void ) +void CPipebomb::WeaponIdle( void ) { if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) return; switch( m_chargeReady ) { - case 0: + case SATCHEL_IDLE: SendWeaponAnim( SATCHEL_FIDGET1 ); // use tripmine animations strcpy( m_pPlayer->m_szAnimExtention, "trip" ); break; - case 1: + case SATCHEL_READY: SendWeaponAnim( SATCHEL_RADIO_FIDGET1 ); // use hivehand animations strcpy( m_pPlayer->m_szAnimExtention, "hive" ); break; - case 2: + case SATCHEL_RELOAD: if( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { m_chargeReady = 0; @@ -432,31 +447,59 @@ void CSatchel::WeaponIdle( void ) } #ifndef CLIENT_DLL - m_pPlayer->pev->viewmodel = MAKE_STRING( "models/v_satchel.mdl" ); - m_pPlayer->pev->weaponmodel = MAKE_STRING( "models/p_satchel.mdl" ); + m_pPlayer->pev->viewmodel = MAKE_STRING( "models/v_pipebomb.mdl" ); + m_pPlayer->pev->weaponmodel = MAKE_STRING( "models/p_pipebomb.mdl" ); #else - LoadVModel( "models/v_satchel.mdl", m_pPlayer ); + LoadVModel( "models/v_pipebomb.mdl", m_pPlayer ); #endif SendWeaponAnim( SATCHEL_DRAW ); // use tripmine animations strcpy( m_pPlayer->m_szAnimExtention, "trip" ); - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; - m_chargeReady = 0; + m_chargeReady = SATCHEL_IDLE; break; } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );// how long till we do this again. } +void CPipebomb::PipebombReload() +{ + int i = 0; + + edict_t *pPlayer = m_pPlayer->edict(); + + CBaseEntity *pEntity = NULL; + + while( ( pEntity = UTIL_FindEntityInSphere( pEntity, m_pPlayer->pev->origin, 4096 ) ) != NULL ) + { + if( FClassnameIs( pEntity->pev, "monster_satchel" ) ) + { + CPipebombCharge *pPipebomb = (CPipebombCharge *)pEntity; + if( pPipebomb->m_hOwner->edict() == pPlayer ) + { + ++i; + } + } + } + + if( i < 2 ) + { + m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase(); + m_chargeReady = SATCHEL_RELOAD; + } +} + //========================================================= -// DeactivateSatchels - removes all satchels owned by +// DeactivatePipebombs - removes all pipebombs owned by // the provided player. Should only be used upon death. // // Made this global on purpose. //========================================================= -void DeactivateSatchels( CBasePlayer *pOwner ) +void DeactivatePipebombs( CBasePlayer *pOwner ) { edict_t *pFind; @@ -465,13 +508,13 @@ void DeactivateSatchels( CBasePlayer *pOwner ) while( !FNullEnt( pFind ) ) { CBaseEntity *pEnt = CBaseEntity::Instance( pFind ); - CSatchelCharge *pSatchel = (CSatchelCharge *)pEnt; + CPipebombCharge *pPipebomb = (CPipebombCharge *)pEnt; - if( pSatchel ) + if( pPipebomb ) { - if( pSatchel->pev->owner == pOwner->edict() ) + if( pPipebomb->m_hOwner->edict() == pOwner->edict() ) { - pSatchel->Deactivate(); + pPipebomb->Deactivate(); } } diff --git a/dlls/saverestore.h b/dlls/saverestore.h index f76613e8..81f9f131 100644 --- a/dlls/saverestore.h +++ b/dlls/saverestore.h @@ -13,6 +13,7 @@ * ****/ // Implementation in UTIL.CPP +#pragma once #ifndef SAVERESTORE_H #define SAVERESTORE_H @@ -23,7 +24,7 @@ class CSaveRestoreBuffer public: CSaveRestoreBuffer( void ); CSaveRestoreBuffer( SAVERESTOREDATA *pdata ); - ~CSaveRestoreBuffer( void ); + virtual ~CSaveRestoreBuffer( void ); int EntityIndex( entvars_t *pevLookup ); int EntityIndex( edict_t *pentLookup ); @@ -41,6 +42,10 @@ protected: SAVERESTOREDATA *m_pdata; void BufferRewind( int size ); unsigned int HashString( const char *pszToken ); +private: + // effc++ rule 11 + void operator = ( CSaveRestoreBuffer& ); + CSaveRestoreBuffer( const CSaveRestoreBuffer& ); }; class CSave : public CSaveRestoreBuffer @@ -59,7 +64,7 @@ public: void WriteVector( const char *pname, const float *value, int count ); // Save a vector void WritePositionVector( const char *pname, const Vector &value ); // Offset for landmark if necessary void WritePositionVector( const char *pname, const float *value, int count ); // array of pos vectors - void WriteFunction( const char *pname, const int *value, int count ); // Save a function pointer + void WriteFunction( const char *pname, void **value, int count ); // Save a function pointer int WriteEntVars( const char *pname, entvars_t *pev ); // Save entvars_t (entvars_t) int WriteFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); @@ -81,7 +86,7 @@ typedef struct class CRestore : public CSaveRestoreBuffer { public: - CRestore( SAVERESTOREDATA *pdata ) : CSaveRestoreBuffer( pdata ) { m_global = 0; m_precache = TRUE; } + CRestore( SAVERESTOREDATA *pdata ) : CSaveRestoreBuffer( pdata ), m_global(0), m_precache( TRUE ) { } int ReadEntVars( const char *pname, entvars_t *pev ); // entvars_t int ReadFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); int ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount, int startField, int size, char *pName, void *pData ); @@ -160,6 +165,9 @@ private: globalentity_t *Find( string_t globalname ); globalentity_t *m_pList; int m_listCount; + // effc++ rule 11 + void operator = ( CGlobalState& ); + CGlobalState( const CGlobalState& ); }; extern CGlobalState gGlobalState; diff --git a/dlls/schedule.cpp b/dlls/schedule.cpp index c28a88fa..4a5cefca 100644 --- a/dlls/schedule.cpp +++ b/dlls/schedule.cpp @@ -238,7 +238,7 @@ void CBaseMonster::MaintainSchedule( void ) { if( (m_afConditions && !HasConditions( bits_COND_SCHEDULE_DONE ) ) || ( m_pSchedule && (m_pSchedule->iInterruptMask & bits_COND_SCHEDULE_DONE ) ) || - ( ( m_MonsterState == MONSTERSTATE_COMBAT ) && ( m_hEnemy == NULL ) ) ) + ( ( m_MonsterState == MONSTERSTATE_COMBAT ) && ( m_hEnemy == 0 ) ) ) { GetIdealState(); } @@ -407,7 +407,7 @@ void CBaseMonster::RunTask( Task_t *pTask ) { float distance; - if( m_hTargetEnt == NULL ) + if( m_hTargetEnt == 0 ) TaskFail(); else { @@ -675,7 +675,7 @@ void CBaseMonster::StartTask( Task_t *pTask ) } case TASK_FIND_NEAR_NODE_COVER_FROM_ENEMY: { - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { TaskFail(); return; @@ -695,7 +695,7 @@ void CBaseMonster::StartTask( Task_t *pTask ) } case TASK_FIND_FAR_NODE_COVER_FROM_ENEMY: { - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { TaskFail(); return; @@ -715,7 +715,7 @@ void CBaseMonster::StartTask( Task_t *pTask ) } case TASK_FIND_NODE_COVER_FROM_ENEMY: { - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { TaskFail(); return; @@ -737,7 +737,7 @@ void CBaseMonster::StartTask( Task_t *pTask ) { entvars_t *pevCover; - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { // Find cover from self if no enemy available pevCover = pev; @@ -821,7 +821,7 @@ void CBaseMonster::StartTask( Task_t *pTask ) SetTurnActivity(); break; case TASK_FACE_TARGET: - if( m_hTargetEnt != NULL ) + if( m_hTargetEnt != 0 ) { MakeIdealYaw( m_hTargetEnt->pev->origin ); SetTurnActivity(); @@ -904,7 +904,7 @@ void CBaseMonster::StartTask( Task_t *pTask ) TaskComplete(); else { - if( m_hTargetEnt == NULL || !MoveToTarget( newActivity, 2 ) ) + if( m_hTargetEnt == 0 || !MoveToTarget( newActivity, 2 ) ) { TaskFail(); ALERT( at_aiconsole, "%s Failed to reach target!!!\n", STRING( pev->classname ) ); @@ -1043,7 +1043,7 @@ void CBaseMonster::StartTask( Task_t *pTask ) case TASK_GET_PATH_TO_TARGET: { RouteClear(); - if( m_hTargetEnt != NULL && MoveToTarget( m_movementActivity, 1 ) ) + if( m_hTargetEnt != 0 && MoveToTarget( m_movementActivity, 1 ) ) { TaskComplete(); } @@ -1272,7 +1272,7 @@ void CBaseMonster::StartTask( Task_t *pTask ) } case TASK_PLANT_ON_SCRIPT: { - if( m_hTargetEnt != NULL ) + if( m_hTargetEnt != 0 ) { pev->origin = m_hTargetEnt->pev->origin; // Plant on target } @@ -1282,7 +1282,7 @@ void CBaseMonster::StartTask( Task_t *pTask ) } case TASK_FACE_SCRIPT: { - if( m_hTargetEnt != NULL ) + if( m_hTargetEnt != 0 ) { pev->ideal_yaw = UTIL_AngleMod( m_hTargetEnt->pev->angles.y ); } diff --git a/dlls/schedule.h b/dlls/schedule.h index 0c4fb1ce..3373ab32 100644 --- a/dlls/schedule.h +++ b/dlls/schedule.h @@ -15,7 +15,7 @@ //========================================================= // Scheduling //========================================================= - +#pragma once #ifndef SCHEDULE_H #define SCHEDULE_H @@ -86,87 +86,87 @@ typedef enum TASK_WAIT_FACE_ENEMY, TASK_WAIT_PVS, TASK_SUGGEST_STATE, - TASK_WALK_TO_TARGET, + TASK_WALK_TO_TARGET, //5 TASK_RUN_TO_TARGET, TASK_MOVE_TO_TARGET_RANGE, TASK_GET_PATH_TO_ENEMY, TASK_GET_PATH_TO_ENEMY_LKP, - TASK_GET_PATH_TO_ENEMY_CORPSE, + TASK_GET_PATH_TO_ENEMY_CORPSE, //10 TASK_GET_PATH_TO_LEADER, TASK_GET_PATH_TO_SPOT, TASK_GET_PATH_TO_TARGET, TASK_GET_PATH_TO_HINTNODE, - TASK_GET_PATH_TO_LASTPOSITION, + TASK_GET_PATH_TO_LASTPOSITION, //15 TASK_GET_PATH_TO_BESTSOUND, TASK_GET_PATH_TO_BESTSCENT, TASK_RUN_PATH, TASK_WALK_PATH, - TASK_STRAFE_PATH, + TASK_STRAFE_PATH, //20 TASK_CLEAR_MOVE_WAIT, TASK_STORE_LASTPOSITION, TASK_CLEAR_LASTPOSITION, TASK_PLAY_ACTIVE_IDLE, - TASK_FIND_HINTNODE, + TASK_FIND_HINTNODE, //25 TASK_CLEAR_HINTNODE, TASK_SMALL_FLINCH, TASK_FACE_IDEAL, TASK_FACE_ROUTE, - TASK_FACE_ENEMY, + TASK_FACE_ENEMY, //30 TASK_FACE_HINTNODE, TASK_FACE_TARGET, TASK_FACE_LASTPOSITION, TASK_RANGE_ATTACK1, - TASK_RANGE_ATTACK2, + TASK_RANGE_ATTACK2, //35 TASK_MELEE_ATTACK1, TASK_MELEE_ATTACK2, TASK_RELOAD, TASK_RANGE_ATTACK1_NOTURN, - TASK_RANGE_ATTACK2_NOTURN, + TASK_RANGE_ATTACK2_NOTURN, //40 TASK_MELEE_ATTACK1_NOTURN, TASK_MELEE_ATTACK2_NOTURN, TASK_RELOAD_NOTURN, TASK_SPECIAL_ATTACK1, - TASK_SPECIAL_ATTACK2, + TASK_SPECIAL_ATTACK2, //45 TASK_CROUCH, TASK_STAND, TASK_GUARD, TASK_STEP_LEFT, - TASK_STEP_RIGHT, + TASK_STEP_RIGHT, //50 TASK_STEP_FORWARD, TASK_STEP_BACK, TASK_DODGE_LEFT, TASK_DODGE_RIGHT, - TASK_SOUND_ANGRY, + TASK_SOUND_ANGRY, //55 TASK_SOUND_DEATH, TASK_SET_ACTIVITY, TASK_SET_SCHEDULE, TASK_SET_FAIL_SCHEDULE, - TASK_CLEAR_FAIL_SCHEDULE, - TASK_PLAY_SEQUENCE, + TASK_CLEAR_FAIL_SCHEDULE,// 60 + TASK_PLAY_SEQUENCE, TASK_PLAY_SEQUENCE_FACE_ENEMY, TASK_PLAY_SEQUENCE_FACE_TARGET, TASK_SOUND_IDLE, - TASK_SOUND_WAKE, + TASK_SOUND_WAKE, //65 TASK_SOUND_PAIN, TASK_SOUND_DIE, TASK_FIND_COVER_FROM_BEST_SOUND,// tries lateral cover first, then node cover TASK_FIND_COVER_FROM_ENEMY,// tries lateral cover first, then node cover - TASK_FIND_LATERAL_COVER_FROM_ENEMY, - TASK_FIND_NODE_COVER_FROM_ENEMY, + TASK_FIND_LATERAL_COVER_FROM_ENEMY, //70 + TASK_FIND_NODE_COVER_FROM_ENEMY, TASK_FIND_NEAR_NODE_COVER_FROM_ENEMY,// data for this one is the MAXIMUM acceptable distance to the cover. TASK_FIND_FAR_NODE_COVER_FROM_ENEMY,// data for this one is there MINIMUM aceptable distance to the cover. TASK_FIND_COVER_FROM_ORIGIN, - TASK_EAT, + TASK_EAT, //75 TASK_DIE, TASK_WAIT_FOR_SCRIPT, TASK_PLAY_SCRIPT, TASK_ENABLE_SCRIPT, - TASK_PLANT_ON_SCRIPT, + TASK_PLANT_ON_SCRIPT, //80 TASK_FACE_SCRIPT, TASK_WAIT_RANDOM, TASK_WAIT_INDEFINITE, TASK_STOP_MOVING, - TASK_TURN_LEFT, + TASK_TURN_LEFT, //85 TASK_TURN_RIGHT, TASK_REMEMBER, TASK_FORGET, diff --git a/dlls/scientist.cpp b/dlls/scientist.cpp index 4e60c58e..8016499b 100644 --- a/dlls/scientist.cpp +++ b/dlls/scientist.cpp @@ -434,7 +434,7 @@ void CScientist::Scream( void ) Activity CScientist::GetStoppedActivity( void ) { - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) return ACT_EXCITED; return CTalkMonster::GetStoppedActivity(); } @@ -464,7 +464,10 @@ void CScientist::StartTask( Task_t *pTask ) { Talk( 2 ); m_hTalkTarget = m_hEnemy; - if( m_hEnemy->IsPlayer() ) + + //The enemy can be null here. - Solokiller + //Discovered while testing the barnacle grapple on headcrabs with scientists in view. + if( m_hEnemy != 0 && m_hEnemy->IsPlayer() ) PlaySentence( "SC_PLFEAR", 5, VOL_NORM, ATTN_NORM ); else PlaySentence( "SC_FEAR", 5, VOL_NORM, ATTN_NORM ); @@ -510,7 +513,7 @@ void CScientist::RunTask( Task_t *pTask ) if( RANDOM_LONG( 0, 63 ) < 8 ) Scream(); - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { TaskFail(); } @@ -893,8 +896,8 @@ Schedule_t *CScientist::GetSchedule( void ) m_fearTime = gpGlobals->time; else if( DisregardEnemy( pEnemy ) ) // After 15 seconds of being hidden, return to alert { - m_hEnemy = NULL; - pEnemy = NULL; + m_hEnemy = 0; + pEnemy = 0; } } @@ -1021,12 +1024,12 @@ MONSTERSTATE CScientist::GetIdealState( void ) { // Strip enemy when going to alert m_IdealMonsterState = MONSTERSTATE_ALERT; - m_hEnemy = NULL; + m_hEnemy = 0; return m_IdealMonsterState; } // Follow if only scared a little - if( m_hTargetEnt != NULL ) + if( m_hTargetEnt != 0 ) { m_IdealMonsterState = MONSTERSTATE_ALERT; return m_IdealMonsterState; @@ -1049,11 +1052,8 @@ MONSTERSTATE CScientist::GetIdealState( void ) } BOOL CScientist::CanHeal( void ) -{ - if( ( m_healTime > gpGlobals->time ) || ( m_hTargetEnt == NULL ) || ( m_hTargetEnt->pev->health > ( m_hTargetEnt->pev->max_health * 0.5 ) ) ) - return FALSE; - - return TRUE; +{ + return FALSE; } void CScientist::Heal( void ) @@ -1093,10 +1093,10 @@ public: void KeyValue( KeyValueData *pkvd ); int m_iPose;// which sequence to display - static char *m_szPoses[7]; + static const char *m_szPoses[7]; }; -char *CDeadScientist::m_szPoses[] = +const char *CDeadScientist::m_szPoses[] = { "lying_on_back", "lying_on_stomach", diff --git a/dlls/scripted.cpp b/dlls/scripted.cpp index f3cf37c5..41638b39 100644 --- a/dlls/scripted.cpp +++ b/dlls/scripted.cpp @@ -712,7 +712,7 @@ void CCineMonster::DelayStart( int state ) else { pTarget->m_iDelay--; - if (pTarget->m_iDelay <= 0) + if( pTarget->m_iDelay <= 0 ) pTarget->m_startTime = gpGlobals->time + 0.05; } } @@ -907,15 +907,15 @@ public: BOOL StartSentence( CBaseMonster *pTarget ); private: - int m_iszSentence; // string index for idle animation - int m_iszEntity; // entity that is wanted for this sentence + string_t m_iszSentence; // string index for idle animation + string_t m_iszEntity; // entity that is wanted for this sentence float m_flRadius; // range to search float m_flDuration; // How long the sentence lasts float m_flRepeat; // repeat rate float m_flAttenuation; float m_flVolume; BOOL m_active; - int m_iszListener; // name of entity to look at while talking + string_t m_iszListener; // name of entity to look at while talking }; #define SF_SENTENCE_ONCE 0x0001 @@ -1068,7 +1068,7 @@ BOOL CScriptedSentence::AcceptableSpeaker( CBaseMonster *pMonster ) { if( pev->spawnflags & SF_SENTENCE_FOLLOWERS ) { - if( pMonster->m_hTargetEnt == NULL || !FClassnameIs( pMonster->m_hTargetEnt->pev, "player" ) ) + if( pMonster->m_hTargetEnt == 0 || !FClassnameIs( pMonster->m_hTargetEnt->pev, "player" ) ) return FALSE; } BOOL override; @@ -1124,7 +1124,7 @@ BOOL CScriptedSentence::StartSentence( CBaseMonster *pTarget ) if( !pTarget ) { ALERT( at_aiconsole, "Not Playing sentence %s\n", STRING( m_iszSentence ) ); - return NULL; + return FALSE; } BOOL bConcurrent = FALSE; @@ -1177,7 +1177,7 @@ void CFurniture::Die( void ) //========================================================= void CFurniture::Spawn() { - PRECACHE_MODEL( (char *)STRING( pev->model ) ); + PRECACHE_MODEL( STRING( pev->model ) ); SET_MODEL( ENT( pev ), STRING( pev->model ) ); pev->movetype = MOVETYPE_NONE; diff --git a/dlls/scripted.h b/dlls/scripted.h index 25348114..59b696f7 100644 --- a/dlls/scripted.h +++ b/dlls/scripted.h @@ -12,6 +12,7 @@ * use or distribution of this code by or to any unlicensed person is illegal. * ****/ +#pragma once #ifndef SCRIPTED_H #define SCRIPTED_H @@ -77,9 +78,9 @@ public: void AllowInterrupt( BOOL fAllow ); int IgnoreConditions( void ); - int m_iszIdle; // string index for idle animation - int m_iszPlay; // string index for scripted animation - int m_iszEntity; // entity that is wanted for this script + string_t m_iszIdle; // string index for idle animation + string_t m_iszPlay; // string index for scripted animation + string_t m_iszEntity; // entity that is wanted for this script int m_fMoveTo; int m_iFinishSchedule; float m_flRadius; // range to search diff --git a/dlls/scriptevent.h b/dlls/scriptevent.h index 714ac99c..18436a26 100644 --- a/dlls/scriptevent.h +++ b/dlls/scriptevent.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef SCRIPTEVENT_H #define SCRIPTEVENT_H @@ -26,4 +27,4 @@ #define SCRIPT_EVENT_SOUND_VOICE 1008 // Play named wave file (on CHAN_VOICE) #define SCRIPT_EVENT_SENTENCE_RND1 1009 // Play sentence group 25% of the time #define SCRIPT_EVENT_NOT_DEAD 1010 // Bring back to life (for life/death sequences) -#endif //SCRIPTEVENT_H +#endif // SCRIPTEVENT_H diff --git a/dlls/shotgun.cpp b/dlls/shotgun.cpp index 943e0d05..ba08f6f8 100644 --- a/dlls/shotgun.cpp +++ b/dlls/shotgun.cpp @@ -59,6 +59,8 @@ void CShotgun::Precache( void ) m_iShell = PRECACHE_MODEL( "models/shotgunshell.mdl" );// shotgun shell + PRECACHE_MODEL( "sprites/wallsmoke.spr" ); + PRECACHE_SOUND( "items/9mmclip1.wav" ); PRECACHE_SOUND( "weapons/dbarrel1.wav" );//shotgun @@ -74,7 +76,6 @@ void CShotgun::Precache( void ) PRECACHE_SOUND( "weapons/scock1.wav" ); // cock gun m_usSingleFire = PRECACHE_EVENT( 1, "events/shotgun1.sc" ); - m_usDoubleFire = PRECACHE_EVENT( 1, "events/shotgun2.sc" ); } int CShotgun::AddToPlayer( CBasePlayer *pPlayer ) @@ -121,11 +122,10 @@ void CShotgun::PrimaryAttack() return; } - if( m_iClip <= 0 ) + if( m_iClip <= 1 ) { Reload(); - if( m_iClip == 0 ) - PlayEmptySound(); + PlayEmptySound(); return; } @@ -143,6 +143,9 @@ void CShotgun::PrimaryAttack() m_pPlayer->pev->effects = (int)( m_pPlayer->pev->effects ) | EF_MUZZLEFLASH; + // player "shoot" animation + m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); + Vector vecSrc = m_pPlayer->GetGunPosition(); Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES ); @@ -152,24 +155,21 @@ void CShotgun::PrimaryAttack() PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usSingleFire, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, 0, 0 ); - m_flNextPrimaryAttack = GetNextAttackDelay( 1.15 ); - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.15; + m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.2; if( m_iClip != 0 ) - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5.0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 6.0; else - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.15; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.2; m_fInSpecialReload = 0; UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle ); - // Take the inverse forward unit vector and zero out z. - // Only horizontal impulse allowed. - Vector vecImpulse = -gpGlobals->v_forward; - vecImpulse.z = 0; + Vector oldVelocity = m_pPlayer->pev->velocity; // Send player impulse. - m_pPlayer->pev->velocity = m_pPlayer->pev->velocity + vecImpulse * 200; + m_pPlayer->pev->velocity = m_pPlayer->pev->velocity - gpGlobals->v_forward * 200; + m_pPlayer->pev->velocity = m_pPlayer->pev->velocity - ( m_pPlayer->pev->velocity - oldVelocity ) * 0.5f; } void CShotgun::SecondaryAttack( void ) @@ -190,10 +190,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 = UTIL_WeaponTimeBase() + 1.0; - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0; + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.4; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.4; + m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.8; + m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.8; return; } else if( m_fInSpecialReload == 1 ) @@ -222,6 +222,16 @@ void CShotgun::Reload( void ) } } +void CShotgun::WeaponTick() +{ + if( m_flPumpTime && m_flPumpTime < gpGlobals->time ) + { + // play pumping sound + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/scock1.wav", 1, ATTN_NORM, 0, 95 + RANDOM_LONG( 0, 0x1f ) ); + m_flPumpTime = 0; + } +} + void CShotgun::WeaponIdle( void ) { ResetEmptySound(); diff --git a/dlls/skill.cpp b/dlls/skill.cpp index 2a68e1a5..689bbadb 100644 --- a/dlls/skill.cpp +++ b/dlls/skill.cpp @@ -25,13 +25,12 @@ skilldata_t gSkillData; // take the name of a cvar, tack a digit for the skill level // on, and return the value.of that Cvar //========================================================= -float GetSkillCvar( char *pName ) +float GetSkillCvar( const char *pName ) { - int iCount; float flValue; char szBuffer[64]; - iCount = sprintf( szBuffer, "%s%d",pName, gSkillData.iSkillLevel ); + sprintf( szBuffer, "%s%d",pName, gSkillData.iSkillLevel ); flValue = CVAR_GET_FLOAT( szBuffer ); diff --git a/dlls/skill.h b/dlls/skill.h index 733a5269..aa605f03 100644 --- a/dlls/skill.h +++ b/dlls/skill.h @@ -15,13 +15,16 @@ //========================================================= // skill.h - skill level concerns //========================================================= +#pragma once +#ifndef SKILL_H +#define SKILL_H struct skilldata_t { int iSkillLevel; // game skill level // Monster Health & Damage - float agruntHealth; + float agruntHealth; float agruntDmgPunch; float apacheHealth; @@ -138,17 +141,14 @@ struct skilldata_t float plrStomach; float plrLeg; float plrArm; - - float plrDmgNail; - - float plrDmgPar21; }; extern DLL_GLOBAL skilldata_t gSkillData; -float GetSkillCvar( char *pName ); +float GetSkillCvar( const char *pName ); extern DLL_GLOBAL int g_iSkillLevel; #define SKILL_EASY 1 #define SKILL_MEDIUM 2 #define SKILL_HARD 3 +#endif // SKILL_H diff --git a/dlls/sound.cpp b/dlls/sound.cpp index 0eb49056..d5b2def4 100644 --- a/dlls/sound.cpp +++ b/dlls/sound.cpp @@ -182,7 +182,7 @@ void CAmbientGeneric::Spawn( void ) m_flAttenuation = ATTN_STATIC; } - char* szSoundFile = (char*)STRING( pev->message ); + const char *szSoundFile = STRING( pev->message ); if( FStringNull( pev->message ) || strlen( szSoundFile ) < 1 ) { @@ -216,7 +216,7 @@ void CAmbientGeneric::Spawn( void ) void CAmbientGeneric::Precache( void ) { - char* szSoundFile = (char*)STRING( pev->message ); + const char *szSoundFile = STRING( pev->message ); if( !FStringNull( pev->message ) && strlen( szSoundFile ) > 1 ) { @@ -248,7 +248,7 @@ void CAmbientGeneric::Precache( void ) // with lfo if active. void CAmbientGeneric::RampThink( void ) { - char* szSoundFile = (char*) STRING(pev->message); + const char *szSoundFile = STRING( pev->message ); int pitch = m_dpv.pitch; int vol = m_dpv.vol; int flags = 0; @@ -448,7 +448,7 @@ void CAmbientGeneric::InitModulationParms( void ) { int pitchinc; - m_dpv.volrun = pev->health * 10; // 0 - 100 + m_dpv.volrun = (int)( pev->health * 10 ); // 0 - 100 if( m_dpv.volrun > 100 ) m_dpv.volrun = 100; if( m_dpv.volrun < 0 ) @@ -533,7 +533,7 @@ void CAmbientGeneric::InitModulationParms( void ) // void CAmbientGeneric::ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - char* szSoundFile = (char*)STRING( pev->message ); + const char *szSoundFile = STRING( pev->message ); float fraction; if( useType != USE_TOGGLE ) @@ -553,7 +553,7 @@ void CAmbientGeneric::ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, if( fraction < 0.0 ) fraction = 0.01; - m_dpv.pitch = fraction * 255; + m_dpv.pitch = (int)( fraction * 255 ); UTIL_EmitAmbientSound( ENT( pev ), pev->origin, szSoundFile, 0, 0, SND_CHANGE_PITCH, m_dpv.pitch ); return; @@ -980,6 +980,52 @@ void CEnvSound::Spawn() pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 0.0, 0.5 ); } +int g_soundtrackCount; +soundtrack_t g_soundtracklist[30]; + +void SOUNDTRACKLIST_Init() +{ + char buffer[512] = {0,}; + int i, j = 0; + byte *pMemFile; + int fileSize, filePos = 0; + + pMemFile = g_engfuncs.pfnLoadFileForMe( "sound/soundtrack.txt", &fileSize ); + if( !pMemFile ) + return; + + // for each line in the file... + while( memfgets( pMemFile, fileSize, filePos, buffer, 511 ) != NULL && j < 30 ) + { + char *pos; + + // skip whitespace + i = 0; + while( buffer[i] && isspace( buffer[i] ) ) + i++; + + if( !buffer[i] ) + continue; + + // skip comment lines + if( buffer[i] == '/' ) + continue; + + if( 3 > sscanf( &buffer[i], "\"%31[^\"]\" \"%31[^\"]\" \"%d\" ", \ + g_soundtracklist[j].mapname, g_soundtracklist[j].soundfile, &g_soundtracklist[j].loop ) ) + continue; + + pos = strchr( g_soundtracklist[j].mapname, '.' ); + *pos = '\0'; + + j++; + } + + g_soundtrackCount = j; + + g_engfuncs.pfnFreeFile( pMemFile ); +} + // ==================== SENTENCE GROUPS, UTILITY FUNCTIONS ====================================== #define CSENTENCE_LRU_MAX 32 // max number of elements per sentence group @@ -1454,14 +1500,6 @@ void EMIT_GROUPNAME_SUIT( edict_t *entity, const char *groupname ) // texture name to a material type. Play footstep sound based // on material type. -int fTextureTypeInit = FALSE; - -#define CTEXTURESMAX 512 // max number of textures loaded - -int gcTextures = 0; -char grgszTextureName[CTEXTURESMAX][CBTEXTURENAMEMAX]; // texture names -char grgchTextureType[CTEXTURESMAX]; // parallel array of texture types - // open materials.txt, get size, alloc space, // save in array. Only works first time called, // ignored on subsequent calls. @@ -1513,87 +1551,17 @@ static char *memfgets( byte *pMemFile, int fileSize, int &filePos, char *pBuffer return NULL; } -void TEXTURETYPE_Init() -{ - char buffer[512]; - int i, j; - byte *pMemFile; - int fileSize, filePos = 0; - - if( fTextureTypeInit ) - return; - - memset( &( grgszTextureName[0][0] ), 0, CTEXTURESMAX * CBTEXTURENAMEMAX ); - memset( grgchTextureType, 0, CTEXTURESMAX ); - - gcTextures = 0; - - pMemFile = g_engfuncs.pfnLoadFileForMe( "sound/materials.txt", &fileSize ); - if( !pMemFile ) - return; - - memset( buffer, 0, 512 ); - // for each line in the file... - while( memfgets( pMemFile, fileSize, filePos, buffer, 511 ) != NULL && ( gcTextures < CTEXTURESMAX) ) - { - // skip whitespace - i = 0; - while( buffer[i] && isspace( buffer[i] ) ) - i++; - - if( !buffer[i] ) - continue; - - // skip comment lines - if( buffer[i] == '/' || !isalpha( buffer[i] ) ) - continue; - - // get texture type - grgchTextureType[gcTextures] = toupper( buffer[i++] ); - - // skip whitespace - while( buffer[i] && isspace( buffer[i] ) ) - i++; - - if( !buffer[i] ) - continue; - - // get sentence name - j = i; - while( buffer[j] && !isspace( buffer[j] ) ) - j++; - - if( !buffer[j] ) - continue; - - // null-terminate name and save in sentences array - j = min( j, CBTEXTURENAMEMAX - 1 + i ); - buffer[j] = 0; - strcpy( &( grgszTextureName[gcTextures++][0] ), &( buffer[i] ) ); - } - - g_engfuncs.pfnFreeFile( pMemFile ); - - fTextureTypeInit = TRUE; -} - // given texture name, find texture type // if not found, return type 'concrete' // NOTE: this routine should ONLY be called if the // current texture under the player changes! +extern "C" char PM_FindTextureType( char *name ); + char TEXTURETYPE_Find( char *name ) { - // CONSIDER: pre-sort texture names and perform faster binary search here - - for( int i = 0; i < gcTextures; i++ ) - { - if( !strnicmp( name, &( grgszTextureName[i][0] ), CBTEXTURENAMEMAX - 1 ) ) - return grgchTextureType[i]; - } - - return CHAR_TEX_CONCRETE; + return PM_FindTextureType(name); } // play a strike sound based on the texture that was hit by the attack traceline. VecSrc/VecEnd are the @@ -1610,7 +1578,7 @@ float TEXTURETYPE_PlaySound( TraceResult *ptr, Vector vecSrc, Vector vecEnd, in const char *pTextureName; float rgfl1[3]; float rgfl2[3]; - char *rgsz[4]; + const char *rgsz[4]; int cnt; float fattn = ATTN_NORM; @@ -1739,16 +1707,8 @@ float TEXTURETYPE_PlaySound( TraceResult *ptr, Vector vecSrc, Vector vecEnd, in return 0.0; // crowbar already makes this sound fvol = 1.0; fvolbar = 0.2; - if( iBulletType == BULLET_PLAYER_NAIL ) - { - rgsz[0] = "weapons/brad_hit1.wav"; - rgsz[1] = "weapons/brad_hit2.wav"; - } - else - { - rgsz[0] = "weapons/bullet_hit1.wav"; - rgsz[1] = "weapons/bullet_hit2.wav"; - } + rgsz[0] = "weapons/bullet_hit1.wav"; + rgsz[1] = "weapons/bullet_hit2.wav"; fattn = 1.0; cnt = 2; break; @@ -1830,7 +1790,7 @@ IMPLEMENT_SAVERESTORE( CSpeaker, CBaseEntity ) // void CSpeaker::Spawn( void ) { - char *szSoundFile = (char*) STRING( pev->message ); + const char *szSoundFile = STRING( pev->message ); if( !m_preset && ( FStringNull( pev->message ) || strlen( szSoundFile ) < 1 ) ) { @@ -1862,7 +1822,7 @@ void CSpeaker::Precache( void ) } void CSpeaker::SpeakerThink( void ) { - char* szSoundFile; + const char* szSoundFile = NULL; float flvolume = pev->health * 0.1; float flattenuation = 0.3; int flags = 0; @@ -1919,7 +1879,7 @@ void CSpeaker::SpeakerThink( void ) } } else - szSoundFile = (char*)STRING( pev->message ); + szSoundFile = STRING( pev->message ); if( szSoundFile[0] == '!' ) { diff --git a/dlls/soundent.h b/dlls/soundent.h index 6c39a6c0..88def506 100644 --- a/dlls/soundent.h +++ b/dlls/soundent.h @@ -17,6 +17,9 @@ // spawns, and handles the world's active and free sound // lists. //========================================================= +#pragma once +#ifndef SOUNDENT_H +#define SOUNDENT_H #define MAX_WORLD_SOUNDS 64 // maximum number of sounds handled by the world at one time. @@ -91,3 +94,4 @@ public: private: CSound m_SoundPool[ MAX_WORLD_SOUNDS ]; }; +#endif // SOUNDENT_H diff --git a/dlls/spectator.h b/dlls/spectator.h index 90f8678f..c4e895c0 100644 --- a/dlls/spectator.h +++ b/dlls/spectator.h @@ -13,6 +13,9 @@ * ****/ // Spectator.h +#pragma once +#ifndef SPECTATOR_H +#define SPECTATOR_H class CBaseSpectator : public CBaseEntity { @@ -25,3 +28,4 @@ public: private: void SpectatorImpulseCommand( void ); }; +#endif // SPECTATOR_H diff --git a/dlls/squad.h b/dlls/squad.h index bb2784bb..2c79ee90 100644 --- a/dlls/squad.h +++ b/dlls/squad.h @@ -1,13 +1,15 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: New version of the slider bar // // $NoKeywords: $ //============================================================================= - //========================================================= // squad.h //========================================================= +#pragma once +#ifndef SQUAD_H +#define SQUAD_H // these are special group roles that are assigned to members when the group is formed. // the reason these are explicitly assigned and tasks like throwing grenades to flush out @@ -19,3 +21,4 @@ #define bits_SQUAD_FLANK_RIGHT ( 1 << 1 ) #define bits_SQUAD_ADVANCE ( 1 << 2 ) #define bits_SQUAD_FLUSH_ATTACK ( 1 << 3 ) +#endif // SQUAD_H diff --git a/dlls/squadmonster.cpp b/dlls/squadmonster.cpp index a89f39f9..3d476b50 100644 --- a/dlls/squadmonster.cpp +++ b/dlls/squadmonster.cpp @@ -192,7 +192,7 @@ BOOL CSquadMonster::SquadAdd( CSquadMonster *pAdd ) for( int i = 0; i < MAX_SQUAD_MEMBERS - 1; i++ ) { - if( m_hSquadMember[i] == NULL ) + if( m_hSquadMember[i] == 0 ) { m_hSquadMember[i] = pAdd; pAdd->m_hSquadLeader = this; @@ -258,7 +258,7 @@ void CSquadMonster::SquadMakeEnemy( CBaseEntity *pEnemy ) // reset members who aren't activly engaged in fighting if( pMember->m_hEnemy != pEnemy && !pMember->HasConditions( bits_COND_SEE_ENEMY ) ) { - if( pMember->m_hEnemy != NULL ) + if( pMember->m_hEnemy != 0 ) { // remember their current enemy pMember->PushEnemy( pMember->m_hEnemy, pMember->m_vecEnemyLKP ); @@ -459,7 +459,7 @@ BOOL CSquadMonster::NoFriendlyFire( void ) Vector v_left; //!!!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 != NULL ) + if( m_hEnemy != 0 ) { UTIL_MakeVectors( UTIL_VecToAngles( m_hEnemy->Center() - pev->origin ) ); } @@ -508,9 +508,7 @@ BOOL CSquadMonster::NoFriendlyFire( void ) //========================================================= MONSTERSTATE CSquadMonster::GetIdealState ( void ) { - int iConditions; - - iConditions = IScheduleFlags(); + IScheduleFlags(); // If no schedule conditions, the new ideal state is probably the reason we're in here. switch( m_MonsterState ) @@ -565,7 +563,7 @@ BOOL CSquadMonster::SquadEnemySplit( void ) for( int i = 0; i < MAX_SQUAD_MEMBERS; i++ ) { CSquadMonster *pMember = pSquadLeader->MySquadMember( i ); - if( pMember != NULL && pMember->m_hEnemy != NULL && pMember->m_hEnemy != pEnemy ) + if( pMember != NULL && pMember->m_hEnemy != 0 && pMember->m_hEnemy != pEnemy ) { return TRUE; } diff --git a/dlls/squadmonster.h b/dlls/squadmonster.h index ecd75ee5..e2c8a5b9 100644 --- a/dlls/squadmonster.h +++ b/dlls/squadmonster.h @@ -16,6 +16,9 @@ // CSquadMonster - all the extra data for monsters that // form squads. //========================================================= +#pragma once +#ifndef SQUADMONSTER_H +#define SQUADMONSTER_H #define SF_SQUADMONSTER_LEADER 32 @@ -88,7 +91,7 @@ public: else return (CSquadMonster *)( (CBaseEntity *)m_hSquadMember[i] ); } - int InSquad( void ) { return m_hSquadLeader != NULL; } + int InSquad( void ) { return m_hSquadLeader != 0; } int IsLeader( void ) { return m_hSquadLeader == this; } int SquadJoin( int searchRadius ); int SquadRecruit( int searchRadius, int maxMembers ); @@ -116,3 +119,4 @@ public: MONSTERSTATE GetIdealState( void ); Schedule_t *GetScheduleOfType( int iType ); }; +#endif // SQUADMONSTER_H diff --git a/dlls/squeakgrenade.cpp b/dlls/squeakgrenade.cpp index 7f382744..5e80e6a7 100644 --- a/dlls/squeakgrenade.cpp +++ b/dlls/squeakgrenade.cpp @@ -94,7 +94,7 @@ int CSqueakGrenade::Classify( void ) if( m_iMyClass != 0 ) return m_iMyClass; // protect against recursion - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { m_iMyClass = CLASS_INSECT; // no one cares about it switch( m_hEnemy->Classify() ) @@ -180,13 +180,13 @@ void CSqueakGrenade::Killed( entvars_t *pevAttacker, int iGib ) UTIL_BloodDrips( pev->origin, g_vecZero, BloodColor(), 80 ); - if( m_hOwner != NULL ) + if( m_hOwner != 0 ) RadiusDamage( pev, m_hOwner->pev, pev->dmg, CLASS_NONE, DMG_BLAST ); else RadiusDamage( pev, pev, pev->dmg, CLASS_NONE, DMG_BLAST ); // reset owner so death message happens - if( m_hOwner != NULL ) + if( m_hOwner != 0 ) pev->owner = m_hOwner->edict(); CBaseMonster::Killed( pevAttacker, GIB_ALWAYS ); @@ -230,7 +230,7 @@ void CSqueakGrenade::HuntThink( void ) pev->velocity = pev->velocity * 0.9; pev->velocity.z += 8.0; } - else if( ( pev->movetype = MOVETYPE_FLY ) ) + else if( pev->movetype == MOVETYPE_FLY ) { pev->movetype = MOVETYPE_BOUNCE; } @@ -241,7 +241,7 @@ void CSqueakGrenade::HuntThink( void ) m_flNextHunt = gpGlobals->time + 2.0; - CBaseEntity *pOther = NULL; + //CBaseEntity *pOther = NULL; Vector vecDir; TraceResult tr; @@ -251,7 +251,7 @@ void CSqueakGrenade::HuntThink( void ) UTIL_MakeVectors( pev->angles ); - if( m_hEnemy == NULL || !m_hEnemy->IsAlive() ) + if( m_hEnemy == 0 || !m_hEnemy->IsAlive() ) { // find target, bounce a bit towards it. Look( 512 ); @@ -270,7 +270,7 @@ void CSqueakGrenade::HuntThink( void ) if( flpitch < 80 ) flpitch = 80; - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { if( FVisible( m_hEnemy ) ) { @@ -350,9 +350,9 @@ void CSqueakGrenade::SuperBounceTouch( CBaseEntity *pOther ) if( tr.pHit->v.modelindex != pev->modelindex ) { // ALERT( at_console, "hit enemy\n" ); - ClearMultiDamage( ); + ClearMultiDamage(); pOther->TraceAttack( pev, gSkillData.snarkDmgBite, gpGlobals->v_forward, &tr, DMG_SLASH ); - if( m_hOwner != NULL ) + if( m_hOwner != 0 ) ApplyMultiDamage( pev, m_hOwner->pev ); else ApplyMultiDamage( pev, pev ); diff --git a/dlls/stats.cpp b/dlls/stats.cpp index 9b21f792..e37832c8 100644 --- a/dlls/stats.cpp +++ b/dlls/stats.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: New version of the slider bar // @@ -48,7 +48,7 @@ float AmmoDamage( const char *pName ) return 0; } -void UpdateStatsFile( float dataTime, char *pMapname, float health, float ammo, int skillLevel ) +void UpdateStatsFile( float dataTime, const char *pMapname, float health, float ammo, int skillLevel ) { FILE *fp; @@ -136,7 +136,7 @@ void UpdateStats( CBasePlayer *pPlayer ) } else if( ( gStats.nextOutputTime != 0 && gStats.nextOutputTime < gStats.gameTime ) || forceWrite ) { - UpdateStatsFile( gStats.dataTime, (char *)STRING( gpGlobals->mapname ), health, ammo, (int)CVAR_GET_FLOAT( "skill" ) ); + UpdateStatsFile( gStats.dataTime, STRING( gpGlobals->mapname ), health, ammo, (int)CVAR_GET_FLOAT( "skill" ) ); gStats.lastAmmo = ammo; gStats.lastHealth = health; diff --git a/dlls/subs.cpp b/dlls/subs.cpp index bc7baf18..2a299ce4 100644 --- a/dlls/subs.cpp +++ b/dlls/subs.cpp @@ -107,6 +107,13 @@ 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 @@ -415,6 +422,14 @@ After moving, set origin to exact final destination, call "move done" function */ void CBaseToggle::LinearMoveDone( void ) { + Vector delta = m_vecFinalDest - pev->origin; + float error = delta.Length(); + if( error > 0.03125 ) + { + LinearMove( m_vecFinalDest, 100 ); + return; + } + UTIL_SetOrigin( pev, m_vecFinalDest ); pev->velocity = g_vecZero; pev->nextthink = -1; diff --git a/dlls/talkmonster.cpp b/dlls/talkmonster.cpp index d832c2cc..9180f037 100644 --- a/dlls/talkmonster.cpp +++ b/dlls/talkmonster.cpp @@ -51,7 +51,7 @@ TYPEDESCRIPTION CTalkMonster::m_SaveData[] = IMPLEMENT_SAVERESTORE( CTalkMonster, CBaseMonster ) // array of friend names -char *CTalkMonster::m_szFriends[TLK_CFRIENDS] = +const char *CTalkMonster::m_szFriends[TLK_CFRIENDS] = { "monster_barney", "monster_scientist", @@ -391,7 +391,7 @@ void CTalkMonster::StartTask( Task_t *pTask ) case TASK_TLK_EYECONTACT: break; case TASK_TLK_IDEALYAW: - if( m_hTalkTarget != NULL ) + if( m_hTalkTarget != 0 ) { pev->yaw_speed = 60; float yaw = VecToYaw( m_hTalkTarget->pev->origin - pev->origin ) - pev->angles.y; @@ -403,11 +403,11 @@ void CTalkMonster::StartTask( Task_t *pTask ) if( yaw < 0 ) { - pev->ideal_yaw = min( yaw + 45, 0 ) + pev->angles.y; + pev->ideal_yaw = Q_min( yaw + 45, 0 ) + pev->angles.y; } else { - pev->ideal_yaw = max( yaw - 45, 0 ) + pev->angles.y; + pev->ideal_yaw = Q_max( yaw - 45, 0 ) + pev->angles.y; } } TaskComplete(); @@ -536,7 +536,7 @@ void CTalkMonster::RunTask( Task_t *pTask ) } break; case TASK_TLK_EYECONTACT: - if( !IsMoving() && IsTalking() && m_hTalkTarget != NULL ) + if( !IsMoving() && IsTalking() && m_hTalkTarget != 0 ) { // ALERT( at_console, "waiting %f\n", m_flStopTalkTime - gpGlobals->time ); IdleHeadTurn( m_hTalkTarget->pev->origin ); @@ -561,7 +561,7 @@ void CTalkMonster::RunTask( Task_t *pTask ) } break; case TASK_WAIT_FOR_MOVEMENT: - if( IsTalking() && m_hTalkTarget != NULL ) + if( IsTalking() && m_hTalkTarget != 0 ) { // ALERT( at_console, "walking, talking\n" ); IdleHeadTurn( m_hTalkTarget->pev->origin ); @@ -582,7 +582,7 @@ void CTalkMonster::RunTask( Task_t *pTask ) IdleHeadTurn( pev->origin ); break; default: - if( IsTalking() && m_hTalkTarget != NULL ) + if( IsTalking() && m_hTalkTarget != 0 ) { IdleHeadTurn( m_hTalkTarget->pev->origin ); } @@ -603,7 +603,7 @@ void CTalkMonster::Killed( entvars_t *pevAttacker, int iGib ) LimitFollowers( CBaseEntity::Instance( pevAttacker ), 0 ); } - m_hTargetEnt = NULL; + m_hTargetEnt = 0; // Don't finish that sentence StopTalking(); SetUse( NULL ); @@ -613,7 +613,7 @@ void CTalkMonster::Killed( entvars_t *pevAttacker, int iGib ) CBaseEntity *CTalkMonster::EnumFriends( CBaseEntity *pPrevious, int listNumber, BOOL bTrace ) { CBaseEntity *pFriend = pPrevious; - char *pszFriend; + const char *pszFriend; TraceResult tr; Vector vecCheck; @@ -712,7 +712,7 @@ void CTalkMonster::LimitFollowers( CBaseEntity *pPlayer, int maxFollowers ) float CTalkMonster::TargetDistance( void ) { // If we lose the player, or he dies, return a really large distance - if( m_hTargetEnt == NULL || !m_hTargetEnt->IsAlive() ) + if( m_hTargetEnt == 0 || !m_hTargetEnt->IsAlive() ) return 1e6; return ( m_hTargetEnt->pev->origin - pev->origin ).Length(); @@ -764,7 +764,7 @@ CBaseEntity *CTalkMonster::FindNearestFriend( BOOL fPlayer ) Vector vecStart = pev->origin; Vector vecCheck; int i; - char *pszFriend; + const char *pszFriend; int cfriends; vecStart.z = pev->absmax.z; @@ -855,7 +855,7 @@ void CTalkMonster::Touch( CBaseEntity *pOther ) //========================================================= void CTalkMonster::IdleRespond( void ) { - int pitch = GetVoicePitch(); + //int pitch = GetVoicePitch(); // play response PlaySentence( m_szGrp[TLK_ANSWER], RANDOM_FLOAT( 2.8, 3.2 ), VOL_NORM, ATTN_IDLE ); @@ -890,7 +890,7 @@ int CTalkMonster::FOkToSpeak( void ) return FALSE; // don't talk if you're in combat - if( m_hEnemy != NULL && FVisible( m_hEnemy ) ) + if( m_hEnemy != 0 && FVisible( m_hEnemy ) ) return FALSE; return TRUE; @@ -977,7 +977,7 @@ void CTalkMonster::IdleHeadTurn( Vector &vecFriend ) int CTalkMonster::FIdleSpeak( void ) { // try to start a conversation, or make statement - int pitch; + //int pitch; const char *szIdleGroup; const char *szQuestionGroup; float duration; @@ -1001,7 +1001,7 @@ int CTalkMonster::FIdleSpeak( void ) duration = RANDOM_FLOAT( 2.8, 3.2 ); } - pitch = GetVoicePitch(); + //pitch = GetVoicePitch(); // player using this entity is alive and wounded? CBaseEntity *pTarget = m_hTargetEnt; @@ -1315,10 +1315,10 @@ void CTalkMonster::StopFollowing( BOOL clearSchedule ) if( m_movementGoal == MOVEGOAL_TARGETENT ) RouteClear(); // Stop him from walking toward the player - m_hTargetEnt = NULL; + m_hTargetEnt = 0; if( clearSchedule ) ClearSchedule(); - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) m_IdealMonsterState = MONSTERSTATE_COMBAT; } } @@ -1328,7 +1328,7 @@ void CTalkMonster::StartFollowing( CBaseEntity *pLeader ) if( m_pCine ) m_pCine->CancelScript(); - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) m_IdealMonsterState = MONSTERSTATE_ALERT; m_hTargetEnt = pLeader; diff --git a/dlls/talkmonster.h b/dlls/talkmonster.h index 57c417e4..36ac21a6 100644 --- a/dlls/talkmonster.h +++ b/dlls/talkmonster.h @@ -12,6 +12,7 @@ * use or distribution of this code by or to any unlicensed person is illegal. * ****/ +#pragma once #ifndef TALKMONSTER_H #define TALKMONSTER_H @@ -138,7 +139,7 @@ public: // For following BOOL CanFollow( void ); - BOOL IsFollowing( void ) { return m_hTargetEnt != NULL && m_hTargetEnt->IsPlayer(); } + BOOL IsFollowing( void ) { return m_hTargetEnt != 0 && m_hTargetEnt->IsPlayer(); } void StopFollowing( BOOL clearSchedule ); void StartFollowing( CBaseEntity *pLeader ); virtual void DeclineFollowing( void ) {} @@ -154,7 +155,7 @@ public: static TYPEDESCRIPTION m_SaveData[]; - static char *m_szFriends[TLK_CFRIENDS]; // array of friend names + static const char *m_szFriends[TLK_CFRIENDS]; // array of friend names static float g_talkWaitTime; int m_bitsSaid; // set bits for sentences we don't want repeated @@ -162,8 +163,8 @@ public: int m_voicePitch; // pitch of voice for this head const char *m_szGrp[TLK_CGROUPS]; // sentence group names float m_useTime; // Don't allow +USE until this time - int m_iszUse; // Custom +USE sentence group (follow) - int m_iszUnUse; // Custom +USE sentence group (stop following) + string_t m_iszUse; // Custom +USE sentence group (follow) + string_t m_iszUnUse; // Custom +USE sentence group (stop following) float m_flLastSaidSmelled;// last time we talked about something that stinks float m_flStopTalkTime;// when in the future that I'll be done saying this sentence. diff --git a/dlls/teamplay_gamerules.cpp b/dlls/teamplay_gamerules.cpp index 614bd7bb..87b695e7 100644 --- a/dlls/teamplay_gamerules.cpp +++ b/dlls/teamplay_gamerules.cpp @@ -116,7 +116,7 @@ void CHalfLifeTeamplay::Think( void ) return; } - remain = flFragLimit - team_scores[i]; + remain = (int)( flFragLimit - team_scores[i] ); if( remain < bestfrags ) { bestfrags = remain; @@ -157,7 +157,7 @@ BOOL CHalfLifeTeamplay::ClientCommand( CBasePlayer *pPlayer, const char *pcmd ) if( CMD_ARGC() < 2 ) return TRUE; - int slot = atoi( CMD_ARGV( 1 ) ); + //int slot = atoi( CMD_ARGV( 1 ) ); // select the item from the current menu return TRUE; @@ -241,7 +241,7 @@ void CHalfLifeTeamplay::InitHUD( CBasePlayer *pPlayer ) ChangePlayerTeam( pPlayer, pPlayer->m_szTeamName, FALSE, FALSE ); UTIL_SayText( text, pPlayer ); - int clientIndex = pPlayer->entindex(); + //int clientIndex = pPlayer->entindex(); RecountTeams(); // update this player with all the other players team info // loop through all active players and send their team info to the new client @@ -300,7 +300,7 @@ void CHalfLifeTeamplay::ChangePlayerTeam( CBasePlayer *pPlayer, const char *pTea MESSAGE_BEGIN( MSG_ALL, gmsgScoreInfo ); WRITE_BYTE( clientIndex ); - WRITE_SHORT( pPlayer->pev->frags ); + WRITE_SHORT( (int)pPlayer->pev->frags ); WRITE_SHORT( pPlayer->m_iDeaths ); WRITE_SHORT( 0 ); WRITE_SHORT( g_pGameRules->GetTeamIndex( pPlayer->m_szTeamName ) + 1 ); @@ -607,7 +607,7 @@ void CHalfLifeTeamplay::RecountTeams( bool bResendInfo ) if( tm >= 0 ) { - team_scores[tm] += plr->pev->frags; + team_scores[tm] += (int)plr->pev->frags; } if( bResendInfo ) //Someone's info changed, let's send the team info again. diff --git a/dlls/teamplay_gamerules.h b/dlls/teamplay_gamerules.h index 06823ca6..12ed038f 100644 --- a/dlls/teamplay_gamerules.h +++ b/dlls/teamplay_gamerules.h @@ -15,6 +15,9 @@ // // teamplay_gamerules.h // +#pragma once +#ifndef TEAMPLAY_GAMERULES_H +#define TEAMPLAY_GAMERULES_H #define MAX_TEAMNAME_LENGTH 16 #define MAX_TEAMS 32 @@ -55,3 +58,4 @@ private: BOOL m_teamLimit; // This means the server set only some teams as valid char m_szTeamList[TEAMPLAY_TEAMLISTLENGTH]; }; +#endif // TEAMPLAY_GAMERULES_H diff --git a/dlls/tentacle.cpp b/dlls/tentacle.cpp index 637b8946..44b8b45b 100644 --- a/dlls/tentacle.cpp +++ b/dlls/tentacle.cpp @@ -486,12 +486,12 @@ void CTentacle::Cycle( void ) m_flSoundYaw += 360; if( m_flSoundYaw > 180 ) m_flSoundYaw -= 360; - +#if 0 // ALERT( at_console, "sound %d %.0f\n", m_iSoundLevel, m_flSoundYaw ); if( m_flSoundTime < gpGlobals->time ) { // play "I hear new something" sound - char *sound; + const char *sound; switch( RANDOM_LONG( 0, 1 ) ) { @@ -505,6 +505,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 ); } @@ -591,7 +592,7 @@ void CTentacle::Cycle( void ) if( m_flNextSong < gpGlobals->time ) { // play "I hear new something" sound - char *sound; + const char *sound; switch( RANDOM_LONG( 0, 1 ) ) { @@ -791,7 +792,7 @@ void CTentacle::DieThink( void ) void CTentacle::HandleAnimEvent( MonsterEvent_t *pEvent ) { - char *sound; + const char *sound; switch( pEvent->event ) { diff --git a/dlls/trains.h b/dlls/trains.h index e8003b3e..f740e2ea 100644 --- a/dlls/trains.h +++ b/dlls/trains.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef TRAINS_H #define TRAINS_H diff --git a/dlls/triggers.cpp b/dlls/triggers.cpp index 431ccfb2..43752316 100644 --- a/dlls/triggers.cpp +++ b/dlls/triggers.cpp @@ -27,6 +27,7 @@ #include "saverestore.h" #include "trains.h" // trigger_camera has train functionality #include "gamerules.h" +#include "weapons.h" #define SF_TRIGGER_PUSH_START_OFF 2//spawnflag that makes trigger_push spawn turned OFF #define SF_TRIGGER_HURT_TARGETONCE 1// Only fire hurt target once @@ -114,7 +115,7 @@ public: static TYPEDESCRIPTION m_SaveData[]; private: - int m_globalstate; + string_t m_globalstate; USE_TYPE triggerType; }; @@ -267,10 +268,10 @@ public: static TYPEDESCRIPTION m_SaveData[]; - int m_cTargets; // the total number of targets in this manager's fire list. + int m_cTargets; // the total number of targets in this manager's fire list. int m_index; // Current target float m_startTime;// Time we started firing - int m_iTargetName[MAX_MULTI_TARGETS];// list if indexes into global string array + string_t m_iTargetName[MAX_MULTI_TARGETS];// list if indexes into global string array float m_flTargetDelay[MAX_MULTI_TARGETS];// delay (in seconds) from time of manager fire to target fire private: inline BOOL IsClone( void ) { return ( pev->spawnflags & SF_MULTIMAN_CLONE ) ? TRUE : FALSE; } @@ -527,7 +528,7 @@ void CBaseTrigger::InitTrigger() SetMovedir( pev ); pev->solid = SOLID_TRIGGER; pev->movetype = MOVETYPE_NONE; - SET_MODEL(ENT(pev), STRING( pev->model ) ); // set size and link into world + SET_MODEL( ENT( pev ), STRING( pev->model ) ); // set size and link into world if( CVAR_GET_FLOAT( "showtriggers" ) == 0 ) SetBits( pev->effects, EF_NODRAW ); } @@ -688,7 +689,7 @@ void PlayCDTrack( int iTrack ) if( iTrack == -1 ) { - CLIENT_COMMAND( pClient, "cd pause\n" ); + CLIENT_COMMAND( pClient, "cd stop\n" ); } else { @@ -1135,7 +1136,7 @@ void CBaseTrigger::ActivateMultiTrigger( CBaseEntity *pActivator ) } if( !FStringNull( pev->noise ) ) - EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noise ), 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noise ), 1, ATTN_NORM ); // don't trigger again until reset // pev->takedamage = DAMAGE_NO; @@ -1264,8 +1265,8 @@ void CTriggerVolume::Spawn( void ) { pev->solid = SOLID_NOT; pev->movetype = MOVETYPE_NONE; - SET_MODEL( ENT(pev), STRING( pev->model ) ); // set size and link into world - pev->model = NULL; + SET_MODEL( ENT( pev ), STRING( pev->model ) ); // set size and link into world + pev->model = 0; pev->modelindex = 0; } @@ -1323,7 +1324,7 @@ public: char m_szMapName[cchMapNameMost]; // trigger_changelevel only: next map char m_szLandmarkName[cchMapNameMost]; // trigger_changelevel only: landmark on next map - int m_changeTarget; + string_t m_changeTarget; float m_changeTargetDelay; }; @@ -1338,7 +1339,7 @@ TYPEDESCRIPTION CChangeLevel::m_SaveData[] = DEFINE_FIELD( CChangeLevel, m_changeTargetDelay, FIELD_FLOAT ), }; -IMPLEMENT_SAVERESTORE(CChangeLevel,CBaseTrigger) +IMPLEMENT_SAVERESTORE( CChangeLevel, CBaseTrigger ) // // Cache user-entity-field values until spawn is called. @@ -1438,7 +1439,7 @@ void CChangeLevel::UseChangeLevel( CBaseEntity *pActivator, CBaseEntity *pCaller void CChangeLevel::ChangeLevelNow( CBaseEntity *pActivator ) { edict_t *pentLandmark; - LEVELLIST levels[16]; + //LEVELLIST levels[16]; ASSERT( !FStrEq( m_szMapName, "" ) ); @@ -1689,7 +1690,7 @@ void NextLevel( void ) // go back to start if no trigger_changelevel if( FNullEnt( pent ) ) { - gpGlobals->mapname = ALLOC_STRING( "start" ); + gpGlobals->mapname = MAKE_STRING( "start" ); pChange = GetClassPtr( (CChangeLevel *)NULL ); strcpy( pChange->m_szMapName, "start" ); } @@ -2054,7 +2055,7 @@ public: static TYPEDESCRIPTION m_SaveData[]; private: - int m_iszNewTarget; + string_t m_iszNewTarget; }; LINK_ENTITY_TO_CLASS( trigger_changetarget, CTriggerChangeTarget ) @@ -2105,6 +2106,7 @@ class CTriggerCamera : public CBaseDelay public: void Spawn( void ); void KeyValue( KeyValueData *pkvd ); + void EXPORT CallAgain(); void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void EXPORT FollowTarget( void ); void Move( void ); @@ -2117,7 +2119,7 @@ public: EHANDLE m_hPlayer; EHANDLE m_hTarget; CBaseEntity *m_pentPath; - int m_sPath; + string_t m_sPath; float m_flWait; float m_flReturnTime; float m_flStopTime; @@ -2127,6 +2129,10 @@ public: float m_acceleration; float m_deceleration; int m_state; + EHANDLE m_hActivator; + EHANDLE m_hCaller; + USE_TYPE m_useType; + float m_flValue; }; LINK_ENTITY_TO_CLASS( trigger_camera, CTriggerCamera ) @@ -2147,6 +2153,10 @@ TYPEDESCRIPTION CTriggerCamera::m_SaveData[] = DEFINE_FIELD( CTriggerCamera, m_acceleration, FIELD_FLOAT ), DEFINE_FIELD( CTriggerCamera, m_deceleration, FIELD_FLOAT ), DEFINE_FIELD( CTriggerCamera, m_state, FIELD_INTEGER ), + DEFINE_FIELD( CTriggerCamera, m_hActivator, FIELD_EHANDLE ), + DEFINE_FIELD( CTriggerCamera, m_hCaller, FIELD_EHANDLE ), + DEFINE_FIELD( CTriggerCamera, m_useType, FIELD_INTEGER ), + DEFINE_FIELD( CTriggerCamera, m_flValue, FIELD_FLOAT ), }; IMPLEMENT_SAVERESTORE( CTriggerCamera, CBaseDelay ) @@ -2191,6 +2201,11 @@ void CTriggerCamera::KeyValue( KeyValueData *pkvd ) CBaseDelay::KeyValue( pkvd ); } +void CTriggerCamera::CallAgain() +{ + Use( m_hActivator, m_hCaller, m_useType, m_flValue ); +} + void CTriggerCamera::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { if( !ShouldToggle( useType, m_state ) ) @@ -2210,6 +2225,22 @@ void CTriggerCamera::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP m_hPlayer = pActivator; + if( pActivator->pev->iuser4 ) + { + CBasePlayer *pPlayer = (CBasePlayer *)pActivator; + if( FClassnameIs( pPlayer->m_pActiveItem->pev, "weapon_cmlwbr" ) ) + { + CCrossbow *pCrossbow = (CCrossbow *)pPlayer->m_pActiveItem; + pCrossbow->ZoomOut(); + m_hActivator = pActivator; + m_hCaller = pCaller; + m_useType = useType; + m_flValue = value; + SetThink( &CTriggerCamera::CallAgain ); + pev->nextthink = gpGlobals->time + 0.1f; + } + } + m_flReturnTime = gpGlobals->time + m_flWait; pev->speed = m_initialSpeed; m_targetSpeed = m_initialSpeed; @@ -2224,7 +2255,7 @@ void CTriggerCamera::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP } // Nothing to look at! - if( m_hTarget == NULL ) + if( m_hTarget == 0 ) { return; } @@ -2232,13 +2263,10 @@ void CTriggerCamera::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP if( FBitSet( pev->spawnflags, SF_CAMERA_PLAYER_TAKECONTROL ) ) { ( (CBasePlayer *)pActivator )->EnableControl( FALSE ); - - if( ( (CBasePlayer *)pActivator )->pev->weapons & ( 1 << WEAPON_SUIT ) ) - { - ( (CBasePlayer *)pActivator )->HidePlayerHUD(); - } } + SetBits( ( (CBasePlayer *)pActivator )->m_iHideHUD, HIDEHUD_WEAPONS | HIDEHUD_HEALTH ); + if( m_sPath ) { m_pentPath = Instance( FIND_ENTITY_BY_TARGETNAME( NULL, STRING( m_sPath ) ) ); @@ -2285,20 +2313,17 @@ void CTriggerCamera::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP void CTriggerCamera::FollowTarget() { - if( m_hPlayer == NULL ) + if( m_hPlayer == 0 ) return; - if( m_hTarget == NULL || m_flReturnTime < gpGlobals->time ) + if( m_hTarget == 0 || m_flReturnTime < gpGlobals->time ) { if( m_hPlayer->IsAlive() ) { + CBasePlayer *pPlayer = (CBasePlayer *)( (CBaseEntity *)m_hPlayer ); SET_VIEW( m_hPlayer->edict(), m_hPlayer->edict() ); - ( (CBasePlayer *)( (CBaseEntity *)m_hPlayer ) )->EnableControl( TRUE ); - - if( ( (CBasePlayer *)( (CBaseEntity *)m_hPlayer ) )->pev->weapons & ( 1 << WEAPON_SUIT ) ) - { - ( (CBasePlayer *)( (CBaseEntity *)m_hPlayer ) )->ShowPlayerHUD(); - } + pPlayer->EnableControl( TRUE ); + ClearBits( pPlayer->m_iHideHUD, HIDEHUD_WEAPONS | HIDEHUD_HEALTH ); } SUB_UseTargets( this, USE_TOGGLE, 0 ); pev->avelocity = Vector( 0, 0, 0 ); diff --git a/dlls/tripmine.cpp b/dlls/tripmine.cpp index 56fa059c..23c21bf0 100644 --- a/dlls/tripmine.cpp +++ b/dlls/tripmine.cpp @@ -43,6 +43,7 @@ class CTripmineGrenade : public CGrenade { void Spawn( void ); void Precache( void ); + void UpdateOnRemove(); virtual int Save( CSave &save ); virtual int Restore( CRestore &restore ); @@ -148,6 +149,13 @@ void CTripmineGrenade::Precache( void ) PRECACHE_SOUND( "weapons/mine_charge.wav" ); } +void CTripmineGrenade::UpdateOnRemove() +{ + CBaseEntity::UpdateOnRemove(); + + KillBeam(); +} + void CTripmineGrenade::WarningThink( void ) { // play warning sound @@ -162,7 +170,7 @@ void CTripmineGrenade::PowerupThink( void ) { TraceResult tr; - if( m_hOwner == NULL ) + if( m_hOwner == 0 ) { // find an owner edict_t *oldowner = pev->owner; @@ -217,7 +225,7 @@ void CTripmineGrenade::PowerupThink( void ) MakeBeam(); // play enabled sound - EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "weapons/mine_activate.wav", 0.5, ATTN_NORM, 1.0, 75 ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "weapons/mine_activate.wav", 0.5, ATTN_NORM, 1, 75 ); } pev->nextthink = gpGlobals->time + 0.1; } @@ -280,7 +288,7 @@ void CTripmineGrenade::BeamBreakThink( void ) } else { - if( m_hOwner == NULL ) + if( m_hOwner == 0 ) bBlowup = 1; else if( m_posOwner != m_hOwner->pev->origin ) bBlowup = 1; @@ -342,3 +350,4 @@ void CTripmineGrenade::DelayDeathThink( void ) Explode( &tr, DMG_BLAST ); } #endif + diff --git a/dlls/turret.cpp b/dlls/turret.cpp index 2dce87fb..093b2032 100644 --- a/dlls/turret.cpp +++ b/dlls/turret.cpp @@ -56,6 +56,7 @@ class CBaseTurret : public CBaseMonster public: void Spawn( void ); virtual void Precache( void ); + void UpdateOnRemove(); void KeyValue( KeyValueData *pkvd ); void EXPORT TurretUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); @@ -279,6 +280,17 @@ void CBaseTurret::Precache() PRECACHE_SOUND( "turret/tu_alert.wav" ); } +void CBaseTurret::UpdateOnRemove() +{ + CBaseEntity::UpdateOnRemove(); + + if( m_pEyeGlow ) + { + UTIL_Remove( m_pEyeGlow ); + m_pEyeGlow = 0; + } +} + #define TURRET_GLOW_SPRITE "sprites/flare3.spr" void CTurret::Spawn() @@ -442,7 +454,7 @@ void CBaseTurret::EyeOff() { if( m_eyeBrightness > 0 ) { - m_eyeBrightness = max( 0, m_eyeBrightness - 30 ); + m_eyeBrightness = Q_max( 0, m_eyeBrightness - 30 ); m_pEyeGlow->SetBrightness( m_eyeBrightness ); } } @@ -456,7 +468,7 @@ void CBaseTurret::ActiveThink( void ) pev->nextthink = gpGlobals->time + 0.1; StudioFrameAdvance(); - if( ( !m_iOn ) || ( m_hEnemy == NULL ) ) + if( ( !m_iOn ) || ( m_hEnemy == 0 ) ) { m_hEnemy = NULL; m_flLastSight = gpGlobals->time + m_flMaxWait; @@ -826,21 +838,21 @@ void CBaseTurret::SearchThink( void ) Ping(); // If we have a target and we're still healthy - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { if( !m_hEnemy->IsAlive() ) m_hEnemy = NULL;// Dead enemy forces a search for new one } // Acquire Target - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { Look( TURRET_RANGE ); m_hEnemy = BestVisibleEnemy(); } // If we've found a target, spin up the barrel and start to attack - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { m_flLastSight = 0; m_flSpinUpTime = 0; @@ -881,20 +893,20 @@ void CBaseTurret::AutoSearchThink( void ) pev->nextthink = gpGlobals->time + 0.3; // If we have a target and we're still healthy - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { if( !m_hEnemy->IsAlive() ) m_hEnemy = NULL;// Dead enemy forces a search for new one } // Acquire Target - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { Look( TURRET_RANGE ); m_hEnemy = BestVisibleEnemy(); } - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { SetThink( &CBaseTurret::Deploy ); EMIT_SOUND( ENT( pev ), CHAN_BODY, "turret/tu_alert.wav", TURRET_MACHINE_VOLUME, ATTN_NORM ); @@ -903,7 +915,7 @@ void CBaseTurret::AutoSearchThink( void ) void CBaseTurret::TurretDeath( void ) { - BOOL iActive = FALSE; + //BOOL iActive = FALSE; StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; @@ -1222,7 +1234,7 @@ void CSentry::SentryTouch( CBaseEntity *pOther ) void CSentry::SentryDeath( void ) { - BOOL iActive = FALSE; + //BOOL iActive = FALSE; StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; diff --git a/dlls/util.cpp b/dlls/util.cpp index d1fceb0a..2a68d4c6 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -31,6 +31,20 @@ #include "weapons.h" #include "gamerules.h" + +void UTIL_MakeTracer( const Vector &vecSrc, const Vector &vecDest ) +{ + MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, vecSrc ); + WRITE_BYTE( TE_TRACER ); + WRITE_COORD( vecSrc.x ); + WRITE_COORD( vecSrc.y ); + WRITE_COORD( vecSrc.z ); + WRITE_COORD( vecDest.x ); + WRITE_COORD( vecDest.y ); + WRITE_COORD( vecDest.z ); + MESSAGE_END(); +} + float UTIL_WeaponTimeBase( void ) { #if defined( CLIENT_WEAPONS ) @@ -118,7 +132,7 @@ float UTIL_SharedRandomFloat( unsigned int seed, float low, float high ) U_Random(); U_Random(); - range = high - low; + range = (int)( high - low ); if( !range ) { return low; @@ -625,7 +639,7 @@ static unsigned short FixedUnsigned16( float value, float scale ) { int output; - output = value * scale; + output = (int)( value * scale ); if( output < 0 ) output = 0; if( output > 0xFFFF ) @@ -638,7 +652,7 @@ static short FixedSigned16( float value, float scale ) { int output; - output = value * scale; + output = (int)( value * scale ); if( output > 32767 ) output = 32767; @@ -937,10 +951,10 @@ TraceResult UTIL_GetGlobalTrace( ) { TraceResult tr; - tr.fAllSolid = gpGlobals->trace_allsolid; - tr.fStartSolid = gpGlobals->trace_startsolid; - tr.fInOpen = gpGlobals->trace_inopen; - tr.fInWater = gpGlobals->trace_inwater; + tr.fAllSolid = (int)gpGlobals->trace_allsolid; + tr.fStartSolid = (int)gpGlobals->trace_startsolid; + tr.fInOpen = (int)gpGlobals->trace_inopen; + tr.fInWater = (int)gpGlobals->trace_inwater; tr.flFraction = gpGlobals->trace_fraction; tr.flPlaneDist = gpGlobals->trace_plane_dist; tr.pHit = gpGlobals->trace_ent; @@ -989,7 +1003,7 @@ float UTIL_Approach( float target, float value, float speed ) float UTIL_ApproachAngle( float target, float value, float speed ) { target = UTIL_AngleMod( target ); - value = UTIL_AngleMod( target ); + value = UTIL_AngleMod( value ); float delta = target - value; @@ -1033,7 +1047,7 @@ float UTIL_SplineFraction( float value, float scale ) return 3 * valueSquared - 2 * valueSquared * value; } -char *UTIL_VarArgs( char *format, ... ) +char *UTIL_VarArgs( const char *format, ... ) { va_list argptr; static char string[1024]; @@ -1052,7 +1066,7 @@ Vector UTIL_GetAimVector( edict_t *pent, float flSpeed ) return tmp; } -int UTIL_IsMasterTriggered(string_t sMaster, CBaseEntity *pActivator) +int UTIL_IsMasterTriggered( string_t sMaster, CBaseEntity *pActivator ) { if( sMaster ) { @@ -1112,7 +1126,7 @@ void UTIL_BloodStream( const Vector &origin, const Vector &direction, int color, WRITE_COORD( direction.y ); WRITE_COORD( direction.z ); WRITE_BYTE( color ); - WRITE_BYTE( min( amount, 255 ) ); + WRITE_BYTE( Q_min( amount, 255 ) ); MESSAGE_END(); } @@ -1144,7 +1158,7 @@ void UTIL_BloodDrips( const Vector &origin, const Vector &direction, int color, WRITE_SHORT( g_sModelIndexBloodSpray ); // initial sprite model WRITE_SHORT( g_sModelIndexBloodDrop ); // droplet sprite models WRITE_BYTE( color ); // color index into host_basepal - WRITE_BYTE( min( max( 3, amount / 10 ), 16 ) ); // size + WRITE_BYTE( Q_min( Q_max( 3, amount / 10 ), 16 ) ); // size MESSAGE_END(); } @@ -1340,7 +1354,7 @@ void UTIL_StringToVector( float *pVector, const char *pString ) while( *pstr && *pstr != ' ' ) pstr++; - if( !(*pstr) ) + if( !( *pstr ) ) break; pstr++; pfront = pstr; @@ -1536,7 +1550,7 @@ void UTIL_PrecacheOther( const char *szClassname ) // UTIL_LogPrintf - Prints a logged message to console. // Preceded by LOG: ( timestamp ) < message > //========================================================= -void UTIL_LogPrintf( char *fmt, ... ) +void UTIL_LogPrintf( const char *fmt, ... ) { va_list argptr; static char string[1024]; @@ -1586,7 +1600,34 @@ void UTIL_StripToken( const char *pKey, char *pDest ) static int gSizes[FIELD_TYPECOUNT] = { sizeof(float), // FIELD_FLOAT - sizeof(int), // FIELD_STRING + sizeof(string_t), // FIELD_STRING + sizeof(void*), // FIELD_ENTITY + sizeof(void*), // FIELD_CLASSPTR + sizeof(void*), // FIELD_EHANDLE + sizeof(void*), // FIELD_entvars_t + sizeof(void*), // FIELD_EDICT + sizeof(float) * 3, // FIELD_VECTOR + sizeof(float) * 3, // FIELD_POSITION_VECTOR + sizeof(void *), // FIELD_POINTER + sizeof(int), // FIELD_INTEGER +#ifdef GNUC + sizeof(void *) * 2, // FIELD_FUNCTION +#else + sizeof(void *), // FIELD_FUNCTION +#endif + sizeof(int), // FIELD_BOOLEAN + sizeof(short), // FIELD_SHORT + sizeof(char), // FIELD_CHARACTER + sizeof(float), // FIELD_TIME + sizeof(int), // FIELD_MODELNAME + sizeof(int), // FIELD_SOUNDNAME +}; + +// entities has different store size +static int gInputSizes[FIELD_TYPECOUNT] = +{ + sizeof(float), // FIELD_FLOAT + sizeof(string_t), // FIELD_STRING sizeof(int), // FIELD_ENTITY sizeof(int), // FIELD_CLASSPTR sizeof(int), // FIELD_EHANDLE @@ -1594,12 +1635,12 @@ static int gSizes[FIELD_TYPECOUNT] = sizeof(int), // FIELD_EDICT sizeof(float) * 3, // FIELD_VECTOR sizeof(float) * 3, // FIELD_POSITION_VECTOR - sizeof(int *), // FIELD_POINTER + sizeof(void *), // FIELD_POINTER sizeof(int), // FIELD_INTEGER #ifdef GNUC - sizeof(int *) * 2, // FIELD_FUNCTION + sizeof(void *) * 2, // FIELD_FUNCTION #else - sizeof(int *), // FIELD_FUNCTION + sizeof(void *), // FIELD_FUNCTION #endif sizeof(int), // FIELD_BOOLEAN sizeof(short), // FIELD_SHORT @@ -1831,7 +1872,7 @@ void CSave::WriteString( const char *pname, const int *stringId, int count ) #if 0 if( count != 1 ) ALERT( at_error, "No string arrays!\n" ); - WriteString( pname, (char *)STRING( *stringId ) ); + WriteString( pname, STRING( *stringId ) ); #endif size = 0; for( i = 0; i < count; i++ ) @@ -1886,7 +1927,7 @@ void CSave::WritePositionVector( const char *pname, const float *value, int coun } } -void CSave::WriteFunction( const char *pname, const int *data, int count ) +void CSave::WriteFunction( const char *pname, void **data, int count ) { const char *functionName; @@ -1894,7 +1935,7 @@ void CSave::WriteFunction( const char *pname, const int *data, int count ) if( functionName ) BufferField( pname, strlen( functionName ) + 1, functionName ); else - ALERT( at_error, "Invalid function pointer in entity!" ); + ALERT( at_error, "Invalid function pointer in entity!\n" ); } void EntvarsKeyvalue( entvars_t *pev, KeyValueData *pkvd ) @@ -1902,7 +1943,7 @@ void EntvarsKeyvalue( entvars_t *pev, KeyValueData *pkvd ) int i; TYPEDESCRIPTION *pField; - for( i = 0; i < ENTVARS_COUNT; i++ ) + for( i = 0; i < (int)ENTVARS_COUNT; i++ ) { pField = &gEntvarsDescription[i]; @@ -1913,7 +1954,7 @@ void EntvarsKeyvalue( entvars_t *pev, KeyValueData *pkvd ) case FIELD_MODELNAME: case FIELD_SOUNDNAME: case FIELD_STRING: - ( *(int *)( (char *)pev + pField->fieldOffset ) ) = ALLOC_STRING( pkvd->szValue ); + ( *(string_t *)( (char *)pev + pField->fieldOffset ) ) = ALLOC_STRING( pkvd->szValue ); break; case FIELD_TIME: case FIELD_FLOAT: @@ -1987,7 +2028,7 @@ int CSave::WriteFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *pFi case FIELD_MODELNAME: case FIELD_SOUNDNAME: case FIELD_STRING: - WriteString( pTest->fieldName, (int *)pOutputData, pTest->fieldSize ); + WriteString( pTest->fieldName, (string_t *)pOutputData, pTest->fieldSize ); break; case FIELD_CLASSPTR: case FIELD_EVARS: @@ -2042,7 +2083,7 @@ int CSave::WriteFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *pFi WriteInt( pTest->fieldName, (int *)(char *)pOutputData, pTest->fieldSize ); break; case FIELD_FUNCTION: - WriteFunction( pTest->fieldName, (int *)pOutputData, pTest->fieldSize ); + WriteFunction( pTest->fieldName, (void **)pOutputData, pTest->fieldSize ); break; default: ALERT( at_error, "Bad field type\n" ); @@ -2137,7 +2178,7 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou for( j = 0; j < pTest->fieldSize; j++ ) { void *pOutputData = ( (char *)pBaseData + pTest->fieldOffset + ( j * gSizes[pTest->fieldType] ) ); - void *pInputData = (char *)pData + j * gSizes[pTest->fieldType]; + void *pInputData = (char *)pData + j * gInputSizes[pTest->fieldType]; switch( pTest->fieldType ) { @@ -2170,21 +2211,21 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou } pInputData = pString; if( strlen( (char *)pInputData ) == 0 ) - *( (int *)pOutputData ) = 0; + *( (string_t *)pOutputData ) = 0; else { - int string; + string_t string; string = ALLOC_STRING( (char *)pInputData ); - *( (int *)pOutputData ) = string; + *( (string_t *)pOutputData ) = string; if( !FStringNull( string ) && m_precache ) { if( pTest->fieldType == FIELD_MODELNAME ) - PRECACHE_MODEL( (char *)STRING( string ) ); + PRECACHE_MODEL( STRING( string ) ); else if( pTest->fieldType == FIELD_SOUNDNAME ) - PRECACHE_SOUND( (char *)STRING( string ) ); + PRECACHE_SOUND( STRING( string ) ); } } break; @@ -2267,7 +2308,7 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou if( strlen( (char *)pInputData ) == 0 ) *( (void**)pOutputData ) = 0; else - *( (void**)pOutputData ) = (void**)FUNCTION_FROM_NAME( (char *)pInputData ); + *( (void**)pOutputData ) = (void*)FUNCTION_FROM_NAME( (char *)pInputData ); break; default: ALERT( at_error, "Bad field type\n" ); diff --git a/dlls/util.h b/dlls/util.h index e8aee878..e4c34ba7 100644 --- a/dlls/util.h +++ b/dlls/util.h @@ -12,6 +12,9 @@ * without written permission from Valve LLC. * ****/ +#pragma once +#ifndef UTIL_H +#define UTIL_H // // Misc utility code // @@ -36,10 +39,17 @@ extern globalvars_t *gpGlobals; // Use this instead of ALLOC_STRING on constant strings #define STRING(offset) (const char *)(gpGlobals->pStringBase + (int)offset) -#if !defined __amd64__ || defined(CLIENT_DLL) -#define MAKE_STRING(str) ((int)(size_t)str - (int)(size_t)STRING(0)) +#if !defined XASH_64BIT || defined(CLIENT_DLL) +#define MAKE_STRING(str) ((int)(long int)str - (int)(long int)STRING(0)) #else -#define MAKE_STRING ALLOC_STRING +static inline int MAKE_STRING(const char *szValue) +{ + long long ptrdiff = szValue - STRING(0); + if( ptrdiff > INT_MAX || ptrdiff < INT_MIN ) + return ALLOC_STRING( szValue ); + else + return (int)ptrdiff; +} #endif inline edict_t *FIND_ENTITY_BY_CLASSNAME(edict_t *entStart, const char *pszName) @@ -87,8 +97,9 @@ typedef int EOFFSET; typedef int BOOL; // In case this ever changes +#ifndef M_PI #define M_PI 3.14159265358979323846 - +#endif // Keeps clutter down a bit, when declaring external entity/global method prototypes #define DECLARE_GLOBAL_METHOD(MethodName) extern void DLLEXPORT MethodName( void ) #define GLOBAL_METHOD(funcname) void DLLEXPORT funcname(void) @@ -304,7 +315,7 @@ extern float UTIL_Approach( float target, float value, float speed ); extern float UTIL_ApproachAngle( float target, float value, float speed ); extern float UTIL_AngleDistance( float next, float cur ); -extern char *UTIL_VarArgs( char *format, ... ); +extern char *UTIL_VarArgs( const char *format, ... ); extern void UTIL_Remove( CBaseEntity *pEntity ); extern BOOL UTIL_IsValidEntity( edict_t *pent ); extern BOOL UTIL_TeamsMatch( const char *pTeamName1, const char *pTeamName2 ); @@ -364,7 +375,7 @@ extern char *UTIL_dtos3( int d ); extern char *UTIL_dtos4( int d ); // Writes message to console with timestamp and FragLog header. -extern void UTIL_LogPrintf( char *fmt, ... ); +extern void UTIL_LogPrintf( const char *fmt, ... ); // Sorta like FInViewCone, but for nonmonsters. extern float UTIL_DotPoints ( const Vector &vecSrc, const Vector &vecCheck, const Vector &vecDir ); @@ -489,6 +500,17 @@ extern DLL_GLOBAL int g_Language; #define CBSENTENCENAME_MAX 16 #define CVOXFILESENTENCEMAX 1536 // max number of sentences in game. NOTE: this must match // CVOXFILESENTENCEMAX in engine\sound.h!!! +typedef struct soundtrack_s +{ + char mapname[32]; + char soundfile[32]; + BOOL loop; +} soundtrack_t; + +extern int g_soundtrackCount; +extern soundtrack_t g_soundtracklist[30]; + +void SOUNDTRACKLIST_Init(); extern char gszallsentencenames[CVOXFILESENTENCEMAX][CBSENTENCENAME_MAX]; extern int gcallsentences; @@ -534,7 +556,7 @@ void EMIT_GROUPID_SUIT(edict_t *entity, int isentenceg); void EMIT_GROUPNAME_SUIT(edict_t *entity, const char *groupname); #define PRECACHE_SOUND_ARRAY( a ) \ - { for (int i = 0; i < ARRAYSIZE( a ); i++ ) PRECACHE_SOUND((char *) a [i]); } + { for (int i = 0; i < (int)ARRAYSIZE( a ); i++ ) PRECACHE_SOUND( a[i] ); } #define EMIT_SOUND_ARRAY_DYN( chan, array ) \ EMIT_SOUND_DYN ( ENT(pev), chan , array [ RANDOM_LONG(0,ARRAYSIZE( array )-1) ], 1.0, ATTN_NORM, 0, RANDOM_LONG(95,105) ); @@ -566,4 +588,6 @@ void UTIL_UnsetGroupTrace( void ); int UTIL_SharedRandomLong( unsigned int seed, int low, int high ); float UTIL_SharedRandomFloat( unsigned int seed, float low, float high ); +void UTIL_MakeTracer( const Vector &vecSrc, const Vector &vecDest ); float UTIL_WeaponTimeBase( void ); +#endif // UTIL_H diff --git a/dlls/vector.h b/dlls/vector.h index d3347983..48c707b4 100644 --- a/dlls/vector.h +++ b/dlls/vector.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef VECTOR_H #define VECTOR_H @@ -22,8 +23,8 @@ class Vector2D { public: - inline Vector2D(void) { } - inline Vector2D(float X, float Y) { x = X; y = Y; } + inline Vector2D(void): x( 0.0f ), y( 0.0f ) { } + inline Vector2D(float X, float Y): x( 0.0f ), y( 0.0f ) { x = X; y = Y; } inline Vector2D operator+(const Vector2D& v) const { return Vector2D( x + v.x, y + v.y ); } inline Vector2D operator-(const Vector2D& v) const { return Vector2D( x - v.x, y - v.y ); } inline Vector2D operator*(float fl) const { return Vector2D( x * fl, y * fl ); } @@ -33,7 +34,7 @@ public: inline Vector2D Normalize ( void ) const { - Vector2D vec2; + //Vector2D vec2; float flLen = Length(); if( flLen == 0 ) @@ -60,12 +61,12 @@ class Vector // same data-layout as engine's vec3_t, { // which is a vec_t[3] public: // Construction/destruction - inline Vector( void ) { } - inline Vector( float X, float Y, float Z ) { x = X; y = Y; z = Z; } + inline Vector( void ): x( 0.0f ), y( 0.0f ), z( 0.0f ) { } + inline Vector( float X, float Y, float Z ): x( 0.0f ), y( 0.0f ), z( 0.0f ) { x = X; y = Y; z = Z; } //inline Vector( double X, double Y, double Z ) { x = (float)X; y = (float)Y; z = (float)Z; } //inline Vector( int X, int Y, int Z ) { x = (float)X; y = (float)Y; z = (float)Z; } - inline Vector( const Vector& v ) { x = v.x; y = v.y; z = v.z; } - inline Vector( float rgfl[3] ) { x = rgfl[0]; y = rgfl[1]; z = rgfl[2]; } + inline Vector( const Vector& v ): x( 0.0f ), y( 0.0f ), z( 0.0f ) { x = v.x; y = v.y; z = v.z; } + inline Vector( float rgfl[3] ): x( 0.0f ), y( 0.0f ), z( 0.0f ) { x = rgfl[0]; y = rgfl[1]; z = rgfl[2]; } // Operators inline Vector operator-( void ) const { return Vector( -x, -y, -z ); } diff --git a/dlls/vendetta/par21.cpp b/dlls/vendetta/par21.cpp index 9cefa5f3..68ce6417 100644 --- a/dlls/vendetta/par21.cpp +++ b/dlls/vendetta/par21.cpp @@ -83,7 +83,6 @@ void CPar21::Precache(void) PRECACHE_SOUND("weapons/357_cock1.wav"); - m_usReload = PRECACHE_EVENT(1, "events/reload.sc"); m_usPar21 = PRECACHE_EVENT(1, "events/par21.sc"); m_usM203 = PRECACHE_EVENT(1, "events/m203.sc"); } @@ -91,13 +90,13 @@ void CPar21::Precache(void) int CPar21::GetItemInfo(ItemInfo *p) { p->pszName = STRING(pev->classname); - p->pszAmmo1 = "par21"; + p->pszAmmo1 = "NATO"; p->iMaxAmmo1 = PAR21_MAX_CARRY; p->pszAmmo2 = "M203grenades"; p->iMaxAmmo2 = M203_GRENADE_MAX_CARRY; p->iMaxClip = PAR21_MAX_CLIP; p->iSlot = 1; - p->iPosition = 0; + p->iPosition = 2; p->iFlags = 0; p->iId = m_iId = WEAPON_PAR21; p->iWeight = PAR21_WEIGHT; @@ -157,7 +156,7 @@ void CPar21::PrimaryAttack() Vector vecDir; // single player spread - vecDir = m_pPlayer->FireBulletsPlayer(1, vecSrc, vecAiming, VECTOR_CONE_3DEGREES, 8192, BULLET_PLAYER_PAR21, 2, 0, m_pPlayer->pev, m_pPlayer->random_seed); + vecDir = m_pPlayer->FireBulletsPlayer(1, vecSrc, vecAiming, VECTOR_CONE_3DEGREES, 8192, BULLET_PLAYER_MP5, 2, 0, m_pPlayer->pev, m_pPlayer->random_seed); int flags; #if defined( CLIENT_WEAPONS ) @@ -221,25 +220,24 @@ void CPar21::SecondaryAttack(void) PLAYBACK_EVENT(0, m_pPlayer->edict(), m_usM203); - m_flNextPrimaryAttack = GetNextAttackDelay(1); - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5;// idle pretty soon after shooting. + m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.9f; + m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.9f; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5.0f;// idle pretty soon after shooting. } void CPar21::Reload(void) { - if (m_pPlayer->ammo_par21 <= 0) - return; - - int iAnim = PAR21_RELOAD; - int iResult = DefaultReload(PAR21_MAX_CLIP, iAnim, 1.5); - - if ( iResult ) - { - PLAYBACK_EVENT_FULL(0, m_pPlayer->edict(), m_usReload, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, iAnim, 0, 0, 0); - } + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == PAR21_MAX_CLIP ) + return; + + DefaultReload( PAR21_MAX_CLIP, PAR21_RELOAD, 1.6 ); } +BOOL CPar21::IsUseable() +{ + //Can be used if the player has AR grenades. - Solokiller + return CBasePlayerWeapon::IsUseable() || m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType] > 0; +} void CPar21::WeaponIdle(void) { @@ -285,7 +283,7 @@ class CPar21AmmoClip : public CBasePlayerAmmo } BOOL AddAmmo(CBaseEntity *pOther) { - int bResult = (pOther->GiveAmmo(AMMO_PAR21CLIP_GIVE, "par21", PAR21_MAX_CARRY) != -1); + int bResult = (pOther->GiveAmmo(AMMO_PAR21CLIP_GIVE, "NATO", PAR21_MAX_CARRY) != -1); if (bResult) { EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM); @@ -293,8 +291,8 @@ class CPar21AmmoClip : public CBasePlayerAmmo return bResult; } }; -LINK_ENTITY_TO_CLASS(ammo_par21_clip, CPar21AmmoClip); - +LINK_ENTITY_TO_CLASS(ammo_par21_clip, CPar21AmmoClip) +LINK_ENTITY_TO_CLASS(ammo_natoclip, CPar21AmmoClip) class CM203GrenadeAmmo : public CBasePlayerAmmo { @@ -320,5 +318,5 @@ class CM203GrenadeAmmo : public CBasePlayerAmmo return bResult; } }; -LINK_ENTITY_TO_CLASS(ammo_par21_grenade, CM203GrenadeAmmo); -LINK_ENTITY_TO_CLASS(ammo_m203grenade, CM203GrenadeAmmo); \ No newline at end of file +LINK_ENTITY_TO_CLASS(ammo_par21_grenade, CM203GrenadeAmmo) +LINK_ENTITY_TO_CLASS(ammo_m203grenade, CM203GrenadeAmmo) diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 032a7884..6a1af794 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -170,8 +170,6 @@ void DecalGunshot( TraceResult *pTrace, int iBulletType ) case BULLET_MONSTER_MP5: case BULLET_PLAYER_BUCKSHOT: case BULLET_PLAYER_357: - case BULLET_PLAYER_NAIL: - case BULLET_PLAYER_PAR21: default: // smoke and decal UTIL_GunshotDecalTrace( pTrace, DamageDecal( pEntity, DMG_BULLET ) ); @@ -298,6 +296,7 @@ void W_Precache( void ) // common world objects UTIL_PrecacheOther( "item_suit" ); + UTIL_PrecacheOther( "item_healthkit" ); UTIL_PrecacheOther( "item_battery" ); UTIL_PrecacheOther( "item_antidote" ); UTIL_PrecacheOther( "item_security" ); @@ -336,13 +335,9 @@ void W_Precache( void ) g_sModelIndexBloodSpray = PRECACHE_MODEL( "sprites/bloodspray.spr" ); // initial blood g_sModelIndexBloodDrop = PRECACHE_MODEL( "sprites/blood.spr" ); // splattered blood - g_sModelIndexLaser = PRECACHE_MODEL( (char *)g_pModelNameLaser ); + g_sModelIndexLaser = PRECACHE_MODEL( g_pModelNameLaser ); g_sModelIndexLaserDot = PRECACHE_MODEL( "sprites/laserdot.spr" ); - g_sModelIndexShockwave = PRECACHE_MODEL( "sprites/shockwave.spr" ); // shockwave explosion - - PRECACHE_MODEL( "sprites/wallsmoke.spr" ); - // used by explosions PRECACHE_MODEL( "models/grenade.mdl" ); PRECACHE_MODEL( "sprites/explode1.spr" ); @@ -361,11 +356,6 @@ void W_Precache( void ) PRECACHE_SOUND( "items/weapondrop1.wav" );// weapon falls to the ground PRECACHE_MODEL( "models/w_grenade.mdl" ); - - PRECACHE_SOUND( "weapons/brad_hit1.wav" ); // hit by nail - PRECACHE_SOUND( "weapons/brad_hit2.wav" ); // hit by nail - - UTIL_PrecacheOther( "fire_trail" ); // pipebomb explosion effect. } TYPEDESCRIPTION CBasePlayerItem::m_SaveData[] = @@ -469,7 +459,7 @@ void CBasePlayerItem::Materialize( void ) pev->solid = SOLID_TRIGGER; UTIL_SetOrigin( pev, pev->origin );// link into world. - SetTouch( &CBasePlayerItem::DefaultTouch); + SetTouch( &CBasePlayerItem::DefaultTouch ); SetThink( NULL ); } @@ -515,7 +505,7 @@ CBaseEntity* CBasePlayerItem::Respawn( void ) { // make a copy of this weapon that is invisible and inaccessible to players (no touch function). The weapon spawn/respawn code // will decide when to make the weapon visible and touchable. - CBaseEntity *pNewWeapon = CBaseEntity::Create( (char *)STRING( pev->classname ), g_pGameRules->VecWeaponRespawnSpot( this ), pev->angles, pev->owner ); + CBaseEntity *pNewWeapon = CBaseEntity::Create( STRING( pev->classname ), g_pGameRules->VecWeaponRespawnSpot( this ), pev->angles, pev->owner ); if( pNewWeapon ) { @@ -582,17 +572,17 @@ BOOL CanAttack( float attack_time, float curtime, BOOL isPredicted ) void CBasePlayerWeapon::ItemPostFrame( void ) { + WeaponTick(); + if( ( m_fInReload ) && ( m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase() ) ) { // complete the reload. - int j = min( iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); + int j = Q_min( iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); // Add them to the clip m_iClip += j; m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= j; - m_pPlayer->TabulateAmmo(); - m_fInReload = FALSE; } @@ -608,7 +598,6 @@ void CBasePlayerWeapon::ItemPostFrame( void ) m_fFireOnEmpty = TRUE; } - m_pPlayer->TabulateAmmo(); SecondaryAttack(); m_pPlayer->pev->button &= ~IN_ATTACK2; } @@ -619,7 +608,6 @@ void CBasePlayerWeapon::ItemPostFrame( void ) m_fFireOnEmpty = TRUE; } - m_pPlayer->TabulateAmmo(); PrimaryAttack(); } else if( m_pPlayer->pev->button & IN_RELOAD && iMaxClip() != WEAPON_NOCLIP && !m_fInReload ) @@ -666,8 +654,8 @@ void CBasePlayerItem::DestroyItem( void ) { if( m_pPlayer ) { - // if attached to a player, remove. - m_pPlayer->RemovePlayerItem( this ); + // if attached to a player, remove. + m_pPlayer->RemovePlayerItem( this, false ); } Kill(); @@ -709,7 +697,7 @@ void CBasePlayerItem::AttachToPlayer( CBasePlayer *pPlayer ) pev->modelindex = 0;// server won't send down to clients if modelindex == 0 pev->model = iStringNull; pev->owner = pPlayer->edict(); - pev->nextthink = gpGlobals->time + .1; + pev->nextthink = 0;// Remove think - prevents futher attempts to materialize SetTouch( NULL ); SetThink( NULL ); } @@ -828,7 +816,7 @@ BOOL CBasePlayerWeapon::AddPrimaryAmmo( int iCount, char *szName, int iMaxClip, else if( m_iClip == 0 ) { int i; - i = min( m_iClip + iCount, iMaxClip ) - m_iClip; + i = Q_min( m_iClip + iCount, iMaxClip ) - m_iClip; m_iClip += i; iIdAmmo = m_pPlayer->GiveAmmo( iCount - i, szName, iMaxCarry ); } @@ -919,12 +907,11 @@ BOOL CBasePlayerWeapon::CanDeploy( void ) return TRUE; } -BOOL CBasePlayerWeapon::DefaultDeploy( char *szViewModel, char *szWeaponModel, int iAnim, char *szAnimExt, int skiplocal /* = 0 */, int body ) +BOOL CBasePlayerWeapon::DefaultDeploy( const char *szViewModel, const char *szWeaponModel, int iAnim, const char *szAnimExt, int skiplocal /* = 0 */, int body ) { if( !CanDeploy() ) return FALSE; - m_pPlayer->TabulateAmmo(); m_pPlayer->pev->viewmodel = MAKE_STRING( szViewModel ); m_pPlayer->pev->weaponmodel = MAKE_STRING( szWeaponModel ); strcpy( m_pPlayer->m_szAnimExtention, szAnimExt ); @@ -942,7 +929,7 @@ BOOL CBasePlayerWeapon::DefaultReload( int iClipSize, int iAnim, float fDelay, i if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) return FALSE; - int j = min( iClipSize - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ); + int j = Q_min( iClipSize - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ); if( j == 0 ) return FALSE; @@ -1029,6 +1016,7 @@ void CBasePlayerAmmo::Materialize( void ) } SetTouch( &CBasePlayerAmmo::DefaultTouch ); + SetThink( NULL ); } void CBasePlayerAmmo::DefaultTouch( CBaseEntity *pOther ) @@ -1117,7 +1105,17 @@ void CBasePlayerWeapon::RetireWeapon( void ) m_pPlayer->pev->weaponmodel = iStringNull; //m_pPlayer->pev->viewmodelindex = NULL; - g_pGameRules->GetNextBestWeapon( m_pPlayer, this ); + if( !g_pGameRules->GetNextBestWeapon( m_pPlayer, this ) ) + { + // Another weapon wasn't selected. Get rid of current one + if( m_pPlayer->m_pActiveItem == this ) + { + m_pPlayer->ResetAutoaim(); + m_pPlayer->m_pActiveItem->Holster(); + m_pPlayer->m_pLastItem = NULL; + m_pPlayer->m_pActiveItem = NULL; + } + } } //========================================================================= @@ -1234,6 +1232,18 @@ void CWeaponBox::Kill( void ) UTIL_Remove( this ); } +static const char* IsAmmoForExhaustibleWeapon(const char* ammoName, int& weaponId) +{ + for (int i=0; im_rgpPlayerItems[j]; + while( pPlayerItem ) + { + if (pPlayerItem->m_iId == exhaustibleWeaponId) { + foundWeapon = true; + break; + } + pPlayerItem = pPlayerItem->m_pNext; + } + } + if (!foundWeapon) { + CBasePlayerWeapon* weapon = (CBasePlayerWeapon*)Create(weaponName, pev->origin, pev->angles); + if (weapon) { + weapon->pev->spawnflags |= SF_NORESPAWN; + weapon->m_iDefaultAmmo = 0; + if (pPlayer->AddPlayerItem(weapon)) { + weapon->AttachToPlayer(pPlayer); + } + } + } + } + // there's some ammo of this type. - pPlayer->GiveAmmo( m_rgAmmo[i], (char *)STRING( m_rgiszAmmo[i] ), MaxAmmoCarry( m_rgiszAmmo[i] ) ); + pPlayer->GiveAmmo( m_rgAmmo[i], STRING( m_rgiszAmmo[i] ), MaxAmmoCarry( m_rgiszAmmo[i] ) ); //ALERT( at_console, "Gave %d rounds of %s\n", m_rgAmmo[i], STRING( m_rgiszAmmo[i] ) ); @@ -1319,7 +1358,7 @@ BOOL CWeaponBox::PackWeapon( CBasePlayerItem *pWeapon ) if( pWeapon->m_pPlayer ) { - if( !pWeapon->m_pPlayer->RemovePlayerItem( pWeapon ) ) + if( !pWeapon->m_pPlayer->RemovePlayerItem( pWeapon, true ) ) { // failed to unhook the weapon from the player! return FALSE; @@ -1376,7 +1415,7 @@ BOOL CWeaponBox::PackAmmo( int iszName, int iCount ) if( iMaxCarry != -1 && iCount > 0 ) { //ALERT( at_console, "Packed %d rounds of %s\n", iCount, STRING( iszName ) ); - GiveAmmo( iCount, (char *)STRING( iszName ), iMaxCarry ); + GiveAmmo( iCount, STRING( iszName ), iMaxCarry ); return TRUE; } @@ -1386,7 +1425,7 @@ BOOL CWeaponBox::PackAmmo( int iszName, int iCount ) //========================================================= // CWeaponBox - GiveAmmo //========================================================= -int CWeaponBox::GiveAmmo( int iCount, char *szName, int iMax, int *pIndex/* = NULL*/ ) +int CWeaponBox::GiveAmmo( int iCount, const char *szName, int iMax, int *pIndex/* = NULL*/ ) { int i; @@ -1397,7 +1436,7 @@ int CWeaponBox::GiveAmmo( int iCount, char *szName, int iMax, int *pIndex/* = NU if( pIndex ) *pIndex = i; - int iAdd = min( iCount, iMax - m_rgAmmo[i] ); + int iAdd = Q_min( iCount, iMax - m_rgAmmo[i] ); if( iCount == 0 || iAdd > 0 ) { m_rgAmmo[i] += iAdd; @@ -1502,7 +1541,7 @@ IMPLEMENT_SAVERESTORE( CRpg, CBasePlayerWeapon ) TYPEDESCRIPTION CRpgRocket::m_SaveData[] = { DEFINE_FIELD( CRpgRocket, m_flIgniteTime, FIELD_TIME ), - DEFINE_FIELD( CRpgRocket, m_pLauncher, FIELD_CLASSPTR ), + DEFINE_FIELD( CRpgRocket, m_hLauncher, FIELD_EHANDLE ), }; IMPLEMENT_SAVERESTORE( CRpgRocket, CGrenade ) @@ -1511,67 +1550,43 @@ 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 ), }; IMPLEMENT_SAVERESTORE( CShotgun, CBasePlayerWeapon ) -TYPEDESCRIPTION CGauss::m_SaveData[] = +TYPEDESCRIPTION CCrossbow::m_SaveData[] = { - DEFINE_FIELD( CGauss, m_fInAttack, FIELD_INTEGER ), + DEFINE_FIELD( CCrossbow, m_fInAttack, FIELD_INTEGER ), + DEFINE_FIELD( CCrossbow, m_fInZoom, FIELD_INTEGER ), +}; + +IMPLEMENT_SAVERESTORE( CCrossbow, CBasePlayerWeapon ) + +TYPEDESCRIPTION CXS::m_SaveData[] = +{ + DEFINE_FIELD( CXS, m_fInAttack, FIELD_INTEGER ), //DEFINE_FIELD( CGauss, m_flStartCharge, FIELD_TIME ), //DEFINE_FIELD( CGauss, m_flPlayAftershock, FIELD_TIME ), //DEFINE_FIELD( CGauss, m_flNextAmmoBurn, FIELD_TIME ), - DEFINE_FIELD( CGauss, m_fPrimaryFire, FIELD_BOOLEAN ), + DEFINE_FIELD( CXS, m_fPrimaryFire, FIELD_BOOLEAN ), }; -IMPLEMENT_SAVERESTORE( CGauss, CBasePlayerWeapon ) +IMPLEMENT_SAVERESTORE( CXS, CBasePlayerWeapon ) -TYPEDESCRIPTION CEgon::m_SaveData[] = +TYPEDESCRIPTION CPipebomb::m_SaveData[] = { - //DEFINE_FIELD( CEgon, m_pBeam, FIELD_CLASSPTR ), - //DEFINE_FIELD( CEgon, m_pNoise, FIELD_CLASSPTR ), - //DEFINE_FIELD( CEgon, m_pSprite, FIELD_CLASSPTR ), - DEFINE_FIELD( CEgon, m_shootTime, FIELD_TIME ), - DEFINE_FIELD( CEgon, m_fireState, FIELD_INTEGER ), - DEFINE_FIELD( CEgon, m_fireMode, FIELD_INTEGER ), - DEFINE_FIELD( CEgon, m_shakeTime, FIELD_TIME ), - DEFINE_FIELD( CEgon, m_flAmmoUseTime, FIELD_TIME ), + DEFINE_FIELD( CPipebomb, m_chargeReady, FIELD_INTEGER ), }; -IMPLEMENT_SAVERESTORE( CEgon, CBasePlayerWeapon ) +IMPLEMENT_SAVERESTORE( CPipebomb, CBasePlayerWeapon ) -TYPEDESCRIPTION CSatchel::m_SaveData[] = +TYPEDESCRIPTION CPipebombCharge::m_SaveData[] = { - DEFINE_FIELD( CSatchel, m_chargeReady, FIELD_INTEGER ), + DEFINE_FIELD( CPipebombCharge, m_flDropTime, FIELD_FLOAT ), + DEFINE_FIELD( CPipebombCharge, m_iTrail, FIELD_INTEGER ), + DEFINE_FIELD( CPipebombCharge, m_hOwner, FIELD_EHANDLE ), }; -IMPLEMENT_SAVERESTORE( CSatchel, CBasePlayerWeapon ) - -TYPEDESCRIPTION CCmlwbr::m_SaveData[] = -{ - DEFINE_FIELD( CCmlwbr, m_fInAttack, FIELD_INTEGER ), - DEFINE_FIELD( CCmlwbr, m_fInZoom, FIELD_INTEGER ), -}; - -IMPLEMENT_SAVERESTORE( CCmlwbr, CBasePlayerWeapon ) - -TYPEDESCRIPTION CXenSquasher::m_SaveData[] = -{ - DEFINE_FIELD( CXenSquasher, m_fInAttack, FIELD_INTEGER ), - //DEFINE_FIELD( CGauss, m_flStartCharge, FIELD_TIME ), - //DEFINE_FIELD( CGauss, m_flPlayAftershock, FIELD_TIME ), - //DEFINE_FIELD( CGauss, m_flNextAmmoBurn, FIELD_TIME ), - DEFINE_FIELD( CXenSquasher, m_fPrimaryFire, FIELD_BOOLEAN ), -}; - -IMPLEMENT_SAVERESTORE( CXenSquasher, CBasePlayerWeapon ) - -TYPEDESCRIPTION CPipeBomb::m_SaveData[] = -{ - DEFINE_FIELD( CPipeBomb, m_thrownByPlayer, FIELD_INTEGER ), -}; - -IMPLEMENT_SAVERESTORE( CPipeBomb, CSatchel ) +IMPLEMENT_SAVERESTORE( CPipebombCharge, CGrenade ) diff --git a/dlls/weapons.h b/dlls/weapons.h index 92f776b5..c6514e01 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef WEAPONS_H #define WEAPONS_H @@ -20,7 +21,7 @@ class CBasePlayer; extern int gmsgWeapPickup; -void DeactivateSatchels( CBasePlayer *pOwner ); +void DeactivatePipebombs( CBasePlayer *pOwner ); // Contact Grenade / Timed grenade / Satchel Charge class CGrenade : public CBaseMonster @@ -62,16 +63,14 @@ public: #define ITEM_BATTERY 4 #define WEAPON_NONE 0 -#define WEAPON_HEATERPIPE 2 -#define WEAPON_BRADNAILER 3 -#define WEAPON_NAILGUN 4 -#define WEAPON_SHOTGUN 5 -#define WEAPON_CMLWBR 6 -#define WEAPON_XS 7 -#define WEAPON_PIPEBOMB 8 -#define WEAPON_PAR21 9 -#define WEAPON_CROWBAR 10 -#define WEAPON_SATCHEL 11 +#define WEAPON_CROWBAR 1 +#define WEAPON_GLOCK 2 +#define WEAPON_MP5 4 +#define WEAPON_PAR21 5 +#define WEAPON_CROSSBOW 6 +#define WEAPON_SHOTGUN 7 +#define WEAPON_XS 9 +#define WEAPON_SATCHEL 14 #define WEAPON_ALLWEAPONS (~(1<Spawn(); - if( !pSoundEnt ) + if( pSoundEnt ) + { + pSoundEnt->Spawn(); + } + else { ALERT ( at_console, "**COULD NOT CREATE SOUNDENT**\n" ); } @@ -497,9 +501,6 @@ void CWorld::Precache( void ) // ok to call this multiple times, calls after first are ignored. SENTENCEG_Init(); - // init texture type array from materials.txt - TEXTURETYPE_Init(); - // the area based ambient sounds MUST be the first precache_sounds // player precaches W_Precache(); // get weapon precaches @@ -582,14 +583,14 @@ void CWorld::Precache( void ) // 63 testing LIGHT_STYLE( 63, "a" ); - for( int i = 0; i < ARRAYSIZE( gDecals ); i++ ) + for( int i = 0; i < (int)ARRAYSIZE( gDecals ); i++ ) gDecals[i].index = DECAL_INDEX( gDecals[i].name ); // init the WorldGraph. WorldGraph.InitGraph(); // make sure the .NOD file is newer than the .BSP file. - if( !WorldGraph.CheckNODFile( ( char * )STRING( gpGlobals->mapname ) ) ) + if( !WorldGraph.CheckNODFile( STRING( gpGlobals->mapname ) ) ) { // NOD file is not present, or is older than the BSP file. WorldGraph.AllocNodes(); @@ -597,7 +598,7 @@ void CWorld::Precache( void ) else { // Load the node graph for this level - if( !WorldGraph.FLoadGraph ( (char *)STRING( gpGlobals->mapname ) ) ) + if( !WorldGraph.FLoadGraph( STRING( gpGlobals->mapname ) ) ) { // couldn't load, so alloc and prepare to build a graph. ALERT( at_console, "*Error opening .NOD file\n" ); @@ -631,6 +632,17 @@ void CWorld::Precache( void ) } } + if( pev->spawnflags & SF_WORLD_AMBIENT_MP3 ) + { + CAmbientMP3 *pMPlayer = CAmbientMP3::AmbientMP3Create( "#po_soundtrack#" ); + + if( pMPlayer ) + { + pMPlayer->SetThink( &CBaseEntity::SUB_CallUseToggle ); + pMPlayer->pev->nextthink = gpGlobals->time + 1.0f; + } + pev->spawnflags &= ~SF_WORLD_AMBIENT_MP3; + } if( pev->spawnflags & SF_WORLD_DARK ) CVAR_SET_FLOAT( "v_dark", 1.0 ); else @@ -663,6 +675,8 @@ void CWorld::Precache( void ) // void CWorld::KeyValue( KeyValueData *pkvd ) { + if( !( pev->spawnflags & SF_WORLD_AMBIENT_MP3 ) ) + pev->spawnflags |= SF_WORLD_AMBIENT_MP3; if( FStrEq( pkvd->szKeyName, "skyname" ) ) { // Sent over net now. diff --git a/dlls/xen.cpp b/dlls/xen.cpp index 8e9c771c..1d86beb3 100644 --- a/dlls/xen.cpp +++ b/dlls/xen.cpp @@ -98,7 +98,7 @@ void CXenPLight::Spawn( void ) 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->SetTransparency( kRenderGlow, pev->rendercolor.x, pev->rendercolor.y, pev->rendercolor.z, pev->renderamt, pev->renderfx ); + 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 ); } @@ -444,9 +444,9 @@ CXenHull *CXenHull::CreateHull( CBaseEntity *source, const Vector &mins, const V CXenHull *pHull = GetClassPtr( (CXenHull *)NULL ); UTIL_SetOrigin( pHull->pev, source->pev->origin + offset ); - SET_MODEL( pHull->edict(), STRING(source->pev->model) ); + SET_MODEL( pHull->edict(), STRING( source->pev->model ) ); pHull->pev->solid = SOLID_BBOX; - pHull->pev->classname = MAKE_STRING("xen_hull"); + pHull->pev->classname = MAKE_STRING( "xen_hull" ); pHull->pev->movetype = MOVETYPE_NONE; pHull->pev->owner = source->edict(); UTIL_SetSize( pHull->pev, mins, maxs ); @@ -497,7 +497,7 @@ void CXenSporeLarge::Spawn( void ) UTIL_MakeVectorsPrivate( pev->angles, forward, right, NULL ); // Rotate the leg hulls into position - for( int i = 0; i < ARRAYSIZE( m_hullSizes ); i++ ) + for( int i = 0; i < (int)ARRAYSIZE( m_hullSizes ); i++ ) CXenHull::CreateHull( this, Vector( -12, -12, 0 ), Vector( 12, 12, 120 ), ( m_hullSizes[i].x * forward ) + ( m_hullSizes[i].y * right ) ); } @@ -527,7 +527,7 @@ const char *CXenSpore::pModelNames[] = void CXenSpore::Precache( void ) { - PRECACHE_MODEL( (char *)pModelNames[pev->skin] ); + PRECACHE_MODEL( pModelNames[pev->skin] ); } void CXenSpore::Touch( CBaseEntity *pOther ) @@ -536,7 +536,7 @@ void CXenSpore::Touch( CBaseEntity *pOther ) void CXenSpore::Think( void ) { - float flInterval = StudioFrameAdvance(); + StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; #if 0 DispatchAnimEvents( flInterval ); diff --git a/dlls/zombie.cpp b/dlls/zombie.cpp index 7fe416c7..96f032e6 100644 --- a/dlls/zombie.cpp +++ b/dlls/zombie.cpp @@ -169,13 +169,15 @@ 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, 100 + RANDOM_LONG( -5, 5 ) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pIdleSounds[RANDOM_LONG( 0, ARRAYSIZE( pIdleSounds ) -1 )], 1.0, ATTN_NORM, 0, pitch ); } 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, 100 + RANDOM_LONG( -5, 5 ) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pAttackSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackSounds ) - 1 )], 1.0, ATTN_NORM, 0, pitch ); } //========================================================= @@ -264,7 +266,7 @@ void CZombie::Spawn() { Precache(); - SET_MODEL( ENT(pev), "models/zombie.mdl" ); + SET_MODEL( ENT( pev ), "models/zombie.mdl" ); UTIL_SetSize( pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX ); pev->solid = SOLID_SLIDEBOX; @@ -284,27 +286,27 @@ void CZombie::Spawn() //========================================================= void CZombie::Precache() { - int i; + size_t i; PRECACHE_MODEL( "models/zombie.mdl" ); for( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackHitSounds[i] ); + PRECACHE_SOUND( pAttackHitSounds[i] ); for( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackMissSounds[i] ); + PRECACHE_SOUND( pAttackMissSounds[i] ); for( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackSounds[i] ); + PRECACHE_SOUND( pAttackSounds[i] ); for( i = 0; i < ARRAYSIZE( pIdleSounds ); i++ ) - PRECACHE_SOUND( (char *)pIdleSounds[i] ); + PRECACHE_SOUND( pIdleSounds[i] ); for( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) - PRECACHE_SOUND( (char *)pAlertSounds[i] ); + PRECACHE_SOUND( pAlertSounds[i] ); for( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) - PRECACHE_SOUND( (char *)pPainSounds[i] ); + PRECACHE_SOUND( pPainSounds[i] ); } //========================================================= diff --git a/engine/cdll_exp.h b/engine/cdll_exp.h index bf43654c..e4c1f5d8 100644 --- a/engine/cdll_exp.h +++ b/engine/cdll_exp.h @@ -12,6 +12,7 @@ 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 @@ -66,4 +67,4 @@ typedef struct cldll_func_s 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 \ No newline at end of file +#endif//CDLL_EXP_H diff --git a/engine/cdll_int.h b/engine/cdll_int.h index eaa7f4e8..abfc43bd 100644 --- a/engine/cdll_int.h +++ b/engine/cdll_int.h @@ -18,7 +18,7 @@ // 4-23-98 // JOHN: client dll interface declarations // - +#pragma once #ifndef CDLL_INT_H #define CDLL_INT_H @@ -93,7 +93,7 @@ typedef struct client_textmessage_s const char *pMessage; } client_textmessage_t; -#if __MSC_VER == 1200 +#if _MSC_VER == 1200 #define ulonglong_t __int64 #else #define ulonglong_t unsigned long long @@ -128,7 +128,7 @@ typedef struct cl_enginefuncs_s void (*pfnSPR_DrawAdditive)( int frame, int x, int y, const wrect_t *prc ); void (*pfnSPR_EnableScissor)( int x, int y, int width, int height ); void (*pfnSPR_DisableScissor)( void ); - client_sprite_t *(*pfnSPR_GetList)( char *psz, int *piCount ); + client_sprite_t *(*pfnSPR_GetList)( const char *psz, int *piCount ); // screen handlers void (*pfnFillRGBA)( int x, int y, int width, int height, int r, int g, int b, int a ); @@ -136,20 +136,20 @@ typedef struct cl_enginefuncs_s void (*pfnSetCrosshair)( HSPRITE hspr, wrect_t rc, int r, int g, int b ); // cvar handlers - struct cvar_s *(*pfnRegisterVariable)( char *szName, char *szValue, int flags ); - float (*pfnGetCvarFloat)( char *szName ); - char* (*pfnGetCvarString)( char *szName ); + struct cvar_s *(*pfnRegisterVariable)( const char *szName, const char *szValue, int flags ); + float (*pfnGetCvarFloat)( const char *szName ); + char* (*pfnGetCvarString)( const char *szName ); // command handlers - int (*pfnAddCommand)( char *cmd_name, void (*function)(void) ); - int (*pfnHookUserMsg)( char *szMsgName, pfnUserMsgHook pfn ); - int (*pfnServerCmd)( char *szCmdString ); - int (*pfnClientCmd)( char *szCmdString ); + int (*pfnAddCommand)( const char *cmd_name, void (*function)(void) ); + int (*pfnHookUserMsg)( const char *szMsgName, pfnUserMsgHook pfn ); + int (*pfnServerCmd)( const char *szCmdString ); + int (*pfnClientCmd)( const char *szCmdString ); void (*pfnGetPlayerInfo)( int ent_num, hud_player_info_t *pinfo ); // sound handlers - void (*pfnPlaySoundByName)( char *szSound, float volume ); + void (*pfnPlaySoundByName)( const char *szSound, float volume ); void (*pfnPlaySoundByIndex)( int iSound, float volume ); // vector helpers @@ -158,7 +158,7 @@ typedef struct cl_enginefuncs_s // text message system client_textmessage_t *(*pfnTextMessageGet)( const char *pName ); int (*pfnDrawCharacter)( int x, int y, int number, int r, int g, int b ); - int (*pfnDrawConsoleString)( int x, int y, char *string ); + int (*pfnDrawConsoleString)( int x, int y, const char *string ); void (*pfnDrawSetTextColor)( float r, float g, float b ); void (*pfnDrawConsoleStringLen)( const char *string, int *length, int *height ); @@ -171,19 +171,19 @@ typedef struct cl_enginefuncs_s void (*GetViewAngles)( float * ); void (*SetViewAngles)( float * ); int (*GetMaxClients)( void ); - void (*Cvar_SetValue)( char *cvar, float value ); + void (*Cvar_SetValue)( const char *cvar, float value ); int (*Cmd_Argc)( void ); char *(*Cmd_Argv)( int arg ); - 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, ... ); + void (*Con_Printf)( const char *fmt, ... ); + void (*Con_DPrintf)( const char *fmt, ... ); + void (*Con_NPrintf)( int pos, const char *fmt, ... ); + void (*Con_NXPrintf)( struct con_nprint_s *info, const char *fmt, ... ); const char* (*PhysInfo_ValueForKey)( const char *key ); const char* (*ServerInfo_ValueForKey)( const char *key ); float (*GetClientMaxspeed)( void ); - int (*CheckParm)( char *parm, char **ppnext ); + int (*CheckParm)( const char *parm, const char **ppnext ); void (*Key_Event)( int key, int down ); void (*GetMousePosition)( int *mx, int *my ); @@ -205,14 +205,14 @@ typedef struct cl_enginefuncs_s int (*CL_CreateVisibleEntity)( int type, struct cl_entity_s *ent ); const struct model_s* (*GetSpritePointer)( HSPRITE hSprite ); - void (*pfnPlaySoundByNameAtLocation)( char *szSound, float volume, float *origin ); + void (*pfnPlaySoundByNameAtLocation)( const char *szSound, float volume, float *origin ); unsigned short (*pfnPrecacheEvent)( int type, const char* psz ); void (*pfnPlaybackEvent)( int flags, const struct edict_s *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); void (*pfnWeaponAnim)( int iAnim, int body ); float (*pfnRandomFloat)( float flLow, float flHigh ); - long (*pfnRandomLong)( long lLow, long lHigh ); - void (*pfnHookEvent)( char *name, void ( *pfnEvent )( struct event_args_s *args )); + int (*pfnRandomLong)( int lLow, int lHigh ); + void (*pfnHookEvent)( const char *name, void ( *pfnEvent )( struct event_args_s *args )); int (*Con_IsVisible) (); const char *(*pfnGetGameDirectory)( void ); struct cvar_s *(*pfnGetCvarPointer)( const char *szName ); @@ -223,8 +223,8 @@ typedef struct cl_enginefuncs_s void* (*VGui_GetPanel)( ); void (*VGui_ViewportPaintBackground)( int extents[4] ); - byte* (*COM_LoadFile)( char *path, int usehunk, int *pLength ); - char* (*COM_ParseFile)( char *data, char *token ); + byte* (*COM_LoadFile)( const char *path, int usehunk, int *pLength ); + char* (*COM_ParseFile)( const char *data, const char *token ); void (*COM_FreeFile)( void *buffer ); struct triangleapi_s *pTriAPI; @@ -252,7 +252,7 @@ typedef struct cl_enginefuncs_s // Gets a unique ID for the specified player. This is the same even if you see the player on a different server. // iPlayer is an entity index, so client 0 would use iPlayer=1. // Returns false if there is no player on the server in the specified slot. - qboolean (*GetPlayerUniqueID)(int iPlayer, char playerID[16]); + qboolean (*GetPlayerUniqueID)(int iPlayer, const char playerID[16]); // TrackerID access int (*GetTrackerIDForPlayer)(int playerSlot); @@ -260,7 +260,7 @@ typedef struct cl_enginefuncs_s // Same as pfnServerCmd, but the message goes in the unreliable stream so it can't clog the net stream // (but it might not get there). - int ( *pfnServerCmdUnreliable )( char *szCmdString ); + int ( *pfnServerCmdUnreliable )( const char *szCmdString ); void (*pfnGetMousePos)( struct tagPOINT *ppt ); void (*pfnSetMousePos)( int x, int y ); @@ -285,12 +285,12 @@ typedef struct cl_enginefuncs_s const char *(*LocalPlayerInfo_ValueForKey)( const char* key ); int (*pfnVGUI2DrawCharacter)( int x, int y, int ch, unsigned int font ); int (*pfnVGUI2DrawCharacterAdditive)( int x, int y, int ch, int r, int g, int b, unsigned int font ); - unsigned int (*pfnGetApproxWavePlayLen)( char *filename ); + unsigned int (*pfnGetApproxWavePlayLen)( const char *filename ); void* (*GetCareerGameUI)( void ); // g-cont. !!!! potential crash-point! - void (*Cvar_Set)( char *name, char *value ); + void (*Cvar_Set)( const char *name, const char *value ); int (*pfnIsPlayingCareerMatch)( void ); - void (*pfnPlaySoundVoiceByName)( char *szSound, float volume, int pitch ); - void (*pfnPrimeMusicStream)( char *filename, int looping ); + void (*pfnPlaySoundVoiceByName)( const char *szSound, float volume, int pitch ); + void (*pfnPrimeMusicStream)( const char *filename, int looping ); double (*pfnSys_FloatTime)( void ); // decay funcs @@ -298,7 +298,7 @@ typedef struct cl_enginefuncs_s void (*pfnConstructTutorMessageDecayBuffer)( int *buffer, int buflen ); void (*pfnResetTutorMessageDecayData)( void ); - void (*pfnPlaySoundByNameAtPitch)( char *szSound, float volume, int pitch ); + void (*pfnPlaySoundByNameAtPitch)( const char *szSound, float volume, int pitch ); void (*pfnFillRGBABlend)( int x, int y, int width, int height, int r, int g, int b, int a ); int (*pfnGetAppID)( void ); cmdalias_t *(*pfnGetAliases)( void ); @@ -311,4 +311,4 @@ typedef struct cl_enginefuncs_s } #endif -#endif//CDLL_INT_H \ No newline at end of file +#endif//CDLL_INT_H diff --git a/engine/custom.h b/engine/custom.h index d48ee72d..02aa2089 100644 --- a/engine/custom.h +++ b/engine/custom.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef CUSTOM_H #define CUSTOM_H diff --git a/engine/customentity.h b/engine/customentity.h index 63e672f8..f524ae79 100644 --- a/engine/customentity.h +++ b/engine/customentity.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef CUSTOMENTITY_H #define CUSTOMENTITY_H diff --git a/engine/edict.h b/engine/edict.h index b0469b86..8584a0d9 100644 --- a/engine/edict.h +++ b/engine/edict.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef EDICT_H #define EDICT_H @@ -39,4 +39,4 @@ struct edict_s // other fields from progs come immediately after }; -#endif//EDICT_H \ No newline at end of file +#endif//EDICT_H diff --git a/engine/eiface.h b/engine/eiface.h index 903451f5..f6cf2f51 100644 --- a/engine/eiface.h +++ b/engine/eiface.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef EIFACE_H #define EIFACE_H @@ -57,7 +57,8 @@ typedef enum { force_exactfile, // File on client must exactly match server's file force_model_samebounds, // For model files only, the geometry must fit in the same bbox - force_model_specifybounds // For model files only, the geometry must fit in the specified bbox + force_model_specifybounds, // For model files only, the geometry must fit in the specified bbox + force_model_specifybounds_if_avail // For Steam model files only, the geometry must fit in the specified bbox (if the file is available) } FORCE_TYPE; // Returned by TraceLine @@ -88,18 +89,18 @@ typedef struct int fPlayTrack; } CDStatus; -typedef unsigned long CRC32_t; +typedef unsigned int CRC32_t; // Engine hands this to DLLs for functionality callbacks typedef struct enginefuncs_s { - int (*pfnPrecacheModel)( char* s ); - int (*pfnPrecacheSound)( char* s ); + int (*pfnPrecacheModel)( const char *s ); + int (*pfnPrecacheSound)( const char *s ); void (*pfnSetModel)( edict_t *e, const char *m ); int (*pfnModelIndex)( const char *m ); int (*pfnModelFrames)( int modelIndex ); void (*pfnSetSize)( edict_t *e, const float *rgflMin, const float *rgflMax ); - void (*pfnChangeLevel)( char* s1, char* s2 ); + void (*pfnChangeLevel)( const char *s1, const char *s2 ); void (*pfnGetSpawnParms)( edict_t *ent ); void (*pfnSaveSpawnParms)( edict_t *ent ); float (*pfnVecToYaw)( const float *rgflVector ); @@ -131,12 +132,12 @@ typedef struct enginefuncs_s void (*pfnTraceModel)( const float *v1, const float *v2, int hullNumber, edict_t *pent, TraceResult *ptr ); const char *(*pfnTraceTexture)( edict_t *pTextureEntity, const float *v1, const float *v2 ); void (*pfnTraceSphere)( const float *v1, const float *v2, int fNoMonsters, float radius, edict_t *pentToSkip, TraceResult *ptr ); - void (*pfnGetAimVector)( edict_t* ent, float speed, float *rgflReturn ); - void (*pfnServerCommand)( char* str ); + void (*pfnGetAimVector)( edict_t *ent, float speed, float *rgflReturn ); + void (*pfnServerCommand)( const char *str ); void (*pfnServerExecute)( void ); - void (*pfnClientCommand)( edict_t* pEdict, char* szFmt, ... ); + void (*pfnClientCommand)( edict_t* pEdict, const char *szFmt, ... ); void (*pfnParticleEffect)( const float *org, const float *dir, float color, float count ); - void (*pfnLightStyle)( int style, char* val ); + void (*pfnLightStyle)( int style, const char *val ); int (*pfnDecalIndex)( const char *name ); int (*pfnPointContents)( const float *rgflVector ); void (*pfnMessageBegin)( int msg_dest, int msg_type, const float *pOrigin, edict_t *ed ); @@ -154,9 +155,9 @@ typedef struct enginefuncs_s const char* (*pfnCVarGetString)( const char *szVarName ); void (*pfnCVarSetFloat)( const char *szVarName, float flValue ); void (*pfnCVarSetString)( const char *szVarName, const char *szValue ); - void (*pfnAlertMessage)( ALERT_TYPE atype, char *szFmt, ... ); - void (*pfnEngineFprintf)( FILE *pfile, char *szFmt, ... ); - void* (*pfnPvAllocEntPrivateData)( edict_t *pEdict, long cb ); + void (*pfnAlertMessage)( ALERT_TYPE atype, const char *szFmt, ... ); + void (*pfnEngineFprintf)( FILE *pfile, const char *szFmt, ... ); + void* (*pfnPvAllocEntPrivateData)( edict_t *pEdict, int cb ); void* (*pfnPvEntPrivateData)( edict_t *pEdict ); void (*pfnFreeEntPrivateData)( edict_t *pEdict ); const char *(*pfnSzFromIndex)( int iString ); @@ -171,8 +172,8 @@ typedef struct enginefuncs_s int (*pfnRegUserMsg)( const char *pszName, int iSize ); void (*pfnAnimationAutomove)( const edict_t* pEdict, float flTime ); void (*pfnGetBonePosition)( const edict_t* pEdict, int iBone, float *rgflOrigin, float *rgflAngles ); - unsigned long (*pfnFunctionFromName)( const char *pName ); - const char *(*pfnNameForFunction)( unsigned long function ); + void* (*pfnFunctionFromName)( const char *pName ); + const char *(*pfnNameForFunction)( void *function ); void (*pfnClientPrintf)( edict_t* pEdict, PRINT_TYPE ptype, const char *szMsg ); // JOHN: engine callbacks so game DLL can print messages to individual clients void (*pfnServerPrint)( const char *szMsg ); const char *(*pfnCmd_Args)( void ); // these 3 added @@ -183,12 +184,12 @@ typedef struct enginefuncs_s void (*pfnCRC32_ProcessBuffer)( CRC32_t *pulCRC, void *p, int len ); void (*pfnCRC32_ProcessByte)( CRC32_t *pulCRC, unsigned char ch ); CRC32_t (*pfnCRC32_Final)( CRC32_t pulCRC ); - long (*pfnRandomLong)( long lLow, long lHigh ); + int (*pfnRandomLong)( int lLow, int lHigh ); float (*pfnRandomFloat)( float flLow, float flHigh ); void (*pfnSetView)( const edict_t *pClient, const edict_t *pViewent ); float (*pfnTime)( void ); void (*pfnCrosshairAngle)( const edict_t *pClient, float pitch, float yaw ); - byte* (*pfnLoadFileForMe)( char *filename, int *pLength ); + byte* (*pfnLoadFileForMe)( const char *filename, int *pLength ); void (*pfnFreeFile)( void *buffer ); void (*pfnEndSection)( const char *pszSectionName ); // trigger_endsection int (*pfnCompareFileTime)( char *filename1, char *filename2, int *iCompare ); @@ -200,12 +201,12 @@ typedef struct enginefuncs_s void (*pfnRunPlayerMove)( edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, unsigned short buttons, byte impulse, byte msec ); int (*pfnNumberOfEntities)( void ); char* (*pfnGetInfoKeyBuffer)( edict_t *e ); // passing in NULL gets the serverinfo - char* (*pfnInfoKeyValue)( char *infobuffer, char *key ); - void (*pfnSetKeyValue)( char *infobuffer, char *key, char *value ); - void (*pfnSetClientKeyValue)( int clientIndex, char *infobuffer, char *key, char *value ); - int (*pfnIsMapValid)( char *filename ); + char* (*pfnInfoKeyValue)( char *infobuffer, const char *key ); + void (*pfnSetKeyValue)( char *infobuffer, const char *key, const char *value ); + void (*pfnSetClientKeyValue)( int clientIndex, char *infobuffer, const char *key, const char *value ); + int (*pfnIsMapValid)( const char *filename ); void (*pfnStaticDecal)( const float *origin, int decalIndex, int entityIndex, int modelIndex ); - int (*pfnPrecacheGeneric)( char *s ); + int (*pfnPrecacheGeneric)( const char *s ); int (*pfnGetPlayerUserId)( edict_t *e ); // returns the server assigned userid for this player. useful for logging frags, etc. returns -1 if the edict couldn't be found in the list of clients void (*pfnBuildSoundMsg)( edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch, int msg_dest, int msg_type, const float *pOrigin, edict_t *ed ); int (*pfnIsDedicatedServer)( void ); // is this a dedicated server? @@ -227,7 +228,7 @@ typedef struct enginefuncs_s void (*pfnDeltaSetField) ( struct delta_s *pFields, const char *fieldname ); void (*pfnDeltaUnsetField)( struct delta_s *pFields, const char *fieldname ); - void (*pfnDeltaAddEncoder)( char *name, void (*conditionalencode)( struct delta_s *pFields, const unsigned char *from, const unsigned char *to ) ); + void (*pfnDeltaAddEncoder)( const char *name, void (*conditionalencode)( struct delta_s *pFields, const unsigned char *from, const unsigned char *to ) ); int (*pfnGetCurrentPlayer)( void ); int (*pfnCanSkipPlayer)( const edict_t *player ); int (*pfnDeltaFindField)( struct delta_s *pFields, const char *fieldname ); @@ -235,7 +236,7 @@ typedef struct enginefuncs_s void (*pfnDeltaUnsetFieldByIndex)( struct delta_s *pFields, int fieldNumber ); void (*pfnSetGroupMask)( int mask, int op ); int (*pfnCreateInstancedBaseline)( int classname, struct entity_state_s *baseline ); - void (*pfnCvar_DirectSet)( struct cvar_s *var, char *value ); + void (*pfnCvar_DirectSet)( struct cvar_s *var, const char *value ); // Forces the client and server to be running with the same version of the specified file // ( e.g., a player model ). @@ -244,7 +245,7 @@ typedef struct enginefuncs_s void (*pfnGetPlayerStats)( const edict_t *pClient, int *ping, int *packet_loss ); - void (*pfnAddServerCommand)( char *cmd_name, void (*function) (void) ); + void (*pfnAddServerCommand)( const char *cmd_name, void (*function) (void) ); // For voice communications, set which clients hear eachother. // NOTE: these functions take player entity indices (starting at 1). @@ -255,7 +256,7 @@ typedef struct enginefuncs_s void *(*pfnSequenceGet)( const char *fileName, const char *entryName ); void *(*pfnSequencePickSentence)( const char *groupName, int pickMethod, int *picked ); - int (*pfnGetFileSize)( char *filename ); + int (*pfnGetFileSize)( const char *filename ); unsigned int (*pfnGetApproxWavePlayLen)( const char *filepath ); int (*pfnIsCareerMatch)( void ); int (*pfnGetLocalizedStringLength)( const char *label ); @@ -273,10 +274,10 @@ typedef struct enginefuncs_s // Passed to pfnKeyValue typedef struct KeyValueData_s { - char *szClassName; // in: entity classname - char *szKeyName; // in: name of key - char *szValue; // in: value of key - long fHandled; // out: DLL sets to true if key-value pair was understood + const char *szClassName; // in: entity classname + const char *szKeyName; // in: name of key + const char *szValue; // in: value of key + int fHandled; // out: DLL sets to true if key-value pair was understood } KeyValueData; @@ -354,7 +355,7 @@ typedef enum _fieldtypes FIELD_TYPECOUNT // MUST BE LAST } FIELDTYPE; -#ifndef offsetof +#if !defined(offsetof) && !defined(GNUC) #define offsetof(s,m) (size_t)&(((s *)0)->m) #endif @@ -373,13 +374,15 @@ typedef enum _fieldtypes typedef struct { FIELDTYPE fieldType; - char *fieldName; + const char *fieldName; int fieldOffset; short fieldSize; short flags; } TYPEDESCRIPTION; +#ifndef ARRAYSIZE #define ARRAYSIZE(p) (sizeof(p)/sizeof(p[0])) +#endif typedef struct { @@ -433,7 +436,7 @@ typedef struct void (*pfnPM_Move)( struct playermove_s *ppmove, qboolean server ); void (*pfnPM_Init)( struct playermove_s *ppmove ); - char (*pfnPM_FindTextureType)( char *name ); + char (*pfnPM_FindTextureType)( const char *name ); void (*pfnSetupVisibility)( struct edict_s *pViewEntity, struct edict_s *pClient, unsigned char **pvs, unsigned char **pas ); void (*pfnUpdateClientData) ( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ); int (*pfnAddToFullPack)( struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet ); diff --git a/engine/keydefs.h b/engine/keydefs.h index ea22139f..5593d75a 100644 --- a/engine/keydefs.h +++ b/engine/keydefs.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef KEYDEFS_H #define KEYDEFS_H @@ -130,4 +130,4 @@ #define K_MOUSE4 244 #define K_MOUSE5 245 -#endif//KEYDEFS_H \ No newline at end of file +#endif//KEYDEFS_H diff --git a/engine/menu_int.h b/engine/menu_int.h index 53b0725a..d907bd87 100644 --- a/engine/menu_int.h +++ b/engine/menu_int.h @@ -12,7 +12,7 @@ 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 @@ -155,7 +155,7 @@ typedef struct ui_enginefuncs_s // menu interface is freezed at version 0.75 // new functions starts here float (*pfnRandomFloat)( float flLow, float flHigh ); - long (*pfnRandomLong)( long lLow, long lHigh ); + int (*pfnRandomLong)( int lLow, int lHigh ); void (*pfnSetCursor)( void *hCursor ); // change cursor int (*pfnIsMapValid)( char *filename ); @@ -185,4 +185,4 @@ typedef struct typedef int (*MENUAPI)( UI_FUNCTIONS *pFunctionTable, ui_enginefuncs_t* engfuncs, ui_globalvars_t *pGlobals ); -#endif//MENU_INT_H \ No newline at end of file +#endif//MENU_INT_H diff --git a/engine/mobility_int.h b/engine/mobility_int.h index 88f63315..d8b6120a 100644 --- a/engine/mobility_int.h +++ b/engine/mobility_int.h @@ -34,7 +34,7 @@ extern "C" { #define TOUCH_FL_DEF_HIDE (1U << 6) #define TOUCH_FL_DRAW_ADDITIVE (1U << 7) #define TOUCH_FL_STROKE (1U << 8) -#define TOUCH_FL_PRECISION (1U << 9) +#define TOUCH_FL_PRECISION (1U << 9) typedef struct mobile_engfuncs_s { @@ -65,13 +65,21 @@ typedef struct mobile_engfuncs_s void (*pfnTouchSetClientOnly)( unsigned char state ); // Clean defaults list - void (*pfnTouchResetDefaultButtons)(); + void (*pfnTouchResetDefaultButtons)( void ); + // Draw scaled font for client + int (*pfnDrawScaledCharacter)( int x, int y, int number, int r, int g, int b, float scale ); + + void (*pfnSys_Warn)( const char *format, ... ); + + // Get native object for current platform. + // Pass NULL to arguments to receive an array of available objects or NULL if nothing + void *(*pfnGetNativeObject)( const char *obj ); + + void (*pfnSetCustomClientID)( const char *id ); // To be continued... } mobile_engfuncs_t; -extern mobile_engfuncs_t *gMobileEngfuncs; - // function exported from client // returns 0 on no error otherwise error typedef int (*pfnMobilityInterface)( mobile_engfuncs_t *gMobileEngfuncs ); diff --git a/engine/physint.h b/engine/physint.h index af923a00..2b4ac8f7 100644 --- a/engine/physint.h +++ b/engine/physint.h @@ -12,7 +12,7 @@ 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 @@ -111,4 +111,4 @@ typedef struct physics_interface_s int (*pfnRestoreDecal)( struct decallist_s *entry, edict_t *pEdict, qboolean adjacent ); } physics_interface_t; -#endif//PHYSINT_H \ No newline at end of file +#endif//PHYSINT_H diff --git a/engine/progdefs.h b/engine/progdefs.h index 74004a27..31cfb3cb 100644 --- a/engine/progdefs.h +++ b/engine/progdefs.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef PROGDEFS_H #define PROGDEFS_H @@ -215,4 +215,4 @@ typedef struct entvars_s edict_t *euser4; } entvars_t; -#endif//PROGDEFS_H \ No newline at end of file +#endif//PROGDEFS_H diff --git a/engine/shake.h b/engine/shake.h index c644a476..a3e49324 100644 --- a/engine/shake.h +++ b/engine/shake.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef SHAKE_H #define SHAKE_H @@ -36,7 +36,7 @@ extern int gmsgFade; #define FFADE_OUT 0x0001 // Fade out (not in) #define FFADE_MODULATE 0x0002 // Modulate (don't blend) #define FFADE_STAYOUT 0x0004 // ignores the duration, stays faded out until new ScreenFade message received - +#define FFADE_LONGFADE 0x0008 // used to indicate the fade can be longer than 16 seconds (added for czero) // This structure is sent over the net to describe a screen fade event typedef struct @@ -47,4 +47,4 @@ typedef struct byte r, g, b, a; // fade to color ( max alpha ) } ScreenFade; -#endif // SHAKE_H \ No newline at end of file +#endif // SHAKE_H diff --git a/engine/sprite.h b/engine/sprite.h index afc81a4e..4368c1ac 100644 --- a/engine/sprite.h +++ b/engine/sprite.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef SPRITE_H #define SPRITE_H @@ -99,4 +99,4 @@ typedef struct frametype_t type; } dframetype_t; -#endif//SPRITE_H \ No newline at end of file +#endif//SPRITE_H diff --git a/engine/studio.h b/engine/studio.h index b5b709bb..88254c96 100644 --- a/engine/studio.h +++ b/engine/studio.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef STUDIO_H #define STUDIO_H @@ -33,14 +33,14 @@ Studio models are position independent, so the cache manager can move them. // studio limits #define MAXSTUDIOTRIANGLES 32768 // max triangles per model #define MAXSTUDIOVERTS 4096 // max vertices per submodel -#define MAXSTUDIOSEQUENCES 256 // total animation sequences +#define MAXSTUDIOSEQUENCES 2048 // total animation sequences #define MAXSTUDIOSKINS 256 // total textures #define MAXSTUDIOSRCBONES 512 // bones allowed at source movement #define MAXSTUDIOBONES 128 // total bones actually used #define MAXSTUDIOMODELS 32 // sub-models per model #define MAXSTUDIOBODYPARTS 32 // body parts per submodel #define MAXSTUDIOGROUPS 16 // sequence groups (e.g. barney01.mdl, barney02.mdl, e.t.c) -#define MAXSTUDIOANIMATIONS 512 // max frames per sequence +#define MAXSTUDIOANIMATIONS 2048 // max frames per sequence #define MAXSTUDIOMESHES 256 // max textures per model #define MAXSTUDIOEVENTS 1024 // events per model #define MAXSTUDIOPIVOTS 256 // pivot points @@ -213,11 +213,9 @@ typedef struct cache_user_s typedef struct { char label[32]; // textual name - char name[64]; // file name - cache_user_t cache; // cache index pointer -#ifndef __amd64 - int data; // hack for group 0 -#endif + char name[64]; // file name + int unused1; // was "cache" - index pointer + int unused2; // was "data" - hack for group 0 } mstudioseqgroup_t; // sequence descriptions diff --git a/make_sdk.bat b/make_sdk.bat deleted file mode 100644 index 96602839..00000000 --- a/make_sdk.bat +++ /dev/null @@ -1,62 +0,0 @@ -@echo off -color 5A -echo XashXT Group 2010 (C) -echo Create Xash3D SDK -echo. - -if not exist D:\Xash3D\src_main\xash_sdk/ mkdir D:\Xash3D\src_main\xash_sdk\ -if not exist D:\Xash3D\src_main\xash_sdk\engine/ mkdir D:\Xash3D\src_main\xash_sdk\engine\ -if not exist D:\Xash3D\src_main\xash_sdk\common/ mkdir D:\Xash3D\src_main\xash_sdk\common\ -if not exist D:\Xash3D\src_main\xash_sdk\mainui/ mkdir D:\Xash3D\src_main\xash_sdk\mainui\ -if not exist D:\Xash3D\src_main\xash_sdk\mainui\legacy/ mkdir D:\Xash3D\src_main\xash_sdk\mainui\legacy -if not exist D:\Xash3D\src_main\xash_sdk\utils/ mkdir D:\Xash3D\src_main\xash_sdk\utils\ -if not exist D:\Xash3D\src_main\xash_sdk\utils\makefont/ mkdir D:\Xash3D\src_main\xash_sdk\utils\makefont -if not exist D:\Xash3D\src_main\xash_sdk\utils\vgui/ mkdir D:\Xash3D\src_main\xash_sdk\utils\vgui -if not exist D:\Xash3D\src_main\xash_sdk\utils\vgui\include/ mkdir D:\Xash3D\src_main\xash_sdk\utils\vgui\include -if not exist D:\Xash3D\src_main\xash_sdk\utils\vgui\lib/ mkdir D:\Xash3D\src_main\xash_sdk\utils\vgui\lib -if not exist D:\Xash3D\src_main\xash_sdk\utils\vgui\lib\win32_vc6/ mkdir D:\Xash3D\src_main\xash_sdk\utils\vgui\lib\win32_vc6 -if not exist D:\Xash3D\src_main\xash_sdk\game_launch/ mkdir D:\Xash3D\src_main\xash_sdk\game_launch\ -if not exist D:\Xash3D\src_main\xash_sdk\cl_dll/ mkdir D:\Xash3D\src_main\xash_sdk\cl_dll\ -if not exist D:\Xash3D\src_main\xash_sdkcl_dll\hl/ mkdir D:\Xash3D\src_main\xash_sdk\cl_dll\hl\ -if not exist D:\Xash3D\src_main\xash_sdk\dlls/ mkdir D:\Xash3D\src_main\xash_sdk\dlls\ -if not exist D:\Xash3D\src_main\xash_sdk\dlls\wpn_shared/ mkdir D:\Xash3D\src_main\xash_sdk\dlls\wpn_shared\ -if not exist D:\Xash3D\src_main\xash_sdk\game_shared/ mkdir D:\Xash3D\src_main\xash_sdk\game_shared\ -if not exist D:\Xash3D\src_main\xash_sdk\pm_shared/ mkdir D:\Xash3D\src_main\xash_sdk\pm_shared\ -@copy /Y engine\*.h xash_sdk\engine\*.h -@copy /Y game_launch\*.* xash_sdk\game_launch\*.* -@copy /Y mainui\*.* xash_sdk\mainui\*.* -@copy /Y mainui\legacy\*.* xash_sdk\mainui\legacy\*.* -@copy /Y common\*.* xash_sdk\common\*.* -@copy /Y cl_dll\*.* xash_sdk\cl_dll\*.* -@copy /Y cl_dll\hl\*.* xash_sdk\cl_dll\hl\*.* -@copy /Y dlls\*.* xash_sdk\dlls\*.* -@copy /Y dlls\wpn_shared\*.* xash_sdk\dlls\wpn_shared\*.* -@copy /Y utils\makefont\*.* xash_sdk\utils\makefont\*.* -@copy /Y utils\vgui\include\*.* xash_sdk\utils\vgui\include\*.* -@copy /Y utils\vgui\lib\win32_vc6\*.* xash_sdk\utils\vgui\lib\win32_vc6\*.* -@copy /Y game_shared\*.* xash_sdk\game_shared\*.* -@copy /Y pm_shared\*.* xash_sdk\pm_shared\*.* -@copy /Y xash_sdk.dsw xash_sdk\xash_sdk.dsw -echo Prepare OK! -echo Please wait: creating SDK in progress -C:\Progra~1\WinRar\rar a xash_sdk -dh -k -r -s -df -m5 @xash_sdk.lst >>makesdk.log -if errorlevel 1 goto error -if errorlevel 0 goto ok -:ok -cls -echo SDK was sucessfully created -echo and stored in RAR-chive "xash_sdk" -echo Press any key for exit. :-) -if exist makesdk.log del /f /q makesdk.log -exit -:error -echo ****************************** -echo ***********Error!************* -echo ****************************** -echo *See makesdk.log for details** -echo ****************************** -echo ****************************** -echo. -echo press any key for exit :-( -pause>nul -exit \ No newline at end of file diff --git a/pm_shared/pm_debug.c b/pm_shared/pm_debug.c index 3baccaef..3b0879c7 100644 --- a/pm_shared/pm_debug.c +++ b/pm_shared/pm_debug.c @@ -23,8 +23,10 @@ #include +#ifdef _MSC_VER #pragma warning(disable : 4244) #pragma warning(disable : 4305) +#endif extern playermove_t *pmove; diff --git a/pm_shared/pm_debug.h b/pm_shared/pm_debug.h index 4959d165..6c91d62e 100644 --- a/pm_shared/pm_debug.h +++ b/pm_shared/pm_debug.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef PM_DEBUG_H #define PM_DEBUG_H diff --git a/pm_shared/pm_defs.h b/pm_shared/pm_defs.h index d29bff19..82480806 100644 --- a/pm_shared/pm_defs.h +++ b/pm_shared/pm_defs.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef PM_DEFS_H #define PM_DEFS_H @@ -201,7 +201,7 @@ typedef struct playermove_s pmtrace_t (*PM_PlayerTrace)( float *start, float *end, int traceFlags, int ignore_pe ); #endif struct pmtrace_s *(*PM_TraceLine)( float *start, float *end, int flags, int usehulll, int ignore_pe ); - long (*RandomLong)( long lLow, long lHigh ); + int (*RandomLong)( int lLow, int lHigh ); float (*RandomFloat)( float flLow, float flHigh ); int (*PM_GetModelType)( struct model_s *mod ); void (*PM_GetModelBounds)( struct model_s *mod, float *mins, float *maxs ); diff --git a/pm_shared/pm_info.h b/pm_shared/pm_info.h index 321527f2..9a971d53 100644 --- a/pm_shared/pm_info.h +++ b/pm_shared/pm_info.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef PM_INFO_H #define PM_INFO_H diff --git a/pm_shared/pm_materials.h b/pm_shared/pm_materials.h index cd1051d2..9bc71b72 100644 --- a/pm_shared/pm_materials.h +++ b/pm_shared/pm_materials.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef PM_MATERIALS_H #define PM_MATERIALS_H @@ -28,4 +29,5 @@ #define CHAR_TEX_COMPUTER 'P' #define CHAR_TEX_GLASS 'Y' #define CHAR_TEX_FLESH 'F' +#define CHAR_TEX_SNOW 'N' #endif//PM_MATERIALS_H diff --git a/pm_shared/pm_math.c b/pm_shared/pm_math.c index 3718dc63..4bb4b93f 100644 --- a/pm_shared/pm_math.c +++ b/pm_shared/pm_math.c @@ -25,7 +25,9 @@ // fall over #define ROLL 2 +#ifdef _MSC_VER #pragma warning(disable : 4244) +#endif vec3_t vec3_origin = { 0,0,0 }; int nanmask = 255 << 23; @@ -237,7 +239,7 @@ float AngleBetweenVectors( const vec3_t v1, const vec3_t v2 ) if( !l1 || !l2 ) return 0.0f; - angle = acos( DotProduct( v1, v2 ) ) / ( l1 * l2 ); + angle = acos( DotProduct( v1, v2 ) / ( l1 * l2 ) ); angle = ( angle * 180.0f ) / M_PI; return angle; diff --git a/pm_shared/pm_movevars.h b/pm_shared/pm_movevars.h index 35fa5b4f..53d8ee9c 100644 --- a/pm_shared/pm_movevars.h +++ b/pm_shared/pm_movevars.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // @@ -6,6 +6,7 @@ //============================================================================= // pm_movevars.h +#pragma once #if !defined( PM_MOVEVARSH ) #define PM_MOVEVARSH diff --git a/pm_shared/pm_shared.c b/pm_shared/pm_shared.c index de855a50..ace56595 100644 --- a/pm_shared/pm_shared.c +++ b/pm_shared/pm_shared.c @@ -27,16 +27,20 @@ #include // atoi #include // isspace +int g_bhopcap = 1; + #ifdef CLIENT_DLL - // Spectator Mode - int iJumpSpectator; -extern float vJumpOrigin[3]; -extern float vJumpAngles[3]; +// Spectator Mode +int iJumpSpectator; +extern float vJumpOrigin[3]; +extern float vJumpAngles[3]; #endif static int pm_shared_initialized = 0; +#ifdef _MSC_VER #pragma warning( disable : 4305 ) +#endif playermove_t *pmove = NULL; @@ -87,8 +91,13 @@ playermove_t *pmove = NULL; #define PLAYER_LONGJUMP_SPEED 350 // how fast we longjump +#define PLAYER_DUCKING_MULTIPLIER 0.333 + // double to float warning +#ifdef _MSC_VER #pragma warning(disable : 4244) +#endif + #define max(a, b) (((a) > (b)) ? (a) : (b)) #define min(a, b) (((a) < (b)) ? (a) : (b)) // up / down @@ -159,24 +168,23 @@ void PM_InitTextureTypes() char buffer[512]; int i, j; byte *pMemFile; - int fileSize, filePos; + int fileSize, filePos = 0; static qboolean bTextureTypeInit = false; if( bTextureTypeInit ) return; - memset(&( grgszTextureName[0][0] ), 0, CTEXTURESMAX * CBTEXTURENAMEMAX ); - memset( grgchTextureType, 0, CTEXTURESMAX ); + memset(&( grgszTextureName[0][0] ), 0, sizeof( grgszTextureName ) ); + memset( grgchTextureType, 0, sizeof( grgchTextureType ) ); gcTextures = 0; - fileSize = pmove->COM_FileSize( "sound/materials.txt" ); - pMemFile = pmove->COM_LoadFile( "sound/materials.txt", 5, NULL ); + pMemFile = pmove->COM_LoadFile( "sound/materials.txt", 5, &fileSize ); if( !pMemFile ) return; - memset( buffer, 0, 512 ); - filePos = 0; + memset( buffer, 0, sizeof( buffer ) ); + // for each line in the file... while( pmove->memfgets( pMemFile, fileSize, &filePos, buffer, 511 ) != NULL && (gcTextures < CTEXTURESMAX ) ) { @@ -547,7 +555,7 @@ void PM_UpdateStepSound( void ) float fvol; vec3_t knee; vec3_t feet; - vec3_t center; + //vec3_t center; float height; float speed; float velrun; @@ -590,7 +598,7 @@ void PM_UpdateStepSound( void ) { fWalking = speed < velrun; - VectorCopy( pmove->origin, center ); + //VectorCopy( pmove->origin, center ); VectorCopy( pmove->origin, knee ); VectorCopy( pmove->origin, feet ); @@ -1060,7 +1068,7 @@ Only used by players. Moves along the ground when player is a MOVETYPE_WALK. */ void PM_WalkMove() { - int clip; + //int clip; int oldonground; int i; @@ -1070,7 +1078,7 @@ void PM_WalkMove() vec3_t wishdir; float wishspeed; - vec3_t dest, start; + vec3_t dest; //, start; vec3_t original, originalvel; vec3_t down, downvel; float downdist, updist; @@ -1133,7 +1141,7 @@ void PM_WalkMove() dest[2] = pmove->origin[2]; // first try moving directly to the next spot - VectorCopy( dest, start ); + //VectorCopy( dest, start ); trace = pmove->PM_PlayerTrace( pmove->origin, dest, PM_NORMAL, -1 ); // If we made it all the way, then copy trace end // as new player position. @@ -1156,7 +1164,8 @@ void PM_WalkMove() VectorCopy( pmove->velocity, originalvel ); // velocity. // Slide move - clip = PM_FlyMove(); + //clip = PM_FlyMove(); + PM_FlyMove(); // Copy the results out VectorCopy( pmove->origin, down ); @@ -1181,7 +1190,8 @@ void PM_WalkMove() } // slide move the rest of the way. - clip = PM_FlyMove(); + //clip = PM_FlyMove(); + PM_FlyMove(); // Now try going back down from the end point // press down the stepheight @@ -1992,8 +2002,8 @@ void PM_Duck( void ) int buttonsChanged = ( pmove->oldbuttons ^ pmove->cmd.buttons ); // These buttons have changed this frame int nButtonPressed = buttonsChanged & pmove->cmd.buttons; // The changed ones still down are "pressed" - int duckchange = buttonsChanged & IN_DUCK ? 1 : 0; - int duckpressed = nButtonPressed & IN_DUCK ? 1 : 0; + //int duckchange = buttonsChanged & IN_DUCK ? 1 : 0; + //int duckpressed = nButtonPressed & IN_DUCK ? 1 : 0; if( pmove->cmd.buttons & IN_DUCK ) { @@ -2017,9 +2027,9 @@ void PM_Duck( void ) if( pmove->flags & FL_DUCKING ) { - pmove->cmd.forwardmove *= 0.333; - pmove->cmd.sidemove *= 0.333; - pmove->cmd.upmove *= 0.333; + pmove->cmd.forwardmove *= PLAYER_DUCKING_MULTIPLIER; + pmove->cmd.sidemove *= PLAYER_DUCKING_MULTIPLIER; + pmove->cmd.upmove *= PLAYER_DUCKING_MULTIPLIER; } if( ( pmove->cmd.buttons & IN_DUCK ) || ( pmove->bInDuck ) || ( pmove->flags & FL_DUCKING ) ) @@ -2110,16 +2120,24 @@ void PM_LadderMove( physent_t *pLadder ) { float forward = 0, right = 0; vec3_t vpn, v_right; + float flSpeed = MAX_CLIMB_SPEED; + + // they shouldn't be able to move faster than their maxspeed + if( flSpeed > pmove->maxspeed ) + flSpeed = pmove->maxspeed; AngleVectors( pmove->angles, vpn, v_right, NULL ); + + if( pmove->flags & FL_DUCKING ) + flSpeed *= PLAYER_DUCKING_MULTIPLIER; if( pmove->cmd.buttons & IN_BACK ) - forward -= MAX_CLIMB_SPEED; + forward -= flSpeed; if( pmove->cmd.buttons & IN_FORWARD ) - forward += MAX_CLIMB_SPEED; + forward += flSpeed; if( pmove->cmd.buttons & IN_MOVELEFT ) - right -= MAX_CLIMB_SPEED; + right -= flSpeed; if( pmove->cmd.buttons & IN_MOVERIGHT ) - right += MAX_CLIMB_SPEED; + right += flSpeed; if( pmove->cmd.buttons & IN_JUMP ) { @@ -2251,6 +2269,7 @@ void PM_AddGravity() pmove->basevelocity[2] = 0; PM_CheckVelocity(); } + /* ============ PM_PushEntity @@ -2538,7 +2557,8 @@ void PM_Jump( void ) // In the air now. pmove->onground = -1; - PM_PreventMegaBunnyJumping(); + if( g_bhopcap ) + PM_PreventMegaBunnyJumping(); if( tfc ) { @@ -3291,8 +3311,8 @@ void PM_Move( struct playermove_s *ppmove, int server ) pmove->flags &= ~FL_ONGROUND; } - // In single player, reset friction after each movement to FrictionModifier Triggers work still. - if( !pmove->multiplayer && ( pmove->movetype == MOVETYPE_WALK ) ) + // Reset friction after each movement to FrictionModifier Triggers work still. + if( pmove->movetype == MOVETYPE_WALK ) { pmove->friction = 1.0f; } diff --git a/pm_shared/pm_shared.h b/pm_shared/pm_shared.h index 124d37ba..c315353b 100644 --- a/pm_shared/pm_shared.h +++ b/pm_shared/pm_shared.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef PM_SHARED_H #define PM_SHARED_H diff --git a/release.bat b/release.bat deleted file mode 100644 index dae2d16c..00000000 --- a/release.bat +++ /dev/null @@ -1,42 +0,0 @@ -@echo off - -set MSDEV=BuildConsole -set CONFIG=/ShowTime /ShowAgent /nologo /cfg= -set MSDEV=msdev -set CONFIG=/make -set build_type=release -set BUILD_ERROR= -call vcvars32 - -%MSDEV% engine/engine.dsp %CONFIG%"engine - Win32 Release" %build_target% -if errorlevel 1 set BUILD_ERROR=1 - -%MSDEV% mainui/mainui.dsp %CONFIG%"mainui - Win32 Release" %build_target% -if errorlevel 1 set BUILD_ERROR=1 - -if "%BUILD_ERROR%"=="" goto build_ok - -echo ********************* -echo ********************* -echo *** Build Errors! *** -echo ********************* -echo ********************* -echo press any key to exit -echo ********************* -pause>nul -goto done - - -@rem -@rem Successful build -@rem -:build_ok - -rem //delete log files -if exist engine\engine.plg del /f /q engine\engine.plg -if exist mainui\mainui.plg del /f /q mainui\mainui.plg - -echo -echo Build succeeded! -echo -:done \ No newline at end of file diff --git a/utils/false_vgui/include/VGUI.h b/utils/false_vgui/include/VGUI.h new file mode 100644 index 00000000..c33e0589 --- /dev/null +++ b/utils/false_vgui/include/VGUI.h @@ -0,0 +1,95 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_H +#define VGUI_H + +//If you are going to add stuff to the vgui core... +// +//Keep it simple. +// +//Never put code in a header. +// +//The name of the class is the name of the the file +// +//Each class gets its own .cpp file for its definition and a .h for its header. Helper +//classes can be used but only within the .cpp and not referenceable from anywhere else. +// +//Don't add unneeded files. Keep the API clean. +// +//No platform specific code in vgui\lib-src\vgui dir. Code in vgui\lib-src\vgui should +//only include from vgui\include or standard C includes. ie, if I see windows.h included +//anywhere but vgui\lib-src\win32 I will hunt you down and kill you. Don't give me any crap +//that mfc is platform inspecific. +// +//Always use <> and not "" for includes +// +//Use minimum dependencies in headers. Don't include another header if you can get away +//with forward declaring (which is usually the case) +// +//No macros in headers. They are tools of satan. This also means no use of DEFINEs, use enum +// +//Minimize global functions +// +//No global variables. +// +//Panel is getting pretty plump, try and avoid adding junk to it if you can + +//TODO: Look and Feel support +// add Panel::setPaintProxy, if _paintProxy exists, it calls _paintProxy->paint +// instead of Panel::paint. Components should implement their painting in a seperate +// plugin class. Perhaps to encourage this, Panel::paint should just go away completely +// The other option is to have Panel have the interface Paintable +// class Paintable +// { +// public: +// virtual void paint()=0; +// }; +// Then a component can implement its paint in the class itself and then call +// setPaintProxy(this). If this is the case _paintProxy->paint should always be called +// and never Panel::paint from within paintTraverse +//TODO: Figure out the 'Valve' Look and Feel and implement that instead of a the Java one +//TODO: Determine ownership policy for Borders, Layouts, etc.. +//TODO: tooltips support +//TODO: ComboKey (hot key support) +//TODO: add Background.cpp, remove paintBackground from all components +// Panel implements setBackground, Panel::paintBackground calls _background->paintBackground +// similiar to the way Border works. +//TODO: Builtin components should never overide paintBackground, only paint +//TODO: All protected members should be converted to private +//TODO: All member variables should be moved to the top of the class prototype +//TODO: All private methods should be prepended with private +//TODO: Use of word internal in method names is not consistent and confusing +//TODO: Cleanup so bullshit publics are properly named, maybe even figure out +// a naming convention for them +//TODO: Breakup InputSignal into logical pieces +//TODO: Button is in a state of disarray, it should have ButtonModel support +//TODO: get rid of all the stupid strdup laziness, convert to vgui_strdup +//TODO: actually figure out policy on String and implement it consistently +//TODO: implement createLayoutInfo for other Layouts than need it +//TODO: BorderLayout should have option for a null LayoutInfo defaulting to center +//TODO: SurfaceBase should go away, put it in Surface +//TODO: ActionSignals and other Signals should just set a flag when they fire. +// then App can come along later and fire all the signals +//TODO: Change all method naming to starting with a capital letter. + +#ifdef _WIN32 +# define VGUIAPI __declspec( dllexport ) +#else +# define VGUIAPI __attribute__ ((visibility("default"))) +#include // size_t define +#endif + +#define null 0L + +typedef unsigned char uchar; +typedef unsigned short ushort; +typedef unsigned int uint; +typedef unsigned long ulong; + +#endif + diff --git a/utils/false_vgui/include/VGUI_App.h b/utils/false_vgui/include/VGUI_App.h new file mode 100644 index 00000000..6e70f909 --- /dev/null +++ b/utils/false_vgui/include/VGUI_App.h @@ -0,0 +1,130 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_APP_H +#define VGUI_APP_H + +#include +#include +#include +#include +#include + +namespace vgui +{ + +class Panel; +class TickSignal; +class Scheme; +class TickSignal; +class SurfaceBase; + +class VGUIAPI App +{ +public: + App() {} + App(bool externalMain) {} +public: + static App* getInstance() {return 0;} + //TODO: the public and public bullshit are all messed up, need to organize + //TODO: actually all of the access needs to be properly thought out while you are at it +public: + virtual void start() {} + virtual void stop() {} + virtual void externalTick() {} + virtual bool wasMousePressed(MouseCode code,Panel* panel) {return false;} + virtual bool wasMouseDoublePressed(MouseCode code,Panel* panel) {return false;} + virtual bool isMouseDown(MouseCode code,Panel* panel) {return false;} + virtual bool wasMouseReleased(MouseCode code,Panel* panel) {return false;} + virtual bool wasKeyPressed(KeyCode code,Panel* panel) {return false;} + virtual bool isKeyDown(KeyCode code,Panel* panel) {return false;} + virtual bool wasKeyTyped(KeyCode code,Panel* panel) {return false;} + virtual bool wasKeyReleased(KeyCode code,Panel* panel) {return false;} + virtual void addTickSignal(TickSignal* s) {} + virtual void setCursorPos(int x,int y) {} + virtual void getCursorPos(int& x,int& y) {} + virtual void setMouseCapture(Panel* panel) {} + virtual void setMouseArena(int x0,int y0,int x1,int y1,bool enabled) {} + virtual void setMouseArena(Panel* panel) {} + virtual void requestFocus(Panel* panel) {} + virtual Panel* getFocus() {return 0;} + virtual void repaintAll() {} + virtual void setScheme(Scheme* scheme) {} + virtual Scheme* getScheme() {return 0;} + virtual void enableBuildMode() {} + virtual long getTimeMillis() {return 0;} + virtual char getKeyCodeChar(KeyCode code,bool shifted) {return '\0';} + virtual void getKeyCodeText(KeyCode code,char* buf,int buflen) {} + virtual int getClipboardTextCount() {return 0;} + virtual void setClipboardText(const char* text,int textLen) {} + virtual int getClipboardText(int offset,char* buf,int bufLen) {return 0;} + virtual void reset() {} + virtual void internalSetMouseArena(int x0,int y0,int x1,int y1,bool enabled) {} + virtual bool setRegistryString(const char* key,const char* value) {return false;} + virtual bool getRegistryString(const char* key,char* value,int valueLen) {return false;} + virtual bool setRegistryInteger(const char* key,int value) {return false;} + virtual bool getRegistryInteger(const char* key,int& value) {return false;} + virtual void setCursorOveride(Cursor* cursor) {} + virtual Cursor* getCursorOveride() {return 0;} + virtual void setMinimumTickMillisInterval(int interval) {} +public: //bullshit public stuff + virtual void main(int argc,char* argv[])=0; + virtual void run() {} + virtual void internalCursorMoved(int x,int y,SurfaceBase* surfaceBase) {} //expects input in surface space + virtual void internalMousePressed(MouseCode code,SurfaceBase* surfaceBase) {} + virtual void internalMouseDoublePressed(MouseCode code,SurfaceBase* surfaceBase) {} + virtual void internalMouseReleased(MouseCode code,SurfaceBase* surfaceBase) {} + virtual void internalMouseWheeled(int delta,SurfaceBase* surfaceBase) {} + virtual void internalKeyPressed(KeyCode code,SurfaceBase* surfaceBase) {} + virtual void internalKeyTyped(KeyCode code,SurfaceBase* surfaceBase) {} + virtual void internalKeyReleased(KeyCode code,SurfaceBase* surfaceBase) {} +private: + virtual void init() {} + virtual void updateMouseFocus(int x,int y,SurfaceBase* surfaceBase) {} + virtual void setMouseFocus(Panel* newMouseFocus) {} +protected: + virtual void surfaceBaseCreated(SurfaceBase* surfaceBase) {} + virtual void surfaceBaseDeleted(SurfaceBase* surfaceBase) {} + virtual void platTick() {} + virtual void internalTick() {} +protected: + static App* _instance; +protected: + bool _running; + bool _externalMain; + Dar _surfaceBaseDar; + Panel* _keyFocus; + Panel* _oldMouseFocus; + Panel* _mouseFocus; + Panel* _mouseCapture; + Panel* _wantedKeyFocus; + bool _mousePressed[MOUSE_LAST]; + bool _mouseDoublePressed[MOUSE_LAST]; + bool _mouseDown[MOUSE_LAST]; + bool _mouseReleased[MOUSE_LAST]; + bool _keyPressed[KEY_LAST]; + bool _keyTyped[KEY_LAST]; + bool _keyDown[KEY_LAST]; + bool _keyReleased[KEY_LAST]; + Dar _tickSignalDar; + Scheme* _scheme; + bool _buildMode; + bool _wantedBuildMode; + Panel* _mouseArenaPanel; + Cursor* _cursor[Cursor::dc_last]; + Cursor* _cursorOveride; +private: + long _nextTickMillis; + long _minimumTickMillisInterval; + friend class SurfaceBase; +}; +} + +#endif + + + diff --git a/utils/false_vgui/include/VGUI_Color.h b/utils/false_vgui/include/VGUI_Color.h new file mode 100644 index 00000000..f3fec5c6 --- /dev/null +++ b/utils/false_vgui/include/VGUI_Color.h @@ -0,0 +1,44 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_COLOR_H +#define VGUI_COLOR_H + +#include +#include + +//TODO: rename getColor(r,g,b,a) to getRGBA(r,g,b,a) +//TODO: rename setColor(r,g,b,a) to setRGBA(r,g,b,a) +//TODO: rename getColor(sc) to getSchemeColor(sc) +//TODO: rename setColor(sc) to setSchemeColor(sc) + +namespace vgui +{ + +class VGUIAPI Color +{ +private: + uchar _color[4]; + Scheme::SchemeColor _schemeColor; +public: + Color() {} + Color(int r,int g,int b,int a) {} + Color(Scheme::SchemeColor sc) {} +private: + virtual void init() {} +public: + virtual void setColor(int r,int g,int b,int a) {} + virtual void setColor(Scheme::SchemeColor sc) {} + virtual void getColor(int& r,int& g,int& b,int& a) {} + virtual void getColor(Scheme::SchemeColor& sc) {} + virtual int operator[](int index) {return 0;} +}; + +} + + +#endif diff --git a/utils/false_vgui/include/VGUI_Cursor.h b/utils/false_vgui/include/VGUI_Cursor.h new file mode 100644 index 00000000..8419e2dd --- /dev/null +++ b/utils/false_vgui/include/VGUI_Cursor.h @@ -0,0 +1,57 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_CURSOR_H +#define VGUI_CURSOR_H + +#include + +namespace vgui +{ + +class Bitmap; + +class VGUIAPI Cursor +{ +public: + enum DefaultCursor + { + dc_user, + dc_none, + dc_arrow, + dc_ibeam, + dc_hourglass, + dc_crosshair, + dc_up, + dc_sizenwse, + dc_sizenesw, + dc_sizewe, + dc_sizens, + dc_sizeall, + dc_no, + dc_hand, + dc_last + }; +private: + int _hotspot[2]; + Bitmap* _bitmap; + DefaultCursor _dc; +public: + Cursor(DefaultCursor dc) {} + Cursor(Bitmap* bitmap,int hotspotX,int hotspotY) {} +public: + virtual void getHotspot(int& x,int& y) {} +private: + virtual void privateInit(Bitmap* bitmap,int hotspotX,int hotspotY) {} +public: + virtual Bitmap* getBitmap() {return 0;} + virtual DefaultCursor getDefaultCursor() {return dc_none;} +}; + +} + +#endif diff --git a/utils/false_vgui/include/VGUI_Dar.h b/utils/false_vgui/include/VGUI_Dar.h new file mode 100644 index 00000000..6f8eb513 --- /dev/null +++ b/utils/false_vgui/include/VGUI_Dar.h @@ -0,0 +1,194 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_DAR_H +#define VGUI_DAR_H + +#include +#include +#include + + + +namespace vgui +{ + +//Simple lightweight dynamic array implementation +template class VGUIAPI Dar +{ +public: + Dar() + { + _count=0; + _capacity=0; + _data=null; + ensureCapacity(4); + } + Dar(int initialCapacity) + { + _count=0; + _capacity=0; + _data=null; + ensureCapacity(initialCapacity); + } +public: + void ensureCapacity(int wantedCapacity) + { + if(wantedCapacity<=_capacity){return;} + + //double capacity until it is >= wantedCapacity + //this could be done with math, but iterative is just so much more fun + int newCapacity=_capacity; + if(newCapacity==0){newCapacity=1;} + while(newCapacity_capacity)) + { + return; + } + _count=count; + } + int getCount() + { + return _count; + } + void addElement(ELEMTYPE elem) + { + ensureCapacity(_count+1); + _data[_count]=elem; + _count++; + } + bool hasElement(ELEMTYPE elem) + { + for(int i=0;i<_count;i++) + { + if(_data[i]==elem) + { + return true; + } + } + return false; + } + void putElement(ELEMTYPE elem) + { + if(hasElement(elem)) + { + return; + } + addElement(elem); + } + void insertElementAt(ELEMTYPE elem,int index) + { + if((index<0)||(index>_count)) + { + return; + } + if((index==_count)||(_count==0)) + { + addElement(elem); + } + else + { + addElement(elem); //just to make sure it is big enough + for(int i=_count-1;i>index;i--) + { + _data[i]=_data[i-1]; + } + _data[index]=elem; + } + } + void setElementAt(ELEMTYPE elem,int index) + { + if((index<0)||(index>=_count)) + { + return; + } + _data[index]=elem; + } + void removeElementAt(int index) + { + if((index<0)||(index>=_count)) + { + return; + } + + //slide everything to the right of index, left one. + for(int i=index;i<(_count-1);i++) + { + _data[i]=_data[i+1]; + } + _count--; + } + void removeElement(ELEMTYPE elem) + { + for(int i=0;i<_count;i++) + { + if(_data[i]==elem) + { + removeElementAt(i); + break; + } + } + } + void removeAll() + { + _count=0; + } + ELEMTYPE operator[](int index) + { + if((index<0)||(index>=_count)) + { + return null; + } + return _data[index]; + } +protected: + int _count; + int _capacity; + ELEMTYPE* _data; +}; + +#ifdef _WIN32 +//forward referencing all the template types used so they get exported +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar*>; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +#endif + +} + + +#endif \ No newline at end of file diff --git a/utils/false_vgui/include/VGUI_KeyCode.h b/utils/false_vgui/include/VGUI_KeyCode.h new file mode 100644 index 00000000..b6aea363 --- /dev/null +++ b/utils/false_vgui/include/VGUI_KeyCode.h @@ -0,0 +1,126 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_KEYCODE_H +#define VGUI_KEYCODE_H + +#include + +namespace vgui +{ +enum VGUIAPI KeyCode +{ + KEY_0=0, + KEY_1, + KEY_2, + KEY_3, + KEY_4, + KEY_5, + KEY_6, + KEY_7, + KEY_8, + KEY_9, + KEY_A, + KEY_B, + KEY_C, + KEY_D, + KEY_E, + KEY_F, + KEY_G, + KEY_H, + KEY_I, + KEY_J, + KEY_K, + KEY_L, + KEY_M, + KEY_N, + KEY_O, + KEY_P, + KEY_Q, + KEY_R, + KEY_S, + KEY_T, + KEY_U, + KEY_V, + KEY_W, + KEY_X, + KEY_Y, + KEY_Z, + KEY_PAD_0, + KEY_PAD_1, + KEY_PAD_2, + KEY_PAD_3, + KEY_PAD_4, + KEY_PAD_5, + KEY_PAD_6, + KEY_PAD_7, + KEY_PAD_8, + KEY_PAD_9, + KEY_PAD_DIVIDE, + KEY_PAD_MULTIPLY, + KEY_PAD_MINUS, + KEY_PAD_PLUS, + KEY_PAD_ENTER, + KEY_PAD_DECIMAL, + KEY_LBRACKET, + KEY_RBRACKET, + KEY_SEMICOLON, + KEY_APOSTROPHE, + KEY_BACKQUOTE, + KEY_COMMA, + KEY_PERIOD, + KEY_SLASH, + KEY_BACKSLASH, + KEY_MINUS, + KEY_EQUAL, + KEY_ENTER, + KEY_SPACE, + KEY_BACKSPACE, + KEY_TAB, + KEY_CAPSLOCK, + KEY_NUMLOCK, + KEY_ESCAPE, + KEY_SCROLLLOCK, + KEY_INSERT, + KEY_DELETE, + KEY_HOME, + KEY_END, + KEY_PAGEUP, + KEY_PAGEDOWN, + KEY_BREAK, + KEY_LSHIFT, + KEY_RSHIFT, + KEY_LALT, + KEY_RALT, + KEY_LCONTROL, + KEY_RCONTROL, + KEY_LWIN, + KEY_RWIN, + KEY_APP, + KEY_UP, + KEY_LEFT, + KEY_DOWN, + KEY_RIGHT, + KEY_F1, + KEY_F2, + KEY_F3, + KEY_F4, + KEY_F5, + KEY_F6, + KEY_F7, + KEY_F8, + KEY_F9, + KEY_F10, + KEY_F11, + KEY_F12, + KEY_LAST +}; +} + + +#endif + diff --git a/utils/false_vgui/include/VGUI_MouseCode.h b/utils/false_vgui/include/VGUI_MouseCode.h new file mode 100644 index 00000000..2de259db --- /dev/null +++ b/utils/false_vgui/include/VGUI_MouseCode.h @@ -0,0 +1,24 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_MOUSECODE_H +#define VGUI_MOUSECODE_H + +#include + +namespace vgui +{ +enum VGUIAPI MouseCode +{ + MOUSE_LEFT=0, + MOUSE_RIGHT, + MOUSE_MIDDLE, + MOUSE_LAST +}; +} + +#endif diff --git a/utils/false_vgui/include/VGUI_Panel.h b/utils/false_vgui/include/VGUI_Panel.h new file mode 100644 index 00000000..351b2375 --- /dev/null +++ b/utils/false_vgui/include/VGUI_Panel.h @@ -0,0 +1,228 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_PANEL_H +#define VGUI_PANEL_H + + +/* + +TODO: + +Maybe have the border know who they are added to. +A border can only be added to 1 thing, and will be +removed from the other. That way they can actually +be memory managed. Also do Layout's this way too. + +TODO: + outlinedRect should have a thickness arg + +*/ + + +#include +#include +#include +#include +#include +#include +#include +//#include + +namespace vgui +{ + +enum KeyCode; +enum MouseCode; +class SurfaceBase; +class FocusChangeSignal; +class InputSignal; +class Cursor; +class Layout; +class FocusNavGroup; +class Border; +class Font; +class BuildGroup; +class App; +class LayoutInfo; +class RepaintSignal; + +class VGUIAPI Panel +{ +public: + Panel() {} + Panel(int x,int y,int wide,int tall) {setPos(x, y); setSize(wide, tall);} +private: + void init(int x,int y,int wide,int tall) {} +public: + virtual void setPos(int x,int y) {_pos[0] = x; _pos[1] = y;} + virtual void getPos(int& x,int& y) {x = _pos[0]; y = _pos[1];} + virtual void setSize(int wide,int tall) {_size[0] = wide, _size[1] = tall;} + virtual void getSize(int& wide,int& tall) {wide = _size[0], tall = _size[1];} + virtual void setBounds(int x,int y,int wide,int tall) {} + virtual void getBounds(int& x,int& y,int& wide,int& tall) {} + virtual int getWide() {return _size[0];} + virtual int getTall() {return _size[1];} + virtual Panel* getParent() {return _parent;} + virtual void setVisible(bool state) {_visible = state;} + virtual bool isVisible() {return _visible;} + virtual bool isVisibleUp() {return false;} + virtual void repaint() {} + virtual void repaintAll() {} + virtual void getAbsExtents(int& x0,int& y0,int& x1,int& y1) {} + virtual void getClipRect(int& x0,int& y0,int& x1,int& y1) {} + virtual void setParent(Panel* newParent) {_parent = newParent; newParent->addChild(this);} + virtual void addChild(Panel* child) {} + virtual void insertChildAt(Panel* child,int index) {} + virtual void removeChild(Panel* child) {} + virtual bool wasMousePressed(MouseCode code) {return false;} + virtual bool wasMouseDoublePressed(MouseCode code) {return false;} + virtual bool isMouseDown(MouseCode code) {return false;} + virtual bool wasMouseReleased(MouseCode code) {return false;} + virtual bool wasKeyPressed(KeyCode code) {return false;} + virtual bool isKeyDown(KeyCode code) {return false;} + virtual bool wasKeyTyped(KeyCode code) {return false;} + virtual bool wasKeyReleased(KeyCode code) {return false;} + virtual void addInputSignal(InputSignal* s) {} + virtual void removeInputSignal(InputSignal* s) {} + virtual void addRepaintSignal(RepaintSignal* s) {} + virtual void removeRepaintSignal(RepaintSignal* s) {} + virtual bool isWithin(int x,int y) {return false;} //in screen space + virtual Panel* isWithinTraverse(int x,int y) {return 0;} + virtual void localToScreen(int& x,int& y) {} + virtual void screenToLocal(int& x,int& y) {} + virtual void setCursor(Cursor* cursor) {} + virtual void setCursor(Scheme::SchemeCursor scu) {} + virtual Cursor* getCursor() {return 0;} + virtual void setMinimumSize(int wide,int tall) {} + virtual void getMinimumSize(int& wide,int& tall) {} + virtual void requestFocus() {} + virtual bool hasFocus() {return false;} + virtual int getChildCount() {return 0;} + virtual Panel* getChild(int index) {return 0;} + virtual void setLayout(Layout* layout) {} + virtual void invalidateLayout(bool layoutNow) {} + virtual void setFocusNavGroup(FocusNavGroup* focusNavGroup) {} + virtual void requestFocusPrev() {} + virtual void requestFocusNext() {} + virtual void addFocusChangeSignal(FocusChangeSignal* s) {} + virtual bool isAutoFocusNavEnabled() {return false;} + virtual void setAutoFocusNavEnabled(bool state) {} + virtual void setBorder(Border* border) {} + virtual void setPaintBorderEnabled(bool state) {} + virtual void setPaintBackgroundEnabled(bool state) {} + virtual void setPaintEnabled(bool state) {} + virtual void getInset(int& left,int& top,int& right,int& bottom) {} + virtual void getPaintSize(int& wide,int& tall) {} + virtual void setPreferredSize(int wide,int tall) {} + virtual void getPreferredSize(int& wide,int& tall) {} + virtual SurfaceBase* getSurfaceBase() {return 0;} + virtual bool isEnabled() {return _enabled = false;} + virtual void setEnabled(bool state) {_enabled = true;} + virtual void setBuildGroup(BuildGroup* buildGroup,const char* panelPersistanceName) {} + virtual bool isBuildGroupEnabled() {return false;} + virtual void removeAllChildren() {} + virtual void repaintParent() {} + virtual Panel* createPropertyPanel() {return 0;} + virtual void getPersistanceText(char* buf,int bufLen) {} + virtual void applyPersistanceText(const char* buf) {} + virtual void setFgColor(Scheme::SchemeColor sc) {} + virtual void setBgColor(Scheme::SchemeColor sc) {} + virtual void setFgColor(int r,int g,int b,int a) {} + virtual void setBgColor(int r,int g,int b,int a) {} + virtual void getFgColor(int& r,int& g,int& b,int& a) {} + virtual void getBgColor(int& r,int& g,int& b,int& a) {} + virtual void setBgColor(Color color) {} + virtual void setFgColor(Color color) {} + virtual void getBgColor(Color& color) {} + virtual void getFgColor(Color& color) {} + virtual void setAsMouseCapture(bool state) {} + virtual void setAsMouseArena(bool state) {} + virtual App* getApp() {return 0;} + virtual void getVirtualSize(int& wide,int& tall) {} + virtual void setLayoutInfo(LayoutInfo* layoutInfo) {} + virtual LayoutInfo* getLayoutInfo() {return 0;} + virtual bool isCursorNone() {return false;} +public: //bullshit public + virtual void solveTraverse() {} + virtual void paintTraverse() {} + virtual void setSurfaceBaseTraverse(SurfaceBase* surfaceBase) {} +protected: + virtual void performLayout() {} + virtual void internalPerformLayout() {} + virtual void drawSetColor(Scheme::SchemeColor sc) {} + virtual void drawSetColor(int r,int g,int b,int a) {} + virtual void drawFilledRect(int x0,int y0,int x1,int y1) {} + virtual void drawOutlinedRect(int x0,int y0,int x1,int y1) {} + virtual void drawSetTextFont(Scheme::SchemeFont sf) {} + virtual void drawSetTextFont(Font* font) {} + virtual void drawSetTextColor(Scheme::SchemeColor sc) {} + virtual void drawSetTextColor(int r,int g,int b,int a) {} + virtual void drawSetTextPos(int x,int y) {} + virtual void drawPrintText(const char* str,int strlen) {} + virtual void drawPrintText(int x,int y,const char* str,int strlen) {} + virtual void drawPrintChar(char ch) {} + virtual void drawPrintChar(int x,int y,char ch) {} + virtual void drawSetTextureRGBA(int id,const char* rgba,int wide,int tall) {} + virtual void drawSetTexture(int id) {} + virtual void drawTexturedRect(int x0,int y0,int x1,int y1) {} + virtual void solve() {} + virtual void paintTraverse(bool repaint) {if(repaint) paintBackground();} + virtual void paintBackground() {} + virtual void paint() {} + virtual void paintBuildOverlay() {} + virtual void internalCursorMoved(int x,int y) {} + virtual void internalCursorEntered() {} + virtual void internalCursorExited() {} + virtual void internalMousePressed(MouseCode code) {} + virtual void internalMouseDoublePressed(MouseCode code) {} + virtual void internalMouseReleased(MouseCode code) {} + virtual void internalMouseWheeled(int delta) {} + virtual void internalKeyPressed(KeyCode code) {} + virtual void internalKeyTyped(KeyCode code) {} + virtual void internalKeyReleased(KeyCode code) {} + virtual void internalKeyFocusTicked() {} + virtual void internalFocusChanged(bool lost) {} + virtual void internalSetCursor() {} +protected: + int _pos[2]; + int _size[2]; + int _loc[2]; + int _minimumSize[2]; + int _preferredSize[2]; + Dar _childDar; + Panel* _parent; + SurfaceBase* _surfaceBase; + Dar _inputSignalDar; + Dar _repaintSignalDar; + int _clipRect[4]; + Cursor* _cursor; + Scheme::SchemeCursor _schemeCursor; + bool _visible; + Layout* _layout; + bool _needsLayout; + FocusNavGroup* _focusNavGroup; + Dar _focusChangeSignalDar; + bool _autoFocusNavEnabled; + Border* _border; +private: + bool _needsRepaint; + bool _enabled; + BuildGroup* _buildGroup; + Color _fgColor; + Color _bgColor; + LayoutInfo* _layoutInfo; + bool _paintBorderEnabled; + bool _paintBackgroundEnabled; + bool _paintEnabled; +friend class App; +friend class SurfaceBase; +friend class Image; +}; +} + +#endif diff --git a/utils/false_vgui/include/VGUI_Scheme.h b/utils/false_vgui/include/VGUI_Scheme.h new file mode 100644 index 00000000..e32d7976 --- /dev/null +++ b/utils/false_vgui/include/VGUI_Scheme.h @@ -0,0 +1,82 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_SCHEME_H +#define VGUI_SCHEME_H + +#include + + +namespace vgui +{ + +class Font; +class Cursor; + +class VGUIAPI Scheme +{ +public: + enum SchemeColor + { + sc_user=0, + sc_black, + sc_white, + sc_primary1, + sc_primary2, + sc_primary3, + sc_secondary1, + sc_secondary2, + sc_secondary3, + sc_last + }; + enum SchemeFont + { + sf_user=0, + sf_primary1, + sf_primary2, + sf_primary3, + sf_secondary1, + sf_last + }; + enum SchemeCursor + { + scu_user=0, + scu_none, + scu_arrow, + scu_ibeam, + scu_hourglass, + scu_crosshair, + scu_up, + scu_sizenwse, + scu_sizenesw, + scu_sizewe, + scu_sizens, + scu_sizeall, + scu_no, + scu_hand, + scu_last + }; +public: + Scheme() {} +public: + virtual void setColor(SchemeColor sc,int r,int g,int b,int a) {} + virtual void getColor(SchemeColor sc,int& r,int& g,int& b,int& a) {} + virtual void setFont(SchemeFont sf,Font* font) {} + virtual Font* getFont(SchemeFont sf) {return 0;} + virtual void setCursor(SchemeCursor sc,Cursor* cursor) {} + virtual Cursor* getCursor(SchemeCursor sc) {return 0;} +protected: + int _color[sc_last][4]; + Font* _font[sf_last]; + Cursor* _cursor[scu_last]; + friend class Panel; + friend class Canvas; +}; + +} + +#endif diff --git a/utils/makefont/makefont.cpp b/utils/makefont/makefont.cpp new file mode 100644 index 00000000..eb2eb3ff --- /dev/null +++ b/utils/makefont/makefont.cpp @@ -0,0 +1,845 @@ +/*** +* +* 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. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ + +#define _NOENUMQBOOL + +#include + +extern "C" +{ + #include "cmdlib.h" + #include "wadlib.h" +} +#include "qfont.h" + +#define DEFAULT_FONT "Arial" + +#define FONT_TAG 6 // Font's are the 6th tag after the TYP_LUMPY base ( 64 )...i.e., type == 70 + +BOOL bItalic = FALSE; +BOOL bBold = FALSE; +BOOL bUnderline = FALSE; + +char fontname[ 256 ]; +int pointsize[3] = { 9, 11, 15 }; + +/* +================= +zeromalloc + +Allocates and zeroes memory +================= +*/ +void *zeromalloc( size_t size ) +{ + unsigned char *pbuffer; + pbuffer = ( unsigned char * )malloc( size ); + if ( !pbuffer ) + { + printf( "Failed on allocation of %i bytes", size ); + exit( -1 ); + } + + memset( pbuffer, 0, size ); + return ( void * )pbuffer; +} + +/* +================= +Draw_SetupConsolePalette + +Set's the palette to full brightness ( 192 ) and +set's up palette entry 0 -- black +================= +*/ +void Draw_SetupConsolePalette( unsigned char *pal ) +{ + unsigned char *pPalette; + int i; + + pPalette = pal; + + *(short *)pPalette = 3 * 256; + pPalette += sizeof( short ); + + for ( i = 0; i < 256; i++ ) + { + pPalette[3 * i + 0 ] = i; + pPalette[3 * i + 1 ] = i; + pPalette[3 * i + 2 ] = i; + } + + // Set palette zero correctly + pPalette[ 0 ] = 0; + pPalette[ 1 ] = 0; + pPalette[ 2 ] = 0; +} + +//DJXX added for debugging +BOOL WriteDIB(LPTSTR szFile, HANDLE hDIB) +{ + BITMAPFILEHEADER hdr; + LPBITMAPINFOHEADER lpbi; + + if (!hDIB) + return FALSE; + + FILE *file; + file = SafeOpenWrite(szFile); + + + lpbi = (LPBITMAPINFOHEADER)hDIB; + + int nColors = 1 << lpbi->biBitCount; + + // Fill in the fields of the file header + hdr.bfType = ((WORD)('M' << 8) | 'B'); // is always "BM" + hdr.bfSize = GlobalSize(hDIB) + sizeof(hdr); + printf("WriteDIB. Error code = %i\n",GetLastError()); + hdr.bfReserved1 = 0; + hdr.bfReserved2 = 0; + hdr.bfOffBits = (DWORD)(sizeof(hdr)+lpbi->biSize + + nColors * sizeof(RGBQUAD)); + + // Write the file header + SafeWrite(file, &hdr, sizeof(hdr)); + + // Write the DIB header and the bits + SafeWrite(file, lpbi, GlobalSize(hDIB)); + fclose(file); + return TRUE; +} + + +/* +================= +CreateProportionalConsoleFont + +Renders TT font into memory dc and creates appropriate qfont_t structure +================= +*/ +//DJXX: New version, draws chararacters closely to each other without spaces + +// YWB: Sigh, VC 6.0's global optimizer causes weird stack fixups in release builds. Disable the globabl optimizer for this function. +#pragma optimize( "g", off ) +qfont_t *CreateProportionalConsoleFont(char *pszFont, int nPointSize, BOOL bItalic, BOOL bUnderline, BOOL bBold, int *outsize) +{ + HDC hdc; + HDC hmemDC; + HBITMAP hbm, oldbm; + RECT rc; + HFONT fnt, oldfnt; + TEXTMETRIC tm; + int startchar = 32; + int c; + int i, j; + int x, y; + int nScans; + unsigned char *bits; + BITMAPINFO tempbmi; + BITMAPINFO *pbmi; + BITMAPINFOHEADER *pbmheader; + unsigned char *pqdata; + unsigned char *pCur; + int x1, y1; + unsigned char *pPalette; + qfont_t *pqf = NULL; + int fullsize; + int w = 16; + //int h = (128 - 32) / 16; + int h = (256 - 32) / 16; + int charheight = nPointSize + 5; + int charwidth = 16;//now used only for calculating width of wad texture + int fontcharwidth; + int edge = 1; + RECT rcChar; + boolean lShadow = true;//draw shadow instead of outline + + // Create the font + fnt = CreateFont(-nPointSize, 0, 0, 0, bBold ? FW_HEAVY : FW_MEDIUM, bItalic, bUnderline, 0, /*ANSI_CHARSET*/DEFAULT_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, VARIABLE_PITCH | FF_DONTCARE, pszFont); + + bits = NULL; + + fullsize = sizeof(qfont_t)-4 + (/*128*/256 * w * charwidth) + sizeof(short)+768 + 64; + + // Store off final size + *outsize = fullsize; + + pqf = (qfont_t *)zeromalloc(fullsize); + pqdata = (unsigned char *)pqf + sizeof(qfont_t)-4; + + pPalette = pqdata + (/*128*/256 * w * charwidth); + + // Configure palette + Draw_SetupConsolePalette(pPalette); + + hdc = GetDC(NULL); + hmemDC = CreateCompatibleDC(hdc); + + oldfnt = (HFONT)SelectObject(hmemDC, fnt); + + if (GetTextMetrics(hmemDC, &tm)) + { + fontcharwidth = tm.tmMaxCharWidth; + if (fontcharwidth % 2)//hack: on odd values of fontcharwidth, bitmaps pixel check gives false triggering + fontcharwidth++; + } + else { + fontcharwidth = charwidth; + } + + if (lShadow) + charheight += edge;//adding 1 pixel to bottom for shadowing + + rc.top = 0; + rc.left = 0; + rc.right = fontcharwidth * w; + rc.bottom = charheight * h; + + hbm = CreateBitmap(fontcharwidth * w, charheight * h, 1, 1, NULL); + oldbm = (HBITMAP)SelectObject(hmemDC, hbm); + + SetTextColor(hmemDC, 0x00ffffff); + SetBkMode(hmemDC, TRANSPARENT); + + // Paint black background + FillRect(hmemDC, &rc, (HBRUSH)GetStockObject(BLACK_BRUSH)); + + // Draw character set into memory DC + for (j = 0; j < h; j++) + { + for (i = 0; i < w; i++) + { + x = i * fontcharwidth; + y = j * charheight; + + c = (unsigned char)(startchar + j * w + i); + + // Only draw printable characters, of course + //if ( isprint( c ) && c <= 127 ) + { + // Draw it. + rcChar.left = x + 1; + rcChar.top = y + 1; + rcChar.right = x + fontcharwidth - 1; + rcChar.bottom = y + charheight - 1; + + DrawText(hmemDC, (char *)&c, 1, &rcChar, DT_NOPREFIX | DT_LEFT); + } + } + } + + // Now turn the qfont into raw format + memset(&tempbmi, 0, sizeof(BITMAPINFO)); + + pbmheader = (BITMAPINFOHEADER *)&tempbmi; + + pbmheader->biSize = sizeof(BITMAPINFOHEADER); + pbmheader->biWidth = w * fontcharwidth; + pbmheader->biHeight = -h * charheight; + pbmheader->biPlanes = 1; + pbmheader->biBitCount = 1; + pbmheader->biCompression = BI_RGB; + + // Find out how big the bitmap is + nScans = GetDIBits(hmemDC, hbm, 0, h * charheight, NULL, &tempbmi, DIB_RGB_COLORS); + + // Allocate space for all bits + pbmi = (BITMAPINFO *)zeromalloc(sizeof (BITMAPINFOHEADER)+2 * sizeof(RGBQUAD)+pbmheader->biSizeImage); + + memcpy(pbmi, &tempbmi, sizeof(BITMAPINFO)); + + bits = (unsigned char *)pbmi + sizeof(BITMAPINFOHEADER)+2 * sizeof(RGBQUAD); + + // Now read in bits + nScans = GetDIBits(hmemDC, hbm, 0, h * charheight, bits, pbmi, DIB_RGB_COLORS); + + if (nScans > 0) + { +#if 0 //for debugging + char sz[128];//DJXX write dib to file + sprintf(sz, "font_%s_%i.bmp", pszFont, nPointSize); + WriteDIB(sz, pbmi); +#endif + // Now convert to proper raw format + // + // Now get results from dib + pqf->height = /*128*/256; // Always set to 128 + pqf->width = charwidth; + pqf->rowheight = charheight; + pqf->rowcount = h; + pCur = pqdata; + + // Set everything to index 255 ( 0xff ) == transparent + memset(pCur, 0xFF, w * charwidth * pqf->height); + + int k = 0, dest_x = 0, dest_y = 0; + + for (j = 0; j < h; j++) + for (i = 0; i < w; i++) + { + int rightmost, leftmost, realcharwidth; + + x = i * fontcharwidth; + y = j * charheight; + + //c = (char)( startchar + j * w + i ); here was memory bug + c = (unsigned char)(startchar + j * w + i); + + rightmost = 0; + leftmost = fontcharwidth; + + //Calculate real width of the character + for (y1 = 0; y1 < charheight; y1++) + for (x1 = 0; x1 < fontcharwidth; x1++) + { + int src_offset; + + src_offset = (y + y1) * w * fontcharwidth + x + x1; + + if (bits[src_offset >> 3] & (1 << (7 - src_offset & 7)))//on odd values of fontcharwidth this check gives false triggering + { + if (x1 > rightmost) + rightmost = x1; + + if (x1 < leftmost) + leftmost = x1; + } + } + if (leftmost > rightmost)//empty characters + { + leftmost = 0; + rightmost = 7; + } else { + rightmost += edge; + if (!lShadow) + leftmost -= edge; + } + + realcharwidth = rightmost - leftmost + 1; + pqf->fontinfo[c].charwidth = realcharwidth; + + if (dest_x + realcharwidth >= w * charwidth)//if it not fits on current line then carry it to the next line + { + dest_x = 0; + k++; + } + + dest_y = k * charheight; + pqf->fontinfo[c].startoffset = dest_y * w * charwidth + dest_x; + + if (lShadow) + { + int shift = edge; + //Draw shadow by shifting character to 1 pixel right and down + for (y1 = 0; y1 < charheight; y1++) + for (x1 = 0; x1 < realcharwidth; x1++) + { + int src_offset, dest_offset; + + src_offset = (y + y1) * w * fontcharwidth + x + x1 + leftmost; + dest_offset = (dest_y + shift + y1) * w * charwidth + (dest_x + shift + x1); + + // Dest + pCur = pqdata + dest_offset; + + if (bits[src_offset >> 3] & (1 << (7 - src_offset & 7))) + { + // Near Black + //pCur[0] = 32; + pCur[0] = 0;//full black so shadow remains black even it's coloured text + } + } + } + else + { + // Put black pixels below and to the right of each pixel(outline) + for (y1 = edge; y1 < charheight - edge; y1++) + for (x1 = 0; x1 < realcharwidth; x1++) + { + int src_offset, dest_offset; + + int xx0, yy0; + + dest_offset = (dest_y + y1) * w * charwidth + (dest_x + x1); + + // Dest + pCur = pqdata + dest_offset; + + for (xx0 = -edge; xx0 <= edge; xx0++) + for (yy0 = -edge; yy0 <= edge; yy0++) + { + src_offset = (y + y1 + yy0) * w * fontcharwidth + x + x1 + xx0 + leftmost;//adding shift + + if (bits[src_offset >> 3] & (1 << (7 - src_offset & 7))) + { + // Near Black + pCur[0] = 32; + } + } + } + } + + // Now copy in the actual font pixels + for (y1 = 0; y1 < charheight; y1++) + for (x1 = 0; x1 < realcharwidth; x1++) + { + int src_offset, dest_offset; + + src_offset = (y + y1) * w * fontcharwidth + x + x1 + leftmost; + dest_offset = (dest_y + y1) * w * charwidth + (dest_x + x1); + + // Dest + pCur = pqdata + dest_offset; + + if (bits[src_offset >> 3] & (1 << (7 - src_offset & 7))) + { + pCur[0] = 192; + } + } + dest_x += realcharwidth; + } + } + // Free memory bits + free(pbmi); + SelectObject(hmemDC, oldfnt); + DeleteObject(fnt); + + SelectObject(hmemDC, oldbm); + + DeleteObject(hbm); + + DeleteDC(hmemDC); + ReleaseDC(NULL, hdc); + + return pqf; +} +#pragma optimize( "g", on ) + + +/* +================= +CreateConsoleFont + +Renders TT font into memory dc and creates appropriate qfont_t structure +================= +*/ +//DJXX: original version, just added drawing of locale characters and fixed memory bug. +// YWB: Sigh, VC 6.0's global optimizer causes weird stack fixups in release builds. Disable the globabl optimizer for this function. +#pragma optimize( "g", off ) +qfont_t *CreateConsoleFont( char *pszFont, int nPointSize, BOOL bItalic, BOOL bUnderline, BOOL bBold, int *outsize ) +{ + HDC hdc; + HDC hmemDC; + HBITMAP hbm, oldbm; + RECT rc; + HFONT fnt, oldfnt; + int startchar = 32; + int c; + int i, j; + int x, y; + int nScans; + unsigned char *bits; + BITMAPINFO tempbmi; + BITMAPINFO *pbmi; + BITMAPINFOHEADER *pbmheader; + unsigned char *pqdata; + unsigned char *pCur; + int x1, y1; + unsigned char *pPalette; + qfont_t *pqf = NULL; + int fullsize; + int w = 16; + //int h = (128-32)/16; + int h = (256 - 32) / 16; + int charheight = nPointSize + 5; + int charwidth = 16; + RECT rcChar; + + // Create the font + fnt = CreateFont( -nPointSize, 0, 0, 0, bBold ? FW_HEAVY : FW_MEDIUM, bItalic, bUnderline, 0, /*ANSI_CHARSET*/DEFAULT_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, VARIABLE_PITCH | FF_DONTCARE, pszFont ); + + bits = NULL; + + fullsize = sizeof( qfont_t ) - 4 + ( /*128*/256 * w * charwidth ) + sizeof(short) + 768 + 64; + + // Store off final size + *outsize = fullsize; + + pqf = ( qfont_t * )zeromalloc( fullsize ); + pqdata = (unsigned char *)pqf + sizeof( qfont_t ) - 4; + + pPalette = pqdata + ( /*128*/256 * w * charwidth); + + // Configure palette + Draw_SetupConsolePalette( pPalette ); + + hdc = GetDC( NULL ); + hmemDC = CreateCompatibleDC( hdc ); + + rc.top = 0; + rc.left = 0; + rc.right = charwidth * w; + rc.bottom = charheight * h; + + hbm = CreateBitmap( charwidth * w, charheight * h, 1, 1, NULL ); + oldbm = (HBITMAP)SelectObject( hmemDC, hbm ); + oldfnt = (HFONT)SelectObject( hmemDC, fnt ); + + SetTextColor( hmemDC, 0x00ffffff ); + SetBkMode( hmemDC, TRANSPARENT ); + + // Paint black background + FillRect( hmemDC, &rc, (HBRUSH)GetStockObject( BLACK_BRUSH ) ); + + // Draw character set into memory DC + for ( j = 0; j < h; j++ ) + { + for ( i = 0; i < w; i++ ) + { + x = i * charwidth; + y = j * charheight; + + c = (unsigned char)( startchar + j * w + i ); + + // Only draw printable characters, of course + //if ( isprint( c ) && c <= 127 ) + { + // Draw it. + rcChar.left = x + 1; + rcChar.top = y + 1; + rcChar.right = x + charwidth - 1; + rcChar.bottom = y + charheight - 1; + + DrawText( hmemDC, (char *)&c, 1, &rcChar, DT_NOPREFIX | DT_LEFT ); + } + } + } + + // Now turn the qfont into raw format + memset( &tempbmi, 0, sizeof( BITMAPINFO ) ); + pbmheader = ( BITMAPINFOHEADER * )&tempbmi; + + pbmheader->biSize = sizeof( BITMAPINFOHEADER ); + pbmheader->biWidth = w * charwidth; + pbmheader->biHeight = -h * charheight; + pbmheader->biPlanes = 1; + pbmheader->biBitCount = 1; + pbmheader->biCompression = BI_RGB; + + // Find out how big the bitmap is + nScans = GetDIBits( hmemDC, hbm, 0, h * charheight, NULL, &tempbmi, DIB_RGB_COLORS ); + + // Allocate space for all bits + pbmi = ( BITMAPINFO * )zeromalloc( sizeof ( BITMAPINFOHEADER ) + 2 * sizeof( RGBQUAD ) + pbmheader->biSizeImage ); + + memcpy( pbmi, &tempbmi, sizeof( BITMAPINFO ) ); + + bits = ( unsigned char * )pbmi + sizeof( BITMAPINFOHEADER ) + 2 * sizeof( RGBQUAD ); + + // Now read in bits + nScans = GetDIBits( hmemDC, hbm, 0, h * charheight, bits, pbmi, DIB_RGB_COLORS ); + + if ( nScans > 0 ) + { +#if 0 //for debugging + char sz[128];//DJXX write dib to file + sprintf(sz, "font_%s_%i.bmp", pszFont, nPointSize); + WriteDIB(sz, pbmi); +#endif + + // Now convert to proper raw format + // + // Now get results from dib + pqf->height = /*128*/256; // Always set to 128 + pqf->width = charwidth; + pqf->rowheight = charheight; + pqf->rowcount = h; + pCur = pqdata; + + // Set everything to index 255 ( 0xff ) == transparent + memset( pCur, 0xFF, w * charwidth * pqf->height ); + + for ( j = 0; j < h; j++ ) + { + for ( i = 0; i < w; i++ ) + { + int edge = 1; + int bestwidth; + x = i * charwidth; + y = j * charheight; + + + //c = (char)( startchar + j * w + i ); here was memory bug + c = (unsigned char)(startchar + j * w + i); + + pqf->fontinfo[ c ].charwidth = charwidth; + pqf->fontinfo[ c ].startoffset = y * w * charwidth + x; + + bestwidth = 0; + + // In this first pass, place the black drop shadow so characters draw ok in the engine against + // most backgrounds. + // YWB: FIXME, apply a box filter and enable blending? +#if 0//DJXX: we already did that for a whole image by memset + // Make it all transparent for starters + for ( y1 = 0; y1 < charheight; y1++ ) + { + for ( x1 = 0; x1 < charwidth; x1++ ) + { + int offset; + offset = ( y + y1 ) * w * charwidth + x + x1 ; + // Dest + pCur = pqdata + offset; + // Assume transparent + pCur[0] = 255; + } + } +#endif + // Put black pixels below and to the right of each pixel + for ( y1 = edge; y1 < charheight - edge; y1++ ) + { + for ( x1 = 0; x1 < charwidth; x1++ ) + { + int offset; + int srcoffset; + + int xx0, yy0; + + offset = ( y + y1 ) * w * charwidth + x + x1 ; + + // Dest + pCur = pqdata + offset; + + for ( xx0 = -edge; xx0 <= edge; xx0++ ) + { + for ( yy0 = -edge; yy0 <= edge; yy0++ ) + { + srcoffset = ( y + y1 + yy0 ) * w * charwidth + x + x1 + xx0; + + if ( bits[ srcoffset >> 3 ] & ( 1 << ( 7 - srcoffset & 7 ) ) ) + { + // Near Black + pCur[0] = 32; + } + } + } + } + } + + // Now copy in the actual font pixels + for ( y1 = 0; y1 < charheight; y1++ ) + { + for ( x1 = 0; x1 < charwidth; x1++ ) + { + int offset; + + offset = ( y + y1 ) * w * charwidth + x + x1; + + // Dest + pCur = pqdata + offset; + + if ( bits[ offset >> 3 ] & ( 1 << ( 7 - offset & 7 ) ) ) + { + if ( x1 > bestwidth ) + { + bestwidth = x1; + } + + // Full color + // FIXME: Enable true palette support in engine? + pCur[0] = 192; + } + } + } + + // bestwidth += 1; + /* + // Now blend it + for ( y1 = 0; y1 < charheight; y1++ ) + { + for ( x1 = 0; x1 < charwidth; x1++ ) + { + int offset; + + offset = ( y + y1 ) * w * charwidth + x + x1; + + // Dest + pCur = pqdata + offset; + + if ( bits[ offset >> 3 ] & ( 1 << ( 7 - offset & 7 ) ) ) + { + if ( x1 > bestwidth ) + { + bestwidth = x1; + } + + // Full color + // FIXME: Enable true palette support in engine? + pCur[0] = 192; + } + } + } + */ + + // Space character width + if ( c == 32 ) + { + bestwidth = 8; + } + else + { + // Small characters needs can be padded a bit so they don't run into each other + if ( bestwidth <= 14 ) + { + bestwidth += 2; + } + } + + // Store off width + pqf->fontinfo[ c ].charwidth = bestwidth; + } + } + } + + // Free memory bits + free ( pbmi ); + + SelectObject( hmemDC, oldfnt ); + DeleteObject( fnt ); + + SelectObject( hmemDC, oldbm ); + + DeleteObject( hbm ); + + DeleteDC( hmemDC ); + ReleaseDC( NULL, hdc ); + + return pqf; +} + +#pragma optimize( "g", on ) + +/* +================= +main + +================= +*/ +int main(int argc, char* argv[]) +{ + int i; + DWORD start, end; + char destfile[1024]; + char sz[ 32 ]; + int outsize[ 3 ]; + + qfont_t *fonts[ 3 ]; + + strcpy( fontname, DEFAULT_FONT ); + + printf("makefont.exe Version 2.0 by valve and DJXX (%s)\n", __DATE__ ); + + printf ("----- Creating Console Font ----\n"); + + for (i=1 ; i= argc ) + { + Error( "Makefont: Insufficient point sizes specified\n" ); + } + pointsize[0] = atoi( argv[i+1] ); + pointsize[1] = atoi( argv[i+2] ); + pointsize[2] = atoi( argv[i+3] ); + i += 3; + } + else if (!strcmp(argv[i],"-italic")) + { + bItalic = TRUE; + printf ( "italic set\n"); + } + else if (!strcmp(argv[i],"-bold")) + { + bBold = TRUE; + printf ( "bold set\n"); + } + else if (!strcmp(argv[i],"-underline")) + { + bUnderline = TRUE; + printf ( "underline set\n"); + } + else if ( argv[i][0] == '-' ) + { + Error ("Unknown option \"%s\"", argv[i]); + } + else + break; + } + + if ( i != argc - 1 ) + { + Error ("usage: makefont [-font \"fontname\"] [-italic] [-underline] [-bold] [-pointsizes sm med lg] outfile"); + } + + printf( "Creating %i, %i, and %i point %s fonts\n", pointsize[0], pointsize[1], pointsize[2], fontname ); + + start = timeGetTime(); + + // Create the fonts + for ( i = 0 ; i < 3; i++ ) + { + fonts[ i ] = CreateProportionalConsoleFont( fontname, pointsize[i], bItalic, bUnderline, bBold, &outsize[ i ] ); + //fonts[i] = CreateConsoleFont(fontname, pointsize[i], bItalic, bUnderline, bBold, &outsize[i]); + } + + // Create wad file + strcpy (destfile, argv[argc - 1]); + StripExtension (destfile); + DefaultExtension (destfile, ".wad"); + + NewWad( destfile, false ); + + // Add fonts as lumps + for ( i = 0; i < 3; i++ ) + { + sprintf( sz, "font%i", i ); + AddLump( sz, fonts[ i ], outsize[ i ], TYP_LUMPY + FONT_TAG, false ); + } + + // Store results as a WAD3 + // NOTE: ( should be named fonts.wad in the valve\ subdirectory ) + WriteWad( 3 ); + + // Clean up memory + for ( i = 0 ; i < 3; i++ ) + { + free( fonts[ i ] ); + } + + end = timeGetTime (); + + printf ( "%5.5f seconds elapsed\n", (float)( end - start )/1000.0 ); + + // Display for a second since it might not be running from command prompt + Sleep( 1000 ); + return 0; +} diff --git a/utils/makefont/makefont.dsp b/utils/makefont/makefont.dsp new file mode 100644 index 00000000..aece6e0c --- /dev/null +++ b/utils/makefont/makefont.dsp @@ -0,0 +1,138 @@ +# Microsoft Developer Studio Project File - Name="makefont" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=makefont - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "makefont.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 "makefont.mak" CFG="makefont - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "makefont - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "makefont - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "makefont - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /W3 /GX /Zi /O2 /I "../../common" /I "../common" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX"qfont.h" /FD /c +# 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 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /subsystem:console /debug /machine:I386 +# Begin Special Build Tool +TargetPath=.\Release\makefont.exe +SOURCE="$(InputPath)" +PostBuild_Desc=Copyint to valve\ +PostBuild_Cmds=xcopy $(TargetPath) ..\..\..\valve /r /i +# End Special Build Tool + +!ELSEIF "$(CFG)" == "makefont - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../common" /I "../common" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX"qfont.h" /FD /GZ /c +# 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 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# Begin Special Build Tool +TargetPath=.\Debug\makefont.exe +SOURCE="$(InputPath)" +PostBuild_Desc=Copyint to valve\ +PostBuild_Cmds=xcopy $(TargetPath) ..\..\..\valve /r /i +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "makefont - Win32 Release" +# Name "makefont - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\common\cmdlib.c +# End Source File +# Begin Source File + +SOURCE=.\makefont.cpp +# End Source File +# Begin Source File + +SOURCE=..\common\wadlib.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=..\common\cmdlib.h +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.h +# End Source File +# Begin Source File + +SOURCE=..\common\wadlib.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\ReadMe.txt +# End Source File +# End Target +# End Project diff --git a/utils/makefont/winebuild.sh b/utils/makefont/winebuild.sh new file mode 100755 index 00000000..ec259577 --- /dev/null +++ b/utils/makefont/winebuild.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +winegcc -g -m32 makefont.cpp ../common/wadlib.c ../common/cmdlib.c -I../common/ -I../../common/ -mwindows -mno-cygwin -lwinmm -fno-stack-protector diff --git a/xash.dsw b/xash.dsw deleted file mode 100644 index 3be1a44d..00000000 --- a/xash.dsw +++ /dev/null @@ -1,65 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "hl"=".\dlls\hl.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "client"=".\cl_dll\cl_dll.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "mainui"=".\mainui\mainui.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "engine"=".\engine\engine.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/xash_sdk.dsw b/xash_sdk.dsw deleted file mode 100644 index ad911ba0..00000000 --- a/xash_sdk.dsw +++ /dev/null @@ -1,65 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "hl"=".\dlls\hl.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "client"=".\cl_dll\cl_dll.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "mainui"=".\mainui\mainui.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "game"=".\game_launch\game.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/xash_sdk.lst b/xash_sdk.lst deleted file mode 100644 index a211c3b4..00000000 --- a/xash_sdk.lst +++ /dev/null @@ -1,22 +0,0 @@ -//======================================================================= -// Copyright XashXT Group 2011 © -// list with SDK directories -//======================================================================= - -// global stuff -xash_sdk\xash_sdk.dsw -xash_sdk\cl_dll\ -xash_sdk\cl_dll\hl\ -xash_sdk\common\ -xash_sdk\dlls\ -xash_sdk\game_shared\ -xash_sdk\game_launch\ -xash_sdk\engine\ -xash_sdk\pm_shared\ -xash_sdk\mainui\ -xash_dsk\mainui\legacy -xash_sdk\utils\ -xash_sdk\makefont\ -xash_sdk\utils\vgui\ -xash_sdk\utils\vgui\include\ -xash_sdk\utils\vgui\lib\win32_vc6\ \ No newline at end of file