Skip to content

Commit

Permalink
Replace IntValues with BoolValues where appropriate.
Browse files Browse the repository at this point in the history
  • Loading branch information
splewis committed Sep 2, 2018
1 parent d45a0ec commit 72a26c4
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 33 deletions.
23 changes: 12 additions & 11 deletions scripting/get5.sp
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,9 @@ public void OnPluginStart() {
"If set to 0, get5 will not force players to the correct team based on steamid");
g_DemoNameFormatCvar = CreateConVar("get5_demo_name_format", "{MATCHID}_map{MAPNUMBER}_{MAPNAME}",
"Format for demo file names, use \"\" to disable");
g_DisplayGotvVeto = CreateConVar("get5_display_gotv_veto", "0",
"Whether to wait for map vetos to be printed to GOTV before changing map");
g_DisplayGotvVeto =
CreateConVar("get5_display_gotv_veto", "0",
"Whether to wait for map vetos to be printed to GOTV before changing map");
g_EndMatchOnEmptyServerCvar = CreateConVar(
"get5_end_match_on_empty_server", "0",
"Whether to end the match if all players disconnect before ending. No winner is set if this happens.");
Expand Down Expand Up @@ -523,20 +524,20 @@ public void OnClientAuthorized(int client, const char[] auth) {
return;
}

if (g_GameState == Get5State_None && g_KickClientsWithNoMatchCvar.IntValue != 0) {
if (g_KickClientImmunity.IntValue == 0 ||
if (g_GameState == Get5State_None && g_KickClientsWithNoMatchCvar.BoolValue) {
if (!g_KickClientImmunity.BoolValue ||
!CheckCommandAccess(client, "get5_kickcheck", ADMFLAG_CHANGEMAP)) {
KickClient(client, "%t", "NoMatchSetupInfoMessage");
}
}

if (g_GameState != Get5State_None && g_CheckAuthsCvar.IntValue != 0) {
if (g_GameState != Get5State_None && g_CheckAuthsCvar.BoolValue) {
MatchTeam team = GetClientMatchTeam(client);
if (team == MatchTeam_TeamNone) {
KickClient(client, "%t", "YourAreNotAPlayerInfoMessage");
} else {
int teamCount = CountPlayersOnMatchTeam(team, client);
if (teamCount >= g_PlayersPerTeam && g_CoachingEnabledCvar.IntValue == 0) {
if (teamCount >= g_PlayersPerTeam && !g_CoachingEnabledCvar.BoolValue) {
KickClient(client, "%t", "TeamIsFullInfoMessage");
}
}
Expand Down Expand Up @@ -830,7 +831,7 @@ public Action Command_DumpStats(int client, int args) {
}

public Action Command_Stop(int client, int args) {
if (g_StopCommandEnabledCvar.IntValue == 0) {
if (!g_StopCommandEnabledCvar.BoolValue) {
return Plugin_Handled;
}

Expand Down Expand Up @@ -1014,10 +1015,10 @@ public Action Timer_NextMatchMap(Handle timer) {
}

public void KickClientsOnEnd() {
if (g_KickClientsWithNoMatchCvar.IntValue != 0) {
if (g_KickClientsWithNoMatchCvar.BoolValue) {
for (int i = 1; i <= MaxClients; i++) {
if (IsPlayer(i) &&
!(g_KickClientImmunity.IntValue != 0 &&
!(g_KickClientImmunity.BoolValue &&
CheckCommandAccess(i, "get5_kickcheck", ADMFLAG_CHANGEMAP))) {
KickClient(i, "%t", "MatchFinishedInfoMessage");
}
Expand Down Expand Up @@ -1082,7 +1083,7 @@ public Action Event_FreezeEnd(Event event, const char[] name, bool dontBroadcast
}

public void WriteBackup() {
if (g_BackupSystemEnabledCvar.IntValue == 0) {
if (!g_BackupSystemEnabledCvar.BoolValue) {
return;
}

Expand Down Expand Up @@ -1195,7 +1196,7 @@ public void SwapSides() {
g_TeamSide[MatchTeam_Team1] = g_TeamSide[MatchTeam_Team2];
g_TeamSide[MatchTeam_Team2] = tmp;

if (g_ResetPausesEachHalfCvar.IntValue != 0) {
if (g_ResetPausesEachHalfCvar.BoolValue) {
LOOP_TEAMS(team) {
g_TeamPauseTimeUsed[team] = 0;
g_TeamPausesUsed[team] = 0;
Expand Down
4 changes: 2 additions & 2 deletions scripting/get5/backups.sp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define TEMP_VALVE_BACKUP_PATTERN "get5_temp_backup%d.txt"

public Action Command_LoadBackup(int client, int args) {
if (g_BackupSystemEnabledCvar.IntValue == 0) {
if (!g_BackupSystemEnabledCvar.BoolValue) {
ReplyToCommand(client, "The backup system is disabled");
return Plugin_Handled;
}
Expand All @@ -22,7 +22,7 @@ public Action Command_LoadBackup(int client, int args) {
}

public Action Command_ListBackups(int client, int args) {
if (g_BackupSystemEnabledCvar.IntValue == 0) {
if (!g_BackupSystemEnabledCvar.BoolValue) {
ReplyToCommand(client, "The backup system is disabled");
return Plugin_Handled;
}
Expand Down
2 changes: 1 addition & 1 deletion scripting/get5/matchconfig.sp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ stock bool LoadMatchConfig(const char[] config, bool restoreBackup = false) {
return false;
}

if (g_CheckAuthsCvar.IntValue == 0 &&
if (!g_CheckAuthsCvar.BoolValue &&
(GetTeamAuths(MatchTeam_Team1).Length != 0 || GetTeamAuths(MatchTeam_Team2).Length != 0)) {
LogError(
"Setting player auths in the \"players\" section has no impact with get5_check_auths 0");
Expand Down
16 changes: 8 additions & 8 deletions scripting/get5/pausing.sp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
public bool Pauseable() {
return g_GameState >= Get5State_KnifeRound && g_PausingEnabledCvar.IntValue != 0;
return g_GameState >= Get5State_KnifeRound && g_PausingEnabledCvar.BoolValue;
}

public Action Command_TechPause(int client, int args) {
if (!g_AllowTechPauseCvar.BoolValue || !Pauseable() || IsPaused()) {
if (g_AllowTechPauseCvar.BoolValue || !Pauseable() || IsPaused()) {
return Plugin_Handled;
}

Expand Down Expand Up @@ -39,7 +39,7 @@ public Action Command_Pause(int client, int args) {
MatchTeam team = GetClientMatchTeam(client);
int maxPauses = g_MaxPausesCvar.IntValue;
char pausePeriodString[32];
if (g_ResetPausesEachHalfCvar.IntValue != 0) {
if (g_ResetPausesEachHalfCvar.BoolValue) {
Format(pausePeriodString, sizeof(pausePeriodString), " %t", "PausePeriodSuffix");
}

Expand Down Expand Up @@ -71,7 +71,7 @@ public Action Command_Pause(int client, int args) {
g_TeamPausesUsed[team]++;

pausePeriodString = "";
if (g_ResetPausesEachHalfCvar.IntValue != 0) {
if (g_ResetPausesEachHalfCvar.BoolValue) {
Format(pausePeriodString, sizeof(pausePeriodString), " %t", "PausePeriodSuffix");
}

Expand All @@ -91,17 +91,17 @@ public Action Command_Pause(int client, int args) {
}

public Action Timer_PauseTimeCheck(Handle timer, int data) {
if (!Pauseable() || !IsPaused() || g_FixedPauseTimeCvar.IntValue != 0) {
if (!Pauseable() || !IsPaused() || g_FixedPauseTimeCvar.BoolValue) {
return Plugin_Stop;
}

// Unlimited pause time.
if (g_MaxPauseTimeCvar.IntValue == 0) {
if (g_MaxPauseTimeCvar.IntValue <= 0) {
return Plugin_Stop;
}

char pausePeriodString[32];
if (g_ResetPausesEachHalfCvar.IntValue != 0) {
if (g_ResetPausesEachHalfCvar.BoolValue) {
Format(pausePeriodString, sizeof(pausePeriodString), " %t", "PausePeriodSuffix");
}

Expand Down Expand Up @@ -141,7 +141,7 @@ public Action Command_Unpause(int client, int args) {
return Plugin_Handled;
}

if (g_FixedPauseTimeCvar.IntValue != 0 && !g_InExtendedPause) {
if (g_FixedPauseTimeCvar.BoolValue && !g_InExtendedPause) {
return Plugin_Handled;
}

Expand Down
2 changes: 1 addition & 1 deletion scripting/get5/stats.sp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void Stats_RoundEnd(int csTeamWinner) {
}
}

if (g_DamagePrintCvar.IntValue != 0) {
if (g_DamagePrintCvar.BoolValue) {
for (int i = 1; i <= MaxClients; i++) {
if (IsValidClient(i)) {
PrintDamageInfo(i);
Expand Down
16 changes: 8 additions & 8 deletions scripting/get5/teamlogic.sp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public Action Command_JoinTeam(int client, const char[] command, int argc) {
}

// Don't enforce team joins.
if (g_CheckAuthsCvar.IntValue == 0) {
if (!g_CheckAuthsCvar.BoolValue) {
return Plugin_Continue;
}

Expand Down Expand Up @@ -71,7 +71,7 @@ public Action Command_JoinTeam(int client, const char[] command, int argc) {
int count = CountPlayersOnCSTeam(csTeam);

if (count >= g_PlayersPerTeam) {
if (g_CoachingEnabledCvar.IntValue == 0) {
if (!g_CoachingEnabledCvar.BoolValue) {
KickClient(client, "%t", "TeamIsFullInfoMessage");
} else {
LogDebug("Forcing player %N to coach", client);
Expand All @@ -96,7 +96,7 @@ public void MoveClientToCoach(int client) {
return;
}

if (g_CoachingEnabledCvar.IntValue == 0) {
if (!g_CoachingEnabledCvar.BoolValue) {
return;
}

Expand Down Expand Up @@ -134,7 +134,7 @@ public Action Command_SmCoach(int client, int args) {
return Plugin_Continue;
}

if (g_CoachingEnabledCvar.IntValue == 0) {
if (!g_CoachingEnabledCvar.BoolValue) {
return Plugin_Handled;
}

Expand All @@ -147,7 +147,7 @@ public Action Command_Coach(int client, const char[] command, int argc) {
return Plugin_Continue;
}

if (g_CoachingEnabledCvar.IntValue == 0) {
if (!g_CoachingEnabledCvar.BoolValue) {
return Plugin_Handled;
}

Expand All @@ -159,7 +159,7 @@ public Action Command_Coach(int client, const char[] command, int argc) {
return Plugin_Stop;
}

if (g_MovingClientToCoach[client] || g_CheckAuthsCvar.IntValue == 0) {
if (g_MovingClientToCoach[client] || !g_CheckAuthsCvar.BoolValue) {
LogDebug("Command_Coach: %L, letting pass-through", client);
return Plugin_Continue;
}
Expand All @@ -169,7 +169,7 @@ public Action Command_Coach(int client, const char[] command, int argc) {
}

public MatchTeam GetClientMatchTeam(int client) {
if (g_CheckAuthsCvar.IntValue == 0) {
if (!g_CheckAuthsCvar.BoolValue) {
return CSTeamToMatchTeam(GetClientTeam(client));
} else {
char auth[AUTH_LENGTH];
Expand Down Expand Up @@ -260,7 +260,7 @@ public MatchTeam GetCaptainTeam(int client) {

public int GetTeamCaptain(MatchTeam team) {
// If not forcing auths, take the 1st client on the team.
if (g_CheckAuthsCvar.IntValue == 0) {
if (!g_CheckAuthsCvar.BoolValue) {
for (int i = 1; i <= MaxClients; i++) {
if (IsAuthedPlayer(i) && GetClientMatchTeam(i) == team) {
return i;
Expand Down
2 changes: 1 addition & 1 deletion scripting/get5/util.sp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ stock bool IsTVEnabled() {
LogError("Failed to get tv_enable cvar");
return false;
}
return tvEnabledCvar.IntValue != 0;
return tvEnabledCvar.BoolValue;
}

stock int GetTvDelay() {
Expand Down
2 changes: 1 addition & 1 deletion scripting/get5_apistats.sp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public Action Command_Avaliable(int client, int args) {
Handle json = json_object();

set_json_int(json, "gamestate", view_as<int>(Get5_GetGameState()));
set_json_int(json, "avaliable", 1); // legacy version since I'm bad at spelling
set_json_int(json, "avaliable", 1); // legacy version since I'm bad at spelling
set_json_int(json, "available", 1);
set_json_string(json, "plugin_version", versionString);

Expand Down

0 comments on commit 72a26c4

Please sign in to comment.