Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
5.9 KiB

  1. //===== Copyright (c) 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. //
  8. //-----------------------------------------------------------------------------
  9. // $NoKeywords: $
  10. //===========================================================================//
  11. #ifndef ICONVAR_H
  12. #define ICONVAR_H
  13. #if _WIN32
  14. #pragma once
  15. #endif
  16. #include "tier0/dbg.h"
  17. #include "tier0/platform.h"
  18. #include "tier1/strtools.h"
  19. #include "color.h"
  20. //-----------------------------------------------------------------------------
  21. // Forward declarations
  22. //-----------------------------------------------------------------------------
  23. class IConVar;
  24. class CCommand;
  25. //-----------------------------------------------------------------------------
  26. // ConVar flags
  27. //-----------------------------------------------------------------------------
  28. // The default, no flags at all
  29. #define FCVAR_NONE 0
  30. // Command to ConVars and ConCommands
  31. // ConVar Systems
  32. #define FCVAR_UNREGISTERED (1<<0) // If this is set, don't add to linked list, etc.
  33. #define FCVAR_DEVELOPMENTONLY (1<<1) // Hidden in released products. Flag is removed automatically if ALLOW_DEVELOPMENT_CVARS is defined.
  34. #define FCVAR_GAMEDLL (1<<2) // defined by the game DLL
  35. #define FCVAR_CLIENTDLL (1<<3) // defined by the client DLL
  36. #define FCVAR_HIDDEN (1<<4) // Hidden. Doesn't appear in find or auto complete. Like DEVELOPMENTONLY, but can't be compiled out.
  37. // ConVar only
  38. #define FCVAR_PROTECTED (1<<5) // It's a server cvar, but we don't send the data since it's a password, etc. Sends 1 if it's not bland/zero, 0 otherwise as value
  39. #define FCVAR_SPONLY (1<<6) // This cvar cannot be changed by clients connected to a multiplayer server.
  40. #define FCVAR_ARCHIVE (1<<7) // set to cause it to be saved to vars.rc
  41. #define FCVAR_NOTIFY (1<<8) // notifies players when changed
  42. #define FCVAR_USERINFO (1<<9) // changes the client's info string
  43. #define FCVAR_PRINTABLEONLY (1<<10) // This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ).
  44. #define FCVAR_UNLOGGED (1<<11) // If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log
  45. #define FCVAR_NEVER_AS_STRING (1<<12) // never try to print that cvar
  46. // It's a ConVar that's shared between the client and the server.
  47. // At signon, the values of all such ConVars are sent from the server to the client (skipped for local
  48. // client, of course )
  49. // If a change is requested it must come from the console (i.e., no remote client changes)
  50. // If a value is changed while a server is active, it's replicated to all connected clients
  51. #define FCVAR_REPLICATED (1<<13) // server setting enforced on clients, TODO rename to FCAR_SERVER at some time
  52. #define FCVAR_CHEAT (1<<14) // Only useable in singleplayer / debug / multiplayer & sv_cheats
  53. #define FCVAR_SS (1<<15) // causes varnameN where N == 2 through max splitscreen slots for mod to be autogenerated
  54. #define FCVAR_DEMO (1<<16) // record this cvar when starting a demo file
  55. #define FCVAR_DONTRECORD (1<<17) // don't record these command in demofiles
  56. #define FCVAR_SS_ADDED (1<<18) // This is one of the "added" FCVAR_SS variables for the splitscreen players
  57. #define FCVAR_RELEASE (1<<19) // Cvars tagged with this are the only cvars avaliable to customers
  58. #define FCVAR_RELOAD_MATERIALS (1<<20) // If this cvar changes, it forces a material reload
  59. #define FCVAR_RELOAD_TEXTURES (1<<21) // If this cvar changes, if forces a texture reload
  60. #define FCVAR_NOT_CONNECTED (1<<22) // cvar cannot be changed by a client that is connected to a server
  61. #define FCVAR_MATERIAL_SYSTEM_THREAD (1<<23) // Indicates this cvar is read from the material system thread
  62. #define FCVAR_ARCHIVE_GAMECONSOLE (1<<24) // cvar written to config.cfg on the Xbox
  63. #define FCVAR_SERVER_CAN_EXECUTE (1<<28)// the server is allowed to execute this command on clients via ClientCommand/NET_StringCmd/CBaseClientState::ProcessStringCmd.
  64. #define FCVAR_SERVER_CANNOT_QUERY (1<<29)// If this is set, then the server is not allowed to query this cvar's value (via IServerPluginHelpers::StartQueryCvarValue).
  65. #define FCVAR_CLIENTCMD_CAN_EXECUTE (1<<30) // IVEngineClient::ClientCmd is allowed to execute this command.
  66. // Note: IVEngineClient::ClientCmd_Unrestricted can run any client command.
  67. #define FCVAR_ACCESSIBLE_FROM_THREADS (1<<25) // used as a debugging tool necessary to check material system thread convars
  68. // #define FCVAR_AVAILABLE (1<<26)
  69. // #define FCVAR_AVAILABLE (1<<27)
  70. // #define FCVAR_AVAILABLE (1<<31)
  71. #define FCVAR_MATERIAL_THREAD_MASK ( FCVAR_RELOAD_MATERIALS | FCVAR_RELOAD_TEXTURES | FCVAR_MATERIAL_SYSTEM_THREAD )
  72. //-----------------------------------------------------------------------------
  73. // Called when a ConVar changes value
  74. // NOTE: For FCVAR_NEVER_AS_STRING ConVars, pOldValue == NULL
  75. //-----------------------------------------------------------------------------
  76. typedef void ( *FnChangeCallback_t )( IConVar *var, const char *pOldValue, float flOldValue );
  77. //-----------------------------------------------------------------------------
  78. // Abstract interface for ConVars
  79. //-----------------------------------------------------------------------------
  80. abstract_class IConVar
  81. {
  82. public:
  83. // Value set
  84. virtual void SetValue( const char *pValue ) = 0;
  85. virtual void SetValue( float flValue ) = 0;
  86. virtual void SetValue( int nValue ) = 0;
  87. virtual void SetValue( Color value ) = 0;
  88. // Return name of command
  89. virtual const char *GetName( void ) const = 0;
  90. // Return name of command (usually == GetName(), except in case of FCVAR_SS_ADDED vars
  91. virtual const char *GetBaseName( void ) const = 0;
  92. // Accessors.. not as efficient as using GetState()/GetInfo()
  93. // if you call these methods multiple times on the same IConVar
  94. virtual bool IsFlagSet( int nFlag ) const = 0;
  95. virtual int GetSplitScreenPlayerSlot() const = 0;
  96. };
  97. #endif // ICONVAR_H