diff --git a/addon.json b/addon.json index dc706894f9..d50f9dd2ff 100644 --- a/addon.json +++ b/addon.json @@ -15,7 +15,7 @@ "git-hooks-pre-commit", "gitrid.sh", "LICENSE", - "wiremod.*" + "wiremod.*", "benchmark_*" ] } diff --git a/lua/entities/gmod_wire_customprop/shared.lua b/lua/entities/gmod_wire_customprop/shared.lua index 97a62c2be5..22264dff67 100644 --- a/lua/entities/gmod_wire_customprop/shared.lua +++ b/lua/entities/gmod_wire_customprop/shared.lua @@ -58,8 +58,8 @@ return { classname = "gmod_wire_customprop", readReliableEntity = function(callback) - index = net.ReadUInt(16) - creationIndex = net.ReadUInt(32) + local index = net.ReadUInt(16) + local creationIndex = net.ReadUInt(32) local startTime = CurTime() local function check() diff --git a/lua/entities/gmod_wire_expression2/core/cl_files.lua b/lua/entities/gmod_wire_expression2/core/cl_files.lua index 0cf2a1126e..714c137fac 100644 --- a/lua/entities/gmod_wire_expression2/core/cl_files.lua +++ b/lua/entities/gmod_wire_expression2/core/cl_files.lua @@ -98,8 +98,9 @@ net.Receive( "wire_expression2_request_list", function() end end for _,fop in pairs(folders) do - net.WriteUInt(#fop, 16) - net.WriteData(fop .. "/") + local folder = fop .. "/" + net.WriteUInt(#folder, 16) + net.WriteData(folder) end net.SendToServer() end) diff --git a/lua/entities/gmod_wire_expression2/core/files.lua b/lua/entities/gmod_wire_expression2/core/files.lua index 9349e21b8f..a23d804ab5 100644 --- a/lua/entities/gmod_wire_expression2/core/files.lua +++ b/lua/entities/gmod_wire_expression2/core/files.lua @@ -241,7 +241,7 @@ end [deprecated = "Use the file events instead", nodiscard] e2function array fileReadList() - local plist = lists[self.player] + local plist = lists[self.player].last return (plist.uploaded and not plist.uploading and plist.data) and plist.data or {} end @@ -410,7 +410,10 @@ end util.AddNetworkString("wire_expression2_file_upload") net.Receive("wire_expression2_file_upload", function(_, ply) - local pfile = uploads[ply][1] + local queue = uploads[ply] + if not queue then return end + + local pfile = queue[1] if pfile then if net.ReadBool() and not pfile.uploading and not pfile.uploaded then local len = net.ReadUInt(32) @@ -438,6 +441,8 @@ end) util.AddNetworkString("wire_expression2_file_list") net.Receive("wire_expression2_file_list", function(_, ply) local queue = lists[ply] + if not queue then return end + local plist = queue[1] if not plist then return end @@ -489,4 +494,4 @@ E2Lib.registerEvent("fileWritten", { E2Lib.registerEvent("fileList", { { "Path", "s"}, { "Contents", "r" } -}) \ No newline at end of file +}) diff --git a/lua/entities/gmod_wire_expression2/core/signal.lua b/lua/entities/gmod_wire_expression2/core/signal.lua index 3a337a18e3..29c732d381 100644 --- a/lua/entities/gmod_wire_expression2/core/signal.lua +++ b/lua/entities/gmod_wire_expression2/core/signal.lua @@ -91,9 +91,6 @@ local function broadcastSignal(group, name, scope, sender, filter_player) end end ---local function table_IsEmpty(t) return not pairs(t)(t) end -local function table_IsEmpty(t) return not next(t) end - local function setGroup(self, group) -- set the current group to the new group self.data.signalgroup = group @@ -241,8 +238,8 @@ __e2setcost(20) --- sends signal S to chips owned by the given player, multiple calls for different players do not overwrite each other e2function void signalSendToPlayer(string name, entity player) - if not IsValid(player) then return end - broadcastSignal(self.data.signalgroup, name, 1, self.entity, player) + if not IsValid(player) or not player:IsPlayer() then return end + broadcastSignal(self.data.signalgroup, name, 1, self.entity, player:UniqueID()) end --[[************************************************************************]]-- @@ -253,6 +250,8 @@ registerCallback("construct",function(self) end) registerCallback("destruct",function(self) + local receiverid = self.entity:EntIndex() + -- loop through all scopes, ... for scope,groups in pairs_ac(scopes) do -- ... all groups ... @@ -260,7 +259,7 @@ registerCallback("destruct",function(self) -- ... and all signals ... for name, contexts in pairs_ac(signals) do -- to remove all signals the chip registered for. - contexts[self] = nil + contexts[receiverid] = nil end end end diff --git a/lua/entities/gmod_wire_fpga/shared.lua b/lua/entities/gmod_wire_fpga/shared.lua index e382b58f4a..5d9163ac48 100644 --- a/lua/entities/gmod_wire_fpga/shared.lua +++ b/lua/entities/gmod_wire_fpga/shared.lua @@ -100,8 +100,10 @@ if SERVER then net.Receive("wire_fpga_options", function(len, ply) local ok, options = pcall(WireLib.von.deserialize, net.ReadString()) - if ok then - FPGAPlayerOptions[ply] = options + if ok and istable(options) then + FPGAPlayerOptions[ply] = { + allow_inside_view = options.allow_inside_view == true + } end end) end @@ -142,4 +144,4 @@ if SERVER then end end end) -end \ No newline at end of file +end diff --git a/lua/weapons/gmod_tool/stools/wire_adv.lua b/lua/weapons/gmod_tool/stools/wire_adv.lua index 1272cc31f7..4d019c9451 100644 --- a/lua/weapons/gmod_tool/stools/wire_adv.lua +++ b/lua/weapons/gmod_tool/stools/wire_adv.lua @@ -187,6 +187,8 @@ if SERVER then end local function wireAdvUnwire(ply, ent, tbl) + if not IsValid(ent) then return end + if WireLib.CanTool(ply, ent, "wire_adv") then for i=1,#tbl do WireLib.Link_Clear( ent, tbl[i] ) @@ -195,6 +197,8 @@ if SERVER then end local function wireAdvRemoveUGLinks(ply, ent) + if not IsValid(ent) then return end + if WireLib.CanTool(ply, ent, "wire_adv") then if ent:IsValid() then removeEntityOutput(ent) diff --git a/lua/wire/client/cl_wirelib.lua b/lua/wire/client/cl_wirelib.lua index a8d6911841..9321f116de 100644 --- a/lua/wire/client/cl_wirelib.lua +++ b/lua/wire/client/cl_wirelib.lua @@ -74,7 +74,7 @@ local function Wire_Render_Enabled(ent) -- CREATING (Not assigning a value) local variables OUTSIDE of cycle a bit faster local blink = ent_tbl.WireBlinkWire - local start, color, nodes, len, endpos, node, node_ent, last_node_ent, vector_cache + local start, color, nodes, len, width, endpos, node, node_ent, last_node_ent, vector_cache for net_name, wiretbl in pairs(wires) do width = wiretbl.Width diff --git a/lua/wire/fpga_gates/execution.lua b/lua/wire/fpga_gates/execution.lua index a2b95c7da3..6169f88ab3 100644 --- a/lua/wire/fpga_gates/execution.lua +++ b/lua/wire/fpga_gates/execution.lua @@ -229,7 +229,7 @@ FPGAGateActions["execution-previous-normal"] = { gate.memory = 0 end, postExecution = function(gate) - local changed = gate.value != gate.memory + local changed = gate.value ~= gate.memory gate.value = gate.memory return changed end, @@ -254,7 +254,7 @@ FPGAGateActions["execution-previous-vector"] = { gate.memory = Vector(0, 0, 0) end, postExecution = function(gate) - local changed = gate.value != gate.memory + local changed = gate.value ~= gate.memory gate.value = gate.memory return changed end, @@ -279,7 +279,7 @@ FPGAGateActions["execution-previous-angle"] = { gate.memory = Angle(0, 0, 0) end, postExecution = function(gate) - local changed = gate.value != gate.memory + local changed = gate.value ~= gate.memory gate.value = gate.memory return changed end, @@ -304,8 +304,8 @@ FPGAGateActions["execution-previous-string"] = { gate.memory = "" end, postExecution = function(gate) - local changed = gate.value != gate.memory + local changed = gate.value ~= gate.memory gate.value = gate.memory return changed end, -} \ No newline at end of file +} diff --git a/lua/wire/server/sents_registry.lua b/lua/wire/server/sents_registry.lua index 8ffc2cfdf4..4514b69ad4 100644 --- a/lua/wire/server/sents_registry.lua +++ b/lua/wire/server/sents_registry.lua @@ -1137,8 +1137,8 @@ register("gmod_wire_value", { VECTOR2 = function(val, e2TypeID) if e2TypeID == TYPE_TABLE and #val >= 2 and isnumber(val[1]) and isnumber(val[2]) then return val[1]..", "..val[2] end if e2TypeID == TYPE_STRING then - local x,y,z = string.match( val, "^ *([^%s,]+) *, *([^%s,]+) *$" ) - if x and y and z then return x..", "..y..", "..z end + local x,y = string.match( val, "^ *([^%s,]+) *, *([^%s,]+) *$" ) + if x and y then return x..", "..y end end return nil @@ -1201,7 +1201,7 @@ register("gmod_wire_value", { elseif e2TypeID == TYPE_VECTOR then val = {"VECTOR", castE2TypeToWireValueType["VECTOR"](val, e2TypeID)} elseif e2TypeID == TYPE_ANGLE then val = {"ANGLE", castE2TypeToWireValueType["ANGLE"](val, e2TypeID)} elseif e2TypeID == TYPE_STRING then val = {"STRING", castE2TypeToWireValueType["STRING"](val, e2TypeID)} - else return "Incorrect 'value' parameter #"..i.." type! Expected table (Ex. table(\"normal\", 0)). Got: "..type( steamid ) end + else return "Incorrect 'value' parameter #"..i.." type! Expected table (Ex. table(\"normal\", 0)). Got: "..type( val ) end elseif not isnumber(val[1]) then -- Plain table if TypeID(val[1]) ~= TYPE_STRING then return "Incorrect 'value' parameter #"..i.."[1] type! Expected string ('NORMAL/VECTOR/VECTOR2/VECTOR4/ANGLE/STRING'). Got: "..type( val ) end @@ -1214,15 +1214,15 @@ register("gmod_wire_value", { end val = {wireValueType, CastFunc(val[2], TypeID(val[2]))} elseif #val == 2 then -- vector2 - local tempVal = castE2TypeToWireValueType["VECTOR2"](val[2], typeID(val[2])) + local tempVal = castE2TypeToWireValueType["VECTOR2"](val, TypeID(val)) if not tempVal then return "Incorrect 'value' parameter #"..i.." value! Expected 'VECTOR2'. Got: "..tostring(val[2]) end val = {"VECTOR2", tempVal} elseif #val==4 then -- vector4 - local tempVal = castE2TypeToWireValueType["VECTOR4"](val[2], typeID(val[2])) - if not tempVal then return "Incorrect 'value' parameter #"..i.." value! Expected 'VECTOR2'. Got: "..tostring(val[2]) end + local tempVal = castE2TypeToWireValueType["VECTOR4"](val, TypeID(val)) + if not tempVal then return "Incorrect 'value' parameter #"..i.." value! Expected 'VECTOR4'. Got: "..tostring(val[2]) end val = {"VECTOR4", tempVal} else diff --git a/lua/wire/server/wirelib.lua b/lua/wire/server/wirelib.lua index 739c8939a3..b14e285e3a 100644 --- a/lua/wire/server/wirelib.lua +++ b/lua/wire/server/wirelib.lua @@ -1180,7 +1180,10 @@ function WireLib.CanModel(ply, model, skin) end function WireLib.MakeWireEnt( pl, Data, ... ) - Data.Class = scripted_ents.Get(Data.Class).ClassName + local sent = scripted_ents.Get(Data.Class) + if not sent or not sent.ClassName then return false end + + Data.Class = sent.ClassName 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 diff --git a/lua/wire/stools/cd_disk.lua b/lua/wire/stools/cd_disk.lua index 9e0b713a2d..d4e7c26626 100644 --- a/lua/wire/stools/cd_disk.lua +++ b/lua/wire/stools/cd_disk.lua @@ -36,8 +36,8 @@ function TOOL:RightClick(trace) if (trace.Entity and trace.Entity:IsValid()) then if (trace.Entity:GetClass() == "prop_physics") then - self:GetOwner():ConCommand('wire_cd_disk_model "'..trace.Entity:GetModel()..'"\n') - self:GetOwner():ConCommand('wire_cd_disk_skin "'..trace.Entity:GetSkin()..'"\n') + self:GetOwner():ConCommand("wire_cd_disk_model \""..trace.Entity:GetModel().."\"\n") + self:GetOwner():ConCommand("wire_cd_disk_skin \""..trace.Entity:GetSkin().."\"\n") end end @@ -45,7 +45,7 @@ function TOOL:RightClick(trace) end function TOOL.BuildCPanel(panel) - WireDermaExts.ModelSelect(panel, "wire_cd_disk_Model", list.Get( "Wire_Laser_Disk_Models" ), 1) + WireDermaExts.ModelSelect(panel, "wire_cd_disk_model", list.Get( "Wire_Laser_Disk_Models" ), 1) panel:NumSlider("Disk density (inches per block, ipb)","wire_cd_disk_precision",1,16,0) panel:NumSlider("Inner radius (disk hole radius)","wire_cd_disk_iradius",1,48,0) panel:NumSlider("Disk skin (0..8, standard disks only)","wire_cd_disk_skin",0,8,0) diff --git a/lua/wire/stools/cd_ray.lua b/lua/wire/stools/cd_ray.lua index d884be16dc..c19b49bc45 100644 --- a/lua/wire/stools/cd_ray.lua +++ b/lua/wire/stools/cd_ray.lua @@ -15,8 +15,8 @@ end WireToolSetup.BaseLang() if (SERVER) then - CreateConVar('sbox_maxwire_cd_rays', 20) - CreateConVar('sbox_maxwire_cd_locks', 20) + CreateConVar("sbox_maxwire_cd_rays", 20) + CreateConVar("sbox_maxwire_cd_locks", 20) end TOOL.ClientConVar[ "model" ] = "models/jaanus/wiretool/wiretool_beamcaster.mdl" @@ -49,13 +49,12 @@ function TOOL:RightClick(trace) local Ang = trace.HitNormal:Angle() Ang.pitch = Ang.pitch + 90 - local range = self:GetClientNumber("Range") - local defZero = (self:GetClientNumber("DefaultZero") ~= 0) local model = self:GetClientInfo("lockmodel") if not util.IsValidModel( model ) or not util.IsValidProp( model ) then return end local wire_cd_lock = WireLib.MakeWireEnt(ply, {Class = "gmod_wire_cd_lock", Pos=trace.HitPos, Angle=Ang, Model=model}) + if not IsValid(wire_cd_lock) then return false end local min = wire_cd_lock:OBBMins() wire_cd_lock:SetPos( trace.HitPos - trace.HitNormal * min.z ) @@ -75,6 +74,6 @@ function TOOL:RightClick(trace) end function TOOL.BuildCPanel(panel) - WireDermaExts.ModelSelect(panel, "wire_cd_ray_Model", list.Get( "Wire_Laser_Tools_Models" ), 1) + WireDermaExts.ModelSelect(panel, "wire_cd_ray_model", list.Get( "Wire_Laser_Tools_Models" ), 1) panel:NumSlider("Range","wire_cd_ray_Range",1,512,2) end diff --git a/lua/wire/stools/colorer.lua b/lua/wire/stools/colorer.lua index beb1a3202f..0bd7383730 100644 --- a/lua/wire/stools/colorer.lua +++ b/lua/wire/stools/colorer.lua @@ -21,7 +21,7 @@ if SERVER then end end -TOOL.ClientConVar[ "Model" ] = "models/jaanus/wiretool/wiretool_siren.mdl" +TOOL.ClientConVar[ "model" ] = "models/jaanus/wiretool/wiretool_siren.mdl" TOOL.ClientConVar[ "outColor" ] = "0" TOOL.ClientConVar[ "range" ] = "2000" @@ -29,5 +29,5 @@ function TOOL.BuildCPanel(panel) WireToolHelpers.MakePresetControl(panel, "wire_colorer") WireDermaExts.ModelSelect(panel, "wire_colorer_model", list.Get( "Wire_Laser_Tools_Models" ), 1, true) panel:CheckBox("#WireColorerTool_outColor", "wire_colorer_outColor") - panel:NumSlider("#WireColorerTool_Range", "wire_colorer_Range", 1, 10000, 2) + panel:NumSlider("#WireColorerTool_Range", "wire_colorer_range", 1, 10000, 2) end diff --git a/lua/wire/stools/cpu.lua b/lua/wire/stools/cpu.lua index 58fe294e4b..785b71f5c1 100644 --- a/lua/wire/stools/cpu.lua +++ b/lua/wire/stools/cpu.lua @@ -73,16 +73,17 @@ if SERVER then function TOOL:CheckHitOwnClass(trace) return trace.Entity:IsValid() and (trace.Entity:GetClass() == self.WireClass or trace.Entity.WriteCell) end - function TOOL:LeftClick_Update(trace) - CPULib.SetUploadTarget(trace.Entity, self:GetOwner()) - net.Start("ZCPU_RequestCode") net.Send(self:GetOwner()) + function TOOL:LeftClick_Update(trace, ent) + local player = self:GetOwner() + CPULib.SetUploadTarget(ent or trace.Entity, player) + net.Start("ZCPU_RequestCode") net.Send(player) net.Start("CPULib.InvalidateDebugger") net.WriteUInt(0,2) net.Send(player) end function TOOL:MakeEnt(ply, model, Ang, trace) local ent = WireLib.MakeWireEnt(ply, {Class = self.WireClass, Pos=trace.HitPos, Angle=Ang, Model=model}) ent:SetMemoryModel(self:GetClientInfo("memorymodel"),self:GetClientInfo("customram"),self:GetClientInfo("customrom")) ent:SetExtensionLoadOrder(self:GetClientInfo("extensions")) - self:LeftClick_Update(trace) + self:LeftClick_Update(trace, ent) return ent end @@ -142,7 +143,6 @@ if CLIENT then ---------------------------------------------------------------------------- - local currentDirectory local FileBrowser = vgui.Create("wire_expression2_browser" , panel) panel:AddPanel(FileBrowser) FileBrowser:Setup("cpuchip") @@ -180,7 +180,7 @@ if CLIENT then ---------------------------------------------------------------------------- - local modelPanel = WireDermaExts.ModelSelect(panel, "wire_cpu_model", list.Get("Wire_gate_Models"), 2) + WireDermaExts.ModelSelect(panel, "wire_cpu_model", list.Get("Wire_gate_Models"), 2) panel:AddControl("Label", {Text = ""}) @@ -389,12 +389,12 @@ if CLIENT then outc(string.format(" RAM %5d KB",collectgarbage("count") or 0),1,Color(255,255,255,255)) surface.SetDrawColor(240, 120, 0, 255) - surface.DrawRect(16*(5),32*2+14,256,4) + surface.DrawRect(16*5,32*2+14,256,4) outc("TASK",2,Color(240, 120,0,255)) outc(" STATUS",3,Color(255,255,255,255)) surface.SetDrawColor(240, 120, 0, 255) - surface.DrawRect(16*(4),32*6+14,256,4) + surface.DrawRect(16*4,32*6+14,256,4) outc("NET",6,Color(240, 120,0,255)) if CPULib.Uploading then outc(string.format("UP %.3f KB",CPULib.RemainingUploadData/1024),7,Color(255,255,255,255)) @@ -485,8 +485,6 @@ if CLIENT then outform(1,1,7,5,"HL-ZASM") outc(string.format(" Stage %d/7",HCOMP.Stage+1),3,Color(0,0,0,255)) outc(" "..stageNameShort[HCOMP.Stage+1],4,Color(0,0,0,255)) - else - -- end end end diff --git a/lua/wire/stools/emarker.lua b/lua/wire/stools/emarker.lua index 9bd044eb6f..c00e91d207 100644 --- a/lua/wire/stools/emarker.lua +++ b/lua/wire/stools/emarker.lua @@ -18,5 +18,5 @@ TOOL.ClientConVar = { WireToolSetup.SetupLinking(true) function TOOL.BuildCPanel(panel) - WireDermaExts.ModelSelect(panel, "wire_emaker_model", list.Get("Wire_Misc_Tools_Models"), nil, true) + WireDermaExts.ModelSelect(panel, "wire_emarker_model", list.Get("Wire_Misc_Tools_Models"), nil, true) end diff --git a/lua/wire/stools/gpu.lua b/lua/wire/stools/gpu.lua index 323febbc53..c428a2d264 100644 --- a/lua/wire/stools/gpu.lua +++ b/lua/wire/stools/gpu.lua @@ -41,7 +41,6 @@ if SERVER then function TOOL:Reload(trace) if trace.Entity:IsPlayer() then return false end - local player = self:GetOwner() if (trace.Entity:IsValid()) and (trace.Entity:GetClass() == "gmod_wire_gpu") then trace.Entity:SetMemoryModel(self:GetClientInfo("memorymodel")) @@ -53,15 +52,16 @@ if SERVER then function TOOL:CheckHitOwnClass(trace) return trace.Entity:IsValid() and (trace.Entity:GetClass() == self.WireClass or trace.Entity.WriteCell) end - function TOOL:LeftClick_Update(trace) - CPULib.SetUploadTarget(trace.Entity, self:GetOwner()) - net.Start("ZGPU_RequestCode") net.Send(self:GetOwner()) + function TOOL:LeftClick_Update(trace, ent) + local player = self:GetOwner() + CPULib.SetUploadTarget(ent or trace.Entity, player) + net.Start("ZGPU_RequestCode") net.Send(player) end function TOOL:MakeEnt(ply, model, Ang, trace) local ent = WireLib.MakeWireEnt(ply, {Class = self.WireClass, Pos=trace.HitPos, Angle=Ang, Model=model}) ent:SetMemoryModel(self:GetClientInfo("memorymodel")) ent:SetExtensionLoadOrder(self:GetClientInfo("extensions")) - self:LeftClick_Update(trace) + self:LeftClick_Update(trace, ent) return ent end @@ -121,7 +121,6 @@ if CLIENT then ---------------------------------------------------------------------------- - local currentDirectory local FileBrowser = vgui.Create("wire_expression2_browser" , panel) panel:AddPanel(FileBrowser) FileBrowser:Setup("GPUChip") diff --git a/lua/wire/stools/igniter.lua b/lua/wire/stools/igniter.lua index 4b103da701..8704765432 100644 --- a/lua/wire/stools/igniter.lua +++ b/lua/wire/stools/igniter.lua @@ -14,11 +14,11 @@ WireToolSetup.BaseLang() WireToolSetup.SetupMax( 20 ) if SERVER then - CreateConVar('sbox_wire_igniters_maxlen', 30) - CreateConVar('sbox_wire_igniters_allowtrgply',1) + CreateConVar("sbox_wire_igniters_maxlen", 30) + CreateConVar("sbox_wire_igniters_allowtrgply",1) function TOOL:GetConVars() - return self:GetClientNumber( "trgply" )~=0, self:GetClientNumber("range") + return self:GetClientNumber("trgply") ~= 0, self:GetClientNumber("range") end end @@ -30,7 +30,7 @@ TOOL.ClientConVar = { function TOOL.BuildCPanel(panel) WireToolHelpers.MakePresetControl(panel, "wire_igniter") - WireDermaExts.ModelSelect(panel, "wire_igniter_Model", list.Get( "Wire_Laser_Tools_Models" ), 1, true) + WireDermaExts.ModelSelect(panel, "wire_igniter_model", list.Get( "Wire_Laser_Tools_Models" ), 1, true) panel:CheckBox("#WireIgniterTool_trgply", "wire_igniter_trgply") panel:NumSlider("#WireIgniterTool_Range", "wire_igniter_range", 1, 10000, 0) end diff --git a/lua/wire/stools/speedometer.lua b/lua/wire/stools/speedometer.lua index 3448b46918..517f6ff510 100644 --- a/lua/wire/stools/speedometer.lua +++ b/lua/wire/stools/speedometer.lua @@ -27,5 +27,5 @@ TOOL.ClientConVar = { function TOOL.BuildCPanel(panel) panel:CheckBox("#Tool_wire_speedometer_xyz_mode", "wire_speedometer_xyz_mode") - panel:CheckBox("#Tool_wire_speedometer_angvel", "wire_speedometer_AngVel") + panel:CheckBox("#Tool_wire_speedometer_angvel", "wire_speedometer_angvel") end diff --git a/lua/wire/stools/spu.lua b/lua/wire/stools/spu.lua index 29e4fad619..21edecb9b9 100644 --- a/lua/wire/stools/spu.lua +++ b/lua/wire/stools/spu.lua @@ -40,7 +40,6 @@ if SERVER then function TOOL:Reload(trace) if trace.Entity:IsPlayer() then return false end - local player = self:GetOwner() if (trace.Entity:IsValid()) and (trace.Entity:GetClass() == "gmod_wire_spu") then trace.Entity:SetMemoryModel(self:GetClientInfo("memorymodel")) @@ -52,15 +51,16 @@ if SERVER then function TOOL:CheckHitOwnClass(trace) return trace.Entity:IsValid() and (trace.Entity:GetClass() == self.WireClass or trace.Entity.WriteCell) end - function TOOL:LeftClick_Update(trace) - CPULib.SetUploadTarget(trace.Entity, self:GetOwner()) - net.Start("ZSPU_RequestCode") net.Send(self:GetOwner()) + function TOOL:LeftClick_Update(trace, ent) + local player = self:GetOwner() + CPULib.SetUploadTarget(ent or trace.Entity, player) + net.Start("ZSPU_RequestCode") net.Send(player) end function TOOL:MakeEnt(ply, model, Ang, trace) local ent = WireLib.MakeWireEnt(ply, {Class = self.WireClass, Pos=trace.HitPos, Angle=Ang, Model=model}) ent:SetMemoryModel(self:GetClientInfo("memorymodel")) ent:SetExtensionLoadOrder(self:GetClientInfo("extensions")) - self:LeftClick_Update(trace) + self:LeftClick_Update(trace, ent) return ent end @@ -126,7 +126,6 @@ if CLIENT then ---------------------------------------------------------------------------- - local currentDirectory local FileBrowser = vgui.Create("wire_expression2_browser" , panel) panel:AddPanel(FileBrowser) FileBrowser:Setup("spuchip") diff --git a/lua/wire/tool_loader.lua b/lua/wire/tool_loader.lua index bdaad92868..656676c46f 100644 --- a/lua/wire/tool_loader.lua +++ b/lua/wire/tool_loader.lua @@ -293,7 +293,7 @@ if CLIENT then else for size=60,20,-2 do surface.SetFont("GmodToolScreen"..size) - local x,y = surface.GetTextSize(text) + local x = surface.GetTextSize(text) if x <= (width - 16) then self.ScreenFont = "GmodToolScreen"..size break @@ -681,6 +681,7 @@ function WireToolSetup.SetupLinking(SingleLink, linkedname) end return true elseif self:GetStage() == 1 then -- stage 1: reloading on something else unlinks it + if not IsValid(self.Controller) then self:SetStage(0) return false end local ply = self:GetOwner() local success, message = self.Controller:UnlinkEnt(ent) if success then diff --git a/lua/wire/wirenet.lua b/lua/wire/wirenet.lua index e4fe6a1672..138fdb91dc 100644 --- a/lua/wire/wirenet.lua +++ b/lua/wire/wirenet.lua @@ -49,10 +49,14 @@ if SERVER then local data = table.concat(tbl) if #data < 4096 then - data = util.Compress(data) + local compressed = util.Compress(data) net.WriteBool(false) - net.WriteUInt(#data, 12) - net.WriteData(data) + if compressed then + net.WriteUInt(#compressed, 12) + net.WriteData(compressed) + else + net.WriteUInt(0, 12) + end else net.WriteBool(true) net.WriteStream(data, nil, false) @@ -207,4 +211,4 @@ function Net.Trivial.Receive(name, callback) update_handlers(name:lower(), callback) end -Net.Receivers = registered_handlers \ No newline at end of file +Net.Receivers = registered_handlers