2018-04-13 18:23:45 +02:00
|
|
|
/*
|
|
|
|
cvar.h - dynamic variable tracking
|
|
|
|
Copyright (C) 2017 Uncle Mike
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CVAR_H
|
|
|
|
#define CVAR_H
|
|
|
|
|
|
|
|
#include "cvardef.h"
|
|
|
|
|
2021-07-20 15:02:59 +02:00
|
|
|
#ifdef XASH_64BIT
|
|
|
|
#define CVAR_SENTINEL 0xDEADBEEFDEADBEEF
|
|
|
|
#else
|
2018-04-13 18:23:45 +02:00
|
|
|
#define CVAR_SENTINEL 0xDEADBEEF
|
2021-07-20 15:02:59 +02:00
|
|
|
#endif
|
|
|
|
#define CVAR_CHECK_SENTINEL( cv ) ((uintptr_t)(cv)->next == CVAR_SENTINEL)
|
2018-04-13 18:23:45 +02:00
|
|
|
|
|
|
|
// NOTE: if this is changed, it must be changed in cvardef.h too
|
|
|
|
typedef struct convar_s
|
|
|
|
{
|
|
|
|
// this part shared with cvar_t
|
|
|
|
char *name;
|
|
|
|
char *string;
|
|
|
|
int flags;
|
|
|
|
float value;
|
|
|
|
struct convar_s *next;
|
|
|
|
|
|
|
|
// this part unique for convar_t
|
|
|
|
char *desc; // variable descrition info
|
|
|
|
char *def_string; // keep pointer to initial value
|
|
|
|
} convar_t;
|
|
|
|
|
|
|
|
// cvar internal flags
|
|
|
|
#define FCVAR_RENDERINFO (1<<16) // save to a seperate config called video.cfg
|
|
|
|
#define FCVAR_READ_ONLY (1<<17) // cannot be set by user at all, and can't be requested by CvarGetPointer from game dlls
|
|
|
|
#define FCVAR_EXTENDED (1<<18) // this is convar_t (sets on registration)
|
|
|
|
#define FCVAR_ALLOCATED (1<<19) // this convar_t is fully dynamic allocated (include description)
|
|
|
|
#define FCVAR_VIDRESTART (1<<20) // recreate the window is cvar with this flag was changed
|
|
|
|
#define FCVAR_TEMPORARY (1<<21) // these cvars holds their values and can be unlink in any time
|
2021-11-02 11:28:43 +01:00
|
|
|
#define FCVAR_MOVEVARS (1<<22) // this cvar is a part of movevars_t struct that shared between client and server
|
2022-11-05 03:09:54 +01:00
|
|
|
#define FCVAR_USER_CREATED (1<<23) // created by a set command (dll's used)
|
2018-04-13 18:23:45 +02:00
|
|
|
|
2021-03-09 21:58:21 +01:00
|
|
|
#define CVAR_DEFINE( cv, cvname, cvstr, cvflags, cvdesc ) \
|
2021-07-20 15:02:59 +02:00
|
|
|
convar_t cv = { (char*)cvname, (char*)cvstr, cvflags, 0.0f, (void *)CVAR_SENTINEL, (char*)cvdesc, NULL }
|
2021-03-09 21:58:21 +01:00
|
|
|
|
|
|
|
#define CVAR_DEFINE_AUTO( cv, cvstr, cvflags, cvdesc ) \
|
|
|
|
CVAR_DEFINE( cv, #cv, cvstr, cvflags, cvdesc )
|
|
|
|
|
2018-04-13 18:23:45 +02:00
|
|
|
#define CVAR_TO_BOOL( x ) ((x) && ((x)->value != 0.0f) ? true : false )
|
|
|
|
|
2018-04-19 23:51:17 +02:00
|
|
|
cvar_t *Cvar_GetList( void );
|
2018-04-13 18:23:45 +02:00
|
|
|
#define Cvar_FindVar( name ) Cvar_FindVarExt( name, 0 )
|
|
|
|
convar_t *Cvar_FindVarExt( const char *var_name, int ignore_group );
|
|
|
|
void Cvar_RegisterVariable( convar_t *var );
|
|
|
|
convar_t *Cvar_Get( const char *var_name, const char *value, int flags, const char *description );
|
2023-01-27 04:49:03 +01:00
|
|
|
convar_t *Cvar_Getf( const char *var_name, int flags, const char *description, const char *format, ... ) _format( 4 );
|
2018-04-13 18:23:45 +02:00
|
|
|
void Cvar_LookupVars( int checkbit, void *buffer, void *ptr, setpair_t callback );
|
|
|
|
void Cvar_FullSet( const char *var_name, const char *value, int flags );
|
|
|
|
void Cvar_DirectSet( convar_t *var, const char *value );
|
|
|
|
void Cvar_Set( const char *var_name, const char *value );
|
|
|
|
void Cvar_SetValue( const char *var_name, float value );
|
2023-03-13 04:22:30 +01:00
|
|
|
const char *Cvar_BuildAutoDescription( const char *szName, int flags );
|
2018-04-13 18:23:45 +02:00
|
|
|
float Cvar_VariableValue( const char *var_name );
|
|
|
|
int Cvar_VariableInteger( const char *var_name );
|
2018-04-23 22:07:54 +02:00
|
|
|
const char *Cvar_VariableString( const char *var_name );
|
2018-04-13 18:23:45 +02:00
|
|
|
void Cvar_WriteVariables( file_t *f, int group );
|
2018-10-27 22:31:55 +02:00
|
|
|
qboolean Cvar_Exists( const char *var_name );
|
2018-04-13 18:23:45 +02:00
|
|
|
void Cvar_Reset( const char *var_name );
|
|
|
|
void Cvar_SetCheatState( void );
|
2021-11-01 18:20:59 +01:00
|
|
|
qboolean Cvar_CommandWithPrivilegeCheck( convar_t *v, qboolean isPrivileged );
|
2018-04-13 18:23:45 +02:00
|
|
|
void Cvar_Init( void );
|
2022-11-27 02:44:41 +01:00
|
|
|
void Cvar_PostFSInit( void );
|
2018-04-13 18:23:45 +02:00
|
|
|
void Cvar_Unlink( int group );
|
|
|
|
|
2018-04-19 23:51:17 +02:00
|
|
|
#endif//CVAR_H
|