merge in HL25 fixes

This commit is contained in:
pierow 2024-03-04 23:29:53 -05:00
commit 833eb0a792
15 changed files with 175 additions and 71 deletions

View file

@ -83,3 +83,6 @@ mp_uplink 0
// Needed so this file is executed on map change, like pre-NS v2.1
mapchangecfgfile listenserver.cfg
//Post HL 25th Aniversary update
sv_rollangle 0

View file

@ -100,3 +100,6 @@ mp_uplink 1
// Needed so this file is executed on map change, like pre-NS v2.1
mapchangecfgfile server.cfg
//Post HL 25th Aniversary update
sv_rollangle 0

View file

@ -24,7 +24,7 @@ public:
AVHHSPRITE m_hsprCursor;
float m_flTime; // the current client time
float m_fOldTime; // the time at which the HUD was last redrawn
float m_wsFOV; //fov recalc corrected for widescreen
//float m_wsFOV; //fov recalc corrected for widescreen
double m_flTimeDelta; // the difference between flTime and fOldTime
Vector m_vecOrigin;
Vector m_vecAngles;

View file

@ -41,47 +41,46 @@ int CHud::UpdateClientData(client_data_t *cdata, float time)
Think();
//cdata->fov = m_iFOV;
cdata->fov = m_iFOV;
float width = ScreenWidth();
float height = ScreenHeight();
//// Horizontal+ widescreen view correction - Removed after HL25 update
//float width = ScreenWidth();
//float height = ScreenHeight();
// Horizontal+ widescreen view correction - engine uses vertical- cropping
//// Cvar to let players use old widescreen. Only allow it to change when not alive so it can't be used as a zoom toggle.
//if (!gHUD.GetIsAlive(false))
//{
// wstoggle = CVAR_GET_FLOAT("cl_widescreen") != 0;
//}
// Cvar to let players use old widescreen. Only allow it to change when not alive so it can't be used as a zoom toggle.
if (!gHUD.GetIsAlive(false))
{
wstoggle = CVAR_GET_FLOAT("cl_widescreen") != 0;
}
//if (wstoggle)
//{
// m_wsFOV = atanf(tan(m_iFOV * M_PI / 360) * 0.75 * width / height) * 360 / M_PI;
if (wstoggle)
{
m_wsFOV = atanf(tan(m_iFOV * M_PI / 360) * 0.75 * width / height) * 360 / M_PI;
// //clamp for game balance
// if (m_iFOV == 105 && m_wsFOV > 121)
// {
// m_wsFOV = 120;
// }
// else if (m_iFOV == 100 && m_wsFOV > 117)
// {
// m_wsFOV = 116;
// }
// else if (m_iFOV == 90 && m_wsFOV > 107)
// {
// m_wsFOV = 106;
// }
// else if (m_wsFOV < 90)
// {
// m_wsFOV = 90;
// }
//}
//else
//{
// m_wsFOV = m_iFOV;
//}
//clamp for game balance
if (m_iFOV == 105 && m_wsFOV > 121)
{
m_wsFOV = 120;
}
else if (m_iFOV == 100 && m_wsFOV > 117)
{
m_wsFOV = 116;
}
else if (m_iFOV == 90 && m_wsFOV > 107)
{
m_wsFOV = 106;
}
else if (m_wsFOV < 90)
{
m_wsFOV = 90;
}
}
else
{
m_wsFOV = m_iFOV;
}
cdata->fov = m_wsFOV;
//cdata->fov = m_wsFOV;
CL_ResetButtonBits( m_iKeyBits );

View file

@ -139,7 +139,7 @@ cvar_t *cl_dynamiclights;
cvar_t *r_dynamic;
cvar_t *cl_buildmessages;
cvar_t *cl_particleinfo;
cvar_t *cl_widescreen;
//cvar_t *cl_widescreen;
cvar_t *cl_ambientsound;
cvar_t *senslock;
cvar_t *cl_chatbeep;
@ -1702,7 +1702,7 @@ void InitInput (void)
cl_cmhotkeys = gEngfuncs.pfnRegisterVariable ( kvCMHotkeys, "qwerasdfzxcv", FCVAR_ARCHIVE );
//cl_forcedefaultfov = gEngfuncs.pfnRegisterVariable ( kvForceDefaultFOV, "0", FCVAR_ARCHIVE );
cl_particleinfo = gEngfuncs.pfnRegisterVariable ( kvParticleInfo, "0", FCVAR_ARCHIVE );
cl_widescreen = gEngfuncs.pfnRegisterVariable ( kvWidescreen, "1", FCVAR_ARCHIVE );
//cl_widescreen = gEngfuncs.pfnRegisterVariable ( kvWidescreen, "1", FCVAR_ARCHIVE );
cl_ambientsound = gEngfuncs.pfnRegisterVariable ( kvAmbientSound, "0.6", FCVAR_ARCHIVE);
senslock = gEngfuncs.pfnRegisterVariable ("senslock", "0", FCVAR_ARCHIVE);
cl_chatbeep = gEngfuncs.pfnRegisterVariable ("cl_chatbeep", "1", FCVAR_ARCHIVE);

View file

@ -96,14 +96,18 @@ int old_mouse_x, old_mouse_y, mx_accum, my_accum;
float mouse_x, mouse_y;
static int restore_spi;
//// Previous code from HL SDK windows98 for era paramaters. See comments in IN_StartupMouse.
//// Previous code from Quake era forced mouse accel. Also adjusted launch params in IN_StartupMouse.
//static int originalmouseparms[3], newmouseparms[3] = {0, 0, 1};
////Mouse accel forced off.
static int originalmouseparms[3], newmouseparms[3] = { 0, 0, 0};
static int mouseactive = 0;
int mouseinitialized;
static int mouseparmsvalid;
static int mouseshowtoggle = 1;
////2024 - Added to fix view spin when disabling the cursor.
static bool cursorDisabledThisFrame = false;
// joystick defines and variables
// where should defines be moved?
#define JOY_ABSOLUTE_AXIS 0x00000000 // control like a joystick
@ -311,7 +315,21 @@ void IN_SetVisibleMouse(bool visible)
g_iVisibleMouse = visible;
IN_SetMouseMode(!visible);
////2024 - Disabled this as SDL mouse mode is handled per use of UIManager::SetMouseVisibility to fix edge case bugs with centering and showing/not showing cursor in game and in the escape menu.
//IN_SetMouseMode(!visible);
//2024 - Added to fix view spin when disabling the cursor. Reassess after new SDK is released.
cursorDisabledThisFrame = (!visible);
////2024 - Move centering here?
//if (visible && gHUD.m_bWindowed)
//{
// gEngfuncs.pfnSetMousePos(ScreenWidth() / 2, ScreenHeight() / 2);
//}
//else
//{
// gEngfuncs.pfnSetMousePos(gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY());
//}
#ifdef _WIN32
UpdateMouseThreadActive();
@ -389,12 +407,7 @@ void IN_StartupMouse (void)
if (mouseparmsvalid)
{
//// Original mouse parameter code. SPI_GETMOUSE windows parameters changed either in win2000 or winxp and these launch parameters haven't made sense since.
//// The newmouseparms[2] (mouse accel on/off in newer windows) was also hardcoded to 1 previously, forcing acceleration on for players without noforcemspd or noforcemparms parameters. This was done so to make mouse speed = 1 in win98.
//// SPI_GETMOUSE documentation:
//// Win10: https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-systemparametersinfoa
//// https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-mouse_event
//// Win98: Retrieve the x-axis and y-axis threshold values for the mouse as well as the mouse speed. uiParam must be 0. pvParam is a 3-element array of Long-type variables which receives the x-threshold, y-threshold, and mouse speed.
//// Original mouse parameter code before disabling forced mouse acceleration.
//if ( gEngfuncs.CheckParm ("-noforcemspd", NULL ) )
// newmouseparms[2] = originalmouseparms[2];
//
@ -646,6 +659,14 @@ void IN_GetMouseDelta( int *pOutX, int *pOutY)
mx = deltaX + mx_accum;
my = deltaY + my_accum;
}
//2024 - Added to fix view spin when disabling the cursor.
if (cursorDisabledThisFrame)
{
mx = 0;
my = 0;
cursorDisabledThisFrame = false;
}
mx_accum = 0;
my_accum = 0;
@ -760,7 +781,7 @@ void IN_MouseMove ( float frametime, usercmd_t *cmd)
}
}
}
gEngfuncs.SetViewAngles( (float *)viewangles );
/*
@ -805,7 +826,7 @@ void CL_DLLEXPORT IN_Accumulate (void)
int deltaX, deltaY;
SDL_GetRelativeMouseState( &deltaX, &deltaY );
mx_accum += deltaX;
my_accum += deltaY;
my_accum += deltaY;
}
// force the mouse to the center, so there's room to move

View file

@ -182,7 +182,14 @@ void CreatePickingRay( int mousex, int mousey, Vector& outVecPickingRay )
// char gDebugMessage[256];
float fovDegrees = gHUD.m_wsFOV;
//float fovDegrees = gHUD.m_wsFOV;
bool wideScreen = CVAR_GET_FLOAT("gl_widescreen_yfov");
float fovDegrees = gHUD.m_iFOV;
//Adjust for widescreen FOV
if (wideScreen)
{
fovDegrees = atanf(tan(gHUD.m_iFOV * M_PI / 360) * 0.75f * ScreenWidth() / ScreenHeight()) * 360 / M_PI;
}
//cl_entity_s* theLocalEntity = gEngfuncs.GetLocalPlayer();
//Vector vecRenderOrigin = theLocalEntity->origin;

View file

@ -123,6 +123,7 @@ cvar_t avh_mapvoteratio = {kvMapVoteRatio, ".6", FCVAR_SERVER};
cvar_t avh_blockscripts = {kvBlockScripts, "1", FCVAR_SERVER};
cvar_t avh_jumpmode = {kvJumpMode, "1", FCVAR_SERVER};
cvar_t avh_version = {kvVersion, "330", FCVAR_SERVER};
cvar_t avh_widescreenclamp = {kvWidescreenClamp, "0", FCVAR_SERVER};
cvar_t avh_randomrfk = {kvRandomRfk, "0", FCVAR_SERVER};
//playtest cvars
cvar_t avh_fastjp = {kvfastjp, "0", FCVAR_SERVER};
@ -239,6 +240,7 @@ void GameDLLInit( void )
CVAR_REGISTER (&avh_blockscripts);
CVAR_REGISTER (&avh_jumpmode);
CVAR_REGISTER (&avh_version);
CVAR_REGISTER (&avh_widescreenclamp);
//playtest cvars
CVAR_REGISTER (&avh_fastjp);
CVAR_REGISTER (&avh_randomrfk);
@ -270,5 +272,9 @@ void GameDLLInit( void )
CVAR_REGISTER (&avh_uplink);
CVAR_REGISTER (&avh_killdelay);
//Remove HL25 addition of roll angle and overbright shader in code so servers don't need to update configs.
CVAR_SET_FLOAT("sv_rollangle", 0.0f);
CVAR_SET_FLOAT("sv_allow_shaders", 0.0f);
}

View file

@ -47,7 +47,7 @@ extern cvar_t* cl_musicdir;
// :
#define kvCMHotKeys "cl_cmhotkeys"
//#define kvForceDefaultFOV "cl_forcedefaultfov"
#define kvWidescreen "cl_widescreen"
//#define kvWidescreen "cl_widescreen"
#define kvAmbientSound "cl_ambientsound"
#define kvCenterEntityID "cl_centerentityid"
#define kvHighDetail "cl_highdetail"

View file

@ -338,6 +338,8 @@ AvHGamerules::AvHGamerules() : mTeamA(TEAM_ONE), mTeamB(TEAM_TWO)
RegisterServerVariable(avh_cheats);
RegisterServerVariable(&avh_structurelimit);
RegisterServerVariable(&avh_version);
RegisterServerVariable(&avh_widescreenclamp);
//playtest cvars
RegisterServerVariable(&avh_fastjp);
RegisterServerVariable(&avh_randomrfk);

View file

@ -4904,6 +4904,8 @@ cvar_t *lightgamma = NULL;
cvar_t *texgamma = NULL;
cvar_t *r_detailtextures = NULL;
cvar_t *gl_max_size = NULL;
cvar_t *gl_widescreen_yfov = NULL;
cvar_t *sv_widescreenclamp = NULL;
void AvHHud::InitExploitPrevention() {
gl_monolights = gEngfuncs.pfnGetCvarPointer("gl_monolights");
@ -4918,6 +4920,7 @@ void AvHHud::InitExploitPrevention() {
texgamma = gEngfuncs.pfnGetCvarPointer("texgamma");
r_detailtextures = gEngfuncs.pfnGetCvarPointer("r_detailtextures");
gl_max_size = gEngfuncs.pfnGetCvarPointer("gl_max_size");
gl_widescreen_yfov = gEngfuncs.pfnGetCvarPointer("gl_widescreen_yfov");
ForceCvar("gl_monolights", gl_monolights, 0.0f);
ForceCvar("gl_overbright", gl_overbright, 0.0f);
@ -4944,6 +4947,11 @@ void AvHHud::InitExploitPrevention() {
if(texgamma && texgamma->value > 5.0) {
ForceCvar("texgamma", texgamma, 5.0f);
}
RemoveAlias("gl_widescreen_yfov");
if (gl_widescreen_yfov)
{
mWideScreen = gl_widescreen_yfov->value;
}
}
@ -4974,6 +4982,48 @@ void AvHHud::UpdateExploitPrevention()
if(texgamma && texgamma->value > 5.0) {
ForceCvar("texgamma", texgamma, 5.0f);
}
//Widescreen exploit prevention
if (gViewPort)
{
if (gHUD.GetIsAlive(false))
{
if (gl_widescreen_yfov && gl_widescreen_yfov->value == 0 && mWideScreen) {
ForceCvar("gl_widescreen_yfov", gl_widescreen_yfov, 1.0f);
mWideScreenChanged = true;
gEngfuncs.pfnCenterPrint("The Widescreen FOV\n will change after death\n");
}
if (gl_widescreen_yfov && gl_widescreen_yfov->value != 0 && !mWideScreen) {
ForceCvar("gl_widescreen_yfov", gl_widescreen_yfov, 0);
mWideScreenChanged = true;
gEngfuncs.pfnCenterPrint("The Widescreen FOV\n will change after death\n");
}
}
else if (mWideScreenChanged)
{
mWideScreen = !mWideScreen;
ForceCvar("gl_widescreen_yfov", gl_widescreen_yfov, (float)mWideScreen);
mWideScreenChanged = false;
}
else
{
mWideScreen = gl_widescreen_yfov->value;
}
//sv_widescreenclamp is to prevent abuse of ultra-widescreen FOVs in competitive play.
if ((ScreenWidth() / ScreenHeight()) > 1.8f)
{
if (this->GetServerVariableFloat(kvWidescreenClamp) != 0 && gl_widescreen_yfov && gl_widescreen_yfov->value != 0)
{
ForceCvar("gl_widescreen_yfov", gl_widescreen_yfov, 0);
gEngfuncs.pfnCenterPrint("This aspect ratio is not allowed\n on this server\n");
}
}
}
//else if (gl_widescreen_yfov)
//{
// mWideScreen = gl_widescreen_yfov->value;
// gEngfuncs.Con_Printf("init mwidescreen from update %d\n", mWideScreen);
//}
}
void AvHHud::UpdateAlienUI(float inCurrentTime)

View file

@ -879,6 +879,9 @@ private:
static bool sShowMap;
bool mWideScreen;
bool mWideScreenChanged;
bool mReInitHUD;
float mLastHudStyle;

View file

@ -79,7 +79,7 @@ PieMenu* AvHPieMenuHandler::GetActivePieMenu()
void AvHPieMenuHandler::ClosePieMenu(void)
{
//if (!sPieMenuOpen)
//{
// return;
@ -138,7 +138,7 @@ void AvHPieMenuHandler::InternalClosePieMenu(void)
if(!gHUD.GetInTopDownMode())
{
gHUD.GetManager().SetMouseVisibility(false);
// OS cursor displaying over in game cursor fix. Remove if showcursor code in SetMouseVisibility is made bug free.
#ifdef WIN32
if(sPieMenuOpen)
@ -153,11 +153,12 @@ void AvHPieMenuHandler::InternalClosePieMenu(void)
}
sLastNodeHighlighted = NULL;
// Return to raw input after menu closes
if (CVAR_GET_FLOAT("m_rawinput") != 0 && sPieMenuOpen)
{
SDL_SetRelativeMouseMode(SDL_TRUE);
}
//// Not needed post-HL25.
//// Return to raw input after menu closes
//if (CVAR_GET_FLOAT("m_rawinput") != 0 && sPieMenuOpen)
//{
// SDL_SetRelativeMouseMode(SDL_TRUE);
//}
// if(sTheDebugBool)
// {
@ -199,10 +200,11 @@ void AvHPieMenuHandler::OpenPieMenu(void)
gHUD.HideCrosshair();
// Workaround for not being able to center mouse with raw input enabled.
// Center mouse for raw input.
if (CVAR_GET_FLOAT("m_rawinput") != 0 && !sPieMenuOpen)
{
SDL_SetRelativeMouseMode(SDL_FALSE);
//// Not needed post-HL25.
//SDL_SetRelativeMouseMode(SDL_FALSE);
if (gHUD.m_bWindowed)
{
@ -299,13 +301,15 @@ void AvHPieMenuHandler::cursorMoved(int x,int y,Panel* panel)
// char theMessage[128];
// sprintf(theMessage, "AvHPieMenuHandler::cursorMoved %d, %d (panel ptr: %d).\n", x, y, (int)panel);
// CenterPrint(theMessage);
if (sPieMenuOpen && CVAR_GET_FLOAT("m_rawinput") != 0)
{
if (SDL_GetRelativeMouseMode() != SDL_TRUE)
{
SDL_SetRelativeMouseMode(SDL_TRUE);
}
}
//// Not needed post-HL25.
//if (sPieMenuOpen && CVAR_GET_FLOAT("m_rawinput") != 0)
//{
// if (SDL_GetRelativeMouseMode() != SDL_TRUE)
// {
// SDL_SetRelativeMouseMode(SDL_TRUE);
// }
//}
}
void AvHPieMenuHandler::cursorEntered(Panel* panel)

View file

@ -96,6 +96,7 @@ extern cvar_t *violence_agibs;
extern cvar_t avh_killdelay;
extern cvar_t *showtriggers;
extern cvar_t avh_version;
extern cvar_t avh_widescreenclamp;
//playtest cvars
extern cvar_t avh_fastjp;
extern cvar_t avh_randomrfk;
@ -149,6 +150,8 @@ float ns_cvar_float(const cvar_t *cvar);
#define kvBlockScripts "mp_blockscripts"
#define kvJumpMode "sv_jumpmode"
#define kvVersion "sv_nsversion"
#define kvWidescreenClamp "sv_widescreenclamp"
//playtest cvars
#define kvfastjp "sv_fastjp"
#define kvRandomRfk "mp_randomresfromkill"

View file

@ -27,6 +27,7 @@ extern "C"
void* VGui_GetPanel();
}
extern int g_iVisibleMouse;
void IN_SetVisibleMouse(bool visible);
UIManager::UIManager(UIFactory* inFactory)
{
@ -295,12 +296,14 @@ bool UIManager::SetLMBActionRelative(const TRTag& inTag)
void UIManager::SetMouseVisibility(bool inState)
{
// 2021 - Check if we need to run code. Prevents showcursor from incrementing or decrementing outside of useful range.
int NewDesiredState = (inState) ? 1 : 0;
int newDesiredState = (inState) ? 1 : 0;
if (g_iVisibleMouse != NewDesiredState)
if (g_iVisibleMouse != newDesiredState)
{
// To change whether the mouse is visible, just change this variable
g_iVisibleMouse = NewDesiredState;
//g_iVisibleMouse = newDesiredState;
//2024 - Using this to fix view spin on reactivation in HL25. SDL mouse modes are changed alongside the use of SetMouseVisibility instead of in this function so the cursor doesn't disappear in the escape menu.
IN_SetVisibleMouse(newDesiredState);
// Update cursor
if(g_iVisibleMouse)
@ -326,7 +329,7 @@ void UIManager::SetMouseVisibility(bool inState)
// Move mouse to center of screen so mouse look isn't changed
// Only do this when in full screen
App::getInstance()->setCursorPos(ScreenWidth()/2, ScreenHeight()/2);
App::getInstance()->setCursorPos(ScreenWidth()/2, ScreenHeight()/2);
// Hide cursor again
App::getInstance()->setCursorOveride( App::getInstance()->getScheme()->getCursor(Scheme::scu_none) );