From 47f9baf2776fa2d61c799d75be1e186a7cc58147 Mon Sep 17 00:00:00 2001 From: Timo Smit Date: Thu, 3 Jan 2019 12:49:11 +0100 Subject: [PATCH] Fixed consistent checking of standalone setting * treat everything non-zero as true (enabled) --- luamods/wolfadmin/auth/auth.lua | 10 +++++----- luamods/wolfadmin/commands/admin/help.lua | 2 +- luamods/wolfadmin/commands/admin/lock.lua | 2 +- luamods/wolfadmin/commands/admin/readconfig.lua | 2 +- luamods/wolfadmin/commands/admin/setlevel.lua | 2 +- luamods/wolfadmin/commands/admin/unlock.lua | 2 +- luamods/wolfadmin/commands/admin/warn.lua | 2 +- luamods/wolfadmin/commands/client/say.lua | 2 +- luamods/wolfadmin/commands/client/team.lua | 2 +- luamods/wolfadmin/util/logs.lua | 2 +- luamods/wolfadmin/util/settings.lua | 2 +- 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/luamods/wolfadmin/auth/auth.lua b/luamods/wolfadmin/auth/auth.lua index 86b2e50..2b3b99a 100644 --- a/luamods/wolfadmin/auth/auth.lua +++ b/luamods/wolfadmin/auth/auth.lua @@ -117,7 +117,11 @@ auth.PERM_IMMUNE = "immune" -- system in this function. might have to think of a better way to implement -- this, but it will suffice. function auth.onGameInit() - if settings.get("g_standalone") == 1 then + if settings.get("g_standalone") ~= 0 then + if et.trap_Cvar_Get("g_shrubbot") ~= "" then + outputDebug("Running in standalone mode while g_shrubbot is set", 3) + end + if not db.isConnected() then -- FIXME simple workaround to deny any commands function auth.isPlayerAllowed() return false end @@ -134,10 +138,6 @@ function auth.onGameInit() srv.loadFlags(et.trap_Cvar_Get("fs_game")) end - if settings.get("g_standalone") == 1 and et.trap_Cvar_Get("g_shrubbot") ~= "" then - outputDebug("Running in standalone mode while g_shrubbot is set", 3) - end - setmetatable(auth, {__index = srv}) end events.handle("onGameInit", auth.onGameInit) diff --git a/luamods/wolfadmin/commands/admin/help.lua b/luamods/wolfadmin/commands/admin/help.lua index 0f582b8..0bc5405 100644 --- a/luamods/wolfadmin/commands/admin/help.lua +++ b/luamods/wolfadmin/commands/admin/help.lua @@ -31,7 +31,7 @@ function commandHelp(clientId, command, cmd) end end - et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..clientId.." \"^dhelp: ^9"..#availableCommands.." "..((settings.get("g_standalone") == 1) and "available" or "additional").." commands (open console for the full list)\";") + et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..clientId.." \"^dhelp: ^9"..#availableCommands.." "..((settings.get("g_standalone") ~= 0) and "available" or "additional").." commands (open console for the full list)\";") local cmdsOnLine, cmdsBuffer = 0, "" diff --git a/luamods/wolfadmin/commands/admin/lock.lua b/luamods/wolfadmin/commands/admin/lock.lua index 96c3b96..19f1e73 100644 --- a/luamods/wolfadmin/commands/admin/lock.lua +++ b/luamods/wolfadmin/commands/admin/lock.lua @@ -42,7 +42,7 @@ function commandLock(clientId, command, team) return false end -commands.addadmin("lock", commandLock, auth.PERM_LOCKTEAM, "lock one or all of the teams from players joining", "^9[^3r|b|s|all#^9]", true, (settings.get("g_standalone") == 1)) +commands.addadmin("lock", commandLock, auth.PERM_LOCKTEAM, "lock one or all of the teams from players joining", "^9[^3r|b|s|all#^9]", true, (settings.get("g_standalone") ~= 0)) function commandLock(clientId, command, team) if team == nil or (team ~= constants.TEAM_AXIS_SC and team ~= constants.TEAM_ALLIES_SC and team ~= constants.TEAM_SPECTATORS_SC and team ~= "all") then diff --git a/luamods/wolfadmin/commands/admin/readconfig.lua b/luamods/wolfadmin/commands/admin/readconfig.lua index 933c912..10d8b94 100644 --- a/luamods/wolfadmin/commands/admin/readconfig.lua +++ b/luamods/wolfadmin/commands/admin/readconfig.lua @@ -37,7 +37,7 @@ function commandReadconfig(clientId, command) return false end -commands.addadmin("readconfig", commandReadconfig, auth.PERM_READCONFIG, "reloads the shrubbot config file and refreshes user flags", nil, true, (settings.get("g_standalone") == 1)) +commands.addadmin("readconfig", commandReadconfig, auth.PERM_READCONFIG, "reloads the shrubbot config file and refreshes user flags", nil, true, (settings.get("g_standalone") ~= 0)) function commandReadconfig(clientId, command) settings.load() diff --git a/luamods/wolfadmin/commands/admin/setlevel.lua b/luamods/wolfadmin/commands/admin/setlevel.lua index 6cddff4..a003ea4 100644 --- a/luamods/wolfadmin/commands/admin/setlevel.lua +++ b/luamods/wolfadmin/commands/admin/setlevel.lua @@ -55,7 +55,7 @@ function commandSetLevel(clientId, command, victim, level) return false end -commands.addadmin("setlevel", commandSetLevel, auth.PERM_SETLEVEL, "sets the admin level of a player", "^9[^3name|slot#^9] ^9[^3level^9]", true, (settings.get("g_standalone") == 1)) +commands.addadmin("setlevel", commandSetLevel, auth.PERM_SETLEVEL, "sets the admin level of a player", "^9[^3name|slot#^9] ^9[^3level^9]", true, (settings.get("g_standalone") ~= 0)) function commandSetLevel(clientId, command, victim, level) local cmdClient diff --git a/luamods/wolfadmin/commands/admin/unlock.lua b/luamods/wolfadmin/commands/admin/unlock.lua index 9719041..5a1d1e6 100644 --- a/luamods/wolfadmin/commands/admin/unlock.lua +++ b/luamods/wolfadmin/commands/admin/unlock.lua @@ -42,7 +42,7 @@ function commandUnlock(clientId, command, team) return false end -commands.addadmin("unlock", commandUnlock, auth.PERM_LOCKTEAM, "unlock one or all locked teams", "^9[^3r|b|s|all#^9]", true, (settings.get("g_standalone") == 1)) +commands.addadmin("unlock", commandUnlock, auth.PERM_LOCKTEAM, "unlock one or all locked teams", "^9[^3r|b|s|all#^9]", true, (settings.get("g_standalone") ~= 0)) function commandUnlock(clientId, command, team) if team == nil or (team ~= constants.TEAM_AXIS_SC and team ~= constants.TEAM_ALLIES_SC and team ~= constants.TEAM_SPECTATORS_SC and team ~= "all") then diff --git a/luamods/wolfadmin/commands/admin/warn.lua b/luamods/wolfadmin/commands/admin/warn.lua index d1cc587..c214eff 100644 --- a/luamods/wolfadmin/commands/admin/warn.lua +++ b/luamods/wolfadmin/commands/admin/warn.lua @@ -50,7 +50,7 @@ function commandWarn(clientId, command, victim, ...) return false end -commands.addadmin("warn", commandWarn, auth.PERM_WARN, "warns a player by displaying the reason", "^9[^3name|slot#^9] ^9[^3reason^9]", true, (settings.get("g_standalone") == 1 or settings.get("g_playerHistory") == 0)) +commands.addadmin("warn", commandWarn, auth.PERM_WARN, "warns a player by displaying the reason", "^9[^3name|slot#^9] ^9[^3reason^9]", true, (settings.get("g_standalone") ~= 0 or settings.get("g_playerHistory") == 0)) function commandWarn(clientId, command, victim, ...) local cmdClient diff --git a/luamods/wolfadmin/commands/client/say.lua b/luamods/wolfadmin/commands/client/say.lua index 565e50b..3026d72 100644 --- a/luamods/wolfadmin/commands/client/say.lua +++ b/luamods/wolfadmin/commands/client/say.lua @@ -53,7 +53,7 @@ function commandVoiceSay(clientId, command, ...) return true end - if settings.get("g_standalone") == 1 then + if settings.get("g_standalone") ~= 0 then logs.writeChat(clientId, types[command], ...) end end diff --git a/luamods/wolfadmin/commands/client/team.lua b/luamods/wolfadmin/commands/client/team.lua index 71e62a8..f305442 100644 --- a/luamods/wolfadmin/commands/client/team.lua +++ b/luamods/wolfadmin/commands/client/team.lua @@ -36,7 +36,7 @@ function commandTeam(clientId, command) end local team = util.getTeamFromCode(et.trap_Argv(1)) - if settings.get("g_standalone") == 1 and teams.isLocked(team) then + if settings.get("g_standalone") ~= 0 and teams.isLocked(team) then local teamName = util.getTeamName(team) local teamColor = util.getTeamColor(team) diff --git a/luamods/wolfadmin/util/logs.lua b/luamods/wolfadmin/util/logs.lua index 61931b6..2ac505f 100644 --- a/luamods/wolfadmin/util/logs.lua +++ b/luamods/wolfadmin/util/logs.lua @@ -61,7 +61,7 @@ function logs.writeAdmin(clientId, command, victimId, ...) local clientFlags = "" local args = table.concat({...}, " ") - if settings.get("g_standalone") == 1 then + if settings.get("g_standalone") ~= 0 then if victimId then local victimName = players.getName(victimId) logLine = string.format("[%s] %s: %s: %s: %s: \"%s\"\n", os.date("%Y-%m-%d %H:%M:%S"), clientGUID, clientName, command, victimName, args) diff --git a/luamods/wolfadmin/util/settings.lua b/luamods/wolfadmin/util/settings.lua index e378f8b..3611720 100644 --- a/luamods/wolfadmin/util/settings.lua +++ b/luamods/wolfadmin/util/settings.lua @@ -172,7 +172,7 @@ function settings.load() settings.determineOS() settings.determineMode() - outputDebug("WolfAdmin running in "..(settings.get("g_standalone") == 1 and "standalone" or "add-on").." mode on "..settings.get("sv_os")..".") + outputDebug("WolfAdmin running in "..(settings.get("g_standalone") ~= 0 and "standalone" or "add-on").." mode on "..settings.get("sv_os")..".") end function settings.determineOS()