From 96b1f4c58e8d8be9c1f743275b3ab562e50111ea Mon Sep 17 00:00:00 2001 From: mittorn Date: Sun, 30 Jul 2017 12:30:47 +0300 Subject: [PATCH 01/25] Fix wrong -std=c99 --- cl_dll/Android.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/cl_dll/Android.mk b/cl_dll/Android.mk index ecbae657..a79b6363 100755 --- a/cl_dll/Android.mk +++ b/cl_dll/Android.mk @@ -13,7 +13,6 @@ LOCAL_MODULE := client #else APP_PLATFORM := android-8 #endif -LOCAL_CONLYFLAGS += -std=c99 include $(XASH3D_CONFIG) From 5aa11a38b3148dd220321a745cbdb3194947f0ba Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Wed, 1 Nov 2017 16:43:29 +0300 Subject: [PATCH 02/25] Give player exhaustible weapons when taking ammo for them from weaponbox --- dlls/weapons.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 80a45284..5e4f8f78 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -1265,6 +1265,18 @@ void CWeaponBox::Kill( void ) UTIL_Remove( this ); } +static const char* IsAmmoForExhaustibleWeapon(const char* ammoName, int& weaponId) +{ + for (int i=0; im_rgpPlayerItems[j]; + while( pPlayerItem ) + { + if (pPlayerItem->m_iId == exhaustibleWeaponId) { + foundWeapon = true; + break; + } + pPlayerItem = pPlayerItem->m_pNext; + } + } + if (!foundWeapon) { + CBasePlayerWeapon* weapon = (CBasePlayerWeapon*)Create(weaponName, pev->origin, pev->angles); + if (weapon) { + weapon->pev->spawnflags |= SF_NORESPAWN; + weapon->m_iDefaultAmmo = 0; + if (pPlayer->AddPlayerItem(weapon)) { + weapon->AttachToPlayer(pPlayer); + } + } + } + } + // there's some ammo of this type. pPlayer->GiveAmmo( m_rgAmmo[i], STRING( m_rgiszAmmo[i] ), MaxAmmoCarry( m_rgiszAmmo[i] ) ); From 7d33351f77d7ac1f843c05a70bae8c9a8eabe8bf Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sat, 18 Nov 2017 14:49:01 +0500 Subject: [PATCH 03/25] Add missing file to build lists. --- dlls/Android.mk | 1 + dlls/CMakeLists.txt | 1 + dlls/Makefile | 1 + 3 files changed, 3 insertions(+) diff --git a/dlls/Android.mk b/dlls/Android.mk index b160c424..1dc79616 100644 --- a/dlls/Android.mk +++ b/dlls/Android.mk @@ -96,6 +96,7 @@ LOCAL_SRC_FILES := agrunt.cpp airtank.cpp \ plane.cpp \ plats.cpp \ player.cpp \ + playermonster.cpp \ python.cpp \ rat.cpp \ roach.cpp \ diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index e0b6a8b3..4e56ab44 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -98,6 +98,7 @@ set (SVDLL_SOURCES plane.cpp plats.cpp player.cpp + playermonster.cpp python.cpp rat.cpp roach.cpp diff --git a/dlls/Makefile b/dlls/Makefile index 9c3a84f2..60aad1b3 100644 --- a/dlls/Makefile +++ b/dlls/Makefile @@ -135,6 +135,7 @@ OBJ = \ $(DLL_OBJDIR)/plane.o \ $(DLL_OBJDIR)/plats.o \ $(DLL_OBJDIR)/player.o \ + $(DLL_OBJDIR)/playermonster.o \^M $(DLL_OBJDIR)/python.o \ $(DLL_OBJDIR)/rat.o \ $(DLL_OBJDIR)/roach.o \ From ad3a2141eb53a42b15dd6a994971900873530c9a Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Sun, 3 Dec 2017 18:52:38 +0300 Subject: [PATCH 04/25] Change __MSC_VER to _MSC_VER to make the client buildable with VS 6 --- engine/cdll_int.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/cdll_int.h b/engine/cdll_int.h index d45bb9d5..20af4b55 100644 --- a/engine/cdll_int.h +++ b/engine/cdll_int.h @@ -93,7 +93,7 @@ typedef struct client_textmessage_s const char *pMessage; } client_textmessage_t; -#if __MSC_VER == 1200 +#if _MSC_VER == 1200 #define ulonglong_t __int64 #else #define ulonglong_t unsigned long long From 31b2a68d6d45bf4682043e9888b2f2b1f4f49df9 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Fri, 18 Nov 2016 01:05:05 +0300 Subject: [PATCH 05/25] goldsource mouse input --- CMakeLists.txt | 3 +- cl_dll/CMakeLists.txt | 42 +- cl_dll/input_goldsource.cpp | 1357 +++++++++++++++++++++++++++++++++++ cl_dll/inputw32.cpp | 901 ----------------------- 4 files changed, 1384 insertions(+), 919 deletions(-) create mode 100644 cl_dll/input_goldsource.cpp delete mode 100644 cl_dll/inputw32.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c2d6822..7719bac6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,6 +31,7 @@ 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 \ @@ -59,4 +60,4 @@ endif() if(NOT BUILD_SERVER AND NOT BUILD_CLIENT) error("Nothing to build") -endif() \ No newline at end of file +endif() diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index 7fffb29b..7bd04f77 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -26,24 +26,27 @@ 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} -lSDL2 -Wl,--no-undefined") +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 +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 + ev_hldm.cpp hl/hl_baseentity.cpp hl/hl_events.cpp hl/hl_objects.cpp @@ -70,7 +73,6 @@ set (CLDLL_SOURCES hud_update.cpp in_camera.cpp input.cpp -#SRCS+=./inputw32.cpp menu.cpp message.cpp overview.cpp @@ -88,9 +90,15 @@ set (CLDLL_SOURCES tri.cpp util.cpp view.cpp - input_xash3d.cpp scoreboard.cpp MOTD.cpp) + +if (GOLDSOURCE_SUPPORT) + set (CLDLL_SOURCES "${CLDLL_SOURCES}" input_goldsource.cpp) +else() + set (CLDLL_SOURCES "${CLDLL_SOURCES}" input_xash3d.cpp) +endif() + include_directories (. hl/ ../dlls ../dlls/wpn_shared ../common ../engine ../pm_shared ../game_shared ../public) if(USE_VOICEMGR) diff --git a/cl_dll/input_goldsource.cpp b/cl_dll/input_goldsource.cpp new file mode 100644 index 00000000..70cd23c5 --- /dev/null +++ b/cl_dll/input_goldsource.cpp @@ -0,0 +1,1357 @@ +//========= 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 "port.h" + +#include "hud.h" +#include "cl_util.h" +#include "camera.h" +#include "kbutton.h" +#include "cvardef.h" +#include "usercmd.h" +#include "const.h" +#include "camera.h" +#include "in_defs.h" +#include "keydefs.h" +#include "view.h" +//#include "Exports.h" + +#ifndef _WIN32 +#define USE_SDL2 +#endif + +#ifdef USE_SDL2 +#include +#include +#endif + +#ifdef _WIN32 +#include +#else +typedef unsigned int DWORD; +#endif + +#define MOUSE_BUTTON_COUNT 5 + +// use IN_SetVisibleMouse to set: +int iVisibleMouse = 0; + +extern cl_enginefunc_t gEngfuncs; + +extern int iMouseInUse; + +extern kbutton_t in_strafe; +extern kbutton_t in_mlook; +extern kbutton_t in_speed; +extern kbutton_t in_jlook; + +extern cvar_t *m_pitch; +extern cvar_t *m_yaw; +extern cvar_t *m_forward; +extern cvar_t *m_side; + +extern cvar_t *lookstrafe; +extern cvar_t *lookspring; +extern cvar_t *cl_pitchdown; +extern cvar_t *cl_pitchup; +extern cvar_t *cl_yawspeed; +extern cvar_t *cl_sidespeed; +extern cvar_t *cl_forwardspeed; +extern cvar_t *cl_pitchspeed; +extern cvar_t *cl_movespeedkey; + +#ifdef _WIN32 +static double s_flRawInputUpdateTime = 0.0f; +static bool m_bRawInput = false; +static bool m_bMouseThread = false; +bool isMouseRelative = false; +#endif + +#ifdef _WIN32 +#include "progdefs.h" +extern globalvars_t *gpGlobals; +#endif + +Vector dead_viewangles(0, 0, 0); + +void V_StopPitchDrift( void ) +{ + +} + +// mouse variables +cvar_t *m_filter; +cvar_t *sensitivity; + +// Custom mouse acceleration (0 disable, 1 to enable, 2 enable with separate yaw/pitch rescale) +static cvar_t *m_customaccel; +//Formula: mousesensitivity = ( rawmousedelta^m_customaccel_exponent ) * m_customaccel_scale + sensitivity +// If mode is 2, then x and y sensitivity are scaled by m_pitch and m_yaw respectively. +// Custom mouse acceleration value. +static cvar_t *m_customaccel_scale; +//Max mouse move scale factor, 0 for no limit +static cvar_t *m_customaccel_max; +//Mouse move is raised to this power before being scaled by scale factor +static cvar_t *m_customaccel_exponent; + +#ifdef _WIN32 +// if threaded mouse is enabled then the time to sleep between polls +static cvar_t *m_mousethread_sleep; +#endif + +int mouse_buttons; +int mouse_oldbuttonstate; +POINT current_pos; +int old_mouse_x, old_mouse_y, mx_accum, my_accum; +float mouse_x, mouse_y; + +static int restore_spi; +static int originalmouseparms[3], newmouseparms[3] = {0, 0, 1}; +static int mouseactive = 0; +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 dwAxisMap[ JOY_MAX_AXES ]; +DWORD dwControlMap[ JOY_MAX_AXES ]; +int pdwRawValue[ JOY_MAX_AXES ]; +DWORD joy_oldbuttonstate, joy_oldpovstate; + +int joy_id; +DWORD joy_numbuttons; + +#ifdef USE_SDL2 +SDL_GameController *s_pJoystick = NULL; +#endif + +// none of these cvars are saved over a session +// this means that advanced controller configuration needs to be executed +// each time. this avoids any problems with getting back to a default usage +// or when changing from one controller to another. this way at least something +// works. +cvar_t *in_joystick; +cvar_t *joy_name; +cvar_t *joy_advanced; +cvar_t *joy_advaxisx; +cvar_t *joy_advaxisy; +cvar_t *joy_advaxisz; +cvar_t *joy_advaxisr; +cvar_t *joy_advaxisu; +cvar_t *joy_advaxisv; +cvar_t *joy_forwardthreshold; +cvar_t *joy_sidethreshold; +cvar_t *joy_pitchthreshold; +cvar_t *joy_yawthreshold; +cvar_t *joy_forwardsensitivity; +cvar_t *joy_sidesensitivity; +cvar_t *joy_pitchsensitivity; +cvar_t *joy_yawsensitivity; +cvar_t *joy_wwhack1; +cvar_t *joy_wwhack2; + +int joy_avail, joy_advancedinit, joy_haspov; + +#ifdef _WIN32 +unsigned int s_hMouseThreadId = 0; +HANDLE s_hMouseThread = 0; +HANDLE s_hMouseQuitEvent = 0; +HANDLE s_hMouseThreadActiveLock = 0; +#endif + +/* +=========== +Force_CenterView_f +=========== +*/ +void Force_CenterView_f (void) +{ + vec3_t viewangles; + + if (!iMouseInUse) + { + gEngfuncs.GetViewAngles( (float *)viewangles ); + viewangles[PITCH] = 0; + gEngfuncs.SetViewAngles( (float *)viewangles ); + } +} + +#ifdef _WIN32 + +LONG mouseThreadActive = 0; +LONG mouseThreadCenterX = 0; +LONG mouseThreadCenterY = 0; +LONG mouseThreadDeltaX = 0; +LONG mouseThreadDeltaY = 0; +LONG mouseThreadSleep = 0; + +bool MouseThread_ActiveLock_Enter( void ) +{ + if(!m_bMouseThread) + return true; + + return WAIT_OBJECT_0 == WaitForSingleObject( s_hMouseThreadActiveLock, INFINITE); +} + +void MouseThread_ActiveLock_Exit( void ) +{ + if(!m_bMouseThread) + return; + + SetEvent( s_hMouseThreadActiveLock ); +} + +unsigned __stdcall MouseThread_Function( void * pArg ) +{ + while ( true ) + { + DWORD sleepVal = (DWORD)InterlockedExchangeAdd(&mouseThreadSleep, 0); + if(0 > sleepVal) sleepVal = 0; + else if(1000 < sleepVal) sleepVal = 1000; + if(WAIT_OBJECT_0 == WaitForSingleObject( s_hMouseQuitEvent, sleepVal)) + { + break; + } + + if( MouseThread_ActiveLock_Enter() ) + { + if ( InterlockedExchangeAdd(&mouseThreadActive, 0) ) + { + POINT mouse_pos; + POINT center_pos; + + center_pos.x = InterlockedExchangeAdd(&mouseThreadCenterX, 0); + center_pos.y = InterlockedExchangeAdd(&mouseThreadCenterY, 0); + GetCursorPos(&mouse_pos); + + mouse_pos.x -= center_pos.x; + mouse_pos.y -= center_pos.y; + + if(mouse_pos.x || mouse_pos.y) SetCursorPos( center_pos.x, center_pos.y ); + + InterlockedExchangeAdd(&mouseThreadDeltaX, mouse_pos.x); + InterlockedExchangeAdd(&mouseThreadDeltaY, mouse_pos.y); + } + + MouseThread_ActiveLock_Exit(); + } + } + + return 0; +} + +/// Updates mouseThreadActive using the global variables mouseactive, iVisibleMouse and m_bRawInput. Should be called after any of these is changed. +/// Has to be interlocked manually by programmer! Use MouseThread_ActiveLock_Enter and MouseThread_ActiveLock_Exit. +void UpdateMouseThreadActive(void) +{ + InterlockedExchange(&mouseThreadActive, mouseactive && !iVisibleMouse && !m_bRawInput); +} + +#endif + +void IN_SetMouseMode(bool enable) +{ + static bool currentMouseMode = false; + + if(enable == currentMouseMode) + return; + + if(enable) + { +#ifdef _WIN32 + if (mouseparmsvalid) + restore_spi = SystemParametersInfo (SPI_SETMOUSE, 0, newmouseparms, 0); + + m_bRawInput = CVAR_GET_FLOAT( "m_rawinput" ) != 0; + if(m_bRawInput) + { +#ifdef USE_SDL2 + SDL_SetRelativeMouseMode(SDL_TRUE); +#endif + isMouseRelative = true; + } +#else + SDL_SetRelativeMouseMode(SDL_TRUE); +#endif + + currentMouseMode = true; + } + else + { +#ifdef _WIN32 + if(isMouseRelative) + { +#ifdef USE_SDL2 + SDL_SetRelativeMouseMode(SDL_FALSE); +#endif + isMouseRelative = false; + } + + if (restore_spi) + SystemParametersInfo (SPI_SETMOUSE, 0, originalmouseparms, 0); +#else + SDL_SetRelativeMouseMode(SDL_FALSE); +#endif + + currentMouseMode = false; + } +} + +void IN_SetVisibleMouse(bool visible) +{ +#ifdef _WIN32 + bool lockEntered = MouseThread_ActiveLock_Enter(); +#endif + + iVisibleMouse = visible; + + IN_SetMouseMode(!visible); + +#ifdef _WIN32 + UpdateMouseThreadActive(); + if(lockEntered) MouseThread_ActiveLock_Exit(); +#endif +} + +void IN_ResetMouse( void ); + +/* +=========== +IN_ActivateMouse +=========== +*/ +extern "C" void DLLEXPORT IN_ActivateMouse (void) +{ + if (mouseinitialized) + { +#ifdef _WIN32 + bool lockEntered = MouseThread_ActiveLock_Enter(); +#endif + + IN_SetMouseMode(true); + + mouseactive = 1; + +#ifdef _WIN32 + UpdateMouseThreadActive(); + if(lockEntered) MouseThread_ActiveLock_Exit(); +#endif + + // now is a good time to reset mouse positon: + IN_ResetMouse(); + } +} + + +/* +=========== +IN_DeactivateMouse +=========== +*/ +extern "C" void DLLEXPORT IN_DeactivateMouse (void) +{ + if (mouseinitialized) + { +#ifdef _WIN32 + bool lockEntered = MouseThread_ActiveLock_Enter(); +#endif + + IN_SetMouseMode(false); + + mouseactive = 0; + +#ifdef _WIN32 + UpdateMouseThreadActive(); + if(lockEntered) MouseThread_ActiveLock_Exit(); +#endif + } +} + +/* +=========== +IN_StartupMouse +=========== +*/ +void IN_StartupMouse (void) +{ + if ( gEngfuncs.CheckParm ("-nomouse", NULL ) ) + return; + + mouseinitialized = 1; +#ifdef _WIN32 + mouseparmsvalid = SystemParametersInfo (SPI_GETMOUSE, 0, originalmouseparms, 0); + + if (mouseparmsvalid) + { + if ( gEngfuncs.CheckParm ("-noforcemspd", NULL ) ) + newmouseparms[2] = originalmouseparms[2]; + + if ( gEngfuncs.CheckParm ("-noforcemaccel", NULL ) ) + { + newmouseparms[0] = originalmouseparms[0]; + newmouseparms[1] = originalmouseparms[1]; + } + + if ( gEngfuncs.CheckParm ("-noforcemparms", NULL ) ) + { + newmouseparms[0] = originalmouseparms[0]; + newmouseparms[1] = originalmouseparms[1]; + newmouseparms[2] = originalmouseparms[2]; + } + } +#endif + + mouse_buttons = MOUSE_BUTTON_COUNT; +} + +/* +=========== +IN_Shutdown +=========== +*/ +void IN_Shutdown (void) +{ + IN_DeactivateMouse (); + +#ifdef _WIN32 + if ( s_hMouseQuitEvent ) + { + SetEvent( s_hMouseQuitEvent ); + } + + if ( s_hMouseThread ) + { + if(WAIT_OBJECT_0 != WaitForSingleObject( s_hMouseThread, 5000 )) + { + TerminateThread( s_hMouseThread, 0 ); + } + CloseHandle( s_hMouseThread ); + s_hMouseThread = (HANDLE)0; + } + + if ( s_hMouseQuitEvent ) + { + CloseHandle( s_hMouseQuitEvent ); + s_hMouseQuitEvent = (HANDLE)0; + } + + if( s_hMouseThreadActiveLock ) + { + CloseHandle( s_hMouseThreadActiveLock ); + s_hMouseThreadActiveLock = (HANDLE)0; + } +#endif +} + +/* +=========== +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 ) +{ + // no work to do in SDL +#ifdef _WIN32 + // reset only if mouse is active and not in visible mode: + if(mouseactive && !iVisibleMouse) + { + if ( !m_bRawInput && gEngfuncs.GetWindowCenterX && gEngfuncs.GetWindowCenterY ) + { + bool lockEntered = MouseThread_ActiveLock_Enter(); + + int centerX = gEngfuncs.GetWindowCenterX(); + int centerY = gEngfuncs.GetWindowCenterY(); + + SetCursorPos ( centerX, centerY ); + InterlockedExchange( &mouseThreadCenterX, centerX ); + InterlockedExchange( &mouseThreadCenterY, centerY ); + InterlockedExchange( &mouseThreadDeltaX, 0 ); + InterlockedExchange( &mouseThreadDeltaY, 0 ); + + if(lockEntered) MouseThread_ActiveLock_Exit(); + } + } +#endif +} + +/* +=========== +IN_MouseEvent +=========== +*/ +extern "C" void DLLEXPORT IN_MouseEvent (int mstate) +{ + int i; + + if ( iMouseInUse || iVisibleMouse ) + return; + + // perform button actions + for (i=0 ; ivalue; + + // Using special accleration values + if ( m_customaccel->value != 0 ) + { + float raw_mouse_movement_distance = sqrt( mx * mx + my * my ); + float acceleration_scale = m_customaccel_scale->value; + float accelerated_sensitivity_max = m_customaccel_max->value; + float accelerated_sensitivity_exponent = m_customaccel_exponent->value; + float accelerated_sensitivity = ( (float)pow( raw_mouse_movement_distance, accelerated_sensitivity_exponent ) * acceleration_scale + mouse_senstivity ); + + if ( accelerated_sensitivity_max > 0.0001f && + accelerated_sensitivity > accelerated_sensitivity_max ) + { + accelerated_sensitivity = accelerated_sensitivity_max; + } + + *x *= accelerated_sensitivity; + *y *= accelerated_sensitivity; + + // Further re-scale by yaw and pitch magnitude if user requests alternate mode 2 + // This means that they will need to up their value for m_customaccel_scale greatly (>40x) since m_pitch/yaw default + // to 0.022 + if ( m_customaccel->value == 2 ) + { + *x *= m_yaw->value; + *y *= m_pitch->value; + } + } + else + { + // Just apply the default + *x *= mouse_senstivity; + *y *= mouse_senstivity; + } +} + +void IN_GetMouseDelta( int *pOutX, int *pOutY) +{ + bool active = mouseactive && !iVisibleMouse; + int mx, my; + + if(active) + { + int deltaX, deltaY; +#ifdef _WIN32 + if ( !m_bRawInput ) + { + if ( m_bMouseThread ) + { + // update mouseThreadSleep: + InterlockedExchange(&mouseThreadSleep, (LONG)m_mousethread_sleep->value); + + bool lockEntered = MouseThread_ActiveLock_Enter(); + + current_pos.x = InterlockedExchange( &mouseThreadDeltaX, 0 ); + current_pos.y = InterlockedExchange( &mouseThreadDeltaY, 0 ); + + if(lockEntered) MouseThread_ActiveLock_Exit(); + } + else + { + GetCursorPos (¤t_pos); + } + } + else +#endif + { +#ifdef USE_SDL2 + SDL_GetRelativeMouseState( &deltaX, &deltaY ); + current_pos.x = deltaX; + current_pos.y = deltaY; +#else + GetCursorPos (¤t_pos); + deltaX = current_pos.x - gEngfuncs.GetWindowCenterX(); + deltaY = current_pos.y - gEngfuncs.GetWindowCenterY(); +#endif + } + +#ifdef _WIN32 + if ( !m_bRawInput ) + { + if ( m_bMouseThread ) + { + mx = current_pos.x; + my = current_pos.y; + } + else + { + mx = current_pos.x - gEngfuncs.GetWindowCenterX() + mx_accum; + my = current_pos.y - gEngfuncs.GetWindowCenterY() + my_accum; + } + } + else +#endif + { + mx = deltaX + mx_accum; + my = deltaY + my_accum; + } + + mx_accum = 0; + my_accum = 0; + + // reset mouse position if required, so there is room to move: +#ifdef _WIN32 + // do not reset if mousethread would do it: + if ( m_bRawInput || !m_bMouseThread ) +#else + if(true) +#endif + IN_ResetMouse(); + +#ifdef _WIN32 + // update m_bRawInput occasionally: + if ( gpGlobals && gpGlobals->time - s_flRawInputUpdateTime > 1.0f ) + { + s_flRawInputUpdateTime = gpGlobals->time; + + bool lockEntered = MouseThread_ActiveLock_Enter(); + + m_bRawInput = CVAR_GET_FLOAT( "m_rawinput" ) != 0; + + if(m_bRawInput && !isMouseRelative) + { +#ifdef USE_SDL2 + SDL_SetRelativeMouseMode(SDL_TRUE); +#endif + isMouseRelative = true; + } + else if(!m_bRawInput && isMouseRelative) + { +#ifdef USE_SDL2 + SDL_SetRelativeMouseMode(SDL_FALSE); +#endif + isMouseRelative = false; + } + + UpdateMouseThreadActive(); + if(lockEntered) MouseThread_ActiveLock_Exit(); + } +#endif + } + else + { + mx = my = 0; + } + + if(pOutX) *pOutX = mx; + if(pOutY) *pOutY = my; +} + +/* +=========== +IN_MouseMove +=========== +*/ +void IN_MouseMove ( float frametime, usercmd_t *cmd) +{ + int mx, my; + vec3_t viewangles; + + gEngfuncs.GetViewAngles( (float *)viewangles ); + + if ( in_mlook.state & 1) + { + V_StopPitchDrift (); + } + + //jjb - this disbles normal mouse control if the user is trying to + // move the camera, or if the mouse cursor is visible or if we're in intermission + if ( !iMouseInUse && !gHUD.m_iIntermission && !iVisibleMouse ) + { + IN_GetMouseDelta( &mx, &my ); + + if (m_filter && m_filter->value) + { + mouse_x = (mx + old_mouse_x) * 0.5; + mouse_y = (my + old_mouse_y) * 0.5; + } + else + { + mouse_x = mx; + mouse_y = my; + } + + old_mouse_x = mx; + old_mouse_y = my; + + // Apply custom mouse scaling/acceleration + IN_ScaleMouse( &mouse_x, &mouse_y ); + + // add mouse X/Y movement to cmd + if ( (in_strafe.state & 1) || (lookstrafe->value && (in_mlook.state & 1) )) + cmd->sidemove += m_side->value * mouse_x; + else + viewangles[YAW] -= m_yaw->value * mouse_x; + + if ( (in_mlook.state & 1) && !(in_strafe.state & 1)) + { + viewangles[PITCH] += m_pitch->value * mouse_y; + if (viewangles[PITCH] > cl_pitchdown->value) + viewangles[PITCH] = cl_pitchdown->value; + if (viewangles[PITCH] < -cl_pitchup->value) + viewangles[PITCH] = -cl_pitchup->value; + } + else + { + if ((in_strafe.state & 1) && gEngfuncs.IsNoClipping() ) + { + cmd->upmove -= m_forward->value * mouse_y; + } + else + { + cmd->forwardmove -= m_forward->value * mouse_y; + } + } + } + + gEngfuncs.SetViewAngles( (float *)viewangles ); + +/* +//#define TRACE_TEST +#if defined( TRACE_TEST ) + { + int mx, my; + void V_Move( int mx, int my ); + IN_GetMousePos( &mx, &my ); + V_Move( mx, my ); + } +#endif +*/ +} + +/* +=========== +IN_Accumulate +=========== +*/ +extern "C" void DLLEXPORT IN_Accumulate (void) +{ + //only accumulate mouse if we are not moving the camera with the mouse + if ( !iMouseInUse && !iVisibleMouse) + { + if (mouseactive) + { +#ifdef _WIN32 + if ( !m_bRawInput ) + { + if ( !m_bMouseThread ) + { + GetCursorPos (¤t_pos); + + mx_accum += current_pos.x - gEngfuncs.GetWindowCenterX(); + my_accum += current_pos.y - gEngfuncs.GetWindowCenterY(); + } + } + else +#endif + { +#ifdef USE_SDL2 + int deltaX, deltaY; + SDL_GetRelativeMouseState( &deltaX, &deltaY ); + mx_accum += deltaX; + my_accum += deltaY; +#else + GetCursorPos (¤t_pos); + + mx_accum += current_pos.x - gEngfuncs.GetWindowCenterX(); + my_accum += current_pos.y - gEngfuncs.GetWindowCenterY(); +#endif + } + + // force the mouse to the center, so there's room to move +#ifdef _WIN32 + // do not reset if mousethread would do it: + if ( m_bRawInput || !m_bMouseThread ) +#else + if(true) +#endif + IN_ResetMouse(); + + } + } + +} + +/* +=================== +IN_ClearStates +=================== +*/ +extern "C" void DLLEXPORT IN_ClearStates (void) +{ + if ( !mouseactive ) + return; + + mx_accum = 0; + my_accum = 0; + mouse_oldbuttonstate = 0; +} + +/* +=============== +IN_StartupJoystick +=============== +*/ +void IN_StartupJoystick (void) +{ + // abort startup if user requests no joystick + if ( gEngfuncs.CheckParm ("-nojoy", NULL ) ) + return; + + // assume no joystick + joy_avail = 0; +#ifdef USE_SDL2 + int nJoysticks = SDL_NumJoysticks(); + if ( nJoysticks > 0 ) + { + for ( int i = 0; i < nJoysticks; i++ ) + { + if ( SDL_IsGameController( i ) ) + { + s_pJoystick = SDL_GameControllerOpen( i ); + if ( s_pJoystick ) + { + //save the joystick's number of buttons and POV status + joy_numbuttons = SDL_CONTROLLER_BUTTON_MAX; + joy_haspov = 0; + + // old button and POV states default to no buttons pressed + joy_oldbuttonstate = joy_oldpovstate = 0; + + // mark the joystick as available and advanced initialization not completed + // this is needed as cvars are not available during initialization + gEngfuncs.Con_Printf ("joystick found\n\n", SDL_GameControllerName(s_pJoystick)); + joy_avail = 1; + joy_advancedinit = 0; + break; + } + } + } + } + else + { + gEngfuncs.Con_DPrintf ("joystick not found -- driver not present\n\n"); + } +#else + gEngfuncs.Con_DPrintf ("joystick not found -- implement joystick without SDL2\n\n"); +#endif +} + +int RawValuePointer (int axis) +{ +#ifdef USE_SDL2 + switch (axis) + { + default: + case JOY_AXIS_X: + return SDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_LEFTX ); + case JOY_AXIS_Y: + return SDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_LEFTY ); + case JOY_AXIS_Z: + return SDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_RIGHTX ); + case JOY_AXIS_R: + return SDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_RIGHTY ); + + } +#else + // TODO: implement joystick without SDL2 + return 0; +#endif +} + +/* +=========== +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; + } +} + + +/* +=========== +IN_Commands +=========== +*/ +void IN_Commands (void) +{ + int i, key_index; + + if (!joy_avail) + { + return; + } + + DWORD buttonstate, povstate; + + // loop through the joystick buttons + // key a joystick event or auxillary event for higher number buttons for each state change + buttonstate = 0; +#ifdef USE_SDL2 + for ( i = 0; i < SDL_CONTROLLER_BUTTON_MAX; i++ ) + { + if ( SDL_GameControllerGetButton( s_pJoystick, (SDL_GameControllerButton)i ) ) + { + buttonstate |= 1<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]; + + 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; + } + V_StopPitchDrift(); + } + else + { + // no pitch movement + // disable pitch return-to-center unless requested by user + // *** this code can be removed when the lookspring bug is fixed + // *** the bug always has the lookspring feature on + if(lookspring->value == 0.0) + { + V_StopPitchDrift(); + } + } + } + else + { + // user wants forward control to be forward control + if (fabs(fAxisValue) > joy_forwardthreshold->value) + { + cmd->forwardmove += (fAxisValue * joy_forwardsensitivity->value) * speed * cl_forwardspeed->value; + } + } + break; + + case AxisSide: + if (fabs(fAxisValue) > joy_sidethreshold->value) + { + cmd->sidemove += (fAxisValue * joy_sidesensitivity->value) * speed * cl_sidespeed->value; + } + break; + + case AxisTurn: + if ((in_strafe.state & 1) || (lookstrafe->value && (in_jlook.state & 1))) + { + // user wants turn control to become side control + if (fabs(fAxisValue) > joy_sidethreshold->value) + { + cmd->sidemove -= (fAxisValue * joy_sidesensitivity->value) * speed * cl_sidespeed->value; + } + } + else + { + // user wants turn control to be turn control + if (fabs(fAxisValue) > joy_yawthreshold->value) + { + if(dwControlMap[i] == JOY_ABSOLUTE_AXIS) + { + viewangles[YAW] += (fAxisValue * joy_yawsensitivity->value) * aspeed * cl_yawspeed->value; + } + else + { + viewangles[YAW] += (fAxisValue * joy_yawsensitivity->value) * speed * 180.0; + } + + } + } + break; + + case AxisLook: + if (in_jlook.state & 1) + { + if (fabs(fAxisValue) > joy_pitchthreshold->value) + { + // pitch movement detected and pitch movement desired by user + if(dwControlMap[i] == JOY_ABSOLUTE_AXIS) + { + viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity->value) * aspeed * cl_pitchspeed->value; + } + else + { + viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity->value) * speed * 180.0; + } + V_StopPitchDrift(); + } + else + { + // no pitch movement + // disable pitch return-to-center unless requested by user + // *** this code can be removed when the lookspring bug is fixed + // *** the bug always has the lookspring feature on + if( lookspring->value == 0.0 ) + { + V_StopPitchDrift(); + } + } + } + break; + + default: + break; + } + } + + // bounds check pitch + if (viewangles[PITCH] > cl_pitchdown->value) + viewangles[PITCH] = cl_pitchdown->value; + if (viewangles[PITCH] < -cl_pitchup->value) + viewangles[PITCH] = -cl_pitchup->value; + + gEngfuncs.SetViewAngles( (float *)viewangles ); +} + +/* +=========== +IN_Move +=========== +*/ +void 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 ); + + m_customaccel = gEngfuncs.pfnRegisterVariable ( "m_customaccel", "0", FCVAR_ARCHIVE ); + m_customaccel_scale = gEngfuncs.pfnRegisterVariable ( "m_customaccel_scale", "0.04", FCVAR_ARCHIVE ); + m_customaccel_max = gEngfuncs.pfnRegisterVariable ( "m_customaccel_max", "0", FCVAR_ARCHIVE ); + m_customaccel_exponent = gEngfuncs.pfnRegisterVariable ( "m_customaccel_exponent", "1", FCVAR_ARCHIVE ); + +#ifdef _WIN32 + m_bRawInput = CVAR_GET_FLOAT( "m_rawinput" ) != 0; + m_bMouseThread = gEngfuncs.CheckParm ("-mousethread", NULL ) != NULL; + m_mousethread_sleep = gEngfuncs.pfnRegisterVariable ( "m_mousethread_sleep", "1", FCVAR_ARCHIVE ); // default to less than 1000 Hz + + m_bMouseThread = m_bMouseThread && NULL != m_mousethread_sleep; + + if (m_bMouseThread) + { + // init mouseThreadSleep: +#if 0 // _beginthreadex is not defined on VS 6? + InterlockedExchange(&mouseThreadSleep, (LONG)m_mousethread_sleep->value); + + s_hMouseQuitEvent = CreateEvent( NULL, FALSE, FALSE, NULL ); + s_hMouseThreadActiveLock = CreateEvent( NULL, FALSE, TRUE, NULL ); + if ( s_hMouseQuitEvent && s_hMouseThreadActiveLock) + { + s_hMouseThread = (HANDLE)_beginthreadex( NULL, 0, MouseThread_Function, NULL, 0, &s_hMouseThreadId ); + } + + m_bMouseThread = NULL != s_hMouseThread; +#else + m_bMouseThread = 0; +#endif + + // at this early stage this won't print anything: + // gEngfuncs.Con_DPrintf ("Mouse thread %s.\n", m_bMouseThread ? "initalized" : "failed to initalize"); + } +#endif + + gEngfuncs.pfnAddCommand ("force_centerview", Force_CenterView_f); + gEngfuncs.pfnAddCommand ("joyadvancedupdate", Joy_AdvancedUpdate_f); + + IN_StartupMouse (); + IN_StartupJoystick (); +} diff --git a/cl_dll/inputw32.cpp b/cl_dll/inputw32.cpp deleted file mode 100644 index 5c8210fa..00000000 --- a/cl_dll/inputw32.cpp +++ /dev/null @@ -1,901 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -// in_win.c -- windows 95 mouse and joystick code -// 02/21/97 JCB Added extended DirectInput code to support external controllers. - -#include "hud.h" -#include "cl_util.h" -#include "camera.h" -#include "kbutton.h" -#include "cvardef.h" -#include "usercmd.h" -#include "const.h" -#include "camera.h" -#include "in_defs.h" -#include "../engine/keydefs.h" -//#include "view.h" -#include "windows.h" - -#define MOUSE_BUTTON_COUNT 5 - -// Set this to 1 to show mouse cursor. Experimental -int g_iVisibleMouse = 0; - -extern "C" -{ - void DLLEXPORT IN_ActivateMouse( void ); - void DLLEXPORT IN_DeactivateMouse( void ); - void DLLEXPORT IN_MouseEvent( int mstate ); - void DLLEXPORT IN_Accumulate( void ); - void DLLEXPORT IN_ClearStates( void ); -} - -extern cl_enginefunc_t gEngfuncs; - -extern int iMouseInUse; - -extern kbutton_t in_strafe; -extern kbutton_t in_mlook; -extern kbutton_t in_speed; -extern kbutton_t in_jlook; - -extern cvar_t *m_pitch; -extern cvar_t *m_yaw; -extern cvar_t *m_forward; -extern cvar_t *m_side; - -extern cvar_t *lookstrafe; -extern cvar_t *lookspring; -extern cvar_t *cl_pitchdown; -extern cvar_t *cl_pitchup; -extern cvar_t *cl_yawspeed; -extern cvar_t *cl_sidespeed; -extern cvar_t *cl_forwardspeed; -extern cvar_t *cl_pitchspeed; -extern cvar_t *cl_movespeedkey; - -// mouse variables -cvar_t *m_filter; -cvar_t *sensitivity; - -int mouse_buttons; -int mouse_oldbuttonstate; -POINT current_pos; -int mouse_x, mouse_y, old_mouse_x, old_mouse_y, mx_accum, my_accum; - -static int restore_spi; -static int originalmouseparms[3], newmouseparms[3] = {0, 0, 1}; -static int mouseactive; -int mouseinitialized; -static int mouseparmsvalid; -static int mouseshowtoggle = 1; - -// joystick defines and variables -// where should defines be moved? -#define JOY_ABSOLUTE_AXIS 0x00000000 // control like a joystick -#define JOY_RELATIVE_AXIS 0x00000010 // control like a mouse, spinner, trackball -#define JOY_MAX_AXES 6 // X, Y, Z, R, U, V -#define JOY_AXIS_X 0 -#define JOY_AXIS_Y 1 -#define JOY_AXIS_Z 2 -#define JOY_AXIS_R 3 -#define JOY_AXIS_U 4 -#define JOY_AXIS_V 5 - -enum _ControlList -{ - AxisNada = 0, - AxisForward, - AxisLook, - AxisSide, - AxisTurn -}; - -DWORD dwAxisFlags[JOY_MAX_AXES] = -{ - JOY_RETURNX, - JOY_RETURNY, - JOY_RETURNZ, - JOY_RETURNR, - JOY_RETURNU, - JOY_RETURNV -}; - -DWORD dwAxisMap[JOY_MAX_AXES]; -DWORD dwControlMap[JOY_MAX_AXES]; -PDWORD pdwRawValue[JOY_MAX_AXES]; - -// none of these cvars are saved over a session -// this means that advanced controller configuration needs to be executed -// each time. this avoids any problems with getting back to a default usage -// or when changing from one controller to another. this way at least something -// works. -cvar_t *in_joystick; -cvar_t *joy_name; -cvar_t *joy_advanced; -cvar_t *joy_advaxisx; -cvar_t *joy_advaxisy; -cvar_t *joy_advaxisz; -cvar_t *joy_advaxisr; -cvar_t *joy_advaxisu; -cvar_t *joy_advaxisv; -cvar_t *joy_forwardthreshold; -cvar_t *joy_sidethreshold; -cvar_t *joy_pitchthreshold; -cvar_t *joy_yawthreshold; -cvar_t *joy_forwardsensitivity; -cvar_t *joy_sidesensitivity; -cvar_t *joy_pitchsensitivity; -cvar_t *joy_yawsensitivity; -cvar_t *joy_wwhack1; -cvar_t *joy_wwhack2; - -int joy_avail, joy_advancedinit, joy_haspov; -DWORD joy_oldbuttonstate, joy_oldpovstate; - -int joy_id; -DWORD joy_flags; -DWORD joy_numbuttons; - -static JOYINFOEX ji; - -/* -=========== -Force_CenterView_f -=========== -*/ -void Force_CenterView_f( void ) -{ - vec3_t viewangles; - - if( !iMouseInUse ) - { - gEngfuncs.GetViewAngles( (float *)viewangles ); - viewangles[PITCH] = 0; - gEngfuncs.SetViewAngles( (float *)viewangles ); - } -} - -/* -=========== -IN_ActivateMouse -=========== -*/ -void DLLEXPORT IN_ActivateMouse( void ) -{ - if( mouseinitialized ) - { - if( mouseparmsvalid ) - restore_spi = SystemParametersInfo( SPI_SETMOUSE, 0, newmouseparms, 0 ); - mouseactive = 1; - } -} - -/* -=========== -IN_DeactivateMouse -=========== -*/ -void DLLEXPORT IN_DeactivateMouse( void ) -{ - if( mouseinitialized ) - { - if( restore_spi ) - SystemParametersInfo( SPI_SETMOUSE, 0, originalmouseparms, 0 ); - mouseactive = 0; - } -} - -/* -=========== -IN_StartupMouse -=========== -*/ -void IN_StartupMouse( void ) -{ - if( gEngfuncs.CheckParm( "-nomouse", NULL ) ) - return; - - mouseinitialized = 1; - mouseparmsvalid = SystemParametersInfo( SPI_GETMOUSE, 0, originalmouseparms, 0 ); - - if( mouseparmsvalid ) - { - if( gEngfuncs.CheckParm( "-noforcemspd", NULL ) ) - newmouseparms[2] = originalmouseparms[2]; - - if( gEngfuncs.CheckParm( "-noforcemaccel", NULL ) ) - { - newmouseparms[0] = originalmouseparms[0]; - newmouseparms[1] = originalmouseparms[1]; - } - - if( gEngfuncs.CheckParm( "-noforcemparms", NULL ) ) - { - newmouseparms[0] = originalmouseparms[0]; - newmouseparms[1] = originalmouseparms[1]; - newmouseparms[2] = originalmouseparms[2]; - } - } - - mouse_buttons = MOUSE_BUTTON_COUNT; -} - -/* -=========== -IN_Shutdown -=========== -*/ -void IN_Shutdown( void ) -{ - IN_DeactivateMouse (); -} - -/* -=========== -IN_GetMousePos - -Ask for mouse position from engine -=========== -*/ -void IN_GetMousePos( int *mx, int *my ) -{ - gEngfuncs.GetMousePosition( mx, my ); -} - -/* -=========== -IN_ResetMouse - -FIXME: Call through to engine? -=========== -*/ -void IN_ResetMouse( void ) -{ - SetCursorPos ( gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY() ); -} - -/* -=========== -IN_MouseEvent -=========== -*/ -void DLLEXPORT IN_MouseEvent( int mstate ) -{ - int i; - - if( iMouseInUse || g_iVisibleMouse ) - return; - - // perform button actions - for( i = 0; i < mouse_buttons; i++ ) - { - if( ( mstate & ( 1 << i ) ) && - !( mouse_oldbuttonstate & ( 1 << i ) ) ) - { - gEngfuncs.Key_Event( K_MOUSE1 + i, 1 ); - } - - if( !( mstate & ( 1 << i ) ) && - ( mouse_oldbuttonstate & ( 1 << i ) ) ) - { - gEngfuncs.Key_Event( K_MOUSE1 + i, 0 ); - } - } - - mouse_oldbuttonstate = mstate; -} - -/* -=========== -IN_MouseMove -=========== -*/ -void IN_MouseMove( float frametime, usercmd_t *cmd ) -{ - int mx, my; - vec3_t viewangles; - - gEngfuncs.GetViewAngles( (float *)viewangles ); - - //jjb - this disbles normal mouse control if the user is trying to - // move the camera, or if the mouse cursor is visible or if we're in intermission - if( !iMouseInUse && !g_iVisibleMouse && !gHUD.m_iIntermission ) - { - GetCursorPos( ¤t_pos ); - - mx = current_pos.x - gEngfuncs.GetWindowCenterX() + mx_accum; - my = current_pos.y - gEngfuncs.GetWindowCenterY() + my_accum; - - mx_accum = 0; - my_accum = 0; - - if( m_filter->value ) - { - mouse_x = ( mx + old_mouse_x ) * 0.5; - mouse_y = ( my + old_mouse_y ) * 0.5; - } - else - { - mouse_x = mx; - mouse_y = my; - } - - old_mouse_x = mx; - old_mouse_y = my; - - if( gHUD.GetSensitivity() != 0 ) - { - mouse_x *= gHUD.GetSensitivity(); - mouse_y *= gHUD.GetSensitivity(); - } - else - { - mouse_x *= sensitivity->value; - mouse_y *= sensitivity->value; - } - - // add mouse X/Y movement to cmd - if( ( in_strafe.state & 1 ) || ( lookstrafe->value && ( in_mlook.state & 1 ) ) ) - cmd->sidemove += m_side->value * mouse_x; - else - viewangles[YAW] -= m_yaw->value * mouse_x; - - if( ( in_mlook.state & 1 ) && !( in_strafe.state & 1 ) ) - { - viewangles[PITCH] += m_pitch->value * mouse_y; - if( viewangles[PITCH] > cl_pitchdown->value ) - viewangles[PITCH] = cl_pitchdown->value; - if( viewangles[PITCH] < -cl_pitchup->value ) - viewangles[PITCH] = -cl_pitchup->value; - } - else - { - if( ( in_strafe.state & 1 ) && gEngfuncs.IsNoClipping() ) - { - cmd->upmove -= m_forward->value * mouse_y; - } - else - { - cmd->forwardmove -= m_forward->value * mouse_y; - } - } - - // if the mouse has moved, force it to the center, so there's room to move - if( mx || my ) - { - IN_ResetMouse(); - } - } - - gEngfuncs.SetViewAngles( (float *)viewangles ); - -/* -//#define TRACE_TEST -#if defined( TRACE_TEST ) - { - int mx, my; - void V_Move( int mx, int my ); - IN_GetMousePos( &mx, &my ); - V_Move( mx, my ); - } -#endif -*/ -} - -/* -=========== -IN_Accumulate -=========== -*/ -void DLLEXPORT IN_Accumulate( void ) -{ - //only accumulate mouse if we are not moving the camera with the mouse - if( !iMouseInUse && !g_iVisibleMouse ) - { - if( mouseactive ) - { - GetCursorPos( ¤t_pos ); - - mx_accum += current_pos.x - gEngfuncs.GetWindowCenterX(); - my_accum += current_pos.y - gEngfuncs.GetWindowCenterY(); - - // force the mouse to the center, so there's room to move - IN_ResetMouse(); - } - } -} - -/* -=================== -IN_ClearStates -=================== -*/ -void DLLEXPORT IN_ClearStates( void ) -{ - if( !mouseactive ) - return; - - mx_accum = 0; - my_accum = 0; - mouse_oldbuttonstate = 0; -} - -/* -=============== -IN_StartupJoystick -=============== -*/ -void IN_StartupJoystick( void ) -{ - int numdevs; - JOYCAPS jc; - MMRESULT mmr; - - // assume no joystick - joy_avail = 0; - - // abort startup if user requests no joystick - if( gEngfuncs.CheckParm( "-nojoy", NULL ) ) - return; - - // verify joystick driver is present - if( ( numdevs = joyGetNumDevs() ) == 0 ) - { - gEngfuncs.Con_DPrintf( "joystick not found -- driver not present\n\n" ); - return; - } - - // cycle through the joystick ids for the first valid one - for( joy_id = 0; joy_id < numdevs; joy_id++ ) - { - memset( &ji, 0, sizeof(ji) ); - ji.dwSize = sizeof(ji); - ji.dwFlags = JOY_RETURNCENTERED; - - if( ( mmr = joyGetPosEx( joy_id, &ji ) ) == JOYERR_NOERROR ) - break; - } - - // abort startup if we didn't find a valid joystick - if( mmr != JOYERR_NOERROR ) - { - gEngfuncs.Con_DPrintf( "joystick not found -- no valid joysticks (%x)\n\n", mmr ); - return; - } - - // get the capabilities of the selected joystick - // abort startup if command fails - memset( &jc, 0, sizeof(jc) ); - if( ( mmr = joyGetDevCaps( joy_id, &jc, sizeof(jc) ) ) != JOYERR_NOERROR ) - { - gEngfuncs.Con_DPrintf( "joystick not found -- invalid joystick capabilities (%x)\n\n", mmr ); - return; - } - - // save the joystick's number of buttons and POV status - joy_numbuttons = jc.wNumButtons; - joy_haspov = jc.wCaps & JOYCAPS_HASPOV; - - // old button and POV states default to no buttons pressed - joy_oldbuttonstate = joy_oldpovstate = 0; - - // mark the joystick as available and advanced initialization not completed - // this is needed as cvars are not available during initialization - gEngfuncs.Con_Printf( "joystick found\n\n", mmr ); - joy_avail = 1; - joy_advancedinit = 0; -} - -/* -=========== -RawValuePointer -=========== -*/ -PDWORD RawValuePointer( int axis ) -{ - switch( axis ) - { - case JOY_AXIS_X: - return &ji.dwXpos; - case JOY_AXIS_Y: - return &ji.dwYpos; - case JOY_AXIS_Z: - return &ji.dwZpos; - case JOY_AXIS_R: - return &ji.dwRpos; - case JOY_AXIS_U: - return &ji.dwUpos; - case JOY_AXIS_V: - return &ji.dwVpos; - } - // FIX: need to do some kind of error - return &ji.dwXpos; -} - -/* -=========== -Joy_AdvancedUpdate_f -=========== -*/ -void Joy_AdvancedUpdate_f( void ) -{ - // called once by IN_ReadJoystick and by user whenever an update is needed - // cvars are now available - int i; - DWORD dwTemp; - - // initialize all the maps - for( i = 0; i < JOY_MAX_AXES; i++ ) - { - dwAxisMap[i] = AxisNada; - dwControlMap[i] = JOY_ABSOLUTE_AXIS; - pdwRawValue[i] = RawValuePointer(i); - } - - if( joy_advanced->value == 0.0 ) - { - // default joystick initialization - // 2 axes only with joystick control - dwAxisMap[JOY_AXIS_X] = AxisTurn; - // dwControlMap[JOY_AXIS_X] = JOY_ABSOLUTE_AXIS; - dwAxisMap[JOY_AXIS_Y] = AxisForward; - // dwControlMap[JOY_AXIS_Y] = JOY_ABSOLUTE_AXIS; - } - else - { - if( strcmp( joy_name->string, "joystick" ) != 0 ) - { - // notify user of advanced controller - gEngfuncs.Con_Printf( "\n%s configured\n\n", joy_name->string ); - } - - // advanced initialization here - // data supplied by user via joy_axisn cvars - dwTemp = (DWORD)joy_advaxisx->value; - dwAxisMap[JOY_AXIS_X] = dwTemp & 0x0000000f; - dwControlMap[JOY_AXIS_X] = dwTemp & JOY_RELATIVE_AXIS; - dwTemp = (DWORD)joy_advaxisy->value; - dwAxisMap[JOY_AXIS_Y] = dwTemp & 0x0000000f; - dwControlMap[JOY_AXIS_Y] = dwTemp & JOY_RELATIVE_AXIS; - dwTemp = (DWORD)joy_advaxisz->value; - dwAxisMap[JOY_AXIS_Z] = dwTemp & 0x0000000f; - dwControlMap[JOY_AXIS_Z] = dwTemp & JOY_RELATIVE_AXIS; - dwTemp = (DWORD)joy_advaxisr->value; - dwAxisMap[JOY_AXIS_R] = dwTemp & 0x0000000f; - dwControlMap[JOY_AXIS_R] = dwTemp & JOY_RELATIVE_AXIS; - dwTemp = (DWORD)joy_advaxisu->value; - dwAxisMap[JOY_AXIS_U] = dwTemp & 0x0000000f; - dwControlMap[JOY_AXIS_U] = dwTemp & JOY_RELATIVE_AXIS; - dwTemp = (DWORD)joy_advaxisv->value; - dwAxisMap[JOY_AXIS_V] = dwTemp & 0x0000000f; - dwControlMap[JOY_AXIS_V] = dwTemp & JOY_RELATIVE_AXIS; - } - - // compute the axes to collect from DirectInput - joy_flags = JOY_RETURNCENTERED | JOY_RETURNBUTTONS | JOY_RETURNPOV; - for( i = 0; i < JOY_MAX_AXES; i++ ) - { - if( dwAxisMap[i] != AxisNada ) - { - joy_flags |= dwAxisFlags[i]; - } - } -} - -/* -=========== -IN_Commands -=========== -*/ -void IN_Commands( void ) -{ - int i, key_index; - DWORD buttonstate, povstate; - - if( !joy_avail ) - { - return; - } - - // loop through the joystick buttons - // key a joystick event or auxillary event for higher number buttons for each state change - buttonstate = ji.dwButtons; - for( i = 0; i < (int)joy_numbuttons; i++ ) - { - if( ( buttonstate & ( 1 << i ) ) && !( joy_oldbuttonstate & ( 1 << i ) ) ) - { - key_index = ( i < 4 ) ? K_JOY1 : K_AUX1; - gEngfuncs.Key_Event( key_index + i, 1 ); - } - - if( !( buttonstate & ( 1 << i ) ) && ( joy_oldbuttonstate & ( 1 << i ) ) ) - { - key_index = ( i < 4 ) ? K_JOY1 : K_AUX1; - gEngfuncs.Key_Event( key_index + i, 0 ); - } - } - joy_oldbuttonstate = buttonstate; - - if( joy_haspov ) - { - // convert POV information into 4 bits of state information - // this avoids any potential problems related to moving from one - // direction to another without going through the center position - povstate = 0; - if( ji.dwPOV != JOY_POVCENTERED ) - { - if( ji.dwPOV == JOY_POVFORWARD ) - povstate |= 0x01; - if( ji.dwPOV == JOY_POVRIGHT ) - povstate |= 0x02; - if( ji.dwPOV == JOY_POVBACKWARD ) - povstate |= 0x04; - if( ji.dwPOV == JOY_POVLEFT ) - povstate |= 0x08; - } - // determine which bits have changed and key an auxillary event for each change - for( i = 0; i < 4; i++ ) - { - if( ( povstate & ( 1 << i ) ) && !( joy_oldpovstate & ( 1 << i ) ) ) - { - gEngfuncs.Key_Event( K_AUX29 + i, 1 ); - } - - if( !( povstate & ( 1 << i ) ) && ( joy_oldpovstate & ( 1 << i ) ) ) - { - gEngfuncs.Key_Event( K_AUX29 + i, 0 ); - } - } - joy_oldpovstate = povstate; - } -} - -/* -=============== -IN_ReadJoystick -=============== -*/ -int IN_ReadJoystick( void ) -{ - memset( &ji, 0, sizeof(ji) ); - ji.dwSize = sizeof(ji); - ji.dwFlags = joy_flags; - - if( joyGetPosEx( joy_id, &ji ) == JOYERR_NOERROR ) - { - // this is a hack -- there is a bug in the Logitech WingMan Warrior DirectInput Driver - // rather than having 32768 be the zero point, they have the zero point at 32668 - // go figure -- anyway, now we get the full resolution out of the device - if( joy_wwhack1->value != 0.0 ) - { - ji.dwUpos += 100; - } - return 1; - } - else - { - // read error occurred - // turning off the joystick seems too harsh for 1 read error,\ - // but what should be done? - // Con_Printf( "IN_ReadJoystick: no response\n" ); - // joy_avail = 0; - return 0; - } -} - -/* -=========== -IN_JoyMove -=========== -*/ -void IN_JoyMove( float frametime, usercmd_t *cmd ) -{ - float speed, aspeed; - float fAxisValue, fTemp; - int i; - vec3_t viewangles; - - gEngfuncs.GetViewAngles( (float *)viewangles ); - - // complete initialization if first time in - // this is needed as cvars are not available at initialization time - if( joy_advancedinit != 1 ) - { - Joy_AdvancedUpdate_f(); - joy_advancedinit = 1; - } - - // verify joystick is available and that the user wants to use it - if( !joy_avail || !in_joystick->value ) - { - return; - } - - // collect the joystick data, if possible - if( IN_ReadJoystick () != 1 ) - { - return; - } - - if( in_speed.state & 1 ) - speed = cl_movespeedkey->value; - else - speed = 1; - - aspeed = speed * frametime; - - // loop through the axes - for( i = 0; i < JOY_MAX_AXES; i++ ) - { - // get the floating point zero-centered, potentially-inverted data for the current axis - fAxisValue = (float) *pdwRawValue[i]; - // move centerpoint to zero - fAxisValue -= 32768.0; - - if( joy_wwhack2->value != 0.0 ) - { - if( dwAxisMap[i] == AxisTurn ) - { - // this is a special formula for the Logitech WingMan Warrior - // y=ax^b; where a = 300 and b = 1.3 - // also x values are in increments of 800 (so this is factored out) - // then bounds check result to level out excessively high spin rates - fTemp = 300.0 * pow( abs( fAxisValue ) / 800.0, 1.3 ); - if( fTemp > 14000.0 ) - fTemp = 14000.0; - // restore direction information - fAxisValue = ( fAxisValue > 0.0 ) ? fTemp : -fTemp; - } - } - - // convert range from -32768..32767 to -1..1 - fAxisValue /= 32768.0; - - switch( dwAxisMap[i] ) - { - case AxisForward: - if( ( joy_advanced->value == 0.0 ) && ( in_jlook.state & 1 ) ) - { - // user wants forward control to become look control - if( fabs( fAxisValue ) > joy_pitchthreshold->value ) - { - // if mouse invert is on, invert the joystick pitch value - // only absolute control support here (joy_advanced is 0) - if( m_pitch->value < 0.0 ) - { - viewangles[PITCH] -= ( fAxisValue * joy_pitchsensitivity->value ) * aspeed * cl_pitchspeed->value; - } - else - { - viewangles[PITCH] += ( fAxisValue * joy_pitchsensitivity->value ) * aspeed * cl_pitchspeed->value; - } - } - } - else - { - // user wants forward control to be forward control - if( fabs( fAxisValue ) > joy_forwardthreshold->value ) - { - cmd->forwardmove += ( fAxisValue * joy_forwardsensitivity->value ) * speed * cl_forwardspeed->value; - } - } - break; - case AxisSide: - if( fabs( fAxisValue ) > joy_sidethreshold->value ) - { - cmd->sidemove += ( fAxisValue * joy_sidesensitivity->value ) * speed * cl_sidespeed->value; - } - break; - case AxisTurn: - if( ( in_strafe.state & 1 ) || ( lookstrafe->value && ( in_jlook.state & 1 ) ) ) - { - // user wants turn control to become side control - if( fabs( fAxisValue ) > joy_sidethreshold->value ) - { - cmd->sidemove -= ( fAxisValue * joy_sidesensitivity->value ) * speed * cl_sidespeed->value; - } - } - else - { - // user wants turn control to be turn control - if( fabs( fAxisValue ) > joy_yawthreshold->value ) - { - if( dwControlMap[i] == JOY_ABSOLUTE_AXIS ) - { - viewangles[YAW] += ( fAxisValue * joy_yawsensitivity->value ) * aspeed * cl_yawspeed->value; - } - else - { - viewangles[YAW] += ( fAxisValue * joy_yawsensitivity->value ) * speed * 180.0; - } - } - } - break; - case AxisLook: - if( in_jlook.state & 1 ) - { - if( fabs( fAxisValue ) > joy_pitchthreshold->value ) - { - // pitch movement detected and pitch movement desired by user - if( dwControlMap[i] == JOY_ABSOLUTE_AXIS ) - { - viewangles[PITCH] += ( fAxisValue * joy_pitchsensitivity->value ) * aspeed * cl_pitchspeed->value; - } - else - { - viewangles[PITCH] += ( fAxisValue * joy_pitchsensitivity->value ) * speed * 180.0; - } - } - } - break; - default: - break; - } - } - - // bounds check pitch - if( viewangles[PITCH] > cl_pitchdown->value ) - viewangles[PITCH] = cl_pitchdown->value; - if( viewangles[PITCH] < -cl_pitchup->value ) - viewangles[PITCH] = -cl_pitchup->value; - - gEngfuncs.SetViewAngles( (float *)viewangles ); -} - -/* -=========== -IN_Move -=========== -*/ -void IN_Move( float frametime, usercmd_t *cmd ) -{ - if( !iMouseInUse && mouseactive ) - { - IN_MouseMove( frametime, cmd ); - } - - IN_JoyMove( frametime, cmd ); -} - -/* -=========== -IN_Init -=========== -*/ -void IN_Init( void ) -{ - m_filter = gEngfuncs.pfnRegisterVariable( "m_filter","0", FCVAR_ARCHIVE ); - sensitivity = gEngfuncs.pfnRegisterVariable( "sensitivity","3", FCVAR_ARCHIVE ); // user mouse sensitivity setting. - - in_joystick = gEngfuncs.pfnRegisterVariable( "joystick","0", FCVAR_ARCHIVE ); - joy_name = gEngfuncs.pfnRegisterVariable( "joyname", "joystick", 0 ); - joy_advanced = gEngfuncs.pfnRegisterVariable( "joyadvanced", "0", 0 ); - joy_advaxisx = gEngfuncs.pfnRegisterVariable( "joyadvaxisx", "0", 0 ); - joy_advaxisy = gEngfuncs.pfnRegisterVariable( "joyadvaxisy", "0", 0 ); - joy_advaxisz = gEngfuncs.pfnRegisterVariable( "joyadvaxisz", "0", 0 ); - joy_advaxisr = gEngfuncs.pfnRegisterVariable( "joyadvaxisr", "0", 0 ); - joy_advaxisu = gEngfuncs.pfnRegisterVariable( "joyadvaxisu", "0", 0 ); - joy_advaxisv = gEngfuncs.pfnRegisterVariable( "joyadvaxisv", "0", 0 ); - joy_forwardthreshold = gEngfuncs.pfnRegisterVariable( "joyforwardthreshold", "0.15", 0 ); - joy_sidethreshold = gEngfuncs.pfnRegisterVariable( "joysidethreshold", "0.15", 0 ); - joy_pitchthreshold = gEngfuncs.pfnRegisterVariable( "joypitchthreshold", "0.15", 0 ); - joy_yawthreshold = gEngfuncs.pfnRegisterVariable( "joyyawthreshold", "0.15", 0 ); - joy_forwardsensitivity = gEngfuncs.pfnRegisterVariable( "joyforwardsensitivity", "-1.0", 0 ); - joy_sidesensitivity = gEngfuncs.pfnRegisterVariable( "joysidesensitivity", "-1.0", 0 ); - joy_pitchsensitivity = gEngfuncs.pfnRegisterVariable( "joypitchsensitivity", "1.0", 0 ); - joy_yawsensitivity = gEngfuncs.pfnRegisterVariable( "joyyawsensitivity", "-1.0", 0 ); - joy_wwhack1 = gEngfuncs.pfnRegisterVariable( "joywwhack1", "0.0", 0 ); - joy_wwhack2 = gEngfuncs.pfnRegisterVariable( "joywwhack2", "0.0", 0 ); - - gEngfuncs.pfnAddCommand ("force_centerview", Force_CenterView_f); - gEngfuncs.pfnAddCommand ("joyadvancedupdate", Joy_AdvancedUpdate_f); - - IN_StartupMouse (); - IN_StartupJoystick (); -} From 1d8d1b5d2e7d804e41c844642bb541cc17be4001 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Sun, 3 Dec 2017 23:52:35 +0300 Subject: [PATCH 06/25] Use mouse input backend depending on the current engine --- cl_dll/CMakeLists.txt | 11 ++--- cl_dll/cl_dll.h | 3 ++ cl_dll/hud.h | 4 +- cl_dll/input_goldsource.cpp | 43 +++++++++---------- cl_dll/input_mouse.cpp | 82 +++++++++++++++++++++++++++++++++++++ cl_dll/input_mouse.h | 77 ++++++++++++++++++++++++++++++++++ cl_dll/input_xash3d.cpp | 41 +++++++------------ 7 files changed, 204 insertions(+), 57 deletions(-) create mode 100644 cl_dll/input_mouse.cpp create mode 100644 cl_dll/input_mouse.h diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index 7bd04f77..776f9bd9 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -27,7 +27,7 @@ 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} -lSDL2 -Wl,--no-undefined") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGOLDSOURCE_SUPPORT -lSDL2 -Wl,--no-undefined") endif() set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") @@ -73,6 +73,9 @@ set (CLDLL_SOURCES hud_update.cpp in_camera.cpp input.cpp + input_goldsource.cpp + input_mouse.cpp + input_xash3d.cpp menu.cpp message.cpp overview.cpp @@ -93,12 +96,6 @@ set (CLDLL_SOURCES scoreboard.cpp MOTD.cpp) -if (GOLDSOURCE_SUPPORT) - set (CLDLL_SOURCES "${CLDLL_SOURCES}" input_goldsource.cpp) -else() - set (CLDLL_SOURCES "${CLDLL_SOURCES}" input_xash3d.cpp) -endif() - include_directories (. hl/ ../dlls ../dlls/wpn_shared ../common ../engine ../pm_shared ../game_shared ../public) if(USE_VOICEMGR) diff --git a/cl_dll/cl_dll.h b/cl_dll/cl_dll.h index 24d1874b..0acd6860 100644 --- a/cl_dll/cl_dll.h +++ b/cl_dll/cl_dll.h @@ -25,6 +25,8 @@ // - Drawing the HUD graphics every frame // - Handling the custum HUD-update packets // +#ifndef CL_DLL_H +#define CL_DLL_H typedef unsigned char byte; typedef unsigned short word; typedef float vec_t; @@ -48,3 +50,4 @@ typedef int ( *pfnUserMsgHook )( const char *pszName, int iSize, void *pbuf ); extern cl_enginefunc_t gEngfuncs; #include "../engine/mobility_int.h" extern mobile_engfuncs_t *gMobileEngfuncs; +#endif diff --git a/cl_dll/hud.h b/cl_dll/hud.h index ab179bbb..1970753d 100644 --- a/cl_dll/hud.h +++ b/cl_dll/hud.h @@ -19,7 +19,8 @@ // // CHud handles the message, calculation, and drawing the HUD // - +#ifndef HUD_H +#define HUD_H #define RGB_YELLOWISH 0x00FFA000 //255,160,0 #define RGB_REDISH 0x00FF1010 //255,160,0 #define RGB_GREENISH 0x0000A000 //0,160,0 @@ -677,3 +678,4 @@ extern int g_iTeamNumber; extern int g_iUser1; extern int g_iUser2; extern int g_iUser3; +#endif diff --git a/cl_dll/input_goldsource.cpp b/cl_dll/input_goldsource.cpp index 70cd23c5..5c2b0381 100644 --- a/cl_dll/input_goldsource.cpp +++ b/cl_dll/input_goldsource.cpp @@ -8,20 +8,20 @@ // in_win.c -- windows 95 mouse and joystick code // 02/21/97 JCB Added extended DirectInput code to support external controllers. -//#include "port.h" +#include "input_mouse.h" + +#ifdef SUPPORT_GOLDSOURCE_INPUT #include "hud.h" #include "cl_util.h" #include "camera.h" #include "kbutton.h" #include "cvardef.h" -#include "usercmd.h" #include "const.h" #include "camera.h" #include "in_defs.h" #include "keydefs.h" #include "view.h" -//#include "Exports.h" #ifndef _WIN32 #define USE_SDL2 @@ -79,7 +79,7 @@ bool isMouseRelative = false; extern globalvars_t *gpGlobals; #endif -Vector dead_viewangles(0, 0, 0); +extern Vector dead_viewangles; void V_StopPitchDrift( void ) { @@ -88,7 +88,7 @@ void V_StopPitchDrift( void ) // mouse variables cvar_t *m_filter; -cvar_t *sensitivity; +extern cvar_t *sensitivity; // Custom mouse acceleration (0 disable, 1 to enable, 2 enable with separate yaw/pitch rescale) static cvar_t *m_customaccel; @@ -106,16 +106,11 @@ static cvar_t *m_customaccel_exponent; static cvar_t *m_mousethread_sleep; #endif -int mouse_buttons; -int mouse_oldbuttonstate; -POINT current_pos; -int old_mouse_x, old_mouse_y, mx_accum, my_accum; float mouse_x, mouse_y; static int restore_spi; static int originalmouseparms[3], newmouseparms[3] = {0, 0, 1}; static int mouseactive = 0; -int mouseinitialized; static int mouseparmsvalid; static int mouseshowtoggle = 1; @@ -158,7 +153,7 @@ SDL_GameController *s_pJoystick = NULL; // 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; +extern cvar_t *in_joystick; cvar_t *joy_name; cvar_t *joy_advanced; cvar_t *joy_advaxisx; @@ -348,7 +343,7 @@ void IN_ResetMouse( void ); IN_ActivateMouse =========== */ -extern "C" void DLLEXPORT IN_ActivateMouse (void) +void GoldSourceInput::IN_ActivateMouse (void) { if (mouseinitialized) { @@ -376,7 +371,7 @@ extern "C" void DLLEXPORT IN_ActivateMouse (void) IN_DeactivateMouse =========== */ -extern "C" void DLLEXPORT IN_DeactivateMouse (void) +void GoldSourceInput::IN_DeactivateMouse (void) { if (mouseinitialized) { @@ -400,7 +395,7 @@ extern "C" void DLLEXPORT IN_DeactivateMouse (void) IN_StartupMouse =========== */ -void IN_StartupMouse (void) +void GoldSourceInput::IN_StartupMouse (void) { if ( gEngfuncs.CheckParm ("-nomouse", NULL ) ) return; @@ -437,7 +432,7 @@ void IN_StartupMouse (void) IN_Shutdown =========== */ -void IN_Shutdown (void) +void GoldSourceInput::IN_Shutdown (void) { IN_DeactivateMouse (); @@ -521,7 +516,7 @@ void IN_ResetMouse( void ) IN_MouseEvent =========== */ -extern "C" void DLLEXPORT IN_MouseEvent (int mstate) +void GoldSourceInput::IN_MouseEvent (int mstate) { int i; @@ -596,7 +591,7 @@ void IN_ScaleMouse( float *x, float *y ) } } -void IN_GetMouseDelta( int *pOutX, int *pOutY) +void GoldSourceInput::IN_GetMouseDelta( int *pOutX, int *pOutY) { bool active = mouseactive && !iVisibleMouse; int mx, my; @@ -715,7 +710,7 @@ void IN_GetMouseDelta( int *pOutX, int *pOutY) IN_MouseMove =========== */ -void IN_MouseMove ( float frametime, usercmd_t *cmd) +void GoldSourceInput::IN_MouseMove ( float frametime, usercmd_t *cmd) { int mx, my; vec3_t viewangles; @@ -797,7 +792,7 @@ void IN_MouseMove ( float frametime, usercmd_t *cmd) IN_Accumulate =========== */ -extern "C" void DLLEXPORT IN_Accumulate (void) +void GoldSourceInput::IN_Accumulate (void) { //only accumulate mouse if we are not moving the camera with the mouse if ( !iMouseInUse && !iVisibleMouse) @@ -850,7 +845,7 @@ extern "C" void DLLEXPORT IN_Accumulate (void) IN_ClearStates =================== */ -extern "C" void DLLEXPORT IN_ClearStates (void) +void GoldSourceInput::IN_ClearStates (void) { if ( !mouseactive ) return; @@ -999,7 +994,7 @@ void Joy_AdvancedUpdate_f (void) IN_Commands =========== */ -void IN_Commands (void) +void GoldSourceInput::IN_Commands (void) { int i, key_index; @@ -1274,7 +1269,7 @@ void IN_JoyMove ( float frametime, usercmd_t *cmd ) IN_Move =========== */ -void IN_Move ( float frametime, usercmd_t *cmd) +void GoldSourceInput::IN_Move ( float frametime, usercmd_t *cmd) { if ( !iMouseInUse && mouseactive ) { @@ -1289,7 +1284,7 @@ void IN_Move ( float frametime, usercmd_t *cmd) IN_Init =========== */ -void IN_Init (void) +void GoldSourceInput::IN_Init (void) { m_filter = gEngfuncs.pfnRegisterVariable ( "m_filter","0", FCVAR_ARCHIVE ); sensitivity = gEngfuncs.pfnRegisterVariable ( "sensitivity","3", FCVAR_ARCHIVE ); // user mouse sensitivity setting. @@ -1355,3 +1350,5 @@ void IN_Init (void) IN_StartupMouse (); IN_StartupJoystick (); } + +#endif diff --git a/cl_dll/input_mouse.cpp b/cl_dll/input_mouse.cpp new file mode 100644 index 00000000..724824cd --- /dev/null +++ b/cl_dll/input_mouse.cpp @@ -0,0 +1,82 @@ +#include "input_mouse.h" +#include "exportdef.h" +#include "hud.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 (gMobileEngfuncs) { + gEngfuncs.Con_Printf( "FWGS Xash3D input is in use\n" ); + currentInput = &fwgsInput; + } else { + gEngfuncs.Con_Printf( "GoldSource input is in use\n" ); + currentInput = &goldSourceInput; + } +#else + currentInput = &fwgsInput; +#endif + currentInput->IN_Init(); +} diff --git a/cl_dll/input_mouse.h b/cl_dll/input_mouse.h new file mode 100644 index 00000000..6ddf54db --- /dev/null +++ b/cl_dll/input_mouse.h @@ -0,0 +1,77 @@ +#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; +}; +#endif + +#endif diff --git a/cl_dll/input_xash3d.cpp b/cl_dll/input_xash3d.cpp index 63cdfbeb..2ff572ee 100644 --- a/cl_dll/input_xash3d.cpp +++ b/cl_dll/input_xash3d.cpp @@ -3,14 +3,9 @@ #include "cvardef.h" #include "kbutton.h" #include "keydefs.h" -cvar_t *sensitivity; -cvar_t *in_joystick; -#define PITCH 0 -#define YAW 1 -#define ROLL 2 - -extern "C" void DLLEXPORT IN_ClientMoveEvent( float forwardmove, float sidemove ); -extern "C" void DLLEXPORT IN_ClientLookEvent( float relyaw, float relpitch ); +#include "input_mouse.h" +extern cvar_t *sensitivity; +extern cvar_t *in_joystick; extern kbutton_t in_strafe; extern kbutton_t in_mlook; @@ -37,12 +32,6 @@ extern cvar_t *cl_movespeedkey; cvar_t *cl_laddermode; -float ac_forwardmove; -float ac_sidemove; -int ac_movecount; -float rel_yaw; -float rel_pitch; - #define F 1U<<0 // Forward #define B 1U<<1 // Back #define L 1U<<2 // Left @@ -55,7 +44,7 @@ float rel_pitch; #define IMPULSE_UP 4 int CL_IsDead( void ); -Vector dead_viewangles(0, 0, 0); +extern Vector dead_viewangles; void IN_ToggleButtons( float forwardmove, float sidemove ) { @@ -135,7 +124,7 @@ void IN_ToggleButtons( float forwardmove, float sidemove ) } } -void IN_ClientMoveEvent( float forwardmove, float sidemove ) +void FWGSInput::IN_ClientMoveEvent( float forwardmove, float sidemove ) { //gEngfuncs.Con_Printf("IN_MoveEvent\n"); @@ -144,14 +133,14 @@ void IN_ClientMoveEvent( float forwardmove, float sidemove ) ac_movecount++; } -void IN_ClientLookEvent( float relyaw, float relpitch ) +void FWGSInput::IN_ClientLookEvent( float relyaw, float relpitch ) { rel_yaw += relyaw; rel_pitch += relpitch; } // Rotate camera and add move values to usercmd -void IN_Move( float frametime, usercmd_t *cmd ) +void FWGSInput::IN_Move( float frametime, usercmd_t *cmd ) { Vector viewangles; bool fLadder = false; @@ -235,7 +224,7 @@ void IN_Move( float frametime, usercmd_t *cmd ) ac_movecount = 0; } -extern "C" void DLLEXPORT IN_MouseEvent( int mstate ) +void FWGSInput::IN_MouseEvent( int mstate ) { static int mouse_oldbuttonstate; // perform button actions @@ -257,37 +246,37 @@ extern "C" void DLLEXPORT IN_MouseEvent( int mstate ) // Stubs -extern "C" void DLLEXPORT IN_ClearStates( void ) +void FWGSInput::IN_ClearStates( void ) { //gEngfuncs.Con_Printf( "IN_ClearStates\n" ); } -extern "C" void DLLEXPORT IN_ActivateMouse( void ) +void FWGSInput::IN_ActivateMouse( void ) { //gEngfuncs.Con_Printf( "IN_ActivateMouse\n" ); } -extern "C" void DLLEXPORT IN_DeactivateMouse( void ) +void FWGSInput::IN_DeactivateMouse( void ) { //gEngfuncs.Con_Printf( "IN_DeactivateMouse\n" ); } -extern "C" void DLLEXPORT IN_Accumulate( void ) +void FWGSInput::IN_Accumulate( void ) { //gEngfuncs.Con_Printf( "IN_Accumulate\n" ); } -void IN_Commands( void ) +void FWGSInput::IN_Commands( void ) { //gEngfuncs.Con_Printf( "IN_Commands\n" ); } -void IN_Shutdown( void ) +void FWGSInput::IN_Shutdown( void ) { } // Register cvars and reset data -void IN_Init( void ) +void FWGSInput::IN_Init( void ) { sensitivity = gEngfuncs.pfnRegisterVariable( "sensitivity", "3", FCVAR_ARCHIVE ); in_joystick = gEngfuncs.pfnRegisterVariable( "joystick", "0", FCVAR_ARCHIVE ); From 84e720eadcfa27434ee65335cb87c8e41a63a92f Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Mon, 4 Dec 2017 15:42:45 +0300 Subject: [PATCH 07/25] Add new input files and goldsource support flag to client makefiles --- cl_dll/Android.mk | 7 +++++++ cl_dll/Makefile | 11 ++++++++--- cl_dll/cl_dll.dsp | 14 +++++++++++++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/cl_dll/Android.mk b/cl_dll/Android.mk index a79b6363..29aee174 100755 --- a/cl_dll/Android.mk +++ b/cl_dll/Android.mk @@ -68,6 +68,8 @@ SRCS+=./hud_spectator.cpp SRCS+=./hud_update.cpp SRCS+=./in_camera.cpp SRCS+=./input.cpp +SRCS+=./input_goldsource.cpp +SRCS+=./input_mouse.cpp #SRCS+=./inputw32.cpp SRCS+=./menu.cpp SRCS+=./message.cpp @@ -100,6 +102,11 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/. \ $(LOCAL_PATH)/../pm_shared LOCAL_CFLAGS += $(DEFINES) $(INCLUDES) +ifeq ($(GOLDSOURCE_SUPPORT),1) + DEFINES += -DGOLDSOURCE_SUPPORT + LOCAL_LDLIBS += -lSDL2 +endif + LOCAL_SRC_FILES := $(SRCS) $(SRCS_C) include $(BUILD_SHARED_LIBRARY) diff --git a/cl_dll/Makefile b/cl_dll/Makefile index 983b61c0..16427f8f 100644 --- a/cl_dll/Makefile +++ b/cl_dll/Makefile @@ -45,7 +45,8 @@ SRCS+=./hud_spectator.cpp SRCS+=./hud_update.cpp SRCS+=./in_camera.cpp SRCS+=./input.cpp -#SRCS+=./inputw32.cpp +SRCS+=./input_mouse.cpp +SRCS+=./input_goldsource.cpp SRCS+=./menu.cpp SRCS+=./message.cpp SRCS+=./overview.cpp @@ -72,9 +73,13 @@ CFLAGS = -m32 OBJS = $(SRCS:.cpp=.o) $(SRCS_C:.c=.o) LIBS=-lm +ifeq ($(GOLDSOURCE_SUPPORT),1) + DEFINES += -DGOLDSOURCE_SUPPORT + LIBS += -lSDL2 +endif ifeq ($(shell uname -s),Linux) - LIBS=$(LIBS) -ldl + LIBS += -ldl endif %.o : %.c @@ -83,7 +88,7 @@ endif %.o : %.cpp $(CXX) $(CFLAGS) $(INCLUDES) $(DEFINES) -fPIC -c $< -o $@ client.so : $(OBJS) - $(CXX) $(OBJS) -o client.so -shared -Wl,--no-undefined -fPIC $(LIBS) + $(CXX) $(CFLAGS) $(OBJS) -o client.so -shared -Wl,--no-undefined -fPIC $(LIBS) clean: $(RM) $(OBJS) diff --git a/cl_dll/cl_dll.dsp b/cl_dll/cl_dll.dsp index 6864326b..e8ae7d15 100644 --- a/cl_dll/cl_dll.dsp +++ b/cl_dll/cl_dll.dsp @@ -300,7 +300,15 @@ SOURCE=.\input.cpp # End Source File # Begin Source File -SOURCE=.\inputw32.cpp +SOURCE=.\input_goldsource.cpp +# End Source File +# Begin Source File + +SOURCE=.\input_mouse.cpp +# End Source File +# Begin Source File + +SOURCE=.\input_xash3d.cpp # End Source File # Begin Source File @@ -513,6 +521,10 @@ SOURCE=.\in_defs.h # End Source File # Begin Source File +SOURCE=.\input_mouse.h +# End Source File +# Begin Source File + SOURCE=..\common\itrackeruser.h # End Source File # Begin Source File From d904505f6a991532fd2eedff4e98b683347f71cd Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Wed, 6 Dec 2017 19:19:27 +0300 Subject: [PATCH 08/25] Get vgui back for goldsource fullscreen support --- cl_dll/CMakeLists.txt | 9 ++++-- cl_dll/cdll_int.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 72 insertions(+), 3 deletions(-) diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index 776f9bd9..2ad46949 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -27,7 +27,12 @@ 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 -lSDL2 -Wl,--no-undefined") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGOLDSOURCE_SUPPORT -L${CMAKE_CURRENT_SOURCE_DIR}/.. -lSDL2 -Wl,--no-undefined") + if (APPLE) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -l:vgui.dylib") + else() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -l:vgui.so") + endif() endif() set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") @@ -96,7 +101,7 @@ set (CLDLL_SOURCES scoreboard.cpp MOTD.cpp) -include_directories (. hl/ ../dlls ../dlls/wpn_shared ../common ../engine ../pm_shared ../game_shared ../public) +include_directories (. hl/ ../dlls ../dlls/wpn_shared ../common ../engine ../pm_shared ../game_shared ../public ../utils/vgui/include) if(USE_VOICEMGR) #set(CLDLL_SOURCES diff --git a/cl_dll/cdll_int.cpp b/cl_dll/cdll_int.cpp index d71659e9..00496ea8 100644 --- a/cl_dll/cdll_int.cpp +++ b/cl_dll/cdll_int.cpp @@ -23,6 +23,13 @@ #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_BorderLayout.h" +#include "VGUI_App.h" +#endif + extern "C" { #include "pm_shared.h" @@ -177,6 +184,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) +{ + 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 @@ -190,7 +237,21 @@ 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(); + root->setBgColor(128,128,0,0); + root->setLayout(new vgui::BorderLayout(0)); + if (gViewPort != NULL) + { + gViewPort->Initialize(); + } + else + { + gViewPort = new TeamFortressViewport(0,0,root->getWide(),root->getTall()); + gViewPort->setParent(root); + } +#endif return 1; } @@ -270,7 +331,10 @@ Called by engine every frame that client .dll is loaded */ void DLLEXPORT HUD_Frame( double time ) -{ gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect()); +{ +#ifndef USE_VGUI_FOR_GOLDSOURCE_SUPPORT + gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect()); +#endif } /* From 51bf51a840649165078226661ef790c0ed3971e4 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Wed, 6 Dec 2017 20:38:14 +0300 Subject: [PATCH 09/25] Provide vgui stub to avoid dependency of client of vgui lib --- cl_dll/CMakeLists.txt | 7 +- cl_dll/cdll_int.cpp | 39 ++-- utils/false_vgui/include/VGUI.h | 108 ++++++++++ utils/false_vgui/include/VGUI_App.h | 130 ++++++++++++ utils/false_vgui/include/VGUI_Bitmap.h | 37 ++++ utils/false_vgui/include/VGUI_Color.h | 44 +++++ utils/false_vgui/include/VGUI_Cursor.h | 57 ++++++ utils/false_vgui/include/VGUI_Dar.h | 194 ++++++++++++++++++ utils/false_vgui/include/VGUI_Image.h | 62 ++++++ utils/false_vgui/include/VGUI_KeyCode.h | 126 ++++++++++++ utils/false_vgui/include/VGUI_MouseCode.h | 24 +++ utils/false_vgui/include/VGUI_Panel.h | 229 ++++++++++++++++++++++ utils/false_vgui/include/VGUI_Scheme.h | 82 ++++++++ 13 files changed, 1115 insertions(+), 24 deletions(-) create mode 100644 utils/false_vgui/include/VGUI.h create mode 100644 utils/false_vgui/include/VGUI_App.h create mode 100644 utils/false_vgui/include/VGUI_Bitmap.h create mode 100644 utils/false_vgui/include/VGUI_Color.h create mode 100644 utils/false_vgui/include/VGUI_Cursor.h create mode 100644 utils/false_vgui/include/VGUI_Dar.h create mode 100644 utils/false_vgui/include/VGUI_Image.h create mode 100644 utils/false_vgui/include/VGUI_KeyCode.h create mode 100644 utils/false_vgui/include/VGUI_MouseCode.h create mode 100644 utils/false_vgui/include/VGUI_Panel.h create mode 100644 utils/false_vgui/include/VGUI_Scheme.h diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index 2ad46949..e52a0d95 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -28,11 +28,6 @@ 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 -L${CMAKE_CURRENT_SOURCE_DIR}/.. -lSDL2 -Wl,--no-undefined") - if (APPLE) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -l:vgui.dylib") - else() - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -l:vgui.so") - endif() endif() set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") @@ -101,7 +96,7 @@ set (CLDLL_SOURCES scoreboard.cpp MOTD.cpp) -include_directories (. hl/ ../dlls ../dlls/wpn_shared ../common ../engine ../pm_shared ../game_shared ../public ../utils/vgui/include) +include_directories (. hl/ ../dlls ../dlls/wpn_shared ../common ../engine ../pm_shared ../game_shared ../public ../utils/false_vgui/include) if(USE_VOICEMGR) #set(CLDLL_SOURCES diff --git a/cl_dll/cdll_int.cpp b/cl_dll/cdll_int.cpp index 00496ea8..1901d9d2 100644 --- a/cl_dll/cdll_int.cpp +++ b/cl_dll/cdll_int.cpp @@ -26,7 +26,6 @@ #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_BorderLayout.h" #include "VGUI_App.h" #endif @@ -197,7 +196,7 @@ public: static TeamFortressViewport* gViewPort = NULL; -TeamFortressViewport::TeamFortressViewport(int x, int y, int wide, int tall) +TeamFortressViewport::TeamFortressViewport(int x, int y, int wide, int tall) : Panel(x, y, wide, tall) { gViewPort = this; Initialize(); @@ -205,14 +204,14 @@ TeamFortressViewport::TeamFortressViewport(int x, int y, int wide, int tall) void TeamFortressViewport::Initialize() { - vgui::App::getInstance()->setCursorOveride( vgui::App::getInstance()->getScheme()->getCursor(vgui::Scheme::scu_none) ); + //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 ); +// int wide, tall; +// getParent()->getSize( wide, tall ); +// setSize( wide, tall ); gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect()); } @@ -239,17 +238,18 @@ int DLLEXPORT HUD_VidInit( void ) gHUD.VidInit(); #ifdef USE_VGUI_FOR_GOLDSOURCE_SUPPORT vgui::Panel* root=(vgui::Panel*)gEngfuncs.VGui_GetPanel(); - root->setBgColor(128,128,0,0); - root->setLayout(new vgui::BorderLayout(0)); - - if (gViewPort != NULL) - { - gViewPort->Initialize(); - } - else - { - gViewPort = new TeamFortressViewport(0,0,root->getWide(),root->getTall()); - gViewPort->setParent(root); + if (root) { + root->setBgColor(128,128,0,0); + + if (gViewPort != NULL) + { + gViewPort->Initialize(); + } + else + { + gViewPort = new TeamFortressViewport(0,0,root->getWide(),root->getTall()); + gViewPort->setParent(root); + } } #endif return 1; @@ -332,7 +332,10 @@ Called by engine every frame that client .dll is loaded void DLLEXPORT HUD_Frame( double time ) { -#ifndef USE_VGUI_FOR_GOLDSOURCE_SUPPORT +#ifdef USE_VGUI_FOR_GOLDSOURCE_SUPPORT + if (!gViewPort) + gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect()); +#else gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect()); #endif } diff --git a/utils/false_vgui/include/VGUI.h b/utils/false_vgui/include/VGUI.h new file mode 100644 index 00000000..0dff607a --- /dev/null +++ b/utils/false_vgui/include/VGUI.h @@ -0,0 +1,108 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_H +#define VGUI_H + +//If you are going to add stuff to the vgui core... +// +//Keep it simple. +// +//Never put code in a header. +// +//The name of the class is the name of the the file +// +//Each class gets its own .cpp file for its definition and a .h for its header. Helper +//classes can be used but only within the .cpp and not referenceable from anywhere else. +// +//Don't add unneeded files. Keep the API clean. +// +//No platform specific code in vgui\lib-src\vgui dir. Code in vgui\lib-src\vgui should +//only include from vgui\include or standard C includes. ie, if I see windows.h included +//anywhere but vgui\lib-src\win32 I will hunt you down and kill you. Don't give me any crap +//that mfc is platform inspecific. +// +//Always use <> and not "" for includes +// +//Use minimum dependencies in headers. Don't include another header if you can get away +//with forward declaring (which is usually the case) +// +//No macros in headers. They are tools of satan. This also means no use of DEFINEs, use enum +// +//Minimize global functions +// +//No global variables. +// +//Panel is getting pretty plump, try and avoid adding junk to it if you can + +//TODO: Look and Feel support +// add Panel::setPaintProxy, if _paintProxy exists, it calls _paintProxy->paint +// instead of Panel::paint. Components should implement their painting in a seperate +// plugin class. Perhaps to encourage this, Panel::paint should just go away completely +// The other option is to have Panel have the interface Paintable +// class Paintable +// { +// public: +// virtual void paint()=0; +// }; +// Then a component can implement its paint in the class itself and then call +// setPaintProxy(this). If this is the case _paintProxy->paint should always be called +// and never Panel::paint from within paintTraverse +//TODO: Figure out the 'Valve' Look and Feel and implement that instead of a the Java one +//TODO: Determine ownership policy for Borders, Layouts, etc.. +//TODO: tooltips support +//TODO: ComboKey (hot key support) +//TODO: add Background.cpp, remove paintBackground from all components +// Panel implements setBackground, Panel::paintBackground calls _background->paintBackground +// similiar to the way Border works. +//TODO: Builtin components should never overide paintBackground, only paint +//TODO: All protected members should be converted to private +//TODO: All member variables should be moved to the top of the class prototype +//TODO: All private methods should be prepended with private +//TODO: Use of word internal in method names is not consistent and confusing +//TODO: Cleanup so bullshit publics are properly named, maybe even figure out +// a naming convention for them +//TODO: Breakup InputSignal into logical pieces +//TODO: Button is in a state of disarray, it should have ButtonModel support +//TODO: get rid of all the stupid strdup laziness, convert to vgui_strdup +//TODO: actually figure out policy on String and implement it consistently +//TODO: implement createLayoutInfo for other Layouts than need it +//TODO: BorderLayout should have option for a null LayoutInfo defaulting to center +//TODO: SurfaceBase should go away, put it in Surface +//TODO: ActionSignals and other Signals should just set a flag when they fire. +// then App can come along later and fire all the signals +//TODO: Change all method naming to starting with a capital letter. + +#ifdef _WIN32 +# define VGUIAPI __declspec( dllexport ) +#else +# define VGUIAPI __attribute__ ((visibility("default"))) +#include // size_t define +#endif + +#define null 0L + +typedef unsigned char uchar; +typedef unsigned short ushort; +typedef unsigned int uint; +typedef unsigned long ulong; + +namespace vgui +{ + +VGUIAPI void vgui_setMalloc(void *(*malloc)(size_t size) ); +VGUIAPI void vgui_setFree(void (*free)(void* memblock)); +VGUIAPI void vgui_strcpy(char* dst,int dstLen,const char* src); +VGUIAPI char* vgui_strdup(const char* src); +VGUIAPI int vgui_printf(const char* format,...); +VGUIAPI int vgui_dprintf(const char* format,...); +VGUIAPI int vgui_dprintf2(const char* format,...); + +} + +#endif + diff --git a/utils/false_vgui/include/VGUI_App.h b/utils/false_vgui/include/VGUI_App.h new file mode 100644 index 00000000..6e70f909 --- /dev/null +++ b/utils/false_vgui/include/VGUI_App.h @@ -0,0 +1,130 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_APP_H +#define VGUI_APP_H + +#include +#include +#include +#include +#include + +namespace vgui +{ + +class Panel; +class TickSignal; +class Scheme; +class TickSignal; +class SurfaceBase; + +class VGUIAPI App +{ +public: + App() {} + App(bool externalMain) {} +public: + static App* getInstance() {return 0;} + //TODO: the public and public bullshit are all messed up, need to organize + //TODO: actually all of the access needs to be properly thought out while you are at it +public: + virtual void start() {} + virtual void stop() {} + virtual void externalTick() {} + virtual bool wasMousePressed(MouseCode code,Panel* panel) {return false;} + virtual bool wasMouseDoublePressed(MouseCode code,Panel* panel) {return false;} + virtual bool isMouseDown(MouseCode code,Panel* panel) {return false;} + virtual bool wasMouseReleased(MouseCode code,Panel* panel) {return false;} + virtual bool wasKeyPressed(KeyCode code,Panel* panel) {return false;} + virtual bool isKeyDown(KeyCode code,Panel* panel) {return false;} + virtual bool wasKeyTyped(KeyCode code,Panel* panel) {return false;} + virtual bool wasKeyReleased(KeyCode code,Panel* panel) {return false;} + virtual void addTickSignal(TickSignal* s) {} + virtual void setCursorPos(int x,int y) {} + virtual void getCursorPos(int& x,int& y) {} + virtual void setMouseCapture(Panel* panel) {} + virtual void setMouseArena(int x0,int y0,int x1,int y1,bool enabled) {} + virtual void setMouseArena(Panel* panel) {} + virtual void requestFocus(Panel* panel) {} + virtual Panel* getFocus() {return 0;} + virtual void repaintAll() {} + virtual void setScheme(Scheme* scheme) {} + virtual Scheme* getScheme() {return 0;} + virtual void enableBuildMode() {} + virtual long getTimeMillis() {return 0;} + virtual char getKeyCodeChar(KeyCode code,bool shifted) {return '\0';} + virtual void getKeyCodeText(KeyCode code,char* buf,int buflen) {} + virtual int getClipboardTextCount() {return 0;} + virtual void setClipboardText(const char* text,int textLen) {} + virtual int getClipboardText(int offset,char* buf,int bufLen) {return 0;} + virtual void reset() {} + virtual void internalSetMouseArena(int x0,int y0,int x1,int y1,bool enabled) {} + virtual bool setRegistryString(const char* key,const char* value) {return false;} + virtual bool getRegistryString(const char* key,char* value,int valueLen) {return false;} + virtual bool setRegistryInteger(const char* key,int value) {return false;} + virtual bool getRegistryInteger(const char* key,int& value) {return false;} + virtual void setCursorOveride(Cursor* cursor) {} + virtual Cursor* getCursorOveride() {return 0;} + virtual void setMinimumTickMillisInterval(int interval) {} +public: //bullshit public stuff + virtual void main(int argc,char* argv[])=0; + virtual void run() {} + virtual void internalCursorMoved(int x,int y,SurfaceBase* surfaceBase) {} //expects input in surface space + virtual void internalMousePressed(MouseCode code,SurfaceBase* surfaceBase) {} + virtual void internalMouseDoublePressed(MouseCode code,SurfaceBase* surfaceBase) {} + virtual void internalMouseReleased(MouseCode code,SurfaceBase* surfaceBase) {} + virtual void internalMouseWheeled(int delta,SurfaceBase* surfaceBase) {} + virtual void internalKeyPressed(KeyCode code,SurfaceBase* surfaceBase) {} + virtual void internalKeyTyped(KeyCode code,SurfaceBase* surfaceBase) {} + virtual void internalKeyReleased(KeyCode code,SurfaceBase* surfaceBase) {} +private: + virtual void init() {} + virtual void updateMouseFocus(int x,int y,SurfaceBase* surfaceBase) {} + virtual void setMouseFocus(Panel* newMouseFocus) {} +protected: + virtual void surfaceBaseCreated(SurfaceBase* surfaceBase) {} + virtual void surfaceBaseDeleted(SurfaceBase* surfaceBase) {} + virtual void platTick() {} + virtual void internalTick() {} +protected: + static App* _instance; +protected: + bool _running; + bool _externalMain; + Dar _surfaceBaseDar; + Panel* _keyFocus; + Panel* _oldMouseFocus; + Panel* _mouseFocus; + Panel* _mouseCapture; + Panel* _wantedKeyFocus; + bool _mousePressed[MOUSE_LAST]; + bool _mouseDoublePressed[MOUSE_LAST]; + bool _mouseDown[MOUSE_LAST]; + bool _mouseReleased[MOUSE_LAST]; + bool _keyPressed[KEY_LAST]; + bool _keyTyped[KEY_LAST]; + bool _keyDown[KEY_LAST]; + bool _keyReleased[KEY_LAST]; + Dar _tickSignalDar; + Scheme* _scheme; + bool _buildMode; + bool _wantedBuildMode; + Panel* _mouseArenaPanel; + Cursor* _cursor[Cursor::dc_last]; + Cursor* _cursorOveride; +private: + long _nextTickMillis; + long _minimumTickMillisInterval; + friend class SurfaceBase; +}; +} + +#endif + + + diff --git a/utils/false_vgui/include/VGUI_Bitmap.h b/utils/false_vgui/include/VGUI_Bitmap.h new file mode 100644 index 00000000..a2cc7a45 --- /dev/null +++ b/utils/false_vgui/include/VGUI_Bitmap.h @@ -0,0 +1,37 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_BITMAP_H +#define VGUI_BITMAP_H + +#include +#include + +namespace vgui +{ + +class Panel; + +class VGUIAPI Bitmap : public Image +{ +private: + int _id; + bool _uploaded; +public: + Bitmap() {} +protected: + virtual void setSize(int wide,int tall) {} + virtual void setRGBA(int x,int y,uchar r,uchar g,uchar b,uchar a) {} +public: + virtual void paint(Panel* panel) {} +protected: + uchar* _rgba; +}; + +} + +#endif diff --git a/utils/false_vgui/include/VGUI_Color.h b/utils/false_vgui/include/VGUI_Color.h new file mode 100644 index 00000000..f3fec5c6 --- /dev/null +++ b/utils/false_vgui/include/VGUI_Color.h @@ -0,0 +1,44 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_COLOR_H +#define VGUI_COLOR_H + +#include +#include + +//TODO: rename getColor(r,g,b,a) to getRGBA(r,g,b,a) +//TODO: rename setColor(r,g,b,a) to setRGBA(r,g,b,a) +//TODO: rename getColor(sc) to getSchemeColor(sc) +//TODO: rename setColor(sc) to setSchemeColor(sc) + +namespace vgui +{ + +class VGUIAPI Color +{ +private: + uchar _color[4]; + Scheme::SchemeColor _schemeColor; +public: + Color() {} + Color(int r,int g,int b,int a) {} + Color(Scheme::SchemeColor sc) {} +private: + virtual void init() {} +public: + virtual void setColor(int r,int g,int b,int a) {} + virtual void setColor(Scheme::SchemeColor sc) {} + virtual void getColor(int& r,int& g,int& b,int& a) {} + virtual void getColor(Scheme::SchemeColor& sc) {} + virtual int operator[](int index) {return 0;} +}; + +} + + +#endif diff --git a/utils/false_vgui/include/VGUI_Cursor.h b/utils/false_vgui/include/VGUI_Cursor.h new file mode 100644 index 00000000..8419e2dd --- /dev/null +++ b/utils/false_vgui/include/VGUI_Cursor.h @@ -0,0 +1,57 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_CURSOR_H +#define VGUI_CURSOR_H + +#include + +namespace vgui +{ + +class Bitmap; + +class VGUIAPI Cursor +{ +public: + enum DefaultCursor + { + dc_user, + dc_none, + dc_arrow, + dc_ibeam, + dc_hourglass, + dc_crosshair, + dc_up, + dc_sizenwse, + dc_sizenesw, + dc_sizewe, + dc_sizens, + dc_sizeall, + dc_no, + dc_hand, + dc_last + }; +private: + int _hotspot[2]; + Bitmap* _bitmap; + DefaultCursor _dc; +public: + Cursor(DefaultCursor dc) {} + Cursor(Bitmap* bitmap,int hotspotX,int hotspotY) {} +public: + virtual void getHotspot(int& x,int& y) {} +private: + virtual void privateInit(Bitmap* bitmap,int hotspotX,int hotspotY) {} +public: + virtual Bitmap* getBitmap() {return 0;} + virtual DefaultCursor getDefaultCursor() {return dc_none;} +}; + +} + +#endif diff --git a/utils/false_vgui/include/VGUI_Dar.h b/utils/false_vgui/include/VGUI_Dar.h new file mode 100644 index 00000000..6f8eb513 --- /dev/null +++ b/utils/false_vgui/include/VGUI_Dar.h @@ -0,0 +1,194 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_DAR_H +#define VGUI_DAR_H + +#include +#include +#include + + + +namespace vgui +{ + +//Simple lightweight dynamic array implementation +template class VGUIAPI Dar +{ +public: + Dar() + { + _count=0; + _capacity=0; + _data=null; + ensureCapacity(4); + } + Dar(int initialCapacity) + { + _count=0; + _capacity=0; + _data=null; + ensureCapacity(initialCapacity); + } +public: + void ensureCapacity(int wantedCapacity) + { + if(wantedCapacity<=_capacity){return;} + + //double capacity until it is >= wantedCapacity + //this could be done with math, but iterative is just so much more fun + int newCapacity=_capacity; + if(newCapacity==0){newCapacity=1;} + while(newCapacity_capacity)) + { + return; + } + _count=count; + } + int getCount() + { + return _count; + } + void addElement(ELEMTYPE elem) + { + ensureCapacity(_count+1); + _data[_count]=elem; + _count++; + } + bool hasElement(ELEMTYPE elem) + { + for(int i=0;i<_count;i++) + { + if(_data[i]==elem) + { + return true; + } + } + return false; + } + void putElement(ELEMTYPE elem) + { + if(hasElement(elem)) + { + return; + } + addElement(elem); + } + void insertElementAt(ELEMTYPE elem,int index) + { + if((index<0)||(index>_count)) + { + return; + } + if((index==_count)||(_count==0)) + { + addElement(elem); + } + else + { + addElement(elem); //just to make sure it is big enough + for(int i=_count-1;i>index;i--) + { + _data[i]=_data[i-1]; + } + _data[index]=elem; + } + } + void setElementAt(ELEMTYPE elem,int index) + { + if((index<0)||(index>=_count)) + { + return; + } + _data[index]=elem; + } + void removeElementAt(int index) + { + if((index<0)||(index>=_count)) + { + return; + } + + //slide everything to the right of index, left one. + for(int i=index;i<(_count-1);i++) + { + _data[i]=_data[i+1]; + } + _count--; + } + void removeElement(ELEMTYPE elem) + { + for(int i=0;i<_count;i++) + { + if(_data[i]==elem) + { + removeElementAt(i); + break; + } + } + } + void removeAll() + { + _count=0; + } + ELEMTYPE operator[](int index) + { + if((index<0)||(index>=_count)) + { + return null; + } + return _data[index]; + } +protected: + int _count; + int _capacity; + ELEMTYPE* _data; +}; + +#ifdef _WIN32 +//forward referencing all the template types used so they get exported +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar*>; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +#endif + +} + + +#endif \ No newline at end of file diff --git a/utils/false_vgui/include/VGUI_Image.h b/utils/false_vgui/include/VGUI_Image.h new file mode 100644 index 00000000..ff83f047 --- /dev/null +++ b/utils/false_vgui/include/VGUI_Image.h @@ -0,0 +1,62 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_IMAGE_H +#define VGUI_IMAGE_H + +#include +#include +#include + +//TODO:: needs concept of insets + +namespace vgui +{ + +class Panel; + +class VGUIAPI Image +{ +friend class Panel; +private: + int _pos[2]; + int _size[2]; + Panel* _panel; + Color _color; +public: + Image(); +public: + virtual void setPos(int x,int y) {} + virtual void getPos(int& x,int& y) {} + virtual void getSize(int& wide,int& tall) {} + virtual void setColor(Color color) {} + virtual void getColor(Color& color) {} +protected: + virtual void setSize(int wide,int tall) {} + virtual void drawSetColor(Scheme::SchemeColor sc) {} + virtual void drawSetColor(int r,int g,int b,int a) {} + virtual void drawFilledRect(int x0,int y0,int x1,int y1) {} + virtual void drawOutlinedRect(int x0,int y0,int x1,int y1) {} + virtual void drawSetTextFont(Scheme::SchemeFont sf) {} + virtual void drawSetTextFont(Font* font) {} + virtual void drawSetTextColor(Scheme::SchemeColor sc) {} + virtual void drawSetTextColor(int r,int g,int b,int a) {} + virtual void drawSetTextPos(int x,int y) {} + virtual void drawPrintText(const char* str,int strlen) {} + virtual void drawPrintText(int x,int y,const char* str,int strlen) {} + virtual void drawPrintChar(char ch) {} + virtual void drawPrintChar(int x,int y,char ch) {} + virtual void drawSetTextureRGBA(int id,const char* rgba,int wide,int tall) {} + virtual void drawSetTexture(int id) {} + virtual void drawTexturedRect(int x0,int y0,int x1,int y1) {} + virtual void paint(Panel* panel) {} +public: + virtual void doPaint(Panel* panel) {} +}; +} + +#endif diff --git a/utils/false_vgui/include/VGUI_KeyCode.h b/utils/false_vgui/include/VGUI_KeyCode.h new file mode 100644 index 00000000..b6aea363 --- /dev/null +++ b/utils/false_vgui/include/VGUI_KeyCode.h @@ -0,0 +1,126 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_KEYCODE_H +#define VGUI_KEYCODE_H + +#include + +namespace vgui +{ +enum VGUIAPI KeyCode +{ + KEY_0=0, + KEY_1, + KEY_2, + KEY_3, + KEY_4, + KEY_5, + KEY_6, + KEY_7, + KEY_8, + KEY_9, + KEY_A, + KEY_B, + KEY_C, + KEY_D, + KEY_E, + KEY_F, + KEY_G, + KEY_H, + KEY_I, + KEY_J, + KEY_K, + KEY_L, + KEY_M, + KEY_N, + KEY_O, + KEY_P, + KEY_Q, + KEY_R, + KEY_S, + KEY_T, + KEY_U, + KEY_V, + KEY_W, + KEY_X, + KEY_Y, + KEY_Z, + KEY_PAD_0, + KEY_PAD_1, + KEY_PAD_2, + KEY_PAD_3, + KEY_PAD_4, + KEY_PAD_5, + KEY_PAD_6, + KEY_PAD_7, + KEY_PAD_8, + KEY_PAD_9, + KEY_PAD_DIVIDE, + KEY_PAD_MULTIPLY, + KEY_PAD_MINUS, + KEY_PAD_PLUS, + KEY_PAD_ENTER, + KEY_PAD_DECIMAL, + KEY_LBRACKET, + KEY_RBRACKET, + KEY_SEMICOLON, + KEY_APOSTROPHE, + KEY_BACKQUOTE, + KEY_COMMA, + KEY_PERIOD, + KEY_SLASH, + KEY_BACKSLASH, + KEY_MINUS, + KEY_EQUAL, + KEY_ENTER, + KEY_SPACE, + KEY_BACKSPACE, + KEY_TAB, + KEY_CAPSLOCK, + KEY_NUMLOCK, + KEY_ESCAPE, + KEY_SCROLLLOCK, + KEY_INSERT, + KEY_DELETE, + KEY_HOME, + KEY_END, + KEY_PAGEUP, + KEY_PAGEDOWN, + KEY_BREAK, + KEY_LSHIFT, + KEY_RSHIFT, + KEY_LALT, + KEY_RALT, + KEY_LCONTROL, + KEY_RCONTROL, + KEY_LWIN, + KEY_RWIN, + KEY_APP, + KEY_UP, + KEY_LEFT, + KEY_DOWN, + KEY_RIGHT, + KEY_F1, + KEY_F2, + KEY_F3, + KEY_F4, + KEY_F5, + KEY_F6, + KEY_F7, + KEY_F8, + KEY_F9, + KEY_F10, + KEY_F11, + KEY_F12, + KEY_LAST +}; +} + + +#endif + diff --git a/utils/false_vgui/include/VGUI_MouseCode.h b/utils/false_vgui/include/VGUI_MouseCode.h new file mode 100644 index 00000000..2de259db --- /dev/null +++ b/utils/false_vgui/include/VGUI_MouseCode.h @@ -0,0 +1,24 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_MOUSECODE_H +#define VGUI_MOUSECODE_H + +#include + +namespace vgui +{ +enum VGUIAPI MouseCode +{ + MOUSE_LEFT=0, + MOUSE_RIGHT, + MOUSE_MIDDLE, + MOUSE_LAST +}; +} + +#endif diff --git a/utils/false_vgui/include/VGUI_Panel.h b/utils/false_vgui/include/VGUI_Panel.h new file mode 100644 index 00000000..bec7ac25 --- /dev/null +++ b/utils/false_vgui/include/VGUI_Panel.h @@ -0,0 +1,229 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_PANEL_H +#define VGUI_PANEL_H + + +/* + +TODO: + +Maybe have the border know who they are added to. +A border can only be added to 1 thing, and will be +removed from the other. That way they can actually +be memory managed. Also do Layout's this way too. + +TODO: + outlinedRect should have a thickness arg + +*/ + + +#include +#include +#include +#include +#include +#include +#include +//#include + +namespace vgui +{ + +enum KeyCode; +enum MouseCode; +class SurfaceBase; +class FocusChangeSignal; +class InputSignal; +class Cursor; +class Layout; +class FocusNavGroup; +class Border; +class Font; +class BuildGroup; +class App; +class LayoutInfo; +class RepaintSignal; + +class VGUIAPI Panel +{ +public: + Panel() {} + Panel(int x,int y,int wide,int tall) {setPos(x, y); setSize(wide, tall);} +private: + void init(int x,int y,int wide,int tall) {} +public: + virtual void setPos(int x,int y) {_pos[0] = x; _pos[1] = y;} + virtual void getPos(int& x,int& y) {x = _pos[0]; y = _pos[1];} + virtual void setSize(int wide,int tall) {_size[0] = wide, _size[1] = tall;} + virtual void getSize(int& wide,int& tall) {wide = _size[0], tall = _size[1];} + virtual void setBounds(int x,int y,int wide,int tall) {} + virtual void getBounds(int& x,int& y,int& wide,int& tall) {} + virtual int getWide() {return _size[0];} + virtual int getTall() {return _size[1];} + virtual Panel* getParent() {return _parent;} + virtual void setVisible(bool state) {_visible = state;} + virtual bool isVisible() {return _visible;} + virtual bool isVisibleUp() {return false;} + virtual void repaint() {} + virtual void repaintAll() {} + virtual void getAbsExtents(int& x0,int& y0,int& x1,int& y1) {} + virtual void getClipRect(int& x0,int& y0,int& x1,int& y1) {} + virtual void setParent(Panel* newParent) {_parent = newParent; newParent->addChild(this);} + virtual void addChild(Panel* child) {} + virtual void insertChildAt(Panel* child,int index) {} + virtual void removeChild(Panel* child) {} + virtual bool wasMousePressed(MouseCode code) {return false;} + virtual bool wasMouseDoublePressed(MouseCode code) {return false;} + virtual bool isMouseDown(MouseCode code) {return false;} + virtual bool wasMouseReleased(MouseCode code) {return false;} + virtual bool wasKeyPressed(KeyCode code) {return false;} + virtual bool isKeyDown(KeyCode code) {return false;} + virtual bool wasKeyTyped(KeyCode code) {return false;} + virtual bool wasKeyReleased(KeyCode code) {return false;} + virtual void addInputSignal(InputSignal* s) {} + virtual void removeInputSignal(InputSignal* s) {} + virtual void addRepaintSignal(RepaintSignal* s) {} + virtual void removeRepaintSignal(RepaintSignal* s) {} + virtual bool isWithin(int x,int y) {return false;} //in screen space + virtual Panel* isWithinTraverse(int x,int y) {return 0;} + virtual void localToScreen(int& x,int& y) {} + virtual void screenToLocal(int& x,int& y) {} + virtual void setCursor(Cursor* cursor) {} + virtual void setCursor(Scheme::SchemeCursor scu) {} + virtual Cursor* getCursor() {return 0;} + virtual void setMinimumSize(int wide,int tall) {} + virtual void getMinimumSize(int& wide,int& tall) {} + virtual void requestFocus() {} + virtual bool hasFocus() {return false;} + virtual int getChildCount() {return 0;} + virtual Panel* getChild(int index) {return 0;} + virtual void setLayout(Layout* layout) {} + virtual void invalidateLayout(bool layoutNow) {} + virtual void setFocusNavGroup(FocusNavGroup* focusNavGroup) {} + virtual void requestFocusPrev() {} + virtual void requestFocusNext() {} + virtual void addFocusChangeSignal(FocusChangeSignal* s) {} + virtual bool isAutoFocusNavEnabled() {return false;} + virtual void setAutoFocusNavEnabled(bool state) {} + virtual void setBorder(Border* border) {} + virtual void setPaintBorderEnabled(bool state) {} + virtual void setPaintBackgroundEnabled(bool state) {} + virtual void setPaintEnabled(bool state) {} + virtual void getInset(int& left,int& top,int& right,int& bottom) {} + virtual void getPaintSize(int& wide,int& tall) {} + virtual void setPreferredSize(int wide,int tall) {} + virtual void getPreferredSize(int& wide,int& tall) {} + virtual SurfaceBase* getSurfaceBase() {return 0;} + virtual bool isEnabled() {return _enabled = false;} + virtual void setEnabled(bool state) {_enabled = true;} + virtual void setBuildGroup(BuildGroup* buildGroup,const char* panelPersistanceName) {} + virtual bool isBuildGroupEnabled() {return false;} + virtual void removeAllChildren() {} + virtual void repaintParent() {} + virtual Panel* createPropertyPanel() {return 0;} + virtual void getPersistanceText(char* buf,int bufLen) {} + virtual void applyPersistanceText(const char* buf) {} + virtual void setFgColor(Scheme::SchemeColor sc) {} + virtual void setBgColor(Scheme::SchemeColor sc) {} + virtual void setFgColor(int r,int g,int b,int a) {} + virtual void setBgColor(int r,int g,int b,int a) {} + virtual void getFgColor(int& r,int& g,int& b,int& a) {} + virtual void getBgColor(int& r,int& g,int& b,int& a) {} + virtual void setBgColor(Color color) {} + virtual void setFgColor(Color color) {} + virtual void getBgColor(Color& color) {} + virtual void getFgColor(Color& color) {} + virtual void setAsMouseCapture(bool state) {} + virtual void setAsMouseArena(bool state) {} + virtual App* getApp() {return 0;} + virtual void getVirtualSize(int& wide,int& tall) {} + virtual void setLayoutInfo(LayoutInfo* layoutInfo) {} + virtual LayoutInfo* getLayoutInfo() {return 0;} + virtual bool isCursorNone() {return false;} +public: //bullshit public + virtual void solveTraverse() {} + virtual void paintTraverse() {} + virtual void setSurfaceBaseTraverse(SurfaceBase* surfaceBase) {} +protected: + virtual void performLayout() {} + virtual void internalPerformLayout() {} + virtual void drawSetColor(Scheme::SchemeColor sc) {} + virtual void drawSetColor(int r,int g,int b,int a) {} + virtual void drawFilledRect(int x0,int y0,int x1,int y1) {} + virtual void drawOutlinedRect(int x0,int y0,int x1,int y1) {} + virtual void drawSetTextFont(Scheme::SchemeFont sf) {} + virtual void drawSetTextFont(Font* font) {} + virtual void drawSetTextColor(Scheme::SchemeColor sc) {} + virtual void drawSetTextColor(int r,int g,int b,int a) {} + virtual void drawSetTextPos(int x,int y) {} + virtual void drawPrintText(const char* str,int strlen) {} + virtual void drawPrintText(int x,int y,const char* str,int strlen) {} + virtual void drawPrintChar(char ch) {} + virtual void drawPrintChar(int x,int y,char ch) {} + virtual void drawSetTextureRGBA(int id,const char* rgba,int wide,int tall) {} + virtual void drawSetTexture(int id) {} + virtual void drawTexturedRect(int x0,int y0,int x1,int y1) {} + virtual void solve() {} + virtual void paintTraverse(bool repaint) {if(repaint) paintBackground();} + virtual void paintBackground() {} + virtual void paint() {} + virtual void paintBuildOverlay() {} + virtual void internalCursorMoved(int x,int y) {} + virtual void internalCursorEntered() {} + virtual void internalCursorExited() {} + virtual void internalMousePressed(MouseCode code) {} + virtual void internalMouseDoublePressed(MouseCode code) {} + virtual void internalMouseReleased(MouseCode code) {} + virtual void internalMouseWheeled(int delta) {} + virtual void internalKeyPressed(KeyCode code) {} + virtual void internalKeyTyped(KeyCode code) {} + virtual void internalKeyReleased(KeyCode code) {} + virtual void internalKeyFocusTicked() {} + virtual void internalFocusChanged(bool lost) {} + virtual void internalSetCursor() {} +protected: + int _pos[2]; + int _size[2]; + int _loc[2]; + int _minimumSize[2]; + int _preferredSize[2]; + Dar _childDar; + Panel* _parent; + SurfaceBase* _surfaceBase; + Dar _inputSignalDar; + Dar _repaintSignalDar; + int _clipRect[4]; + Cursor* _cursor; + Scheme::SchemeCursor _schemeCursor; + bool _visible; + Layout* _layout; + bool _needsLayout; + FocusNavGroup* _focusNavGroup; + Dar _focusChangeSignalDar; + bool _autoFocusNavEnabled; + Border* _border; +private: + bool _needsRepaint; + bool _enabled; + BuildGroup* _buildGroup; + Color _fgColor; + Color _bgColor; + LayoutInfo* _layoutInfo; + bool _paintBorderEnabled; + bool _paintBackgroundEnabled; + bool _paintEnabled; +friend class Panel; +friend class App; +friend class SurfaceBase; +friend class Image; +}; +} + +#endif diff --git a/utils/false_vgui/include/VGUI_Scheme.h b/utils/false_vgui/include/VGUI_Scheme.h new file mode 100644 index 00000000..e32d7976 --- /dev/null +++ b/utils/false_vgui/include/VGUI_Scheme.h @@ -0,0 +1,82 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_SCHEME_H +#define VGUI_SCHEME_H + +#include + + +namespace vgui +{ + +class Font; +class Cursor; + +class VGUIAPI Scheme +{ +public: + enum SchemeColor + { + sc_user=0, + sc_black, + sc_white, + sc_primary1, + sc_primary2, + sc_primary3, + sc_secondary1, + sc_secondary2, + sc_secondary3, + sc_last + }; + enum SchemeFont + { + sf_user=0, + sf_primary1, + sf_primary2, + sf_primary3, + sf_secondary1, + sf_last + }; + enum SchemeCursor + { + scu_user=0, + scu_none, + scu_arrow, + scu_ibeam, + scu_hourglass, + scu_crosshair, + scu_up, + scu_sizenwse, + scu_sizenesw, + scu_sizewe, + scu_sizens, + scu_sizeall, + scu_no, + scu_hand, + scu_last + }; +public: + Scheme() {} +public: + virtual void setColor(SchemeColor sc,int r,int g,int b,int a) {} + virtual void getColor(SchemeColor sc,int& r,int& g,int& b,int& a) {} + virtual void setFont(SchemeFont sf,Font* font) {} + virtual Font* getFont(SchemeFont sf) {return 0;} + virtual void setCursor(SchemeCursor sc,Cursor* cursor) {} + virtual Cursor* getCursor(SchemeCursor sc) {return 0;} +protected: + int _color[sc_last][4]; + Font* _font[sf_last]; + Cursor* _cursor[scu_last]; + friend class Panel; + friend class Canvas; +}; + +} + +#endif From 33de8458d64353b2c4657a6c6648b4e1bc85cf86 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Wed, 6 Dec 2017 22:18:34 +0300 Subject: [PATCH 10/25] Some cleanup. Add false_vgui include path to makefiles --- cl_dll/Android.mk | 5 ++- cl_dll/CMakeLists.txt | 2 +- cl_dll/Makefile | 2 +- cl_dll/cdll_int.cpp | 3 ++ cl_dll/cl_dll.dsp | 4 +- utils/false_vgui/include/VGUI.h | 13 ------ utils/false_vgui/include/VGUI_Bitmap.h | 37 --------------- utils/false_vgui/include/VGUI_Image.h | 62 -------------------------- 8 files changed, 10 insertions(+), 118 deletions(-) delete mode 100644 utils/false_vgui/include/VGUI_Bitmap.h delete mode 100644 utils/false_vgui/include/VGUI_Image.h diff --git a/cl_dll/Android.mk b/cl_dll/Android.mk index 29aee174..452eb48b 100755 --- a/cl_dll/Android.mk +++ b/cl_dll/Android.mk @@ -91,7 +91,7 @@ SRCS+=./view.cpp SRCS+=./input_xash3d.cpp SRCS+=./scoreboard.cpp SRCS+=./MOTD.cpp -INCLUDES = -I../common -I. -I../game_shared -I../pm_shared -I../engine -I../dlls +INCLUDES = -I../common -I. -I../game_shared -I../pm_shared -I../engine -I../dlls -I../utils/false_vgui/include DEFINES = -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w LOCAL_C_INCLUDES := $(LOCAL_PATH)/. \ @@ -99,7 +99,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/. \ $(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) diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index e52a0d95..e5a3aa0a 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -27,7 +27,7 @@ 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 -L${CMAKE_CURRENT_SOURCE_DIR}/.. -lSDL2 -Wl,--no-undefined") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGOLDSOURCE_SUPPORT -lSDL2") endif() set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") diff --git a/cl_dll/Makefile b/cl_dll/Makefile index 16427f8f..f624473e 100644 --- a/cl_dll/Makefile +++ b/cl_dll/Makefile @@ -67,7 +67,7 @@ SRCS+=./view.cpp SRCS+=./input_xash3d.cpp SRCS+=./scoreboard.cpp SRCS+=./MOTD.cpp -INCLUDES = -I../common -I. -I../game_shared -I../pm_shared -I../engine -I../dlls +INCLUDES = -I../common -I. -I../game_shared -I../pm_shared -I../engine -I../dlls -I../utils/false_vgui/include DEFINES = -Wno-write-strings -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL CFLAGS = -m32 OBJS = $(SRCS:.cpp=.o) $(SRCS_C:.c=.o) diff --git a/cl_dll/cdll_int.cpp b/cl_dll/cdll_int.cpp index 1901d9d2..7427ef80 100644 --- a/cl_dll/cdll_int.cpp +++ b/cl_dll/cdll_int.cpp @@ -239,6 +239,7 @@ int DLLEXPORT HUD_VidInit( void ) #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) @@ -250,6 +251,8 @@ int DLLEXPORT HUD_VidInit( void ) 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; diff --git a/cl_dll/cl_dll.dsp b/cl_dll/cl_dll.dsp index e8ae7d15..17beb9ae 100644 --- a/cl_dll/cl_dll.dsp +++ b/cl_dll/cl_dll.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 1 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\utils\vgui\include" /I "..\engine" /I "..\common" /I "..\pm_shared" /I "..\dlls" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "CLIENT_DLL" /D "CLIENT_WEAPONS" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\utils\false_vgui\include" /I "..\engine" /I "..\common" /I "..\pm_shared" /I "..\dlls" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "CLIENT_DLL" /D "CLIENT_WEAPONS" /YX /FD /c # SUBTRACT CPP /Z # ADD BASE MTL /nologo /D "NDEBUG" /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 @@ -80,7 +80,7 @@ SOURCE="$(InputPath)" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /G5 /MTd /W3 /Gm /GR /GX /ZI /Od /I "..\dlls" /I "..\common" /I "..\pm_shared" /I "..\engine" /I "..\utils\vgui\include" /I "..\game_shared" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "CLIENT_DLL" /D "CLIENT_WEAPONS" /FR /YX /FD /c +# ADD CPP /nologo /G5 /MTd /W3 /Gm /GR /GX /ZI /Od /I "..\dlls" /I "..\common" /I "..\pm_shared" /I "..\engine" /I "..\utils\false_vgui\include" /I "..\game_shared" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "CLIENT_DLL" /D "CLIENT_WEAPONS" /FR /YX /FD /c # ADD BASE MTL /nologo /D "_DEBUG" /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "_DEBUG" diff --git a/utils/false_vgui/include/VGUI.h b/utils/false_vgui/include/VGUI.h index 0dff607a..c33e0589 100644 --- a/utils/false_vgui/include/VGUI.h +++ b/utils/false_vgui/include/VGUI.h @@ -91,18 +91,5 @@ typedef unsigned short ushort; typedef unsigned int uint; typedef unsigned long ulong; -namespace vgui -{ - -VGUIAPI void vgui_setMalloc(void *(*malloc)(size_t size) ); -VGUIAPI void vgui_setFree(void (*free)(void* memblock)); -VGUIAPI void vgui_strcpy(char* dst,int dstLen,const char* src); -VGUIAPI char* vgui_strdup(const char* src); -VGUIAPI int vgui_printf(const char* format,...); -VGUIAPI int vgui_dprintf(const char* format,...); -VGUIAPI int vgui_dprintf2(const char* format,...); - -} - #endif diff --git a/utils/false_vgui/include/VGUI_Bitmap.h b/utils/false_vgui/include/VGUI_Bitmap.h deleted file mode 100644 index a2cc7a45..00000000 --- a/utils/false_vgui/include/VGUI_Bitmap.h +++ /dev/null @@ -1,37 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#ifndef VGUI_BITMAP_H -#define VGUI_BITMAP_H - -#include -#include - -namespace vgui -{ - -class Panel; - -class VGUIAPI Bitmap : public Image -{ -private: - int _id; - bool _uploaded; -public: - Bitmap() {} -protected: - virtual void setSize(int wide,int tall) {} - virtual void setRGBA(int x,int y,uchar r,uchar g,uchar b,uchar a) {} -public: - virtual void paint(Panel* panel) {} -protected: - uchar* _rgba; -}; - -} - -#endif diff --git a/utils/false_vgui/include/VGUI_Image.h b/utils/false_vgui/include/VGUI_Image.h deleted file mode 100644 index ff83f047..00000000 --- a/utils/false_vgui/include/VGUI_Image.h +++ /dev/null @@ -1,62 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#ifndef VGUI_IMAGE_H -#define VGUI_IMAGE_H - -#include -#include -#include - -//TODO:: needs concept of insets - -namespace vgui -{ - -class Panel; - -class VGUIAPI Image -{ -friend class Panel; -private: - int _pos[2]; - int _size[2]; - Panel* _panel; - Color _color; -public: - Image(); -public: - virtual void setPos(int x,int y) {} - virtual void getPos(int& x,int& y) {} - virtual void getSize(int& wide,int& tall) {} - virtual void setColor(Color color) {} - virtual void getColor(Color& color) {} -protected: - virtual void setSize(int wide,int tall) {} - virtual void drawSetColor(Scheme::SchemeColor sc) {} - virtual void drawSetColor(int r,int g,int b,int a) {} - virtual void drawFilledRect(int x0,int y0,int x1,int y1) {} - virtual void drawOutlinedRect(int x0,int y0,int x1,int y1) {} - virtual void drawSetTextFont(Scheme::SchemeFont sf) {} - virtual void drawSetTextFont(Font* font) {} - virtual void drawSetTextColor(Scheme::SchemeColor sc) {} - virtual void drawSetTextColor(int r,int g,int b,int a) {} - virtual void drawSetTextPos(int x,int y) {} - virtual void drawPrintText(const char* str,int strlen) {} - virtual void drawPrintText(int x,int y,const char* str,int strlen) {} - virtual void drawPrintChar(char ch) {} - virtual void drawPrintChar(int x,int y,char ch) {} - virtual void drawSetTextureRGBA(int id,const char* rgba,int wide,int tall) {} - virtual void drawSetTexture(int id) {} - virtual void drawTexturedRect(int x0,int y0,int x1,int y1) {} - virtual void paint(Panel* panel) {} -public: - virtual void doPaint(Panel* panel) {} -}; -} - -#endif From ca590f24208f7cf37889f833286822e33f4a1b5f Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Thu, 7 Dec 2017 00:31:27 +0300 Subject: [PATCH 11/25] Use old API to draw scoreboard and motd lines in goldsource --- cl_dll/cdll_int.cpp | 5 +++++ cl_dll/cl_util.h | 6 +++++- cl_dll/hud_redraw.cpp | 42 ++++++++++++++++++++++++------------------ cl_dll/input_mouse.cpp | 3 ++- 4 files changed, 36 insertions(+), 20 deletions(-) diff --git a/cl_dll/cdll_int.cpp b/cl_dll/cdll_int.cpp index d71659e9..80b45e31 100644 --- a/cl_dll/cdll_int.cpp +++ b/cl_dll/cdll_int.cpp @@ -305,3 +305,8 @@ void DLLEXPORT HUD_MobilityInterface( mobile_engfuncs_t *gpMobileEngfuncs ) return; gMobileEngfuncs = gpMobileEngfuncs; } + +bool isXashFWGS() +{ + return gMobileEngfuncs != NULL; +} diff --git a/cl_dll/cl_util.h b/cl_dll/cl_util.h index 1996543d..23f12230 100644 --- a/cl_dll/cl_util.h +++ b/cl_dll/cl_util.h @@ -15,7 +15,8 @@ // // cl_util.h // - +#ifndef CL_UTIL_H +#define CL_UTIL_H #include "exportdef.h" #include "cvardef.h" @@ -179,3 +180,6 @@ inline void UnpackRGB( int &r, int &g, int &b, unsigned long ulRGB )\ } HSPRITE LoadSprite( const char *pszName ); + +bool isXashFWGS(); +#endif diff --git a/cl_dll/hud_redraw.cpp b/cl_dll/hud_redraw.cpp index 829fd4b2..06b25a33 100644 --- a/cl_dll/hud_redraw.cpp +++ b/cl_dll/hud_redraw.cpp @@ -235,29 +235,35 @@ int CHud::DrawHudString( int xpos, int ypos, int iMaxX, const char *szIt, int r, int DrawUtfString( int xpos, int ypos, int iMaxX, const char *szIt, int r, int g, int b ) { - // 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++ ) + if (isXashFWGS()) { - int w = gHUD.m_scrinfo.charWidths['M']; - if( xpos + w > iMaxX ) - return xpos; - if( ( *szIt == '^' ) && ( *( szIt + 1 ) >= '0') && ( *( szIt + 1 ) <= '7') ) + // 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++ ) { - szIt++; - r = colors[*szIt - '0'][0]; - g = colors[*szIt - '0'][1]; - b = colors[*szIt - '0'][2]; - if( !*(++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 ); } - 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); } - - return xpos; } int CHud::DrawHudStringLen( const char *szIt ) diff --git a/cl_dll/input_mouse.cpp b/cl_dll/input_mouse.cpp index 724824cd..8d57091b 100644 --- a/cl_dll/input_mouse.cpp +++ b/cl_dll/input_mouse.cpp @@ -1,6 +1,7 @@ #include "input_mouse.h" #include "exportdef.h" #include "hud.h" +#include "cl_util.h" // shared between backends Vector dead_viewangles(0, 0, 0); @@ -68,7 +69,7 @@ void IN_Shutdown( void ) void IN_Init( void ) { #ifdef SUPPORT_GOLDSOURCE_INPUT - if (gMobileEngfuncs) { + if (isXashFWGS()) { gEngfuncs.Con_Printf( "FWGS Xash3D input is in use\n" ); currentInput = &fwgsInput; } else { From 1759e8c956e1d4cbd42e9a6d17c1d4208b5b8f1a Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Thu, 7 Dec 2017 01:25:59 +0300 Subject: [PATCH 12/25] Dynamic sdl2 loading from client --- cl_dll/CMakeLists.txt | 5 ++- cl_dll/input_goldsource.cpp | 73 ++++++++++++++++++++++++++++--------- cl_dll/input_mouse.h | 1 + 3 files changed, 60 insertions(+), 19 deletions(-) diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index e5a3aa0a..e3ac075a 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -27,7 +27,10 @@ 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 -lSDL2") + 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}") diff --git a/cl_dll/input_goldsource.cpp b/cl_dll/input_goldsource.cpp index 5c2b0381..7c0e6183 100644 --- a/cl_dll/input_goldsource.cpp +++ b/cl_dll/input_goldsource.cpp @@ -28,8 +28,18 @@ #endif #ifdef USE_SDL2 +#include #include #include +int (*pfnSDL_SetRelativeMouseMode)(SDL_bool); +Uint32 (*pfnSDL_GetRelativeMouseState)(int* x, int* y); +int (*pfnSDL_NumJoysticks)(void); +SDL_bool (*pfnSDL_IsGameController)(int); +SDL_GameController* (*pfnSDL_GameControllerOpen)(int); +Sint16 (*pfnSDL_GameControllerGetAxis)(SDL_GameController*, SDL_GameControllerAxis); +Uint8 (*pfnSDL_GameControllerGetButton)(SDL_GameController*, SDL_GameControllerButton); +void (*pfnSDL_JoystickUpdate)(void); +const char* (*pfnSDL_GameControllerName)(SDL_GameController*); #endif #ifdef _WIN32 @@ -289,12 +299,12 @@ void IN_SetMouseMode(bool enable) if(m_bRawInput) { #ifdef USE_SDL2 - SDL_SetRelativeMouseMode(SDL_TRUE); + pfnSDL_SetRelativeMouseMode(SDL_TRUE); #endif isMouseRelative = true; } #else - SDL_SetRelativeMouseMode(SDL_TRUE); + pfnSDL_SetRelativeMouseMode(SDL_TRUE); #endif currentMouseMode = true; @@ -305,7 +315,7 @@ void IN_SetMouseMode(bool enable) if(isMouseRelative) { #ifdef USE_SDL2 - SDL_SetRelativeMouseMode(SDL_FALSE); + pfnSDL_SetRelativeMouseMode(SDL_FALSE); #endif isMouseRelative = false; } @@ -313,7 +323,7 @@ void IN_SetMouseMode(bool enable) if (restore_spi) SystemParametersInfo (SPI_SETMOUSE, 0, originalmouseparms, 0); #else - SDL_SetRelativeMouseMode(SDL_FALSE); + pfnSDL_SetRelativeMouseMode(SDL_FALSE); #endif currentMouseMode = false; @@ -464,6 +474,11 @@ void GoldSourceInput::IN_Shutdown (void) s_hMouseThreadActiveLock = (HANDLE)0; } #endif + +#ifdef USE_SDL2 + dlclose(sdl2Lib); + sdl2Lib = NULL; +#endif } /* @@ -623,7 +638,7 @@ void GoldSourceInput::IN_GetMouseDelta( int *pOutX, int *pOutY) #endif { #ifdef USE_SDL2 - SDL_GetRelativeMouseState( &deltaX, &deltaY ); + pfnSDL_GetRelativeMouseState( &deltaX, &deltaY ); current_pos.x = deltaX; current_pos.y = deltaY; #else @@ -679,14 +694,14 @@ void GoldSourceInput::IN_GetMouseDelta( int *pOutX, int *pOutY) if(m_bRawInput && !isMouseRelative) { #ifdef USE_SDL2 - SDL_SetRelativeMouseMode(SDL_TRUE); + pfnSDL_SetRelativeMouseMode(SDL_TRUE); #endif isMouseRelative = true; } else if(!m_bRawInput && isMouseRelative) { #ifdef USE_SDL2 - SDL_SetRelativeMouseMode(SDL_FALSE); + pfnSDL_SetRelativeMouseMode(SDL_FALSE); #endif isMouseRelative = false; } @@ -815,7 +830,7 @@ void GoldSourceInput::IN_Accumulate (void) { #ifdef USE_SDL2 int deltaX, deltaY; - SDL_GetRelativeMouseState( &deltaX, &deltaY ); + pfnSDL_GetRelativeMouseState( &deltaX, &deltaY ); mx_accum += deltaX; my_accum += deltaY; #else @@ -869,14 +884,14 @@ void IN_StartupJoystick (void) // assume no joystick joy_avail = 0; #ifdef USE_SDL2 - int nJoysticks = SDL_NumJoysticks(); + int nJoysticks = pfnSDL_NumJoysticks(); if ( nJoysticks > 0 ) { for ( int i = 0; i < nJoysticks; i++ ) { - if ( SDL_IsGameController( i ) ) + if ( pfnSDL_IsGameController( i ) ) { - s_pJoystick = SDL_GameControllerOpen( i ); + s_pJoystick = pfnSDL_GameControllerOpen( i ); if ( s_pJoystick ) { //save the joystick's number of buttons and POV status @@ -888,7 +903,7 @@ void IN_StartupJoystick (void) // 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", SDL_GameControllerName(s_pJoystick)); + gEngfuncs.Con_Printf ("joystick found\n\n", pfnSDL_GameControllerName(s_pJoystick)); joy_avail = 1; joy_advancedinit = 0; break; @@ -912,13 +927,13 @@ int RawValuePointer (int axis) { default: case JOY_AXIS_X: - return SDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_LEFTX ); + return pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_LEFTX ); case JOY_AXIS_Y: - return SDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_LEFTY ); + return pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_LEFTY ); case JOY_AXIS_Z: - return SDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_RIGHTX ); + return pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_RIGHTX ); case JOY_AXIS_R: - return SDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_RIGHTY ); + return pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_RIGHTY ); } #else @@ -1011,7 +1026,7 @@ void GoldSourceInput::IN_Commands (void) #ifdef USE_SDL2 for ( i = 0; i < SDL_CONTROLLER_BUTTON_MAX; i++ ) { - if ( SDL_GameControllerGetButton( s_pJoystick, (SDL_GameControllerButton)i ) ) + if ( pfnSDL_GameControllerGetButton( s_pJoystick, (SDL_GameControllerButton)i ) ) { buttonstate |= 1< Date: Thu, 7 Dec 2017 04:43:25 +0300 Subject: [PATCH 13/25] Provide safe wrappers around sdl function pointers. Use dylib extension on macOS --- cl_dll/input_goldsource.cpp | 137 ++++++++++++++++++++++++++++-------- 1 file changed, 108 insertions(+), 29 deletions(-) diff --git a/cl_dll/input_goldsource.cpp b/cl_dll/input_goldsource.cpp index 7c0e6183..e367a37e 100644 --- a/cl_dll/input_goldsource.cpp +++ b/cl_dll/input_goldsource.cpp @@ -40,6 +40,63 @@ Sint16 (*pfnSDL_GameControllerGetAxis)(SDL_GameController*, SDL_GameControllerAx Uint8 (*pfnSDL_GameControllerGetButton)(SDL_GameController*, SDL_GameControllerButton); void (*pfnSDL_JoystickUpdate)(void); const char* (*pfnSDL_GameControllerName)(SDL_GameController*); + +int safe_pfnSDL_SetRelativeMouseMode(SDL_bool mode) +{ + if (pfnSDL_SetRelativeMouseMode) + return pfnSDL_SetRelativeMouseMode(mode); + return -1; +} +Uint32 safe_pfnSDL_GetRelativeMouseState(int* x, int* y) +{ + if (pfnSDL_GetRelativeMouseState) + return pfnSDL_GetRelativeMouseState(x, y); + return 0; +} +int safe_pfnSDL_NumJoysticks() +{ + if (pfnSDL_NumJoysticks) + return pfnSDL_NumJoysticks(); + return -1; +} +SDL_bool safe_pfnSDL_IsGameController(int joystick_index) +{ + if (pfnSDL_IsGameController) + return pfnSDL_IsGameController(joystick_index); + return SDL_FALSE; +} +SDL_GameController* safe_pfnSDL_GameControllerOpen(int joystick_index) +{ + if (pfnSDL_GameControllerOpen) + return pfnSDL_GameControllerOpen(joystick_index); + return NULL; +} +Sint16 safe_pfnSDL_GameControllerGetAxis(SDL_GameController* gamecontroller, SDL_GameControllerAxis axis) +{ + if (pfnSDL_GameControllerGetAxis) + return pfnSDL_GameControllerGetAxis(gamecontroller, axis); + return 0; +} +Uint8 safe_pfnSDL_GameControllerGetButton(SDL_GameController* gamecontroller, SDL_GameControllerButton button) +{ + if (pfnSDL_GameControllerGetButton) + return pfnSDL_GameControllerGetButton(gamecontroller, button); + return 0; +} +void safe_pfnSDL_JoystickUpdate() +{ + if (pfnSDL_JoystickUpdate) + pfnSDL_JoystickUpdate(); +} +const char* safe_pfnSDL_GameControllerName(SDL_GameController* gamecontroller) +{ + if (pfnSDL_GameControllerName) + return pfnSDL_GameControllerName(gamecontroller); + return NULL; +} +static void** const sdlFunctionPointers[] = {(void**)&pfnSDL_SetRelativeMouseMode, (void**)&pfnSDL_GetRelativeMouseState, (void**)&pfnSDL_NumJoysticks, + (void**)&pfnSDL_IsGameController, (void**)&pfnSDL_GameControllerOpen, (void**)&pfnSDL_GameControllerGetAxis, + (void**)&pfnSDL_GameControllerGetButton, (void**)&pfnSDL_JoystickUpdate, (void**)&pfnSDL_GameControllerName}; #endif #ifdef _WIN32 @@ -299,12 +356,12 @@ void IN_SetMouseMode(bool enable) if(m_bRawInput) { #ifdef USE_SDL2 - pfnSDL_SetRelativeMouseMode(SDL_TRUE); + safe_pfnSDL_SetRelativeMouseMode(SDL_TRUE); #endif isMouseRelative = true; } #else - pfnSDL_SetRelativeMouseMode(SDL_TRUE); + safe_pfnSDL_SetRelativeMouseMode(SDL_TRUE); #endif currentMouseMode = true; @@ -315,7 +372,7 @@ void IN_SetMouseMode(bool enable) if(isMouseRelative) { #ifdef USE_SDL2 - pfnSDL_SetRelativeMouseMode(SDL_FALSE); + safe_pfnSDL_SetRelativeMouseMode(SDL_FALSE); #endif isMouseRelative = false; } @@ -323,7 +380,7 @@ void IN_SetMouseMode(bool enable) if (restore_spi) SystemParametersInfo (SPI_SETMOUSE, 0, originalmouseparms, 0); #else - pfnSDL_SetRelativeMouseMode(SDL_FALSE); + safe_pfnSDL_SetRelativeMouseMode(SDL_FALSE); #endif currentMouseMode = false; @@ -476,6 +533,9 @@ void GoldSourceInput::IN_Shutdown (void) #endif #ifdef USE_SDL2 + for (int j=0; j 0 ) { for ( int i = 0; i < nJoysticks; i++ ) { - if ( pfnSDL_IsGameController( i ) ) + if ( safe_pfnSDL_IsGameController( i ) ) { - s_pJoystick = pfnSDL_GameControllerOpen( i ); + s_pJoystick = safe_pfnSDL_GameControllerOpen( i ); if ( s_pJoystick ) { //save the joystick's number of buttons and POV status @@ -903,7 +963,7 @@ void IN_StartupJoystick (void) // 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", pfnSDL_GameControllerName(s_pJoystick)); + gEngfuncs.Con_Printf ("joystick found\n\n", safe_pfnSDL_GameControllerName(s_pJoystick)); joy_avail = 1; joy_advancedinit = 0; break; @@ -927,13 +987,13 @@ int RawValuePointer (int axis) { default: case JOY_AXIS_X: - return pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_LEFTX ); + return safe_pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_LEFTX ); case JOY_AXIS_Y: - return pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_LEFTY ); + return safe_pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_LEFTY ); case JOY_AXIS_Z: - return pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_RIGHTX ); + return safe_pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_RIGHTX ); case JOY_AXIS_R: - return pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_RIGHTY ); + return safe_pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_RIGHTY ); } #else @@ -1026,7 +1086,7 @@ void GoldSourceInput::IN_Commands (void) #ifdef USE_SDL2 for ( i = 0; i < SDL_CONTROLLER_BUTTON_MAX; i++ ) { - if ( pfnSDL_GameControllerGetButton( s_pJoystick, (SDL_GameControllerButton)i ) ) + if ( safe_pfnSDL_GameControllerGetButton( s_pJoystick, (SDL_GameControllerButton)i ) ) { buttonstate |= 1< Date: Thu, 7 Dec 2017 21:25:26 +0300 Subject: [PATCH 14/25] sdl loading refactoring --- cl_dll/input_goldsource.cpp | 58 ++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 33 deletions(-) diff --git a/cl_dll/input_goldsource.cpp b/cl_dll/input_goldsource.cpp index e367a37e..38dac71d 100644 --- a/cl_dll/input_goldsource.cpp +++ b/cl_dll/input_goldsource.cpp @@ -28,6 +28,7 @@ #endif #ifdef USE_SDL2 +#define ARRAYSIZE(p) ( sizeof(p) /sizeof(p[0]) ) #include #include #include @@ -94,9 +95,23 @@ const char* safe_pfnSDL_GameControllerName(SDL_GameController* gamecontroller) return pfnSDL_GameControllerName(gamecontroller); return NULL; } -static void** const sdlFunctionPointers[] = {(void**)&pfnSDL_SetRelativeMouseMode, (void**)&pfnSDL_GetRelativeMouseState, (void**)&pfnSDL_NumJoysticks, - (void**)&pfnSDL_IsGameController, (void**)&pfnSDL_GameControllerOpen, (void**)&pfnSDL_GameControllerGetAxis, - (void**)&pfnSDL_GameControllerGetButton, (void**)&pfnSDL_JoystickUpdate, (void**)&pfnSDL_GameControllerName}; + +struct SDLFunction +{ + void** ppfnFunc; + const char* name; +}; +static SDLFunction sdlFunctions[] = { + {(void**)&pfnSDL_SetRelativeMouseMode, "SDL_SetRelativeMouseMode"}, + {(void**)&pfnSDL_GetRelativeMouseState, "SDL_GetRelativeMouseState"}, + {(void**)&pfnSDL_NumJoysticks, "SDL_NumJoysticks"}, + {(void**)&pfnSDL_IsGameController, "SDL_IsGameController"}, + {(void**)&pfnSDL_GameControllerOpen, "SDL_GameControllerOpen"}, + {(void**)&pfnSDL_GameControllerGetAxis, "SDL_GameControllerGetAxis"}, + {(void**)&pfnSDL_GameControllerGetButton, "SDL_GameControllerGetButton"}, + {(void**)&pfnSDL_JoystickUpdate, "SDL_JoystickUpdate"}, + {(void**)&pfnSDL_GameControllerName, "SDL_GameControllerName"} +}; #endif #ifdef _WIN32 @@ -533,8 +548,8 @@ void GoldSourceInput::IN_Shutdown (void) #endif #ifdef USE_SDL2 - for (int j=0; j Date: Sat, 9 Dec 2017 00:16:29 +0300 Subject: [PATCH 15/25] Update README.md, update makefiles, add .bat scripts for msvc --- README.md | 92 +++++++++++++++++++++++++++++----- cl_dll/Android.mk | 4 +- cl_dll/Makefile | 1 - cl_dll/compile.bat | 84 +++++++++++++++++++++++++++++++ dlls/Makefile | 4 +- dlls/compile.bat | 121 +++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 291 insertions(+), 15 deletions(-) create mode 100644 cl_dll/compile.bat create mode 100644 dlls/compile.bat diff --git a/README.md b/README.md index bb1cc675..21db93fb 100644 --- a/README.md +++ b/README.md @@ -6,22 +6,41 @@ Half-Life SDK for Xash3D & GoldSource with some fixes. ### CMake as most universal way -``` -mkdir build && cd build -cmake ../ -``` + mkdir build && cd build + cmake ../ + make 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 -TODO + (cd dlls && make) + (cd cl_dll && make) ### OS X @@ -29,14 +48,65 @@ TODO ### FreeBSD -``` - cd dlls - gmake CXX=clang++ CC=clang - cd ../cl_dll - gmake CXX=clang++ CC=clang -``` + (cd dlls && gmake CXX=clang++ CC=clang) + (cd cl_dll && gmake CXX=clang++ CC=clang) ### Android Just typical `ndk-build`. +TODO: describe what it is. + +### Building GoldSource-compatible libraries + +To enable building the goldsource compatible client library add GOLDSOURCE_SUPPORT flag when calling cmake: + + cmake .. -DGOLDSOURCE_SUPPORT=ON + +or when using make without cmake: + + make GOLDSOURCE_SUPPORT=1 + +Unlike original client by Valve the resulting client library will not depend on vgui or SDL2 just like the one that's used in FWGS Xash3d. + +Note for **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: Create and use 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 --`: + + schroot -c jessie -- cmake ../ -DGOLDSOURCE_SUPPORT=ON + schroot -c jessie -- make + +#### Method 3: Install the needed g++ version yourself +TODO: describe steps. diff --git a/cl_dll/Android.mk b/cl_dll/Android.mk index 452eb48b..68917633 100755 --- a/cl_dll/Android.mk +++ b/cl_dll/Android.mk @@ -105,7 +105,9 @@ LOCAL_CFLAGS += $(DEFINES) $(INCLUDES) ifeq ($(GOLDSOURCE_SUPPORT),1) DEFINES += -DGOLDSOURCE_SUPPORT - LOCAL_LDLIBS += -lSDL2 + ifeq ($(shell uname -s),Linux) + LOCAL_LDLIBS += -ldl + endif endif LOCAL_SRC_FILES := $(SRCS) $(SRCS_C) diff --git a/cl_dll/Makefile b/cl_dll/Makefile index f624473e..0ff4dadf 100644 --- a/cl_dll/Makefile +++ b/cl_dll/Makefile @@ -75,7 +75,6 @@ OBJS = $(SRCS:.cpp=.o) $(SRCS_C:.c=.o) LIBS=-lm ifeq ($(GOLDSOURCE_SUPPORT),1) DEFINES += -DGOLDSOURCE_SUPPORT - LIBS += -lSDL2 endif ifeq ($(shell uname -s),Linux) diff --git a/cl_dll/compile.bat b/cl_dll/compile.bat new file mode 100644 index 00000000..9270d4bc --- /dev/null +++ b/cl_dll/compile.bat @@ -0,0 +1,84 @@ +@echo off +echo Setting environment for minimal Visual C++ 6 +set INCLUDE=%MSVCDir%\VC98\Include +set LIB=%MSVCDir%\VC98\Lib +set PATH=%MSVCDir%\VC98\Bin;%MSVCDir%\Common\MSDev98\Bin\;%PATH% + +echo -- Compiler is MSVC6 + +set XASH3DSRC=..\..\Xash3D_original +set INCLUDES=-I../common -I../engine -I../pm_shared -I../game_shared -I../public -I../external -I../dlls -I../utils/false_vgui/include +set SOURCES=../dlls/crossbow.cpp^ + ../dlls/crowbar.cpp^ + ../dlls/egon.cpp^ + ../dlls/gauss.cpp^ + ../dlls/handgrenade.cpp^ + ../dlls/hornetgun.cpp^ + ../dlls/mp5.cpp^ + ../dlls/python.cpp^ + ../dlls/rpg.cpp^ + ../dlls/satchel.cpp^ + ../dlls/shotgun.cpp^ + ../dlls/squeakgrenade.cpp^ + ../dlls/tripmine.cpp^ + ../dlls/glock.cpp^ + ev_hldm.cpp^ + hl/hl_baseentity.cpp^ + hl/hl_events.cpp^ + hl/hl_objects.cpp^ + hl/hl_weapons.cpp^ + ammo.cpp^ + ammo_secondary.cpp^ + ammohistory.cpp^ + battery.cpp^ + cdll_int.cpp^ + com_weapons.cpp^ + death.cpp^ + demo.cpp^ + entity.cpp^ + ev_common.cpp^ + events.cpp^ + flashlight.cpp^ + GameStudioModelRenderer.cpp^ + geiger.cpp^ + health.cpp^ + hud.cpp^ + hud_msg.cpp^ + hud_redraw.cpp^ + hud_spectator.cpp^ + hud_update.cpp^ + in_camera.cpp^ + input.cpp^ + input_goldsource.cpp^ + input_mouse.cpp^ + input_xash3d.cpp^ + menu.cpp^ + message.cpp^ + overview.cpp^ + parsemsg.cpp^ + ../pm_shared/pm_debug.c^ + ../pm_shared/pm_math.c^ + ../pm_shared/pm_shared.c^ + saytext.cpp^ + status_icons.cpp^ + statusbar.cpp^ + studio_util.cpp^ + StudioModelRenderer.cpp^ + text_message.cpp^ + train.cpp^ + tri.cpp^ + util.cpp^ + view.cpp^ + scoreboard.cpp^ + MOTD.cpp +set DEFINES=/DCLIENT_DLL /DCLIENT_WEAPONS /Dsnprintf=_snprintf /DNO_VOICEGAMEMGR /DGOLDSOURCE_SUPPORT +set LIBS=user32.lib Winmm.lib +set OUTNAME=client.dll +set DEBUG=/debug + +cl %DEFINES% %LIBS% %SOURCES% %INCLUDES% -o %OUTNAME% /link /dll /out:%OUTNAME% %DEBUG% + +echo -- Compile done. Cleaning... + +del *.obj *.exp *.lib *.ilk +echo -- Done. diff --git a/dlls/Makefile b/dlls/Makefile index 60aad1b3..3599b9c7 100644 --- a/dlls/Makefile +++ b/dlls/Makefile @@ -129,13 +129,13 @@ OBJ = \ $(DLL_OBJDIR)/multiplay_gamerules.o \ $(DLL_OBJDIR)/nihilanth.o \ $(DLL_OBJDIR)/nodes.o \ - $(DLL_OBJDIR)/observer.cpp \^M + $(DLL_OBJDIR)/observer.o \ $(DLL_OBJDIR)/osprey.o \ $(DLL_OBJDIR)/pathcorner.o \ $(DLL_OBJDIR)/plane.o \ $(DLL_OBJDIR)/plats.o \ $(DLL_OBJDIR)/player.o \ - $(DLL_OBJDIR)/playermonster.o \^M + $(DLL_OBJDIR)/playermonster.o \ $(DLL_OBJDIR)/python.o \ $(DLL_OBJDIR)/rat.o \ $(DLL_OBJDIR)/roach.o \ diff --git a/dlls/compile.bat b/dlls/compile.bat new file mode 100644 index 00000000..53c4511b --- /dev/null +++ b/dlls/compile.bat @@ -0,0 +1,121 @@ +@echo off +echo Setting environment for minimal Visual C++ 6 +set INCLUDE=%MSVCDir%\VC98\Include +set LIB=%MSVCDir%\VC98\Lib +set PATH=%MSVCDir%\VC98\Bin;%MSVCDir%\Common\MSDev98\Bin\;%PATH% + +echo -- Compiler is MSVC6 + +set XASH3DSRC=..\..\Xash3D_original +set INCLUDES=-I../common -I../engine -I../pm_shared -I../game_shared -I../public +set SOURCES=agrunt.cpp^ + airtank.cpp^ + aflock.cpp^ + animating.cpp^ + animation.cpp^ + apache.cpp^ + barnacle.cpp^ + barney.cpp^ + bigmomma.cpp^ + bloater.cpp^ + bmodels.cpp^ + bullsquid.cpp^ + buttons.cpp^ + cbase.cpp^ + client.cpp^ + combat.cpp^ + controller.cpp^ + crossbow.cpp^ + crowbar.cpp^ + defaultai.cpp^ + doors.cpp^ + effects.cpp^ + egon.cpp^ + explode.cpp^ + flyingmonster.cpp^ + func_break.cpp^ + func_tank.cpp^ + game.cpp^ + gamerules.cpp^ + gargantua.cpp^ + gauss.cpp^ + genericmonster.cpp^ + ggrenade.cpp^ + globals.cpp^ + glock.cpp^ + gman.cpp^ + h_ai.cpp^ + h_battery.cpp^ + h_cine.cpp^ + h_cycler.cpp^ + h_export.cpp^ + handgrenade.cpp^ + hassassin.cpp^ + headcrab.cpp^ + healthkit.cpp^ + hgrunt.cpp^ + hornet.cpp^ + hornetgun.cpp^ + houndeye.cpp^ + ichthyosaur.cpp^ + islave.cpp^ + items.cpp^ + leech.cpp^ + lights.cpp^ + maprules.cpp^ + monstermaker.cpp^ + monsters.cpp^ + monsterstate.cpp^ + mortar.cpp^ + mp5.cpp^ + multiplay_gamerules.cpp^ + nihilanth.cpp^ + nodes.cpp^ + observer.cpp^ + osprey.cpp^ + pathcorner.cpp^ + plane.cpp^ + plats.cpp^ + player.cpp^ + playermonster.cpp^ + python.cpp^ + rat.cpp^ + roach.cpp^ + rpg.cpp^ + satchel.cpp^ + schedule.cpp^ + scientist.cpp^ + scripted.cpp^ + shotgun.cpp^ + singleplay_gamerules.cpp^ + skill.cpp^ + sound.cpp^ + soundent.cpp^ + spectator.cpp^ + squadmonster.cpp^ + squeakgrenade.cpp^ + subs.cpp^ + talkmonster.cpp^ + teamplay_gamerules.cpp^ + tempmonster.cpp^ + tentacle.cpp^ + triggers.cpp^ + tripmine.cpp^ + turret.cpp^ + util.cpp^ + weapons.cpp^ + world.cpp^ + xen.cpp^ + zombie.cpp^ + ../pm_shared/pm_debug.c ../pm_shared/pm_math.c ../pm_shared/pm_shared.c +set DEFINES=/DCLIENT_WEAPONS /Dsnprintf=_snprintf /DNO_VOICEGAMEMGR +set LIBS=user32.lib +set OUTNAME=hl.dll +set DEBUG=/debug + +cl %DEFINES% %LIBS% %SOURCES% %INCLUDES% -o %OUTNAME% /link /dll /out:%OUTNAME% %DEBUG% /def:".\hl.def" + +echo -- Compile done. Cleaning... + +del *.obj *.exp *.lib *.ilk +echo -- Done. From 0d56674e28cf6d08eda6cca79ce208a16a1af6bd Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Sat, 9 Dec 2017 13:49:31 +0300 Subject: [PATCH 16/25] Add steam runtime chroot method --- README.md | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 21db93fb..f0d3b4a1 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,21 @@ This one is the most simple but has a drawback. The drawback is that the compiled libraries will be larger in size. -#### Method 2: Create and use chroot with older distro that includes g++ 4. +#### 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. @@ -104,9 +118,10 @@ personality=linux32 Insert your actual user name in place of `yourusername`. Then prepend any make or cmake call with `schroot -c jessie --`: - schroot -c jessie -- cmake ../ -DGOLDSOURCE_SUPPORT=ON - schroot -c jessie -- make + mkdir build-in-chroot && cd build-in-chroot + schroot --chroot jessie -- cmake ../ -DGOLDSOURCE_SUPPORT=ON + schroot --chroot jessie -- make -#### Method 3: Install the needed g++ version yourself +#### Method 4: Install the needed g++ version yourself TODO: describe steps. From 87d6ca3b687eb0f6b3745c1ec79d22aac9071783 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Sat, 9 Dec 2017 14:45:54 +0300 Subject: [PATCH 17/25] Add instructions for using chroot toolchain in QtCreator --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index f0d3b4a1..9261b1b3 100644 --- a/README.md +++ b/README.md @@ -125,3 +125,17 @@ Insert your actual user name in place of `yourusername`. Then prepend any make o #### 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. From 5a60f08a59651aaaac73efa4af147f2a2d391a57 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Mon, 4 Dec 2017 01:02:25 +0300 Subject: [PATCH 18/25] Joystick support for non-sdl win32 (untested) --- cl_dll/input_goldsource.cpp | 161 ++++++++++++++++++++++++++++++++++-- 1 file changed, 153 insertions(+), 8 deletions(-) diff --git a/cl_dll/input_goldsource.cpp b/cl_dll/input_goldsource.cpp index 38dac71d..f530bdbc 100644 --- a/cl_dll/input_goldsource.cpp +++ b/cl_dll/input_goldsource.cpp @@ -217,10 +217,25 @@ enum _ControlList AxisTurn }; +#if !defined(USE_SDL2) && defined(_WIN32) +DWORD dwAxisFlags[JOY_MAX_AXES] = +{ + JOY_RETURNX, + JOY_RETURNY, + JOY_RETURNZ, + JOY_RETURNR, + JOY_RETURNU, + JOY_RETURNV +}; +#endif DWORD dwAxisMap[ JOY_MAX_AXES ]; DWORD dwControlMap[ JOY_MAX_AXES ]; +#if defined(USE_SDL2) int pdwRawValue[ JOY_MAX_AXES ]; +#elif defined(_WIN32) +PDWORD pdwRawValue[ JOY_MAX_AXES ]; +#endif DWORD joy_oldbuttonstate, joy_oldpovstate; int joy_id; @@ -228,6 +243,9 @@ DWORD joy_numbuttons; #ifdef USE_SDL2 SDL_GameController *s_pJoystick = NULL; +#elif defined(_WIN32) +DWORD joy_flags; +static JOYINFOEX ji; #endif // none of these cvars are saved over a session @@ -990,14 +1008,64 @@ void IN_StartupJoystick (void) { gEngfuncs.Con_DPrintf ("joystick not found -- driver not present\n\n"); } +#elif defined(_WIN32) + int numdevs; + JOYCAPS jc; + MMRESULT mmr; + // verify joystick driver is present + if ((numdevs = joyGetNumDevs ()) == 0) + { + gEngfuncs.Con_DPrintf ("joystick not found -- driver not present\n\n"); + return; + } + + // cycle through the joystick ids for the first valid one + for (joy_id=0 ; joy_idvalue != 0.0) + { + ji.dwUpos += 100; + } + return 1; + } + else + { + // read error occurred + // turning off the joystick seems too harsh for 1 read error,\ + // but what should be done? + // Con_Printf ("IN_ReadJoystick: no response\n"); + // joy_avail = 0; + return 0; + } +#else + return 0; +#endif } @@ -1213,7 +1353,12 @@ void IN_JoyMove ( float frametime, usercmd_t *cmd ) for (i = 0; i < JOY_MAX_AXES; i++) { // get the floating point zero-centered, potentially-inverted data for the current axis +#ifdef USE_SDL2 fAxisValue = (float)pdwRawValue[i]; +#elif defined(_WIN32) + fAxisValue = (float) *pdwRawValue[i]; + fAxisValue -= 32768.0; +#endif if (joy_wwhack2->value != 0.0) { From 18adf0979fe6fe8a9af2e5f46721f198b6274e5e Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 10 Dec 2017 20:56:46 +0500 Subject: [PATCH 19/25] Redefine string_t. Fix wrong variables type. --- cl_dll/util_vector.h | 2 +- common/const.h | 2 +- dlls/bigmomma.cpp | 2 +- dlls/cbase.h | 2 +- dlls/effects.cpp | 6 +++--- dlls/effects.h | 2 +- dlls/extdll.h | 2 +- dlls/func_break.h | 4 ++-- dlls/func_tank.cpp | 6 +++--- dlls/lights.cpp | 2 +- dlls/mortar.cpp | 4 ++-- dlls/plats.cpp | 6 +++--- dlls/scripted.cpp | 6 +++--- dlls/scripted.h | 6 +++--- dlls/talkmonster.h | 4 ++-- dlls/triggers.cpp | 14 +++++++------- dlls/util.cpp | 14 +++++++------- dlls/util.h | 4 ++-- dlls/weapons.h | 2 +- 19 files changed, 45 insertions(+), 45 deletions(-) diff --git a/cl_dll/util_vector.h b/cl_dll/util_vector.h index ff5f9a91..8b596ac1 100644 --- a/cl_dll/util_vector.h +++ b/cl_dll/util_vector.h @@ -23,7 +23,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 //========================================================= diff --git a/common/const.h b/common/const.h index d29816e6..3d738675 100644 --- a/common/const.h +++ b/common/const.h @@ -733,7 +733,7 @@ enum }; typedef unsigned int func_t; -typedef unsigned int string_t; +typedef int string_t; typedef unsigned char byte; typedef unsigned short word; diff --git a/dlls/bigmomma.cpp b/dlls/bigmomma.cpp index 6b594983..434d6134 100644 --- a/dlls/bigmomma.cpp +++ b/dlls/bigmomma.cpp @@ -49,7 +49,7 @@ public: virtual int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; - int m_preSequence; + string_t m_preSequence; }; LINK_ENTITY_TO_CLASS( info_bigmomma, CInfoBM ) diff --git a/dlls/cbase.h b/dlls/cbase.h index b78de883..10f7a85f 100644 --- a/dlls/cbase.h +++ b/dlls/cbase.h @@ -438,7 +438,7 @@ class CBaseDelay : public CBaseEntity { public: float m_flDelay; - int m_iszKillTarget; + string_t m_iszKillTarget; virtual void KeyValue( KeyValueData *pkvd ); virtual int Save( CSave &save ); diff --git a/dlls/effects.cpp b/dlls/effects.cpp index 15df3bc3..5b8d650c 100644 --- a/dlls/effects.cpp +++ b/dlls/effects.cpp @@ -379,9 +379,10 @@ public: void BeamUpdateVars( void ); + string_t m_iszStartEntity; + string_t m_iszEndEntity; + string_t m_iszSpriteName; int m_active; - int m_iszStartEntity; - int m_iszEndEntity; float m_life; int m_boltWidth; int m_noiseAmplitude; @@ -389,7 +390,6 @@ public: int m_speed; float m_restrike; int m_spriteTexture; - int m_iszSpriteName; int m_frameStart; float m_radius; diff --git a/dlls/effects.h b/dlls/effects.h index 68f0ea29..f4b6b5b2 100644 --- a/dlls/effects.h +++ b/dlls/effects.h @@ -321,7 +321,7 @@ public: static TYPEDESCRIPTION m_SaveData[]; CSprite *m_pSprite; - int m_iszSpriteName; + string_t m_iszSpriteName; Vector m_firePosition; }; #endif //EFFECTS_H diff --git a/dlls/extdll.h b/dlls/extdll.h index 45c42309..812ce40f 100644 --- a/dlls/extdll.h +++ b/dlls/extdll.h @@ -69,7 +69,7 @@ typedef int BOOL; // Header file containing definition of globalvars_t and entvars_t typedef unsigned int func_t; -typedef unsigned int string_t; // from engine's pr_comp.h; +typedef int string_t; // from engine's pr_comp.h; typedef float vec_t; // needed before including progdefs.h // Vector class diff --git a/dlls/func_break.h b/dlls/func_break.h index ab5dda41..b4ff1fc1 100644 --- a/dlls/func_break.h +++ b/dlls/func_break.h @@ -82,9 +82,9 @@ public: Materials m_Material; Explosions m_Explosion; + string_t m_iszGibModel; + string_t m_iszSpawnObject; int m_idShard; float m_angle; - int m_iszGibModel; - int m_iszSpawnObject; }; #endif // FUNC_BREAK_H diff --git a/dlls/func_tank.cpp b/dlls/func_tank.cpp index 6eebc675..013948eb 100644 --- a/dlls/func_tank.cpp +++ b/dlls/func_tank.cpp @@ -97,6 +97,9 @@ public: protected: CBasePlayer* m_pController; + string_t m_iszSpriteSmoke; + string_t m_iszSpriteFlash; + string_t m_iszMaster; // Master entity (game_team_master or multisource) float m_flNextAttack; Vector m_vecControllerUsePos; @@ -120,14 +123,11 @@ protected: Vector m_barrelPos; // Length of the freakin barrel float m_spriteScale; // Scale of any sprites we shoot - int m_iszSpriteSmoke; - int m_iszSpriteFlash; TANKBULLET m_bulletType; // Bullet type int m_iBulletDamage; // 0 means use Bullet type's default damage Vector m_sightOrigin; // Last sight of target int m_spread; // firing spread - int m_iszMaster; // Master entity (game_team_master or multisource) }; TYPEDESCRIPTION CFuncTank::m_SaveData[] = diff --git a/dlls/lights.cpp b/dlls/lights.cpp index e6b03125..8a4f8de8 100644 --- a/dlls/lights.cpp +++ b/dlls/lights.cpp @@ -37,8 +37,8 @@ public: static TYPEDESCRIPTION m_SaveData[]; private: + string_t m_iszPattern; int m_iStyle; - int m_iszPattern; }; LINK_ENTITY_TO_CLASS( light, CLight ) diff --git a/dlls/mortar.cpp b/dlls/mortar.cpp index 33a7d2da..7faf3e56 100644 --- a/dlls/mortar.cpp +++ b/dlls/mortar.cpp @@ -45,8 +45,8 @@ public: void EXPORT FieldUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - int m_iszXController; - int m_iszYController; + string_t m_iszXController; + string_t m_iszYController; float m_flSpread; float m_flDelay; int m_iCount; diff --git a/dlls/plats.cpp b/dlls/plats.cpp index c1220f3c..b3e1c683 100644 --- a/dlls/plats.cpp +++ b/dlls/plats.cpp @@ -1619,9 +1619,9 @@ public: CFuncTrackTrain *m_train; - int m_trackTopName; - int m_trackBottomName; - int m_trainName; + string_t m_trackTopName; + string_t m_trackBottomName; + string_t m_trainName; TRAIN_CODE m_code; int m_targetState; int m_use; diff --git a/dlls/scripted.cpp b/dlls/scripted.cpp index 678502f6..92b9aa6a 100644 --- a/dlls/scripted.cpp +++ b/dlls/scripted.cpp @@ -907,15 +907,15 @@ public: BOOL StartSentence( CBaseMonster *pTarget ); private: - int m_iszSentence; // string index for idle animation - int m_iszEntity; // entity that is wanted for this sentence + string_t m_iszSentence; // string index for idle animation + string_t m_iszEntity; // entity that is wanted for this sentence + string_t m_iszListener; // name of entity to look at while talking float m_flRadius; // range to search float m_flDuration; // How long the sentence lasts float m_flRepeat; // repeat rate float m_flAttenuation; float m_flVolume; BOOL m_active; - int m_iszListener; // name of entity to look at while talking }; #define SF_SENTENCE_ONCE 0x0001 diff --git a/dlls/scripted.h b/dlls/scripted.h index 25348114..6cf8cfa1 100644 --- a/dlls/scripted.h +++ b/dlls/scripted.h @@ -77,9 +77,9 @@ public: void AllowInterrupt( BOOL fAllow ); int IgnoreConditions( void ); - int m_iszIdle; // string index for idle animation - int m_iszPlay; // string index for scripted animation - int m_iszEntity; // entity that is wanted for this script + string_t m_iszIdle; // string index for idle animation + string_t m_iszPlay; // string index for scripted animation + string_t m_iszEntity; // entity that is wanted for this script int m_fMoveTo; int m_iFinishSchedule; float m_flRadius; // range to search diff --git a/dlls/talkmonster.h b/dlls/talkmonster.h index 72222aae..084861bc 100644 --- a/dlls/talkmonster.h +++ b/dlls/talkmonster.h @@ -162,8 +162,8 @@ public: int m_voicePitch; // pitch of voice for this head const char *m_szGrp[TLK_CGROUPS]; // sentence group names float m_useTime; // Don't allow +USE until this time - int m_iszUse; // Custom +USE sentence group (follow) - int m_iszUnUse; // Custom +USE sentence group (stop following) + string_t m_iszUse; // Custom +USE sentence group (follow) + string_t m_iszUnUse; // Custom +USE sentence group (stop following) float m_flLastSaidSmelled;// last time we talked about something that stinks float m_flStopTalkTime;// when in the future that I'll be done saying this sentence. diff --git a/dlls/triggers.cpp b/dlls/triggers.cpp index 8171a195..7d7f255c 100644 --- a/dlls/triggers.cpp +++ b/dlls/triggers.cpp @@ -114,7 +114,7 @@ public: static TYPEDESCRIPTION m_SaveData[]; private: - int m_globalstate; + string_t m_globalstate; USE_TYPE triggerType; }; @@ -267,11 +267,11 @@ public: static TYPEDESCRIPTION m_SaveData[]; - int m_cTargets; // the total number of targets in this manager's fire list. + string_t m_iTargetName[MAX_MULTI_TARGETS];// list if indexes into global string array + float m_flTargetDelay[MAX_MULTI_TARGETS];// delay (in seconds) from time of manager fire to target fire + int m_cTargets; // the total number of targets in this manager's fire list. int m_index; // Current target float m_startTime;// Time we started firing - int m_iTargetName[MAX_MULTI_TARGETS];// list if indexes into global string array - float m_flTargetDelay[MAX_MULTI_TARGETS];// delay (in seconds) from time of manager fire to target fire private: inline BOOL IsClone( void ) { return ( pev->spawnflags & SF_MULTIMAN_CLONE ) ? TRUE : FALSE; } inline BOOL ShouldClone( void ) @@ -1321,9 +1321,9 @@ public: static TYPEDESCRIPTION m_SaveData[]; + string_t m_changeTarget; char m_szMapName[cchMapNameMost]; // trigger_changelevel only: next map char m_szLandmarkName[cchMapNameMost]; // trigger_changelevel only: landmark on next map - int m_changeTarget; float m_changeTargetDelay; }; @@ -2054,7 +2054,7 @@ public: static TYPEDESCRIPTION m_SaveData[]; private: - int m_iszNewTarget; + string_t m_iszNewTarget; }; LINK_ENTITY_TO_CLASS( trigger_changetarget, CTriggerChangeTarget ) @@ -2117,7 +2117,7 @@ public: EHANDLE m_hPlayer; EHANDLE m_hTarget; CBaseEntity *m_pentPath; - int m_sPath; + string_t m_sPath; float m_flWait; float m_flReturnTime; float m_flStopTime; diff --git a/dlls/util.cpp b/dlls/util.cpp index f382ac58..94c8c68c 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -1586,7 +1586,7 @@ void UTIL_StripToken( const char *pKey, char *pDest ) static int gSizes[FIELD_TYPECOUNT] = { sizeof(float), // FIELD_FLOAT - sizeof(int), // FIELD_STRING + sizeof(string_t), // FIELD_STRING sizeof(void*), // FIELD_ENTITY sizeof(void*), // FIELD_CLASSPTR sizeof(void*), // FIELD_EHANDLE @@ -1613,7 +1613,7 @@ static int gSizes[FIELD_TYPECOUNT] = static int gInputSizes[FIELD_TYPECOUNT] = { sizeof(float), // FIELD_FLOAT - sizeof(int), // FIELD_STRING + sizeof(string_t), // FIELD_STRING sizeof(int), // FIELD_ENTITY sizeof(int), // FIELD_CLASSPTR sizeof(int), // FIELD_EHANDLE @@ -1940,7 +1940,7 @@ void EntvarsKeyvalue( entvars_t *pev, KeyValueData *pkvd ) case FIELD_MODELNAME: case FIELD_SOUNDNAME: case FIELD_STRING: - ( *(int *)( (char *)pev + pField->fieldOffset ) ) = ALLOC_STRING( pkvd->szValue ); + ( *(string_t *)( (char *)pev + pField->fieldOffset ) ) = ALLOC_STRING( pkvd->szValue ); break; case FIELD_TIME: case FIELD_FLOAT: @@ -2014,7 +2014,7 @@ int CSave::WriteFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *pFi case FIELD_MODELNAME: case FIELD_SOUNDNAME: case FIELD_STRING: - WriteString( pTest->fieldName, (int *)pOutputData, pTest->fieldSize ); + WriteString( pTest->fieldName, (string_t *)pOutputData, pTest->fieldSize ); break; case FIELD_CLASSPTR: case FIELD_EVARS: @@ -2197,14 +2197,14 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou } pInputData = pString; if( strlen( (char *)pInputData ) == 0 ) - *( (int *)pOutputData ) = 0; + *( (string_t *)pOutputData ) = 0; else { - int string; + string_t string; string = ALLOC_STRING( (char *)pInputData ); - *( (int *)pOutputData ) = string; + *( (string_t *)pOutputData ) = string; if( !FStringNull( string ) && m_precache ) { diff --git a/dlls/util.h b/dlls/util.h index 2ffe536e..ee7d116b 100644 --- a/dlls/util.h +++ b/dlls/util.h @@ -37,13 +37,13 @@ extern globalvars_t *gpGlobals; #define STRING(offset) (const char *)(gpGlobals->pStringBase + (int)offset) #if !defined XASH_64BIT || defined(CLIENT_DLL) -#define MAKE_STRING(str) ((size_t)str - (size_t)STRING(0)) +#define MAKE_STRING(str) ((int)str - (int)STRING(0)) #else static inline int MAKE_STRING(const char *szValue) { long long ptrdiff = szValue - STRING(0); if( ptrdiff > INT_MAX || ptrdiff < INT_MIN ) - return ALLOC_STRING(szValue); + return ALLOC_STRING( szValue ); else return (int)ptrdiff; } diff --git a/dlls/weapons.h b/dlls/weapons.h index 6c03105b..0cfa2031 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -446,7 +446,7 @@ public: CBasePlayerItem *m_rgpPlayerItems[MAX_ITEM_TYPES];// one slot for each - int m_rgiszAmmo[MAX_AMMO_SLOTS];// ammo names + string_t m_rgiszAmmo[MAX_AMMO_SLOTS];// ammo names int m_rgAmmo[MAX_AMMO_SLOTS];// ammo quantities int m_cAmmoTypes;// how many ammo types packed into this box (if packed by a level designer) From 28020503292fb16cf30b6ccd639f5e6cb9cd4b46 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 10 Dec 2017 21:05:13 +0500 Subject: [PATCH 20/25] Add missing break. --- dlls/hgrunt.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/dlls/hgrunt.cpp b/dlls/hgrunt.cpp index 4cb85c2c..62c947f1 100644 --- a/dlls/hgrunt.cpp +++ b/dlls/hgrunt.cpp @@ -959,6 +959,7 @@ void CHGrunt::HandleAnimEvent( MonsterEvent_t *pEvent ) } } + break; default: CSquadMonster::HandleAnimEvent( pEvent ); break; From 83c0505ffe12da025c207fcca1f9bd67b5291097 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 10 Dec 2017 21:08:10 +0500 Subject: [PATCH 21/25] Add missing precache calls. --- dlls/effects.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dlls/effects.cpp b/dlls/effects.cpp index 5b8d650c..2e127b2d 100644 --- a/dlls/effects.cpp +++ b/dlls/effects.cpp @@ -2181,6 +2181,8 @@ public: void CItemSoda::Precache( void ) { + PRECACHE_MODEL( "models/can.mdl" ); + PRECACHE_SOUND( "weapons/g_bounce.wav" ); } LINK_ENTITY_TO_CLASS( item_sodacan, CItemSoda ) From 41c9b072e5f871f6d4ce778a037cfa6ae38abcdb Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 10 Dec 2017 22:19:34 +0500 Subject: [PATCH 22/25] Add missing #include guards. --- cl_dll/ammohistory.h | 3 +++ cl_dll/health.h | 3 +++ cl_dll/hud_spectator.h | 4 ++-- cl_dll/parsemsg.h | 3 +++ dlls/gamerules.h | 4 +++- dlls/plane.h | 6 +++--- dlls/skill.h | 3 +++ dlls/spectator.h | 3 +++ dlls/squad.h | 4 +++- dlls/squadmonster.h | 3 +++ dlls/util.h | 3 +++ 11 files changed, 32 insertions(+), 7 deletions(-) diff --git a/cl_dll/ammohistory.h b/cl_dll/ammohistory.h index f1063ae1..032d3ee3 100644 --- a/cl_dll/ammohistory.h +++ b/cl_dll/ammohistory.h @@ -15,6 +15,8 @@ // // ammohistory.h // +#ifndef AMMOHISTORY_H +#define AMMOHISTORY_H // this is the max number of items in each bucket #define MAX_WEAPON_POSITIONS MAX_WEAPON_SLOTS @@ -137,3 +139,4 @@ public: }; extern HistoryResource gHR; +#endif // AMMOHISTORY_H diff --git a/cl_dll/health.h b/cl_dll/health.h index 132b9cb4..1007c17c 100644 --- a/cl_dll/health.h +++ b/cl_dll/health.h @@ -12,6 +12,8 @@ * without written permission from Valve LLC. * ****/ +#ifndef HEALTH_H +#define HEALTH_H #define DMG_IMAGE_LIFE 2 // seconds that image is up @@ -122,3 +124,4 @@ private: void CalcDamageDirection( vec3_t vecFrom ); void UpdateTiles( float fTime, long bits ); }; +#endif // HEALTH_H diff --git a/cl_dll/hud_spectator.h b/cl_dll/hud_spectator.h index 58026668..9cfc5519 100644 --- a/cl_dll/hud_spectator.h +++ b/cl_dll/hud_spectator.h @@ -5,8 +5,8 @@ // $NoKeywords: $ //============================================================================= -#ifndef SPECTATOR_H -#define SPECTATOR_H +#ifndef HUD_SPECTATOR_H +#define HUD_SPECTATOR_H #pragma once #include "cl_entity.h" diff --git a/cl_dll/parsemsg.h b/cl_dll/parsemsg.h index 0e6bd2a3..6d552413 100644 --- a/cl_dll/parsemsg.h +++ b/cl_dll/parsemsg.h @@ -15,6 +15,8 @@ // // parsemsg.h // +#ifndef PARSEMSG_H +#define PARSEMSG_H #define ASSERT( x ) @@ -30,6 +32,7 @@ float READ_COORD( void ); float READ_ANGLE( void ); float READ_HIRESANGLE( void ); +#endif // PARSEMSG_H diff --git a/dlls/gamerules.h b/dlls/gamerules.h index 6ad470d0..71036151 100644 --- a/dlls/gamerules.h +++ b/dlls/gamerules.h @@ -15,7 +15,8 @@ //========================================================= // GameRules //========================================================= - +#ifndef GAMERULES_H +#define GAMERULES_H //#include "weapons.h" //#include "items.h" class CBasePlayerItem; @@ -361,3 +362,4 @@ protected: }; extern DLL_GLOBAL CGameRules *g_pGameRules; +#endif // GAMERULES_H diff --git a/dlls/plane.h b/dlls/plane.h index 35a17611..912062f6 100644 --- a/dlls/plane.h +++ b/dlls/plane.h @@ -12,12 +12,12 @@ * without written permission from Valve LLC. * ****/ -#ifndef PLANE_H -#define PLANE_H - //========================================================= // Plane //========================================================= +#ifndef PLANE_H +#define PLANE_H + class CPlane { public: diff --git a/dlls/skill.h b/dlls/skill.h index 12b784e3..aa338362 100644 --- a/dlls/skill.h +++ b/dlls/skill.h @@ -15,6 +15,8 @@ //========================================================= // skill.h - skill level concerns //========================================================= +#ifndef SKILL_H +#define SKILL_H struct skilldata_t { @@ -143,3 +145,4 @@ extern DLL_GLOBAL int g_iSkillLevel; #define SKILL_EASY 1 #define SKILL_MEDIUM 2 #define SKILL_HARD 3 +#endif // SKILL_H diff --git a/dlls/spectator.h b/dlls/spectator.h index 90f8678f..00567fc6 100644 --- a/dlls/spectator.h +++ b/dlls/spectator.h @@ -13,6 +13,8 @@ * ****/ // Spectator.h +#ifndef SPECTATOR_H +#define SPECTATOR_H class CBaseSpectator : public CBaseEntity { @@ -25,3 +27,4 @@ public: private: void SpectatorImpulseCommand( void ); }; +#endif // SPECTATOR_H diff --git a/dlls/squad.h b/dlls/squad.h index bb2784bb..c29a7199 100644 --- a/dlls/squad.h +++ b/dlls/squad.h @@ -4,10 +4,11 @@ // // $NoKeywords: $ //============================================================================= - //========================================================= // squad.h //========================================================= +#ifndef SQUAD_H +#define SQUAD_H // these are special group roles that are assigned to members when the group is formed. // the reason these are explicitly assigned and tasks like throwing grenades to flush out @@ -19,3 +20,4 @@ #define bits_SQUAD_FLANK_RIGHT ( 1 << 1 ) #define bits_SQUAD_ADVANCE ( 1 << 2 ) #define bits_SQUAD_FLUSH_ATTACK ( 1 << 3 ) +#endif // SQUAD_H diff --git a/dlls/squadmonster.h b/dlls/squadmonster.h index 707910c2..132d4177 100644 --- a/dlls/squadmonster.h +++ b/dlls/squadmonster.h @@ -16,6 +16,8 @@ // CSquadMonster - all the extra data for monsters that // form squads. //========================================================= +#ifndef SQUADMONSTER_H +#define SQUADMONSTER_H #define SF_SQUADMONSTER_LEADER 32 @@ -116,3 +118,4 @@ public: MONSTERSTATE GetIdealState( void ); Schedule_t *GetScheduleOfType( int iType ); }; +#endif // SQUADMONSTER_H diff --git a/dlls/util.h b/dlls/util.h index ee7d116b..8f56cd76 100644 --- a/dlls/util.h +++ b/dlls/util.h @@ -12,6 +12,8 @@ * without written permission from Valve LLC. * ****/ +#ifndef UTIL_H +#define UTIL_H // // Misc utility code // @@ -575,3 +577,4 @@ int UTIL_SharedRandomLong( unsigned int seed, int low, int high ); float UTIL_SharedRandomFloat( unsigned int seed, float low, float high ); float UTIL_WeaponTimeBase( void ); +#endif // UTIL_H From f27d1028acf7ae1cf7494002e880d235177f2c52 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 11 Dec 2017 01:40:41 +0500 Subject: [PATCH 23/25] Do not reorganize variables in classes. Add missing #pragma once directives and more #include guards. --- cl_dll/GameStudioModelRenderer.h | 6 ++---- cl_dll/GameStudioModelRenderer_Sample.h | 6 ++---- cl_dll/StudioModelRenderer.h | 4 +--- cl_dll/ammo.h | 2 +- cl_dll/ammohistory.h | 1 + cl_dll/camera.h | 2 +- cl_dll/cl_dll.h | 1 + cl_dll/com_weapons.h | 4 +--- cl_dll/demo.h | 2 +- cl_dll/ev_hldm.h | 1 + cl_dll/eventscripts.h | 1 + cl_dll/health.h | 1 + cl_dll/hud.h | 1 + cl_dll/hud_iface.h | 2 +- cl_dll/hud_spectator.h | 2 +- cl_dll/in_defs.h | 2 +- cl_dll/input_mouse.h | 1 + cl_dll/kbutton.h | 3 +-- cl_dll/overview.h | 2 +- cl_dll/parsemsg.h | 1 + cl_dll/studio_util.h | 4 +--- cl_dll/util_vector.h | 4 ++++ common/beamdef.h | 4 ++-- common/bspfile.h | 2 +- common/cl_entity.h | 4 ++-- common/com_model.h | 4 ++-- common/con_nprint.h | 3 ++- common/const.h | 1 + common/cvardef.h | 1 + common/demo_api.h | 4 ++-- common/dlight.h | 4 ++-- common/entity_state.h | 3 ++- common/entity_types.h | 4 ++-- common/event_api.h | 4 ++-- common/event_args.h | 3 ++- common/event_flags.h | 4 ++-- common/gameinfo.h | 4 ++-- common/hltv.h | 4 ++-- common/ivoicetweak.h | 4 ++-- common/lightstyle.h | 4 ++-- common/mathlib.h | 5 ++++- common/net_api.h | 4 ++-- common/netadr.h | 4 ++-- common/particledef.h | 4 ++-- common/pmtrace.h | 4 ++-- common/qfont.h | 4 ++-- common/r_efx.h | 4 ++-- common/r_studioint.h | 5 ++--- common/ref_params.h | 4 ++-- common/render_api.h | 4 ++-- common/screenfade.h | 4 ++-- common/studio_event.h | 4 ++-- common/triangleapi.h | 2 +- common/usercmd.h | 4 ++-- common/wadfile.h | 4 ++-- common/weaponinfo.h | 4 ++-- common/wrect.h | 4 ++-- dlls/activity.h | 2 +- dlls/activitymap.h | 5 ++++- dlls/animation.h | 1 + dlls/basemonster.h | 2 +- dlls/cbase.h | 1 + dlls/cdll_dll.h | 2 +- dlls/client.h | 1 + dlls/decals.h | 1 + dlls/doors.h | 1 + dlls/effects.cpp | 4 ++-- dlls/effects.h | 1 + dlls/explode.h | 3 ++- dlls/exportdef.h | 1 + dlls/extdll.h | 1 + dlls/flyingmonster.h | 2 +- dlls/func_break.h | 5 +++-- dlls/func_tank.cpp | 6 +++--- dlls/game.h | 2 +- dlls/gamerules.h | 1 + dlls/hornet.h | 5 ++++- dlls/items.h | 1 + dlls/lights.cpp | 2 +- dlls/monsters.h | 1 + dlls/nodes.h | 1 + dlls/physcallback.h | 2 +- dlls/player.h | 1 + dlls/saverestore.h | 1 + dlls/schedule.h | 2 +- dlls/scripted.cpp | 2 +- dlls/scripted.h | 1 + dlls/scriptevent.h | 3 ++- dlls/skill.h | 3 ++- dlls/soundent.h | 4 ++++ dlls/spectator.h | 1 + dlls/squad.h | 1 + dlls/squadmonster.h | 1 + dlls/talkmonster.h | 1 + dlls/teamplay_gamerules.h | 4 ++++ dlls/trains.h | 1 + dlls/triggers.cpp | 6 +++--- dlls/util.h | 1 + dlls/vector.h | 1 + dlls/weapons.h | 1 + engine/cdll_exp.h | 3 ++- engine/cdll_int.h | 2 +- engine/custom.h | 3 +-- engine/customentity.h | 2 +- engine/edict.h | 4 +--- engine/eiface.h | 2 +- engine/keydefs.h | 4 ++-- engine/menu_int.h | 2 +- engine/physint.h | 4 ++-- engine/progdefs.h | 3 +-- engine/shake.h | 2 +- engine/sprite.h | 4 ++-- engine/studio.h | 2 +- pm_shared/pm_debug.h | 3 +-- pm_shared/pm_defs.h | 3 +-- pm_shared/pm_info.h | 3 +-- pm_shared/pm_materials.h | 1 + pm_shared/pm_movevars.h | 1 + pm_shared/pm_shared.h | 4 +--- 119 files changed, 183 insertions(+), 140 deletions(-) diff --git a/cl_dll/GameStudioModelRenderer.h b/cl_dll/GameStudioModelRenderer.h index 7d06f70f..881dd144 100644 --- a/cl_dll/GameStudioModelRenderer.h +++ b/cl_dll/GameStudioModelRenderer.h @@ -5,11 +5,9 @@ // $NoKeywords: $ //============================================================================= +#pragma once #if !defined( GAMESTUDIOMODELRENDERER_H ) #define GAMESTUDIOMODELRENDERER_H -#if defined( _WIN32 ) -#pragma once -#endif /* ==================== @@ -23,4 +21,4 @@ public: CGameStudioModelRenderer( void ); }; -#endif // GAMESTUDIOMODELRENDERER_H \ No newline at end of file +#endif // GAMESTUDIOMODELRENDERER_H diff --git a/cl_dll/GameStudioModelRenderer_Sample.h b/cl_dll/GameStudioModelRenderer_Sample.h index c924ba3e..9c09374b 100644 --- a/cl_dll/GameStudioModelRenderer_Sample.h +++ b/cl_dll/GameStudioModelRenderer_Sample.h @@ -5,11 +5,9 @@ // $NoKeywords: $ //============================================================================= +#pragma once #if !defined( GAMESTUDIOMODELRENDERER_H ) #define GAMESTUDIOMODELRENDERER_H -#if defined( _WIN32 ) -#pragma once -#endif /* ==================== @@ -52,4 +50,4 @@ private: bool m_bLocal; }; -#endif // GAMESTUDIOMODELRENDERER_H \ No newline at end of file +#endif // GAMESTUDIOMODELRENDERER_H diff --git a/cl_dll/StudioModelRenderer.h b/cl_dll/StudioModelRenderer.h index 0a56b731..cbfd0d3b 100644 --- a/cl_dll/StudioModelRenderer.h +++ b/cl_dll/StudioModelRenderer.h @@ -5,11 +5,9 @@ // $NoKeywords: $ //============================================================================= +#pragma once #if !defined ( STUDIOMODELRENDERER_H ) #define STUDIOMODELRENDERER_H -#if defined( _WIN32 ) -#pragma once -#endif /* ==================== diff --git a/cl_dll/ammo.h b/cl_dll/ammo.h index 9134681c..57c08805 100644 --- a/cl_dll/ammo.h +++ b/cl_dll/ammo.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef __AMMO_H__ #define __AMMO_H__ diff --git a/cl_dll/ammohistory.h b/cl_dll/ammohistory.h index 032d3ee3..44edc916 100644 --- a/cl_dll/ammohistory.h +++ b/cl_dll/ammohistory.h @@ -15,6 +15,7 @@ // // ammohistory.h // +#pragma once #ifndef AMMOHISTORY_H #define AMMOHISTORY_H diff --git a/cl_dll/camera.h b/cl_dll/camera.h index 448b22ca..69a00216 100644 --- a/cl_dll/camera.h +++ b/cl_dll/camera.h @@ -7,7 +7,7 @@ // Camera.h -- defines and such for a 3rd person camera // NOTE: must include quakedef.h first - +#pragma once #ifndef _CAMERA_H_ #define _CAMERA_H_ diff --git a/cl_dll/cl_dll.h b/cl_dll/cl_dll.h index 0acd6860..6e1c4e69 100644 --- a/cl_dll/cl_dll.h +++ b/cl_dll/cl_dll.h @@ -25,6 +25,7 @@ // - 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; diff --git a/cl_dll/com_weapons.h b/cl_dll/com_weapons.h index d252c196..efe06ad6 100644 --- a/cl_dll/com_weapons.h +++ b/cl_dll/com_weapons.h @@ -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" diff --git a/cl_dll/demo.h b/cl_dll/demo.h index a0a1b30e..b7dbaff0 100644 --- a/cl_dll/demo.h +++ b/cl_dll/demo.h @@ -5,9 +5,9 @@ // $NoKeywords: $ //============================================================================= +#pragma once #if !defined( DEMOH ) #define DEMOH -#pragma once // Types of demo messages we can write/parse enum diff --git a/cl_dll/ev_hldm.h b/cl_dll/ev_hldm.h index bff43b1e..88b221df 100644 --- a/cl_dll/ev_hldm.h +++ b/cl_dll/ev_hldm.h @@ -5,6 +5,7 @@ // $NoKeywords: $ //============================================================================= +#pragma once #if !defined ( EV_HLDMH ) #define EV_HLDMH diff --git a/cl_dll/eventscripts.h b/cl_dll/eventscripts.h index bb835474..c11ee338 100644 --- a/cl_dll/eventscripts.h +++ b/cl_dll/eventscripts.h @@ -6,6 +6,7 @@ //============================================================================= // eventscripts.h +#pragma once #if !defined ( EVENTSCRIPTSH ) #define EVENTSCRIPTSH diff --git a/cl_dll/health.h b/cl_dll/health.h index 1007c17c..62d7e0bc 100644 --- a/cl_dll/health.h +++ b/cl_dll/health.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef HEALTH_H #define HEALTH_H diff --git a/cl_dll/hud.h b/cl_dll/hud.h index 1970753d..decfa917 100644 --- a/cl_dll/hud.h +++ b/cl_dll/hud.h @@ -19,6 +19,7 @@ // // CHud handles the message, calculation, and drawing the HUD // +#pragma once #ifndef HUD_H #define HUD_H #define RGB_YELLOWISH 0x00FFA000 //255,160,0 diff --git a/cl_dll/hud_iface.h b/cl_dll/hud_iface.h index a7a05e7e..7993bd9d 100644 --- a/cl_dll/hud_iface.h +++ b/cl_dll/hud_iface.h @@ -5,9 +5,9 @@ // $NoKeywords: $ //============================================================================= +#pragma once #if !defined( HUD_IFACEH ) #define HUD_IFACEH -#pragma once #include "exportdef.h" diff --git a/cl_dll/hud_spectator.h b/cl_dll/hud_spectator.h index 9cfc5519..7a9ec9d3 100644 --- a/cl_dll/hud_spectator.h +++ b/cl_dll/hud_spectator.h @@ -5,9 +5,9 @@ // $NoKeywords: $ //============================================================================= +#pragma once #ifndef HUD_SPECTATOR_H #define HUD_SPECTATOR_H -#pragma once #include "cl_entity.h" diff --git a/cl_dll/in_defs.h b/cl_dll/in_defs.h index 037c7cc6..d5c352fa 100644 --- a/cl_dll/in_defs.h +++ b/cl_dll/in_defs.h @@ -5,9 +5,9 @@ // $NoKeywords: $ //============================================================================= +#pragma once #if !defined( IN_DEFSH ) #define IN_DEFSH -#pragma once // up / down #define PITCH 0 diff --git a/cl_dll/input_mouse.h b/cl_dll/input_mouse.h index 6ddf54db..cf0102c8 100644 --- a/cl_dll/input_mouse.h +++ b/cl_dll/input_mouse.h @@ -1,3 +1,4 @@ +#pragma once #ifndef INPUT_MOUSE_H #define INPUT_MOUSE_H #include "cl_dll.h" diff --git a/cl_dll/kbutton.h b/cl_dll/kbutton.h index 29accdf5..54f1ea93 100644 --- a/cl_dll/kbutton.h +++ b/cl_dll/kbutton.h @@ -4,10 +4,9 @@ // // $NoKeywords: $ //============================================================================= - +#pragma once #if !defined( KBUTTONH ) #define KBUTTONH -#pragma once typedef struct kbutton_s { diff --git a/cl_dll/overview.h b/cl_dll/overview.h index 6748760b..59535fb4 100644 --- a/cl_dll/overview.h +++ b/cl_dll/overview.h @@ -5,9 +5,9 @@ // $NoKeywords: $ //============================================================================= +#pragma once #ifndef OVERVIEW_H #define OVERVIEW_H -#pragma once //----------------------------------------------------------------------------- // Purpose: Handles the drawing of the top-down map and all the things on it diff --git a/cl_dll/parsemsg.h b/cl_dll/parsemsg.h index 6d552413..05efefc3 100644 --- a/cl_dll/parsemsg.h +++ b/cl_dll/parsemsg.h @@ -15,6 +15,7 @@ // // parsemsg.h // +#pragma once #ifndef PARSEMSG_H #define PARSEMSG_H diff --git a/cl_dll/studio_util.h b/cl_dll/studio_util.h index 963dcda7..7af94672 100644 --- a/cl_dll/studio_util.h +++ b/cl_dll/studio_util.h @@ -5,11 +5,9 @@ // $NoKeywords: $ //============================================================================= +#pragma once #if !defined( STUDIO_UTIL_H ) #define STUDIO_UTIL_H -#if defined( WIN32 ) -#pragma once -#endif #ifndef M_PI #define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h diff --git a/cl_dll/util_vector.h b/cl_dll/util_vector.h index 8b596ac1..477d97be 100644 --- a/cl_dll/util_vector.h +++ b/cl_dll/util_vector.h @@ -15,6 +15,9 @@ // Vector.h // A subset of the extdll.h in the project HL Entity DLL // +#pragma once +#ifndef UTIL_VECTOR_H +#define UTIL_VECTOR_H // Misc C-runtime library headers #include "stdio.h" @@ -124,3 +127,4 @@ inline float DotProduct( const Vector& a, const Vector& b) { return( a.x * b.x + inline Vector CrossProduct(const Vector& a, const Vector& b) { return Vector( a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x ); } #define vec3_t Vector +#endif // UTIL_VECTOR_H diff --git a/common/beamdef.h b/common/beamdef.h index 3b8c553a..f254428c 100644 --- a/common/beamdef.h +++ b/common/beamdef.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef BEAMDEF_H #define BEAMDEF_H @@ -57,4 +57,4 @@ struct beam_s struct particle_s *particles; }; -#endif//BEAMDEF_H \ No newline at end of file +#endif//BEAMDEF_H diff --git a/common/bspfile.h b/common/bspfile.h index 809e2fd0..079e1b21 100644 --- a/common/bspfile.h +++ b/common/bspfile.h @@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ - +#pragma once #ifndef BSPFILE_H #define BSPFILE_H diff --git a/common/cl_entity.h b/common/cl_entity.h index 02f84e35..c003ce30 100644 --- a/common/cl_entity.h +++ b/common/cl_entity.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef CL_ENTITY_H #define CL_ENTITY_H @@ -102,4 +102,4 @@ struct cl_entity_s colorVec cvFloorColor; }; -#endif//CL_ENTITY_H \ No newline at end of file +#endif//CL_ENTITY_H diff --git a/common/com_model.h b/common/com_model.h index 709f23d9..abc8e8e6 100644 --- a/common/com_model.h +++ b/common/com_model.h @@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ - +#pragma once #ifndef COM_MODEL_H #define COM_MODEL_H @@ -410,4 +410,4 @@ typedef struct mspriteframedesc_t frames[1]; } msprite_t; -#endif//COM_MODEL_H \ No newline at end of file +#endif//COM_MODEL_H diff --git a/common/con_nprint.h b/common/con_nprint.h index 5d87c760..615a1850 100644 --- a/common/con_nprint.h +++ b/common/con_nprint.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef CON_NPRINT_H #define CON_NPRINT_H @@ -22,4 +23,4 @@ typedef struct con_nprint_s float color[3]; // RGB colors ( 0.0 -> 1.0 scale ) } con_nprint_t; -#endif//CON_NPRINT_H \ No newline at end of file +#endif//CON_NPRINT_H diff --git a/common/const.h b/common/const.h index 3d738675..fa0f33e6 100644 --- a/common/const.h +++ b/common/const.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef CONST_H #define CONST_H // diff --git a/common/cvardef.h b/common/cvardef.h index e8a24581..f461c329 100644 --- a/common/cvardef.h +++ b/common/cvardef.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef CVARDEF_H #define CVARDEF_H diff --git a/common/demo_api.h b/common/demo_api.h index fa89bbef..1a678b60 100644 --- a/common/demo_api.h +++ b/common/demo_api.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef DEMO_API_H #define DEMO_API_H @@ -24,4 +24,4 @@ typedef struct demo_api_s void (*WriteBuffer)( int size, unsigned char *buffer ); } demo_api_t; -#endif//DEMO_API_H \ No newline at end of file +#endif//DEMO_API_H diff --git a/common/dlight.h b/common/dlight.h index b139d582..ecb01445 100644 --- a/common/dlight.h +++ b/common/dlight.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef DLIGHT_H #define DLIGHT_H @@ -28,4 +28,4 @@ typedef struct dlight_s qboolean dark; // subtracts light instead of adding } dlight_t; -#endif//DLIGHT_H \ No newline at end of file +#endif//DLIGHT_H diff --git a/common/entity_state.h b/common/entity_state.h index ef5448f1..2ffd70dc 100644 --- a/common/entity_state.h +++ b/common/entity_state.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef ENTITY_STATE_H #define ENTITY_STATE_H @@ -183,4 +184,4 @@ typedef struct local_state_s weapon_data_t weapondata[64]; } local_state_t; -#endif//ENTITY_STATE_H \ No newline at end of file +#endif//ENTITY_STATE_H diff --git a/common/entity_types.h b/common/entity_types.h index 25a8fce9..f5754fea 100644 --- a/common/entity_types.h +++ b/common/entity_types.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef ENTITY_TYPES_H #define ENTITY_TYPES_H @@ -22,4 +22,4 @@ #define ET_BEAM 3 #define ET_FRAGMENTED 4 // BMODEL or SPRITE that was split across BSP nodes -#endif//ENTITY_TYPES_H \ No newline at end of file +#endif//ENTITY_TYPES_H diff --git a/common/event_api.h b/common/event_api.h index a7ff71b2..86c5fbe9 100644 --- a/common/event_api.h +++ b/common/event_api.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef EVENT_API_H #define EVENT_API_H @@ -51,4 +51,4 @@ typedef struct event_api_s struct msurface_s *( *EV_TraceSurface )( int ground, float *vstart, float *vend ); } event_api_t; -#endif//EVENT_API_H \ No newline at end of file +#endif//EVENT_API_H diff --git a/common/event_args.h b/common/event_args.h index d85906cc..4cf63741 100644 --- a/common/event_args.h +++ b/common/event_args.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef EVENT_ARGS_H #define EVENT_ARGS_H @@ -44,4 +45,4 @@ typedef struct event_args_s int bparam2; } event_args_t; -#endif//EVENT_ARGS_H \ No newline at end of file +#endif//EVENT_ARGS_H diff --git a/common/event_flags.h b/common/event_flags.h index 3c1d8fb3..a2d5f3b7 100644 --- a/common/event_flags.h +++ b/common/event_flags.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef EVENT_FLAGS_H #define EVENT_FLAGS_H @@ -42,4 +42,4 @@ // Only issue event client side ( from shared code ) #define FEV_CLIENT (1<<6) -#endif//EVENT_FLAGS_H \ No newline at end of file +#endif//EVENT_FLAGS_H diff --git a/common/gameinfo.h b/common/gameinfo.h index 511b3718..ab5f649c 100644 --- a/common/gameinfo.h +++ b/common/gameinfo.h @@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ - +#pragma once #ifndef GAMEINFO_H #define GAMEINFO_H @@ -46,4 +46,4 @@ typedef struct int gamemode; } GAMEINFO; -#endif//GAMEINFO_H \ No newline at end of file +#endif//GAMEINFO_H diff --git a/common/hltv.h b/common/hltv.h index 79251910..e64dd30b 100644 --- a/common/hltv.h +++ b/common/hltv.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef HLTV_H #define HLTV_H @@ -56,4 +56,4 @@ #define MAX_DIRECTOR_CMD_PARAMETERS 4 #define MAX_DIRECTOR_CMD_STRING 128 -#endif//HLTV_H \ No newline at end of file +#endif//HLTV_H diff --git a/common/ivoicetweak.h b/common/ivoicetweak.h index 541a63fa..96879beb 100644 --- a/common/ivoicetweak.h +++ b/common/ivoicetweak.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef IVOICETWEAK_H #define IVOICETWEAK_H @@ -37,4 +37,4 @@ typedef struct IVoiceTweak_s int (*GetSpeakingVolume)( void ); } IVoiceTweak; -#endif//IVOICETWEAK_H \ No newline at end of file +#endif//IVOICETWEAK_H diff --git a/common/lightstyle.h b/common/lightstyle.h index 8b42edac..a12702f4 100644 --- a/common/lightstyle.h +++ b/common/lightstyle.h @@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ - +#pragma once #ifndef LIGHTSTYLE_H #define LIGHTSTYLE_H @@ -26,4 +26,4 @@ typedef struct float time; // local time is gurantee what new style begins from the start, not mid or end of the sequence } lightstyle_t; -#endif//LIGHTSTYLE_H \ No newline at end of file +#endif//LIGHTSTYLE_H diff --git a/common/mathlib.h b/common/mathlib.h index 12fb972f..6bcf76eb 100644 --- a/common/mathlib.h +++ b/common/mathlib.h @@ -13,7 +13,9 @@ * ****/ // mathlib.h - +#pragma once +#ifndef MATHLIB_H +#define MATHLIB_H #include typedef float vec_t; @@ -98,3 +100,4 @@ float anglemod(float a); ) \ : \ BoxOnPlaneSide( (emins), (emaxs), (p))) +#endif // MATHLIB_H diff --git a/common/net_api.h b/common/net_api.h index 00831394..da18fc30 100644 --- a/common/net_api.h +++ b/common/net_api.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef NET_API_H #define NET_API_H @@ -94,4 +94,4 @@ typedef struct net_api_s void (*SetValueForKey)( char *s, const char *key, const char *value, int maxsize ); } net_api_t; -#endif//NET_APIH \ No newline at end of file +#endif // NET_APIH diff --git a/common/netadr.h b/common/netadr.h index dfeea8b0..0d70a22b 100644 --- a/common/netadr.h +++ b/common/netadr.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef NETADR_H #define NETADR_H @@ -34,4 +34,4 @@ typedef struct netadr_s unsigned short port; } netadr_t; -#endif//NETADR_H \ No newline at end of file +#endif//NETADR_H diff --git a/common/particledef.h b/common/particledef.h index 3f2ead66..15c95feb 100644 --- a/common/particledef.h +++ b/common/particledef.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef PARTICLEDEF_H #define PARTICLEDEF_H @@ -51,4 +51,4 @@ typedef struct particle_s unsigned char context; } particle_t; -#endif//PARTICLEDEF_H \ No newline at end of file +#endif//PARTICLEDEF_H diff --git a/common/pmtrace.h b/common/pmtrace.h index 6394de56..d5dd1453 100644 --- a/common/pmtrace.h +++ b/common/pmtrace.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef PM_TRACE_H #define PM_TRACE_H @@ -38,4 +38,4 @@ struct pmtrace_s int hitgroup; }; -#endif//PM_TRACE_H \ No newline at end of file +#endif//PM_TRACE_H diff --git a/common/qfont.h b/common/qfont.h index 06408572..beb36ff9 100644 --- a/common/qfont.h +++ b/common/qfont.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef QFONT_H #define QFONT_H @@ -35,4 +35,4 @@ typedef struct qfont_s byte data[4]; } qfont_t; -#endif//QFONT_H \ No newline at end of file +#endif//QFONT_H diff --git a/common/r_efx.h b/common/r_efx.h index fc27bef7..1a55aa0b 100644 --- a/common/r_efx.h +++ b/common/r_efx.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef R_EFX_H #define R_EFX_H @@ -192,4 +192,4 @@ struct efx_api_s void (*R_FireCustomDecal)( int textureIndex, int entity, int modelIndex, float *position, int flags, float scale ); }; -#endif//R_EFX_H \ No newline at end of file +#endif//R_EFX_H diff --git a/common/r_studioint.h b/common/r_studioint.h index 00384a16..b17e826f 100644 --- a/common/r_studioint.h +++ b/common/r_studioint.h @@ -12,8 +12,7 @@ * without written permission from Valve LLC. * ****/ - - +#pragma once #ifndef R_STUDIOINT_H #define R_STUDIOINT_H @@ -151,4 +150,4 @@ typedef struct sv_blending_interface_s const edict_t *pEdict ); } sv_blending_interface_t; -#endif//R_STUDIOINT_H \ No newline at end of file +#endif//R_STUDIOINT_H diff --git a/common/ref_params.h b/common/ref_params.h index 0458c4f4..61527eca 100644 --- a/common/ref_params.h +++ b/common/ref_params.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef REF_PARAMS_H #define REF_PARAMS_H @@ -87,4 +87,4 @@ typedef struct ref_overview_s float flZoom; } ref_overview_t; -#endif//REF_PARAMS_H \ No newline at end of file +#endif//REF_PARAMS_H diff --git a/common/render_api.h b/common/render_api.h index 7a9fcffe..03973f27 100644 --- a/common/render_api.h +++ b/common/render_api.h @@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ - +#pragma once #ifndef RENDER_API_H #define RENDER_API_H @@ -258,4 +258,4 @@ typedef struct render_interface_s void (*Mod_ProcessUserData)( struct model_s *mod, qboolean create, const byte *buffer ); } render_interface_t; -#endif//RENDER_API_H \ No newline at end of file +#endif//RENDER_API_H diff --git a/common/screenfade.h b/common/screenfade.h index 730f729e..1611f914 100644 --- a/common/screenfade.h +++ b/common/screenfade.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef SCREENFADE_H #define SCREENFADE_H @@ -26,4 +26,4 @@ typedef struct screenfade_s int fadeFlags; // Fading flags } screenfade_t; -#endif//SCREENFADE_H \ No newline at end of file +#endif//SCREENFADE_H diff --git a/common/studio_event.h b/common/studio_event.h index 29ea1f90..cf21e82a 100644 --- a/common/studio_event.h +++ b/common/studio_event.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef STUDIO_EVENT_H #define STUDIO_EVENT_H @@ -24,4 +24,4 @@ typedef struct mstudioevent_s char options[64]; } mstudioevent_t; -#endif//STUDIO_EVENT_H \ No newline at end of file +#endif//STUDIO_EVENT_H diff --git a/common/triangleapi.h b/common/triangleapi.h index f2e9a309..49dc919f 100644 --- a/common/triangleapi.h +++ b/common/triangleapi.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef TRIANGLEAPI_H #define TRIANGLEAPI_H diff --git a/common/usercmd.h b/common/usercmd.h index 96e3c91b..538c60a6 100644 --- a/common/usercmd.h +++ b/common/usercmd.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef USERCMD_H #define USERCMD_H @@ -36,4 +36,4 @@ typedef struct usercmd_s vec3_t impact_position; } usercmd_t; -#endif//USERCMD_H \ No newline at end of file +#endif//USERCMD_H diff --git a/common/wadfile.h b/common/wadfile.h index 38a08032..84ffbb2d 100644 --- a/common/wadfile.h +++ b/common/wadfile.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef WADFILE_H #define WADFILE_H @@ -76,4 +76,4 @@ typedef struct mip_s unsigned int offsets[4]; // four mip maps stored } mip_t; -#endif//WADFILE_H \ No newline at end of file +#endif//WADFILE_H diff --git a/common/weaponinfo.h b/common/weaponinfo.h index ae78c645..b94857b6 100644 --- a/common/weaponinfo.h +++ b/common/weaponinfo.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef WEAPONINFO_H #define WEAPONINFO_H @@ -47,4 +47,4 @@ typedef struct weapon_data_s float fuser4; } weapon_data_t; -#endif//WEAPONINFO_H \ No newline at end of file +#endif//WEAPONINFO_H diff --git a/common/wrect.h b/common/wrect.h index 8dd2ba2f..51e84d88 100644 --- a/common/wrect.h +++ b/common/wrect.h @@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ - +#pragma once #ifndef WRECT_H #define WRECT_H @@ -21,4 +21,4 @@ typedef struct wrect_s int left, right, top, bottom; } wrect_t; -#endif//WRECT_H \ No newline at end of file +#endif//WRECT_H diff --git a/dlls/activity.h b/dlls/activity.h index 5382d70d..90d85a08 100644 --- a/dlls/activity.h +++ b/dlls/activity.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef ACTIVITY_H #define ACTIVITY_H diff --git a/dlls/activitymap.h b/dlls/activitymap.h index 5f77c55a..b5f789f9 100644 --- a/dlls/activitymap.h +++ b/dlls/activitymap.h @@ -12,7 +12,9 @@ * without written permission from Valve LLC. * ****/ - +#pragma once +#ifndef ACTIVITYMAP_H +#define ACTIVITYMAP_H #define _A( a ) { a, #a } activity_map_t activity_map[] = @@ -95,3 +97,4 @@ _A( ACT_FLINCH_LEFTLEG ), _A( ACT_FLINCH_RIGHTLEG ), { 0, NULL } }; +#endif // ACTIVITYMAP_H diff --git a/dlls/animation.h b/dlls/animation.h index 384c1e98..6def910c 100644 --- a/dlls/animation.h +++ b/dlls/animation.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef ANIMATION_H #define ANIMATION_H diff --git a/dlls/basemonster.h b/dlls/basemonster.h index 0d22104f..2234aaf9 100644 --- a/dlls/basemonster.h +++ b/dlls/basemonster.h @@ -12,7 +12,7 @@ * use or distribution of this code by or to any unlicensed person is illegal. * ****/ - +#pragma once #ifndef BASEMONSTER_H #define BASEMONSTER_H diff --git a/dlls/cbase.h b/dlls/cbase.h index 10f7a85f..4cf40abd 100644 --- a/dlls/cbase.h +++ b/dlls/cbase.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef CBASE_H #define CBASE_H /* diff --git a/dlls/cdll_dll.h b/dlls/cdll_dll.h index c960a6ac..0aafafbd 100644 --- a/dlls/cdll_dll.h +++ b/dlls/cdll_dll.h @@ -16,7 +16,7 @@ // cdll_dll.h // this file is included by both the game-dll and the client-dll, - +#pragma once #ifndef CDLL_DLL_H #define CDLL_DLL_H diff --git a/dlls/client.h b/dlls/client.h index 6728151b..6feaac1a 100644 --- a/dlls/client.h +++ b/dlls/client.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef CLIENT_H #define CLIENT_H diff --git a/dlls/decals.h b/dlls/decals.h index 97f5f29f..5de54421 100644 --- a/dlls/decals.h +++ b/dlls/decals.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef DECALS_H #define DECALS_H diff --git a/dlls/doors.h b/dlls/doors.h index 7e89b497..fe2b5a85 100644 --- a/dlls/doors.h +++ b/dlls/doors.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef DOORS_H #define DOORS_H diff --git a/dlls/effects.cpp b/dlls/effects.cpp index 2e127b2d..bd9959f9 100644 --- a/dlls/effects.cpp +++ b/dlls/effects.cpp @@ -379,10 +379,9 @@ public: void BeamUpdateVars( void ); + int m_active; string_t m_iszStartEntity; string_t m_iszEndEntity; - string_t m_iszSpriteName; - int m_active; float m_life; int m_boltWidth; int m_noiseAmplitude; @@ -390,6 +389,7 @@ public: int m_speed; float m_restrike; int m_spriteTexture; + string_t m_iszSpriteName; int m_frameStart; float m_radius; diff --git a/dlls/effects.h b/dlls/effects.h index f4b6b5b2..5dd55209 100644 --- a/dlls/effects.h +++ b/dlls/effects.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef EFFECTS_H #define EFFECTS_H diff --git a/dlls/explode.h b/dlls/explode.h index e1c6cce0..001d93ca 100644 --- a/dlls/explode.h +++ b/dlls/explode.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef EXPLODE_H #define EXPLODE_H @@ -26,4 +27,4 @@ extern DLL_GLOBAL short g_sModelIndexFireball; extern DLL_GLOBAL short g_sModelIndexSmoke; extern void ExplosionCreate( const Vector ¢er, const Vector &angles, edict_t *pOwner, int magnitude, BOOL doDamage ); -#endif //EXPLODE_H +#endif // EXPLODE_H diff --git a/dlls/exportdef.h b/dlls/exportdef.h index 995613ff..363d8d12 100644 --- a/dlls/exportdef.h +++ b/dlls/exportdef.h @@ -1,3 +1,4 @@ +#pragma once #ifndef EXPORTDEF_H #define EXPORTDEF_H #if defined _WIN32 || defined __CYGWIN__ diff --git a/dlls/extdll.h b/dlls/extdll.h index 812ce40f..d6ea4888 100644 --- a/dlls/extdll.h +++ b/dlls/extdll.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef EXTDLL_H #define EXTDLL_H diff --git a/dlls/flyingmonster.h b/dlls/flyingmonster.h index 4dd87fb4..31ff4e33 100644 --- a/dlls/flyingmonster.h +++ b/dlls/flyingmonster.h @@ -13,7 +13,7 @@ * ****/ // Base class for flying monsters. This overrides the movement test & execution code from CBaseMonster - +#pragma once #ifndef FLYINGMONSTER_H #define FLYINGMONSTER_H diff --git a/dlls/func_break.h b/dlls/func_break.h index b4ff1fc1..89c9f54e 100644 --- a/dlls/func_break.h +++ b/dlls/func_break.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef FUNC_BREAK_H #define FUNC_BREAK_H @@ -82,9 +83,9 @@ public: Materials m_Material; Explosions m_Explosion; - string_t m_iszGibModel; - string_t m_iszSpawnObject; int m_idShard; float m_angle; + string_t m_iszGibModel; + string_t m_iszSpawnObject; }; #endif // FUNC_BREAK_H diff --git a/dlls/func_tank.cpp b/dlls/func_tank.cpp index 013948eb..a3dba841 100644 --- a/dlls/func_tank.cpp +++ b/dlls/func_tank.cpp @@ -97,9 +97,6 @@ public: protected: CBasePlayer* m_pController; - string_t m_iszSpriteSmoke; - string_t m_iszSpriteFlash; - string_t m_iszMaster; // Master entity (game_team_master or multisource) float m_flNextAttack; Vector m_vecControllerUsePos; @@ -123,11 +120,14 @@ protected: Vector m_barrelPos; // Length of the freakin barrel float m_spriteScale; // Scale of any sprites we shoot + string_t m_iszSpriteSmoke; + string_t m_iszSpriteFlash; TANKBULLET m_bulletType; // Bullet type int m_iBulletDamage; // 0 means use Bullet type's default damage Vector m_sightOrigin; // Last sight of target int m_spread; // firing spread + string_t m_iszMaster; // Master entity (game_team_master or multisource) }; TYPEDESCRIPTION CFuncTank::m_SaveData[] = diff --git a/dlls/game.h b/dlls/game.h index a6d0cd1c..0dc5ba87 100644 --- a/dlls/game.h +++ b/dlls/game.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef GAME_H #define GAME_H diff --git a/dlls/gamerules.h b/dlls/gamerules.h index 71036151..04c6eea5 100644 --- a/dlls/gamerules.h +++ b/dlls/gamerules.h @@ -15,6 +15,7 @@ //========================================================= // GameRules //========================================================= +#pragma once #ifndef GAMERULES_H #define GAMERULES_H //#include "weapons.h" diff --git a/dlls/hornet.h b/dlls/hornet.h index dc78fc40..f0f0d366 100644 --- a/dlls/hornet.h +++ b/dlls/hornet.h @@ -15,7 +15,9 @@ //========================================================= // Hornets //========================================================= - +#pragma once +#ifndef HORNET_H +#define HORNET_H //========================================================= // Hornet Defines //========================================================= @@ -55,3 +57,4 @@ public: int m_iHornetType; float m_flFlySpeed; }; +#endif // HORNET_H diff --git a/dlls/items.h b/dlls/items.h index 2c31f801..060678c8 100644 --- a/dlls/items.h +++ b/dlls/items.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef ITEMS_H #define ITEMS_H diff --git a/dlls/lights.cpp b/dlls/lights.cpp index 8a4f8de8..1c39266b 100644 --- a/dlls/lights.cpp +++ b/dlls/lights.cpp @@ -37,8 +37,8 @@ public: static TYPEDESCRIPTION m_SaveData[]; private: - string_t m_iszPattern; int m_iStyle; + string_t m_iszPattern; }; LINK_ENTITY_TO_CLASS( light, CLight ) diff --git a/dlls/monsters.h b/dlls/monsters.h index 6f2df294..4aeca3a9 100644 --- a/dlls/monsters.h +++ b/dlls/monsters.h @@ -12,6 +12,7 @@ * use or distribution of this code by or to any unlicensed person is illegal. * ****/ +#pragma once #ifndef MONSTERS_H #include "skill.h" #define MONSTERS_H diff --git a/dlls/nodes.h b/dlls/nodes.h index 49036a39..52b715e5 100644 --- a/dlls/nodes.h +++ b/dlls/nodes.h @@ -15,6 +15,7 @@ //========================================================= // nodes.h //========================================================= +#pragma once #ifndef NODES_H #define NODES_H //========================================================= diff --git a/dlls/physcallback.h b/dlls/physcallback.h index 1db276e0..fd68936c 100644 --- a/dlls/physcallback.h +++ b/dlls/physcallback.h @@ -12,9 +12,9 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef PHYSCALLBACK_H #define PHYSCALLBACK_H -#pragma once #include "physint.h" diff --git a/dlls/player.h b/dlls/player.h index fecaf3c9..6fc06dbb 100644 --- a/dlls/player.h +++ b/dlls/player.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef PLAYER_H #define PLAYER_H diff --git a/dlls/saverestore.h b/dlls/saverestore.h index 4295871d..81f9f131 100644 --- a/dlls/saverestore.h +++ b/dlls/saverestore.h @@ -13,6 +13,7 @@ * ****/ // Implementation in UTIL.CPP +#pragma once #ifndef SAVERESTORE_H #define SAVERESTORE_H diff --git a/dlls/schedule.h b/dlls/schedule.h index 0c4fb1ce..6414ff15 100644 --- a/dlls/schedule.h +++ b/dlls/schedule.h @@ -15,7 +15,7 @@ //========================================================= // Scheduling //========================================================= - +#pragma once #ifndef SCHEDULE_H #define SCHEDULE_H diff --git a/dlls/scripted.cpp b/dlls/scripted.cpp index 92b9aa6a..41638b39 100644 --- a/dlls/scripted.cpp +++ b/dlls/scripted.cpp @@ -909,13 +909,13 @@ public: private: string_t m_iszSentence; // string index for idle animation string_t m_iszEntity; // entity that is wanted for this sentence - string_t m_iszListener; // name of entity to look at while talking float m_flRadius; // range to search float m_flDuration; // How long the sentence lasts float m_flRepeat; // repeat rate float m_flAttenuation; float m_flVolume; BOOL m_active; + string_t m_iszListener; // name of entity to look at while talking }; #define SF_SENTENCE_ONCE 0x0001 diff --git a/dlls/scripted.h b/dlls/scripted.h index 6cf8cfa1..59b696f7 100644 --- a/dlls/scripted.h +++ b/dlls/scripted.h @@ -12,6 +12,7 @@ * use or distribution of this code by or to any unlicensed person is illegal. * ****/ +#pragma once #ifndef SCRIPTED_H #define SCRIPTED_H diff --git a/dlls/scriptevent.h b/dlls/scriptevent.h index 714ac99c..18436a26 100644 --- a/dlls/scriptevent.h +++ b/dlls/scriptevent.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef SCRIPTEVENT_H #define SCRIPTEVENT_H @@ -26,4 +27,4 @@ #define SCRIPT_EVENT_SOUND_VOICE 1008 // Play named wave file (on CHAN_VOICE) #define SCRIPT_EVENT_SENTENCE_RND1 1009 // Play sentence group 25% of the time #define SCRIPT_EVENT_NOT_DEAD 1010 // Bring back to life (for life/death sequences) -#endif //SCRIPTEVENT_H +#endif // SCRIPTEVENT_H diff --git a/dlls/skill.h b/dlls/skill.h index aa338362..5244c923 100644 --- a/dlls/skill.h +++ b/dlls/skill.h @@ -15,6 +15,7 @@ //========================================================= // skill.h - skill level concerns //========================================================= +#pragma once #ifndef SKILL_H #define SKILL_H @@ -23,7 +24,7 @@ struct skilldata_t int iSkillLevel; // game skill level // Monster Health & Damage - float agruntHealth; + float agruntHealth; float agruntDmgPunch; float apacheHealth; diff --git a/dlls/soundent.h b/dlls/soundent.h index 6c39a6c0..88def506 100644 --- a/dlls/soundent.h +++ b/dlls/soundent.h @@ -17,6 +17,9 @@ // spawns, and handles the world's active and free sound // lists. //========================================================= +#pragma once +#ifndef SOUNDENT_H +#define SOUNDENT_H #define MAX_WORLD_SOUNDS 64 // maximum number of sounds handled by the world at one time. @@ -91,3 +94,4 @@ public: private: CSound m_SoundPool[ MAX_WORLD_SOUNDS ]; }; +#endif // SOUNDENT_H diff --git a/dlls/spectator.h b/dlls/spectator.h index 00567fc6..c4e895c0 100644 --- a/dlls/spectator.h +++ b/dlls/spectator.h @@ -13,6 +13,7 @@ * ****/ // Spectator.h +#pragma once #ifndef SPECTATOR_H #define SPECTATOR_H diff --git a/dlls/squad.h b/dlls/squad.h index c29a7199..f8f20aa0 100644 --- a/dlls/squad.h +++ b/dlls/squad.h @@ -7,6 +7,7 @@ //========================================================= // squad.h //========================================================= +#pragma once #ifndef SQUAD_H #define SQUAD_H diff --git a/dlls/squadmonster.h b/dlls/squadmonster.h index 132d4177..e2c8a5b9 100644 --- a/dlls/squadmonster.h +++ b/dlls/squadmonster.h @@ -16,6 +16,7 @@ // CSquadMonster - all the extra data for monsters that // form squads. //========================================================= +#pragma once #ifndef SQUADMONSTER_H #define SQUADMONSTER_H diff --git a/dlls/talkmonster.h b/dlls/talkmonster.h index 084861bc..36ac21a6 100644 --- a/dlls/talkmonster.h +++ b/dlls/talkmonster.h @@ -12,6 +12,7 @@ * use or distribution of this code by or to any unlicensed person is illegal. * ****/ +#pragma once #ifndef TALKMONSTER_H #define TALKMONSTER_H diff --git a/dlls/teamplay_gamerules.h b/dlls/teamplay_gamerules.h index 06823ca6..12ed038f 100644 --- a/dlls/teamplay_gamerules.h +++ b/dlls/teamplay_gamerules.h @@ -15,6 +15,9 @@ // // teamplay_gamerules.h // +#pragma once +#ifndef TEAMPLAY_GAMERULES_H +#define TEAMPLAY_GAMERULES_H #define MAX_TEAMNAME_LENGTH 16 #define MAX_TEAMS 32 @@ -55,3 +58,4 @@ private: BOOL m_teamLimit; // This means the server set only some teams as valid char m_szTeamList[TEAMPLAY_TEAMLISTLENGTH]; }; +#endif // TEAMPLAY_GAMERULES_H diff --git a/dlls/trains.h b/dlls/trains.h index e8003b3e..f740e2ea 100644 --- a/dlls/trains.h +++ b/dlls/trains.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef TRAINS_H #define TRAINS_H diff --git a/dlls/triggers.cpp b/dlls/triggers.cpp index 7d7f255c..6d8fef04 100644 --- a/dlls/triggers.cpp +++ b/dlls/triggers.cpp @@ -267,11 +267,11 @@ public: static TYPEDESCRIPTION m_SaveData[]; - string_t m_iTargetName[MAX_MULTI_TARGETS];// list if indexes into global string array - float m_flTargetDelay[MAX_MULTI_TARGETS];// delay (in seconds) from time of manager fire to target fire int m_cTargets; // the total number of targets in this manager's fire list. int m_index; // Current target float m_startTime;// Time we started firing + string_t m_iTargetName[MAX_MULTI_TARGETS];// list if indexes into global string array + float m_flTargetDelay[MAX_MULTI_TARGETS];// delay (in seconds) from time of manager fire to target fire private: inline BOOL IsClone( void ) { return ( pev->spawnflags & SF_MULTIMAN_CLONE ) ? TRUE : FALSE; } inline BOOL ShouldClone( void ) @@ -1321,9 +1321,9 @@ public: static TYPEDESCRIPTION m_SaveData[]; - string_t m_changeTarget; char m_szMapName[cchMapNameMost]; // trigger_changelevel only: next map char m_szLandmarkName[cchMapNameMost]; // trigger_changelevel only: landmark on next map + string_t m_changeTarget; float m_changeTargetDelay; }; diff --git a/dlls/util.h b/dlls/util.h index 8f56cd76..7f9dea70 100644 --- a/dlls/util.h +++ b/dlls/util.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef UTIL_H #define UTIL_H // diff --git a/dlls/vector.h b/dlls/vector.h index 265a9b00..48c707b4 100644 --- a/dlls/vector.h +++ b/dlls/vector.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef VECTOR_H #define VECTOR_H diff --git a/dlls/weapons.h b/dlls/weapons.h index 0cfa2031..312f5531 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef WEAPONS_H #define WEAPONS_H diff --git a/engine/cdll_exp.h b/engine/cdll_exp.h index bf43654c..e4c1f5d8 100644 --- a/engine/cdll_exp.h +++ b/engine/cdll_exp.h @@ -12,6 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ +#pragma once #ifndef CDLL_EXP_H #define CDLL_EXP_H @@ -66,4 +67,4 @@ typedef struct cldll_func_s void (*pfnClipMoveToEntity)( struct physent_s *pe, const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, struct pmtrace_s *tr ); } cldll_func_t; -#endif//CDLL_EXP_H \ No newline at end of file +#endif//CDLL_EXP_H diff --git a/engine/cdll_int.h b/engine/cdll_int.h index 20af4b55..abfc43bd 100644 --- a/engine/cdll_int.h +++ b/engine/cdll_int.h @@ -18,7 +18,7 @@ // 4-23-98 // JOHN: client dll interface declarations // - +#pragma once #ifndef CDLL_INT_H #define CDLL_INT_H diff --git a/engine/custom.h b/engine/custom.h index 30ee8d53..02aa2089 100644 --- a/engine/custom.h +++ b/engine/custom.h @@ -12,11 +12,10 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef CUSTOM_H #define CUSTOM_H -#pragma once - #include "const.h" ///////////////// diff --git a/engine/customentity.h b/engine/customentity.h index 63e672f8..f524ae79 100644 --- a/engine/customentity.h +++ b/engine/customentity.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef CUSTOMENTITY_H #define CUSTOMENTITY_H diff --git a/engine/edict.h b/engine/edict.h index 3994c705..8584a0d9 100644 --- a/engine/edict.h +++ b/engine/edict.h @@ -12,12 +12,10 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef EDICT_H #define EDICT_H -#pragma once - #define MAX_ENT_LEAFS 48 #include "progdefs.h" diff --git a/engine/eiface.h b/engine/eiface.h index 6fa51c12..f6cf2f51 100644 --- a/engine/eiface.h +++ b/engine/eiface.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef EIFACE_H #define EIFACE_H diff --git a/engine/keydefs.h b/engine/keydefs.h index ea22139f..5593d75a 100644 --- a/engine/keydefs.h +++ b/engine/keydefs.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef KEYDEFS_H #define KEYDEFS_H @@ -130,4 +130,4 @@ #define K_MOUSE4 244 #define K_MOUSE5 245 -#endif//KEYDEFS_H \ No newline at end of file +#endif//KEYDEFS_H diff --git a/engine/menu_int.h b/engine/menu_int.h index 69c10ce4..d907bd87 100644 --- a/engine/menu_int.h +++ b/engine/menu_int.h @@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ - +#pragma once #ifndef MENU_INT_H #define MENU_INT_H diff --git a/engine/physint.h b/engine/physint.h index af923a00..2b4ac8f7 100644 --- a/engine/physint.h +++ b/engine/physint.h @@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ - +#pragma once #ifndef PHYSINT_H #define PHYSINT_H @@ -111,4 +111,4 @@ typedef struct physics_interface_s int (*pfnRestoreDecal)( struct decallist_s *entry, edict_t *pEdict, qboolean adjacent ); } physics_interface_t; -#endif//PHYSINT_H \ No newline at end of file +#endif//PHYSINT_H diff --git a/engine/progdefs.h b/engine/progdefs.h index 56d904b1..31cfb3cb 100644 --- a/engine/progdefs.h +++ b/engine/progdefs.h @@ -12,11 +12,10 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef PROGDEFS_H #define PROGDEFS_H -#pragma once - typedef struct { float time; diff --git a/engine/shake.h b/engine/shake.h index b2e88a33..a3e49324 100644 --- a/engine/shake.h +++ b/engine/shake.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef SHAKE_H #define SHAKE_H diff --git a/engine/sprite.h b/engine/sprite.h index afc81a4e..4368c1ac 100644 --- a/engine/sprite.h +++ b/engine/sprite.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef SPRITE_H #define SPRITE_H @@ -99,4 +99,4 @@ typedef struct frametype_t type; } dframetype_t; -#endif//SPRITE_H \ No newline at end of file +#endif//SPRITE_H diff --git a/engine/studio.h b/engine/studio.h index 00e7ad27..88254c96 100644 --- a/engine/studio.h +++ b/engine/studio.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef STUDIO_H #define STUDIO_H diff --git a/pm_shared/pm_debug.h b/pm_shared/pm_debug.h index 417c3478..6c91d62e 100644 --- a/pm_shared/pm_debug.h +++ b/pm_shared/pm_debug.h @@ -12,11 +12,10 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef PM_DEBUG_H #define PM_DEBUG_H -#pragma once - void PM_ViewEntity( void ); void PM_DrawBBox( vec3_t mins, vec3_t maxs, vec3_t origin, int pcolor, float life ); void PM_ParticleLine( vec3_t start, vec3_t end, int pcolor, float life, float vert ); diff --git a/pm_shared/pm_defs.h b/pm_shared/pm_defs.h index eddb17b6..82480806 100644 --- a/pm_shared/pm_defs.h +++ b/pm_shared/pm_defs.h @@ -12,11 +12,10 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef PM_DEFS_H #define PM_DEFS_H -#pragma once - #define MAX_PHYSENTS 600 // Must have room for all entities in the world. #define MAX_MOVEENTS 64 #define MAX_CLIP_PLANES 5 diff --git a/pm_shared/pm_info.h b/pm_shared/pm_info.h index d75b67fc..9a971d53 100644 --- a/pm_shared/pm_info.h +++ b/pm_shared/pm_info.h @@ -12,10 +12,9 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef PM_INFO_H #define PM_INFO_H -#pragma once - #define MAX_PHYSINFO_STRING 256 #endif//PM_INFO_H diff --git a/pm_shared/pm_materials.h b/pm_shared/pm_materials.h index e625b4fc..9bc71b72 100644 --- a/pm_shared/pm_materials.h +++ b/pm_shared/pm_materials.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef PM_MATERIALS_H #define PM_MATERIALS_H diff --git a/pm_shared/pm_movevars.h b/pm_shared/pm_movevars.h index 35fa5b4f..61eb06fd 100644 --- a/pm_shared/pm_movevars.h +++ b/pm_shared/pm_movevars.h @@ -6,6 +6,7 @@ //============================================================================= // pm_movevars.h +#pragma once #if !defined( PM_MOVEVARSH ) #define PM_MOVEVARSH diff --git a/pm_shared/pm_shared.h b/pm_shared/pm_shared.h index 2fb947a2..c315353b 100644 --- a/pm_shared/pm_shared.h +++ b/pm_shared/pm_shared.h @@ -12,12 +12,10 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef PM_SHARED_H #define PM_SHARED_H -#pragma once - void PM_Init( struct playermove_s *ppmove ); void PM_Move( struct playermove_s *ppmove, int server ); char PM_FindTextureType( char *name ); From bf429f0709d5045a8cf2880b3b035fb0ab0b41e7 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Sat, 16 Dec 2017 04:56:23 +0300 Subject: [PATCH 24/25] Fix item soda precache --- dlls/effects.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/effects.cpp b/dlls/effects.cpp index bd9959f9..bd12f8aa 100644 --- a/dlls/effects.cpp +++ b/dlls/effects.cpp @@ -2182,7 +2182,7 @@ public: void CItemSoda::Precache( void ) { PRECACHE_MODEL( "models/can.mdl" ); - PRECACHE_SOUND( "weapons/g_bounce.wav" ); + PRECACHE_SOUND( "weapons/g_bounce3.wav" ); } LINK_ENTITY_TO_CLASS( item_sodacan, CItemSoda ) From 1285d4834781aead0d99c65784ebb671be5e59e1 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 17 Dec 2017 02:35:36 +0500 Subject: [PATCH 25/25] Update .travis.yml. --- .travis.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9e165b81..00f3f479 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,10 +5,20 @@ compiler: os: - linux - osx -sudo: true +addons: + apt: + packages: + - gcc-multilib + - g++-multilib before_script: - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install gcc-multilib g++-multilib; fi + - curl http://libsdl.org/release/SDL2-devel-2.0.7-mingw.tar.gz | tar xzf - + - mv SDL2-2.0.7/i686-w64-mingw32/include/SDL2 cl_dll/ script: - mkdir -p build && cd build - - cmake ../ -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" -DUSE_VOICEMGR=0 && make -j3 && rm -rf * - - cmake ../ -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" -DUSE_VOICEMGR=1 && make -j3 && rm -rf * \ No newline at end of file + - cmake ../ -DCMAKE_C_FLAGS="-O2 -pipe -DNDEBUG -march=nocona -fvisibility=hidden -fomit-frame-pointer" -DCMAKE_CXX_FLAGS="-fno-exceptions -fno-rtti" -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined -Wl,--strip-all" -DGOLDSOURCE_SUPPORT=1 -DUSE_VOICEMGR=0 && make -j3 + - mkdir -p gamelibs/cl_dlls + - mkdir -p gamelibs/dlls + - cp cl_dll/libclient.* gamelibs/cl_dlls + - cp dlls/libserver.* gamelibs/dlls + - tar -J -cf gamelibs.txz gamelibs + - curl --upload-file gamelibs.txz https://transfer.sh/gamelibs.txz