From 0e0d7ec9d5b11d12c1cdad57738d43db2f7ab022 Mon Sep 17 00:00:00 2001 From: xPaw Date: Tue, 29 Jul 2014 00:33:08 +0300 Subject: [PATCH] Instead of assigning FCVAR_PROTECTED to cvars after startup, register cvars with said flag --- plugins/admin.sma | 20 ++++++++++---------- plugins/adminchat.sma | 2 +- plugins/admincmd.sma | 32 +++++++++----------------------- plugins/adminslots.sma | 2 +- plugins/adminvote.sma | 2 ++ plugins/include/amxmisc.inc | 6 +++--- plugins/plmenu.sma | 2 +- 7 files changed, 27 insertions(+), 39 deletions(-) diff --git a/plugins/admin.sma b/plugins/admin.sma index 706c72b8..3a10b80a 100755 --- a/plugins/admin.sma +++ b/plugins/admin.sma @@ -69,16 +69,16 @@ public plugin_init() #endif register_dictionary("admin.txt") register_dictionary("common.txt") - amx_mode=register_cvar("amx_mode", "1") - amx_password_field=register_cvar("amx_password_field", "_pw") - amx_default_access=register_cvar("amx_default_access", "") + amx_mode=register_cvar("amx_mode", "1", FCVAR_PROTECTED) + amx_password_field=register_cvar("amx_password_field", "_pw", FCVAR_PROTECTED) + amx_default_access=register_cvar("amx_default_access", "", FCVAR_PROTECTED) register_cvar("amx_vote_ratio", "0.02") register_cvar("amx_vote_time", "10") register_cvar("amx_vote_answers", "1") register_cvar("amx_vote_delay", "60") register_cvar("amx_last_voting", "0") - register_cvar("amx_show_activity", "2") + register_cvar("amx_show_activity", "2", FCVAR_PROTECTED) register_cvar("amx_votekick_ratio", "0.40") register_cvar("amx_voteban_ratio", "0.40") register_cvar("amx_votemap_ratio", "0.40") @@ -87,13 +87,13 @@ public plugin_init() #if defined USING_SQL register_srvcmd("amx_sqladmins", "adminSql") - register_cvar("amx_sql_table", "admins") + register_cvar("amx_sql_table", "admins", FCVAR_PROTECTED) #endif - register_cvar("amx_sql_host", "127.0.0.1") - register_cvar("amx_sql_user", "root") - register_cvar("amx_sql_pass", "") - register_cvar("amx_sql_db", "amx") - register_cvar("amx_sql_type", "mysql") + register_cvar("amx_sql_host", "127.0.0.1", FCVAR_PROTECTED) + register_cvar("amx_sql_user", "root", FCVAR_PROTECTED) + register_cvar("amx_sql_pass", "", FCVAR_PROTECTED) + register_cvar("amx_sql_db", "amx", FCVAR_PROTECTED) + register_cvar("amx_sql_type", "mysql", FCVAR_PROTECTED) register_concmd("amx_reloadadmins", "cmdReload", ADMIN_CFG) register_concmd("amx_addadmin", "addadminfn", ADMIN_RCON, " [password] [authtype] - add specified player as an admin to users.ini") diff --git a/plugins/adminchat.sma b/plugins/adminchat.sma index ceb7335e..14198996 100755 --- a/plugins/adminchat.sma +++ b/plugins/adminchat.sma @@ -70,7 +70,7 @@ public plugin_init() if (amx_show_activity == 0) { - amx_show_activity = register_cvar("amx_show_activity", "2"); + amx_show_activity = register_cvar("amx_show_activity", "2", FCVAR_PROTECTED); } new str[1] diff --git a/plugins/admincmd.sma b/plugins/admincmd.sma index 52c16596..3d1e5859 100755 --- a/plugins/admincmd.sma +++ b/plugins/admincmd.sma @@ -42,7 +42,6 @@ new g_pauseCon new Float:g_pausAble new bool:g_Paused new bool:g_PauseAllowed = false -new g_addCvar[] = "amx_cvar add %s" new pausable; new rcon_password; @@ -162,8 +161,7 @@ public plugin_init() register_dictionary("admincmd.txt") register_dictionary("common.txt") register_dictionary("adminhelp.txt") - - + register_concmd("amx_kick", "cmdKick", ADMIN_KICK, " [reason]") register_concmd("amx_ban", "cmdBan", ADMIN_BAN|ADMIN_BAN_TEMP, " [reason]") register_concmd("amx_banip", "cmdBanIP", ADMIN_BAN|ADMIN_BAN_TEMP, " [reason]") @@ -188,33 +186,19 @@ public plugin_init() register_clcmd("amx_showrcon", "cmdShowRcon", ADMIN_RCON, "") register_clcmd("pauseAck", "cmdLBack") - rcon_password=get_cvar_pointer("rcon_password"); pausable=get_cvar_pointer("pausable"); timelimit=get_cvar_pointer( "mp_timelimit" ); - p_amx_tempban_maxtime = register_cvar("amx_tempban_maxtime", "4320"); + p_amx_tempban_maxtime = register_cvar("amx_tempban_maxtime", "4320", FCVAR_PROTECTED); g_tempBans = TrieCreate(); -} -public plugin_cfg() -{ - // Cvars which can be changed only with rcon access - server_cmd(g_addCvar, "rcon_password") - server_cmd(g_addCvar, "amx_show_activity") - server_cmd(g_addCvar, "amx_mode") - server_cmd(g_addCvar, "amx_password_field") - server_cmd(g_addCvar, "amx_default_access") - server_cmd(g_addCvar, "amx_reserved_slots") - server_cmd(g_addCvar, "amx_reservation") - server_cmd(g_addCvar, "amx_sql_table"); - server_cmd(g_addCvar, "amx_sql_host"); - server_cmd(g_addCvar, "amx_sql_user"); - server_cmd(g_addCvar, "amx_sql_pass"); - server_cmd(g_addCvar, "amx_sql_db"); - server_cmd(g_addCvar, "amx_sql_type"); - server_cmd(g_addCvar, "amx_tempban_maxtime"); + new flags = get_pcvar_flags(rcon_password); + if (!(flags & FCVAR_PROTECTED)) + { + set_pcvar_flags(rcon_password, flags | FCVAR_PROTECTED); + } } public cmdKick(id, level, cid) @@ -774,6 +758,8 @@ public cmdCvar(id, level, cid) return PLUGIN_HANDLED } + trim(arg); + if ((pointer=get_cvar_pointer(arg))==0) { console_print(id, "[AMXX] %L", id, "UNKNOWN_CVAR", arg) diff --git a/plugins/adminslots.sma b/plugins/adminslots.sma index 65190c8a..83ce5f27 100755 --- a/plugins/adminslots.sma +++ b/plugins/adminslots.sma @@ -44,7 +44,7 @@ public plugin_init() register_plugin("Slots Reservation", AMXX_VERSION_STR, "AMXX Dev Team") register_dictionary("adminslots.txt") register_dictionary("common.txt") - g_ResPtr = register_cvar("amx_reservation", "0") + g_ResPtr = register_cvar("amx_reservation", "0", FCVAR_PROTECTED) g_HidePtr = register_cvar("amx_hideslots", "0") g_sv_visiblemaxplayers = get_cvar_pointer("sv_visiblemaxplayers") } diff --git a/plugins/adminvote.sma b/plugins/adminvote.sma index bc9b6495..4b0069ab 100755 --- a/plugins/adminvote.sma +++ b/plugins/adminvote.sma @@ -362,6 +362,8 @@ public cmdVote(id, level, cid) new quest[48] read_argv(1, quest, 47) + trim(quest); + if (contain(quest, "sv_password") != -1 || contain(quest, "rcon_password") != -1) { console_print(id, "%L", id, "VOTING_FORBIDDEN") diff --git a/plugins/include/amxmisc.inc b/plugins/include/amxmisc.inc index c2b7f712..e57c9188 100755 --- a/plugins/include/amxmisc.inc +++ b/plugins/include/amxmisc.inc @@ -158,7 +158,7 @@ stock show_activity( id, const name[], const fmt[], any:... ) // if still not found, then register the cvar as a dummy if (__amx_show_activity == 0) { - __amx_show_activity = register_cvar("amx_show_activity", "2"); + __amx_show_activity = register_cvar("amx_show_activity", "2", FCVAR_PROTECTED); } } @@ -256,7 +256,7 @@ stock show_activity_id(idtarget, idadmin, const name[], const fmt[], any:...) // if still not found, then register the cvar as a dummy if (__amx_show_activity == 0) { - __amx_show_activity = register_cvar("amx_show_activity", "2"); + __amx_show_activity = register_cvar("amx_show_activity", "2", FCVAR_PROTECTED); } } @@ -335,7 +335,7 @@ stock show_activity_key(const KeyWithoutName[], const KeyWithName[], const ___Ad // if still not found, then register the cvar as a dummy if (__amx_show_activity == 0) { - __amx_show_activity = register_cvar("amx_show_activity", "2"); + __amx_show_activity = register_cvar("amx_show_activity", "2", FCVAR_PROTECTED); } } diff --git a/plugins/plmenu.sma b/plugins/plmenu.sma index 8eb4673c..0839b663 100755 --- a/plugins/plmenu.sma +++ b/plugins/plmenu.sma @@ -175,7 +175,7 @@ public plugin_cfg() p_amx_tempban_maxtime = get_cvar_pointer(amx_tempban_maxtime); if( !p_amx_tempban_maxtime ) { - p_amx_tempban_maxtime = register_cvar(amx_tempban_maxtime, "4320"); + p_amx_tempban_maxtime = register_cvar(amx_tempban_maxtime, "4320", FCVAR_PROTECTED); server_cmd("amx_cvar add %s", amx_tempban_maxtime); } }