Allow to disable crosshair by server via sending "no crosshair" string in server info to client

This commit is contained in:
Petr Bartos 2022-03-18 20:43:20 +01:00
parent 9aef5b5d68
commit eccea2469f
5 changed files with 11 additions and 3 deletions

View file

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

View file

@ -1972,6 +1972,9 @@ void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum ) {
CG_ShaderStateChanged(); CG_ShaderStateChanged();
trap_S_ClearLoopingSounds( qtrue ); 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 // set up gun position
CG_CalculateVRWeaponPosition( hand.origin, angles ); 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; vec3_t forward, end, dir;
AngleVectors(angles, forward, NULL, NULL); AngleVectors(angles, forward, NULL, NULL);

View file

@ -515,6 +515,10 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) {
G_RemapTeamShaders(); G_RemapTeamShaders();
trap_SetConfigstring( CS_INTERMISSION, "" ); 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

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