Permalink
Browse files

Replace TTT_Has*Flags with TTT_CheckCommandAccess (#340)

* Mark TTT_HasCVarFlags and TTT_HasFlags as deprecated

* Replace TTT_HasFlags with TTT_CheckCommandAccess
  • Loading branch information...
Bara committed Jun 5, 2018
1 parent 09b75c4 commit 688342c85bafa98f8787c0ca0a0b7e408817a936
View
1 PUSH
@@ -4,3 +4,4 @@ Discord test.
Translations updated
Update Camera and Drones
New VPS
Travis updated
@@ -523,6 +523,7 @@ stock void TTT_IsGameCSGO()
}
}
#pragma deprecated TTT_HasCVarFlags is "unsafe". Please use TTT_CheckCommandAccess
stock bool TTT_HasCVarFlags(int client, ConVar cFlags)
{
char flags[24];
@@ -534,6 +535,7 @@ stock bool TTT_HasCVarFlags(int client, ConVar cFlags)
return tHasFlags(client, aFlags);
}
#pragma deprecated TTT_HasFlags is "unsafe". Please use TTT_CheckCommandAccess
stock bool TTT_HasFlags(int client, const char[] flags)
{
AdminFlag aFlags[24];
@@ -157,16 +157,6 @@ public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] n
g_cpluginTag.GetString(g_sTag, sizeof(g_sTag));
}
if (convar == g_ckickImmunity)
{
g_ckickImmunity.GetString(g_sKickImmunity, sizeof(g_sKickImmunity));
}
if (convar == g_clogsAccess)
{
g_clogsAccess.GetString(g_sLogAccess, sizeof(g_sLogAccess));
}
if (convar == g_cdefaultPriD)
{
g_cdefaultPriD.GetString(g_sDefaultPrimary, sizeof(g_sDefaultPrimary));
@@ -197,19 +187,4 @@ public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] n
g_cFSSecondary.GetString(g_sFSSecondary, sizeof(g_sFSSecondary));
}
if (convar == g_cSetRole)
{
g_cSetRole.GetString(g_sSetRole, sizeof(g_sSetRole));
}
if (convar == g_cKarmaReset)
{
g_cKarmaReset.GetString(g_sKarmaReset, sizeof(g_sKarmaReset));
}
if (convar == g_cSetKarma)
{
g_cSetKarma.GetString(g_sSetKarma, sizeof(g_sSetKarma));
}
}
@@ -9,17 +9,12 @@ char g_sRulesFile[PLATFORM_MAX_PATH + 1];
char g_sErrorFile[PLATFORM_MAX_PATH + 1];
char g_sLogFile[PLATFORM_MAX_PATH + 1];
char g_sTag[64];
char g_sKickImmunity[18];
char g_sLogAccess[18];
char g_sDefaultPrimary[32];
char g_sDefaultSecondary[32];
char g_sRoundStartedFontColor[12];
char g_sRoundStartFontColor[12];
char g_sFSSecondary[32];
char g_sFSPrimary[32];
char g_sSetRole[18];
char g_sKarmaReset[18];
char g_sSetKarma[18];
bool g_bRoundEnded = false;
@@ -157,17 +157,12 @@ public void OnConfigsExecuted()
{
// Save configs in strings
g_cpluginTag.GetString(g_sTag, sizeof(g_sTag));
g_ckickImmunity.GetString(g_sKickImmunity, sizeof(g_sKickImmunity));
g_clogsAccess.GetString(g_sLogAccess, sizeof(g_sLogAccess));
g_cdefaultPriD.GetString(g_sDefaultPrimary, sizeof(g_sDefaultPrimary));
g_cdefaultSec.GetString(g_sDefaultSecondary, sizeof(g_sDefaultSecondary));
g_cRoundStartedFontColor.GetString(g_sRoundStartedFontColor, sizeof(g_sRoundStartedFontColor));
g_cRoundStartFontColor.GetString(g_sRoundStartFontColor, sizeof(g_sRoundStartFontColor));
g_cFSPrimary.GetString(g_sFSPrimary, sizeof(g_sFSPrimary));
g_cFSSecondary.GetString(g_sFSSecondary, sizeof(g_sFSSecondary));
g_cSetRole.GetString(g_sSetRole, sizeof(g_sSetRole));
g_cKarmaReset.GetString(g_sKarmaReset, sizeof(g_sKarmaReset));
g_cSetKarma.GetString(g_sSetKarma, sizeof(g_sSetKarma));
// Prepare & Format log files
char sDate[12];
@@ -223,7 +218,7 @@ public Action Command_Logs(int client, int args)
{
ShowLogs(client);
}
else if (TTT_IsClientValid(client) && TTT_HasFlags(client, g_sLogAccess))
else if (TTT_IsClientValid(client) && TTT_CheckCommandAccess(client, "ttt_log_access", g_clogsAccess, true))
{
if (g_cLogsDeadOnly.BoolValue)
{
@@ -249,7 +244,7 @@ public Action Command_Logs(int client, int args)
{
LoopValidClients(j)
{
if (TTT_HasFlags(j, g_sLogAccess))
if (TTT_CheckCommandAccess(j, "ttt_log_access", g_clogsAccess, true))
{
CPrintToChat(j, "%s %T", g_sTag, "watching logs alive", j, client);
}
@@ -2079,7 +2074,7 @@ public Action Command_RSlays(int client, int args)
return Plugin_Handled;
}
if (!TTT_CheckCommandAccess(client, "sm_rslays", g_cRoundSlayAccess))
if (!TTT_CheckCommandAccess(client, "sm_rslays", g_cRoundSlayAccess, true))
{
return Plugin_Handled;
}
@@ -2392,7 +2387,7 @@ public int Menu_ShowWelcomeMenu(Menu menu, MenuAction action, int client, int pa
{
if (TTT_IsClientValid(client) && g_crulesClosePunishment.IntValue == 0)
{
if (!TTT_HasFlags(client, g_sKickImmunity))
if (!TTT_CheckCommandAccess(client, "ttt_kick_immunity", g_ckickImmunity, true))
{
char sMessage[128];
Format(sMessage, sizeof(sMessage), "%T", "WM Kick Message", client);
@@ -3710,7 +3705,7 @@ public Action Command_SetRole(int client, int args)
return Plugin_Handled;
}
if (!TTT_HasFlags(client, g_sSetRole))
if (!TTT_CheckCommandAccess(client, "ttt_set_role", g_cSetRole, true))
{
return Plugin_Handled;
}
@@ -3805,7 +3800,7 @@ public Action Command_SetKarma(int client, int args)
return Plugin_Handled;
}
if (!TTT_HasFlags(client, g_sSetKarma))
if (!TTT_CheckCommandAccess(client, "ttt_set_karma", g_cSetKarma, true))
{
return Plugin_Handled;
}
@@ -4066,7 +4061,7 @@ public Action Command_KarmaReset(int client, int args)
return Plugin_Handled;
}
if (!TTT_HasFlags(client, g_sKarmaReset))
if (!TTT_CheckCommandAccess(client, "ttt_karma_reset", g_cKarmaReset, true))
{
return Plugin_Handled;
}
@@ -163,10 +163,7 @@ stock void GrabSomething(int client)
if (g_cShowNames.BoolValue)
{
char sAccess[16];
g_cFlags.GetString(sAccess, sizeof(sAccess));
if (TTT_HasFlags(client, sAccess))
if (TTT_CheckCommandAccess(client, "gbm_output", g_cFlags, true))
{
CPrintToChat(client, "Name of Entity: %s", sName);
}
@@ -16,8 +16,6 @@ ConVar g_cSeeRoles = null;
ConVar g_cTraitorIcon = null;
ConVar g_cDetectiveIcon = null;
char g_sAdminImmunity[18];
public Plugin myinfo =
{
name = PLUGIN_NAME,
@@ -48,9 +46,6 @@ public void OnPluginStart()
g_cAdminImmunity = AutoExecConfig_CreateConVar("ttt_icon_dead_admin", "b", "Show traitor icon for dead admins? (Nothing to disable it)");
TTT_EndConfig();
g_cAdminImmunity.AddChangeHook(OnConVarChanged);
g_cAdminImmunity.GetString(g_sAdminImmunity, sizeof(g_sAdminImmunity));
HookEvent("player_death", Event_PlayerDeathPre, EventHookMode_Pre);
HookEvent("player_team", Event_PlayerTeamPre, EventHookMode_Pre);
@@ -65,14 +60,6 @@ public void OnPluginEnd()
}
}
public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue)
{
if (convar == g_cAdminImmunity)
{
g_cAdminImmunity.GetString(g_sAdminImmunity, sizeof(g_sAdminImmunity));
}
}
public void OnConfigsExecuted()
{
char sBuffer[PLATFORM_MAX_PATH];
@@ -223,12 +210,9 @@ public Action Hook_SetTransmitT(int entity, int client)
}
else
{
if (strlen(g_sAdminImmunity) > 0)
if (TTT_CheckCommandAccess(client, "icon_immunity", g_cAdminImmunity, true))
{
if (TTT_HasFlags(client, g_sAdminImmunity))
{
return Plugin_Continue;
}
return Plugin_Continue;
}
}
}
@@ -61,10 +61,7 @@ public Action Command_ReloadRadio(int client, int args)
return Plugin_Handled;
}
char sAccess[18];
g_cReloadAccess.GetString(sAccess, sizeof(sAccess));
if (!TTT_HasFlags(client, sAccess))
if (!TTT_CheckCommandAccess(client, "sm_reload_radio", g_cReloadAccess, true))
{
return Plugin_Handled;
}
@@ -536,10 +536,8 @@ public Action Command_Shop(int client, int args)
if (cDEnable != null && temp_item[Discount])
{
ConVar g_cFlags = FindConVar("shop_discount_flags");
char sAccess[18];
g_cFlags.GetString(sAccess, sizeof(sAccess));
if (TTT_HasFlags(client, sAccess))
if (TTT_CheckCommandAccess(client, "ttt_purchaseitem", g_cFlags, true))
{
ConVar cDPercents = FindConVar("shop_discount_percents");
iPercents = cDPercents.IntValue;
@@ -42,10 +42,7 @@ public Action TTT_OnItemPurchase(int client, int &price, bool &count, const char
return Plugin_Continue;
}
char sAccess[18];
g_cFlags.GetString(sAccess, sizeof(sAccess));
if (TTT_IsClientValid(client) && TTT_HasFlags(client, sAccess) && IsPlayerAlive(client))
if (TTT_IsClientValid(client) && TTT_CheckCommandAccess(client, "ttt_purchaseitem", g_cFlags, true) && IsPlayerAlive(client))
{
float fPercents = 1.0 + g_cPercents.FloatValue / 100;
int newPrice = RoundToCeil(price / fPercents);

0 comments on commit 688342c

Please sign in to comment.