Merge branch 'master' into sohl1.2

This commit is contained in:
Roman Chistokhodov 2017-12-18 23:47:12 +03:00
commit 30f2409952
347 changed files with 49269 additions and 33961 deletions

View File

@ -1,6 +1,9 @@
# Binaries
*.o
*.so
*/*.o
*/*/*.o
*.a
*.framework
*.exe
build/

14
.travis.yml Normal file
View File

@ -0,0 +1,14 @@
language: cpp
compiler:
- gcc
- clang
os:
- linux
- osx
sudo: true
before_script:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install gcc-multilib g++-multilib; fi
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 *

1
Android.mk Normal file
View File

@ -0,0 +1 @@
include $(call all-subdir-makefiles)

63
CMakeLists.txt Normal file
View File

@ -0,0 +1,63 @@
#
# Copyright (c) 2016 Alibek Omarov
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
cmake_minimum_required(VERSION 2.6.0)
project (HLSDK-XASH3D)
#--------------
# USER DEFINES \
################\
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)
#-----------------
# MAIN BUILD CODE \
###################\
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(MSVC)
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")
endif()
endif()
if(BUILD_CLIENT)
add_subdirectory(cl_dll)
endif()
if(BUILD_SERVER)
add_subdirectory(dlls)
endif()
if(NOT BUILD_SERVER AND NOT BUILD_CLIENT)
error("Nothing to build")
endif()

141
README.md Normal file
View File

@ -0,0 +1,141 @@
# 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 & GoldSource with some fixes.
## How to build
### CMake as most universal way
mkdir build && cd build
cmake ../
make
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 MVS 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 MVS versions.
#### Using mingw
TODO
### Linux
(cd dlls && make)
(cd cl_dll && make)
### OS X
TODO
### FreeBSD
(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 **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.

31
backup.bat Normal file
View File

@ -0,0 +1,31 @@
@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

36
backup.lst Normal file
View File

@ -0,0 +1,36 @@
//=======================================================================
// 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\

View File

@ -13,7 +13,6 @@ LOCAL_MODULE := client
#else
APP_PLATFORM := android-8
#endif
LOCAL_CONLYFLAGS += -std=c99
include $(XASH3D_CONFIG)
@ -25,7 +24,6 @@ LOCAL_CFLAGS += -DCLIENT_DLL=1
SRCS=
SRCS_C=
SRCS+=./MOTD.cpp
SRCS+=../dlls/crossbow.cpp
SRCS+=../dlls/crowbar.cpp
SRCS+=../dlls/egon.cpp
@ -36,9 +34,7 @@ SRCS+=./hl/hl_baseentity.cpp
SRCS+=./hl/hl_events.cpp
SRCS+=./hl/hl_objects.cpp
SRCS+=./hl/hl_weapons.cpp
SRCS+=../dlls/wpn_shared/hl_wpn_glock.cpp
SRCS+=../dlls/hornetgun.cpp
SRCS+=../common/interface.cpp
SRCS+=../dlls/mp5.cpp
SRCS+=../dlls/python.cpp
SRCS+=../dlls/rpg.cpp
@ -46,6 +42,9 @@ SRCS+=../dlls/satchel.cpp
SRCS+=../dlls/shotgun.cpp
SRCS+=../dlls/squeakgrenade.cpp
SRCS+=../dlls/tripmine.cpp
SRCS+=../dlls/glock.cpp
#SRCS+=../game_shared/voice_banmgr.cpp
#SRCS+=../game_shared/voice_status.cpp
SRCS+=./ammo.cpp
SRCS+=./ammo_secondary.cpp
SRCS+=./ammohistory.cpp
@ -64,20 +63,22 @@ SRCS+=./health.cpp
SRCS+=./hud.cpp
SRCS+=./hud_msg.cpp
SRCS+=./hud_redraw.cpp
#SRCS+=./hud_servers.cpp
SRCS+=./hud_spectator.cpp
SRCS+=./hud_update.cpp
SRCS+=./in_camera.cpp
SRCS+=./input.cpp
SRCS+=./input_xash3d.cpp
SRCS+=./input_goldsource.cpp
SRCS+=./input_mouse.cpp
#SRCS+=./inputw32.cpp
SRCS+=./menu.cpp
SRCS+=./message.cpp
SRCS+=./overview.cpp
SRCS+=./parsemsg.cpp
SRCS+=./particlemgr.cpp
SRCS+=./particlemsg.cpp
SRCS+=./particlesys.cpp
SRCS_C+=../pm_shared/pm_debug.c
SRCS_C+=../pm_shared/pm_math.c
SRCS_C+=../pm_shared/pm_shared.c
SRCS+=./saytext.cpp
SRCS+=./scoreboard.cpp
SRCS+=./status_icons.cpp
SRCS+=./statusbar.cpp
SRCS+=./studio_util.cpp
@ -87,21 +88,28 @@ SRCS+=./train.cpp
SRCS+=./tri.cpp
SRCS+=./util.cpp
SRCS+=./view.cpp
SRCS_C+=../pm_shared/pm_debug.c
SRCS_C+=../pm_shared/pm_math.c
SRCS_C+=../pm_shared/pm_shared.c
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
SRCS+=./input_xash3d.cpp
SRCS+=./scoreboard.cpp
SRCS+=./MOTD.cpp
INCLUDES = -I../common -I. -I../game_shared -I../pm_shared -I../engine -I../dlls -I../utils/false_vgui/include
DEFINES = -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w
LOCAL_C_INCLUDES := $(LOCAL_PATH)/. \
$(LOCAL_PATH)/../common \
$(LOCAL_PATH)/../engine \
$(LOCAL_PATH)/../game_shared \
$(LOCAL_PATH)/../dlls \
$(LOCAL_PATH)/../pm_shared
$(LOCAL_PATH)/../pm_shared \
$(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)

118
cl_dll/CMakeLists.txt Normal file
View File

@ -0,0 +1,118 @@
#
# Copyright (c) 2016 Alibek Omarov
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
cmake_minimum_required(VERSION 2.6.0)
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")
if (GOLDSOURCE_SUPPORT)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGOLDSOURCE_SUPPORT")
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ldl")
endif()
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}")
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
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
particlemgr.cpp
particlemsg.cpp
particlesys.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)
include_directories (. hl/ ../dlls ../dlls/wpn_shared ../common ../engine ../pm_shared ../game_shared ../public ../utils/false_vgui/include)
if(USE_VOICEMGR)
#set(CLDLL_SOURCES
# ${CLDLL_SOURCES}
# ../game_shared/voice_banmgr.cpp
# ../game_shared/voice_status.cpp)
endif()
add_library (${CLDLL_LIBRARY} SHARED ${CLDLL_SOURCES})
set_target_properties (${CLDLL_SHARED} PROPERTIES
POSITION_INDEPENDENT_CODE 1)

View File

@ -1,4 +1,4 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//========= Copyright <EFBFBD> 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
@ -99,9 +99,6 @@ HUD_GetStudioModelInterface
Export this function for the engine to use the studio renderer class to render objects.
====================
*/
#include "exportdef.h"
extern "C" int DLLEXPORT HUD_GetStudioModelInterface( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio )
{
if ( version != STUDIO_INTERFACE_VERSION )

View File

@ -1,15 +1,13 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#pragma once
#if !defined( GAMESTUDIOMODELRENDERER_H )
#define GAMESTUDIOMODELRENDERER_H
#if defined( _WIN32 )
#pragma once
#endif
/*
====================

View File

@ -1,4 +1,4 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//========= Copyright <EFBFBD> 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
@ -972,7 +972,7 @@ HUD_GetStudioModelInterface
Export this function for the engine to use the studio renderer class to render objects.
====================
*/
#include "exportdef.h"
extern "C" int DLLEXPORT HUD_GetStudioModelInterface( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio )
{
if ( version != STUDIO_INTERFACE_VERSION )

View File

@ -1,15 +1,13 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//========= Copyright <EFBFBD> 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#pragma once
#if !defined( GAMESTUDIOMODELRENDERER_H )
#define GAMESTUDIOMODELRENDERER_H
#if defined( _WIN32 )
#pragma once
#endif
/*
====================

View File

@ -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;
@ -130,7 +130,7 @@ int CHudMOTD::MsgFunc_MOTD( const char *pszName, int iSize, void *pbuf )
BEGIN_READ( pbuf, iSize );
int is_finished = READ_BYTE();
strncat( m_szMOTD, READ_STRING(), sizeof(m_szMOTD) );
strncat( m_szMOTD, READ_STRING(), sizeof(m_szMOTD) - 1 );
if( is_finished )
{

93
cl_dll/Makefile Normal file
View File

@ -0,0 +1,93 @@
CC?=gcc
CXX?=g++
SRCS+=../dlls/crossbow.cpp
SRCS+=../dlls/crowbar.cpp
SRCS+=../dlls/egon.cpp
SRCS+=./ev_hldm.cpp
SRCS+=../dlls/gauss.cpp
SRCS+=../dlls/handgrenade.cpp
SRCS+=./hl/hl_baseentity.cpp
SRCS+=./hl/hl_events.cpp
SRCS+=./hl/hl_objects.cpp
SRCS+=./hl/hl_weapons.cpp
SRCS+=../dlls/glock.cpp
SRCS+=../dlls/hornetgun.cpp
#SRCS+=../common/interface.cpp
SRCS+=../dlls/mp5.cpp
SRCS+=../dlls/python.cpp
SRCS+=../dlls/rpg.cpp
SRCS+=../dlls/satchel.cpp
SRCS+=../dlls/shotgun.cpp
SRCS+=../dlls/squeakgrenade.cpp
SRCS+=../dlls/tripmine.cpp
#SRCS+=../game_shared/voice_banmgr.cpp
#SRCS+=../game_shared/voice_status.cpp
SRCS+=./ammo.cpp
SRCS+=./ammo_secondary.cpp
SRCS+=./ammohistory.cpp
SRCS+=./battery.cpp
SRCS+=./cdll_int.cpp
SRCS+=./com_weapons.cpp
SRCS+=./death.cpp
SRCS+=./demo.cpp
SRCS+=./entity.cpp
SRCS+=./ev_common.cpp
SRCS+=./events.cpp
SRCS+=./flashlight.cpp
SRCS+=./GameStudioModelRenderer.cpp
SRCS+=./geiger.cpp
SRCS+=./health.cpp
SRCS+=./hud.cpp
SRCS+=./hud_msg.cpp
SRCS+=./hud_redraw.cpp
#SRCS+=./hud_servers.cpp
SRCS+=./hud_spectator.cpp
SRCS+=./hud_update.cpp
SRCS+=./in_camera.cpp
SRCS+=./input.cpp
SRCS+=./input_mouse.cpp
SRCS+=./input_goldsource.cpp
SRCS+=./menu.cpp
SRCS+=./message.cpp
SRCS+=./overview.cpp
SRCS+=./parsemsg.cpp
SRCS_C+=../pm_shared/pm_debug.c
SRCS_C+=../pm_shared/pm_math.c
SRCS_C+=../pm_shared/pm_shared.c
SRCS+=./saytext.cpp
SRCS+=./status_icons.cpp
SRCS+=./statusbar.cpp
SRCS+=./studio_util.cpp
SRCS+=./StudioModelRenderer.cpp
SRCS+=./text_message.cpp
SRCS+=./train.cpp
SRCS+=./tri.cpp
SRCS+=./util.cpp
SRCS+=./view.cpp
SRCS+=./input_xash3d.cpp
SRCS+=./scoreboard.cpp
SRCS+=./MOTD.cpp
INCLUDES = -I../common -I. -I../game_shared -I../pm_shared -I../engine -I../dlls -I../utils/false_vgui/include
DEFINES = -Wno-write-strings -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL
CFLAGS = -m32
OBJS = $(SRCS:.cpp=.o) $(SRCS_C:.c=.o)
LIBS=-lm
ifeq ($(GOLDSOURCE_SUPPORT),1)
DEFINES += -DGOLDSOURCE_SUPPORT
endif
ifeq ($(shell uname -s),Linux)
LIBS += -ldl
endif
%.o : %.c
$(CC) $(CFLAGS) $(INCLUDES) $(DEFINES) -fPIC -c $< -o $@
%.o : %.cpp
$(CXX) $(CFLAGS) $(INCLUDES) $(DEFINES) -fPIC -c $< -o $@
client.so : $(OBJS)
$(CXX) $(CFLAGS) $(OBJS) -o client.so -shared -Wl,--no-undefined -fPIC $(LIBS)
clean:
$(RM) $(OBJS)

View File

@ -1,4 +1,4 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//========= Copyright <EFBFBD> 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
@ -34,6 +34,20 @@ engine_studio_api_t IEngineStudio;
/////////////////////
// Implementation of CStudioModelRenderer.h
#define LEGS_BONES_COUNT 8
// enumerate all the bones that used for gait animation
const char *legs_bones[] =
{
"Bip01",
"Bip01 Pelvis",
"Bip01 L Leg",
"Bip01 L Leg1",
"Bip01 L Foot",
"Bip01 R Leg",
"Bip01 R Leg1",
"Bip01 R Foot"
};
/*
====================
@ -330,8 +344,10 @@ void CStudioModelRenderer::StudioSlerpBones( vec4_t q1[], float pos1[][3], vec4_
vec4_t q3;
float s1;
if (s < 0) s = 0;
else if (s > 1.0) s = 1.0;
if( s < 0 )
s = 0;
else if( s > 1.0 )
s = 1.0;
s1 = 1.0 - s;
@ -363,7 +379,7 @@ mstudioanim_t *CStudioModelRenderer::StudioGetAnim( model_t *m_pSubModel, mstudi
if( pseqdesc->seqgroup == 0 )
{
return (mstudioanim_t *)((byte *)m_pStudioHeader + pseqgroup->data + pseqdesc->animindex);
return (mstudioanim_t *)( (byte *)m_pStudioHeader + pseqdesc->animindex );
}
paSequences = (cache_user_t *)m_pSubModel->submodels;
@ -474,7 +490,6 @@ void CStudioModelRenderer::StudioSetUpTransform (int trivial_accept)
// NOTE: Because multiplayer lag can be relatively large, we don't want to cap
// f at 1.5 anymore.
//if( f > -1.0 && f < 1.5 ) {}
//Con_DPrintf( "%.0f %.0f\n",m_pCurrentEntity->msg_angles[0][YAW], m_pCurrentEntity->msg_angles[1][YAW] );
for( i = 0; i < 3; i++ )
{
@ -532,12 +547,9 @@ void CStudioModelRenderer::StudioSetUpTransform (int trivial_accept)
{
for( i = 0; i < 4; i++ )
{
(*m_paliastransform)[0][i] *= m_fSoftwareXScale *
(1.0 / (ZISCALE * 0x10000));
(*m_paliastransform)[1][i] *= m_fSoftwareYScale *
(1.0 / (ZISCALE * 0x10000));
(*m_paliastransform)[0][i] *= m_fSoftwareXScale * ( 1.0 / ( ZISCALE * 0x10000 ) );
(*m_paliastransform)[1][i] *= m_fSoftwareYScale * ( 1.0 / ( ZISCALE * 0x10000 ) );
(*m_paliastransform)[2][i] *= 1.0 / ( ZISCALE * 0x10000 );
}
}
}
@ -616,7 +628,6 @@ void CStudioModelRenderer::StudioCalcRotations ( float pos[][3], vec4_t *q, mstu
// Con_DPrintf( "frame %d %d\n", frame1, frame2 );
dadt = StudioEstimateInterpolant();
s = ( f - frame );
@ -704,7 +715,6 @@ void CStudioModelRenderer::StudioFxTransform( cl_entity_t *ent, float transform[
transform[2][1] *= scale;
}
break;
}
}
@ -727,7 +737,6 @@ float CStudioModelRenderer::StudioEstimateFrame( mstudioseqdesc_t *pseqdesc )
else
{
dfdt = ( m_clTime - m_pCurrentEntity->curstate.animtime ) * m_pCurrentEntity->curstate.framerate * pseqdesc->fps;
}
}
else
@ -779,7 +788,7 @@ StudioSetupBones
*/
void CStudioModelRenderer::StudioSetupBones( void )
{
int i;
int i, j;
double f;
mstudiobone_t *pbones;
@ -843,8 +852,7 @@ void CStudioModelRenderer::StudioSetupBones ( void )
}
}
if (m_fDoInterp &&
m_pCurrentEntity->latched.sequencetime &&
if( m_fDoInterp && m_pCurrentEntity->latched.sequencetime &&
( m_pCurrentEntity->latched.sequencetime + 0.2 > m_clTime ) &&
( m_pCurrentEntity->latched.prevsequence < m_pStudioHeader->numseq ) )
{
@ -908,8 +916,15 @@ void CStudioModelRenderer::StudioSetupBones ( void )
for( i = 0; i < m_pStudioHeader->numbones; i++ )
{
if (strcmp( pbones[i].name, "Bip01 Spine") == 0)
for( j = 0; j < LEGS_BONES_COUNT; j++ )
{
if( !strcmp( pbones[i].name, legs_bones[j] ) )
break;
}
if( j == LEGS_BONES_COUNT )
continue; // not used for legs
memcpy( pos[i], pos2[i], sizeof(pos[i]) );
memcpy( q[i], q2[i], sizeof(q[i]) );
}
@ -951,7 +966,6 @@ void CStudioModelRenderer::StudioSetupBones ( void )
}
}
/*
====================
StudioSaveBones
@ -975,7 +989,6 @@ void CStudioModelRenderer::StudioSaveBones( void )
}
}
/*
====================
StudioMergeBones
@ -1015,7 +1028,6 @@ void CStudioModelRenderer::StudioMergeBones ( model_t *m_pSubModel )
pbones = (mstudiobone_t *)( (byte *)m_pStudioHeader + m_pStudioHeader->boneindex );
for( i = 0; i < m_pStudioHeader->numbones; i++ )
{
for( j = 0; j < m_nCachedBones; j++ )
@ -1316,7 +1328,6 @@ void CStudioModelRenderer::StudioEstimateGait( entity_state_t *pplayer )
if( m_pPlayerInfo->gaityaw < -180 )
m_pPlayerInfo->gaityaw = -180;
}
}
/*
@ -1736,6 +1747,11 @@ void CStudioModelRenderer::StudioRenderFinal_Hardware( void )
gEngfuncs.pTriAPI->RenderMode( kRenderNormal );
}
if( m_pCvarDrawEntities->value == 5 )
{
IEngineStudio.StudioDrawAbsBBox();
}
IEngineStudio.RestoreRenderer();
}
@ -1756,4 +1772,3 @@ void CStudioModelRenderer::StudioRenderFinal(void)
StudioRenderFinal_Software();
}
}

View File

@ -1,15 +1,13 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//========= Copyright <EFBFBD> 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#pragma once
#if !defined ( STUDIOMODELRENDERER_H )
#define STUDIOMODELRENDERER_H
#if defined( _WIN32 )
#pragma once
#endif
/*
====================

View File

@ -68,7 +68,6 @@ int WeaponsResource :: HasAmmo( WEAPON *p )
|| CountAmmo( p->iAmmo2Type ) || ( p->iFlags & WEAPON_FLAGS_SELECTONEMPTY );
}
void WeaponsResource::LoadWeaponSprites( WEAPON *pWeapon )
{
int i, iRes;
@ -108,7 +107,7 @@ void WeaponsResource :: LoadWeaponSprites( WEAPON *pWeapon )
pWeapon->rcCrosshair = p->rc;
}
else
pWeapon->hCrosshair = NULL;
pWeapon->hCrosshair = 0;
p = GetSpriteList( pList, "autoaim", iRes, i );
if( p )
@ -191,7 +190,6 @@ void WeaponsResource :: LoadWeaponSprites( WEAPON *pWeapon )
}
else
pWeapon->hAmmo2 = 0;
}
// Returns the first weapon for a given slot.
@ -211,7 +209,6 @@ WEAPON *WeaponsResource :: GetFirstPos( int iSlot )
return pret;
}
WEAPON* WeaponsResource::GetNextActivePos( int iSlot, int iSlotPos )
{
if ( iSlotPos >= MAX_WEAPON_POSITIONS || iSlot >= MAX_WEAPON_SLOTS )
@ -225,32 +222,31 @@ WEAPON* WeaponsResource :: GetNextActivePos( int iSlot, int iSlotPos )
return p;
}
int giBucketHeight, giBucketWidth, giABHeight, giABWidth; // Ammo Bar width and height
HSPRITE ghsprBuckets; // Sprite for top row of weapons menu
DECLARE_MESSAGE(m_Ammo, CurWeapon ); // Current weapon and clip
DECLARE_MESSAGE(m_Ammo, WeaponList); // new weapon type
DECLARE_MESSAGE(m_Ammo, AmmoX); // update known ammo type's count
DECLARE_MESSAGE(m_Ammo, AmmoPickup); // flashes an ammo pickup record
DECLARE_MESSAGE(m_Ammo, WeapPickup); // flashes a weapon pickup record
DECLARE_MESSAGE(m_Ammo, HideWeapon); // hides the weapon, ammo, and crosshair displays temporarily
DECLARE_MESSAGE(m_Ammo, ItemPickup);
DECLARE_MESSAGE( m_Ammo, CurWeapon ) // Current weapon and clip
DECLARE_MESSAGE( m_Ammo, WeaponList ) // new weapon type
DECLARE_MESSAGE( m_Ammo, AmmoX ) // update known ammo type's count
DECLARE_MESSAGE( m_Ammo, AmmoPickup ) // flashes an ammo pickup record
DECLARE_MESSAGE( m_Ammo, WeapPickup ) // flashes a weapon pickup record
DECLARE_MESSAGE( m_Ammo, HideWeapon ) // hides the weapon, ammo, and crosshair displays temporarily
DECLARE_MESSAGE( m_Ammo, ItemPickup )
DECLARE_COMMAND(m_Ammo, Slot1);
DECLARE_COMMAND(m_Ammo, Slot2);
DECLARE_COMMAND(m_Ammo, Slot3);
DECLARE_COMMAND(m_Ammo, Slot4);
DECLARE_COMMAND(m_Ammo, Slot5);
DECLARE_COMMAND(m_Ammo, Slot6);
DECLARE_COMMAND(m_Ammo, Slot7);
DECLARE_COMMAND(m_Ammo, Slot8);
DECLARE_COMMAND(m_Ammo, Slot9);
DECLARE_COMMAND(m_Ammo, Slot10);
DECLARE_COMMAND(m_Ammo, Close);
DECLARE_COMMAND(m_Ammo, NextWeapon);
DECLARE_COMMAND(m_Ammo, PrevWeapon);
DECLARE_COMMAND( m_Ammo, Slot1 )
DECLARE_COMMAND( m_Ammo, Slot2 )
DECLARE_COMMAND( m_Ammo, Slot3 )
DECLARE_COMMAND( m_Ammo, Slot4 )
DECLARE_COMMAND( m_Ammo, Slot5 )
DECLARE_COMMAND( m_Ammo, Slot6 )
DECLARE_COMMAND( m_Ammo, Slot7 )
DECLARE_COMMAND( m_Ammo, Slot8 )
DECLARE_COMMAND( m_Ammo, Slot9 )
DECLARE_COMMAND( m_Ammo, Slot10 )
DECLARE_COMMAND( m_Ammo, Close )
DECLARE_COMMAND( m_Ammo, NextWeapon )
DECLARE_COMMAND( m_Ammo, PrevWeapon )
// width of ammo fonts
#define AMMO_SMALL_WIDTH 10
@ -295,7 +291,7 @@ int CHudAmmo::Init(void)
gHR.Init();
return 1;
};
}
void CHudAmmo::Reset( void )
{
@ -309,7 +305,7 @@ void CHudAmmo::Reset(void)
gHR.Reset();
//VidInit();
wrect_t nullrc = {};
wrect_t nullrc = {0,};
SetCrosshair( 0, nullrc, 0, 0, 0 ); // reset crosshair
m_pWeapon = NULL; // reset last weapon
}
@ -394,7 +390,6 @@ void CHudAmmo::Think(void)
//
// Helper function to return a Ammo pointer from id
//
HSPRITE* WeaponsResource::GetAmmoPicFromWeapon( int iAmmoId, wrect_t& rect )
{
for( int i = 0; i < MAX_WEAPONS; i++ )
@ -414,13 +409,12 @@ HSPRITE* WeaponsResource :: GetAmmoPicFromWeapon( int iAmmoId, wrect_t& rect )
return NULL;
}
// Menu Selection Code
void WeaponsResource::SelectSlot( int iSlot, int fAdvance, int iDirection )
{
if( gHUD.m_Menu.m_fMenuDisplayed && ( fAdvance == FALSE ) && ( iDirection == 1 ) )
{ // menu is overriding slot use commands
{
// menu is overriding slot use commands
gHUD.m_Menu.SelectMenuItem( iSlot + 1 ); // slots are one off the key numbers
return;
}
@ -451,7 +445,8 @@ void WeaponsResource :: SelectSlot( int iSlot, int fAdvance, int iDirection )
// but only if there is only one item in the bucket
WEAPON *p2 = GetNextActivePos( p->iSlot, p->iSlotPos );
if ( !p2 )
{ // only one active item in bucket, so change directly to weapon
{
// only one active item in bucket, so change directly to weapon
ServerCmd( p->szName );
g_weaponselect = p->iId;
return;
@ -533,13 +528,13 @@ int CHudAmmo::MsgFunc_ItemPickup( const char *pszName, int iSize, void *pbuf )
return 1;
}
int CHudAmmo::MsgFunc_HideWeapon( const char *pszName, int iSize, void *pbuf )
{
BEGIN_READ( pbuf, iSize );
gHUD.m_iHideHUDDisplay = READ_BYTE();
if( gEngfuncs.IsSpectateOnly() )
return 1;
//LRCT - experiment to allow a custom crosshair.
if ( gHUD.m_iHideHUDDisplay & HIDEHUD_CUSTOMCROSSHAIR )
{
@ -550,7 +545,7 @@ int CHudAmmo::MsgFunc_HideWeapon( const char *pszName, int iSize, void *pbuf )
}
else if ( (m_pWeapon == NULL) || (gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL )) )
{
static wrect_t nullrc;
wrect_t nullrc = {0,};
gpActiveSel = NULL;
SetCrosshair( 0, nullrc, 0, 0, 0 );
// CONPRINT("Blanking crosshair\n");
@ -572,7 +567,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 );
@ -590,7 +585,8 @@ int CHudAmmo::MsgFunc_CurWeapon(const char *pszName, int iSize, void *pbuf )
if( iId < 1 )
{
SetCrosshair( 0, nullrc, 0, 0, 0 );
m_pWeapon = NULL; //LRC
// Clear out the weapon so we don't keep drawing the last active weapon's ammo. - Solokiller
m_pWeapon = 0;
return 0;
}
@ -616,7 +612,6 @@ int CHudAmmo::MsgFunc_CurWeapon(const char *pszName, int iSize, void *pbuf )
else
pWeapon->iClip = iClip;
if( iState == 0 ) // we're not the current weapon, so update no more
return 1;
@ -631,14 +626,16 @@ int CHudAmmo::MsgFunc_CurWeapon(const char *pszName, int iSize, void *pbuf )
else if ( !(gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL )) )
{
if( gHUD.m_iFOV >= 90 )
{ // normal crosshairs
{
// 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
{ // zoomed crosshairs
{
// zoomed crosshairs
if( fOnTarget && m_pWeapon->hZoomedAutoaim )
SetCrosshair( m_pWeapon->hZoomedAutoaim, m_pWeapon->rcZoomedAutoaim, 255, 255, 255 );
else
@ -682,7 +679,6 @@ int CHudAmmo::MsgFunc_WeaponList(const char *pszName, int iSize, void *pbuf )
gWR.AddWeapon( &Weapon );
return 1;
}
//------------------------------------------------------------------------
@ -691,6 +687,10 @@ int CHudAmmo::MsgFunc_WeaponList(const char *pszName, int iSize, void *pbuf )
// Slot button pressed
void CHudAmmo::SlotInput( int iSlot )
{
// Let the Viewport use it first, for menus
// if( gViewPort && gViewPort->SlotInput( iSlot ) )
// return;
gWR.SelectSlot(iSlot, FALSE, 1);
}
@ -839,12 +839,9 @@ void CHudAmmo::UserCmd_PrevWeapon(void)
gpActiveSel = NULL;
}
//-------------------------------------------------------------------------
// Drawing code
//-------------------------------------------------------------------------
int CHudAmmo::Draw( float flTime )
{
int a, x, y, r, g, b;
@ -878,7 +875,6 @@ int CHudAmmo::Draw(float flTime)
if( ( pw->iAmmoType < 0 ) && ( pw->iAmmo2Type < 0 ) )
return 0;
int iFlags = DHN_DRAWZERO; // draw 0 values
AmmoWidth = gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).right - gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).left;
@ -903,15 +899,14 @@ int CHudAmmo::Draw(float flTime)
if( pw->iClip >= 0 )
{
// room for the number and the '|' and the current ammo
x = ScreenWidth - ( 8 * AmmoWidth ) - iIconWidth;
x = gHUD.DrawHudNumber( x, y, iFlags | DHN_3DIGITS, pw->iClip, r, g, b );
wrect_t rc;
/*wrect_t rc;
rc.top = 0;
rc.left = 0;
rc.right = AmmoWidth;
rc.bottom = 100;
rc.bottom = 100;*/
int iBarWidth = AmmoWidth / 10;
@ -922,13 +917,11 @@ int CHudAmmo::Draw(float flTime)
// draw the | bar
FillRGBA( x, y, iBarWidth, gHUD.m_iFontHeight, r, g, b, a );
x += iBarWidth + AmmoWidth/2;;
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 );
}
else
{
@ -964,7 +957,6 @@ int CHudAmmo::Draw(float flTime)
return 1;
}
//
// Draws the ammo bar on the hud
//
@ -997,8 +989,6 @@ int DrawBar(int x, int y, int width, int height, float f)
return ( x + width );
}
void DrawAmmoBar( WEAPON *p, int x, int y, int width, int height )
{
if( !p )
@ -1013,9 +1003,7 @@ void DrawAmmoBar(WEAPON *p, int x, int y, int width, int height)
x = DrawBar( x, y, width, height, f );
// Do we have secondary ammo too?
if( p->iAmmo2Type != -1 )
{
f = (float)gWR.CountAmmo( p->iAmmo2Type ) / (float)p->iMax2;
@ -1027,9 +1015,6 @@ void DrawAmmoBar(WEAPON *p, int x, int y, int width, int height)
}
}
//
// Draw Weapon Menu
//
@ -1050,7 +1035,6 @@ int CHudAmmo::DrawWList(float flTime)
x = 10; //!!!
y = 10; //!!!
// Ensure that there are available choices in the active slot
if( iActiveSlot > 0 )
{
@ -1093,7 +1077,6 @@ int CHudAmmo::DrawWList(float flTime)
x += iWidth + 5;
}
a = 128; //!!!
x = 10;
@ -1121,7 +1104,6 @@ int CHudAmmo::DrawWList(float flTime)
UnpackRGB( r,g,b, gHUD.m_iHUDColor );
// if active, then we must have ammo.
if( gpActiveSel == p )
{
SPR_Set( p->hActive, r, g, b );
@ -1133,7 +1115,6 @@ int CHudAmmo::DrawWList(float flTime)
else
{
// Draw Weapon if Red if no ammo
if( gWR.HasAmmo( p ) )
ScaleColors( r, g, b, 192 );
else
@ -1147,14 +1128,12 @@ int CHudAmmo::DrawWList(float flTime)
}
// Draw Ammo Bar
DrawAmmoBar( p, x + giABWidth / 2, y, giABWidth, giABHeight );
y += p->rcActive.bottom - p->rcActive.top + 5;
}
x += iWidth + 5;
}
else
{
@ -1190,10 +1169,8 @@ int CHudAmmo::DrawWList(float flTime)
}
return 1;
}
/* =================================
GetSpriteList

View File

@ -12,13 +12,12 @@
* without written permission from Valve LLC.
*
****/
#pragma once
#ifndef __AMMO_H__
#define __AMMO_H__
#define MAX_WEAPON_NAME 128
#define WEAPON_FLAGS_SELECTONEMPTY 1
#define WEAPON_IS_ONTARGET 0x40
@ -57,6 +56,4 @@ struct WEAPON
};
typedef int AMMO;
#endif

View File

@ -24,8 +24,8 @@
#include <stdio.h>
#include "parsemsg.h"
DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoVal );
DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoIcon );
DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoVal )
DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoIcon )
int CHudAmmoSecondary::Init( void )
{
@ -81,7 +81,8 @@ int CHudAmmoSecondary :: Draw(float flTime)
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect( m_HUD_ammoicon ) );
}
else
{ // move the cursor by the '0' char instead, since we don't have an icon to work with
{
// move the cursor by the '0' char instead, since we don't have an icon to work with
x -= AmmoWidth;
y -= ( gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).top - gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).bottom );
}
@ -145,7 +146,8 @@ int CHudAmmoSecondary :: MsgFunc_SecAmmoVal( const char *pszName, int iSize, voi
}
if( count == 0 )
{ // the ammo fields are all empty, so turn off this hud area
{
// the ammo fields are all empty, so turn off this hud area
m_iFlags &= ~HUD_ACTIVE;
return 1;
}
@ -155,5 +157,3 @@ int CHudAmmoSecondary :: MsgFunc_SecAmmoVal( const char *pszName, int iSize, voi
return 1;
}

View File

@ -49,7 +49,8 @@ void HistoryResource :: AddToHistory( int iType, int iId, int iCount )
return; // no amount, so don't add
if( ( ( ( AMMO_PICKUP_GAP * iCurrentHistorySlot ) + AMMO_PICKUP_PICK_HEIGHT ) > AMMO_PICKUP_HEIGHT_MAX ) || ( iCurrentHistorySlot >= MAX_HISTORY ) )
{ // the pic would have to be drawn too high
{
// the pic would have to be drawn too high
// so start from the bottom
iCurrentHistorySlot = 0;
}
@ -69,7 +70,8 @@ void HistoryResource :: AddToHistory( int iType, const char *szName, int iCount
return;
if( ( ( ( AMMO_PICKUP_GAP * iCurrentHistorySlot ) + AMMO_PICKUP_PICK_HEIGHT ) > AMMO_PICKUP_HEIGHT_MAX ) || ( iCurrentHistorySlot >= MAX_HISTORY ) )
{ // the pic would have to be drawn too high
{
// the pic would have to be drawn too high
// so start from the bottom
iCurrentHistorySlot = 0;
}
@ -77,7 +79,6 @@ void HistoryResource :: AddToHistory( int iType, const char *szName, int iCount
HIST_ITEM *freeslot = &rgAmmoHistory[iCurrentHistorySlot++]; // default to just writing to the first slot
// I am really unhappy with all the code in this file
int i = gHUD.GetSpriteIndex( szName );
if( i == -1 )
return; // unknown sprite name, don't add it to history
@ -90,7 +91,6 @@ void HistoryResource :: AddToHistory( int iType, const char *szName, int iCount
freeslot->DisplayTime = gHUD.m_flTime + HISTORY_DRAW_TIME;
}
void HistoryResource::CheckClearHistory( void )
{
for( int i = 0; i < MAX_HISTORY; i++ )
@ -114,7 +114,8 @@ int HistoryResource :: DrawAmmoHistory( float flTime )
rgAmmoHistory[i].DisplayTime = min( rgAmmoHistory[i].DisplayTime, gHUD.m_flTime + HISTORY_DRAW_TIME );
if( rgAmmoHistory[i].DisplayTime <= flTime )
{ // pic drawing time has expired
{
// pic drawing time has expired
memset( &rgAmmoHistory[i], 0, sizeof(HIST_ITEM) );
CheckClearHistory();
}
@ -132,7 +133,8 @@ int HistoryResource :: DrawAmmoHistory( float flTime )
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
int xpos = ScreenWidth - 24;
if( spr && *spr ) // weapon isn't loaded yet so just don't draw the pic
{ // the dll has to make sure it has sent info the weapons you need
{
// the dll has to make sure it has sent info the weapons you need
SPR_Set( *spr, r, g, b );
SPR_DrawAdditive( 0, xpos, ypos, &rcPic );
}
@ -185,8 +187,5 @@ int HistoryResource :: DrawAmmoHistory( float flTime )
}
}
return 1;
}

View File

@ -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
@ -94,13 +97,12 @@ public:
extern WeaponsResource gWR;
#define MAX_HISTORY 12
enum {
HISTSLOT_EMPTY,
HISTSLOT_AMMO,
HISTSLOT_WEAP,
HISTSLOT_ITEM,
HISTSLOT_ITEM
};
class HistoryResource
@ -138,6 +140,4 @@ public:
};
extern HistoryResource gHR;
#endif // AMMOHISTORY_H

View File

@ -38,8 +38,7 @@ int CHudBattery::Init(void)
gHUD.AddHudElem( this );
return 1;
};
}
int CHudBattery::VidInit( void )
{
@ -52,13 +51,12 @@ int CHudBattery::VidInit(void)
m_iHeight = m_prc2->bottom - m_prc1->top;
m_fFade = 0;
return 1;
};
}
int CHudBattery::MsgFunc_Battery( const char *pszName, int iSize, void *pbuf )
{
m_iFlags |= HUD_ACTIVE;
BEGIN_READ( pbuf, iSize );
int x = READ_SHORT();
@ -71,7 +69,6 @@ int CHudBattery:: MsgFunc_Battery(const char *pszName, int iSize, void *pbuf )
return 1;
}
int CHudBattery::Draw( float flTime )
{
if( gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH )
@ -102,9 +99,7 @@ int CHudBattery::Draw(float flTime)
}
// Fade the health number back to dim
a = MIN_ALPHA + ( m_fFade / FADE_TIME ) * 128;
}
else
a = MIN_ALPHA;

View File

@ -1,4 +1,4 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//========= Copyright <EFBFBD> 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_
@ -20,5 +20,4 @@ void CAM_Init( void );
void CAM_ClearStates( void );
void CAM_StartMouseMove( void );
void CAM_EndMouseMove( void );
#endif // _CAMERA_H_

View File

@ -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"
{
@ -28,10 +35,6 @@ extern "C"
}
#include <string.h>
#include "interface.h"
#include "exportdef.h"
cl_enginefunc_t gEngfuncs;
CHud gHUD;
@ -45,10 +48,21 @@ int g_iTeamNumber;
int g_iPlayerClass;*/
mobile_engfuncs_t *gMobileEngfuncs = NULL;
extern "C" int g_bhopcap;
void InitInput( void );
void EV_HookEvents( void );
void IN_Commands( void );
int __MsgFunc_Bhopcap( const char *pszName, int iSize, void *pbuf )
{
BEGIN_READ( pbuf, iSize );
g_bhopcap = READ_BYTE();
return 1;
}
/*
==========================
Initialize
@ -89,18 +103,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;
}
@ -178,6 +192,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
@ -191,7 +245,25 @@ so the HUD can reinitialize itself.
int DLLEXPORT HUD_VidInit( void )
{
gHUD.VidInit();
#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,8 +281,9 @@ void DLLEXPORT HUD_Init( void )
{
InitInput();
gHUD.Init();
}
gEngfuncs.pfnHookUserMsg( "Bhopcap", __MsgFunc_Bhopcap );
}
/*
==========================
@ -228,7 +301,6 @@ int DLLEXPORT HUD_Redraw( float time, int intermission )
return 1;
}
/*
==========================
HUD_UpdateClientData
@ -272,10 +344,14 @@ Called by engine every frame that client .dll is loaded
void DLLEXPORT HUD_Frame( double time )
{
#ifdef USE_VGUI_FOR_GOLDSOURCE_SUPPORT
if (!gViewPort)
gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect());
#else
gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect());
#endif
}
/*
==========================
HUD_VoiceStatus
@ -308,3 +384,8 @@ void DLLEXPORT HUD_MobilityInterface( mobile_engfuncs_t *gpMobileEngfuncs )
return;
gMobileEngfuncs = gpMobileEngfuncs;
}
bool isXashFWGS()
{
return gMobileEngfuncs != NULL;
}

View File

@ -23,8 +23,8 @@ CFG=cl_dll - Win32 Release
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""$/GoldSrc/cl_dll", HGEBAAAA"
# PROP Scc_LocalPath "."
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
@ -38,12 +38,13 @@ RSC=rc.exe
# 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 Output_Dir "..\temp\cl_dll\!release"
# PROP Intermediate_Dir "..\temp\cl_dll\!release"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
# ADD CPP /nologo /MT /W3 /GX /Zi /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" /FR /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<none>
# ADD BASE MTL /nologo /D "NDEBUG" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
@ -53,14 +54,15 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib winmm.lib ../utils/vgui/lib/win32_vc6/vgui.lib wsock32.lib /nologo /subsystem:windows /dll /map /machine:I386 /out:".\Release\client.dll"
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib winmm.lib ../utils/vgui/lib/win32_vc6/vgui.lib wsock32.lib /nologo /subsystem:windows /dll /machine:I386 /out:"..\temp\cl_dll\!release/client.dll"
# SUBTRACT LINK32 /map
# Begin Custom Build
TargetDir=.\Release
InputPath=.\Release\client.dll
TargetDir=\Xash3D\src_main\temp\cl_dll\!release
InputPath=\Xash3D\src_main\temp\cl_dll\!release\client.dll
SOURCE="$(InputPath)"
"C:\games\half-life\spiritdev\cl_dlls\client.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
copy $(TargetDir)\client.dll "C:\games\half-life\spiritdev\cl_dlls\client.dll"
"D:\Xash3D\valve\cl_dlls\client.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
copy $(TargetDir)\client.dll "D:\Xash3D\valve\cl_dlls\client.dll"
# End Custom Build
@ -73,12 +75,12 @@ SOURCE="$(InputPath)"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir ".\Debug"
# PROP Intermediate_Dir ".\Debug"
# PROP Output_Dir "..\temp\cl_dll\!debug"
# PROP Intermediate_Dir "..\temp\cl_dll\!debug"
# 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"
@ -88,14 +90,14 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386
# ADD LINK32 oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib winmm.lib ../utils/vgui/lib/win32_vc6/vgui.lib wsock32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:".\Debug\client.dll"
# ADD LINK32 oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib winmm.lib ../utils/vgui/lib/win32_vc6/vgui.lib wsock32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"..\temp\cl_dll\!debug/client.dll"
# Begin Custom Build
TargetDir=.\Debug
InputPath=.\Debug\client.dll
TargetDir=\Xash3D\src_main\temp\cl_dll\!debug
InputPath=\Xash3D\src_main\temp\cl_dll\!debug\client.dll
SOURCE="$(InputPath)"
"C:\sierra\Half-Life\spiritdev\cl_dlls\client.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
copy $(TargetDir)\client.dll "C:\sierra\Half-Life\spiritdev\cl_dlls\client.dll"
"D:\Xash3D\valve\cl_dlls\client.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
copy $(TargetDir)\client.dll "D:\Xash3D\valve\cl_dlls\client.dll"
# End Custom Build
@ -153,7 +155,7 @@ SOURCE=.\hl\hl_weapons.cpp
# End Source File
# Begin Source File
SOURCE=..\dlls\wpn_shared\hl_wpn_glock.cpp
SOURCE=..\dlls\glock.cpp
# End Source File
# Begin Source File
@ -161,10 +163,6 @@ SOURCE=..\dlls\hornetgun.cpp
# End Source File
# Begin Source File
SOURCE=..\common\interface.cpp
# End Source File
# Begin Source File
SOURCE=..\dlls\mp5.cpp
# End Source File
# Begin Source File
@ -207,10 +205,6 @@ SOURCE=..\game_shared\voice_banmgr.cpp
SOURCE=..\game_shared\voice_status.cpp
# End Source File
# Begin Source File
SOURCE=..\game_shared\voice_vgui_tweakdlg.cpp
# End Source File
# End Group
# Begin Source File
@ -306,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
@ -327,15 +329,7 @@ SOURCE=.\parsemsg.cpp
# End Source File
# Begin Source File
SOURCE=.\particlemgr.cpp
# End Source File
# Begin Source File
SOURCE=.\particlemsg.cpp
# End Source File
# Begin Source File
SOURCE=.\particlesys.cpp
SOURCE=.\parsemsg.h
# End Source File
# Begin Source File
@ -527,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
@ -539,18 +537,6 @@ SOURCE=.\overview.h
# End Source File
# Begin Source File
SOURCE=.\parsemsg.h
# End Source File
# Begin Source File
SOURCE=.\particlemgr.h
# End Source File
# Begin Source File
SOURCE=.\particlesys.h
# End Source File
# Begin Source File
SOURCE=..\pm_shared\pm_debug.h
# End Source File
# Begin Source File

View File

@ -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;
@ -35,7 +38,18 @@ typedef int (*pfnUserMsgHook)(const char *pszName, int iSize, void *pbuf);
#include "../engine/cdll_int.h"
#include "../dlls/cdll_dll.h"
#ifndef __MSC_VER
#define _cdecl
#endif
#include "exportdef.h"
#include <string.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
extern cl_enginefunc_t gEngfuncs;
#include "../engine/mobility_int.h"
extern mobile_engfuncs_t *gMobileEngfuncs;
#define CONPRINT (gEngfuncs.Con_Printf) //LRC - I can't live without printf!
#endif

View File

@ -15,7 +15,9 @@
//
// cl_util.h
//
#ifndef CL_UTIL_H
#define CL_UTIL_H
#include "exportdef.h"
#include "cvardef.h"
#ifndef TRUE
@ -24,6 +26,7 @@
#endif
// Macros to hook function calls into the HUD object
#define HOOK_MESSAGE(x) gEngfuncs.pfnHookUserMsg( #x, __MsgFunc_##x );
#define DECLARE_MESSAGE(y, x) int __MsgFunc_##x( const char *pszName, int iSize, void *pbuf ) \
@ -31,7 +34,6 @@
return gHUD.y.MsgFunc_##x(pszName, iSize, pbuf ); \
}
#define HOOK_COMMAND(x, y) gEngfuncs.pfnAddCommand( x, __CmdFunc_##y );
#define DECLARE_COMMAND(y, x) void __CmdFunc_##x( void ) \
{ \
@ -61,7 +63,6 @@ inline struct cvar_s *CVAR_CREATE( const char *cv, const char *val, const int fl
//
#define FillRGBA ( *gEngfuncs.pfnFillRGBA )
// ScreenHeight returns the height of the screen, in pixels
#define ScreenHeight ( gHUD.m_scrinfo.iHeight )
// ScreenWidth returns the width of the screen, in pixels
@ -80,10 +81,8 @@ inline struct cvar_s *CVAR_CREATE( const char *cv, const char *val, const int fl
#define ClientCmd ( *gEngfuncs.pfnClientCmd )
#define SetCrosshair ( *gEngfuncs.pfnSetCrosshair )
#define AngleVectors ( *gEngfuncs.pfnAngleVectors )
extern cvar_t *hud_textmode;
extern float g_hud_text_color[3];
inline void DrawSetTextColor( float r, float g, float b )
{
if( hud_textmode->value == 1 )
@ -96,7 +95,11 @@ 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 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 );
@ -117,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;
@ -140,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))
@ -175,3 +180,6 @@ inline void UnpackRGB(int &r, int &g, int &b, unsigned long ulRGB)\
}
HSPRITE LoadSprite( const char *pszName );
bool isXashFWGS();
#endif

View File

@ -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;
@ -151,7 +151,6 @@ void HUD_SetMaxSpeed( const edict_t *ed, float speed )
{
}
/*
=====================
UTIL_WeaponTimeBase
@ -236,7 +235,6 @@ UTIL_SharedRandomFloat
*/
float UTIL_SharedRandomFloat( unsigned int seed, float low, float high )
{
//
unsigned int range;
U_Srand( (int)seed + *(int *)&low + *(int *)&high );
@ -270,8 +268,26 @@ 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 ) { return 0; }
int stub_PrecacheSound ( char* s ) { return 0; }
unsigned short stub_PrecacheEvent ( int type, const char *s ) { return 0; }
const char *stub_NameForFunction ( unsigned long function ) { return "func"; }
void stub_SetModel ( edict_t *e, const char *m ) {}
int stub_PrecacheModel( const char* s )
{
return 0;
}
int stub_PrecacheSound( const char* s )
{
return 0;
}
unsigned short stub_PrecacheEvent( int type, const char *s )
{
return 0;
}
const char *stub_NameForFunction( void *function )
{
return "func";
}
void stub_SetModel( edict_t *e, const char *m )
{
}

View File

@ -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,21 +26,19 @@ 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;
extern int g_runfuncs;
extern vec3_t v_angles;
extern float g_lastFOV;
extern struct local_state_s *g_finalstate;
#endif

84
cl_dll/compile.bat Normal file
View File

@ -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.

View File

@ -15,6 +15,7 @@
//
// death notice
//
#include "hud.h"
#include "cl_util.h"
#include "parsemsg.h"
@ -22,8 +23,7 @@
#include <string.h>
#include <stdio.h>
DECLARE_MESSAGE( m_DeathNotice, DeathMsg );
DECLARE_MESSAGE( m_DeathNotice, DeathMsg )
struct DeathNoticeItem {
char szKiller[MAX_PLAYER_NAME_LENGTH * 2];
@ -59,7 +59,6 @@ float *GetClientColor( int clientIndex )
case 3: return g_ColorYellow;
case 4: return g_ColorGreen;
case 0: return g_ColorYellow;
default: return g_ColorGrey;
}
@ -77,13 +76,11 @@ int CHudDeathNotice :: Init( void )
return 1;
}
void CHudDeathNotice::InitHUDData( void )
{
memset( rgDeathNoticeList, 0, sizeof(rgDeathNoticeList) );
}
int CHudDeathNotice::VidInit( void )
{
m_HUD_d_skull = gHUD.GetSpriteIndex( "d_skull" );
@ -101,7 +98,8 @@ int CHudDeathNotice :: Draw( float flTime )
break; // we've gone through them all
if( rgDeathNoticeList[i].flDisplayTime < flTime )
{ // display time has expired
{
// display time has expired
// remove the current item from the list
memmove( &rgDeathNoticeList[i], &rgDeathNoticeList[i + 1], sizeof(DeathNoticeItem) * ( MAX_DEATHNOTICES - i ) );
i--; // continue on the next item; stop the counter getting incremented
@ -111,6 +109,7 @@ int CHudDeathNotice :: Draw( float flTime )
rgDeathNoticeList[i].flDisplayTime = min( rgDeathNoticeList[i].flDisplayTime, gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME );
// Only draw if the viewport will let me
// vgui dropped out
//if( gViewPort && gViewPort->AllowedToPrintText() )
{
// Draw the death notice
@ -177,7 +176,8 @@ int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *p
break;
}
if( i == MAX_DEATHNOTICES )
{ // move the rest of the list forward to make room for this item
{
// move the rest of the list forward to make room for this item
memmove( rgDeathNoticeList, rgDeathNoticeList + 1, sizeof(DeathNoticeItem) * MAX_DEATHNOTICES );
i = MAX_DEATHNOTICES - 1;
}
@ -187,7 +187,8 @@ int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *p
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,7 +202,7 @@ int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *p
}
// 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 )
victim_name = g_PlayerInfoList[victim].name;
@ -296,7 +297,3 @@ int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *p
return 1;
}

View File

@ -12,14 +12,13 @@
* without written permission from Valve LLC.
*
****/
#include "hud.h"
#include "cl_util.h"
#include "demo.h"
#include "demo_api.h"
#include <memory.h>
#include "exportdef.h"
int g_demosniper = 0;
int g_demosniperdamage = 0;
float g_demosniperorg[3];

View File

@ -1,13 +1,13 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//========= Copyright © 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
@ -23,5 +23,4 @@ extern int g_demosniperdamage;
extern float g_demosniperorg[3];
extern float g_demosniperangles[3];
extern float g_demozoom;
#endif

View File

@ -1,4 +1,4 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
@ -20,8 +20,6 @@
#include "pmtrace.h"
#include "pm_shared.h"
#include "exportdef.h"
void Game_AddObjects( void );
extern vec3_t v_origin;
@ -70,7 +68,6 @@ int DLLEXPORT HUD_AddEntity( int type, struct cl_entity_s *ent, const char *mode
if( ( g_iUser1 == OBS_IN_EYE || gHUD.m_Spectator.m_pip->value == INSET_IN_EYE ) &&
ent->index == g_iUser2 )
return 0; // don't draw the player we are following in eye
}
return 1;
@ -212,7 +209,6 @@ void DLLEXPORT HUD_TxferPredictionData ( struct entity_state_s *ps, const struct
pcd->iuser1 = g_iUser1; // observer mode
pcd->iuser2 = g_iUser2; // first target
pcd->iuser3 = g_iUser3; // second target
}
// Fire prevention
@ -270,9 +266,7 @@ void MoveModel( void )
gEngfuncs.CL_CreateVisibleEntity( ET_NORMAL, &mymodel[i * 3 + j] );
}
}
}
#endif
//#define TRACE_TEST
@ -303,7 +297,6 @@ void TraceModel( void )
gEngfuncs.CL_CreateVisibleEntity( ET_NORMAL, &hit );
}
#endif
*/
@ -349,7 +342,7 @@ void Particles( void )
for( j = 0; j < 3; j++ )
{
p->org[ j ] = v_origin[ j ] + gEngfuncs.pfnRandomFloat( -32.0, 32.0 );;
p->org[j] = v_origin[j] + gEngfuncs.pfnRandomFloat( -32.0, 32.0 );
p->vel[j] = gEngfuncs.pfnRandomFloat( -100.0, 100.0 );
}
@ -520,7 +513,6 @@ void DLLEXPORT HUD_CreateEntities( void )
#if defined( TEST_IT )
MoveModel();
#endif
#if defined( TRACE_TEST )
TraceModel();
#endif
@ -531,11 +523,9 @@ void DLLEXPORT HUD_CreateEntities( void )
/*
TempEnts();
*/
#if defined( BEAM_TEST )
Beams();
#endif
// Add in any game specific objects
Game_AddObjects();
}
@ -595,7 +585,7 @@ 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 )
@ -633,7 +623,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;
@ -655,7 +645,6 @@ void DLLEXPORT HUD_TempEntUpdate (
pTemp->entity.curstate.renderamt = pTemp->entity.baseline.renderamt * ( 1 + life * pTemp->fadeSpeed );
if( pTemp->entity.curstate.renderamt <= 0 )
active = 0;
}
else
active = 0;
@ -720,15 +709,14 @@ 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)pTemp );
pTemp->entity.origin[1] += pTemp->entity.baseline.origin[1] * frametime + 4 * sin( client_time * 30 + (int)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
{
for( i = 0; i < 3; i++ )
@ -788,7 +776,6 @@ void DLLEXPORT HUD_TempEntUpdate (
gEngfuncs.pEventAPI->EV_PlayerTrace( pTemp->entity.prevstate.origin, pTemp->entity.origin, PM_STUDIO_BOX, -1, &pmtrace );
if( pmtrace.fraction != 1 )
{
pe = gEngfuncs.pEventAPI->EV_GetPhysent( pmtrace.ent );
@ -893,7 +880,6 @@ void DLLEXPORT HUD_TempEntUpdate (
}
}
if( ( pTemp->flags & FTENT_FLICKER ) && gTempEntFrame == pTemp->entity.curstate.effects )
{
dlight_t *dl = gEngfuncs.pEfxAPI->CL_AllocDlight(0);
@ -938,7 +924,6 @@ void DLLEXPORT HUD_TempEntUpdate (
}
pTemp = pnext;
}
finish:
// Restore state info
gEngfuncs.pEventAPI->EV_PopPMStates();
@ -972,4 +957,3 @@ cl_entity_t DLLEXPORT *HUD_GetUserEntity( int index )
return NULL;
#endif
}

View File

@ -13,6 +13,7 @@
*
****/
// shared event functions
#include "hud.h"
#include "cl_util.h"
#include "const.h"

View File

@ -12,6 +12,7 @@
* without written permission from Valve LLC.
*
****/
#include "hud.h"
#include "cl_util.h"
#include "const.h"
@ -37,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 );
@ -48,7 +49,6 @@ extern cvar_t *cl_lw;
extern "C"
{
// HLDM
void EV_FireGlock1( struct event_args_s *args );
void EV_FireGlock2( struct event_args_s *args );
@ -69,7 +69,6 @@ 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 );
}
@ -95,7 +94,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;
@ -107,7 +106,6 @@ float EV_HLDM_PlayTextureSound( int idx, pmtrace_t *ptr, float *vecSrc, float *v
// FIXME check if playtexture sounds movevar is set
//
chTextureType = 0;
// Player
@ -149,47 +147,63 @@ float EV_HLDM_PlayTextureSound( int idx, pmtrace_t *ptr, float *vecSrc, float *v
switch (chTextureType)
{
default:
case CHAR_TEX_CONCRETE: fvol = 0.9; fvolbar = 0.6;
case CHAR_TEX_CONCRETE:
fvol = 0.9;
fvolbar = 0.6;
rgsz[0] = "player/pl_step1.wav";
rgsz[1] = "player/pl_step2.wav";
cnt = 2;
break;
case CHAR_TEX_METAL: fvol = 0.9; fvolbar = 0.3;
case CHAR_TEX_METAL:
fvol = 0.9;
fvolbar = 0.3;
rgsz[0] = "player/pl_metal1.wav";
rgsz[1] = "player/pl_metal2.wav";
cnt = 2;
break;
case CHAR_TEX_DIRT: fvol = 0.9; fvolbar = 0.1;
case CHAR_TEX_DIRT:
fvol = 0.9;
fvolbar = 0.1;
rgsz[0] = "player/pl_dirt1.wav";
rgsz[1] = "player/pl_dirt2.wav";
rgsz[2] = "player/pl_dirt3.wav";
cnt = 3;
break;
case CHAR_TEX_VENT: fvol = 0.5; fvolbar = 0.3;
case CHAR_TEX_VENT:
fvol = 0.5;
fvolbar = 0.3;
rgsz[0] = "player/pl_duct1.wav";
rgsz[1] = "player/pl_duct1.wav";
cnt = 2;
break;
case CHAR_TEX_GRATE: fvol = 0.9; fvolbar = 0.5;
case CHAR_TEX_GRATE:
fvol = 0.9;
fvolbar = 0.5;
rgsz[0] = "player/pl_grate1.wav";
rgsz[1] = "player/pl_grate4.wav";
cnt = 2;
break;
case CHAR_TEX_TILE: fvol = 0.8; fvolbar = 0.2;
case CHAR_TEX_TILE:
fvol = 0.8;
fvolbar = 0.2;
rgsz[0] = "player/pl_tile1.wav";
rgsz[1] = "player/pl_tile3.wav";
rgsz[2] = "player/pl_tile2.wav";
rgsz[3] = "player/pl_tile4.wav";
cnt = 4;
break;
case CHAR_TEX_SLOSH: fvol = 0.9; fvolbar = 0.0;
case CHAR_TEX_SLOSH:
fvol = 0.9;
fvolbar = 0.0;
rgsz[0] = "player/pl_slosh1.wav";
rgsz[1] = "player/pl_slosh3.wav";
rgsz[2] = "player/pl_slosh2.wav";
rgsz[3] = "player/pl_slosh4.wav";
cnt = 4;
break;
case CHAR_TEX_WOOD: fvol = 0.9; fvolbar = 0.2;
case CHAR_TEX_WOOD:
fvol = 0.9;
fvolbar = 0.2;
rgsz[0] = "debris/wood1.wav";
rgsz[1] = "debris/wood2.wav";
rgsz[2] = "debris/wood3.wav";
@ -197,7 +211,8 @@ float EV_HLDM_PlayTextureSound( int idx, pmtrace_t *ptr, float *vecSrc, float *v
break;
case CHAR_TEX_GLASS:
case CHAR_TEX_COMPUTER:
fvol = 0.8; fvolbar = 0.2;
fvol = 0.8;
fvolbar = 0.2;
rgsz[0] = "debris/glass1.wav";
rgsz[1] = "debris/glass2.wav";
rgsz[2] = "debris/glass3.wav";
@ -206,7 +221,8 @@ float EV_HLDM_PlayTextureSound( int idx, pmtrace_t *ptr, float *vecSrc, float *v
case CHAR_TEX_FLESH:
if( iBulletType == BULLET_PLAYER_CROWBAR )
return 0.0; // crowbar already makes this sound
fvol = 1.0; fvolbar = 0.2;
fvol = 1.0;
fvolbar = 0.2;
rgsz[0] = "weapons/bullet_hit1.wav";
rgsz[1] = "weapons/bullet_hit2.wav";
fattn = 1.0;
@ -253,11 +269,21 @@ void EV_HLDM_GunshotDecalTrace( pmtrace_t *pTrace, char *decalName )
{
switch( iRand % 5 )
{
case 0: gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break;
case 1: gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break;
case 2: gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric3.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break;
case 3: gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric4.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break;
case 4: gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric5.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break;
case 0:
gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM );
break;
case 1:
gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM );
break;
case 2:
gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric3.wav", 1.0, ATTN_NORM, 0, PITCH_NORM );
break;
case 3:
gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric4.wav", 1.0, ATTN_NORM, 0, PITCH_NORM );
break;
case 4:
gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric5.wav", 1.0, ATTN_NORM, 0, PITCH_NORM );
break;
}
}
@ -281,7 +307,7 @@ void EV_HLDM_DecalGunshot( pmtrace_t *pTrace, int iBulletType )
pe = gEngfuncs.pEventAPI->EV_GetPhysent( pTrace->ent );
if ( pe && pe->solid == SOLID_BSP )
if( pe && ( pe->solid == SOLID_BSP || pe->movetype == MOVETYPE_PUSHSTEP ) )
{
switch( iBulletType )
{
@ -342,7 +368,6 @@ int EV_HLDM_CheckTracer( int idx, float *vecSrc, float *end, float *forward, flo
return tracer;
}
/*
================
FireBullets
@ -360,8 +385,8 @@ void EV_HLDM_FireBullets( int idx, float *forward, float *right, float *up, int
for( iShot = 1; iShot <= cShots; iShot++ )
{
vec3_t vecDir, vecEnd;
float x, y, z;
//We randomize for the Shotgun.
if( iBulletType == BULLET_PLAYER_BUCKSHOT )
{
@ -379,7 +404,6 @@ void EV_HLDM_FireBullets( int idx, float *forward, float *right, float *up, int
}//But other guns already have their spread randomized in the synched spread.
else
{
for( i = 0 ; i < 3; i++ )
{
vecDir[i] = vecDirShooting[i] + flSpreadX * right[i] + flSpreadY * up [i];
@ -407,13 +431,10 @@ void EV_HLDM_FireBullets( int idx, float *forward, float *right, float *up, int
{
default:
case BULLET_PLAYER_9MM:
EV_HLDM_PlayTextureSound( idx, &tr, vecSrc, vecEnd, iBulletType );
EV_HLDM_DecalGunshot( &tr, iBulletType );
break;
case BULLET_PLAYER_MP5:
if( !tracer )
{
EV_HLDM_PlayTextureSound( idx, &tr, vecSrc, vecEnd, iBulletType );
@ -421,17 +442,12 @@ void EV_HLDM_FireBullets( int idx, float *forward, float *right, float *up, int
}
break;
case BULLET_PLAYER_BUCKSHOT:
EV_HLDM_DecalGunshot( &tr, iBulletType );
break;
case BULLET_PLAYER_357:
EV_HLDM_PlayTextureSound( idx, &tr, vecSrc, vecEnd, iBulletType );
EV_HLDM_DecalGunshot( &tr, iBulletType );
break;
}
}
@ -505,6 +521,7 @@ 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 );
@ -514,7 +531,7 @@ void EV_FireGlock2( event_args_t *args )
{
// 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 );
}
@ -529,8 +546,7 @@ 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
@ -553,7 +569,7 @@ void EV_FireShotGunDouble( 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 );
@ -586,11 +602,11 @@ void EV_FireShotGunDouble( event_args_t *args )
if( gEngfuncs.GetMaxClients() > 1 )
{
EV_HLDM_FireBullets( idx, forward, right, up, 8, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &tracerCount[idx-1], 0.17365, 0.04362 );
EV_HLDM_FireBullets( idx, forward, right, up, 8, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &g_tracerCount[idx - 1], 0.17365, 0.04362 );
}
else
{
EV_HLDM_FireBullets( idx, forward, right, up, 12, 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 );
}
}
@ -607,7 +623,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 );
@ -638,11 +654,11 @@ void EV_FireShotGunSingle( event_args_t *args )
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 );
EV_HLDM_FireBullets( idx, forward, right, up, 4, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &g_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, 6, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &g_tracerCount[idx - 1], 0.08716, 0.08716 );
}
}
//======================
@ -664,7 +680,7 @@ void EV_FireMP5( event_args_t *args )
int shell;
vec3_t vecSrc, vecAiming;
vec3_t up, right, forward;
float flSpread = 0.01;
//float flSpread = 0.01;
idx = args->entindex;
VectorCopy( args->origin, origin );
@ -703,11 +719,11 @@ void EV_FireMP5( event_args_t *args )
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 );
EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_MP5, 2, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 );
}
else
{
EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_MP5, 2, &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 );
}
}
@ -754,7 +770,7 @@ void EV_FirePython( event_args_t *args )
vec3_t vecSrc, vecAiming;
vec3_t up, right, forward;
float flSpread = 0.01;
//float flSpread = 0.01;
idx = args->entindex;
VectorCopy( args->origin, origin );
@ -845,16 +861,16 @@ void EV_FireGauss( event_args_t *args )
vec3_t angles;
vec3_t velocity;
float flDamage = args->fparam1;
int primaryfire = args->bparam1;
//int primaryfire = args->bparam1;
int m_fPrimaryFire = args->bparam1;
int m_iWeaponVolume = GAUSS_PRIMARY_FIRE_VOLUME;
//int m_iWeaponVolume = GAUSS_PRIMARY_FIRE_VOLUME;
vec3_t vecSrc;
vec3_t vecDest;
edict_t *pentIgnore;
//edict_t *pentIgnore;
pmtrace_t tr, beam_tr;
float flMaxFrac = 1.0;
int nTotal = 0;
//int nTotal = 0;
int fHasPunched = 0;
int fFirstBeam = 1;
int nMaxHits = 10;
@ -890,7 +906,6 @@ void EV_FireGauss( event_args_t *args )
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 ) );
@ -966,7 +981,7 @@ void EV_FireGauss( event_args_t *args )
{
float n;
pentIgnore = NULL;
//pentIgnore = NULL;
n = -DotProduct( tr.plane.normal, forward );
@ -1000,7 +1015,6 @@ void EV_FireGauss( event_args_t *args )
}
flDamage = flDamage * ( 1 - n );
}
else
{
@ -1035,10 +1049,8 @@ void EV_FireGauss( event_args_t *args )
if( !beam_tr.allsolid )
{
vec3_t delta;
//float n;
// 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 );
@ -1091,7 +1103,6 @@ void EV_FireGauss( event_args_t *args )
// slug doesn't punch through ever with primary
// fire, so leave a little glowy bit and make some balls
gEngfuncs.pEfxAPI->R_TempSprite( tr.endpos, vec3_origin, 0.2, m_iGlow, kRenderGlow, kRenderFxNoDissipation, 200.0 / 255.0, 0.3, FTENT_FADEOUT );
{
vec3_t fwd;
VectorAdd( tr.endpos, tr.plane.normal, fwd );
@ -1117,8 +1128,8 @@ void EV_FireGauss( event_args_t *args )
//======================
// CROWBAR START
//======================
enum crowbar_e {
enum crowbar_e
{
CROWBAR_IDLE = 0,
CROWBAR_DRAW,
CROWBAR_HOLSTER,
@ -1127,7 +1138,13 @@ enum crowbar_e {
CROWBAR_ATTACK2MISS,
CROWBAR_ATTACK2HIT,
CROWBAR_ATTACK3MISS,
#ifndef CROWBAR_IDLE_ANIM
CROWBAR_ATTACK3HIT
#else
CROWBAR_ATTACK3HIT,
CROWBAR_IDLE2,
CROWBAR_IDLE3
#endif
};
int g_iSwing;
@ -1149,16 +1166,17 @@ void EV_Crowbar( event_args_t *args )
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;
gEngfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK1MISS, 1 );
break;
case 1:
gEngfuncs.pEventAPI->EV_WeaponAnimation ( CROWBAR_ATTACK2MISS, 1 ); break;
gEngfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK2MISS, 1 );
break;
case 2:
gEngfuncs.pEventAPI->EV_WeaponAnimation ( CROWBAR_ATTACK3MISS, 1 ); break;
gEngfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK3MISS, 1 );
break;
}
}
}
@ -1169,7 +1187,8 @@ void EV_Crowbar( event_args_t *args )
//======================
// CROSSBOW START
//======================
enum crossbow_e {
enum crossbow_e
{
CROSSBOW_IDLE1 = 0, // full
CROSSBOW_IDLE2, // empty
CROSSBOW_FIDGET1, // full
@ -1181,7 +1200,7 @@ enum crossbow_e {
CROSSBOW_DRAW1, // full
CROSSBOW_DRAW2, // empty
CROSSBOW_HOLSTER1, // full
CROSSBOW_HOLSTER2, // empty
CROSSBOW_HOLSTER2 // empty
};
//=====================
@ -1248,9 +1267,11 @@ void EV_FireCrossbow2( event_args_t *args )
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;
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;
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.
@ -1312,7 +1333,8 @@ void EV_FireCrossbow( event_args_t *args )
//======================
// RPG START
//======================
enum rpg_e {
enum rpg_e
{
RPG_IDLE = 0,
RPG_FIDGET,
RPG_RELOAD, // to reload
@ -1322,7 +1344,7 @@ enum rpg_e {
RPG_HOLSTER2, // unloaded
RPG_DRAW_UL, // unloaded
RPG_IDLE_UL, // unloaded idle
RPG_FIDGET_UL, // unloaded fidget
RPG_FIDGET_UL // unloaded fidget
};
void EV_FireRpg( event_args_t *args )
@ -1351,7 +1373,8 @@ void EV_FireRpg( event_args_t *args )
//======================
// EGON END
//======================
enum egon_e {
enum egon_e
{
EGON_IDLE1 = 0,
EGON_FIDGET1,
EGON_ALTFIREON,
@ -1368,8 +1391,17 @@ enum egon_e {
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};
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"
@ -1385,16 +1417,15 @@ BEAM *pBeam2;
void EV_EgonFire( event_args_t *args )
{
int idx, iFireState, iFireMode;
int idx, /*iFireState,*/ iFireMode;
vec3_t origin;
idx = args->entindex;
VectorCopy( args->origin, origin );
iFireState = args->iparam1;
//iFireState = args->iparam1;
iFireMode = args->iparam2;
int iStartup = args->bparam1;
if( iStartup )
{
if( iFireMode == FIRE_WIDE )
@ -1404,6 +1435,12 @@ void EV_EgonFire( event_args_t *args )
}
else
{
// If there is any sound playing already, kill it. - Solokiller
// This is necessary because multiple sounds can play on the same channel at the same time.
// In some cases, more than 1 run sound plays when the egon stops firing, in which case only the earliest entry in the list is stopped.
// This ensures no more than 1 of those is ever active at the same time.
gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_STATIC, EGON_SOUND_RUN );
if( iFireMode == FIRE_WIDE )
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_STATIC, EGON_SOUND_RUN, 0.98, ATTN_NORM, 0, 125 );
else
@ -1456,7 +1493,6 @@ void EV_EgonFire( event_args_t *args )
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 )
@ -1488,7 +1524,6 @@ void EV_EgonStop( event_args_t *args )
pBeam = NULL;
}
if( pBeam2 )
{
pBeam2->die = 0.0;
@ -1503,7 +1538,8 @@ void EV_EgonStop( event_args_t *args )
//======================
// HORNET START
//======================
enum hgun_e {
enum hgun_e
{
HGUN_IDLE1 = 0,
HGUN_FIDGETSWAY,
HGUN_FIDGETSHAKE,
@ -1514,13 +1550,13 @@ enum hgun_e {
void EV_HornetGunFire( event_args_t *args )
{
int idx, iFireMode;
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;
//iFireMode = args->iparam1;
//Only play the weapon anims if I shot it.
if( EV_IsLocal( idx ) )
@ -1531,9 +1567,15 @@ void EV_HornetGunFire( event_args_t *args )
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;
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;
}
}
//======================
@ -1543,7 +1585,8 @@ void EV_HornetGunFire( event_args_t *args )
//======================
// TRIPMINE START
//======================
enum tripmine_e {
enum tripmine_e
{
TRIPMINE_IDLE1 = 0,
TRIPMINE_IDLE2,
TRIPMINE_ARM1,
@ -1552,7 +1595,7 @@ enum tripmine_e {
TRIPMINE_HOLSTER,
TRIPMINE_DRAW,
TRIPMINE_WORLD,
TRIPMINE_GROUND,
TRIPMINE_GROUND
};
//We only check if it's possible to put a trip mine
@ -1598,7 +1641,8 @@ void EV_TripmineFire( event_args_t *args )
//======================
// SQUEAK START
//======================
enum squeak_e {
enum squeak_e
{
SQUEAK_IDLE1 = 0,
SQUEAK_FIDGETFIT,
SQUEAK_FIDGETNIP,
@ -1657,7 +1701,7 @@ void EV_TrainPitchAdjust( event_args_t *args )
int pitch;
int stop;
char sz[ 256 ];
const char *pszSound;
idx = args->entindex;
@ -1672,25 +1716,36 @@ void EV_TrainPitchAdjust( event_args_t *args )
switch( noise )
{
case 1: strcpy( sz, "plats/ttrain1.wav"); break;
case 2: strcpy( sz, "plats/ttrain2.wav"); break;
case 3: strcpy( sz, "plats/ttrain3.wav"); break;
case 4: strcpy( sz, "plats/ttrain4.wav"); break;
case 5: strcpy( sz, "plats/ttrain6.wav"); break;
case 6: strcpy( sz, "plats/ttrain7.wav"); break;
case 1:
pszSound = "plats/ttrain1.wav";
break;
case 2:
pszSound = "plats/ttrain2.wav";
break;
case 3:
pszSound = "plats/ttrain3.wav";
break;
case 4:
pszSound = "plats/ttrain4.wav";
break;
case 5:
pszSound = "plats/ttrain6.wav";
break;
case 6:
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 );
}
}

View File

@ -1,10 +1,11 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#pragma once
#if !defined ( EV_HLDMH )
#define EV_HLDMH
@ -20,10 +21,11 @@ typedef enum
BULLET_MONSTER_9MM,
BULLET_MONSTER_MP5,
BULLET_MONSTER_12MM,
BULLET_MONSTER_12MM
}Bullet;
enum glock_e {
enum glock_e
{
GLOCK_IDLE1 = 0,
GLOCK_IDLE2,
GLOCK_IDLE3,
@ -36,7 +38,8 @@ enum glock_e {
GLOCK_ADD_SILENCER
};
enum shotgun_e {
enum shotgun_e
{
SHOTGUN_IDLE = 0,
SHOTGUN_FIRE,
SHOTGUN_FIRE2,
@ -58,10 +61,11 @@ enum mp5_e
MP5_DEPLOY,
MP5_FIRE1,
MP5_FIRE2,
MP5_FIRE3,
MP5_FIRE3
};
enum python_e {
enum python_e
{
PYTHON_IDLE1 = 0,
PYTHON_FIDGET,
PYTHON_FIRE1,
@ -75,7 +79,8 @@ enum python_e {
#define GAUSS_PRIMARY_CHARGE_VOLUME 256// how loud gauss is while charging
#define GAUSS_PRIMARY_FIRE_VOLUME 450// how loud gauss is when discharged
enum gauss_e {
enum gauss_e
{
GAUSS_IDLE = 0,
GAUSS_IDLE2,
GAUSS_FIDGET,
@ -91,5 +96,4 @@ void EV_HLDM_GunshotDecalTrace( pmtrace_t *pTrace, char *decalName );
void EV_HLDM_DecalGunshot( pmtrace_t *pTrace, int iBulletType );
int EV_HLDM_CheckTracer( int idx, float *vecSrc, float *end, float *forward, float *right, int iBulletType, int iTracerFreq, int *tracerCount );
void EV_HLDM_FireBullets( int idx, float *forward, float *right, float *up, int cShots, float *vecSrc, float *vecDirShooting, float flDistance, int iBulletType, int iTracerFreq, int *tracerCount, float flSpreadX, float flSpreadY );
#endif // EV_HLDMH

View File

@ -1,4 +1,4 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
@ -6,6 +6,7 @@
//=============================================================================
// eventscripts.h
#pragma once
#if !defined ( EVENTSCRIPTSH )
#define EVENTSCRIPTSH
@ -15,49 +16,6 @@
#define FTENT_FADEOUT 0x00000080
#define DMG_GENERIC 0 // generic damage was done
#define DMG_CRUSH (1 << 0) // crushed by falling or moving object
#define DMG_BULLET (1 << 1) // shot
#define DMG_SLASH (1 << 2) // cut, clawed, stabbed
#define DMG_BURN (1 << 3) // heat burned
#define DMG_FREEZE (1 << 4) // frozen
#define DMG_FALL (1 << 5) // fell too far
#define DMG_BLAST (1 << 6) // explosive blast damage
#define DMG_CLUB (1 << 7) // crowbar, punch, headbutt
#define DMG_SHOCK (1 << 8) // electric shock
#define DMG_SONIC (1 << 9) // sound pulse shockwave
#define DMG_ENERGYBEAM (1 << 10) // laser or other high energy beam
#define DMG_NEVERGIB (1 << 12) // with this bit OR'd in, no damage type will be able to gib victims upon death
#define DMG_ALWAYSGIB (1 << 13) // with this bit OR'd in, any damage type can be made to gib victims upon death.
// time-based damage
//mask off TF-specific stuff too
#define DMG_TIMEBASED (~(0xff003fff)) // mask for time-based damage
#define DMG_DROWN (1 << 14) // Drowning
#define DMG_FIRSTTIMEBASED DMG_DROWN
#define DMG_PARALYZE (1 << 15) // slows affected creature down
#define DMG_NERVEGAS (1 << 16) // nerve toxins, very bad
#define DMG_POISON (1 << 17) // blood poisioning
#define DMG_RADIATION (1 << 18) // radiation exposure
#define DMG_DROWNRECOVER (1 << 19) // drowning recovery
#define DMG_ACID (1 << 20) // toxic chemicals or acid burns
#define DMG_SLOWBURN (1 << 21) // in an oven
#define DMG_SLOWFREEZE (1 << 22) // in a subzero freezer
#define DMG_MORTAR (1 << 23) // Hit by air raid (done to distinguish grenade from mortar)
//TF ADDITIONS
#define DMG_IGNITE (1 << 24) // Players hit by this begin to burn
#define DMG_RADIUS_MAX (1 << 25) // Radius damage with this flag doesn't decrease over distance
#define DMG_RADIUS_QUAKE (1 << 26) // Radius damage is done like Quake. 1/2 damage at 1/2 radius.
#define DMG_IGNOREARMOR (1 << 27) // Damage ignores target's armor
#define DMG_AIMED (1 << 28) // Does Hit location damage
#define DMG_WALLPIERCING (1 << 29) // Blast Damages ents through walls
#define DMG_CALTROP (1<<30)
#define DMG_HALLUC (1<<31)
// Some of these are HL/TFC specific?
void EV_EjectBrass( float *origin, float *velocity, float rotation, int model, int soundtype );
void EV_GetGunPosition( struct event_args_s *args, float *pos, float *origin );
@ -69,5 +27,4 @@ void EV_CreateTracer( float *start, float *end );
struct cl_entity_s *GetEntity( int idx );
struct cl_entity_s *GetViewEntity( void );
void EV_MuzzleFlash( void );
#endif // EVENTSCRIPTSH

View File

@ -25,8 +25,6 @@
#include <string.h>
#include <stdio.h>
DECLARE_MESSAGE( m_Flash, FlashBat )
DECLARE_MESSAGE( m_Flash, Flashlight )
@ -45,12 +43,14 @@ int CHudFlashlight::Init(void)
gHUD.AddHudElem( this );
return 1;
};
}
void CHudFlashlight::Reset( void )
{
m_fFade = 0;
m_fOn = 0;
m_iBat = 100;
m_flBat = 1.0;
}
int CHudFlashlight::VidInit( void )
@ -68,12 +68,10 @@ int CHudFlashlight::VidInit(void)
m_iWidth = m_prc2->right - m_prc2->left;
return 1;
};
}
int CHudFlashlight::MsgFunc_FlashBat( const char *pszName, int iSize, void *pbuf )
{
BEGIN_READ( pbuf, iSize );
int x = READ_BYTE();
m_iBat = x;
@ -84,7 +82,6 @@ int CHudFlashlight:: MsgFunc_FlashBat(const char *pszName, int iSize, void *pbu
int CHudFlashlight::MsgFunc_Flashlight( const char *pszName, int iSize, void *pbuf )
{
BEGIN_READ( pbuf, iSize );
m_fOn = READ_BYTE();
int x = READ_BYTE();
@ -134,7 +131,8 @@ int CHudFlashlight::Draw(float flTime)
SPR_DrawAdditive( 0, x, y, m_prc1 );
if( m_fOn )
{ // draw the flashlight beam
{
// draw the flashlight beam
x = ScreenWidth - m_iWidth / 2;
SPR_Set( m_hBeam, r, g, b );
@ -153,6 +151,5 @@ int CHudFlashlight::Draw(float flTime)
SPR_DrawAdditive( 0, x + iOffset, y, &rc );
}
return 1;
}

View File

@ -40,12 +40,12 @@ int CHudGeiger::Init(void)
srand( (unsigned)time( NULL ) );
return 1;
};
}
int CHudGeiger::VidInit( void )
{
return 1;
};
}
int CHudGeiger::MsgFunc_Geiger( const char *pszName, int iSize, void *pbuf )
{
@ -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,25 +141,25 @@ 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;
}
@ -176,7 +176,6 @@ int CHudGeiger::Draw (float flTime)
sprintf( sz, "player/geiger%d.wav", j + 1 );
PlaySound( sz, flvol );
}
}

View File

@ -67,7 +67,6 @@ int CHudHealth::Init(void)
memset( m_dmg, 0, sizeof(DAMAGE_IMAGE) * NUM_DMG_TYPES );
gHUD.AddHudElem( this );
return 1;
}
@ -77,7 +76,6 @@ void CHudHealth::Reset( void )
// make sure the pain compass is cleared when the player respawns
m_fAttackFront = m_fAttackRear = m_fAttackRight = m_fAttackLeft = 0;
// force all the flashing damage icons to expire
m_bitsDamage = 0;
for( int i = 0; i < NUM_DMG_TYPES; i++ )
@ -95,6 +93,7 @@ int CHudHealth::VidInit(void)
giDmgHeight = gHUD.GetSpriteRect( m_HUD_dmg_bio ).right - gHUD.GetSpriteRect( m_HUD_dmg_bio ).left;
giDmgWidth = gHUD.GetSpriteRect( m_HUD_dmg_bio ).bottom - gHUD.GetSpriteRect( m_HUD_dmg_bio ).top;
return 1;
}
@ -116,7 +115,6 @@ int CHudHealth:: MsgFunc_Health(const char *pszName, int iSize, void *pbuf )
return 1;
}
int CHudHealth::MsgFunc_Damage( const char *pszName, int iSize, void *pbuf )
{
BEGIN_READ( pbuf, iSize );
@ -141,14 +139,15 @@ int CHudHealth:: MsgFunc_Damage(const char *pszName, int iSize, void *pbuf )
{
float time = damageTaken * 4.0f;
if( time > 200.0f ) time = 200.0f;
if( time > 200.0f )
time = 200.0f;
gMobileEngfuncs->pfnVibrate( time, 0 );
}
}
return 1;
}
// Returns back a color from the
// Green <-> Yellow <-> Red ramp
void CHudHealth::GetPainColor( int &r, int &g, int &b )
@ -200,9 +199,7 @@ int CHudHealth::Draw(float flTime)
}
// Fade the health number back to dim
a = MIN_ALPHA + ( m_fFade / FADE_TIME ) * 128;
}
else
a = MIN_ALPHA;
@ -256,11 +253,9 @@ void CHudHealth::CalcDamageDirection(vec3_t vecFrom)
return;
}
memcpy( vecOrigin, gHUD.m_vecOrigin, sizeof(vec3_t) );
memcpy( vecAngles, gHUD.m_vecAngles, sizeof(vec3_t) );
VectorSubtract( vecFrom, vecOrigin, vecFrom );
float flDistToTarget = vecFrom.Length();
@ -342,7 +337,8 @@ int CHudHealth::DrawPain(float flTime)
y = ScreenHeight / 2 - SPR_Height( m_hSprite,1 ) / 2;
SPR_DrawAdditive( 1, x, y, NULL );
m_fAttackRight = max( 0, m_fAttackRight - fFade );
} else
}
else
m_fAttackRight = 0;
if( m_fAttackRear > 0.4 )
@ -356,7 +352,8 @@ int CHudHealth::DrawPain(float flTime)
y = ScreenHeight / 2 + SPR_Height( m_hSprite, 2 ) * 2;
SPR_DrawAdditive( 2, x, y, NULL );
m_fAttackRear = max( 0, m_fAttackRear - fFade );
} else
}
else
m_fAttackRear = 0;
if( m_fAttackLeft > 0.4 )
@ -379,9 +376,7 @@ int CHudHealth::DrawPain(float flTime)
int CHudHealth::DrawDamage( float flTime )
{
int r, g, b, a;
int i;
int i, r, g, b, a;
DAMAGE_IMAGE *pdmg;
if( !m_bitsDamage )
@ -431,7 +426,6 @@ int CHudHealth::DrawDamage(float flTime)
return 1;
}
void CHudHealth::UpdateTiles( float flTime, long bitsDamage )
{
DAMAGE_IMAGE *pdmg;
@ -468,7 +462,6 @@ void CHudHealth::UpdateTiles(float flTime, long bitsDamage)
pdmg = &m_dmg[j];
if( pdmg->y )
pdmg->y -= giDmgHeight;
}
pdmg = &m_dmg[i];
}

View File

@ -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
@ -23,6 +26,7 @@
#define DMG_IMAGE_NERVE 5
#define DMG_IMAGE_RAD 6
#define DMG_IMAGE_SHOCK 7
//tf defines
#define DMG_IMAGE_CALTROP 8
#define DMG_IMAGE_TRANQ 9
@ -46,12 +50,10 @@
#define DMG_NEVERGIB (1 << 12) // with this bit OR'd in, no damage type will be able to gib victims upon death
#define DMG_ALWAYSGIB (1 << 13) // with this bit OR'd in, any damage type can be made to gib victims upon death.
// time-based damage
//mask off TF-specific stuff too
#define DMG_TIMEBASED (~(0xff003fff)) // mask for time-based damage
#define DMG_DROWN (1 << 14) // Drowning
#define DMG_FIRSTTIMEBASED DMG_DROWN
@ -78,16 +80,14 @@
// TF Healing Additions for TakeHealth
#define DMG_IGNORE_MAXHEALTH DMG_IGNITE
// TF Redefines since we never use the originals
#define DMG_NAIL DMG_SLASH
#define DMG_NOT_SELF DMG_FREEZE
#define DMG_TRANQ DMG_MORTAR
#define DMG_CONCUSS DMG_SONIC
typedef struct
{
float fExpire;
@ -125,3 +125,4 @@ private:
void CalcDamageDirection( vec3_t vecFrom );
void UpdateTiles( float fTime, long bits );
};
#endif // HEALTH_H

View File

@ -21,6 +21,7 @@ This file contains "stubs" of class member implementations so that we can predic
add in the functionality you need.
==========================
*/
#include "extdll.h"
#include "util.h"
#include "cbase.h"
@ -53,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 ) { }
void CBaseEntity::Activate( void ) { } //LRC
void CBaseEntity::InitMoveWith( void ) { } //LRC
@ -114,7 +116,6 @@ void CBeam::PointEntInit( const Vector &start, int endIndex ) { }
CBeam *CBeam::BeamCreate( const char *pSpriteName, int width ) { return NULL; }
void CSprite::Expand( float scaleSpeed, float fadeSpeed ) { }
CBaseEntity* CBaseMonster::CheckTraceHullAttack( float flDist, int iDamage, int iDmgType ) { return NULL; }
void CBaseMonster::Eat( float flFullDuration ) { }
BOOL CBaseMonster::FShouldEat( void ) { return TRUE; }
@ -152,7 +153,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 ) { }
@ -220,7 +221,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 ) { }
@ -264,7 +265,7 @@ 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::SetSuitUpdate( const char *name, int fgroup, int iNoRepeatTime ) { }
void CBasePlayer::UpdatePlayerSound( void ) { }
void CBasePlayer::PostThink() { }
void CBasePlayer::Precache( void ) { }
@ -282,7 +283,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; }
@ -304,7 +305,7 @@ 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 ) { }
@ -320,6 +321,7 @@ int CBasePlayerItem::Restore( class CRestore & ) { return 1; }
int CBasePlayerItem::Save( class CSave & ) { return 1; }
int CBasePlayerWeapon::Restore( class CRestore & ) { return 1; }
int CBasePlayerWeapon::Save( class CSave & ) { return 1; }
float CBasePlayerWeapon::GetNextAttackDelay( float flTime ) { return flTime; }
void CBasePlayerItem::SetObjectCollisionBox( void ) { }
void CBasePlayerItem::FallInit( void ) { }
void CBasePlayerItem::FallThink( void ) { }

View File

@ -12,6 +12,7 @@
* without written permission from Valve LLC.
*
****/
#include "../hud.h"
#include "../cl_util.h"
#include "event_api.h"
@ -38,8 +39,6 @@ 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 );
}

View File

@ -12,6 +12,7 @@
* without written permission from Valve LLC.
*
****/
#include "../hud.h"
#include "../cl_util.h"
#include "../demo.h"

View File

@ -12,6 +12,7 @@
* without written permission from Valve LLC.
*
****/
#include "extdll.h"
#include "util.h"
#include "cbase.h"
@ -67,7 +68,6 @@ CSatchel g_Satchel;
CTripmine g_Tripmine;
CSqueak g_Snark;
/*
======================
AlertMessage
@ -75,7 +75,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];
@ -94,8 +94,9 @@ bool bIsMultiplayer ( void )
{
return gEngfuncs.GetMaxClients() == 1 ? 0 : 1;
}
//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 );
}
@ -147,11 +148,10 @@ CBasePlayerWeapon :: DefaultReload
*/
BOOL CBasePlayerWeapon::DefaultReload( int iClipSize, int iAnim, float fDelay, int body )
{
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;
@ -215,7 +215,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;
@ -295,7 +295,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, y, z;
float x = 0.0f, y = 0.0f, z;
for( ULONG iShot = 1; iShot <= cShots; iShot++ )
{
@ -316,7 +316,6 @@ Vector CBaseEntity::FireBulletsPlayer ( ULONG cShots, Vector vecSrc, Vector vecD
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;
}
}
return Vector( x * vecSpread.x, y * vecSpread.y, 0.0 );
@ -373,7 +372,6 @@ void CBasePlayerWeapon::ItemPostFrame( void )
else if( !( m_pPlayer->pev->button & ( IN_ATTACK | IN_ATTACK2 ) ) )
{
// no fire buttons down
m_fFireOnEmpty = FALSE;
// weapon is useable. Reload if empty and weapon has waited as long as it has to after firing
@ -411,7 +409,6 @@ void CBasePlayer::SelectItem(const char *pstr)
if( !pItem )
return;
if( pItem == m_pActiveItem )
return;
@ -693,11 +690,9 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
int buttonsChanged;
CBasePlayerWeapon *pWeapon = NULL;
CBasePlayerWeapon *pCurrent;
weapon_data_t nulldata, *pfrom, *pto;
weapon_data_t nulldata = {0}, *pfrom, *pto;
static int lasthealth;
memset( &nulldata, 0, sizeof( nulldata ) );
HUD_InitClientWeapons();
// Get current clock
@ -710,55 +705,42 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
case WEAPON_CROWBAR:
pWeapon = &g_Crowbar;
break;
case WEAPON_GLOCK:
pWeapon = &g_Glock;
break;
case WEAPON_PYTHON:
pWeapon = &g_Python;
break;
case WEAPON_MP5:
pWeapon = &g_Mp5;
break;
case WEAPON_CROSSBOW:
pWeapon = &g_Crossbow;
break;
case WEAPON_SHOTGUN:
pWeapon = &g_Shotgun;
break;
case WEAPON_RPG:
pWeapon = &g_Rpg;
break;
case WEAPON_GAUSS:
pWeapon = &g_Gauss;
break;
case WEAPON_EGON:
pWeapon = &g_Egon;
break;
case WEAPON_HORNETGUN:
pWeapon = &g_HGun;
break;
case WEAPON_HANDGRENADE:
pWeapon = &g_HandGren;
break;
case WEAPON_SATCHEL:
pWeapon = &g_Satchel;
break;
case WEAPON_TRIPMINE:
pWeapon = &g_Tripmine;
break;
case WEAPON_SNARK:
pWeapon = &g_Snark;
break;
@ -776,7 +758,6 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
if( to->client.health <= 0 && lasthealth > 0 )
{
player.Killed( NULL, 0 );
}
else if( to->client.health > 0 && lasthealth <= 0 )
{
@ -861,7 +842,6 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
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 )
{

View File

@ -26,16 +26,19 @@
#include <string.h>
#include <stdio.h>
#include "parsemsg.h"
#include "hud_servers.h"
#include "demo.h"
#include "demo_api.h"
cvar_t *hud_textmode;
float g_hud_text_color[3];
extern client_sprite_t *GetSpriteList( client_sprite_t *pList, const char *psz, int iRes, int iCount );
extern cvar_t *sensitivity;
cvar_t *cl_lw = NULL;
cvar_t *cl_viewbob = NULL;
void ShutdownInput( void );
@ -268,6 +271,7 @@ void CHud :: Init( void )
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;
m_pShinySurface = NULL; //LRC
@ -309,8 +313,6 @@ void CHud :: Init( void )
m_Menu.Init();
MsgFunc_ResetHUD( 0, 0, NULL );
}
@ -336,8 +338,6 @@ CHud :: ~CHud()
}
m_pHudList = NULL;
}
}
// GetSpriteIndex()
@ -361,6 +361,7 @@ void CHud :: VidInit( void )
#ifdef ENGINE_DEBUG
CONPRINT("## CHud::VidInit\n");
#endif
int j;
m_scrinfo.iSize = sizeof(m_scrinfo);
GetScreenInfo( &m_scrinfo );
@ -385,7 +386,6 @@ void CHud :: VidInit( void )
if( m_pSpriteList )
{
int j;
// count the number of sprites of the appropriate res
m_iSpriteCount = 0;
client_sprite_t *p = m_pSpriteList;
@ -425,14 +425,37 @@ void CHud :: VidInit( void )
// we have already have loaded the sprite reference from hud.txt, but
// we need to make sure all the sprites have been loaded (we've gone through a transition, or loaded a save game)
client_sprite_t *p = m_pSpriteList;
// count the number of sprites of the appropriate res
m_iSpriteCount = 0;
for( j = 0; j < m_iSpriteCountAllRes; j++ )
{
if( p->iRes == m_iRes )
m_iSpriteCount++;
p++;
}
delete[] m_rghSprites;
delete[] m_rgrcRects;
delete[] m_rgszSpriteNames;
// allocated memory for sprite handle arrays
m_rghSprites = new HSPRITE[m_iSpriteCount];
m_rgrcRects = new wrect_t[m_iSpriteCount];
m_rgszSpriteNames = new char[m_iSpriteCount * MAX_SPRITE_NAME_LENGTH];
p = m_pSpriteList;
int index = 0;
for ( int j = 0; j < m_iSpriteCountAllRes; j++ )
for( j = 0; j < m_iSpriteCountAllRes; j++ )
{
if( p->iRes == m_iRes )
{
char sz[256];
sprintf( sz, "sprites/%s.spr", p->szSprite );
m_rghSprites[index] = SPR_Load( sz );
m_rgrcRects[index] = p->rc;
strncpy( &m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH], p->szName, MAX_SPRITE_NAME_LENGTH );
index++;
}
@ -509,7 +532,6 @@ void COM_FileBase ( const char *in, char *out)
else
end--; // Found ',', copy to left of '.'
// Scan backward for '/'
start = len - 1;
while( start >= 0 && in[start] != '/' && in[start] != '\\' )
@ -525,6 +547,7 @@ void COM_FileBase ( const char *in, char *out)
// Copy partial string
strncpy( out, &in[start], len );
// Terminate it
out[len] = 0;
}
@ -618,7 +641,6 @@ int CHud::MsgFunc_SetFOV(const char *pszName, int iSize, void *pbuf)
return 1;
}
void CHud::AddHudElem( CHudBase *phudelem )
{
HUDLIST *pdl, *ptemp;
@ -653,5 +675,3 @@ float CHud::GetSensitivity( void )
{
return m_flMouseSensitivity;
}

View File

@ -19,7 +19,9 @@
//
// CHud handles the message, calculation, and drawing the HUD
//
#pragma once
#ifndef HUD_H
#define HUD_H
#define FOG_LIMIT 30000
#define RGB_YELLOWISH 0x00FFA000 //255,160,0
#define RGB_REDISH 0x00FF1010 //255,160,0
@ -36,7 +38,8 @@
#define HUDELEM_ACTIVE 1
typedef struct {
typedef struct
{
int x, y;
} POSITION;
@ -44,16 +47,16 @@ enum
{
MAX_PLAYERS = 64,
MAX_TEAMS = 64,
MAX_TEAM_NAME = 16,
MAX_TEAM_NAME = 16
};
typedef struct {
typedef struct
{
unsigned char r, g, b, a;
} RGBA;
typedef struct cvar_s cvar_t;
#define HUD_ACTIVE 1
#define HUD_INTERMISSION 2
@ -77,19 +80,16 @@ public:
virtual void Think( void ) { return; }
virtual void Reset( void ) { return; }
virtual void InitHUDData( void ) {} // called every time a server is connected to
};
struct HUDLIST {
struct HUDLIST
{
CHudBase *p;
HUDLIST *pNext;
};
//
//-----------------------------------------------------
#include "hud_spectator.h"
#define _cdecl
@ -134,13 +134,11 @@ private:
WEAPON *m_pWeapon;
int m_HUD_bucket0;
int m_HUD_selection;
};
//
//-----------------------------------------------------
//
class CHudAmmoSecondary : public CHudBase
{
public:
@ -182,7 +180,6 @@ public:
private:
int m_iGeigerRange;
};
//
@ -199,7 +196,6 @@ public:
private:
HSPRITE m_hSprite;
int m_iPos;
};
//
@ -207,7 +203,6 @@ private:
//
// REMOVED: Vgui has replaced this.
//
class CHudMOTD : public CHudBase
{
public:
@ -215,20 +210,47 @@ public:
int VidInit( void );
int Draw( float flTime );
void Reset( void );
int MsgFunc_MOTD( const char *pszName, int iSize, void *pbuf );
void Scroll( int dir );
void Scroll( float amount );
float scroll;
bool m_bShow;
int MsgFunc_MOTD( const char *pszName, int iSize, void *pbuf );
protected:
static int MOTD_DISPLAY_TIME;
char m_szMOTD[MAX_MOTD_LENGTH];
int m_iLines;
int m_iMaxLength;
};
class CHudScoreboard : public CHudBase
{
public:
int Init( void );
void InitHUDData( void );
int VidInit( void );
int Draw( float flTime );
int DrawPlayers( int xoffset, float listslot, int nameoffset = 0, char *team = NULL ); // returns the ypos where it finishes drawing
void UserCmd_ShowScores( void );
void UserCmd_HideScores( void );
int MsgFunc_ScoreInfo( const char *pszName, int iSize, void *pbuf );
int MsgFunc_TeamInfo( const char *pszName, int iSize, void *pbuf );
int MsgFunc_TeamScore( const char *pszName, int iSize, void *pbuf );
int MsgFunc_TeamScores( const char *pszName, int iSize, void *pbuf );
int MsgFunc_TeamNames( const char *pszName, int iSize, void *pbuf );
void DeathMsg( int killer, int victim );
int m_iNumTeams;
int m_iLastKilledBy;
int m_fLastKillTime;
int m_iPlayerNum;
int m_iShowscoresHeld;
void GetAllPlayersInfo( void );
};
//
//-----------------------------------------------------
@ -246,10 +268,11 @@ public:
int MsgFunc_StatusValue( const char *pszName, int iSize, void *pbuf );
protected:
enum {
enum
{
MAX_STATUSTEXT_LENGTH = 128,
MAX_STATUSBAR_VALUES = 8,
MAX_STATUSBAR_LINES = 2,
MAX_STATUSBAR_LINES = 2
};
char m_szStatusText[MAX_STATUSBAR_LINES][MAX_STATUSTEXT_LENGTH]; // a text string describing how the status bar is to be drawn
@ -267,6 +290,7 @@ protected:
//
// REMOVED: Vgui has replaced this.
//
/*
class CHudScoreboard : public CHudBase
{
public:
@ -290,10 +314,11 @@ public:
int m_iShowscoresHeld;
void GetAllPlayersInfo( void );
private:
struct cvar_s *cl_showpacketloss;
};
*/
struct extra_player_info_t
{
@ -323,7 +348,6 @@ extern extra_player_info_t g_PlayerExtraInfo[MAX_PLAYERS+1]; // additional pl
extern team_info_t g_TeamInfo[MAX_TEAMS + 1];
extern int g_IsSpectator[MAX_PLAYERS + 1];
//
//-----------------------------------------------------
//
@ -377,7 +401,6 @@ public:
friend class CHudSpectator;
private:
struct cvar_s * m_HUD_saytext;
struct cvar_s * m_HUD_saytext_time;
};
@ -403,7 +426,6 @@ private:
int m_iHeight; // width of the battery innards
};
//
//-----------------------------------------------------
//
@ -475,7 +497,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 );
};
@ -528,19 +550,18 @@ public:
int Draw( float flTime );
int MsgFunc_StatusIcon( const char *pszName, int iSize, void *pbuf );
enum {
enum
{
MAX_ICONSPRITENAME_LENGTH = MAX_SPRITE_NAME_LENGTH,
MAX_ICONSPRITES = 4,
MAX_ICONSPRITES = 4
};
//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
{
char szSpriteName[MAX_ICONSPRITENAME_LENGTH];
@ -604,7 +625,6 @@ private:
int m_iConcussionEffect;
public:
HSPRITE m_hsprCursor;
float m_flTime; // the current client time
float m_fOldTime; // the time at which the HUD was last redrawn
@ -625,11 +645,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 );
int m_iHUDColor; //LRC
@ -653,7 +673,6 @@ public:
return m_rgrcRects[index];
}
int GetSpriteIndex( const char *SpriteName ); // gets a sprite index, for use in the m_rghSprites[] array
CHudAmmo m_Ammo;
@ -706,15 +725,15 @@ public:
int m_iWeaponBits;
int m_fPlayerDead;
int m_iIntermission;
int m_iNoConsolePrint;
// sprite indexes
int m_HUD_number_0;
int m_iNoConsolePrint;
void AddHudElem( CHudBase *p );
float GetSensitivity();
};
extern CHud gHUD;
@ -724,4 +743,4 @@ extern int g_iTeamNumber;
extern int g_iUser1;
extern int g_iUser2;
extern int g_iUser3;
#endif

View File

@ -1,13 +1,13 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#pragma once
#if !defined( HUD_IFACEH )
#define HUD_IFACEH
#pragma once
#include "exportdef.h"
@ -15,5 +15,4 @@ typedef int (*pfnUserMsgHook)(const char *pszName, int iSize, void *pbuf);
#include "wrect.h"
#include "../engine/cdll_int.h"
extern cl_enginefunc_t gEngfuncs;
#endif

View File

@ -210,7 +210,6 @@ int CHud :: MsgFunc_GameMode(const char *pszName, int iSize, void *pbuf )
return 1;
}
int CHud::MsgFunc_Damage( const char *pszName, int iSize, void *pbuf )
{
int armor, blood;
@ -231,7 +230,6 @@ int CHud :: MsgFunc_Damage(const char *pszName, int iSize, void *pbuf )
count = 10;
// TODO: kick viewangles, show damage visually
return 1;
}

View File

@ -29,7 +29,6 @@ int grgLogoFrame[MAX_LOGO_FRAMES] =
29, 29, 29, 29, 29, 28, 27, 26, 25, 24, 30, 31
};
extern int g_iVisibleMouse;
float HUD_GetFOV( void );
@ -60,7 +59,6 @@ void CHud::Think(void)
}
// the clients fov is actually set in the client data update section of the hud
// Set a new sensitivity
if( m_iFOV == default_fov->value )
{
@ -75,7 +73,8 @@ void CHud::Think(void)
// think about default fov
if( m_iFOV == 0 )
{ // only let players adjust up in fov, and only if they are not overriden by something else
{
// only let players adjust up in fov, and only if they are not overriden by something else
m_iFOV = max( default_fov->value, 90 );
}
}
@ -166,7 +165,8 @@ int CHud :: Redraw( float flTime, int intermission )
pList->p->Draw( flTime );
}
else
{ // it's an intermission, so only draw hud elements that are set to draw during intermissions
{
// it's an intermission, so only draw hud elements that are set to draw during intermissions
if( pList->p->m_iFlags & HUD_INTERMISSION )
pList->p->Draw( flTime );
}
@ -241,12 +241,12 @@ 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 )
{
gEngfuncs.pfnDrawSetTextColor( r / 255.0, g / 255.0, b / 255.0 );
return gEngfuncs.pfnDrawConsoleString( xpos, ypos, szIt );
return gEngfuncs.pfnDrawConsoleString( xpos, ypos, (char*) szIt );
}
// xash3d: reset unicode state
@ -275,7 +275,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++ )
@ -290,29 +323,17 @@ int CHud :: DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int
char szString[32];
sprintf( szString, "%d", iNumber );
return DrawHudStringReverse( xpos, ypos, iMinX, szString, r, g, b );
}
// 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 )
{
char *szIt;
// find the end of the string
for ( szIt = szString; *szIt != 0; szIt++ )
{ // we should count the length?
}
// iterate throug the string in reverse
for ( szIt--; szIt != (szString-1); szIt-- )
{
int next = xpos - gHUD.m_scrinfo.charWidths[ *szIt ]; // variable-width fonts look cool
if ( next < iMinX )
return xpos;
xpos = next;
TextMessageDrawChar( xpos, ypos, *szIt, r, g, b );
}
for( const char *szIt = szString; *szIt != 0; szIt++ )
xpos -= gHUD.m_scrinfo.charWidths[(unsigned char)*szIt];
if( xpos < iMinX )
xpos = iMinX;
DrawHudString( xpos, ypos, gHUD.m_scrinfo.iWidth, szString, r, g, b );
return xpos;
}
@ -375,7 +396,6 @@ int CHud :: DrawHudNumber( int x, int y, int iFlags, int iNumber, int r, int g,
}
// SPR_Draw ones
SPR_DrawAdditive( 0, x, y, &GetSpriteRect( m_HUD_number_0 ) );
x += iWidth;
}
@ -383,7 +403,6 @@ int CHud :: DrawHudNumber( int x, int y, int iFlags, int iNumber, int r, int g,
return x;
}
int CHud::GetNumWidth( int iNumber, int iFlags )
{
if( iFlags & ( DHN_3DIGITS ) )
@ -407,7 +426,6 @@ int CHud::GetNumWidth( int iNumber, int iFlags )
return 2;
return 3;
}
void CHud::DrawDarkRectangle( int x, int y, int wide, int tall )

1226
cl_dll/hud_servers.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
@ -37,5 +37,4 @@ int ServersGetCount( void );
const char *ServersGetInfo( int server );
int ServersIsQuerying( void );
void SortServers( const char *fieldname );
#endif // HUD_SERVERSH

View File

@ -1,4 +1,4 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
@ -94,5 +94,4 @@ private:
request_t *m_pRulesRequest;
request_t *m_pPlayersRequest;
};
#endif // HUD_SERVERS_PRIVH

View File

@ -1,4 +1,4 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
@ -23,7 +23,6 @@
#include "event_api.h"
#include "studio_util.h"
#include "screenfade.h"
#include "string.h"
#pragma warning(disable: 4244)
@ -31,7 +30,6 @@ extern "C" int iJumpSpectator;
extern "C" float vJumpOrigin[3];
extern "C" float vJumpAngles[3];
extern void V_GetInEyePos( int entity, float * origin, float * angles );
extern void V_ResetChaseCam();
extern void V_GetChasePos( int target, float * cl_angles, float * origin, float * angles );
@ -46,8 +44,6 @@ extern vec3_t v_sim_org; // last sim origin
void SpectatorMode( void )
{
if( gEngfuncs.Cmd_Argc() <= 1 )
{
gEngfuncs.Con_Printf( "usage: spec_mode <Main Mode> [<Inset Mode>]\n" );
@ -79,7 +75,6 @@ void SpectatorSpray(void)
trace->endpos[0], trace->endpos[1], trace->endpos[2], trace->ent );
gEngfuncs.pfnServerCmd( string );
}
}
void SpectatorHelp( void )
{
@ -150,11 +145,9 @@ int CHudSpectator::Init()
return 1;
}
//-----------------------------------------------------------------------------
// UTIL_StringToVector originally from ..\dlls\util.cpp, slightly changed
//-----------------------------------------------------------------------------
void UTIL_StringToVector( float * pVector, const char *pString )
{
char *pstr, *pfront, tempString[128];
@ -169,7 +162,7 @@ void UTIL_StringToVector( float * pVector, const char *pString )
while( *pstr && *pstr != ' ' )
pstr++;
if (!*pstr)
if( !( *pstr ) )
break;
pstr++;
pfront = pstr;
@ -182,17 +175,19 @@ 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[1024];
char token[2048];
cl_entity_t *pEnt = gEngfuncs.GetEntityByIndex( 0 ); // get world model
if ( !pEnt ) return 0;
if( !pEnt )
return 0;
if ( !pEnt->model ) return 0;
if( !pEnt->model )
return 0;
char *data = pEnt->model->entities;
@ -216,7 +211,6 @@ int UTIL_FindEntityInMap(char * name, float * origin, float * angle)
}
// we parse the first { now parse entities properties
while( 1 )
{
// parse key
@ -228,7 +222,7 @@ int UTIL_FindEntityInMap(char * name, float * origin, float * angle)
{
gEngfuncs.Con_DPrintf( "UTIL_FindEntityInMap: EOF without closing brace\n" );
return 0;
};
}
strcpy( keyname, token );
@ -246,7 +240,7 @@ int UTIL_FindEntityInMap(char * name, float * origin, float * angle)
{
gEngfuncs.Con_DPrintf( "UTIL_FindEntityInMap: EOF without closing brace\n" );
return 0;
};
}
if( token[0] == '}' )
{
@ -260,7 +254,7 @@ int UTIL_FindEntityInMap(char * name, float * origin, float * angle)
{
found = 1; // thats our entity
}
};
}
if( !strcmp( keyname, "angle" ) )
{
@ -293,25 +287,20 @@ int UTIL_FindEntityInMap(char * name, float * origin, float * angle)
if( !strcmp( keyname, "origin" ) )
{
UTIL_StringToVector( origin, token );
};
}
} // while (1)
if( found )
return 1;
}
return 0; // we search all entities, but didn't found the correct
}
//-----------------------------------------------------------------------------
// SetSpectatorStartPosition():
// Get valid map position and 'beam' spectator to this position
//-----------------------------------------------------------------------------
void CHudSpectator::SetSpectatorStartPosition()
{
// search for info_player start
@ -393,7 +382,6 @@ int CHudSpectator::Draw(float flTime)
VectorScale( right, m_moveDelta, right );
VectorAdd( m_mapOrigin, right, m_mapOrigin )
}
// Only draw the icon names only if map mode is in Main Mode
@ -410,7 +398,6 @@ int CHudSpectator::Draw(float flTime)
// loop through all the players and draw additional infos to their sprites on the map
for( int i = 0; i < MAX_PLAYERS; i++ )
{
if( m_vPlayerPos[i][2] < 0 ) // marked as invisible ?
continue;
@ -420,8 +407,8 @@ int CHudSpectator::Draw(float flTime)
if( m_vPlayerPos[i][0] > XRES( m_OverviewData.insetWindowX ) &&
m_vPlayerPos[i][1] > YRES( m_OverviewData.insetWindowY ) &&
m_vPlayerPos[i][0] < XRES( m_OverviewData.insetWindowX + m_OverviewData.insetWindowWidth ) &&
m_vPlayerPos[i][1] < YRES( m_OverviewData.insetWindowY + m_OverviewData.insetWindowHeight)
) continue;
m_vPlayerPos[i][1] < YRES( m_OverviewData.insetWindowY + m_OverviewData.insetWindowHeight) )
continue;
}
color = GetClientColor( i + 1 );
@ -433,13 +420,11 @@ int CHudSpectator::Draw(float flTime)
DrawSetTextColor( color[0], color[1], color[2] );
DrawConsoleString( m_vPlayerPos[i][0] - lx,m_vPlayerPos[i][1], string );
}
return 1;
}
void CHudSpectator::DirectorMessage( int iSize, void *pbuf )
{
float value;
@ -459,9 +444,7 @@ void CHudSpectator::DirectorMessage( int iSize, void *pbuf )
// fake a InitHUD & ResetHUD message
gHUD.MsgFunc_InitHUD( NULL, 0, NULL );
gHUD.MsgFunc_ResetHUD( NULL, 0, NULL );
break;
case DRC_CMD_EVENT:
m_lastPrimaryObject = READ_WORD();
m_lastSecondaryObject = READ_WORD();
@ -478,14 +461,12 @@ void CHudSpectator::DirectorMessage( int iSize, void *pbuf )
// gEngfuncs.Con_Printf( "Director Camera: %i %i\n", firstObject, secondObject );
break;
case DRC_CMD_MODE:
if( m_autoDirector->value )
{
SetModes( READ_BYTE(), -1 );
}
break;
case DRC_CMD_CAMERA:
if( m_autoDirector->value )
{
@ -502,7 +483,6 @@ void CHudSpectator::DirectorMessage( int iSize, void *pbuf )
iJumpSpectator = 1;
}
break;
case DRC_CMD_MESSAGE:
{
client_textmessage_t * msg = &m_HUDMessages[m_lastHudMessage];
@ -533,48 +513,33 @@ void CHudSpectator::DirectorMessage( int iSize, void *pbuf )
m_lastHudMessage++;
m_lastHudMessage %= MAX_SPEC_HUD_MESSAGES;
}
break;
case DRC_CMD_SOUND:
string = READ_STRING();
value = READ_FLOAT();
// gEngfuncs.Con_Printf("DRC_CMD_FX_SOUND: %s %.2f\n", string, value );
gEngfuncs.pEventAPI->EV_PlaySound( 0, v_origin, CHAN_BODY, string, value, ATTN_NORM, 0, PITCH_NORM );
break;
case DRC_CMD_TIMESCALE:
value = READ_FLOAT();
break;
case DRC_CMD_STATUS:
READ_LONG(); // total number of spectator slots
m_iSpectatorNumber = READ_LONG(); // total number of spectator
READ_WORD(); // total number of relay proxies
// gViewPort->UpdateSpectatorPanel();
break;
case DRC_CMD_BANNER:
// gEngfuncs.Con_DPrintf( "GUI: Banner %s\n",READ_STRING() ); // name of banner tga eg gfx/temp/7454562234563475.tga
// gViewPort->m_pSpectatorPanel->m_TopBanner->LoadImage( READ_STRING() );
// gViewPort->UpdateSpectatorPanel();
break;
case DRC_CMD_FADE:
break;
case DRC_CMD_STUFFTEXT:
ClientCmd( READ_STRING() );
break;
default : gEngfuncs.Con_DPrintf("CHudSpectator::DirectorMessage: unknown command %i.\n", cmd );
default:
gEngfuncs.Con_DPrintf( "CHudSpectator::DirectorMessage: unknown command %i.\n", cmd );
}
}
@ -627,10 +592,8 @@ void CHudSpectator::FindNextPlayer(bool bReverse)
continue;
// MOD AUTHORS: Add checks on target here.
g_iUser2 = iCurrent;
break;
} while( iCurrent != iStart );
// Did we find a target?
@ -658,6 +621,7 @@ void CHudSpectator::HandleButtonsDown( int ButtonPressed )
int newInsetMode = m_pip->value;
// gEngfuncs.Con_Printf( " HandleButtons:%i\n", ButtonPressed );
//Not in intermission.
if( gHUD.m_iIntermission )
return;
@ -672,6 +636,10 @@ void CHudSpectator::HandleButtonsDown( int ButtonPressed )
if( m_flNextObserverInput > time )
return;
// enable spectator screen
//if( ButtonPressed & IN_DUCK )
// gViewPort->m_pSpectatorPanel->ShowMenu( !gViewPort->m_pSpectatorPanel->m_menuVisible );
// 'Use' changes inset window mode
if( ButtonPressed & IN_USE )
{
@ -688,19 +656,14 @@ void CHudSpectator::HandleButtonsDown( int ButtonPressed )
{
if( g_iUser1 == OBS_CHASE_LOCKED )
newMainMode = OBS_CHASE_FREE;
else if( g_iUser1 == OBS_CHASE_FREE )
newMainMode = OBS_IN_EYE;
else if( g_iUser1 == OBS_IN_EYE )
newMainMode = OBS_ROAMING;
else if( g_iUser1 == OBS_ROAMING )
newMainMode = OBS_MAP_FREE;
else if( g_iUser1 == OBS_MAP_FREE )
newMainMode = OBS_MAP_CHASE;
else
newMainMode = OBS_CHASE_FREE; // don't use OBS_CHASE_LOCKED anymore
}
@ -714,7 +677,6 @@ void CHudSpectator::HandleButtonsDown( int ButtonPressed )
{
gEngfuncs.SetViewAngles( vJumpAngles );
iJumpSpectator = 1;
}
// lease directed mode if player want to see another player
m_autoDirector->value = 0.0f;
@ -791,12 +753,12 @@ void CHudSpectator::SetModes(int iNewMainMode, int iNewInsetMode)
switch( iNewMainMode )
{
case OBS_CHASE_LOCKED: g_iUser1 = OBS_CHASE_LOCKED;
case OBS_CHASE_LOCKED:
g_iUser1 = OBS_CHASE_LOCKED;
break;
case OBS_CHASE_FREE : g_iUser1 = OBS_CHASE_FREE;
case OBS_CHASE_FREE:
g_iUser1 = OBS_CHASE_FREE;
break;
case OBS_ROAMING: // jump to current vJumpOrigin/angle
g_iUser1 = OBS_ROAMING;
if( g_iUser2 )
@ -806,17 +768,17 @@ void CHudSpectator::SetModes(int iNewMainMode, int iNewInsetMode)
iJumpSpectator = 1;
}
break;
case OBS_IN_EYE : g_iUser1 = OBS_IN_EYE;
case OBS_IN_EYE:
g_iUser1 = OBS_IN_EYE;
break;
case OBS_MAP_FREE : g_iUser1 = OBS_MAP_FREE;
case OBS_MAP_FREE:
g_iUser1 = OBS_MAP_FREE;
// reset user values
m_mapZoom = m_OverviewData.zoom;
m_mapOrigin = m_OverviewData.origin;
break;
case OBS_MAP_CHASE : g_iUser1 = OBS_MAP_CHASE;
case OBS_MAP_CHASE:
g_iUser1 = OBS_MAP_CHASE;
// reset user values
m_mapZoom = m_OverviewData.zoom;
m_mapOrigin = m_OverviewData.origin;
@ -856,7 +818,6 @@ bool CHudSpectator::IsActivePlayer(cl_entity_t * ent)
);
}
bool CHudSpectator::ParseOverviewFile()
{
char filename[255] = { 0 };
@ -893,11 +854,10 @@ bool CHudSpectator::ParseOverviewFile( )
if( !pfile )
{
gEngfuncs.Con_Printf("Couldn't open file %s. Using default values for overiew mode.\n", filename );
gEngfuncs.Con_DPrintf( "Couldn't open file %s. Using default values for overiew mode.\n", filename );
return false;
}
while( true )
{
pfile = gEngfuncs.COM_ParseFile( pfile, token );
@ -948,7 +908,6 @@ bool CHudSpectator::ParseOverviewFile( )
m_OverviewData.insetWindowWidth = atof( token );
pfile = gEngfuncs.COM_ParseFile( pfile, token );
m_OverviewData.insetWindowHeight = atof( token );
}
else
{
@ -957,13 +916,11 @@ bool CHudSpectator::ParseOverviewFile( )
}
pfile = gEngfuncs.COM_ParseFile( pfile, token ); // parse next token
}
}
else if( !stricmp( token, "layer" ) )
{
// parse a layer data
if( m_OverviewData.layers == OVERVIEW_MAX_LAYERS )
{
gEngfuncs.Con_Printf( "Error parsing overview file %s. ( too many layers )\n", filename );
@ -972,7 +929,6 @@ bool CHudSpectator::ParseOverviewFile( )
pfile = gEngfuncs.COM_ParseFile( pfile, token );
if( stricmp( token, "{" ) )
{
gEngfuncs.Con_Printf( "Error parsing overview file %s. (expected { )\n", filename );
@ -987,8 +943,6 @@ bool CHudSpectator::ParseOverviewFile( )
{
pfile = gEngfuncs.COM_ParseFile( pfile, token );
strcpy( m_OverviewData.layersImages[m_OverviewData.layers], token );
}
else if ( !stricmp( token, "height" ) )
{
@ -1006,7 +960,6 @@ bool CHudSpectator::ParseOverviewFile( )
}
m_OverviewData.layers++;
}
}
@ -1016,7 +969,6 @@ bool CHudSpectator::ParseOverviewFile( )
m_mapOrigin = m_OverviewData.origin;
return true;
}
void CHudSpectator::LoadMapSprites()
@ -1041,7 +993,7 @@ void CHudSpectator::DrawOverviewLayer()
if ( hasMapImage)
{
i = m_MapSprite->numframes / (4*3);
i = sqrt(i);
i = sqrt(float(i));
xTiles = i*4;
yTiles = i*3;
}
@ -1051,10 +1003,8 @@ void CHudSpectator::DrawOverviewLayer()
yTiles = 6;
}
screenaspect = 4.0f / 3.0f;
xs = m_OverviewData.origin[0];
ys = m_OverviewData.origin[1];
z = ( 90.0f - v_angles[0] ) / 90.0f;
@ -1068,7 +1018,6 @@ void CHudSpectator::DrawOverviewLayer()
frame = 0;
// rotated view ?
if( m_OverviewData.rotated )
{
@ -1114,14 +1063,10 @@ void CHudSpectator::DrawOverviewLayer()
xStep = -( 2 * 4096.0f / m_OverviewData.zoom ) / xTiles;
yStep = -( 2 * 4096.0f / ( m_OverviewData.zoom* screenaspect ) ) / yTiles;
x = xs + ( 4096.0f / ( m_OverviewData.zoom * screenaspect ) );
for( ix = 0; ix < yTiles; ix++ )
{
y = ys + ( 4096.0f / ( m_OverviewData.zoom ) );
for( iy = 0; iy < xTiles; iy++ )
@ -1151,7 +1096,6 @@ void CHudSpectator::DrawOverviewLayer()
}
x += xStep;
}
}
}
@ -1167,7 +1111,6 @@ void CHudSpectator::DrawOverviewEntities()
float zScale = ( 90.0f - v_angles[0] ) / 90.0f;
z = m_OverviewData.layersHeights[0] * zScale;
// get yellow/brown HUD color
UnpackRGB( ir, ig, ib, RGB_YELLOWISH );
@ -1194,7 +1137,6 @@ void CHudSpectator::DrawOverviewEntities()
// see R_DrawSpriteModel
// draws players sprite
AngleVectors( ent->angles, right, up, NULL );
VectorCopy( ent->origin,origin );
@ -1230,9 +1172,9 @@ void CHudSpectator::DrawOverviewEntities()
gEngfuncs.pTriAPI->End();
if( !ent->player )
continue;
// draw line under player icons
origin[2] *= zScale;
@ -1296,7 +1238,6 @@ void CHudSpectator::DrawOverviewEntities()
return;
// get current camera position and angle
if( m_pip->value == INSET_IN_EYE || g_iUser1 == OBS_IN_EYE )
{
V_GetInEyePos( g_iUser2, origin, angles );
@ -1313,9 +1254,7 @@ void CHudSpectator::DrawOverviewEntities()
else
V_GetChasePos( g_iUser2, NULL, origin, angles );
// draw camera sprite
x = origin[0];
y = origin[1];
z = origin[2];
@ -1326,7 +1265,6 @@ void CHudSpectator::DrawOverviewEntities()
gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd );
gEngfuncs.pTriAPI->SpriteTexture( hSpriteModel, 0 );
gEngfuncs.pTriAPI->Color4f( r, g, b, 1.0 );
AngleVectors( angles, forward, NULL, NULL );
@ -1353,11 +1291,8 @@ void CHudSpectator::DrawOverviewEntities()
gEngfuncs.pTriAPI->TexCoord2f( 1, 1 );
gEngfuncs.pTriAPI->Vertex3f( x + left[0], y + left[1], ( z + left[2] ) * zScale );
gEngfuncs.pTriAPI->End ();
}
void CHudSpectator::DrawOverview()
{
// draw only in sepctator mode
@ -1375,6 +1310,7 @@ void CHudSpectator::DrawOverview()
DrawOverviewEntities();
CheckOverviewEntities();
}
void CHudSpectator::CheckOverviewEntities()
{
double time = gEngfuncs.GetClientTime();
@ -1405,9 +1341,15 @@ bool CHudSpectator::AddOverviewEntity( int type, struct cl_entity_s *ent, const
switch ( g_PlayerExtraInfo[ent->index].teamnumber )
{
// blue and red teams are swapped in CS and TFC
case 1 : hSprite = m_hsprPlayerBlue; break;
case 2 : hSprite = m_hsprPlayerRed; break;
default : hSprite = m_hsprPlayer; break;
case 1:
hSprite = m_hsprPlayerBlue;
break;
case 2:
hSprite = m_hsprPlayerRed;
break;
default:
hSprite = m_hsprPlayer;
break;
}
}
else
@ -1448,10 +1390,10 @@ bool CHudSpectator::AddOverviewEntityToList(HSPRITE sprite, cl_entity_t *ent, do
return false; // maximum overview entities reached
}
void CHudSpectator::CheckSettings()
{
// disallow same inset mode as main mode:
m_pip->value = (int)m_pip->value;
if( ( g_iUser1 < OBS_MAP_FREE ) && ( m_pip->value == INSET_CHASE_FREE || m_pip->value == INSET_IN_EYE ) )
@ -1501,8 +1443,6 @@ void CHudSpectator::CheckSettings()
SetCrosshair( 0, m_crosshairRect, 0, 0, 0 );
}
// if we are a real player on server don't allow inset window
// in First Person mode since this is our resticted forcecamera mode 2
// team number 3 = SPECTATOR see player.h
@ -1543,6 +1483,7 @@ int CHudSpectator::ToggleInset(bool allowOff)
return newInsetMode;
}
void CHudSpectator::Reset()
{
// Reset HUD
@ -1584,4 +1525,3 @@ void CHudSpectator::InitHUDData()
// reset HUD FOV
gHUD.m_iFOV = CVAR_GET_FLOAT( "default_fov" );
}

View File

@ -1,18 +1,16 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//========= Copyright © 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"
#define INSET_OFF 0
#define INSET_CHASE_FREE 1
#define INSET_IN_EYE 2
@ -21,8 +19,6 @@
#define MAX_SPEC_HUD_MESSAGES 8
#define OVERVIEW_TILE_SIZE 128 // don't change this
#define OVERVIEW_MAX_LAYERS 1
@ -30,7 +26,8 @@
// Purpose: Handles the drawing of the spectator stuff (camera & top-down map and all the things on it )
//-----------------------------------------------------------------------------
typedef struct overviewInfo_s {
typedef struct overviewInfo_s
{
char map[64]; // cl.levelname or empty
vec3_t origin; // center of map
float zoom; // zoom of map images
@ -45,8 +42,8 @@ typedef struct overviewInfo_s {
int insetWindowWidth;
} overviewInfo_t;
typedef struct overviewEntity_s {
typedef struct overviewEntity_s
{
HSPRITE hSprite;
struct cl_entity_s * entity;
double killTime;
@ -100,13 +97,11 @@ public:
cvar_t *m_autoDirector;
cvar_t *m_pip;
qboolean m_chatEnabled;
vec3_t m_cameraOrigin; // a help camera
vec3_t m_cameraAngles; // and it's angles
private:
vec3_t m_vPlayerPos[MAX_PLAYERS];
HSPRITE m_hsprPlayerBlue;
@ -128,5 +123,4 @@ private:
int m_lastPrimaryObject;
int m_lastSecondaryObject;
};
#endif // SPECTATOR_H

View File

@ -50,5 +50,3 @@ int CHud::UpdateClientData(client_data_t *cdata, float time)
// return 1 if in anything in the client_data struct has been changed, 0 otherwise
return 1;
}

View File

@ -1,4 +1,4 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
@ -14,7 +14,6 @@
#include "const.h"
#include "camera.h"
#include "in_defs.h"
#include "exportdef.h"
float CL_KeyState( kbutton_t *key );
@ -66,7 +65,6 @@ cvar_t *c_mindistance;
// pitch, yaw, dist
vec3_t cam_ofs;
// In third person
int cam_thirdperson;
int cam_mousemove; //true if we are moving the cam with the mouse, False if not
@ -87,7 +85,6 @@ void CAM_ToFirstPerson(void);
void CAM_StartDistance(void);
void CAM_EndDistance(void);
//-------------------------------------------------- Local Functions
float MoveToward( float cur, float goal, float maxspeed )
@ -118,7 +115,6 @@ float MoveToward( float cur, float goal, float maxspeed )
}
}
// bring cur back into range
if( cur < 0 )
cur += 360.0;
@ -128,7 +124,6 @@ float MoveToward( float cur, float goal, float maxspeed )
return cur;
}
//-------------------------------------------------- Gobal Functions
typedef struct
@ -163,11 +158,9 @@ void DLLEXPORT CAM_Think( void )
case CAM_COMMAND_TOTHIRDPERSON:
CAM_ToThirdPerson();
break;
case CAM_COMMAND_TOFIRSTPERSON:
CAM_ToFirstPerson();
break;
case CAM_COMMAND_NONE:
default:
break;
@ -175,7 +168,6 @@ void DLLEXPORT CAM_Think( void )
if( !cam_thirdperson )
return;
#ifdef LATER
if( cam_contain->value )
{
@ -183,10 +175,10 @@ void DLLEXPORT CAM_Think( void )
ext[0] = ext[1] = ext[2] = 0.0;
}
#endif
camAngles[PITCH] = cam_idealpitch->value;
camAngles[YAW] = cam_idealyaw->value;
dist = cam_idealdist->value;
//
//movement of the camera with the mouse
//
@ -194,23 +186,22 @@ void DLLEXPORT CAM_Think( void )
{
//get windows cursor position
GetCursorPos( &cam_mouse );
//check for X delta values and adjust accordingly
//eventually adjust YAW based on amount of movement
//don't do any movement of the cam using YAW/PITCH if we are zooming in/out the camera
if( !cam_distancemove )
{
//keep the camera within certain limits around the player (ie avoid certain bad viewing angles)
if( cam_mouse.x>gEngfuncs.GetWindowCenterX() )
{
//if( ( camAngles[YAW] >= 225.0 ) || ( camAngles[YAW] < 135.0 ) )
if( camAngles[YAW] < c_maxyaw->value )
{
camAngles[ YAW ] += (CAM_ANGLE_MOVE)*((cam_mouse.x-gEngfuncs.GetWindowCenterX())/2);
camAngles[YAW] += CAM_ANGLE_MOVE * ( ( cam_mouse.x - gEngfuncs.GetWindowCenterX() ) / 2 );
}
if( camAngles[YAW] > c_maxyaw->value )
{
camAngles[YAW] = c_maxyaw->value;
}
}
@ -219,13 +210,11 @@ void DLLEXPORT CAM_Think( void )
//if( ( camAngles[YAW] <= 135.0 ) || ( camAngles[YAW] > 225.0 ) )
if( camAngles[YAW] > c_minyaw->value )
{
camAngles[ YAW ] -= (CAM_ANGLE_MOVE)* ((gEngfuncs.GetWindowCenterX()-cam_mouse.x)/2);
camAngles[YAW] -= CAM_ANGLE_MOVE * ( ( gEngfuncs.GetWindowCenterX() - cam_mouse.x ) / 2 );
}
if( camAngles[YAW] < c_minyaw->value )
{
camAngles[YAW] = c_minyaw->value;
}
}
@ -236,7 +225,7 @@ void DLLEXPORT CAM_Think( void )
{
if( camAngles[PITCH] < c_maxpitch->value )
{
camAngles[PITCH] +=(CAM_ANGLE_MOVE)* ((cam_mouse.y-gEngfuncs.GetWindowCenterY())/2);
camAngles[PITCH] += CAM_ANGLE_MOVE * ( ( cam_mouse.y - gEngfuncs.GetWindowCenterY() ) / 2 );
}
if( camAngles[PITCH] > c_maxpitch->value )
{
@ -247,7 +236,7 @@ void DLLEXPORT CAM_Think( void )
{
if( camAngles[PITCH] > c_minpitch->value )
{
camAngles[PITCH] -= (CAM_ANGLE_MOVE)*((gEngfuncs.GetWindowCenterY()-cam_mouse.y)/2);
camAngles[PITCH] -= CAM_ANGLE_MOVE * ( ( gEngfuncs.GetWindowCenterY() - cam_mouse.y ) / 2 );
}
if( camAngles[PITCH] < c_minpitch->value )
{
@ -257,7 +246,6 @@ void DLLEXPORT CAM_Think( void )
//set old mouse coordinates to current mouse coordinates
//since we are done with the mouse
if( ( flSensitivity = gHUD.GetSensitivity() ) != 0 )
{
cam_old_mouse_x = cam_mouse.x * flSensitivity;
@ -293,7 +281,6 @@ void DLLEXPORT CAM_Think( void )
camAngles[YAW] = 0;
dist = CAM_MIN_DIST;
}
}
else if( CL_KeyState( &cam_out ) )
dist += CAM_DIST_DELTA;
@ -315,7 +302,7 @@ void DLLEXPORT CAM_Think( void )
{
if( dist > c_mindistance->value )
{
dist -= (CAM_DIST_DELTA)*((gEngfuncs.GetWindowCenterY()-cam_mouse.y)/2);
dist -= CAM_DIST_DELTA * ( ( gEngfuncs.GetWindowCenterY() - cam_mouse.y ) / 2 );
}
if ( dist < c_mindistance->value )
{
@ -409,23 +396,69 @@ void DLLEXPORT CAM_Think( void )
extern void KeyDown( kbutton_t *b ); // HACK
extern void KeyUp( kbutton_t *b ); // HACK
void CAM_PitchUpDown(void) { KeyDown( &cam_pitchup ); }
void CAM_PitchUpUp(void) { KeyUp( &cam_pitchup ); }
void CAM_PitchDownDown(void) { KeyDown( &cam_pitchdown ); }
void CAM_PitchDownUp(void) { KeyUp( &cam_pitchdown ); }
void CAM_YawLeftDown(void) { KeyDown( &cam_yawleft ); }
void CAM_YawLeftUp(void) { KeyUp( &cam_yawleft ); }
void CAM_YawRightDown(void) { KeyDown( &cam_yawright ); }
void CAM_YawRightUp(void) { KeyUp( &cam_yawright ); }
void CAM_InDown(void) { KeyDown( &cam_in ); }
void CAM_InUp(void) { KeyUp( &cam_in ); }
void CAM_OutDown(void) { KeyDown( &cam_out ); }
void CAM_OutUp(void) { KeyUp( &cam_out ); }
void CAM_PitchUpDown( void )
{
KeyDown( &cam_pitchup );
}
void CAM_PitchUpUp( void )
{
KeyUp( &cam_pitchup );
}
void CAM_PitchDownDown( void )
{
KeyDown( &cam_pitchdown );
}
void CAM_PitchDownUp( void )
{
KeyUp( &cam_pitchdown );
}
void CAM_YawLeftDown( void )
{
KeyDown( &cam_yawleft );
}
void CAM_YawLeftUp( void )
{
KeyUp( &cam_yawleft );
}
void CAM_YawRightDown( void )
{
KeyDown( &cam_yawright );
}
void CAM_YawRightUp( void )
{
KeyUp( &cam_yawright );
}
void CAM_InDown( void )
{
KeyDown( &cam_in );
}
void CAM_InUp( void )
{
KeyUp( &cam_in );
}
void CAM_OutDown( void )
{
KeyDown( &cam_out );
}
void CAM_OutUp( void )
{
KeyUp( &cam_out );
}
void CAM_ToThirdPerson( void )
{
vec3_t viewangles;
#if !defined( _DEBUG )
if( gEngfuncs.GetMaxClients() > 1 )
{
@ -433,7 +466,6 @@ void CAM_ToThirdPerson(void)
return;
}
#endif
gEngfuncs.GetViewAngles( (float *)viewangles );
if( !cam_thirdperson )
@ -569,7 +601,6 @@ void CAM_EndMouseMove(void)
iMouseInUse = 0;
}
//----------------------------------------------------------
//routines to start the process of moving the cam in or out
//using the mouse

View File

@ -1,13 +1,13 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//========= Copyright <EFBFBD> 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
@ -17,16 +17,16 @@
#define ROLL 2
#ifdef _WIN32
#define HSPRITE WINAPI_HSPRITE
#define HSPRITE HSPRITE_win32
#include <windows.h>
#undef HSPRITE
#else
typedef struct point_s{
typedef struct point_s
{
int x;
int y;
} POINT;
#define GetCursorPos(x)
#define SetCursorPos(x,y)
#endif
#endif

View File

@ -1,4 +1,4 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
@ -11,6 +11,7 @@
// Quake is a trademark of Id Software, Inc., (c) 1996 Id Software, Inc. All
// rights reserved.
#include "hud.h"
#include "cl_util.h"
#include "camera.h"
@ -26,8 +27,6 @@ extern "C"
//#include "view.h"
#include <string.h>
#include <ctype.h>
#include "exportdef.h"
extern "C"
{
@ -76,6 +75,7 @@ cvar_t *cl_yawspeed;
cvar_t *cl_pitchspeed;
cvar_t *cl_anglespeedkey;
cvar_t *cl_vsmoothing;
/*
===============================================================================
@ -97,7 +97,6 @@ state bit 2 is edge triggered on the down to up transition
===============================================================================
*/
kbutton_t in_mlook;
kbutton_t in_klook;
kbutton_t in_jlook;
@ -343,7 +342,8 @@ void KeyUp (kbutton_t *b)
if( c[0] )
k = atoi(c);
else
{ // typed manually at the console, assume for unsticking, so clear all
{
// typed manually at the console, assume for unsticking, so clear all
b->down[0] = b->down[1] = 0;
b->state = 4; // impulse up
return;
@ -380,21 +380,80 @@ int DLLEXPORT HUD_Key_Event( int down, int keynum, const char *pszCurrentBinding
return 1;
}
void IN_BreakDown( void ) { KeyDown( &in_break );};
void IN_BreakUp( void ) { KeyUp( &in_break ); };
void IN_KLookDown (void) {KeyDown(&in_klook);}
void IN_KLookUp (void) {KeyUp(&in_klook);}
void IN_JLookDown (void) {KeyDown(&in_jlook);}
void IN_JLookUp (void) {KeyUp(&in_jlook);}
void IN_MLookDown (void) {KeyDown(&in_mlook);}
void IN_UpDown(void) {KeyDown(&in_up);}
void IN_UpUp(void) {KeyUp(&in_up);}
void IN_DownDown(void) {KeyDown(&in_down);}
void IN_DownUp(void) {KeyUp(&in_down);}
void IN_LeftDown(void) {KeyDown(&in_left);}
void IN_LeftUp(void) {KeyUp(&in_left);}
void IN_RightDown(void) {KeyDown(&in_right);}
void IN_RightUp(void) {KeyUp(&in_right);}
void IN_BreakDown( void )
{
KeyDown( &in_break );
}
void IN_BreakUp( void )
{
KeyUp( &in_break );
}
void IN_KLookDown( void )
{
KeyDown( &in_klook );
}
void IN_KLookUp( void )
{
KeyUp( &in_klook );
}
void IN_JLookDown( void )
{
KeyDown( &in_jlook );
}
void IN_JLookUp( void )
{
KeyUp( &in_jlook );
}
void IN_MLookDown( void )
{
KeyDown( &in_mlook );
}
void IN_UpDown( void )
{
KeyDown( &in_up );
}
void IN_UpUp( void )
{
KeyUp( &in_up );
}
void IN_DownDown( void )
{
KeyDown( &in_down );
}
void IN_DownUp( void )
{
KeyUp( &in_down );
}
void IN_LeftDown( void )
{
KeyDown( &in_left );
}
void IN_LeftUp( void )
{
KeyUp( &in_left );
}
void IN_RightDown( void )
{
KeyDown( &in_right );
}
void IN_RightUp( void )
{
KeyUp( &in_right );
}
void IN_ForwardDown( void )
{
@ -419,10 +478,27 @@ void IN_BackUp(void)
KeyUp( &in_back );
gHUD.m_Spectator.HandleButtonsUp( IN_BACK );
}
void IN_LookupDown(void) {KeyDown(&in_lookup);}
void IN_LookupUp(void) {KeyUp(&in_lookup);}
void IN_LookdownDown(void) {KeyDown(&in_lookdown);}
void IN_LookdownUp(void) {KeyUp(&in_lookdown);}
void IN_LookupDown( void )
{
KeyDown( &in_lookup );
}
void IN_LookupUp( void )
{
KeyUp( &in_lookup );
}
void IN_LookdownDown( void )
{
KeyDown( &in_lookdown );
}
void IN_LookdownUp( void )
{
KeyUp( &in_lookdown );
}
void IN_MoveleftDown( void )
{
KeyDown( &in_moveleft );
@ -446,10 +522,26 @@ void IN_MoverightUp(void)
KeyUp( &in_moveright );
gHUD.m_Spectator.HandleButtonsUp( IN_MOVERIGHT );
}
void IN_SpeedDown(void) {KeyDown(&in_speed);}
void IN_SpeedUp(void) {KeyUp(&in_speed);}
void IN_StrafeDown(void) {KeyDown(&in_strafe);}
void IN_StrafeUp(void) {KeyUp(&in_strafe);}
void IN_SpeedDown( void )
{
KeyDown( &in_speed );
}
void IN_SpeedUp( void )
{
KeyUp( &in_speed );
}
void IN_StrafeDown( void )
{
KeyDown( &in_strafe );
}
void IN_StrafeUp( void )
{
KeyUp( &in_strafe );
}
// needs capture by hud/vgui also
extern void __CmdFunc_InputPlayerSpecial( void );
@ -461,33 +553,71 @@ void IN_Attack2Down(void)
gHUD.m_Spectator.HandleButtonsDown( IN_ATTACK2 );
}
void IN_Attack2Up(void) {KeyUp(&in_attack2);}
void IN_Attack2Up( void )
{
KeyUp( &in_attack2 );
}
void IN_UseDown( void )
{
KeyDown( &in_use );
gHUD.m_Spectator.HandleButtonsDown( IN_USE );
}
void IN_UseUp (void) {KeyUp(&in_use);}
void IN_UseUp( void )
{
KeyUp( &in_use );
}
void IN_JumpDown( void )
{
KeyDown( &in_jump );
gHUD.m_Spectator.HandleButtonsDown( IN_JUMP );
}
void IN_JumpUp (void) {KeyUp(&in_jump);}
void IN_JumpUp( void )
{
KeyUp( &in_jump );
}
void IN_DuckDown( void )
{
KeyDown( &in_duck );
gHUD.m_Spectator.HandleButtonsDown( IN_DUCK );
}
void IN_DuckUp(void) {KeyUp(&in_duck);}
void IN_ReloadDown(void) {KeyDown(&in_reload);}
void IN_ReloadUp(void) {KeyUp(&in_reload);}
void IN_Alt1Down(void) {KeyDown(&in_alt1);}
void IN_Alt1Up(void) {KeyUp(&in_alt1);}
void IN_GraphDown(void) {KeyDown(&in_graph);}
void IN_GraphUp(void) {KeyUp(&in_graph);}
void IN_DuckUp( void )
{
KeyUp( &in_duck );
}
void IN_ReloadDown( void )
{
KeyDown( &in_reload );
}
void IN_ReloadUp( void )
{
KeyUp( &in_reload );
}
void IN_Alt1Down( void )
{
KeyDown( &in_alt1 );
}
void IN_Alt1Up( void )
{
KeyUp( &in_alt1 );
}
void IN_GraphDown( void )
{
KeyDown( &in_graph );
}
void IN_GraphUp( void )
{
KeyUp( &in_graph );
}
void IN_AttackDown( void )
{
@ -610,6 +740,7 @@ void CL_AdjustAngles ( float frametime, float *viewangles )
viewangles[YAW] += speed * cl_yawspeed->value * CL_KeyState( &in_left );
viewangles[YAW] = anglemod( viewangles[YAW] );
}
if( in_klook.state & 1 )
{
viewangles[PITCH] -= speed * cl_pitchspeed->value * CL_KeyState( &in_forward );
@ -716,7 +847,6 @@ void DLLEXPORT CL_CreateMove ( float frametime, struct usercmd_s *cmd, int activ
//
cmd->buttons = CL_ButtonBits( 1 );
// If they're in a modal dialog, ignore the attack button.
// Using joystick?
if( in_joystick->value )
{
@ -952,10 +1082,6 @@ void InitInput (void)
gEngfuncs.pfnAddCommand( "-reload", IN_ReloadUp );
gEngfuncs.pfnAddCommand( "+alt1", IN_Alt1Down );
gEngfuncs.pfnAddCommand( "-alt1", IN_Alt1Up );
//gEngfuncs.pfnAddCommand ("+score", IN_ScoreDown);
//gEngfuncs.pfnAddCommand ("-score", IN_ScoreUp);
//gEngfuncs.pfnAddCommand ("+showscores", IN_ScoreDown);
//gEngfuncs.pfnAddCommand ("-showscores", IN_ScoreUp);
gEngfuncs.pfnAddCommand( "+graph", IN_GraphDown );
gEngfuncs.pfnAddCommand( "-graph", IN_GraphUp );
gEngfuncs.pfnAddCommand( "+break", IN_BreakDown );

1607
cl_dll/input_goldsource.cpp Normal file

File diff suppressed because it is too large Load Diff

83
cl_dll/input_mouse.cpp Normal file
View File

@ -0,0 +1,83 @@
#include "input_mouse.h"
#include "exportdef.h"
#include "hud.h"
#include "cl_util.h"
// shared between backends
Vector dead_viewangles(0, 0, 0);
cvar_t *sensitivity;
cvar_t *in_joystick;
FWGSInput fwgsInput;
#ifdef SUPPORT_GOLDSOURCE_INPUT
GoldSourceInput goldSourceInput;
AbstractInput* currentInput = &goldSourceInput;
#else
AbstractInput* currentInput = &fwgsInput;
#endif
extern "C" void DLLEXPORT IN_ClientMoveEvent( float forwardmove, float sidemove )
{
currentInput->IN_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();
}

79
cl_dll/input_mouse.h Normal file
View File

@ -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

View File

@ -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
#include "exportdef.h"
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
@ -54,8 +43,8 @@ float rel_pitch;
#define IMPULSE_DOWN 2
#define IMPULSE_UP 4
bool CL_IsDead();
Vector dead_viewangles(0, 0, 0);
int CL_IsDead( void );
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 );

View File

@ -1,919 +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"
#define HSPRITE WINAPI_HSPRITE
#include "windows.h"
#undef HSPRITE
#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 (&current_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 (&current_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 ();
}

View File

@ -1,18 +1,16 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#pragma once
#if !defined( KBUTTONH )
#define KBUTTONH
#pragma once
typedef struct kbutton_s
{
int down[2]; // key nums holding it down
int state; // low bit is down state
} kbutton_t;
#endif // !KBUTTONH

View File

@ -17,21 +17,20 @@
//
// generic menu handler
//
#include "hud.h"
#include "cl_util.h"
#include "parsemsg.h"
#include <string.h>
#include <stdio.h>
#define MAX_MENU_STRING 512
char g_szMenuString[MAX_MENU_STRING];
char g_szPrelocalisedMenuString[MAX_MENU_STRING];
int KB_ConvertString( char *in, char **ppout );
DECLARE_MESSAGE( m_Menu, ShowMenu );
DECLARE_MESSAGE( m_Menu, ShowMenu )
int CHudMenu::Init( void )
{
@ -64,11 +63,14 @@ int CHudMenu :: VidInit( void )
int CHudMenu::Draw( float flTime )
{
int i;
// check for if menu is set to disappear
if( m_flShutoffTime > 0 )
{
if( m_flShutoffTime <= gHUD.m_flTime )
{ // times up, shutoff
{
// times up, shutoff
m_fMenuDisplayed = 0;
m_iFlags &= ~HUD_ACTIVE;
return 1;
@ -77,10 +79,8 @@ int CHudMenu :: Draw( float flTime )
// don't draw the menu if the scoreboard is being shown
// draw the menu, along the left-hand side of the screen
// count the number of newlines
int nlc = 0;
int i;
for( i = 0; i < MAX_MENU_STRING && g_szMenuString[i] != '\0'; i++ )
{
if( g_szMenuString[i] == '\n' )
@ -122,7 +122,6 @@ void CHudMenu :: SelectMenuItem( int menu_item )
}
}
// Message handler for ShowMenu message
// takes four values:
// short: a bitfield of keys that are valid input
@ -152,19 +151,23 @@ int CHudMenu :: MsgFunc_ShowMenu( const char *pszName, int iSize, void *pbuf )
strncpy( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING );
}
else
{ // append to the current menu string
strncat( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING - strlen(g_szPrelocalisedMenuString) );
{
// append to the current menu string
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 ) );
{
// we have the whole string, so we can localise it now
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 );
}
}

View File

@ -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 )
@ -42,7 +42,7 @@ int CHudMessage::Init(void)
Reset();
return 1;
};
}
int CHudMessage::VidInit( void )
{
@ -50,8 +50,7 @@ int CHudMessage::VidInit( void )
m_HUD_title_life = gHUD.GetSpriteIndex( "title_life" );
return 1;
};
}
void CHudMessage::Reset( void )
{
@ -62,7 +61,6 @@ void CHudMessage::Reset( void )
m_pGameTitle = NULL;
}
float CHudMessage::FadeBlend( float fadein, float fadeout, float hold, float localTime )
{
float fadeTime = fadein + hold;
@ -113,7 +111,6 @@ int CHudMessage::XPosition( float x, int width, int totalWidth )
return xPos;
}
int CHudMessage::YPosition( float y, int height )
{
int yPos;
@ -137,7 +134,6 @@ int CHudMessage::YPosition( float y, int height )
return yPos;
}
void CHudMessage::MessageScanNextChar( void )
{
int srcRed, srcGreen, srcBlue, destRed = 0, destGreen = 0, destBlue = 0;
@ -156,7 +152,6 @@ void CHudMessage::MessageScanNextChar( void )
destRed = destGreen = destBlue = 0;
blend = m_parms.fadeBlend;
break;
case 2:
m_parms.charTime += m_parms.pMessage->fadein;
if( m_parms.charTime > m_parms.time )
@ -201,7 +196,6 @@ void CHudMessage::MessageScanNextChar( void )
}
}
void CHudMessage::MessageScanStart( void )
{
switch( m_parms.pMessage->effect )
@ -230,7 +224,6 @@ void CHudMessage::MessageScanStart( void )
if( m_parms.pMessage->effect == 1 && ( rand() % 100 ) < 10 )
m_parms.charTime = 1;
break;
case 2:
m_parms.fadeTime = (m_parms.pMessage->fadein * m_parms.length) + m_parms.pMessage->holdtime;
@ -274,7 +267,6 @@ void CHudMessage::MessageDrawScan( client_textmessage_t *pMessage, float time )
m_parms.length = length;
m_parms.totalHeight = ( m_parms.lines * gHUD.m_scrinfo.iCharHeight );
m_parms.y = YPosition( pMessage->y, m_parms.totalHeight );
pText = pMessage->pMessage;
@ -314,12 +306,11 @@ void CHudMessage::MessageDrawScan( client_textmessage_t *pMessage, float time )
}
}
int CHudMessage::Draw( float fTime )
{
int i, drawn;
client_textmessage_t *pMessage;
float endTime;
float endTime = 0.0f;
drawn = 0;
@ -345,7 +336,6 @@ int CHudMessage::Draw( float fTime )
int x = XPosition( m_pGameTitle->x, fullWidth, fullWidth );
int y = YPosition( m_pGameTitle->y, fullHeight );
SPR_Set( gHUD.GetSprite( m_HUD_title_half ), brightness * m_pGameTitle->r1, brightness * m_pGameTitle->g1, brightness * m_pGameTitle->b1 );
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect( m_HUD_title_half ) );
@ -416,7 +406,6 @@ int CHudMessage::Draw( float fTime )
return 1;
}
void CHudMessage::MessageAdd( const char *pName, float time )
{
int i, j;
@ -481,7 +470,6 @@ void CHudMessage::MessageAdd( const char *pName, float time )
}
}
int CHudMessage::MsgFunc_HudText( const char *pszName, int iSize, void *pbuf )
{
BEGIN_READ( pbuf, iSize );
@ -489,6 +477,7 @@ int CHudMessage::MsgFunc_HudText( const char *pszName, int iSize, void *pbuf )
char *pString = READ_STRING();
MessageAdd( pString, gHUD.m_flTime );
// Remember the time -- to fix up level transitions
m_parms.time = gHUD.m_flTime;
@ -499,7 +488,6 @@ int CHudMessage::MsgFunc_HudText( const char *pszName, int iSize, void *pbuf )
return 1;
}
int CHudMessage::MsgFunc_GameTitle( const char *pszName, int iSize, void *pbuf )
{
m_pGameTitle = TextMessageGet( "GAMETITLE" );
@ -532,5 +520,4 @@ void CHudMessage::MessageAdd(client_textmessage_t * newMessage )
return;
}
}
}

View File

@ -1,4 +1,4 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
@ -9,6 +9,7 @@
#include "cl_util.h"
#include "cl_entity.h"
#include "triangleapi.h"
#include "overview.h"
// these are included for the math functions
#include "com_model.h"
@ -46,16 +47,18 @@ int CHudOverview::VidInit()
//-----------------------------------------------------------------------------
int CHudOverview::Draw( float flTime )
{
#if 0
// only draw in overview mode
if( !gEngfuncs.Overview_GetOverviewState() )
return 1;
// make sure we have player info
gViewPort->GetAllPlayersInfo();
//gViewPort->GetAllPlayersInfo();
gHUD.m_Scoreboard.GetAllPlayersInfo();
// calculate player size on the overview
int x1, y1, x2, y2;
float v0[3]={0,0,0}, v1[3]={64,64,0};
float v0[3] = { 0.0f }, v1[3] = { 64.0f, 64.0f };
gEngfuncs.Overview_WorldToScreen( v0, &x1, &y1 );
gEngfuncs.Overview_WorldToScreen( v1, &x2, &y2 );
float scale = abs( x2 - x1 );
@ -143,7 +146,7 @@ int CHudOverview::Draw(float flTime)
DrawConsoleString( x, y + ( 1.1 * scale ), string );
}
}
#endif
return 1;
}

View File

@ -1,14 +1,13 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//========= Copyright © 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
@ -26,6 +25,4 @@ private:
HSPRITE m_hsprPlayer;
HSPRITE m_hsprViewcone;
};
#endif // OVERVIEW_H

View File

@ -15,6 +15,7 @@
//
// parsemsg.cpp
//
typedef unsigned char byte;
#define true 1
@ -31,7 +32,6 @@ void BEGIN_READ( void *buf, int size )
gpBuf = (byte*)buf;
}
int READ_CHAR( void )
{
int c;
@ -86,7 +86,6 @@ int READ_WORD( void )
return READ_SHORT();
}
int READ_LONG( void )
{
int c;
@ -137,7 +136,7 @@ char* READ_STRING( void )
if( giRead+1 > giSize )
break; // no more characters
c = READ_CHAR();
c = READ_BYTE();
if( c == -1 || c == 0 )
break;
string[l] = c;
@ -163,4 +162,3 @@ float READ_HIRESANGLE( void )
{
return (float)( READ_SHORT() * ( 360.0 / 65536 ) );
}

View File

@ -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

View File

@ -43,7 +43,7 @@ static float flScrollTime = 0; // the time at which the lines next scroll up
static int Y_START = 0;
static int line_height = 0;
DECLARE_MESSAGE( m_SayText, SayText );
DECLARE_MESSAGE( m_SayText, SayText )
int CHudSayText::Init( void )
{
@ -61,7 +61,6 @@ int CHudSayText :: Init( void )
return 1;
}
void CHudSayText::InitHUDData( void )
{
memset( g_szLineBuffer, 0, sizeof g_szLineBuffer );
@ -74,7 +73,6 @@ int CHudSayText :: VidInit( void )
return 1;
}
int ScrollTextUp( void )
{
ConsolePrint( g_szLineBuffer[0] ); // move the first line into the console buffer
@ -97,7 +95,6 @@ int CHudSayText :: Draw( float flTime )
{
int y = Y_START;
// make sure the scrolltime is within reasonable bounds, to guard against the clock being reset
flScrollTime = min( flScrollTime, flTime + m_HUD_saytext_time->value );
@ -113,7 +110,8 @@ int CHudSayText :: Draw( float flTime )
ScrollTextUp();
}
else
{ // buffer is empty, just disable drawing of this section
{
// buffer is empty, just disable drawing of this section
m_iFlags &= ~HUD_ACTIVE;
}
}
@ -146,7 +144,6 @@ int CHudSayText :: Draw( float flTime )
y += line_height;
}
return 1;
}
@ -163,10 +160,12 @@ int CHudSayText :: MsgFunc_SayText( const char *pszName, int iSize, void *pbuf )
void CHudSayText::SayTextPrint( const char *pszBuf, int iBufSize, int clientIndex )
{
int i;
ConsolePrint( pszBuf );
// find an empty string slot
for( i = 0; i < MAX_LINES; i++ )
{
if ( ! *g_szLineBuffer[i] )
if( !( *g_szLineBuffer[i] ) )
break;
}
if( i == MAX_LINES )
@ -216,7 +215,6 @@ void CHudSayText :: SayTextPrint( const char *pszBuf, int iBufSize, int clientIn
else
Y_START = ScreenHeight - 45;
Y_START -= ( line_height * ( MAX_LINES + 1 ) );
}
void CHudSayText::EnsureTextFitsInOneLineAndWrapIfHaveTo( int line )
@ -225,7 +223,8 @@ void CHudSayText :: EnsureTextFitsInOneLineAndWrapIfHaveTo( int line )
GetConsoleStringSize( g_szLineBuffer[line], &line_width, &line_height );
if( ( line_width + LINE_START ) > MAX_LINE_WIDTH )
{ // string is too long to fit on line
{
// string is too long to fit on line
// scan the string until we find what word is too long, and wrap the end of the sentence after the word
int length = LINE_START;
int tmp_len = 0;
@ -258,7 +257,8 @@ void CHudSayText :: EnsureTextFitsInOneLineAndWrapIfHaveTo( int line )
length += tmp_len;
if( length > MAX_LINE_WIDTH )
{ // needs to be broken up
{
// needs to be broken up
if( !last_break )
last_break = x - 1;
@ -270,7 +270,7 @@ void CHudSayText :: EnsureTextFitsInOneLineAndWrapIfHaveTo( int line )
{
for( j = 0; j < MAX_LINES; j++ )
{
if ( ! *g_szLineBuffer[j] )
if( !( *g_szLineBuffer[j] ) )
break;
}
if( j == MAX_LINES )

View File

@ -26,6 +26,7 @@
#include <string.h>
#include <stdio.h>
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;
@ -90,7 +92,7 @@ We have a minimum width of 1-320 - we could have the field widths scale with it?
// X positions
// relative to the side of the scoreboard
#define NAME_RANGE_MIN 20
#define NAME_RANGE_MIN -100
#define NAME_RANGE_MAX 145
#define KILLS_RANGE_MIN 130
#define KILLS_RANGE_MAX 170
@ -143,21 +145,22 @@ int CHudScoreboard::Draw( float fTime )
int xpos = NAME_RANGE_MIN + xpos_rel;
FAR_RIGHT = can_show_packetloss ? PL_RANGE_MAX : PING_RANGE_MAX;
FAR_RIGHT += 5;
FAR_RIGHT += 125;
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;
@ -272,7 +275,7 @@ int CHudScoreboard::Draw( float fTime )
}
// 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 +283,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 +303,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
@ -337,7 +340,7 @@ 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;
FAR_RIGHT += 125;
// draw the players, in order, and restricted to team if set
while( 1 )
@ -400,7 +403,7 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset,
}
// 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 +411,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 +438,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

View File

@ -15,11 +15,10 @@
//
// $NoKeywords: $
//=============================================================================
#define HSPRITE WINAPI_HSPRITE
#include <windows.h>
#include <dsound.h>
#include <mmsystem.h>
#undef HSPRITE
#include "r_studioint.h"
extern engine_studio_api_t IEngineStudio;

View File

@ -15,6 +15,7 @@
//
// status_icons.cpp
//
#include "hud.h"
#include "cl_util.h"
#include "const.h"
@ -25,7 +26,7 @@
#include "parsemsg.h"
#include "event_api.h"
DECLARE_MESSAGE( m_StatusIcons, StatusIcon );
DECLARE_MESSAGE( m_StatusIcons, StatusIcon )
int CHudStatusIcons::Init( void )
{
@ -40,7 +41,6 @@ int CHudStatusIcons::Init( void )
int CHudStatusIcons::VidInit( void )
{
return 1;
}
@ -104,9 +104,10 @@ 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;
// check to see if the sprite is in the current list
for( i = 0; i < MAX_ICONSPRITES; i++ )
{
@ -148,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++ )

View File

@ -26,8 +26,8 @@
#include <string.h>
#include <stdio.h>
DECLARE_MESSAGE( m_StatusBar, StatusText );
DECLARE_MESSAGE( m_StatusBar, StatusValue );
DECLARE_MESSAGE( m_StatusBar, StatusText )
DECLARE_MESSAGE( m_StatusBar, StatusValue )
#define STATUSBAR_ID_LINE 1
@ -51,7 +51,6 @@ int CHudStatusBar :: Init( void )
int CHudStatusBar::VidInit( void )
{
// Load sprites here
return 1;
}
@ -74,8 +73,7 @@ void CHudStatusBar :: Reset( void )
void CHudStatusBar::ParseStatusString( int line_num )
{
// localise string first
char szBuffer[MAX_STATUSTEXT_LENGTH];
memset( szBuffer, 0, sizeof szBuffer );
char szBuffer[MAX_STATUSTEXT_LENGTH] = {0};
gHUD.m_TextMessage.LocaliseTextString( m_szStatusText[line_num], szBuffer, MAX_STATUSTEXT_LENGTH );
// parse m_szStatusText & m_iStatusValues into m_szStatusBar
@ -96,7 +94,8 @@ void CHudStatusBar :: ParseStatusString( int line_num )
int index = atoi( src );
// should we draw this line?
if( ( index >= 0 && index < MAX_STATUSBAR_VALUES ) && ( m_iStatusValues[index] != 0 ) )
{ // parse this line and append result to the status bar
{
// parse this line and append result to the status bar
while ( *src >= '0' && *src <= '9' )
src++;
@ -107,7 +106,8 @@ void CHudStatusBar :: ParseStatusString( int line_num )
while( *src != '\n' && *src != 0 )
{
if( *src != '%' )
{ // just copy the character
{
// just copy the character
*dst = *src;
dst++, src++;
}
@ -148,7 +148,6 @@ void CHudStatusBar :: ParseStatusString( int line_num )
{
strcpy( szRepString, "******" );
}
break;
case 'i': // number
sprintf( szRepString, "%d", indexval );

View File

@ -1,4 +1,4 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//========= Copyright <EFBFBD> 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
@ -199,7 +199,8 @@ void QuaternionSlerp( vec4_t p, vec4_t q, float t, vec4_t qt )
sclp = 1.0 - t;
sclq = t;
}
for (i = 0; i < 4; i++) {
for( i = 0; i < 4; i++ )
{
qt[i] = sclp * p[i] + sclq * q[i];
}
}

View File

@ -1,15 +1,13 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//========= Copyright <EFBFBD> 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
@ -36,5 +34,4 @@ void MatrixCopy( float in[3][4], float out[3][4] );
void QuaternionMatrix( vec4_t quaternion, float (*matrix)[4] );
void QuaternionSlerp( vec4_t p, vec4_t q, float t, vec4_t qt );
void AngleQuaternion( float *angles, vec4_t quaternion );
#endif // STUDIO_UTIL_H

View File

@ -26,7 +26,7 @@
#include <stdio.h>
#include "parsemsg.h"
DECLARE_MESSAGE( m_TextMessage, TextMsg );
DECLARE_MESSAGE( m_TextMessage, TextMsg )
int CHudTextMessage::Init( void )
{
@ -37,7 +37,7 @@ int CHudTextMessage::Init(void)
Reset();
return 1;
};
}
// Searches through the string for any msg names (indicated by a '#')
// any found are looked up in titles.txt and the new message substituted
@ -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,11 +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;
{
// nothing special about this message, so just return the same string
return msg;
}
}
@ -161,45 +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
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 );
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
}
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;
}

View File

@ -362,7 +362,6 @@ enum
// Silent Spy Feign
#define TF_SPY_SILENTDIE 199
/*==================================================*/
/* Defines for the ENGINEER's Building ability */
/*==================================================*/
@ -1382,8 +1381,5 @@ public:
void Spawn( void );
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
};
#endif // TF_DEFS_ONLY
#endif // __TF_DEFS_H

View File

@ -26,7 +26,6 @@
DECLARE_MESSAGE( m_Train, Train )
int CHudTrain::Init( void )
{
HOOK_MESSAGE( Train );
@ -36,14 +35,14 @@ int CHudTrain::Init(void)
gHUD.AddHudElem( this );
return 1;
};
}
int CHudTrain::VidInit( void )
{
m_hSprite = 0;
return 1;
};
}
int CHudTrain::Draw( float fTime )
{
@ -62,13 +61,11 @@ int CHudTrain::Draw(float fTime)
x = ScreenWidth / 3 + SPR_Width( m_hSprite, 0 ) / 4;
SPR_DrawAdditive( m_iPos - 1, x, y, NULL );
}
return 1;
}
int CHudTrain::MsgFunc_Train( const char *pszName, int iSize, void *pbuf )
{
BEGIN_READ( pbuf, iSize );

View File

@ -1,4 +1,4 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
@ -18,8 +18,6 @@
#include "triangleapi.h"
#include "particlemgr.h"
#include "exportdef.h"
extern "C"
{
void DLLEXPORT HUD_DrawNormalTriangles( void );
@ -187,7 +185,6 @@ void Draw_Triangles( void )
gEngfuncs.pTriAPI->End();
gEngfuncs.pTriAPI->RenderMode( kRenderNormal );
}
#endif
void BlackFog ( void )
@ -221,7 +218,6 @@ Non-transparent triangles-- add them here
void DLLEXPORT HUD_DrawNormalTriangles( void )
{
gHUD.m_Spectator.DrawOverview();
#if defined( TEST_IT )
// Draw_Triangles();
#endif

View File

@ -30,7 +30,11 @@
#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
#endif
vec3_t vec3_origin( 0, 0, 0 );
extern vec3_t vec3_origin;
#ifdef _MSC_VER
vec3_t vec3_origin;
#endif
double sqrt( double x );
@ -92,7 +96,6 @@ float VectorNormalize (float *v)
}
return length;
}
void VectorInverse( float *v )
@ -130,4 +133,3 @@ HSPRITE LoadSprite(const char *pszName)
return SPR_Load( sz );
}

View File

@ -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
//=========================================================
@ -109,13 +112,19 @@ public:
return Vec2;
}
inline float Length2D(void) const { return (float)sqrt(x*x + y*y); }
inline float Length2D( void ) const
{
return (float)sqrt( x * x + y * y );
}
// Members
vec_t x, y, z;
};
inline Vector operator*( float fl, const Vector& v ) { return v * fl; }
inline float DotProduct( const Vector& a, const Vector& b) { return( a.x * b.x + a.y * b.y + a.z * b.z ); }
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

View File

@ -1,4 +1,4 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
@ -25,8 +25,7 @@
#include "screenfade.h"
#include "shake.h"
#include "hltv.h"
#include "exportdef.h"
#include "string.h"
// Spectator Mode
extern "C"
{
@ -79,6 +78,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
@ -91,7 +91,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;
@ -122,6 +122,7 @@ float v_idlescale; // used by TFC for concussion grenade effect
void V_NormalizeAngles( float *angles )
{
int i;
// Normalize angles
for( i = 0; i < 3; i++ )
{
@ -136,7 +137,6 @@ void V_NormalizeAngles( float *angles )
}
}
===================
V_InterpolateAngles
@ -184,7 +184,6 @@ float V_CalcBob ( struct ref_params_s *pparams )
static float lasttime;
vec3_t vel;
if( pparams->onground == -1 ||
pparams->time == lasttime )
{
@ -217,7 +216,6 @@ float V_CalcBob ( struct ref_params_s *pparams )
bob = min( bob, 4 );
bob = max( bob, -7 );
return bob;
}
/*
@ -251,6 +249,27 @@ float V_CalcRoll (vec3_t angles, vec3_t velocity, float rollangle, float rollspe
return side * sign;
}
typedef struct pitchdrift_s
{
float pitchvel;
int nodrift;
float driftmove;
double laststop;
} pitchdrift_t;
static pitchdrift_t pd;
/*
===============
V_DriftPitch
Moves the client pitch angle towards idealpitch sent by the server.
If the user is adjusting pitch manually, either with lookup/lookdown,
mlook and mouse, or klook and keyboard, pitch drifting is constantly stopped.
===============
*/
/*
==============================================================================
VIEW RENDERING
@ -296,7 +315,6 @@ void V_AddIdle ( struct ref_params_s *pparams )
pparams->viewangles[YAW] += v_idlescale * sin( pparams->time * v_iyaw_cycle.value ) * v_iyaw_level.value;
}
/*
==============
V_CalcViewRoll
@ -326,7 +344,6 @@ void V_CalcViewRoll ( struct ref_params_s *pparams )
}
}
/*
==================
V_CalcIntermissionRefdef
@ -335,11 +352,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();
@ -451,7 +468,7 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams )
// refresh position
VectorCopy( pparams->simorg, pparams->vieworg );
pparams->vieworg[2] += ( bob );
pparams->vieworg[2] += bob ;
VectorAdd( pparams->vieworg, pparams->viewheight, pparams->vieworg );
if( pparams->health <= 0 )
@ -470,7 +487,6 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams )
// dissapear when viewed with the eye exactly on it.
// FIXME, we send origin at 1/128 now, change this?
// the server protocol only specifies to 1/16 pixel, so add 1/32 in each axis
pparams->vieworg[0] += 1.0 / 32;
pparams->vieworg[1] += 1.0 / 32;
pparams->vieworg[2] += 1.0 / 32;
@ -589,13 +605,12 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams )
{
VectorCopy( pparams->cl_viewangles, view->angles );
}
// set up gun position
V_CalcGunAngle( pparams );
// Use predicted origin as view origin.
VectorCopy( pparams->simorg, view->origin );
view->origin[2] += ( waterOffset );
view->origin[2] += waterOffset;
VectorAdd( view->origin, pparams->viewheight, view->origin );
// Let the viewmodel shake at about 10% of the amplitude
@ -612,6 +627,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).
@ -640,9 +658,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
@ -651,6 +669,7 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams )
float steptime;
steptime = pparams->time - lasttime;
if( steptime < 0 )
//FIXME I_Error( "steptime < 0" );
steptime = 0;
@ -668,7 +687,6 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams )
oldz = pparams->simorg[2];
}
#endif
{
static float lastorg[3];
vec3_t delta;
@ -730,7 +748,6 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams )
VectorAdd( pparams->simorg, delta, pparams->simorg );
VectorAdd( pparams->vieworg, delta, pparams->vieworg );
VectorAdd( view->origin, delta, view->origin );
}
}
}
@ -844,7 +861,6 @@ void V_SmoothInterpolateAngles( float * startAngle, float * endAngle, float * fi
{
finalAngle[i] = endAngle[i];
}
}
NormalizeAngles( finalAngle );
@ -989,7 +1005,6 @@ void V_GetSingleTargetCam(cl_entity_t * ent1, float * angle, float * origin)
newOrigin[2] += 2; //laying on ground
else
newOrigin[2] += 17; // head level of living player
}
else
newOrigin[2]+= 8; // object, tricky, must be above bomb in CS
@ -1002,7 +1017,6 @@ void V_GetSingleTargetCam(cl_entity_t * ent1, float * angle, float * origin)
if( flags & DRC_FLAG_FACEPLAYER )
newAngle[1] += 180.0f;
newAngle[0] += 12.5f * dfactor; // lower angle if dramatic
// if final scene (bomb), show from real high pos
@ -1051,7 +1065,7 @@ float MaxAngleBetweenAngles( float * a1, float * a2 )
void V_GetDoubleTargetsCam( cl_entity_t *ent1, cl_entity_t *ent2, float *angle, float *origin )
{
float newAngle[3]; float newOrigin[3]; float tempVec[3];
float newAngle[3], newOrigin[3], tempVec[3];
int flags = gHUD.m_Spectator.m_iObserverFlags;
@ -1131,14 +1145,10 @@ void V_GetDoubleTargetsCam(cl_entity_t * ent1, cl_entity_t * ent2,float * angle
/* take middle between two viewangles
InterpolateAngles( newAngle, tempVec, newAngle, 0.5f ); */
}
void V_GetDirectedChasePosition(cl_entity_t *ent1, cl_entity_t *ent2,float *angle, float *origin)
{
if( v_resetCamera )
{
v_lastDistance = 4096.0f;
@ -1198,7 +1208,7 @@ void V_GetChasePos(int target, float * cl_angles, float * origin, float * angles
if( target )
{
ent = gEngfuncs.GetEntityByIndex( target );
};
}
if( !ent )
{
@ -1208,8 +1218,6 @@ void V_GetChasePos(int target, float * cl_angles, float * origin, float * angles
return;
}
if( gHUD.m_Spectator.m_autoDirector->value )
{
if( g_iUser3 )
@ -1229,7 +1237,6 @@ void V_GetChasePos(int target, float * cl_angles, float * origin, float * angles
else
VectorCopy( cl_angles, angles );
VectorCopy( ent->origin, origin );
origin[2] += 28; // DEFAULT_VIEWHEIGHT - some offset
@ -1245,7 +1252,6 @@ void V_ResetChaseCam()
v_resetCamera = true;
}
void V_GetInEyePos( int target, float *origin, float *angles )
{
if( !target )
@ -1256,7 +1262,6 @@ void V_GetInEyePos(int target, float * origin, float * angles )
return;
};
cl_entity_t *ent = gEngfuncs.GetEntityByIndex( target );
if( !ent )
@ -1294,7 +1299,6 @@ void V_GetMapFreePosition( float * cl_angles, float * origin, float * angles )
zScaledTarget[1] = gHUD.m_Spectator.m_mapOrigin[1];
zScaledTarget[2] = gHUD.m_Spectator.m_mapOrigin[2] * ( ( 90.0f - angles[0] ) / 90.0f );
AngleVectors( angles, forward, NULL, NULL );
VectorNormalize( forward );
@ -1347,8 +1351,8 @@ 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_crossbow.mdl", "models/v_crossbow.mdl" },
{ "models/p_crowbar.mdl", "models/v_crowbar.mdl" },
{ "models/p_egon.mdl", "models/v_egon.mdl" },
@ -1364,7 +1368,8 @@ int V_FindViewModelByWeaponModel(int weaponindex)
{ "models/p_tripmine.mdl", "models/v_tripmine.mdl" },
{ "models/p_satchel_radio.mdl", "models/v_satchel_radio.mdl" },
{ "models/p_satchel.mdl", "models/v_satchel.mdl" },
{ NULL, NULL } };
{ NULL, NULL }
};
struct model_s *weaponModel = IEngineStudio.GetModelByIndex( weaponindex );
@ -1386,10 +1391,8 @@ int V_FindViewModelByWeaponModel(int weaponindex)
}
else
return 0;
}
/*
==================
V_CalcSpectatorRefdef
@ -1445,7 +1448,6 @@ void V_CalcSpectatorRefdef ( struct ref_params_s * pparams )
if( lastWeaponModelIndex != ent->curstate.weaponmodel )
{
// weapon model changed
lastWeaponModelIndex = ent->curstate.weaponmodel;
lastViewModelIndex = V_FindViewModelByWeaponModel( lastWeaponModelIndex );
if( lastViewModelIndex )
@ -1486,27 +1488,27 @@ void V_CalcSpectatorRefdef ( struct ref_params_s * pparams )
if( pparams->nextView == 0 )
{
// first renderer cycle, full screen
switch( g_iUser1 )
{
case OBS_CHASE_LOCKED: V_GetChasePos( g_iUser2, NULL, v_origin, v_angles );
case OBS_CHASE_LOCKED:
V_GetChasePos( g_iUser2, NULL, v_origin, v_angles );
break;
case OBS_CHASE_FREE: V_GetChasePos( g_iUser2, v_cl_angles, v_origin, v_angles );
case OBS_CHASE_FREE:
V_GetChasePos( g_iUser2, v_cl_angles, v_origin, v_angles );
break;
case OBS_ROAMING : VectorCopy (v_cl_angles, v_angles);
case OBS_ROAMING:
VectorCopy( v_cl_angles, v_angles );
VectorCopy( v_sim_org, v_origin );
break;
case OBS_IN_EYE : V_CalcNormalRefdef ( pparams );
case OBS_IN_EYE:
V_CalcNormalRefdef( pparams );
break;
case OBS_MAP_FREE : pparams->onlyClientDraw = true;
case OBS_MAP_FREE:
pparams->onlyClientDraw = true;
V_GetMapFreePosition( v_cl_angles, v_origin, v_angles );
break;
case OBS_MAP_CHASE : pparams->onlyClientDraw = true;
case OBS_MAP_CHASE:
pparams->onlyClientDraw = true;
V_GetMapChasePosition( g_iUser2, v_cl_angles, v_origin, v_angles );
break;
}
@ -1515,12 +1517,10 @@ void V_CalcSpectatorRefdef ( struct ref_params_s * pparams )
pparams->nextView = 1; // force a second renderer view
gHUD.m_Spectator.m_iDrawCycle = 0;
}
else
{
// second renderer cycle, inset window
// set inset parameters
pparams->viewport[0] = XRES( gHUD.m_Spectator.m_OverviewData.insetWindowX ); // change viewport to inset window
pparams->viewport[1] = YRES( gHUD.m_Spectator.m_OverviewData.insetWindowY );
@ -1531,23 +1531,22 @@ void V_CalcSpectatorRefdef ( struct ref_params_s * pparams )
// override some settings in certain modes
switch( (int)gHUD.m_Spectator.m_pip->value )
{
case INSET_CHASE_FREE : V_GetChasePos( g_iUser2, v_cl_angles, v_origin, v_angles );
case INSET_CHASE_FREE:
V_GetChasePos( g_iUser2, v_cl_angles, v_origin, v_angles );
break;
case INSET_IN_EYE : V_CalcNormalRefdef ( pparams );
case INSET_IN_EYE:
V_CalcNormalRefdef( pparams );
break;
case INSET_MAP_FREE : pparams->onlyClientDraw = true;
case INSET_MAP_FREE:
pparams->onlyClientDraw = true;
V_GetMapFreePosition( v_cl_angles, v_origin, v_angles );
break;
case INSET_MAP_CHASE : pparams->onlyClientDraw = true;
case INSET_MAP_CHASE:
pparams->onlyClientDraw = true;
if( g_iUser1 == OBS_ROAMING )
V_GetMapChasePosition( 0, v_cl_angles, v_origin, v_angles );
else
V_GetMapChasePosition( g_iUser2, v_cl_angles, v_origin, v_angles );
break;
}
@ -1558,11 +1557,8 @@ void V_CalcSpectatorRefdef ( struct ref_params_s * pparams )
VectorCopy( v_cl_angles, pparams->cl_viewangles );
VectorCopy( v_angles, pparams->viewangles )
VectorCopy( v_origin, pparams->vieworg );
}
void DLLEXPORT V_CalcRefdef( struct ref_params_s *pparams )
{
// intermission / finale rendering
@ -1578,7 +1574,6 @@ void DLLEXPORT V_CalcRefdef( struct ref_params_s *pparams )
{
V_CalcNormalRefdef( pparams );
}
/*
// Example of how to overlay the whole screen with red at 50 % alpha
#define SF_TEST
@ -1624,7 +1619,7 @@ Client side punch effect
*/
void V_PunchAxis( int axis, float punch )
{
ev_punchangle[ axis ] = punch;
g_ev_punchangle[axis] = punch;
}
/*
@ -1648,7 +1643,6 @@ void V_Init (void)
cl_chasedist = gEngfuncs.pfnRegisterVariable( "cl_chasedist","112", 0 );
}
//#define TRACE_TEST
#if defined( TRACE_TEST )
@ -1728,5 +1722,4 @@ void V_Move( int mx, int my )
hitent = -1;
}
}
#endif

View File

@ -1,4 +1,4 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
@ -11,5 +11,4 @@
void V_StartPitchDrift( void );
void V_StopPitchDrift( void );
#endif // !VIEWH

View File

@ -12,11 +12,9 @@
* without written permission from Valve LLC.
*
****/
#if !defined ( BEAMDEFH )
#define BEAMDEFH
#ifdef _WIN32
#pragma once
#endif
#ifndef BEAMDEF_H
#define BEAMDEF_H
#define FBEAM_STARTENTITY 0x00000001
#define FBEAM_ENDENTITY 0x00000002
@ -59,4 +57,4 @@ struct beam_s
struct particle_s *particles;
};
#endif
#endif//BEAMDEF_H

246
common/bspfile.h Normal file
View File

@ -0,0 +1,246 @@
/*
bspfile.h - BSP format included q1, hl1 support
Copyright (C) 2010 Uncle Mike
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#pragma once
#ifndef BSPFILE_H
#define BSPFILE_H
/*
==============================================================================
BRUSH MODELS
.bsp contain level static geometry with including PVS and lightning info
==============================================================================
*/
// header
#define Q1BSP_VERSION 29 // quake1 regular version (beta is 28)
#define HLBSP_VERSION 30 // half-life regular version
#define XTBSP_VERSION 31 // extended lightmaps and expanded clipnodes limit
#define IDEXTRAHEADER (('H'<<24)+('S'<<16)+('A'<<8)+'X') // little-endian "XASH"
#define EXTRA_VERSION 2 // because version 1 was occupied by old versions of XashXT
#define DELUXEMAP_VERSION 1
#define IDDELUXEMAPHEADER (('T'<<24)+('I'<<16)+('L'<<8)+'Q') // little-endian "QLIT"
// worldcraft predefined angles
#define ANGLE_UP -1
#define ANGLE_DOWN -2
// bmodel limits
#define MAX_MAP_HULLS 4 // MAX_HULLS
#define SURF_NOCULL BIT( 0 ) // two-sided polygon (e.g. 'water4b')
#define SURF_PLANEBACK BIT( 1 ) // plane should be negated
#define SURF_DRAWSKY BIT( 2 ) // sky surface
#define SURF_WATERCSG BIT( 3 ) // culled by csg (was SURF_DRAWSPRITE)
#define SURF_DRAWTURB BIT( 4 ) // warp surface
#define SURF_DRAWTILED BIT( 5 ) // face without lighmap
#define SURF_CONVEYOR BIT( 6 ) // scrolled texture (was SURF_DRAWBACKGROUND)
#define SURF_UNDERWATER BIT( 7 ) // caustics
#define SURF_TRANSPARENT BIT( 8 ) // it's a transparent texture (was SURF_DONTWARP)
#define SURF_REFLECT BIT( 31 ) // reflect surface (mirror)
// lightstyle management
#define LM_STYLES 4 // MAXLIGHTMAPS
#define LS_NORMAL 0x00
#define LS_UNUSED 0xFE
#define LS_NONE 0xFF
#define MAX_MAP_MODELS 1024 // can be increased up to 2048 if needed
#define MAX_MAP_BRUSHES 32768 // unsigned short limit
#define MAX_MAP_ENTITIES 8192 // can be increased up to 32768 if needed
#define MAX_MAP_ENTSTRING 0x80000 // 512 kB should be enough
#define MAX_MAP_PLANES 65536 // can be increased without problems
#define MAX_MAP_NODES 32767 // because negative shorts are leafs
#define MAX_MAP_CLIPNODES 32767 // because negative shorts are contents
#define MAX_MAP_LEAFS 32767 // signed short limit
#define MAX_MAP_VERTS 65535 // unsigned short limit
#define MAX_MAP_FACES 65535 // unsigned short limit
#define MAX_MAP_MARKSURFACES 65535 // unsigned short limit
#define MAX_MAP_TEXINFO MAX_MAP_FACES // in theory each face may have personal texinfo
#define MAX_MAP_EDGES 0x100000 // can be increased but not needed
#define MAX_MAP_SURFEDGES 0x200000 // can be increased but not needed
#define MAX_MAP_TEXTURES 2048 // can be increased but not needed
#define MAX_MAP_MIPTEX 0x2000000 // 32 Mb internal textures data
#define MAX_MAP_LIGHTING 0x2000000 // 32 Mb lightmap raw data (can contain deluxemaps)
#define MAX_MAP_VISIBILITY 0x800000 // 8 Mb visdata
// quake lump ordering
#define LUMP_ENTITIES 0
#define LUMP_PLANES 1
#define LUMP_TEXTURES 2 // internal textures
#define LUMP_VERTEXES 3
#define LUMP_VISIBILITY 4
#define LUMP_NODES 5
#define LUMP_TEXINFO 6
#define LUMP_FACES 7
#define LUMP_LIGHTING 8
#define LUMP_CLIPNODES 9
#define LUMP_LEAFS 10
#define LUMP_MARKSURFACES 11
#define LUMP_EDGES 12
#define LUMP_SURFEDGES 13
#define LUMP_MODELS 14 // internal submodels
#define HEADER_LUMPS 15
// version 31
#define LUMP_CLIPNODES2 15 // hull0 goes into LUMP_NODES, hull1 goes into LUMP_CLIPNODES,
#define LUMP_CLIPNODES3 16 // hull2 goes into LUMP_CLIPNODES2, hull3 goes into LUMP_CLIPNODES3
#define HEADER_LUMPS_31 17
#define LUMP_FACES_EXTRADATA 0 // extension of dface_t
#define LUMP_VERTS_EXTRADATA 1 // extension of dvertex_t
#define LUMP_CUBEMAPS 2 // cubemap description
#define EXTRA_LUMPS 8 // g-cont. just for future expansions
// texture flags
#define TEX_SPECIAL BIT( 0 ) // sky or slime, no lightmap or 256 subdivision
// ambient sound types
enum
{
AMBIENT_WATER = 0, // waterfall
AMBIENT_SKY, // wind
AMBIENT_SLIME, // never used in quake
AMBIENT_LAVA, // never used in quake
NUM_AMBIENTS // automatic ambient sounds
};
//
// BSP File Structures
//
typedef struct
{
int fileofs;
int filelen;
} dlump_t;
typedef struct
{
int version;
dlump_t lumps[HEADER_LUMPS];
} dheader_t;
typedef struct
{
int version;
dlump_t lumps[HEADER_LUMPS_31];
} dheader31_t;
typedef struct
{
int id; // must be little endian XASH
int version;
dlump_t lumps[EXTRA_LUMPS];
} dextrahdr_t;
typedef struct
{
vec3_t mins;
vec3_t maxs;
vec3_t origin; // for sounds or lights
int headnode[MAX_MAP_HULLS];
int visleafs; // not including the solid leaf 0
int firstface;
int numfaces;
} dmodel_t;
typedef struct
{
int nummiptex;
int dataofs[4]; // [nummiptex]
} dmiptexlump_t;
typedef struct
{
vec3_t point;
} dvertex_t;
typedef struct
{
vec3_t normal;
float dist;
int type; // PLANE_X - PLANE_ANYZ ?
} dplane_t;
typedef struct
{
int planenum;
short children[2]; // negative numbers are -(leafs + 1), not nodes
short mins[3]; // for sphere culling
short maxs[3];
word firstface;
word numfaces; // counting both sides
} dnode_t;
// leaf 0 is the generic CONTENTS_SOLID leaf, used for all solid areas
// all other leafs need visibility info
typedef struct
{
int contents;
int visofs; // -1 = no visibility info
short mins[3]; // for frustum culling
short maxs[3];
word firstmarksurface;
word nummarksurfaces;
// automatic ambient sounds
byte ambient_level[NUM_AMBIENTS]; // ambient sound level (0 - 255)
} dleaf_t;
typedef struct
{
int planenum;
short children[2]; // negative numbers are contents
} dclipnode_t;
typedef struct
{
float vecs[2][4]; // texmatrix [s/t][xyz offset]
int miptex;
int flags;
} dtexinfo_t;
typedef word dmarkface_t; // leaf marksurfaces indexes
typedef int dsurfedge_t; // map surfedges
// NOTE: that edge 0 is never used, because negative edge nums
// are used for counterclockwise use of the edge in a face
typedef struct
{
word v[2]; // vertex numbers
} dedge_t;
typedef struct
{
word planenum;
short side;
int firstedge; // we must support > 64k edges
short numedges;
short texinfo;
// lighting info
byte styles[LM_STYLES];
int lightofs; // start of [numstyles*surfsize] samples
} dface_t;
#endif//BSPFILE_H

View File

@ -12,12 +12,9 @@
* without written permission from Valve LLC.
*
****/
// cl_entity.h
#if !defined( CL_ENTITYH )
#define CL_ENTITYH
#ifdef _WIN32
#pragma once
#endif
#ifndef CL_ENTITY_H
#define CL_ENTITY_H
typedef struct efrag_s
{
@ -63,19 +60,12 @@ typedef struct cl_entity_s cl_entity_t;
#define HISTORY_MAX 64 // Must be power of 2
#define HISTORY_MASK ( HISTORY_MAX - 1 )
#if !defined( ENTITY_STATEH )
#include "entity_state.h"
#endif
#if !defined( PROGS_H )
#include "progs.h"
#endif
#include "event_args.h"
struct cl_entity_s
{
int index; // Index into cl_entities ( should match actual slot, but not necessarily )
qboolean player; // True if this entity is a "player"
entity_state_t baseline; // The original state from which to delta during an uncompressed message
@ -112,4 +102,4 @@ struct cl_entity_s
colorVec cvFloorColor;
};
#endif // !CL_ENTITYH
#endif//CL_ENTITY_H

View File

@ -1,81 +1,58 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
/*
com_model.h - cient model structures
Copyright (C) 2010 Uncle Mike
// com_model.h
#if !defined( COM_MODEL_H )
#define COM_MODEL_H
#if defined( _WIN32 )
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#pragma once
#endif
#ifndef COM_MODEL_H
#define COM_MODEL_H
#include "bspfile.h" // we need some declarations from it
typedef vec_t vec2_t[2];
typedef vec_t vec4_t[4];
/*
==============================================================================
ENGINE MODEL FORMAT
==============================================================================
*/
#define STUDIO_RENDER 1
#define STUDIO_EVENTS 2
#define MAX_CLIENTS 32
#define MAX_EDICTS 900
#define MAX_MODEL_NAME 64
#define MAX_MAP_HULLS 4
#define MIPLEVELS 4
#define NUM_AMBIENTS 4 // automatic ambient sounds
#define MAXLIGHTMAPS 4
#define PLANE_ANYZ 5
#define ALIAS_Z_CLIP_PLANE 5
// flags in finalvert_t.flags
#define ALIAS_LEFT_CLIP 0x0001
#define ALIAS_TOP_CLIP 0x0002
#define ALIAS_RIGHT_CLIP 0x0004
#define ALIAS_BOTTOM_CLIP 0x0008
#define ALIAS_Z_CLIP 0x0010
#define ALIAS_ONSEAM 0x0020
#define ALIAS_XY_CLIP_MASK 0x000F
#define ZISCALE ((float)0x8000)
#define CACHE_SIZE 32 // used to align key data structures
#define MIPLEVELS 4
#define VERTEXSIZE 7
#define MAXLIGHTMAPS 4
#define NUM_AMBIENTS 4 // automatic ambient sounds
// model types
typedef enum
{
mod_bad = -1,
mod_brush,
mod_sprite,
mod_alias,
mod_studio
} modtype_t;
// must match definition in modelgen.h
#ifndef SYNCTYPE_T
#define SYNCTYPE_T
typedef enum
{
ST_SYNC=0,
ST_RAND
} synctype_t;
#endif
typedef struct
{
float mins[3], maxs[3];
float origin[3];
int headnode[MAX_MAP_HULLS];
int visleafs; // not including the solid leaf 0
int firstface, numfaces;
} dmodel_t;
// plane_t structure
typedef struct mplane_s
{
vec3_t normal; // surface normal
float dist; // closest appoach to origin
byte type; // for texture axis selection and fast side tests
byte signbits; // signx + signy<<1 + signz<<1
vec3_t normal;
float dist;
byte type; // for fast side tests
byte signbits; // signx + (signy<<1) + (signz<<1)
byte pad[2];
} mplane_t;
@ -93,13 +70,16 @@ typedef struct
typedef struct texture_s
{
char name[16];
unsigned width, height;
unsigned int width, height;
int gl_texturenum;
struct msurface_s *texturechain; // for gl_texsort drawing
int anim_total; // total tenths in sequence ( 0 = no)
int anim_min, anim_max; // time for this frame min <=time< max
struct texture_s *anim_next; // in the animation sequence
struct texture_s *alternate_anims; // bmodels in frame 1 use these
unsigned offsets[MIPLEVELS]; // four mip maps stored
unsigned paloffset;
unsigned short fb_texturenum; // auto-luma texturenum
unsigned short dt_texturenum; // detail-texture binding
unsigned int unused[3]; // reserved
} texture_t;
typedef struct
@ -107,19 +87,41 @@ typedef struct
float vecs[2][4]; // [s/t] unit vectors in world space.
// [i][3] is the s/t offset relative to the origin.
// s or t = dot( 3Dpoint, vecs[i] ) + vecs[i][3]
float mipadjust; // ?? mipmap limits for very small surfaces
float mipadjust; // mipmap limits for very small surfaces
texture_t *texture;
int flags; // sky or slime, no lightmap or 256 subdivision
} mtexinfo_t;
// 73 bytes per VBO vertex
// FIXME: align to 32 bytes
typedef struct glvert_s
{
vec3_t vertex; // position
vec3_t normal; // normal
vec2_t stcoord; // ST texture coords
vec2_t lmcoord; // ST lightmap coords
vec2_t sccoord; // ST scissor coords (decals only) - for normalmap coords migration
vec3_t tangent; // tangent
vec3_t binormal; // binormal
byte color[4]; // colors per vertex
} glvert_t;
typedef struct glpoly_s
{
struct glpoly_s *next;
struct glpoly_s *chain;
int numverts;
int flags; // for SURF_UNDERWATER
float verts[4][VERTEXSIZE]; // variable sized (xyz s1t1 s2t2)
} glpoly_t;
typedef struct mnode_s
{
// common with leaf
int contents; // 0, to differentiate from leafs
int visframe; // node needs to be traversed if current
short minmaxs[6]; // for bounding box culling
float minmaxs[6]; // for bounding box culling
struct mnode_s *parent;
// node specific
@ -138,36 +140,40 @@ struct decal_s
{
decal_t *pnext; // linked list for each surface
msurface_t *psurface; // Surface id for persistence / unlinking
short dx; // Offsets into surface texture (in texture coordinates, so we don't need floats)
short dy;
float dx; // local texture coordinates
float dy; //
float scale; // Pixel scale
short texture; // Decal texture
byte scale; // Pixel scale
byte flags; // Decal flags
byte flags; // Decal flags FDECAL_*
short entityIndex; // Entity this is attached to
// Xash3D added
vec3_t position; // location of the decal center in world space.
vec3_t saxis; // direction of the s axis in world space
struct msurfmesh_s *mesh; // decal mesh in local space
int reserved[4]; // for future expansions
};
typedef struct mleaf_s
{
// common with node
int contents; // wil be a negative contents number
int contents;
int visframe; // node needs to be traversed if current
short minmaxs[6]; // for bounding box culling
float minmaxs[6]; // for bounding box culling
struct mnode_s *parent;
// leaf specific
byte *compressed_vis;
struct efrag_s *efrags;
msurface_t **firstmarksurface;
int nummarksurfaces;
int key; // BSP sequence number for leaf's contents
byte *compressed_pas;
byte ambient_sound_level[NUM_AMBIENTS];
} mleaf_t;
struct msurface_s
typedef struct msurface_s
{
int visframe; // should be drawn when node is crossed
@ -181,28 +187,56 @@ struct msurface_s
int firstedge; // look up in model->surfedges[], negative numbers
int numedges; // are backwards edges
// surface generation data
struct surfcache_s *cachespots[MIPLEVELS];
short texturemins[2];
short extents[2];
short texturemins[2]; // smallest s/t position on the surface.
short extents[2]; // ?? s/t texture size, 1..256 for all non-sky surfaces
int light_s, light_t; // gl lightmap coordinates
glpoly_t *polys; // multiple if warped
struct msurface_s *texturechain;
mtexinfo_t *texinfo;
// lighting info
byte styles[MAXLIGHTMAPS]; // index into d_lightstylevalue[] for animated lights
// no one surface can be effected by more than 4
// animated lights.
color24 *samples;
int lightmaptexturenum;
byte styles[MAXLIGHTMAPS];
int cached_light[MAXLIGHTMAPS]; // values currently used in lightmap
struct msurface_s *lightmapchain; // for new dlights rendering (was cached_dlight)
color24 *samples; // note: this is the actual lightmap data for this surface
decal_t *pdecals;
};
} msurface_t;
typedef struct
typedef struct msurfmesh_s
{
int planenum;
short children[2]; // negative numbers are contents
} dclipnode_t;
unsigned short numVerts;
unsigned short numElems; // ~ 20 000 vertex per one surface. Should be enough
unsigned int startVert; // user-variable. may be used for construct world single-VBO
unsigned int startElem; // user-variable. may be used for construct world single-VBO
glvert_t *verts; // vertexes array
unsigned short *elems; // indices
struct msurface_s *surf; // pointer to parent surface. Just for consistency
struct msurfmesh_s *next; // temporary chain of subdivided surfaces
} msurfmesh_t;
// surface extradata stored in cache.data for all brushmodels
typedef struct mextrasurf_s
{
vec3_t mins, maxs;
vec3_t origin; // surface origin
msurfmesh_t *mesh; // VBO\VA ready surface mesh. Not used by engine but can be used by mod-makers
int dlight_s, dlight_t; // gl lightmap coordinates for dynamic lightmaps
int mirrortexturenum; // gl texnum
float mirrormatrix[4][4];
struct mextrasurf_s *mirrorchain; // for gl_texsort drawing
struct mextrasurf_s *detailchain; // for detail textures drawing
color24 *deluxemap; // note: this is the actual deluxemap data for this surface
int reserved[32]; // just for future expansions or mod-makers
} mextrasurf_t;
typedef struct hull_s
{
@ -214,44 +248,43 @@ typedef struct hull_s
vec3_t clip_maxs;
} hull_t;
#if !defined( CACHE_USER ) && !defined( QUAKEDEF_H )
#ifndef CACHE_USER
#define CACHE_USER
typedef struct cache_user_s
{
void *data;
void *data; // extradata
} cache_user_t;
#endif
typedef struct model_s
{
char name[ MAX_MODEL_NAME ];
char name[64]; // model name
qboolean needload; // bmodels and sprites don't cache normally
modtype_t type;
int numframes;
synctype_t synctype;
int flags;
// shared modelinfo
modtype_t type; // model type
int numframes; // sprite's framecount
byte *mempool; // private mempool (was synctype)
int flags; // hl compatibility
//
// volume occupied by the model
//
vec3_t mins, maxs;
vec3_t mins, maxs; // bounding box at angles '0 0 0'
float radius;
//
// brush model
//
int firstmodelsurface, nummodelsurfaces;
int firstmodelsurface;
int nummodelsurfaces;
int numsubmodels;
dmodel_t *submodels;
dmodel_t *submodels; // or studio animations
int numplanes;
mplane_t *planes;
int numleafs; // number of visible leafs, not counting 0
struct mleaf_s *leafs;
mleaf_t *leafs;
int numvertexes;
mvertex_t *vertexes;
@ -285,18 +318,13 @@ typedef struct model_s
byte *visdata;
color24 *lightdata;
char *entities;
//
// additional model data
//
cache_user_t cache; // only access through Mod_Extradata
} model_t;
typedef vec_t vec4_t[4];
typedef struct alight_s
{
int ambientlight; // clip at 128
@ -310,29 +338,23 @@ typedef struct auxvert_s
float fv[3]; // viewspace x, y
} auxvert_t;
#define MAX_SCOREBOARDNAME 32
#define MAX_INFO_STRING 256
#include "custom.h"
#define MAX_INFO_STRING 256
#define MAX_SCOREBOARDNAME 32
typedef struct player_info_s
{
// User id on server
int userid;
// User info string
char userinfo[ MAX_INFO_STRING ];
// Name
char name[ MAX_SCOREBOARDNAME ];
// Spectator or not, unused
int spectator;
int userid; // User id on server
char userinfo[MAX_INFO_STRING]; // User info string
char name[MAX_SCOREBOARDNAME]; // Name (extracted from userinfo)
int spectator; // Spectator or not, unused
int ping;
int packet_loss;
// skin information
char model[MAX_QPATH];
char model[64];
int topcolor;
int bottomcolor;
@ -348,4 +370,43 @@ typedef struct player_info_s
customization_t customdata;
} player_info_t;
#endif // #define COM_MODEL_H
//
// sprite representation in memory
//
typedef enum { SPR_SINGLE = 0, SPR_GROUP, SPR_ANGLED } spriteframetype_t;
typedef struct mspriteframe_s
{
int width;
int height;
float up, down, left, right;
int gl_texturenum;
} mspriteframe_t;
typedef struct
{
int numframes;
float *intervals;
mspriteframe_t *frames[1];
} mspritegroup_t;
typedef struct
{
spriteframetype_t type;
mspriteframe_t *frameptr;
} mspriteframedesc_t;
typedef struct
{
short type;
short texFormat;
int maxwidth;
int maxheight;
int numframes;
int radius;
int facecull;
int synctype;
mspriteframedesc_t frames[1];
} msprite_t;
#endif//COM_MODEL_H

View File

@ -12,11 +12,9 @@
* without written permission from Valve LLC.
*
****/
#if !defined( CON_NPRINTH )
#define CON_NPRINTH
#ifdef _WIN32
#pragma once
#endif
#ifndef CON_NPRINT_H
#define CON_NPRINT_H
typedef struct con_nprint_s
{

View File

@ -12,6 +12,7 @@
* without written permission from Valve LLC.
*
****/
#pragma once
#ifndef CONST_H
#define CONST_H
//
@ -54,10 +55,9 @@
#define FL_KILLME (1<<30) // This entity is marked for death -- This allows the engine to kill ents at the appropriate time
#define FL_DORMANT (1<<31) // Entity is dormant, no updates to client
// Goes into globalvars_t.trace_flags
#define FTRACE_SIMPLEBOX (1<<0) // Traceline with a simple box
#define FTRACE_IGNORE_GLASS (1<<1) // traceline will be ignored entities with rendermode != kRenderNormal
// walkmove modes
#define WALKMOVE_NORMAL 0 // normal walkmove
@ -79,6 +79,7 @@
#define MOVETYPE_BOUNCEMISSILE 11 // bounce w/o gravity
#define MOVETYPE_FOLLOW 12 // track movement of aiment
#define MOVETYPE_PUSHSTEP 13 // BSP model that needs physics/world collisions (uses nearest hull for world collision)
#define MOVETYPE_COMPOUND 14 // glue two entities together (simple movewith)
// edict->solid values
// NOTE: Some movetypes will cause collisions independent of SOLID_NOT/SOLID_TRIGGER when the entity moves
@ -88,6 +89,7 @@
#define SOLID_BBOX 2 // touch on edge, block
#define SOLID_SLIDEBOX 3 // touch on edge, but not an onground
#define SOLID_BSP 4 // bsp clip, touch on edge, block
#define SOLID_CUSTOM 5 // call external callbacks for tracing
// edict->deadflag values
#define DEAD_NO 0 // alive
@ -109,6 +111,19 @@
#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
#define EF_REFLECTONLY (1<<25) // Entity will be drawing only in mirrors
#define EF_NOWATERCSG (1<<26) // Do not remove sides for func_water entity
#define EF_FULLBRIGHT (1<<27) // Just get fullbright
#define EF_NOSHADOW (1<<28) // ignore shadow for this entity
#define EF_MERGE_VISIBILITY (1<<29) // this entity allowed to merge vis (e.g. env_sky or portal camera)
#define EF_REQUEST_PHS (1<<30) // This entity requested phs bitvector instead of pvsbitvector in AddToFullPack calls
// g-cont. one reserved bit here for me
// entity flags
#define EFLAG_SLERP 1 // do studio interpolation of this entity
@ -158,7 +173,8 @@
#define TE_EXPLFLAG_NODLIGHTS 2 // do not render dynamic lights
#define TE_EXPLFLAG_NOSOUND 4 // do not play client explosion sound
#define TE_EXPLFLAG_NOPARTICLES 8 // do not draw particles
#define TE_EXPLFLAG_DRAWALPHA 16 // sprite will be drawn alpha
#define TE_EXPLFLAG_ROTATE 32 // rotate the sprite randomly
#define TE_TAREXPLOSION 4 // Quake1 "tarbaby" explosion with sound
// coord coord coord (position)
@ -313,7 +329,7 @@
// byte (color)
// short (count)
// short (base speed)
// short (ramdon velocity)
// short (random velocity)
#define TE_BEAMHOSE 26 // obsolete
@ -339,7 +355,6 @@
// byte Effect 0 = fade in/fade out
// 1 is flickery credits
// 2 is write out (training room)
// 4 bytes r,g,b,a color1 (text color)
// 4 bytes r,g,b,a color2 (effect color)
// ushort 8.8 fadein time
@ -520,6 +535,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)
@ -560,8 +576,6 @@
// byte ( color ) this is an index into an array of color vectors in the engine. (0 - )
// byte ( length * 10 )
#define MSG_BROADCAST 0 // unreliable to all
#define MSG_ONE 1 // reliable to one (msg_entity)
#define MSG_ALL 2 // reliable to all
@ -580,7 +594,7 @@
#define CONTENTS_SLIME -4
#define CONTENTS_LAVA -5
#define CONTENTS_SKY -6
/* These additional contents constants are defined in bspfile.h
// These additional contents constants are defined in bspfile.h
#define CONTENTS_ORIGIN -7 // removed at csg time
#define CONTENTS_CLIP -8 // changed to contents_solid
#define CONTENTS_CURRENT_0 -9
@ -589,9 +603,8 @@
#define CONTENTS_CURRENT_270 -12
#define CONTENTS_CURRENT_UP -13
#define CONTENTS_CURRENT_DOWN -14
#define CONTENTS_TRANSLUCENT -15
*/
#define CONTENTS_LADDER -16
//LRC- New (long overdue) content types for Spirit
@ -620,6 +633,7 @@
#define CHAN_STATIC 6 // allocate channel from the static area
#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
@ -644,25 +658,35 @@
#define SF_TRAIN_PASSABLE 8 // Train is not solid -- used to make water trains
// buttons
#ifndef IN_BUTTONS_H
#include "in_buttons.h"
#endif
#define IN_ATTACK (1<<0)
#define IN_JUMP (1<<1)
#define IN_DUCK (1<<2)
#define IN_FORWARD (1<<3)
#define IN_BACK (1<<4)
#define IN_USE (1<<5)
#define IN_CANCEL (1<<6)
#define IN_LEFT (1<<7)
#define IN_RIGHT (1<<8)
#define IN_MOVELEFT (1<<9)
#define IN_MOVERIGHT (1<<10)
#define IN_ATTACK2 (1<<11)
#define IN_RUN (1<<12)
#define IN_RELOAD (1<<13)
#define IN_ALT1 (1<<14)
#define IN_SCORE (1<<15) // Used by client.dll for when scoreboard is held down
// Break Model Defines
#define BREAK_TYPEMASK 0x4F
#define BREAK_GLASS 0x01
#define BREAK_METAL 0x02
#define BREAK_FLESH 0x04
#define BREAK_WOOD 0x08
#define BREAK_SMOKE 0x10
#define BREAK_TRANS 0x20
#define BREAK_CONCRETE 0x40
#define BREAK_2 0x80
// Colliding temp entity sounds
#define BOUNCE_GLASS BREAK_GLASS
#define BOUNCE_METAL BREAK_METAL
#define BOUNCE_FLESH BREAK_FLESH
@ -686,6 +710,7 @@ enum
kRenderGlow, // src*a+dest -- No Z buffer checks
kRenderTransAlpha, // src*srca+dest*(1-srca)
kRenderTransAdd, // src*a+dest
kRenderWorldGlow // Same as kRenderGlow but not fixed size in screen space
};
enum
@ -714,9 +739,8 @@ enum
kRenderFxReflection, //LRC - draw a reflection under my feet
};
typedef unsigned int func_t;
typedef unsigned int string_t;
typedef int string_t;
typedef unsigned char byte;
typedef unsigned short word;
@ -778,5 +802,4 @@ typedef struct
int hitgroup; // 0 == generic, non zero is specific body part
} trace_t;
#endif
#endif//CONST_H

View File

@ -12,6 +12,7 @@
* without written permission from Valve LLC.
*
****/
#pragma once
#ifndef CVARDEF_H
#define CVARDEF_H
@ -24,13 +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
#endif//CVARDEF_H

View File

@ -12,11 +12,9 @@
* without written permission from Valve LLC.
*
****/
#if !defined ( DEMO_APIH )
#define DEMO_APIH
#ifdef _WIN32
#pragma once
#endif
#ifndef DEMO_API_H
#define DEMO_API_H
typedef struct demo_api_s
{

View File

@ -12,11 +12,9 @@
* without written permission from Valve LLC.
*
****/
#if !defined ( DLIGHTH )
#define DLIGHTH
#ifdef _WIN32
#pragma once
#endif
#ifndef DLIGHT_H
#define DLIGHT_H
typedef struct dlight_s
{
@ -30,4 +28,4 @@ typedef struct dlight_s
qboolean dark; // subtracts light instead of adding
} dlight_t;
#endif
#endif//DLIGHT_H

View File

@ -12,11 +12,9 @@
* without written permission from Valve LLC.
*
****/
#if !defined( ENTITY_STATEH )
#define ENTITY_STATEH
#ifdef _WIN32
#pragma once
#endif
#ifndef ENTITY_STATE_H
#define ENTITY_STATE_H
// For entityType below
#define ENTITY_NORMAL (1<<0)
@ -49,7 +47,6 @@ struct entity_state_s
short solid;
int effects;
float scale;
byte eflags;
// Render information
@ -138,7 +135,6 @@ typedef struct clientdata_s
float health;
int bInDuck;
int weapons; // remove?
int flTimeStepSound;
@ -159,11 +155,8 @@ typedef struct clientdata_s
float m_flNextAttack;
int tfstate;
int pushmsec;
int deadflag;
char physinfo[MAX_PHYSINFO_STRING];
// For mods
@ -179,6 +172,7 @@ typedef struct clientdata_s
vec3_t vuser2;
vec3_t vuser3;
vec3_t vuser4;
} clientdata_t;
#include "weaponinfo.h"
@ -187,7 +181,7 @@ typedef struct local_state_s
{
entity_state_t playerstate;
clientdata_t client;
weapon_data_t weapondata[ 32 ];
weapon_data_t weapondata[64];
} local_state_t;
#endif // !ENTITY_STATEH
#endif//ENTITY_STATE_H

View File

@ -12,15 +12,14 @@
* without written permission from Valve LLC.
*
****/
// entity_types.h
#if !defined( ENTITY_TYPESH )
#define ENTITY_TYPESH
#pragma once
#ifndef ENTITY_TYPES_H
#define ENTITY_TYPES_H
#define ET_NORMAL 0
#define ET_PLAYER 1
#define ET_TEMPENTITY 2
#define ET_BEAM 3
// BMODEL or SPRITE that was split across BSP nodes
#define ET_FRAGMENTED 4
#define ET_FRAGMENTED 4 // BMODEL or SPRITE that was split across BSP nodes
#endif // !ENTITY_TYPESH
#endif//ENTITY_TYPES_H

View File

@ -12,11 +12,9 @@
* without written permission from Valve LLC.
*
****/
#if !defined ( EVENT_APIH )
#define EVENT_APIH
#ifdef _WIN32
#pragma once
#endif
#ifndef EVENT_API_H
#define EVENT_API_H
#define EVENT_API_VERSION 1
@ -44,8 +42,13 @@ typedef struct event_api_s
const char *( *EV_TraceTexture )( int ground, float *vstart, float *vend );
void ( *EV_StopAllSounds )( int entnum, int entchannel );
void ( *EV_KillEvents )( int entnum, const char *eventname );
// Xash3D extension
unsigned short (*EV_IndexForEvent)( const char *name );
const char *(*EV_EventForIndex)( unsigned short index );
void ( *EV_PlayerTraceExt )( float *start, float *end, int traceFlags, int (*pfnIgnore)( struct physent_s *pe ), struct pmtrace_s *tr );
const char *(*EV_SoundForIndex)( int index );
struct msurface_s *( *EV_TraceSurface )( int ground, float *vstart, float *vend );
} event_api_t;
extern event_api_t eventapi;
#endif
#endif//EVENT_API_H

Some files were not shown because too many files have changed in this diff Show More