Merge pull request #24 from petr666/feature/no-crosshair-mod

Allow to disable crosshair by server via sending "no crosshair" string in server info to client
This commit is contained in:
Simon 2022-03-18 22:25:35 +00:00 committed by GitHub
commit 58d51a9b47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 3 deletions

View file

@ -1884,7 +1884,7 @@ static void CG_DrawCrosshair(void)
float x, y;
int ca;
if ( !cg_drawCrosshair.integer ) {
if ( !cg_drawCrosshair.integer || vr->no_crosshair ) {
return;
}
@ -1951,7 +1951,7 @@ static void CG_DrawCrosshair3D(void)
char rendererinfos[128];
refEntity_t ent;
if ( !cg_drawCrosshair.integer ) {
if ( !cg_drawCrosshair.integer || vr->no_crosshair ) {
return;
}

View file

@ -1972,6 +1972,9 @@ void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum ) {
CG_ShaderStateChanged();
trap_S_ClearLoopingSounds( qtrue );
const char *serverinfo = CG_ConfigString( CS_SERVERINFO );
vr->no_crosshair = (strcasestr(serverinfo, "nocrosshair") != NULL || strcasestr(serverinfo, "no crosshair") != NULL);
}
/*

View file

@ -1722,7 +1722,7 @@ void CG_AddViewWeapon( playerState_t *ps ) {
// set up gun position
CG_CalculateVRWeaponPosition( hand.origin, angles );
if (trap_Cvar_VariableValue("vr_lasersight") != 0.0f)
if (trap_Cvar_VariableValue("vr_lasersight") != 0.0f && !vr->no_crosshair)
{
vec3_t forward, end, dir;
AngleVectors(angles, forward, NULL, NULL);

View file

@ -515,6 +515,10 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) {
G_RemapTeamShaders();
trap_SetConfigstring( CS_INTERMISSION, "" );
char serverinfo[MAX_INFO_STRING];
trap_GetServerinfo( serverinfo, sizeof( serverinfo ) );
vr->no_crosshair = (strcasestr(serverinfo, "nocrosshair") != NULL || strcasestr(serverinfo, "no crosshair") != NULL);
}

View file

@ -22,6 +22,7 @@ typedef struct {
vrFollowMode_t follow_mode;
qboolean weapon_select;
qboolean weapon_select_autoclose;
qboolean no_crosshair;
int realign; // used to realign the fake 6DoF playspace in a multiplayer game