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; float x, y;
int ca; int ca;
if ( !cg_drawCrosshair.integer ) { if ( !cg_drawCrosshair.integer || vr->no_crosshair ) {
return; return;
} }
@ -1951,7 +1951,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

@ -22,6 +22,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