about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/engine/shared/config.cpp12
-rw-r--r--src/engine/shared/config.h4
-rw-r--r--src/engine/shared/config_variables.h8
-rw-r--r--src/engine/shared/console.cpp14
4 files changed, 34 insertions, 4 deletions
diff --git a/src/engine/shared/config.cpp b/src/engine/shared/config.cpp
index d0cb7a6b..69a65a48 100644
--- a/src/engine/shared/config.cpp
+++ b/src/engine/shared/config.cpp
@@ -54,22 +54,30 @@ public:
 	{
 		#define MACRO_CONFIG_INT(Name,ScriptName,def,min,max,flags,desc) g_Config.m_##Name = def;
 		#define MACRO_CONFIG_STR(Name,ScriptName,len,def,flags,desc) str_copy(g_Config.m_##Name, def, len);
+		#define MACRO_CONFIG_INT_ACCESSLEVEL(Name,ScriptName,def,min,max,flags,desc,accessLevel) g_Config.m_##Name = def;
+		#define MACRO_CONFIG_STR_ACCESSLEVEL(Name,ScriptName,len,def,flags,desc,accessLevel) str_copy(g_Config.m_##Name, def, len);
 
 		#include "config_variables.h"
 
 		#undef MACRO_CONFIG_INT
 		#undef MACRO_CONFIG_STR
+		#undef MACRO_CONFIG_INT_ACCESSLEVEL
+		#undef MACRO_CONFIG_STR_ACCESSLEVEL
 	}
 
 	virtual void RestoreStrings()
 	{
 		#define MACRO_CONFIG_INT(Name,ScriptName,def,min,max,flags,desc)	// nop
 		#define MACRO_CONFIG_STR(Name,ScriptName,len,def,flags,desc) if(!g_Config.m_##Name[0] && def[0]) str_copy(g_Config.m_##Name, def, len);
+		#define MACRO_CONFIG_INT_ACCESSLEVEL(Name,ScriptName,def,min,max,flags,desc,accessLevel)	// nop
+		#define MACRO_CONFIG_STR_ACCESSLEVEL(Name,ScriptName,len,def,flags,desc,accessLevel) if(!g_Config.m_##Name[0] && def[0]) str_copy(g_Config.m_##Name, def, len);
 
 		#include "config_variables.h"
 
 		#undef MACRO_CONFIG_INT
 		#undef MACRO_CONFIG_STR
+		#undef MACRO_CONFIG_INT_ACCESSLEVEL
+		#undef MACRO_CONFIG_STR_ACCESSLEVEL
 	}
 
 	virtual void Save()
@@ -86,11 +94,15 @@ public:
 
 		#define MACRO_CONFIG_INT(Name,ScriptName,def,min,max,flags,desc) if((flags)&CFGFLAG_SAVE){ str_format(aLineBuf, sizeof(aLineBuf), "%s %i", #ScriptName, g_Config.m_##Name); WriteLine(aLineBuf); }
 		#define MACRO_CONFIG_STR(Name,ScriptName,len,def,flags,desc) if((flags)&CFGFLAG_SAVE){ EscapeParam(aEscapeBuf, g_Config.m_##Name, sizeof(aEscapeBuf)); str_format(aLineBuf, sizeof(aLineBuf), "%s \"%s\"", #ScriptName, aEscapeBuf); WriteLine(aLineBuf); }
+		#define MACRO_CONFIG_INT_ACCESSLEVEL(Name,ScriptName,def,min,max,flags,desc,accessLevel) if((flags)&CFGFLAG_SAVE){ str_format(aLineBuf, sizeof(aLineBuf), "%s %i", #ScriptName, g_Config.m_##Name); WriteLine(aLineBuf); }
+		#define MACRO_CONFIG_STR_ACCESSLEVEL(Name,ScriptName,len,def,flags,desc,accessLevel) if((flags)&CFGFLAG_SAVE){ EscapeParam(aEscapeBuf, g_Config.m_##Name, sizeof(aEscapeBuf)); str_format(aLineBuf, sizeof(aLineBuf), "%s \"%s\"", #ScriptName, aEscapeBuf); WriteLine(aLineBuf); }
 
 		#include "config_variables.h"
 
 		#undef MACRO_CONFIG_INT
 		#undef MACRO_CONFIG_STR
+		#undef MACRO_CONFIG_INT_ACCESSLEVEL
+		#undef MACRO_CONFIG_STR_ACCESSLEVEL
 
 		for(int i = 0; i < m_NumCallbacks; i++)
 			m_aCallbacks[i].m_pfnFunc(this, m_aCallbacks[i].m_pUserData);
diff --git a/src/engine/shared/config.h b/src/engine/shared/config.h
index 4200303e..2ca40e4b 100644
--- a/src/engine/shared/config.h
+++ b/src/engine/shared/config.h
@@ -7,9 +7,13 @@ struct CConfiguration
 {
 	#define MACRO_CONFIG_INT(Name,ScriptName,Def,Min,Max,Save,Desc) int m_##Name;
 	#define MACRO_CONFIG_STR(Name,ScriptName,Len,Def,Save,Desc) char m_##Name[Len]; // Flawfinder: ignore
+	#define MACRO_CONFIG_INT_ACCESSLEVEL(Name,ScriptName,Def,Min,Max,Save,Desc,accessLevel) int m_##Name;
+	#define MACRO_CONFIG_STR_ACCESSLEVEL(Name,ScriptName,Len,Def,Save,Desc,accessLevel) char m_##Name[Len]; // Flawfinder: ignore
 	#include "config_variables.h"
 	#undef MACRO_CONFIG_INT
 	#undef MACRO_CONFIG_STR
+	#undef MACRO_CONFIG_INT_ACCESSLEVEL
+	#undef MACRO_CONFIG_STR_ACCESSLEVEL
 };
 
 extern CConfiguration g_Config;
diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h
index 2a43f6d0..0d3b197c 100644
--- a/src/engine/shared/config_variables.h
+++ b/src/engine/shared/config_variables.h
@@ -89,10 +89,10 @@ MACRO_CONFIG_INT(SvMaxClients, sv_max_clients, 8, 1, MAX_CLIENTS, CFGFLAG_SERVER
 MACRO_CONFIG_INT(SvMaxClientsPerIP, sv_max_clients_per_ip, 4, 1, MAX_CLIENTS, CFGFLAG_SERVER, "Maximum number of clients with the same IP that can connect to the server")
 MACRO_CONFIG_INT(SvHighBandwidth, sv_high_bandwidth, 0, 0, 1, CFGFLAG_SERVER, "Use high bandwidth mode. Doubles the bandwidth required for the server. LAN use only")
 MACRO_CONFIG_INT(SvRegister, sv_register, 1, 0, 1, CFGFLAG_SERVER, "Register server with master server for public listing")
-MACRO_CONFIG_STR(SvRconPassword, sv_rcon_password, 32, "", CFGFLAG_SERVER, "Remote console password (full access)")
-MACRO_CONFIG_STR(SvRconModPassword, sv_rcon_mod_password, 32, "", CFGFLAG_SERVER, "Remote console password for moderators (limited access)")
-MACRO_CONFIG_INT(SvRconMaxTries, sv_rcon_max_tries, 3, 0, 100, CFGFLAG_SERVER, "Maximum number of tries for remote console authentication")
-MACRO_CONFIG_INT(SvRconBantime, sv_rcon_bantime, 5, 0, 1440, CFGFLAG_SERVER, "The time a client gets banned if remote console authentication fails. 0 makes it just use kick")
+MACRO_CONFIG_STR_ACCESSLEVEL(SvRconPassword, sv_rcon_password, 32, "", CFGFLAG_SERVER, "Remote console password (full access)", IConsole::ACCESS_LEVEL_ADMIN)
+MACRO_CONFIG_STR_ACCESSLEVEL(SvRconModPassword, sv_rcon_mod_password, 32, "", CFGFLAG_SERVER, "Remote console password for moderators (limited access)", IConsole::ACCESS_LEVEL_ADMIN)
+MACRO_CONFIG_INT_ACCESSLEVEL(SvRconMaxTries, sv_rcon_max_tries, 3, 0, 100, CFGFLAG_SERVER, "Maximum number of tries for remote console authentication", IConsole::ACCESS_LEVEL_ADMIN)
+MACRO_CONFIG_INT_ACCESSLEVEL(SvRconBantime, sv_rcon_bantime, 5, 0, 1440, CFGFLAG_SERVER, "The time a client gets banned if remote console authentication fails. 0 makes it just use kick", IConsole::ACCESS_LEVEL_ADMIN)
 MACRO_CONFIG_INT(SvAutoDemoRecord, sv_auto_demo_record, 0, 0, 1, CFGFLAG_SERVER, "Automatically record demos")
 MACRO_CONFIG_INT(SvAutoDemoMax, sv_auto_demo_max, 10, 0, 1000, CFGFLAG_SERVER, "Maximum number of automatically recorded demos (0 = no limit)")
 
diff --git a/src/engine/shared/console.cpp b/src/engine/shared/console.cpp
index dcace5b8..a0d786ae 100644
--- a/src/engine/shared/console.cpp
+++ b/src/engine/shared/console.cpp
@@ -683,10 +683,24 @@ CConsole::CConsole(int FlagMask)
 		Register(#ScriptName, "?r", Flags, StrVariableCommand, &Data, Desc); \
 	}
 
+	#define MACRO_CONFIG_INT_ACCESSLEVEL(Name,ScriptName,Def,Min,Max,Flags,Desc,accessLevel) \
+	{ \
+		static CIntVariableData Data = { this, &g_Config.m_##Name, Min, Max }; \
+		Register(#ScriptName, "?i", Flags, IntVariableCommand, &Data, Desc, ACCESS_LEVEL_ADMIN); \
+	}
+
+	#define MACRO_CONFIG_STR_ACCESSLEVEL(Name,ScriptName,Len,Def,Flags,Desc,accessLevel) \
+	{ \
+		static CStrVariableData Data = { this, g_Config.m_##Name, Len }; \
+		Register(#ScriptName, "?r", Flags, StrVariableCommand, &Data, Desc, ACCESS_LEVEL_ADMIN); \
+	}
+
 	#include "config_variables.h"
 
 	#undef MACRO_CONFIG_INT
 	#undef MACRO_CONFIG_STR
+	#undef MACRO_CONFIG_INT_ACCESSLEVEL
+	#undef MACRO_CONFIG_STR_ACCESSLEVEL
 }
 
 void CConsole::ParseArguments(int NumArgs, const char **ppArguments)