From 90407014ab06e77b5d1d1ae71c96f032938ec72f Mon Sep 17 00:00:00 2001 From: Python1320 Date: Sat, 14 Nov 2015 14:57:01 +0200 Subject: [PATCH 01/56] Improve serverside performance Do not iterate over a huge array, but make the runtime checking work through time keeping. Pending proper testing and validation. All I'm worried of is that this makes output firing stricter. --- lua/wire/server/wirelib.lua | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lua/wire/server/wirelib.lua b/lua/wire/server/wirelib.lua index 931122b37f..0114c41f8f 100644 --- a/lua/wire/server/wirelib.lua +++ b/lua/wire/server/wirelib.lua @@ -47,10 +47,13 @@ local Inputs = {} local Outputs = {} local CurLink = {} +local frametime = FrameTime() +local cur_time = CurTime() +local max_overtime = cur_time + frametime*4 hook.Add("Think", "WireLib_Think", function() - for idx,port in pairs(Outputs) do - port.TriggerLimit = 4 - end + frametime = FrameTime() + cur_time = CurTime() + max_overtime = cur_time + frametime * 4 end) -- helper function that pcalls an input @@ -158,7 +161,7 @@ function WireLib.CreateSpecialOutputs(ent, names, types, descs) Type = tp, Value = WireLib.DT[ tp ].Zero, Connected = {}, - TriggerLimit = 8, + TriggerLimit = 0, Num = n, } @@ -258,7 +261,7 @@ function WireLib.AdjustSpecialOutputs(ent, names, types, descs) Type = types[n] or "NORMAL", Value = WireLib.DT[ (types[n] or "NORMAL") ].Zero, Connected = {}, - TriggerLimit = 8, + TriggerLimit = 0, Num = n, } @@ -506,9 +509,13 @@ function WireLib.TriggerOutput(ent, oname, value, iter) local output = ent.Outputs[oname] if (output) and (value ~= output.Value or output.Type == "ARRAY" or output.Type == "TABLE") then - if (output.TriggerLimit <= 0) then return end - output.TriggerLimit = output.TriggerLimit - 1 + local lastfire = output.TriggerLimit + + if (lastfire >= max_overtime) then return end + + output.TriggerLimit = (lastfire < cur_time and cur_time or lastfire) + frametime + output.Value = value if (iter) then From 368eb913b73e1a7486a3feee4d74c10fe27a7b44 Mon Sep 17 00:00:00 2001 From: Python1320 Date: Sat, 14 Nov 2015 23:23:42 +0200 Subject: [PATCH 02/56] Update wirelib.lua Double limits to at least not go under original limits --- lua/wire/server/wirelib.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lua/wire/server/wirelib.lua b/lua/wire/server/wirelib.lua index 0114c41f8f..9d8dada9ed 100644 --- a/lua/wire/server/wirelib.lua +++ b/lua/wire/server/wirelib.lua @@ -19,6 +19,8 @@ local tostring = tostring local Vector = Vector local Color = Color local Material = Material +local FrameTime = FrameTime +local CurTime= CurTime local HasPorts = WireLib.HasPorts -- Very important for checks! @@ -49,11 +51,11 @@ local CurLink = {} local frametime = FrameTime() local cur_time = CurTime() -local max_overtime = cur_time + frametime*4 +local max_overtime = 1/0 hook.Add("Think", "WireLib_Think", function() frametime = FrameTime() cur_time = CurTime() - max_overtime = cur_time + frametime * 4 + max_overtime = cur_time + frametime * 8 end) -- helper function that pcalls an input From 18e492c60c90a11f4711e08cf190a17c557c10bd Mon Sep 17 00:00:00 2001 From: Python1320 Date: Thu, 26 Nov 2015 02:29:15 +0200 Subject: [PATCH 03/56] Update wirelib.lua Use math.huge, lower limit to 5 as 4 is an edge case until proven otherwise and 8 does not make sense --- lua/wire/server/wirelib.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/wire/server/wirelib.lua b/lua/wire/server/wirelib.lua index 9d8dada9ed..0acbea4bb9 100644 --- a/lua/wire/server/wirelib.lua +++ b/lua/wire/server/wirelib.lua @@ -51,11 +51,11 @@ local CurLink = {} local frametime = FrameTime() local cur_time = CurTime() -local max_overtime = 1/0 +local max_overtime = math.huge hook.Add("Think", "WireLib_Think", function() frametime = FrameTime() cur_time = CurTime() - max_overtime = cur_time + frametime * 8 + max_overtime = cur_time + frametime * 5 end) -- helper function that pcalls an input From 609b2ab94f11671291a167f3e71a4fb9e2199e6e Mon Sep 17 00:00:00 2001 From: Python1320 Date: Thu, 26 Nov 2015 23:56:40 +0200 Subject: [PATCH 04/56] Update wirelib.lua add space --- lua/wire/server/wirelib.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/wire/server/wirelib.lua b/lua/wire/server/wirelib.lua index 0acbea4bb9..efabbc9bad 100644 --- a/lua/wire/server/wirelib.lua +++ b/lua/wire/server/wirelib.lua @@ -20,7 +20,7 @@ local Vector = Vector local Color = Color local Material = Material local FrameTime = FrameTime -local CurTime= CurTime +local CurTime = CurTime local HasPorts = WireLib.HasPorts -- Very important for checks! From 8921b997fa0dd5f00107023ddc1eda4a39393834 Mon Sep 17 00:00:00 2001 From: Python1320 Date: Fri, 27 Nov 2015 00:23:03 +0200 Subject: [PATCH 05/56] Update wirelib.lua Update rate limiting to work like a good approximation of the old behavior based on simulation --- lua/wire/server/wirelib.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lua/wire/server/wirelib.lua b/lua/wire/server/wirelib.lua index efabbc9bad..47c8abac64 100644 --- a/lua/wire/server/wirelib.lua +++ b/lua/wire/server/wirelib.lua @@ -55,7 +55,7 @@ local max_overtime = math.huge hook.Add("Think", "WireLib_Think", function() frametime = FrameTime() cur_time = CurTime() - max_overtime = cur_time + frametime * 5 + max_overtime = cur_time + frametime -- timestamp of one frame into future end) -- helper function that pcalls an input @@ -514,9 +514,11 @@ function WireLib.TriggerOutput(ent, oname, value, iter) local lastfire = output.TriggerLimit + -- Do not trigger if we have eaten our slices of the frame (rate limiter) if (lastfire >= max_overtime) then return end - output.TriggerLimit = (lastfire < cur_time and cur_time or lastfire) + frametime + -- Each trigger eats 1/4 of a frame time, after 4 triggers we are one frametime into future and get rate limited + output.TriggerLimit = (lastfire < cur_time and cur_time or lastfire) + frametime * 0.22221 -- around 4.5 per triggers frame (1/4.5 rounded down, 4.5 to allow headroom for float weirdnesses) output.Value = value From 8248b404293d534d27546021b2ca00c3375e3a71 Mon Sep 17 00:00:00 2001 From: Marceau Maubert Date: Wed, 21 Dec 2016 19:35:14 +0100 Subject: [PATCH 06/56] nek minnit --- lua/entities/gmod_wire_expression2/core/find.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/entities/gmod_wire_expression2/core/find.lua b/lua/entities/gmod_wire_expression2/core/find.lua index 729cd06326..f20cb38d21 100644 --- a/lua/entities/gmod_wire_expression2/core/find.lua +++ b/lua/entities/gmod_wire_expression2/core/find.lua @@ -59,6 +59,7 @@ local forbidden_classes = { ["player_manager"] = true, ["predicted_viewmodel"] = true, ["gmod_ghost"] = true, + ["coin"] = true, } local function filter_default(self) local chip = self.entity From 0ed1b0e237e9f0b9973843a231fee87284f64b66 Mon Sep 17 00:00:00 2001 From: Garrett Brown Date: Thu, 22 Dec 2016 00:45:21 -0600 Subject: [PATCH 07/56] Fix network overflows from hologram functions --- .../gmod_wire_expression2/core/hologram.lua | 55 +++++++++++++------ 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/lua/entities/gmod_wire_expression2/core/hologram.lua b/lua/entities/gmod_wire_expression2/core/hologram.lua index 944b53130e..5403d761d4 100644 --- a/lua/entities/gmod_wire_expression2/core/hologram.lua +++ b/lua/entities/gmod_wire_expression2/core/hologram.lua @@ -154,10 +154,36 @@ local clip_queue = {} local vis_queue = {} local player_color_queue = {} -local function add_scale_queue( Holo, scale ) -- Add an item to the scale queue (used by UWSVN holoModel) +local function add_scale_queue( Holo, scale ) + if #scale_queue==wire_holograms_max:GetInt() then return end scale_queue[#scale_queue+1] = { Holo, scale } end +local function add_bone_scale_queue( Holo, bone, scale ) + if #bone_scale_queue==wire_holograms_max:GetInt() then return end + bone_scale_queue[#bone_scale_queue+1] = { Holo, bone, scale } +end + +local function add_clip_queue( Holo, clip ) + if #clip_queue==wire_holograms_max:GetInt() then return end + clip_queue[#clip_queue+1] = { Holo, clip } +end + +local function add_vis_queue( ply, Holo, vis ) + local queue = vis_queue[ply] + if not queue then + queue = {} + vis_queue[ply] = queue + end + if #queue==wire_holograms_max:GetInt() then return end + queue[#queue+1] = { Holo, vis } +end + +local function add_player_color_queue( Holo, color ) + if #player_color_queue==wire_holograms_max:GetInt() then return end + player_color_queue[#player_color_queue+1] = { Holo, color } +end + local function flush_scale_queue(queue, recipient) if not queue then queue = scale_queue end if not next(queue) then return end @@ -272,7 +298,7 @@ local function rescale(Holo, scale, bone) local scale = Vector(x, y, z) if Holo.scale ~= scale then - table.insert(scale_queue, { Holo, scale }) + add_scale_queue( Holo, scale ) Holo.scale = scale end end @@ -286,10 +312,10 @@ local function rescale(Holo, scale, bone) local z = math.Clamp( b_scale[3], minval, maxval ) local scale = Vector(x, y, z) - table.insert(bone_scale_queue, { Holo, bidx, scale }) + add_bone_scale_queue( Holo, bidx, scale ) Holo.bone_scale[bidx] = scale else -- reset holo bone scale - table.insert(bone_scale_queue, { Holo, -1, Vector(0,0,0) }) + add_bone_scale_queue( Holo, -1, Vector(0,0,0) ) Holo.bone_scale = {} end end @@ -319,13 +345,13 @@ local function enable_clip(Holo, idx, enabled) if clip and clip.enabled ~= enabled then clip.enabled = enabled - table.insert(clip_queue, { + add_clip_queue( Holo, { index = idx, enabled = enabled } - } ) + ) end end @@ -337,7 +363,7 @@ local function set_clip(Holo, idx, origin, normal, isglobal) clip.normal = normal clip.isglobal = isglobal - table.insert(clip_queue, { + add_clip_queue( Holo, { index = idx, @@ -345,7 +371,7 @@ local function set_clip(Holo, idx, origin, normal, isglobal) normal = normal, isglobal = isglobal } - } ) + ) end end @@ -355,9 +381,7 @@ local function set_visible(Holo, players, visible) for _,ply in pairs( players ) do if IsValid( ply ) and ply:IsPlayer() and Holo.visible[ply] ~= visible then Holo.visible[ply] = visible - vis_queue[ply] = vis_queue[ply] or {} - - table.insert( vis_queue[ply], { Holo, visible } ) + add_vis_queue(ply, Holo, visible ) end end end @@ -366,12 +390,12 @@ local function reset_clholo(Holo, scale) if Holo.clips then for cidx, clip in pairs(Holo.clips) do if clip.enabled then - table.insert(clip_queue, { + add_clip_queue( Holo, { index = cidx, enabled = false } - } ) + ) end end Holo.clips = {} @@ -380,8 +404,7 @@ local function reset_clholo(Holo, scale) if Holo.visible then for ply, state in pairs(Holo.visible) do if not state then - vis_queue[ply] = vis_queue[ply] or {} - table.insert( vis_queue[ply], { Holo, true } ) + add_vis_queue(ply, Holo, true ) end end Holo.visible = {} @@ -389,7 +412,7 @@ local function reset_clholo(Holo, scale) end local function set_player_color(Holo, color) - table.insert( player_color_queue, { Holo, color } ) + add_player_color_queue(Holo, color) end hook.Add( "PlayerInitialSpawn", "wire_holograms_set_vars", function(ply) From 073e7b325d3555e55a995a06f540fd6b727a35fd Mon Sep 17 00:00:00 2001 From: Garrett Brown Date: Thu, 22 Dec 2016 15:56:55 -0600 Subject: [PATCH 08/56] Restructure queues so each player gets their own table with its own limit. --- .../gmod_wire_expression2/core/hologram.lua | 138 ++++++++---------- 1 file changed, 57 insertions(+), 81 deletions(-) diff --git a/lua/entities/gmod_wire_expression2/core/hologram.lua b/lua/entities/gmod_wire_expression2/core/hologram.lua index 5403d761d4..b17c5509c8 100644 --- a/lua/entities/gmod_wire_expression2/core/hologram.lua +++ b/lua/entities/gmod_wire_expression2/core/hologram.lua @@ -154,34 +154,14 @@ local clip_queue = {} local vis_queue = {} local player_color_queue = {} -local function add_scale_queue( Holo, scale ) - if #scale_queue==wire_holograms_max:GetInt() then return end - scale_queue[#scale_queue+1] = { Holo, scale } -end - -local function add_bone_scale_queue( Holo, bone, scale ) - if #bone_scale_queue==wire_holograms_max:GetInt() then return end - bone_scale_queue[#bone_scale_queue+1] = { Holo, bone, scale } -end - -local function add_clip_queue( Holo, clip ) - if #clip_queue==wire_holograms_max:GetInt() then return end - clip_queue[#clip_queue+1] = { Holo, clip } -end - -local function add_vis_queue( ply, Holo, vis ) - local queue = vis_queue[ply] - if not queue then - queue = {} - vis_queue[ply] = queue +local function add_queue( queue, ply, data ) + local plyqueue = queue[ply] + if not plyqueue then + plyqueue = {} + queue[ply] = plyqueue end - if #queue==wire_holograms_max:GetInt() then return end - queue[#queue+1] = { Holo, vis } -end - -local function add_player_color_queue( Holo, color ) - if #player_color_queue==wire_holograms_max:GetInt() then return end - player_color_queue[#player_color_queue+1] = { Holo, color } + if #plyqueue==wire_holograms_max:GetInt() then return end + plyqueue[#plyqueue+1] = data end local function flush_scale_queue(queue, recipient) @@ -189,32 +169,31 @@ local function flush_scale_queue(queue, recipient) if not next(queue) then return end net.Start("wire_holograms_set_scale") - for _,Holo,scale in ipairs_map(queue, unpack) do - net.WriteUInt(Holo.ent:EntIndex(), 16) - net.WriteFloat(scale.x) - net.WriteFloat(scale.y) - net.WriteFloat(scale.z) + for _, plyqueue in pairs(queue) do + for _,Holo,scale in ipairs_map(plyqueue, unpack) do + net.WriteUInt(Holo.ent:EntIndex(), 16) + net.WriteFloat(scale.x) + net.WriteFloat(scale.y) + net.WriteFloat(scale.z) + end end net.WriteUInt(0, 16) if recipient then net.Send(recipient) else net.Broadcast() end end - -local function add_bone_scale_queue( Holo, bone, scale ) - bone_scale_queue[#bone_scale_queue+1] = { Holo, bone, scale } -end - local function flush_bone_scale_queue(queue, recipient) if not queue then queue = bone_scale_queue end if not next(queue) then return end net.Start("wire_holograms_set_bone_scale") - for _,Holo,bone,scale in ipairs_map(queue, unpack) do - net.WriteUInt(Holo.ent:EntIndex(), 16) - net.WriteUInt(bone + 1, 16) -- using +1 to be able reset holo bones scale with -1 and not use signed int - net.WriteFloat(scale.x) - net.WriteFloat(scale.y) - net.WriteFloat(scale.z) + for _, plyqueue in pairs(queue) do + for _,Holo,bone,scale in ipairs_map(plyqueue, unpack) do + net.WriteUInt(Holo.ent:EntIndex(), 16) + net.WriteUInt(bone + 1, 16) -- using +1 to be able reset holo bones scale with -1 and not use signed int + net.WriteFloat(scale.x) + net.WriteFloat(scale.y) + net.WriteFloat(scale.z) + end end net.WriteUInt(0, 16) net.WriteUInt(0, 16) @@ -226,18 +205,20 @@ local function flush_clip_queue(queue, recipient) if not next(queue) then return end net.Start("wire_holograms_clip") - for _,Holo,clip in ipairs_map(queue, unpack) do - if clip and clip.index then - net.WriteUInt(Holo.ent:EntIndex(), 16) - net.WriteUInt(clip.index, 4) -- 4: absolute highest wire_holograms_max_clips is thus 16 - if clip.enabled ~= nil then - net.WriteBit(true) - net.WriteBit(clip.enabled) - elseif clip.origin and clip.normal and clip.isglobal then - net.WriteBit(false) - net.WriteVector(clip.origin) - net.WriteFloat(clip.normal.x) net.WriteFloat(clip.normal.y) net.WriteFloat(clip.normal.z) - net.WriteBit(clip.isglobal ~= 0) + for _, plyqueue in pairs(queue) do + for _,Holo,clip in ipairs_map(plyqueue, unpack) do + if clip and clip.index then + net.WriteUInt(Holo.ent:EntIndex(), 16) + net.WriteUInt(clip.index, 4) -- 4: absolute highest wire_holograms_max_clips is thus 16 + if clip.enabled ~= nil then + net.WriteBit(true) + net.WriteBit(clip.enabled) + elseif clip.origin and clip.normal and clip.isglobal then + net.WriteBit(false) + net.WriteVector(clip.origin) + net.WriteFloat(clip.normal.x) net.WriteFloat(clip.normal.y) net.WriteFloat(clip.normal.z) + net.WriteBit(clip.isglobal ~= 0) + end end end end @@ -265,9 +246,11 @@ local function flush_player_color_queue() if not next(player_color_queue) then return end net.Start("wire_holograms_set_player_color") - for _,Holo,color in ipairs_map(player_color_queue, unpack) do - net.WriteUInt(Holo.ent:EntIndex(), 16) - net.WriteVector(color) + for _, plyqueue in pairs(player_color_queue) do + for _,Holo,color in ipairs_map(plyqueue, unpack) do + net.WriteUInt(Holo.ent:EntIndex(), 16) + net.WriteVector(color) + end end net.WriteUInt(0, 16) net.Broadcast() @@ -298,7 +281,7 @@ local function rescale(Holo, scale, bone) local scale = Vector(x, y, z) if Holo.scale ~= scale then - add_scale_queue( Holo, scale ) + add_queue( scale_queue, Holo.e2owner, { Holo, scale } ) Holo.scale = scale end end @@ -312,10 +295,10 @@ local function rescale(Holo, scale, bone) local z = math.Clamp( b_scale[3], minval, maxval ) local scale = Vector(x, y, z) - add_bone_scale_queue( Holo, bidx, scale ) + add_queue( bone_scale_queue, Holo.e2owner, { Holo, bidx, scale } ) Holo.bone_scale[bidx] = scale else -- reset holo bone scale - add_bone_scale_queue( Holo, -1, Vector(0,0,0) ) + add_queue( bone_scale_queue, Holo.e2owner, { Holo, -1, Vector(0,0,0) } ) Holo.bone_scale = {} end end @@ -345,12 +328,11 @@ local function enable_clip(Holo, idx, enabled) if clip and clip.enabled ~= enabled then clip.enabled = enabled - add_clip_queue( - Holo, + add_queue( clip_queue, Holo.e2owner, { Holo, { index = idx, enabled = enabled - } + }} ) end end @@ -363,14 +345,13 @@ local function set_clip(Holo, idx, origin, normal, isglobal) clip.normal = normal clip.isglobal = isglobal - add_clip_queue( - Holo, + add_queue( clip_queue, Holo.e2owner, { Holo, { index = idx, origin = origin, normal = normal, isglobal = isglobal - } + }} ) end end @@ -381,7 +362,7 @@ local function set_visible(Holo, players, visible) for _,ply in pairs( players ) do if IsValid( ply ) and ply:IsPlayer() and Holo.visible[ply] ~= visible then Holo.visible[ply] = visible - add_vis_queue(ply, Holo, visible ) + add_queue( vis_queue, ply, { Holo, visible } ) end end end @@ -390,11 +371,11 @@ local function reset_clholo(Holo, scale) if Holo.clips then for cidx, clip in pairs(Holo.clips) do if clip.enabled then - add_clip_queue( - Holo, { + add_queue(clip_queue, Holo.e2owner, { Holo, + { index = cidx, enabled = false - } + }} ) end end @@ -404,7 +385,7 @@ local function reset_clholo(Holo, scale) if Holo.visible then for ply, state in pairs(Holo.visible) do if not state then - add_vis_queue(ply, Holo, true ) + add_queue(vis_queue, ply, { Holo, true }) end end Holo.visible = {} @@ -412,7 +393,7 @@ local function reset_clholo(Holo, scale) end local function set_player_color(Holo, color) - add_player_color_queue(Holo, color) + add_queue(player_color_queue, Holo.e2owner, { Holo, color }) end hook.Add( "PlayerInitialSpawn", "wire_holograms_set_vars", function(ply) @@ -464,9 +445,9 @@ hook.Add( "PlayerInitialSpawn", "wire_holograms_set_vars", function(ply) end end - flush_scale_queue(s_queue, ply) - flush_bone_scale_queue(b_s_queue, ply) - flush_clip_queue(c_queue, ply) + flush_scale_queue({[ply] = s_queue}, ply) + flush_bone_scale_queue({[ply] = b_s_queue}, ply) + flush_clip_queue({[ply] = c_queue}, ply) end) -- ----------------------------------------------------------------------------- @@ -1306,11 +1287,6 @@ end ) -- ----------------------------------------------------------------------------- wire_holograms = {} -- This global table is used to share certain functions and variables with UWSVN -wire_holograms.wire_holograms_size_max = wire_holograms_size_max -wire_holograms.ModelList = ModelList -wire_holograms.add_scale_queue = add_scale_queue -wire_holograms.add_bone_scale_queue = add_bone_scale_queue -wire_holograms.rescale = rescale wire_holograms.CheckIndex = CheckIndex registerCallback( "postinit", function() From 700409bbdde54e29ae83b8bb9569bf464d234224 Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Mon, 28 Nov 2016 10:50:53 +0100 Subject: [PATCH 09/56] Borrow GLua eradication from oldmud0's branch --- lua/wire/client/sound_browser.lua | 324 +++++++++++++++--------------- 1 file changed, 162 insertions(+), 162 deletions(-) diff --git a/lua/wire/client/sound_browser.lua b/lua/wire/client/sound_browser.lua index b6ca7bf82a..fa2136d4a2 100644 --- a/lua/wire/client/sound_browser.lua +++ b/lua/wire/client/sound_browser.lua @@ -1,8 +1,8 @@ -// A sound browser for the sound emitter and the expression 2 editor. -// Made by Grocel. +-- A sound browser for the sound emitter and the expression 2 editor. +-- Made by Grocel. -local max_char_count = 200 //File length limit -local max_char_chat_count = 110 // chat has a ~128 char limit, varies depending on char wide. +local max_char_count = 200 -- File length limit +local max_char_chat_count = 110 -- chat has a ~128 char limit, varies depending on char wide. local Disabled_Gray = Color(140, 140, 140, 255) @@ -30,9 +30,9 @@ local TranslateCHAN = { [CHAN_USER_BASE] = "CHAN_USER_BASE" } -// Output the infos about the given sound. +-- Output the infos about the given sound. local function GetFileInfos(strfile) - if (!isstring(strfile) or strfile == "") then return end + if not isstring(strfile) or strfile == "" then return end local nsize = tonumber(file.Size("sound/" .. strfile, "GAME") or "-1") local strformat = string.lower(string.GetExtensionFromFilename(strfile) or "n/a") @@ -41,19 +41,19 @@ local function GetFileInfos(strfile) end local function FormatSize(nsize) - if (!nsize) then return end + if not nsize then return end - //Negative filessizes aren't Valid. - if (nsize < 0) then return end + -- Negative filessizes aren't Valid. + if nsize < 0 then return end return nsize, string.NiceSize(nsize) end local function FormatLength(nduration) - if (!nduration) then return end + if not nduration then return end - //Negative durations aren't Valid. - if (nduration < 0) then return end + -- Negative durations aren't Valid. + if nduration < 0 then return end local nm = math.floor(nduration / 60) local ns = math.floor(nduration % 60) @@ -63,10 +63,10 @@ end local function GetInfoTable(strfile) local nsize, strformat, nduration = GetFileInfos(strfile) - if (!nsize) then return end + if not nsize then return end - nduration = SoundDuration(strfile) //Get the duration for the info text only. - if(nduration) then + nduration = SoundDuration(strfile) -- Get the duration for the info text only. + if nduration then nduration = math.Round(nduration * 1000) / 1000 end local nduration, strduration = FormatLength(nduration, nsize) @@ -75,7 +75,7 @@ local function GetInfoTable(strfile) local T = {} local tabproperty = sound.GetProperties(strfile) - if (tabproperty) then + if tabproperty then T = tabproperty else T.Path = strfile @@ -84,37 +84,37 @@ local function GetInfoTable(strfile) T.Format = strformat end - return T, !tabproperty + return T, not tabproperty end -// Output the infos about the given sound. +-- Output the infos about the given sound. local oldstrfile local function GenerateInfoTree(strfile, backnode, count) - if(oldstrfile == strfile and strfile) then return end + if oldstrfile == strfile and strfile then return end oldstrfile = strfile local SoundData, IsFile = GetInfoTable(strfile) - if (!IsValid(backnode)) then - if (IsValid(SoundInfoTreeRoot)) then + if not IsValid(backnode) then + if IsValid(SoundInfoTreeRoot) then SoundInfoTreeRoot:Remove() end end - if(!SoundData) then return end + if not SoundData then return end local strcount = "" - if (count) then + if count then strcount = " ("..count..")" end - if (IsFile) then + if IsFile then local index = "" local node = nil local mainnode = nil local subnode = nil - if (IsValid(backnode)) then + if IsValid(backnode) then mainnode = backnode:AddNode("Sound File"..strcount, "icon16/sound.png") else mainnode = SoundInfoTree:AddNode("Sound File", "icon16/sound.png") @@ -155,7 +155,7 @@ local function GenerateInfoTree(strfile, backnode, count) local node = nil local mainnode = nil - if (IsValid(backnode)) then + if IsValid(backnode) then mainnode = backnode:AddNode("Sound Property"..strcount, "icon16/table_gear.png") else mainnode = SoundInfoTree:AddNode("Sound Property", "icon16/table_gear.png") @@ -170,7 +170,7 @@ local function GenerateInfoTree(strfile, backnode, count) end do local tabchannel = SoundData["channel"] or 0 - if (istable(tabchannel)) then + if istable(tabchannel) then node = mainnode:AddNode("Channel", "icon16/page_white_gear.png") for k, v in pairs(tabchannel) do subnode = node:AddNode(v, "icon16/page.png") @@ -188,7 +188,7 @@ local function GenerateInfoTree(strfile, backnode, count) end do local tablevel = SoundData["level"] or 0 - if (istable(tablevel)) then + if istable(tablevel) then node = mainnode:AddNode("Level", "icon16/page_white_gear.png") for k, v in pairs(tablevel) do subnode = node:AddNode(v, "icon16/page.png") @@ -204,7 +204,7 @@ local function GenerateInfoTree(strfile, backnode, count) end do local tabpitch = SoundData["volume"] or 0 - if (istable(tabpitch)) then + if istable(tabpitch) then node = mainnode:AddNode("Volume", "icon16/page_white_gear.png") for k, v in pairs(tabpitch) do subnode = node:AddNode(v, "icon16/page.png") @@ -218,7 +218,7 @@ local function GenerateInfoTree(strfile, backnode, count) end do local tabpitch = SoundData["pitch"] or 0 - if (istable(tabpitch)) then + if istable(tabpitch) then node = mainnode:AddNode("Pitch", "icon16/page_white_gear.png") for k, v in pairs(tabpitch) do subnode = node:AddNode(v, "icon16/page.png") @@ -232,7 +232,7 @@ local function GenerateInfoTree(strfile, backnode, count) end do local tabsound = SoundData["sound"] or "" - if (istable(tabsound)) then + if istable(tabsound) then node = mainnode:AddNode("Sounds", "icon16/table_multiple.png") else node = mainnode:AddNode("Sound", "icon16/table.png") @@ -241,8 +241,8 @@ local function GenerateInfoTree(strfile, backnode, count) node.SubData = tabsound node.BackNode = mainnode node.Expander.DoClick = function(self) - if (!IsValid(SoundInfoTree)) then return end - if (!IsValid(node)) then return end + if not IsValid(SoundInfoTree) then return end + if not IsValid(node) then return end node:SetExpanded(false) SoundInfoTree:SetSelectedItem(node) @@ -251,111 +251,111 @@ local function GenerateInfoTree(strfile, backnode, count) end end - if (IsValid(backnode)) then + if IsValid(backnode) then return end - if (IsValid(SoundInfoTreeRoot)) then + if IsValid(SoundInfoTreeRoot) then SoundInfoTreeRoot:SetExpanded(true) end end -// Set the volume of the sound. +-- Set the volume of the sound. local function SetSoundVolume(volume) - if(!SoundObj) then return end + if not SoundObj then return end SoundObj:ChangeVolume(tonumber(volume) or 1, 0.1) end -// Set the pitch of the sound. +-- Set the pitch of the sound. local function SetSoundPitch(pitch) - if(!SoundObj) then return end + if not SoundObj then return end SoundObj:ChangePitch(tonumber(pitch) or 100, 0.1) end -// Play the given sound, if no sound is given then mute a playing sound. +-- Play the given sound, if no sound is given then mute a playing sound. local function PlaySound(file, volume, pitch) - if(SoundObj) then + if SoundObj then SoundObj:Stop() SoundObj = nil end - if (!file or file == "") then return end + if not file or file == "" then return end local ply = LocalPlayer() - if (!IsValid(ply)) then return end + if not IsValid(ply) then return end util.PrecacheSound(file) SoundObj = CreateSound(ply, file) - if(SoundObj) then + if SoundObj then SoundObj:PlayEx(tonumber(volume) or 1, tonumber(pitch) or 100) end end -// Play the given sound without effects, if no sound is given then mute a playing sound. +-- Play the given sound without effects, if no sound is given then mute a playing sound. local function PlaySoundNoEffect(file) - if(SoundObjNoEffect) then + if SoundObjNoEffect then SoundObjNoEffect:Stop() SoundObjNoEffect = nil end - if (!file or file == "") then return end + if not file or file == "" then return end local ply = LocalPlayer() - if (!IsValid(ply)) then return end + if not IsValid(ply) then return end util.PrecacheSound(file) SoundObjNoEffect = CreateSound(ply, file) - if(SoundObjNoEffect) then + if SoundObjNoEffect then SoundObjNoEffect:PlayEx(1, 100) end end local function SetupSoundemitter(strSound) - // Setup the Soundemitter stool with the soundpath. + -- Setup the Soundemitter stool with the soundpath. RunConsoleCommand("wire_soundemitter_sound", strSound) - // Pull out the soundemitter stool after setup. + -- Pull out the soundemitter stool after setup. spawnmenu.ActivateTool("wire_soundemitter") end local function SetupClipboard(strSound) - // Copy the soundpath to Clipboard. + -- Copy the soundpath to Clipboard. SetClipboardText(strSound) end -local function Sendmenu(strSound, SoundEmitter, nSoundVolume, nSoundPitch) // Open a sending and setup menu on right click on a sound file. - if (!isstring(strSound)) then return end - if (strSound == "") then return end +local function Sendmenu(strSound, SoundEmitter, nSoundVolume, nSoundPitch) -- Open a sending and setup menu on right click on a sound file. + if not isstring(strSound) then return end + if strSound == "" then return end local Menu = DermaMenu() local MenuItem = nil - if (SoundEmitter) then + if SoundEmitter then - //Setup soundemitter + -- Setup soundemitter MenuItem = Menu:AddOption("Setup soundemitter", function() SetupSoundemitter(strSound) end) MenuItem:SetImage("icon16/sound.png") - //Setup soundemitter and close + -- Setup soundemitter and close MenuItem = Menu:AddOption("Setup soundemitter and close", function() SetupSoundemitter(strSound) SoundBrowserPanel:Close() end) MenuItem:SetImage("icon16/sound.png") - //Copy to clipboard + -- Copy to clipboard MenuItem = Menu:AddOption("Copy to clipboard", function() SetupClipboard(strSound) end) MenuItem:SetImage("icon16/page_paste.png") - //Copy to clipboard and close + -- Copy to clipboard and close MenuItem = Menu:AddOption("Copy to clipboard and close", function() SetupClipboard(strSound) SoundBrowserPanel:Close() @@ -364,26 +364,26 @@ local function Sendmenu(strSound, SoundEmitter, nSoundVolume, nSoundPitch) // Op else - //Copy to clipboard + -- Copy to clipboard MenuItem = Menu:AddOption("Copy to clipboard", function() SetupClipboard(strSound) end) MenuItem:SetImage("icon16/page_paste.png") - //Copy to clipboard and close + -- Copy to clipboard and close MenuItem = Menu:AddOption("Copy to clipboard and close", function() SetupClipboard(strSound) SoundBrowserPanel:Close() end) MenuItem:SetImage("icon16/page_paste.png") - //Setup soundemitter + -- Setup soundemitter MenuItem = Menu:AddOption("Setup soundemitter", function() SetupSoundemitter(strSound) end) MenuItem:SetImage("icon16/sound.png") - //Setup soundemitter and close + -- Setup soundemitter and close MenuItem = Menu:AddOption("Setup soundemitter and close", function() SetupSoundemitter(strSound) SoundBrowserPanel:Close() @@ -394,11 +394,11 @@ local function Sendmenu(strSound, SoundEmitter, nSoundVolume, nSoundPitch) // Op Menu:AddSpacer() - if (IsValid(TabFavourites)) then - // Add the soundpath to the favourites. - if (TabFavourites:ItemInList(strSound)) then + if IsValid(TabFavourites) then + -- Add the soundpath to the favourites. + if TabFavourites:ItemInList(strSound) then - //Remove from favourites + -- Remove from favourites MenuItem = Menu:AddOption("Remove from favourites", function() TabFavourites:RemoveItem(strSound) end) @@ -406,15 +406,15 @@ local function Sendmenu(strSound, SoundEmitter, nSoundVolume, nSoundPitch) // Op else - //Add to favourites + -- Add to favourites MenuItem = Menu:AddOption("Add to favourites", function() TabFavourites:AddItem(strSound, sound.GetProperties(strSound) and "property" or "file") end) MenuItem:SetImage("icon16/star.png") local max_item_count = TabFavourites:GetMaxItems() local count = TabFavourites.TabfileCount - if (count >= max_item_count) then - MenuItem:SetTextColor(Disabled_Gray) // custom disabling + if count >= max_item_count then + MenuItem:SetTextColor(Disabled_Gray) -- custom disabling MenuItem.DoClick = function() end MenuItem:SetToolTip("The favourites list is Full! It can't hold more than "..max_item_count.." items!") @@ -425,26 +425,26 @@ local function Sendmenu(strSound, SoundEmitter, nSoundVolume, nSoundPitch) // Op Menu:AddSpacer() - //Print to console + -- Print to console MenuItem = Menu:AddOption("Print to console", function() - // Print the soundpath in the Console/HUD. + -- Print the soundpath in the Console/HUD. local ply = LocalPlayer() - if (!IsValid(ply)) then return end + if not IsValid(ply) then return end ply:PrintMessage( HUD_PRINTTALK, strSound) end) MenuItem:SetImage("icon16/monitor_go.png") - //Print to Chat + -- Print to Chat MenuItem = Menu:AddOption("Print to Chat", function() - // Say the the soundpath. + -- Say the the soundpath. RunConsoleCommand("say", strSound) end) MenuItem:SetImage("icon16/group_go.png") local len = #strSound - if (len > max_char_chat_count) then - MenuItem:SetTextColor(Disabled_Gray) // custom disabling + if len > max_char_chat_count then + MenuItem:SetTextColor(Disabled_Gray) -- custom disabling MenuItem.DoClick = function() end MenuItem:SetToolTip("The filepath ("..len.." chars) is too long to print in chat. It should be shorter than "..max_char_chat_count.." chars!") @@ -452,14 +452,14 @@ local function Sendmenu(strSound, SoundEmitter, nSoundVolume, nSoundPitch) // Op Menu:AddSpacer() - //Play + -- Play MenuItem = Menu:AddOption("Play", function() PlaySound(strSound, nSoundVolume, nSoundPitch, strtype) PlaySoundNoEffect() end) MenuItem:SetImage("icon16/control_play.png") - //Play without effects + -- Play without effects MenuItem = Menu:AddOption("Play without effects", function() PlaySound() PlaySoundNoEffect(strSound, strtype) @@ -470,45 +470,45 @@ local function Sendmenu(strSound, SoundEmitter, nSoundVolume, nSoundPitch) // Op end local function Infomenu(parent, node, SoundEmitter, nSoundVolume, nSoundPitch) - if(!IsValid(node)) then return end - if(!node.IsDataNode) then return end + if not IsValid(node) then return end + if not node.IsDataNode then return end local strNodeName = node:GetText() local IsSoundNode = node.IsSoundNode - if(IsSoundNode) then + if IsSoundNode then Sendmenu(strNodeName, SoundEmitter, nSoundVolume, nSoundPitch) return end local Menu = DermaMenu() - //Copy to clipboard + -- Copy to clipboard MenuItem = Menu:AddOption("Copy to clipboard", function() SetupClipboard(strNodeName) end) MenuItem:SetImage("icon16/page_paste.png") - //Print to console + -- Print to console MenuItem = Menu:AddOption("Print to console", function() - // Print the soundpath in the Console/HUD. + -- Print the soundpath in the Console/HUD. local ply = LocalPlayer() - if (!IsValid(ply)) then return end + if not IsValid(ply) then return end ply:PrintMessage( HUD_PRINTTALK, strNodeName) end) MenuItem:SetImage("icon16/monitor_go.png") - //Print to Chat + -- Print to Chat MenuItem = Menu:AddOption("Print to Chat", function() - // Say the the soundpath. + -- Say the the soundpath. RunConsoleCommand("say", strNodeName) end) MenuItem:SetImage("icon16/group_go.png") local len = #strNodeName - if (len > max_char_chat_count) then - MenuItem:SetTextColor(Disabled_Gray) // custom disabling + if len > max_char_chat_count then + MenuItem:SetTextColor(Disabled_Gray) -- custom disabling MenuItem.DoClick = function() end MenuItem:SetToolTip("The filepath ("..len.." chars) is too long to print in chat. It should be shorter than "..max_char_chat_count.." chars!") @@ -517,27 +517,27 @@ local function Infomenu(parent, node, SoundEmitter, nSoundVolume, nSoundPitch) Menu:Open() end -// Save the file path. It should be cross session. -// It's used when opening the browser in the e2 editor. +-- Save the file path. It should be cross session. +-- It's used when opening the browser in the e2 editor. local function SaveFilePath(panel, file) - if (!IsValid(panel)) then return end - if (panel.Soundemitter) then return end + if not IsValid(panel) then return end + if panel.Soundemitter then return end panel:SetCookie("wire_soundfile", file) end -// Open the Sound Browser. +-- Open the Sound Browser. local function CreateSoundBrowser(path, se) local soundemitter = false - if (isstring(path) and path ~= "") then + if isstring(path) and path ~= "" then soundemitter = true - if (tonumber(se) ~= 1) then + if tonumber(se) ~= 1 then soundemitter = false end end - if (tonumber(se) == 1) then + if tonumber(se) == 1 then soundemitter = true end @@ -545,14 +545,14 @@ local function CreateSoundBrowser(path, se) local nSoundVolume = 1 local nSoundPitch = 100 - if(IsValid(SoundBrowserPanel)) then SoundBrowserPanel:Remove() end - if(IsValid(TabFileBrowser)) then TabFileBrowser:Remove() end - if(IsValid(TabSoundPropertyList)) then TabSoundPropertyList:Remove() end - if(IsValid(TabFavourites)) then TabFavourites:Remove() end - if(IsValid(SoundInfoTree)) then SoundInfoTree:Remove() end - if(IsValid(SoundInfoTreeRoot)) then SoundInfoTreeRoot:Remove() end + if IsValid(SoundBrowserPanel) then SoundBrowserPanel:Remove() end + if IsValid(TabFileBrowser) then TabFileBrowser:Remove() end + if IsValid(TabSoundPropertyList) then TabSoundPropertyList:Remove() end + if IsValid(TabFavourites) then TabFavourites:Remove() end + if IsValid(SoundInfoTree) then SoundInfoTree:Remove() end + if IsValid(SoundInfoTreeRoot) then SoundInfoTreeRoot:Remove() end - SoundBrowserPanel = vgui.Create("DFrame") // The main frame. + SoundBrowserPanel = vgui.Create("DFrame") -- The main frame. SoundBrowserPanel:SetPos(50,25) SoundBrowserPanel:SetSize(750, 500) @@ -564,11 +564,11 @@ local function CreateSoundBrowser(path, se) SoundBrowserPanel:SetTitle("Sound Browser") SoundBrowserPanel:SetVisible(false) SoundBrowserPanel:SetCookieName( "wire_sound_browser" ) - SoundBrowserPanel:GetParent():SetWorldClicker(true) // Allow the use of the toolgun while in menu. + SoundBrowserPanel:GetParent():SetWorldClicker(true) -- Allow the use of the toolgun while in menu. - TabFileBrowser = vgui.Create("wire_filebrowser") // The file tree browser. - TabSoundPropertyList = vgui.Create("wire_soundpropertylist") // The sound property browser. - TabFavourites = vgui.Create("wire_listeditor") // The favourites manager. + TabFileBrowser = vgui.Create("wire_filebrowser") -- The file tree browser. + TabSoundPropertyList = vgui.Create("wire_soundpropertylist") -- The sound property browser. + TabFavourites = vgui.Create("wire_listeditor") -- The favourites manager. TabFileBrowser:SetListSpeed(6) TabFileBrowser:SetMaxItemsPerPage(200) @@ -579,58 +579,58 @@ local function CreateSoundBrowser(path, se) TabFavourites:SetListSpeed(40) TabFavourites:SetMaxItems(512) - local BrowserTabs = vgui.Create("DPropertySheet") // The tabs. + local BrowserTabs = vgui.Create("DPropertySheet") -- The tabs. BrowserTabs:DockMargin(5, 5, 5, 5) BrowserTabs:AddSheet("File Browser", TabFileBrowser, "icon16/folder.png", false, false, "Browse your sound folder.") BrowserTabs:AddSheet("Sound Property Browser", TabSoundPropertyList, "icon16/table_gear.png", false, false, "Browse the sound properties.") BrowserTabs:AddSheet("Favourites", TabFavourites, "icon16/star.png", false, false, "View your favourites.") - SoundInfoTree = vgui.Create("DTree") // The info tree. + SoundInfoTree = vgui.Create("DTree") -- The info tree. SoundInfoTree:SetClickOnDragHover(false) local oldClicktime = CurTime() SoundInfoTree.DoClick = function( parent, node ) - if (!IsValid(parent)) then return end - if (!IsValid(node)) then return end + if not IsValid(parent) then return end + if not IsValid(node) then return end parent:SetSelectedItem(node) local Clicktime = CurTime() - if ((Clicktime - oldClicktime) > 0.3) then oldClicktime = Clicktime return end + if (Clicktime - oldClicktime) > 0.3 then oldClicktime = Clicktime return end oldClicktime = Clicktime - if (!node.IsSoundNode) then return end + if not node.IsSoundNode then return end local file = node:GetText() PlaySound(file, nSoundVolume, nSoundPitch) PlaySoundNoEffect() end SoundInfoTree.DoRightClick = function( parent, node ) - if (!IsValid(parent)) then return end - if (!IsValid(node)) then return end + if not IsValid(parent) then return end + if not IsValid(node) then return end parent:SetSelectedItem(node) Infomenu(parent, node, SoundEmitter, nSoundVolume, nSoundPitch) end SoundInfoTree.OnNodeSelected = function( parent, node ) - if (!IsValid(parent)) then return end - if (!IsValid(node)) then return end + if not IsValid(parent) then return end + if not IsValid(node) then return end local backnode = node.BackNode - if (!IsValid(node.BackNode)) then - node:SetExpanded(!node.m_bExpanded) + if not IsValid(node.BackNode) then + node:SetExpanded(not node.m_bExpanded) return end local tabsound = node.SubData - if (!tabsound) then - node:SetExpanded(!node.m_bExpanded) + if not tabsound then + node:SetExpanded(not node.m_bExpanded) return end node:SetExpanded(false) node:Remove() - if (istable(tabsound)) then + if istable(tabsound) then node = backnode:AddNode("Sounds", "icon16/table_multiple.png") for k, v in pairs(tabsound) do GenerateInfoTree(v, node, k) @@ -642,7 +642,7 @@ local function CreateSoundBrowser(path, se) node:SetExpanded(false) parent:SetSelectedItem(node) - node:SetExpanded(!node.m_bExpanded) + node:SetExpanded(not node.m_bExpanded) end local SplitPanel = SoundBrowserPanel:Add( "DHorizontalDivider" ) @@ -659,7 +659,7 @@ local function CreateSoundBrowser(path, se) TabFileBrowser:SetWildCard("GAME") TabFileBrowser:SetFileTyps({"*.mp3","*.wav"}) - //TabFileBrowser:AddColumns("Type", "Size", "Length") //getting the duration is very slow. + --TabFileBrowser:AddColumns("Type", "Size", "Length") -- getting the duration is very slow. local Columns = TabFileBrowser:AddColumns("Format", "Size") Columns[1]:SetFixedWidth(70) Columns[1]:SetWide(70) @@ -667,15 +667,15 @@ local function CreateSoundBrowser(path, se) Columns[2]:SetWide(70) TabFileBrowser.LineData = function(self, id, strfile, ...) - if (#strfile > max_char_count) then return nil, true end // skip and hide to long filenames. + if #strfile > max_char_count then return nil, true end -- skip and hide to long filenames. local nsize, strformat, nduration = GetFileInfos(strfile) - if (!nsize) then return end + if not nsize then return end local nsizeB, strsize = FormatSize(nsize, nduration) local nduration, strduration = FormatLength(nduration, nsize) - //return {strformat, strsize or "n/a", strduration or "n/a"} //getting the duration is very slow. + --return {strformat, strsize or "n/a", strduration or "n/a"} -- getting the duration is very slow. return {strformat, strsize or "n/a"} end @@ -734,7 +734,7 @@ local function CreateSoundBrowser(path, se) TabFavourites:SetRootPath("soundlists") TabFavourites.DoClick = function(parent, item, data) - if(file.Exists("sound/"..item, "GAME")) then + if file.Exists("sound/"..item, "GAME") then TabFileBrowser:SetOpenFile(item) end @@ -743,7 +743,7 @@ local function CreateSoundBrowser(path, se) end TabFavourites.DoDoubleClick = function(parent, item, data) - if(file.Exists("sound/"..item, "GAME")) then + if file.Exists("sound/"..item, "GAME") then TabFileBrowser:SetOpenFile(item) end @@ -753,7 +753,7 @@ local function CreateSoundBrowser(path, se) end TabFavourites.DoRightClick = function(parent, item, data) - if(file.Exists("sound/"..item, "GAME")) then + if file.Exists("sound/"..item, "GAME") then TabFileBrowser:SetOpenFile(item) end @@ -762,25 +762,25 @@ local function CreateSoundBrowser(path, se) GenerateInfoTree(item) end - local ControlPanel = SoundBrowserPanel:Add("DPanel") // The bottom part of the frame. + local ControlPanel = SoundBrowserPanel:Add("DPanel") -- The bottom part of the frame. ControlPanel:DockMargin(0, 5, 0, 0) ControlPanel:Dock(BOTTOM) ControlPanel:SetTall(60) ControlPanel:SetDrawBackground(false) - local ButtonsPanel = ControlPanel:Add("DPanel") // The buttons. + local ButtonsPanel = ControlPanel:Add("DPanel") -- The buttons. ButtonsPanel:DockMargin(4, 0, 0, 0) ButtonsPanel:Dock(RIGHT) ButtonsPanel:SetWide(250) ButtonsPanel:SetDrawBackground(false) - local TunePanel = ControlPanel:Add("DPanel") // The effect Sliders. + local TunePanel = ControlPanel:Add("DPanel") -- The effect Sliders. TunePanel:DockMargin(0, 4, 0, 0) TunePanel:Dock(LEFT) TunePanel:SetWide(350) TunePanel:SetDrawBackground(false) - local TuneVolumeSlider = TunePanel:Add("DNumSlider") // The volume slider. + local TuneVolumeSlider = TunePanel:Add("DNumSlider") -- The volume slider. TuneVolumeSlider:DockMargin(2, 0, 0, 0) TuneVolumeSlider:Dock(TOP) TuneVolumeSlider:SetText("Volume") @@ -793,7 +793,7 @@ local function CreateSoundBrowser(path, se) SetSoundVolume(nSoundVolume) end - local TunePitchSlider = TunePanel:Add("DNumSlider") // The pitch slider. + local TunePitchSlider = TunePanel:Add("DNumSlider") -- The pitch slider. TunePitchSlider:DockMargin(2, 0, 0, 0) TunePitchSlider:Dock(BOTTOM) TunePitchSlider:SetText("Pitch") @@ -806,12 +806,12 @@ local function CreateSoundBrowser(path, se) SetSoundPitch(nSoundPitch) end - local PlayStopPanel = ButtonsPanel:Add("DPanel") // Play and stop. + local PlayStopPanel = ButtonsPanel:Add("DPanel") -- Play and stop. PlayStopPanel:DockMargin(0, 0, 0, 2) PlayStopPanel:Dock(TOP) PlayStopPanel:SetDrawBackground(false) - local PlayButton = PlayStopPanel:Add("DButton") // The play button. + local PlayButton = PlayStopPanel:Add("DButton") -- The play button. PlayButton:SetText("Play") PlayButton:Dock(LEFT) PlayButton:SetWide(PlayStopPanel:GetWide() / 2 - 2) @@ -820,16 +820,16 @@ local function CreateSoundBrowser(path, se) PlaySoundNoEffect() end - local StopButton = PlayStopPanel:Add("DButton") // The stop button. + local StopButton = PlayStopPanel:Add("DButton") -- The stop button. StopButton:SetText("Stop") StopButton:Dock(RIGHT) StopButton:SetWide(PlayButton:GetWide()) StopButton.DoClick = function() - PlaySound() // Mute a playing sound by not giving a sound. + PlaySound() -- Mute a playing sound by not giving a sound. PlaySoundNoEffect() end - local SoundemitterButton = ButtonsPanel:Add("DButton") // The soundemitter button. Hidden in e2 mode. + local SoundemitterButton = ButtonsPanel:Add("DButton") -- The soundemitter button. Hidden in e2 mode. SoundemitterButton:SetText("Send to soundemitter") SoundemitterButton:DockMargin(0, 2, 0, 0) SoundemitterButton:Dock(FILL) @@ -838,7 +838,7 @@ local function CreateSoundBrowser(path, se) SetupSoundemitter(strSound) end - local ClipboardButton = ButtonsPanel:Add("DButton") // The soundemitter button. Hidden in soundemitter mode. + local ClipboardButton = ButtonsPanel:Add("DButton") -- The soundemitter button. Hidden in soundemitter mode. ClipboardButton:SetText("Copy to clipboard") ClipboardButton:DockMargin(0, 2, 0, 0) ClipboardButton:Dock(FILL) @@ -850,18 +850,18 @@ local function CreateSoundBrowser(path, se) local oldw, oldh = SoundBrowserPanel:GetSize() SoundBrowserPanel.PerformLayout = function(self, ...) SoundemitterButton:SetVisible(self.Soundemitter) - ClipboardButton:SetVisible(!self.Soundemitter) + ClipboardButton:SetVisible(not self.Soundemitter) local w = self:GetWide() local rightw = SplitPanel:GetLeftWidth() + w - oldw - if (rightw < SplitPanel:GetLeftMin()) then + if rightw < SplitPanel:GetLeftMin() then rightw = SplitPanel:GetLeftMin() end SplitPanel:SetLeftWidth(rightw) local minw = w - SplitPanel:GetRightMin() + SplitPanel:GetDividerWidth() - if (SplitPanel:GetLeftWidth() > minw) then + if SplitPanel:GetLeftWidth() > minw then SplitPanel:SetLeftWidth(minw) end @@ -869,7 +869,7 @@ local function CreateSoundBrowser(path, se) PlayButton:SetWide(PlayStopPanel:GetWide() / 2 - 2) StopButton:SetWide(PlayButton:GetWide()) - if (self.Soundemitter) then + if self.Soundemitter then SoundemitterButton:SetTall(PlayStopPanel:GetTall() - 2) else ClipboardButton:SetTall(PlayStopPanel:GetTall() - 2) @@ -880,7 +880,7 @@ local function CreateSoundBrowser(path, se) DFrame.PerformLayout(self, ...) end - SoundBrowserPanel.OnClose = function() // Set effects back and mute when closing. + SoundBrowserPanel.OnClose = function() -- Set effects back and mute when closing. nSoundVolume = 1 nSoundPitch = 100 TuneVolumeSlider:SetValue(nSoundVolume * 100) @@ -892,12 +892,12 @@ local function CreateSoundBrowser(path, se) SoundBrowserPanel:InvalidateLayout(true) end -// Open the Sound Browser. +-- Open the Sound Browser. local function OpenSoundBrowser(pl, cmd, args) - local path = args[1] // nil or "" will put the browser in e2 mode else the soundemitter mode is applied. + local path = args[1] -- nil or "" will put the browser in e2 mode else the soundemitter mode is applied. local se = args[2] - if (!IsValid(SoundBrowserPanel)) then + if not IsValid(SoundBrowserPanel) then CreateSoundBrowser(path, se) end @@ -905,36 +905,36 @@ local function OpenSoundBrowser(pl, cmd, args) SoundBrowserPanel:MakePopup() SoundBrowserPanel:InvalidateLayout(true) - if (!IsValid(TabFileBrowser)) then return end + if not IsValid(TabFileBrowser) then return end - //Replaces the timer, doesn't get paused in singleplayer. + -- Replaces the timer, doesn't get paused in singleplayer. WireLib.Timedcall(function(SoundBrowserPanel, TabFileBrowser, path, se) - if (!IsValid(SoundBrowserPanel)) then return end - if (!IsValid(TabFileBrowser)) then return end + if not IsValid(SoundBrowserPanel) then return end + if not IsValid(TabFileBrowser) then return end local soundemitter = false - if (isstring(path) and path ~= "") then + if isstring(path) and path ~= "" then soundemitter = true end local soundemitter = false - if (isstring(path) and path ~= "") then + if isstring(path) and path ~= "" then soundemitter = true - if (tonumber(se) ~= 1) then + if tonumber(se) ~= 1 then soundemitter = false end end - if (tonumber(se) == 1) then + if tonumber(se) == 1 then soundemitter = true end SoundBrowserPanel.Soundemitter = soundemitter SoundBrowserPanel:InvalidateLayout(true) - if (!soundemitter) then - path = SoundBrowserPanel:GetCookie("wire_soundfile", "") // load last session + if not soundemitter then + path = SoundBrowserPanel:GetCookie("wire_soundfile", "") -- load last session end TabFileBrowser:SetOpenFile(path) end, SoundBrowserPanel, TabFileBrowser, path, se) From a48b06f86d9bbc68c6b73df92138b973fb9e9cc3 Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Mon, 28 Nov 2016 11:25:50 +0100 Subject: [PATCH 10/56] Update .luacheckrc and add a script to regenerate it from the wiki --- .luacheckrc | 3430 +++++++++++++++++++++++++++++++++++++++++- generate-luacheck.sh | 119 ++ 2 files changed, 3548 insertions(+), 1 deletion(-) create mode 100755 generate-luacheck.sh diff --git a/.luacheckrc b/.luacheckrc index c753c5bc1a..a892839c7d 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -3,7 +3,3435 @@ -- string values with integer keys mean read-only globals stds.garrysmod = { - "AddCSLuaFiles", + -- BEGIN_GENERATED_CODE + + -- Hooks + "EFFECT", + "ENT", + "ENTITY", + "ENT_AI", + "ENT_ANIM", + "ENT_BRUSH", + "ENT_FILTER", + "ENT_NEXTBOT", + "ENT_POINT", + "GM", + "PANEL", + "PLAYER", + "SANDBOX", + "SWEP", + "TOOL", + + -- Libraries + "GWEN", + "achievements", + "ai", + "ai_schedule", + "ai_task", + "baseclass", + "bit", + "cam", + "chat", + "cleanup", + "concommand", + "constraint", + "construct", + "controlpanel", + "cookie", + "coroutine", + "cvars", + "debug", + "debugoverlay", + "derma", + "dragndrop", + "draw", + "drive", + "duplicator", + "effects", + "engine", + "ents", + "file", + "frame_blend", + "game", + "gameevent", + "gamemode", + "gmod", + "gmsave", + "gui", + "halo", + "hammer", + "hook", + "http", + "input", + "jit", + "killicon", + "language", + "list", + "markup", + "math", + "matproxy", + "menu", + "menubar", + "mesh", + "motionsensor", + "navmesh", + "net", + "notification", + "numpad", + "os", + "package", + "physenv", + "player", + "player_manager", + "presets", + "properties", + "render", + "resource", + "saverestore", + "scripted_ents", + "search", + "serverlist", + "sound", + "spawnmenu", + "sql", + "steamworks", + "string", + "surface", + "system", + "table", + "team", + "timer", + "umsg", + "undo", + "usermessage", + "utf8", + "util", + "vgui", + "video", + "weapons", + "widgets", + + -- Global + "AccessorFunc", + "Add_NPC_Class", + "AddBackgroundImage", + "AddConsoleCommand", + "AddCSLuaFile", + "AddonMaterial", + "AddOriginToPVS", + "AddWorldTip", + "Angle", + "AngleRand", + "assert", + "BroadcastLua", + "BuildNetworkedVarsTable", + "CancelLoading", + "ChangeBackground", + "ChangeTooltip", + "ClearBackgroundImages", + "ClientsideModel", + "ClientsideRagdoll", + "ClientsideScene", + "CloseDermaMenus", + "collectgarbage", + "Color", + "ColorAlpha", + "ColorRand", + "ColorToHSV", + "CompileFile", + "CompileString", + "ConsoleAutoComplete", + "ConVarExists", + "CreateClientConVar", + "CreateConVar", + "CreateMaterial", + "CreateParticleSystem", + "CreateSound", + "CreateSprite", + "CurTime", + "DamageInfo", + "DebugInfo", + "DeriveGamemode", + "Derma_Anim", + "Derma_DrawBackgroundBlur", + "Derma_Hook", + "Derma_Install_Convar_Functions", + "Derma_Message", + "Derma_Query", + "Derma_StringRequest", + "DermaMenu", + "DisableClipping", + "DOF_Kill", + "DOF_Start", + "DOFModeHack", + "DrawBackground", + "DrawBloom", + "DrawColorModify", + "DrawMaterialOverlay", + "DrawMotionBlur", + "DrawSharpen", + "DrawSobel", + "DrawSunbeams", + "DrawTexturize", + "DrawToyTown", + "DropEntityIfHeld", + "DynamicLight", + "EffectData", + "Either", + "EmitSentence", + "EmitSound", + "EndTooltip", + "Entity", + "Error", + "error", + "ErrorNoHalt", + "EyeAngles", + "EyePos", + "EyeVector", + "FindMetaTable", + "FindTooltip", + "Format", + "FrameNumber", + "FrameTime", + "GameDetails", + "gcinfo", + "GetConVar", + "GetConVarNumber", + "GetConVarString", + "GetDefaultLoadingHTML", + "GetDemoFileDetails", + "GetDownloadables", + "getfenv", + "GetGlobalAngle", + "GetGlobalBool", + "GetGlobalEntity", + "GetGlobalFloat", + "GetGlobalInt", + "GetGlobalString", + "GetGlobalVector", + "GetHostName", + "GetHUDPanel", + "GetLoadPanel", + "GetLoadStatus", + "getmetatable", + "GetOverlayPanel", + "GetRenderTarget", + "GetRenderTargetEx", + "GetSaveFileDetails", + "GetViewEntity", + "HSVToColor", + "HTTP", + "include", + "IncludeCS", + "ipairs", + "isangle", + "isbool", + "IsColor", + "IsEnemyEntityName", + "IsEntity", + "isentity", + "IsFirstTimePredicted", + "IsFriendEntityName", + "isfunction", + "IsInGame", + "ismatrix", + "IsMounted", + "isnumber", + "ispanel", + "isstring", + "istable", + "IsTableOfEntitiesValid", + "IsUselessModel", + "IsValid", + "isvector", + "JoinServer", + "JS_Language", + "JS_Utility", + "JS_Workshop", + "Label", + "LanguageChanged", + "Lerp", + "LerpAngle", + "LerpVector", + "LoadLastMap", + "LoadPresets", + "Localize", + "LocalPlayer", + "LocalToWorld", + "Material", + "Matrix", + "Mesh", + "Model", + "module", + "Msg", + "MsgAll", + "MsgC", + "MsgN", + "NamedColor", + "newproxy", + "next", + "NumDownloadables", + "NumModelSkins", + "OnModelLoaded", + "OpenFolder", + "OrderVectors", + "pairs", + "Particle", + "ParticleEffect", + "ParticleEffectAttach", + "ParticleEmitter", + "Path", + "pcall", + "Player", + "PositionSpawnIcon", + "PrecacheParticleSystem", + "PrecacheScene", + "PrecacheSentenceFile", + "PrecacheSentenceGroup", + "print", + "PrintMessage", + "PrintTable", + "ProjectedTexture", + "ProtectedCall", + "RandomPairs", + "rawequal", + "rawget", + "rawset", + "RealFrameTime", + "RealTime", + "RecipientFilter", + "RecordDemoFrame", + "RegisterDermaMenuForClose", + "RememberCursorPosition", + "RemoveTooltip", + "RenderAngles", + "RenderDoF", + "RenderStereoscopy", + "RenderSuperDoF", + "require", + "RestoreCursorPosition", + "RunConsoleCommand", + "RunGameUICommand", + "RunString", + "RunStringEx", + "SafeRemoveEntity", + "SafeRemoveEntityDelayed", + "SaveLastMap", + "SavePresets", + "ScreenScale", + "ScrH", + "ScrW", + "select", + "SendUserMessage", + "ServerLog", + "SetClipboardText", + "setfenv", + "SetGlobalAngle", + "SetGlobalBool", + "SetGlobalEntity", + "SetGlobalFloat", + "SetGlobalInt", + "SetGlobalString", + "SetGlobalVector", + "setmetatable", + "SetPhysConstraintSystem", + "SortedPairs", + "SortedPairsByMemberValue", + "SortedPairsByValue", + "Sound", + "SoundDuration", + "SQLStr", + "SScale", + "STNDRD", + "SuppressHostEvents", + "SysTime", + "TauntCamera", + "TextEntryLoseFocus", + "TimedCos", + "TimedSin", + "tobool", + "ToggleFavourite", + "tonumber", + "tostring", + "TranslateDownloadableName", + "type", + "TypeID", + "unpack", + "UnPredictedCurTime", + "UpdateLoadPanel", + "UpdateRenderTarget", + "UTIL_IsUselessModel", + "ValidPanel", + "Vector", + "VectorRand", + "VGUIFrameTime", + "VGUIRect", + "VisualizeLayout", + "WorkshopFileBase", + "WorldToLocal", + "xpcall", + + -- Classes + "Angle", + "CEffectData", + "CLuaEmitter", + "CLuaLocomotion", + "CLuaParticle", + "CMoveData", + "CNavArea", + "CNavLadder", + "CNewParticleEffect", + "CRecipientFilter", + "CSEnt", + "CSoundPatch", + "CTakeDamageInfo", + "CUserCmd", + "ConVar", + "Entity", + "File", + "IGModAudioChannel", + "IMaterial", + "IMesh", + "IRestore", + "ISave", + "ITexture", + "IVideoWriter", + "MarkupObject", + "NPC", + "NextBot", + "Panel", + "PathFollower", + "PhysObj", + "Player", + "ProjectedTexture", + "Schedule", + "Stack", + "TOOL", + "Task", + "VMatrix", + "Vector", + "Vehicle", + "Weapon", + "bf_read", + + -- Panels + "AchievementIcon", + "AvatarImage", + "Awesomium", + "Button", + "CheckButton", + "ContentIcon", + "ContextBase", + "ControlPanel", + "ControlPresets", + "CtrlListBox", + "DAdjustableModelPanel", + "DAlphaBar", + "DBinder", + "DBubbleContainer", + "DButton", + "DCategoryList", + "DCheckBox", + "DCheckBoxLabel", + "DCollapsibleCategory", + "DColorButton", + "DColorCombo", + "DColorCube", + "DColorMixer", + "DColorPalette", + "DColumnSheet", + "DComboBox", + "DDragBase", + "DDrawer", + "DEntityProperties", + "DExpandButton", + "DFileBrowser", + "DForm", + "DFrame", + "DGrid", + "DHTML", + "DHTMLControls", + "DHorizontalDivider", + "DHorizontalScroller", + "DIconBrowser", + "DIconLayout", + "DImage", + "DImageButton", + "DKillIcon", + "DLabel", + "DLabelEditable", + "DLabelURL", + "DListBox", + "DListBoxItem", + "DListLayout", + "DListView", + "DListViewHeaderLabel", + "DListViewLabel", + "DListViewLine", + "DListView_Column", + "DListView_ColumnPlain", + "DListView_DraggerBar", + "DListView_Line", + "DMenu", + "DMenuBar", + "DMenuOption", + "DMenuOptionCVar", + "DModelPanel", + "DModelSelect", + "DModelSelectMulti", + "DNotify", + "DNumPad", + "DNumSlider", + "DNumberScratch", + "DNumberWang", + "DPanel", + "DPanelList", + "DPanelOverlay", + "DPanelSelect", + "DProgress", + "DProperties", + "DPropertySheet", + "DProperty_Boolean", + "DProperty_Combo", + "DProperty_Float", + "DProperty_Generic", + "DProperty_Int", + "DProperty_VectorColor", + "DRGBPicker", + "DScrollBarGrip", + "DScrollPanel", + "DShape", + "DSizeToContents", + "DSlider", + "DSprite", + "DTab", + "DTextEntry", + "DTileLayout", + "DTooltip", + "DTree", + "DTree_Node", + "DTree_Node_Button", + "DVScrollBar", + "DVerticalDivider", + "EditablePanel", + "FingerVar", + "Frame", + "HTML", + "IconEditor", + "ImageCheckBox", + "Label", + "MatSelect", + "Material", + "ModelImage", + "Panel", + "PanelList", + "PresetEditor", + "PropSelect", + "RadioButton", + "RichText", + "SlideBar", + "Slider", + "SpawnIcon", + "TGAImage", + "TextEntry", + "URLLabel", + "fingerposer", + + -- Enumerations + --- ACT + "ACT_INVALID", + "ACT_RESET", + "ACT_IDLE", + "ACT_TRANSITION", + "ACT_COVER", + "ACT_COVER_MED", + "ACT_COVER_LOW", + "ACT_WALK", + "ACT_WALK_AIM", + "ACT_WALK_CROUCH", + "ACT_WALK_CROUCH_AIM", + "ACT_RUN", + "ACT_RUN_AIM", + "ACT_RUN_CROUCH", + "ACT_RUN_CROUCH_AIM", + "ACT_RUN_PROTECTED", + "ACT_SCRIPT_CUSTOM_MOVE", + "ACT_RANGE_ATTACK1", + "ACT_RANGE_ATTACK2", + "ACT_RANGE_ATTACK1_LOW", + "ACT_RANGE_ATTACK2_LOW", + "ACT_DIESIMPLE", + "ACT_DIEBACKWARD", + "ACT_DIEFORWARD", + "ACT_DIEVIOLENT", + "ACT_DIERAGDOLL", + "ACT_FLY", + "ACT_HOVER", + "ACT_GLIDE", + "ACT_SWIM", + "ACT_SWIM_IDLE", + "ACT_JUMP", + "ACT_HOP", + "ACT_LEAP", + "ACT_LAND", + "ACT_CLIMB_UP", + "ACT_CLIMB_DOWN", + "ACT_CLIMB_DISMOUNT", + "ACT_SHIPLADDER_UP", + "ACT_SHIPLADDER_DOWN", + "ACT_STRAFE_LEFT", + "ACT_STRAFE_RIGHT", + "ACT_ROLL_LEFT", + "ACT_ROLL_RIGHT", + "ACT_TURN_LEFT", + "ACT_TURN_RIGHT", + "ACT_CROUCH", + "ACT_CROUCHIDLE", + "ACT_STAND", + "ACT_USE", + "ACT_SIGNAL1", + "ACT_SIGNAL2", + "ACT_SIGNAL3", + "ACT_SIGNAL_ADVANCE", + "ACT_SIGNAL_FORWARD", + "ACT_SIGNAL_GROUP", + "ACT_SIGNAL_HALT", + "ACT_SIGNAL_LEFT", + "ACT_SIGNAL_RIGHT", + "ACT_SIGNAL_TAKECOVER", + "ACT_LOOKBACK_RIGHT", + "ACT_LOOKBACK_LEFT", + "ACT_COWER", + "ACT_SMALL_FLINCH", + "ACT_BIG_FLINCH", + "ACT_MELEE_ATTACK1", + "ACT_MELEE_ATTACK2", + "ACT_RELOAD", + "ACT_RELOAD_START", + "ACT_RELOAD_FINISH", + "ACT_RELOAD_LOW", + "ACT_ARM", + "ACT_DISARM", + "ACT_DROP_WEAPON", + "ACT_DROP_WEAPON_SHOTGUN", + "ACT_PICKUP_GROUND", + "ACT_PICKUP_RACK", + "ACT_IDLE_ANGRY", + "ACT_IDLE_RELAXED", + "ACT_IDLE_STIMULATED", + "ACT_IDLE_AGITATED", + "ACT_IDLE_STEALTH", + "ACT_IDLE_HURT", + "ACT_WALK_RELAXED", + "ACT_WALK_STIMULATED", + "ACT_WALK_AGITATED", + "ACT_WALK_STEALTH", + "ACT_RUN_RELAXED", + "ACT_RUN_STIMULATED", + "ACT_RUN_AGITATED", + "ACT_RUN_STEALTH", + "ACT_IDLE_AIM_RELAXED", + "ACT_IDLE_AIM_STIMULATED", + "ACT_IDLE_AIM_AGITATED", + "ACT_IDLE_AIM_STEALTH", + "ACT_WALK_AIM_RELAXED", + "ACT_WALK_AIM_STIMULATED", + "ACT_WALK_AIM_AGITATED", + "ACT_WALK_AIM_STEALTH", + "ACT_RUN_AIM_RELAXED", + "ACT_RUN_AIM_STIMULATED", + "ACT_RUN_AIM_AGITATED", + "ACT_RUN_AIM_STEALTH", + "ACT_CROUCHIDLE_STIMULATED", + "ACT_CROUCHIDLE_AIM_STIMULATED", + "ACT_CROUCHIDLE_AGITATED", + "ACT_WALK_HURT", + "ACT_RUN_HURT", + "ACT_SPECIAL_ATTACK1", + "ACT_SPECIAL_ATTACK2", + "ACT_COMBAT_IDLE", + "ACT_WALK_SCARED", + "ACT_RUN_SCARED", + "ACT_VICTORY_DANCE", + "ACT_DIE_HEADSHOT", + "ACT_DIE_CHESTSHOT", + "ACT_DIE_GUTSHOT", + "ACT_DIE_BACKSHOT", + "ACT_FLINCH_HEAD", + "ACT_FLINCH_CHEST", + "ACT_FLINCH_STOMACH", + "ACT_FLINCH_LEFTARM", + "ACT_FLINCH_RIGHTARM", + "ACT_FLINCH_LEFTLEG", + "ACT_FLINCH_RIGHTLEG", + "ACT_FLINCH_PHYSICS", + "ACT_IDLE_ON_FIRE", + "ACT_WALK_ON_FIRE", + "ACT_RUN_ON_FIRE", + "ACT_RAPPEL_LOOP", + "ACT_180_LEFT", + "ACT_180_RIGHT", + "ACT_90_LEFT", + "ACT_90_RIGHT", + "ACT_STEP_LEFT", + "ACT_STEP_RIGHT", + "ACT_STEP_BACK", + "ACT_STEP_FORE", + "ACT_GESTURE_RANGE_ATTACK1", + "ACT_GESTURE_RANGE_ATTACK2", + "ACT_GESTURE_MELEE_ATTACK1", + "ACT_GESTURE_MELEE_ATTACK2", + "ACT_GESTURE_RANGE_ATTACK1_LOW", + "ACT_GESTURE_RANGE_ATTACK2_LOW", + "ACT_MELEE_ATTACK_SWING_GESTURE", + "ACT_GESTURE_SMALL_FLINCH", + "ACT_GESTURE_BIG_FLINCH", + "ACT_GESTURE_FLINCH_BLAST", + "ACT_GESTURE_FLINCH_BLAST_SHOTGUN", + "ACT_GESTURE_FLINCH_BLAST_DAMAGED", + "ACT_GESTURE_FLINCH_BLAST_DAMAGED_SHOTGUN", + "ACT_GESTURE_FLINCH_HEAD", + "ACT_GESTURE_FLINCH_CHEST", + "ACT_GESTURE_FLINCH_STOMACH", + "ACT_GESTURE_FLINCH_LEFTARM", + "ACT_GESTURE_FLINCH_RIGHTARM", + "ACT_GESTURE_FLINCH_LEFTLEG", + "ACT_GESTURE_FLINCH_RIGHTLEG", + "ACT_GESTURE_TURN_LEFT", + "ACT_GESTURE_TURN_RIGHT", + "ACT_GESTURE_TURN_LEFT45", + "ACT_GESTURE_TURN_RIGHT45", + "ACT_GESTURE_TURN_LEFT90", + "ACT_GESTURE_TURN_RIGHT90", + "ACT_GESTURE_TURN_LEFT45_FLAT", + "ACT_GESTURE_TURN_RIGHT45_FLAT", + "ACT_GESTURE_TURN_LEFT90_FLAT", + "ACT_GESTURE_TURN_RIGHT90_FLAT", + "ACT_BARNACLE_HIT", + "ACT_BARNACLE_PULL", + "ACT_BARNACLE_CHOMP", + "ACT_BARNACLE_CHEW", + "ACT_DO_NOT_DISTURB", + "ACT_VM_DRAW", + "ACT_VM_HOLSTER", + "ACT_VM_IDLE", + "ACT_VM_FIDGET", + "ACT_VM_PULLBACK", + "ACT_VM_PULLBACK_HIGH", + "ACT_VM_PULLBACK_LOW", + "ACT_VM_THROW", + "ACT_VM_PULLPIN", + "ACT_VM_PRIMARYATTACK", + "ACT_VM_SECONDARYATTACK", + "ACT_VM_RELOAD", + "ACT_VM_DRYFIRE", + "ACT_VM_HITLEFT", + "ACT_VM_HITLEFT2", + "ACT_VM_HITRIGHT", + "ACT_VM_HITRIGHT2", + "ACT_VM_HITCENTER", + "ACT_VM_HITCENTER2", + "ACT_VM_MISSLEFT", + "ACT_VM_MISSLEFT2", + "ACT_VM_MISSRIGHT", + "ACT_VM_MISSRIGHT2", + "ACT_VM_MISSCENTER", + "ACT_VM_MISSCENTER2", + "ACT_VM_HAULBACK", + "ACT_VM_SWINGHARD", + "ACT_VM_SWINGMISS", + "ACT_VM_SWINGHIT", + "ACT_VM_IDLE_TO_LOWERED", + "ACT_VM_IDLE_LOWERED", + "ACT_VM_LOWERED_TO_IDLE", + "ACT_VM_RECOIL1", + "ACT_VM_RECOIL2", + "ACT_VM_RECOIL3", + "ACT_VM_PICKUP", + "ACT_VM_RELEASE", + "ACT_VM_ATTACH_SILENCER", + "ACT_VM_DETACH_SILENCER", + "ACT_SLAM_STICKWALL_IDLE", + "ACT_SLAM_STICKWALL_ND_IDLE", + "ACT_SLAM_STICKWALL_ATTACH", + "ACT_SLAM_STICKWALL_ATTACH2", + "ACT_SLAM_STICKWALL_ND_ATTACH", + "ACT_SLAM_STICKWALL_ND_ATTACH2", + "ACT_SLAM_STICKWALL_DETONATE", + "ACT_SLAM_STICKWALL_DETONATOR_HOLSTER", + "ACT_SLAM_STICKWALL_DRAW", + "ACT_SLAM_STICKWALL_ND_DRAW", + "ACT_SLAM_STICKWALL_TO_THROW", + "ACT_SLAM_STICKWALL_TO_THROW_ND", + "ACT_SLAM_STICKWALL_TO_TRIPMINE_ND", + "ACT_SLAM_THROW_IDLE", + "ACT_SLAM_THROW_ND_IDLE", + "ACT_SLAM_THROW_THROW", + "ACT_SLAM_THROW_THROW2", + "ACT_SLAM_THROW_THROW_ND", + "ACT_SLAM_THROW_THROW_ND2", + "ACT_SLAM_THROW_DRAW", + "ACT_SLAM_THROW_ND_DRAW", + "ACT_SLAM_THROW_TO_STICKWALL", + "ACT_SLAM_THROW_TO_STICKWALL_ND", + "ACT_SLAM_THROW_DETONATE", + "ACT_SLAM_THROW_DETONATOR_HOLSTER", + "ACT_SLAM_THROW_TO_TRIPMINE_ND", + "ACT_SLAM_TRIPMINE_IDLE", + "ACT_SLAM_TRIPMINE_DRAW", + "ACT_SLAM_TRIPMINE_ATTACH", + "ACT_SLAM_TRIPMINE_ATTACH2", + "ACT_SLAM_TRIPMINE_TO_STICKWALL_ND", + "ACT_SLAM_TRIPMINE_TO_THROW_ND", + "ACT_SLAM_DETONATOR_IDLE", + "ACT_SLAM_DETONATOR_DRAW", + "ACT_SLAM_DETONATOR_DETONATE", + "ACT_SLAM_DETONATOR_HOLSTER", + "ACT_SLAM_DETONATOR_STICKWALL_DRAW", + "ACT_SLAM_DETONATOR_THROW_DRAW", + "ACT_SHOTGUN_RELOAD_START", + "ACT_SHOTGUN_RELOAD_FINISH", + "ACT_SHOTGUN_PUMP", + "ACT_SMG2_IDLE2", + "ACT_SMG2_FIRE2", + "ACT_SMG2_DRAW2", + "ACT_SMG2_RELOAD2", + "ACT_SMG2_DRYFIRE2", + "ACT_SMG2_TOAUTO", + "ACT_SMG2_TOBURST", + "ACT_PHYSCANNON_UPGRADE", + "ACT_RANGE_ATTACK_AR1", + "ACT_RANGE_ATTACK_AR2", + "ACT_RANGE_ATTACK_AR2_LOW", + "ACT_RANGE_ATTACK_AR2_GRENADE", + "ACT_RANGE_ATTACK_HMG1", + "ACT_RANGE_ATTACK_ML", + "ACT_RANGE_ATTACK_SMG1", + "ACT_RANGE_ATTACK_SMG1_LOW", + "ACT_RANGE_ATTACK_SMG2", + "ACT_RANGE_ATTACK_SHOTGUN", + "ACT_RANGE_ATTACK_SHOTGUN_LOW", + "ACT_RANGE_ATTACK_PISTOL", + "ACT_RANGE_ATTACK_PISTOL_LOW", + "ACT_RANGE_ATTACK_SLAM", + "ACT_RANGE_ATTACK_TRIPWIRE", + "ACT_RANGE_ATTACK_THROW", + "ACT_RANGE_ATTACK_SNIPER_RIFLE", + "ACT_RANGE_ATTACK_RPG", + "ACT_MELEE_ATTACK_SWING", + "ACT_RANGE_AIM_LOW", + "ACT_RANGE_AIM_SMG1_LOW", + "ACT_RANGE_AIM_PISTOL_LOW", + "ACT_RANGE_AIM_AR2_LOW", + "ACT_COVER_PISTOL_LOW", + "ACT_COVER_SMG1_LOW", + "ACT_GESTURE_RANGE_ATTACK_AR1", + "ACT_GESTURE_RANGE_ATTACK_AR2", + "ACT_GESTURE_RANGE_ATTACK_AR2_GRENADE", + "ACT_GESTURE_RANGE_ATTACK_HMG1", + "ACT_GESTURE_RANGE_ATTACK_ML", + "ACT_GESTURE_RANGE_ATTACK_SMG1", + "ACT_GESTURE_RANGE_ATTACK_SMG1_LOW", + "ACT_GESTURE_RANGE_ATTACK_SMG2", + "ACT_GESTURE_RANGE_ATTACK_SHOTGUN", + "ACT_GESTURE_RANGE_ATTACK_PISTOL", + "ACT_GESTURE_RANGE_ATTACK_PISTOL_LOW", + "ACT_GESTURE_RANGE_ATTACK_SLAM", + "ACT_GESTURE_RANGE_ATTACK_TRIPWIRE", + "ACT_GESTURE_RANGE_ATTACK_THROW", + "ACT_GESTURE_RANGE_ATTACK_SNIPER_RIFLE", + "ACT_GESTURE_MELEE_ATTACK_SWING", + "ACT_IDLE_RIFLE", + "ACT_IDLE_SMG1", + "ACT_IDLE_ANGRY_SMG1", + "ACT_IDLE_PISTOL", + "ACT_IDLE_ANGRY_PISTOL", + "ACT_IDLE_ANGRY_SHOTGUN", + "ACT_IDLE_STEALTH_PISTOL", + "ACT_IDLE_PACKAGE", + "ACT_WALK_PACKAGE", + "ACT_IDLE_SUITCASE", + "ACT_WALK_SUITCASE", + "ACT_IDLE_SMG1_RELAXED", + "ACT_IDLE_SMG1_STIMULATED", + "ACT_WALK_RIFLE_RELAXED", + "ACT_RUN_RIFLE_RELAXED", + "ACT_WALK_RIFLE_STIMULATED", + "ACT_RUN_RIFLE_STIMULATED", + "ACT_IDLE_AIM_RIFLE_STIMULATED", + "ACT_WALK_AIM_RIFLE_STIMULATED", + "ACT_RUN_AIM_RIFLE_STIMULATED", + "ACT_IDLE_SHOTGUN_RELAXED", + "ACT_IDLE_SHOTGUN_STIMULATED", + "ACT_IDLE_SHOTGUN_AGITATED", + "ACT_WALK_ANGRY", + "ACT_POLICE_HARASS1", + "ACT_POLICE_HARASS2", + "ACT_IDLE_MANNEDGUN", + "ACT_IDLE_MELEE", + "ACT_IDLE_ANGRY_MELEE", + "ACT_IDLE_RPG_RELAXED", + "ACT_IDLE_RPG", + "ACT_IDLE_ANGRY_RPG", + "ACT_COVER_LOW_RPG", + "ACT_WALK_RPG", + "ACT_RUN_RPG", + "ACT_WALK_CROUCH_RPG", + "ACT_RUN_CROUCH_RPG", + "ACT_WALK_RPG_RELAXED", + "ACT_RUN_RPG_RELAXED", + "ACT_WALK_RIFLE", + "ACT_WALK_AIM_RIFLE", + "ACT_WALK_CROUCH_RIFLE", + "ACT_WALK_CROUCH_AIM_RIFLE", + "ACT_RUN_RIFLE", + "ACT_RUN_AIM_RIFLE", + "ACT_RUN_CROUCH_RIFLE", + "ACT_RUN_CROUCH_AIM_RIFLE", + "ACT_RUN_STEALTH_PISTOL", + "ACT_WALK_AIM_SHOTGUN", + "ACT_RUN_AIM_SHOTGUN", + "ACT_WALK_PISTOL", + "ACT_RUN_PISTOL", + "ACT_WALK_AIM_PISTOL", + "ACT_RUN_AIM_PISTOL", + "ACT_WALK_STEALTH_PISTOL", + "ACT_WALK_AIM_STEALTH_PISTOL", + "ACT_RUN_AIM_STEALTH_PISTOL", + "ACT_RELOAD_PISTOL", + "ACT_RELOAD_PISTOL_LOW", + "ACT_RELOAD_SMG1", + "ACT_RELOAD_SMG1_LOW", + "ACT_RELOAD_SHOTGUN", + "ACT_RELOAD_SHOTGUN_LOW", + "ACT_GESTURE_RELOAD", + "ACT_GESTURE_RELOAD_PISTOL", + "ACT_GESTURE_RELOAD_SMG1", + "ACT_GESTURE_RELOAD_SHOTGUN", + "ACT_BUSY_LEAN_LEFT", + "ACT_BUSY_LEAN_LEFT_ENTRY", + "ACT_BUSY_LEAN_LEFT_EXIT", + "ACT_BUSY_LEAN_BACK", + "ACT_BUSY_LEAN_BACK_ENTRY", + "ACT_BUSY_LEAN_BACK_EXIT", + "ACT_BUSY_SIT_GROUND", + "ACT_BUSY_SIT_GROUND_ENTRY", + "ACT_BUSY_SIT_GROUND_EXIT", + "ACT_BUSY_SIT_CHAIR", + "ACT_BUSY_SIT_CHAIR_ENTRY", + "ACT_BUSY_SIT_CHAIR_EXIT", + "ACT_BUSY_STAND", + "ACT_BUSY_QUEUE", + "ACT_DUCK_DODGE", + "ACT_DIE_BARNACLE_SWALLOW", + "ACT_GESTURE_BARNACLE_STRANGLE", + "ACT_PHYSCANNON_DETACH", + "ACT_PHYSCANNON_ANIMATE", + "ACT_PHYSCANNON_ANIMATE_PRE", + "ACT_PHYSCANNON_ANIMATE_POST", + "ACT_DIE_FRONTSIDE", + "ACT_DIE_RIGHTSIDE", + "ACT_DIE_BACKSIDE", + "ACT_DIE_LEFTSIDE", + "ACT_OPEN_DOOR", + "ACT_DI_ALYX_ZOMBIE_MELEE", + "ACT_DI_ALYX_ZOMBIE_TORSO_MELEE", + "ACT_DI_ALYX_HEADCRAB_MELEE", + "ACT_DI_ALYX_ANTLION", + "ACT_DI_ALYX_ZOMBIE_SHOTGUN64", + "ACT_DI_ALYX_ZOMBIE_SHOTGUN26", + "ACT_READINESS_RELAXED_TO_STIMULATED", + "ACT_READINESS_RELAXED_TO_STIMULATED_WALK", + "ACT_READINESS_AGITATED_TO_STIMULATED", + "ACT_READINESS_STIMULATED_TO_RELAXED", + "ACT_READINESS_PISTOL_RELAXED_TO_STIMULATED", + "ACT_READINESS_PISTOL_RELAXED_TO_STIMULATED_WALK", + "ACT_READINESS_PISTOL_AGITATED_TO_STIMULATED", + "ACT_READINESS_PISTOL_STIMULATED_TO_RELAXED", + "ACT_IDLE_CARRY", + "ACT_WALK_CARRY", + "ACT_STARTDYING", + "ACT_DYINGLOOP", + "ACT_DYINGTODEAD", + "ACT_RIDE_MANNED_GUN", + "ACT_VM_SPRINT_ENTER", + "ACT_VM_SPRINT_IDLE", + "ACT_VM_SPRINT_LEAVE", + "ACT_FIRE_START", + "ACT_FIRE_LOOP", + "ACT_FIRE_END", + "ACT_CROUCHING_GRENADEIDLE", + "ACT_CROUCHING_GRENADEREADY", + "ACT_CROUCHING_PRIMARYATTACK", + "ACT_OVERLAY_GRENADEIDLE", + "ACT_OVERLAY_GRENADEREADY", + "ACT_OVERLAY_PRIMARYATTACK", + "ACT_OVERLAY_SHIELD_UP", + "ACT_OVERLAY_SHIELD_DOWN", + "ACT_OVERLAY_SHIELD_UP_IDLE", + "ACT_OVERLAY_SHIELD_ATTACK", + "ACT_OVERLAY_SHIELD_KNOCKBACK", + "ACT_SHIELD_UP", + "ACT_SHIELD_DOWN", + "ACT_SHIELD_UP_IDLE", + "ACT_SHIELD_ATTACK", + "ACT_SHIELD_KNOCKBACK", + "ACT_CROUCHING_SHIELD_UP", + "ACT_CROUCHING_SHIELD_DOWN", + "ACT_CROUCHING_SHIELD_UP_IDLE", + "ACT_CROUCHING_SHIELD_ATTACK", + "ACT_CROUCHING_SHIELD_KNOCKBACK", + "ACT_TURNRIGHT45", + "ACT_TURNLEFT45", + "ACT_TURN", + "ACT_OBJ_ASSEMBLING", + "ACT_OBJ_DISMANTLING", + "ACT_OBJ_STARTUP", + "ACT_OBJ_RUNNING", + "ACT_OBJ_IDLE", + "ACT_OBJ_PLACING", + "ACT_OBJ_DETERIORATING", + "ACT_OBJ_UPGRADING", + "ACT_DEPLOY", + "ACT_DEPLOY_IDLE", + "ACT_UNDEPLOY", + "ACT_GRENADE_ROLL", + "ACT_GRENADE_TOSS", + "ACT_HANDGRENADE_THROW1", + "ACT_HANDGRENADE_THROW2", + "ACT_HANDGRENADE_THROW3", + "ACT_SHOTGUN_IDLE_DEEP", + "ACT_SHOTGUN_IDLE4", + "ACT_GLOCK_SHOOTEMPTY", + "ACT_GLOCK_SHOOT_RELOAD", + "ACT_RPG_DRAW_UNLOADED", + "ACT_RPG_HOLSTER_UNLOADED", + "ACT_RPG_IDLE_UNLOADED", + "ACT_RPG_FIDGET_UNLOADED", + "ACT_CROSSBOW_DRAW_UNLOADED", + "ACT_CROSSBOW_IDLE_UNLOADED", + "ACT_CROSSBOW_FIDGET_UNLOADED", + "ACT_GAUSS_SPINUP", + "ACT_GAUSS_SPINCYCLE", + "ACT_TRIPMINE_GROUND", + "ACT_TRIPMINE_WORLD", + "ACT_VM_PRIMARYATTACK_SILENCED", + "ACT_VM_RELOAD_SILENCED", + "ACT_VM_DRYFIRE_SILENCED", + "ACT_VM_IDLE_SILENCED", + "ACT_VM_DRAW_SILENCED", + "ACT_VM_IDLE_EMPTY_LEFT", + "ACT_VM_DRYFIRE_LEFT", + "ACT_PLAYER_IDLE_FIRE", + "ACT_PLAYER_CROUCH_FIRE", + "ACT_PLAYER_CROUCH_WALK_FIRE", + "ACT_PLAYER_WALK_FIRE", + "ACT_PLAYER_RUN_FIRE", + "ACT_IDLETORUN", + "ACT_RUNTOIDLE", + "ACT_SPRINT", + "ACT_GET_DOWN_STAND", + "ACT_GET_UP_STAND", + "ACT_GET_DOWN_CROUCH", + "ACT_GET_UP_CROUCH", + "ACT_PRONE_FORWARD", + "ACT_PRONE_IDLE", + "ACT_DEEPIDLE1", + "ACT_DEEPIDLE2", + "ACT_DEEPIDLE3", + "ACT_DEEPIDLE4", + "ACT_VM_RELOAD_DEPLOYED", + "ACT_VM_RELOAD_IDLE", + "ACT_VM_DRAW_DEPLOYED", + "ACT_VM_DRAW_EMPTY", + "ACT_VM_PRIMARYATTACK_EMPTY", + "ACT_VM_RELOAD_EMPTY", + "ACT_VM_IDLE_EMPTY", + "ACT_VM_IDLE_DEPLOYED_EMPTY", + "ACT_VM_IDLE_8", + "ACT_VM_IDLE_7", + "ACT_VM_IDLE_6", + "ACT_VM_IDLE_5", + "ACT_VM_IDLE_4", + "ACT_VM_IDLE_3", + "ACT_VM_IDLE_2", + "ACT_VM_IDLE_1", + "ACT_VM_IDLE_DEPLOYED", + "ACT_VM_IDLE_DEPLOYED_8", + "ACT_VM_IDLE_DEPLOYED_7", + "ACT_VM_IDLE_DEPLOYED_6", + "ACT_VM_IDLE_DEPLOYED_5", + "ACT_VM_IDLE_DEPLOYED_4", + "ACT_VM_IDLE_DEPLOYED_3", + "ACT_VM_IDLE_DEPLOYED_2", + "ACT_VM_IDLE_DEPLOYED_1", + "ACT_VM_UNDEPLOY", + "ACT_VM_UNDEPLOY_8", + "ACT_VM_UNDEPLOY_7", + "ACT_VM_UNDEPLOY_6", + "ACT_VM_UNDEPLOY_5", + "ACT_VM_UNDEPLOY_4", + "ACT_VM_UNDEPLOY_3", + "ACT_VM_UNDEPLOY_2", + "ACT_VM_UNDEPLOY_1", + "ACT_VM_UNDEPLOY_EMPTY", + "ACT_VM_DEPLOY", + "ACT_VM_DEPLOY_8", + "ACT_VM_DEPLOY_7", + "ACT_VM_DEPLOY_6", + "ACT_VM_DEPLOY_5", + "ACT_VM_DEPLOY_4", + "ACT_VM_DEPLOY_3", + "ACT_VM_DEPLOY_2", + "ACT_VM_DEPLOY_1", + "ACT_VM_DEPLOY_EMPTY", + "ACT_VM_PRIMARYATTACK_8", + "ACT_VM_PRIMARYATTACK_7", + "ACT_VM_PRIMARYATTACK_6", + "ACT_VM_PRIMARYATTACK_5", + "ACT_VM_PRIMARYATTACK_4", + "ACT_VM_PRIMARYATTACK_3", + "ACT_VM_PRIMARYATTACK_2", + "ACT_VM_PRIMARYATTACK_1", + "ACT_VM_PRIMARYATTACK_DEPLOYED", + "ACT_VM_PRIMARYATTACK_DEPLOYED_8", + "ACT_VM_PRIMARYATTACK_DEPLOYED_7", + "ACT_VM_PRIMARYATTACK_DEPLOYED_6", + "ACT_VM_PRIMARYATTACK_DEPLOYED_5", + "ACT_VM_PRIMARYATTACK_DEPLOYED_4", + "ACT_VM_PRIMARYATTACK_DEPLOYED_3", + "ACT_VM_PRIMARYATTACK_DEPLOYED_2", + "ACT_VM_PRIMARYATTACK_DEPLOYED_1", + "ACT_VM_PRIMARYATTACK_DEPLOYED_EMPTY", + "ACT_DOD_DEPLOYED", + "ACT_DOD_PRONE_DEPLOYED", + "ACT_DOD_IDLE_ZOOMED", + "ACT_DOD_WALK_ZOOMED", + "ACT_DOD_CROUCH_ZOOMED", + "ACT_DOD_CROUCHWALK_ZOOMED", + "ACT_DOD_PRONE_ZOOMED", + "ACT_DOD_PRONE_FORWARD_ZOOMED", + "ACT_DOD_PRIMARYATTACK_DEPLOYED", + "ACT_DOD_PRIMARYATTACK_PRONE_DEPLOYED", + "ACT_DOD_RELOAD_DEPLOYED", + "ACT_DOD_RELOAD_PRONE_DEPLOYED", + "ACT_DOD_PRIMARYATTACK_PRONE", + "ACT_DOD_SECONDARYATTACK_PRONE", + "ACT_DOD_RELOAD_CROUCH", + "ACT_DOD_RELOAD_PRONE", + "ACT_DOD_STAND_IDLE", + "ACT_DOD_STAND_AIM", + "ACT_DOD_CROUCH_IDLE", + "ACT_DOD_CROUCH_AIM", + "ACT_DOD_CROUCHWALK_IDLE", + "ACT_DOD_CROUCHWALK_AIM", + "ACT_DOD_WALK_IDLE", + "ACT_DOD_WALK_AIM", + "ACT_DOD_RUN_IDLE", + "ACT_DOD_RUN_AIM", + "ACT_DOD_STAND_AIM_PISTOL", + "ACT_DOD_CROUCH_AIM_PISTOL", + "ACT_DOD_CROUCHWALK_AIM_PISTOL", + "ACT_DOD_WALK_AIM_PISTOL", + "ACT_DOD_RUN_AIM_PISTOL", + "ACT_DOD_PRONE_AIM_PISTOL", + "ACT_DOD_STAND_IDLE_PISTOL", + "ACT_DOD_CROUCH_IDLE_PISTOL", + "ACT_DOD_CROUCHWALK_IDLE_PISTOL", + "ACT_DOD_WALK_IDLE_PISTOL", + "ACT_DOD_RUN_IDLE_PISTOL", + "ACT_DOD_SPRINT_IDLE_PISTOL", + "ACT_DOD_PRONEWALK_IDLE_PISTOL", + "ACT_DOD_STAND_AIM_C96", + "ACT_DOD_CROUCH_AIM_C96", + "ACT_DOD_CROUCHWALK_AIM_C96", + "ACT_DOD_WALK_AIM_C96", + "ACT_DOD_RUN_AIM_C96", + "ACT_DOD_PRONE_AIM_C96", + "ACT_DOD_STAND_IDLE_C96", + "ACT_DOD_CROUCH_IDLE_C96", + "ACT_DOD_CROUCHWALK_IDLE_C96", + "ACT_DOD_WALK_IDLE_C96", + "ACT_DOD_RUN_IDLE_C96", + "ACT_DOD_SPRINT_IDLE_C96", + "ACT_DOD_PRONEWALK_IDLE_C96", + "ACT_DOD_STAND_AIM_RIFLE", + "ACT_DOD_CROUCH_AIM_RIFLE", + "ACT_DOD_CROUCHWALK_AIM_RIFLE", + "ACT_DOD_WALK_AIM_RIFLE", + "ACT_DOD_RUN_AIM_RIFLE", + "ACT_DOD_PRONE_AIM_RIFLE", + "ACT_DOD_STAND_IDLE_RIFLE", + "ACT_DOD_CROUCH_IDLE_RIFLE", + "ACT_DOD_CROUCHWALK_IDLE_RIFLE", + "ACT_DOD_WALK_IDLE_RIFLE", + "ACT_DOD_RUN_IDLE_RIFLE", + "ACT_DOD_SPRINT_IDLE_RIFLE", + "ACT_DOD_PRONEWALK_IDLE_RIFLE", + "ACT_DOD_STAND_AIM_BOLT", + "ACT_DOD_CROUCH_AIM_BOLT", + "ACT_DOD_CROUCHWALK_AIM_BOLT", + "ACT_DOD_WALK_AIM_BOLT", + "ACT_DOD_RUN_AIM_BOLT", + "ACT_DOD_PRONE_AIM_BOLT", + "ACT_DOD_STAND_IDLE_BOLT", + "ACT_DOD_CROUCH_IDLE_BOLT", + "ACT_DOD_CROUCHWALK_IDLE_BOLT", + "ACT_DOD_WALK_IDLE_BOLT", + "ACT_DOD_RUN_IDLE_BOLT", + "ACT_DOD_SPRINT_IDLE_BOLT", + "ACT_DOD_PRONEWALK_IDLE_BOLT", + "ACT_DOD_STAND_AIM_TOMMY", + "ACT_DOD_CROUCH_AIM_TOMMY", + "ACT_DOD_CROUCHWALK_AIM_TOMMY", + "ACT_DOD_WALK_AIM_TOMMY", + "ACT_DOD_RUN_AIM_TOMMY", + "ACT_DOD_PRONE_AIM_TOMMY", + "ACT_DOD_STAND_IDLE_TOMMY", + "ACT_DOD_CROUCH_IDLE_TOMMY", + "ACT_DOD_CROUCHWALK_IDLE_TOMMY", + "ACT_DOD_WALK_IDLE_TOMMY", + "ACT_DOD_RUN_IDLE_TOMMY", + "ACT_DOD_SPRINT_IDLE_TOMMY", + "ACT_DOD_PRONEWALK_IDLE_TOMMY", + "ACT_DOD_STAND_AIM_MP40", + "ACT_DOD_CROUCH_AIM_MP40", + "ACT_DOD_CROUCHWALK_AIM_MP40", + "ACT_DOD_WALK_AIM_MP40", + "ACT_DOD_RUN_AIM_MP40", + "ACT_DOD_PRONE_AIM_MP40", + "ACT_DOD_STAND_IDLE_MP40", + "ACT_DOD_CROUCH_IDLE_MP40", + "ACT_DOD_CROUCHWALK_IDLE_MP40", + "ACT_DOD_WALK_IDLE_MP40", + "ACT_DOD_RUN_IDLE_MP40", + "ACT_DOD_SPRINT_IDLE_MP40", + "ACT_DOD_PRONEWALK_IDLE_MP40", + "ACT_DOD_STAND_AIM_MP44", + "ACT_DOD_CROUCH_AIM_MP44", + "ACT_DOD_CROUCHWALK_AIM_MP44", + "ACT_DOD_WALK_AIM_MP44", + "ACT_DOD_RUN_AIM_MP44", + "ACT_DOD_PRONE_AIM_MP44", + "ACT_DOD_STAND_IDLE_MP44", + "ACT_DOD_CROUCH_IDLE_MP44", + "ACT_DOD_CROUCHWALK_IDLE_MP44", + "ACT_DOD_WALK_IDLE_MP44", + "ACT_DOD_RUN_IDLE_MP44", + "ACT_DOD_SPRINT_IDLE_MP44", + "ACT_DOD_PRONEWALK_IDLE_MP44", + "ACT_DOD_STAND_AIM_GREASE", + "ACT_DOD_CROUCH_AIM_GREASE", + "ACT_DOD_CROUCHWALK_AIM_GREASE", + "ACT_DOD_WALK_AIM_GREASE", + "ACT_DOD_RUN_AIM_GREASE", + "ACT_DOD_PRONE_AIM_GREASE", + "ACT_DOD_STAND_IDLE_GREASE", + "ACT_DOD_CROUCH_IDLE_GREASE", + "ACT_DOD_CROUCHWALK_IDLE_GREASE", + "ACT_DOD_WALK_IDLE_GREASE", + "ACT_DOD_RUN_IDLE_GREASE", + "ACT_DOD_SPRINT_IDLE_GREASE", + "ACT_DOD_PRONEWALK_IDLE_GREASE", + "ACT_DOD_STAND_AIM_MG", + "ACT_DOD_CROUCH_AIM_MG", + "ACT_DOD_CROUCHWALK_AIM_MG", + "ACT_DOD_WALK_AIM_MG", + "ACT_DOD_RUN_AIM_MG", + "ACT_DOD_PRONE_AIM_MG", + "ACT_DOD_STAND_IDLE_MG", + "ACT_DOD_CROUCH_IDLE_MG", + "ACT_DOD_CROUCHWALK_IDLE_MG", + "ACT_DOD_WALK_IDLE_MG", + "ACT_DOD_RUN_IDLE_MG", + "ACT_DOD_SPRINT_IDLE_MG", + "ACT_DOD_PRONEWALK_IDLE_MG", + "ACT_DOD_STAND_AIM_30CAL", + "ACT_DOD_CROUCH_AIM_30CAL", + "ACT_DOD_CROUCHWALK_AIM_30CAL", + "ACT_DOD_WALK_AIM_30CAL", + "ACT_DOD_RUN_AIM_30CAL", + "ACT_DOD_PRONE_AIM_30CAL", + "ACT_DOD_STAND_IDLE_30CAL", + "ACT_DOD_CROUCH_IDLE_30CAL", + "ACT_DOD_CROUCHWALK_IDLE_30CAL", + "ACT_DOD_WALK_IDLE_30CAL", + "ACT_DOD_RUN_IDLE_30CAL", + "ACT_DOD_SPRINT_IDLE_30CAL", + "ACT_DOD_PRONEWALK_IDLE_30CAL", + "ACT_DOD_STAND_AIM_GREN_FRAG", + "ACT_DOD_CROUCH_AIM_GREN_FRAG", + "ACT_DOD_CROUCHWALK_AIM_GREN_FRAG", + "ACT_DOD_WALK_AIM_GREN_FRAG", + "ACT_DOD_RUN_AIM_GREN_FRAG", + "ACT_DOD_PRONE_AIM_GREN_FRAG", + "ACT_DOD_SPRINT_AIM_GREN_FRAG", + "ACT_DOD_PRONEWALK_AIM_GREN_FRAG", + "ACT_DOD_STAND_AIM_GREN_STICK", + "ACT_DOD_CROUCH_AIM_GREN_STICK", + "ACT_DOD_CROUCHWALK_AIM_GREN_STICK", + "ACT_DOD_WALK_AIM_GREN_STICK", + "ACT_DOD_RUN_AIM_GREN_STICK", + "ACT_DOD_PRONE_AIM_GREN_STICK", + "ACT_DOD_SPRINT_AIM_GREN_STICK", + "ACT_DOD_PRONEWALK_AIM_GREN_STICK", + "ACT_DOD_STAND_AIM_KNIFE", + "ACT_DOD_CROUCH_AIM_KNIFE", + "ACT_DOD_CROUCHWALK_AIM_KNIFE", + "ACT_DOD_WALK_AIM_KNIFE", + "ACT_DOD_RUN_AIM_KNIFE", + "ACT_DOD_PRONE_AIM_KNIFE", + "ACT_DOD_SPRINT_AIM_KNIFE", + "ACT_DOD_PRONEWALK_AIM_KNIFE", + "ACT_DOD_STAND_AIM_SPADE", + "ACT_DOD_CROUCH_AIM_SPADE", + "ACT_DOD_CROUCHWALK_AIM_SPADE", + "ACT_DOD_WALK_AIM_SPADE", + "ACT_DOD_RUN_AIM_SPADE", + "ACT_DOD_PRONE_AIM_SPADE", + "ACT_DOD_SPRINT_AIM_SPADE", + "ACT_DOD_PRONEWALK_AIM_SPADE", + "ACT_DOD_STAND_AIM_BAZOOKA", + "ACT_DOD_CROUCH_AIM_BAZOOKA", + "ACT_DOD_CROUCHWALK_AIM_BAZOOKA", + "ACT_DOD_WALK_AIM_BAZOOKA", + "ACT_DOD_RUN_AIM_BAZOOKA", + "ACT_DOD_PRONE_AIM_BAZOOKA", + "ACT_DOD_STAND_IDLE_BAZOOKA", + "ACT_DOD_CROUCH_IDLE_BAZOOKA", + "ACT_DOD_CROUCHWALK_IDLE_BAZOOKA", + "ACT_DOD_WALK_IDLE_BAZOOKA", + "ACT_DOD_RUN_IDLE_BAZOOKA", + "ACT_DOD_SPRINT_IDLE_BAZOOKA", + "ACT_DOD_PRONEWALK_IDLE_BAZOOKA", + "ACT_DOD_STAND_AIM_PSCHRECK", + "ACT_DOD_CROUCH_AIM_PSCHRECK", + "ACT_DOD_CROUCHWALK_AIM_PSCHRECK", + "ACT_DOD_WALK_AIM_PSCHRECK", + "ACT_DOD_RUN_AIM_PSCHRECK", + "ACT_DOD_PRONE_AIM_PSCHRECK", + "ACT_DOD_STAND_IDLE_PSCHRECK", + "ACT_DOD_CROUCH_IDLE_PSCHRECK", + "ACT_DOD_CROUCHWALK_IDLE_PSCHRECK", + "ACT_DOD_WALK_IDLE_PSCHRECK", + "ACT_DOD_RUN_IDLE_PSCHRECK", + "ACT_DOD_SPRINT_IDLE_PSCHRECK", + "ACT_DOD_PRONEWALK_IDLE_PSCHRECK", + "ACT_DOD_STAND_AIM_BAR", + "ACT_DOD_CROUCH_AIM_BAR", + "ACT_DOD_CROUCHWALK_AIM_BAR", + "ACT_DOD_WALK_AIM_BAR", + "ACT_DOD_RUN_AIM_BAR", + "ACT_DOD_PRONE_AIM_BAR", + "ACT_DOD_STAND_IDLE_BAR", + "ACT_DOD_CROUCH_IDLE_BAR", + "ACT_DOD_CROUCHWALK_IDLE_BAR", + "ACT_DOD_WALK_IDLE_BAR", + "ACT_DOD_RUN_IDLE_BAR", + "ACT_DOD_SPRINT_IDLE_BAR", + "ACT_DOD_PRONEWALK_IDLE_BAR", + "ACT_DOD_STAND_ZOOM_RIFLE", + "ACT_DOD_CROUCH_ZOOM_RIFLE", + "ACT_DOD_CROUCHWALK_ZOOM_RIFLE", + "ACT_DOD_WALK_ZOOM_RIFLE", + "ACT_DOD_RUN_ZOOM_RIFLE", + "ACT_DOD_PRONE_ZOOM_RIFLE", + "ACT_DOD_STAND_ZOOM_BOLT", + "ACT_DOD_CROUCH_ZOOM_BOLT", + "ACT_DOD_CROUCHWALK_ZOOM_BOLT", + "ACT_DOD_WALK_ZOOM_BOLT", + "ACT_DOD_RUN_ZOOM_BOLT", + "ACT_DOD_PRONE_ZOOM_BOLT", + "ACT_DOD_STAND_ZOOM_BAZOOKA", + "ACT_DOD_CROUCH_ZOOM_BAZOOKA", + "ACT_DOD_CROUCHWALK_ZOOM_BAZOOKA", + "ACT_DOD_WALK_ZOOM_BAZOOKA", + "ACT_DOD_RUN_ZOOM_BAZOOKA", + "ACT_DOD_PRONE_ZOOM_BAZOOKA", + "ACT_DOD_STAND_ZOOM_PSCHRECK", + "ACT_DOD_CROUCH_ZOOM_PSCHRECK", + "ACT_DOD_CROUCHWALK_ZOOM_PSCHRECK", + "ACT_DOD_WALK_ZOOM_PSCHRECK", + "ACT_DOD_RUN_ZOOM_PSCHRECK", + "ACT_DOD_PRONE_ZOOM_PSCHRECK", + "ACT_DOD_DEPLOY_RIFLE", + "ACT_DOD_DEPLOY_TOMMY", + "ACT_DOD_DEPLOY_MG", + "ACT_DOD_DEPLOY_30CAL", + "ACT_DOD_PRONE_DEPLOY_RIFLE", + "ACT_DOD_PRONE_DEPLOY_TOMMY", + "ACT_DOD_PRONE_DEPLOY_MG", + "ACT_DOD_PRONE_DEPLOY_30CAL", + "ACT_DOD_PRIMARYATTACK_RIFLE", + "ACT_DOD_SECONDARYATTACK_RIFLE", + "ACT_DOD_PRIMARYATTACK_PRONE_RIFLE", + "ACT_DOD_SECONDARYATTACK_PRONE_RIFLE", + "ACT_DOD_PRIMARYATTACK_PRONE_DEPLOYED_RIFLE", + "ACT_DOD_PRIMARYATTACK_DEPLOYED_RIFLE", + "ACT_DOD_PRIMARYATTACK_BOLT", + "ACT_DOD_SECONDARYATTACK_BOLT", + "ACT_DOD_PRIMARYATTACK_PRONE_BOLT", + "ACT_DOD_SECONDARYATTACK_PRONE_BOLT", + "ACT_DOD_PRIMARYATTACK_TOMMY", + "ACT_DOD_PRIMARYATTACK_PRONE_TOMMY", + "ACT_DOD_SECONDARYATTACK_TOMMY", + "ACT_DOD_SECONDARYATTACK_PRONE_TOMMY", + "ACT_DOD_PRIMARYATTACK_MP40", + "ACT_DOD_PRIMARYATTACK_PRONE_MP40", + "ACT_DOD_SECONDARYATTACK_MP40", + "ACT_DOD_SECONDARYATTACK_PRONE_MP40", + "ACT_DOD_PRIMARYATTACK_MP44", + "ACT_DOD_PRIMARYATTACK_PRONE_MP44", + "ACT_DOD_PRIMARYATTACK_GREASE", + "ACT_DOD_PRIMARYATTACK_PRONE_GREASE", + "ACT_DOD_PRIMARYATTACK_PISTOL", + "ACT_DOD_PRIMARYATTACK_PRONE_PISTOL", + "ACT_DOD_PRIMARYATTACK_C96", + "ACT_DOD_PRIMARYATTACK_PRONE_C96", + "ACT_DOD_PRIMARYATTACK_MG", + "ACT_DOD_PRIMARYATTACK_PRONE_MG", + "ACT_DOD_PRIMARYATTACK_PRONE_DEPLOYED_MG", + "ACT_DOD_PRIMARYATTACK_DEPLOYED_MG", + "ACT_DOD_PRIMARYATTACK_30CAL", + "ACT_DOD_PRIMARYATTACK_PRONE_30CAL", + "ACT_DOD_PRIMARYATTACK_DEPLOYED_30CAL", + "ACT_DOD_PRIMARYATTACK_PRONE_DEPLOYED_30CAL", + "ACT_DOD_PRIMARYATTACK_GREN_FRAG", + "ACT_DOD_PRIMARYATTACK_PRONE_GREN_FRAG", + "ACT_DOD_PRIMARYATTACK_GREN_STICK", + "ACT_DOD_PRIMARYATTACK_PRONE_GREN_STICK", + "ACT_DOD_PRIMARYATTACK_KNIFE", + "ACT_DOD_PRIMARYATTACK_PRONE_KNIFE", + "ACT_DOD_PRIMARYATTACK_SPADE", + "ACT_DOD_PRIMARYATTACK_PRONE_SPADE", + "ACT_DOD_PRIMARYATTACK_BAZOOKA", + "ACT_DOD_PRIMARYATTACK_PRONE_BAZOOKA", + "ACT_DOD_PRIMARYATTACK_PSCHRECK", + "ACT_DOD_PRIMARYATTACK_PRONE_PSCHRECK", + "ACT_DOD_PRIMARYATTACK_BAR", + "ACT_DOD_PRIMARYATTACK_PRONE_BAR", + "ACT_DOD_RELOAD_GARAND", + "ACT_DOD_RELOAD_K43", + "ACT_DOD_RELOAD_BAR", + "ACT_DOD_RELOAD_MP40", + "ACT_DOD_RELOAD_MP44", + "ACT_DOD_RELOAD_BOLT", + "ACT_DOD_RELOAD_M1CARBINE", + "ACT_DOD_RELOAD_TOMMY", + "ACT_DOD_RELOAD_GREASEGUN", + "ACT_DOD_RELOAD_PISTOL", + "ACT_DOD_RELOAD_FG42", + "ACT_DOD_RELOAD_RIFLE", + "ACT_DOD_RELOAD_RIFLEGRENADE", + "ACT_DOD_RELOAD_C96", + "ACT_DOD_RELOAD_CROUCH_BAR", + "ACT_DOD_RELOAD_CROUCH_RIFLE", + "ACT_DOD_RELOAD_CROUCH_RIFLEGRENADE", + "ACT_DOD_RELOAD_CROUCH_BOLT", + "ACT_DOD_RELOAD_CROUCH_MP44", + "ACT_DOD_RELOAD_CROUCH_MP40", + "ACT_DOD_RELOAD_CROUCH_TOMMY", + "ACT_DOD_RELOAD_CROUCH_BAZOOKA", + "ACT_DOD_RELOAD_CROUCH_PSCHRECK", + "ACT_DOD_RELOAD_CROUCH_PISTOL", + "ACT_DOD_RELOAD_CROUCH_M1CARBINE", + "ACT_DOD_RELOAD_CROUCH_C96", + "ACT_DOD_RELOAD_BAZOOKA", + "ACT_DOD_ZOOMLOAD_BAZOOKA", + "ACT_DOD_RELOAD_PSCHRECK", + "ACT_DOD_ZOOMLOAD_PSCHRECK", + "ACT_DOD_RELOAD_DEPLOYED_FG42", + "ACT_DOD_RELOAD_DEPLOYED_30CAL", + "ACT_DOD_RELOAD_DEPLOYED_MG", + "ACT_DOD_RELOAD_DEPLOYED_MG34", + "ACT_DOD_RELOAD_DEPLOYED_BAR", + "ACT_DOD_RELOAD_PRONE_PISTOL", + "ACT_DOD_RELOAD_PRONE_GARAND", + "ACT_DOD_RELOAD_PRONE_M1CARBINE", + "ACT_DOD_RELOAD_PRONE_BOLT", + "ACT_DOD_RELOAD_PRONE_K43", + "ACT_DOD_RELOAD_PRONE_MP40", + "ACT_DOD_RELOAD_PRONE_MP44", + "ACT_DOD_RELOAD_PRONE_BAR", + "ACT_DOD_RELOAD_PRONE_GREASEGUN", + "ACT_DOD_RELOAD_PRONE_TOMMY", + "ACT_DOD_RELOAD_PRONE_FG42", + "ACT_DOD_RELOAD_PRONE_RIFLE", + "ACT_DOD_RELOAD_PRONE_RIFLEGRENADE", + "ACT_DOD_RELOAD_PRONE_C96", + "ACT_DOD_RELOAD_PRONE_BAZOOKA", + "ACT_DOD_ZOOMLOAD_PRONE_BAZOOKA", + "ACT_DOD_RELOAD_PRONE_PSCHRECK", + "ACT_DOD_ZOOMLOAD_PRONE_PSCHRECK", + "ACT_DOD_RELOAD_PRONE_DEPLOYED_BAR", + "ACT_DOD_RELOAD_PRONE_DEPLOYED_FG42", + "ACT_DOD_RELOAD_PRONE_DEPLOYED_30CAL", + "ACT_DOD_RELOAD_PRONE_DEPLOYED_MG", + "ACT_DOD_RELOAD_PRONE_DEPLOYED_MG34", + "ACT_DOD_PRONE_ZOOM_FORWARD_RIFLE", + "ACT_DOD_PRONE_ZOOM_FORWARD_BOLT", + "ACT_DOD_PRONE_ZOOM_FORWARD_BAZOOKA", + "ACT_DOD_PRONE_ZOOM_FORWARD_PSCHRECK", + "ACT_DOD_PRIMARYATTACK_CROUCH", + "ACT_DOD_PRIMARYATTACK_CROUCH_SPADE", + "ACT_DOD_PRIMARYATTACK_CROUCH_KNIFE", + "ACT_DOD_PRIMARYATTACK_CROUCH_GREN_FRAG", + "ACT_DOD_PRIMARYATTACK_CROUCH_GREN_STICK", + "ACT_DOD_SECONDARYATTACK_CROUCH", + "ACT_DOD_SECONDARYATTACK_CROUCH_TOMMY", + "ACT_DOD_SECONDARYATTACK_CROUCH_MP40", + "ACT_DOD_HS_IDLE", + "ACT_DOD_HS_CROUCH", + "ACT_DOD_HS_IDLE_30CAL", + "ACT_DOD_HS_IDLE_BAZOOKA", + "ACT_DOD_HS_IDLE_PSCHRECK", + "ACT_DOD_HS_IDLE_KNIFE", + "ACT_DOD_HS_IDLE_MG42", + "ACT_DOD_HS_IDLE_PISTOL", + "ACT_DOD_HS_IDLE_STICKGRENADE", + "ACT_DOD_HS_IDLE_TOMMY", + "ACT_DOD_HS_IDLE_MP44", + "ACT_DOD_HS_IDLE_K98", + "ACT_DOD_HS_CROUCH_30CAL", + "ACT_DOD_HS_CROUCH_BAZOOKA", + "ACT_DOD_HS_CROUCH_PSCHRECK", + "ACT_DOD_HS_CROUCH_KNIFE", + "ACT_DOD_HS_CROUCH_MG42", + "ACT_DOD_HS_CROUCH_PISTOL", + "ACT_DOD_HS_CROUCH_STICKGRENADE", + "ACT_DOD_HS_CROUCH_TOMMY", + "ACT_DOD_HS_CROUCH_MP44", + "ACT_DOD_HS_CROUCH_K98", + "ACT_DOD_STAND_IDLE_TNT", + "ACT_DOD_CROUCH_IDLE_TNT", + "ACT_DOD_CROUCHWALK_IDLE_TNT", + "ACT_DOD_WALK_IDLE_TNT", + "ACT_DOD_RUN_IDLE_TNT", + "ACT_DOD_SPRINT_IDLE_TNT", + "ACT_DOD_PRONEWALK_IDLE_TNT", + "ACT_DOD_PLANT_TNT", + "ACT_DOD_DEFUSE_TNT", + "ACT_VM_FIZZLE", + "ACT_MP_STAND_IDLE", + "ACT_MP_CROUCH_IDLE", + "ACT_MP_CROUCH_DEPLOYED_IDLE", + "ACT_MP_CROUCH_DEPLOYED", + "ACT_MP_DEPLOYED_IDLE", + "ACT_MP_RUN", + "ACT_MP_WALK", + "ACT_MP_AIRWALK", + "ACT_MP_CROUCHWALK", + "ACT_MP_SPRINT", + "ACT_MP_JUMP", + "ACT_MP_JUMP_START", + "ACT_MP_JUMP_FLOAT", + "ACT_MP_JUMP_LAND", + "ACT_MP_DOUBLEJUMP", + "ACT_MP_SWIM", + "ACT_MP_DEPLOYED", + "ACT_MP_SWIM_DEPLOYED", + "ACT_MP_VCD", + "ACT_MP_SWIM_IDLE", + "ACT_MP_ATTACK_STAND_PRIMARYFIRE", + "ACT_MP_ATTACK_STAND_PRIMARYFIRE_DEPLOYED", + "ACT_MP_ATTACK_STAND_SECONDARYFIRE", + "ACT_MP_ATTACK_STAND_GRENADE", + "ACT_MP_ATTACK_CROUCH_PRIMARYFIRE", + "ACT_MP_ATTACK_CROUCH_PRIMARYFIRE_DEPLOYED", + "ACT_MP_ATTACK_CROUCH_SECONDARYFIRE", + "ACT_MP_ATTACK_CROUCH_GRENADE", + "ACT_MP_ATTACK_SWIM_PRIMARYFIRE", + "ACT_MP_ATTACK_SWIM_SECONDARYFIRE", + "ACT_MP_ATTACK_SWIM_GRENADE", + "ACT_MP_ATTACK_AIRWALK_PRIMARYFIRE", + "ACT_MP_ATTACK_AIRWALK_SECONDARYFIRE", + "ACT_MP_ATTACK_AIRWALK_GRENADE", + "ACT_MP_RELOAD_STAND", + "ACT_MP_RELOAD_STAND_LOOP", + "ACT_MP_RELOAD_STAND_END", + "ACT_MP_RELOAD_CROUCH", + "ACT_MP_RELOAD_CROUCH_LOOP", + "ACT_MP_RELOAD_CROUCH_END", + "ACT_MP_RELOAD_SWIM", + "ACT_MP_RELOAD_SWIM_LOOP", + "ACT_MP_RELOAD_SWIM_END", + "ACT_MP_RELOAD_AIRWALK", + "ACT_MP_RELOAD_AIRWALK_LOOP", + "ACT_MP_RELOAD_AIRWALK_END", + "ACT_MP_ATTACK_STAND_PREFIRE", + "ACT_MP_ATTACK_STAND_POSTFIRE", + "ACT_MP_ATTACK_STAND_STARTFIRE", + "ACT_MP_ATTACK_CROUCH_PREFIRE", + "ACT_MP_ATTACK_CROUCH_POSTFIRE", + "ACT_MP_ATTACK_SWIM_PREFIRE", + "ACT_MP_ATTACK_SWIM_POSTFIRE", + "ACT_MP_STAND_PRIMARY", + "ACT_MP_CROUCH_PRIMARY", + "ACT_MP_RUN_PRIMARY", + "ACT_MP_WALK_PRIMARY", + "ACT_MP_AIRWALK_PRIMARY", + "ACT_MP_CROUCHWALK_PRIMARY", + "ACT_MP_JUMP_PRIMARY", + "ACT_MP_JUMP_START_PRIMARY", + "ACT_MP_JUMP_FLOAT_PRIMARY", + "ACT_MP_JUMP_LAND_PRIMARY", + "ACT_MP_SWIM_PRIMARY", + "ACT_MP_DEPLOYED_PRIMARY", + "ACT_MP_SWIM_DEPLOYED_PRIMARY", + "ACT_MP_ATTACK_STAND_PRIMARY", + "ACT_MP_ATTACK_STAND_PRIMARY_DEPLOYED", + "ACT_MP_ATTACK_CROUCH_PRIMARY", + "ACT_MP_ATTACK_CROUCH_PRIMARY_DEPLOYED", + "ACT_MP_ATTACK_SWIM_PRIMARY", + "ACT_MP_ATTACK_AIRWALK_PRIMARY", + "ACT_MP_RELOAD_STAND_PRIMARY", + "ACT_MP_RELOAD_STAND_PRIMARY_LOOP", + "ACT_MP_RELOAD_STAND_PRIMARY_END", + "ACT_MP_RELOAD_CROUCH_PRIMARY", + "ACT_MP_RELOAD_CROUCH_PRIMARY_LOOP", + "ACT_MP_RELOAD_CROUCH_PRIMARY_END", + "ACT_MP_RELOAD_SWIM_PRIMARY", + "ACT_MP_RELOAD_SWIM_PRIMARY_LOOP", + "ACT_MP_RELOAD_SWIM_PRIMARY_END", + "ACT_MP_RELOAD_AIRWALK_PRIMARY", + "ACT_MP_RELOAD_AIRWALK_PRIMARY_LOOP", + "ACT_MP_RELOAD_AIRWALK_PRIMARY_END", + "ACT_MP_ATTACK_STAND_GRENADE_PRIMARY", + "ACT_MP_ATTACK_CROUCH_GRENADE_PRIMARY", + "ACT_MP_ATTACK_SWIM_GRENADE_PRIMARY", + "ACT_MP_ATTACK_AIRWALK_GRENADE_PRIMARY", + "ACT_MP_STAND_SECONDARY", + "ACT_MP_CROUCH_SECONDARY", + "ACT_MP_RUN_SECONDARY", + "ACT_MP_WALK_SECONDARY", + "ACT_MP_AIRWALK_SECONDARY", + "ACT_MP_CROUCHWALK_SECONDARY", + "ACT_MP_JUMP_SECONDARY", + "ACT_MP_JUMP_START_SECONDARY", + "ACT_MP_JUMP_FLOAT_SECONDARY", + "ACT_MP_JUMP_LAND_SECONDARY", + "ACT_MP_SWIM_SECONDARY", + "ACT_MP_ATTACK_STAND_SECONDARY", + "ACT_MP_ATTACK_CROUCH_SECONDARY", + "ACT_MP_ATTACK_SWIM_SECONDARY", + "ACT_MP_ATTACK_AIRWALK_SECONDARY", + "ACT_MP_RELOAD_STAND_SECONDARY", + "ACT_MP_RELOAD_STAND_SECONDARY_LOOP", + "ACT_MP_RELOAD_STAND_SECONDARY_END", + "ACT_MP_RELOAD_CROUCH_SECONDARY", + "ACT_MP_RELOAD_CROUCH_SECONDARY_LOOP", + "ACT_MP_RELOAD_CROUCH_SECONDARY_END", + "ACT_MP_RELOAD_SWIM_SECONDARY", + "ACT_MP_RELOAD_SWIM_SECONDARY_LOOP", + "ACT_MP_RELOAD_SWIM_SECONDARY_END", + "ACT_MP_RELOAD_AIRWALK_SECONDARY", + "ACT_MP_RELOAD_AIRWALK_SECONDARY_LOOP", + "ACT_MP_RELOAD_AIRWALK_SECONDARY_END", + "ACT_MP_ATTACK_STAND_GRENADE_SECONDARY", + "ACT_MP_ATTACK_CROUCH_GRENADE_SECONDARY", + "ACT_MP_ATTACK_SWIM_GRENADE_SECONDARY", + "ACT_MP_ATTACK_AIRWALK_GRENADE_SECONDARY", + "ACT_MP_STAND_MELEE", + "ACT_MP_CROUCH_MELEE", + "ACT_MP_RUN_MELEE", + "ACT_MP_WALK_MELEE", + "ACT_MP_AIRWALK_MELEE", + "ACT_MP_CROUCHWALK_MELEE", + "ACT_MP_JUMP_MELEE", + "ACT_MP_JUMP_START_MELEE", + "ACT_MP_JUMP_FLOAT_MELEE", + "ACT_MP_JUMP_LAND_MELEE", + "ACT_MP_SWIM_MELEE", + "ACT_MP_ATTACK_STAND_MELEE", + "ACT_MP_ATTACK_STAND_MELEE_SECONDARY", + "ACT_MP_ATTACK_CROUCH_MELEE", + "ACT_MP_ATTACK_CROUCH_MELEE_SECONDARY", + "ACT_MP_ATTACK_SWIM_MELEE", + "ACT_MP_ATTACK_AIRWALK_MELEE", + "ACT_MP_ATTACK_STAND_GRENADE_MELEE", + "ACT_MP_ATTACK_CROUCH_GRENADE_MELEE", + "ACT_MP_ATTACK_SWIM_GRENADE_MELEE", + "ACT_MP_ATTACK_AIRWALK_GRENADE_MELEE", + "ACT_MP_GESTURE_FLINCH", + "ACT_MP_GESTURE_FLINCH_PRIMARY", + "ACT_MP_GESTURE_FLINCH_SECONDARY", + "ACT_MP_GESTURE_FLINCH_MELEE", + "ACT_MP_GESTURE_FLINCH_HEAD", + "ACT_MP_GESTURE_FLINCH_CHEST", + "ACT_MP_GESTURE_FLINCH_STOMACH", + "ACT_MP_GESTURE_FLINCH_LEFTARM", + "ACT_MP_GESTURE_FLINCH_RIGHTARM", + "ACT_MP_GESTURE_FLINCH_LEFTLEG", + "ACT_MP_GESTURE_FLINCH_RIGHTLEG", + "ACT_MP_GRENADE1_DRAW", + "ACT_MP_GRENADE1_IDLE", + "ACT_MP_GRENADE1_ATTACK", + "ACT_MP_GRENADE2_DRAW", + "ACT_MP_GRENADE2_IDLE", + "ACT_MP_GRENADE2_ATTACK", + "ACT_MP_PRIMARY_GRENADE1_DRAW", + "ACT_MP_PRIMARY_GRENADE1_IDLE", + "ACT_MP_PRIMARY_GRENADE1_ATTACK", + "ACT_MP_PRIMARY_GRENADE2_DRAW", + "ACT_MP_PRIMARY_GRENADE2_IDLE", + "ACT_MP_PRIMARY_GRENADE2_ATTACK", + "ACT_MP_SECONDARY_GRENADE1_DRAW", + "ACT_MP_SECONDARY_GRENADE1_IDLE", + "ACT_MP_SECONDARY_GRENADE1_ATTACK", + "ACT_MP_SECONDARY_GRENADE2_DRAW", + "ACT_MP_SECONDARY_GRENADE2_IDLE", + "ACT_MP_SECONDARY_GRENADE2_ATTACK", + "ACT_MP_MELEE_GRENADE1_DRAW", + "ACT_MP_MELEE_GRENADE1_IDLE", + "ACT_MP_MELEE_GRENADE1_ATTACK", + "ACT_MP_MELEE_GRENADE2_DRAW", + "ACT_MP_MELEE_GRENADE2_IDLE", + "ACT_MP_MELEE_GRENADE2_ATTACK", + "ACT_MP_STAND_BUILDING", + "ACT_MP_CROUCH_BUILDING", + "ACT_MP_RUN_BUILDING", + "ACT_MP_WALK_BUILDING", + "ACT_MP_AIRWALK_BUILDING", + "ACT_MP_CROUCHWALK_BUILDING", + "ACT_MP_JUMP_BUILDING", + "ACT_MP_JUMP_START_BUILDING", + "ACT_MP_JUMP_FLOAT_BUILDING", + "ACT_MP_JUMP_LAND_BUILDING", + "ACT_MP_SWIM_BUILDING", + "ACT_MP_ATTACK_STAND_BUILDING", + "ACT_MP_ATTACK_CROUCH_BUILDING", + "ACT_MP_ATTACK_SWIM_BUILDING", + "ACT_MP_ATTACK_AIRWALK_BUILDING", + "ACT_MP_ATTACK_STAND_GRENADE_BUILDING", + "ACT_MP_ATTACK_CROUCH_GRENADE_BUILDING", + "ACT_MP_ATTACK_SWIM_GRENADE_BUILDING", + "ACT_MP_ATTACK_AIRWALK_GRENADE_BUILDING", + "ACT_MP_STAND_PDA", + "ACT_MP_CROUCH_PDA", + "ACT_MP_RUN_PDA", + "ACT_MP_WALK_PDA", + "ACT_MP_AIRWALK_PDA", + "ACT_MP_CROUCHWALK_PDA", + "ACT_MP_JUMP_PDA", + "ACT_MP_JUMP_START_PDA", + "ACT_MP_JUMP_FLOAT_PDA", + "ACT_MP_JUMP_LAND_PDA", + "ACT_MP_SWIM_PDA", + "ACT_MP_ATTACK_STAND_PDA", + "ACT_MP_ATTACK_SWIM_PDA", + "ACT_MP_GESTURE_VC_HANDMOUTH", + "ACT_MP_GESTURE_VC_FINGERPOINT", + "ACT_MP_GESTURE_VC_FISTPUMP", + "ACT_MP_GESTURE_VC_THUMBSUP", + "ACT_MP_GESTURE_VC_NODYES", + "ACT_MP_GESTURE_VC_NODNO", + "ACT_MP_GESTURE_VC_HANDMOUTH_PRIMARY", + "ACT_MP_GESTURE_VC_FINGERPOINT_PRIMARY", + "ACT_MP_GESTURE_VC_FISTPUMP_PRIMARY", + "ACT_MP_GESTURE_VC_THUMBSUP_PRIMARY", + "ACT_MP_GESTURE_VC_NODYES_PRIMARY", + "ACT_MP_GESTURE_VC_NODNO_PRIMARY", + "ACT_MP_GESTURE_VC_HANDMOUTH_SECONDARY", + "ACT_MP_GESTURE_VC_FINGERPOINT_SECONDARY", + "ACT_MP_GESTURE_VC_FISTPUMP_SECONDARY", + "ACT_MP_GESTURE_VC_THUMBSUP_SECONDARY", + "ACT_MP_GESTURE_VC_NODYES_SECONDARY", + "ACT_MP_GESTURE_VC_NODNO_SECONDARY", + "ACT_MP_GESTURE_VC_HANDMOUTH_MELEE", + "ACT_MP_GESTURE_VC_FINGERPOINT_MELEE", + "ACT_MP_GESTURE_VC_FISTPUMP_MELEE", + "ACT_MP_GESTURE_VC_THUMBSUP_MELEE", + "ACT_MP_GESTURE_VC_NODYES_MELEE", + "ACT_MP_GESTURE_VC_NODNO_MELEE", + "ACT_MP_GESTURE_VC_HANDMOUTH_BUILDING", + "ACT_MP_GESTURE_VC_FINGERPOINT_BUILDING", + "ACT_MP_GESTURE_VC_FISTPUMP_BUILDING", + "ACT_MP_GESTURE_VC_THUMBSUP_BUILDING", + "ACT_MP_GESTURE_VC_NODYES_BUILDING", + "ACT_MP_GESTURE_VC_NODNO_BUILDING", + "ACT_MP_GESTURE_VC_HANDMOUTH_PDA", + "ACT_MP_GESTURE_VC_FINGERPOINT_PDA", + "ACT_MP_GESTURE_VC_FISTPUMP_PDA", + "ACT_MP_GESTURE_VC_THUMBSUP_PDA", + "ACT_MP_GESTURE_VC_NODYES_PDA", + "ACT_MP_GESTURE_VC_NODNO_PDA", + "ACT_VM_UNUSABLE", + "ACT_VM_UNUSABLE_TO_USABLE", + "ACT_VM_USABLE_TO_UNUSABLE", + "ACT_GMOD_GESTURE_AGREE", + "ACT_GMOD_GESTURE_BECON", + "ACT_GMOD_GESTURE_BOW", + "ACT_GMOD_GESTURE_DISAGREE", + "ACT_GMOD_TAUNT_SALUTE", + "ACT_GMOD_GESTURE_WAVE", + "ACT_GMOD_TAUNT_PERSISTENCE", + "ACT_GMOD_TAUNT_MUSCLE", + "ACT_GMOD_TAUNT_LAUGH", + "ACT_GMOD_GESTURE_POINT", + "ACT_GMOD_TAUNT_CHEER", + "ACT_HL2MP_RUN_FAST", + "ACT_HL2MP_RUN_CHARGING", + "ACT_HL2MP_RUN_PANICKED", + "ACT_HL2MP_RUN_PROTECTED", + "ACT_HL2MP_IDLE_MELEE_ANGRY", + "ACT_HL2MP_ZOMBIE_SLUMP_IDLE", + "ACT_HL2MP_ZOMBIE_SLUMP_RISE", + "ACT_HL2MP_WALK_ZOMBIE_01", + "ACT_HL2MP_WALK_ZOMBIE_02", + "ACT_HL2MP_WALK_ZOMBIE_03", + "ACT_HL2MP_WALK_ZOMBIE_04", + "ACT_HL2MP_WALK_ZOMBIE_05", + "ACT_HL2MP_WALK_CROUCH_ZOMBIE_01", + "ACT_HL2MP_WALK_CROUCH_ZOMBIE_02", + "ACT_HL2MP_WALK_CROUCH_ZOMBIE_03", + "ACT_HL2MP_WALK_CROUCH_ZOMBIE_04", + "ACT_HL2MP_WALK_CROUCH_ZOMBIE_05", + "ACT_HL2MP_IDLE_CROUCH_ZOMBIE_01", + "ACT_HL2MP_IDLE_CROUCH_ZOMBIE_02", + "ACT_GMOD_GESTURE_RANGE_ZOMBIE", + "ACT_GMOD_GESTURE_TAUNT_ZOMBIE", + "ACT_GMOD_TAUNT_DANCE", + "ACT_GMOD_TAUNT_ROBOT", + "ACT_GMOD_GESTURE_RANGE_ZOMBIE_SPECIAL", + "ACT_GMOD_GESTURE_RANGE_FRENZY", + "ACT_HL2MP_RUN_ZOMBIE_FAST", + "ACT_HL2MP_WALK_ZOMBIE_06", + "ACT_ZOMBIE_LEAP_START", + "ACT_ZOMBIE_LEAPING", + "ACT_ZOMBIE_CLIMB_UP", + "ACT_ZOMBIE_CLIMB_START", + "ACT_ZOMBIE_CLIMB_END", + "ACT_HL2MP_IDLE_MAGIC", + "ACT_HL2MP_WALK_MAGIC", + "ACT_HL2MP_RUN_MAGIC", + "ACT_HL2MP_IDLE_CROUCH_MAGIC", + "ACT_HL2MP_WALK_CROUCH_MAGIC", + "ACT_HL2MP_GESTURE_RANGE_ATTACK_MAGIC", + "ACT_HL2MP_GESTURE_RELOAD_MAGIC", + "ACT_HL2MP_JUMP_MAGIC", + "ACT_HL2MP_SWIM_IDLE_MAGIC", + "ACT_HL2MP_SWIM_MAGIC", + "ACT_HL2MP_IDLE_REVOLVER", + "ACT_HL2MP_WALK_REVOLVER", + "ACT_HL2MP_RUN_REVOLVER", + "ACT_HL2MP_IDLE_CROUCH_REVOLVER", + "ACT_HL2MP_WALK_CROUCH_REVOLVER", + "ACT_HL2MP_GESTURE_RANGE_ATTACK_REVOLVER", + "ACT_HL2MP_GESTURE_RELOAD_REVOLVER", + "ACT_HL2MP_JUMP_REVOLVER", + "ACT_HL2MP_SWIM_IDLE_REVOLVER", + "ACT_HL2MP_SWIM_REVOLVER", + "ACT_HL2MP_IDLE_CAMERA", + "ACT_HL2MP_WALK_CAMERA", + "ACT_HL2MP_RUN_CAMERA", + "ACT_HL2MP_IDLE_CROUCH_CAMERA", + "ACT_HL2MP_WALK_CROUCH_CAMERA", + "ACT_HL2MP_GESTURE_RANGE_ATTACK_CAMERA", + "ACT_HL2MP_GESTURE_RELOAD_CAMERA", + "ACT_HL2MP_JUMP_CAMERA", + "ACT_HL2MP_SWIM_IDLE_CAMERA", + "ACT_HL2MP_SWIM_CAMERA", + "ACT_HL2MP_IDLE_ANGRY", + "ACT_HL2MP_WALK_ANGRY", + "ACT_HL2MP_RUN_ANGRY", + "ACT_HL2MP_IDLE_CROUCH_ANGRY", + "ACT_HL2MP_WALK_CROUCH_ANGRY", + "ACT_HL2MP_GESTURE_RANGE_ATTACK_ANGRY", + "ACT_HL2MP_GESTURE_RELOAD_ANGRY", + "ACT_HL2MP_JUMP_ANGRY", + "ACT_HL2MP_SWIM_IDLE_ANGRY", + "ACT_HL2MP_SWIM_ANGRY", + "ACT_HL2MP_IDLE_SCARED", + "ACT_HL2MP_WALK_SCARED", + "ACT_HL2MP_RUN_SCARED", + "ACT_HL2MP_IDLE_CROUCH_SCARED", + "ACT_HL2MP_WALK_CROUCH_SCARED", + "ACT_HL2MP_GESTURE_RANGE_ATTACK_SCARED", + "ACT_HL2MP_GESTURE_RELOAD_SCARED", + "ACT_HL2MP_JUMP_SCARED", + "ACT_HL2MP_SWIM_IDLE_SCARED", + "ACT_HL2MP_SWIM_SCARED", + "ACT_HL2MP_IDLE_ZOMBIE", + "ACT_HL2MP_WALK_ZOMBIE", + "ACT_HL2MP_RUN_ZOMBIE", + "ACT_HL2MP_IDLE_CROUCH_ZOMBIE", + "ACT_HL2MP_WALK_CROUCH_ZOMBIE", + "ACT_HL2MP_GESTURE_RANGE_ATTACK_ZOMBIE", + "ACT_HL2MP_GESTURE_RELOAD_ZOMBIE", + "ACT_HL2MP_JUMP_ZOMBIE", + "ACT_HL2MP_SWIM_IDLE_ZOMBIE", + "ACT_HL2MP_SWIM_ZOMBIE", + "ACT_HL2MP_IDLE_SUITCASE", + "ACT_HL2MP_WALK_SUITCASE", + "ACT_HL2MP_RUN_SUITCASE", + "ACT_HL2MP_IDLE_CROUCH_SUITCASE", + "ACT_HL2MP_WALK_CROUCH_SUITCASE", + "ACT_HL2MP_GESTURE_RANGE_ATTACK_SUITCASE", + "ACT_HL2MP_GESTURE_RELOAD_SUITCASE", + "ACT_HL2MP_JUMP_SUITCASE", + "ACT_HL2MP_SWIM_IDLE_SUITCASE", + "ACT_HL2MP_SWIM_SUITCASE", + "ACT_HL2MP_IDLE", + "ACT_HL2MP_WALK", + "ACT_HL2MP_RUN", + "ACT_HL2MP_IDLE_CROUCH", + "ACT_HL2MP_WALK_CROUCH", + "ACT_HL2MP_GESTURE_RANGE_ATTACK", + "ACT_HL2MP_GESTURE_RELOAD", + "ACT_HL2MP_JUMP", + "ACT_HL2MP_SWIM", + "ACT_HL2MP_IDLE_PISTOL", + "ACT_HL2MP_WALK_PISTOL", + "ACT_HL2MP_RUN_PISTOL", + "ACT_HL2MP_IDLE_CROUCH_PISTOL", + "ACT_HL2MP_WALK_CROUCH_PISTOL", + "ACT_HL2MP_GESTURE_RANGE_ATTACK_PISTOL", + "ACT_HL2MP_GESTURE_RELOAD_PISTOL", + "ACT_HL2MP_JUMP_PISTOL", + "ACT_HL2MP_SWIM_IDLE_PISTOL", + "ACT_HL2MP_SWIM_PISTOL", + "ACT_HL2MP_IDLE_SMG1", + "ACT_HL2MP_WALK_SMG1", + "ACT_HL2MP_RUN_SMG1", + "ACT_HL2MP_IDLE_CROUCH_SMG1", + "ACT_HL2MP_WALK_CROUCH_SMG1", + "ACT_HL2MP_GESTURE_RANGE_ATTACK_SMG1", + "ACT_HL2MP_GESTURE_RELOAD_SMG1", + "ACT_HL2MP_JUMP_SMG1", + "ACT_HL2MP_SWIM_IDLE_SMG1", + "ACT_HL2MP_SWIM_SMG1", + "ACT_HL2MP_IDLE_AR2", + "ACT_HL2MP_WALK_AR2", + "ACT_HL2MP_RUN_AR2", + "ACT_HL2MP_IDLE_CROUCH_AR2", + "ACT_HL2MP_WALK_CROUCH_AR2", + "ACT_HL2MP_GESTURE_RANGE_ATTACK_AR2", + "ACT_HL2MP_GESTURE_RELOAD_AR2", + "ACT_HL2MP_JUMP_AR2", + "ACT_HL2MP_SWIM_IDLE_AR2", + "ACT_HL2MP_SWIM_AR2", + "ACT_HL2MP_IDLE_SHOTGUN", + "ACT_HL2MP_WALK_SHOTGUN", + "ACT_HL2MP_RUN_SHOTGUN", + "ACT_HL2MP_IDLE_CROUCH_SHOTGUN", + "ACT_HL2MP_WALK_CROUCH_SHOTGUN", + "ACT_HL2MP_GESTURE_RANGE_ATTACK_SHOTGUN", + "ACT_HL2MP_GESTURE_RELOAD_SHOTGUN", + "ACT_HL2MP_JUMP_SHOTGUN", + "ACT_HL2MP_SWIM_IDLE_SHOTGUN", + "ACT_HL2MP_SWIM_SHOTGUN", + "ACT_HL2MP_IDLE_RPG", + "ACT_HL2MP_WALK_RPG", + "ACT_HL2MP_RUN_RPG", + "ACT_HL2MP_IDLE_CROUCH_RPG", + "ACT_HL2MP_WALK_CROUCH_RPG", + "ACT_HL2MP_GESTURE_RANGE_ATTACK_RPG", + "ACT_HL2MP_GESTURE_RELOAD_RPG", + "ACT_HL2MP_JUMP_RPG", + "ACT_HL2MP_SWIM_IDLE_RPG", + "ACT_HL2MP_SWIM_RPG", + "ACT_HL2MP_IDLE_GRENADE", + "ACT_HL2MP_WALK_GRENADE", + "ACT_HL2MP_RUN_GRENADE", + "ACT_HL2MP_IDLE_CROUCH_GRENADE", + "ACT_HL2MP_WALK_CROUCH_GRENADE", + "ACT_HL2MP_GESTURE_RANGE_ATTACK_GRENADE", + "ACT_HL2MP_GESTURE_RELOAD_GRENADE", + "ACT_HL2MP_JUMP_GRENADE", + "ACT_HL2MP_SWIM_IDLE_GRENADE", + "ACT_HL2MP_SWIM_GRENADE", + "ACT_HL2MP_IDLE_DUEL", + "ACT_HL2MP_WALK_DUEL", + "ACT_HL2MP_RUN_DUEL", + "ACT_HL2MP_IDLE_CROUCH_DUEL", + "ACT_HL2MP_WALK_CROUCH_DUEL", + "ACT_HL2MP_GESTURE_RANGE_ATTACK_DUEL", + "ACT_HL2MP_GESTURE_RELOAD_DUEL", + "ACT_HL2MP_JUMP_DUEL", + "ACT_HL2MP_SWIM_IDLE_DUEL", + "ACT_HL2MP_SWIM_DUEL", + "ACT_HL2MP_IDLE_PHYSGUN", + "ACT_HL2MP_WALK_PHYSGUN", + "ACT_HL2MP_RUN_PHYSGUN", + "ACT_HL2MP_IDLE_CROUCH_PHYSGUN", + "ACT_HL2MP_WALK_CROUCH_PHYSGUN", + "ACT_HL2MP_GESTURE_RANGE_ATTACK_PHYSGUN", + "ACT_HL2MP_GESTURE_RELOAD_PHYSGUN", + "ACT_HL2MP_JUMP_PHYSGUN", + "ACT_HL2MP_SWIM_IDLE_PHYSGUN", + "ACT_HL2MP_SWIM_PHYSGUN", + "ACT_HL2MP_IDLE_CROSSBOW", + "ACT_HL2MP_WALK_CROSSBOW", + "ACT_HL2MP_RUN_CROSSBOW", + "ACT_HL2MP_IDLE_CROUCH_CROSSBOW", + "ACT_HL2MP_WALK_CROUCH_CROSSBOW", + "ACT_HL2MP_GESTURE_RANGE_ATTACK_CROSSBOW", + "ACT_HL2MP_GESTURE_RELOAD_CROSSBOW", + "ACT_HL2MP_JUMP_CROSSBOW", + "ACT_HL2MP_SWIM_IDLE_CROSSBOW", + "ACT_HL2MP_SWIM_CROSSBOW", + "ACT_HL2MP_IDLE_MELEE", + "ACT_HL2MP_WALK_MELEE", + "ACT_HL2MP_RUN_MELEE", + "ACT_HL2MP_IDLE_CROUCH_MELEE", + "ACT_HL2MP_WALK_CROUCH_MELEE", + "ACT_HL2MP_GESTURE_RANGE_ATTACK_MELEE", + "ACT_HL2MP_GESTURE_RELOAD_MELEE", + "ACT_HL2MP_JUMP_MELEE", + "ACT_HL2MP_SWIM_IDLE_MELEE", + "ACT_HL2MP_SWIM_MELEE", + "ACT_HL2MP_IDLE_SLAM", + "ACT_HL2MP_WALK_SLAM", + "ACT_HL2MP_RUN_SLAM", + "ACT_HL2MP_IDLE_CROUCH_SLAM", + "ACT_HL2MP_WALK_CROUCH_SLAM", + "ACT_HL2MP_GESTURE_RANGE_ATTACK_SLAM", + "ACT_HL2MP_GESTURE_RELOAD_SLAM", + "ACT_HL2MP_JUMP_SLAM", + "ACT_HL2MP_SWIM_IDLE_SLAM", + "ACT_HL2MP_SWIM_SLAM", + "ACT_VM_CRAWL", + "ACT_VM_CRAWL_EMPTY", + "ACT_VM_HOLSTER_EMPTY", + "ACT_VM_DOWN", + "ACT_VM_DOWN_EMPTY", + "ACT_VM_READY", + "ACT_VM_ISHOOT", + "ACT_VM_IIN", + "ACT_VM_IIN_EMPTY", + "ACT_VM_IIDLE", + "ACT_VM_IIDLE_EMPTY", + "ACT_VM_IOUT", + "ACT_VM_IOUT_EMPTY", + "ACT_VM_PULLBACK_HIGH_BAKE", + "ACT_VM_HITKILL", + "ACT_VM_DEPLOYED_IN", + "ACT_VM_DEPLOYED_IDLE", + "ACT_VM_DEPLOYED_FIRE", + "ACT_VM_DEPLOYED_DRYFIRE", + "ACT_VM_DEPLOYED_RELOAD", + "ACT_VM_DEPLOYED_RELOAD_EMPTY", + "ACT_VM_DEPLOYED_OUT", + "ACT_VM_DEPLOYED_IRON_IN", + "ACT_VM_DEPLOYED_IRON_IDLE", + "ACT_VM_DEPLOYED_IRON_FIRE", + "ACT_VM_DEPLOYED_IRON_DRYFIRE", + "ACT_VM_DEPLOYED_IRON_OUT", + "ACT_VM_DEPLOYED_LIFTED_IN", + "ACT_VM_DEPLOYED_LIFTED_IDLE", + "ACT_VM_DEPLOYED_LIFTED_OUT", + "ACT_VM_RELOADEMPTY", + "ACT_VM_IRECOIL1", + "ACT_VM_IRECOIL2", + "ACT_VM_FIREMODE", + "ACT_VM_ISHOOT_LAST", + "ACT_VM_IFIREMODE", + "ACT_VM_DFIREMODE", + "ACT_VM_DIFIREMODE", + "ACT_VM_SHOOTLAST", + "ACT_VM_ISHOOTDRY", + "ACT_VM_DRAW_M203", + "ACT_VM_DRAWFULL_M203", + "ACT_VM_READY_M203", + "ACT_VM_IDLE_M203", + "ACT_VM_RELOAD_M203", + "ACT_VM_HOLSTER_M203", + "ACT_VM_HOLSTERFULL_M203", + "ACT_VM_IIN_M203", + "ACT_VM_IIDLE_M203", + "ACT_VM_IOUT_M203", + "ACT_VM_CRAWL_M203", + "ACT_VM_DOWN_M203", + "ACT_VM_ISHOOT_M203", + "ACT_VM_RELOAD_INSERT", + "ACT_VM_RELOAD_INSERT_PULL", + "ACT_VM_RELOAD_END", + "ACT_VM_RELOAD_END_EMPTY", + "ACT_VM_RELOAD_INSERT_EMPTY", + "ACT_CROSSBOW_HOLSTER_UNLOADED", + "ACT_VM_FIRE_TO_EMPTY", + "ACT_VM_UNLOAD", + "ACT_VM_RELOAD2", + "ACT_GMOD_NOCLIP_LAYER", + "ACT_HL2MP_IDLE_FIST", + "ACT_HL2MP_WALK_FIST", + "ACT_HL2MP_RUN_FIST", + "ACT_HL2MP_IDLE_CROUCH_FIST", + "ACT_HL2MP_WALK_CROUCH_FIST", + "ACT_HL2MP_GESTURE_RANGE_ATTACK_FIST", + "ACT_HL2MP_GESTURE_RELOAD_FIST", + "ACT_HL2MP_JUMP_FIST", + "ACT_HL2MP_SWIM_IDLE_FIST", + "ACT_HL2MP_SWIM_FIST", + "ACT_HL2MP_SIT", + "ACT_HL2MP_FIST_BLOCK", + "ACT_DRIVE_AIRBOAT", + "ACT_DRIVE_JEEP", + "ACT_GMOD_SIT_ROLLERCOASTER", + "ACT_HL2MP_IDLE_KNIFE", + "ACT_HL2MP_WALK_KNIFE", + "ACT_HL2MP_RUN_KNIFE", + "ACT_HL2MP_IDLE_CROUCH_KNIFE", + "ACT_HL2MP_WALK_CROUCH_KNIFE", + "ACT_HL2MP_GESTURE_RANGE_ATTACK_KNIFE", + "ACT_HL2MP_GESTURE_RELOAD_KNIFE", + "ACT_HL2MP_JUMP_KNIFE", + "ACT_HL2MP_SWIM_IDLE_KNIFE", + "ACT_HL2MP_SWIM_KNIFE", + "ACT_HL2MP_IDLE_PASSIVE", + "ACT_HL2MP_WALK_PASSIVE", + "ACT_HL2MP_RUN_PASSIVE", + "ACT_HL2MP_IDLE_CROUCH_PASSIVE", + "ACT_HL2MP_WALK_CROUCH_PASSIVE", + "ACT_HL2MP_GESTURE_RANGE_ATTACK_PASSIVE", + "ACT_HL2MP_GESTURE_RELOAD_PASSIVE", + "ACT_HL2MP_JUMP_PASSIVE", + "ACT_HL2MP_SWIM_PASSIVE", + "ACT_HL2MP_SWIM_IDLE_PASSIVE", + "ACT_HL2MP_IDLE_MELEE2", + "ACT_HL2MP_WALK_MELEE2", + "ACT_HL2MP_RUN_MELEE2", + "ACT_HL2MP_IDLE_CROUCH_MELEE2", + "ACT_HL2MP_WALK_CROUCH_MELEE2", + "ACT_HL2MP_GESTURE_RANGE_ATTACK_MELEE2", + "ACT_HL2MP_GESTURE_RELOAD_MELEE2", + "ACT_HL2MP_JUMP_MELEE2", + "ACT_HL2MP_SWIM_IDLE_MELEE2", + "ACT_HL2MP_SWIM_MELEE2", + "ACT_HL2MP_SIT_PISTOL", + "ACT_HL2MP_SIT_SHOTGUN", + "ACT_HL2MP_SIT_SMG1", + "ACT_HL2MP_SIT_AR2", + "ACT_HL2MP_SIT_PHYSGUN", + "ACT_HL2MP_SIT_GRENADE", + "ACT_HL2MP_SIT_RPG", + "ACT_HL2MP_SIT_CROSSBOW", + "ACT_HL2MP_SIT_MELEE", + "ACT_HL2MP_SIT_SLAM", + "ACT_HL2MP_SIT_FIST", + "ACT_GMOD_IN_CHAT", + "ACT_GMOD_GESTURE_ITEM_GIVE", + "ACT_GMOD_GESTURE_ITEM_DROP", + "ACT_GMOD_GESTURE_ITEM_PLACE", + "ACT_GMOD_GESTURE_ITEM_THROW", + "ACT_GMOD_GESTURE_MELEE_SHOVE_2HAND", + "ACT_GMOD_GESTURE_MELEE_SHOVE_1HAND", + "ACT_HL2MP_SWIM_IDLE", + + --- BLOOD_COLOR + "BLOOD_COLOR_RED", + "BLOOD_COLOR_YELLOW", + "BLOOD_COLOR_GREEN", + "BLOOD_COLOR_MECH", + "BLOOD_COLOR_ANTLION", + "BLOOD_COLOR_ZOMBIE", + "BLOOD_COLOR_ANTLION_WORKER", + + --- BONE + "BONE_PHYSICALLY_SIMULATED", + "BONE_PHYSICS_PROCEDURAL", + "BONE_ALWAYS_PROCEDURAL", + "BONE_SCREEN_ALIGN_SPHERE", + "BONE_SCREEN_ALIGN_CYLINDER", + "BONE_CALCULATE_MASK", + "BONE_USED_BY_HITBOX", + "BONE_USED_BY_ATTACHMENT", + "BONE_USED_BY_VERTEX_LOD0", + "BONE_USED_BY_VERTEX_LOD1", + "BONE_USED_BY_VERTEX_LOD2", + "BONE_USED_BY_VERTEX_LOD3", + "BONE_USED_BY_VERTEX_LOD4", + "BONE_USED_BY_VERTEX_LOD5", + "BONE_USED_BY_VERTEX_LOD6", + "BONE_USED_BY_VERTEX_LOD7", + "BONE_USED_BY_VERTEX_MASK", + "BONE_USED_BY_BONE_MERGE", + "BONE_USED_BY_ANYTHING", + "BONE_USED_MASK", + + --- BOX + "BOX_FRONT", + "BOX_BACK", + "BOX_RIGHT", + "BOX_LEFT", + "BOX_TOP", + "BOX_BOTTOM", + + --- BUTTON_CODE + "BUTTON_CODE_INVALID", + "BUTTON_CODE_NONE", + "BUTTON_CODE_LAST", + "BUTTON_CODE_COUNT", + + --- CAP + "CAP_SIMPLE_RADIUS_DAMAGE", + "CAP_MOVE_GROUND", + "CAP_MOVE_JUMP", + "CAP_MOVE_FLY", + "CAP_MOVE_CLIMB", + "CAP_MOVE_SWIM", + "CAP_MOVE_CRAWL", + "CAP_MOVE_SHOOT", + "CAP_SKIP_NAV_GROUND_CHECK", + "CAP_USE", + "CAP_AUTO_DOORS", + "CAP_OPEN_DOORS", + "CAP_TURN_HEAD", + "CAP_WEAPON_RANGE_ATTACK1", + "CAP_WEAPON_RANGE_ATTACK2", + "CAP_WEAPON_MELEE_ATTACK1", + "CAP_WEAPON_MELEE_ATTACK2", + "CAP_INNATE_RANGE_ATTACK1", + "CAP_INNATE_RANGE_ATTACK2", + "CAP_INNATE_MELEE_ATTACK1", + "CAP_INNATE_MELEE_ATTACK2", + "CAP_USE_WEAPONS", + "CAP_USE_SHOT_REGULATOR", + "CAP_ANIMATEDFACE", + "CAP_FRIENDLY_DMG_IMMUNE", + "CAP_SQUAD", + "CAP_DUCK", + "CAP_NO_HIT_PLAYER", + "CAP_AIM_GUN", + "CAP_NO_HIT_SQUADMATES", + + --- CHAN + "CHAN_REPLACE", + "CHAN_AUTO", + "CHAN_WEAPON", + "CHAN_VOICE", + "CHAN_ITEM", + "CHAN_BODY", + "CHAN_STREAM", + "CHAN_STATIC", + "CHAN_VOICE2", + "CHAN_VOICE_BASE", + "CHAN_USER_BASE", + + --- CLASS + "CLASS_NONE", + "CLASS_PLAYER", + "CLASS_PLAYER_ALLY", + "CLASS_PLAYER_ALLY_VITAL", + "CLASS_ANTLION", + "CLASS_BARNACLE", + "CLASS_BULLSEYE", + "CLASS_CITIZEN_PASSIVE", + "CLASS_CITIZEN_REBEL", + "CLASS_COMBINE", + "CLASS_COMBINE_GUNSHIP", + "CLASS_CONSCRIPT", + "CLASS_HEADCRAB", + "CLASS_MANHACK", + "CLASS_METROPOLICE", + "CLASS_MILITARY", + "CLASS_SCANNER", + "CLASS_STALKER", + "CLASS_VORTIGAUNT", + "CLASS_ZOMBIE", + "CLASS_PROTOSNIPER", + "CLASS_MISSILE", + "CLASS_FLARE", + "CLASS_EARTH_FAUNA", + "CLASS_HACKED_ROLLERMINE", + "CLASS_COMBINE_HUNTER", + + --- COLLISION_GROUP + "COLLISION_GROUP_NONE", + "COLLISION_GROUP_DEBRIS", + "COLLISION_GROUP_DEBRIS_TRIGGER", + "COLLISION_GROUP_INTERACTIVE_DEBRIS", + "COLLISION_GROUP_INTERACTIVE", + "COLLISION_GROUP_PLAYER", + "COLLISION_GROUP_BREAKABLE_GLASS", + "COLLISION_GROUP_VEHICLE", + "COLLISION_GROUP_PLAYER_MOVEMENT", + "COLLISION_GROUP_NPC", + "COLLISION_GROUP_IN_VEHICLE", + "COLLISION_GROUP_WEAPON", + "COLLISION_GROUP_VEHICLE_CLIP", + "COLLISION_GROUP_PROJECTILE", + "COLLISION_GROUP_DOOR_BLOCKER", + "COLLISION_GROUP_PASSABLE_DOOR", + "COLLISION_GROUP_DISSOLVING", + "COLLISION_GROUP_PUSHAWAY", + "COLLISION_GROUP_NPC_ACTOR", + "COLLISION_GROUP_NPC_SCRIPTED", + "COLLISION_GROUP_WORLD", + + --- COND + "COND_BEHIND_ENEMY", + "COND_BETTER_WEAPON_AVAILABLE", + "COND_CAN_MELEE_ATTACK1", + "COND_CAN_MELEE_ATTACK2", + "COND_CAN_RANGE_ATTACK1", + "COND_CAN_RANGE_ATTACK2", + "COND_ENEMY_DEAD", + "COND_ENEMY_FACING_ME", + "COND_ENEMY_OCCLUDED", + "COND_ENEMY_TOO_FAR", + "COND_ENEMY_UNREACHABLE", + "COND_ENEMY_WENT_NULL", + "COND_FLOATING_OFF_GROUND", + "COND_GIVE_WAY", + "COND_HAVE_ENEMY_LOS", + "COND_HAVE_TARGET_LOS", + "COND_HEALTH_ITEM_AVAILABLE", + "COND_HEAR_BUGBAIT", + "COND_HEAR_BULLET_IMPACT", + "COND_HEAR_COMBAT", + "COND_HEAR_DANGER", + "COND_HEAR_MOVE_AWAY", + "COND_HEAR_PHYSICS_DANGER", + "COND_HEAR_PLAYER", + "COND_HEAR_SPOOKY", + "COND_HEAR_THUMPER", + "COND_HEAR_WORLD", + "COND_HEAVY_DAMAGE", + "COND_IDLE_INTERRUPT", + "COND_IN_PVS", + "COND_LIGHT_DAMAGE", + "COND_LOST_ENEMY", + "COND_LOST_PLAYER", + "COND_LOW_PRIMARY_AMMO", + "COND_MOBBED_BY_ENEMIES", + "COND_NEW_ENEMY", + "COND_NO_CUSTOM_INTERRUPTS", + "COND_NO_HEAR_DANGER", + "COND_NO_PRIMARY_AMMO", + "COND_NO_SECONDARY_AMMO", + "COND_NO_WEAPON", + "COND_NONE", + "COND_NOT_FACING_ATTACK", + "COND_NPC_FREEZE", + "COND_NPC_UNFREEZE", + "COND_PHYSICS_DAMAGE", + "COND_PLAYER_ADDED_TO_SQUAD", + "COND_PLAYER_PUSHING", + "COND_PLAYER_REMOVED_FROM_SQUAD", + "COND_PROVOKED", + "COND_RECEIVED_ORDERS", + "COND_REPEATED_DAMAGE", + "COND_SCHEDULE_DONE", + "COND_SEE_DISLIKE", + "COND_SEE_ENEMY", + "COND_SEE_FEAR", + "COND_SEE_HATE", + "COND_SEE_NEMESIS", + "COND_SEE_PLAYER", + "COND_SMELL", + "COND_TALKER_RESPOND_TO_QUESTION", + "COND_TARGET_OCCLUDED", + "COND_TASK_FAILED", + "COND_TOO_CLOSE_TO_ATTACK", + "COND_TOO_FAR_TO_ATTACK", + "COND_WAY_CLEAR", + "COND_WEAPON_BLOCKED_BY_FRIEND", + "COND_WEAPON_HAS_LOS", + "COND_WEAPON_PLAYER_IN_SPREAD", + "COND_WEAPON_PLAYER_NEAR_TARGET", + "COND_WEAPON_SIGHT_OCCLUDED", + + --- CONTENTS + "CONTENTS_EMPTY", + "CONTENTS_SOLID", + "CONTENTS_WINDOW", + "CONTENTS_AUX", + "CONTENTS_GRATE", + "CONTENTS_SLIME", + "CONTENTS_WATER", + "CONTENTS_BLOCKLOS", + "CONTENTS_OPAQUE", + "CONTENTS_TESTFOGVOLUME", + "CONTENTS_TEAM4", + "CONTENTS_TEAM3", + "CONTENTS_TEAM1", + "CONTENTS_TEAM2", + "CONTENTS_IGNORE_NODRAW_OPAQUE", + "CONTENTS_MOVEABLE", + "CONTENTS_AREAPORTAL", + "CONTENTS_PLAYERCLIP", + "CONTENTS_MONSTERCLIP", + "CONTENTS_CURRENT_0", + "CONTENTS_CURRENT_180", + "CONTENTS_CURRENT_270", + "CONTENTS_CURRENT_90", + "CONTENTS_CURRENT_DOWN", + "CONTENTS_CURRENT_UP", + "CONTENTS_DEBRIS", + "CONTENTS_DETAIL", + "CONTENTS_HITBOX", + "CONTENTS_LADDER", + "CONTENTS_MONSTER", + "CONTENTS_ORIGIN", + "CONTENTS_TRANSLUCENT", + + --- CREATERENDERTARGETFLAGS + "CREATERENDERTARGETFLAGS_HDR", + "CREATERENDERTARGETFLAGS_AUTOMIPMAP", + "CREATERENDERTARGETFLAGS_UNFILTERABLE_OK", + + --- CT + "CT_DEFAULT", + "CT_DOWNTRODDEN", + "CT_REFUGEE", + "CT_REBEL", + "CT_UNIQUE", + + --- D + "D_ER", + "D_HT", + "D_FR", + "D_LI", + "D_NU", + + --- DMG + "DMG_GENERIC", + "DMG_CRUSH", + "DMG_BULLET", + "DMG_SLASH", + "DMG_BURN", + "DMG_VEHICLE", + "DMG_FALL", + "DMG_BLAST", + "DMG_CLUB", + "DMG_SHOCK", + "DMG_SONIC", + "DMG_ENERGYBEAM", + "DMG_NEVERGIB", + "DMG_ALWAYSGIB", + "DMG_DROWN", + "DMG_PARALYZE", + "DMG_NERVEGAS", + "DMG_POISON", + "DMG_ACID", + "DMG_AIRBOAT", + "DMG_BLAST_SURFACE", + "DMG_BUCKSHOT", + "DMG_DIRECT", + "DMG_DISSOLVE", + "DMG_DROWNRECOVER", + "DMG_PHYSGUN", + "DMG_PLASMA", + "DMG_PREVENT_PHYSICS_FORCE", + "DMG_RADIATION", + "DMG_REMOVENORAGDOLL", + "DMG_SLOWBURN", + + --- DOCK + + --- DOF + "DOF_OFFSET", + "DOF_SPACING", + + --- EF + "EF_BONEMERGE", + "EF_BONEMERGE_FASTCULL", + "EF_BRIGHTLIGHT", + "EF_DIMLIGHT", + "EF_NOINTERP", + "EF_NOSHADOW", + "EF_NODRAW", + "EF_NORECEIVESHADOW", + "EF_ITEM_BLINK", + "EF_PARENT_ANIMATES", + + --- EFL + "EFL_BOT_FROZEN", + "EFL_CHECK_UNTOUCH", + "EFL_DIRTY_ABSANGVELOCITY", + "EFL_DIRTY_ABSTRANSFORM", + "EFL_DIRTY_ABSVELOCITY", + "EFL_DIRTY_SHADOWUPDATE", + "EFL_DIRTY_SPATIAL_PARTITION", + "EFL_DIRTY_SURROUNDING_COLLISION_BOUNDS", + "EFL_DONTBLOCKLOS", + "EFL_DONTWALKON", + "EFL_DORMANT", + "EFL_FORCE_CHECK_TRANSMIT", + "EFL_HAS_PLAYER_CHILD", + "EFL_IN_SKYBOX", + "EFL_IS_BEING_LIFTED_BY_BARNACLE", + "EFL_KEEP_ON_RECREATE_ENTITIES", + "EFL_KILLME", + "EFL_NOCLIP_ACTIVE", + "EFL_NOTIFY", + "EFL_NO_AUTO_EDICT_ATTACH", + "EFL_NO_DAMAGE_FORCES", + "EFL_NO_DISSOLVE", + "EFL_NO_GAME_PHYSICS_SIMULATION", + "EFL_NO_MEGAPHYSCANNON_RAGDOLL", + "EFL_NO_PHYSCANNON_INTERACTION", + "EFL_NO_ROTORWASH_PUSH", + "EFL_NO_THINK_FUNCTION", + "EFL_NO_WATER_VELOCITY_CHANGE", + "EFL_SERVER_ONLY", + "EFL_SETTING_UP_BONES", + "EFL_TOUCHING_FLUID", + "EFL_USE_PARTITION_WHEN_NOT_SOLID", + + --- FCVAR + "FCVAR_ARCHIVE", + "FCVAR_ARCHIVE_XBOX", + "FCVAR_CHEAT", + "FCVAR_CLIENTCMD_CAN_EXECUTE", + "FCVAR_CLIENTDLL", + "FCVAR_DEMO", + "FCVAR_DONTRECORD", + "FCVAR_GAMEDLL", + "FCVAR_LUA_CLIENT", + "FCVAR_LUA_SERVER", + "FCVAR_NEVER_AS_STRING", + "FCVAR_NONE", + "FCVAR_NOTIFY", + "FCVAR_NOT_CONNECTED", + "FCVAR_PRINTABLEONLY", + "FCVAR_PROTECTED", + "FCVAR_REPLICATED", + "FCVAR_SERVER_CANNOT_QUERY", + "FCVAR_SERVER_CAN_EXECUTE", + "FCVAR_SPONLY", + "FCVAR_UNLOGGED", + "FCVAR_UNREGISTERED", + "FCVAR_USERINFO", + + --- FFT + "FFT_256", + "FFT_512", + "FFT_1024", + "FFT_2048", + "FFT_4096", + "FFT_8192", + "FFT_16384", + "FFT_32768", + + --- FL + "FL_ONGROUND", + "FL_DUCKING", + "FL_ANIMDUCKING", + "FL_WATERJUMP", + "FL_ONTRAIN", + "FL_INRAIN", + "FL_FROZEN", + "FL_ATCONTROLS", + "FL_CLIENT", + "FL_FAKECLIENT", + "FL_INWATER", + "FL_FLY", + "FL_SWIM", + "FL_CONVEYOR", + "FL_NPC", + "FL_GODMODE", + "FL_NOTARGET", + "FL_AIMTARGET", + "FL_PARTIALGROUND", + "FL_STATICPROP", + "FL_GRAPHED", + "FL_GRENADE", + "FL_STEPMOVEMENT", + "FL_DONTTOUCH", + "FL_BASEVELOCITY", + "FL_WORLDBRUSH", + "FL_OBJECT", + "FL_KILLME", + "FL_ONFIRE", + "FL_DISSOLVING", + "FL_TRANSRAGDOLL", + "FL_UNBLOCKABLE_BY_PLAYER", + + --- FORCE + "FORCE_STRING", + "FORCE_NUMBER", + "FORCE_BOOL", + + --- FSOLID + "FSOLID_CUSTOMRAYTEST", + "FSOLID_CUSTOMBOXTEST", + "FSOLID_NOT_SOLID", + "FSOLID_TRIGGER", + "FSOLID_NOT_STANDABLE", + "FSOLID_VOLUME_CONTENTS", + "FSOLID_FORCE_WORLD_ALIGNED", + "FSOLID_USE_TRIGGER_BOUNDS", + "FSOLID_ROOT_PARENT_ALIGNED", + "FSOLID_TRIGGER_TOUCH_DEBRIS", + "FSOLID_MAX_BITS", + + --- FVPHYSICS + "FVPHYSICS_CONSTRAINT_STATIC", + "FVPHYSICS_DMG_DISSOLVE", + "FVPHYSICS_DMG_SLICE", + "FVPHYSICS_HEAVY_OBJECT", + "FVPHYSICS_MULTIOBJECT_ENTITY", + "FVPHYSICS_NO_IMPACT_DMG", + "FVPHYSICS_NO_NPC_IMPACT_DMG", + "FVPHYSICS_NO_PLAYER_PICKUP", + "FVPHYSICS_NO_SELF_COLLISIONS", + "FVPHYSICS_PART_OF_RAGDOLL", + "FVPHYSICS_PENETRATING", + "FVPHYSICS_PLAYER_HELD", + "FVPHYSICS_WAS_THROWN", + + --- GESTURE_SLOT + "GESTURE_SLOT_ATTACK_AND_RELOAD", + "GESTURE_SLOT_GRENADE", + "GESTURE_SLOT_JUMP", + "GESTURE_SLOT_SWIM", + "GESTURE_SLOT_FLINCH", + "GESTURE_SLOT_VCD", + "GESTURE_SLOT_CUSTOM", + + --- GMOD_CHANNEL + "GMOD_CHANNEL_STOPPED", + "GMOD_CHANNEL_PLAYING", + "GMOD_CHANNEL_PAUSED", + "GMOD_CHANNEL_STALLED", + + --- HITGROUP + "HITGROUP_GENERIC", + "HITGROUP_HEAD", + "HITGROUP_CHEST", + "HITGROUP_STOMACH", + "HITGROUP_LEFTARM", + "HITGROUP_RIGHTARM", + "HITGROUP_LEFTLEG", + "HITGROUP_RIGHTLEG", + "HITGROUP_GEAR", + + --- HUD + "HUD_PRINTNOTIFY", + "HUD_PRINTCONSOLE", + "HUD_PRINTTALK", + "HUD_PRINTCENTER", + + --- HULL + "HULL_HUMAN", + "HULL_SMALL_CENTERED", + "HULL_WIDE_HUMAN", + "HULL_TINY", + "HULL_WIDE_SHORT", + "HULL_MEDIUM", + "HULL_TINY_CENTERED", + "HULL_LARGE", + "HULL_LARGE_CENTERED", + "HULL_MEDIUM_TALL", + + --- IMAGE_FORMAT + "IMAGE_FORMAT_DEFAULT", + "IMAGE_FORMAT_RGBA8888", + "IMAGE_FORMAT_ABGR8888", + "IMAGE_FORMAT_RGB888", + "IMAGE_FORMAT_BGR888", + "IMAGE_FORMAT_RGB565", + "IMAGE_FORMAT_ARGB8888", + "IMAGE_FORMAT_BGRA8888", + "IMAGE_FORMAT_RGBA16161616", + "IMAGE_FORMAT_RGBA16161616F", + + --- IN + "IN_ALT1", + "IN_ALT2", + "IN_ATTACK", + "IN_ATTACK2", + "IN_BACK", + "IN_DUCK", + "IN_FORWARD", + "IN_JUMP", + "IN_LEFT", + "IN_MOVELEFT", + "IN_MOVERIGHT", + "IN_RELOAD", + "IN_RIGHT", + "IN_SCORE", + "IN_SPEED", + "IN_USE", + "IN_WALK", + "IN_ZOOM", + "IN_GRENADE1", + "IN_GRENADE2", + "IN_WEAPON1", + "IN_WEAPON2", + "IN_BULLRUSH", + "IN_CANCEL", + "IN_RUN", + + --- JOYSTICK + "JOYSTICK_FIRST", + "JOYSTICK_FIRST_AXIS_BUTTON", + "JOYSTICK_FIRST_BUTTON", + "JOYSTICK_FIRST_POV_BUTTON", + "JOYSTICK_LAST", + "JOYSTICK_LAST_AXIS_BUTTON", + "JOYSTICK_LAST_BUTTON", + "JOYSTICK_LAST_POV_BUTTON", + + --- KEY + "KEY_FIRST", + "KEY_NONE", + "KEY_0", + "KEY_1", + "KEY_2", + "KEY_3", + "KEY_4", + "KEY_5", + "KEY_6", + "KEY_7", + "KEY_8", + "KEY_9", + "KEY_A", + "KEY_B", + "KEY_C", + "KEY_D", + "KEY_E", + "KEY_F", + "KEY_G", + "KEY_H", + "KEY_I", + "KEY_J", + "KEY_K", + "KEY_L", + "KEY_M", + "KEY_N", + "KEY_O", + "KEY_P", + "KEY_Q", + "KEY_R", + "KEY_S", + "KEY_T", + "KEY_U", + "KEY_V", + "KEY_W", + "KEY_X", + "KEY_Y", + "KEY_Z", + "KEY_PAD_0", + "KEY_PAD_1", + "KEY_PAD_2", + "KEY_PAD_3", + "KEY_PAD_4", + "KEY_PAD_5", + "KEY_PAD_6", + "KEY_PAD_7", + "KEY_PAD_8", + "KEY_PAD_9", + "KEY_PAD_DIVIDE", + "KEY_PAD_MULTIPLY", + "KEY_PAD_MINUS", + "KEY_PAD_PLUS", + "KEY_PAD_ENTER", + "KEY_PAD_DECIMAL", + "KEY_LBRACKET", + "KEY_RBRACKET", + "KEY_SEMICOLON", + "KEY_APOSTROPHE", + "KEY_BACKQUOTE", + "KEY_COMMA", + "KEY_PERIOD", + "KEY_SLASH", + "KEY_BACKSLASH", + "KEY_MINUS", + "KEY_EQUAL", + "KEY_ENTER", + "KEY_SPACE", + "KEY_BACKSPACE", + "KEY_TAB", + "KEY_CAPSLOCK", + "KEY_NUMLOCK", + "KEY_ESCAPE", + "KEY_SCROLLLOCK", + "KEY_INSERT", + "KEY_DELETE", + "KEY_HOME", + "KEY_END", + "KEY_PAGEUP", + "KEY_PAGEDOWN", + "KEY_BREAK", + "KEY_LSHIFT", + "KEY_RSHIFT", + "KEY_LALT", + "KEY_RALT", + "KEY_LCONTROL", + "KEY_RCONTROL", + "KEY_LWIN", + "KEY_RWIN", + "KEY_APP", + "KEY_UP", + "KEY_LEFT", + "KEY_DOWN", + "KEY_RIGHT", + "KEY_F1", + "KEY_F2", + "KEY_F3", + "KEY_F4", + "KEY_F5", + "KEY_F6", + "KEY_F7", + "KEY_F8", + "KEY_F9", + "KEY_F10", + "KEY_F11", + "KEY_F12", + "KEY_CAPSLOCKTOGGLE", + "KEY_NUMLOCKTOGGLE", + "KEY_LAST", + "KEY_SCROLLLOCKTOGGLE", + "KEY_COUNT", + "KEY_XBUTTON_A", + "KEY_XBUTTON_B", + "KEY_XBUTTON_X", + "KEY_XBUTTON_Y", + "KEY_XBUTTON_LEFT_SHOULDER", + "KEY_XBUTTON_RIGHT_SHOULDER", + "KEY_XBUTTON_BACK", + "KEY_XBUTTON_START", + "KEY_XBUTTON_STICK1", + "KEY_XBUTTON_STICK2", + "KEY_XBUTTON_UP", + "KEY_XBUTTON_RIGHT", + "KEY_XBUTTON_DOWN", + "KEY_XBUTTON_LEFT", + "KEY_XSTICK1_RIGHT", + "KEY_XSTICK1_LEFT", + "KEY_XSTICK1_DOWN", + "KEY_XSTICK1_UP", + "KEY_XBUTTON_LTRIGGER", + "KEY_XBUTTON_RTRIGGER", + "KEY_XSTICK2_RIGHT", + "KEY_XSTICK2_LEFT", + "KEY_XSTICK2_DOWN", + "KEY_XSTICK2_UP", + + --- kRenderFx + + --- MASK + "MASK_ALL", + "MASK_BLOCKLOS", + "MASK_BLOCKLOS_AND_NPCS", + "MASK_CURRENT", + "MASK_DEADSOLID", + "MASK_NPCSOLID", + "MASK_NPCSOLID_BRUSHONLY", + "MASK_NPCWORLDSTATIC", + "MASK_OPAQUE", + "MASK_OPAQUE_AND_NPCS", + "MASK_PLAYERSOLID", + "MASK_PLAYERSOLID_BRUSHONLY", + "MASK_SHOT", + "MASK_SHOT_HULL", + "MASK_SHOT_PORTAL", + "MASK_SOLID", + "MASK_SOLID_BRUSHONLY", + "MASK_SPLITAREAPORTAL", + "MASK_VISIBLE", + "MASK_VISIBLE_AND_NPCS", + "MASK_WATER", + + --- MAT + "MAT_ALIENFLESH", + "MAT_ANTLION", + "MAT_BLOODYFLESH", + "MAT_CLIP", + "MAT_COMPUTER", + "MAT_CONCRETE", + "MAT_DIRT", + "MAT_EGGSHELL", + "MAT_FLESH", + "MAT_FOLIAGE", + "MAT_GLASS", + "MAT_GRATE", + "MAT_SNOW", + "MAT_METAL", + "MAT_PLASTIC", + "MAT_SAND", + "MAT_SLOSH", + "MAT_TILE", + "MAT_GRASS", + "MAT_VENT", + "MAT_WOOD", + "MAT_DEFAULT", + "MAT_WARPSHIELD", + + --- MATERIAL + "MATERIAL_LINES", + "MATERIAL_LINE_LOOP", + "MATERIAL_LINE_STRIP", + "MATERIAL_POINTS", + "MATERIAL_POLYGON", + "MATERIAL_QUADS", + "MATERIAL_TRIANGLES", + "MATERIAL_TRIANGLE_STRIP", + + --- MATERIAL_CULLMODE + "MATERIAL_CULLMODE_CCW", + "MATERIAL_CULLMODE_CW", + + --- MATERIAL_FOG + "MATERIAL_FOG_NONE", + "MATERIAL_FOG_LINEAR", + "MATERIAL_FOG_LINEAR_BELOW_FOG_Z", + + --- MATERIAL_LIGHT + "MATERIAL_LIGHT_DISABLE", + "MATERIAL_LIGHT_POINT", + "MATERIAL_LIGHT_DIRECTIONAL", + "MATERIAL_LIGHT_SPOT", + + --- MATERIAL_RT_DEPTH + "MATERIAL_RT_DEPTH_SHARED", + "MATERIAL_RT_DEPTH_SEPARATE", + "MATERIAL_RT_DEPTH_NONE", + "MATERIAL_RT_DEPTH_ONLY", + + --- MOUSE + "MOUSE_LEFT", + "MOUSE_RIGHT", + "MOUSE_MIDDLE", + "MOUSE_4", + "MOUSE_5", + "MOUSE_WHEEL_UP", + "MOUSE_WHEEL_DOWN", + "MOUSE_COUNT", + "MOUSE_FIRST", + "MOUSE_LAST", + + --- MOVECOLLIDE + "MOVECOLLIDE_DEFAULT", + "MOVECOLLIDE_FLY_BOUNCE", + "MOVECOLLIDE_FLY_CUSTOM", + "MOVECOLLIDE_FLY_SLIDE", + "MOVECOLLIDE_COUNT", + + --- MOVETYPE + "MOVETYPE_NONE", + "MOVETYPE_ISOMETRIC", + "MOVETYPE_WALK", + "MOVETYPE_STEP", + "MOVETYPE_FLY", + "MOVETYPE_FLYGRAVITY", + "MOVETYPE_VPHYSICS", + "MOVETYPE_PUSH", + "MOVETYPE_NOCLIP", + "MOVETYPE_LADDER", + "MOVETYPE_OBSERVER", + "MOVETYPE_CUSTOM", + + --- NAV_MESH + "NAV_MESH_INVALID", + "NAV_MESH_CROUCH", + "NAV_MESH_JUMP", + "NAV_MESH_PRECISE", + "NAV_MESH_NO_JUMP", + "NAV_MESH_STOP", + "NAV_MESH_RUN", + "NAV_MESH_WALK", + "NAV_MESH_AVOID", + "NAV_MESH_TRANSIENT", + "NAV_MESH_DONT_HIDE", + "NAV_MESH_STAND", + "NAV_MESH_NO_HOSTAGES", + "NAV_MESH_STAIRS", + "NAV_MESH_NO_MERGE", + "NAV_MESH_OBSTACLE_TOP", + "NAV_MESH_CLIFF", + "NAV_MESH_FUNC_COST", + "NAV_MESH_HAS_ELEVATOR", + "NAV_MESH_NAV_BLOCKER", + + --- NavCorner + + --- NavDir + + --- NavTraverseType + + --- NOTIFY + "NOTIFY_GENERIC", + "NOTIFY_ERROR", + "NOTIFY_UNDO", + "NOTIFY_HINT", + "NOTIFY_CLEANUP", + + --- NPC_STATE + "NPC_STATE_INVALID", + "NPC_STATE_NONE", + "NPC_STATE_IDLE", + "NPC_STATE_ALERT", + "NPC_STATE_COMBAT", + "NPC_STATE_SCRIPT", + "NPC_STATE_PLAYDEAD", + "NPC_STATE_PRONE", + "NPC_STATE_DEAD", + + --- NUM + "NUM_AI_CLASSES", + "NUM_HULLS", + "NUM_BEAMS", + "NUM_SPRITES", + + --- OBS_MODE + "OBS_MODE_NONE", + "OBS_MODE_DEATHCAM", + "OBS_MODE_FREEZECAM", + "OBS_MODE_FIXED", + "OBS_MODE_IN_EYE", + "OBS_MODE_CHASE", + "OBS_MODE_ROAMING", + + --- PATTACH + "PATTACH_ABSORIGIN", + "PATTACH_ABSORIGIN_FOLLOW", + "PATTACH_CUSTOMORIGIN", + "PATTACH_POINT", + "PATTACH_POINT_FOLLOW", + "PATTACH_WORLDORIGIN", + + --- PLAYER + "PLAYER_IDLE", + "PLAYER_WALK", + "PLAYER_JUMP", + "PLAYER_SUPERJUMP", + "PLAYER_DIE", + "PLAYER_ATTACK1", + "PLAYER_IN_VEHICLE", + "PLAYER_RELOAD", + "PLAYER_START_AIMING", + "PLAYER_LEAVE_AIMING", + + --- PLAYERANIMEVENT + "PLAYERANIMEVENT_ATTACK_GRENADE", + "PLAYERANIMEVENT_ATTACK_PRIMARY", + "PLAYERANIMEVENT_ATTACK_SECONDARY", + "PLAYERANIMEVENT_CANCEL", + "PLAYERANIMEVENT_CUSTOM", + "PLAYERANIMEVENT_CUSTOM_GESTURE", + "PLAYERANIMEVENT_CUSTOM_GESTURE_SEQUENCE", + "PLAYERANIMEVENT_CUSTOM_SEQUENCE", + "PLAYERANIMEVENT_DIE", + "PLAYERANIMEVENT_DOUBLEJUMP", + "PLAYERANIMEVENT_FLINCH_CHEST", + "PLAYERANIMEVENT_FLINCH_HEAD", + "PLAYERANIMEVENT_FLINCH_LEFTARM", + "PLAYERANIMEVENT_FLINCH_LEFTLEG", + "PLAYERANIMEVENT_FLINCH_RIGHTARM", + "PLAYERANIMEVENT_FLINCH_RIGHTLEG", + "PLAYERANIMEVENT_JUMP", + "PLAYERANIMEVENT_RELOAD", + "PLAYERANIMEVENT_RELOAD_END", + "PLAYERANIMEVENT_RELOAD_LOOP", + "PLAYERANIMEVENT_SNAP_YAW", + "PLAYERANIMEVENT_SPAWN", + "PLAYERANIMEVENT_SWIM", + + --- RENDERGROUP + "RENDERGROUP_STATIC_HUGE", + "RENDERGROUP_OPAQUE_HUGE", + "RENDERGROUP_STATIC", + "RENDERGROUP_OPAQUE", + "RENDERGROUP_TRANSLUCENT", + "RENDERGROUP_BOTH", + "RENDERGROUP_VIEWMODEL", + "RENDERGROUP_VIEWMODEL_TRANSLUCENT", + "RENDERGROUP_OPAQUE_BRUSH", + "RENDERGROUP_OTHER", + + --- RENDERMODE + "RENDERMODE_NORMAL", + "RENDERMODE_TRANSCOLOR", + "RENDERMODE_TRANSTEXTURE", + "RENDERMODE_GLOW", + "RENDERMODE_TRANSALPHA", + "RENDERMODE_TRANSADD", + "RENDERMODE_ENVIROMENTAL", + "RENDERMODE_TRANSADDFRAMEBLEND", + "RENDERMODE_TRANSALPHADD", + "RENDERMODE_WORLDGLOW", + "RENDERMODE_NONE", + + --- RT_SIZE + "RT_SIZE_NO_CHANGE", + "RT_SIZE_DEFAULT", + "RT_SIZE_PICMIP", + "RT_SIZE_HDR", + "RT_SIZE_FULL_FRAME_BUFFER", + "RT_SIZE_OFFSCREEN", + "RT_SIZE_FULL_FRAME_BUFFER_ROUNDED_UP", + + --- SCHED + "SCHED_AISCRIPT", + "SCHED_ALERT_FACE", + "SCHED_ALERT_FACE_BESTSOUND", + "SCHED_ALERT_REACT_TO_COMBAT_SOUND", + "SCHED_ALERT_SCAN", + "SCHED_ALERT_STAND", + "SCHED_ALERT_WALK", + "SCHED_AMBUSH", + "SCHED_ARM_WEAPON", + "SCHED_BACK_AWAY_FROM_ENEMY", + "SCHED_BACK_AWAY_FROM_SAVE_POSITION", + "SCHED_BIG_FLINCH", + "SCHED_CHASE_ENEMY", + "SCHED_CHASE_ENEMY_FAILED", + "SCHED_COMBAT_FACE", + "SCHED_COMBAT_PATROL", + "SCHED_COMBAT_STAND", + "SCHED_COMBAT_SWEEP", + "SCHED_COMBAT_WALK", + "SCHED_COWER", + "SCHED_DIE", + "SCHED_DIE_RAGDOLL", + "SCHED_DISARM_WEAPON", + "SCHED_DROPSHIP_DUSTOFF", + "SCHED_DUCK_DODGE", + "SCHED_ESTABLISH_LINE_OF_FIRE", + "SCHED_ESTABLISH_LINE_OF_FIRE_FALLBACK", + "SCHED_FAIL", + "SCHED_FAIL_ESTABLISH_LINE_OF_FIRE", + "SCHED_FAIL_NOSTOP", + "SCHED_FAIL_TAKE_COVER", + "SCHED_FALL_TO_GROUND", + "SCHED_FEAR_FACE", + "SCHED_FLEE_FROM_BEST_SOUND", + "SCHED_FLINCH_PHYSICS", + "SCHED_FORCED_GO", + "SCHED_FORCED_GO_RUN", + "SCHED_GET_HEALTHKIT", + "SCHED_HIDE_AND_RELOAD", + "SCHED_IDLE_STAND", + "SCHED_IDLE_WALK", + "SCHED_IDLE_WANDER", + "SCHED_INTERACTION_MOVE_TO_PARTNER", + "SCHED_INTERACTION_WAIT_FOR_PARTNER", + "SCHED_INVESTIGATE_SOUND", + "SCHED_MELEE_ATTACK1", + "SCHED_MELEE_ATTACK2", + "SCHED_MOVE_AWAY", + "SCHED_MOVE_AWAY_END", + "SCHED_MOVE_AWAY_FAIL", + "SCHED_MOVE_AWAY_FROM_ENEMY", + "SCHED_MOVE_TO_WEAPON_RANGE", + "SCHED_NEW_WEAPON", + "SCHED_NEW_WEAPON_CHEAT", + "SCHED_NONE", + "SCHED_NPC_FREEZE", + "SCHED_PATROL_RUN", + "SCHED_PATROL_WALK", + "SCHED_PRE_FAIL_ESTABLISH_LINE_OF_FIRE", + "SCHED_RANGE_ATTACK1", + "SCHED_RANGE_ATTACK2", + "SCHED_RELOAD", + "SCHED_RUN_FROM_ENEMY", + "SCHED_RUN_FROM_ENEMY_FALLBACK", + "SCHED_RUN_FROM_ENEMY_MOB", + "SCHED_RUN_RANDOM", + "SCHED_SCENE_GENERIC", + "SCHED_SCRIPTED_CUSTOM_MOVE", + "SCHED_SCRIPTED_FACE", + "SCHED_SCRIPTED_RUN", + "SCHED_SCRIPTED_WAIT", + "SCHED_SCRIPTED_WALK", + "SCHED_SHOOT_ENEMY_COVER", + "SCHED_SLEEP", + "SCHED_SMALL_FLINCH", + "SCHED_SPECIAL_ATTACK1", + "SCHED_SPECIAL_ATTACK2", + "SCHED_STANDOFF", + "SCHED_SWITCH_TO_PENDING_WEAPON", + "SCHED_TAKE_COVER_FROM_BEST_SOUND", + "SCHED_TAKE_COVER_FROM_ENEMY", + "SCHED_TAKE_COVER_FROM_ORIGIN", + "SCHED_TARGET_CHASE", + "SCHED_TARGET_FACE", + "SCHED_VICTORY_DANCE", + "SCHED_WAIT_FOR_SCRIPT", + "SCHED_WAIT_FOR_SPEAK_FINISH", + "SCHED_WAKE_ANGRY", + + --- SCREENFADE + + --- SENSORBONE + + --- SF + "SF_CITIZEN_AMMORESUPPLIER", + "SF_CITIZEN_FOLLOW", + "SF_CITIZEN_IGNORE_SEMAPHORE", + "SF_CITIZEN_MEDIC", + "SF_CITIZEN_NOT_COMMANDABLE", + "SF_CITIZEN_RANDOM_HEAD", + "SF_CITIZEN_RANDOM_HEAD_FEMALE", + "SF_CITIZEN_RANDOM_HEAD_MALE", + "SF_CITIZEN_USE_RENDER_BOUNDS", + "SF_FLOOR_TURRET_CITIZEN", + "SF_NPC_ALTCOLLISION", + "SF_NPC_ALWAYSTHINK", + "SF_NPC_DROP_HEALTHKIT", + "SF_NPC_FADE_CORPSE", + "SF_NPC_FALL_TO_GROUND", + "SF_NPC_GAG", + "SF_NPC_LONG_RANGE", + "SF_NPC_NO_PLAYER_PUSHAWAY", + "SF_NPC_NO_WEAPON_DROP", + "SF_NPC_START_EFFICIENT", + "SF_NPC_TEMPLATE", + "SF_NPC_WAIT_FOR_SCRIPT", + "SF_NPC_WAIT_TILL_SEEN", + "SF_PHYSBOX_MOTIONDISABLED", + "SF_PHYSBOX_NEVER_PICK_UP", + "SF_PHYSPROP_MOTIONDISABLED", + "SF_PHYSPROP_PREVENT_PICKUP", + "SF_ROLLERMINE_FRIENDLY", + + --- SIM + "SIM_NOTHING", + "SIM_LOCAL_ACCELERATION", + "SIM_LOCAL_FORCE", + "SIM_GLOBAL_ACCELERATION", + "SIM_GLOBAL_FORCE", + + --- SND + "SND_NOFLAGS", + "SND_CHANGE_VOL", + "SND_CHANGE_PITCH", + "SND_STOP", + "SND_SPAWNING", + "SND_DELAY", + "SND_STOP_LOOPING", + "SND_SHOULDPAUSE", + "SND_IGNORE_PHONEMES", + "SND_IGNORE_NAME", + "SND_DO_NOT_OVERWRITE_EXISTING_ON_CHANNEL", + + --- SNDLVL + "SNDLVL_NONE", + "SNDLVL_20dB", + "SNDLVL_25dB", + "SNDLVL_30dB", + "SNDLVL_35dB", + "SNDLVL_40dB", + "SNDLVL_45dB", + "SNDLVL_50dB", + "SNDLVL_55dB", + "SNDLVL_60dB
SNDLVL_IDLE", + "SNDLVL_65dB", + "SNDLVL_STATIC", + "SNDLVL_70dB", + "SNDLVL_75dB
SNDLVL_NORM", + "SNDLVL_80dB
SNDLVL_TALKING", + "SNDLVL_85dB", + "SNDLVL_90dB", + "SNDLVL_95dB", + "SNDLVL_100dB", + "SNDLVL_105dB", + "SNDLVL_110dB", + "SNDLVL_120dB", + "SNDLVL_130dB", + "SNDLVL_140dB
SNDLVL_GUNFIRE", + "SNDLVL_150dB", + "SNDLVL_180dB", + + --- SOLID + "SOLID_NONE", + "SOLID_BSP", + "SOLID_BBOX", + "SOLID_OBB", + "SOLID_OBB_YAW", + "SOLID_CUSTOM", + "SOLID_VPHYSICS", + + --- STENCIL + "STENCIL_NEVER", + "STENCIL_LESS", + "STENCIL_EQUAL", + "STENCIL_LESSEQUAL", + "STENCIL_GREATER", + "STENCIL_NOTEQUAL", + "STENCIL_GREATEREQUAL", + "STENCIL_ALWAYS", + "STENCIL_KEEP", + "STENCIL_ZERO", + "STENCIL_REPLACE", + "STENCIL_INCRSAT", + "STENCIL_DECRSAT", + "STENCIL_INVERT", + "STENCIL_INCR", + "STENCIL_DECR", + + --- STENCILCOMPARISONFUNCTION + "STENCILCOMPARISONFUNCTION_NEVER", + "STENCILCOMPARISONFUNCTION_LESS", + "STENCILCOMPARISONFUNCTION_EQUAL", + "STENCILCOMPARISONFUNCTION_LESSEQUAL", + "STENCILCOMPARISONFUNCTION_GREATER", + "STENCILCOMPARISONFUNCTION_NOTEQUAL", + "STENCILCOMPARISONFUNCTION_GREATEREQUAL", + "STENCILCOMPARISONFUNCTION_ALWAYS", + + --- STENCILOPERATION + "STENCILOPERATION_KEEP", + "STENCILOPERATION_ZERO", + "STENCILOPERATION_REPLACE", + "STENCILOPERATION_INCRSAT", + "STENCILOPERATION_DECRSAT", + "STENCILOPERATION_INVERT", + "STENCILOPERATION_INCR", + "STENCILOPERATION_DECR", + + --- STEPSOUNDTIME + "STEPSOUNDTIME_NORMAL", + "STEPSOUNDTIME_ON_LADDER", + "STEPSOUNDTIME_WATER_KNEE", + "STEPSOUNDTIME_WATER_FOOT", + + --- STUDIO + "STUDIO_DRAWTRANSLUCENTSUBMODELS", + "STUDIO_GENERATE_STATS", + "STUDIO_ITEM_BLINK", + "STUDIO_NOSHADOWS", + "STUDIO_RENDER", + "STUDIO_SHADOWDEPTHTEXTURE", + "STUDIO_SSAODEPTHTEXTURE", + "STUDIO_STATIC_LIGHTING", + "STUDIO_TRANSPARENCY", + "STUDIO_TWOPASS", + "STUDIO_VIEWXFORMATTACHMENTS", + "STUDIO_WIREFRAME", + "STUDIO_WIREFRAME_VCOLLIDE", + + --- SURF + "SURF_LIGHT", + "SURF_SKY", + "SURF_WARP", + "SURF_TRANS", + "SURF_NOPORTAL", + "SURF_TRIGGER", + "SURF_NODRAW", + "SURF_HINT", + "SURF_SKIP", + "SURF_NOLIGHT", + "SURF_BUMPLIGHT", + "SURF_NOSHADOWS", + "SURF_NODECALS", + "SURF_NOCHOP", + "SURF_HITBOX", + + --- TEAM + "TEAM_CONNECTING", + "TEAM_UNASSIGNED", + "TEAM_SPECTATOR", + + --- TEXFILTER + + --- TEXT_ALIGN + "TEXT_ALIGN_LEFT", + "TEXT_ALIGN_CENTER", + "TEXT_ALIGN_RIGHT", + "TEXT_ALIGN_TOP", + "TEXT_ALIGN_BOTTOM", + + --- TEXTUREFLAGS + "TEXTUREFLAGS_POINTSAMPLE", + "TEXTUREFLAGS_TRILINEAR", + "TEXTUREFLAGS_CLAMPS", + "TEXTUREFLAGS_CLAMPT", + "TEXTUREFLAGS_ANISOTROPIC", + "TEXTUREFLAGS_HINT_DXT5", + "TEXTUREFLAGS_PWL_CORRECTED", + "TEXTUREFLAGS_NORMAL", + "TEXTUREFLAGS_NOMIP", + "TEXTUREFLAGS_NOLOD", + "TEXTUREFLAGS_ALL_MIPS", + "TEXTUREFLAGS_PROCEDURAL", + "TEXTUREFLAGS_ONEBITALPHA", + "TEXTUREFLAGS_EIGHTBITALPHA", + "TEXTUREFLAGS_ENVMAP", + "TEXTUREFLAGS_RENDERTARGET", + "TEXTUREFLAGS_DEPTHRENDERTARGET", + "TEXTUREFLAGS_NODEBUGOVERRIDE", + "TEXTUREFLAGS_SINGLECOPY", + "TEXTUREFLAGS_UNUSED_00080000", + "TEXTUREFLAGS_UNUSED_00100000", + "TEXTUREFLAGS_UNUSED_00200000", + "TEXTUREFLAGS_UNUSED_00400000", + "TEXTUREFLAGS_NODEPTHBUFFER", + "TEXTUREFLAGS_UNUSED_01000000", + "TEXTUREFLAGS_CLAMPU", + "TEXTUREFLAGS_VERTEXTEXTURE", + "TEXTUREFLAGS_SSBUMP", + "TEXTUREFLAGS_UNUSED_10000000", + "TEXTUREFLAGS_BORDER", + "TEXTUREFLAGS_UNUSED_40000000", + "TEXTUREFLAGS_UNUSED_80000000", + + --- TRACER + "TRACER_NONE", + "TRACER_LINE", + "TRACER_RAIL", + "TRACER_BEAM", + "TRACER_LINE_AND_WHIZ", + + --- TRANSMIT + "TRANSMIT_NEVER", + "TRANSMIT_PVS", + "TRANSMIT_ALWAYS", + + --- TYPE + "TYPE_ANGLE", + "TYPE_BOOL", + "TYPE_COLOR", + "TYPE_CONVAR", + "TYPE_COUNT", + "TYPE_DAMAGEINFO", + "TYPE_DLIGHT", + "TYPE_EFFECTDATA", + "TYPE_ENTITY", + "TYPE_FILE", + "TYPE_FUNCTION", + "TYPE_IMESH", + "TYPE_INVALID", + "TYPE_LIGHTUSERDATA", + "TYPE_LOCOMOTION", + "TYPE_MATERIAL", + "TYPE_MATRIX", + "TYPE_MOVEDATA", + "TYPE_NAVAREA", + "TYPE_NAVLADDER", + "TYPE_NIL", + "TYPE_NUMBER", + "TYPE_PANEL", + "TYPE_PARTICLE", + "TYPE_PARTICLEEMITTER", + "TYPE_PARTICLESYSTEM", + "TYPE_PATH", + "TYPE_PHYSOBJ", + "TYPE_PIXELVISHANDLE", + "TYPE_RECIPIENTFILTER", + "TYPE_RESTORE", + "TYPE_SAVE", + "TYPE_SCRIPTEDVEHICLE", + "TYPE_SOUND", + "TYPE_SOUNDHANDLE", + "TYPE_STRING", + "TYPE_TABLE", + "TYPE_TEXTURE", + "TYPE_THREAD", + "TYPE_USERCMD", + "TYPE_USERDATA", + "TYPE_USERMSG", + "TYPE_VECTOR", + "TYPE_VIDEO", + + --- USE + "USE_OFF", + "USE_ON", + "USE_SET", + "USE_TOGGLE", + + --- WEAPON_PROFICIENCY + "WEAPON_PROFICIENCY_POOR", + "WEAPON_PROFICIENCY_AVERAGE", + "WEAPON_PROFICIENCY_GOOD", + "WEAPON_PROFICIENCY_VERY_GOOD", + "WEAPON_PROFICIENCY_PERFECT", + + -- END_GENERATED_CODE } -- string keys mean read-write globals diff --git a/generate-luacheck.sh b/generate-luacheck.sh new file mode 100755 index 0000000000..e822e8bf75 --- /dev/null +++ b/generate-luacheck.sh @@ -0,0 +1,119 @@ +#!/bin/bash + +set -e + +base_url='http://wiki.garrysmod.com' + +detag() { + printf '%s' "${1##*>}" +} + +wget -o /dev/null -O - "$base_url"/navbar/ | + sed -r ' + # Split up before each closing tag + s#//g + + # Remove everything before the last tag + s/.*&2 "unknown section '$section' for '$detagged'" + ;; + esac + ;; + + '&2 "Retrieving enum data for $detagged" + + url="$base_url/page/Enums/$detagged" # TODO: use URL from the tag + wget "$url" -o /dev/null -O - | + sed -rn 's/ ('"$detagged"'_.*)/ "\1",/p' + ;; + + Structures|Shaders|'Lua Reference'|Hooks|Libraries|Classes|Panels) + : + ;; + + *) + echo >&2 "unknown section '$section' for '$detagged'" + ;; + esac + ;; + + '

'*) + section="$detagged" + case "$section" in + Reference) + : + ;; + + *) + echo >&2 "Parsing section $section" + printf '\n -- %s\n' "$section" + ;; + esac + ;; + + '

'*) + section="$detagged" + case "$section" in + Enumerations) + echo >&2 "Parsing section $section" + printf '\n -- %s' "$section" # No newline after this, to avoid double newlines + ;; + esac + ;; + + ' tags + : + ;; + + *) + echo >&2 "Warning: Unhandled line '$line'" + esac + done + + printf '\n' + } | + sed -ri ' + 0,/BEGIN_GENERATED_CODE/ { + /BEGIN_GENERATED_CODE/ { + r /dev/stdin + } + b + } + /END_GENERATED_CODE/,$ b + d + ' .luacheckrc From e14cb2bf468cebc5e63d6efcebe4f61dfe4ad44c Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Mon, 28 Nov 2016 15:12:50 +0100 Subject: [PATCH 11/56] Add stupidly named enum constants --- .luacheckrc | 33 +++++++++++++++++++++++++++++++++ generate-luacheck.sh | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/.luacheckrc b/.luacheckrc index a892839c7d..bbb68907a8 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -2117,8 +2117,10 @@ stds.garrysmod = { "ACT_GMOD_GESTURE_MELEE_SHOVE_2HAND", "ACT_GMOD_GESTURE_MELEE_SHOVE_1HAND", "ACT_HL2MP_SWIM_IDLE", + "LAST_SHARED_ACTIVITY", --- BLOOD_COLOR + "DONT_BLEED", "BLOOD_COLOR_RED", "BLOOD_COLOR_YELLOW", "BLOOD_COLOR_GREEN", @@ -2258,6 +2260,7 @@ stds.garrysmod = { "COLLISION_GROUP_NPC_ACTOR", "COLLISION_GROUP_NPC_SCRIPTED", "COLLISION_GROUP_WORLD", + "LAST_SHARED_COLLISION_GROUP", --- COND "COND_BEHIND_ENEMY", @@ -2365,6 +2368,8 @@ stds.garrysmod = { "CONTENTS_MONSTER", "CONTENTS_ORIGIN", "CONTENTS_TRANSLUCENT", + "LAST_VISIBLE_CONTENTS", + "ALL_VISIBLE_CONTENTS", --- CREATERENDERTARGETFLAGS "CREATERENDERTARGETFLAGS_HDR", @@ -2419,6 +2424,12 @@ stds.garrysmod = { "DMG_SLOWBURN", --- DOCK + "NODOCK", + "FILL", + "LEFT", + "RIGHT", + "TOP", + "BOTTOM", --- DOF "DOF_OFFSET", @@ -2938,10 +2949,27 @@ stds.garrysmod = { "NAV_MESH_NAV_BLOCKER", --- NavCorner + "NORTH_WEST", + "NORTH_EAST", + "SOUTH_EAST", + "SOUTH_WEST", --- NavDir + "NORTH", + "EAST", + "SOUTH", + "WEST", --- NavTraverseType + "GO_NORTH", + "GO_EAST", + "GO_SOUTH", + "GO_WEST", + "GO_LADDER_UP", + "GO_LADDER_DOWN", + "GO_JUMP", + "GO_ELEVATOR_UP", + "GO_ELEVATOR_DOWN", --- NOTIFY "NOTIFY_GENERIC", @@ -3056,6 +3084,7 @@ stds.garrysmod = { "RT_SIZE_FULL_FRAME_BUFFER_ROUNDED_UP", --- SCHED + "LAST_SHARED_SCHEDULE", "SCHED_AISCRIPT", "SCHED_ALERT_FACE", "SCHED_ALERT_FACE_BESTSOUND", @@ -3423,6 +3452,10 @@ stds.garrysmod = { "USE_ON", "USE_SET", "USE_TOGGLE", + "CONTINUOUS_USE", + "ONOFF_USE", + "DIRECTIONAL_USE", + "SIMPLE_USE", --- WEAPON_PROFICIENCY "WEAPON_PROFICIENCY_POOR", diff --git a/generate-luacheck.sh b/generate-luacheck.sh index e822e8bf75..f3f77a8d4e 100755 --- a/generate-luacheck.sh +++ b/generate-luacheck.sh @@ -58,7 +58,7 @@ wget -o /dev/null -O - "$base_url"/navbar/ | url="$base_url/page/Enums/$detagged" # TODO: use URL from the tag wget "$url" -o /dev/null -O - | - sed -rn 's/ ('"$detagged"'_.*)/ "\1",/p' + sed -rn 's/^ ('"$detagged"'_[^[:space:]]+|[A-Z][A-Z0-9_]{2,})$/ "\1",/p' ;; Structures|Shaders|'Lua Reference'|Hooks|Libraries|Classes|Panels) From d43fc307fcc296e360ba503c493ac3b7e5672d4f Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Mon, 28 Nov 2016 11:26:52 +0100 Subject: [PATCH 12/56] Whitespace optimization --- lua/wire/client/sound_browser.lua | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lua/wire/client/sound_browser.lua b/lua/wire/client/sound_browser.lua index fa2136d4a2..f244d9a9bd 100644 --- a/lua/wire/client/sound_browser.lua +++ b/lua/wire/client/sound_browser.lua @@ -102,7 +102,7 @@ local function GenerateInfoTree(strfile, backnode, count) end end if not SoundData then return end - + local strcount = "" if count then strcount = " ("..count..")" @@ -113,7 +113,7 @@ local function GenerateInfoTree(strfile, backnode, count) local node = nil local mainnode = nil local subnode = nil - + if IsValid(backnode) then mainnode = backnode:AddNode("Sound File"..strcount, "icon16/sound.png") else @@ -121,7 +121,7 @@ local function GenerateInfoTree(strfile, backnode, count) SoundInfoTreeRoot = mainnode end - + do index = "Path" node = mainnode:AddNode(index, "icon16/sound.png") @@ -161,7 +161,7 @@ local function GenerateInfoTree(strfile, backnode, count) mainnode = SoundInfoTree:AddNode("Sound Property", "icon16/table_gear.png") SoundInfoTreeRoot = mainnode end - + do node = mainnode:AddNode("Name", "icon16/sound.png") subnode = node:AddNode(SoundData["name"], "icon16/page.png") @@ -569,7 +569,7 @@ local function CreateSoundBrowser(path, se) TabFileBrowser = vgui.Create("wire_filebrowser") -- The file tree browser. TabSoundPropertyList = vgui.Create("wire_soundpropertylist") -- The sound property browser. TabFavourites = vgui.Create("wire_listeditor") -- The favourites manager. - + TabFileBrowser:SetListSpeed(6) TabFileBrowser:SetMaxItemsPerPage(200) @@ -592,13 +592,13 @@ local function CreateSoundBrowser(path, se) if not IsValid(parent) then return end if not IsValid(node) then return end parent:SetSelectedItem(node) - + local Clicktime = CurTime() if (Clicktime - oldClicktime) > 0.3 then oldClicktime = Clicktime return end oldClicktime = Clicktime if not node.IsSoundNode then return end - + local file = node:GetText() PlaySound(file, nSoundVolume, nSoundPitch) PlaySoundNoEffect() @@ -653,7 +653,7 @@ local function CreateSoundBrowser(path, se) SplitPanel:SetLeftMin(500) SplitPanel:SetRightMin(150) SplitPanel:SetDividerWidth(3) - + TabFileBrowser:SetRootName("sound") TabFileBrowser:SetRootPath("sound") TabFileBrowser:SetWildCard("GAME") @@ -851,7 +851,7 @@ local function CreateSoundBrowser(path, se) SoundBrowserPanel.PerformLayout = function(self, ...) SoundemitterButton:SetVisible(self.Soundemitter) ClipboardButton:SetVisible(not self.Soundemitter) - + local w = self:GetWide() local rightw = SplitPanel:GetLeftWidth() + w - oldw @@ -874,7 +874,7 @@ local function CreateSoundBrowser(path, se) else ClipboardButton:SetTall(PlayStopPanel:GetTall() - 2) end - + oldw, oldh = self:GetSize() DFrame.PerformLayout(self, ...) @@ -896,7 +896,7 @@ end local function OpenSoundBrowser(pl, cmd, args) local path = args[1] -- nil or "" will put the browser in e2 mode else the soundemitter mode is applied. local se = args[2] - + if not IsValid(SoundBrowserPanel) then CreateSoundBrowser(path, se) end @@ -940,4 +940,4 @@ local function OpenSoundBrowser(pl, cmd, args) end, SoundBrowserPanel, TabFileBrowser, path, se) end -concommand.Add("wire_sound_browser_open", OpenSoundBrowser) \ No newline at end of file +concommand.Add("wire_sound_browser_open", OpenSoundBrowser) From dca84774696ec0fd3e79f7824e4ddc1db1390e67 Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Mon, 28 Nov 2016 11:44:06 +0100 Subject: [PATCH 13/56] Fix unused loop variables --- lua/wire/client/sound_browser.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lua/wire/client/sound_browser.lua b/lua/wire/client/sound_browser.lua index f244d9a9bd..b5328249aa 100644 --- a/lua/wire/client/sound_browser.lua +++ b/lua/wire/client/sound_browser.lua @@ -132,7 +132,7 @@ local function GenerateInfoTree(strfile, backnode, count) do index = "Duration" node = mainnode:AddNode(index, "icon16/time.png") - for k, v in pairs(SoundData[index]) do + for _, v in pairs(SoundData[index]) do subnode = node:AddNode(v, "icon16/page.png") subnode.IsDataNode = true end @@ -140,7 +140,7 @@ local function GenerateInfoTree(strfile, backnode, count) do index = "Size" node = mainnode:AddNode(index, "icon16/disk.png") - for k, v in pairs(SoundData[index]) do + for _, v in pairs(SoundData[index]) do subnode = node:AddNode(v, "icon16/page.png") subnode.IsDataNode = true end @@ -172,7 +172,7 @@ local function GenerateInfoTree(strfile, backnode, count) local tabchannel = SoundData["channel"] or 0 if istable(tabchannel) then node = mainnode:AddNode("Channel", "icon16/page_white_gear.png") - for k, v in pairs(tabchannel) do + for _, v in pairs(tabchannel) do subnode = node:AddNode(v, "icon16/page.png") subnode.IsDataNode = true subnode = node:AddNode(TranslateCHAN[v] or TranslateCHAN[CHAN_USER_BASE], "icon16/page.png") @@ -190,7 +190,7 @@ local function GenerateInfoTree(strfile, backnode, count) local tablevel = SoundData["level"] or 0 if istable(tablevel) then node = mainnode:AddNode("Level", "icon16/page_white_gear.png") - for k, v in pairs(tablevel) do + for _, v in pairs(tablevel) do subnode = node:AddNode(v, "icon16/page.png") subnode.IsDataNode = true subnode = node:AddNode(v, "icon16/page.png") @@ -206,7 +206,7 @@ local function GenerateInfoTree(strfile, backnode, count) local tabpitch = SoundData["volume"] or 0 if istable(tabpitch) then node = mainnode:AddNode("Volume", "icon16/page_white_gear.png") - for k, v in pairs(tabpitch) do + for _, v in pairs(tabpitch) do subnode = node:AddNode(v, "icon16/page.png") subnode.IsDataNode = true end @@ -220,7 +220,7 @@ local function GenerateInfoTree(strfile, backnode, count) local tabpitch = SoundData["pitch"] or 0 if istable(tabpitch) then node = mainnode:AddNode("Pitch", "icon16/page_white_gear.png") - for k, v in pairs(tabpitch) do + for _, v in pairs(tabpitch) do subnode = node:AddNode(v, "icon16/page.png") subnode.IsDataNode = true end From b584ef0aa6a17d2ba956a9310da1b09dab2cc6ba Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Mon, 28 Nov 2016 11:43:44 +0100 Subject: [PATCH 14/56] Fix unused initializations --- lua/wire/client/sound_browser.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) mode change 100644 => 100755 lua/wire/client/sound_browser.lua diff --git a/lua/wire/client/sound_browser.lua b/lua/wire/client/sound_browser.lua old mode 100644 new mode 100755 index b5328249aa..5fd41a9438 --- a/lua/wire/client/sound_browser.lua +++ b/lua/wire/client/sound_browser.lua @@ -62,10 +62,10 @@ local function FormatLength(nduration) end local function GetInfoTable(strfile) - local nsize, strformat, nduration = GetFileInfos(strfile) + local nsize, strformat = GetFileInfos(strfile) if not nsize then return end - nduration = SoundDuration(strfile) -- Get the duration for the info text only. + local nduration = SoundDuration(strfile) -- Get the duration for the info text only. if nduration then nduration = math.Round(nduration * 1000) / 1000 end @@ -109,10 +109,10 @@ local function GenerateInfoTree(strfile, backnode, count) end if IsFile then - local index = "" - local node = nil - local mainnode = nil - local subnode = nil + local index + local node + local mainnode + local subnode if IsValid(backnode) then mainnode = backnode:AddNode("Sound File"..strcount, "icon16/sound.png") @@ -152,8 +152,8 @@ local function GenerateInfoTree(strfile, backnode, count) subnode.IsDataNode = true end else - local node = nil - local mainnode = nil + local node + local mainnode if IsValid(backnode) then mainnode = backnode:AddNode("Sound Property"..strcount, "icon16/table_gear.png") @@ -332,7 +332,7 @@ local function Sendmenu(strSound, SoundEmitter, nSoundVolume, nSoundPitch) -- Op if strSound == "" then return end local Menu = DermaMenu() - local MenuItem = nil + local MenuItem if SoundEmitter then From 23a8b01fb603174c63b5f0ee0e32b9490273ceec Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Mon, 28 Nov 2016 11:38:40 +0100 Subject: [PATCH 15/56] Add missing locals --- lua/wire/client/sound_browser.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/wire/client/sound_browser.lua b/lua/wire/client/sound_browser.lua index 5fd41a9438..7234e81f08 100755 --- a/lua/wire/client/sound_browser.lua +++ b/lua/wire/client/sound_browser.lua @@ -154,6 +154,7 @@ local function GenerateInfoTree(strfile, backnode, count) else local node local mainnode + local subnode if IsValid(backnode) then mainnode = backnode:AddNode("Sound Property"..strcount, "icon16/table_gear.png") @@ -482,6 +483,7 @@ local function Infomenu(parent, node, SoundEmitter, nSoundVolume, nSoundPitch) end local Menu = DermaMenu() + local MenuItem -- Copy to clipboard MenuItem = Menu:AddOption("Copy to clipboard", function() From 62645d9fe319c4e4e7e927cc4fb6578b5a7a88ec Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Mon, 28 Nov 2016 14:48:45 +0100 Subject: [PATCH 16/56] Fix some double definition errors --- lua/wire/client/sound_browser.lua | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lua/wire/client/sound_browser.lua b/lua/wire/client/sound_browser.lua index 7234e81f08..bf20e35316 100755 --- a/lua/wire/client/sound_browser.lua +++ b/lua/wire/client/sound_browser.lua @@ -58,7 +58,7 @@ local function FormatLength(nduration) local nm = math.floor(nduration / 60) local ns = math.floor(nduration % 60) local nms = (nduration % 1) * 1000 - return nduration, (string.format("%01d", nm)..":"..string.format("%02d", ns).."."..string.format("%03d", nms)) + return string.format("%01d", nm)..":"..string.format("%02d", ns).."."..string.format("%03d", nms) end local function GetInfoTable(strfile) @@ -69,7 +69,7 @@ local function GetInfoTable(strfile) if nduration then nduration = math.Round(nduration * 1000) / 1000 end - local nduration, strduration = FormatLength(nduration, nsize) + local strduration = FormatLength(nduration, nsize) local nsizeB, strsize = FormatSize(nsize) local T = {} @@ -675,7 +675,7 @@ local function CreateSoundBrowser(path, se) if not nsize then return end local nsizeB, strsize = FormatSize(nsize, nduration) - local nduration, strduration = FormatLength(nduration, nsize) + local strduration = FormatLength(nduration, nsize) --return {strformat, strsize or "n/a", strduration or "n/a"} -- getting the duration is very slow. return {strformat, strsize or "n/a"} @@ -914,11 +914,6 @@ local function OpenSoundBrowser(pl, cmd, args) if not IsValid(SoundBrowserPanel) then return end if not IsValid(TabFileBrowser) then return end - local soundemitter = false - if isstring(path) and path ~= "" then - soundemitter = true - end - local soundemitter = false if isstring(path) and path ~= "" then soundemitter = true From de6c877469dea9657058387245a4ff0974d25146 Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Mon, 28 Nov 2016 14:59:09 +0100 Subject: [PATCH 17/56] Fix some shadowed upvalue errors --- lua/wire/client/sound_browser.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/wire/client/sound_browser.lua b/lua/wire/client/sound_browser.lua index bf20e35316..f138172a43 100755 --- a/lua/wire/client/sound_browser.lua +++ b/lua/wire/client/sound_browser.lua @@ -910,7 +910,7 @@ local function OpenSoundBrowser(pl, cmd, args) if not IsValid(TabFileBrowser) then return end -- Replaces the timer, doesn't get paused in singleplayer. - WireLib.Timedcall(function(SoundBrowserPanel, TabFileBrowser, path, se) + WireLib.Timedcall(function() if not IsValid(SoundBrowserPanel) then return end if not IsValid(TabFileBrowser) then return end @@ -934,7 +934,7 @@ local function OpenSoundBrowser(pl, cmd, args) path = SoundBrowserPanel:GetCookie("wire_soundfile", "") -- load last session end TabFileBrowser:SetOpenFile(path) - end, SoundBrowserPanel, TabFileBrowser, path, se) + end) end concommand.Add("wire_sound_browser_open", OpenSoundBrowser) From f4b7dfdc5d0b45ae206a981e4f5f92749524dc2a Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Mon, 28 Nov 2016 16:04:24 +0100 Subject: [PATCH 18/56] Remove an unused callback --- lua/wire/client/sound_browser.lua | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lua/wire/client/sound_browser.lua b/lua/wire/client/sound_browser.lua index f138172a43..a6f2ba482e 100755 --- a/lua/wire/client/sound_browser.lua +++ b/lua/wire/client/sound_browser.lua @@ -681,10 +681,6 @@ local function CreateSoundBrowser(path, se) return {strformat, strsize or "n/a"} end - TabFileBrowser.OnLineAdded = function(self, id, line, strfile, ...) - - end - TabFileBrowser.DoClick = function(parent, file) SaveFilePath(SoundBrowserPanel, file) From dedc59c65362156df11b27db9a6d8dad450aaf29 Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Mon, 28 Nov 2016 16:07:17 +0100 Subject: [PATCH 19/56] Remove superfluous arguments --- lua/wire/client/sound_browser.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/wire/client/sound_browser.lua b/lua/wire/client/sound_browser.lua index a6f2ba482e..6e5734be00 100755 --- a/lua/wire/client/sound_browser.lua +++ b/lua/wire/client/sound_browser.lua @@ -455,7 +455,7 @@ local function Sendmenu(strSound, SoundEmitter, nSoundVolume, nSoundPitch) -- Op -- Play MenuItem = Menu:AddOption("Play", function() - PlaySound(strSound, nSoundVolume, nSoundPitch, strtype) + PlaySound(strSound, nSoundVolume, nSoundPitch) PlaySoundNoEffect() end) MenuItem:SetImage("icon16/control_play.png") @@ -463,7 +463,7 @@ local function Sendmenu(strSound, SoundEmitter, nSoundVolume, nSoundPitch) -- Op -- Play without effects MenuItem = Menu:AddOption("Play without effects", function() PlaySound() - PlaySoundNoEffect(strSound, strtype) + PlaySoundNoEffect(strSound) end) MenuItem:SetImage("icon16/control_play_blue.png") From ad9603e1c09a602675773efb708d7126240991b3 Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Mon, 28 Nov 2016 15:53:11 +0100 Subject: [PATCH 20/56] Fix an "undefined variable" error Potentially fixes some kind of right-click functionality in the sound browser tree. --- lua/wire/client/sound_browser.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lua/wire/client/sound_browser.lua b/lua/wire/client/sound_browser.lua index 6e5734be00..cd56e582e0 100755 --- a/lua/wire/client/sound_browser.lua +++ b/lua/wire/client/sound_browser.lua @@ -328,14 +328,14 @@ local function SetupClipboard(strSound) SetClipboardText(strSound) end -local function Sendmenu(strSound, SoundEmitter, nSoundVolume, nSoundPitch) -- Open a sending and setup menu on right click on a sound file. +local function Sendmenu(strSound, soundemitter, nSoundVolume, nSoundPitch) -- Open a sending and setup menu on right click on a sound file. if not isstring(strSound) then return end if strSound == "" then return end local Menu = DermaMenu() local MenuItem - if SoundEmitter then + if soundemitter then -- Setup soundemitter MenuItem = Menu:AddOption("Setup soundemitter", function() @@ -470,7 +470,7 @@ local function Sendmenu(strSound, SoundEmitter, nSoundVolume, nSoundPitch) -- Op Menu:Open() end -local function Infomenu(parent, node, SoundEmitter, nSoundVolume, nSoundPitch) +local function Infomenu(parent, node, soundemitter, nSoundVolume, nSoundPitch) if not IsValid(node) then return end if not node.IsDataNode then return end @@ -478,7 +478,7 @@ local function Infomenu(parent, node, SoundEmitter, nSoundVolume, nSoundPitch) local IsSoundNode = node.IsSoundNode if IsSoundNode then - Sendmenu(strNodeName, SoundEmitter, nSoundVolume, nSoundPitch) + Sendmenu(strNodeName, soundemitter, nSoundVolume, nSoundPitch) return end @@ -610,7 +610,7 @@ local function CreateSoundBrowser(path, se) if not IsValid(node) then return end parent:SetSelectedItem(node) - Infomenu(parent, node, SoundEmitter, nSoundVolume, nSoundPitch) + Infomenu(parent, node, soundemitter, nSoundVolume, nSoundPitch) end SoundInfoTree.OnNodeSelected = function( parent, node ) From d757b4c713fc38495c69c577bc16dfaccdd05077 Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Mon, 28 Nov 2016 08:56:59 +0100 Subject: [PATCH 21/56] Added "Games" node to the sound browser's info tree --- lua/wire/client/sound_browser.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lua/wire/client/sound_browser.lua b/lua/wire/client/sound_browser.lua index cd56e582e0..0ed326de8b 100755 --- a/lua/wire/client/sound_browser.lua +++ b/lua/wire/client/sound_browser.lua @@ -87,6 +87,17 @@ local function GetInfoTable(strfile) return T, not tabproperty end +local function GetGamesForSound(path) + local games = {} + + for _,game in pairs(engine.GetGames()) do + if game.mounted and file.Exists(path, game.folder) then + table.insert(games, game) + end + end + + return games +end -- Output the infos about the given sound. local oldstrfile @@ -151,6 +162,16 @@ local function GenerateInfoTree(strfile, backnode, count) subnode = node:AddNode(SoundData[index], "icon16/page.png") subnode.IsDataNode = true end + do + local games = GetGamesForSound(SoundData["Path"]) + + node = mainnode:AddNode("Games", "icon16/page_white_key.png") + + for _, game in ipairs(games) do + subnode = node:AddNode(game, "icon16/page.png") + subnode.IsDataNode = true + end + end else local node local mainnode From e7decff218098d42b757bea9b002e3fa0cb1edfe Mon Sep 17 00:00:00 2001 From: Python1320 Date: Sat, 31 Dec 2016 13:58:17 +0200 Subject: [PATCH 22/56] Fix invalid hook call --- lua/entities/gmod_wire_forcer.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/entities/gmod_wire_forcer.lua b/lua/entities/gmod_wire_forcer.lua index 51e14b1226..e55c83cbf8 100644 --- a/lua/entities/gmod_wire_forcer.lua +++ b/lua/entities/gmod_wire_forcer.lua @@ -68,7 +68,7 @@ function ENT:Think() } if not IsValid(trace.Entity) then return end - if not gamemode.Call( "GravGunPunt", self:GetPlayer(), trace.Entity ) then return end + if self:GetPlayer():IsValid() and not gamemode.Call( "GravGunPunt", self:GetPlayer(), trace.Entity ) then return end if trace.Entity:GetMoveType() == MOVETYPE_VPHYSICS then local phys = trace.Entity:GetPhysicsObject() From f1bd8477de35a7366523534d256e6c1c95bf41ea Mon Sep 17 00:00:00 2001 From: Python1320 Date: Sun, 1 Jan 2017 01:36:45 +0200 Subject: [PATCH 23/56] Add WireLib.NumModelSkins(model) ```lua -- test: print(WireLib.NumModelSkins'models/props_junk/plasticCrate01a.mdl') ``` --- lua/wire/server/wirelib.lua | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lua/wire/server/wirelib.lua b/lua/wire/server/wirelib.lua index 305b4cbbd3..f6ee08d8de 100644 --- a/lua/wire/server/wirelib.lua +++ b/lua/wire/server/wirelib.lua @@ -1058,10 +1058,21 @@ function WireLib.dummytrace(ent) } end +function WireLib.NumModelSkins(model) + if NumModelSkins then + return NumModelSkins(model) + end + local info = util.GetModelInfo(model) + return info and info.SkinCount +end + --- @return whether the given player can spawn an object with the given model and skin function WireLib.CanModel(player, model, skin) if not util.IsValidModel(model) then return false end - if skin ~= nil and NumModelSkins(model) <= skin then return false end + if skin ~= nil then + local count = WireLib.NumModelSkins(model) + if count and count <= skin then return false end + end if IsValid(player) and player:IsPlayer() and not hook.Run("PlayerSpawnObject", player, model, skin) then return false end return true end @@ -1071,7 +1082,7 @@ function WireLib.MakeWireEnt( pl, Data, ... ) if IsValid(pl) and not pl:CheckLimit(Data.Class:sub(6).."s") then return false end if Data.Model and not WireLib.CanModel(pl, Data.Model, Data.Skin) then return false end - local ent = ents.Create( Data.Class ) + local ent = ents.Create( Data.Class ) if not IsValid(ent) then return false end duplicator.DoGeneric( ent, Data ) From 3924a7df92e1d864e205f6bcc2ebdb11122fa668 Mon Sep 17 00:00:00 2001 From: Python1320 Date: Sun, 1 Jan 2017 15:14:31 +0200 Subject: [PATCH 24/56] my fault --- lua/wire/server/wirelib.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/wire/server/wirelib.lua b/lua/wire/server/wirelib.lua index da21373f6c..04a9d360d4 100644 --- a/lua/wire/server/wirelib.lua +++ b/lua/wire/server/wirelib.lua @@ -1047,7 +1047,7 @@ function WireLib.MakeWireEnt( pl, Data, ... ) if IsValid(pl) and not pl:CheckLimit(Data.Class:sub(6).."s") then return false end if Data.Model and not WireLib.CanModel(pl, Data.Model, Data.Skin) then return false end - local ent = ents.Create( Data.Class ) + local ent = ents.Create( Data.Class ) if not IsValid(ent) then return false end duplicator.DoGeneric( ent, Data ) From c43b7cb66ab9fcf07127b83725d223e467e6e17f Mon Sep 17 00:00:00 2001 From: Python1320 Date: Sun, 1 Jan 2017 17:19:43 +0200 Subject: [PATCH 25/56] Revert "Merge branch 'ropt'" This reverts commit 2aa02db76a9959856044f30670ee5c94715fb452, reversing changes made to 91769955ec77542ce7429f670aa9ad452de33088. --- lua/autorun/wire_load.lua | 6 +- lua/weapons/gmod_tool/stools/wire_adv.lua | 8 +- lua/wire/beam_netvars.lua | 406 ++++++++++++++++++++++ lua/wire/client/cl_wirelib.lua | 188 +++++++--- lua/wire/server/wirelib.lua | 79 ++++- lua/wire/wire_paths.lua | 116 ------- 6 files changed, 621 insertions(+), 182 deletions(-) create mode 100644 lua/wire/beam_netvars.lua delete mode 100644 lua/wire/wire_paths.lua diff --git a/lua/autorun/wire_load.lua b/lua/autorun/wire_load.lua index 904fdfa7b1..41e0927aac 100644 --- a/lua/autorun/wire_load.lua +++ b/lua/autorun/wire_load.lua @@ -26,8 +26,8 @@ if SERVER then AddCSLuaFile("autorun/wire_load.lua") -- shared includes - AddCSLuaFile("wire/wire_paths.lua") AddCSLuaFile("wire/wireshared.lua") + AddCSLuaFile("wire/beam_netvars.lua") AddCSLuaFile("wire/wiregates.lua") AddCSLuaFile("wire/wiremonitors.lua") AddCSLuaFile("wire/gpulib.lua") @@ -86,7 +86,7 @@ end -- shared includes include("wire/wireshared.lua") -include("wire/wire_paths.lua") +include("wire/beam_netvars.lua") include("wire/wiregates.lua") include("wire/wiremonitors.lua") include("wire/gpulib.lua") @@ -126,7 +126,7 @@ if CLIENT then include("wire/client/rendertarget_fix.lua") include("wire/client/hlzasm/hc_compiler.lua") include("wire/client/customspawnmenu.lua") - + end -- Load UWSVN, done here so its definitely after Wire is loaded. diff --git a/lua/weapons/gmod_tool/stools/wire_adv.lua b/lua/weapons/gmod_tool/stools/wire_adv.lua index 66a2f08ade..74a4df84fe 100644 --- a/lua/weapons/gmod_tool/stools/wire_adv.lua +++ b/lua/weapons/gmod_tool/stools/wire_adv.lua @@ -339,7 +339,7 @@ elseif CLIENT then TOOL.ShowEntity = false -- bool for showing "Create Entity" output function TOOL:Holster() - if IsValid(self.CurrentEntity) then self.CurrentEntity:SetNWString("BlinkWire", "") end + if IsValid(self.CurrentEntity) then self.CurrentEntity:SetNetworkedBeamString("BlinkWire", "") end self.CurrentEntity = nil self.Wiring = {} self.WiringRender = {} @@ -657,7 +657,7 @@ elseif CLIENT then end if oldport ~= self.CurrentWireIndex then - ent:SetNWString("BlinkWire", check[self.CurrentWireIndex][1]) + ent:SetNetworkedBeamString("BlinkWire", check[self.CurrentWireIndex][1]) self:GetOwner():EmitSound("weapons/pistol/pistol_empty.wav") end return true @@ -729,7 +729,7 @@ elseif CLIENT then -- Clear blinking wire if IsValid( self.AimingEnt ) then - self.AimingEnt:SetNWString("BlinkWire", "") + self.AimingEnt:SetNetworkedBeamString("BlinkWire", "") end if IsValid( ent ) then @@ -750,7 +750,7 @@ elseif CLIENT then -- Set blinking wire if check[self.CurrentWireIndex] then - ent:SetNWString("BlinkWire", check[self.CurrentWireIndex][1]) + ent:SetNetworkedBeamString("BlinkWire", check[self.CurrentWireIndex][1]) end end end diff --git a/lua/wire/beam_netvars.lua b/lua/wire/beam_netvars.lua new file mode 100644 index 0000000000..3d513e945b --- /dev/null +++ b/lua/wire/beam_netvars.lua @@ -0,0 +1,406 @@ +-- this is all crap D: + +/////////////////////////////////////////////// +// ===BeamNetVars=== // +// Custom Networked Vars Module // +// Based off Garry's Networked Vars Module // +// Modification by: TAD2020 // +/////////////////////////////////////////////// +// How to use: // +// Just like NetVars, ent:SetNetworkedBeam* // +// and ent:GetNetworkedBeam* // +// Key should be short or a small number. // +// These functions should only be used instead // +// standard NetVars when very large quanity // +// of rarly updated values need to be sent with // +// low importantance. Mainly this is used by // +// wire's client side beams and rapidly updating // +// overlay text. // +// Data is sent at a tick interval, if too much // +// is in the outgoing query, the delay between // +// sends is increased. // +// On player joins, all current data is queried to // +// to send to them in the lowest priority stack. // +// Low priority stack sends a few entities's // +// vars each tick. // +/////////////////////////////////////////////// + +//RD header for multi distro-ablity +local ThisBeamNetVarsVersion = 0.71 +if (BeamNetVars) and (BeamNetVars.Version) and (BeamNetVars.Version > ThisBeamNetVarsVersion) then + Msg("======== A Newer Version of BeamNetVars Detected ========\n".. + "======== This ver: "..ThisBeamNetVarsVersion.." || Detected ver: "..BeamNetVars.Version.." || Skipping\n") + return +elseif (BeamNetVars) and (BeamNetVars.Version) and (BeamNetVars.Version == ThisBeamNetVarsVersion) then + --Msg("======== The Same Version of BeamNetVars Detected || Skipping ========\n") + return +elseif (BeamNetVars) and (BeamNetVars.Version) then + Msg("======== Am Older Version of BeamNetVars Detected ========\n".. + "======== This ver: "..ThisBeamNetVarsVersion.." || Detected ver: "..BeamNetVars.Version.." || Overriding\n") +end + + +BeamNetVars = {} +BeamNetVars.Version = ThisBeamNetVarsVersion + +if (SERVER) then + //we want this + //sv_usermessage_maxsize = 1024 + game.ConsoleCommand( "sv_usermessage_maxsize 1024\n" ) +end + +local meta = FindMetaTable( "Entity" ) + +// Return if there's nothing to add on to +if (!meta) then return end + +local Vector_Default = Vector(0,0,0) +local Angle_Default = Angle(0,0,0) + +local NetworkVars = {} + +local NetworkFunction = {} +local DelayedUpdates = {} +local DelayedUpdatesNum = 0 +local ExtraDelayedUpdates = {} + +local NextCleanup = CurTime() + +local Wire_FastOverlayTextUpdate = CreateConVar("Wire_FastOverlayTextUpdate", 0, FCVAR_ARCHIVE) + +if ( CLIENT ) then + local function Dump() + Msg("Networked Beam Vars...\n") + PrintTable( NetworkVars ) + end + concommand.Add( "networkbeamvars_dump", Dump ) +end + +local function AttemptToSwitchTables( Ent, EntIndex ) + if ( NetworkVars[ EntIndex ] == nil ) then return end + // We have an old entindex based entry! Move it over! + NetworkVars[ Ent ] = NetworkVars[ EntIndex ] + NetworkVars[ EntIndex ] = nil +end + +local function CleaupNetworkVars() + if ( NextCleanup > CurTime() ) then return end + NextCleanup = CurTime() + 30 + for k, v in pairs( NetworkVars ) do + if !isnumber( k ) and !isstring( k ) then + if ( !k:IsValid() ) then + NetworkVars[ k ] = nil + end + end + end +end + +local function GetNetworkTable( ent, name ) + if ( CLIENT ) then + CleaupNetworkVars() + end + if ( !NetworkVars[ ent ] ) then + NetworkVars[ ent ] = {} + // This is the first time this entity has been created. + // Check whether we previously had an entindex based table + if ( CLIENT && !isnumber( ent ) && !isstring( ent ) ) then + AttemptToSwitchTables( ent, ent:EntIndex() ) + end + end + NetworkVars[ ent ][ name ] = NetworkVars[ ent ][ name ] or {} + return NetworkVars[ ent ][ name ] +end + +local function SendNetworkUpdate( VarType, Index, Key, Value, Player ) + if(Player and not (Player:IsValid() and Player:IsPlayer())) then return end // Be sure, Player is not a NULL-Entity, or the server will crash! + + umsg.Start( "RcvEntityVarBeam_"..VarType, Player ) + umsg.Short( Index ) + umsg.String( Key ) + umsg[ NetworkFunction[VarType].SetFunction ]( Value ) + umsg.End() + + +end + +local function AddDelayedNetworkUpdate( VarType, Ent, Key, Value ) + if (Wire_FastOverlayTextUpdate:GetBool()) then + SendNetworkUpdate( VarType, Ent, Key, Value ) + elseif (Ent) and (VarType) then + DelayedUpdates[Ent] = DelayedUpdates[Ent] or {} + DelayedUpdates[Ent][ VarType ] = DelayedUpdates[Ent][ VarType ] or {} + DelayedUpdates[Ent][ VarType ][Key] = Value + DelayedUpdatesNum = DelayedUpdatesNum + 1 + + if (ExtraDelayedUpdates[Ent]) + and (ExtraDelayedUpdates[Ent][VarType]) + and (ExtraDelayedUpdates[Ent][VarType][Key]) then + ExtraDelayedUpdates[Ent][VarType][Key] = nil + end + end +end + +local function AddExtraDelayedNetworkUpdate( VarType, Ent, Key, Value, Player ) + if (Wire_FastOverlayTextUpdate:GetBool()) then + SendNetworkUpdate( VarType, Ent, Key, Value ) + elseif (Ent) and (VarType) and (Key) then + ExtraDelayedUpdates[Ent] = ExtraDelayedUpdates[Ent] or {} + ExtraDelayedUpdates[Ent][VarType] = ExtraDelayedUpdates[Ent][VarType] or {} + ExtraDelayedUpdates[Ent][VarType][Key] = ExtraDelayedUpdates[Ent][VarType][Key] or {} + ExtraDelayedUpdates[Ent][VarType][Key].Value = Value + ExtraDelayedUpdates[Ent][VarType][Key].Player = Player + --ExtraDelayedUpdatesNum = ExtraDelayedUpdatesNum + 1 + end +end + + + +// +// make all the ent.Get/SetNetworkedBeamVarCrap +// +local function AddNetworkFunctions( name, SetFunction, GetFunction, Default ) + + NetworkFunction[ name ] = {} + NetworkFunction[ name ].SetFunction = SetFunction + NetworkFunction[ name ].GetFunction = GetFunction + + // SetNetworkedBlah + meta[ "SetNetworkedBeam" .. name ] = function ( self, key, value, urgent ) + + key = tostring(key) + + // The same - don't waste our time. + if ( value == GetNetworkTable( self, name )[ key ] ) then return end + + // Clients can set this too, but they should only really be setting it + // when they expect the exact same result coming over the wire (ie prediction) + GetNetworkTable( self, name )[key] = value + + if ( SERVER ) then + + local Index = self:EntIndex() + if (Index <= 0) then return end + + if ( urgent ) then + SendNetworkUpdate( name, Index, key, value ) + else + AddDelayedNetworkUpdate( name, Index, key, value ) + end + + end + + end + + meta[ "SetNWB" .. name ] = meta[ "SetNetworkedBeam" .. name ] + + // GetNetworkedBlah + meta[ "GetNetworkedBeam" .. name ] = function ( self, key, default ) + + key = tostring(key) + + local out = GetNetworkTable( self, name )[ key ] + if ( out != nil ) then return out end + if ( default == nil ) then return Default end + //default = default or Default -- not a good idea for booleans :) + + return default + + end + + meta[ "GetNWB" .. name ] = meta[ "GetNetworkedBeam" .. name ] + + + // SetGlobalBlah + _G[ "SetGlobalBeam"..name ] = function ( key, value, urgent ) + + key = tostring(key) + + if ( value == GetNetworkTable( "G", name )[key] ) then return end + GetNetworkTable( "G", name )[key] = value + + if ( SERVER ) then + if ( urgent ) then + SendNetworkUpdate( name, -1, key, value ) + else + AddDelayedNetworkUpdate( name, -1, key, value ) + end + end + + end + + + // GetGlobalBlah + _G[ "GetGlobalBeam"..name ] = function ( key ) + + key = tostring(key) + + local out = GetNetworkTable( "G", name )[key] + if ( out != nil ) then return out end + + return Default + + end + + + if ( SERVER ) then + // Pool the name of the function. + // Makes it send a number representing the string rather than the string itself. + // Only do this with strings that you send quite a bit and always stay the same. + umsg.PoolString( "RcvEntityBeamVar_"..name ) + end + + // Client Receive Function + if ( CLIENT ) then + + local function RecvFunc( m ) + local EntIndex = m:ReadShort() + local Key = m:ReadString() + local Value = m[GetFunction]( m ) + + local IndexKey + if ( EntIndex <= 0 ) then + IndexKey = "G" + else + IndexKey = Entity( EntIndex ) + // No entity yet - store using entindex + if ( IndexKey == NULL ) then IndexKey = EntIndex end + end + GetNetworkTable( IndexKey, name )[Key] = Value + end + usermessage.Hook( "RcvEntityVarBeam_"..name, RecvFunc ) + + end + +end + +AddNetworkFunctions( "Vector", "Vector", "ReadVector", Vector_Default ) +AddNetworkFunctions( "Angle", "Angle", "ReadAngle", Angle_Default ) +AddNetworkFunctions( "Float", "Float", "ReadFloat", 0 ) +AddNetworkFunctions( "Int", "Short", "ReadShort", 0 ) +AddNetworkFunctions( "Entity", "Entity", "ReadEntity", NULL ) +AddNetworkFunctions( "Bool", "Bool", "ReadBool", false ) +AddNetworkFunctions( "String", "String", "ReadString", "" ) + + + + + + +// +// We want our networked vars to save don't we? Yeah - we do - stupid. +// +local function Save( save ) + // Remove baggage + for k, v in pairs(NetworkVars) do + if ( k == NULL ) then + NetworkVars[k] = nil + end + end + saverestore.WriteTable( NetworkVars, save ) +end +local function Restore( restore ) + NetworkVars = saverestore.ReadTable( restore ) + //PrintTable(NetworkVars) +end +saverestore.AddSaveHook( "EntityNetworkedBeamVars", Save ) +saverestore.AddRestoreHook( "EntityNetworkedBeamVars", Restore ) + +if (SERVER) then +// +// send the netvars queried in the stack +// +local NextBeamVarsDelayedSendTime = 0 +local NormalOpMode = true +local function NetworkVarsSend() + if (CurTime() >= NextBeamVarsDelayedSendTime) then + + if (NormalOpMode) and (DelayedUpdatesNum > 75) then + --Msg("========BeamVars leaving NormalOpMode | "..DelayedUpdatesNum.."\n") + NormalOpMode = false + elseif (!NormalOpMode) and (DelayedUpdatesNum < 50) then + --Msg("========BeamVars returning NormalOpMode | "..DelayedUpdatesNum.."\n") + NormalOpMode = true + end + + + if (DelayedUpdatesNum > 0) then + for Index, a in pairs(DelayedUpdates) do + for VarType, b in pairs(a) do + for Key, Value in pairs(b) do + SendNetworkUpdate( VarType, Index, Key, Value ) + end + end + end + DelayedUpdatesNum = 0 + DelayedUpdates = {} + end + + //we send one entity's ExtraDelayedUpdates each tick + local i = 0 + for Index, a in pairs(ExtraDelayedUpdates) do + for VarType, b in pairs(a) do + for Key, data in pairs(b) do + SendNetworkUpdate( VarType, Index, Key, data.Value, data.Player ) + end + end + ExtraDelayedUpdates[Index] = nil + i = i + 1 + if (i >= 2) then + break + end + end + + if (!NormalOpMode) then + NextBeamVarsDelayedSendTime = CurTime() + .25 + else + NextBeamVarsDelayedSendTime = CurTime() + .1 + end + + end +end +hook.Add("Think", "NetBeamLib_Think", NetworkVarsSend) + + +// +// Send a full update to player that have just joined the server +// +local function FullUpdateEntityNetworkVars( ply ) + --Msg("==sending netbeamvar var data to "..tostring(ply).."\n") + --Msg("\n===Size: "..table.Count(NetworkVars).."\n") + for Ent, EntTable in pairs(NetworkVars) do + for Type, TypeTable in pairs(EntTable) do + for Key, Value in pairs(TypeTable) do + local Index = Ent + if !isstring(Ent) then + Index = Ent:EntIndex() + end + --SendNetworkUpdate( Type, Index , Key, Value, ply ) + AddExtraDelayedNetworkUpdate( Type, Index , Key, Value, ply ) + end + end + + end +end +local function DelayedFullUpdateEntityNetworkVars( ply ) + --Msg("==starting timer for sending var data too "..tostring(ply).."\n") + timer.Simple(4, function() FullUpdateEntityNetworkVars(ply) end ) +end +hook.Add( "PlayerInitialSpawn", "FullUpdateEntityNetworkBeamVars", DelayedFullUpdateEntityNetworkVars ) +concommand.Add( "networkbeamvars_SendAll", DelayedFullUpdateEntityNetworkVars ) +concommand.Add( "networkbeamvars_SendAllNow", FullUpdateEntityNetworkVars ) + + +// +// Listen out for dead entities so we can remove their vars +// +local function NetworkVarsCleanup( ent ) + NetworkVars[ ent ] = nil +end +hook.Add( "EntityRemoved", "NetworkBeamVarsCleanup", NetworkVarsCleanup ) + + +end //end SERVER olny + + + +--Msg("======== Beam NetVars Lib v"..BeamNetVars.Version.." Installed ========\n") diff --git a/lua/wire/client/cl_wirelib.lua b/lua/wire/client/cl_wirelib.lua index 42882abad4..07615e8184 100644 --- a/lua/wire/client/cl_wirelib.lua +++ b/lua/wire/client/cl_wirelib.lua @@ -1,7 +1,7 @@ local WIRE_SCROLL_SPEED = 0.5 local WIRE_BLINKS_PER_SECOND = 2 local CurPathEnt = {} -local Wire_DisableWireRender = 0 +local Wire_DisableWireRender = 2 --bug with mode 0 and gmod2007beta WIRE_CLIENT_INSTALLED = 1 @@ -34,53 +34,149 @@ end local beam_mat = mats["tripmine_laser"] local beamhi_mat = mats["Models/effects/comball_tape"] -local lastrender, scroll, shouldblink = 0, 0, false function Wire_Render(ent) + if (not ent:IsValid()) then return end + if (Wire_DisableWireRender == 1) then return end + if (Wire_DisableWireRender == 0) then - local wires = ent.WirePaths - if wires and next(wires) then - - local t = CurTime() - if lastrender ~= t then - local w, f = math.modf(t*WIRE_BLINKS_PER_SECOND) - shouldblink = f < 0.5 - scroll = t*WIRE_SCROLL_SPEED - lastrender = t - end + local path_count = ent:GetNetworkedBeamInt("wpn_count") or 0 + if (path_count <= 0) then return end - local blink = shouldblink and ent:GetNWString("BlinkWire") + local w,f = math.modf(CurTime()*WIRE_BLINKS_PER_SECOND) + local blink = nil + if (f < 0.5) then + blink = ent:GetNetworkedBeamString("BlinkWire") + end - for net_name, wiretbl in pairs(wires) do - local width = wiretbl.Width - if width > 0 and blink ~= net_name then - local start = wiretbl.StartPos - if (ent:IsValid()) then start = ent:LocalToWorld(start) end - local color = wiretbl.Color + for i = 1,path_count do + local path_name = ent:GetNetworkedBeamString("wpn_" .. i) + if (blink ~= path_name) then + local net_name = "wp_"..path_name + local len = ent:GetNetworkedBeamInt(net_name) or 0 - local nodes = wiretbl.Path - local len = #nodes - if len>0 then - render.SetMaterial(getmat(wiretbl.Material)) + if (len > 0) then + + local width = ent:GetNetworkedBeamFloat(net_name .. "_width") + if width > 0 then + + local start = ent:GetNetworkedBeamVector(net_name .. "_start") + if (ent:IsValid()) then start = ent:LocalToWorld(start) end + local color_v = ent:GetNetworkedBeamVector(net_name .. "_col") + local color = Color(color_v.x, color_v.y, color_v.z, 255) + local scroll = CurTime()*WIRE_SCROLL_SPEED + + render.SetMaterial(getmat(ent:GetNetworkedBeamString(net_name .. "_mat"))) render.StartBeam(len+1) render.AddBeam(start, width, scroll, color) - for j=1, len do - local node = nodes[j] - local node_ent = node.Entity + for j=1,len do + local node_ent = ent:GetNetworkedBeamEntity(net_name .. "_" .. j .. "_ent") + local endpos = ent:GetNetworkedBeamVector(net_name .. "_" .. j .. "_pos") if (node_ent:IsValid()) then - local endpos = node_ent:LocalToWorld(node.Pos) + endpos = node_ent:LocalToWorld(endpos) scroll = scroll+(endpos-start):Length()/10 + render.AddBeam(endpos, width, scroll, color) start = endpos end end render.EndBeam() + end end end end + + else + local p = ent.ppp + if p == nil then p = {next = -100} end + + if p.next < CurTime() then + p.next = CurTime() + 0.25 + p.paths = {} + + local path_count = ent:GetNetworkedBeamInt("wpn_count") or 0 + if (path_count <= 0) then return end + + for i = 1,path_count do + local x = {} + local path_name = ent:GetNetworkedBeamString("wpn_" .. i) + x.path_name = path_name + local net_name = "wp_"..path_name + local len = ent:GetNetworkedBeamInt(net_name) or 0 + + if (len > 0) then + + local start = ent:GetNetworkedBeamVector(net_name .. "_start") + x.startx = start + if (ent:IsValid()) then start = ent:LocalToWorld(start) end + local color_v = ent:GetNetworkedBeamVector(net_name .. "_col") + local color = Color(color_v.x, color_v.y, color_v.z, 255) + local width = ent:GetNetworkedBeamFloat(net_name .. "_width") + + local scroll = CurTime()*WIRE_SCROLL_SPEED + + x.material = getmat(ent:GetNetworkedBeamString(net_name .. "_mat")) + x.startbeam = len + 1 + x.start = start + x.width = width + x.scroll = scroll + x.color = color + x.beams = {} + + for j=1,len do + local v = {} + local node_ent = ent:GetNetworkedBeamEntity(net_name .. "_" .. j .. "_ent") + local endpos = ent:GetNetworkedBeamVector(net_name .. "_" .. j .. "_pos") + v.node_ent = node_ent + v.node_endpos = endpos + if (node_ent:IsValid()) then + endpos = node_ent:LocalToWorld(endpos) + + scroll = scroll+(endpos-start):Length()/10 + + v.endpos = endpos + v.width = width + v.scroll = scroll + v.color = color + table.insert(x.beams, v) + + start = endpos + end + end + + table.insert(p.paths, x) + + end + end + + ent.ppp = p + end + + + local w,f = math.modf(CurTime()*WIRE_BLINKS_PER_SECOND) + local blink = f < 0.5 + local blinkname = ent:GetNetworkedBeamString("BlinkWire") + for _,k in ipairs(p.paths) do + if not (blink and blinkname == k.path_name) and k.material then + k.scroll = CurTime()*WIRE_SCROLL_SPEED + k.start = ent:LocalToWorld(k.startx) + render.SetMaterial(k.material) + render.StartBeam(k.startbeam) + render.AddBeam(k.start, k.width, k.scroll, k.color) + for _,v in ipairs(k.beams) do + if (v.node_ent:IsValid()) then + local endpos = v.node_ent:LocalToWorld(v.node_endpos) + local scroll = k.scroll+(endpos-k.start):Length()/10 + render.AddBeam(endpos, v.width, scroll, v.color) + end + end + render.EndBeam() + end + end + end end @@ -88,25 +184,31 @@ end local function Wire_GetWireRenderBounds(ent) if (not ent:IsValid()) then return end + local paths = ent.WirePaths local bbmin = ent:OBBMins() local bbmax = ent:OBBMaxs() - if ent.WirePaths then - for net_name, wiretbl in pairs(ent.WirePaths) do - local nodes = wiretbl.Path - local len = #nodes - for j=1, len do - local node_ent = nodes[j].Entity - local nodepos = nodes[j].Pos - if (node_ent:IsValid()) then - nodepos = ent:WorldToLocal(node_ent:LocalToWorld(nodepos)) - - if (nodepos.x < bbmin.x) then bbmin.x = nodepos.x end - if (nodepos.y < bbmin.y) then bbmin.y = nodepos.y end - if (nodepos.z < bbmin.z) then bbmin.z = nodepos.z end - if (nodepos.x > bbmax.x) then bbmax.x = nodepos.x end - if (nodepos.y > bbmax.y) then bbmax.y = nodepos.y end - if (nodepos.z > bbmax.z) then bbmax.z = nodepos.z end + local path_count = ent:GetNetworkedBeamInt("wpn_count") or 0 + if (path_count > 0) then + for i = 1,path_count do + local path_name = ent:GetNetworkedBeamString("wpn_" .. i) + local net_name = "wp_"..path_name + local len = ent:GetNetworkedBeamInt(net_name) or 0 + + if (len > 0) then + for j=1,len do + local node_ent = ent:GetNetworkedBeamEntity(net_name .. "_" .. j .. "_ent") + local nodepos = ent:GetNetworkedBeamVector(net_name .. "_" .. j .. "_pos") + if (node_ent:IsValid()) then + nodepos = ent:WorldToLocal(node_ent:LocalToWorld(nodepos)) + + if (nodepos.x < bbmin.x) then bbmin.x = nodepos.x end + if (nodepos.y < bbmin.y) then bbmin.y = nodepos.y end + if (nodepos.z < bbmin.z) then bbmin.z = nodepos.z end + if (nodepos.x > bbmax.x) then bbmax.x = nodepos.x end + if (nodepos.y > bbmax.y) then bbmax.y = nodepos.y end + if (nodepos.z > bbmax.z) then bbmax.z = nodepos.z end + end end end end diff --git a/lua/wire/server/wirelib.lua b/lua/wire/server/wirelib.lua index 04a9d360d4..34cb08edca 100644 --- a/lua/wire/server/wirelib.lua +++ b/lua/wire/server/wirelib.lua @@ -143,6 +143,7 @@ function WireLib.CreateSpecialInputs(ent, names, types, descs) Inputs[idx] = port end + WireLib.SetPathNames(ent, names) WireLib._SetInputs(ent) return ent_ports @@ -233,6 +234,7 @@ function WireLib.AdjustSpecialInputs(ent, names, types, descs) end end + WireLib.SetPathNames(ent, names) WireLib._SetInputs(ent) return ent_ports @@ -486,7 +488,6 @@ local function Wire_Link(dst, dstid, src, srcid, path) input.SrcId = srcid input.Path = path - WireLib.Paths.Add(input) WireLib._SetLink(input) table.insert(output.Connected, { Entity = dst, Name = dstid }) @@ -589,18 +590,28 @@ function WireLib.Link_Start(idx, ent, pos, iname, material, color, width) local input = ent.Inputs[iname] - if not input.Path then input.Path = {} end - CurLink[idx] = { Dst = ent, DstId = iname, - Path = input.Path, - OldPath = {} - } - for i=1, #input.Path do - CurLink[idx].OldPath[i] = input.Path[i] - input.Path[i] = nil - end + Path = {}, + OldPath = input.Path, + } + + CurLink[idx].OldPath = CurLink[idx].OldPath or {} + CurLink[idx].OldPath[0] = {} + CurLink[idx].OldPath[0].pos = input.StartPos + CurLink[idx].OldPath[0].material = input.Material + CurLink[idx].OldPath[0].color = input.Color + CurLink[idx].OldPath[0].width = input.Width + + local net_name = "wp_" .. iname + ent:SetNetworkedBeamInt(net_name, 0) + ent:SetNetworkedBeamVector(net_name .. "_start", pos) + ent:SetNetworkedBeamString(net_name .. "_mat", material) + ent:SetNetworkedBeamVector(net_name .. "_col", Vector(color.r, color.g, color.b)) + ent:SetNetworkedBeamFloat(net_name .. "_width", width) + + --RDbeamlib.StartWireBeam( ent, iname, pos, material, color, width ) input.StartPos = pos input.Material = material @@ -616,8 +627,15 @@ function WireLib.Link_Node(idx, ent, pos) if not IsValid(CurLink[idx].Dst) then return end if not IsValid(ent) then return end -- its the world, give up + local net_name = "wp_" .. CurLink[idx].DstId + local node_idx = CurLink[idx].Dst:GetNetworkedBeamInt(net_name)+1 + CurLink[idx].Dst:SetNetworkedBeamEntity(net_name .. "_" .. node_idx .. "_ent", ent) + CurLink[idx].Dst:SetNetworkedBeamVector(net_name .. "_" .. node_idx .. "_pos", pos) + CurLink[idx].Dst:SetNetworkedBeamInt(net_name, node_idx) + + --RDbeamlib.AddWireBeamNode( CurLink[idx].Dst, CurLink[idx].DstId, ent, pos ) + table.insert(CurLink[idx].Path, { Entity = ent, Pos = pos }) - WireLib.Paths.Add(CurLink[idx].Dst.Inputs[CurLink[idx].DstId]) end @@ -659,7 +677,16 @@ function WireLib.Link_End(idx, ent, pos, oname, pl) return end + local net_name = "wp_" .. CurLink[idx].DstId + local node_idx = CurLink[idx].Dst:GetNetworkedBeamInt(net_name)+1 + CurLink[idx].Dst:SetNetworkedBeamEntity(net_name .. "_" .. node_idx .. "_ent", ent) + CurLink[idx].Dst:SetNetworkedBeamVector(net_name .. "_" .. node_idx .. "_pos", pos) + CurLink[idx].Dst:SetNetworkedBeamInt(net_name, node_idx) + + --RDbeamlib.AddWireBeamNode( CurLink[idx].Dst, CurLink[idx].DstId, ent, pos ) + table.insert(CurLink[idx].Path, { Entity = ent, Pos = pos }) + Wire_Link(CurLink[idx].Dst, CurLink[idx].DstId, ent, oname, CurLink[idx].Path) if (WireLib.DT[input.Type].BiDir) then @@ -674,20 +701,39 @@ function WireLib.Link_Cancel(idx) if not CurLink[idx] then return end if not IsValid(CurLink[idx].Dst) then return end - if CurLink[idx].input then - CurLink[idx].Path = CurLink[idx].input.Path - else - WireLib.Paths.Add({Entity = CurLink[idx].Dst, Name = CurLink[idx].DstId, Width = 0}) + --local orig = CurLink[idx].OldPath[0] + --RDbeamlib.StartWireBeam( CurLink[idx].Dst, CurLink[idx].DstId, orig.pos, orig.material, orig.color, orig.width ) + + local path_len = 0 + if (CurLink[idx].OldPath) then path_len = #CurLink[idx].OldPath end + + local net_name = "wp_" .. CurLink[idx].DstId + for i=1,path_len do + CurLink[idx].Dst:SetNetworkedBeamEntity(net_name .. "_" .. i, CurLink[idx].OldPath[i].Entity) + CurLink[idx].Dst:SetNetworkedBeamVector(net_name .. "_" .. i, CurLink[idx].OldPath[i].Pos) + --RDbeamlib.AddWireBeamNode( CurLink[idx].Dst, CurLink[idx].DstId, CurLink[idx].OldPath[i].Entity, CurLink[idx].OldPath[i].Pos ) end + CurLink[idx].Dst:SetNetworkedBeamInt(net_name, path_len) + CurLink[idx] = nil end function WireLib.Link_Clear(ent, iname, DontSendToCL) - WireLib.Paths.Add({Entity = ent, Name = iname, Width = 0}) + local net_name = "wp_" .. iname + ent:SetNetworkedBeamInt(net_name, 0) + --RDbeamlib.ClearWireBeam( ent, iname ) + Wire_Unlink(ent, iname, DontSendToCL) end +function WireLib.SetPathNames(ent, names) + for k,v in pairs(names) do + ent:SetNetworkedBeamString("wpn_" .. k, v) + end + ent:SetNetworkedBeamInt("wpn_count", #names) +end + function WireLib.WireAll(ply, ient, oent, ipos, opos, material, color, width) if not IsValid(ient) or not IsValid(oent) or not ient.Inputs or not oent.Outputs then return false end @@ -910,6 +956,7 @@ Wire_Link_Node = WireLib.Link_Node Wire_Link_End = WireLib.Link_End Wire_Link_Cancel = WireLib.Link_Cancel Wire_Link_Clear = WireLib.Link_Clear +Wire_SetPathNames = WireLib.SetPathNames Wire_CreateOutputIterator = WireLib.CreateOutputIterator Wire_BuildDupeInfo = WireLib.BuildDupeInfo Wire_ApplyDupeInfo = WireLib.ApplyDupeInfo diff --git a/lua/wire/wire_paths.lua b/lua/wire/wire_paths.lua deleted file mode 100644 index 8eeda5969b..0000000000 --- a/lua/wire/wire_paths.lua +++ /dev/null @@ -1,116 +0,0 @@ --- wire_paths.lua --- --- This file implements syncing of wire paths, which are the visual --- component of wires. --- --- Conceptually, a wire path has a material, a color, and a non-zero width, as --- well as as a non-empty polyline along the wire. (Each point in the line --- has both a parent entity, and a local offset from that entity.) --- - -if not WireLib then return end -WireLib.Paths = {} - -local transmit_queues = setmetatable({}, { __index = function(t,p) t[p] = {} return t[p] end }) - -if CLIENT then - net.Receive("WireLib.Paths.TransmitPath", function(length) - local path = { - Path = {} - } - path.Entity = net.ReadEntity() - path.Name = net.ReadString() - path.Width = net.ReadFloat() - if path.Width<=0 then - if path.Entity.WirePaths then - path.Entity.WirePaths[path.Name] = nil - if not next(path.Entity.WirePaths) then path.Entity.WirePaths = nil end - end - return - end - path.StartPos = net.ReadVector() - path.Material = net.ReadString() - path.Color = net.ReadColor() - - local num_points = net.ReadUInt(15) - for i = 1, num_points do - path.Path[i] = { Entity = net.ReadEntity(), Pos = net.ReadVector() } - end - - if path.Entity.WirePaths == nil then path.Entity.WirePaths = {} end - path.Entity.WirePaths[path.Name] = path - - end) - - hook.Add("NetworkEntityCreated", "WireLib.Paths.NetworkEntityCreated", function(ent) - if ent.Inputs then - net.Start("WireLib.Paths.RequestPaths") - net.WriteEntity(ent) - net.SendToServer() - end - end) - return -end - -util.AddNetworkString("WireLib.Paths.RequestPaths") -util.AddNetworkString("WireLib.Paths.TransmitPath") - -net.Receive("WireLib.Paths.RequestPaths", function(length, ply) - local ent = net.ReadEntity() - if ent:IsValid() and ent.Inputs then - for name, input in pairs(ent.Inputs) do - if input.Src then - WireLib.Paths.Add(path, ply) - end - end - end -end) - -local function TransmitPath(input) - local color = input.Color - net.WriteEntity(input.Entity) - net.WriteString(input.Name) - if not input.Src or input.Width<=0 then net.WriteFloat(0) return end - net.WriteFloat(input.Width) - net.WriteVector(input.StartPos) - net.WriteString(input.Material) - net.WriteColor(Color(color.r or 255, color.g or 255, color.b or 255, color.a or 255)) - net.WriteUInt(#input.Path, 15) - for _, point in ipairs(input.Path) do - net.WriteEntity(point.Entity) - net.WriteVector(point.Pos) - end -end - -local function ProcessQueue() - for ply, queue in pairs(transmit_queues) do - if not ply:IsValid() then transmit_queues[ply] = nil continue end - if next(queue) then - net.Start("WireLib.Paths.TransmitPath") - while queue[1] and net.BytesWritten() < 63 * 1024 do - TransmitPath(queue[1]) - table.remove(queue, 1) - end - net.Send(ply) - else - transmit_queues[ply] = nil - end - end - if not next(transmit_queues) then - timer.Remove("WireLib.Paths.ProcessQueue") - end -end - --- Add a path to every player's transmit queue -function WireLib.Paths.Add(input, ply) - if ply then - table.insert(transmit_queues[ply], input) - else - for _, player in pairs(player.GetAll()) do - table.insert(transmit_queues[player], input) - end - end - if not timer.Exists("WireLib.Paths.ProcessQueue") then - timer.Create("WireLib.Paths.ProcessQueue", 0.2, 0, ProcessQueue) - end -end From 0e263e4b3ab4d0f7cd9cbdc29f3036f9540e96f7 Mon Sep 17 00:00:00 2001 From: Python1320 Date: Fri, 20 Jan 2017 22:16:53 +0200 Subject: [PATCH 26/56] Add hooks for editor events --- lua/wire/client/text_editor/wire_expression2_editor.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/wire/client/text_editor/wire_expression2_editor.lua b/lua/wire/client/text_editor/wire_expression2_editor.lua index 2f69deed7f..35414805f4 100644 --- a/lua/wire/client/text_editor/wire_expression2_editor.lua +++ b/lua/wire/client/text_editor/wire_expression2_editor.lua @@ -588,6 +588,7 @@ function Editor:CreateTab(chosenfile) timer.Create("e2autosave", 5, 1, function() self:AutoSave() end) + hook.Run("WireEditorText", self, editor) end editor.OnShortcut = function(_, code) if code == KEY_S then @@ -1700,6 +1701,7 @@ end function Editor:Open(Line, code, forcenewtab) if self:IsVisible() and not Line and not code then self:Close() end + hook.Run("WireEditorOpen", self, Line, code, forcenewtab) self:SetV(true) if self.chip then self.C.SaE:SetText("Upload & Exit") @@ -1844,6 +1846,8 @@ function Editor:Close() self.chip = false self:SaveEditorSettings() + + hook.Run("WireEditorClose", self) end function Editor:Setup(nTitle, nLocation, nEditorType) From 20e724b92280a4c0d7e269c80a7354328b7ec44d Mon Sep 17 00:00:00 2001 From: ajloveslily14 Date: Tue, 6 Feb 2018 16:20:38 -0600 Subject: [PATCH 27/56] Fix CPPI isFriend For some ungodly reason entities on the map are owner by other entities so running CPPIGetOwner on them throws an error, this fixes that --- lua/entities/gmod_wire_expression2/core/e2lib.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/entities/gmod_wire_expression2/core/e2lib.lua b/lua/entities/gmod_wire_expression2/core/e2lib.lua index dbabdc0c90..a39a822ad4 100644 --- a/lua/entities/gmod_wire_expression2/core/e2lib.lua +++ b/lua/entities/gmod_wire_expression2/core/e2lib.lua @@ -737,6 +737,7 @@ hook.Add("InitPostEntity", "e2lib", function() if debug.getregistry().Player.CPPIGetFriends then E2Lib.replace_function("isFriend", function(owner, player) if owner == nil then return false end + if not owner:IsPlayer() then return false end if owner == player then return true end local friends = owner:CPPIGetFriends() From 24b04ceabfaee1f3e2f294709f5546483b879ade Mon Sep 17 00:00:00 2001 From: Python1320 Date: Sat, 10 Feb 2018 15:13:01 +0200 Subject: [PATCH 28/56] Revert "Merge remote-tracking branch 'remotes/upstream/master'" This reverts commit cf301964c58417cd63da3a034114b60e032c90cb, reversing changes made to 31ef3451730ba683711ecaa21e8b2e2ec42e5a6b. Fixes up merge fuckups, keeps our changes. --- lua/autorun/wire_load.lua | 4 +- .../gmod_wire_expression2/core/e2lib.lua | 52 +-- .../gmod_wire_expression2/core/find.lua | 2 +- lua/weapons/gmod_tool/stools/wire_adv.lua | 278 ++++++------ lua/wire/client/cl_wirelib.lua | 188 ++------ lua/wire/client/sound_browser.lua | 402 +++++++++--------- lua/wire/wire_paths.lua | 117 +++++ 7 files changed, 523 insertions(+), 520 deletions(-) mode change 100755 => 100644 lua/wire/client/sound_browser.lua create mode 100644 lua/wire/wire_paths.lua diff --git a/lua/autorun/wire_load.lua b/lua/autorun/wire_load.lua index 41e0927aac..ed29f385de 100644 --- a/lua/autorun/wire_load.lua +++ b/lua/autorun/wire_load.lua @@ -26,6 +26,7 @@ if SERVER then AddCSLuaFile("autorun/wire_load.lua") -- shared includes + AddCSLuaFile("wire/wire_paths.lua") AddCSLuaFile("wire/wireshared.lua") AddCSLuaFile("wire/beam_netvars.lua") AddCSLuaFile("wire/wiregates.lua") @@ -86,6 +87,7 @@ end -- shared includes include("wire/wireshared.lua") +include("wire/wire_paths.lua") include("wire/beam_netvars.lua") include("wire/wiregates.lua") include("wire/wiremonitors.lua") @@ -126,7 +128,7 @@ if CLIENT then include("wire/client/rendertarget_fix.lua") include("wire/client/hlzasm/hc_compiler.lua") include("wire/client/customspawnmenu.lua") - + end -- Load UWSVN, done here so its definitely after Wire is loaded. diff --git a/lua/entities/gmod_wire_expression2/core/e2lib.lua b/lua/entities/gmod_wire_expression2/core/e2lib.lua index bf71812b78..71736b2e7f 100644 --- a/lua/entities/gmod_wire_expression2/core/e2lib.lua +++ b/lua/entities/gmod_wire_expression2/core/e2lib.lua @@ -459,7 +459,7 @@ end do -- Shared stuff, defined later. - + local extensions = nil local function printExtensions() end local function conCommandSetExtensionStatus() end @@ -476,9 +476,9 @@ do function E2Lib.GetExtensionDocumentation(name) return extensions.documentation[name] or {} end - + if SERVER then -- serverside stuff - + util.AddNetworkString( "wire_expression2_server_send_extensions_list" ) util.AddNetworkString( "wire_expression2_client_request_print_extensions" ) util.AddNetworkString( "wire_expression2_client_request_set_extension_status" ) @@ -513,7 +513,7 @@ do -- thus making its functions not available in the E2 Editor (see function e2_include_pass2 in extloader.lua). assert( extensions.status[ name ], "EXTENSION_DISABLED" ) end - + function E2Lib.SetExtensionStatus( name, status ) name = name:Trim():lower() status = tobool( status ) @@ -522,7 +522,7 @@ do sql.Query( "REPLACE INTO wire_expression2_extensions ( name, enabled ) VALUES ( " .. sql.SQLStr( name ) .. ", " .. ( status and 1 or 0 ) .. " )" ) end end - + -- After using E2Lib.SetExtensionStatus in an external script, this function should be called. -- Its purpose is to update the clientside autocomplete list for the concommands. function E2Lib.UpdateClientsideExtensionsList( ply ) @@ -534,12 +534,12 @@ do net.Broadcast() end end - + local function buildPrettyList() local function padLeft( str, len ) return (" "):rep( len - #str ) .. str end local function padRight( str, len ) return str .. (" "):rep( len - #str ) end local function padCenter( str, len ) return padRight( padLeft( str, math.floor( (len + #str) / 2 ) ), len ) end - + local list, column1, column2, columnsWidth = extensions.list, {}, {}, 0 for i = 1, #list do local name = list[ i ] @@ -552,7 +552,7 @@ do columnsWidth = maxWidth / 2 maxWidth = maxWidth + 3 local delimiter = " +-" .. ("-"):rep( columnsWidth ) .. "-+-" .. ("-"):rep( columnsWidth ) .. "-+" - + list = { " +-" .. ("-"):rep( maxWidth ) .. "-+", @@ -563,10 +563,10 @@ do } for i = 1, maxRows do list[ #list + 1 ] = " | " .. padRight( column1[ i ] or "", columnsWidth ) .. " | " .. padRight( column2[ i ] or "", columnsWidth ) .. " |" end list[ #list + 1 ] = delimiter - + extensions.prettyList = list end - + function printExtensions( ply, str ) if IsValid( ply ) then if str then ply:PrintMessage( 2, str ) end @@ -576,7 +576,7 @@ do for i = 1, #extensions.prettyList do print( extensions.prettyList[ i ] ) end end end - + function conCommandSetExtensionStatus( ply, cmd, args ) if IsValid( ply ) and not ply:IsSuperAdmin() and not game.SinglePlayer() then ply:PrintMessage( 2, "Sorry " .. ply:Name() .. ", you don't have access to this command." ) @@ -603,21 +603,21 @@ do else printExtensions( ply, "Unknown extension '" .. name .. "'. Here is a list of available extensions:" ) end else printExtensions( ply, "Usage: '" .. cmd .. " '. Here is a list of available extensions:" ) end end - + net.Receive( "wire_expression2_client_request_print_extensions", function( _, ply ) printExtensions( ply ) end ) - + net.Receive( "wire_expression2_client_request_set_extension_status", function( _, ply ) conCommandSetExtensionStatus( ply, net.ReadString(), net.ReadTable() ) end ) - + hook.Add( "PlayerInitialSpawn", "wire_expression2_updateClientsideExtensions", E2Lib.UpdateClientsideExtensionsList ) - + function wire_expression2_PostLoadExtensions() table.sort( extensions.list, function( a, b ) return a < b end ) E2Lib.UpdateClientsideExtensionsList() @@ -627,16 +627,16 @@ do end hook.Run( "Expression2_PostLoadExtensions" ) end - + else -- clientside stuff extensions = { status = {}, list = {} } - + function printExtensions() net.Start( "wire_expression2_client_request_print_extensions" ) net.SendToServer() end - + function conCommandSetExtensionStatus( _, cmd, args ) net.Start( "wire_expression2_client_request_set_extension_status" ) net.WriteString( cmd ) @@ -647,11 +647,11 @@ do net.Receive( "wire_expression2_server_send_extensions_list", function() extensions = net.ReadTable() end) - + end -- shared stuff - + local function makeAutoCompleteList( cmd, args ) args = args:Trim():lower() local status, list, tbl, j = tobool( cmd:find( "enable" ) ), extensions.list, {}, 1 @@ -675,25 +675,25 @@ end do if SERVER then - + util.AddNetworkString( "wire_expression2_client_request_reload" ) net.Receive( "wire_expression2_client_request_reload", function( n, ply ) wire_expression2_reload( ply ) end ) - + else - + local function wire_expression2_reload() net.Start( "wire_expression2_client_request_reload" ) net.SendToServer() end - + concommand.Add( "wire_expression2_reload", wire_expression2_reload ) - + end - + end -- ------------------------------ compatibility -------------------------------- diff --git a/lua/entities/gmod_wire_expression2/core/find.lua b/lua/entities/gmod_wire_expression2/core/find.lua index 87cf9e589b..97ad170639 100644 --- a/lua/entities/gmod_wire_expression2/core/find.lua +++ b/lua/entities/gmod_wire_expression2/core/find.lua @@ -830,7 +830,7 @@ __e2setcost(5) local function applyClip(self, filter) local findlist = self.data.findlist self.prf = self.prf + #findlist * 5 - + filterList(findlist, filter) return #findlist diff --git a/lua/weapons/gmod_tool/stools/wire_adv.lua b/lua/weapons/gmod_tool/stools/wire_adv.lua index 9cfac6b058..64ff1874a4 100644 --- a/lua/weapons/gmod_tool/stools/wire_adv.lua +++ b/lua/weapons/gmod_tool/stools/wire_adv.lua @@ -73,23 +73,23 @@ if SERVER then types[num] = v.Type descs[num] = v.Desc end - + names[x+1] = "wirelink" types[x+1] = "WIRELINK" descs[x+1] = "" - + WireLib.AdjustSpecialOutputs( ent, names, types, descs ) else WireLib.CreateSpecialOutputs( ent, { "wirelink" }, { "WIRELINK" } ) end - + ent.extended = true WireLib.TriggerOutput( ent, "wirelink", ent ) end duplicator.StoreEntityModifier( ent, "CreateWirelinkOutput", data ) end duplicator.RegisterEntityModifier( "CreateWirelinkOutput", WireLib.CreateWirelinkOutput ) - + function WireLib.CreateEntityOutput( ply, ent, data ) if data[1] == true then if ent.Outputs then @@ -105,50 +105,50 @@ if SERVER then types[num] = v.Type descs[num] = v.Desc end - + names[x+1] = "entity" types[x+1] = "ENTITY" descs[x+1] = "" - + WireLib.AdjustSpecialOutputs( ent, names, types, descs ) else WireLib.CreateSpecialOutputs( ent, { "entity" }, { "ENTITY" } ) end - + WireLib.TriggerOutput( ent, "entity", ent ) end duplicator.StoreEntityModifier( ent, "CreateEntityOutput", data ) end duplicator.RegisterEntityModifier( "CreateEntityOutput", WireLib.CreateEntityOutput ) - - + + ----------------------------------------------------------------- -- Receving data from client ----------------------------------------------------------------- - + util.AddNetworkString( "wire_adv_upload" ) net.Receive( "wire_adv_upload", function( len, ply ) local wirings = net.ReadTable() - + local tool = get_active_tool(ply,"wire_adv") if not tool then return end - + local material = tool:GetClientInfo("material") local width = tool:GetClientNumber("width") local color = Color(tool:GetClientNumber("r"), tool:GetClientNumber("g"), tool:GetClientNumber("b")) - + local uid = ply:UniqueID() - + for i=1,#wirings do local wiring = wirings[i] - + local inputentity = wiring[3] local outputentity = wiring[5] - + if IsValid( inputentity ) and IsValid( outputentity ) and hook.Run( "CanTool", ply, WireLib.dummytrace( inputentity ), "wire_adv" ) and hook.Run( "CanTool", ply, WireLib.dummytrace( outputentity ), "wire_adv" ) then - + local inputname = wiring[1] local inputpos = wiring[2] if WireLib.Link_Start( uid, inputentity, inputpos, inputname, material, color, width ) then @@ -158,7 +158,7 @@ if SERVER then end local outputpos = wiring[6] local outputname = wiring[7] - + if outputname == "Create Wirelink" and (not outputentity.Outputs or not outputentity.Outputs["wirelink"]) then WireLib.CreateWirelinkOutput( ply, outputentity, {true} ) outputname = "wirelink" @@ -170,25 +170,25 @@ if SERVER then elseif outputname == "Create Entity" and outputentity.Outputs and outputentity.Outputs["entity"] then outputname = "entity" end - + WireLib.Link_End( uid, outputentity, outputpos, outputname, ply ) end - end + end end end) - + util.AddNetworkString( "wire_adv_unwire" ) net.Receive( "wire_adv_unwire", function( len, ply ) local ent = net.ReadEntity() local tbl = net.ReadTable() - + if hook.Run( "CanTool", ply, WireLib.dummytrace( ent ), "wire_adv" ) then for i=1,#tbl do WireLib.Link_Clear( ent, tbl[i] ) end end end) - + WireToolHelpers.SetupSingleplayerClickHacks(TOOL) elseif CLIENT then @@ -208,22 +208,22 @@ elseif CLIENT then local inputentity = wiring[3] local outputentity = wiring[5] local outputname = wiring[7] - + if not IsValid(inputentity) or not IsValid(outputentity) or not outputname then -- we don't need to check everything because only these things can possibly be invalid - + table.remove(self.Wiring,i) end end end function TOOL:Upload() self:SanitizeUpload() -- Remove all invalid wirings before sending - + net.Start( "wire_adv_upload" ) net.WriteTable( self.Wiring ) net.SendToServer() - + self:Holster() end function TOOL:Unwire( ent, names ) @@ -232,8 +232,8 @@ elseif CLIENT then net.WriteTable( names ) net.SendToServer() end - - + + ----------------------------------------------------------------- -- GetPorts ----------------------------------------------------------------- @@ -242,9 +242,9 @@ elseif CLIENT then TOOL.CurrentOutputs = nil function TOOL:CachePorts( ent ) local inputs, outputs = WireLib.GetPorts( ent ) - + local copied = false - + if self.ShowWirelink then if outputs then local found = false @@ -260,7 +260,7 @@ elseif CLIENT then outputs = { { "Create Wirelink", "WIRELINK" } } end end - + if self.ShowEntity then if outputs then local found = false @@ -281,7 +281,7 @@ elseif CLIENT then self.CurrentInputs = inputs self.CurrentOutputs = outputs end - + local next_recache = 0 function TOOL:GetPorts( ent ) if IsValid( ent ) then @@ -307,7 +307,7 @@ elseif CLIENT then TOOL.ShowEntity = false -- bool for showing "Create Entity" output function TOOL:Holster() - if IsValid(self.CurrentEntity) then self.CurrentEntity:SetNetworkedBeamString("BlinkWire", "") end + if IsValid(self.CurrentEntity) then self.CurrentEntity:SetNWString("BlinkWire", "") end self.CurrentEntity = nil self.Wiring = {} self.WiringRender = {} @@ -319,12 +319,12 @@ elseif CLIENT then ----------------------------------------------------------------- -- Wiring helper functions ----------------------------------------------------------------- - + --[[ Wirings table format: self.Wiring[x] = wiring - + where - + wiring = { [1] = inputname, [2] = inputpos, @@ -335,23 +335,23 @@ elseif CLIENT then [7] = outputname, [8] = inputtype, } - + where - + nodes = { [1] = entity, [2] = pos, } ]] - - + + function TOOL:FindWiring( entity, inputname, inputtype ) for i=1,#self.Wiring do local wiring = self.Wiring[i] if wiring[1] == inputname and wiring[3] == entity and wiring[8] == inputtype then return wiring, i end end end - + function TOOL:WireStart( entity, pos, inputname, inputtype ) local wiring, id = self:FindWiring( entity, inputname, inputtype ) if wiring then -- wiring is already started, user wants to cancel it @@ -359,20 +359,20 @@ elseif CLIENT then self:WiringRenderRemove( inputname, inputtype ) return end - + local t = { inputname, entity:WorldToLocal( pos ), entity, {} } t[8] = inputtype self.Wiring[#self.Wiring+1] = t - + if inputtype == "WIRELINK" then self.ShowWirelink = true elseif inputtype == "ENTITY" then self.ShowEntity = true end - + -- Add info to the wiringrender table, which is used to render the "x2" "x3" etc self:WiringRenderAdd( inputname, inputtype ) - + return t end function TOOL:WireNode( wiring, entity, pos ) @@ -387,8 +387,8 @@ elseif CLIENT then wiring[8] = nil -- we don't need to send the type to the server; wasted net message space. Delete it self.NeedsUpload = true -- We want to upload next tick. We don't upload immediately because the client may call this function more this tick (for multi wiring) end - - + + -- This function will help when using ALT to wire, when a single output's type matches but the name does not -- it will allow us to check if only a single output of matching types exist on the entity without looping -- through the entity's outputs several times per frame @@ -401,7 +401,7 @@ elseif CLIENT then local _, outputs = self:GetPorts( ent ) for i=1,#outputs do local outputtype = outputs[i][2] - if self.AutoWiringTypeLookup_t[outputtype] == nil then -- if we haven't found any outputs of this type yet, + if self.AutoWiringTypeLookup_t[outputtype] == nil then -- if we haven't found any outputs of this type yet, self.AutoWiringTypeLookup_t[outputtype] = i -- set the index elseif self.AutoWiringTypeLookup_t[outputtype] ~= nil then -- if we've already found outputs of this type, self.AutoWiringTypeLookup_t[outputtype] = false -- set to false @@ -412,7 +412,7 @@ elseif CLIENT then function TOOL:AutoWiringTypeLookup_Check( inputtype ) return self.AutoWiringTypeLookup_t[inputtype] end - + ----------------------------------------------------------------- -- Mouse buttons ----------------------------------------------------------------- @@ -421,15 +421,15 @@ elseif CLIENT then function TOOL:LeftClick(trace) if self.wtfgarry > CurTime() then return end self.wtfgarry = CurTime() + 0.1 - + local shift = self:GetOwner():KeyDown(IN_SPEED) local alt = self:GetOwner():KeyDown(IN_WALK) - + if IsValid( trace.Entity ) then if self:GetStage() == 0 then local inputs, _ = self:GetPorts( trace.Entity ) if not inputs then return end - + if alt then -- Select everything for i=1,#inputs do self:WireStart( trace.Entity, trace.HitPos, inputs[i][1], inputs[i][2] ) @@ -439,33 +439,33 @@ elseif CLIENT then if not inputs[self.CurrentWireIndex] then return end -- Can happen if theres no inputs, only outputs self:WireStart( trace.Entity, trace.HitPos, inputs[self.CurrentWireIndex][1], inputs[self.CurrentWireIndex][2] ) end - + self:GetOwner():EmitSound( "weapons/airboat/airboat_gun_lastshot" .. math.random(1,2) .. ".wav" ) - + if not shift then self:SetStage(1) -- Set this immediately so the HUD doesn't glitch end - + return elseif self:GetStage() == 1 then local _, outputs = self:GetPorts( trace.Entity ) if not outputs then return end - + self.CurrentEntity = trace.Entity self:AutoWiringTypeLookup( self.CurrentEntity ) - + self:SetStage(2) - + for i=1,#self.Wiring do self:WireEndEntityPos( self.Wiring[i], self.CurrentEntity, trace.HitPos ) end - + if next(outputs,next(outputs)) == nil then -- there's only one element in the table self.wtfgarry = 0 self:LeftClick( trace ) -- wire it right away return end - + self:LoadMemorizedIndex( self.CurrentEntity, true ) -- find first matching output by name or type @@ -480,27 +480,27 @@ elseif CLIENT then if outputs[port][2] == self.Wiring[1][8] and not matchingByType then matchingByType = port end - + port = port + 1 if port > #outputs then port = 1 end until port == oldport or (matchingByName and matchingByType) - + if matchingByName then self.CurrentWireIndex = matchingByName elseif matchingByType then self.CurrentWireIndex = matchingByType end - + self:GetOwner():EmitSound( "weapons/airboat/airboat_gun_lastshot" .. math.random(1,2) .. ".wav" ) return end end - + if self:GetStage() == 2 then local _, outputs = self:GetPorts( self.CurrentEntity ) - + if alt then -- Auto wiring local notwired = 0 local typematched = 0 @@ -512,14 +512,14 @@ elseif CLIENT then for j=1,#outputs do local outputname = outputs[j][1] local outputtype = outputs[j][2] - + if self:IsMatch( inputname, inputtype, outputname, outputtype, true ) then self:WireEndOutputName( wiring, outputname ) found = true break end end - + if not found then -- if we didn't find a matching name & type, check if there's only one matching type (ignoring name) local idx = self:AutoWiringTypeLookup_Check( inputtype ) if idx then @@ -530,13 +530,13 @@ elseif CLIENT then end end end - + if notwired > 0 then WireLib.AddNotify( "Could not find a matching name/type for " .. notwired .. " inputs. They were not wired.", NOTIFY_HINT, 10, NOTIFYSOUND_DRIP1 ) end if typematched > 0 then WireLib.AddNotify( "Could not find a matching name/type for " .. typematched .. " inputs. However, a single output of that type was found, which was used instead.", NOTIFY_HINT, 10, NOTIFYSOUND_DRIP1 ) - end + end else -- Normal wiring local notwired = 0 for i=1,#self.Wiring do @@ -546,22 +546,22 @@ elseif CLIENT then notwired = notwired + 1 end end - + if notwired > 0 then WireLib.AddNotify( "The type did not match for " .. notwired .. " inputs. They were not wired.", NOTIFY_HINT, 5, NOTIFYSOUND_DRIP1 ) end end - + self:SetStage(0) self.WiringRender = {} -- Empty this now so the HUD doesn't glitch self:GetOwner():EmitSound( "weapons/airboat/airboat_gun_lastshot" .. math.random(1,2) .. ".wav" ) end end - + function TOOL:RightClick(trace) if self.wtfgarry > CurTime() then return end self.wtfgarry = CurTime() + 0.1 - + if self:GetStage() == 0 or self:GetStage() == 2 then self:ScrollDown(trace) elseif IsValid(trace.Entity) and self:GetStage() == 1 then @@ -574,7 +574,7 @@ elseif CLIENT then function TOOL:Reload(trace) if self.wtfgarry > CurTime() then return end self.wtfgarry = CurTime() + 0.1 - + if self:GetStage() == 0 and IsValid( trace.Entity ) and WireLib.HasPorts( trace.Entity ) then local inputs, outputs = self:GetPorts( trace.Entity ) if not inputs then return end @@ -593,7 +593,7 @@ elseif CLIENT then self:GetOwner():EmitSound( "weapons/airboat/airboat_gun_lastshot" .. math.random(1,2) .. ".wav" ) end - + function TOOL:Scroll(trace,dir) local ent = self:GetStage() == 0 and trace.Entity or self.CurrentEntity if IsValid(ent) then @@ -601,10 +601,10 @@ elseif CLIENT then if not inputs and not outputs then return end local check = self:GetStage() == 0 and inputs or outputs if #check == 0 then return end - + local b = false local oldport = self.CurrentWireIndex - + if self:GetStage() == 2 then repeat self.CurrentWireIndex = self.CurrentWireIndex + dir @@ -616,63 +616,63 @@ elseif CLIENT then until not self:IsBlocked( "Outputs", outputs, ent, self.CurrentWireIndex ) or self.CurrentWireIndex == oldport else self.CurrentWireIndex = self.CurrentWireIndex + dir - + if self.CurrentWireIndex > #check then self.CurrentWireIndex = 1 elseif self.CurrentWireIndex < 1 then self.CurrentWireIndex = #check end end - + if oldport ~= self.CurrentWireIndex then - ent:SetNetworkedBeamString("BlinkWire", check[self.CurrentWireIndex][1]) + ent:SetNWString("BlinkWire", check[self.CurrentWireIndex][1]) self:GetOwner():EmitSound("weapons/pistol/pistol_empty.wav") end return true end end - + function TOOL:ScrollUp(trace) return self:Scroll(trace,-1) end function TOOL:ScrollDown(trace) return self:Scroll(trace,1) end - + local function hookfunc( ply, bind, pressed ) if not pressed then return end - + if bind == "invnext" then local self = get_active_tool(ply, "wire_adv") if not self then return end - + return self:ScrollDown(ply:GetEyeTraceNoCursor()) elseif bind == "invprev" then local self = get_active_tool(ply, "wire_adv") if not self then return end - + return self:ScrollUp(ply:GetEyeTraceNoCursor()) elseif bind == "impulse 100" and ply:KeyDown( IN_SPEED ) then local self = get_active_tool(ply, "wire_adv") if not self then self = get_active_tool(ply, "wire_debugger") if not self then return end - + spawnmenu.ActivateTool( "wire_adv") -- switch back to wire adv return true end - + spawnmenu.ActivateTool("wire_debugger") -- switch to debugger return true end end - + if game.SinglePlayer() then -- wtfgarry (have to have a delay in single player or the hook won't get added) timer.Simple(5,function() hook.Add( "PlayerBindPress", "wire_adv_playerbindpress", hookfunc ) end) else hook.Add( "PlayerBindPress", "wire_adv_playerbindpress", hookfunc ) end - + ----------------------------------------------------------------- -- Remember wire indexes ----------------------------------------------------------------- - + -- Remember wire index positions for entities TOOL.WireIndexMemory = {} TOOL.AimingEnt = nil @@ -682,7 +682,7 @@ elseif CLIENT then if self:GetStage() == 2 and self.CurrentEntity ~= ent then -- if you aim away during stage 2, don't change CurrentWireIndex return end - + -- Memorize selected input if IsValid(self.AimingEnt) and not forceload then if not self.WireIndexMemory[self.AimingEnt] then @@ -694,12 +694,12 @@ elseif CLIENT then self.WireIndexMemory[self.AimingEnt][self.AimingStage] = self.CurrentWireIndex self.WireIndexMemory[self.AimingEnt:GetClass()][self.AimingStage] = self.CurrentWireIndex -- save to class as well end - + -- Clear blinking wire if IsValid( self.AimingEnt ) then - self.AimingEnt:SetNetworkedBeamString("BlinkWire", "") + self.AimingEnt:SetNWString("BlinkWire", "") end - + if IsValid( ent ) then -- Retrieve memorized selected input if self.WireIndexMemory[ent] and self.WireIndexMemory[ent][self:GetStage()] then @@ -709,48 +709,48 @@ elseif CLIENT then else self.CurrentWireIndex = 1 end - + -- Clamp index local inputs, outputs = self:GetPorts( ent ) local check = self:GetStage() == 0 and inputs or outputs if check then self.CurrentWireIndex = math.Clamp( self.CurrentWireIndex, 1, #check ) - + -- Set blinking wire if check[self.CurrentWireIndex] then - ent:SetNetworkedBeamString("BlinkWire", check[self.CurrentWireIndex][1]) + ent:SetNWString("BlinkWire", check[self.CurrentWireIndex][1]) end end end - + self.AimingEnt = ent self.AimingStage = self:GetStage() end end - + ----------------------------------------------------------------- -- Think ----------------------------------------------------------------- function TOOL:Think() local ent = self:GetOwner():GetEyeTrace().Entity self:LoadMemorizedIndex( ent ) - + -- Check for holding shift etc local shift = self:GetOwner():KeyDown( IN_SPEED ) - + if #self.Wiring > 0 and self:GetStage() == 0 and not shift then self:SetStage(1) elseif #self.Wiring > 0 and self:GetStage() == 1 and shift then self:SetStage(0) end - + -- Check if we need to upload if self.NeedsUpload then self.NeedsUpload = false self:Upload() end end - + ----------------------------------------------------------------- -- HUD Stuff ----------------------------------------------------------------- @@ -760,15 +760,15 @@ elseif CLIENT then if alt then -- if we're holding alt, highlight all outputs that will be wired to local outputname = tbl[idx][1] local outputtype = tbl[idx][2] - + for i=1,#self.WiringRender do local inputname = self.WiringRender[i][1] local inputtype = self.WiringRender[i][2] - + if self:IsMatch( inputname, inputtype, outputname, outputtype, true ) then return true end - + local _idx = self:AutoWiringTypeLookup_Check( inputtype ) if _idx then local _outputtype = tbl[_idx][2] @@ -782,10 +782,10 @@ elseif CLIENT then end elseif name == "Selected" and self:GetStage() == 2 and alt then -- highlight all selected inputs that will be wired local inputs, outputs = self:GetPorts( ent ) - + local inputname = tbl[idx][1] local inputtype = tbl[idx][2] - + for i=1,#outputs do local outputname = outputs[i][1] local outputtype = outputs[i][2] @@ -793,7 +793,7 @@ elseif CLIENT then return true end end - + local _idx = self:AutoWiringTypeLookup_Check( inputtype ) if _idx then return true @@ -805,7 +805,7 @@ elseif CLIENT then end return false end - + function TOOL:IsBlocked( name, tbl, ent, idx ) if name == "Outputs" and self:GetStage() > 0 then -- Gray out the ones that we can't wire any of the selected inputs to for i=1,#self.WiringRender do @@ -831,14 +831,14 @@ elseif CLIENT then end return false end - + local function getName( input ) local name = input[1] local tp = input[8] or (type(input[2]) == "string" and input[2] or "") local desc = (IsEntity(input[3]) and "" or input[3]) or "" return name .. (desc ~= "" and " (" .. desc .. ")" or "") .. (tp ~= "NORMAL" and " [" .. tp.. "]" or "") end - + local function getWidthHeight( inputs ) local width, height = 0, 0 for i=1,#inputs do @@ -853,15 +853,15 @@ elseif CLIENT then end return width, height end - + local fontData = {font = "Trebuchet24"} -- 24 and 18 are stock for _,size in pairs({22,20,16,14}) do fontData.size = size surface.CreateFont("Trebuchet"..size, fontData) end - + local fontheights - + local function getFontSizes() fontheights = {} for i=14,24,2 do @@ -870,7 +870,7 @@ elseif CLIENT then fontheights[fontname] = h end end - + TOOL.CurrentFont = "Trebuchet24" -- Find the largest font that can fit `lines` lines of text into a box `maxsize` -- tall. Set that font as current, and return the size of one line of text. @@ -881,7 +881,7 @@ elseif CLIENT then end local minFontSize = 14 - + for i=24, minFontSize, -2 do local fontname = "Trebuchet" .. i local height = fontheights[fontname] @@ -891,36 +891,36 @@ elseif CLIENT then local w, _ = surface.GetTextSize( "Selected:" ) return w, height end - end + end end - + function TOOL:DrawList( name, tbl, ent, x, y, w, h, fonth ) draw.RoundedBox( 6, x, y, w+16, h+14, Color(50,50,75,192) ) - + x = x + 8 y = y + 2 - + local temp,_ = surface.GetTextSize( name .. ":" ) surface.SetTextColor( Color(255,255,255,255) ) surface.SetTextPos( x-temp/2+w/2, y ) surface.DrawText( name .. ":" ) surface.SetDrawColor( Color(255,255,255,255) ) surface.DrawLine( x, y + fonth+2, x+w, y + fonth+2 ) - + y = y + 6 - + -- Draw inputs for i=1,#tbl do y = y + fonth - + local highlighted, diffcolor = self:IsHighlighted( name, tbl, ent, i ) if highlighted then - local clr = Color(0,150,0,192) + local clr = Color(0,150,0,192) if diffcolor and (self.CurrentWireIndex == i or self:GetOwner():KeyDown( IN_WALK )) then clr = Color(100,100,175,192) elseif diffcolor then clr = Color(0,0,150,192) end draw.RoundedBox( 4, x-4,y, w+8,fonth+2, clr ) end - + if tbl[i][4] == true then surface.SetTextColor( Color(255,0,0,255) ) elseif self:IsBlocked( name, tbl, ent, i ) then @@ -928,7 +928,7 @@ elseif CLIENT then else surface.SetTextColor( Color(255,255,255,255) ) end - + if tbl[i][9] and tbl[i][9] > 1 then surface.SetFont( "Trebuchet14" ) local tempw, temph = surface.GetTextSize( "x" .. tbl[i][9] ) @@ -936,7 +936,7 @@ elseif CLIENT then surface.DrawText( "x" .. tbl[i][9] ) surface.SetFont( self.CurrentFont ) end - + surface.SetTextPos( x, y ) surface.DrawText( getName( tbl[i] ) ) end @@ -944,7 +944,7 @@ elseif CLIENT then function TOOL:DrawHUD() local centerx, centery = ScrW()/2, ScrH()/2 - + local ent = self:GetStage() == 2 and self.CurrentEntity or self:GetOwner():GetEyeTrace().Entity local maxwidth = 0 if IsValid( ent ) then @@ -959,7 +959,7 @@ elseif CLIENT then local y = centery-hh/2-16 self:DrawList( "Inputs", inputs, ent, x, y, ww, hh, h ) end - + if outputs and #outputs > 0 and self:GetStage() > 0 then local w, h = self:fitFont( #outputs, ScrH() - 32 ) local ww, hh = getWidthHeight( outputs ) @@ -970,8 +970,8 @@ elseif CLIENT then self:DrawList( "Outputs", outputs, ent, x, y, ww, hh, h ) end end - - if #self.WiringRender > 0 then + + if #self.WiringRender > 0 then local w, h = self:fitFont( #self.WiringRender, ScrH() - 32 ) local ww, hh = getWidthHeight( self.WiringRender ) local ww = math.max(ww,w) @@ -981,7 +981,7 @@ elseif CLIENT then self:DrawList( "Selected", self.WiringRender, ent, x, y, ww, hh, h ) end end - + ----------------------------------------------------------------- -- Wiring Render @@ -997,7 +997,7 @@ elseif CLIENT then return (outputname == inputname and outputtype == inputtype) end end - + function TOOL:WiringRenderFind( inputname, inputtype ) for i=1,#self.WiringRender do local wiringrender = self.WiringRender[i] @@ -1006,10 +1006,10 @@ elseif CLIENT then end end end - + function TOOL:WiringRenderRemove( inputname, inputtype ) local wiringrender, idx = self:WiringRenderFind( inputname, inputtype ) - + if wiringrender then wiringrender[9] = wiringrender[9] - 1 if wiringrender[9] == 0 then @@ -1017,10 +1017,10 @@ elseif CLIENT then end end end - + function TOOL:WiringRenderAdd( inputname, inputtype ) local wiringrender = self:WiringRenderFind( inputname, inputtype ) - + if wiringrender then wiringrender[9] = wiringrender[9] + 1 else diff --git a/lua/wire/client/cl_wirelib.lua b/lua/wire/client/cl_wirelib.lua index 07615e8184..42882abad4 100644 --- a/lua/wire/client/cl_wirelib.lua +++ b/lua/wire/client/cl_wirelib.lua @@ -1,7 +1,7 @@ local WIRE_SCROLL_SPEED = 0.5 local WIRE_BLINKS_PER_SECOND = 2 local CurPathEnt = {} -local Wire_DisableWireRender = 2 --bug with mode 0 and gmod2007beta +local Wire_DisableWireRender = 0 WIRE_CLIENT_INSTALLED = 1 @@ -34,149 +34,53 @@ end local beam_mat = mats["tripmine_laser"] local beamhi_mat = mats["Models/effects/comball_tape"] +local lastrender, scroll, shouldblink = 0, 0, false function Wire_Render(ent) - if (not ent:IsValid()) then return end - if (Wire_DisableWireRender == 1) then return end - if (Wire_DisableWireRender == 0) then - local path_count = ent:GetNetworkedBeamInt("wpn_count") or 0 - if (path_count <= 0) then return end - - local w,f = math.modf(CurTime()*WIRE_BLINKS_PER_SECOND) - local blink = nil - if (f < 0.5) then - blink = ent:GetNetworkedBeamString("BlinkWire") - end - - for i = 1,path_count do - local path_name = ent:GetNetworkedBeamString("wpn_" .. i) - if (blink ~= path_name) then - local net_name = "wp_"..path_name - local len = ent:GetNetworkedBeamInt(net_name) or 0 - - if (len > 0) then + local wires = ent.WirePaths + if wires and next(wires) then + + local t = CurTime() + if lastrender ~= t then + local w, f = math.modf(t*WIRE_BLINKS_PER_SECOND) + shouldblink = f < 0.5 + scroll = t*WIRE_SCROLL_SPEED + lastrender = t + end - local width = ent:GetNetworkedBeamFloat(net_name .. "_width") - if width > 0 then + local blink = shouldblink and ent:GetNWString("BlinkWire") - local start = ent:GetNetworkedBeamVector(net_name .. "_start") - if (ent:IsValid()) then start = ent:LocalToWorld(start) end - local color_v = ent:GetNetworkedBeamVector(net_name .. "_col") - local color = Color(color_v.x, color_v.y, color_v.z, 255) - local scroll = CurTime()*WIRE_SCROLL_SPEED + for net_name, wiretbl in pairs(wires) do + local width = wiretbl.Width + if width > 0 and blink ~= net_name then + local start = wiretbl.StartPos + if (ent:IsValid()) then start = ent:LocalToWorld(start) end + local color = wiretbl.Color - render.SetMaterial(getmat(ent:GetNetworkedBeamString(net_name .. "_mat"))) + local nodes = wiretbl.Path + local len = #nodes + if len>0 then + render.SetMaterial(getmat(wiretbl.Material)) render.StartBeam(len+1) render.AddBeam(start, width, scroll, color) - for j=1,len do - local node_ent = ent:GetNetworkedBeamEntity(net_name .. "_" .. j .. "_ent") - local endpos = ent:GetNetworkedBeamVector(net_name .. "_" .. j .. "_pos") + for j=1, len do + local node = nodes[j] + local node_ent = node.Entity if (node_ent:IsValid()) then - endpos = node_ent:LocalToWorld(endpos) + local endpos = node_ent:LocalToWorld(node.Pos) scroll = scroll+(endpos-start):Length()/10 - render.AddBeam(endpos, width, scroll, color) start = endpos end end render.EndBeam() - end end end end - - else - local p = ent.ppp - if p == nil then p = {next = -100} end - - if p.next < CurTime() then - p.next = CurTime() + 0.25 - p.paths = {} - - local path_count = ent:GetNetworkedBeamInt("wpn_count") or 0 - if (path_count <= 0) then return end - - for i = 1,path_count do - local x = {} - local path_name = ent:GetNetworkedBeamString("wpn_" .. i) - x.path_name = path_name - local net_name = "wp_"..path_name - local len = ent:GetNetworkedBeamInt(net_name) or 0 - - if (len > 0) then - - local start = ent:GetNetworkedBeamVector(net_name .. "_start") - x.startx = start - if (ent:IsValid()) then start = ent:LocalToWorld(start) end - local color_v = ent:GetNetworkedBeamVector(net_name .. "_col") - local color = Color(color_v.x, color_v.y, color_v.z, 255) - local width = ent:GetNetworkedBeamFloat(net_name .. "_width") - - local scroll = CurTime()*WIRE_SCROLL_SPEED - - x.material = getmat(ent:GetNetworkedBeamString(net_name .. "_mat")) - x.startbeam = len + 1 - x.start = start - x.width = width - x.scroll = scroll - x.color = color - x.beams = {} - - for j=1,len do - local v = {} - local node_ent = ent:GetNetworkedBeamEntity(net_name .. "_" .. j .. "_ent") - local endpos = ent:GetNetworkedBeamVector(net_name .. "_" .. j .. "_pos") - v.node_ent = node_ent - v.node_endpos = endpos - if (node_ent:IsValid()) then - endpos = node_ent:LocalToWorld(endpos) - - scroll = scroll+(endpos-start):Length()/10 - - v.endpos = endpos - v.width = width - v.scroll = scroll - v.color = color - table.insert(x.beams, v) - - start = endpos - end - end - - table.insert(p.paths, x) - - end - end - - ent.ppp = p - end - - - local w,f = math.modf(CurTime()*WIRE_BLINKS_PER_SECOND) - local blink = f < 0.5 - local blinkname = ent:GetNetworkedBeamString("BlinkWire") - for _,k in ipairs(p.paths) do - if not (blink and blinkname == k.path_name) and k.material then - k.scroll = CurTime()*WIRE_SCROLL_SPEED - k.start = ent:LocalToWorld(k.startx) - render.SetMaterial(k.material) - render.StartBeam(k.startbeam) - render.AddBeam(k.start, k.width, k.scroll, k.color) - for _,v in ipairs(k.beams) do - if (v.node_ent:IsValid()) then - local endpos = v.node_ent:LocalToWorld(v.node_endpos) - local scroll = k.scroll+(endpos-k.start):Length()/10 - render.AddBeam(endpos, v.width, scroll, v.color) - end - end - render.EndBeam() - end - end - end end @@ -184,31 +88,25 @@ end local function Wire_GetWireRenderBounds(ent) if (not ent:IsValid()) then return end - local paths = ent.WirePaths local bbmin = ent:OBBMins() local bbmax = ent:OBBMaxs() - local path_count = ent:GetNetworkedBeamInt("wpn_count") or 0 - if (path_count > 0) then - for i = 1,path_count do - local path_name = ent:GetNetworkedBeamString("wpn_" .. i) - local net_name = "wp_"..path_name - local len = ent:GetNetworkedBeamInt(net_name) or 0 - - if (len > 0) then - for j=1,len do - local node_ent = ent:GetNetworkedBeamEntity(net_name .. "_" .. j .. "_ent") - local nodepos = ent:GetNetworkedBeamVector(net_name .. "_" .. j .. "_pos") - if (node_ent:IsValid()) then - nodepos = ent:WorldToLocal(node_ent:LocalToWorld(nodepos)) - - if (nodepos.x < bbmin.x) then bbmin.x = nodepos.x end - if (nodepos.y < bbmin.y) then bbmin.y = nodepos.y end - if (nodepos.z < bbmin.z) then bbmin.z = nodepos.z end - if (nodepos.x > bbmax.x) then bbmax.x = nodepos.x end - if (nodepos.y > bbmax.y) then bbmax.y = nodepos.y end - if (nodepos.z > bbmax.z) then bbmax.z = nodepos.z end - end + if ent.WirePaths then + for net_name, wiretbl in pairs(ent.WirePaths) do + local nodes = wiretbl.Path + local len = #nodes + for j=1, len do + local node_ent = nodes[j].Entity + local nodepos = nodes[j].Pos + if (node_ent:IsValid()) then + nodepos = ent:WorldToLocal(node_ent:LocalToWorld(nodepos)) + + if (nodepos.x < bbmin.x) then bbmin.x = nodepos.x end + if (nodepos.y < bbmin.y) then bbmin.y = nodepos.y end + if (nodepos.z < bbmin.z) then bbmin.z = nodepos.z end + if (nodepos.x > bbmax.x) then bbmax.x = nodepos.x end + if (nodepos.y > bbmax.y) then bbmax.y = nodepos.y end + if (nodepos.z > bbmax.z) then bbmax.z = nodepos.z end end end end diff --git a/lua/wire/client/sound_browser.lua b/lua/wire/client/sound_browser.lua old mode 100755 new mode 100644 index 0ed326de8b..18caf1a135 --- a/lua/wire/client/sound_browser.lua +++ b/lua/wire/client/sound_browser.lua @@ -1,8 +1,8 @@ --- A sound browser for the sound emitter and the expression 2 editor. --- Made by Grocel. +// A sound browser for the sound emitter and the expression 2 editor. +// Made by Grocel. -local max_char_count = 200 -- File length limit -local max_char_chat_count = 110 -- chat has a ~128 char limit, varies depending on char wide. +local max_char_count = 200 //File length limit +local max_char_chat_count = 110 // chat has a ~128 char limit, varies depending on char wide. local Disabled_Gray = Color(140, 140, 140, 255) @@ -30,9 +30,9 @@ local TranslateCHAN = { [CHAN_USER_BASE] = "CHAN_USER_BASE" } --- Output the infos about the given sound. +// Output the infos about the given sound. local function GetFileInfos(strfile) - if not isstring(strfile) or strfile == "" then return end + if (!isstring(strfile) or strfile == "") then return end local nsize = tonumber(file.Size("sound/" .. strfile, "GAME") or "-1") local strformat = string.lower(string.GetExtensionFromFilename(strfile) or "n/a") @@ -41,41 +41,41 @@ local function GetFileInfos(strfile) end local function FormatSize(nsize) - if not nsize then return end + if (!nsize) then return end - -- Negative filessizes aren't Valid. - if nsize < 0 then return end + //Negative filessizes aren't Valid. + if (nsize < 0) then return end return nsize, string.NiceSize(nsize) end local function FormatLength(nduration) - if not nduration then return end + if (!nduration) then return end - -- Negative durations aren't Valid. - if nduration < 0 then return end + //Negative durations aren't Valid. + if (nduration < 0) then return end local nm = math.floor(nduration / 60) local ns = math.floor(nduration % 60) local nms = (nduration % 1) * 1000 - return string.format("%01d", nm)..":"..string.format("%02d", ns).."."..string.format("%03d", nms) + return nduration, (string.format("%01d", nm)..":"..string.format("%02d", ns).."."..string.format("%03d", nms)) end local function GetInfoTable(strfile) - local nsize, strformat = GetFileInfos(strfile) - if not nsize then return end + local nsize, strformat, nduration = GetFileInfos(strfile) + if (!nsize) then return end - local nduration = SoundDuration(strfile) -- Get the duration for the info text only. - if nduration then + nduration = SoundDuration(strfile) //Get the duration for the info text only. + if(nduration) then nduration = math.Round(nduration * 1000) / 1000 end - local strduration = FormatLength(nduration, nsize) + local nduration, strduration = FormatLength(nduration, nsize) local nsizeB, strsize = FormatSize(nsize) local T = {} local tabproperty = sound.GetProperties(strfile) - if tabproperty then + if (tabproperty) then T = tabproperty else T.Path = strfile @@ -84,48 +84,37 @@ local function GetInfoTable(strfile) T.Format = strformat end - return T, not tabproperty + return T, !tabproperty end -local function GetGamesForSound(path) - local games = {} - for _,game in pairs(engine.GetGames()) do - if game.mounted and file.Exists(path, game.folder) then - table.insert(games, game) - end - end - - return games -end - --- Output the infos about the given sound. +// Output the infos about the given sound. local oldstrfile local function GenerateInfoTree(strfile, backnode, count) - if oldstrfile == strfile and strfile then return end + if(oldstrfile == strfile and strfile) then return end oldstrfile = strfile local SoundData, IsFile = GetInfoTable(strfile) - if not IsValid(backnode) then - if IsValid(SoundInfoTreeRoot) then + if (!IsValid(backnode)) then + if (IsValid(SoundInfoTreeRoot)) then SoundInfoTreeRoot:Remove() end end - if not SoundData then return end + if(!SoundData) then return end local strcount = "" - if count then + if (count) then strcount = " ("..count..")" end - if IsFile then - local index - local node - local mainnode - local subnode + if (IsFile) then + local index = "" + local node = nil + local mainnode = nil + local subnode = nil - if IsValid(backnode) then + if (IsValid(backnode)) then mainnode = backnode:AddNode("Sound File"..strcount, "icon16/sound.png") else mainnode = SoundInfoTree:AddNode("Sound File", "icon16/sound.png") @@ -143,7 +132,7 @@ local function GenerateInfoTree(strfile, backnode, count) do index = "Duration" node = mainnode:AddNode(index, "icon16/time.png") - for _, v in pairs(SoundData[index]) do + for k, v in pairs(SoundData[index]) do subnode = node:AddNode(v, "icon16/page.png") subnode.IsDataNode = true end @@ -151,7 +140,7 @@ local function GenerateInfoTree(strfile, backnode, count) do index = "Size" node = mainnode:AddNode(index, "icon16/disk.png") - for _, v in pairs(SoundData[index]) do + for k, v in pairs(SoundData[index]) do subnode = node:AddNode(v, "icon16/page.png") subnode.IsDataNode = true end @@ -162,22 +151,11 @@ local function GenerateInfoTree(strfile, backnode, count) subnode = node:AddNode(SoundData[index], "icon16/page.png") subnode.IsDataNode = true end - do - local games = GetGamesForSound(SoundData["Path"]) - - node = mainnode:AddNode("Games", "icon16/page_white_key.png") - - for _, game in ipairs(games) do - subnode = node:AddNode(game, "icon16/page.png") - subnode.IsDataNode = true - end - end else - local node - local mainnode - local subnode + local node = nil + local mainnode = nil - if IsValid(backnode) then + if (IsValid(backnode)) then mainnode = backnode:AddNode("Sound Property"..strcount, "icon16/table_gear.png") else mainnode = SoundInfoTree:AddNode("Sound Property", "icon16/table_gear.png") @@ -192,9 +170,9 @@ local function GenerateInfoTree(strfile, backnode, count) end do local tabchannel = SoundData["channel"] or 0 - if istable(tabchannel) then + if (istable(tabchannel)) then node = mainnode:AddNode("Channel", "icon16/page_white_gear.png") - for _, v in pairs(tabchannel) do + for k, v in pairs(tabchannel) do subnode = node:AddNode(v, "icon16/page.png") subnode.IsDataNode = true subnode = node:AddNode(TranslateCHAN[v] or TranslateCHAN[CHAN_USER_BASE], "icon16/page.png") @@ -210,9 +188,9 @@ local function GenerateInfoTree(strfile, backnode, count) end do local tablevel = SoundData["level"] or 0 - if istable(tablevel) then + if (istable(tablevel)) then node = mainnode:AddNode("Level", "icon16/page_white_gear.png") - for _, v in pairs(tablevel) do + for k, v in pairs(tablevel) do subnode = node:AddNode(v, "icon16/page.png") subnode.IsDataNode = true subnode = node:AddNode(v, "icon16/page.png") @@ -226,9 +204,9 @@ local function GenerateInfoTree(strfile, backnode, count) end do local tabpitch = SoundData["volume"] or 0 - if istable(tabpitch) then + if (istable(tabpitch)) then node = mainnode:AddNode("Volume", "icon16/page_white_gear.png") - for _, v in pairs(tabpitch) do + for k, v in pairs(tabpitch) do subnode = node:AddNode(v, "icon16/page.png") subnode.IsDataNode = true end @@ -240,9 +218,9 @@ local function GenerateInfoTree(strfile, backnode, count) end do local tabpitch = SoundData["pitch"] or 0 - if istable(tabpitch) then + if (istable(tabpitch)) then node = mainnode:AddNode("Pitch", "icon16/page_white_gear.png") - for _, v in pairs(tabpitch) do + for k, v in pairs(tabpitch) do subnode = node:AddNode(v, "icon16/page.png") subnode.IsDataNode = true end @@ -254,7 +232,7 @@ local function GenerateInfoTree(strfile, backnode, count) end do local tabsound = SoundData["sound"] or "" - if istable(tabsound) then + if (istable(tabsound)) then node = mainnode:AddNode("Sounds", "icon16/table_multiple.png") else node = mainnode:AddNode("Sound", "icon16/table.png") @@ -263,8 +241,8 @@ local function GenerateInfoTree(strfile, backnode, count) node.SubData = tabsound node.BackNode = mainnode node.Expander.DoClick = function(self) - if not IsValid(SoundInfoTree) then return end - if not IsValid(node) then return end + if (!IsValid(SoundInfoTree)) then return end + if (!IsValid(node)) then return end node:SetExpanded(false) SoundInfoTree:SetSelectedItem(node) @@ -273,111 +251,111 @@ local function GenerateInfoTree(strfile, backnode, count) end end - if IsValid(backnode) then + if (IsValid(backnode)) then return end - if IsValid(SoundInfoTreeRoot) then + if (IsValid(SoundInfoTreeRoot)) then SoundInfoTreeRoot:SetExpanded(true) end end --- Set the volume of the sound. +// Set the volume of the sound. local function SetSoundVolume(volume) - if not SoundObj then return end + if(!SoundObj) then return end SoundObj:ChangeVolume(tonumber(volume) or 1, 0.1) end --- Set the pitch of the sound. +// Set the pitch of the sound. local function SetSoundPitch(pitch) - if not SoundObj then return end + if(!SoundObj) then return end SoundObj:ChangePitch(tonumber(pitch) or 100, 0.1) end --- Play the given sound, if no sound is given then mute a playing sound. +// Play the given sound, if no sound is given then mute a playing sound. local function PlaySound(file, volume, pitch) - if SoundObj then + if(SoundObj) then SoundObj:Stop() SoundObj = nil end - if not file or file == "" then return end + if (!file or file == "") then return end local ply = LocalPlayer() - if not IsValid(ply) then return end + if (!IsValid(ply)) then return end util.PrecacheSound(file) SoundObj = CreateSound(ply, file) - if SoundObj then + if(SoundObj) then SoundObj:PlayEx(tonumber(volume) or 1, tonumber(pitch) or 100) end end --- Play the given sound without effects, if no sound is given then mute a playing sound. +// Play the given sound without effects, if no sound is given then mute a playing sound. local function PlaySoundNoEffect(file) - if SoundObjNoEffect then + if(SoundObjNoEffect) then SoundObjNoEffect:Stop() SoundObjNoEffect = nil end - if not file or file == "" then return end + if (!file or file == "") then return end local ply = LocalPlayer() - if not IsValid(ply) then return end + if (!IsValid(ply)) then return end util.PrecacheSound(file) SoundObjNoEffect = CreateSound(ply, file) - if SoundObjNoEffect then + if(SoundObjNoEffect) then SoundObjNoEffect:PlayEx(1, 100) end end local function SetupSoundemitter(strSound) - -- Setup the Soundemitter stool with the soundpath. + // Setup the Soundemitter stool with the soundpath. RunConsoleCommand("wire_soundemitter_sound", strSound) - -- Pull out the soundemitter stool after setup. + // Pull out the soundemitter stool after setup. spawnmenu.ActivateTool("wire_soundemitter") end local function SetupClipboard(strSound) - -- Copy the soundpath to Clipboard. + // Copy the soundpath to Clipboard. SetClipboardText(strSound) end -local function Sendmenu(strSound, soundemitter, nSoundVolume, nSoundPitch) -- Open a sending and setup menu on right click on a sound file. - if not isstring(strSound) then return end - if strSound == "" then return end +local function Sendmenu(strSound, SoundEmitter, nSoundVolume, nSoundPitch) // Open a sending and setup menu on right click on a sound file. + if (!isstring(strSound)) then return end + if (strSound == "") then return end local Menu = DermaMenu() - local MenuItem + local MenuItem = nil - if soundemitter then + if (SoundEmitter) then - -- Setup soundemitter + //Setup soundemitter MenuItem = Menu:AddOption("Setup soundemitter", function() SetupSoundemitter(strSound) end) MenuItem:SetImage("icon16/sound.png") - -- Setup soundemitter and close + //Setup soundemitter and close MenuItem = Menu:AddOption("Setup soundemitter and close", function() SetupSoundemitter(strSound) SoundBrowserPanel:Close() end) MenuItem:SetImage("icon16/sound.png") - -- Copy to clipboard + //Copy to clipboard MenuItem = Menu:AddOption("Copy to clipboard", function() SetupClipboard(strSound) end) MenuItem:SetImage("icon16/page_paste.png") - -- Copy to clipboard and close + //Copy to clipboard and close MenuItem = Menu:AddOption("Copy to clipboard and close", function() SetupClipboard(strSound) SoundBrowserPanel:Close() @@ -386,26 +364,26 @@ local function Sendmenu(strSound, soundemitter, nSoundVolume, nSoundPitch) -- Op else - -- Copy to clipboard + //Copy to clipboard MenuItem = Menu:AddOption("Copy to clipboard", function() SetupClipboard(strSound) end) MenuItem:SetImage("icon16/page_paste.png") - -- Copy to clipboard and close + //Copy to clipboard and close MenuItem = Menu:AddOption("Copy to clipboard and close", function() SetupClipboard(strSound) SoundBrowserPanel:Close() end) MenuItem:SetImage("icon16/page_paste.png") - -- Setup soundemitter + //Setup soundemitter MenuItem = Menu:AddOption("Setup soundemitter", function() SetupSoundemitter(strSound) end) MenuItem:SetImage("icon16/sound.png") - -- Setup soundemitter and close + //Setup soundemitter and close MenuItem = Menu:AddOption("Setup soundemitter and close", function() SetupSoundemitter(strSound) SoundBrowserPanel:Close() @@ -416,11 +394,11 @@ local function Sendmenu(strSound, soundemitter, nSoundVolume, nSoundPitch) -- Op Menu:AddSpacer() - if IsValid(TabFavourites) then - -- Add the soundpath to the favourites. - if TabFavourites:ItemInList(strSound) then + if (IsValid(TabFavourites)) then + // Add the soundpath to the favourites. + if (TabFavourites:ItemInList(strSound)) then - -- Remove from favourites + //Remove from favourites MenuItem = Menu:AddOption("Remove from favourites", function() TabFavourites:RemoveItem(strSound) end) @@ -428,15 +406,15 @@ local function Sendmenu(strSound, soundemitter, nSoundVolume, nSoundPitch) -- Op else - -- Add to favourites + //Add to favourites MenuItem = Menu:AddOption("Add to favourites", function() TabFavourites:AddItem(strSound, sound.GetProperties(strSound) and "property" or "file") end) MenuItem:SetImage("icon16/star.png") local max_item_count = TabFavourites:GetMaxItems() local count = TabFavourites.TabfileCount - if count >= max_item_count then - MenuItem:SetTextColor(Disabled_Gray) -- custom disabling + if (count >= max_item_count) then + MenuItem:SetTextColor(Disabled_Gray) // custom disabling MenuItem.DoClick = function() end MenuItem:SetToolTip("The favourites list is Full! It can't hold more than "..max_item_count.." items!") @@ -447,26 +425,26 @@ local function Sendmenu(strSound, soundemitter, nSoundVolume, nSoundPitch) -- Op Menu:AddSpacer() - -- Print to console + //Print to console MenuItem = Menu:AddOption("Print to console", function() - -- Print the soundpath in the Console/HUD. + // Print the soundpath in the Console/HUD. local ply = LocalPlayer() - if not IsValid(ply) then return end + if (!IsValid(ply)) then return end ply:PrintMessage( HUD_PRINTTALK, strSound) end) MenuItem:SetImage("icon16/monitor_go.png") - -- Print to Chat + //Print to Chat MenuItem = Menu:AddOption("Print to Chat", function() - -- Say the the soundpath. + // Say the the soundpath. RunConsoleCommand("say", strSound) end) MenuItem:SetImage("icon16/group_go.png") local len = #strSound - if len > max_char_chat_count then - MenuItem:SetTextColor(Disabled_Gray) -- custom disabling + if (len > max_char_chat_count) then + MenuItem:SetTextColor(Disabled_Gray) // custom disabling MenuItem.DoClick = function() end MenuItem:SetToolTip("The filepath ("..len.." chars) is too long to print in chat. It should be shorter than "..max_char_chat_count.." chars!") @@ -474,64 +452,63 @@ local function Sendmenu(strSound, soundemitter, nSoundVolume, nSoundPitch) -- Op Menu:AddSpacer() - -- Play + //Play MenuItem = Menu:AddOption("Play", function() - PlaySound(strSound, nSoundVolume, nSoundPitch) + PlaySound(strSound, nSoundVolume, nSoundPitch, strtype) PlaySoundNoEffect() end) MenuItem:SetImage("icon16/control_play.png") - -- Play without effects + //Play without effects MenuItem = Menu:AddOption("Play without effects", function() PlaySound() - PlaySoundNoEffect(strSound) + PlaySoundNoEffect(strSound, strtype) end) MenuItem:SetImage("icon16/control_play_blue.png") Menu:Open() end -local function Infomenu(parent, node, soundemitter, nSoundVolume, nSoundPitch) - if not IsValid(node) then return end - if not node.IsDataNode then return end +local function Infomenu(parent, node, SoundEmitter, nSoundVolume, nSoundPitch) + if(!IsValid(node)) then return end + if(!node.IsDataNode) then return end local strNodeName = node:GetText() local IsSoundNode = node.IsSoundNode - if IsSoundNode then - Sendmenu(strNodeName, soundemitter, nSoundVolume, nSoundPitch) + if(IsSoundNode) then + Sendmenu(strNodeName, SoundEmitter, nSoundVolume, nSoundPitch) return end local Menu = DermaMenu() - local MenuItem - -- Copy to clipboard + //Copy to clipboard MenuItem = Menu:AddOption("Copy to clipboard", function() SetupClipboard(strNodeName) end) MenuItem:SetImage("icon16/page_paste.png") - -- Print to console + //Print to console MenuItem = Menu:AddOption("Print to console", function() - -- Print the soundpath in the Console/HUD. + // Print the soundpath in the Console/HUD. local ply = LocalPlayer() - if not IsValid(ply) then return end + if (!IsValid(ply)) then return end ply:PrintMessage( HUD_PRINTTALK, strNodeName) end) MenuItem:SetImage("icon16/monitor_go.png") - -- Print to Chat + //Print to Chat MenuItem = Menu:AddOption("Print to Chat", function() - -- Say the the soundpath. + // Say the the soundpath. RunConsoleCommand("say", strNodeName) end) MenuItem:SetImage("icon16/group_go.png") local len = #strNodeName - if len > max_char_chat_count then - MenuItem:SetTextColor(Disabled_Gray) -- custom disabling + if (len > max_char_chat_count) then + MenuItem:SetTextColor(Disabled_Gray) // custom disabling MenuItem.DoClick = function() end MenuItem:SetToolTip("The filepath ("..len.." chars) is too long to print in chat. It should be shorter than "..max_char_chat_count.." chars!") @@ -540,27 +517,27 @@ local function Infomenu(parent, node, soundemitter, nSoundVolume, nSoundPitch) Menu:Open() end --- Save the file path. It should be cross session. --- It's used when opening the browser in the e2 editor. +// Save the file path. It should be cross session. +// It's used when opening the browser in the e2 editor. local function SaveFilePath(panel, file) - if not IsValid(panel) then return end - if panel.Soundemitter then return end + if (!IsValid(panel)) then return end + if (panel.Soundemitter) then return end panel:SetCookie("wire_soundfile", file) end --- Open the Sound Browser. +// Open the Sound Browser. local function CreateSoundBrowser(path, se) local soundemitter = false - if isstring(path) and path ~= "" then + if (isstring(path) and path ~= "") then soundemitter = true - if tonumber(se) ~= 1 then + if (tonumber(se) ~= 1) then soundemitter = false end end - if tonumber(se) == 1 then + if (tonumber(se) == 1) then soundemitter = true end @@ -568,14 +545,14 @@ local function CreateSoundBrowser(path, se) local nSoundVolume = 1 local nSoundPitch = 100 - if IsValid(SoundBrowserPanel) then SoundBrowserPanel:Remove() end - if IsValid(TabFileBrowser) then TabFileBrowser:Remove() end - if IsValid(TabSoundPropertyList) then TabSoundPropertyList:Remove() end - if IsValid(TabFavourites) then TabFavourites:Remove() end - if IsValid(SoundInfoTree) then SoundInfoTree:Remove() end - if IsValid(SoundInfoTreeRoot) then SoundInfoTreeRoot:Remove() end + if(IsValid(SoundBrowserPanel)) then SoundBrowserPanel:Remove() end + if(IsValid(TabFileBrowser)) then TabFileBrowser:Remove() end + if(IsValid(TabSoundPropertyList)) then TabSoundPropertyList:Remove() end + if(IsValid(TabFavourites)) then TabFavourites:Remove() end + if(IsValid(SoundInfoTree)) then SoundInfoTree:Remove() end + if(IsValid(SoundInfoTreeRoot)) then SoundInfoTreeRoot:Remove() end - SoundBrowserPanel = vgui.Create("DFrame") -- The main frame. + SoundBrowserPanel = vgui.Create("DFrame") // The main frame. SoundBrowserPanel:SetPos(50,25) SoundBrowserPanel:SetSize(750, 500) @@ -587,11 +564,11 @@ local function CreateSoundBrowser(path, se) SoundBrowserPanel:SetTitle("Sound Browser") SoundBrowserPanel:SetVisible(false) SoundBrowserPanel:SetCookieName( "wire_sound_browser" ) - SoundBrowserPanel:GetParent():SetWorldClicker(true) -- Allow the use of the toolgun while in menu. + SoundBrowserPanel:GetParent():SetWorldClicker(true) // Allow the use of the toolgun while in menu. - TabFileBrowser = vgui.Create("wire_filebrowser") -- The file tree browser. - TabSoundPropertyList = vgui.Create("wire_soundpropertylist") -- The sound property browser. - TabFavourites = vgui.Create("wire_listeditor") -- The favourites manager. + TabFileBrowser = vgui.Create("wire_filebrowser") // The file tree browser. + TabSoundPropertyList = vgui.Create("wire_soundpropertylist") // The sound property browser. + TabFavourites = vgui.Create("wire_listeditor") // The favourites manager. TabFileBrowser:SetListSpeed(6) TabFileBrowser:SetMaxItemsPerPage(200) @@ -602,58 +579,58 @@ local function CreateSoundBrowser(path, se) TabFavourites:SetListSpeed(40) TabFavourites:SetMaxItems(512) - local BrowserTabs = vgui.Create("DPropertySheet") -- The tabs. + local BrowserTabs = vgui.Create("DPropertySheet") // The tabs. BrowserTabs:DockMargin(5, 5, 5, 5) BrowserTabs:AddSheet("File Browser", TabFileBrowser, "icon16/folder.png", false, false, "Browse your sound folder.") BrowserTabs:AddSheet("Sound Property Browser", TabSoundPropertyList, "icon16/table_gear.png", false, false, "Browse the sound properties.") BrowserTabs:AddSheet("Favourites", TabFavourites, "icon16/star.png", false, false, "View your favourites.") - SoundInfoTree = vgui.Create("DTree") -- The info tree. + SoundInfoTree = vgui.Create("DTree") // The info tree. SoundInfoTree:SetClickOnDragHover(false) local oldClicktime = CurTime() SoundInfoTree.DoClick = function( parent, node ) - if not IsValid(parent) then return end - if not IsValid(node) then return end + if (!IsValid(parent)) then return end + if (!IsValid(node)) then return end parent:SetSelectedItem(node) local Clicktime = CurTime() - if (Clicktime - oldClicktime) > 0.3 then oldClicktime = Clicktime return end + if ((Clicktime - oldClicktime) > 0.3) then oldClicktime = Clicktime return end oldClicktime = Clicktime - if not node.IsSoundNode then return end + if (!node.IsSoundNode) then return end local file = node:GetText() PlaySound(file, nSoundVolume, nSoundPitch) PlaySoundNoEffect() end SoundInfoTree.DoRightClick = function( parent, node ) - if not IsValid(parent) then return end - if not IsValid(node) then return end + if (!IsValid(parent)) then return end + if (!IsValid(node)) then return end parent:SetSelectedItem(node) - Infomenu(parent, node, soundemitter, nSoundVolume, nSoundPitch) + Infomenu(parent, node, SoundEmitter, nSoundVolume, nSoundPitch) end SoundInfoTree.OnNodeSelected = function( parent, node ) - if not IsValid(parent) then return end - if not IsValid(node) then return end + if (!IsValid(parent)) then return end + if (!IsValid(node)) then return end local backnode = node.BackNode - if not IsValid(node.BackNode) then - node:SetExpanded(not node.m_bExpanded) + if (!IsValid(node.BackNode)) then + node:SetExpanded(!node.m_bExpanded) return end local tabsound = node.SubData - if not tabsound then - node:SetExpanded(not node.m_bExpanded) + if (!tabsound) then + node:SetExpanded(!node.m_bExpanded) return end node:SetExpanded(false) node:Remove() - if istable(tabsound) then + if (istable(tabsound)) then node = backnode:AddNode("Sounds", "icon16/table_multiple.png") for k, v in pairs(tabsound) do GenerateInfoTree(v, node, k) @@ -665,7 +642,7 @@ local function CreateSoundBrowser(path, se) node:SetExpanded(false) parent:SetSelectedItem(node) - node:SetExpanded(not node.m_bExpanded) + node:SetExpanded(!node.m_bExpanded) end local SplitPanel = SoundBrowserPanel:Add( "DHorizontalDivider" ) @@ -682,7 +659,7 @@ local function CreateSoundBrowser(path, se) TabFileBrowser:SetWildCard("GAME") TabFileBrowser:SetFileTyps({"*.mp3","*.wav"}) - --TabFileBrowser:AddColumns("Type", "Size", "Length") -- getting the duration is very slow. + //TabFileBrowser:AddColumns("Type", "Size", "Length") //getting the duration is very slow. local Columns = TabFileBrowser:AddColumns("Format", "Size") Columns[1]:SetFixedWidth(70) Columns[1]:SetWide(70) @@ -690,18 +667,22 @@ local function CreateSoundBrowser(path, se) Columns[2]:SetWide(70) TabFileBrowser.LineData = function(self, id, strfile, ...) - if #strfile > max_char_count then return nil, true end -- skip and hide to long filenames. + if (#strfile > max_char_count) then return nil, true end // skip and hide to long filenames. local nsize, strformat, nduration = GetFileInfos(strfile) - if not nsize then return end + if (!nsize) then return end local nsizeB, strsize = FormatSize(nsize, nduration) - local strduration = FormatLength(nduration, nsize) + local nduration, strduration = FormatLength(nduration, nsize) - --return {strformat, strsize or "n/a", strduration or "n/a"} -- getting the duration is very slow. + //return {strformat, strsize or "n/a", strduration or "n/a"} //getting the duration is very slow. return {strformat, strsize or "n/a"} end + TabFileBrowser.OnLineAdded = function(self, id, line, strfile, ...) + + end + TabFileBrowser.DoClick = function(parent, file) SaveFilePath(SoundBrowserPanel, file) @@ -753,7 +734,7 @@ local function CreateSoundBrowser(path, se) TabFavourites:SetRootPath("soundlists") TabFavourites.DoClick = function(parent, item, data) - if file.Exists("sound/"..item, "GAME") then + if(file.Exists("sound/"..item, "GAME")) then TabFileBrowser:SetOpenFile(item) end @@ -762,7 +743,7 @@ local function CreateSoundBrowser(path, se) end TabFavourites.DoDoubleClick = function(parent, item, data) - if file.Exists("sound/"..item, "GAME") then + if(file.Exists("sound/"..item, "GAME")) then TabFileBrowser:SetOpenFile(item) end @@ -772,7 +753,7 @@ local function CreateSoundBrowser(path, se) end TabFavourites.DoRightClick = function(parent, item, data) - if file.Exists("sound/"..item, "GAME") then + if(file.Exists("sound/"..item, "GAME")) then TabFileBrowser:SetOpenFile(item) end @@ -781,25 +762,25 @@ local function CreateSoundBrowser(path, se) GenerateInfoTree(item) end - local ControlPanel = SoundBrowserPanel:Add("DPanel") -- The bottom part of the frame. + local ControlPanel = SoundBrowserPanel:Add("DPanel") // The bottom part of the frame. ControlPanel:DockMargin(0, 5, 0, 0) ControlPanel:Dock(BOTTOM) ControlPanel:SetTall(60) ControlPanel:SetDrawBackground(false) - local ButtonsPanel = ControlPanel:Add("DPanel") -- The buttons. + local ButtonsPanel = ControlPanel:Add("DPanel") // The buttons. ButtonsPanel:DockMargin(4, 0, 0, 0) ButtonsPanel:Dock(RIGHT) ButtonsPanel:SetWide(250) ButtonsPanel:SetDrawBackground(false) - local TunePanel = ControlPanel:Add("DPanel") -- The effect Sliders. + local TunePanel = ControlPanel:Add("DPanel") // The effect Sliders. TunePanel:DockMargin(0, 4, 0, 0) TunePanel:Dock(LEFT) TunePanel:SetWide(350) TunePanel:SetDrawBackground(false) - local TuneVolumeSlider = TunePanel:Add("DNumSlider") -- The volume slider. + local TuneVolumeSlider = TunePanel:Add("DNumSlider") // The volume slider. TuneVolumeSlider:DockMargin(2, 0, 0, 0) TuneVolumeSlider:Dock(TOP) TuneVolumeSlider:SetText("Volume") @@ -812,7 +793,7 @@ local function CreateSoundBrowser(path, se) SetSoundVolume(nSoundVolume) end - local TunePitchSlider = TunePanel:Add("DNumSlider") -- The pitch slider. + local TunePitchSlider = TunePanel:Add("DNumSlider") // The pitch slider. TunePitchSlider:DockMargin(2, 0, 0, 0) TunePitchSlider:Dock(BOTTOM) TunePitchSlider:SetText("Pitch") @@ -825,12 +806,12 @@ local function CreateSoundBrowser(path, se) SetSoundPitch(nSoundPitch) end - local PlayStopPanel = ButtonsPanel:Add("DPanel") -- Play and stop. + local PlayStopPanel = ButtonsPanel:Add("DPanel") // Play and stop. PlayStopPanel:DockMargin(0, 0, 0, 2) PlayStopPanel:Dock(TOP) PlayStopPanel:SetDrawBackground(false) - local PlayButton = PlayStopPanel:Add("DButton") -- The play button. + local PlayButton = PlayStopPanel:Add("DButton") // The play button. PlayButton:SetText("Play") PlayButton:Dock(LEFT) PlayButton:SetWide(PlayStopPanel:GetWide() / 2 - 2) @@ -839,16 +820,16 @@ local function CreateSoundBrowser(path, se) PlaySoundNoEffect() end - local StopButton = PlayStopPanel:Add("DButton") -- The stop button. + local StopButton = PlayStopPanel:Add("DButton") // The stop button. StopButton:SetText("Stop") StopButton:Dock(RIGHT) StopButton:SetWide(PlayButton:GetWide()) StopButton.DoClick = function() - PlaySound() -- Mute a playing sound by not giving a sound. + PlaySound() // Mute a playing sound by not giving a sound. PlaySoundNoEffect() end - local SoundemitterButton = ButtonsPanel:Add("DButton") -- The soundemitter button. Hidden in e2 mode. + local SoundemitterButton = ButtonsPanel:Add("DButton") // The soundemitter button. Hidden in e2 mode. SoundemitterButton:SetText("Send to soundemitter") SoundemitterButton:DockMargin(0, 2, 0, 0) SoundemitterButton:Dock(FILL) @@ -857,7 +838,7 @@ local function CreateSoundBrowser(path, se) SetupSoundemitter(strSound) end - local ClipboardButton = ButtonsPanel:Add("DButton") -- The soundemitter button. Hidden in soundemitter mode. + local ClipboardButton = ButtonsPanel:Add("DButton") // The soundemitter button. Hidden in soundemitter mode. ClipboardButton:SetText("Copy to clipboard") ClipboardButton:DockMargin(0, 2, 0, 0) ClipboardButton:Dock(FILL) @@ -869,18 +850,18 @@ local function CreateSoundBrowser(path, se) local oldw, oldh = SoundBrowserPanel:GetSize() SoundBrowserPanel.PerformLayout = function(self, ...) SoundemitterButton:SetVisible(self.Soundemitter) - ClipboardButton:SetVisible(not self.Soundemitter) + ClipboardButton:SetVisible(!self.Soundemitter) local w = self:GetWide() local rightw = SplitPanel:GetLeftWidth() + w - oldw - if rightw < SplitPanel:GetLeftMin() then + if (rightw < SplitPanel:GetLeftMin()) then rightw = SplitPanel:GetLeftMin() end SplitPanel:SetLeftWidth(rightw) local minw = w - SplitPanel:GetRightMin() + SplitPanel:GetDividerWidth() - if SplitPanel:GetLeftWidth() > minw then + if (SplitPanel:GetLeftWidth() > minw) then SplitPanel:SetLeftWidth(minw) end @@ -888,7 +869,7 @@ local function CreateSoundBrowser(path, se) PlayButton:SetWide(PlayStopPanel:GetWide() / 2 - 2) StopButton:SetWide(PlayButton:GetWide()) - if self.Soundemitter then + if (self.Soundemitter) then SoundemitterButton:SetTall(PlayStopPanel:GetTall() - 2) else ClipboardButton:SetTall(PlayStopPanel:GetTall() - 2) @@ -899,7 +880,7 @@ local function CreateSoundBrowser(path, se) DFrame.PerformLayout(self, ...) end - SoundBrowserPanel.OnClose = function() -- Set effects back and mute when closing. + SoundBrowserPanel.OnClose = function() // Set effects back and mute when closing. nSoundVolume = 1 nSoundPitch = 100 TuneVolumeSlider:SetValue(nSoundVolume * 100) @@ -911,12 +892,12 @@ local function CreateSoundBrowser(path, se) SoundBrowserPanel:InvalidateLayout(true) end --- Open the Sound Browser. +// Open the Sound Browser. local function OpenSoundBrowser(pl, cmd, args) - local path = args[1] -- nil or "" will put the browser in e2 mode else the soundemitter mode is applied. + local path = args[1] // nil or "" will put the browser in e2 mode else the soundemitter mode is applied. local se = args[2] - if not IsValid(SoundBrowserPanel) then + if (!IsValid(SoundBrowserPanel)) then CreateSoundBrowser(path, se) end @@ -924,34 +905,39 @@ local function OpenSoundBrowser(pl, cmd, args) SoundBrowserPanel:MakePopup() SoundBrowserPanel:InvalidateLayout(true) - if not IsValid(TabFileBrowser) then return end + if (!IsValid(TabFileBrowser)) then return end - -- Replaces the timer, doesn't get paused in singleplayer. - WireLib.Timedcall(function() - if not IsValid(SoundBrowserPanel) then return end - if not IsValid(TabFileBrowser) then return end + //Replaces the timer, doesn't get paused in singleplayer. + WireLib.Timedcall(function(SoundBrowserPanel, TabFileBrowser, path, se) + if (!IsValid(SoundBrowserPanel)) then return end + if (!IsValid(TabFileBrowser)) then return end + + local soundemitter = false + if (isstring(path) and path ~= "") then + soundemitter = true + end local soundemitter = false - if isstring(path) and path ~= "" then + if (isstring(path) and path ~= "") then soundemitter = true - if tonumber(se) ~= 1 then + if (tonumber(se) ~= 1) then soundemitter = false end end - if tonumber(se) == 1 then + if (tonumber(se) == 1) then soundemitter = true end SoundBrowserPanel.Soundemitter = soundemitter SoundBrowserPanel:InvalidateLayout(true) - if not soundemitter then - path = SoundBrowserPanel:GetCookie("wire_soundfile", "") -- load last session + if (!soundemitter) then + path = SoundBrowserPanel:GetCookie("wire_soundfile", "") // load last session end TabFileBrowser:SetOpenFile(path) - end) + end, SoundBrowserPanel, TabFileBrowser, path, se) end concommand.Add("wire_sound_browser_open", OpenSoundBrowser) diff --git a/lua/wire/wire_paths.lua b/lua/wire/wire_paths.lua new file mode 100644 index 0000000000..7f7d2db8d9 --- /dev/null +++ b/lua/wire/wire_paths.lua @@ -0,0 +1,117 @@ +-- wire_paths.lua +-- +-- This file implements syncing of wire paths, which are the visual +-- component of wires. +-- +-- Conceptually, a wire path has a material, a color, and a non-zero width, as +-- well as as a non-empty polyline along the wire. (Each point in the line +-- has both a parent entity, and a local offset from that entity.) +-- + +if not WireLib then return end +WireLib.Paths = {} + +local transmit_queues = setmetatable({}, { __index = function(t,p) t[p] = {} return t[p] end }) + +if CLIENT then + net.Receive("WireLib.Paths.TransmitPath", function(length) + local path = { + Path = {} + } + path.Entity = net.ReadEntity() + if not path.Entity:IsValid() then return end + path.Name = net.ReadString() + path.Width = net.ReadFloat() + if path.Width<=0 then + if path.Entity.WirePaths then + path.Entity.WirePaths[path.Name] = nil + if not next(path.Entity.WirePaths) then path.Entity.WirePaths = nil end + end + return + end + path.StartPos = net.ReadVector() + path.Material = net.ReadString() + path.Color = net.ReadColor() + + local num_points = net.ReadUInt(15) + for i = 1, num_points do + path.Path[i] = { Entity = net.ReadEntity(), Pos = net.ReadVector() } + end + + if path.Entity.WirePaths == nil then path.Entity.WirePaths = {} end + path.Entity.WirePaths[path.Name] = path + + end) + + hook.Add("NetworkEntityCreated", "WireLib.Paths.NetworkEntityCreated", function(ent) + if ent.Inputs then + net.Start("WireLib.Paths.RequestPaths") + net.WriteEntity(ent) + net.SendToServer() + end + end) + return +end + +util.AddNetworkString("WireLib.Paths.RequestPaths") +util.AddNetworkString("WireLib.Paths.TransmitPath") + +net.Receive("WireLib.Paths.RequestPaths", function(length, ply) + local ent = net.ReadEntity() + if ent:IsValid() and ent.Inputs then + for name, input in pairs(ent.Inputs) do + if input.Src then + WireLib.Paths.Add(path, ply) + end + end + end +end) + +local function TransmitPath(input) + local color = input.Color + net.WriteEntity(input.Entity) + net.WriteString(input.Name) + if not input.Src or input.Width<=0 then net.WriteFloat(0) return end + net.WriteFloat(input.Width) + net.WriteVector(input.StartPos) + net.WriteString(input.Material) + net.WriteColor(Color(color.r or 255, color.g or 255, color.b or 255, color.a or 255)) + net.WriteUInt(#input.Path, 15) + for _, point in ipairs(input.Path) do + net.WriteEntity(point.Entity) + net.WriteVector(point.Pos) + end +end + +local function ProcessQueue() + for ply, queue in pairs(transmit_queues) do + if not ply:IsValid() then transmit_queues[ply] = nil continue end + if next(queue) then + net.Start("WireLib.Paths.TransmitPath") + while queue[1] and net.BytesWritten() < 63 * 1024 do + TransmitPath(queue[1]) + table.remove(queue, 1) + end + net.Send(ply) + else + transmit_queues[ply] = nil + end + end + if not next(transmit_queues) then + timer.Remove("WireLib.Paths.ProcessQueue") + end +end + +-- Add a path to every player's transmit queue +function WireLib.Paths.Add(input, ply) + if ply then + table.insert(transmit_queues[ply], input) + else + for _, player in pairs(player.GetAll()) do + table.insert(transmit_queues[player], input) + end + end + if not timer.Exists("WireLib.Paths.ProcessQueue") then + timer.Create("WireLib.Paths.ProcessQueue", 0.2, 0, ProcessQueue) + end +end From 903de1dd054cb77adbe00ab1c65daad9601dd346 Mon Sep 17 00:00:00 2001 From: ajloveslily14 Date: Sat, 25 Aug 2018 21:22:32 -0700 Subject: [PATCH 29/56] add a test for unlimited ops players that can be trusted --- lua/entities/gmod_wire_expression2/init.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/entities/gmod_wire_expression2/init.lua b/lua/entities/gmod_wire_expression2/init.lua index 168e439ebb..666430228b 100644 --- a/lua/entities/gmod_wire_expression2/init.lua +++ b/lua/entities/gmod_wire_expression2/init.lua @@ -118,6 +118,7 @@ local SysTime = SysTime function ENT:Execute() if self.error then return end if self.context.resetting then return end + local unlimited = self.player:GetPData("expression2_unlimited",0) for k, v in pairs(self.tvars) do self.GlobalScope[k] = copytype(wire_expression_types2[v][2]) @@ -132,7 +133,7 @@ function ENT:Execute() local ok, msg = pcall(self.script[1], self.context, self.script) if not ok then if msg == "exit" then - elseif msg == "perf" then + elseif msg == "perf" and not unlimited then self:Error("Expression 2 (" .. self.name .. "): tick quota exceeded", "tick quota exceeded") else self:Error("Expression 2 (" .. self.name .. "): " .. msg, "script error") @@ -166,7 +167,7 @@ function ENT:Execute() self.GlobalScope[k] = copytype(wire_expression_types2[v][2]) end - if self.context.prfcount + self.context.prf - e2_softquota > e2_hardquota then + if self.context.prfcount + self.context.prf - e2_softquota > e2_hardquota and not unlimited then self:Error("Expression 2 (" .. self.name .. "): tick quota exceeded", "hard quota exceeded") end From 02846078501b57b358b7570ef3aa1c5e43d45664 Mon Sep 17 00:00:00 2001 From: ajloveslily14 Date: Sat, 25 Aug 2018 22:10:58 -0700 Subject: [PATCH 30/56] I think this needs to be added too? --- lua/entities/gmod_wire_expression2/core/core.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/entities/gmod_wire_expression2/core/core.lua b/lua/entities/gmod_wire_expression2/core/core.lua index a57f1cbe7e..85dcabb46b 100644 --- a/lua/entities/gmod_wire_expression2/core/core.lua +++ b/lua/entities/gmod_wire_expression2/core/core.lua @@ -24,7 +24,7 @@ __e2setcost(0) registerOperator("seq", "", "", function(self, args) self.prf = self.prf + args[2] - if self.prf > e2_tickquota then error("perf", 0) end + if self.prf > e2_tickquota and not self.player:GetPData("expression2_unlimited",false) then error("perf", 0) end local n = #args if n == 2 then return end From 1ea9ddd352d7237e9e5610f189c8c7d8301e8d01 Mon Sep 17 00:00:00 2001 From: ajloveslily14 Date: Sat, 1 Sep 2018 14:30:33 -0700 Subject: [PATCH 31/56] tobool for the love of god tobool --- lua/entities/gmod_wire_expression2/core/core.lua | 2 +- lua/entities/gmod_wire_expression2/init.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/entities/gmod_wire_expression2/core/core.lua b/lua/entities/gmod_wire_expression2/core/core.lua index 85dcabb46b..ea58b1190f 100644 --- a/lua/entities/gmod_wire_expression2/core/core.lua +++ b/lua/entities/gmod_wire_expression2/core/core.lua @@ -24,7 +24,7 @@ __e2setcost(0) registerOperator("seq", "", "", function(self, args) self.prf = self.prf + args[2] - if self.prf > e2_tickquota and not self.player:GetPData("expression2_unlimited",false) then error("perf", 0) end + if self.prf > e2_tickquota and not tobool(self.player:GetPData("expression2_unlimited",false)) then error("perf", 0) end local n = #args if n == 2 then return end diff --git a/lua/entities/gmod_wire_expression2/init.lua b/lua/entities/gmod_wire_expression2/init.lua index 666430228b..268dd657c7 100644 --- a/lua/entities/gmod_wire_expression2/init.lua +++ b/lua/entities/gmod_wire_expression2/init.lua @@ -118,7 +118,7 @@ local SysTime = SysTime function ENT:Execute() if self.error then return end if self.context.resetting then return end - local unlimited = self.player:GetPData("expression2_unlimited",0) + local unlimited = tobool(self.player:GetPData("expression2_unlimited",0)) for k, v in pairs(self.tvars) do self.GlobalScope[k] = copytype(wire_expression_types2[v][2]) From da1256059113da8e9fb1738fe9170d1abcd4ab2e Mon Sep 17 00:00:00 2001 From: ajloveslily14 Date: Sat, 1 Sep 2018 14:39:47 -0700 Subject: [PATCH 32/56] unlimited is now the same as the cvar, no more crashing --- lua/entities/gmod_wire_expression2/core/core.lua | 2 +- lua/entities/gmod_wire_expression2/init.lua | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/entities/gmod_wire_expression2/core/core.lua b/lua/entities/gmod_wire_expression2/core/core.lua index ea58b1190f..0d8aa56dda 100644 --- a/lua/entities/gmod_wire_expression2/core/core.lua +++ b/lua/entities/gmod_wire_expression2/core/core.lua @@ -24,7 +24,7 @@ __e2setcost(0) registerOperator("seq", "", "", function(self, args) self.prf = self.prf + args[2] - if self.prf > e2_tickquota and not tobool(self.player:GetPData("expression2_unlimited",false)) then error("perf", 0) end + if self.prf > e2_tickquota or (tobool(self.player:GetPData("expression2_unlimited",false)) and self.prf > 100000) then error("perf", 0) end local n = #args if n == 2 then return end diff --git a/lua/entities/gmod_wire_expression2/init.lua b/lua/entities/gmod_wire_expression2/init.lua index 268dd657c7..9d6a0a17f1 100644 --- a/lua/entities/gmod_wire_expression2/init.lua +++ b/lua/entities/gmod_wire_expression2/init.lua @@ -133,7 +133,7 @@ function ENT:Execute() local ok, msg = pcall(self.script[1], self.context, self.script) if not ok then if msg == "exit" then - elseif msg == "perf" and not unlimited then + elseif msg == "perf" then self:Error("Expression 2 (" .. self.name .. "): tick quota exceeded", "tick quota exceeded") else self:Error("Expression 2 (" .. self.name .. "): " .. msg, "script error") @@ -167,7 +167,7 @@ function ENT:Execute() self.GlobalScope[k] = copytype(wire_expression_types2[v][2]) end - if self.context.prfcount + self.context.prf - e2_softquota > e2_hardquota and not unlimited then + if self.context.prfcount + self.context.prf - e2_softquota > e2_hardquota or (unlimited and self.context.prfcount + self.context.prf - 1000000 > 1000000) then self:Error("Expression 2 (" .. self.name .. "): tick quota exceeded", "hard quota exceeded") end From 19f47769b3d0c2270f3d536c95687a4826061b78 Mon Sep 17 00:00:00 2001 From: Python1320 Date: Mon, 29 Oct 2018 23:36:36 +0200 Subject: [PATCH 33/56] Check for valid player --- lua/entities/gmod_wire_expression2/init.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lua/entities/gmod_wire_expression2/init.lua b/lua/entities/gmod_wire_expression2/init.lua index 3109815edb..9c1fa25a09 100644 --- a/lua/entities/gmod_wire_expression2/init.lua +++ b/lua/entities/gmod_wire_expression2/init.lua @@ -120,8 +120,10 @@ local SysTime = SysTime function ENT:Execute() if self.error then return end if self.context.resetting then return end - local unlimited = tobool(self.player:GetPData("expression2_unlimited",0)) - + local pl = self.player + local unlimited = pl:IsValid() and pl:GetPData("expression2_unlimited") + unlimited = unlimited and unlimited~='0' and unlimited~='' + for k, v in pairs(self.tvars) do self.GlobalScope[k] = copytype(wire_expression_types2[v][2]) end From b5727d125ced27c0a05f699b2632df6e60408bc3 Mon Sep 17 00:00:00 2001 From: Python1320 Date: Sun, 11 Nov 2018 21:45:06 +0200 Subject: [PATCH 34/56] Kill unlimited e2 because it lags due to GetPData --- lua/entities/gmod_wire_expression2/core/core.lua | 2 +- lua/entities/gmod_wire_expression2/init.lua | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/lua/entities/gmod_wire_expression2/core/core.lua b/lua/entities/gmod_wire_expression2/core/core.lua index 0d8aa56dda..a57f1cbe7e 100644 --- a/lua/entities/gmod_wire_expression2/core/core.lua +++ b/lua/entities/gmod_wire_expression2/core/core.lua @@ -24,7 +24,7 @@ __e2setcost(0) registerOperator("seq", "", "", function(self, args) self.prf = self.prf + args[2] - if self.prf > e2_tickquota or (tobool(self.player:GetPData("expression2_unlimited",false)) and self.prf > 100000) then error("perf", 0) end + if self.prf > e2_tickquota then error("perf", 0) end local n = #args if n == 2 then return end diff --git a/lua/entities/gmod_wire_expression2/init.lua b/lua/entities/gmod_wire_expression2/init.lua index 9c1fa25a09..a06f314aa4 100644 --- a/lua/entities/gmod_wire_expression2/init.lua +++ b/lua/entities/gmod_wire_expression2/init.lua @@ -120,10 +120,7 @@ local SysTime = SysTime function ENT:Execute() if self.error then return end if self.context.resetting then return end - local pl = self.player - local unlimited = pl:IsValid() and pl:GetPData("expression2_unlimited") - unlimited = unlimited and unlimited~='0' and unlimited~='' - + for k, v in pairs(self.tvars) do self.GlobalScope[k] = copytype(wire_expression_types2[v][2]) end @@ -171,7 +168,7 @@ function ENT:Execute() self.GlobalScope[k] = copytype(wire_expression_types2[v][2]) end - if self.context.prfcount + self.context.prf - e2_softquota > e2_hardquota or (unlimited and self.context.prfcount + self.context.prf - 1000000 > 1000000) then + if self.context.prfcount + self.context.prf - e2_softquota > e2_hardquota then self:Error("Expression 2 (" .. self.name .. "): tick quota exceeded", "hard quota exceeded") end From 110eb2f92632fb1808ade5292d2646ca989d1ce3 Mon Sep 17 00:00:00 2001 From: Python1320 Date: Fri, 7 Dec 2018 19:10:52 +0200 Subject: [PATCH 35/56] Do not receive team or local chat --- lua/entities/gmod_wire_expression2/core/chat.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lua/entities/gmod_wire_expression2/core/chat.lua b/lua/entities/gmod_wire_expression2/core/chat.lua index a4d9a086f2..f47d14a31a 100644 --- a/lua/entities/gmod_wire_expression2/core/chat.lua +++ b/lua/entities/gmod_wire_expression2/core/chat.lua @@ -16,11 +16,13 @@ registerCallback("destruct",function(self) ChatAlert[self.entity] = nil end) -hook.Add("PlayerSay","Exp2TextReceiving", function(ply, text, teamchat) - local entry = { text, CurTime(), ply, teamchat } +hook.Add("PlayerSay","Exp2TextReceiving", function(ply, text, teamchat, localchat ) + if teamchat or localchat then return end + + local entry = { text, CurTime(), ply } TextList[ply:EntIndex()] = entry TextList.last = entry - + runByChat = 1 chipHideChat = false local hideCurrent = false From 023e9cfd59868ba2ce4c0ba5dd08b153d44322b1 Mon Sep 17 00:00:00 2001 From: Python1320 Date: Sun, 26 Jan 2020 18:33:27 +0200 Subject: [PATCH 36/56] Optimize hsv2rgb From https://gist.github.com/GigsD4X/8513963 --- .../gmod_wire_expression2/core/color.lua | 47 +++++++++++++++++-- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/lua/entities/gmod_wire_expression2/core/color.lua b/lua/entities/gmod_wire_expression2/core/color.lua index 19499ceef6..c6b4fffb9b 100644 --- a/lua/entities/gmod_wire_expression2/core/color.lua +++ b/lua/entities/gmod_wire_expression2/core/color.lua @@ -105,15 +105,54 @@ end --- HSV + +local math=math +local function HSVToRGB( hue, saturation, value ) + -- Returns the RGB equivalent of the given HSV-defined color + -- (adapted from some code found around the web) + + -- If it's achromatic, just return the value, clamp yourself + if saturation == 0 then + return value,value,value + end + + hue=hue%360 + + -- Get the hue sector + local hue_sector = math.floor( hue / 60 ) + local hue_sector_offset = ( hue / 60 ) - hue_sector + + local p = value * ( 1 - saturation ) + local q = value * ( 1 - saturation * hue_sector_offset ) + local t = value * ( 1 - saturation * ( 1 - hue_sector_offset ) ) + + if hue_sector == 0 then + return value, t, p + elseif hue_sector == 1 then + return q, value, p + elseif hue_sector == 2 then + return p, value, t + elseif hue_sector == 3 then + return p, q, value + elseif hue_sector == 4 then + return t, p, value + elseif hue_sector == 5 then + return value, p, q + end +end + +local function HSVToRGB(H,S,V) + local r,g,b = HSVToRGB(H,S,V) + return r*255,g*255,b*255 +end + --- Converts from the [http://en.wikipedia.org/wiki/HSV_color_space HSV color space] to the [http://en.wikipedia.org/wiki/RGB_color_space RGB color space] e2function vector hsv2rgb(vector hsv) - local col = HSVToColor(hsv[1], hsv[2], hsv[3]) - return { col.r, col.g, col.b } + return { HSVToRGB(hsv[1], hsv[2], hsv[3]) } end e2function vector hsv2rgb(h, s, v) - local col = HSVToColor(h, s, v) - return { col.r, col.g, col.b } + return { HSVToRGB(h, s, v) } end --- Converts from the [http://en.wikipedia.org/wiki/RGB_color_space RGB color space] to the [http://en.wikipedia.org/wiki/HSV_color_space HSV color space] From b2b324a2e2df70cbda891924926be3251ebdcca5 Mon Sep 17 00:00:00 2001 From: Python1320 Date: Wed, 5 Feb 2020 01:21:22 +0200 Subject: [PATCH 37/56] Update color.lua --- lua/entities/gmod_wire_expression2/core/color.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/entities/gmod_wire_expression2/core/color.lua b/lua/entities/gmod_wire_expression2/core/color.lua index c6b4fffb9b..a0f7def822 100644 --- a/lua/entities/gmod_wire_expression2/core/color.lua +++ b/lua/entities/gmod_wire_expression2/core/color.lua @@ -107,7 +107,7 @@ end local math=math -local function HSVToRGB( hue, saturation, value ) +local function _HSVToRGB( hue, saturation, value ) -- Returns the RGB equivalent of the given HSV-defined color -- (adapted from some code found around the web) @@ -142,7 +142,7 @@ local function HSVToRGB( hue, saturation, value ) end local function HSVToRGB(H,S,V) - local r,g,b = HSVToRGB(H,S,V) + local r,g,b = _HSVToRGB(H,S,V) return r*255,g*255,b*255 end From 37740dcee489e13f6727b9685fa3841aa7cda23b Mon Sep 17 00:00:00 2001 From: Python1320 Date: Wed, 5 Feb 2020 01:53:33 +0200 Subject: [PATCH 38/56] Limit string lengths --- .../gmod_wire_expression2/core/string.lua | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/lua/entities/gmod_wire_expression2/core/string.lua b/lua/entities/gmod_wire_expression2/core/string.lua index c837d46205..ebddac7804 100644 --- a/lua/entities/gmod_wire_expression2/core/string.lua +++ b/lua/entities/gmod_wire_expression2/core/string.lua @@ -8,6 +8,12 @@ // TODO: benchmarks! local string = string -- optimization +local function limitlen(str) + if str and #str>1024*1024 then + error ("string too long",2) + end + return str +end /******************************************************************************/ @@ -103,7 +109,7 @@ registerOperator("add", "ss", "s", function(self, args) self.prf = self.prf + #rv1*0.01 + #rv2*0.01 - return rv1 .. rv2 + return limitlen(rv1 .. rv2) end) /******************************************************************************/ @@ -114,7 +120,7 @@ registerOperator("add", "sn", "s", function(self, args) self.prf = self.prf + #rv1*0.01 - return rv1 .. tostring(rv2) + return limitlen(rv1 .. tostring(rv2)) end) registerOperator("add", "ns", "s", function(self, args) @@ -123,7 +129,7 @@ registerOperator("add", "ns", "s", function(self, args) self.prf = self.prf + #rv2*0.01 - return tostring(rv1) .. rv2 + return limitlen(tostring(rv1) .. rv2) end) /******************************************************************************/ @@ -134,7 +140,7 @@ registerOperator("add", "sv", "s", function(self, args) self.prf = self.prf + #rv1*0.01 - return ("%s[%s,%s,%s]"):format( rv1, rv2[1], rv2[2], rv2[3] ) + return limitlen(("%s[%s,%s,%s]"):format( rv1, rv2[1], rv2[2], rv2[3] )) end) registerOperator("add", "vs", "s", function(self, args) @@ -143,7 +149,7 @@ registerOperator("add", "vs", "s", function(self, args) self.prf = self.prf + #rv2*0.01 - return ("[%s,%s,%s]%s"):format( rv1[1],rv1[2],rv1[3],rv2) + return limitlen(("[%s,%s,%s]%s"):format( rv1[1],rv1[2],rv1[3],rv2)) end) /******************************************************************************/ @@ -154,7 +160,7 @@ registerOperator("add", "sa", "s", function(self, args) self.prf = self.prf + #rv1*0.01 - return ("%s[%s,%s,%s]"):format( rv1,rv2[1],rv2[2],rv2[3] ) + return limitlen(("%s[%s,%s,%s]"):format( rv1,rv2[1],rv2[2],rv2[3] )) end) registerOperator("add", "as", "s", function(self, args) @@ -163,7 +169,7 @@ registerOperator("add", "as", "s", function(self, args) self.prf = self.prf + #rv2*0.01 - return ("[%s,%s,%s]%s"):format( rv1[1],rv1[2],rv1[3],rv2) + return limitlen(("[%s,%s,%s]%s"):format( rv1[1],rv1[2],rv1[3],rv2)) end) /******************************************************************************/ @@ -313,7 +319,8 @@ registerFunction("repeat", "s:n", "s", function(self,args) local op1, op2 = args[2], args[3] local rv1, rv2 = op1[1](self, op1), math.abs(op2[1](self, op2)) self.prf = self.prf + #rv1 * rv2 * 0.01 - return rv1:rep(rv2) + assert(#rv1*rv2<1024*1024,"string too long") + return limitlen(rv1:rep(rv2)) end) registerFunction("trim", "s:", "s", function(self,args) @@ -376,17 +383,17 @@ end --- Finds and replaces every occurrence of with without regular expressions e2function string string:replace(string needle, string new) if needle == "" then return this end - return this:Replace( needle, new) + return limitlen(this:Replace( limitlen(needle), limitlen(new))) end --- Finds and replaces every occurrence of with using regular expressions. Prints malformed string errors to the chat area. e2function string string:replaceRE(string pattern, string new) - local OK, NewStr = pcall(gsub, this, pattern, new) + local OK, NewStr = pcall(gsub, this, limitlen(pattern), limitlen(new)) if not OK then self.player:ChatPrint(NewStr) return "" else - return NewStr or "" + return limitlen(NewStr) or "" end end @@ -426,7 +433,7 @@ e2function string format(string fmt, ...) self.player:ChatPrint(ret) return "" end - return ret + return limitlen(ret) end /******************************************************************************/ From 74c14014a30e3993b2da6c98a5786f2ebb078e1e Mon Sep 17 00:00:00 2001 From: FailCake Date: Thu, 20 Feb 2020 19:56:36 +0000 Subject: [PATCH 39/56] Spent so much time in this code, but wire community being wire, no one cared. This is better than streamcore --- .../gmod_wire_expression2/core/cl_sound.lua | 369 ++++++++++++++++++ .../gmod_wire_expression2/core/sound.lua | 331 ++++++++++++---- 2 files changed, 623 insertions(+), 77 deletions(-) create mode 100644 lua/entities/gmod_wire_expression2/core/cl_sound.lua diff --git a/lua/entities/gmod_wire_expression2/core/cl_sound.lua b/lua/entities/gmod_wire_expression2/core/cl_sound.lua new file mode 100644 index 0000000000..36c59dd4f9 --- /dev/null +++ b/lua/entities/gmod_wire_expression2/core/cl_sound.lua @@ -0,0 +1,369 @@ +local E2Sounds = {} +local BlockedPlayers = {} + +local wire_expression2_sound_enabled = CreateConVar( "wire_expression2_sound_enabled_cl", 2, {FCVAR_ARCHIVE},"2: Anyone's sounds can be heard, 1: Only friend's sounds will be heard, 0: Only your own sounds will be heard") +cvars.AddChangeCallback("wire_expression2_sound_enabled_cl", function(name, old, new) + if new~=2 then + for k,v in pairs(E2Sounds) do + v.SoundChannel:Stop() + end + E2Sounds = {} + end +end) + +local function doPlayerBlocking(args, cb) + local name = args[1]:lower() + local players = E2Lib.filterList(player.GetAll(), function(ent) return ent:GetName():lower():match(name) end) + if #players == 1 then + cb(players[1]) + elseif #players > 1 then + ply:PrintMessage( HUD_PRINTCONSOLE, "More than one player matches that name!" ) + else + ply:PrintMessage( HUD_PRINTCONSOLE, "No player names found with " .. args[1] ) + end +end + +concommand.Add("wire_expression2_sound_blockplayer",function(ply,com,args) + doPlayerBlocking(args, function(found) + BlockedPlayers[found:SteamID()] = true + + for k,v in pairs(E2Sounds) do + if v.Player == found then + v.SoundChannel:Stop() + E2Sounds[k] = nil + end + end + end) +end) + +concommand.Add("wire_expression2_sound_unblockplayer",function(ply,com,args) + doPlayerBlocking(args, function(found) + BlockedPlayers[found:SteamID()] = nil + end) +end ) + +local function moveSounds() + for k,v in pairs(E2Sounds) do + if v.SoundChannel then + if v.IsBass and v.SoundChannel:IsValid() then + if IsValid(v.Entity) then + v.SoundChannel:SetPos(v.Entity:GetPos()) + else + v.SoundChannel:Stop() + E2Sounds[k] = nil + end + end + if not v.IsBass or (v.IsBass and v.SoundChannel:IsValid()) then + if v.FadePitchStart then + local t = (CurTime() - v.FadePitchStart)/v.FadePitchTime + local inter = v.OriginalPitch + v.DeltaPitch*t + if t>=1 then + v.SoundChannel:SetPlaybackRate(v.OriginalPitch + v.DeltaPitch) + v.FadePitchStart = nil + else + v.SoundChannel:SetPlaybackRate(inter) + end + end + if v.FadeVolumeStart then + local t = (CurTime() - v.FadeVolumeStart)/v.FadeVolumeTime + local inter = v.OriginalVolume + v.DeltaVolume*t + if t>=1 then + v.SoundChannel:SetVolume(v.OriginalVolume + v.DeltaVolume) + v.FadeVolumeStart = nil + else + v.SoundChannel:SetVolume(inter) + end + end + if v.DieTime then + if CurTime()>=v.DieTime then + v.SoundChannel:Stop() + v.DieTime = nil + E2Sounds[k] = nil + end + end + end + end + end + + if not next(E2Sounds) then + hook.Remove("Think", "E2_move_sounds") + end +end + +local CSSoundMeta = FindMetaTable("CSoundPatch") +CSSoundMeta.SetVolume = CSSoundMeta.ChangeVolume +CSSoundMeta.SetPlaybackRate = CSSoundMeta.ChangePitch + +local function setFadePitch(sound, pitch, time) + sound.FadePitchStart = CurTime() + sound.FadePitchTime = math.max(time,0.01) + sound.OriginalPitch = sound.SoundChannel:GetPlaybackRate() + sound.DeltaPitch = pitch - sound.OriginalPitch +end + +local function setFadeVolume(sound, volume, time) + sound.FadeVolumeStart = CurTime() + sound.FadeVolumeTime = math.max(time,0.01) + sound.OriginalVolume = sound.SoundChannel:GetVolume() + sound.DeltaVolume = volume - sound.OriginalVolume +end + +local netFuncs = { + Play = function() return net.ReadDouble(), net.ReadEntity() end, + Pause = function() end, + Resume = function() end, + Stop = function() return net.ReadDouble() end, + StopNoTime = function() end, + ChangeVolume = function() return net.ReadDouble(), net.ReadDouble() end, + ChangePitch = function() return net.ReadDouble(), net.ReadDouble() end, + ChangeFadeDistance = function() return net.ReadDouble(), net.ReadDouble() end, + SetLooping = function() return net.ReadUInt(8) end, + SetTime = function() return net.ReadUInt(32) end, +} + +local funcLookup = { + "Create", + "Pause", + "Resume", + "Stop", + "StopNoTime", + "ChangeVolume", + "ChangePitch", + "ChangeFadeDistance", + "SetLooping", + "SetTime" +} + +local bassNetFunctions = { + Play = function(sound, time, ent) + sound.SoundChannel:Play() + sound.Entity = ent + if time > 0 then + sound.DieTime = CurTime() + time + end + end, + Pause = function(sound) + sound.SoundChannel:Pause() + end, + Resume = function(sound) + sound.SoundChannel:Play() + end, + Stop = function(sound, time) + sound.DieTime = CurTime() + time + setFadeVolume(sound, 0, time) + end, + StopNoTime = function(sound) + sound.SoundChannel:Stop() + E2Sounds[sound.Index] = nil + end, + ChangeVolume = function(sound, volume, time) + if sound.SoundChannel then + if time > 0 then + setFadeVolume(sound, volume, time) + else + sound.SoundChannel:SetVolume(volume) + end + else + sound.StartVolume = volume + end + end, + ChangePitch = function(sound, rate, time) + rate = sound.IsBass and math.Clamp( rate, 0, 400 ) / 100 or math.Clamp( rate, 0, 255 ) + if sound.SoundChannel then + if time > 0 then + setFadePitch(sound, rate, time) + else + sound.SoundChannel:SetPlaybackRate(rate) + end + else + sound.StartPitch = rate + end + end, + ChangeFadeDistance = function(sound, min, max) + sound.SoundChannel:Set3DFadeDistance(min, max) + end, + SetLooping = function(sound, loop ) + sound.SoundChannel:EnableLooping( loop~=0 ) + end, + SetTime = function(sound, time) + sound.SoundChannel:SetTime( time ) + end +} + +local gmodSoundFuncs = { + Play = bassNetFunctions.Play, + Stop = bassNetFunctions.Stop, + ChangeVolume = bassNetFunctions.ChangeVolume, + ChangePitch = bassNetFunctions.ChangePitch +} + +local function loadSound(index) + + local soundtbl = E2Sounds[index] + local path = soundtbl.Path + + if soundtbl.IsBass then + sound.PlayURL(path, "3d mono noblock", function(channel, er, ername) + + if IsValid(channel) then + + if E2Sounds[index] and IsValid(soundtbl.Entity) then + + if soundtbl.SoundChannel then + soundtbl.SoundChannel:Stop() + end + + soundtbl.SoundChannel = channel + channel:SetPos(soundtbl.Entity:GetPos()) + + if soundtbl.Pitch then + channel:SetPlaybackRate(math.Clamp( soundtbl.Pitch, 0, 400 ) / 100) + end + + if soundtbl.Volume then + channel:SetVolume( math.Clamp( soundtbl.Volume, 0, 1 )) + end + + // Execute the QUEUED Stuff. + local queue = soundtbl.Queue + if queue then + for I=1, #queue do + queue[I].Func(soundtbl, unpack(queue[I].Arg)) + end + soundtbl.Queue = nil + end + + if soundtbl.Length > 0 then + E2Sounds[index].DieTime = CurTime() + soundtbl.Length + end + soundtbl.Length = 0 + else + channel:Stop() + E2Sounds[index] = nil + end + else + LocalPlayer():PrintMessage( HUD_PRINTCONSOLE, "[E2] Failed to play sound: " .. path .. " | BASS_ERROR : " .. ername .."\n") + + if er == -1 then // BASS_ERROR_UNKNOWN , its usually because the sound isnt mono and 3D requires that, (mono) tag doesn't seem to affect it. + LocalPlayer():PrintMessage( HUD_PRINTCONSOLE, "[E2] Please make sure the HTTP sound is MONO.\n") + end + + E2Sounds[index] = nil + end + + end) + else + if E2Sounds[index] != nil and IsValid(soundtbl.Entity) then + local s = Sound(path) + local newsound = CreateSound(soundtbl.Entity, s) + if !newsound then E2Sounds[index] = nil return end + + --For some reason trying to stop the sound after the entity is dead won't work + soundtbl.Entity:CallOnRemove("E2SoundRemove"..index, function() + newsound:Stop() + end) + + soundtbl.SoundChannel = newsound + + --Check for a starting volume or pitch + local queue = soundtbl.Queue + if queue then + for k, tbl in pairs(queue) do + if tbl.Func == gmodSoundFuncs.ChangeVolume or tbl.Func == gmodSoundFuncs.ChangePitch then + tbl.Func(soundtbl, unpack(tbl.Arg)) + queue[k] = nil + end + end + end + + newsound:PlayEx(soundtbl.StartVolume or 1, soundtbl.StartPitch or 100) + + if queue then + for k, tbl in pairs(queue) do + tbl.Func(soundtbl, unpack(tbl.Arg)) + end + soundtbl.Queue = nil + end + + if soundtbl.Length > 0 then + E2Sounds[index].DieTime = CurTime() + soundtbl.Length + end + soundtbl.Length = 0 + end + end + +end + +local createList = {} +local function createSound(index) + + local path = net.ReadString() + local time = net.ReadDouble() + local ent = net.ReadEntity() + local ply = net.ReadEntity() + + if not IsValid(ent) or not IsValid(ply) then return end + if wire_expression2_sound_enabled:GetInt()==1 and ply:GetFriendStatus()~="friend" and ply~=LocalPlayer() then return end + if BlockedPlayers[ply:SteamID()] then return end + + if not next(E2Sounds) then + hook.Add("Think", "E2_move_sounds",moveSounds) + end + + // Delete old one + if E2Sounds[index] and E2Sounds[index].SoundChannel then + E2Sounds[index].SoundChannel:Stop() + end + + local bass = false + if path:sub(1,4) == "http" || path:sub(1,3) == "www" then + bass = true + end + + E2Sounds[index] = {SoundChannel = nil, Entity = ent, Player = ply, Queue = {}, Path = path, Length = time, Index = index, IsBass = bass} + createList[#createList + 1] = index + +end + +local function decideFunction(index,func) + if func == "Create" then + createSound(index) + else + local sound = E2Sounds[index] + local netdata = netFuncs[func] + if sound then + local soundFunc = sound.IsBass and bassNetFunctions[func] or gmodSoundFuncs[func] + if soundFunc then + if sound.SoundChannel then + soundFunc(sound, netdata()) // Execute the sound Function + elseif sound.Queue then // QUEUE it + sound.Queue[#sound.Queue+1] = {Func = soundFunc, Arg = {netdata()}} + end + end + else + netdata() + end + end +end + + +net.Receive("e2_soundrequest",function() + + local access = wire_expression2_sound_enabled:GetInt() + if access==0 then return end + + local numRequests = math.Clamp(net.ReadUInt(32),0,100) + for I=1, numRequests do + local index = net.ReadString() + local funcLook = funcLookup[net.ReadUInt(8)] + if not funcLook then return end + + decideFunction(index, funcLook) + end + + for I=1, #createList do + loadSound(createList[I]) + end + createList = {} + +end) \ No newline at end of file diff --git a/lua/entities/gmod_wire_expression2/core/sound.lua b/lua/entities/gmod_wire_expression2/core/sound.lua index 10135044cb..2329b3f411 100644 --- a/lua/entities/gmod_wire_expression2/core/sound.lua +++ b/lua/entities/gmod_wire_expression2/core/sound.lua @@ -7,20 +7,168 @@ E2Lib.RegisterExtension("sound", true, "Allows E2s to play sounds.", "Sounds can local wire_expression2_maxsounds = CreateConVar( "wire_expression2_maxsounds", 16, {FCVAR_ARCHIVE} ) local wire_expression2_sound_burst_max = CreateConVar( "wire_expression2_sound_burst_max", 8, {FCVAR_ARCHIVE} ) local wire_expression2_sound_burst_rate = CreateConVar( "wire_expression2_sound_burst_rate", 0.1, {FCVAR_ARCHIVE} ) +local wire_expression2_sound_allowurl = CreateConVar( "wire_expression2_sound_allowurl", 1, {FCVAR_ARCHIVE} ) + +util.AddNetworkString("e2_soundrequest") + +--------------------------------------------------------------- +-- Client-side sound class +--------------------------------------------------------------- + +local ClientSideSound = {} +ClientSideSound.mt = {__index = ClientSideSound} + +ClientSideSound.SendRequests = {} + +ClientSideSound.SendFuncs = { + Create = function(self, time, ent, ply) + net.WriteString(self.path) + net.WriteDouble(time) + net.WriteEntity(ent) + net.WriteEntity(ply) + end, + Pause = function(self) + end, + Resume = function(self) + end, + Stop = function(self, time) + net.WriteDouble(time) + end, + StopNoTime = function(self) + end, + ChangeVolume = function(self, vol, time) + net.WriteDouble(vol) + net.WriteDouble(time) + end, + ChangePitch = function(self, pitch, time) + net.WriteDouble(pitch) + net.WriteDouble(time) + end, + ChangeFadeDistance = function(self, min, max) + net.WriteDouble(min) + net.WriteDouble(max) + end, + SetLooping = function(self, val) + net.WriteUInt(val, 8) + end, + SetTime = function(self, val) + net.WriteUInt(val, 32) + end +} + +ClientSideSound.SendFuncsLookup = { + Create = 1, + Pause = 2, + Resume = 3, + Stop = 4, + StopNoTime = 5, + ChangeVolume = 6, + ChangePitch = 7, + ChangeFadeDistance = 8, + SetLooping = 9, + SetTime = 10, +} + +function ClientSideSound.CreateSound( path, time, index, entity, e2, pitch, volume) + + local self = setmetatable({},ClientSideSound.mt) + self.index = e2:EntIndex() .. "_" .. index + self.path = path + self.entity = entity + self:SendRequest("Create",time,entity,e2:GetPlayer()) + if pitch then + self:SendRequest("ChangePitch", pitch, 0) + end + if volume then + self:SendRequest("ChangeVolume", volume, 0) + end + + return self +end + +function ClientSideSound:SendRequest(request, ...) + local len = #ClientSideSound.SendRequests + if len>=100 then return end + ClientSideSound.SendRequests[len + 1] = {Func = request, Arg = {self, ...}} +end + +function ClientSideSound.Broadcast() + + local numReq = #ClientSideSound.SendRequests + if numReq > 0 then + net.Start("e2_soundrequest") + net.WriteUInt(numReq, 32) + for I=1, numReq do + local Request = ClientSideSound.SendRequests[I] + net.WriteString(Request.Arg[1].index) + net.WriteUInt(ClientSideSound.SendFuncsLookup[Request.Func],8) + ClientSideSound.SendFuncs[Request.Func](unpack(Request.Arg)) + end + net.Broadcast() + ClientSideSound.SendRequests = {} + end + +end + +function ClientSideSound:Pause() + self:SendRequest("Pause") +end + +function ClientSideSound:Resume() + self:SendRequest("Resume") +end + +function ClientSideSound:Stop(time) + if time == 0 then + self:SendRequest("StopNoTime") + else + self:SendRequest("Stop",time) + end +end + +function ClientSideSound:ChangeVolume(vol, time) + self:SendRequest("ChangeVolume", vol, time) +end + +function ClientSideSound:ChangePitch(pitch, time) + self:SendRequest("ChangePitch",pitch,time) +end + +function ClientSideSound:ChangeFadeDistance(min, max) + self:SendRequest("ChangeFadeDistance",min,max) +end + +function ClientSideSound:SetLooping(val) + self:SendRequest("SetLooping",val) +end + +function ClientSideSound:SetTime(val) + self:SendRequest("SetTime",val) +end --------------------------------------------------------------- -- Helper functions --------------------------------------------------------------- local function isAllowed( self ) - local data = self.data.sound_data - local count = data.count - if count == wire_expression2_maxsounds:GetInt() then return false end + local data = self.data.sound_data + if data.count >= wire_expression2_maxsounds:GetInt() then + --See if there are any dead sounds + for _, sound in pairs(data.sounds) do + if (sound.DieTime and CurTime() >= sound.DieTime) or not IsValid(sound.entity) then + data.sounds[ _ ] = nil + data.count = data.count - 1 + end + end + if data.count >= wire_expression2_maxsounds:GetInt() then + return false + end + end + if data.burst == 0 then return false end - data.burst = data.burst - 1 - + local timerid = "E2_sound_burst_count_" .. self.entity:EntIndex() if not timer.Exists( timerid ) then timer.Create( timerid, wire_expression2_sound_burst_rate:GetFloat(), 0, function() @@ -28,92 +176,71 @@ local function isAllowed( self ) timer.Remove( timerid ) return end - + data.burst = data.burst + 1 if data.burst == wire_expression2_sound_burst_max:GetInt() then timer.Remove( timerid ) end end) end - + return true end +local function clearSound( data, sound ) + sound:Stop( 0 ) + data.sounds[sound.index] = nil + data.count = data.count - 1 +end + local function getSound( self, index ) if isnumber( index ) then index = math.floor( index ) end return self.data.sound_data.sounds[index] end -local function soundStop(self, index, fade) - local sound = getSound( self, index ) - if not sound then return end - - fade = math.abs( fade ) - - if fade == 0 then - sound:Stop() +local function soundCreate(self, entity, index, time, path, pitch, volume) - if isnumber( index ) then index = math.floor( index ) end - self.data.sound_data.sounds[index] = nil - - self.data.sound_data.count = self.data.sound_data.count - 1 + if isnumber( index ) then index = math.floor( index ) end + local data = self.data.sound_data + local oldsound = getSound( self, index ) + if oldsound then + clearSound( data, oldsound ) + end + + if not isAllowed( self ) then return end + + if path:sub(1,4)=="http" || path:sub(1,3) == "www" then + if wire_expression2_sound_allowurl:GetInt()==0 then return end else - sound:FadeOut( fade ) - - timer.Simple( fade, function() soundStop( self, index, 0 ) end) + if path:match('["?]') then return end + path = path:Trim() + path = path:gsub( "\\", "/" ) end - - timer.Remove( "E2_sound_stop_" .. self.entity:EntIndex() .. "_" .. index ) -end - -local function soundCreate(self, entity, index, time, path, fade) - if path:match('["?]') then return end + + if isnumber( index ) then index = math.floor( index ) end local data = self.data.sound_data - if not isAllowed( self ) then return end - - path = path:Trim() - path = path:gsub( "\\", "/" ) - if isnumber( index ) then index = math.floor( index ) end + + local oldsound = getSound( self, index ) - local timerid = "E2_sound_stop_" .. self.entity:EntIndex() .. "_" .. index - - local sound = getSound( self, index ) - if sound then - sound:Stop() - timer.Remove( timerid ) + if oldsound then + oldsound:Stop(0) // The sound is overwriten, we don't need to increase the count since we are using the same "sound spot" else data.count = data.count + 1 end - - local sound = CreateSound( entity, path ) + + local sound = ClientSideSound.CreateSound(path,time,index,entity,self.entity,pitch,volume) data.sounds[index] = sound - sound:Play() - - entity:CallOnRemove( "E2_stopsound", function() - soundStop( self, index, 0 ) - end ) - - if time == 0 and fade == 0 then return end - time = math.abs( time ) - - timer.Create( timerid, time, 1, function() - if not self or not IsValid( self.entity ) or not IsValid( entity ) then return end - - soundStop( self, index, fade ) - end) + end local function soundPurge( self ) + local sound_data = self.data.sound_data if sound_data.sounds then for k,v in pairs( sound_data.sounds ) do - v:Stop() - timer.Remove( "E2_sound_stop_" .. self.entity:EntIndex() .. "_" .. k ) + clearSound( sound_data, v ) end end - - sound_data.sounds = {} - sound_data.count = 0 end --------------------------------------------------------------- @@ -123,28 +250,27 @@ end __e2setcost(25) e2function void soundPlay( index, duration, string path ) - soundCreate(self,self.entity,index,duration,path,0) + soundCreate(self,self.entity,index,duration,path) end e2function void entity:soundPlay( index, duration, string path) if not IsValid(this) or not isOwner(self, this) then return end - soundCreate(self,this,index,duration,path,0) + soundCreate(self,this,index,duration,path) end -e2function void soundPlay( index, duration, string path, fade ) - soundCreate(self,self.entity,index,duration,path,fade) +e2function void soundPlay( index, duration, string path, pitch, volume ) + soundCreate(self,self.entity,index,duration,path,pitch,volume) end -e2function void entity:soundPlay( index, duration, string path, fade ) +e2function void entity:soundPlay( index, duration, string path, pitch, volume ) if not IsValid(this) or not isOwner(self, this) then return end - soundCreate(self,this,index,duration,path,fade) + soundCreate(self,this,index,duration,path,pitch,volume) end e2function void soundPlay( string index, duration, string path ) = e2function void soundPlay( index, duration, string path ) e2function void entity:soundPlay( string index, duration, string path ) = e2function void entity:soundPlay( index, duration, string path ) e2function void soundPlay( string index, duration, string path, fade ) = e2function void soundPlay( index, duration, string path, fade ) -e2function void entity:soundPlay( string index, duration, string path, fade ) = e2function void entity:soundPlay( index, duration, string path, fade ) - +e2function void entity:soundPlay( string index, duration, string path, pitch, volume ) = e2function void entity:soundPlay( index, duration, string path, pitch, volume ) --------------------------------------------------------------- -- Modifier functions --------------------------------------------------------------- @@ -152,50 +278,96 @@ e2function void entity:soundPlay( string index, duration, string path, fade ) = __e2setcost(5) e2function void soundStop( index ) - soundStop(self, index, 0) + local sound = getSound( self, index ) + if not sound then return end + + clearSound( self.data.sound_data, sound ) end e2function void soundStop( index, fadetime ) - soundStop(self, index, fadetime) + local sound = getSound( self, index ) + if not sound then return end + + fadetime = math.abs( fadetime ) + sound.DieTime = CurTime() + fadetime // Fade seems to take a little longer to remove the sound + sound:Stop(fadetime) end -e2function void soundVolume( index, volume ) +e2function void soundPause( index ) local sound = getSound( self, index ) if not sound then return end + + sound:Pause() +end +e2function void soundResume( index ) + local sound = getSound( self, index ) + if not sound then return end + + sound:Resume() +end + +e2function void soundVolume( index, volume ) + local sound = getSound( self, index ) + if not sound then return end + sound:ChangeVolume( math.Clamp( volume, 0, 1 ), 0 ) end e2function void soundVolume( index, volume, fadetime ) local sound = getSound( self, index ) if not sound then return end - + sound:ChangeVolume( math.Clamp( volume, 0, 1 ), math.abs( fadetime ) ) end - - + e2function void soundPitch( index, pitch ) local sound = getSound( self, index ) if not sound then return end - - sound:ChangePitch( math.Clamp( pitch, 0, 255 ), 0 ) + + sound:ChangePitch( pitch, 0 ) end e2function void soundPitch( index, pitch, fadetime ) local sound = getSound( self, index ) if not sound then return end + sound:ChangePitch( pitch, math.abs( fadetime ) ) +end - sound:ChangePitch( math.Clamp( pitch, 0, 255 ), math.abs( fadetime ) ) +e2function void soundFadeDistance( index, min, max ) + local sound = getSound( self, index ) + if not sound then return end + + sound:ChangeFadeDistance( math.Clamp(min,50,1000), math.Clamp(max,10000,200000) ) end +e2function void soundLoop( index, val ) + local sound = getSound( self, index ) + if not sound then return end + + sound:SetLooping( val ) +end + +e2function void soundTime( index, val ) + local sound = getSound( self, index ) + if not sound then return end + + sound:SetTime( val ) +end e2function void soundStop( string index ) = e2function void soundStop( index ) e2function void soundStop( string index, fadetime ) = e2function void soundStop( index, fadetime ) +e2function void soundPause( string index ) = e2function void soundPause( index ) +e2function void soundResume( string index ) = e2function void soundResume( index ) e2function void soundVolume( string index, volume ) = e2function void soundVolume( index, volume ) e2function void soundVolume( string index, volume, fadetime ) = e2function void soundVolume( index, volume, fadetime ) + e2function void soundPitch( string index, pitch ) = e2function void soundPitch( index, pitch ) e2function void soundPitch( string index, pitch, fadetime ) = e2function void soundPitch( index, pitch, fadetime ) +e2function void soundFadeDistance( string index, min, max ) = e2function void soundFadeDistance( index, min, max ) +e2function void soundLoop( string index, bool ) = e2function void soundLoop( index, bool ) +e2function void soundTime( string index, val ) = e2function void soundTime( index, val ) --------------------------------------------------------------- -- Other --------------------------------------------------------------- @@ -219,4 +391,9 @@ end) registerCallback("destruct", function(self) soundPurge( self ) + ClientSideSound.Broadcast() end) + +registerCallback("postexecute",function(self) + ClientSideSound.Broadcast() +end) \ No newline at end of file From ca4d064f2678686152b6b473939f87a028c9af54 Mon Sep 17 00:00:00 2001 From: Python1320 Date: Sat, 22 Feb 2020 13:26:31 +0200 Subject: [PATCH 40/56] Revert "HTTP soundPlay" --- .../gmod_wire_expression2/core/cl_sound.lua | 369 ------------------ .../gmod_wire_expression2/core/sound.lua | 331 ++++------------ 2 files changed, 77 insertions(+), 623 deletions(-) delete mode 100644 lua/entities/gmod_wire_expression2/core/cl_sound.lua diff --git a/lua/entities/gmod_wire_expression2/core/cl_sound.lua b/lua/entities/gmod_wire_expression2/core/cl_sound.lua deleted file mode 100644 index 36c59dd4f9..0000000000 --- a/lua/entities/gmod_wire_expression2/core/cl_sound.lua +++ /dev/null @@ -1,369 +0,0 @@ -local E2Sounds = {} -local BlockedPlayers = {} - -local wire_expression2_sound_enabled = CreateConVar( "wire_expression2_sound_enabled_cl", 2, {FCVAR_ARCHIVE},"2: Anyone's sounds can be heard, 1: Only friend's sounds will be heard, 0: Only your own sounds will be heard") -cvars.AddChangeCallback("wire_expression2_sound_enabled_cl", function(name, old, new) - if new~=2 then - for k,v in pairs(E2Sounds) do - v.SoundChannel:Stop() - end - E2Sounds = {} - end -end) - -local function doPlayerBlocking(args, cb) - local name = args[1]:lower() - local players = E2Lib.filterList(player.GetAll(), function(ent) return ent:GetName():lower():match(name) end) - if #players == 1 then - cb(players[1]) - elseif #players > 1 then - ply:PrintMessage( HUD_PRINTCONSOLE, "More than one player matches that name!" ) - else - ply:PrintMessage( HUD_PRINTCONSOLE, "No player names found with " .. args[1] ) - end -end - -concommand.Add("wire_expression2_sound_blockplayer",function(ply,com,args) - doPlayerBlocking(args, function(found) - BlockedPlayers[found:SteamID()] = true - - for k,v in pairs(E2Sounds) do - if v.Player == found then - v.SoundChannel:Stop() - E2Sounds[k] = nil - end - end - end) -end) - -concommand.Add("wire_expression2_sound_unblockplayer",function(ply,com,args) - doPlayerBlocking(args, function(found) - BlockedPlayers[found:SteamID()] = nil - end) -end ) - -local function moveSounds() - for k,v in pairs(E2Sounds) do - if v.SoundChannel then - if v.IsBass and v.SoundChannel:IsValid() then - if IsValid(v.Entity) then - v.SoundChannel:SetPos(v.Entity:GetPos()) - else - v.SoundChannel:Stop() - E2Sounds[k] = nil - end - end - if not v.IsBass or (v.IsBass and v.SoundChannel:IsValid()) then - if v.FadePitchStart then - local t = (CurTime() - v.FadePitchStart)/v.FadePitchTime - local inter = v.OriginalPitch + v.DeltaPitch*t - if t>=1 then - v.SoundChannel:SetPlaybackRate(v.OriginalPitch + v.DeltaPitch) - v.FadePitchStart = nil - else - v.SoundChannel:SetPlaybackRate(inter) - end - end - if v.FadeVolumeStart then - local t = (CurTime() - v.FadeVolumeStart)/v.FadeVolumeTime - local inter = v.OriginalVolume + v.DeltaVolume*t - if t>=1 then - v.SoundChannel:SetVolume(v.OriginalVolume + v.DeltaVolume) - v.FadeVolumeStart = nil - else - v.SoundChannel:SetVolume(inter) - end - end - if v.DieTime then - if CurTime()>=v.DieTime then - v.SoundChannel:Stop() - v.DieTime = nil - E2Sounds[k] = nil - end - end - end - end - end - - if not next(E2Sounds) then - hook.Remove("Think", "E2_move_sounds") - end -end - -local CSSoundMeta = FindMetaTable("CSoundPatch") -CSSoundMeta.SetVolume = CSSoundMeta.ChangeVolume -CSSoundMeta.SetPlaybackRate = CSSoundMeta.ChangePitch - -local function setFadePitch(sound, pitch, time) - sound.FadePitchStart = CurTime() - sound.FadePitchTime = math.max(time,0.01) - sound.OriginalPitch = sound.SoundChannel:GetPlaybackRate() - sound.DeltaPitch = pitch - sound.OriginalPitch -end - -local function setFadeVolume(sound, volume, time) - sound.FadeVolumeStart = CurTime() - sound.FadeVolumeTime = math.max(time,0.01) - sound.OriginalVolume = sound.SoundChannel:GetVolume() - sound.DeltaVolume = volume - sound.OriginalVolume -end - -local netFuncs = { - Play = function() return net.ReadDouble(), net.ReadEntity() end, - Pause = function() end, - Resume = function() end, - Stop = function() return net.ReadDouble() end, - StopNoTime = function() end, - ChangeVolume = function() return net.ReadDouble(), net.ReadDouble() end, - ChangePitch = function() return net.ReadDouble(), net.ReadDouble() end, - ChangeFadeDistance = function() return net.ReadDouble(), net.ReadDouble() end, - SetLooping = function() return net.ReadUInt(8) end, - SetTime = function() return net.ReadUInt(32) end, -} - -local funcLookup = { - "Create", - "Pause", - "Resume", - "Stop", - "StopNoTime", - "ChangeVolume", - "ChangePitch", - "ChangeFadeDistance", - "SetLooping", - "SetTime" -} - -local bassNetFunctions = { - Play = function(sound, time, ent) - sound.SoundChannel:Play() - sound.Entity = ent - if time > 0 then - sound.DieTime = CurTime() + time - end - end, - Pause = function(sound) - sound.SoundChannel:Pause() - end, - Resume = function(sound) - sound.SoundChannel:Play() - end, - Stop = function(sound, time) - sound.DieTime = CurTime() + time - setFadeVolume(sound, 0, time) - end, - StopNoTime = function(sound) - sound.SoundChannel:Stop() - E2Sounds[sound.Index] = nil - end, - ChangeVolume = function(sound, volume, time) - if sound.SoundChannel then - if time > 0 then - setFadeVolume(sound, volume, time) - else - sound.SoundChannel:SetVolume(volume) - end - else - sound.StartVolume = volume - end - end, - ChangePitch = function(sound, rate, time) - rate = sound.IsBass and math.Clamp( rate, 0, 400 ) / 100 or math.Clamp( rate, 0, 255 ) - if sound.SoundChannel then - if time > 0 then - setFadePitch(sound, rate, time) - else - sound.SoundChannel:SetPlaybackRate(rate) - end - else - sound.StartPitch = rate - end - end, - ChangeFadeDistance = function(sound, min, max) - sound.SoundChannel:Set3DFadeDistance(min, max) - end, - SetLooping = function(sound, loop ) - sound.SoundChannel:EnableLooping( loop~=0 ) - end, - SetTime = function(sound, time) - sound.SoundChannel:SetTime( time ) - end -} - -local gmodSoundFuncs = { - Play = bassNetFunctions.Play, - Stop = bassNetFunctions.Stop, - ChangeVolume = bassNetFunctions.ChangeVolume, - ChangePitch = bassNetFunctions.ChangePitch -} - -local function loadSound(index) - - local soundtbl = E2Sounds[index] - local path = soundtbl.Path - - if soundtbl.IsBass then - sound.PlayURL(path, "3d mono noblock", function(channel, er, ername) - - if IsValid(channel) then - - if E2Sounds[index] and IsValid(soundtbl.Entity) then - - if soundtbl.SoundChannel then - soundtbl.SoundChannel:Stop() - end - - soundtbl.SoundChannel = channel - channel:SetPos(soundtbl.Entity:GetPos()) - - if soundtbl.Pitch then - channel:SetPlaybackRate(math.Clamp( soundtbl.Pitch, 0, 400 ) / 100) - end - - if soundtbl.Volume then - channel:SetVolume( math.Clamp( soundtbl.Volume, 0, 1 )) - end - - // Execute the QUEUED Stuff. - local queue = soundtbl.Queue - if queue then - for I=1, #queue do - queue[I].Func(soundtbl, unpack(queue[I].Arg)) - end - soundtbl.Queue = nil - end - - if soundtbl.Length > 0 then - E2Sounds[index].DieTime = CurTime() + soundtbl.Length - end - soundtbl.Length = 0 - else - channel:Stop() - E2Sounds[index] = nil - end - else - LocalPlayer():PrintMessage( HUD_PRINTCONSOLE, "[E2] Failed to play sound: " .. path .. " | BASS_ERROR : " .. ername .."\n") - - if er == -1 then // BASS_ERROR_UNKNOWN , its usually because the sound isnt mono and 3D requires that, (mono) tag doesn't seem to affect it. - LocalPlayer():PrintMessage( HUD_PRINTCONSOLE, "[E2] Please make sure the HTTP sound is MONO.\n") - end - - E2Sounds[index] = nil - end - - end) - else - if E2Sounds[index] != nil and IsValid(soundtbl.Entity) then - local s = Sound(path) - local newsound = CreateSound(soundtbl.Entity, s) - if !newsound then E2Sounds[index] = nil return end - - --For some reason trying to stop the sound after the entity is dead won't work - soundtbl.Entity:CallOnRemove("E2SoundRemove"..index, function() - newsound:Stop() - end) - - soundtbl.SoundChannel = newsound - - --Check for a starting volume or pitch - local queue = soundtbl.Queue - if queue then - for k, tbl in pairs(queue) do - if tbl.Func == gmodSoundFuncs.ChangeVolume or tbl.Func == gmodSoundFuncs.ChangePitch then - tbl.Func(soundtbl, unpack(tbl.Arg)) - queue[k] = nil - end - end - end - - newsound:PlayEx(soundtbl.StartVolume or 1, soundtbl.StartPitch or 100) - - if queue then - for k, tbl in pairs(queue) do - tbl.Func(soundtbl, unpack(tbl.Arg)) - end - soundtbl.Queue = nil - end - - if soundtbl.Length > 0 then - E2Sounds[index].DieTime = CurTime() + soundtbl.Length - end - soundtbl.Length = 0 - end - end - -end - -local createList = {} -local function createSound(index) - - local path = net.ReadString() - local time = net.ReadDouble() - local ent = net.ReadEntity() - local ply = net.ReadEntity() - - if not IsValid(ent) or not IsValid(ply) then return end - if wire_expression2_sound_enabled:GetInt()==1 and ply:GetFriendStatus()~="friend" and ply~=LocalPlayer() then return end - if BlockedPlayers[ply:SteamID()] then return end - - if not next(E2Sounds) then - hook.Add("Think", "E2_move_sounds",moveSounds) - end - - // Delete old one - if E2Sounds[index] and E2Sounds[index].SoundChannel then - E2Sounds[index].SoundChannel:Stop() - end - - local bass = false - if path:sub(1,4) == "http" || path:sub(1,3) == "www" then - bass = true - end - - E2Sounds[index] = {SoundChannel = nil, Entity = ent, Player = ply, Queue = {}, Path = path, Length = time, Index = index, IsBass = bass} - createList[#createList + 1] = index - -end - -local function decideFunction(index,func) - if func == "Create" then - createSound(index) - else - local sound = E2Sounds[index] - local netdata = netFuncs[func] - if sound then - local soundFunc = sound.IsBass and bassNetFunctions[func] or gmodSoundFuncs[func] - if soundFunc then - if sound.SoundChannel then - soundFunc(sound, netdata()) // Execute the sound Function - elseif sound.Queue then // QUEUE it - sound.Queue[#sound.Queue+1] = {Func = soundFunc, Arg = {netdata()}} - end - end - else - netdata() - end - end -end - - -net.Receive("e2_soundrequest",function() - - local access = wire_expression2_sound_enabled:GetInt() - if access==0 then return end - - local numRequests = math.Clamp(net.ReadUInt(32),0,100) - for I=1, numRequests do - local index = net.ReadString() - local funcLook = funcLookup[net.ReadUInt(8)] - if not funcLook then return end - - decideFunction(index, funcLook) - end - - for I=1, #createList do - loadSound(createList[I]) - end - createList = {} - -end) \ No newline at end of file diff --git a/lua/entities/gmod_wire_expression2/core/sound.lua b/lua/entities/gmod_wire_expression2/core/sound.lua index 2329b3f411..10135044cb 100644 --- a/lua/entities/gmod_wire_expression2/core/sound.lua +++ b/lua/entities/gmod_wire_expression2/core/sound.lua @@ -7,168 +7,20 @@ E2Lib.RegisterExtension("sound", true, "Allows E2s to play sounds.", "Sounds can local wire_expression2_maxsounds = CreateConVar( "wire_expression2_maxsounds", 16, {FCVAR_ARCHIVE} ) local wire_expression2_sound_burst_max = CreateConVar( "wire_expression2_sound_burst_max", 8, {FCVAR_ARCHIVE} ) local wire_expression2_sound_burst_rate = CreateConVar( "wire_expression2_sound_burst_rate", 0.1, {FCVAR_ARCHIVE} ) -local wire_expression2_sound_allowurl = CreateConVar( "wire_expression2_sound_allowurl", 1, {FCVAR_ARCHIVE} ) - -util.AddNetworkString("e2_soundrequest") - ---------------------------------------------------------------- --- Client-side sound class ---------------------------------------------------------------- - -local ClientSideSound = {} -ClientSideSound.mt = {__index = ClientSideSound} - -ClientSideSound.SendRequests = {} - -ClientSideSound.SendFuncs = { - Create = function(self, time, ent, ply) - net.WriteString(self.path) - net.WriteDouble(time) - net.WriteEntity(ent) - net.WriteEntity(ply) - end, - Pause = function(self) - end, - Resume = function(self) - end, - Stop = function(self, time) - net.WriteDouble(time) - end, - StopNoTime = function(self) - end, - ChangeVolume = function(self, vol, time) - net.WriteDouble(vol) - net.WriteDouble(time) - end, - ChangePitch = function(self, pitch, time) - net.WriteDouble(pitch) - net.WriteDouble(time) - end, - ChangeFadeDistance = function(self, min, max) - net.WriteDouble(min) - net.WriteDouble(max) - end, - SetLooping = function(self, val) - net.WriteUInt(val, 8) - end, - SetTime = function(self, val) - net.WriteUInt(val, 32) - end -} - -ClientSideSound.SendFuncsLookup = { - Create = 1, - Pause = 2, - Resume = 3, - Stop = 4, - StopNoTime = 5, - ChangeVolume = 6, - ChangePitch = 7, - ChangeFadeDistance = 8, - SetLooping = 9, - SetTime = 10, -} - -function ClientSideSound.CreateSound( path, time, index, entity, e2, pitch, volume) - - local self = setmetatable({},ClientSideSound.mt) - self.index = e2:EntIndex() .. "_" .. index - self.path = path - self.entity = entity - self:SendRequest("Create",time,entity,e2:GetPlayer()) - if pitch then - self:SendRequest("ChangePitch", pitch, 0) - end - if volume then - self:SendRequest("ChangeVolume", volume, 0) - end - - return self -end - -function ClientSideSound:SendRequest(request, ...) - local len = #ClientSideSound.SendRequests - if len>=100 then return end - ClientSideSound.SendRequests[len + 1] = {Func = request, Arg = {self, ...}} -end - -function ClientSideSound.Broadcast() - - local numReq = #ClientSideSound.SendRequests - if numReq > 0 then - net.Start("e2_soundrequest") - net.WriteUInt(numReq, 32) - for I=1, numReq do - local Request = ClientSideSound.SendRequests[I] - net.WriteString(Request.Arg[1].index) - net.WriteUInt(ClientSideSound.SendFuncsLookup[Request.Func],8) - ClientSideSound.SendFuncs[Request.Func](unpack(Request.Arg)) - end - net.Broadcast() - ClientSideSound.SendRequests = {} - end - -end - -function ClientSideSound:Pause() - self:SendRequest("Pause") -end - -function ClientSideSound:Resume() - self:SendRequest("Resume") -end - -function ClientSideSound:Stop(time) - if time == 0 then - self:SendRequest("StopNoTime") - else - self:SendRequest("Stop",time) - end -end - -function ClientSideSound:ChangeVolume(vol, time) - self:SendRequest("ChangeVolume", vol, time) -end - -function ClientSideSound:ChangePitch(pitch, time) - self:SendRequest("ChangePitch",pitch,time) -end - -function ClientSideSound:ChangeFadeDistance(min, max) - self:SendRequest("ChangeFadeDistance",min,max) -end - -function ClientSideSound:SetLooping(val) - self:SendRequest("SetLooping",val) -end - -function ClientSideSound:SetTime(val) - self:SendRequest("SetTime",val) -end --------------------------------------------------------------- -- Helper functions --------------------------------------------------------------- local function isAllowed( self ) - local data = self.data.sound_data - if data.count >= wire_expression2_maxsounds:GetInt() then - --See if there are any dead sounds - for _, sound in pairs(data.sounds) do - if (sound.DieTime and CurTime() >= sound.DieTime) or not IsValid(sound.entity) then - data.sounds[ _ ] = nil - data.count = data.count - 1 - end - end - if data.count >= wire_expression2_maxsounds:GetInt() then - return false - end - end - + local count = data.count + if count == wire_expression2_maxsounds:GetInt() then return false end + if data.burst == 0 then return false end + data.burst = data.burst - 1 - + local timerid = "E2_sound_burst_count_" .. self.entity:EntIndex() if not timer.Exists( timerid ) then timer.Create( timerid, wire_expression2_sound_burst_rate:GetFloat(), 0, function() @@ -176,21 +28,15 @@ local function isAllowed( self ) timer.Remove( timerid ) return end - + data.burst = data.burst + 1 if data.burst == wire_expression2_sound_burst_max:GetInt() then timer.Remove( timerid ) end end) end - - return true -end -local function clearSound( data, sound ) - sound:Stop( 0 ) - data.sounds[sound.index] = nil - data.count = data.count - 1 + return true end local function getSound( self, index ) @@ -198,49 +44,76 @@ local function getSound( self, index ) return self.data.sound_data.sounds[index] end -local function soundCreate(self, entity, index, time, path, pitch, volume) +local function soundStop(self, index, fade) + local sound = getSound( self, index ) + if not sound then return end - if isnumber( index ) then index = math.floor( index ) end - local data = self.data.sound_data - local oldsound = getSound( self, index ) - if oldsound then - clearSound( data, oldsound ) - end - - if not isAllowed( self ) then return end - - if path:sub(1,4)=="http" || path:sub(1,3) == "www" then - if wire_expression2_sound_allowurl:GetInt()==0 then return end + fade = math.abs( fade ) + + if fade == 0 then + sound:Stop() + + if isnumber( index ) then index = math.floor( index ) end + self.data.sound_data.sounds[index] = nil + + self.data.sound_data.count = self.data.sound_data.count - 1 else - if path:match('["?]') then return end - path = path:Trim() - path = path:gsub( "\\", "/" ) + sound:FadeOut( fade ) + + timer.Simple( fade, function() soundStop( self, index, 0 ) end) end - - if isnumber( index ) then index = math.floor( index ) end + + timer.Remove( "E2_sound_stop_" .. self.entity:EntIndex() .. "_" .. index ) +end + +local function soundCreate(self, entity, index, time, path, fade) + if path:match('["?]') then return end local data = self.data.sound_data - - local oldsound = getSound( self, index ) + if not isAllowed( self ) then return end + + path = path:Trim() + path = path:gsub( "\\", "/" ) + if isnumber( index ) then index = math.floor( index ) end - if oldsound then - oldsound:Stop(0) // The sound is overwriten, we don't need to increase the count since we are using the same "sound spot" + local timerid = "E2_sound_stop_" .. self.entity:EntIndex() .. "_" .. index + + local sound = getSound( self, index ) + if sound then + sound:Stop() + timer.Remove( timerid ) else data.count = data.count + 1 end - - local sound = ClientSideSound.CreateSound(path,time,index,entity,self.entity,pitch,volume) + + local sound = CreateSound( entity, path ) data.sounds[index] = sound - + sound:Play() + + entity:CallOnRemove( "E2_stopsound", function() + soundStop( self, index, 0 ) + end ) + + if time == 0 and fade == 0 then return end + time = math.abs( time ) + + timer.Create( timerid, time, 1, function() + if not self or not IsValid( self.entity ) or not IsValid( entity ) then return end + + soundStop( self, index, fade ) + end) end local function soundPurge( self ) - local sound_data = self.data.sound_data if sound_data.sounds then for k,v in pairs( sound_data.sounds ) do - clearSound( sound_data, v ) + v:Stop() + timer.Remove( "E2_sound_stop_" .. self.entity:EntIndex() .. "_" .. k ) end end + + sound_data.sounds = {} + sound_data.count = 0 end --------------------------------------------------------------- @@ -250,27 +123,28 @@ end __e2setcost(25) e2function void soundPlay( index, duration, string path ) - soundCreate(self,self.entity,index,duration,path) + soundCreate(self,self.entity,index,duration,path,0) end e2function void entity:soundPlay( index, duration, string path) if not IsValid(this) or not isOwner(self, this) then return end - soundCreate(self,this,index,duration,path) + soundCreate(self,this,index,duration,path,0) end -e2function void soundPlay( index, duration, string path, pitch, volume ) - soundCreate(self,self.entity,index,duration,path,pitch,volume) +e2function void soundPlay( index, duration, string path, fade ) + soundCreate(self,self.entity,index,duration,path,fade) end -e2function void entity:soundPlay( index, duration, string path, pitch, volume ) +e2function void entity:soundPlay( index, duration, string path, fade ) if not IsValid(this) or not isOwner(self, this) then return end - soundCreate(self,this,index,duration,path,pitch,volume) + soundCreate(self,this,index,duration,path,fade) end e2function void soundPlay( string index, duration, string path ) = e2function void soundPlay( index, duration, string path ) e2function void entity:soundPlay( string index, duration, string path ) = e2function void entity:soundPlay( index, duration, string path ) e2function void soundPlay( string index, duration, string path, fade ) = e2function void soundPlay( index, duration, string path, fade ) -e2function void entity:soundPlay( string index, duration, string path, pitch, volume ) = e2function void entity:soundPlay( index, duration, string path, pitch, volume ) +e2function void entity:soundPlay( string index, duration, string path, fade ) = e2function void entity:soundPlay( index, duration, string path, fade ) + --------------------------------------------------------------- -- Modifier functions --------------------------------------------------------------- @@ -278,96 +152,50 @@ e2function void entity:soundPlay( string index, duration, string path, pitch, vo __e2setcost(5) e2function void soundStop( index ) - local sound = getSound( self, index ) - if not sound then return end - - clearSound( self.data.sound_data, sound ) + soundStop(self, index, 0) end e2function void soundStop( index, fadetime ) - local sound = getSound( self, index ) - if not sound then return end - - fadetime = math.abs( fadetime ) - sound.DieTime = CurTime() + fadetime // Fade seems to take a little longer to remove the sound - sound:Stop(fadetime) -end - -e2function void soundPause( index ) - local sound = getSound( self, index ) - if not sound then return end - - sound:Pause() -end - -e2function void soundResume( index ) - local sound = getSound( self, index ) - if not sound then return end - - sound:Resume() + soundStop(self, index, fadetime) end e2function void soundVolume( index, volume ) local sound = getSound( self, index ) if not sound then return end - + sound:ChangeVolume( math.Clamp( volume, 0, 1 ), 0 ) end e2function void soundVolume( index, volume, fadetime ) local sound = getSound( self, index ) if not sound then return end - + sound:ChangeVolume( math.Clamp( volume, 0, 1 ), math.abs( fadetime ) ) end - + + e2function void soundPitch( index, pitch ) local sound = getSound( self, index ) if not sound then return end - - sound:ChangePitch( pitch, 0 ) -end -e2function void soundPitch( index, pitch, fadetime ) - local sound = getSound( self, index ) - if not sound then return end - sound:ChangePitch( pitch, math.abs( fadetime ) ) + sound:ChangePitch( math.Clamp( pitch, 0, 255 ), 0 ) end -e2function void soundFadeDistance( index, min, max ) +e2function void soundPitch( index, pitch, fadetime ) local sound = getSound( self, index ) if not sound then return end - - sound:ChangeFadeDistance( math.Clamp(min,50,1000), math.Clamp(max,10000,200000) ) -end -e2function void soundLoop( index, val ) - local sound = getSound( self, index ) - if not sound then return end - - sound:SetLooping( val ) + sound:ChangePitch( math.Clamp( pitch, 0, 255 ), math.abs( fadetime ) ) end -e2function void soundTime( index, val ) - local sound = getSound( self, index ) - if not sound then return end - - sound:SetTime( val ) -end e2function void soundStop( string index ) = e2function void soundStop( index ) e2function void soundStop( string index, fadetime ) = e2function void soundStop( index, fadetime ) -e2function void soundPause( string index ) = e2function void soundPause( index ) -e2function void soundResume( string index ) = e2function void soundResume( index ) e2function void soundVolume( string index, volume ) = e2function void soundVolume( index, volume ) e2function void soundVolume( string index, volume, fadetime ) = e2function void soundVolume( index, volume, fadetime ) - e2function void soundPitch( string index, pitch ) = e2function void soundPitch( index, pitch ) e2function void soundPitch( string index, pitch, fadetime ) = e2function void soundPitch( index, pitch, fadetime ) -e2function void soundFadeDistance( string index, min, max ) = e2function void soundFadeDistance( index, min, max ) -e2function void soundLoop( string index, bool ) = e2function void soundLoop( index, bool ) -e2function void soundTime( string index, val ) = e2function void soundTime( index, val ) --------------------------------------------------------------- -- Other --------------------------------------------------------------- @@ -391,9 +219,4 @@ end) registerCallback("destruct", function(self) soundPurge( self ) - ClientSideSound.Broadcast() end) - -registerCallback("postexecute",function(self) - ClientSideSound.Broadcast() -end) \ No newline at end of file From 5dab574bf8875867e14530a3f0e71d7dd5edb50c Mon Sep 17 00:00:00 2001 From: Carl Roberts <48777329+carlroberts99@users.noreply.github.com> Date: Sun, 28 Jun 2020 23:04:09 +0100 Subject: [PATCH 41/56] fix errors, change comments to lua style This fixes player eyetrace being nil, changes comments to lua style comments and removes an unneeded ErrorNoHalt --- lua/weapons/laserpointer/cl_init.lua | 100 +++++++++++++-------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/lua/weapons/laserpointer/cl_init.lua b/lua/weapons/laserpointer/cl_init.lua index a53018ce46..06545e3602 100644 --- a/lua/weapons/laserpointer/cl_init.lua +++ b/lua/weapons/laserpointer/cl_init.lua @@ -1,50 +1,50 @@ -include('shared.lua') -SWEP.PrintName = "Laser Pointer" -SWEP.Slot = 0 -SWEP.SlotPos = 4 -SWEP.DrawAmmo = false -SWEP.DrawCrosshair = true - -local LASER = Material('cable/redlaser') - -function SWEP:Setup(ply) - if ply.GetViewModel and ply:GetViewModel():IsValid() then - local attachmentIndex = ply:GetViewModel():LookupAttachment("muzzle") - if attachmentIndex == 0 then attachmentIndex = ply:GetViewModel():LookupAttachment("1") end - if LocalPlayer():GetAttachment(attachmentIndex) then - self.VM = ply:GetViewModel() - self.Attach = attachmentIndex - end - end - if ply:IsValid() then - local attachmentIndex = ply:LookupAttachment("anim_attachment_RH") - if ply:GetAttachment(attachmentIndex) then - self.WM = ply - self.WAttach = attachmentIndex - end - end -end -function SWEP:Initialize() - self:Setup(self:GetOwner()) -end -function SWEP:Deploy(ply) - self:Setup(self:GetOwner()) -end - -function SWEP:ViewModelDrawn() - if self.Weapon:GetNWBool("Active") and self.VM then - //Draw the laser beam. - render.SetMaterial( LASER ) - render.DrawBeam(self.VM:GetAttachment(self.Attach).Pos, self:GetOwner():GetEyeTrace().HitPos, 2, 0, 12.5, Color(255, 0, 0, 255)) - end -end -function SWEP:DrawWorldModel() - self.Weapon:DrawModel() - if self.Weapon:GetNWBool("Active") and self.WM then - //Draw the laser beam. - render.SetMaterial( LASER ) - local posang = self.WM:GetAttachment(self.WAttach) - if not posang then self.WM = nil ErrorNoHalt("Laserpointer CL: Attachment lost, did they change model or something?\n") return end - render.DrawBeam(posang.Pos + posang.Ang:Forward()*10 + posang.Ang:Up()*4.4 + posang.Ang:Right(), self:GetOwner():GetEyeTrace().HitPos, 2, 0, 12.5, Color(255, 0, 0, 255)) - end -end +include('shared.lua') +SWEP.PrintName = "Laser Pointer" +SWEP.Slot = 0 +SWEP.SlotPos = 4 +SWEP.DrawAmmo = false +SWEP.DrawCrosshair = true + +local LASER = Material('cable/redlaser') + +function SWEP:Setup(ply) + if ply.GetViewModel and ply:GetViewModel():IsValid() then + local attachmentIndex = ply:GetViewModel():LookupAttachment("muzzle") + if attachmentIndex == 0 then attachmentIndex = ply:GetViewModel():LookupAttachment("1") end + if LocalPlayer():GetAttachment(attachmentIndex) then + self.VM = ply:GetViewModel() + self.Attach = attachmentIndex + end + end + if ply:IsValid() then + local attachmentIndex = ply:LookupAttachment("anim_attachment_RH") + if ply:GetAttachment(attachmentIndex) then + self.WM = ply + self.WAttach = attachmentIndex + end + end +end +function SWEP:Initialize() + self:Setup(self:GetOwner()) +end +function SWEP:Deploy(ply) + self:Setup(self:GetOwner()) +end + +function SWEP:ViewModelDrawn() + if self.Weapon:GetNWBool("Active") and self.VM then + -- Draw the laser beam. + render.SetMaterial( LASER ) + render.DrawBeam(self.VM:GetAttachment(self.Attach).Pos, self:GetOwner():GetEyeTrace().HitPos, 2, 0, 12.5, Color(255, 0, 0, 255)) + end +end +function SWEP:DrawWorldModel() + self.Weapon:DrawModel() + if self.Weapon:GetNWBool("Active") and self.WM and IsValid(self:GetOwner()) then + -- Draw the laser beam. + render.SetMaterial( LASER ) + local posang = self.WM:GetAttachment(self.WAttach) + if not posang then self.WM = nil return end + render.DrawBeam(posang.Pos + posang.Ang:Forward()*10 + posang.Ang:Up()*4.4 + posang.Ang:Right(), self:GetOwner():GetEyeTrace().HitPos, 2, 0, 12.5, Color(255, 0, 0, 255)) + end +end From c54960816c5a6279296ff468378db7022ef45a70 Mon Sep 17 00:00:00 2001 From: Zeni Date: Sat, 26 Jun 2021 22:28:34 +0200 Subject: [PATCH 42/56] Blacklist classes mining rock mining ore mining xen crystal --- lua/entities/gmod_wire_expression2/core/find.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/entities/gmod_wire_expression2/core/find.lua b/lua/entities/gmod_wire_expression2/core/find.lua index 97ad170639..2b98d264e9 100644 --- a/lua/entities/gmod_wire_expression2/core/find.lua +++ b/lua/entities/gmod_wire_expression2/core/find.lua @@ -60,6 +60,9 @@ local forbidden_classes = { ["predicted_viewmodel"] = true, ["gmod_ghost"] = true, ["coin"] = true, + ["mining_rock"] = true, + ["mining_ore"] = true, + ["mining_xen_crystal"] = true, } local function filter_default(self) local chip = self.entity From 70f991b986f8a2fa26542369c8dfeac2ac1bad0a Mon Sep 17 00:00:00 2001 From: Henke Date: Tue, 5 Apr 2022 16:45:12 +0200 Subject: [PATCH 43/56] fix dis --- lua/entities/gmod_wire_expression2/init.lua | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lua/entities/gmod_wire_expression2/init.lua b/lua/entities/gmod_wire_expression2/init.lua index 55af2909b2..4ab300e5d8 100644 --- a/lua/entities/gmod_wire_expression2/init.lua +++ b/lua/entities/gmod_wire_expression2/init.lua @@ -584,18 +584,16 @@ hook.Add("EntityRemoved", "Wire_Expression2_Player_Disconnected", function(ent) end) hook.Add("PlayerAuthed", "Wire_Expression2_Player_Authed", function(ply, sid, uid) - local c for _, ent in ipairs(ents.FindByClass("gmod_wire_expression2")) do if (ent.uid == uid) then ent.context.player = ply ent.player = ply ent:SetNWEntity("player", ply) if (ent.disconnectPaused) then - c = ent.disconnectPaused - ent:SetColor(Color(c[1], c[2], c[3], c[4])) + ent:SetColor(ent.disconnectPaused) ent:SetRenderMode(ent:GetColor().a == 255 and RENDERMODE_NORMAL or RENDERMODE_TRANSALPHA) ent.error = false - ent.disconnectPaused = false + ent.disconnectPaused = nil ent:SetOverlayText(ent.name) end end From 1914c61d49ffabf9686188cab12408ee60047085 Mon Sep 17 00:00:00 2001 From: d Date: Fri, 15 Apr 2022 13:05:25 +0200 Subject: [PATCH 44/56] Fixed syntax error --- lua/entities/gmod_wire_expression2/init.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lua/entities/gmod_wire_expression2/init.lua b/lua/entities/gmod_wire_expression2/init.lua index 8abc8e6497..4cb589b60b 100644 --- a/lua/entities/gmod_wire_expression2/init.lua +++ b/lua/entities/gmod_wire_expression2/init.lua @@ -591,14 +591,13 @@ hook.Add("PlayerAuthed", "Wire_Expression2_Player_Authed", function(ply, sid, ui ent.context.player = ply ent.player = ply ent:SetNWEntity("player", ply) - ent:SetColor(Color(c[1], c[2], c[3], c[4])) + ent:SetColor(ent.disconnectPaused) ent:SetRenderMode(ent:GetColor().a == 255 and RENDERMODE_NORMAL or RENDERMODE_TRANSALPHA) ent.error = false ent.disconnectPaused = nil ent:SetOverlayText(ent.name) end end - end for _, ent in ipairs(ents.FindByClass("gmod_wire_hologram")) do if ent.steamid == sid then ent:SetPlayer(ply) From 6d306ef6d41faabf711ddb59cf7f6697356b49af Mon Sep 17 00:00:00 2001 From: Python1320 Date: Mon, 25 Apr 2022 21:26:33 +0300 Subject: [PATCH 45/56] Add checkregex --- lua/entities/gmod_wire_textreceiver.lua | 36 ++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/lua/entities/gmod_wire_textreceiver.lua b/lua/entities/gmod_wire_textreceiver.lua index ee3f38210c..afa1623b31 100644 --- a/lua/entities/gmod_wire_textreceiver.lua +++ b/lua/entities/gmod_wire_textreceiver.lua @@ -15,6 +15,26 @@ local function RemoveReceiver( ent ) receivers[ent] = nil end + +local function checkregex(data, pattern) + local limits = {[0] = 50000000, 15000, 500, 150, 70, 40} -- Worst case is about 200ms + -- strip escaped things + local stripped, nrepl = string.gsub(pattern, "%%.", "") + -- strip bracketed things + stripped, nrepl2 = string.gsub(stripped, "%[.-%]", "") + -- strip captures + stripped = string.gsub(stripped, "[()]", "") + -- Find extenders + local n = 0 for i in string.gmatch(stripped, "[%+%-%*]") do n = n + 1 end + local msg + if n<=#limits then + if #data*(#stripped + nrepl - n + nrepl2)>limits[n] then msg = n.." ext search length too long ("..limits[n].." max)" else return end + else + msg = "too many extenders" + end + error("Regex is too complex! " .. msg) +end + hook.Add( "PlayerSay", "Wire Text receiver PlayerSay", function( ply, txt ) for ent,_ in pairs( receivers ) do if not ent or not ent:IsValid() then @@ -33,7 +53,7 @@ function ENT:Initialize() RegisterReceiver( self ) self.Outputs = WireLib.CreateOutputs( self, { "Message [STRING]", "Player [ENTITY]", "Clk (Will output 1 for a single tick after both 'Message' and 'Player' have been updated.)" } ) - + self.UseLuaPatterns = false self.CaseInsensitive = true self.Matches = {} @@ -79,6 +99,14 @@ local string_lower = string.lower local string_match = string.match function ENT:PcallFind( text, match ) + if self.UseLuaPatterns then + local ok,err = pcall(function() checkregex(text, match) end) + if not ok then + self.PatternError = err + return false + end + end + local ok, ret = pcall( string_find, text, match, 1, not self.UseLuaPatterns ) if ok == true then @@ -93,6 +121,12 @@ function ENT:AddError( err, idx ) end function ENT:PcallMatch( text, match, idx ) + local ok,err = pcall(function() checkregex(text, match) end) + if not ok then + self:AddError( err, idx ) + return {} + end + local ret = { pcall( string_match, text, match ) } if ret[1] == true then From d987502aa9587b42eab99695880f3e56b15ef881 Mon Sep 17 00:00:00 2001 From: Python1320 Date: Thu, 13 Oct 2022 21:37:54 +0300 Subject: [PATCH 46/56] Add applyTorqueCenter --- lua/entities/gmod_wire_expression2/core/entity.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lua/entities/gmod_wire_expression2/core/entity.lua b/lua/entities/gmod_wire_expression2/core/entity.lua index 5763b5685c..b315122144 100644 --- a/lua/entities/gmod_wire_expression2/core/entity.lua +++ b/lua/entities/gmod_wire_expression2/core/entity.lua @@ -588,6 +588,16 @@ e2function void entity:applyOffsetForce(vector force, vector position) phys:ApplyForceOffset(force, position) end +e2function void entity:applyTorqueCenter(vector angularImpulse) + if not validPhysics(this) then return self:throw("Invalid physics object!", nil) end + if not isOwner(self, this) then return self:throw("You do not own this entity!", nil) end + + angularImpulse = clamp(angularImpulse) + + local phys = this:GetPhysicsObject() + phys:ApplyTorqueCenter(angularImpulse) +end + e2function void entity:applyAngForce(angle angForce) if not validPhysics(this) then return self:throw("Invalid physics object!", nil) end if not isOwner(self, this) then return self:throw("You do not own this entity!", nil) end From 2f621e50f3a4eb6e4fef3fb33d310394408cbecf Mon Sep 17 00:00:00 2001 From: Python1320 Date: Thu, 13 Oct 2022 21:50:07 +0300 Subject: [PATCH 47/56] How to check merges with will-it-at-least-compile easily --- lua/entities/gmod_wire_expression2/init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/entities/gmod_wire_expression2/init.lua b/lua/entities/gmod_wire_expression2/init.lua index ea893d1306..03af357760 100644 --- a/lua/entities/gmod_wire_expression2/init.lua +++ b/lua/entities/gmod_wire_expression2/init.lua @@ -603,6 +603,7 @@ hook.Add("PlayerAuthed", "Wire_Expression2_Player_Authed", function(ply, sid, ui ent:SetOverlayText(ent.name) end end + end for _, ent in ipairs(ents.FindByClass("gmod_wire_hologram")) do if ent.steamid == sid then ent:SetPlayer(ply) From 6357bed90cdc69ff0a6dbd33ff034637388d543e Mon Sep 17 00:00:00 2001 From: Niccep <43934118+0x098@users.noreply.github.com> Date: Mon, 20 Mar 2023 22:02:39 +0200 Subject: [PATCH 48/56] introduce CanTool hook to PropCore.ValidAction (#14) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * introduce CanTool hook to PropCore.ValidAction this might fix like several exploits or cause several hundred more errors :) * fix 💀 (and format a little) --- .../core/custom/prop.lua | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/lua/entities/gmod_wire_expression2/core/custom/prop.lua b/lua/entities/gmod_wire_expression2/core/custom/prop.lua index 205c259406..5a73e3c443 100644 --- a/lua/entities/gmod_wire_expression2/core/custom/prop.lua +++ b/lua/entities/gmod_wire_expression2/core/custom/prop.lua @@ -15,15 +15,15 @@ local TimeStamp = 0 local playerMeta = FindMetaTable("Player") local function TempReset() - if (CurTime()>= TimeStamp) then - E2tempSpawnedProps = 0 - TimeStamp = CurTime()+1 - end + if CurTime() >= TimeStamp then + E2tempSpawnedProps = 0 + TimeStamp = CurTime() + 1 + end end hook.Add("Think","TempReset",TempReset) function PropCore.WithinPropcoreLimits() - return (sbox_E2_maxProps:GetInt() <= 0 or E2totalspawnedprops Date: Wed, 29 Mar 2023 00:16:29 +0300 Subject: [PATCH 49/56] Fix ent->entity --- lua/entities/gmod_wire_expression2/core/custom/prop.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/entities/gmod_wire_expression2/core/custom/prop.lua b/lua/entities/gmod_wire_expression2/core/custom/prop.lua index 5a73e3c443..ba577423e0 100644 --- a/lua/entities/gmod_wire_expression2/core/custom/prop.lua +++ b/lua/entities/gmod_wire_expression2/core/custom/prop.lua @@ -55,7 +55,7 @@ function PropCore.ValidAction(self, entity, cmd) if not IsValid(entity) then return self:throw("Invalid entity!", false) end if not canHaveInvalidPhysics[cmd] and not validPhysics(entity) then return self:throw("Invalid physics object!", false) end if not isOwner(self, entity) then return self:throw("You do not own this entity!", false) end - if not hook.Run("CanTool", self.player, WireLib.dummytrace(ent)) then return self:throw("You can not toolgun this entity!", false) end + if not hook.Run("CanTool", self.player, WireLib.dummytrace(entity)) then return self:throw("You can not toolgun this entity!", false) end if entity:IsPlayer() then return self:throw("You cannot modify players", false) end -- make sure we can only perform the same action on this prop once per tick From 837720f4c17536643474504e43ab73ba4cc9a3fe Mon Sep 17 00:00:00 2001 From: Niccep <43934118+0x098@users.noreply.github.com> Date: Fri, 9 Jun 2023 20:48:31 +0300 Subject: [PATCH 50/56] Empy fixed it, worry no more! --- lua/wire/stools/expression2.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lua/wire/stools/expression2.lua b/lua/wire/stools/expression2.lua index 125eb2fbd0..01dfdebc6e 100644 --- a/lua/wire/stools/expression2.lua +++ b/lua/wire/stools/expression2.lua @@ -341,6 +341,13 @@ if SERVER then return end + local ent_owner = toent:CPPIGetOwner() + + if not prop_owner.AreFriends(ply, ent_owner) or prop_owner.HasPlySet(ent_owner , "hate_everyone") then + WireLib.AddNotify(ply, "Insufficient user permissions to access this chip.", NOTIFY_ERROR, 7, NOTIFYSOUND_DRIP3) + return + end + if not wantedfiles[ply] then wantedfiles[ply] = {} end table.insert(wantedfiles[ply], net.ReadData(net.ReadUInt(32))) if numpackets <= #wantedfiles[ply] then From 5a573507010e8e8652307970bd4e3e0cf6423cc6 Mon Sep 17 00:00:00 2001 From: Python1320 Date: Sun, 25 Jun 2023 22:39:06 +0300 Subject: [PATCH 51/56] Add "toolname" --- lua/entities/gmod_wire_expression2/core/custom/prop.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/entities/gmod_wire_expression2/core/custom/prop.lua b/lua/entities/gmod_wire_expression2/core/custom/prop.lua index 1767ef4816..795ed21d89 100644 --- a/lua/entities/gmod_wire_expression2/core/custom/prop.lua +++ b/lua/entities/gmod_wire_expression2/core/custom/prop.lua @@ -64,7 +64,7 @@ function PropCore.ValidAction(self, entity, cmd, bone) if cmd == "spawn" or cmd == "Tdelete" then return true end if not IsValid(entity) then return self:throw("Invalid entity!", false) end if not isOwner(self, entity) then return self:throw("You do not own this entity!", false) end - if not hook.Run("CanTool", self.player, WireLib.dummytrace(entity)) then return self:throw("You can not toolgun this entity!", false) end + if not hook.Run("CanTool", self.player, WireLib.dummytrace(entity),cmd and ("propcore:"..cmd) or "propcore") then return self:throw("You can not toolgun this entity!", false) end if entity:IsPlayer() then return self:throw("You cannot modify players", false) end -- For cases when we'd only want to check an entity From 143b13dd5b90861f19f7dda10127f0ba895392a2 Mon Sep 17 00:00:00 2001 From: Python1320 Date: Tue, 27 Jun 2023 22:25:48 +0300 Subject: [PATCH 52/56] remove dummytrace, obsoleted --- lua/entities/gmod_wire_expression2/core/custom/prop.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/entities/gmod_wire_expression2/core/custom/prop.lua b/lua/entities/gmod_wire_expression2/core/custom/prop.lua index 795ed21d89..2a866b6045 100644 --- a/lua/entities/gmod_wire_expression2/core/custom/prop.lua +++ b/lua/entities/gmod_wire_expression2/core/custom/prop.lua @@ -64,7 +64,7 @@ function PropCore.ValidAction(self, entity, cmd, bone) if cmd == "spawn" or cmd == "Tdelete" then return true end if not IsValid(entity) then return self:throw("Invalid entity!", false) end if not isOwner(self, entity) then return self:throw("You do not own this entity!", false) end - if not hook.Run("CanTool", self.player, WireLib.dummytrace(entity),cmd and ("propcore:"..cmd) or "propcore") then return self:throw("You can not toolgun this entity!", false) end + if not WireLib.CanTool(self.player, entity,cmd and ("propcore:"..cmd) or "propcore") then return self:throw("You can not toolgun this entity!", false) end if entity:IsPlayer() then return self:throw("You cannot modify players", false) end -- For cases when we'd only want to check an entity From 6e11239c69c6c6d9c03a02211a68614932ed41e0 Mon Sep 17 00:00:00 2001 From: Python1320 Date: Sun, 21 Jul 2024 14:57:22 +0300 Subject: [PATCH 53/56] Add extra permission checks --- .../gmod_wire_expression2/core/custom/prop.lua | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lua/entities/gmod_wire_expression2/core/custom/prop.lua b/lua/entities/gmod_wire_expression2/core/custom/prop.lua index 83476f5b75..b8f3a47ae5 100644 --- a/lua/entities/gmod_wire_expression2/core/custom/prop.lua +++ b/lua/entities/gmod_wire_expression2/core/custom/prop.lua @@ -883,7 +883,8 @@ e2function void bone:boneManipulate(vector pos, angle rot, isFrozen, gravity, co end e2function void bone:boneFreeze(isFrozen) - if not boneVerify(self, this) then return end + local ent, index = boneVerify(self, this) + if not ValidAction(self, ent, "freeze", index) then return end this:EnableMotion( isFrozen == 0 ) this:Wake() end @@ -891,24 +892,28 @@ end __e2setcost(30) e2function void bone:setCollisions(enable) - if not boneVerify(self, this) then return end + local ent, index = boneVerify(self, this) + if not ValidAction(self, ent, "collisions", index) then return end this:EnableCollisions(enable ~= 0) this:Wake() end e2function void bone:setDrag( number drag ) - if not boneVerify(self, this) then return end + local ent, index = boneVerify(self, this) + if not ValidAction(self, ent, "drag", index) then return end this:EnableDrag( drag ~= 0 ) end e2function void bone:setInertia( vector inertia ) - if not boneVerify(self, this) then return end + local ent, index = boneVerify(self, this) + if not ValidAction(self, ent, "inertia", index) then return end if inertia:IsZero() then return end this:SetInertia(inertia) end e2function void bone:setBuoyancy(number buoyancy) - if not boneVerify(self, this) then return end + local ent, index = boneVerify(self, this) + if not ValidAction(self, ent, "buoyancy", index) then return end this:SetBuoyancyRatio( math.Clamp(buoyancy, 0, 1) ) end From f8988763a47543e7526ca158fe3d08709290d83b Mon Sep 17 00:00:00 2001 From: Mats Date: Mon, 5 Aug 2024 19:23:35 +0200 Subject: [PATCH 54/56] Do not E2 access check owner of chip as friend --- lua/wire/stools/expression2.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/wire/stools/expression2.lua b/lua/wire/stools/expression2.lua index ae6d928466..73d3912db1 100644 --- a/lua/wire/stools/expression2.lua +++ b/lua/wire/stools/expression2.lua @@ -360,7 +360,7 @@ if SERVER then local ent_owner = toent:CPPIGetOwner() - if not prop_owner.AreFriends(ply, ent_owner) or prop_owner.HasPlySet(ent_owner , "hate_everyone") then + if ent_owner ~= ply and (not prop_owner.AreFriends(ply, ent_owner) or prop_owner.HasPlySet(ent_owner , "hate_everyone")) then WireLib.AddNotify(ply, "Insufficient user permissions to access this chip.", NOTIFY_ERROR, 7, NOTIFYSOUND_DRIP3) return end From 92ef13f5ddec10799394bcd3ce149508e3de80d3 Mon Sep 17 00:00:00 2001 From: Python1320 Date: Sun, 5 Jan 2025 21:50:20 +0200 Subject: [PATCH 55/56] Block localchat/teamchat --- lua/entities/gmod_wire_textreceiver.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/entities/gmod_wire_textreceiver.lua b/lua/entities/gmod_wire_textreceiver.lua index 6998ccc86d..6b7a924e24 100644 --- a/lua/entities/gmod_wire_textreceiver.lua +++ b/lua/entities/gmod_wire_textreceiver.lua @@ -15,11 +15,13 @@ local function RemoveReceiver( ent ) receivers[ent] = nil end -hook.Add( "PlayerSay", "Wire Text receiver PlayerSay", function( ply, txt ) +hook.Add( "PlayerSay", "Wire Text receiver PlayerSay", function( ply, txt, teamchat, localchat ) + if teamchat == true then return end for ent,_ in pairs( receivers ) do if not ent or not ent:IsValid() then RemoveReceiver( ent ) else + if localchat == true and ply ~= (ent.CPPIGetOwner and ent:CPPIGetOwner()) then continue end ent:PlayerSpoke( ply, txt ) end end From b532ce4d37b5cac8eaf8a69427ec31e2bbbd92a4 Mon Sep 17 00:00:00 2001 From: Python1320 Date: Sat, 3 May 2025 02:26:26 +0300 Subject: [PATCH 56/56] PlayerUse needs a player --- lua/entities/gmod_wire_user.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/entities/gmod_wire_user.lua b/lua/entities/gmod_wire_user.lua index dd578125f0..d48ef581b4 100644 --- a/lua/entities/gmod_wire_user.lua +++ b/lua/entities/gmod_wire_user.lua @@ -37,7 +37,7 @@ function ENT:TriggerInput(iname, value) if ply:IsPlayer() and ply:InVehicle() and trace.Entity:IsVehicle() then return end -- don't use a vehicle if you're in one - if hook.Run( "PlayerUse", ply, trace.Entity ) == false then return false end + if ply:IsPlayer() and hook.Run( "PlayerUse", ply, trace.Entity ) == false then return false end if hook.Run( "WireUse", ply, trace.Entity, self ) == false then return false end if trace.Entity.Use then