Hide classarg prints behind convar (#437)

* Hide classarg prints behind convar

* Tabs instead of spaces

* Group defines and move includes to be done last

* Cleanup spawnrate code

---------

Co-authored-by: thegrb93 <grbrown93@sbcglobal.net>
This commit is contained in:
Redox 2023-08-26 21:50:05 +01:00 committed by GitHub
parent e58e15fb6d
commit a7adb33ef8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 47 deletions

View File

@ -13,6 +13,8 @@ AdvDupe2.JobManager = {}
AdvDupe2.JobManager.PastingHook = false AdvDupe2.JobManager.PastingHook = false
AdvDupe2.JobManager.Queue = {} AdvDupe2.JobManager.Queue = {}
local debugConvar = GetConVar("AdvDupe2_DebugInfo")
local constraints = { local constraints = {
Weld = true, Weld = true,
Axis = true, Axis = true,
@ -54,7 +56,9 @@ local function CopyClassArgTable(tab)
newtable[k] = v newtable[k] = v
end end
else else
print("[AdvDupe2] ClassArg table with key \"" .. tostring(k) .. "\" has unsupported value of type \"".. type(v) .."\"!") if debugConvar:GetBool() then
print("[AdvDupe2] ClassArg table with key \"" .. tostring(k) .. "\" has unsupported value of type \"".. type(v) .."\"!")
end
end end
end end
return newtable return newtable
@ -143,9 +147,8 @@ local function CopyEntTable(Ent, Offset)
else else
Tab[Key] = EntTable[Key] Tab[Key] = EntTable[Key]
end end
elseif varType ~= TYPE_NIL then elseif varType ~= TYPE_NIL and debugConvar:GetBool() then
print("[AdvDupe2] Entity ClassArg \"" .. Key .. "\" of type \"" .. Ent:GetClass() .. print("[AdvDupe2] Entity ClassArg \"" .. Key .. "\" of type \"" .. Ent:GetClass() .. "\" has unsupported value of type \"" .. type(EntTable[Key]) .. "\"!\n")
"\" has unsupported value of type \"" .. type(EntTable[Key]) .. "\"!\n")
end end
end end
end end
@ -1473,7 +1476,7 @@ end
local ticktotal = 0 local ticktotal = 0
local function ErrorCatchSpawning() local function ErrorCatchSpawning()
ticktotal = ticktotal + AdvDupe2.SpawnRate ticktotal = ticktotal + math.max(GetConVarNumber("AdvDupe2_SpawnRate"), 0.01)
while ticktotal >= 1 do while ticktotal >= 1 do
ticktotal = ticktotal - 1 ticktotal = ticktotal - 1
local status, err = pcall(AdvDupe2_Spawn) local status, err = pcall(AdvDupe2_Spawn)

View File

@ -5,11 +5,17 @@ AdvDupe2 = {
AdvDupe2.DataFolder = "advdupe2" --name of the folder in data where dupes will be saved AdvDupe2.DataFolder = "advdupe2" --name of the folder in data where dupes will be saved
include "advdupe2/sv_clipboard.lua" function AdvDupe2.Notify(ply,msg,typ, showsvr, dur)
include "advdupe2/sh_codec.lua" net.Start("AdvDupe2Notify")
include "advdupe2/sv_misc.lua" net.WriteString(msg)
include "advdupe2/sv_file.lua" net.WriteUInt(typ or 0, 8)
include "advdupe2/sv_ghost.lua" net.WriteFloat(dur or 5)
net.Send(ply)
if(showsvr==true)then
print("[AdvDupe2Notify]\t"..ply:Nick()..": "..msg)
end
end
AddCSLuaFile "autorun/client/advdupe2_cl_init.lua" AddCSLuaFile "autorun/client/advdupe2_cl_init.lua"
AddCSLuaFile "advdupe2/file_browser.lua" AddCSLuaFile "advdupe2/file_browser.lua"
@ -29,20 +35,11 @@ util.AddNetworkString("AdvDupe2_RemoveSelectBox")
util.AddNetworkString("AdvDupe2_UpdateProgressBar") util.AddNetworkString("AdvDupe2_UpdateProgressBar")
util.AddNetworkString("AdvDupe2_RemoveProgressBar") util.AddNetworkString("AdvDupe2_RemoveProgressBar")
util.AddNetworkString("AdvDupe2_ResetOffsets") util.AddNetworkString("AdvDupe2_ResetOffsets")
util.AddNetworkString("AdvDupe2_SetDupeInfo")
util.AddNetworkString("AdvDupe2_ReceiveFile")
util.AddNetworkString("AdvDupe2_CanAutoSave")
function AdvDupe2.Notify(ply,msg,typ, showsvr, dur) CreateConVar("AdvDupe2_DebugInfo", "0", {FCVAR_ARCHIVE}, "Should extra info be printed to console?", 0, 1)
net.Start("AdvDupe2Notify")
net.WriteString(msg)
net.WriteUInt(typ or 0, 8)
net.WriteFloat(dur or 5)
net.Send(ply)
if(showsvr==true)then
print("[AdvDupe2Notify]\t"..ply:Nick()..": "..msg)
end
end
AdvDupe2.SpawnRate = AdvDupe2.SpawnRate or 1
CreateConVar("AdvDupe2_SpawnRate", "1", {FCVAR_ARCHIVE}) CreateConVar("AdvDupe2_SpawnRate", "1", {FCVAR_ARCHIVE})
CreateConVar("AdvDupe2_MaxFileSize", "200", {FCVAR_ARCHIVE}) CreateConVar("AdvDupe2_MaxFileSize", "200", {FCVAR_ARCHIVE})
CreateConVar("AdvDupe2_MaxEntities", "0", {FCVAR_ARCHIVE}) CreateConVar("AdvDupe2_MaxEntities", "0", {FCVAR_ARCHIVE})
@ -60,16 +57,6 @@ CreateConVar("AdvDupe2_UpdateFilesDelay", "10", {FCVAR_ARCHIVE})
CreateConVar("AdvDupe2_LoadMap", "0", {FCVAR_ARCHIVE}) CreateConVar("AdvDupe2_LoadMap", "0", {FCVAR_ARCHIVE})
CreateConVar("AdvDupe2_MapFileName", "", {FCVAR_ARCHIVE}) CreateConVar("AdvDupe2_MapFileName", "", {FCVAR_ARCHIVE})
cvars.AddChangeCallback("AdvDupe2_SpawnRate",
function(cvar, preval, newval)
newval = tonumber(newval)
if(newval~=nil and newval>0)then
AdvDupe2.SpawnRate = newval
else
print("[AdvDupe2Notify]\tINVALID SPAWN RATE")
end
end)
local function PasteMap() local function PasteMap()
if(GetConVarString("AdvDupe2_LoadMap")=="0")then return end if(GetConVarString("AdvDupe2_LoadMap")=="0")then return end
local filename = GetConVarString("AdvDupe2_MapFileName") local filename = GetConVarString("AdvDupe2_MapFileName")
@ -127,23 +114,15 @@ local function PasteMap()
print("[AdvDupe2Notify]\tMap save pasted.") print("[AdvDupe2Notify]\tMap save pasted.")
end end
util.AddNetworkString("AdvDupe2_SetDupeInfo")
util.AddNetworkString("AdvDupe2_ReceiveFile")
util.AddNetworkString("AdvDupe2_CanAutoSave")
hook.Add("InitPostEntity", "AdvDupe2_PasteMap", PasteMap) hook.Add("InitPostEntity", "AdvDupe2_PasteMap", PasteMap)
hook.Add("PostCleanupMap", "AdvDupe2_PasteMap", PasteMap) hook.Add("PostCleanupMap", "AdvDupe2_PasteMap", PasteMap)
hook.Add("Initialize", "AdvDupe2_CheckServerSettings",function()
AdvDupe2.SpawnRate = tonumber(GetConVarString("AdvDupe2_SpawnRate"))
if not AdvDupe2.SpawnRate or AdvDupe2.SpawnRate <= 0 then
AdvDupe2.SpawnRate = 1
print("[AdvDupe2Notify]\tINVALID SPAWN RATE DEFAULTING VALUE")
end
end)
hook.Add("PlayerInitialSpawn","AdvDupe2_AddPlayerTable",function(ply) hook.Add("PlayerInitialSpawn","AdvDupe2_AddPlayerTable",function(ply)
ply.AdvDupe2 = {} ply.AdvDupe2 = {}
end) end)
include "advdupe2/sv_clipboard.lua"
include "advdupe2/sh_codec.lua"
include "advdupe2/sv_misc.lua"
include "advdupe2/sv_file.lua"
include "advdupe2/sv_ghost.lua"